mirror of https://github.com/fltk/fltk
Fixed the use of FL_SUBMENU_POINTER in Fl_Sys_Menu_Bar objects (cont'd).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9223 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
2d4cf9e26b
commit
b8d34a254f
|
@ -52,7 +52,7 @@ public:
|
|||
int clear_submenu(int index);
|
||||
#if ! defined(FL_DOXYGEN)
|
||||
enum menuOrItemOperation { itemAtIndex, setKeyEquivalent, setKeyEquivalentModifierMask, setState, initWithTitle,
|
||||
numberOfItems, setSubmenu, setEnabled, addSeparatorItem, setTitle, removeItem, addNewItem, renameItem };
|
||||
numberOfItems, setSubmenu, setEnabled, addSeparatorItem, setTitle, removeItem, addNewItem };
|
||||
// function doMenuOrItemOperation is in file Fl_cocoa.mm because it contains objective-c code
|
||||
static void *doMenuOrItemOperation( menuOrItemOperation operation, ...);
|
||||
#endif
|
||||
|
|
|
@ -261,8 +261,8 @@ void Fl_Sys_Menu_Bar::remove(int rank)
|
|||
*/
|
||||
void Fl_Sys_Menu_Bar::replace(int rank, const char *name)
|
||||
{
|
||||
doMenuOrItemOperation(renameItem, rank, name);
|
||||
fl_sys_menu_bar->Fl_Menu_::replace(rank, name);
|
||||
Fl_Menu_::replace(rank, name);
|
||||
convertToMenuBar(Fl_Menu_::menu());
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,9 +273,6 @@ void Fl_Sys_Menu_Bar::replace(int rank, const char *name)
|
|||
void Fl_Sys_Menu_Bar::draw() {
|
||||
}
|
||||
|
||||
extern class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
|
||||
|
||||
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
//
|
||||
|
|
|
@ -3151,28 +3151,6 @@ void *Fl_Sys_Menu_Bar::doMenuOrItemOperation(Fl_Sys_Menu_Bar::menuOrItemOperatio
|
|||
if (prank != NULL) *prank = [menu indexOfItem:item];
|
||||
[item release];
|
||||
}
|
||||
else if (operation == Fl_Sys_Menu_Bar::renameItem) { // arguments: int rank, const char *newname
|
||||
// renames the system menu item numbered rank in fl_sys_menu_bar->menu()
|
||||
int rank = va_arg(ap, int);
|
||||
char *newname = remove_ampersand( va_arg(ap, const char *) );
|
||||
int countmenus = [[NSApp mainMenu] numberOfItems];
|
||||
bool found = NO;
|
||||
NSMenuItem *macitem = 0;
|
||||
for(int i = 1; (!found) && i < countmenus; i++) {
|
||||
NSMenuItem *item = [[NSApp mainMenu] itemAtIndex:i];
|
||||
NSMenu *submenu = [item submenu];
|
||||
if (submenu == nil) continue;
|
||||
int countitems = [submenu numberOfItems];
|
||||
for(int j = 0; j < countitems; j++) {
|
||||
macitem = [submenu itemAtIndex:j];
|
||||
if ([macitem tag] == rank) { found = YES; break; }
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
[macitem setTitle:[[[NSString alloc] initWithUTF8String:newname] autorelease]];
|
||||
}
|
||||
free(newname);
|
||||
}
|
||||
va_end(ap);
|
||||
[localPool release];
|
||||
return retval;
|
||||
|
|
Loading…
Reference in New Issue