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