]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_sizer.cpp
Don't set insertion point if the text is the same in SetValue
[wxWidgets.git] / src / xrc / xh_sizer.cpp
index 0a64cbcfadcb23e7c037df6a9068664c074e8aa6..eaeec961c29237c780a498936d1e5ba01eb35f2b 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        xh_sizer.cpp
-// Purpose:     XML resource for wxBoxSizer
+// Purpose:     XRC resource for wxBoxSizer
 // Author:      Vaclav Slavik
 // Created:     2000/03/21
 // RCS-ID:      $Id$
 #include "wx/log.h"
 #include "wx/statbox.h"
 #include "wx/notebook.h"
+#include "wx/panel.h"
 #include "wx/tokenzr.h"
 
+IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler)
+
 bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node)
 {
     return (IsOfClass(node, wxT("wxBoxSizer"))) ||
@@ -39,35 +42,37 @@ bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node)
 wxSizerXmlHandler::wxSizerXmlHandler() 
 : wxXmlResourceHandler(), m_isInside(FALSE), m_parentSizer(NULL)
 {
-    ADD_STYLE(wxHORIZONTAL);
-    ADD_STYLE(wxVERTICAL);
+    XRC_ADD_STYLE(wxHORIZONTAL);
+    XRC_ADD_STYLE(wxVERTICAL);
 
     // and flags
-    ADD_STYLE(wxLEFT);
-    ADD_STYLE(wxRIGHT);
-    ADD_STYLE(wxTOP);
-    ADD_STYLE(wxBOTTOM);
-    ADD_STYLE(wxNORTH);
-    ADD_STYLE(wxSOUTH);
-    ADD_STYLE(wxEAST);
-    ADD_STYLE(wxWEST);
-    ADD_STYLE(wxALL);
-
-    ADD_STYLE(wxGROW);
-    ADD_STYLE(wxEXPAND);
-    ADD_STYLE(wxSHAPED);
-    ADD_STYLE(wxSTRETCH_NOT);
-
-    ADD_STYLE(wxALIGN_CENTER);
-    ADD_STYLE(wxALIGN_CENTRE);
-    ADD_STYLE(wxALIGN_LEFT);
-    ADD_STYLE(wxALIGN_TOP);
-    ADD_STYLE(wxALIGN_RIGHT);
-    ADD_STYLE(wxALIGN_BOTTOM);
-    ADD_STYLE(wxALIGN_CENTER_HORIZONTAL);
-    ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
-    ADD_STYLE(wxALIGN_CENTER_VERTICAL);
-    ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
+    XRC_ADD_STYLE(wxLEFT);
+    XRC_ADD_STYLE(wxRIGHT);
+    XRC_ADD_STYLE(wxTOP);
+    XRC_ADD_STYLE(wxBOTTOM);
+    XRC_ADD_STYLE(wxNORTH);
+    XRC_ADD_STYLE(wxSOUTH);
+    XRC_ADD_STYLE(wxEAST);
+    XRC_ADD_STYLE(wxWEST);
+    XRC_ADD_STYLE(wxALL);
+
+    XRC_ADD_STYLE(wxGROW);
+    XRC_ADD_STYLE(wxEXPAND);
+    XRC_ADD_STYLE(wxSHAPED);
+    XRC_ADD_STYLE(wxSTRETCH_NOT);
+
+    XRC_ADD_STYLE(wxALIGN_CENTER);
+    XRC_ADD_STYLE(wxALIGN_CENTRE);
+    XRC_ADD_STYLE(wxALIGN_LEFT);
+    XRC_ADD_STYLE(wxALIGN_TOP);
+    XRC_ADD_STYLE(wxALIGN_RIGHT);
+    XRC_ADD_STYLE(wxALIGN_BOTTOM);
+    XRC_ADD_STYLE(wxALIGN_CENTER_HORIZONTAL);
+    XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
+    XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL);
+    XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
+    
+    XRC_ADD_STYLE(wxADJUST_MINSIZE);
 }
 
 
@@ -78,6 +83,9 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
     {
         wxXmlNode *n = GetParamNode(wxT("object"));
 
+       if ( !n )
+           n = GetParamNode(wxT("object_ref"));
+
         if (n)
         {
             bool old_ins = m_isInside;
@@ -119,7 +127,7 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
     
     else if (m_class == wxT("spacer"))
     {
-        wxCHECK_MSG(m_parentSizer, NULL, wxT("Incorrect syntax of XML resource: spacer not within sizer!"));
+        wxCHECK_MSG(m_parentSizer, NULL, wxT("Incorrect syntax of XRC resource: spacer not within sizer!"));
         wxSize sz = GetSize();
         m_parentSizer->Add(sz.x, sz.y,
             GetLong(wxT("option")), GetStyle(wxT("flag")), GetDimension(wxT("border")));
@@ -133,10 +141,13 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
         wxXmlNode *parentNode = m_node->GetParent();
 
         wxCHECK_MSG(m_parentSizer != NULL ||
-                ((IsOfClass(parentNode, wxT("wxPanel")) ||
-                  IsOfClass(parentNode, wxT("wxDialog"))) &&
-                 parentNode->GetType() == wxXML_ELEMENT_NODE), NULL,
-                wxT("Incorrect use of sizer: parent is not 'wxDialog' or 'wxPanel'."));
+                (parentNode->GetType() == wxXML_ELEMENT_NODE &&
+                    m_parentAsWindow != NULL &&
+                    (m_parentAsWindow->IsKindOf(CLASSINFO(wxPanel)) ||
+                     m_parentAsWindow->IsKindOf(CLASSINFO(wxFrame)) ||
+                     m_parentAsWindow->IsKindOf(CLASSINFO(wxDialog)))
+                ), NULL,
+                wxT("Incorrect use of sizer: parent is not 'wxDialog', 'wxFrame' or 'wxPanel'."));
 
         if (m_class == wxT("wxBoxSizer"))
             sizer = new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
@@ -144,7 +155,12 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
         else if (m_class == wxT("wxStaticBoxSizer"))
         {
             sizer = new wxStaticBoxSizer(
-                         new wxStaticBox(m_parentAsWindow, -1, GetText(wxT("label"))),
+                         new wxStaticBox(m_parentAsWindow,
+                                         GetID(),
+                                         GetText(wxT("label")),
+                                         wxDefaultPosition, wxDefaultSize,
+                                         0/*style*/,
+                                         GetName()),
                          GetStyle(wxT("orient"), wxHORIZONTAL));
         }