]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/xml/xh_menu.cpp
added 'name' to wxEditableListBox ctor
[wxWidgets.git] / contrib / src / xml / xh_menu.cpp
index bb3693da5ba8be3aa93feeae24646eeec64e3643..0b42642ed461bd50739bae6095e6c3c25fd4ca2b 100644 (file)
@@ -24,7 +24,7 @@
 
 
 wxMenuXmlHandler::wxMenuXmlHandler() : 
-        wxXmlResourceHandler(), m_InsideMenu(FALSE)
+        wxXmlResourceHandler(), m_insideMenu(FALSE)
 {
     ADD_STYLE(wxMENU_TEAROFF);
 }
@@ -33,23 +33,23 @@ wxMenuXmlHandler::wxMenuXmlHandler() :
 
 wxObject *wxMenuXmlHandler::DoCreateResource()
 {
-    if (m_Node->GetName() == _T("menu"))
+    if (m_class == wxT("wxMenu"))
     {
         wxMenu *menu = new wxMenu(GetStyle());
-        wxString title = GetText(_T("label"));
-        wxString help = GetText(_T("help"));
-    
-        bool oldins = m_InsideMenu;
-        m_InsideMenu = TRUE;
+        wxString title = GetText(wxT("label"));
+        wxString help = GetText(wxT("help"));
+        
+        bool oldins = m_insideMenu;
+        m_insideMenu = TRUE;
         CreateChildren(menu, TRUE/*only this handler*/);
-        m_InsideMenu = oldins;
+        m_insideMenu = oldins;
 
-        wxMenuBar *p_bar = wxDynamicCast(m_Parent, wxMenuBar);
+        wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
         if (p_bar)
             p_bar->Append(menu, title);
         else
         {
-            wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu);
+            wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
             if (p_menu)
                 p_menu->Append(GetID(), title, menu, help);
         }
@@ -59,32 +59,32 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
 
     else
     {
-        wxMenu *p_menu = wxDynamicCast(m_Parent, wxMenu);
+        wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
         
-        if (m_Node->GetName() == _T("separator"))
+        if (m_class == wxT("separator"))
             p_menu->AppendSeparator();
-        else if (m_Node->GetName() == _T("break"))
+        else if (m_class == wxT("break"))
             p_menu->Break();
-        else /*menuitem*/
+        else /*wxMenuItem*/
         {
             int id = GetID();
-            bool checkable = GetBool(_T("checkable"));
-
-            p_menu->Append(id, GetText(_T("label")), 
-                           GetText(_T("help")), checkable);
-            if (id != -1)
-            {
-                p_menu->Enable(id, GetBool(_T("enabled"), TRUE));
-                if (checkable) p_menu->Check(id, GetBool(_T("checked")));
-                
+            bool checkable = GetBool(wxT("checkable"));
+            wxString label = GetText(wxT("label"));
+            wxString accel = GetText(wxT("accel"));
+            wxString fullLabel = label;
+            if (!accel.IsEmpty())
+                fullLabel << wxT("\t") << accel;
+
+            wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
+                                               GetText(wxT("help")), checkable);
+                                               
 #if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
-                if (HasParam(_T("bitmap")))
-                {
-                    wxMenuItem *mitem = p_menu->FindItem(id);
-                    mitem->SetBitmap(GetBitmap(_T("bitmap")));
-                }
+                if (HasParam(wxT("bitmap")))
+                    mitem->SetBitmap(GetBitmap(wxT("bitmap")));
 #endif
-            }
+            p_menu->Append(mitem);
+            mitem->Enable(GetBool(wxT("enabled"), TRUE));
+            if (checkable) mitem->Check(GetBool(wxT("checked")));
         }
         return NULL;
     }
@@ -94,11 +94,11 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
 
 bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
 {
-    return node->GetName() == _T("menu") ||
-           (m_InsideMenu && 
-               (node->GetName() == _T("menuitem") ||
-                node->GetName() == _T("break") ||
-                node->GetName() == _T("separator"))
+    return IsOfClass(node, wxT("wxMenu")) ||
+           (m_insideMenu && 
+               (IsOfClass(node, wxT("wxMenuItem")) ||
+                IsOfClass(node, wxT("break")) ||
+                IsOfClass(node, wxT("separator")))
            );
 }
 
@@ -130,6 +130,6 @@ wxObject *wxMenuBarXmlHandler::DoCreateResource()
 
 bool wxMenuBarXmlHandler::CanHandle(wxXmlNode *node)
 {
-    return node->GetName() == _T("menubar");
+    return IsOfClass(node, wxT("wxMenuBar"));
 }