]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/menu.h
adding a more extensive version to arrive at the impl when given a native control...
[wxWidgets.git] / include / wx / gtk / menu.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/menu.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTKMENU_H_
11 #define _WX_GTKMENU_H_
12
13 //-----------------------------------------------------------------------------
14 // wxMenuBar
15 //-----------------------------------------------------------------------------
16
17 class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
18 {
19 public:
20 // ctors
21 wxMenuBar();
22 wxMenuBar(long style);
23 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
24 ~wxMenuBar();
25
26 // implement base class (pure) virtuals
27 virtual bool Append( wxMenu *menu, const wxString &title );
28 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
29 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
30 virtual wxMenu *Remove(size_t pos);
31
32 virtual int FindMenuItem(const wxString& menuString,
33 const wxString& itemString) const;
34 virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
35
36 virtual void EnableTop( size_t pos, bool flag );
37 virtual bool IsEnabledTop(size_t pos) const;
38 virtual void SetMenuLabel( size_t pos, const wxString& label );
39 virtual wxString GetMenuLabel( size_t pos ) const;
40
41 void SetLayoutDirection(wxLayoutDirection dir);
42 wxLayoutDirection GetLayoutDirection() const;
43
44 virtual void Attach(wxFrame *frame);
45 virtual void Detach();
46
47 private:
48 // common part of Append and Insert
49 void GtkAppend(wxMenu* menu, const wxString& title, int pos = -1);
50
51 void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
52
53 // wxMenuBar is not a top level window but it still doesn't need a parent
54 // window
55 virtual bool GTKNeedsParent() const { return false; }
56
57 GtkWidget* m_menubar;
58
59 DECLARE_DYNAMIC_CLASS(wxMenuBar)
60 };
61
62 //-----------------------------------------------------------------------------
63 // wxMenu
64 //-----------------------------------------------------------------------------
65
66 class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
67 {
68 public:
69 // ctors & dtor
70 wxMenu(const wxString& title, long style = 0)
71 : wxMenuBase(title, style) { Init(); }
72
73 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
74
75 virtual ~wxMenu();
76
77 void Attach(wxMenuBarBase *menubar);
78
79 void SetLayoutDirection(const wxLayoutDirection dir);
80 wxLayoutDirection GetLayoutDirection() const;
81
82 // Returns the title, with mnemonics translated to wx format
83 wxString GetTitle() const;
84
85 // TODO: virtual void SetTitle(const wxString& title);
86
87 // implementation GTK only
88 GtkWidget *m_menu; // GtkMenu
89 GtkWidget *m_owner;
90 GtkAccelGroup *m_accel;
91 bool m_popupShown;
92
93 protected:
94 virtual wxMenuItem* DoAppend(wxMenuItem *item);
95 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
96 virtual wxMenuItem* DoRemove(wxMenuItem *item);
97
98 private:
99 // common code for all constructors:
100 void Init();
101
102 // common part of Append (if pos == -1) and Insert
103 void GtkAppend(wxMenuItem* item, int pos = -1);
104
105
106 DECLARE_DYNAMIC_CLASS(wxMenu)
107 };
108
109 #endif
110 // _WX_GTKMENU_H_