]> git.saurik.com Git - wxWidgets.git/blame - include/wx/palmos/menu.h
compilation fix for WXWIN_COMPATIBILITY_2_2 (bug 1252476)
[wxWidgets.git] / include / wx / palmos / menu.h
CommitLineData
ffecfa5a
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/palmos/menu.h
3// Purpose: wxMenu, wxMenuBar classes
e1d63b79 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/04
e1d63b79 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MENU_H_
13#define _WX_MENU_H_
14
15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "menu.h"
17#endif
18
19#if wxUSE_ACCEL
20 #include "wx/accel.h"
21 #include "wx/dynarray.h"
22
23 WX_DEFINE_EXPORTED_ARRAY_PTR(wxAcceleratorEntry *, wxAcceleratorArray);
24#endif // wxUSE_ACCEL
25
26class WXDLLEXPORT wxFrame;
27
28#if defined(__WXWINCE__) && wxUSE_TOOLBAR
29class WXDLLEXPORT wxToolBar;
30#endif
31
32#include "wx/arrstr.h"
33
34// ----------------------------------------------------------------------------
35// Menu
36// ----------------------------------------------------------------------------
37
38class WXDLLEXPORT wxMenu : public wxMenuBase
39{
40public:
41 // ctors & dtor
42 wxMenu(const wxString& title, long style = 0)
43 : wxMenuBase(title, style) { Init(); }
44
45 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
46
47 virtual ~wxMenu();
48
49 // implement base class virtuals
50 virtual wxMenuItem* DoAppend(wxMenuItem *item);
51 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
52 virtual wxMenuItem* DoRemove(wxMenuItem *item);
53
54 virtual void Break();
55
56 virtual void SetTitle(const wxString& title);
57
ffecfa5a
JS
58 // implementation only from now on
59 // -------------------------------
60
61 virtual void Attach(wxMenuBarBase *menubar);
62
63 bool PalmCommand(WXUINT param, WXWORD id);
64
65 // semi-private accessors
66 // get the window which contains this menu
67 wxWindow *GetWindow() const;
ffecfa5a
JS
68
69#if wxUSE_ACCEL
70 // called by wxMenuBar to build its accel table from the accels of all menus
71 bool HasAccels() const { return !m_accels.IsEmpty(); }
72 size_t GetAccelCount() const { return m_accels.GetCount(); }
73 size_t CopyAccels(wxAcceleratorEntry *accels) const;
74
75 // called by wxMenuItem when its accels changes
76 void UpdateAccel(wxMenuItem *item);
77
78 // helper used by wxMenu itself (returns the index in m_accels)
79 int FindAccel(int id) const;
80#endif // wxUSE_ACCEL
81
82private:
83 // common part of all ctors
84 void Init();
85
86 // common part of Append/Insert (behaves as Append is pos == (size_t)-1)
87 bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1);
88
89 // terminate the current radio group, if any
90 void EndRadioGroup();
91
4055ed82 92 // if true, insert a break before appending the next item
ffecfa5a
JS
93 bool m_doBreak;
94
95 // the position of the first item in the current radio group or -1
96 int m_startRadioGroup;
97
ffecfa5a
JS
98#if wxUSE_ACCEL
99 // the accelerators for our menu items
100 wxAcceleratorArray m_accels;
101#endif // wxUSE_ACCEL
102
103 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenu)
104};
105
106// ----------------------------------------------------------------------------
107// Menu Bar (a la Windows)
108// ----------------------------------------------------------------------------
109
110class WXDLLEXPORT wxMenuInfo : public wxObject
111{
112public :
113 wxMenuInfo() { m_menu = NULL ; }
114 virtual ~wxMenuInfo() { }
115
4055ed82 116 void Create( wxMenu *menu , const wxString &title )
ffecfa5a
JS
117 { m_menu = menu ; m_title = title ; }
118 wxMenu* GetMenu() const { return m_menu ; }
119 wxString GetTitle() const { return m_title ; }
120private :
121 wxMenu *m_menu ;
122 wxString m_title ;
123
124 DECLARE_DYNAMIC_CLASS(wxMenuInfo) ;
125} ;
126
127WX_DECLARE_EXPORTED_LIST(wxMenuInfo, wxMenuInfoList );
128
129class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
130{
131public:
4055ed82 132 // ctors & dtor
ffecfa5a
JS
133 // default constructor
134 wxMenuBar();
135
136 wxMenuBar(long style);
137 // menubar takes ownership of the menus arrays but copies the titles
294ea16d 138 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
ffecfa5a
JS
139 virtual ~wxMenuBar();
140
141 // menubar construction
142 bool Append( wxMenuInfo *info ) { return Append( info->GetMenu() , info->GetTitle() ) ; }
143 const wxMenuInfoList& GetMenuInfos() const ;
144
145 virtual bool Append( wxMenu *menu, const wxString &title );
146 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
147 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
148 virtual wxMenu *Remove(size_t pos);
149
150 virtual void EnableTop( size_t pos, bool flag );
151 virtual void SetLabelTop( size_t pos, const wxString& label );
152 virtual wxString GetLabelTop( size_t pos ) const;
153
154 // implementation from now on
155 WXHMENU Create();
156 virtual void Detach();
157 virtual void Attach(wxFrame *frame);
158
159 void LoadMenu();
160 int ProcessCommand(int ItemID);
161
ffecfa5a
JS
162#if wxUSE_ACCEL
163 // get the accel table for all the menus
164 const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
165
3103e8a9 166 // update the accel table (must be called after adding/deleting a menu)
ffecfa5a
JS
167 void RebuildAccelTable();
168#endif // wxUSE_ACCEL
169
ffecfa5a
JS
170 // if the menubar is modified, the display is not updated automatically,
171 // call this function to update it (m_menuBarFrame should be !NULL)
172 void Refresh();
173
174 // To avoid compile warning
175 void Refresh( bool eraseBackground,
176 const wxRect *rect = (const wxRect *) NULL ) { wxWindow::Refresh(eraseBackground, rect); }
177
178protected:
179 // common part of all ctors
180 void Init();
181
182 wxArrayString m_titles ;
183 wxMenuInfoList m_menuInfos;
184
ffecfa5a
JS
185 // Return the Palm position for a wxMenu which is sometimes different from
186 // the wxWidgets position.
187 int PalmPositionForWxMenu(wxMenu *menu, int wxpos);
188#if wxUSE_ACCEL
189 // the accelerator table for all accelerators in all our menus
190 wxAcceleratorTable m_accelTable;
191#endif // wxUSE_ACCEL
192
193#if defined(__WXWINCE__) && wxUSE_TOOLBAR
194 wxToolBar* m_toolBar;
195#endif
ffecfa5a
JS
196
197private:
198 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar)
199};
200
201#endif // _WX_MENU_H_