<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >General object methods- the class hk_visible</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="PREVIOUS" TITLE="The various actions" HREF="chapter1.html"><LINK REL="NEXT" TITLE="Data sensitive methods" HREF="chapter3.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="CHAPTER" 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="chapter1.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="chapter3.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="CHAPTER" ><H1 ><A NAME="CHAPTER2" ></A >Chapter 2. General object methods- the class hk_visible</H1 ><P >Each visible object of hk_classes is inherited from a class called hk_visible, so we will now have a look on the general available methods <DIV CLASS="FIGURE" ><HR><A NAME="AEN52" ></A ><P ><B >Figure 2-1. Geometry specific methods</B ></P ><A NAME="AEN54" ></A ><BLOCKQUOTE CLASS="BLOCKQUOTE" ><UL ><LI STYLE="list-style-type: disc" ><P > set_size(x, y,width,height): lets you to set position and size of an object</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_size(width,height): lets you to set size of an object</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_position(x,y): lets you to set position of an object</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_x(x): lets you to set the horizontal position of an object</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_y(y): lets you to set the vertical position of an object</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_width(width)</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_height(height)</P ></LI ><LI STYLE="list-style-type: disc" ><P >x() returns the x co-ordinate of the object</P ></LI ><LI STYLE="list-style-type: disc" ><P >y() returns the y co-ordinate of the object</P ></LI ><LI STYLE="list-style-type: disc" ><P >width() returns the width of the object</P ></LI ><LI STYLE="list-style-type: disc" ><P >height() returns the height of the object</P ></LI ></UL ></BLOCKQUOTE ><HR></DIV > <DIV CLASS="FIGURE" ><HR><A NAME="AEN78" ></A ><P ><B >Figure 2-2. Look and Feel methods</B ></P ><A NAME="AEN80" ></A ><BLOCKQUOTE CLASS="BLOCKQUOTE" ><UL ><LI STYLE="list-style-type: disc" ><P >set_font(fontname,size), sets the font, e.g. set_font("Arial",12)</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_font(font)</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_font font(), returns a font object</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_foregroundcolour(colour)</P ></LI ><LI STYLE="list-style-type: disc" ><P >foregroundcolour()</P ></LI ><LI STYLE="list-style-type: disc" ><P >set_backgroundcolour(colour)</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_colour backgroundcolour()</P ></LI ></UL ></BLOCKQUOTE ><HR></DIV > <DIV CLASS="FIGURE" ><HR><A NAME="AEN96" ></A ><P ><B >Figure 2-3. Miscelleanous methods</B ></P ><A NAME="AEN98" ></A ><BLOCKQUOTE CLASS="BLOCKQUOTE" ><UL ><LI STYLE="list-style-type: disc" ><P >set_label(labeltext)</P ></LI ><LI STYLE="list-style-type: disc" ><P >label()</P ></LI ><LI STYLE="list-style-type: disc" ><P >enum enum_visibletype {textlabel,button,rowselector,boolean,lineedit,memo,combobox,grid,form,report,reportsection,reportdata,other}</P ></LI ><LI STYLE="list-style-type: disc" ><P >enum_visibletype type(void) </P ></LI ><LI STYLE="list-style-type: disc" ><P >identifier()</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_presentation* presentation(); returns the parent presentation object (either a form or a report)</P ></LI ></UL ></BLOCKQUOTE ><HR></DIV > The following example shows how to move the button within the form, how to change the colour and how to display different text on the button. <DIV CLASS="EXAMPLE" ><HR><A NAME="AEN112" ></A ><P ><B >Example 2-1. Changing colour and position</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" > 1 redcolour =hk_colour(255,0,0) 2 greencolour =hk_colour(0,255,0) 3 if hk_this.foregroundcolour().red()!=255: 4 hk_this.set_foregroundcolour(redcolour) 5 hk_this.set_backgroundcolour(greencolour) 6 hk_this.set_label("green button") 7 else: 8 hk_this.set_foregroundcolour(greencolour) 9 hk_this.set_backgroundcolour(redcolour) 10 hk_this.set_label("red button") 11 12 hk_this.set_position(hk_this.x()+50,hk_this.y()+10) 13 </PRE ></TD ></TR ></TABLE ><HR></DIV > </P ><P ><DIV CLASS="FIGURE" ><HR><A NAME="AEN116" ></A ><P ><B >Figure 2-4. Predefined colour names</B ></P ><A NAME="AEN118" ></A ><BLOCKQUOTE CLASS="BLOCKQUOTE" ><UL ><LI STYLE="list-style-type: disc" ><P >hk_aqua</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_beige</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_black</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_blue</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_brown</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_fuchsia</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_darkgrey</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_green</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_grey</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_lightgrey</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_lime</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_maroon</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_navy</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_olive</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_orange</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_pink</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_purple</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_red</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_silver</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_teal</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_white</P ></LI ><LI STYLE="list-style-type: disc" ><P >hk_yellow</P ></LI ></UL ></BLOCKQUOTE ><HR></DIV ></P ></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="chapter1.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="chapter3.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >The various actions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Data sensitive methods</TD ></TR ></TABLE ></DIV ></BODY ></HTML >