From 605c7e7ed81c740e80de66c751f50fc54bd77e4d Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 5 Sep 2003 14:00:53 +0000 Subject: [PATCH] * Move m_cocoaNSMenu out of wxCocoaNSMenu and into wxMenu and wxMenuBar * Comment out wxPoserNSMenu (it's not needed for now, may never be) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23398 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/NSMenu.h | 23 +-------------------- include/wx/cocoa/menu.h | 21 +++++++++++++++++++ src/cocoa/NSMenu.mm | 43 ++++++--------------------------------- src/cocoa/menu.mm | 15 +++++++------- 4 files changed, 36 insertions(+), 66 deletions(-) diff --git a/include/wx/cocoa/NSMenu.h b/include/wx/cocoa/NSMenu.h index 4e9043f61b..354d4738d4 100644 --- a/include/wx/cocoa/NSMenu.h +++ b/include/wx/cocoa/NSMenu.h @@ -4,7 +4,7 @@ // Author: David Elliott // Modified by: // Created: 2002/12/09 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) 2002 David Elliott // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -24,27 +24,6 @@ WX_DECLARE_OBJC_HASHMAP(NSMenu); class wxCocoaNSMenu { WX_DECLARE_OBJC_INTERFACE(NSMenu) -// ------------------------------------------------------------------------ -// initialization -// ------------------------------------------------------------------------ -public: - inline wxCocoaNSMenu() - { - m_cocoaNSMenu = NULL; - } - ~wxCocoaNSMenu(); -// ------------------------------------------------------------------------ -// Cocoa specifics -// ------------------------------------------------------------------------ -public: - bool CocoaCreate(const wxString &title); - inline WX_NSMenu GetNSMenu() { return m_cocoaNSMenu; } -protected: - WX_NSMenu m_cocoaNSMenu; -// ------------------------------------------------------------------------ -// Implementation -// ------------------------------------------------------------------------ -protected: }; #endif // _WX_COCOA_NSMENU_H_ diff --git a/include/wx/cocoa/menu.h b/include/wx/cocoa/menu.h index 814599dea0..8a75b38687 100644 --- a/include/wx/cocoa/menu.h +++ b/include/wx/cocoa/menu.h @@ -34,6 +34,16 @@ public: virtual ~wxMenu(); +// ------------------------------------------------------------------------ +// Cocoa specifics +// ------------------------------------------------------------------------ +public: + inline WX_NSMenu GetNSMenu() { return m_cocoaNSMenu; } +protected: + WX_NSMenu m_cocoaNSMenu; +// ------------------------------------------------------------------------ +// Implementation +// ------------------------------------------------------------------------ protected: // implement base class virtuals virtual bool DoAppend(wxMenuItem *item); @@ -66,6 +76,17 @@ public: bool Create(long style = 0); virtual ~wxMenuBar(); +// ------------------------------------------------------------------------ +// Cocoa specifics +// ------------------------------------------------------------------------ +public: + inline WX_NSMenu GetNSMenu() { return m_cocoaNSMenu; } +protected: + WX_NSMenu m_cocoaNSMenu; +// ------------------------------------------------------------------------ +// Implementation +// ------------------------------------------------------------------------ +public: wxMenuItemList m_items; // the list of menu items // implement base class virtuals diff --git a/src/cocoa/NSMenu.mm b/src/cocoa/NSMenu.mm index 4508915289..bbf68e96d5 100644 --- a/src/cocoa/NSMenu.mm +++ b/src/cocoa/NSMenu.mm @@ -4,37 +4,21 @@ // Author: David Elliott // Modified by: // Created: 2002/12/09 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) 2002 David Elliott -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - #include "wx/wxprec.h" +#if wxUSE_MENUS #ifndef WX_PRECOMP #include "wx/log.h" #endif // WX_PRECOMP #include "wx/cocoa/NSMenu.h" -#include "wx/cocoa/ObjcPose.h" -#include "wx/cocoa/autorelease.h" - -#import -#import - -#if wxUSE_MENUS - -// ---------------------------------------------------------------------------- -// globals -// ---------------------------------------------------------------------------- +//#include "wx/cocoa/ObjcPose.h" +#if 0 // There is no reason to pose for NSMenu at this time. // ============================================================================ // @class wxPoserNSMenu // ============================================================================ @@ -48,21 +32,6 @@ WX_IMPLEMENT_POSER(wxPoserNSMenu); @implementation wxPoserNSMenu : NSMenu @end // wxPoserNSMenu - -// ============================================================================ -// wxCocoaNSMenu implementation -// ============================================================================ -bool wxCocoaNSMenu::CocoaCreate(const wxString &title) -{ - wxAutoNSAutoreleasePool pool; - wxLogDebug("CocoaCreate: "+title); - m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: [NSString stringWithCString: title.c_str()]]; - return true; -} - -wxCocoaNSMenu::~wxCocoaNSMenu() -{ - [m_cocoaNSMenu release]; -} +#endif // 0 #endif // wxUSE_MENUS diff --git a/src/cocoa/menu.mm b/src/cocoa/menu.mm index d1e0df837d..3c69ea7481 100644 --- a/src/cocoa/menu.mm +++ b/src/cocoa/menu.mm @@ -42,15 +42,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler) bool wxMenu::Create(const wxString& title, long style) { -#if 0 - if(!title) - return CocoaCreate("wxMenu"); -#endif - return CocoaCreate(title); + wxAutoNSAutoreleasePool pool; + m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: [NSString stringWithCString: title.c_str()]]; + return true; } wxMenu::~wxMenu() { + [m_cocoaNSMenu release]; } bool wxMenu::DoAppend(wxMenuItem *item) @@ -87,8 +86,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow) bool wxMenuBar::Create(long style) { - if(!CocoaCreate("wxMenuBar")) - return false; + wxAutoNSAutoreleasePool pool; + m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: @"wxMenuBar"]; + NSMenuItem *dummyItem = [[NSMenuItem alloc] initWithTitle:@"App menu" /* Note: title gets clobbered by app name anyway */ action:nil keyEquivalent:@""]; @@ -99,6 +99,7 @@ bool wxMenuBar::Create(long style) wxMenuBar::~wxMenuBar() { + [m_cocoaNSMenu release]; } bool wxMenuBar::Append( wxMenu *menu, const wxString &title ) -- 2.45.2