EVT_MENU(myMenuID_EmptyConsoleWindow, MyApp::OnEmptyConsoleWindow)
EVT_MENU(myMenuID_ViewGlobalParameters, MyApp::OnViewGlobalParameters)
EVT_MENU(myMenuID_ViewParameterFilesList, MyApp::OnViewParameterFilesList)
+ EVT_MENU(myMenuID_BringAllWindowsToFront, MyApp::OnBringAllWindowsToFront)
#if defined(__WXMAC__)
EVT_ACTIVATE(MyApp::OnActivate)
#endif
wxMenuBar *
MyApp::CreateMenuBar(int kind, wxMenu **out_file_history_menu, wxMenu **out_edit_menu)
{
-
//// Make a menubar
wxMenu *file_menu = new wxMenu;
+ wxMenu *file_history_menu = NULL;
file_menu->Append(wxID_NEW, _T("&New...\tCtrl-N"));
file_menu->Append(wxID_OPEN, _T("&Open...\tCtrl-O"));
if (out_file_history_menu != NULL) {
- *out_file_history_menu = new wxMenu;
+ file_history_menu = new wxMenu;
+ *out_file_history_menu = file_history_menu;
file_menu->AppendSubMenu(*out_file_history_menu, _T("Open Recent"));
m_docManager->FileHistoryAddFilesToMenu(*out_file_history_menu);
m_docManager->FileHistoryUseMenu(*out_file_history_menu); // Should be removed when menu is discarded
menu_bar->Append(view_menu, _T("View"));
menu_bar->Append(md_menu, _T("MM/MD"));
menu_bar->Append(script_menu, _T("&Script"));
+
+#if defined(__WXMAC__)
+ wxMenu *window_menu = new wxMenu;
+ window_menu->Append(myMenuID_BringAllWindowsToFront, _T("Bring All to Front"));
+ window_menu->AppendSeparator();
+ menu_bar->Append(window_menu, _T("Window"));
+#endif
+
menu_bar->Append(help_menu, _T("&Help"));
UpdateScriptMenu(menu_bar);
parameterFilesFrame->Raise();
}
+void
+MyApp::OnBringAllWindowsToFront(wxCommandEvent &event)
+{
+ int size = 0, n;
+ wxWindowList::iterator iter;
+ wxTopLevelWindow **wins;
+ size = wxTopLevelWindows.size();
+ if (size > 0) {
+ wins = (wxTopLevelWindow **)calloc(sizeof(wxTopLevelWindow *), size);
+ for (iter = wxTopLevelWindows.begin(), n = 0; iter != wxTopLevelWindows.end(); ++iter, ++n) {
+ wins[n] = (wxTopLevelWindow *)(*iter);
+ }
+ for (n = 0; n < size; n++) {
+ if (wins[n]->IsShown())
+ wins[n]->Raise();
+ }
+ }
+}
+
int
MyApp::LookupScriptMenu(const char *title)
{
MyAppCallback_setConsoleColor(0);
MyAppCallback_showScriptMessage("%s", buf);
}
- }
+ } else break;
}
while (m_process != NULL && (m_process->IsErrorAvailable())) {
err = m_process->GetErrorStream();
MyAppCallback_showScriptMessage("\n%s", buf);
MyAppCallback_setConsoleColor(0);
}
- }
+ } else break;
}
if (m_processTerminated) {
// OnEndProcess has been called
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/osx/cocoa/menu.mm
+// Purpose: wxMenu, wxMenuBar, wxMenuItem
+// Author: Stefan Csomor
+// Modified by:
+// Created: 1998-01-01
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// headers & declarations
+// ============================================================================
+
+// wxWidgets headers
+// -----------------
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+#include "wx/log.h"
+#include "wx/app.h"
+#include "wx/utils.h"
+#include "wx/frame.h"
+#include "wx/menuitem.h"
+#endif
+
+#include "wx/menu.h"
+
+#include "wx/osx/private.h"
+
+// other standard headers
+// ----------------------
+#include <string.h>
+
+@implementation wxNSMenu
+
+- (id) initWithTitle:(NSString*) title
+{
+ self = [super initWithTitle:title];
+ impl = NULL;
+ return self;
+}
+
+- (void)setImplementation: (wxMenuImpl *) theImplementation
+{
+ impl = theImplementation;
+}
+
+- (wxMenuImpl*) implementation
+{
+ return impl;
+}
+
+@end
+
+// this is more compatible, as it is also called for command-key shortcuts
+// and under 10.4, we are not getting a 'close' event however...
+#define wxOSX_USE_NEEDSUPDATE_HOOK 1
+
+@interface wxNSMenuController : NSObject wxOSX_10_6_AND_LATER(<NSMenuDelegate>)
+{
+}
+
+#if wxOSX_USE_NEEDSUPDATE_HOOK
+- (void)menuNeedsUpdate:(NSMenu*)smenu;
+#else
+- (void)menuWillOpen:(NSMenu *)menu;
+#endif
+- (void)menuDidClose:(NSMenu *)menu;
+- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item;
+
+@end
+
+@implementation wxNSMenuController
+
+- (id) init
+{
+ self = [super init];
+ return self;
+}
+
+#if wxOSX_USE_NEEDSUPDATE_HOOK
+- (void)menuNeedsUpdate:(NSMenu*)smenu
+{
+ wxNSMenu* menu = (wxNSMenu*) smenu;
+ wxMenuImpl* menuimpl = [menu implementation];
+ if ( menuimpl )
+ {
+ wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleMenuOpened();
+ }
+}
+#else
+- (void)menuWillOpen:(NSMenu *)smenu
+{
+ wxNSMenu* menu = (wxNSMenu*) smenu;
+ wxMenuImpl* menuimpl = [menu implementation];
+ if ( menuimpl )
+ {
+ wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleMenuOpened();
+ }
+}
+#endif
+
+- (void)menuDidClose:(NSMenu *)smenu
+{
+ wxNSMenu* menu = (wxNSMenu*) smenu;
+ wxMenuImpl* menuimpl = [menu implementation];
+ if ( menuimpl )
+ {
+ wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleMenuClosed();
+ }
+}
+
+- (void)menu:(NSMenu *)smenu willHighlightItem:(NSMenuItem *)item
+{
+ wxNSMenu* menu = (wxNSMenu*) smenu;
+ wxMenuImpl* menuimpl = [menu implementation];
+ if ( menuimpl )
+ {
+ wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer();
+ if ( [ item isKindOfClass:[wxNSMenuItem class] ] )
+ {
+ wxMenuItemImpl* menuitemimpl = (wxMenuItemImpl*) [ (wxNSMenuItem*) item implementation ];
+ if ( wxpeer && menuitemimpl )
+ {
+ wxpeer->HandleMenuItemHighlighted( menuitemimpl->GetWXPeer() );
+ }
+ }
+ }
+}
+
+@end
+
+@interface NSApplication(MissingAppleMenuCall)
+- (void)setAppleMenu:(NSMenu *)menu;
+@end
+
+class wxMenuCocoaImpl : public wxMenuImpl
+{
+public :
+ wxMenuCocoaImpl( wxMenu* peer , wxNSMenu* menu) : wxMenuImpl(peer), m_osxMenu(menu)
+ {
+ static wxNSMenuController* controller = NULL;
+ if ( controller == NULL )
+ {
+ controller = [[wxNSMenuController alloc] init];
+ }
+ [menu setDelegate:controller];
+ [m_osxMenu setImplementation:this];
+ // gc aware
+ if ( m_osxMenu )
+ CFRetain(m_osxMenu);
+ [m_osxMenu release];
+ }
+
+ virtual ~wxMenuCocoaImpl();
+
+ virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos)
+ {
+ NSMenuItem* nsmenuitem = (NSMenuItem*) pItem->GetPeer()->GetHMenuItem();
+ // make sure a call of SetSubMenu is also reflected (occurring after Create)
+ // update the native menu item accordingly
+
+ if ( pItem->IsSubMenu() )
+ {
+ wxMenu* wxsubmenu = pItem->GetSubMenu();
+ WXHMENU nssubmenu = wxsubmenu->GetHMenu();
+ if ( [nsmenuitem submenu] != nssubmenu )
+ {
+ wxsubmenu->GetPeer()->SetTitle( pItem->GetItemLabelText() );
+ [nsmenuitem setSubmenu:nssubmenu];
+ }
+ }
+
+ if ( pos == (size_t) -1 )
+ [m_osxMenu addItem:nsmenuitem ];
+ else
+ [m_osxMenu insertItem:nsmenuitem atIndex:pos];
+ }
+
+ virtual void Remove( wxMenuItem *pItem )
+ {
+ [m_osxMenu removeItem:(NSMenuItem*) pItem->GetPeer()->GetHMenuItem()];
+ }
+
+ virtual void MakeRoot()
+ {
+ [NSApp setMainMenu:m_osxMenu];
+ [NSApp setAppleMenu:[[m_osxMenu itemAtIndex:0] submenu]];
+ {
+ // 2014.4.26. Toshi Nagata
+ // Enable "Window" menu
+ static NSMutableArray *sWindowsMenus = nil;
+ if (sWindowsMenus == nil) {
+ sWindowsMenus = [[NSMutableArray array] retain];
+ }
+ id windowsMenu = [m_osxMenu itemWithTitle:@"Window"];
+ if (windowsMenu && ![sWindowsMenus containsObject:windowsMenu]) {
+ [NSApp setWindowsMenu:[windowsMenu submenu]];
+ [sWindowsMenus addObject:windowsMenu];
+ }
+ // End Toshi Nagata
+ }
+ }
+
+ virtual void Enable( bool WXUNUSED(enable) )
+ {
+ }
+
+ virtual void SetTitle( const wxString& text )
+ {
+ wxCFStringRef cfText(text);
+ [m_osxMenu setTitle:cfText.AsNSString()];
+ }
+
+ virtual void PopUp( wxWindow *win, int x, int y )
+ {
+ win->ScreenToClient( &x , &y ) ;
+ NSView *view = win->GetPeer()->GetWXWidget();
+ NSRect frame = [view frame];
+ frame.origin.x = x;
+ frame.origin.y = y;
+ frame.size.width = 1;
+ frame.size.height = 1;
+ NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO];
+ [popUpButtonCell setAutoenablesItems:NO];
+ [popUpButtonCell setAltersStateOfSelectedItem:NO];
+ [popUpButtonCell setMenu:m_osxMenu];
+ [popUpButtonCell selectItem:nil];
+ [popUpButtonCell performClickWithFrame:frame inView:view];
+ [popUpButtonCell release];
+ }
+
+ WXHMENU GetHMenu() { return m_osxMenu; }
+
+ static wxMenuImpl* Create( wxMenu* peer, const wxString& title );
+ static wxMenuImpl* CreateRootMenu( wxMenu* peer );
+protected :
+ wxNSMenu* m_osxMenu;
+} ;
+
+wxMenuCocoaImpl::~wxMenuCocoaImpl()
+{
+ [m_osxMenu setDelegate:nil];
+ [m_osxMenu setImplementation:nil];
+ // gc aware
+ if ( m_osxMenu )
+ CFRelease(m_osxMenu);
+}
+
+wxMenuImpl* wxMenuImpl::Create( wxMenu* peer, const wxString& title )
+{
+ wxCFStringRef cfText( title );
+ wxNSMenu* menu = [[wxNSMenu alloc] initWithTitle:cfText.AsNSString()];
+ wxMenuImpl* c = new wxMenuCocoaImpl( peer, menu );
+ return c;
+}
objects = {
/* Begin PBXBuildFile section */
+ E4196C66190B2FA500183E62 /* menu.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4196C65190B2FA500183E62 /* menu.mm */; };
E420BDEF1885746700A2B983 /* ConsoleFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BDE81885746700A2B983 /* ConsoleFrame.cpp */; };
E420BDF01885746700A2B983 /* filedlg.mm in Sources */ = {isa = PBXBuildFile; fileRef = E420BDEA1885746700A2B983 /* filedlg.mm */; };
E420BDF11885746700A2B983 /* GlobalParameterFilesFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BDEB1885746700A2B983 /* GlobalParameterFilesFrame.cpp */; };
/* Begin PBXFileReference section */
8D1107320486CEB800E47090 /* Molby.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Molby.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ E4196C65190B2FA500183E62 /* menu.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = menu.mm; sourceTree = "<group>"; };
E420BDE81885746700A2B983 /* ConsoleFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleFrame.cpp; sourceTree = "<group>"; };
E420BDE91885746700A2B983 /* ConsoleFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleFrame.h; sourceTree = "<group>"; };
E420BDEA1885746700A2B983 /* filedlg.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = filedlg.mm; sourceTree = "<group>"; };
E420BDF31885749000A2B983 /* listctrl_private.h */,
E420BDF41885749000A2B983 /* listctrl.cpp */,
E4653CB018A0CC7D0022377B /* textctrl_addition.mm */,
+ E4196C65190B2FA500183E62 /* menu.mm */,
E420BDF51885749000A2B983 /* MoleculeView.cpp */,
E420BDF61885749000A2B983 /* MoleculeView.h */,
E420BDF71885749000A2B983 /* MyApp.cpp */,
E420BE23188574F600A2B983 /* RubyDialogFrame.cpp in Sources */,
E420BE24188574F600A2B983 /* wxKillAddition.cpp in Sources */,
E4653CB118A0CC7D0022377B /* textctrl_addition.mm in Sources */,
+ E4196C66190B2FA500183E62 /* menu.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};