Resizing and Moving Controls

OBJECTS

  typedef void (*drawfn)(control c, rect r);

FUNCTIONS

  void  setresize(control c, drawfn fn);

  void  resize(control c, rect r);

  rect  getrect(control c);
  int   getwidth(control c);
  int   getheight(control c);

NOTES

The setresize function specifies a call-back function which will be called whenever a control or window is resized. Normally controls can only be resized by the programmer, but windows can often be resized by the user of an application. This function allows an application to respond to such an event.

When a window or control is resized, the call-back is called, and is passed two parameters: the object which has just changed size, and the rectangle of the object in local co-ordinates.

A window or control can be moved and resized using the resize function. This will change the location and size of the control on its parent window, and redraw it to reflect its new size. It will also call the resize call-back, if any.

The rectangular area occupied by a control can be found using getrect. The rectangle returned by getrect will always have a top-left point of (0,0), since the co-ordinate system used within controls defines this to be the case. In other words, the returned rectangle is in local co-ordinates.

If you just need to know the width or height of a control, the getwidth and getheight functions will report those dimensions.