[fltk.general] Fl_Menu_Item offset calculation
Hi, I am using fltk-1.1.10 and I have in my menu some check menu items. Their settings shall be updated according to some preference information. I do this using the 'Name' of the menu item defined by FLUID in the property dialog of the item. So I write PTimeBaseRELA-setonly(); (with PTimeBaseRela being the 'name' of the menu item) But it doesn't work. Instead the predecessor menu item is set! Looking in the generated .h file the 'Name' is defined (in my case) as #define PTimeBaseRELA (menu_PMenuBar+23) But for my opinion it should be #define PTimeBaseRELA (menu_PMenuBar+24) Indeed, it can be fixed by using (PTimeBaseRELA+1)-setonly(); But this behaviour is very confusing. I thing the calculation of the menu item offsets in fluid is buggy. Regards Rainer ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Fl_Menu_Item offset calculation
I am using fltk-1.1.10 and I have in my menu some check menu items. Their settings shall be updated according to some preference information. I do this using the 'Name' of the menu item defined by FLUID in the property dialog of the item. So I write PTimeBaseRELA-setonly(); (with PTimeBaseRela being the 'name' of the menu item) But it doesn't work. Instead the predecessor menu item is set! Looking in the generated .h file the 'Name' is defined (in my case) as #define PTimeBaseRELA (menu_PMenuBar+23) But for my opinion it should be #define PTimeBaseRELA (menu_PMenuBar+24) Indeed, it can be fixed by using (PTimeBaseRELA+1)-setonly(); But this behaviour is very confusing. I thing the calculation of the menu item offsets in fluid is buggy. Hmm, that does sound wrong: if possible, can you post a minimal fluid file, maybe just showing your menu layout, that exhibits the fault? It would be very useful to see how your menus are laid out, so we can see where the discrepancy arises! Thanks... 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 fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Fl_Menu_Item offset calculation
Below is my .fl file with the original menu bar reproducing the error. Hope it helps! Thanks Rainer # data file for the Fltk User Interface Designer (fluid) version 1.0110 header_name {.h} code_name {.cxx} decl {\#include string} {} decl {\#include stdarg.h} {} decl {\#include stdio.h} {} decl {\#include FL/Fl.H} {} decl {\#include FL/fl_ask.H} {} decl {\#include FL/fl_draw.H} {} decl {\#include FL/x.H} {} decl {\#include FL/Fl_Help_Dialog.H} {} decl {\#include FL/Fl_Preferences.H} {} decl {\#include FL/Fl_Native_File_Chooser.H} {} Function {} {open selected return_type int } { Fl_Window PMainWindow { label {UDI Data Browser} callback {// terminate_all();} open xywh {495 275 930 640} type Double hide resizable code0 {initialiseMainWindow(argc,argv);} } { Fl_Menu_Bar PMenuBar {open xywh {0 0 930 20} labelsize 12 textsize 12 } { Submenu {} { label File open xywh {0 0 62 20} labelsize 12 } { MenuItem {} { label {Open DataFile...} tooltip {Opens a recording data file for analysis} xywh {0 0 30 20} shortcut 0x4006f labelsize 12 } MenuItem {} { label {Save as...} xywh {0 0 30 20} shortcut 0x40073 labelsize 12 } MenuItem {} { label Close tooltip {Unloads the actual data file} xywh {0 0 30 20} shortcut 0x40063 labelsize 12 divider } MenuItem {} { label Quit tooltip {Terminates the program} xywh {0 0 30 20} shortcut 0x40071 labelsize 12 divider } Submenu {} { label {Recent Files} xywh {0 0 62 20} labelsize 12 } {} } Submenu {} { label DataMap open xywh {0 0 62 20} labelsize 12 } { MenuItem {} { label {Create DataMap...} tooltip {Creates a datamap with all signals of the data file} xywh {5 5 30 20} shortcut 0x4006d labelsize 12 } MenuItem {} { label {Import DataMap...} tooltip {Imports an existing datamap as user parameter} xywh {5 5 30 20} shortcut 0x40069 labelsize 12 } MenuItem {} { label {Save DataMap ...} tooltip {Saves the actual user parameter list as a datamap file} xywh {5 5 30 20} shortcut 0x40073 labelsize 12 divider } MenuItem {} { label {Import XRef File...} xywh {5 5 30 20} labelsize 12 hide } MenuItem {} { label {Save XRef File...} xywh {5 5 30 20} labelsize 12 hide } MenuItem {} { label {XRef Path...} xywh {5 5 30 20} labelsize 12 } MenuItem {} { label {Test Xref...} xywh {0 0 30 20} labelsize 12 hide } MenuItem {} { label {Clear XRef List} xywh {0 0 30 20} labelsize 12 hide } } MenuItem PMExpDat { label ExportData xywh {0 0 30 20} labelsize 12 } Submenu {} { label Settings open xywh {0 0 62 20} labelsize 12 } { MenuItem {} { label {Increment...} xywh {0 0 30 20} labelsize 12 } MenuItem {} { label {Tolerance...} xywh {0 0 30 20} labelsize 12 deactivate } Submenu {} { label {Time Base} open xywh {0 0 62 20} labelsize 12 } { MenuItem PTimeBaseTEST { label {Test Time} xywh {0 0 30 20} type Radio value 1 labelsize 12 } MenuItem PTimeBaseRELA { label {Relative Time} xywh {0 0 30 20} type Radio labelsize 12 } MenuItem PTimeBaseIRIG { label {IRIG Time} xywh {0 0 30 20} type Radio labelsize 12 } MenuItem PTimeBaseSS1J { label {Sec since 1 Jan} xywh {0 0 30 20} type Radio labelsize 12 } MenuItem PTimeBaseSSMN { label {Midnight Time} xywh {0 0 30 20} type Radio labelsize 12 } } Submenu {} { label {Signal View} open tooltip {Selects how the signals are displayed in Signal Browser: Object Tree or Signal List} xywh {0 0 62 20} labelsize 12 } { MenuItem {} { label {Signal List} tooltip {Shows the Signal List in the SignalBrowser} xywh {0 0 30 20} type Radio value 1 labelsize 12 } MenuItem {} { label {Object Tree} tooltip {Shows the Object Tree in the SignalBrowser} xywh {0 0 30 20} type Radio labelsize 12 } } Submenu {} { label {PANLink CW Option} open xywh {0 0 62 20} labelsize 12 } { MenuItem {} { label NONE xywh {0 0 30 20} type Radio labelsize 12 } MenuItem {} { label REDUCED xywh {0 0 30 20} type Radio
Re: [fltk.general] Fl_Menu_Item offset calculation
Below is my .fl file with the original menu bar reproducing the error. Hope it helps! Thanks Hmm, OK - I *think* the problem is the empty Recent Files submenu item... If that item is made to be not-empty, then things seem to work a whole lot better! Though, for what it is worth, I don't think that using the fluid-generated offsets is going to work all that well if you are using any dynamically generated menu content, since the computed offsets will likely always be wrong. (Though, indeed I could be wrong too!) I'd favour doing what Greg does, and build and manipulate the menus dynamically... Um, try starting about here: http://www.seriss.com/people/erco/fltk/#Menu_ChangeLabel The alternate might be, if you plan on having a fixed number of previous files listed, to pre-populate the Recent Files submenu with unused entries, then either hiding or inactivating those until they are populated. That should work... I think... Maybe... Yup, just tested that and it seems to be fine (used inactive entries in my test, though I assume hidden would do too!) 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 fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Fl_Menu_Item offset calculation
Below is my .fl file with the original menu bar reproducing the error. Hope it helps! Thanks Hmm, OK - I *think* the problem is the empty Recent Files submenu item... If that item is made to be not-empty, then things seem to work a whole lot = better! Though, for what it is worth, I don't think that using the fluid-generated = offsets is going to work all that well if you are using any dynamically g= enerated menu content, since the computed offsets will likely always be wro= ng. (Though, indeed I could be wrong too!) I'd favour doing what Greg does, and build and manipulate the menus dynamic= ally... Um, try starting about here: http://www.seriss.com/people/erco/fltk/#Menu_ChangeLabel = The alternate might be, if you plan on having a fixed number of previous fi= les listed, to pre-populate the Recent Files submenu with unused entrie= s, then either hiding or inactivating those until they are populated. That should work... I think... Maybe... Yup, just tested that and it seems = to be fine (used inactive entries in my test, though I assume hidden woul= d do too!) 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. Thanks for the answer. It's ok that it will not work when the menu is modified at run time; but I think the menu_item access should work correctly as long as the menu is *not* modified. (This is given in my case.) Alternatively FLUID could generate the menu_item pointer in the .h file as a function call (using Gregs recommendation) like : #define PTimeBaseTEST (menu_PMenuBar-find_item(Settings/TimeBase/Test Time)) That should work even on modified menus. [OK, but only as long as the the menu_item name is not modified... :-( ] Regards Rainer ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Fl_Menu_Item offset calculation
It's ok that it will not work when the menu is modified at run time; but I think the menu_item access should work correctly as long as the menu is *not* modified. (This is given in my case.) Yup: I think it would be good if you filed an STR recording this stuff, because it does look like there's something a bit, erm, suspect about the current behaviour... Alternatively FLUID could generate the menu_item pointer in the .h file as a function call (using Gregs recommendation) like : #define PTimeBaseTEST (menu_PMenuBar-find_item(Settings/TimeBase/Test Time)) That should work even on modified menus. Indeed. [OK, but only as long as the the menu_item name is not modified... :-( ] Though I think Greg also has a demo showing how to change the menu items name without actually changing its name too, for internationalization purposes and etc... 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 fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Fl_Menu_Item offset calculation
[OK, but only as long as the the menu_item name is not modified... :-( ] It's also possible to use callback pointer or userdata value entry: // // Menu using additional foo name: // Menu.add(File,0,0,0,FL_SUBMENU); Menu.add(File/Konvert1, 0, 0, (void*) Konvert1); Menu.add(File/Konvert2, 0, 0, (void*) Konvert2); Menu.add(File/Calc Linear, 0, 0, (void*) Linear); Menu.add(File/Quit,0, 0, (void*) Quit); // // Subroutines to get menuitem by value or by foo (also usable for Fl_Choice): // Fl_Menu_Item* Choice_Value(Fl_Menu_* pChoice, void* Val) { if (pChoice) for (int i= 0; i pChoice-size(); ++i) if (pChoice-menu()[i].user_data_== Val) { pChoice-value(i); pChoice-redraw(); return const_cast Fl_Menu_Item* (pChoice-menu()[i]); } return 0; } //-- Fl_Menu_Item* Choice_Foo(Fl_Menu_* pChoice, const char* Foo) { if (pChoice Foo) for (int i= 0; i pChoice-size(); ++i) { const char* pFoo= (const char*) pChoice-menu()[i].user_data_; if (pFoo strcmp(pFoo, Foo)== 0) { pChoice-value(i); pChoice-redraw(); return const_cast Fl_Menu_Item* (pChoice-menu()[i]); } } return 0; } // // Examples of using subroutines: // void dlg_main::Menu_Toggle(string Foo, bool An, bool Only) { if (Fl_Menu_Item* pMI= Choice_Foo(pMenu, Foo.c_str())) { if (Only) pMI-setonly(); else if (An)pMI-set(); elsepMI-clear(); } } // bool dlg_main::Menu_Value(string Foo) { if (Fl_Menu_Item* pMI= Choice_Foo(pMenu, Foo.c_str())) return pMI-value(); else return false; } // void dlg_main::Menu_Deactivate(string Foo) { if (Fl_Menu_Item* pMI= Choice_Foo(pMenu, Foo.c_str())) pMI-deactivate(); } // void dlg_main::Cb_Menu() { // Callback of Menu: string Foo; if (const Fl_Menu_Item* pV= pMenu-mvalue()) { if (const char* pU= (const char*) pV-user_data()) Foo= pU; else return; } else return; // Evaluate valid callback: if (Foo== Quit)Close(); ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk
Re: [fltk.general] Fl_Menu_Item offset calculation
On 02/05/13 07:14, MacArthur, Ian (Selex ES, UK) wrote: Though I think Greg also has a demo showing how to change the menu items name without actually changing its name too, for internationalization purposes and etc... Yes, that'd be this one: http://www.seriss.com/people/erco/fltk/#MultiLanguageApp ___ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk