]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/xh_menu.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML resource for menus and menubars
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_menu.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xml/xh_menu.h"
26 wxMenuXmlHandler::wxMenuXmlHandler() :
27 wxXmlResourceHandler(), m_InsideMenu(FALSE
)
29 ADD_STYLE(wxMENU_TEAROFF
);
34 wxObject
*wxMenuXmlHandler::DoCreateResource()
36 if (m_Node
->GetName() == _T("menu"))
38 wxMenu
*menu
= new wxMenu(GetStyle());
39 wxString title
= GetText(_T("label"));
40 wxString help
= GetText(_T("help"));
42 bool oldins
= m_InsideMenu
;
44 CreateChildren(menu
, TRUE
/*only this handler*/);
45 m_InsideMenu
= oldins
;
47 wxMenuBar
*p_bar
= wxDynamicCast(m_Parent
, wxMenuBar
);
49 p_bar
->Append(menu
, title
);
52 wxMenu
*p_menu
= wxDynamicCast(m_Parent
, wxMenu
);
54 p_menu
->Append(GetID(), title
, menu
, help
);
62 wxMenu
*p_menu
= wxDynamicCast(m_Parent
, wxMenu
);
64 if (m_Node
->GetName() == _T("separator"))
65 p_menu
->AppendSeparator();
66 else if (m_Node
->GetName() == _T("break"))
71 bool checkable
= GetBool(_T("checkable"));
72 p_menu
->Append(id
, GetText(_T("label")),
73 GetText(_T("help")), checkable
);
76 p_menu
->Enable(id
, GetBool(_T("enabled"), TRUE
));
77 if (checkable
) p_menu
->Check(id
, GetBool(_T("checked")));
86 bool wxMenuXmlHandler::CanHandle(wxXmlNode
*node
)
88 return node
->GetName() == _T("menu") ||
90 (node
->GetName() == _T("menuitem") ||
91 node
->GetName() == _T("break") ||
92 node
->GetName() == _T("separator"))
106 wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
108 ADD_STYLE(wxMB_DOCKABLE
);
113 wxObject
*wxMenuBarXmlHandler::DoCreateResource()
115 wxMenuBar
*menubar
= new wxMenuBar(GetStyle());
116 CreateChildren(menubar
);
122 bool wxMenuBarXmlHandler::CanHandle(wxXmlNode
*node
)
124 return node
->GetName() == _T("menubar");