]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/motif/menu.h
Fix wrong tab order in wxAuiNotebook after dragging.
[wxWidgets.git] / include / wx / motif / menu.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/motif/menu.h
3// Purpose: wxMenu, wxMenuBar classes
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MOTIF_MENU_H_
13#define _WX_MOTIF_MENU_H_
14
15#include "wx/colour.h"
16#include "wx/font.h"
17#include "wx/arrstr.h"
18
19class WXDLLIMPEXP_FWD_CORE wxFrame;
20
21// ----------------------------------------------------------------------------
22// Menu
23// ----------------------------------------------------------------------------
24
25class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
26{
27public:
28 // ctors & dtor
29 wxMenu(const wxString& title, long style = 0)
30 : wxMenuBase(title, style) { Init(); }
31
32 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
33
34 virtual ~wxMenu();
35
36 // implement base class virtuals
37 virtual wxMenuItem* DoAppend(wxMenuItem *item);
38 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
39 virtual wxMenuItem* DoRemove(wxMenuItem *item);
40
41 virtual void Break();
42
43 virtual void SetTitle(const wxString& title);
44
45 bool ProcessCommand(wxCommandEvent& event);
46
47 //// Motif-specific
48 WXWidget GetButtonWidget() const { return m_buttonWidget; }
49 void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
50
51 WXWidget GetMainWidget() const { return m_menuWidget; }
52
53 int GetId() const { return m_menuId; }
54 void SetId(int id) { m_menuId = id; }
55
56 void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
57 wxMenuBar* GetMenuBar() const { return m_menuBar; }
58
59 void CreatePopup(WXWidget logicalParent, int x, int y);
60 void DestroyPopup();
61 void ShowPopup(int x, int y);
62 void HidePopup();
63
64 WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu,
65 size_t index, const wxString& title = wxEmptyString,
66 bool isPulldown = false);
67
68 // For popups, need to destroy, then recreate menu for a different (or
69 // possibly same) window, since the parent may change.
70 void DestroyMenu(bool full);
71 WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const;
72
73 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
74 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
75 const wxFont& GetFont() const { return m_font; }
76
77 void SetBackgroundColour(const wxColour& colour);
78 void SetForegroundColour(const wxColour& colour);
79 void SetFont(const wxFont& colour);
80 void ChangeFont(bool keepOriginalSize = false);
81
82 WXWidget GetHandle() const { return m_menuWidget; }
83
84 bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
85
86 void DestroyWidgetAndDetach();
87public:
88 // Motif-specific data
89 int m_numColumns;
90 WXWidget m_menuWidget;
91 WXWidget m_popupShell; // For holding the popup shell widget
92 WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
93 int m_menuId;
94 wxMenu* m_topLevelMenu ;
95 bool m_ownedByMenuBar;
96 wxColour m_foregroundColour;
97 wxColour m_backgroundColour;
98 wxFont m_font;
99
100private:
101 // common code for both constructors:
102 void Init();
103
104 DECLARE_DYNAMIC_CLASS(wxMenu)
105};
106
107// ----------------------------------------------------------------------------
108// Menu Bar
109// ----------------------------------------------------------------------------
110
111class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
112{
113public:
114 wxMenuBar() { Init(); }
115 wxMenuBar(long WXUNUSED(style)) { Init(); }
116 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
117 wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long style = 0);
118 virtual ~wxMenuBar();
119
120 // implement base class (pure) virtuals
121 // ------------------------------------
122
123 virtual bool Append( wxMenu *menu, const wxString &title );
124 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
125 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
126 virtual wxMenu *Remove(size_t pos);
127
128 virtual int FindMenuItem(const wxString& menuString,
129 const wxString& itemString) const;
130 virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
131
132 virtual void EnableTop( size_t pos, bool flag );
133 virtual void SetMenuLabel( size_t pos, const wxString& label );
134 virtual wxString GetMenuLabel( size_t pos ) const;
135
136 // implementation only from now on
137 // -------------------------------
138
139 wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
140 void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
141 WXWidget GetMainWidget() const { return m_mainWidget; }
142 void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
143
144 // Create menubar
145 bool CreateMenuBar(wxFrame* frame);
146
147 // Destroy menubar, but keep data structures intact so we can recreate it.
148 bool DestroyMenuBar();
149
150 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
151 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
152 const wxFont& GetFont() const { return m_font; }
153
154 virtual bool SetBackgroundColour(const wxColour& colour);
155 virtual bool SetForegroundColour(const wxColour& colour);
156 virtual bool SetFont(const wxFont& colour);
157 void ChangeFont(bool keepOriginalSize = false);
158
159public:
160 // common part of all ctors
161 void Init();
162
163 wxArrayString m_titles;
164 wxFrame *m_menuBarFrame;
165
166 WXWidget m_mainWidget;
167
168 wxColour m_foregroundColour;
169 wxColour m_backgroundColour;
170 wxFont m_font;
171
172 DECLARE_DYNAMIC_CLASS(wxMenuBar)
173};
174
175#endif // _WX_MOTIF_MENU_H_