From f25881804583790351480098b50f4ce1b924e697 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 27 Dec 2001 23:16:48 +0000 Subject: [PATCH] Changes to the XRC library: 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 --- contrib/src/xrc/xh_bttn.cpp | 20 +++++++++++++------- contrib/src/xrc/xh_cald.cpp | 19 ++++++++++++------- contrib/src/xrc/xh_chckb.cpp | 20 ++++++++++++-------- contrib/src/xrc/xh_chckl.cpp | 23 +++++++++++++---------- contrib/src/xrc/xh_choic.cpp | 23 +++++++++++++---------- contrib/src/xrc/xh_combo.cpp | 24 ++++++++++++++---------- contrib/src/xrc/xh_dlg.cpp | 6 ++++-- contrib/src/xrc/xh_frame.cpp | 14 ++++++++------ contrib/src/xrc/xh_gauge.cpp | 20 ++++++++++++-------- contrib/src/xrc/xh_html.cpp | 33 +++++++++++++++++---------------- contrib/src/xrc/xh_listb.cpp | 23 +++++++++++++---------- contrib/src/xrc/xh_listc.cpp | 18 ++++++++++++------ contrib/src/xrc/xh_menu.cpp | 16 +++++++++------- contrib/src/xrc/xh_notbk.cpp | 20 ++++++++++++++------ contrib/src/xrc/xh_panel.cpp | 21 +++++++++------------ contrib/src/xrc/xh_radbt.cpp | 20 ++++++++++++-------- contrib/src/xrc/xh_radbx.cpp | 27 +++++++++++++++------------ contrib/src/xrc/xh_scrol.cpp | 19 ++++++++++++------- contrib/src/xrc/xh_sizer.cpp | 3 +++ contrib/src/xrc/xh_slidr.cpp | 24 ++++++++++++++---------- contrib/src/xrc/xh_spin.cpp | 16 ++++++++++------ contrib/src/xrc/xh_stbmp.cpp | 19 ++++++++++++------- contrib/src/xrc/xh_stbox.cpp | 19 ++++++++++++------- contrib/src/xrc/xh_stlin.cpp | 17 +++++++++++------ contrib/src/xrc/xh_sttxt.cpp | 19 ++++++++++++------- contrib/src/xrc/xh_text.cpp | 21 +++++++++++++-------- contrib/src/xrc/xh_toolb.cpp | 36 +++++++++++++++++++++++++++--------- contrib/src/xrc/xh_tree.cpp | 19 ++++++++++++------- src/xrc/xh_bttn.cpp | 20 +++++++++++++------- src/xrc/xh_cald.cpp | 19 ++++++++++++------- src/xrc/xh_chckb.cpp | 20 ++++++++++++-------- src/xrc/xh_chckl.cpp | 23 +++++++++++++---------- src/xrc/xh_choic.cpp | 23 +++++++++++++---------- src/xrc/xh_combo.cpp | 24 ++++++++++++++---------- src/xrc/xh_dlg.cpp | 6 ++++-- src/xrc/xh_frame.cpp | 14 ++++++++------ src/xrc/xh_gauge.cpp | 20 ++++++++++++-------- src/xrc/xh_html.cpp | 33 +++++++++++++++++---------------- src/xrc/xh_listb.cpp | 23 +++++++++++++---------- src/xrc/xh_listc.cpp | 18 ++++++++++++------ src/xrc/xh_menu.cpp | 16 +++++++++------- src/xrc/xh_notbk.cpp | 20 ++++++++++++++------ src/xrc/xh_panel.cpp | 21 +++++++++------------ src/xrc/xh_radbt.cpp | 20 ++++++++++++-------- src/xrc/xh_radbx.cpp | 27 +++++++++++++++------------ src/xrc/xh_scrol.cpp | 19 ++++++++++++------- src/xrc/xh_sizer.cpp | 3 +++ src/xrc/xh_slidr.cpp | 24 ++++++++++++++---------- src/xrc/xh_spin.cpp | 16 ++++++++++------ src/xrc/xh_stbmp.cpp | 19 ++++++++++++------- src/xrc/xh_stbox.cpp | 19 ++++++++++++------- src/xrc/xh_stlin.cpp | 17 +++++++++++------ src/xrc/xh_sttxt.cpp | 19 ++++++++++++------- src/xrc/xh_text.cpp | 21 +++++++++++++-------- src/xrc/xh_toolb.cpp | 36 +++++++++++++++++++++++++++--------- src/xrc/xh_tree.cpp | 19 ++++++++++++------- 56 files changed, 680 insertions(+), 438 deletions(-) diff --git a/contrib/src/xrc/xh_bttn.cpp b/contrib/src/xrc/xh_bttn.cpp index 1a0a7486ef..d2c48b42a7 100644 --- a/contrib/src/xrc/xh_bttn.cpp +++ b/contrib/src/xrc/xh_bttn.cpp @@ -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); diff --git a/contrib/src/xrc/xh_cald.cpp b/contrib/src/xrc/xh_cald.cpp index 1367c5e8f7..4fba39eb75 100644 --- a/contrib/src/xrc/xh_cald.cpp +++ b/contrib/src/xrc/xh_cald.cpp @@ -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); diff --git a/contrib/src/xrc/xh_chckb.cpp b/contrib/src/xrc/xh_chckb.cpp index 9bd2eb99ac..493c876f5c 100644 --- a/contrib/src/xrc/xh_chckb.cpp +++ b/contrib/src/xrc/xh_chckb.cpp @@ -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); diff --git a/contrib/src/xrc/xh_chckl.cpp b/contrib/src/xrc/xh_chckl.cpp index c9f114ea92..81f06455f0 100644 --- a/contrib/src/xrc/xh_chckl.cpp +++ b/contrib/src/xrc/xh_chckl.cpp @@ -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")); diff --git a/contrib/src/xrc/xh_choic.cpp b/contrib/src/xrc/xh_choic.cpp index 9c9e7aa2c1..4de735f9d2 100644 --- a/contrib/src/xrc/xh_choic.cpp +++ b/contrib/src/xrc/xh_choic.cpp @@ -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 ); diff --git a/contrib/src/xrc/xh_combo.cpp b/contrib/src/xrc/xh_combo.cpp index 37c29089c3..26e9ad9abd 100644 --- a/contrib/src/xrc/xh_combo.cpp +++ b/contrib/src/xrc/xh_combo.cpp @@ -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 ); diff --git a/contrib/src/xrc/xh_dlg.cpp b/contrib/src/xrc/xh_dlg.cpp index 392d9376f7..ab40e6da07 100644 --- a/contrib/src/xrc/xh_dlg.cpp +++ b/contrib/src/xrc/xh_dlg.cpp @@ -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); diff --git a/contrib/src/xrc/xh_frame.cpp b/contrib/src/xrc/xh_frame.cpp index c8168e6e2b..2674ea4008 100644 --- a/contrib/src/xrc/xh_frame.cpp +++ b/contrib/src/xrc/xh_frame.cpp @@ -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")); } diff --git a/contrib/src/xrc/xh_gauge.cpp b/contrib/src/xrc/xh_gauge.cpp index b49257895e..4c692b9cbf 100644 --- a/contrib/src/xrc/xh_gauge.cpp +++ b/contrib/src/xrc/xh_gauge.cpp @@ -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") )) { diff --git a/contrib/src/xrc/xh_html.cpp b/contrib/src/xrc/xh_html.cpp index 53b0808bdf..be7716b008 100644 --- a/contrib/src/xrc/xh_html.cpp +++ b/contrib/src/xrc/xh_html.cpp @@ -30,28 +30,29 @@ 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); diff --git a/contrib/src/xrc/xh_listb.cpp b/contrib/src/xrc/xh_listb.cpp index d1b48f96d7..ce4ecc3818 100644 --- a/contrib/src/xrc/xh_listb.cpp +++ b/contrib/src/xrc/xh_listb.cpp @@ -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 ); diff --git a/contrib/src/xrc/xh_listc.cpp b/contrib/src/xrc/xh_listc.cpp index aeb7f5756e..de3635dede 100644 --- a/contrib/src/xrc/xh_listc.cpp +++ b/contrib/src/xrc/xh_listc.cpp @@ -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); diff --git a/contrib/src/xrc/xh_menu.cpp b/contrib/src/xrc/xh_menu.cpp index 709f4e2381..a7935f8018 100644 --- a/contrib/src/xrc/xh_menu.cpp +++ b/contrib/src/xrc/xh_menu.cpp @@ -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; } diff --git a/contrib/src/xrc/xh_notbk.cpp b/contrib/src/xrc/xh_notbk.cpp index 7cf5fb9ad2..0a44e451b8 100644 --- a/contrib/src/xrc/xh_notbk.cpp +++ b/contrib/src/xrc/xh_notbk.cpp @@ -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; diff --git a/contrib/src/xrc/xh_panel.cpp b/contrib/src/xrc/xh_panel.cpp index bc3552dc7c..539527bbca 100644 --- a/contrib/src/xrc/xh_panel.cpp +++ b/contrib/src/xrc/xh_panel.cpp @@ -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); diff --git a/contrib/src/xrc/xh_radbt.cpp b/contrib/src/xrc/xh_radbt.cpp index a14b34a72f..a850d44437 100644 --- a/contrib/src/xrc/xh_radbt.cpp +++ b/contrib/src/xrc/xh_radbt.cpp @@ -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); diff --git a/contrib/src/xrc/xh_radbx.cpp b/contrib/src/xrc/xh_radbx.cpp index 17beaac5f9..2fbf045da3 100644 --- a/contrib/src/xrc/xh_radbx.cpp +++ b/contrib/src/xrc/xh_radbx.cpp @@ -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 ); diff --git a/contrib/src/xrc/xh_scrol.cpp b/contrib/src/xrc/xh_scrol.cpp index 0171894f87..6e2dfb1b71 100644 --- a/contrib/src/xrc/xh_scrol.cpp +++ b/contrib/src/xrc/xh_scrol.cpp @@ -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), diff --git a/contrib/src/xrc/xh_sizer.cpp b/contrib/src/xrc/xh_sizer.cpp index 7b6aff301b..bd56618d03 100644 --- a/contrib/src/xrc/xh_sizer.cpp +++ b/contrib/src/xrc/xh_sizer.cpp @@ -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; diff --git a/contrib/src/xrc/xh_slidr.cpp b/contrib/src/xrc/xh_slidr.cpp index c0aec23463..de99697f63 100644 --- a/contrib/src/xrc/xh_slidr.cpp +++ b/contrib/src/xrc/xh_slidr.cpp @@ -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") )) { diff --git a/contrib/src/xrc/xh_spin.cpp b/contrib/src/xrc/xh_spin.cpp index 3888c6daa3..3940024ef0 100644 --- a/contrib/src/xrc/xh_spin.cpp +++ b/contrib/src/xrc/xh_spin.cpp @@ -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), diff --git a/contrib/src/xrc/xh_stbmp.cpp b/contrib/src/xrc/xh_stbmp.cpp index 034fe3dd68..544b43de9f 100644 --- a/contrib/src/xrc/xh_stbmp.cpp +++ b/contrib/src/xrc/xh_stbmp.cpp @@ -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; diff --git a/contrib/src/xrc/xh_stbox.cpp b/contrib/src/xrc/xh_stbox.cpp index f3a27b937e..977de263d4 100644 --- a/contrib/src/xrc/xh_stbox.cpp +++ b/contrib/src/xrc/xh_stbox.cpp @@ -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; diff --git a/contrib/src/xrc/xh_stlin.cpp b/contrib/src/xrc/xh_stlin.cpp index 72955efbae..5f9889a929 100644 --- a/contrib/src/xrc/xh_stlin.cpp +++ b/contrib/src/xrc/xh_stlin.cpp @@ -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; diff --git a/contrib/src/xrc/xh_sttxt.cpp b/contrib/src/xrc/xh_sttxt.cpp index 63f941fb8e..7aba85fda8 100644 --- a/contrib/src/xrc/xh_sttxt.cpp +++ b/contrib/src/xrc/xh_sttxt.cpp @@ -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; diff --git a/contrib/src/xrc/xh_text.cpp b/contrib/src/xrc/xh_text.cpp index ac1573f297..8a77e6ae7b 100644 --- a/contrib/src/xrc/xh_text.cpp +++ b/contrib/src/xrc/xh_text.cpp @@ -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; diff --git a/contrib/src/xrc/xh_toolb.cpp b/contrib/src/xrc/xh_toolb.cpp index 3cddf6f6b2..526a3a9377 100644 --- a/contrib/src/xrc/xh_toolb.cpp +++ b/contrib/src/xrc/xh_toolb.cpp @@ -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; } } diff --git a/contrib/src/xrc/xh_tree.cpp b/contrib/src/xrc/xh_tree.cpp index 2e6f9f64f2..cb0cde7e60 100644 --- a/contrib/src/xrc/xh_tree.cpp +++ b/contrib/src/xrc/xh_tree.cpp @@ -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; diff --git a/src/xrc/xh_bttn.cpp b/src/xrc/xh_bttn.cpp index 1a0a7486ef..d2c48b42a7 100644 --- a/src/xrc/xh_bttn.cpp +++ b/src/xrc/xh_bttn.cpp @@ -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); diff --git a/src/xrc/xh_cald.cpp b/src/xrc/xh_cald.cpp index 1367c5e8f7..4fba39eb75 100644 --- a/src/xrc/xh_cald.cpp +++ b/src/xrc/xh_cald.cpp @@ -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); diff --git a/src/xrc/xh_chckb.cpp b/src/xrc/xh_chckb.cpp index 9bd2eb99ac..493c876f5c 100644 --- a/src/xrc/xh_chckb.cpp +++ b/src/xrc/xh_chckb.cpp @@ -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); diff --git a/src/xrc/xh_chckl.cpp b/src/xrc/xh_chckl.cpp index c9f114ea92..81f06455f0 100644 --- a/src/xrc/xh_chckl.cpp +++ b/src/xrc/xh_chckl.cpp @@ -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")); diff --git a/src/xrc/xh_choic.cpp b/src/xrc/xh_choic.cpp index 9c9e7aa2c1..4de735f9d2 100644 --- a/src/xrc/xh_choic.cpp +++ b/src/xrc/xh_choic.cpp @@ -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 ); diff --git a/src/xrc/xh_combo.cpp b/src/xrc/xh_combo.cpp index 37c29089c3..26e9ad9abd 100644 --- a/src/xrc/xh_combo.cpp +++ b/src/xrc/xh_combo.cpp @@ -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 ); diff --git a/src/xrc/xh_dlg.cpp b/src/xrc/xh_dlg.cpp index 392d9376f7..ab40e6da07 100644 --- a/src/xrc/xh_dlg.cpp +++ b/src/xrc/xh_dlg.cpp @@ -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); diff --git a/src/xrc/xh_frame.cpp b/src/xrc/xh_frame.cpp index c8168e6e2b..2674ea4008 100644 --- a/src/xrc/xh_frame.cpp +++ b/src/xrc/xh_frame.cpp @@ -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")); } diff --git a/src/xrc/xh_gauge.cpp b/src/xrc/xh_gauge.cpp index b49257895e..4c692b9cbf 100644 --- a/src/xrc/xh_gauge.cpp +++ b/src/xrc/xh_gauge.cpp @@ -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") )) { diff --git a/src/xrc/xh_html.cpp b/src/xrc/xh_html.cpp index 53b0808bdf..be7716b008 100644 --- a/src/xrc/xh_html.cpp +++ b/src/xrc/xh_html.cpp @@ -30,28 +30,29 @@ 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); diff --git a/src/xrc/xh_listb.cpp b/src/xrc/xh_listb.cpp index d1b48f96d7..ce4ecc3818 100644 --- a/src/xrc/xh_listb.cpp +++ b/src/xrc/xh_listb.cpp @@ -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 ); diff --git a/src/xrc/xh_listc.cpp b/src/xrc/xh_listc.cpp index aeb7f5756e..de3635dede 100644 --- a/src/xrc/xh_listc.cpp +++ b/src/xrc/xh_listc.cpp @@ -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); diff --git a/src/xrc/xh_menu.cpp b/src/xrc/xh_menu.cpp index 709f4e2381..a7935f8018 100644 --- a/src/xrc/xh_menu.cpp +++ b/src/xrc/xh_menu.cpp @@ -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; } diff --git a/src/xrc/xh_notbk.cpp b/src/xrc/xh_notbk.cpp index 7cf5fb9ad2..0a44e451b8 100644 --- a/src/xrc/xh_notbk.cpp +++ b/src/xrc/xh_notbk.cpp @@ -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; diff --git a/src/xrc/xh_panel.cpp b/src/xrc/xh_panel.cpp index bc3552dc7c..539527bbca 100644 --- a/src/xrc/xh_panel.cpp +++ b/src/xrc/xh_panel.cpp @@ -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); diff --git a/src/xrc/xh_radbt.cpp b/src/xrc/xh_radbt.cpp index a14b34a72f..a850d44437 100644 --- a/src/xrc/xh_radbt.cpp +++ b/src/xrc/xh_radbt.cpp @@ -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); diff --git a/src/xrc/xh_radbx.cpp b/src/xrc/xh_radbx.cpp index 17beaac5f9..2fbf045da3 100644 --- a/src/xrc/xh_radbx.cpp +++ b/src/xrc/xh_radbx.cpp @@ -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 ); diff --git a/src/xrc/xh_scrol.cpp b/src/xrc/xh_scrol.cpp index 0171894f87..6e2dfb1b71 100644 --- a/src/xrc/xh_scrol.cpp +++ b/src/xrc/xh_scrol.cpp @@ -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), diff --git a/src/xrc/xh_sizer.cpp b/src/xrc/xh_sizer.cpp index 7b6aff301b..bd56618d03 100644 --- a/src/xrc/xh_sizer.cpp +++ b/src/xrc/xh_sizer.cpp @@ -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; diff --git a/src/xrc/xh_slidr.cpp b/src/xrc/xh_slidr.cpp index c0aec23463..de99697f63 100644 --- a/src/xrc/xh_slidr.cpp +++ b/src/xrc/xh_slidr.cpp @@ -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") )) { diff --git a/src/xrc/xh_spin.cpp b/src/xrc/xh_spin.cpp index 3888c6daa3..3940024ef0 100644 --- a/src/xrc/xh_spin.cpp +++ b/src/xrc/xh_spin.cpp @@ -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), diff --git a/src/xrc/xh_stbmp.cpp b/src/xrc/xh_stbmp.cpp index 034fe3dd68..544b43de9f 100644 --- a/src/xrc/xh_stbmp.cpp +++ b/src/xrc/xh_stbmp.cpp @@ -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; diff --git a/src/xrc/xh_stbox.cpp b/src/xrc/xh_stbox.cpp index f3a27b937e..977de263d4 100644 --- a/src/xrc/xh_stbox.cpp +++ b/src/xrc/xh_stbox.cpp @@ -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; diff --git a/src/xrc/xh_stlin.cpp b/src/xrc/xh_stlin.cpp index 72955efbae..5f9889a929 100644 --- a/src/xrc/xh_stlin.cpp +++ b/src/xrc/xh_stlin.cpp @@ -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; diff --git a/src/xrc/xh_sttxt.cpp b/src/xrc/xh_sttxt.cpp index 63f941fb8e..7aba85fda8 100644 --- a/src/xrc/xh_sttxt.cpp +++ b/src/xrc/xh_sttxt.cpp @@ -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; diff --git a/src/xrc/xh_text.cpp b/src/xrc/xh_text.cpp index ac1573f297..8a77e6ae7b 100644 --- a/src/xrc/xh_text.cpp +++ b/src/xrc/xh_text.cpp @@ -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; diff --git a/src/xrc/xh_toolb.cpp b/src/xrc/xh_toolb.cpp index 3cddf6f6b2..526a3a9377 100644 --- a/src/xrc/xh_toolb.cpp +++ b/src/xrc/xh_toolb.cpp @@ -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; } } diff --git a/src/xrc/xh_tree.cpp b/src/xrc/xh_tree.cpp index 2e6f9f64f2..cb0cde7e60 100644 --- a/src/xrc/xh_tree.cpp +++ b/src/xrc/xh_tree.cpp @@ -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; -- 2.45.2