> > 3. use fluid to create abstract base classes for GUI components,
> > with named member widgets and empty callbacks, and then subclass
> > these using a standard editor/environment of your choice. This
> > keeps the fluid files relatively simple, but adds complexity in
> > the class hierarchy.
> i would really like to know how i can tap into the productivity
> of Fluid but at present its just weird seeing the code indented
> and written in a style that i am not used to reading for example
Once you start to understand what fluid is doing, you don't need to
look at the fluid-generated code at all. Or not very often anyway.
> ...but i can't understand what the real working cycle is like
> with Fluid or similar designers, i don't think you are supposed
> to write all your e.g. callback code in using the little dialog
> boxes etc, i imagine that the interface is all that is designed
> then you export the files and open them in the editor you normally
> work with and flesh out the code there.
Here's a contrived example, where the TimeDisplay.fl fluid file
only contains widgets and a callback that you need to override.
In main.cxx, you subclass TimeDisplay and put in the logic you
need, all in the editor/IDE of your choice.
To build on Linux you need a variation on:
CXXFLAGS=$(fltk-config --cxxflags)
LIBS=$(fltk-config --libs)
LDFLAGS=$(fltk-config --ldflags)
fluid -c TimeDisplay.fl
g++ -Wall -o main $CXXFLAGS main.cxx TimeDisplay.cxx $LIBS $LDFLAGS
Hope this helps (and survives the mail system :-)
Duncan
/* TimeDisplay.fl */
# data file for the Fltk User Interface Designer (fluid)
version 1.0110
header_name {.h}
code_name {.cxx}
decl {\#include <stdio.h>} {}
widget_class TimeDisplay {open
xywh {590 491 245 35} type Double
code0 {Fl_Group::resize(this->x(), this->y(), this->w(), this->h());} visible
} {
Function {buttonCallback_(Fl_Widget* widget, void* data)} {open return_type
{static void}
} {
code {TimeDisplay* timeDisplay = (TimeDisplay*)data;
timeDisplay->buttonCallback(widget, data);} {}
}
Function {buttonCallback(Fl_Widget* widget, void* data)} {open selected
return_type {virtual void}
} {
code {printf("buttonCallback(widget=%p, data=%p\\n", widget, data);} {}
}
Fl_Box m_title {
label label
xywh {5 5 75 25} align 24
}
Fl_Output m_hoursOutput {
tooltip Hours xywh {88 5 30 25} deactivate
}
Fl_Output m_minutesOutput {
label {:}
tooltip Minutes xywh {130 5 30 25} deactivate
}
Fl_Button m_button {
label button
user_data this
callback buttonCallback_
xywh {170 5 70 25}
}
}
/* main.cxx */
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <stdio.h>
#include "TimeDisplay.h"
class MasterTime : public TimeDisplay
{
public:
MasterTime(int X, int Y, int W, int H, const char* T=0)
: TimeDisplay(X,Y,W,H,T)
{
m_hours = 12;
m_minutes= 0;
m_24hour = 1;
m_title->copy_label("Time");
m_button->copy_label("12/24h");
}
void buttonCallback(Fl_Widget* widget, void* data)
{
toggle24hour();
redraw();
}
void draw()
{
char buffer[32];
sprintf(buffer, "%02d", m_24hour ? m_hours : m_hours % 12);
m_hoursOutput->value(buffer);
sprintf(buffer, "%02d", m_minutes);
m_minutesOutput->value(buffer);
TimeDisplay::draw();
}
void setHours(const int hours) {m_hours = hours % 24;}
void setMinutes(const int minutes) {m_minutes = minutes % 60; }
void toggle24hour() { m_24hour = m_24hour ? 0 : 1; }
private:
int m_hours;
int m_minutes;
int m_24hour;
};
int main(int argc, char* argv[])
{
Fl_Window* mainWin = new Fl_Window(265, 35);
MasterTime* masterTime = new MasterTime(10, 10, 245, 35);
masterTime->setHours(14);
masterTime->setMinutes(30);
mainWin->end();
mainWin->show(argc, argv);
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk