fixed use of wxMenuItem::SetBitmap

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8489 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2000-10-07 21:52:01 +00:00
parent ef8698d677
commit 88a2dafd70

View File

@ -33,7 +33,7 @@ wxMenuXmlHandler::wxMenuXmlHandler() :
wxObject *wxMenuXmlHandler::DoCreateResource() wxObject *wxMenuXmlHandler::DoCreateResource()
{ {
if (m_Node->GetName() == _T("menu")) if (m_Class == _T("wxMenu"))
{ {
wxMenu *menu = new wxMenu(GetStyle()); wxMenu *menu = new wxMenu(GetStyle());
wxString title = GetText(_T("label")); wxString title = GetText(_T("label"));
@ -61,30 +61,25 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
{ {
wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu); wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu);
if (m_Node->GetName() == _T("separator")) if (m_Class == _T("separator"))
p_menu->AppendSeparator(); p_menu->AppendSeparator();
else if (m_Node->GetName() == _T("break")) else if (m_Class == _T("break"))
p_menu->Break(); p_menu->Break();
else /*menuitem*/ else /*wxMenuItem*/
{ {
int id = GetID(); int id = GetID();
bool checkable = GetBool(_T("checkable")); bool checkable = GetBool(_T("checkable"));
p_menu->Append(id, GetText(_T("label")), wxMenuItem *mitem = new wxMenuItem(p_menu, id, GetText(_T("label")),
GetText(_T("help")), checkable); GetText(_T("help")), checkable);
if (id != -1)
{
p_menu->Enable(id, GetBool(_T("enabled"), TRUE));
if (checkable) p_menu->Check(id, GetBool(_T("checked")));
#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__) #if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
if (HasParam(_T("bitmap"))) if (HasParam(_T("bitmap")))
{
wxMenuItem *mitem = p_menu->FindItem(id);
mitem->SetBitmap(GetBitmap(_T("bitmap"))); mitem->SetBitmap(GetBitmap(_T("bitmap")));
}
#endif #endif
} p_menu->Append(mitem);
mitem->Enable(GetBool(_T("enabled"), TRUE));
if (checkable) mitem->Check(GetBool(_T("checked")));
} }
return NULL; return NULL;
} }
@ -94,11 +89,11 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
bool wxMenuXmlHandler::CanHandle(wxXmlNode *node) bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("menu") || return IsOfClass(node, _T("wxMenu")) ||
(m_InsideMenu && (m_InsideMenu &&
(node->GetName() == _T("menuitem") || (IsOfClass(node, _T("wxMenuItem")) ||
node->GetName() == _T("break") || IsOfClass(node, _T("break")) ||
node->GetName() == _T("separator")) IsOfClass(node, _T("separator")))
); );
} }
@ -130,6 +125,6 @@ wxObject *wxMenuBarXmlHandler::DoCreateResource()
bool wxMenuBarXmlHandler::CanHandle(wxXmlNode *node) bool wxMenuBarXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("menubar"); return IsOfClass(node, _T("wxMenuBar"));
} }