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"
29 #include "wx/menuitem.h"
33 #include "wx/bitmap.h"
34 #include "wx/settings.h"
36 #include "wx/window.h"
38 #include "wx/string.h"
47 // ---------------------------------------------------------------------------
49 // ---------------------------------------------------------------------------
51 // conditional compilation
53 #define OWNER_DRAWN_ONLY( code ) if ( IsOwnerDrawn() ) code
54 #else // !wxUSE_OWNER_DRAWN
55 #define OWNER_DRAWN_ONLY( code )
56 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
58 // ============================================================================
60 // ============================================================================
62 // ----------------------------------------------------------------------------
63 // dynamic classes implementation
64 // ----------------------------------------------------------------------------
66 #if wxUSE_EXTENDED_RTTI
68 bool wxMenuItemStreamingCallback( const wxObject
*object
, wxWriter
* , wxPersister
* , wxxVariantArray
& )
70 const wxMenuItem
* mitem
= dynamic_cast<const wxMenuItem
*>(object
) ;
71 if ( mitem
->GetMenu() && !mitem
->GetMenu()->GetTitle().empty() )
73 // we don't stream out the first two items for menus with a title, they will be reconstructed
74 if ( mitem
->GetMenu()->FindItemByPosition(0) == mitem
|| mitem
->GetMenu()->FindItemByPosition(1) == mitem
)
80 wxBEGIN_ENUM( wxItemKind
)
81 wxENUM_MEMBER( wxITEM_SEPARATOR
)
82 wxENUM_MEMBER( wxITEM_NORMAL
)
83 wxENUM_MEMBER( wxITEM_CHECK
)
84 wxENUM_MEMBER( wxITEM_RADIO
)
85 wxEND_ENUM( wxItemKind
)
87 IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem
, wxObject
,"wx/menuitem.h",wxMenuItemStreamingCallback
)
89 wxBEGIN_PROPERTIES_TABLE(wxMenuItem
)
90 wxPROPERTY( Parent
,wxMenu
*, SetMenu
, GetMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
91 wxPROPERTY( Id
,int, SetId
, GetId
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
92 wxPROPERTY( Text
, wxString
, SetText
, GetText
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
93 wxPROPERTY( Help
, wxString
, SetHelp
, GetHelp
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
94 wxREADONLY_PROPERTY( Kind
, wxItemKind
, GetKind
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
95 wxPROPERTY( SubMenu
,wxMenu
*, SetSubMenu
, GetSubMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
96 wxPROPERTY( Enabled
, bool , Enable
, IsEnabled
, wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
97 wxPROPERTY( Checked
, bool , Check
, IsChecked
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
98 wxPROPERTY( Checkable
, bool , SetCheckable
, IsCheckable
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
99 wxEND_PROPERTIES_TABLE()
101 wxBEGIN_HANDLERS_TABLE(wxMenuItem
)
102 wxEND_HANDLERS_TABLE()
104 wxDIRECT_CONSTRUCTOR_6( wxMenuItem
, wxMenu
* , Parent
, int , Id
, wxString
, Text
, wxString
, Help
, wxItemKind
, Kind
, wxMenu
* , SubMenu
)
106 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
109 // ----------------------------------------------------------------------------
111 // ----------------------------------------------------------------------------
116 wxMenuItem::wxMenuItem(wxMenu
*pParentMenu
,
118 const wxString
& text
,
119 const wxString
& strHelp
,
122 : wxMenuItemBase(pParentMenu
, id
, text
, strHelp
, kind
, pSubMenu
)
123 #if wxUSE_OWNER_DRAWN
124 , wxOwnerDrawn(text
, kind
== wxITEM_CHECK
, true)
125 #endif // owner drawn
129 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
131 const wxString
& text
,
132 const wxString
& help
,
135 : wxMenuItemBase(parentMenu
, id
, text
, help
,
136 isCheckable
? wxITEM_CHECK
: wxITEM_NORMAL
, subMenu
)
137 #if wxUSE_OWNER_DRAWN
138 , wxOwnerDrawn(text
, isCheckable
, true)
139 #endif // owner drawn
143 void wxMenuItem::Init()
147 wxMenuItem::~wxMenuItem()
157 bool wxMenuItem::IsChecked() const
163 wxString
wxMenuItemBase::GetLabelFromText(const wxString
& text
)
165 return wxStripMenuCodes(text
);
171 void wxMenuItem::SetAsRadioGroupStart()
175 void wxMenuItem::SetRadioGroupStart(int start
)
179 void wxMenuItem::SetRadioGroupEnd(int end
)
186 void wxMenuItem::Enable(bool enable
)
190 void wxMenuItem::Check(bool check
)
194 void wxMenuItem::SetText(const wxString
& text
)
198 void wxMenuItem::SetCheckable(bool checkable
)
202 // ----------------------------------------------------------------------------
204 // ----------------------------------------------------------------------------
206 wxMenuItem
*wxMenuItemBase::New(wxMenu
*parentMenu
,
208 const wxString
& name
,
209 const wxString
& help
,
213 return new wxMenuItem(parentMenu
, id
, name
, help
, kind
, subMenu
);
216 #endif // wxUSE_MENUS