1. wxMenu changes: wxMenuBase appears, several new functions for dynamic menu

handling as well
2. new sample: menu
3. small corrections to wxFileHistory made possible by wxMenu changes
4. ugly fix for panel loaded from resources and TABbing
5. wxDataObject &c doc updates


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4288 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-02 01:25:43 +00:00
parent cf85cb95f1
commit 717a57c2fa
29 changed files with 2205 additions and 1790 deletions

View File

@@ -51,10 +51,6 @@ public:
long m_style;
wxWindow *m_invokingWindow;
#if 0 // seems to be unused (VZ)
wxMenuList& GetMenus() { return m_menus; }
#endif // 0
private:
DECLARE_DYNAMIC_CLASS(wxMenuBar)
};
@@ -63,92 +59,34 @@ private:
// wxMenu
//-----------------------------------------------------------------------------
class wxMenu : public wxEvtHandler
class wxMenu : public wxMenuBase
{
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
wxMenu( const wxString& title, const wxFunction func)
{
Init(title, 0, func);
}
wxMenu( long style )
{
Init( wxEmptyString, style );
}
wxMenu( const wxString& title = wxEmptyString, long style = 0 )
{
Init(title, style);
}
// ctors & dtor
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style) { Init(); }
~wxMenu();
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
// title
void SetTitle(const wxString& label);
const wxString GetTitle() const;
virtual ~wxMenu();
// menu creation
void AppendSeparator();
void Append(int id, const wxString &item,
const wxString &helpStr = "", bool checkable = FALSE);
void Append(int id, const wxString &item,
wxMenu *subMenu, const wxString &helpStr = "" );
void Append(wxMenuItem *pItem);
void Break() { }
// implement base class virtuals
virtual bool DoAppend(wxMenuItem *item);
virtual bool DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem *DoRemove(wxMenuItem *item);
// delete item. don't delete the wxMenu if it's a submenu
void Delete( int id );
// find item by name/id
int FindItem( const wxString itemString ) const;
wxMenuItem *FindItem( int id ) const;
// get/set item's state
void Enable( int id, bool enable );
bool IsEnabled( int id ) const;
void Check( int id, bool check );
bool IsChecked( int id ) const;
void SetLabel( int id, const wxString &label );
wxString GetLabel( int id ) const;
// helpstring
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const ;
// accessors
wxList& GetItems() { return m_items; }
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
void SetClientData( void* clientData ) { m_clientData = clientData; }
void* GetClientData() const { return m_clientData; }
// Updates the UI for a menu and all submenus recursively.
// source is the object that has the update event handlers
// defined for it. If NULL, the menu or associated window
// will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL);
wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); }
wxFunction GetCallback() const { return m_callback; }
void Callback(const wxFunction func) { m_callback = func; }
wxFunction m_callback;
// TODO: virtual void SetTitle(const wxString& title);
#ifdef WXWIN_COMPATIBILITY
// compatibility: these functions are deprecated
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
wxMenu(const wxString& title, const wxFunction func)
: wxMenuBase(title)
{
Callback(func);
}
#endif // WXWIN_COMPATIBILITY
// implementation
int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
void SetInvokingWindow( wxWindow *win );
wxWindow *GetInvokingWindow();
// implementation GTK only
GtkWidget *m_menu; // GtkMenu
@@ -156,21 +94,11 @@ public:
GtkAccelGroup *m_accel;
GtkItemFactory *m_factory;
// used by wxMenuBar
long GetStyle(void) const { return m_style; }
private:
// common code for both constructors:
void Init( const wxString& title,
long style,
const wxFunction func = (wxFunction) NULL );
// common code for all constructors:
void Init();
wxString m_title;
wxList m_items;
wxWindow *m_invokingWindow;
wxEvtHandler *m_eventHandler;
void *m_clientData;
long m_style;
DECLARE_DYNAMIC_CLASS(wxMenu)
};
#endif // __GTKMENUH__

View File

@@ -31,10 +31,15 @@ public:
// implement base class virtuals
virtual void SetText( const wxString& str );
virtual wxString GetLabel() const;
virtual void Enable( bool enable = TRUE );
virtual void Check( bool check = TRUE );
virtual bool IsChecked() const;
#if wxUSE_ACCEL
virtual wxAcceleratorEntry *GetAccel() const;
#endif // wxUSE_ACCEL
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }

View File

@@ -51,10 +51,6 @@ public:
long m_style;
wxWindow *m_invokingWindow;
#if 0 // seems to be unused (VZ)
wxMenuList& GetMenus() { return m_menus; }
#endif // 0
private:
DECLARE_DYNAMIC_CLASS(wxMenuBar)
};
@@ -63,92 +59,34 @@ private:
// wxMenu
//-----------------------------------------------------------------------------
class wxMenu : public wxEvtHandler
class wxMenu : public wxMenuBase
{
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
wxMenu( const wxString& title, const wxFunction func)
{
Init(title, 0, func);
}
wxMenu( long style )
{
Init( wxEmptyString, style );
}
wxMenu( const wxString& title = wxEmptyString, long style = 0 )
{
Init(title, style);
}
// ctors & dtor
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style) { Init(); }
~wxMenu();
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
// title
void SetTitle(const wxString& label);
const wxString GetTitle() const;
virtual ~wxMenu();
// menu creation
void AppendSeparator();
void Append(int id, const wxString &item,
const wxString &helpStr = "", bool checkable = FALSE);
void Append(int id, const wxString &item,
wxMenu *subMenu, const wxString &helpStr = "" );
void Append(wxMenuItem *pItem);
void Break() { }
// implement base class virtuals
virtual bool DoAppend(wxMenuItem *item);
virtual bool DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem *DoRemove(wxMenuItem *item);
// delete item. don't delete the wxMenu if it's a submenu
void Delete( int id );
// find item by name/id
int FindItem( const wxString itemString ) const;
wxMenuItem *FindItem( int id ) const;
// get/set item's state
void Enable( int id, bool enable );
bool IsEnabled( int id ) const;
void Check( int id, bool check );
bool IsChecked( int id ) const;
void SetLabel( int id, const wxString &label );
wxString GetLabel( int id ) const;
// helpstring
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const ;
// accessors
wxList& GetItems() { return m_items; }
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
void SetClientData( void* clientData ) { m_clientData = clientData; }
void* GetClientData() const { return m_clientData; }
// Updates the UI for a menu and all submenus recursively.
// source is the object that has the update event handlers
// defined for it. If NULL, the menu or associated window
// will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL);
wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); }
wxFunction GetCallback() const { return m_callback; }
void Callback(const wxFunction func) { m_callback = func; }
wxFunction m_callback;
// TODO: virtual void SetTitle(const wxString& title);
#ifdef WXWIN_COMPATIBILITY
// compatibility: these functions are deprecated
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
wxMenu(const wxString& title, const wxFunction func)
: wxMenuBase(title)
{
Callback(func);
}
#endif // WXWIN_COMPATIBILITY
// implementation
int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
void SetInvokingWindow( wxWindow *win );
wxWindow *GetInvokingWindow();
// implementation GTK only
GtkWidget *m_menu; // GtkMenu
@@ -156,21 +94,11 @@ public:
GtkAccelGroup *m_accel;
GtkItemFactory *m_factory;
// used by wxMenuBar
long GetStyle(void) const { return m_style; }
private:
// common code for both constructors:
void Init( const wxString& title,
long style,
const wxFunction func = (wxFunction) NULL );
// common code for all constructors:
void Init();
wxString m_title;
wxList m_items;
wxWindow *m_invokingWindow;
wxEvtHandler *m_eventHandler;
void *m_clientData;
long m_style;
DECLARE_DYNAMIC_CLASS(wxMenu)
};
#endif // __GTKMENUH__

View File

@@ -31,10 +31,15 @@ public:
// implement base class virtuals
virtual void SetText( const wxString& str );
virtual wxString GetLabel() const;
virtual void Enable( bool enable = TRUE );
virtual void Check( bool check = TRUE );
virtual bool IsChecked() const;
#if wxUSE_ACCEL
virtual wxAcceleratorEntry *GetAccel() const;
#endif // wxUSE_ACCEL
// implementation
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
GtkWidget *GetMenuItem() const { return m_menuItem; }

View File

@@ -20,20 +20,204 @@
// headers
// ----------------------------------------------------------------------------
#include "wx/list.h" // for wxMenuList
#include "wx/list.h" // for "template" list classes
#include "wx/window.h" // base class for wxMenuBar
// also include this one to ensure compatibility with old code which only
// included wx/menu.h
#include "wx/menuitem.h"
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxMenuItem;
// pseudo template list classes
WX_DECLARE_LIST(wxMenu, wxMenuList);
WX_DECLARE_LIST(wxMenuItem, wxMenuItemList);
// ----------------------------------------------------------------------------
// wxMenu
// ----------------------------------------------------------------------------
// for now, it's in platform-specific file
class WXDLLEXPORT wxMenuBase : public wxEvtHandler
{
public:
// create a menu
static wxMenu *New(const wxString& title = wxEmptyString, long style = 0);
WX_DECLARE_LIST(wxMenu, wxMenuList);
// ctors
wxMenuBase(const wxString& title, long style = 0) : m_title(title)
{ Init(style); }
wxMenuBase(long style = 0)
{ Init(style); }
// dtor deletes all the menu items we own
virtual ~wxMenuBase();
// menu construction
// -----------------
// append a separator to the menu
void AppendSeparator() { Append(wxID_SEPARATOR, wxEmptyString); }
// append a normal item to the menu
void Append(int id,
const wxString& text,
const wxString& help = wxEmptyString,
bool isCheckable = FALSE)
{
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
}
// append a submenu
void Append(int id,
const wxString& text,
wxMenu *submenu,
const wxString& help = wxEmptyString)
{
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, FALSE, submenu));
}
// the most generic form of Append() - append anything
void Append(wxMenuItem *item) { DoAppend(item); }
// insert a break in the menu (only works when appending the items, not
// inserting them)
virtual void Break() { }
// insert an item before given position
bool Insert(size_t pos, wxMenuItem *item);
// detach an item from the menu, but don't delete it so that it can be
// added back later (but if it's not, the caller is responsible for
// deleting it!)
wxMenuItem *Remove(int id) { return Remove(FindChildItem(id)); }
wxMenuItem *Remove(wxMenuItem *item);
// delete an item from the menu (submenus are not destroyed by this
// function, see Destroy)
bool Delete(int id) { return Delete(FindChildItem(id)); }
bool Delete(wxMenuItem *item);
// delete the item from menu and destroy it (if it's a submenu)
bool Destroy(int id) { return Destroy(FindChildItem(id)); }
bool Destroy(wxMenuItem *item);
// menu items access
// -----------------
// get the items
size_t GetMenuItemCount() const { return m_items.GetCount(); }
const wxMenuItemList& GetMenuItems() const { return m_items; }
wxMenuItemList& GetMenuItems() { return m_items; }
// search
virtual int FindItem(const wxString& itemString) const;
wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const;
// get/set items attributes
void Enable(int id, bool enable);
bool IsEnabled(int id) const;
void Check(int id, bool check);
bool IsChecked(int id) const;
void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const;
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const;
// misc accessors
// --------------
// the title
virtual void SetTitle(const wxString& title) { m_title = title; }
const wxString GetTitle() const { return m_title; }
// client data
void SetClientData(void* clientData) { m_clientData = clientData; }
void* GetClientData() const { return m_clientData; }
// event handler
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
// invoking window
void SetInvokingWindow(wxWindow *win) { m_invokingWindow = win; }
wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
// style
long GetStyle() const { return m_style; }
// implementation helpers
// ----------------------
// Updates the UI for a menu and all submenus recursively. source is the
// object that has the update event handlers defined for it. If NULL, the
// menu or associated window will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*)NULL);
// is the menu attached to a menu bar (or is it a popup one)?
bool IsAttached() const { return m_menuBar != NULL; }
// set/get the parent of this menu
void SetParent(wxMenu *parent) { m_menuParent = parent; }
wxMenu *GetParent() const { return m_menuParent; }
#if WXWIN_COMPATIBILITY
// compatibility: these functions are deprecated, use the new ones instead
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
wxMenuItem* FindItemForId(int itemId, wxMenu **itemMenu) const
{ return FindItem(itemId, itemMenu); }
wxList& GetItems() const { return (wxList &)m_items; }
// wxWin 1.6x compatible menu event handling
wxFunction GetCallback() const { return m_callback; }
void Callback(const wxFunction func) { m_callback = func; }
wxFunction m_callback;
#endif // WXWIN_COMPATIBILITY
protected:
// virtuals to override in derived classes
// ---------------------------------------
virtual bool DoAppend(wxMenuItem *item);
virtual bool DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem *DoRemove(wxMenuItem *item);
virtual bool DoDelete(wxMenuItem *item);
virtual bool DoDestroy(wxMenuItem *item);
// helpers
// -------
// common part of all ctors
void Init(long style);
// unlike FindItem(), this function doesn't recurse but only looks through
// our direct children and also may return the index of the found child if
// pos != NULL
wxMenuItem *FindChildItem(int id, size_t *pos = NULL) const;
protected:
wxMenuBar *m_menuBar; // menubar we belong to or NULL
wxMenu *m_menuParent; // parent menu or NULL
wxString m_title; // the menu title or label
wxMenuItemList m_items; // the list of menu items
wxWindow *m_invokingWindow; // for popup menus
void *m_clientData; // associated with the menu
long m_style; // combination of wxMENU_XXX flags
wxEvtHandler *m_eventHandler; // a pluggable in event handler
};
// ----------------------------------------------------------------------------
// wxMenuBar
@@ -122,7 +306,7 @@ public:
// compatibility only: these functions are deprecated, use the new ones
// instead
#ifdef WXWIN_COMPATIBILITY
#if WXWIN_COMPATIBILITY
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
@@ -161,9 +345,5 @@ protected:
#endif
#endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
// also include this one to ensure compatibility with old code which only
// included wx/menu.h
#include "wx/menuitem.h"
#endif
// _WX_MENU_H_BASE_

View File

@@ -33,6 +33,7 @@
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAcceleratorEntry;
class WXDLLEXPORT wxMenuItem;
class WXDLLEXPORT wxMenu;
@@ -52,6 +53,9 @@ public:
bool isCheckable = FALSE,
wxMenu *subMenu = (wxMenu *)NULL);
// destruction: wxMenuItem will delete its submenu
virtual ~wxMenuItemBase();
// the menu we're in
wxMenu *GetMenu() const { return m_parentMenu; }
@@ -60,8 +64,14 @@ public:
int GetId() const { return m_id; }
bool IsSeparator() const { return m_id == wxID_SEPARATOR; }
// the item's text (or name, or label...)
// the item's text (or name)
//
// NB: the item's text includes the accelerators and mnemonics info (if
// any), i.e. it may contain '&' or '_' or "\t..." and thus is
// different from the item's label which only contains the text shown
// in the menu
virtual void SetText(const wxString& str) { m_text = str; }
virtual wxString GetLabel() const { return m_text; }
const wxString& GetText() const { return m_text; }
// what kind of menu item we are
@@ -75,13 +85,24 @@ public:
// state
virtual void Enable(bool enable = TRUE) { m_isEnabled = enable; }
virtual bool IsEnabled() const { return m_isEnabled; }
virtual void Check(bool check = TRUE) { m_isChecked = check; }
virtual bool IsChecked() const { return m_isChecked; }
void Toggle() { Check(!m_isChecked); }
// help string (displayed in the status bar by default)
void SetHelp(const wxString& str) { m_help = str; }
const wxString& GetHelp() const { return m_help; }
#if wxUSE_ACCEL
// get our accelerator or NULL (caller must delete the pointer)
virtual wxAcceleratorEntry *GetAccel() const { return NULL; }
// set the accel for this item - this may also be done indirectly with
// SetText()
virtual void SetAccel(wxAcceleratorEntry *accel);
#endif // wxUSE_ACCEL
// compatibility only, use new functions in the new code
void SetName(const wxString& str) { SetText(str); }
const wxString& GetName() const { return GetText(); }

View File

@@ -16,179 +16,97 @@
#pragma interface "menu.h"
#endif
#include "wx/defs.h"
#include "wx/event.h"
#include "wx/dynarray.h"
#include "wx/string.h"
#if wxUSE_ACCEL
#include "wx/accel.h"
#include "wx/dynarray.h"
WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
#endif // wxUSE_ACCEL
class WXDLLEXPORT wxMenuItem;
class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxFrame;
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
// ----------------------------------------------------------------------------
// Menu
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMenu : public wxEvtHandler
class WXDLLEXPORT wxMenu : public wxMenuBase
{
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
// ctors & dtor
wxMenu(const wxString& title,
const wxFunction func)
{
Init(title, func);
}
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style) { Init(); }
wxMenu( long WXUNUSED(style) )
{
Init( wxEmptyString );
}
wxMenu(const wxString& title = wxEmptyString, long WXUNUSED(style) = 0)
{
Init(title);
}
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
virtual ~wxMenu();
// construct menu
// append a separator to the menu
void AppendSeparator();
// append a normal item to the menu
void Append(int id, const wxString& label,
const wxString& helpString = wxEmptyString,
bool checkable = FALSE);
// append a submenu
void Append(int id, const wxString& label,
wxMenu *submenu,
const wxString& helpString = wxEmptyString);
// append anything (create wxMenuItem first)
void Append(wxMenuItem *pItem);
// implement base class virtuals
virtual bool DoAppend(wxMenuItem *item);
virtual bool DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem *DoRemove(wxMenuItem *item);
// insert a break in the menu
void Break();
virtual void Break();
// delete an item
// If it's a submenu, menu is not destroyed.
// VZ: why? shouldn't it return "wxMenu *" then?
void Delete(int id);
// client data
void SetClientData(void* clientData) { m_clientData = clientData; }
void* GetClientData() const { return m_clientData; }
// menu item control
// enable/disable item
void Enable(int id, bool enable);
// TRUE if enabled
bool IsEnabled(int id) const;
// check/uncheck item - only for checkable items, of course
void Check(int id, bool check);
// TRUE if checked
bool IsChecked(int id) const;
// other properties
// the menu title
void SetTitle(const wxString& label);
const wxString GetTitle() const;
// the item label
void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const;
// help string
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const;
// get the list of items
wxList& GetItems() const { return (wxList &)m_menuItems; }
// find item
// returns id of the item matching the given string or wxNOT_FOUND
virtual int FindItem(const wxString& itemString) const;
// returns NULL if not found
wxMenuItem* FindItem(int id) const { return FindItemForId(id); }
// find wxMenuItem by ID, and item's menu too if itemMenu is !NULL
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
// Updates the UI for a menu and all submenus recursively. source is the
// object that has the update event handlers defined for it. If NULL, the
// menu or associated window will be used.
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*)NULL);
virtual void SetTitle(const wxString& title);
// MSW-specific
bool ProcessCommand(wxCommandEvent& event);
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
#ifdef WXWIN_COMPATIBILITY
wxMenu(const wxString& title, const wxFunction func)
: wxMenuBase(title)
{
Callback(func);
}
#endif // WXWIN_COMPATIBILITY
// implementation only from now on
// -------------------------------
// IMPLEMENTATION
bool MSWCommand(WXUINT param, WXWORD id);
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; }
// semi-private accessors
// get the window which contains this menu
wxWindow *GetWindow() const;
// get the menu handle
WXHMENU GetHMenu() const;
WXHMENU GetHMenu() const { return m_hMenu; }
// only for wxMenuBar
// attach/detach menu to/from wxMenuBar
void Attach(wxMenuBar *menubar);
void Detach();
#if wxUSE_ACCEL
// called by wxMenuBar to build its accel table from the accels of all menus
bool HasAccels() const { return !m_accels.IsEmpty(); }
size_t GetAccelCount() const { return m_accels.GetCount(); }
size_t CopyAccels(wxAcceleratorEntry *accels) const;
// called by wxMenuItem when its accels changes
void UpdateAccel(wxMenuItem *item);
// helper used by wxMenu itself (returns the index in m_accels)
int FindAccel(int id) const;
#endif // wxUSE_ACCEL
wxFunction GetCallback() const { return m_callback; }
void Callback(const wxFunction func) { m_callback = func; }
wxFunction m_callback;
#ifdef WXWIN_COMPATIBILITY
// compatibility: these functions are deprecated
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
#endif // WXWIN_COMPATIBILITY
private:
// common part of all ctors
void Init(const wxString& title, const wxFunction func = NULL );
void Init();
bool m_doBreak;
// common part of Append/Insert (behaves as Append is pos == (size_t)-1)
bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1);
// This is used when m_hMenu is NULL because we don't want to
// delete it in ~wxMenu (it's been added to a parent menu).
// But we'll still need the handle for other purposes.
// Might be better to have a flag saying whether it's deleteable or not.
WXHMENU m_savehMenu ; // Used for Enable() on popup
WXHMENU m_hMenu;
// if TRUE, insert a breal before appending the next item
bool m_doBreak;
int m_noItems;
wxString m_title;
wxMenu * m_topLevelMenu;
wxMenuBar * m_menuBar;
wxList m_menuItems;
wxEvtHandler * m_eventHandler;
wxWindow *m_pInvokingWindow;
void* m_clientData;
// the menu handle of this menu
WXHMENU m_hMenu;
#if wxUSE_ACCEL
// the accelerators for our menu items
wxAcceleratorArray m_accels;
#endif // wxUSE_ACCEL
DECLARE_DYNAMIC_CLASS(wxMenu)
};
// ----------------------------------------------------------------------------
@@ -243,8 +161,11 @@ public:
void Attach(wxFrame *frame);
#if wxUSE_ACCEL
// get the accel table for the menus
// get the accel table for all the menus
const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
// update the accel table (must be called after adding/deletign a menu)
void RebuildAccelTable();
#endif // wxUSE_ACCEL
// get the menu handle

View File

@@ -45,12 +45,17 @@ public:
// override base class virtuals
virtual void SetText(const wxString& strName);
virtual wxString GetLabel() const;
virtual void SetCheckable(bool checkable);
virtual void Enable(bool bDoEnable = TRUE);
virtual void Check(bool bDoCheck = TRUE);
virtual bool IsChecked() const;
#if wxUSE_ACCEL
virtual wxAcceleratorEntry *GetAccel() const;
#endif // wxUSE_ACCEL
// unfortunately needed to resolve ambiguity between
// wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); }
@@ -60,9 +65,6 @@ public:
// menu handle depending on what we're
int GetRealId() const;
// delete the submenu
void DeleteSubMenu();
private:
DECLARE_DYNAMIC_CLASS(wxMenuItem)
};