Chapter 2. General object methods- the class hk_visible

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)


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-1. Changing colour and position

   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 


Figure 2-4. Predefined colour names

  • hk_aqua

  • hk_beige

  • hk_black

  • hk_blue

  • hk_brown

  • hk_fuchsia

  • hk_darkgrey

  • hk_green

  • hk_grey

  • hk_lightgrey

  • hk_lime

  • hk_maroon

  • hk_navy

  • hk_olive

  • hk_orange

  • hk_pink

  • hk_purple

  • hk_red

  • hk_silver

  • hk_teal

  • hk_white

  • hk_yellow