mal content wrote:
> See that's the part I didn't get. I thought that I would need
> to modify some top-level structure in order to get colours, etc,
> to propagate down, but couldn't work it out from that description.
Hmm, yeah, didn't work for me either.
For lack of any example, I tried to follow my nose on this one
making a simple app that uses Style to change the defaults of the
app by changing a chooser.
I implemented it the way it /seemed/ it should work (always a mistake ;)
and without resorting to RTSL.
This is as far as I got.
It compiles and runs but doesn't work; changing the chooser
doesn't actually change anything about how the app looks.
(Using latest fltk2.x SVN/fedora3)
Maybe someone who knows FLTK 2.0 can fix this code..?
#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Button.h>
#include <fltk/Choice.h>
#include <fltk/Style.h>
#include <stdio.h>
#include <string.h>
//
// FLTK 2.x example showing how to use Style to change defaults
// NOTE: THIS EXAMPLE DOES NOT WORK CURRENTLY
//
using namespace fltk;
class GlobalStyle : public Style {
public:
GlobalStyle() {
parent_ = Widget::default_style; // ? as per Style
ctor's docs
}
};
// GLOBAL STYLE
GlobalStyle G_style; // ? may not even need to be an actual global
void Choice_CB(fltk::Widget *w) {
Choice *c = (Choice*)w;
const char *choice = c->get_item()->label(); // "SmallFont",
"BigFont", etc
printf("You picked: '%s'\n", choice);
if ( strcmp(choice, "SmallFont" ) == 0 ) { G_style.labelsize(12); }
// ?
if ( strcmp(choice, "BigFont" ) == 0 ) { G_style.labelsize(24); }
// ?
if ( strcmp(choice, "RedButton" ) == 0 ) { G_style.buttoncolor(RED); }
// ?
if ( strcmp(choice, "GreenButton" ) == 0 ) { G_style.buttoncolor(GREEN); }
// ?
w->window()->redraw(); // tell window to redraw itself..
}
int main(int argc, char** argv) {
Window w(300,200);
w.begin();
Button b(50,10,200,25,"Some Button");
Choice c(50,40,200,25,"Style");
c.add("SmallFont");
c.add("BigFont");
c.add("RedButton");
c.add("GreenButton");
c.callback(Choice_CB);
w.end();
w.show(argc,argv);
return(run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk