]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/palmos/menu.h
Added wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT to fix tree and list control selection rendering.
[wxWidgets.git] / include / wx / palmos / menu.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/palmos/menu.h
3// Purpose: wxMenu, wxMenuBar classes
4// Author: William Osborne - minimal working wxPalmOS port
5// Modified by:
6// Created: 10/13/04
7// RCS-ID: $Id$
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MENU_H_
13#define _WX_MENU_H_
14
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
22class WXDLLIMPEXP_FWD_CORE wxFrame;
23
24#if defined(__WXWINCE__) && wxUSE_TOOLBAR
25class WXDLLIMPEXP_FWD_CORE wxToolBar;
26#endif
27
28#include "wx/arrstr.h"
29
30// ----------------------------------------------------------------------------
31// Menu
32// ----------------------------------------------------------------------------
33
34class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
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
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;
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
88 // if true, insert a break before appending the next item
89 bool m_doBreak;
90
91 // the position of the first item in the current radio group or -1
92 int m_startRadioGroup;
93
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
106class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
107{
108public:
109 // ctors & dtor
110 // default constructor
111 wxMenuBar();
112
113 wxMenuBar(long style);
114 // menubar takes ownership of the menus arrays but copies the titles
115 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
116 virtual ~wxMenuBar();
117
118 virtual bool Append( wxMenu *menu, const wxString &title );
119 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
120 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
121 virtual wxMenu *Remove(size_t pos);
122
123 virtual void EnableTop( size_t pos, bool flag );
124 virtual void SetMenuLabel( size_t pos, const wxString& label );
125 virtual wxString GetMenuLabel( size_t pos ) const;
126
127 // implementation from now on
128 WXHMENU Create();
129 virtual void Detach();
130 virtual void Attach(wxFrame *frame);
131
132 void LoadMenu();
133 int ProcessCommand(int ItemID);
134
135#if wxUSE_ACCEL
136 // get the accel table for all the menus
137 const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
138
139 // update the accel table (must be called after adding/deleting a menu)
140 void RebuildAccelTable();
141#endif // wxUSE_ACCEL
142
143 // if the menubar is modified, the display is not updated automatically,
144 // call this function to update it (m_menuBarFrame should be !NULL)
145 void Refresh();
146
147 // To avoid compile warning
148 void Refresh( bool eraseBackground,
149 const wxRect *rect = (const wxRect *) NULL ) { wxWindow::Refresh(eraseBackground, rect); }
150
151protected:
152 // common part of all ctors
153 void Init();
154
155 wxArrayString m_titles ;
156 wxMenuInfoList m_menuInfos;
157
158 // Return the Palm position for a wxMenu which is sometimes different from
159 // the wxWidgets position.
160 int PalmPositionForWxMenu(wxMenu *menu, int wxpos);
161#if wxUSE_ACCEL
162 // the accelerator table for all accelerators in all our menus
163 wxAcceleratorTable m_accelTable;
164#endif // wxUSE_ACCEL
165
166#if defined(__WXWINCE__) && wxUSE_TOOLBAR
167 wxToolBar* m_toolBar;
168#endif
169
170private:
171 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar)
172};
173
174#endif // _WX_MENU_H_