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"
35 #include "wx/window.h"
37 #include "wx/string.h"
46 // ---------------------------------------------------------------------------
48 // ---------------------------------------------------------------------------
50 // conditional compilation
52 #define OWNER_DRAWN_ONLY( code ) if ( IsOwnerDrawn() ) code
53 #else // !wxUSE_OWNER_DRAWN
54 #define OWNER_DRAWN_ONLY( code )
55 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
57 // ============================================================================
59 // ============================================================================
61 // ----------------------------------------------------------------------------
62 // dynamic classes implementation
63 // ----------------------------------------------------------------------------
65 #if wxUSE_EXTENDED_RTTI
67 bool wxMenuItemStreamingCallback( const wxObject
*object
, wxWriter
* , wxPersister
* , wxxVariantArray
& )
69 const wxMenuItem
* mitem
= dynamic_cast<const wxMenuItem
*>(object
) ;
70 if ( mitem
->GetMenu() && !mitem
->GetMenu()->GetTitle().empty() )
72 // we don't stream out the first two items for menus with a title, they will be reconstructed
73 if ( mitem
->GetMenu()->FindItemByPosition(0) == mitem
|| mitem
->GetMenu()->FindItemByPosition(1) == mitem
)
79 wxBEGIN_ENUM( wxItemKind
)
80 wxENUM_MEMBER( wxITEM_SEPARATOR
)
81 wxENUM_MEMBER( wxITEM_NORMAL
)
82 wxENUM_MEMBER( wxITEM_CHECK
)
83 wxENUM_MEMBER( wxITEM_RADIO
)
84 wxEND_ENUM( wxItemKind
)
86 IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem
, wxObject
,"wx/menuitem.h",wxMenuItemStreamingCallback
)
88 wxBEGIN_PROPERTIES_TABLE(wxMenuItem
)
89 wxPROPERTY( Parent
,wxMenu
*, SetMenu
, GetMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
90 wxPROPERTY( Id
,int, SetId
, GetId
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
91 wxPROPERTY( Text
, wxString
, SetText
, GetText
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
92 wxPROPERTY( Help
, wxString
, SetHelp
, GetHelp
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
93 wxREADONLY_PROPERTY( Kind
, wxItemKind
, GetKind
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
94 wxPROPERTY( SubMenu
,wxMenu
*, SetSubMenu
, GetSubMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
95 wxPROPERTY( Enabled
, bool , Enable
, IsEnabled
, wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
96 wxPROPERTY( Checked
, bool , Check
, IsChecked
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
97 wxPROPERTY( Checkable
, bool , SetCheckable
, IsCheckable
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
98 wxEND_PROPERTIES_TABLE()
100 wxBEGIN_HANDLERS_TABLE(wxMenuItem
)
101 wxEND_HANDLERS_TABLE()
103 wxDIRECT_CONSTRUCTOR_6( wxMenuItem
, wxMenu
* , Parent
, int , Id
, wxString
, Text
, wxString
, Help
, wxItemKind
, Kind
, wxMenu
* , SubMenu
)
105 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
115 wxMenuItem::wxMenuItem(wxMenu
*pParentMenu
,
117 const wxString
& text
,
118 const wxString
& strHelp
,
121 : wxMenuItemBase(pParentMenu
, id
, text
, strHelp
, kind
, pSubMenu
)
122 #if wxUSE_OWNER_DRAWN
123 , wxOwnerDrawn(text
, kind
== wxITEM_CHECK
, true)
124 #endif // owner drawn
128 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
130 const wxString
& text
,
131 const wxString
& help
,
134 : wxMenuItemBase(parentMenu
, id
, text
, help
,
135 isCheckable
? wxITEM_CHECK
: wxITEM_NORMAL
, subMenu
)
136 #if wxUSE_OWNER_DRAWN
137 , wxOwnerDrawn(text
, isCheckable
, true)
138 #endif // owner drawn
142 void wxMenuItem::Init()
146 wxMenuItem::~wxMenuItem()
156 bool wxMenuItem::IsChecked() const
162 wxString
wxMenuItemBase::GetLabelText(const wxString
& text
)
164 return wxStripMenuCodes(text
);
170 void wxMenuItem::SetAsRadioGroupStart()
174 void wxMenuItem::SetRadioGroupStart(int start
)
178 void wxMenuItem::SetRadioGroupEnd(int end
)
185 void wxMenuItem::Enable(bool enable
)
189 void wxMenuItem::Check(bool check
)
193 void wxMenuItem::SetItemLabel(const wxString
& text
)
197 void wxMenuItem::SetCheckable(bool checkable
)
201 // ----------------------------------------------------------------------------
203 // ----------------------------------------------------------------------------
205 wxMenuItem
*wxMenuItemBase::New(wxMenu
*parentMenu
,
207 const wxString
& name
,
208 const wxString
& help
,
212 return new wxMenuItem(parentMenu
, id
, name
, help
, kind
, subMenu
);
215 #endif // wxUSE_MENUS