Domingo Alvarez Duarte wrote:
> I'm facing a problem using fluid, I'm writing forms for view/edit database
> records I want to name the widgets used to show/edit field information
> with the same name as the database records, but sometimes those names can
> conflict with some parent class field/method names, ideally I want a kind
> of namespace for those fields and that can be don using an internal
> class/struct without any inheritance.
I've had to do a bit of this myself.
My approach is to make an 'input' class of my own
for each of the input fields (eg. one for Fl_Input,
Fl_Choice, etc).
And in these classes have a 'name' field (std::string or char*)
that is the "database name".
This way I don't need a variable for each field; I just keep
an array of the 'fields', and whenever I want to load or save
the entire form, I have an application level load/save method
that walks the array and either reads or writes all the names
and field contents.
For input checking, all the fields invoke a sanitizer callback
that the app programmer can set (eg. if it's an integer oriented
field, then set up the "integer sanitizer" as the callback).
I avoid keeping C++ variable names for each field, so that
fields can be dynamically created. (In my case I have external
"ascii art" text files (sample below) that define the forms,
so this is a must. But it works for hard coded forms too)
In fluid you can just drop regular input/choice/etc widgets,
but set their 'class' to be your own classes, and configure
the 'callback' to be the sanitizer.
Here's an example of the ascii art files I use for my forms.
The "prompt name" automatically becomes the "database name"
(minus the spaces). The underbars define how wide the fields
are, and the vertical spacing defines the vertical positioning
of the widgets. A parser reads this file and creates the
widgets automatically. I have about 30 such files (each about
5x larger than the excerpt shown here) each with different contents.
Some are multiline fields, or have bodies of text or images embedded
in there as well. Ascii art FTW ;)
****
<<TAB>> "Properties"
AutoDump: "off,fail,done,donefail" ?
Done Mail: ______________ ?
Dump Mail: ______________ ?
= WaitFor: ______________ ?
= Wait For State: "Dump,Done,DoneFail,Fail" ?
Ram: ______________ ?
Submit Hosts: __________________________________________________ ?
Job Start Command: ___________________________________________ ? Browse
Job Done Command: ___________________________________________ ? Browse
Job Dump Command: ___________________________________________ ? Browse
Never Use Cpus: __________________________________________________ ?
__________________________________________________
__________________________________________________
Submit Options: __________________________________________________ ?
__________________________________________________
__________________________________________________
****
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk