Bambookit Home    Bambookit GUI Tutorial

Back    Next   

II. GUI Basics

Chapter 10. Widgets Attributes




Size


Method signature

setSize = "[int width, int height]"
[width, height] sets the size of the widget control. Valid values are integers.

setShape = "[int x, int y, int width, int height]"
[x, y, width, height] sets the location and size in the widgets. Valid values are integers. 'x'and 'y' are specified in the relation to the parent it sits in.

NOTE: setSize is used for a Widget control only. For a button or any other GUI element inside the Widget use setShape.

setLocation = "[int x, int y]"
[x, y] sets the location in the widgets. Valid values are integers.

setWidth = "[int width]"
[width] sets the width in the widgets. Valid values are integers.

setHeight = "[int height]"
[height] sets the height in the widgets. Valid values are integers.

Four fields for the setShape property define both the geographical position and size of the widget. It would be easier to think about these settings as two groups of two fields. The first pair of fields specifies the horizontal (x) and vertical (y) pixel coordinates of the top left corner of the widget's rectangle. These measurement assumes the following:

  • Measurements are relative to the upper-left corner of the widget's container.
  • The top-left pixel of the container border is coordinate '0,0'.


  • The second pair of fields contains values for the width and height of the widget. Notice that these values are not the bottom-right x and y coordinates, but rather the dimensions of the rectangle. To calculate the bottom-right coordinates points, add the width to x for the bottom-right x value; add the height to the y for the bottom-right y value.

    Examples

    In this example we will be using a widget control

    .. setSize="300,100"



    In this example we will be using a button widget. Button with the coordinates 10,10, width 120, and height 50 is placed inside the widget above:

    .. setShape="10,10,120,50"



    We will be resetting location for the button inside the widget above. The location is moved to x = 30, y = 30.

    .. setShape="10,10,120,50" setLocation="30,30"



    We will be changing the width of the button from 120 to 200.

    .. setShape="10,10,120,50" setLocation="30,30" setWidth="200"



    We will be changing the height of the button from 50 to 60.

    .. setShape="10,10,120,50" setLocation="30,30" setWidth="200" setHeight="60"



    Back    Next