I can create the callback from fluid without problem. The issue I have is that
I want to trigger the callback from outside of the GUI. In my case, I am
reading in a state file which changes menu settings. When I examine the fluid
generated code, it calls the callback I defined indirectly.
For example, I have a Fl_Menu_Item called "revdraworder" whose callback I want
to trigger from some part of my program. Here is the fluid code generated for
the callback:
void Controls::cb_revdraworder_i(Fl_Menu_* o, void*) {
// I defined this callback in fluid
my_function( (bool)(o->mvalue()->value()) );
}
void Controls::cb_revdraworder(Fl_Menu_* o, void* v) {
// fluid generated this
((Controls*)(o->parent()->user_data()))->cb_revdraworder_i(o,v);
}
I need to pass a Fl_menu_ pointer to cb_revdraworder() but cannot figure out
which one. Somewhere in my code I will write
revdraworder->do_callback(w)
which will call cb_revorder() which will call cb_revorder_i().
How do I know what the value of w is?
I hope this clarifies things
> > I have a checked menu item for which I would like to trigger the callback.
> > I can change the state of the check. I see there is a method for
> > Fl_Menu_Item to call the callback but cannot figure out which widget
> > pointer I should supply?
>
>
> Not exactly sure what it is you are asking about, but as a general note, I =
> find that it is often instructive to create a little example of what I'm tr=
> ying to do using fluid, then look at athe code it generated for insights in=
> to how to use the widgets...
>
> e.g. (assuming this fluid file does what you want, of course!) this fluid f=
> ile..
>
> ------------
> # data file for the Fltk User Interface Designer (fluid)
> version 1.0300 =
>
> header_name {.h} =
>
> code_name {.cxx}
> decl {\#include <stdio.h>} {selected private local
> } =
>
>
> Function {} {open
> } {
> Fl_Window main_win {
> label {Test Window} open
> xywh {640 311 356 231} type Double visible
> } {
> Fl_Menu_Bar menu_bar {open
> xywh {0 0 356 20}
> } {
> Submenu menu1 {
> label {A Menu} open
> xywh {0 0 62 20}
> } {
> MenuItem item1 {
> label {Item 1}
> callback {puts("Item 1");
> fflush(stdout);}
> xywh {0 0 30 20} type Toggle
> }
> MenuItem item2 {
> label {Item 2}
> callback {puts("Item 2");
> fflush(stdout);}
> xywh {10 10 30 20} type Toggle
> }
> MenuItem item3 {
> label {Item 3}
> callback {puts("Item 3");
> fflush(stdout);}
> xywh {20 20 30 20} type Toggle
> }
> MenuItem item4 {
> label {Item 4}
> callback {puts("Item 4");
> fflush(stdout);}
> xywh {30 30 30 20} type Toggle
> }
> }
> }
> }
> }
>
> ------------
>
> Creates the following C++ output:
>
> ------------
> // generated by Fast Light User Interface Designer (fluid) version 1.0300
>
> #include "menu-chk.h"
> #include <stdio.h>
>
> Fl_Double_Window *main_win=3D(Fl_Double_Window *)0;
>
> Fl_Menu_Bar *menu_bar=3D(Fl_Menu_Bar *)0;
>
> static void cb_item1(Fl_Menu_*, void*) {
> puts("Item 1");
> fflush(stdout);
> }
>
> static void cb_item2(Fl_Menu_*, void*) {
> puts("Item 2");
> fflush(stdout);
> }
>
> static void cb_item3(Fl_Menu_*, void*) {
> puts("Item 3");
> fflush(stdout);
> }
>
> static void cb_item4(Fl_Menu_*, void*) {
> puts("Item 4");
> fflush(stdout);
> }
>
> Fl_Menu_Item menu_menu_bar[] =3D {
> {"A Menu", 0, 0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0},
> {"Item 1", 0, (Fl_Callback*)cb_item1, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
> {"Item 2", 0, (Fl_Callback*)cb_item2, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
> {"Item 3", 0, (Fl_Callback*)cb_item3, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
> {"Item 4", 0, (Fl_Callback*)cb_item4, 0, 2, FL_NORMAL_LABEL, 0, 14, 0},
> {0,0,0,0,0,0,0,0,0},
> {0,0,0,0,0,0,0,0,0}
> };
>
> int main(int argc, char **argv) {
> { main_win =3D new Fl_Double_Window(356, 231, "Test Window");
> { menu_bar =3D new Fl_Menu_Bar(0, 0, 356, 20);
> menu_bar->menu(menu_menu_bar);
> } // Fl_Menu_Bar* menu_bar
> main_win->end();
> } // Fl_Double_Window* main_win
> main_win->show(argc, argv);
> return Fl::run();
> }
>
> ------------
>
> Does that help at all?
>
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 3EL
> A company registered in England & Wales. Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk