From 70ca1d156ba8bb0aa1b3a925b89f935fe4dccfbe Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 11 Mar 2004 05:17:12 +0000 Subject: Fl_Value_Slider::draw_bg() didn't always apply the clipping rectangle (STR #235) fl_filename_relative() returned the wrong string if the absolute pathname was equal to the current working directory (STR #224) Fl_Help_Dialog didn't correctly restore the scroll position when going forward/back in the link history if the file changed (STR #218) glutGetModifiers() did not mask off extra state bits, confusing some GLUT-based applications (STR #213) Fixed mouse capture problems on MacOS X (STR #209, STR #229) Fl_Sys_Menu_Bar is now built into the library for MacOS X (STR #229) Fl_Menu_ now provides item_pathname() methods to get the "pathname" of a menu item, e.g. "File/Quit" (STR #283) Fl_Text_Display now provides cursor_color() methods to get and set the cursor color (STR #271) Fl_Scroll didn't honor FL_NO_BOX (STR #305) FLUID declaration blocks didn't support public/private definitions (STR #301) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3231 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Menu_.cxx | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'src/Fl_Menu_.cxx') diff --git a/src/Fl_Menu_.cxx b/src/Fl_Menu_.cxx index 6b9567547..56ca4e4b3 100644 --- a/src/Fl_Menu_.cxx +++ b/src/Fl_Menu_.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu_.cxx,v 1.7.2.8.2.6 2003/01/30 21:42:11 easysw Exp $" +// "$Id: Fl_Menu_.cxx,v 1.7.2.8.2.7 2004/03/11 05:17:12 easysw Exp $" // // Common menu code for the Fast Light Tool Kit (FLTK). // @@ -36,6 +36,43 @@ #include #include +// Set 'pathname' of specified menuitem +// If finditem==NULL, mvalue() is used (the most recently picked menuitem) +// Returns: +// 0 : OK +// -1 : item not found (name="") +// -2 : 'name' not large enough (name="") +// +#define SAFE_STRCAT(s) \ + { len += strlen(s); if ( len >= namelen ) { *name='\0'; return(-2); } else strcat(name,(s)); } +int Fl_Menu_::item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem) const { + int len = 0; + finditem = finditem ? finditem : mvalue(); + name[0] = '\0'; + for ( int t=0; tsubmenu() ) { // submenu? descend + if ( *name ) SAFE_STRCAT("/"); + SAFE_STRCAT(m->label()); + } else { + if ( m->label() ) { // menu item? + if ( m == finditem ) { // found? tack on itemname, done. + SAFE_STRCAT("/"); + SAFE_STRCAT(m->label()); + return(0); + } + } else { // end of submenu? pop + char *ss = strrchr(name, '/'); + if ( ss ) { *ss = 0; len = strlen(name); } // "File/Edit" -> "File" + else { name[0] = '\0'; len = 0; } // "File" -> "" + continue; + } + } + } + *name = '\0'; + return(-1); // item not found +} + int Fl_Menu_::value(const Fl_Menu_Item* m) { clear_changed(); if (value_ != m) {value_ = m; return 1;} @@ -150,5 +187,5 @@ void Fl_Menu_::clear() { } // -// End of "$Id: Fl_Menu_.cxx,v 1.7.2.8.2.6 2003/01/30 21:42:11 easysw Exp $". +// End of "$Id: Fl_Menu_.cxx,v 1.7.2.8.2.7 2004/03/11 05:17:12 easysw Exp $". // -- cgit v1.2.3