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