Setting Up the Program
The first step with getting the program running is to write the code that initializes the program, creates the form, creates the dialog window, and then waits for events. As it turns out, this does not require an excessive amount of program code.
main()
Function of the colorlab Programinclude "colorlab_form.sma" constant iSTARTCOLOR 0xffffff function main() wxform f wxdialog d integer e e = 0 f =@ colorlab(error=e) if f =@= .nul errormsg(e) else d =@ wxdialog.new(1, 1, innerwidth=f.width, \ innerheight=f.height, \ visible=.false, \ captiontext="SIMPOL Color Lab", \ error=e) if d =@= .nul errormsg(e) else adjustformcolorvals(f, iSTARTCOLOR) f.setcontainer(d) centerdialogonparent(d) d.processmodal(.inf) end if end if end function
The code above is fairly straightforward. It calls the generated colorlab()
function to create the form. If anything goes wrong, it calls the errormsg()
function if anything goes wrong. Assuming that the form was successfully created, it creates the
dialog window, sizing it based on the size of the form. Again it checks for success, and assuming
that worked, it calls a function to initialize the form for a specific color value (the starting
color). That color value is contained in a constant called iSTARTCOLOR
.
Finally, the form is selected into the dialog window, the dialog window is centered on the display
(since it has no parent), and it then is set to wait forever (or until the dialog is made
invisible, either by calling the setvisible()
method, or by the user
clicking the gadget.
The program as is will not yet compile without warnings nor will it run without errors. The source code of the form contains assignments of function names for handling events, but those functions have not yet been created.