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