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
Figure 2-1. Geometry specific methods
- set_size(x, y,width,height)
lets you to set position and size of an object
- set_size(width,height)
lets you to set size of an object
- set_position(x,y)
lets you to set position of an object
- set_x(x)
lets you to set the horizontal position of an object
- set_y(y)
lets you to set the vertical position of an object
- set_width(width)
- set_height(height)
- x()
returns the x co-ordinate of the object
- y()
returns the y co-ordinate of the object
- width()
returns the width of the object
- height()
returns the height of the object
Figure 2-2. Look and Feel methods
- set_font(fontname,size)
sets the font, e.g. set_font("Arial",12)
- set_font(font)
- hk_font font()
returns a font object
- set_foregroundcolour(colour)
- foregroundcolour()
- set_backgroundcolour(colour)
- hk_colour backgroundcolour()
Figure 2-3. Miscelleanous methods
- set_label(labeltext)
- label()
- enum enum_visibletype {textlabel,button,rowselector,boolean,lineedit,memo,combobox,grid,form,report,reportsection,reportdata,other}
- enum_visibletype type(void)
- identifier()
- hk_presentation* presentation()
returns the parent presentation object (either a form or a report)
Example 2-1. Changing colour and position
redcolour =hk_colour(255,0,0) greencolour =hk_colour(0,255,0) if hk_this.foregroundcolour().red()!=255: hk_this.set_foregroundcolour(redcolour) hk_this.set_backgroundcolour(greencolour) hk_this.set_label("green button") else: hk_this.set_foregroundcolour(greencolour) hk_this.set_backgroundcolour(redcolour) hk_this.set_label("red button") hk_this.set_position(hk_this.x()+50,hk_this.y()+10)