# Controls

    #include <stdio.h>
    #include "graphapp.h"

    void draw_shapes(Control *c, Graphics *g)
    {
      Rect r = get_control_area(c);

      set_colour(g, RED);
      draw_rect(g, r);

      set_colour(g, BLUE);
      fill_rect(g, rect(10,40,80,10));
    }

    int main(int argc, char *argv[])
    {
      App *app;
      Window *w;
      Control *c;
      Rect r;

      app = new_app(argc, argv);
      w = new_window(app, rect(50,50,150,200),
                    "Rectangles", STANDARD_WINDOW);
      set_window_background(w, LIGHT_GREY);
      r = rect(10,10,100,100);
      c = new_control(w, r);
      on_control_redraw(c, draw_shapes);
      show_window(w);
      main_loop(app);
      return 0;
    }

Notes:

- Use `new_control` to create a control on a window's surface.
- Use `on_control_redraw` to associate a redraw call-back function to it.
- Whenever the control needs to be redrawn, that callback is used.
- Use `set_window_background` to change a window's background colour.
- Use `set_colour` to change the drawing colour.
- `get_control_area` returns the rectangle which outlines the control, it its own co-ordinate system.
- `draw_rect` draws a border inside a rectangle.
- `fill_rect` fills the given rectangle.