1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/menuitem.cpp
3 // Purpose: wxMenuItem implementation
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
33 #include "wx/bitmap.h"
34 #include "wx/settings.h"
36 #include "wx/window.h"
38 #include "wx/string.h"
42 #include "wx/menuitem.h"
48 // ---------------------------------------------------------------------------
50 // ---------------------------------------------------------------------------
52 // conditional compilation
54 #define OWNER_DRAWN_ONLY( code ) if ( IsOwnerDrawn() ) code
55 #else // !wxUSE_OWNER_DRAWN
56 #define OWNER_DRAWN_ONLY( code )
57 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
59 // ============================================================================
61 // ============================================================================
63 // ----------------------------------------------------------------------------
64 // dynamic classes implementation
65 // ----------------------------------------------------------------------------
67 #if wxUSE_EXTENDED_RTTI
69 bool wxMenuItemStreamingCallback( const wxObject
*object
, wxWriter
* , wxPersister
* , wxxVariantArray
& )
71 const wxMenuItem
* mitem
= dynamic_cast<const wxMenuItem
*>(object
) ;
72 if ( mitem
->GetMenu() && !mitem
->GetMenu()->GetTitle().empty() )
74 // we don't stream out the first two items for menus with a title, they will be reconstructed
75 if ( mitem
->GetMenu()->FindItemByPosition(0) == mitem
|| mitem
->GetMenu()->FindItemByPosition(1) == mitem
)
81 wxBEGIN_ENUM( wxItemKind
)
82 wxENUM_MEMBER( wxITEM_SEPARATOR
)
83 wxENUM_MEMBER( wxITEM_NORMAL
)
84 wxENUM_MEMBER( wxITEM_CHECK
)
85 wxENUM_MEMBER( wxITEM_RADIO
)
86 wxEND_ENUM( wxItemKind
)
88 IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem
, wxObject
,"wx/menuitem.h",wxMenuItemStreamingCallback
)
90 wxBEGIN_PROPERTIES_TABLE(wxMenuItem
)
91 wxPROPERTY( Parent
,wxMenu
*, SetMenu
, GetMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
92 wxPROPERTY( Id
,int, SetId
, GetId
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
93 wxPROPERTY( Text
, wxString
, SetText
, GetText
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
94 wxPROPERTY( Help
, wxString
, SetHelp
, GetHelp
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
95 wxREADONLY_PROPERTY( Kind
, wxItemKind
, GetKind
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
96 wxPROPERTY( SubMenu
,wxMenu
*, SetSubMenu
, GetSubMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
97 wxPROPERTY( Enabled
, bool , Enable
, IsEnabled
, wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
98 wxPROPERTY( Checked
, bool , Check
, IsChecked
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
99 wxPROPERTY( Checkable
, bool , SetCheckable
, IsCheckable
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
100 wxEND_PROPERTIES_TABLE()
102 wxBEGIN_HANDLERS_TABLE(wxMenuItem
)
103 wxEND_HANDLERS_TABLE()
105 wxDIRECT_CONSTRUCTOR_6( wxMenuItem
, wxMenu
* , Parent
, int , Id
, wxString
, Text
, wxString
, Help
, wxItemKind
, Kind
, wxMenu
* , SubMenu
)
107 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
110 // ----------------------------------------------------------------------------
112 // ----------------------------------------------------------------------------
117 wxMenuItem::wxMenuItem(wxMenu
*pParentMenu
,
119 const wxString
& text
,
120 const wxString
& strHelp
,
123 : wxMenuItemBase(pParentMenu
, id
, text
, strHelp
, kind
, pSubMenu
)
124 #if wxUSE_OWNER_DRAWN
125 , wxOwnerDrawn(text
, kind
== wxITEM_CHECK
, true)
126 #endif // owner drawn
130 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
132 const wxString
& text
,
133 const wxString
& help
,
136 : wxMenuItemBase(parentMenu
, id
, text
, help
,
137 isCheckable
? wxITEM_CHECK
: wxITEM_NORMAL
, subMenu
)
138 #if wxUSE_OWNER_DRAWN
139 , wxOwnerDrawn(text
, isCheckable
, true)
140 #endif // owner drawn
144 void wxMenuItem::Init()
148 wxMenuItem::~wxMenuItem()
158 bool wxMenuItem::IsChecked() const
164 wxString
wxMenuItemBase::GetLabelFromText(const wxString
& text
)
166 return wxStripMenuCodes(text
);
172 void wxMenuItem::SetAsRadioGroupStart()
176 void wxMenuItem::SetRadioGroupStart(int start
)
180 void wxMenuItem::SetRadioGroupEnd(int end
)
187 void wxMenuItem::Enable(bool enable
)
191 void wxMenuItem::Check(bool check
)
195 void wxMenuItem::SetText(const wxString
& text
)
199 void wxMenuItem::SetCheckable(bool checkable
)
203 // ----------------------------------------------------------------------------
205 // ----------------------------------------------------------------------------
207 wxMenuItem
*wxMenuItemBase::New(wxMenu
*parentMenu
,
209 const wxString
& name
,
210 const wxString
& help
,
214 return new wxMenuItem(parentMenu
, id
, name
, help
, kind
, subMenu
);
217 #endif // wxUSE_MENUS