hk_visible

Base class for visible widgets. It handles the geometry and the look of the widgets.

Inherits from hk_class.

Figure 2-7. 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)

see set_size()

set_height(height)

see set_size()

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

key()

returns a object of type hk_key. You can use this during the action_on_key() action. In combination with the hk_keys 'set_accept_key()' method you can handle whether or not this key will be accepted as input.

action_on_click(void)

triggers the on_click action

action_on_doubleclick(void)

triggers the on_doubleclick action

action_on_close(void)

triggers the on_close action

action_on_open(void)

triggers the on_open action

action_on_getfocus(void)

triggers the on_getfocus action

action_on_loosefocus(void)

triggers the on_loosefocus action

action_on_key(void)

triggers the on_key action

Figure 2-8. Look and Feel methods

set_font(fontname,size)

sets the font, e.g. set_font("Arial",12)

set_font(font)

sets the font of type hk_font, e.g.

Example 2-12. Setting a font

  myfont=hk_font("Arial",12)
  set_font(myfont)

hk_font font()

returns a font object of type hk_font

set_foregroundcolour(colour)

sets the foreground colour. 'colour' is of type hk_colour. The foreground colour will be used for fonts, frames etc

foregroundcolour()

returns the foreground colour, which is of type hk_colour.

set_backgroundcolour(colour)

sets the background colour. 'colour' is of type hk_colour. This colour will be used to fill the whole background.

hk_colour backgroundcolour()

returns the background colour, which is of type hk_colour.

Figure 2-9. Miscelleanous methods

set_label(labeltext)

Every visible object has a label which will be displayed when necessary, i.e. a button usually needs a label

label()

returns the label string.

type()

returns the type of this object. Possible values are:

  • textlabel

  • button

  • rowselector

  • boolean

  • lineedit

  • memo

  • combobox

  • grid

  • report

  • reportsection

  • reportdata

  • other

identifier()

the identifier is a unique name within a presentation (either a form or a report) with which this object can be identified and thus located

presentation()

returns the parent hk_presentation object (either a form or a report)

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.

Example 2-13. 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)