]> git.saurik.com Git - wxWidgets.git/commitdiff
Changes to the XRC library:
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 27 Dec 2001 23:16:48 +0000 (23:16 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 27 Dec 2001 23:16:48 +0000 (23:16 +0000)
1. preparation of XRC handlers for subclassing (Alex)
2. fixed incorrect use of _() in couple of places
3. wxFrame and wxDialog positioning fixes
4. menus and toolbars attach themselves to the parent frame
5. style unification: let all _T()s be wxT()s

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13205 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

56 files changed:
contrib/src/xrc/xh_bttn.cpp
contrib/src/xrc/xh_cald.cpp
contrib/src/xrc/xh_chckb.cpp
contrib/src/xrc/xh_chckl.cpp
contrib/src/xrc/xh_choic.cpp
contrib/src/xrc/xh_combo.cpp
contrib/src/xrc/xh_dlg.cpp
contrib/src/xrc/xh_frame.cpp
contrib/src/xrc/xh_gauge.cpp
contrib/src/xrc/xh_html.cpp
contrib/src/xrc/xh_listb.cpp
contrib/src/xrc/xh_listc.cpp
contrib/src/xrc/xh_menu.cpp
contrib/src/xrc/xh_notbk.cpp
contrib/src/xrc/xh_panel.cpp
contrib/src/xrc/xh_radbt.cpp
contrib/src/xrc/xh_radbx.cpp
contrib/src/xrc/xh_scrol.cpp
contrib/src/xrc/xh_sizer.cpp
contrib/src/xrc/xh_slidr.cpp
contrib/src/xrc/xh_spin.cpp
contrib/src/xrc/xh_stbmp.cpp
contrib/src/xrc/xh_stbox.cpp
contrib/src/xrc/xh_stlin.cpp
contrib/src/xrc/xh_sttxt.cpp
contrib/src/xrc/xh_text.cpp
contrib/src/xrc/xh_toolb.cpp
contrib/src/xrc/xh_tree.cpp
src/xrc/xh_bttn.cpp
src/xrc/xh_cald.cpp
src/xrc/xh_chckb.cpp
src/xrc/xh_chckl.cpp
src/xrc/xh_choic.cpp
src/xrc/xh_combo.cpp
src/xrc/xh_dlg.cpp
src/xrc/xh_frame.cpp
src/xrc/xh_gauge.cpp
src/xrc/xh_html.cpp
src/xrc/xh_listb.cpp
src/xrc/xh_listc.cpp
src/xrc/xh_menu.cpp
src/xrc/xh_notbk.cpp
src/xrc/xh_panel.cpp
src/xrc/xh_radbt.cpp
src/xrc/xh_radbx.cpp
src/xrc/xh_scrol.cpp
src/xrc/xh_sizer.cpp
src/xrc/xh_slidr.cpp
src/xrc/xh_spin.cpp
src/xrc/xh_stbmp.cpp
src/xrc/xh_stbox.cpp
src/xrc/xh_stlin.cpp
src/xrc/xh_sttxt.cpp
src/xrc/xh_text.cpp
src/xrc/xh_toolb.cpp
src/xrc/xh_tree.cpp

index 1a0a7486ef988e7fc9f18532af59c11284c395fc..d2c48b42a773c66b4e9080b2d69e63fc4033da96 100644 (file)
@@ -36,13 +36,19 @@ wxButtonXmlHandler::wxButtonXmlHandler()
 
 wxObject *wxButtonXmlHandler::DoCreateResource()
 { 
-    wxButton *button = new wxButton(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName());
+   wxButton *button = wxStaticCast(m_instance, wxButton);
+
+   if (!button)
+       button = new wxButton;
+
+   button->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
+
     if (GetBool(wxT("default"), 0) == 1) button->SetDefault();
     SetupWindow(button);
     
index 1367c5e8f7cdf4bbc0034882e8fd4082e31055f3..4fba39eb75b8e5c2bd4dd282860cbcef87f5e1e0 100644 (file)
@@ -38,13 +38,18 @@ wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
 
 wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
 { 
-    wxCalendarCtrl *calendar = new wxCalendarCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    wxDefaultDateTime,
-                                    /*TODO: take it from resource*/
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName());
+    wxCalendarCtrl *calendar = wxStaticCast(m_instance, wxCalendarCtrl);
+
+    if (!calendar)
+       calendar = new wxCalendarCtrl;
+
+    calendar->Create(m_parentAsWindow,
+                     GetID(),
+                     wxDefaultDateTime,
+                     /*TODO: take it from resource*/
+                     GetPosition(), GetSize(),
+                     GetStyle(),
+                     GetName());
     
     SetupWindow(calendar);
     
index 9bd2eb99ace4f78a886aa9a46e2b3cc917de3a88..493c876f5c596807a256d1492634b904c7a3c216 100644 (file)
@@ -32,14 +32,18 @@ wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
 
 wxObject *wxCheckBoxXmlHandler::DoCreateResource()
 { 
-    wxCheckBox *control = new wxCheckBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxCheckBox *control = wxStaticCast(m_instance, wxCheckBox);
+
+    if (!control)
+       control = new wxCheckBox;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     control->SetValue( GetBool( wxT("checked")));
     SetupWindow(control);
index c9f114ea92d54db8923a0848668af5a7a7f3ebbd..81f06455f025d2518473cdbae17e78b89acb514b 100644 (file)
@@ -45,16 +45,19 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxCheckListBox *control = wxStaticCast(m_instance, wxCheckListBox);
+
+        if (!control)
+           control = new wxCheckListBox;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         // step through children myself (again.)
         wxXmlNode *n = GetParamNode(wxT("content"));
index 9c9e7aa2c172712a2d3a3e2ab4dfd29373be2e57..4de735f9d215ea53fa928dcb89036e342e6d39bf 100644 (file)
@@ -48,16 +48,19 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxChoice *control = new wxChoice(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxChoice *control = wxStaticCast(m_instance, wxChoice);
+
+        if (!control)
+           control = new wxChoice;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index 37c29089c3e924a82b53f621c774519f42543f12..26e9ad9abd82479282ee9288486e6ec762c29f97 100644 (file)
@@ -54,16 +54,20 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
         }
 
 
-        wxComboBox *control = new wxComboBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("value")),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxComboBox *control = wxStaticCast(m_instance, wxComboBox);
+
+        if (!control)
+           control = new wxComboBox;
+            
+       control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetText(wxT("value")),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index 392d9376f7204a12cb5a9dc29cac3f44e3da4b30..ab40e6da07a5e7169286e4aab535ba34a4dacb3f 100644 (file)
@@ -58,8 +58,10 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
                 wxDefaultPosition, wxDefaultSize,
                 GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE),
                 GetName());
-    dlg->SetClientSize(GetSize());
-    dlg->Move(GetPosition());
+    if (HasParam(wxT("size")))
+        dlg->SetClientSize(GetSize());
+    if (HasParam(wxT("pos")))
+        dlg->Move(GetPosition());
     SetupWindow(dlg);
 
     CreateChildren(dlg);
index c8168e6e2b6af610673de1ef0ad62322f9bec80d..2674ea4008ede76a85fcf2febf9882da255e760b 100644 (file)
@@ -59,17 +59,19 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
     
     frame->Create(m_parentAsWindow,
                 GetID(),
-                GetText(_T("title")),
+                GetText(wxT("title")),
                 wxDefaultPosition, wxDefaultSize,
-                GetStyle(_T("style"), wxDEFAULT_FRAME_STYLE),
+                GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
                 GetName());
-    frame->SetClientSize(GetSize());
-    frame->Move(GetPosition());
+    if (HasParam(wxT("size")))
+        frame->SetClientSize(GetSize());
+    if (HasParam(wxT("pos")))
+        frame->Move(GetPosition());
     SetupWindow(frame);
 
     CreateChildren(frame);
     
-    if (GetBool(_("centered"), FALSE))
+    if (GetBool(wxT("centered"), FALSE))
         frame->Centre();
     
     return frame;
@@ -79,7 +81,7 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
 
 bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
 {
-    return IsOfClass(node, _T("wxFrame"));
+    return IsOfClass(node, wxT("wxFrame"));
 }
 
 
index b49257895e624da39ffd13f165b6e0f90ea6d776..4c692b9cbfd9e6a2c5db39d212ad78e4b72dc4b5 100644 (file)
@@ -36,14 +36,18 @@ wxGaugeXmlHandler::wxGaugeXmlHandler()
 
 wxObject *wxGaugeXmlHandler::DoCreateResource()
 { 
-    wxGauge *control = new wxGauge(m_parentAsWindow,
-                                    GetID(),
-                                    GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), 
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxGauge *control = wxStaticCast(m_instance, wxGauge);
+
+    if (!control)
+       control = new wxGauge;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), 
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     if( HasParam( wxT("value") ))
     {
index 53b0808bdf1ff5382e2ebd174607fb7608f48bff..be7716b0081598791530baccee12c27ce71dd5bc 100644 (file)
 wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() 
 : wxXmlResourceHandler() 
 {
-    ADD_STYLE( wxHW_SCROLLBAR_NEVER );
-    ADD_STYLE( wxHW_SCROLLBAR_AUTO );
+    ADD_STYLE(wxHW_SCROLLBAR_NEVER);
+    ADD_STYLE(wxHW_SCROLLBAR_AUTO);
     AddWindowStyles();
 }
 
 wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
-{ 
-    wxHtmlWindow *control = new wxHtmlWindow(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle( wxT("style" ), wxHW_SCROLLBAR_AUTO),
-                                    GetName()
-                                    );
-
-    if( HasParam( wxT("borders") ))
+{
+    wxHtmlWindow *control = wxStaticCast(m_instance, wxHtmlWindow);
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
+                    GetName());
+
+    if (HasParam(wxT("borders")))
     {
-        control->SetBorders( GetDimension( wxT("borders" )));
+        control->SetBorders(GetDimension(wxT("borders")));
     }
 
-    if( HasParam( wxT("url") ))
+    if( HasParam(wxT("url")))
     {
-        wxString url = GetParamValue(wxT("url" ));
+        wxString url = GetParamValue(wxT("url"));
         wxFileSystem& fsys = GetCurFileSystem();
         
         wxFSFile *f = fsys.OpenFile(url);
@@ -64,9 +65,9 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
             control->LoadPage(url);
     }
     
-    else if( HasParam( wxT("htmlcode") ))
+    else if (HasParam(wxT("htmlcode")))
     {
-        control->SetPage( GetText(wxT("htmlcode")) );
+        control->SetPage(GetText(wxT("htmlcode")));
     }
 
     SetupWindow(control);
index d1b48f96d76d7119d22ee3e2338d40e8f65505cf..ce4ecc38184848f538d78d9b52893dd024ad910d 100644 (file)
@@ -54,16 +54,19 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxListBox *control = new wxListBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxListBox *control = wxStaticCast(m_instance, wxListBox);
+
+        if (!control)
+           control = new wxListBox;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index aeb7f5756ecdeb0235ae90f024ba737a1865fdf5..de3635dedee0e8257b16815eef3d1fac931798df 100644 (file)
@@ -46,12 +46,18 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler()
 
 wxObject *wxListCtrlXmlHandler::DoCreateResource()
 { 
-    wxListCtrl *list = new wxListCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName());
+   wxListCtrl *list = wxStaticCast(m_instance, wxListCtrl);
+
+   if (!list)
+       list = new wxListCtrl;
+
+   list->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
+
     /* TODO: columns definition */
     
     SetupWindow(list);
index 709f4e23810cb18d2a75fc1da55ef5a8f4fe6de2..a7935f8018c5d8dc9f793a5d03139c06d96f3718 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "wx/xrc/xh_menu.h"
 #include "wx/menu.h"
+#include "wx/frame.h"
 
 
 wxMenuXmlHandler::wxMenuXmlHandler() : 
@@ -105,13 +106,6 @@ bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
 
 
 
-
-
-
-
-
-
-
 wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
 {
     ADD_STYLE(wxMB_DOCKABLE);
@@ -123,6 +117,14 @@ wxObject *wxMenuBarXmlHandler::DoCreateResource()
 {
     wxMenuBar *menubar = new wxMenuBar(GetStyle());
     CreateChildren(menubar);
+
+    if (m_parentAsWindow)
+    {
+        wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
+        if (parentFrame)
+            parentFrame->SetMenuBar(menubar);
+    }
+
     return menubar;
 }
 
index 7cf5fb9ad22133fbac435976c4a8be95b54c75c6..0a44e451b875bca8cf4e1ff142bf2eabd5af3dc6 100644 (file)
@@ -45,6 +45,9 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
     {
         wxXmlNode *n = GetParamNode(wxT("object"));
 
+       if ( !n )
+           n = GetParamNode(wxT("object_ref"));
+
         if (n)
         {
             bool old_ins = m_isInside;
@@ -68,12 +71,17 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
     }
     
     else {
-        wxNotebook *nb = new wxNotebook(m_parentAsWindow, 
-                                        GetID(),
-                                        GetPosition(), GetSize(),
-                                        GetStyle( wxT("style" )),
-                                        GetName());
-    
+       wxNotebook *nb = wxStaticCast(m_instance, wxNotebook);
+
+       if ( !nb )
+           nb = new wxNotebook;
+
+       nb->Create(m_parentAsWindow, 
+                 GetID(),
+                 GetPosition(), GetSize(),
+                 GetStyle( wxT("style" )),
+                 GetName());
+
         wxNotebook *old_par = m_notebook;
         m_notebook = nb;
         bool old_ins = m_isInside;
index bc3552dc7ca101af140938889798b0417fb574d5..539527bbcaf793bb2c47f54dc3009b565a6cac54 100644 (file)
@@ -38,18 +38,15 @@ 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());
+    if (!panel)
+       panel = new wxPanel;
+
+    panel->Create(m_parentAsWindow,
+                  GetID(),
+                  GetPosition(), GetSize(),
+                  GetStyle(wxT("style"), wxTAB_TRAVERSAL),
+                  GetName());
+
     SetupWindow(panel);
     CreateChildren(panel);
     
index a14b34a72f9e966b795418b745f4c1712ad5e861..a850d4443713790ee12f64476481b531967bcac1 100644 (file)
@@ -40,14 +40,18 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
      * normal radio button.
      */ 
 
-    wxRadioButton *control = new wxRadioButton(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxRadioButton *control = wxStaticCast(m_instance, wxRadioButton);
+
+    if (!control)
+       control = new wxRadioButton;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     control->SetValue( GetBool(wxT("value"), 0));
     SetupWindow(control);
index 17beaac5f9315217dd56bff5c98d8134d7372ba8..2fbf045da3bf162da67c9ad7efb2945a0825b87d 100644 (file)
@@ -53,18 +53,21 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxRadioBox *control = new wxRadioBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetLong( wxT("dimension"), 1 ),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxRadioBox *control = wxStaticCast(m_instance, wxRadioBox);
+
+        if (!control)
+           control = new wxRadioBox;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetText(wxT("label")),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetLong(wxT("dimension"), 1),
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index 0171894f87cbe0321597ecb694f7fa699e43f69f..6e2dfb1b7125973f4cce23beeb10837a055b23cf 100644 (file)
@@ -33,13 +33,18 @@ wxScrollBarXmlHandler::wxScrollBarXmlHandler()
 
 wxObject *wxScrollBarXmlHandler::DoCreateResource()
 { 
-    wxScrollBar *control = new wxScrollBar(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxScrollBar *control = wxStaticCast(m_instance, wxScrollBar);
+
+    if (!control)
+       control = new wxScrollBar;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
+
     control->SetScrollbar(GetLong( wxT("value"), 0), 
                           GetLong( wxT("thumbsize"),1),
                           GetLong( wxT("range"), 10),
index 7b6aff301baf69ca7bbed9fbacaf01b630d950b6..bd56618d03c9835ad89e14d5228b3571b7e2d64d 100644 (file)
@@ -78,6 +78,9 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
     {
         wxXmlNode *n = GetParamNode(wxT("object"));
 
+       if ( !n )
+           n = GetParamNode(wxT("object_ref"));
+
         if (n)
         {
             bool old_ins = m_isInside;
index c0aec234639182c06834af26c75939e4d09195c7..de99697f634bd1b1459ea3389a496713a8ec03e4 100644 (file)
@@ -42,16 +42,20 @@ wxSliderXmlHandler::wxSliderXmlHandler()
 
 wxObject *wxSliderXmlHandler::DoCreateResource()
 { 
-    wxSlider *control = new wxSlider(m_parentAsWindow,
-                                    GetID(),
-                                    GetLong( wxT("value"), wxSL_DEFAULT_VALUE), 
-                                    GetLong( wxT("min"), wxSL_DEFAULT_MIN),
-                                    GetLong( wxT("max"), wxSL_DEFAULT_MAX),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxSlider *control = wxStaticCast(m_instance, wxSlider);
+
+    if (!control)
+       control = new wxSlider;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetLong(wxT("value"), wxSL_DEFAULT_VALUE), 
+                    GetLong(wxT("min"), wxSL_DEFAULT_MIN),
+                    GetLong(wxT("max"), wxSL_DEFAULT_MAX),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     if( HasParam( wxT("tickfreq") ))
     {
index 3888c6daa3779823bc31f6ba646cf8a191b7518c..3940024ef0de86633d08e35bb1a19e9c52e6c892 100644 (file)
@@ -36,12 +36,16 @@ wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
 
 wxObject *wxSpinButtonXmlHandler::DoCreateResource()
 { 
-    wxSpinButton *control = new wxSpinButton(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle( wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS ),
-                                    GetName()
-                                    );
+    wxSpinButton *control = wxStaticCast(m_instance, wxSpinButton);
+
+    if (!control)
+       control = new wxSpinButton;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS),
+                    GetName());
 
     control->SetValue( GetLong( wxT("value"), wxSP_DEFAULT_VALUE) );
     control->SetRange( GetLong( wxT("min"), wxSP_DEFAULT_MIN),
index 034fe3dd68f8f40e9e3eb8bb80a8c22f10b640fe..544b43de9f6dda2a2a5c4d0fea2251a4d7681bf2 100644 (file)
@@ -30,13 +30,18 @@ wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
 
 wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
 { 
-    wxStaticBitmap *bmp = new wxStaticBitmap(m_parentAsWindow,
-                                    GetID(),
-                                    GetBitmap(wxT("bitmap"), GetSize()),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName()
-                                    );
+    wxStaticBitmap *bmp = wxStaticCast(m_instance, wxStaticBitmap);
+
+    if (!bmp)
+       bmp = new wxStaticBitmap;
+
+    bmp->Create(m_parentAsWindow,
+                GetID(),
+                GetBitmap(wxT("bitmap"), GetSize()),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                GetName());
+
     SetupWindow(bmp);
     
     return bmp;
index f3a27b937ee6c997afeae85b46ad3caecd1c674b..977de263d4d526c4e756b9e68f52845063fdae05 100644 (file)
@@ -30,13 +30,18 @@ wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
 
 wxObject *wxStaticBoxXmlHandler::DoCreateResource()
 { 
-    wxStaticBox *box = new wxStaticBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName()
-                                    );
+    wxStaticBox *box = wxStaticCast(m_instance, wxStaticBox);
+
+    if (!box)
+       box = new wxStaticBox;
+
+    box->Create(m_parentAsWindow,
+                GetID(),
+                GetText(wxT("label")),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                GetName());
+
     SetupWindow(box);
     
     return box;
index 72955efbaee59b5bf1730ed6ca9ae98100af0c3e..5f9889a9295cc448aa8e0813e54016b62c989e12 100644 (file)
@@ -34,12 +34,17 @@ wxStaticLineXmlHandler::wxStaticLineXmlHandler()
 
 wxObject *wxStaticLineXmlHandler::DoCreateResource()
 { 
-    wxStaticLine *line = new wxStaticLine(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(wxT("style"), wxLI_HORIZONTAL),
-                                    GetName()
-                                    );
+    wxStaticLine *line = wxStaticCast(m_instance, wxStaticLine);
+
+    if (!line)
+       line = new wxStaticLine;
+
+    line->Create(m_parentAsWindow,
+                GetID(),
+                GetPosition(), GetSize(),
+                GetStyle(wxT("style"), wxLI_HORIZONTAL),
+                GetName());
+
     SetupWindow(line);
     
     return line;
index 63f941fb8e8227726e6ca7dcacfedef5991c92bc..7aba85fda8432d0bae72e358b4167f9031758ec1 100644 (file)
@@ -34,13 +34,18 @@ wxStaticTextXmlHandler::wxStaticTextXmlHandler()
 
 wxObject *wxStaticTextXmlHandler::DoCreateResource()
 { 
-    wxStaticText *text = new wxStaticText(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName()
-                                    );
+    wxStaticText *text = wxStaticCast(m_instance, wxStaticText);
+
+    if (!text)
+       text = new wxStaticText;
+
+    text->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    GetName());
+
     SetupWindow(text);
     
     return text;
index ac1573f297b776c868d107e0a774f485b56d32df..8a77e6ae7b56c79c7087d7121fa254a54494b09e 100644 (file)
@@ -35,14 +35,19 @@ wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
 
 wxObject *wxTextCtrlXmlHandler::DoCreateResource()
 { 
-    wxTextCtrl *text = new wxTextCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("value")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+   wxTextCtrl *text = wxStaticCast(m_instance, wxTextCtrl);
+
+   if ( !text )
+       text = new wxTextCtrl;
+
+   text->Create( m_parentAsWindow,
+                GetID(),
+                GetText(wxT("value")),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                wxDefaultValidator,
+                GetName() );
+
     SetupWindow(text);
     
     return text;
index 3cddf6f6b271a348eb825728a3da50122982fc65..526a3a937712b99bad667ad9a60049d16c5a29e0 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "wx/xrc/xh_toolb.h"
 #include "wx/toolbar.h"
-
+#include "wx/frame.h"
 
 #if wxUSE_TOOLBAR
 
@@ -66,12 +66,18 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
 #ifdef __WXMSW__
         if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
 #endif
-        wxToolBar *toolbar = new wxToolBar(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(),
-                                    GetSize(),
-                                    style,
-                                    GetName());
+
+        wxToolBar *toolbar = wxStaticCast(m_instance, wxToolBar);
+        if ( !toolbar )
+            toolbar = new wxToolBar;
+        toolbar->Create(m_parentAsWindow,
+                         GetID(),
+                         GetPosition(),
+                         GetSize(),
+                         style,
+                         GetName());
 
         wxSize bmpsize = GetSize(wxT("bitmapsize"));
         if (!(bmpsize == wxDefaultSize))
@@ -87,6 +93,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
             toolbar->SetToolSeparation(separation);
 
         wxXmlNode *children_node = GetParamNode(wxT("object"));
+        if (!children_node)
+           children_node = GetParamNode(wxT("object_ref"));
+
         if (children_node == NULL) return toolbar;
 
         m_isInside = TRUE;
@@ -96,8 +105,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
 
         while (n)
         {
-            if (n->GetType() == wxXML_ELEMENT_NODE && 
-                n->GetName() == wxT("object"))
+            if ((n->GetType() == wxXML_ELEMENT_NODE) && 
+                (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
             {
                 wxObject *created = CreateResFromNode(n, toolbar, NULL);
                 wxControl *control = wxDynamicCast(created, wxControl);
@@ -113,6 +122,15 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
         m_toolbar = NULL;
 
         toolbar->Realize();
+
+        // FIXME: how can I create a toolbar without immediately setting it to the frame?
+        if (m_parentAsWindow)
+        {
+            wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
+            if (parentFrame)
+                parentFrame->SetToolBar(toolbar);
+        }
+
         return toolbar;
     }
 }
index 2e6f9f64f2aeb3913abeff4d32dd0f18a0cf115e..cb0cde7e60ea273fe51ddfc7dd1ad9dba157e760 100644 (file)
@@ -35,13 +35,18 @@ wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
 
 wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
 { 
-    wxTreeCtrl *tree = new wxTreeCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName());
-    
+   wxTreeCtrl *tree = wxStaticCast(m_instance, wxTreeCtrl);
+
+   if (!tree)
+       tree = new wxTreeCtrl;
+
+   tree->Create( m_parentAsWindow,
+                GetID(),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                wxDefaultValidator,
+                GetName());
+
     SetupWindow(tree);
     
     return tree;
index 1a0a7486ef988e7fc9f18532af59c11284c395fc..d2c48b42a773c66b4e9080b2d69e63fc4033da96 100644 (file)
@@ -36,13 +36,19 @@ wxButtonXmlHandler::wxButtonXmlHandler()
 
 wxObject *wxButtonXmlHandler::DoCreateResource()
 { 
-    wxButton *button = new wxButton(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName());
+   wxButton *button = wxStaticCast(m_instance, wxButton);
+
+   if (!button)
+       button = new wxButton;
+
+   button->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
+
     if (GetBool(wxT("default"), 0) == 1) button->SetDefault();
     SetupWindow(button);
     
index 1367c5e8f7cdf4bbc0034882e8fd4082e31055f3..4fba39eb75b8e5c2bd4dd282860cbcef87f5e1e0 100644 (file)
@@ -38,13 +38,18 @@ wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
 
 wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
 { 
-    wxCalendarCtrl *calendar = new wxCalendarCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    wxDefaultDateTime,
-                                    /*TODO: take it from resource*/
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName());
+    wxCalendarCtrl *calendar = wxStaticCast(m_instance, wxCalendarCtrl);
+
+    if (!calendar)
+       calendar = new wxCalendarCtrl;
+
+    calendar->Create(m_parentAsWindow,
+                     GetID(),
+                     wxDefaultDateTime,
+                     /*TODO: take it from resource*/
+                     GetPosition(), GetSize(),
+                     GetStyle(),
+                     GetName());
     
     SetupWindow(calendar);
     
index 9bd2eb99ace4f78a886aa9a46e2b3cc917de3a88..493c876f5c596807a256d1492634b904c7a3c216 100644 (file)
@@ -32,14 +32,18 @@ wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
 
 wxObject *wxCheckBoxXmlHandler::DoCreateResource()
 { 
-    wxCheckBox *control = new wxCheckBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxCheckBox *control = wxStaticCast(m_instance, wxCheckBox);
+
+    if (!control)
+       control = new wxCheckBox;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     control->SetValue( GetBool( wxT("checked")));
     SetupWindow(control);
index c9f114ea92d54db8923a0848668af5a7a7f3ebbd..81f06455f025d2518473cdbae17e78b89acb514b 100644 (file)
@@ -45,16 +45,19 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxCheckListBox *control = wxStaticCast(m_instance, wxCheckListBox);
+
+        if (!control)
+           control = new wxCheckListBox;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         // step through children myself (again.)
         wxXmlNode *n = GetParamNode(wxT("content"));
index 9c9e7aa2c172712a2d3a3e2ab4dfd29373be2e57..4de735f9d215ea53fa928dcb89036e342e6d39bf 100644 (file)
@@ -48,16 +48,19 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxChoice *control = new wxChoice(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxChoice *control = wxStaticCast(m_instance, wxChoice);
+
+        if (!control)
+           control = new wxChoice;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index 37c29089c3e924a82b53f621c774519f42543f12..26e9ad9abd82479282ee9288486e6ec762c29f97 100644 (file)
@@ -54,16 +54,20 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
         }
 
 
-        wxComboBox *control = new wxComboBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("value")),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxComboBox *control = wxStaticCast(m_instance, wxComboBox);
+
+        if (!control)
+           control = new wxComboBox;
+            
+       control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetText(wxT("value")),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index 392d9376f7204a12cb5a9dc29cac3f44e3da4b30..ab40e6da07a5e7169286e4aab535ba34a4dacb3f 100644 (file)
@@ -58,8 +58,10 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
                 wxDefaultPosition, wxDefaultSize,
                 GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE),
                 GetName());
-    dlg->SetClientSize(GetSize());
-    dlg->Move(GetPosition());
+    if (HasParam(wxT("size")))
+        dlg->SetClientSize(GetSize());
+    if (HasParam(wxT("pos")))
+        dlg->Move(GetPosition());
     SetupWindow(dlg);
 
     CreateChildren(dlg);
index c8168e6e2b6af610673de1ef0ad62322f9bec80d..2674ea4008ede76a85fcf2febf9882da255e760b 100644 (file)
@@ -59,17 +59,19 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
     
     frame->Create(m_parentAsWindow,
                 GetID(),
-                GetText(_T("title")),
+                GetText(wxT("title")),
                 wxDefaultPosition, wxDefaultSize,
-                GetStyle(_T("style"), wxDEFAULT_FRAME_STYLE),
+                GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
                 GetName());
-    frame->SetClientSize(GetSize());
-    frame->Move(GetPosition());
+    if (HasParam(wxT("size")))
+        frame->SetClientSize(GetSize());
+    if (HasParam(wxT("pos")))
+        frame->Move(GetPosition());
     SetupWindow(frame);
 
     CreateChildren(frame);
     
-    if (GetBool(_("centered"), FALSE))
+    if (GetBool(wxT("centered"), FALSE))
         frame->Centre();
     
     return frame;
@@ -79,7 +81,7 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
 
 bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
 {
-    return IsOfClass(node, _T("wxFrame"));
+    return IsOfClass(node, wxT("wxFrame"));
 }
 
 
index b49257895e624da39ffd13f165b6e0f90ea6d776..4c692b9cbfd9e6a2c5db39d212ad78e4b72dc4b5 100644 (file)
@@ -36,14 +36,18 @@ wxGaugeXmlHandler::wxGaugeXmlHandler()
 
 wxObject *wxGaugeXmlHandler::DoCreateResource()
 { 
-    wxGauge *control = new wxGauge(m_parentAsWindow,
-                                    GetID(),
-                                    GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), 
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxGauge *control = wxStaticCast(m_instance, wxGauge);
+
+    if (!control)
+       control = new wxGauge;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), 
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     if( HasParam( wxT("value") ))
     {
index 53b0808bdf1ff5382e2ebd174607fb7608f48bff..be7716b0081598791530baccee12c27ce71dd5bc 100644 (file)
 wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() 
 : wxXmlResourceHandler() 
 {
-    ADD_STYLE( wxHW_SCROLLBAR_NEVER );
-    ADD_STYLE( wxHW_SCROLLBAR_AUTO );
+    ADD_STYLE(wxHW_SCROLLBAR_NEVER);
+    ADD_STYLE(wxHW_SCROLLBAR_AUTO);
     AddWindowStyles();
 }
 
 wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
-{ 
-    wxHtmlWindow *control = new wxHtmlWindow(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle( wxT("style" ), wxHW_SCROLLBAR_AUTO),
-                                    GetName()
-                                    );
-
-    if( HasParam( wxT("borders") ))
+{
+    wxHtmlWindow *control = wxStaticCast(m_instance, wxHtmlWindow);
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
+                    GetName());
+
+    if (HasParam(wxT("borders")))
     {
-        control->SetBorders( GetDimension( wxT("borders" )));
+        control->SetBorders(GetDimension(wxT("borders")));
     }
 
-    if( HasParam( wxT("url") ))
+    if( HasParam(wxT("url")))
     {
-        wxString url = GetParamValue(wxT("url" ));
+        wxString url = GetParamValue(wxT("url"));
         wxFileSystem& fsys = GetCurFileSystem();
         
         wxFSFile *f = fsys.OpenFile(url);
@@ -64,9 +65,9 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
             control->LoadPage(url);
     }
     
-    else if( HasParam( wxT("htmlcode") ))
+    else if (HasParam(wxT("htmlcode")))
     {
-        control->SetPage( GetText(wxT("htmlcode")) );
+        control->SetPage(GetText(wxT("htmlcode")));
     }
 
     SetupWindow(control);
index d1b48f96d76d7119d22ee3e2338d40e8f65505cf..ce4ecc38184848f538d78d9b52893dd024ad910d 100644 (file)
@@ -54,16 +54,19 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxListBox *control = new wxListBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxListBox *control = wxStaticCast(m_instance, wxListBox);
+
+        if (!control)
+           control = new wxListBox;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index aeb7f5756ecdeb0235ae90f024ba737a1865fdf5..de3635dedee0e8257b16815eef3d1fac931798df 100644 (file)
@@ -46,12 +46,18 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler()
 
 wxObject *wxListCtrlXmlHandler::DoCreateResource()
 { 
-    wxListCtrl *list = new wxListCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName());
+   wxListCtrl *list = wxStaticCast(m_instance, wxListCtrl);
+
+   if (!list)
+       list = new wxListCtrl;
+
+   list->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
+
     /* TODO: columns definition */
     
     SetupWindow(list);
index 709f4e23810cb18d2a75fc1da55ef5a8f4fe6de2..a7935f8018c5d8dc9f793a5d03139c06d96f3718 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "wx/xrc/xh_menu.h"
 #include "wx/menu.h"
+#include "wx/frame.h"
 
 
 wxMenuXmlHandler::wxMenuXmlHandler() : 
@@ -105,13 +106,6 @@ bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
 
 
 
-
-
-
-
-
-
-
 wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
 {
     ADD_STYLE(wxMB_DOCKABLE);
@@ -123,6 +117,14 @@ wxObject *wxMenuBarXmlHandler::DoCreateResource()
 {
     wxMenuBar *menubar = new wxMenuBar(GetStyle());
     CreateChildren(menubar);
+
+    if (m_parentAsWindow)
+    {
+        wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
+        if (parentFrame)
+            parentFrame->SetMenuBar(menubar);
+    }
+
     return menubar;
 }
 
index 7cf5fb9ad22133fbac435976c4a8be95b54c75c6..0a44e451b875bca8cf4e1ff142bf2eabd5af3dc6 100644 (file)
@@ -45,6 +45,9 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
     {
         wxXmlNode *n = GetParamNode(wxT("object"));
 
+       if ( !n )
+           n = GetParamNode(wxT("object_ref"));
+
         if (n)
         {
             bool old_ins = m_isInside;
@@ -68,12 +71,17 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
     }
     
     else {
-        wxNotebook *nb = new wxNotebook(m_parentAsWindow, 
-                                        GetID(),
-                                        GetPosition(), GetSize(),
-                                        GetStyle( wxT("style" )),
-                                        GetName());
-    
+       wxNotebook *nb = wxStaticCast(m_instance, wxNotebook);
+
+       if ( !nb )
+           nb = new wxNotebook;
+
+       nb->Create(m_parentAsWindow, 
+                 GetID(),
+                 GetPosition(), GetSize(),
+                 GetStyle( wxT("style" )),
+                 GetName());
+
         wxNotebook *old_par = m_notebook;
         m_notebook = nb;
         bool old_ins = m_isInside;
index bc3552dc7ca101af140938889798b0417fb574d5..539527bbcaf793bb2c47f54dc3009b565a6cac54 100644 (file)
@@ -38,18 +38,15 @@ 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());
+    if (!panel)
+       panel = new wxPanel;
+
+    panel->Create(m_parentAsWindow,
+                  GetID(),
+                  GetPosition(), GetSize(),
+                  GetStyle(wxT("style"), wxTAB_TRAVERSAL),
+                  GetName());
+
     SetupWindow(panel);
     CreateChildren(panel);
     
index a14b34a72f9e966b795418b745f4c1712ad5e861..a850d4443713790ee12f64476481b531967bcac1 100644 (file)
@@ -40,14 +40,18 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
      * normal radio button.
      */ 
 
-    wxRadioButton *control = new wxRadioButton(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxRadioButton *control = wxStaticCast(m_instance, wxRadioButton);
+
+    if (!control)
+       control = new wxRadioButton;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     control->SetValue( GetBool(wxT("value"), 0));
     SetupWindow(control);
index 17beaac5f9315217dd56bff5c98d8134d7372ba8..2fbf045da3bf162da67c9ad7efb2945a0825b87d 100644 (file)
@@ -53,18 +53,21 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
                 strings[i]=strList[i];
         }
 
-
-        wxRadioBox *control = new wxRadioBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    strList.GetCount(),
-                                    strings,
-                                    GetLong( wxT("dimension"), 1 ),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+        wxRadioBox *control = wxStaticCast(m_instance, wxRadioBox);
+
+        if (!control)
+           control = new wxRadioBox;
+
+        control->Create(m_parentAsWindow,
+                        GetID(),
+                        GetText(wxT("label")),
+                        GetPosition(), GetSize(),
+                        strList.GetCount(),
+                        strings,
+                        GetLong(wxT("dimension"), 1),
+                        GetStyle(),
+                        wxDefaultValidator,
+                        GetName());
 
         if( selection != -1 )
             control->SetSelection( selection );
index 0171894f87cbe0321597ecb694f7fa699e43f69f..6e2dfb1b7125973f4cce23beeb10837a055b23cf 100644 (file)
@@ -33,13 +33,18 @@ wxScrollBarXmlHandler::wxScrollBarXmlHandler()
 
 wxObject *wxScrollBarXmlHandler::DoCreateResource()
 { 
-    wxScrollBar *control = new wxScrollBar(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxScrollBar *control = wxStaticCast(m_instance, wxScrollBar);
+
+    if (!control)
+       control = new wxScrollBar;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
+
     control->SetScrollbar(GetLong( wxT("value"), 0), 
                           GetLong( wxT("thumbsize"),1),
                           GetLong( wxT("range"), 10),
index 7b6aff301baf69ca7bbed9fbacaf01b630d950b6..bd56618d03c9835ad89e14d5228b3571b7e2d64d 100644 (file)
@@ -78,6 +78,9 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
     {
         wxXmlNode *n = GetParamNode(wxT("object"));
 
+       if ( !n )
+           n = GetParamNode(wxT("object_ref"));
+
         if (n)
         {
             bool old_ins = m_isInside;
index c0aec234639182c06834af26c75939e4d09195c7..de99697f634bd1b1459ea3389a496713a8ec03e4 100644 (file)
@@ -42,16 +42,20 @@ wxSliderXmlHandler::wxSliderXmlHandler()
 
 wxObject *wxSliderXmlHandler::DoCreateResource()
 { 
-    wxSlider *control = new wxSlider(m_parentAsWindow,
-                                    GetID(),
-                                    GetLong( wxT("value"), wxSL_DEFAULT_VALUE), 
-                                    GetLong( wxT("min"), wxSL_DEFAULT_MIN),
-                                    GetLong( wxT("max"), wxSL_DEFAULT_MAX),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+    wxSlider *control = wxStaticCast(m_instance, wxSlider);
+
+    if (!control)
+       control = new wxSlider;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetLong(wxT("value"), wxSL_DEFAULT_VALUE), 
+                    GetLong(wxT("min"), wxSL_DEFAULT_MIN),
+                    GetLong(wxT("max"), wxSL_DEFAULT_MAX),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    wxDefaultValidator,
+                    GetName());
 
     if( HasParam( wxT("tickfreq") ))
     {
index 3888c6daa3779823bc31f6ba646cf8a191b7518c..3940024ef0de86633d08e35bb1a19e9c52e6c892 100644 (file)
@@ -36,12 +36,16 @@ wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
 
 wxObject *wxSpinButtonXmlHandler::DoCreateResource()
 { 
-    wxSpinButton *control = new wxSpinButton(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle( wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS ),
-                                    GetName()
-                                    );
+    wxSpinButton *control = wxStaticCast(m_instance, wxSpinButton);
+
+    if (!control)
+       control = new wxSpinButton;
+
+    control->Create(m_parentAsWindow,
+                    GetID(),
+                    GetPosition(), GetSize(),
+                    GetStyle(wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS),
+                    GetName());
 
     control->SetValue( GetLong( wxT("value"), wxSP_DEFAULT_VALUE) );
     control->SetRange( GetLong( wxT("min"), wxSP_DEFAULT_MIN),
index 034fe3dd68f8f40e9e3eb8bb80a8c22f10b640fe..544b43de9f6dda2a2a5c4d0fea2251a4d7681bf2 100644 (file)
@@ -30,13 +30,18 @@ wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
 
 wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
 { 
-    wxStaticBitmap *bmp = new wxStaticBitmap(m_parentAsWindow,
-                                    GetID(),
-                                    GetBitmap(wxT("bitmap"), GetSize()),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName()
-                                    );
+    wxStaticBitmap *bmp = wxStaticCast(m_instance, wxStaticBitmap);
+
+    if (!bmp)
+       bmp = new wxStaticBitmap;
+
+    bmp->Create(m_parentAsWindow,
+                GetID(),
+                GetBitmap(wxT("bitmap"), GetSize()),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                GetName());
+
     SetupWindow(bmp);
     
     return bmp;
index f3a27b937ee6c997afeae85b46ad3caecd1c674b..977de263d4d526c4e756b9e68f52845063fdae05 100644 (file)
@@ -30,13 +30,18 @@ wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
 
 wxObject *wxStaticBoxXmlHandler::DoCreateResource()
 { 
-    wxStaticBox *box = new wxStaticBox(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName()
-                                    );
+    wxStaticBox *box = wxStaticCast(m_instance, wxStaticBox);
+
+    if (!box)
+       box = new wxStaticBox;
+
+    box->Create(m_parentAsWindow,
+                GetID(),
+                GetText(wxT("label")),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                GetName());
+
     SetupWindow(box);
     
     return box;
index 72955efbaee59b5bf1730ed6ca9ae98100af0c3e..5f9889a9295cc448aa8e0813e54016b62c989e12 100644 (file)
@@ -34,12 +34,17 @@ wxStaticLineXmlHandler::wxStaticLineXmlHandler()
 
 wxObject *wxStaticLineXmlHandler::DoCreateResource()
 { 
-    wxStaticLine *line = new wxStaticLine(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(wxT("style"), wxLI_HORIZONTAL),
-                                    GetName()
-                                    );
+    wxStaticLine *line = wxStaticCast(m_instance, wxStaticLine);
+
+    if (!line)
+       line = new wxStaticLine;
+
+    line->Create(m_parentAsWindow,
+                GetID(),
+                GetPosition(), GetSize(),
+                GetStyle(wxT("style"), wxLI_HORIZONTAL),
+                GetName());
+
     SetupWindow(line);
     
     return line;
index 63f941fb8e8227726e6ca7dcacfedef5991c92bc..7aba85fda8432d0bae72e358b4167f9031758ec1 100644 (file)
@@ -34,13 +34,18 @@ wxStaticTextXmlHandler::wxStaticTextXmlHandler()
 
 wxObject *wxStaticTextXmlHandler::DoCreateResource()
 { 
-    wxStaticText *text = new wxStaticText(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("label")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    GetName()
-                                    );
+    wxStaticText *text = wxStaticCast(m_instance, wxStaticText);
+
+    if (!text)
+       text = new wxStaticText;
+
+    text->Create(m_parentAsWindow,
+                    GetID(),
+                    GetText(wxT("label")),
+                    GetPosition(), GetSize(),
+                    GetStyle(),
+                    GetName());
+
     SetupWindow(text);
     
     return text;
index ac1573f297b776c868d107e0a774f485b56d32df..8a77e6ae7b56c79c7087d7121fa254a54494b09e 100644 (file)
@@ -35,14 +35,19 @@ wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
 
 wxObject *wxTextCtrlXmlHandler::DoCreateResource()
 { 
-    wxTextCtrl *text = new wxTextCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    GetText(wxT("value")),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName()
-                                    );
+   wxTextCtrl *text = wxStaticCast(m_instance, wxTextCtrl);
+
+   if ( !text )
+       text = new wxTextCtrl;
+
+   text->Create( m_parentAsWindow,
+                GetID(),
+                GetText(wxT("value")),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                wxDefaultValidator,
+                GetName() );
+
     SetupWindow(text);
     
     return text;
index 3cddf6f6b271a348eb825728a3da50122982fc65..526a3a937712b99bad667ad9a60049d16c5a29e0 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "wx/xrc/xh_toolb.h"
 #include "wx/toolbar.h"
-
+#include "wx/frame.h"
 
 #if wxUSE_TOOLBAR
 
@@ -66,12 +66,18 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
 #ifdef __WXMSW__
         if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
 #endif
-        wxToolBar *toolbar = new wxToolBar(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(),
-                                    GetSize(),
-                                    style,
-                                    GetName());
+
+        wxToolBar *toolbar = wxStaticCast(m_instance, wxToolBar);
+        if ( !toolbar )
+            toolbar = new wxToolBar;
+        toolbar->Create(m_parentAsWindow,
+                         GetID(),
+                         GetPosition(),
+                         GetSize(),
+                         style,
+                         GetName());
 
         wxSize bmpsize = GetSize(wxT("bitmapsize"));
         if (!(bmpsize == wxDefaultSize))
@@ -87,6 +93,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
             toolbar->SetToolSeparation(separation);
 
         wxXmlNode *children_node = GetParamNode(wxT("object"));
+        if (!children_node)
+           children_node = GetParamNode(wxT("object_ref"));
+
         if (children_node == NULL) return toolbar;
 
         m_isInside = TRUE;
@@ -96,8 +105,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
 
         while (n)
         {
-            if (n->GetType() == wxXML_ELEMENT_NODE && 
-                n->GetName() == wxT("object"))
+            if ((n->GetType() == wxXML_ELEMENT_NODE) && 
+                (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
             {
                 wxObject *created = CreateResFromNode(n, toolbar, NULL);
                 wxControl *control = wxDynamicCast(created, wxControl);
@@ -113,6 +122,15 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
         m_toolbar = NULL;
 
         toolbar->Realize();
+
+        // FIXME: how can I create a toolbar without immediately setting it to the frame?
+        if (m_parentAsWindow)
+        {
+            wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
+            if (parentFrame)
+                parentFrame->SetToolBar(toolbar);
+        }
+
         return toolbar;
     }
 }
index 2e6f9f64f2aeb3913abeff4d32dd0f18a0cf115e..cb0cde7e60ea273fe51ddfc7dd1ad9dba157e760 100644 (file)
@@ -35,13 +35,18 @@ wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
 
 wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
 { 
-    wxTreeCtrl *tree = new wxTreeCtrl(m_parentAsWindow,
-                                    GetID(),
-                                    GetPosition(), GetSize(),
-                                    GetStyle(),
-                                    wxDefaultValidator,
-                                    GetName());
-    
+   wxTreeCtrl *tree = wxStaticCast(m_instance, wxTreeCtrl);
+
+   if (!tree)
+       tree = new wxTreeCtrl;
+
+   tree->Create( m_parentAsWindow,
+                GetID(),
+                GetPosition(), GetSize(),
+                GetStyle(),
+                wxDefaultValidator,
+                GetName());
+
     SetupWindow(tree);
     
     return tree;