Graphics Reference
In-Depth Information
constraints on, the application source code system (e.g., source code organization,
file names, variable names).
Control Variables
There are two situations where the back-end event-driven program must define a
control variable to represent a front-end GUI element.
Polling/setting of GUI element state information. A control variable
should be defined for GUI elements with state information that must be
polled/set during run time. For example, a checkbox's state information is
altered every time a user clicks it. When servicing a checkbox's click event,
the service routine must poll the GUI element (through the control variable)
for its state. Notice that in this case, the data type of the checkbox control
variable should be of bool . To support polling and setting operations, the
data type of the corresponding control variable should reflect the state in-
formation and not the GUI element type. For example, a slider bar's state
information is the position of the knob, or a float . Thus, control variables
for polling and setting a slider-bar GUI element should be a variable with
float data type and not CSliderBar .
Customization of GUI element behavior. A control variable should be
defined for GUI elements when an application demands customized behav-
iors. For example, an application may demand that the state of a checkbox
be associated with the color of the checkbox: green for checked and red
for unchecked. In this case, during event servicing, we must first poll the
GUI element state and then modify the color attributes of the checkbox.
This means that the application needs to have access to the CCheckBox data
type.
2.4
Examples: FLTK and MFC
2.4.1
FLTK—Fluid and External Service Linkage
Figure 2.1 shows a screenshot of working with Fluid, FLTK's GUI builder. In
the lower-right corner of Figure 2.1, we see that (A) Fluid allows an application
developer to interactively place graphical representations of GUI elements (3D-
looking icons). (B) is an area representing the application window. In addition
(C), the application developer can interactively select each GUI element to de-
fine its physical appearances (color, shape, size, etc.). In the lower-left corner of
Search WWH ::




Custom Search