* 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
This commit is contained in:
David Elliott
2003-09-05 14:00:53 +00:00
parent da02681123
commit 605c7e7ed8
4 changed files with 36 additions and 66 deletions

View File

@@ -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_

View File

@@ -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

View File

@@ -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 <Foundation/NSString.h>
#import <AppKit/NSMenu.h>
#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

View File

@@ -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 )