Programs - User Interface


Aim

The reson for writing this unit was to make it easy to draw boxes and buttons on the screen. It’s supposed to look like windows and therefore be more user friendly.

Method

In the begining the programmer only wrote a unit to draw dialog boxes, but then as he sat back and watched his work, he decided that it needed to look even better. The programmer created buttons, but he felt this was still not enough so he created other controls like textboxes and labels.

Yes this is what it was like, version one drew boxes, a very simple procedure that took the four co-ordinates nessary to define a window and drew it. You could even ask it to draw single or double lines.

Later came buttons, added by Gary, they looked much better than plain menu options that you had to press keys for. The mouse unit was upgraded to support mouse interaction and two procedures were added to it. One to check the current mouse button state, and the other to decide if you just let go of the mouse button at the same place as you put it down. The buttons did not show whether they were pressed or not, i.e. the were non-animated.

Now the whole unit is getting very much like the Turbo Vision unit. With dynamic allocation for the dialog and it’s controls. Several different types now: button, textbox, label, checkbox and option buttons. This makes it much easier just to let the program to do the work not the programmer!

The interface exposes the following procedures / functions:

  • initwindow - sets-up the window structure initilizing all variables that need to be,
  • addctrl - adds a control to a window,
  • drawwindow - shows the window on the screen for the first time, shows all controls,
  • drawcontrols - redraws the controls on the window, used after updating settings,
  • downdevents - do window events, does all the stuff nessary to keep the window in operating order,
  • donewindow - and finally, kills the window, freeing all the memory associated with it.