Sophie

Sophie

distrib > Mandriva > 10.2 > i586 > media > contrib > by-pkgid > 6338fb0a19fe7b6baeca7897c46a9ee3 > files > 83

knoda-0.7.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>Objects of type hk_presentation - forms and reports</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="The knoda scripting tutorial"
HREF="index.html"><LINK
REL="UP"
TITLE="Data sensitive methods"
HREF="chapter3.html"><LINK
REL="PREVIOUS"
TITLE="Objects of type hk_dsdatavisible - the class hk_column"
HREF="hk_dsdatavisible.html"><LINK
REL="NEXT"
TITLE="using hk_classes as a Python module"
HREF="chapter4.html"><META
HTTP-EQUIV="Content-Style-Type"
CONTENT="text/css"><LINK
REL="stylesheet"
HREF="common/kde-common.css"
TYPE="text/css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1"><META
HTTP-EQUIV="Content-Language"
CONTENT="en"><LINK
REL="stylesheet"
HREF="common/kde-localised.css"
TYPE="text/css"
TITLE="KDE-English"><LINK
REL="stylesheet"
HREF="common/kde-default.css"
TYPE="text/css"
TITLE="KDE-Default"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#AA0000"
VLINK="#AA0055"
ALINK="#AA0000"
STYLE="font-family: sans-serif;"
><DIV
CLASS="logoheader"
><A
HREF="http://www.kde.org/"
></A
></DIV
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The knoda scripting tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="hk_dsdatavisible.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. Data sensitive methods</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="chapter4.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="HK_PRESENTATION"
></A
>3.3. Objects of type hk_presentation - forms and reports</H1
><P
>Both forms and reports inherit from hk_presentation.  The most import function of hk_presentation is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>set_mode(mode)</I
></SPAN
>.
The two possible modes are <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>hk_presentation.designmode</I
></SPAN
> and <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>hk_presentation.viewmode</I
></SPAN
></P
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="HK_FORM"
></A
>3.3.1. Handling forms</H2
><P
>If you want to get a reference to a specific object in a form you have two possibilities
<UL
><LI
STYLE="list-style-type: disc"
><P
>hk_visible* get_visible(unique_number)</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_visible* get_visible(const hk_string&#38; identifier)</P
></LI
></UL
>
The first function needs the unique identifier number of the wanted object.  Each visible object of type hk_visible has a unique number as an identifier, which can't be changed.
<DIV
CLASS="IMPORTANT"
><TABLE
CLASS="IMPORTANT"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="common/important.png"
HSPACE="5"
ALT="Important"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>To find this number, click on the object.  In the caption of the property editor you can see the number in brackets.</P
></TD
></TR
></TABLE
></DIV
>
The second function uses a unique text identifier.  This is a user-defined unique identifier and can be set in the property editor.</P
><P
>Both functions return a reference of type hk_visible.  To change it to the type you need there are some type casting functions
<DIV
CLASS="FIGURE"
><HR><A
NAME="AEN307"
></A
><P
><B
>Figure 3-6. Type casting</B
></P
><A
NAME="AEN309"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><UL
><LI
STYLE="list-style-type: disc"
><P
>hk_button *cast_button(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_dslineedit *cast_dslineedit(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_dsmemo *cast_dsmemo(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_dsgrid *cast_dsgrid(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_dscombobox *cast_dscombobox(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_dsboolean *cast_dsboolean(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_dsvisible *cast_dsvisible(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_form *cast_form(hk_visible*);</P
></LI
><LI
STYLE="list-style-type: disc"
><P
>hk_report *cast_report(hk_visible*);</P
></LI
></UL
></BLOCKQUOTE
><HR></DIV
></P
><P
>The next program shows you how to start a form:
<DIV
CLASS="EXAMPLE"
><HR><A
NAME="AEN330"
></A
><P
><B
>Example 3-6. displaying  a form</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>   1&nbsp;myform=hk_this.datasource().database().new_formvisible()
   2&nbsp;myform.load_form("authorform")
   3&nbsp;myform.set_mode(myform.viewmode)</PRE
></TD
></TR
></TABLE
><HR></DIV
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="HK_REPORT"
></A
>3.3.2. Handling reports</H2
><P
>Here is how to start a report:
<DIV
CLASS="EXAMPLE"
><HR><A
NAME="AEN336"
></A
><P
><B
>Example 3-7. displaying  a report</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>   1&nbsp;myreport=hk_this.datasource().database().new_reportvisible()
   2&nbsp;myreport.load_report("complexreport")
   3&nbsp;myreport.set_mode(myreport.viewmode)
   4&nbsp;</PRE
></TD
></TR
></TABLE
><HR></DIV
></P
><P
>A visible object in a report is of type hk_reportdata, which inherits from hk_dsdatavisible.  The main methods are
<UL
><LI
><P
>set_data(const hk_string&#38; d)</P
></LI
><LI
><P
>hk_string data(void)</P
></LI
></UL
>

The data property contains the value that is displayed.  See the knodatutorial chapter "The report field" for details.</P
><P
>The following example shows how to print numbers in different colours.  For this we use the "onprint" action

<DIV
CLASS="EXAMPLE"
><HR><A
NAME="AEN346"
></A
><P
><B
>Example 3-8. reportdata onprint</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>   1&nbsp;value=hk_this.column().asdouble()
   2&nbsp;if value&#60;0:
   3&nbsp;   hk_this.set_foregroundcolour(hk_red)
   4&nbsp;else:
   5&nbsp;   if value==0:
   6&nbsp;       hk_this.set_foregroundcolour(hk_black)
   7&nbsp;   else:
   8&nbsp;      hk_this.set_foregroundcolour(hk_blue)</PRE
></TD
></TR
></TABLE
><HR></DIV
></P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="hk_dsdatavisible.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="chapter4.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Objects of type hk_dsdatavisible - the class hk_column</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chapter3.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>using hk_classes as a Python module</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>