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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "menuitem.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/bitmap.h"
36 #include "wx/settings.h"
38 #include "wx/window.h"
41 #include "wx/string.h"
44 #include "wx/menuitem.h"
51 // ---------------------------------------------------------------------------
53 // ---------------------------------------------------------------------------
55 // conditional compilation
57 #define OWNER_DRAWN_ONLY( code ) if ( IsOwnerDrawn() ) code
58 #else // !wxUSE_OWNER_DRAWN
59 #define OWNER_DRAWN_ONLY( code )
60 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
62 // ============================================================================
64 // ============================================================================
66 // ----------------------------------------------------------------------------
67 // dynamic classes implementation
68 // ----------------------------------------------------------------------------
70 #if wxUSE_EXTENDED_RTTI
72 bool wxMenuItemStreamingCallback( const wxObject
*object
, wxWriter
* , wxPersister
* , wxxVariantArray
& )
74 const wxMenuItem
* mitem
= dynamic_cast<const wxMenuItem
*>(object
) ;
75 if ( mitem
->GetMenu() && !mitem
->GetMenu()->GetTitle().IsEmpty() )
77 // we don't stream out the first two items for menus with a title, they will be reconstructed
78 if ( mitem
->GetMenu()->FindItemByPosition(0) == mitem
|| mitem
->GetMenu()->FindItemByPosition(1) == mitem
)
84 wxBEGIN_ENUM( wxItemKind
)
85 wxENUM_MEMBER( wxITEM_SEPARATOR
)
86 wxENUM_MEMBER( wxITEM_NORMAL
)
87 wxENUM_MEMBER( wxITEM_CHECK
)
88 wxENUM_MEMBER( wxITEM_RADIO
)
89 wxEND_ENUM( wxItemKind
)
91 IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem
, wxObject
,"wx/menuitem.h",wxMenuItemStreamingCallback
)
93 wxBEGIN_PROPERTIES_TABLE(wxMenuItem
)
94 wxPROPERTY( Parent
,wxMenu
*, SetMenu
, GetMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
95 wxPROPERTY( Id
,int, SetId
, GetId
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
96 wxPROPERTY( Text
, wxString
, SetText
, GetText
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
97 wxPROPERTY( Help
, wxString
, SetHelp
, GetHelp
, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
98 wxREADONLY_PROPERTY( Kind
, wxItemKind
, GetKind
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
99 wxPROPERTY( SubMenu
,wxMenu
*, SetSubMenu
, GetSubMenu
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
100 wxPROPERTY( Enabled
, bool , Enable
, IsEnabled
, wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
101 wxPROPERTY( Checked
, bool , Check
, IsChecked
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
102 wxPROPERTY( Checkable
, bool , SetCheckable
, IsCheckable
, wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
103 wxEND_PROPERTIES_TABLE()
105 wxBEGIN_HANDLERS_TABLE(wxMenuItem
)
106 wxEND_HANDLERS_TABLE()
108 wxDIRECT_CONSTRUCTOR_6( wxMenuItem
, wxMenu
* , Parent
, int , Id
, wxString
, Text
, wxString
, Help
, wxItemKind
, Kind
, wxMenu
* , SubMenu
)
110 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem
, wxObject
)
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
120 wxMenuItem::wxMenuItem(wxMenu
*pParentMenu
,
122 const wxString
& text
,
123 const wxString
& strHelp
,
126 : wxMenuItemBase(pParentMenu
, id
, text
, strHelp
, kind
, pSubMenu
)
127 #if wxUSE_OWNER_DRAWN
128 , wxOwnerDrawn(text
, kind
== wxITEM_CHECK
, true)
129 #endif // owner drawn
133 wxMenuItem::wxMenuItem(wxMenu
*parentMenu
,
135 const wxString
& text
,
136 const wxString
& help
,
139 : wxMenuItemBase(parentMenu
, id
, text
, help
,
140 isCheckable
? wxITEM_CHECK
: wxITEM_NORMAL
, subMenu
)
141 #if wxUSE_OWNER_DRAWN
142 , wxOwnerDrawn(text
, isCheckable
, true)
143 #endif // owner drawn
147 void wxMenuItem::Init()
151 wxMenuItem::~wxMenuItem()
158 // return the id for calling Win32 API functions
159 int wxMenuItem::GetRealId() const
167 bool wxMenuItem::IsChecked() const
173 wxString
wxMenuItemBase::GetLabelFromText(const wxString
& text
)
175 return wxStripMenuCodes(text
);
181 void wxMenuItem::SetAsRadioGroupStart()
185 void wxMenuItem::SetRadioGroupStart(int start
)
189 void wxMenuItem::SetRadioGroupEnd(int end
)
196 void wxMenuItem::Enable(bool enable
)
200 void wxMenuItem::Check(bool check
)
204 void wxMenuItem::SetText(const wxString
& text
)
208 void wxMenuItem::SetCheckable(bool checkable
)
212 // ----------------------------------------------------------------------------
214 // ----------------------------------------------------------------------------
216 wxMenuItem
*wxMenuItemBase::New(wxMenu
*parentMenu
,
218 const wxString
& name
,
219 const wxString
& help
,
223 return new wxMenuItem(parentMenu
, id
, name
, help
, kind
, subMenu
);
226 #endif // wxUSE_MENUS