]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/menuitem.h
Added wxNB_FLAT for WinCE property sheet tabs
[wxWidgets.git] / include / wx / univ / menuitem.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/menuitem.h
3 // Purpose: wxMenuItem class for wxUniversal
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 05.05.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_MENUITEM_H_
13 #define _WX_UNIV_MENUITEM_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univmenuitem.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // wxMenuItem implements wxMenuItemBase
21 // ----------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxMenuItem : public wxMenuItemBase
24 {
25 public:
26 // ctor & dtor
27 wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
28 int id = wxID_SEPARATOR,
29 const wxString& name = wxEmptyString,
30 const wxString& help = wxEmptyString,
31 wxItemKind kind = wxITEM_NORMAL,
32 wxMenu *subMenu = (wxMenu *)NULL);
33 virtual ~wxMenuItem();
34
35 // override base class virtuals to update the item appearance on screen
36 virtual void SetText(const wxString& text);
37 virtual void SetCheckable(bool checkable);
38
39 virtual void Enable(bool enable = true);
40 virtual void Check(bool check = true);
41
42 // we add some extra functions which are also available under MSW from
43 // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
44 // hopefully
45 void SetBitmaps(const wxBitmap& bmpChecked,
46 const wxBitmap& bmpUnchecked = wxNullBitmap);
47 void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
48 const wxBitmap& GetBitmap(bool checked = true) const
49 { return checked ? m_bmpChecked : m_bmpUnchecked; }
50
51 void SetDisabledBitmap( const wxBitmap& bmpDisabled )
52 { m_bmpDisabled = bmpDisabled; }
53 const wxBitmap& GetDisabledBitmap() const
54 { return m_bmpDisabled; }
55
56 // mark item as belonging to the given radio group
57 void SetAsRadioGroupStart();
58 void SetRadioGroupStart(int start);
59 void SetRadioGroupEnd(int end);
60
61 // wxUniv-specific methods for implementation only starting from here
62
63 // get the accel index of our label or -1 if none
64 int GetAccelIndex() const { return m_indexAccel; }
65
66 // get the accel string (displayed to the right of the label)
67 const wxString& GetAccelString() const { return m_strAccel; }
68
69 // set/get the y coord and the height of this item: note that it must be
70 // set first and retrieved later, the item doesn't calculate it itself
71 void SetGeometry(wxCoord y, wxCoord height)
72 {
73 m_posY = y;
74 m_height = height;
75 }
76
77 wxCoord GetPosition() const
78 {
79 wxASSERT_MSG( m_posY != wxDefaultCoord, _T("must call SetHeight first!") );
80
81 return m_posY;
82 }
83
84 wxCoord GetHeight() const
85 {
86 wxASSERT_MSG( m_height != wxDefaultCoord, _T("must call SetHeight first!") );
87
88 return m_height;
89 }
90
91 protected:
92 // notify the menu about the change in this item
93 inline void NotifyMenu();
94
95 // set the accel index and string from text
96 void UpdateAccelInfo();
97
98 // the bitmaps (may be invalid, then they're not used)
99 wxBitmap m_bmpChecked,
100 m_bmpUnchecked,
101 m_bmpDisabled;
102
103 // the positions of the first and last items of the radio group this item
104 // belongs to or -1: start is the radio group start and is valid for all
105 // but first radio group items (m_isRadioGroupStart == false), end is valid
106 // only for the first one
107 union
108 {
109 int start;
110 int end;
111 } m_radioGroup;
112
113 // does this item start a radio group?
114 bool m_isRadioGroupStart;
115
116 // the position of the accelerator in our label, -1 if none
117 int m_indexAccel;
118
119 // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
120 wxString m_strAccel;
121
122 // the position and height of the displayed item
123 wxCoord m_posY,
124 m_height;
125
126 private:
127 DECLARE_DYNAMIC_CLASS(wxMenuItem)
128 };
129
130 #endif // _WX_UNIV_MENUITEM_H_
131