]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_panel.cpp
Split some of the recent code out to make it more reusable.
[wxWidgets.git] / src / xrc / xh_panel.cpp
index d4d40956f68cc63ad5dd3c6b0a7e7b7ee91c2c06..d059aebba823114fbb809fd9c75f909ed63592cc 100644 (file)
@@ -1,14 +1,14 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        xh_panel.cpp
-// Purpose:     XML resource for panels
+// Purpose:     XRC resource for panels
 // Author:      Vaclav Slavik
 // Created:     2000/03/05
 // RCS-ID:      $Id$
 // Copyright:   (c) 2000 Vaclav Slavik
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "xh_panel.h"
 #endif
 
     #pragma hdrstop
 #endif
 
+#if wxUSE_XRC
+
 #include "wx/xrc/xh_panel.h"
 #include "wx/panel.h"
+#include "wx/frame.h"  // to get wxNO_3D
 
+IMPLEMENT_DYNAMIC_CLASS(wxPanelXmlHandler, wxXmlResourceHandler)
 
 wxPanelXmlHandler::wxPanelXmlHandler() : wxXmlResourceHandler()
 {
-    ADD_STYLE(wxNO_3D);
-    ADD_STYLE(wxTAB_TRAVERSAL);
-    ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
-    ADD_STYLE(wxCLIP_CHILDREN);
+    XRC_ADD_STYLE(wxNO_3D);
+    XRC_ADD_STYLE(wxTAB_TRAVERSAL);
+    XRC_ADD_STYLE(wxWS_EX_VALIDATE_RECURSIVELY);
+    
     AddWindowStyles();
 }
 
+wxObject *wxPanelXmlHandler::DoCreateResource()
+{
+    XRC_MAKE_INSTANCE(panel, wxPanel)
 
+    panel->Create(m_parentAsWindow,
+                  GetID(),
+                  GetPosition(), GetSize(),
+                  GetStyle(wxT("style"), wxTAB_TRAVERSAL),
+                  GetName());
 
-wxObject *wxPanelXmlHandler::DoCreateResource()
-{ 
-    wxPanel *panel = wxDynamicCast(m_instance, wxPanel);
-
-    if (panel == NULL)
-        panel = new wxPanel(m_parentAsWindow,
-                                 GetID(),
-                                 GetPosition(), GetSize(),
-                                 GetStyle(wxT("style"), wxTAB_TRAVERSAL),
-                                 GetName());
-    else
-        panel->Create(m_parentAsWindow,
-                                 GetID(),
-                                 GetPosition(), GetSize(),
-                                 GetStyle(wxT("style"), wxTAB_TRAVERSAL),
-                                 GetName());
     SetupWindow(panel);
     CreateChildren(panel);
-    
+
     return panel;
 }
 
-
 bool wxPanelXmlHandler::CanHandle(wxXmlNode *node)
 {
     return IsOfClass(node, wxT("wxPanel"));
 }
+
+#endif // wxUSE_XRC