JohnK wrote:That is interesting, as i have always wanted a rapidq like gui library, that would use fltk under the hood. I didn't start it because it would be a LOT of work. If you method is simple then great.
It's not a lot of work if you restrict yourself to replicating only those features that you use. Over the years, I've developed a very simple structure for my applications that keeps the number of widget types to a minimum. My applications consist of a single window that contains a menu panel down the left side, a status panel along the bottom, and a task panel that occupies the rest of the window.
The status panel contains a number of simple boxes for displaying messages.
The menu panel contains a Tree widget that activates items in the task panel.
The task panel contains a Wizard widget. Each page in the wizard widget represents a program which is linked to an entry in the menu tree. Each program page is also implemented as a Wizard widget, with its pages representing the program screens. These screens contain the actual buttons, boxes, etc.
As you can see, I use very few widget types -- and also a very small subset of Joshy's FLTK wrapper.
To isolate my application code from FLTK, and to avoid using ZStrings in my application code, I put all the FLTK calls that I use in a single namespace. Here's a sample:
Code: Select all
'
'-----------------------------------------------
' Procedure 54 : set the window caption text
BeginExternalSubroutine (subWindowCaption) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
, BVal (bvsCaption, typString) _ ' 15328 : caption text
ParmEnd
'
'
Fl_WindowCopyLabel (bvpWidgetRef, StrPtr(bvsCaption))
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 55 : create a window
BeginExternalFunction (funWindowCreate) _
BVal (bviBaseLeft, typInt32) _ ' 16413 : nominal left position of the gui object (pixels)
, BVal (bviBaseTop, typInt32) _ ' 16414 : nominal top position of the gui object (pixels)
, BVal (bviBaseWidth, typInt32) _ ' 16415 : nominal width of the gui object (pixels)
, BVal (bviBaseHeight, typInt32) _ ' 16416 : nominal height of the gui object (pixels)
ParmReturn (typPointer)
'
LocalPointer (pWidgetRef) ' 16882 : fltk widget reference
'
pWidgetRef = Fl_Double_WindowNew2 (bviBaseLeft, bviBaseTop, bviBaseWidth, bviBaseHeight)
prpAppWidgetRef = pWidgetRef ' save the reference to the main application window widget
Return pWidgetRef
'
EndExternalFunction
'
'-----------------------------------------------
' Procedure 56 : begin the window design
BeginExternalSubroutine (subWindowDesignBegin) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
ParmEnd
'
'
Fl_WindowBegin (bvpWidgetRef)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 57 : end the window design
BeginExternalSubroutine (subWindowDesignEnd) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
ParmEnd
'
'
Fl_WindowEnd (bvpWidgetRef)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 58 : destroy a window
BeginExternalSubroutine (subWindowDestroy) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
ParmEnd
'
'
Fl_Double_WindowDelete (bvpWidgetRef)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 59 : link the window to the window events router
BeginExternalSubroutine (subWindowEventsCommon) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
ParmEnd
'
'
Fl_WidgetSetCallback0 (bvpWidgetRef, ProcPtr(funWindowEventsRouter))
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 60 : kill the application window
BeginExternalSubroutine (subWindowKill) _
ParmEnd
'
'
Fl_WindowHide (prpAppWidgetRef)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 61 : resize and reposition a window
BeginExternalSubroutine (subWindowResize) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
, BVal (bviActualLeft, typInt32) _ ' 16417 : actual left position of the gui object (pixels)
, BVal (bviActualTop, typInt32) _ ' 16418 : actual top position of the gui object (pixels)
, BVal (bviActualWidth, typInt32) _ ' 16419 : actual width of the gui object (pixels)
, BVal (bviActualHeight, typInt32) _ ' 16420 : actual height of the gui object (pixels)
ParmEnd
'
'
Fl_WindowResize (bvpWidgetRef, bviActualLeft, bviActualTop, bviActualWidth, bviActualHeight)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 62 : get the window`s gadget reference
BeginExternalFunction (funWindowSelfGet) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
ParmReturn (typPointer)
'
LocalPointer (pSelf) ' 16898 : reference to the active gadget object
'
pSelf = Fl_WidgetGetUserData (bvpWidgetRef)
Return pSelf
'
EndExternalFunction
'
'-----------------------------------------------
' Procedure 63 : link the window to its gadget object
BeginExternalSubroutine (subWindowSelfSet) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
, BPtr (bvpSelf) _ ' 16898 : reference to the active gadget object
ParmEnd
'
'
Fl_WidgetSetUserData (bvpWidgetRef, bvpSelf)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 64 : show a window
BeginExternalSubroutine (subWindowShow) _
BPtr (bvpWidgetRef) _ ' 16882 : fltk widget reference
ParmEnd
'
'
Fl_WindowShow (bvpWidgetRef)
'
EndExternalSubroutine
'
'-----------------------------------------------
' Procedure 65 : create a wizard
BeginExternalFunction (funWizardCreate) _
BVal (bviBaseLeft, typInt32) _ ' 16413 : nominal left position of the gui object (pixels)
, BVal (bviBaseTop, typInt32) _ ' 16414 : nominal top position of the gui object (pixels)
, BVal (bviBaseWidth, typInt32) _ ' 16415 : nominal width of the gui object (pixels)
, BVal (bviBaseHeight, typInt32) _ ' 16416 : nominal height of the gui object (pixels)
ParmReturn (typPointer)
'
LocalPointer (pWidgetRef) ' 16882 : fltk widget reference
'
pWidgetRef = Fl_WizardNew (bviBaseLeft, bviBaseTop, bviBaseWidth, bviBaseHeight)
Return pWidgetRef
'
EndExternalFunction
'
'-----------------------------------------------
' Procedure 66 : create a wizard page
BeginExternalFunction (funWizardPageCreate) _
BVal (bviBaseLeft, typInt32) _ ' 16413 : nominal left position of the gui object (pixels)
, BVal (bviBaseTop, typInt32) _ ' 16414 : nominal top position of the gui object (pixels)
, BVal (bviBaseWidth, typInt32) _ ' 16415 : nominal width of the gui object (pixels)
, BVal (bviBaseHeight, typInt32) _ ' 16416 : nominal height of the gui object (pixels)
ParmReturn (typPointer)
'
LocalPointer (pWidgetRef) ' 16882 : fltk widget reference
'
pWidgetRef = Fl_WizardPageNew (bviBaseLeft, bviBaseTop, bviBaseWidth, bviBaseHeight)
Return pWidgetRef
'
EndExternalFunction
Once the basic GUI elements are in place it's an easy process to customize the glitz and glam.
Rod