summaryrefslogtreecommitdiff
path: root/src/Fl_Menu_add.cxx
diff options
context:
space:
mode:
authorBill Spitzak <spitzak@gmail.com>2001-05-19 21:30:23 +0000
committerBill Spitzak <spitzak@gmail.com>2001-05-19 21:30:23 +0000
commit07656afb7d81867ce91ac1c83645e28d276e1302 (patch)
treee76590453296b7a9854595b23ac2d869f88ca88e /src/Fl_Menu_add.cxx
parent9c19542bd28b586657a017363c37a630aac93342 (diff)
Fl_Menu_add of a menu item with the same name as an existing submenu
title would mess up by replacing that menu title, it now adds a new item. Fl_Menu::add() of text starting with '/' to a menu is assummed to be a filename. So "/foo/bar" creates a single menu item. You can also put filenames into submenus by doing "submenu//foo/bar", this will create a submenu called "submenu" with an item "/foo/bar". Menu items starting with "\_" will insert an item starting with '_' rather than a divider line. These changes make the menus compatable with fltk 2.0. Another little fix for the BoXX OpenGL overlays. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1460 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Menu_add.cxx')
-rw-r--r--src/Fl_Menu_add.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/Fl_Menu_add.cxx b/src/Fl_Menu_add.cxx
index c8792b865..b7c4bd0c3 100644
--- a/src/Fl_Menu_add.cxx
+++ b/src/Fl_Menu_add.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_add.cxx,v 1.9.2.11 2001/02/12 15:34:37 easysw Exp $"
+// "$Id: Fl_Menu_add.cxx,v 1.9.2.12 2001/05/19 21:30:23 spitzak Exp $"
//
// Menu utilities for the Fast Light Tool Kit (FLTK).
//
@@ -112,16 +112,23 @@ int Fl_Menu_Item::add(
int size = array==local_array ? local_array_size : array->size();
int flags1 = 0;
- char* item;
- for (;;) { /* do all the supermenus: */
+ const char* item;
- /* fill in the buf with name, changing \x to x: */
+ // split at slashes to make submenus:
+ for (;;) {
+
+ // leading slash makes us assumme it is a filename:
+ if (*mytext == '/') {item = mytext; break;}
+
+ // leading underscore causes divider line:
+ if (*mytext == '_') {mytext++; flags1 = FL_MENU_DIVIDER;}
+
+ // copy to buf, changing \x to x:
q = buf;
for (p=mytext; *p && *p != '/'; *q++ = *p++) if (*p=='\\') p++;
*q = 0;
item = buf;
- if (*item == '_') {item++; flags1 = FL_MENU_DIVIDER;}
if (*p != '/') break; /* not a menu title */
mytext = p+1; /* point at item title */
@@ -143,7 +150,7 @@ int Fl_Menu_Item::add(
/* find a matching menu item: */
for (; m->text; m = m->next())
- if (!compare(m->text,item)) break;
+ if (!(m->flags&FL_SUBMENU) && !compare(m->text,item)) break;
if (!m->text) { /* add a new menu item */
int n = m-array;
@@ -254,5 +261,5 @@ void Fl_Menu_::remove(int i) {
}
//
-// End of "$Id: Fl_Menu_add.cxx,v 1.9.2.11 2001/02/12 15:34:37 easysw Exp $".
+// End of "$Id: Fl_Menu_add.cxx,v 1.9.2.12 2001/05/19 21:30:23 spitzak Exp $".
//