wxMenu code clean up
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1967 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,118 +39,148 @@ class wxMenu;
|
||||
// wxMenuBar
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenuBar: public wxWindow
|
||||
class wxMenuBar : public wxWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||
|
||||
public:
|
||||
wxMenuBar( long style );
|
||||
wxMenuBar();
|
||||
void Append( wxMenu *menu, const wxString &title );
|
||||
// ctors
|
||||
wxMenuBar();
|
||||
wxMenuBar(long style);
|
||||
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
||||
|
||||
int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
|
||||
wxMenuItem* FindMenuItemById( int id ) const;
|
||||
inline wxMenuItem* FindItemForId( int id ) const { return FindMenuItemById( id ); }
|
||||
|
||||
void Check( int id, bool check );
|
||||
bool Checked( int id ) const;
|
||||
void Enable( int id, bool enable );
|
||||
bool Enabled( int id ) const;
|
||||
inline bool IsEnabled( int id ) const { return Enabled(id); }
|
||||
inline bool IsChecked( int id ) const { return Checked(id); }
|
||||
|
||||
wxString GetLabel( int id ) const;
|
||||
void SetLabel( int id, const wxString &label );
|
||||
|
||||
void EnableTop( int pos, bool flag );
|
||||
void SetLabelTop( int pos, const wxString& label );
|
||||
wxString GetLabelTop( int pos ) const;
|
||||
// menubar construction
|
||||
void Append( wxMenu *menu, const wxString &title );
|
||||
|
||||
virtual void SetHelpString( int id, const wxString& helpString );
|
||||
virtual wxString GetHelpString( int id ) const;
|
||||
|
||||
inline int GetMenuCount() const { return m_menus.Number(); }
|
||||
inline wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
|
||||
// item search
|
||||
// by menu and item names, returns wxNOT_FOUND if not found
|
||||
virtual int FindMenuItem(const wxString& menuString,
|
||||
const wxString& itemString) const;
|
||||
// returns NULL if not found
|
||||
wxMenuItem* FindItem( int id ) const;
|
||||
// returns NULL if not found, fills menuForItem if !NULL
|
||||
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const;
|
||||
|
||||
wxList m_menus;
|
||||
GtkWidget *m_menubar;
|
||||
// state control
|
||||
void Check( int id, bool check );
|
||||
bool IsChecked( int id ) const;
|
||||
void Enable( int id, bool enable );
|
||||
bool IsEnabled( int id ) const;
|
||||
|
||||
wxString GetLabel( int id ) const;
|
||||
void SetLabel( int id, const wxString &label );
|
||||
|
||||
void EnableTop( int pos, bool flag );
|
||||
void SetLabelTop( int pos, const wxString& label );
|
||||
wxString GetLabelTop( int pos ) const;
|
||||
|
||||
virtual void SetHelpString( int id, const wxString& helpString );
|
||||
virtual wxString GetHelpString( int id ) const;
|
||||
|
||||
int GetMenuCount() const { return m_menus.Number(); }
|
||||
wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
|
||||
|
||||
#ifdef WXWIN_COMPATIBILITY
|
||||
// compatibility: these functions are deprecated
|
||||
bool Enabled(int id) const { return IsEnabled(id); }
|
||||
bool Checked(int id) const { return IsChecked(id); }
|
||||
|
||||
wxMenuItem* FindMenuItemById( int id ) const { return FindItem(id); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// implementation
|
||||
wxList& GetMenus() { return m_menus; }
|
||||
|
||||
protected:
|
||||
wxList m_menus;
|
||||
GtkWidget *m_menubar;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMenu
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenu: public wxEvtHandler
|
||||
class wxMenu : public wxEvtHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
|
||||
public:
|
||||
// construction
|
||||
wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL );
|
||||
// construction
|
||||
wxMenu( const wxString& title = wxEmptyString,
|
||||
const wxFunction func = (wxFunction) NULL );
|
||||
|
||||
// operations
|
||||
// title
|
||||
void SetTitle(const wxString& label);
|
||||
const wxString GetTitle() const;
|
||||
// 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() {};
|
||||
// operations
|
||||
// title
|
||||
void SetTitle(const wxString& label);
|
||||
const wxString GetTitle() const;
|
||||
// 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() { }
|
||||
|
||||
// find item by name/id
|
||||
int FindItem( const wxString itemString ) const;
|
||||
wxMenuItem *FindItem( int id ) const;
|
||||
wxMenuItem *FindItemForId( int id ) const { return FindItem( 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 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;
|
||||
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; }
|
||||
// helpstring
|
||||
virtual void SetHelpString(int id, const wxString& helpString);
|
||||
virtual wxString GetHelpString(int id) const ;
|
||||
|
||||
inline void Callback(const wxFunction func) { m_callback = func; }
|
||||
|
||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
|
||||
inline void SetClientData( void* clientData ) { m_clientData = clientData; }
|
||||
inline 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);
|
||||
// accessors
|
||||
wxList& GetItems() { return m_items; }
|
||||
|
||||
// implementation
|
||||
|
||||
int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
|
||||
void SetInvokingWindow( wxWindow *win );
|
||||
wxWindow *GetInvokingWindow();
|
||||
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
|
||||
wxString m_title;
|
||||
wxList m_items;
|
||||
wxWindow *m_invokingWindow;
|
||||
wxFunction m_callback;
|
||||
wxEvtHandler *m_eventHandler;
|
||||
void *m_clientData;
|
||||
void SetClientData( void* clientData ) { m_clientData = clientData; }
|
||||
void* GetClientData() const { return m_clientData; }
|
||||
|
||||
GtkWidget *m_menu; // GtkMenu
|
||||
GtkWidget *m_owner;
|
||||
// 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 ); }
|
||||
|
||||
#ifdef WXWIN_COMPATIBILITY
|
||||
wxFunction GetCallback() const { return m_callback; }
|
||||
void Callback(const wxFunction func) { m_callback = func; }
|
||||
|
||||
// compatibility: these functions are deprecated
|
||||
bool Enabled(int id) const { return IsEnabled(id); }
|
||||
bool Checked(int id) const { return IsChecked(id); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// implementation
|
||||
int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
|
||||
void SetInvokingWindow( wxWindow *win );
|
||||
wxWindow *GetInvokingWindow();
|
||||
|
||||
// implementation only
|
||||
GtkWidget *m_menu; // GtkMenu
|
||||
GtkWidget *m_owner;
|
||||
|
||||
private:
|
||||
wxString m_title;
|
||||
wxList m_items;
|
||||
wxWindow *m_invokingWindow;
|
||||
wxFunction m_callback;
|
||||
wxEvtHandler *m_eventHandler;
|
||||
void *m_clientData;
|
||||
};
|
||||
|
||||
#endif // __GTKMENUH__
|
||||
|
@@ -28,63 +28,65 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenuItem;
|
||||
|
||||
class wxMenu;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMenuItem
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenuItem: public wxObject
|
||||
class wxMenuItem : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuItem)
|
||||
|
||||
public:
|
||||
wxMenuItem();
|
||||
wxMenuItem();
|
||||
|
||||
// accessors
|
||||
// id
|
||||
void SetId(int id) { m_id = id; }
|
||||
int GetId() const { return m_id; }
|
||||
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
|
||||
// accessors
|
||||
// id
|
||||
void SetId(int id) { m_id = id; }
|
||||
int GetId() const { return m_id; }
|
||||
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
|
||||
|
||||
// the item's text = name
|
||||
void SetName(const wxString& str);
|
||||
void SetText(const wxString& str) { SetName(str); } // compatibility
|
||||
const wxString& GetName() const { return m_text; }
|
||||
const wxString& GetText() const { return GetName(); }
|
||||
// the item's text = name
|
||||
void SetName(const wxString& str);
|
||||
void SetText(const wxString& str) { SetName(str); } // compatibility
|
||||
const wxString& GetName() const { return m_text; }
|
||||
const wxString& GetText() const { return GetName(); }
|
||||
|
||||
// what kind of menu item we are
|
||||
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
|
||||
bool IsCheckable() const { return m_isCheckMenu; }
|
||||
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
||||
wxMenu *GetSubMenu() const { return m_subMenu; }
|
||||
bool IsSubMenu() const { return m_subMenu != NULL; }
|
||||
// what kind of menu item we are
|
||||
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
|
||||
bool IsCheckable() const { return m_isCheckMenu; }
|
||||
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
||||
wxMenu *GetSubMenu() const { return m_subMenu; }
|
||||
bool IsSubMenu() const { return m_subMenu != NULL; }
|
||||
|
||||
// state
|
||||
void Enable( bool enable = TRUE );
|
||||
bool IsEnabled() const { return m_isEnabled; }
|
||||
void Check( bool check = TRUE );
|
||||
bool IsChecked() const;
|
||||
// state
|
||||
void Enable( bool enable = TRUE );
|
||||
bool IsEnabled() const { return m_isEnabled; }
|
||||
void Check( bool check = TRUE );
|
||||
bool IsChecked() const;
|
||||
|
||||
// help string (displayed in the status bar by default)
|
||||
void SetHelp(const wxString& str) { m_helpStr = str; }
|
||||
const wxString& GetHelp() const { return m_helpStr; }
|
||||
// help string (displayed in the status bar by default)
|
||||
void SetHelp(const wxString& str) { m_helpStr = str; }
|
||||
const wxString& GetHelp() const { return m_helpStr; }
|
||||
|
||||
// implementation
|
||||
|
||||
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
|
||||
GtkWidget *GetMenuItem() const { return m_menuItem; }
|
||||
// implementation
|
||||
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
|
||||
GtkWidget *GetMenuItem() const { return m_menuItem; }
|
||||
|
||||
int m_id;
|
||||
wxString m_text;
|
||||
bool m_isCheckMenu;
|
||||
bool m_isChecked;
|
||||
bool m_isEnabled;
|
||||
wxMenu *m_subMenu;
|
||||
wxString m_helpStr;
|
||||
void SetCheckedFlag(bool checked) { m_isChecked = checked; }
|
||||
bool GetCheckedFlag() const { return m_isChecked; }
|
||||
|
||||
GtkWidget *m_menuItem; // GtkMenuItem
|
||||
private:
|
||||
int m_id;
|
||||
wxString m_text;
|
||||
bool m_isCheckMenu;
|
||||
bool m_isChecked;
|
||||
bool m_isEnabled;
|
||||
wxMenu *m_subMenu;
|
||||
wxString m_helpStr;
|
||||
|
||||
GtkWidget *m_menuItem; // GtkMenuItem
|
||||
};
|
||||
|
||||
|
||||
|
@@ -39,118 +39,148 @@ class wxMenu;
|
||||
// wxMenuBar
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenuBar: public wxWindow
|
||||
class wxMenuBar : public wxWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||
|
||||
public:
|
||||
wxMenuBar( long style );
|
||||
wxMenuBar();
|
||||
void Append( wxMenu *menu, const wxString &title );
|
||||
// ctors
|
||||
wxMenuBar();
|
||||
wxMenuBar(long style);
|
||||
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
||||
|
||||
int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
|
||||
wxMenuItem* FindMenuItemById( int id ) const;
|
||||
inline wxMenuItem* FindItemForId( int id ) const { return FindMenuItemById( id ); }
|
||||
|
||||
void Check( int id, bool check );
|
||||
bool Checked( int id ) const;
|
||||
void Enable( int id, bool enable );
|
||||
bool Enabled( int id ) const;
|
||||
inline bool IsEnabled( int id ) const { return Enabled(id); }
|
||||
inline bool IsChecked( int id ) const { return Checked(id); }
|
||||
|
||||
wxString GetLabel( int id ) const;
|
||||
void SetLabel( int id, const wxString &label );
|
||||
|
||||
void EnableTop( int pos, bool flag );
|
||||
void SetLabelTop( int pos, const wxString& label );
|
||||
wxString GetLabelTop( int pos ) const;
|
||||
// menubar construction
|
||||
void Append( wxMenu *menu, const wxString &title );
|
||||
|
||||
virtual void SetHelpString( int id, const wxString& helpString );
|
||||
virtual wxString GetHelpString( int id ) const;
|
||||
|
||||
inline int GetMenuCount() const { return m_menus.Number(); }
|
||||
inline wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
|
||||
// item search
|
||||
// by menu and item names, returns wxNOT_FOUND if not found
|
||||
virtual int FindMenuItem(const wxString& menuString,
|
||||
const wxString& itemString) const;
|
||||
// returns NULL if not found
|
||||
wxMenuItem* FindItem( int id ) const;
|
||||
// returns NULL if not found, fills menuForItem if !NULL
|
||||
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const;
|
||||
|
||||
wxList m_menus;
|
||||
GtkWidget *m_menubar;
|
||||
// state control
|
||||
void Check( int id, bool check );
|
||||
bool IsChecked( int id ) const;
|
||||
void Enable( int id, bool enable );
|
||||
bool IsEnabled( int id ) const;
|
||||
|
||||
wxString GetLabel( int id ) const;
|
||||
void SetLabel( int id, const wxString &label );
|
||||
|
||||
void EnableTop( int pos, bool flag );
|
||||
void SetLabelTop( int pos, const wxString& label );
|
||||
wxString GetLabelTop( int pos ) const;
|
||||
|
||||
virtual void SetHelpString( int id, const wxString& helpString );
|
||||
virtual wxString GetHelpString( int id ) const;
|
||||
|
||||
int GetMenuCount() const { return m_menus.Number(); }
|
||||
wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
|
||||
|
||||
#ifdef WXWIN_COMPATIBILITY
|
||||
// compatibility: these functions are deprecated
|
||||
bool Enabled(int id) const { return IsEnabled(id); }
|
||||
bool Checked(int id) const { return IsChecked(id); }
|
||||
|
||||
wxMenuItem* FindMenuItemById( int id ) const { return FindItem(id); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// implementation
|
||||
wxList& GetMenus() { return m_menus; }
|
||||
|
||||
protected:
|
||||
wxList m_menus;
|
||||
GtkWidget *m_menubar;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMenu
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenu: public wxEvtHandler
|
||||
class wxMenu : public wxEvtHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
|
||||
public:
|
||||
// construction
|
||||
wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL );
|
||||
// construction
|
||||
wxMenu( const wxString& title = wxEmptyString,
|
||||
const wxFunction func = (wxFunction) NULL );
|
||||
|
||||
// operations
|
||||
// title
|
||||
void SetTitle(const wxString& label);
|
||||
const wxString GetTitle() const;
|
||||
// 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() {};
|
||||
// operations
|
||||
// title
|
||||
void SetTitle(const wxString& label);
|
||||
const wxString GetTitle() const;
|
||||
// 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() { }
|
||||
|
||||
// find item by name/id
|
||||
int FindItem( const wxString itemString ) const;
|
||||
wxMenuItem *FindItem( int id ) const;
|
||||
wxMenuItem *FindItemForId( int id ) const { return FindItem( 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 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;
|
||||
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; }
|
||||
// helpstring
|
||||
virtual void SetHelpString(int id, const wxString& helpString);
|
||||
virtual wxString GetHelpString(int id) const ;
|
||||
|
||||
inline void Callback(const wxFunction func) { m_callback = func; }
|
||||
|
||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
|
||||
inline void SetClientData( void* clientData ) { m_clientData = clientData; }
|
||||
inline 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);
|
||||
// accessors
|
||||
wxList& GetItems() { return m_items; }
|
||||
|
||||
// implementation
|
||||
|
||||
int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
|
||||
void SetInvokingWindow( wxWindow *win );
|
||||
wxWindow *GetInvokingWindow();
|
||||
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
|
||||
wxString m_title;
|
||||
wxList m_items;
|
||||
wxWindow *m_invokingWindow;
|
||||
wxFunction m_callback;
|
||||
wxEvtHandler *m_eventHandler;
|
||||
void *m_clientData;
|
||||
void SetClientData( void* clientData ) { m_clientData = clientData; }
|
||||
void* GetClientData() const { return m_clientData; }
|
||||
|
||||
GtkWidget *m_menu; // GtkMenu
|
||||
GtkWidget *m_owner;
|
||||
// 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 ); }
|
||||
|
||||
#ifdef WXWIN_COMPATIBILITY
|
||||
wxFunction GetCallback() const { return m_callback; }
|
||||
void Callback(const wxFunction func) { m_callback = func; }
|
||||
|
||||
// compatibility: these functions are deprecated
|
||||
bool Enabled(int id) const { return IsEnabled(id); }
|
||||
bool Checked(int id) const { return IsChecked(id); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// implementation
|
||||
int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
|
||||
void SetInvokingWindow( wxWindow *win );
|
||||
wxWindow *GetInvokingWindow();
|
||||
|
||||
// implementation only
|
||||
GtkWidget *m_menu; // GtkMenu
|
||||
GtkWidget *m_owner;
|
||||
|
||||
private:
|
||||
wxString m_title;
|
||||
wxList m_items;
|
||||
wxWindow *m_invokingWindow;
|
||||
wxFunction m_callback;
|
||||
wxEvtHandler *m_eventHandler;
|
||||
void *m_clientData;
|
||||
};
|
||||
|
||||
#endif // __GTKMENUH__
|
||||
|
@@ -28,63 +28,65 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenuItem;
|
||||
|
||||
class wxMenu;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMenuItem
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMenuItem: public wxObject
|
||||
class wxMenuItem : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuItem)
|
||||
|
||||
public:
|
||||
wxMenuItem();
|
||||
wxMenuItem();
|
||||
|
||||
// accessors
|
||||
// id
|
||||
void SetId(int id) { m_id = id; }
|
||||
int GetId() const { return m_id; }
|
||||
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
|
||||
// accessors
|
||||
// id
|
||||
void SetId(int id) { m_id = id; }
|
||||
int GetId() const { return m_id; }
|
||||
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
|
||||
|
||||
// the item's text = name
|
||||
void SetName(const wxString& str);
|
||||
void SetText(const wxString& str) { SetName(str); } // compatibility
|
||||
const wxString& GetName() const { return m_text; }
|
||||
const wxString& GetText() const { return GetName(); }
|
||||
// the item's text = name
|
||||
void SetName(const wxString& str);
|
||||
void SetText(const wxString& str) { SetName(str); } // compatibility
|
||||
const wxString& GetName() const { return m_text; }
|
||||
const wxString& GetText() const { return GetName(); }
|
||||
|
||||
// what kind of menu item we are
|
||||
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
|
||||
bool IsCheckable() const { return m_isCheckMenu; }
|
||||
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
||||
wxMenu *GetSubMenu() const { return m_subMenu; }
|
||||
bool IsSubMenu() const { return m_subMenu != NULL; }
|
||||
// what kind of menu item we are
|
||||
void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
|
||||
bool IsCheckable() const { return m_isCheckMenu; }
|
||||
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
||||
wxMenu *GetSubMenu() const { return m_subMenu; }
|
||||
bool IsSubMenu() const { return m_subMenu != NULL; }
|
||||
|
||||
// state
|
||||
void Enable( bool enable = TRUE );
|
||||
bool IsEnabled() const { return m_isEnabled; }
|
||||
void Check( bool check = TRUE );
|
||||
bool IsChecked() const;
|
||||
// state
|
||||
void Enable( bool enable = TRUE );
|
||||
bool IsEnabled() const { return m_isEnabled; }
|
||||
void Check( bool check = TRUE );
|
||||
bool IsChecked() const;
|
||||
|
||||
// help string (displayed in the status bar by default)
|
||||
void SetHelp(const wxString& str) { m_helpStr = str; }
|
||||
const wxString& GetHelp() const { return m_helpStr; }
|
||||
// help string (displayed in the status bar by default)
|
||||
void SetHelp(const wxString& str) { m_helpStr = str; }
|
||||
const wxString& GetHelp() const { return m_helpStr; }
|
||||
|
||||
// implementation
|
||||
|
||||
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
|
||||
GtkWidget *GetMenuItem() const { return m_menuItem; }
|
||||
// implementation
|
||||
void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
|
||||
GtkWidget *GetMenuItem() const { return m_menuItem; }
|
||||
|
||||
int m_id;
|
||||
wxString m_text;
|
||||
bool m_isCheckMenu;
|
||||
bool m_isChecked;
|
||||
bool m_isEnabled;
|
||||
wxMenu *m_subMenu;
|
||||
wxString m_helpStr;
|
||||
void SetCheckedFlag(bool checked) { m_isChecked = checked; }
|
||||
bool GetCheckedFlag() const { return m_isChecked; }
|
||||
|
||||
GtkWidget *m_menuItem; // GtkMenuItem
|
||||
private:
|
||||
int m_id;
|
||||
wxString m_text;
|
||||
bool m_isCheckMenu;
|
||||
bool m_isChecked;
|
||||
bool m_isEnabled;
|
||||
wxMenu *m_subMenu;
|
||||
wxString m_helpStr;
|
||||
|
||||
GtkWidget *m_menuItem; // GtkMenuItem
|
||||
};
|
||||
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#define _WX_MENU_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "menu.h"
|
||||
#pragma interface "menu.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
@@ -22,171 +22,212 @@
|
||||
class WXDLLEXPORT wxMenuItem;
|
||||
class WXDLLEXPORT wxMenuBar;
|
||||
class WXDLLEXPORT wxMenu;
|
||||
class WXDLLEXPORT wxFrame;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Menu
|
||||
// ----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxMenu: public wxEvtHandler
|
||||
|
||||
class WXDLLEXPORT wxMenu : public wxEvtHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
|
||||
public:
|
||||
// ctor & dtor
|
||||
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
|
||||
~wxMenu();
|
||||
// ctor & dtor
|
||||
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
|
||||
virtual ~wxMenu();
|
||||
|
||||
// construct menu
|
||||
// append items to the menu
|
||||
// separator line
|
||||
void AppendSeparator();
|
||||
// normal item
|
||||
void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
|
||||
bool checkable = FALSE);
|
||||
// a submenu
|
||||
void Append(int id, const wxString& Label, wxMenu *SubMenu,
|
||||
const wxString& helpString = wxEmptyString);
|
||||
// the most generic form (create wxMenuItem first and use it's functions)
|
||||
void Append(wxMenuItem *pItem);
|
||||
// insert a break in the menu
|
||||
void Break();
|
||||
// delete an item
|
||||
void Delete(int id); /* If it's a submenu, menu is not destroyed. VZ: why? */
|
||||
// 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);
|
||||
|
||||
// Client data
|
||||
inline void SetClientData(void* clientData) { m_clientData = clientData; }
|
||||
inline void* GetClientData() const { return m_clientData; }
|
||||
// insert a break in the menu
|
||||
void Break();
|
||||
|
||||
// menu item control
|
||||
void Enable(int id, bool Flag);
|
||||
bool Enabled(int id) const;
|
||||
inline bool IsEnabled(int id) const { return Enabled(id); };
|
||||
void Check(int id, bool Flag);
|
||||
bool Checked(int id) const;
|
||||
inline bool IsChecked(int id) const { return Checked(id); };
|
||||
// delete an item
|
||||
// If it's a submenu, menu is not destroyed.
|
||||
// VZ: why? shouldn't it return "wxMenu *" then?
|
||||
void Delete(int id);
|
||||
|
||||
// item properties
|
||||
// title
|
||||
void SetTitle(const wxString& label);
|
||||
const wxString GetTitle() const;
|
||||
// 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 ;
|
||||
// client data
|
||||
void SetClientData(void* clientData) { m_clientData = clientData; }
|
||||
void* GetClientData() const { return m_clientData; }
|
||||
|
||||
// find item
|
||||
// Finds the item id matching the given string, wxNOT_FOUND if not found.
|
||||
virtual int FindItem(const wxString& itemString) const ;
|
||||
// Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL.
|
||||
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
|
||||
// menu item control
|
||||
// enable/disable item
|
||||
void Enable(int id, bool enable);
|
||||
// TRUE if enabled
|
||||
bool IsEnabled(int id) 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);
|
||||
// check/uncheck item - only for checkable items, of course
|
||||
void Check(int id, bool check);
|
||||
// TRUE if checked
|
||||
bool IsChecked(int id) const;
|
||||
|
||||
void ProcessCommand(wxCommandEvent& event);
|
||||
inline void Callback(const wxFunction func) { m_callback = func; }
|
||||
// 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;
|
||||
|
||||
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
|
||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
// get the list of items
|
||||
wxList& GetItems() const { return (wxList &)m_menuItems; }
|
||||
|
||||
inline 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;
|
||||
|
||||
// IMPLEMENTATION
|
||||
bool MSWCommand(WXUINT param, WXWORD id);
|
||||
// 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);
|
||||
|
||||
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
|
||||
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; }
|
||||
void ProcessCommand(wxCommandEvent& event);
|
||||
|
||||
// semi-private accessors
|
||||
// get the window which contains this menu
|
||||
wxWindow *GetWindow() const;
|
||||
// get the menu handle
|
||||
WXHMENU GetHMenu() const;
|
||||
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
|
||||
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
|
||||
|
||||
#ifdef WXWIN_COMPATIBILITY
|
||||
void Callback(const wxFunction func) { m_callback = func; }
|
||||
|
||||
// compatibility: these functions are deprecated
|
||||
bool Enabled(int id) const { return IsEnabled(id); }
|
||||
bool Checked(int id) const { return IsChecked(id); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
// 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;
|
||||
|
||||
private:
|
||||
bool m_doBreak ;
|
||||
bool m_doBreak ;
|
||||
|
||||
public:
|
||||
// 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;
|
||||
wxFunction m_callback;
|
||||
// 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;
|
||||
wxFunction m_callback;
|
||||
|
||||
int m_noItems;
|
||||
wxString m_title;
|
||||
wxMenu * m_topLevelMenu;
|
||||
wxMenuBar * m_menuBar;
|
||||
wxList m_menuItems;
|
||||
wxEvtHandler * m_parent;
|
||||
wxEvtHandler * m_eventHandler;
|
||||
wxWindow *m_pInvokingWindow;
|
||||
void* m_clientData;
|
||||
int m_noItems;
|
||||
wxString m_title;
|
||||
wxMenu * m_topLevelMenu;
|
||||
wxMenuBar * m_menuBar;
|
||||
wxList m_menuItems;
|
||||
wxEvtHandler * m_parent;
|
||||
wxEvtHandler * m_eventHandler;
|
||||
wxWindow *m_pInvokingWindow;
|
||||
void* m_clientData;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Menu Bar (a la Windows)
|
||||
// ----------------------------------------------------------------------------
|
||||
class WXDLLEXPORT wxFrame;
|
||||
class WXDLLEXPORT wxMenuBar: public wxEvtHandler
|
||||
|
||||
class WXDLLEXPORT wxMenuBar : public wxEvtHandler
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||
|
||||
public:
|
||||
wxMenuBar();
|
||||
wxMenuBar( long style );
|
||||
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
||||
~wxMenuBar();
|
||||
// ctors & dtor
|
||||
wxMenuBar();
|
||||
wxMenuBar(long style);
|
||||
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
||||
virtual ~wxMenuBar();
|
||||
|
||||
void Append(wxMenu *menu, const wxString& title);
|
||||
// Must only be used AFTER menu has been attached to frame,
|
||||
// otherwise use individual menus to enable/disable items
|
||||
void Enable(int Id, bool Flag);
|
||||
bool Enabled(int Id) const ;
|
||||
inline bool IsEnabled(int Id) const { return Enabled(Id); };
|
||||
void EnableTop(int pos, bool Flag);
|
||||
void Check(int id, bool Flag);
|
||||
bool Checked(int id) const ;
|
||||
inline bool IsChecked(int Id) const { return Checked(Id); };
|
||||
void SetLabel(int id, const wxString& label) ;
|
||||
wxString GetLabel(int id) const ;
|
||||
void SetLabelTop(int pos, const wxString& label) ;
|
||||
wxString GetLabelTop(int pos) const ;
|
||||
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
|
||||
virtual bool OnAppend(wxMenu *menu, const char *title);
|
||||
virtual bool OnDelete(wxMenu *menu, int index);
|
||||
// menubar construction
|
||||
void Append(wxMenu *menu, const wxString& title);
|
||||
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
|
||||
|
||||
virtual void SetHelpString(int Id, const wxString& helpString);
|
||||
virtual wxString GetHelpString(int Id) const ;
|
||||
// state control
|
||||
// NB: must only be used AFTER menu has been attached to frame,
|
||||
// otherwise use individual menus to enable/disable items
|
||||
// enable the item
|
||||
void Enable(int id, bool enable);
|
||||
// TRUE if item enabled
|
||||
bool IsEnabled(int id) const;
|
||||
//
|
||||
void EnableTop(int pos, bool enable);
|
||||
|
||||
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
|
||||
// works only with checkable items
|
||||
void Check(int id, bool check);
|
||||
// TRUE if checked
|
||||
bool IsChecked(int id) const;
|
||||
|
||||
// Find wxMenuItem for item ID, and return item's
|
||||
// menu too if itemMenu is non-NULL.
|
||||
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
|
||||
void SetLabel(int id, const wxString& label) ;
|
||||
wxString GetLabel(int id) const ;
|
||||
|
||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
virtual void SetHelpString(int id, const wxString& helpString);
|
||||
virtual wxString GetHelpString(int id) const ;
|
||||
|
||||
inline int GetMenuCount() const { return m_menuCount; }
|
||||
inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
|
||||
void SetLabelTop(int pos, const wxString& label) ;
|
||||
wxString GetLabelTop(int pos) const ;
|
||||
|
||||
public:
|
||||
wxEvtHandler * m_eventHandler;
|
||||
int m_menuCount;
|
||||
wxMenu ** m_menus;
|
||||
wxString * m_titles;
|
||||
wxFrame * m_menuBarFrame;
|
||||
WXHMENU m_hMenu;
|
||||
// notifications
|
||||
virtual bool OnAppend(wxMenu *menu, const char *title);
|
||||
virtual bool OnDelete(wxMenu *menu, int index);
|
||||
|
||||
// item search
|
||||
// by menu and item names, returns wxNOT_FOUND if not found
|
||||
virtual int FindMenuItem(const wxString& menuString,
|
||||
const wxString& itemString) const;
|
||||
// returns NULL if not found
|
||||
wxMenuItem* FindItem(int id) const { return FindItemForId(id); }
|
||||
// returns NULL if not found, fills menuForItem if !NULL
|
||||
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const;
|
||||
|
||||
// submenus access
|
||||
int GetMenuCount() const { return m_menuCount; }
|
||||
wxMenu *GetMenu(int i) const { return m_menus[i]; }
|
||||
|
||||
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
|
||||
#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
|
||||
|
||||
public:
|
||||
wxEvtHandler * m_eventHandler;
|
||||
int m_menuCount;
|
||||
wxMenu ** m_menus;
|
||||
wxString * m_titles;
|
||||
wxFrame * m_menuBarFrame;
|
||||
WXHMENU m_hMenu;
|
||||
};
|
||||
|
||||
#endif // _WX_MENU_H_
|
||||
|
@@ -2,7 +2,7 @@
|
||||
// Name: menuitem.h
|
||||
// Purpose: wxMenuItem class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Modified by:
|
||||
// Created: 11.11.97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
@@ -13,7 +13,7 @@
|
||||
#define _MENUITEM_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "menuitem.h"
|
||||
#pragma interface "menuitem.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -26,7 +26,7 @@
|
||||
// headers - only because ownerdrw.h is not always included and I don't want
|
||||
// to write #ifdef's everywhere...
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
#include "wx/ownerdrw.h"
|
||||
#include "wx/ownerdrw.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user