From 4ee2c1fafa0c72e396a9f91816325b4a8ec6dfbb Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Thu, 18 Jan 2007 19:20:13 +0000 Subject: Somewhat improved the system menu bar for OS X (STR #1505) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5617 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Sys_Menu_Bar.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Fl_Sys_Menu_Bar.cxx b/src/Fl_Sys_Menu_Bar.cxx index 002689917..e0a464bc7 100644 --- a/src/Fl_Sys_Menu_Bar.cxx +++ b/src/Fl_Sys_Menu_Bar.cxx @@ -178,8 +178,6 @@ static void catMenuFlags( const Fl_Menu_Item *m, char *dst ) { if ( !m->flags ) return; - while ( *dst ) - dst++; if ( m->flags & FL_MENU_INACTIVE ) strcat( dst, "(" ); } @@ -245,27 +243,32 @@ void Fl_Sys_Menu_Bar::menu(const Fl_Menu_Item *m) fl_sys_menu_bar = this; char buf[255]; - int cnt = 1; // first menu is no 2. no 1 is the Apple Menu + int cnt = 1; // first menu is no 2. no 1 is the Apple Menu const Fl_Menu_Item *mm = m; for (;;) { - if ( !mm->text ) + if ( !mm || !mm->text ) break; + char visible = mm->visible() ? 1 : 0; buf[1] = 0; catMenuText( mm->text, buf+1 ); buf[0] = strlen( buf+1 ); MenuHandle mh = NewMenu( ++cnt, (unsigned char*)buf ); + if ( mm->flags & FL_MENU_INACTIVE ) { + ChangeMenuAttributes(mh, kMenuAttrAutoDisable, 0); + DisableAllMenuItems(mh); + DisableMenuItem(mh, 0); + } if ( mm->flags & FL_SUBMENU ) createSubMenu( mh, cnt, ++mm ); - else if ( mm->flags & FL_SUBMENU_POINTER ) - { + else if ( mm->flags & FL_SUBMENU_POINTER ) { const Fl_Menu_Item *smm = (Fl_Menu_Item*)mm->user_data_; createSubMenu( mh, cnt, smm ); } - - InsertMenu( mh, 0 ); - if ( mm->flags & FL_MENU_INACTIVE ) DisableMenuItem( mh, 0 ); + if ( visible ) { + InsertMenu( mh, 0 ); + } mm++; } DrawMenuBar(); -- cgit v1.2.3