summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2006-06-20 10:18:49 +0000
committerMatthias Melcher <fltk@matthiasm.com>2006-06-20 10:18:49 +0000
commit77a20dbef3e748c5880116d24c84de9f10c1d40e (patch)
treed3c9fffb8709f5d8609e5d143e399423fe8dd729
parent87bb58803a171ed486f7396b19ba7baf9cfc76d2 (diff)
STR #1280: added support for assigning Fl_Menu_Items to array variables in Fluid
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5218 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES2
-rw-r--r--fluid/Fl_Menu_Type.cxx33
2 files changed, 28 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index eb4653a78..42ae10d68 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.1.8
+ - Added support for assigning Fl_Menu_Items to array
+ variables in Fluid (STR #1280)
- Added --with-archflags configure option to allow
passing of specific architecture-selection options to
the compiler and linker.
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx
index 5d3295072..1e493cc19 100644
--- a/fluid/Fl_Menu_Type.cxx
+++ b/fluid/Fl_Menu_Type.cxx
@@ -244,10 +244,19 @@ void Fl_Menu_Item_Type::write_static() {
// Write menu item variables...
t = prev; while (t && t->is_menu_item()) t = t->prev;
for (Fl_Type* q = t->next; q && q->is_menu_item(); q = q->next) {
- const char *c = array_name((Fl_Menu_Item_Type *)q);
+ Fl_Menu_Item_Type *m = (Fl_Menu_Item_Type*)q;
+ const char *c = array_name(m);
if (c) {
- int i; const char* n = ((Fl_Menu_Item_Type *)q)->menu_name(i);
- write_c("Fl_Menu_Item* %s::%s = %s::%s + %d;\n", k, c, k, n, i);
+ if (c==m->name()) {
+ // assign a menu item address directly to a variable
+ int i;
+ const char* n = ((Fl_Menu_Item_Type *)q)->menu_name(i);
+ write_c("Fl_Menu_Item* %s::%s = %s::%s + %d;\n", k, c, k, n, i);
+ } else {
+ // if the name is an array, only define the array.
+ // The actual assignment is in write_code1()
+ write_c("Fl_Menu_Item* %s::%s;\n", k, c);
+ }
}
}
}
@@ -336,8 +345,12 @@ void Fl_Menu_Item_Type::write_code1() {
if (class_name(1)) {
write_public(public_);
write_h(" static Fl_Menu_Item *%s;\n", c);
- } else
- write_h("#define %s (%s+%d)\n", c, mname, i);
+ } else {
+ if (c==name())
+ write_h("#define %s (%s+%d)\n", c, mname, i);
+ else
+ write_h("extern Fl_Menu_Item *%s;\n", c);
+ }
}
if (callback()) {
@@ -351,9 +364,15 @@ void Fl_Menu_Item_Type::write_code1() {
}
int init = 0;
+ // if the name is an array variable, assign the value here
+ if (name() && strchr(name(), '[')) {
+ write_c("%s%s = &%s[%d];\n", indent(), name(), mname, i);
+ }
if (image) {
- write_c(" {Fl_Menu_Item* o = &%s[%d];\n", mname, i);
- init = 1;
+ if (!init) {
+ init = 1;
+ write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
+ }
image->write_code();
}
for (int n=0; n < NUM_EXTRA_CODE; n++)