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
This commit is contained in:
Václav Slavík 2001-12-27 23:16:48 +00:00
parent 7ee7772018
commit f258818045
56 changed files with 670 additions and 428 deletions

View File

@ -36,13 +36,19 @@ wxButtonXmlHandler::wxButtonXmlHandler()
wxObject *wxButtonXmlHandler::DoCreateResource() wxObject *wxButtonXmlHandler::DoCreateResource()
{ {
wxButton *button = new wxButton(m_parentAsWindow, wxButton *button = wxStaticCast(m_instance, wxButton);
GetID(),
GetText(wxT("label")), if (!button)
GetPosition(), GetSize(), button = new wxButton;
GetStyle(),
wxDefaultValidator, button->Create(m_parentAsWindow,
GetName()); GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if (GetBool(wxT("default"), 0) == 1) button->SetDefault(); if (GetBool(wxT("default"), 0) == 1) button->SetDefault();
SetupWindow(button); SetupWindow(button);

View File

@ -38,13 +38,18 @@ wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
wxObject *wxCalendarCtrlXmlHandler::DoCreateResource() wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
{ {
wxCalendarCtrl *calendar = new wxCalendarCtrl(m_parentAsWindow, wxCalendarCtrl *calendar = wxStaticCast(m_instance, wxCalendarCtrl);
GetID(),
wxDefaultDateTime, if (!calendar)
/*TODO: take it from resource*/ calendar = new wxCalendarCtrl;
GetPosition(), GetSize(),
GetStyle(), calendar->Create(m_parentAsWindow,
GetName()); GetID(),
wxDefaultDateTime,
/*TODO: take it from resource*/
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(calendar); SetupWindow(calendar);

View File

@ -32,14 +32,18 @@ wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
wxObject *wxCheckBoxXmlHandler::DoCreateResource() wxObject *wxCheckBoxXmlHandler::DoCreateResource()
{ {
wxCheckBox *control = new wxCheckBox(m_parentAsWindow, wxCheckBox *control = wxStaticCast(m_instance, wxCheckBox);
GetID(),
GetText(wxT("label")), if (!control)
GetPosition(), GetSize(), control = new wxCheckBox;
GetStyle(),
wxDefaultValidator, control->Create(m_parentAsWindow,
GetName() GetID(),
); GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetValue( GetBool( wxT("checked"))); control->SetValue( GetBool( wxT("checked")));
SetupWindow(control); SetupWindow(control);

View File

@ -45,16 +45,19 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxCheckListBox *control = wxStaticCast(m_instance, wxCheckListBox);
wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow, if (!control)
GetID(), control = new wxCheckListBox;
GetPosition(), GetSize(),
strList.GetCount(), control->Create(m_parentAsWindow,
strings, GetID(),
GetStyle(), GetPosition(), GetSize(),
wxDefaultValidator, strList.GetCount(),
GetName() strings,
); GetStyle(),
wxDefaultValidator,
GetName());
// step through children myself (again.) // step through children myself (again.)
wxXmlNode *n = GetParamNode(wxT("content")); wxXmlNode *n = GetParamNode(wxT("content"));

View File

@ -48,16 +48,19 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxChoice *control = wxStaticCast(m_instance, wxChoice);
wxChoice *control = new wxChoice(m_parentAsWindow, if (!control)
GetID(), control = new wxChoice;
GetPosition(), GetSize(),
strList.GetCount(), control->Create(m_parentAsWindow,
strings, GetID(),
GetStyle(), GetPosition(), GetSize(),
wxDefaultValidator, strList.GetCount(),
GetName() strings,
); GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -54,16 +54,20 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
} }
wxComboBox *control = new wxComboBox(m_parentAsWindow, wxComboBox *control = wxStaticCast(m_instance, wxComboBox);
GetID(),
GetText(wxT("value")), if (!control)
GetPosition(), GetSize(), control = new wxComboBox;
strList.GetCount(),
strings, control->Create(m_parentAsWindow,
GetStyle(), GetID(),
wxDefaultValidator, GetText(wxT("value")),
GetName() GetPosition(), GetSize(),
); strList.GetCount(),
strings,
GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -58,8 +58,10 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE), GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE),
GetName()); GetName());
dlg->SetClientSize(GetSize()); if (HasParam(wxT("size")))
dlg->Move(GetPosition()); dlg->SetClientSize(GetSize());
if (HasParam(wxT("pos")))
dlg->Move(GetPosition());
SetupWindow(dlg); SetupWindow(dlg);
CreateChildren(dlg); CreateChildren(dlg);

View File

@ -59,17 +59,19 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
frame->Create(m_parentAsWindow, frame->Create(m_parentAsWindow,
GetID(), GetID(),
GetText(_T("title")), GetText(wxT("title")),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
GetStyle(_T("style"), wxDEFAULT_FRAME_STYLE), GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
GetName()); GetName());
frame->SetClientSize(GetSize()); if (HasParam(wxT("size")))
frame->Move(GetPosition()); frame->SetClientSize(GetSize());
if (HasParam(wxT("pos")))
frame->Move(GetPosition());
SetupWindow(frame); SetupWindow(frame);
CreateChildren(frame); CreateChildren(frame);
if (GetBool(_("centered"), FALSE)) if (GetBool(wxT("centered"), FALSE))
frame->Centre(); frame->Centre();
return frame; return frame;
@ -79,7 +81,7 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
bool wxFrameXmlHandler::CanHandle(wxXmlNode *node) bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
{ {
return IsOfClass(node, _T("wxFrame")); return IsOfClass(node, wxT("wxFrame"));
} }

View File

@ -36,14 +36,18 @@ wxGaugeXmlHandler::wxGaugeXmlHandler()
wxObject *wxGaugeXmlHandler::DoCreateResource() wxObject *wxGaugeXmlHandler::DoCreateResource()
{ {
wxGauge *control = new wxGauge(m_parentAsWindow, wxGauge *control = wxStaticCast(m_instance, wxGauge);
GetID(),
GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), if (!control)
GetPosition(), GetSize(), control = new wxGauge;
GetStyle(),
wxDefaultValidator, control->Create(m_parentAsWindow,
GetName() GetID(),
); GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if( HasParam( wxT("value") )) if( HasParam( wxT("value") ))
{ {

View File

@ -30,28 +30,29 @@
wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
ADD_STYLE( wxHW_SCROLLBAR_NEVER ); ADD_STYLE(wxHW_SCROLLBAR_NEVER);
ADD_STYLE( wxHW_SCROLLBAR_AUTO ); ADD_STYLE(wxHW_SCROLLBAR_AUTO);
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxHtmlWindowXmlHandler::DoCreateResource() wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
{ {
wxHtmlWindow *control = new wxHtmlWindow(m_parentAsWindow, wxHtmlWindow *control = wxStaticCast(m_instance, wxHtmlWindow);
GetID(),
GetPosition(), GetSize(),
GetStyle( wxT("style" ), wxHW_SCROLLBAR_AUTO),
GetName()
);
if( HasParam( wxT("borders") )) 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(); wxFileSystem& fsys = GetCurFileSystem();
wxFSFile *f = fsys.OpenFile(url); wxFSFile *f = fsys.OpenFile(url);
@ -64,9 +65,9 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
control->LoadPage(url); 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); SetupWindow(control);

View File

@ -54,16 +54,19 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxListBox *control = wxStaticCast(m_instance, wxListBox);
wxListBox *control = new wxListBox(m_parentAsWindow, if (!control)
GetID(), control = new wxListBox;
GetPosition(), GetSize(),
strList.GetCount(), control->Create(m_parentAsWindow,
strings, GetID(),
GetStyle(), GetPosition(), GetSize(),
wxDefaultValidator, strList.GetCount(),
GetName() strings,
); GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -46,12 +46,18 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler()
wxObject *wxListCtrlXmlHandler::DoCreateResource() wxObject *wxListCtrlXmlHandler::DoCreateResource()
{ {
wxListCtrl *list = new wxListCtrl(m_parentAsWindow, wxListCtrl *list = wxStaticCast(m_instance, wxListCtrl);
GetID(),
GetPosition(), GetSize(), if (!list)
GetStyle(), list = new wxListCtrl;
wxDefaultValidator,
GetName()); list->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
/* TODO: columns definition */ /* TODO: columns definition */
SetupWindow(list); SetupWindow(list);

View File

@ -21,6 +21,7 @@
#include "wx/xrc/xh_menu.h" #include "wx/xrc/xh_menu.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/frame.h"
wxMenuXmlHandler::wxMenuXmlHandler() : wxMenuXmlHandler::wxMenuXmlHandler() :
@ -105,13 +106,6 @@ bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler() wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
{ {
ADD_STYLE(wxMB_DOCKABLE); ADD_STYLE(wxMB_DOCKABLE);
@ -123,6 +117,14 @@ wxObject *wxMenuBarXmlHandler::DoCreateResource()
{ {
wxMenuBar *menubar = new wxMenuBar(GetStyle()); wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(menubar); CreateChildren(menubar);
if (m_parentAsWindow)
{
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
if (parentFrame)
parentFrame->SetMenuBar(menubar);
}
return menubar; return menubar;
} }

View File

@ -45,6 +45,9 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
{ {
wxXmlNode *n = GetParamNode(wxT("object")); wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n) if (n)
{ {
bool old_ins = m_isInside; bool old_ins = m_isInside;
@ -68,12 +71,17 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
} }
else { else {
wxNotebook *nb = new wxNotebook(m_parentAsWindow, wxNotebook *nb = wxStaticCast(m_instance, wxNotebook);
GetID(),
GetPosition(), GetSize(), if ( !nb )
GetStyle( wxT("style" )), nb = new wxNotebook;
GetName());
nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle( wxT("style" )),
GetName());
wxNotebook *old_par = m_notebook; wxNotebook *old_par = m_notebook;
m_notebook = nb; m_notebook = nb;
bool old_ins = m_isInside; bool old_ins = m_isInside;

View File

@ -38,18 +38,15 @@ wxObject *wxPanelXmlHandler::DoCreateResource()
{ {
wxPanel *panel = wxDynamicCast(m_instance, wxPanel); wxPanel *panel = wxDynamicCast(m_instance, wxPanel);
if (panel == NULL) if (!panel)
panel = new wxPanel(m_parentAsWindow, panel = new wxPanel;
GetID(),
GetPosition(), GetSize(), panel->Create(m_parentAsWindow,
GetStyle(wxT("style"), wxTAB_TRAVERSAL), GetID(),
GetName()); GetPosition(), GetSize(),
else GetStyle(wxT("style"), wxTAB_TRAVERSAL),
panel->Create(m_parentAsWindow, GetName());
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxTAB_TRAVERSAL),
GetName());
SetupWindow(panel); SetupWindow(panel);
CreateChildren(panel); CreateChildren(panel);

View File

@ -40,14 +40,18 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
* normal radio button. * normal radio button.
*/ */
wxRadioButton *control = new wxRadioButton(m_parentAsWindow, wxRadioButton *control = wxStaticCast(m_instance, wxRadioButton);
GetID(),
GetText(wxT("label")), if (!control)
GetPosition(), GetSize(), control = new wxRadioButton;
GetStyle(),
wxDefaultValidator, control->Create(m_parentAsWindow,
GetName() GetID(),
); GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetValue( GetBool(wxT("value"), 0)); control->SetValue( GetBool(wxT("value"), 0));
SetupWindow(control); SetupWindow(control);

View File

@ -53,18 +53,21 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxRadioBox *control = wxStaticCast(m_instance, wxRadioBox);
wxRadioBox *control = new wxRadioBox(m_parentAsWindow, if (!control)
GetID(), control = new wxRadioBox;
GetText(wxT("label")),
GetPosition(), GetSize(), control->Create(m_parentAsWindow,
strList.GetCount(), GetID(),
strings, GetText(wxT("label")),
GetLong( wxT("dimension"), 1 ), GetPosition(), GetSize(),
GetStyle(), strList.GetCount(),
wxDefaultValidator, strings,
GetName() GetLong(wxT("dimension"), 1),
); GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -33,13 +33,18 @@ wxScrollBarXmlHandler::wxScrollBarXmlHandler()
wxObject *wxScrollBarXmlHandler::DoCreateResource() wxObject *wxScrollBarXmlHandler::DoCreateResource()
{ {
wxScrollBar *control = new wxScrollBar(m_parentAsWindow, wxScrollBar *control = wxStaticCast(m_instance, wxScrollBar);
GetID(),
GetPosition(), GetSize(), if (!control)
GetStyle(), control = new wxScrollBar;
wxDefaultValidator,
GetName() control->Create(m_parentAsWindow,
); GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetScrollbar(GetLong( wxT("value"), 0), control->SetScrollbar(GetLong( wxT("value"), 0),
GetLong( wxT("thumbsize"),1), GetLong( wxT("thumbsize"),1),
GetLong( wxT("range"), 10), GetLong( wxT("range"), 10),

View File

@ -78,6 +78,9 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
{ {
wxXmlNode *n = GetParamNode(wxT("object")); wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n) if (n)
{ {
bool old_ins = m_isInside; bool old_ins = m_isInside;

View File

@ -42,16 +42,20 @@ wxSliderXmlHandler::wxSliderXmlHandler()
wxObject *wxSliderXmlHandler::DoCreateResource() wxObject *wxSliderXmlHandler::DoCreateResource()
{ {
wxSlider *control = new wxSlider(m_parentAsWindow, wxSlider *control = wxStaticCast(m_instance, wxSlider);
GetID(),
GetLong( wxT("value"), wxSL_DEFAULT_VALUE), if (!control)
GetLong( wxT("min"), wxSL_DEFAULT_MIN), control = new wxSlider;
GetLong( wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(), control->Create(m_parentAsWindow,
GetStyle(), GetID(),
wxDefaultValidator, GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
GetName() GetLong(wxT("min"), wxSL_DEFAULT_MIN),
); GetLong(wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if( HasParam( wxT("tickfreq") )) if( HasParam( wxT("tickfreq") ))
{ {

View File

@ -36,12 +36,16 @@ wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
wxObject *wxSpinButtonXmlHandler::DoCreateResource() wxObject *wxSpinButtonXmlHandler::DoCreateResource()
{ {
wxSpinButton *control = new wxSpinButton(m_parentAsWindow, wxSpinButton *control = wxStaticCast(m_instance, wxSpinButton);
GetID(),
GetPosition(), GetSize(), if (!control)
GetStyle( wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS ), control = new wxSpinButton;
GetName()
); 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->SetValue( GetLong( wxT("value"), wxSP_DEFAULT_VALUE) );
control->SetRange( GetLong( wxT("min"), wxSP_DEFAULT_MIN), control->SetRange( GetLong( wxT("min"), wxSP_DEFAULT_MIN),

View File

@ -30,13 +30,18 @@ wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
wxObject *wxStaticBitmapXmlHandler::DoCreateResource() wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
{ {
wxStaticBitmap *bmp = new wxStaticBitmap(m_parentAsWindow, wxStaticBitmap *bmp = wxStaticCast(m_instance, wxStaticBitmap);
GetID(),
GetBitmap(wxT("bitmap"), GetSize()), if (!bmp)
GetPosition(), GetSize(), bmp = new wxStaticBitmap;
GetStyle(),
GetName() bmp->Create(m_parentAsWindow,
); GetID(),
GetBitmap(wxT("bitmap"), GetSize()),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(bmp); SetupWindow(bmp);
return bmp; return bmp;

View File

@ -30,13 +30,18 @@ wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
wxObject *wxStaticBoxXmlHandler::DoCreateResource() wxObject *wxStaticBoxXmlHandler::DoCreateResource()
{ {
wxStaticBox *box = new wxStaticBox(m_parentAsWindow, wxStaticBox *box = wxStaticCast(m_instance, wxStaticBox);
GetID(),
GetText(wxT("label")), if (!box)
GetPosition(), GetSize(), box = new wxStaticBox;
GetStyle(),
GetName() box->Create(m_parentAsWindow,
); GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(box); SetupWindow(box);
return box; return box;

View File

@ -34,12 +34,17 @@ wxStaticLineXmlHandler::wxStaticLineXmlHandler()
wxObject *wxStaticLineXmlHandler::DoCreateResource() wxObject *wxStaticLineXmlHandler::DoCreateResource()
{ {
wxStaticLine *line = new wxStaticLine(m_parentAsWindow, wxStaticLine *line = wxStaticCast(m_instance, wxStaticLine);
GetID(),
GetPosition(), GetSize(), if (!line)
GetStyle(wxT("style"), wxLI_HORIZONTAL), line = new wxStaticLine;
GetName()
); line->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxLI_HORIZONTAL),
GetName());
SetupWindow(line); SetupWindow(line);
return line; return line;

View File

@ -34,13 +34,18 @@ wxStaticTextXmlHandler::wxStaticTextXmlHandler()
wxObject *wxStaticTextXmlHandler::DoCreateResource() wxObject *wxStaticTextXmlHandler::DoCreateResource()
{ {
wxStaticText *text = new wxStaticText(m_parentAsWindow, wxStaticText *text = wxStaticCast(m_instance, wxStaticText);
GetID(),
GetText(wxT("label")), if (!text)
GetPosition(), GetSize(), text = new wxStaticText;
GetStyle(),
GetName() text->Create(m_parentAsWindow,
); GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(text); SetupWindow(text);
return text; return text;

View File

@ -35,14 +35,19 @@ wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
wxObject *wxTextCtrlXmlHandler::DoCreateResource() wxObject *wxTextCtrlXmlHandler::DoCreateResource()
{ {
wxTextCtrl *text = new wxTextCtrl(m_parentAsWindow, wxTextCtrl *text = wxStaticCast(m_instance, wxTextCtrl);
GetID(),
GetText(wxT("value")), if ( !text )
GetPosition(), GetSize(), text = new wxTextCtrl;
GetStyle(),
wxDefaultValidator, text->Create( m_parentAsWindow,
GetName() GetID(),
); GetText(wxT("value")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName() );
SetupWindow(text); SetupWindow(text);
return text; return text;

View File

@ -21,7 +21,7 @@
#include "wx/xrc/xh_toolb.h" #include "wx/xrc/xh_toolb.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/frame.h"
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
@ -66,12 +66,18 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
#ifdef __WXMSW__ #ifdef __WXMSW__
if (!(style & wxNO_BORDER)) style |= wxNO_BORDER; if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
#endif #endif
wxToolBar *toolbar = new wxToolBar(m_parentAsWindow,
GetID(), wxToolBar *toolbar = wxStaticCast(m_instance, wxToolBar);
GetPosition(),
GetSize(), if ( !toolbar )
style, toolbar = new wxToolBar;
GetName());
toolbar->Create(m_parentAsWindow,
GetID(),
GetPosition(),
GetSize(),
style,
GetName());
wxSize bmpsize = GetSize(wxT("bitmapsize")); wxSize bmpsize = GetSize(wxT("bitmapsize"));
if (!(bmpsize == wxDefaultSize)) if (!(bmpsize == wxDefaultSize))
@ -87,6 +93,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
toolbar->SetToolSeparation(separation); toolbar->SetToolSeparation(separation);
wxXmlNode *children_node = GetParamNode(wxT("object")); wxXmlNode *children_node = GetParamNode(wxT("object"));
if (!children_node)
children_node = GetParamNode(wxT("object_ref"));
if (children_node == NULL) return toolbar; if (children_node == NULL) return toolbar;
m_isInside = TRUE; m_isInside = TRUE;
@ -96,8 +105,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE && if ((n->GetType() == wxXML_ELEMENT_NODE) &&
n->GetName() == wxT("object")) (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
{ {
wxObject *created = CreateResFromNode(n, toolbar, NULL); wxObject *created = CreateResFromNode(n, toolbar, NULL);
wxControl *control = wxDynamicCast(created, wxControl); wxControl *control = wxDynamicCast(created, wxControl);
@ -113,6 +122,15 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
m_toolbar = NULL; m_toolbar = NULL;
toolbar->Realize(); 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; return toolbar;
} }
} }

View File

@ -35,13 +35,18 @@ wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
wxObject *wxTreeCtrlXmlHandler::DoCreateResource() wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
{ {
wxTreeCtrl *tree = new wxTreeCtrl(m_parentAsWindow, wxTreeCtrl *tree = wxStaticCast(m_instance, wxTreeCtrl);
GetID(),
GetPosition(), GetSize(), if (!tree)
GetStyle(), tree = new wxTreeCtrl;
wxDefaultValidator,
GetName()); tree->Create( m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
SetupWindow(tree); SetupWindow(tree);
return tree; return tree;

View File

@ -36,13 +36,19 @@ wxButtonXmlHandler::wxButtonXmlHandler()
wxObject *wxButtonXmlHandler::DoCreateResource() wxObject *wxButtonXmlHandler::DoCreateResource()
{ {
wxButton *button = new wxButton(m_parentAsWindow, wxButton *button = wxStaticCast(m_instance, wxButton);
GetID(),
GetText(wxT("label")), if (!button)
GetPosition(), GetSize(), button = new wxButton;
GetStyle(),
wxDefaultValidator, button->Create(m_parentAsWindow,
GetName()); GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if (GetBool(wxT("default"), 0) == 1) button->SetDefault(); if (GetBool(wxT("default"), 0) == 1) button->SetDefault();
SetupWindow(button); SetupWindow(button);

View File

@ -38,13 +38,18 @@ wxCalendarCtrlXmlHandler::wxCalendarCtrlXmlHandler()
wxObject *wxCalendarCtrlXmlHandler::DoCreateResource() wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
{ {
wxCalendarCtrl *calendar = new wxCalendarCtrl(m_parentAsWindow, wxCalendarCtrl *calendar = wxStaticCast(m_instance, wxCalendarCtrl);
GetID(),
wxDefaultDateTime, if (!calendar)
/*TODO: take it from resource*/ calendar = new wxCalendarCtrl;
GetPosition(), GetSize(),
GetStyle(), calendar->Create(m_parentAsWindow,
GetName()); GetID(),
wxDefaultDateTime,
/*TODO: take it from resource*/
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(calendar); SetupWindow(calendar);

View File

@ -32,14 +32,18 @@ wxCheckBoxXmlHandler::wxCheckBoxXmlHandler()
wxObject *wxCheckBoxXmlHandler::DoCreateResource() wxObject *wxCheckBoxXmlHandler::DoCreateResource()
{ {
wxCheckBox *control = new wxCheckBox(m_parentAsWindow, wxCheckBox *control = wxStaticCast(m_instance, wxCheckBox);
GetID(),
GetText(wxT("label")), if (!control)
GetPosition(), GetSize(), control = new wxCheckBox;
GetStyle(),
wxDefaultValidator, control->Create(m_parentAsWindow,
GetName() GetID(),
); GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetValue( GetBool( wxT("checked"))); control->SetValue( GetBool( wxT("checked")));
SetupWindow(control); SetupWindow(control);

View File

@ -45,16 +45,19 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxCheckListBox *control = wxStaticCast(m_instance, wxCheckListBox);
wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow, if (!control)
GetID(), control = new wxCheckListBox;
GetPosition(), GetSize(),
strList.GetCount(), control->Create(m_parentAsWindow,
strings, GetID(),
GetStyle(), GetPosition(), GetSize(),
wxDefaultValidator, strList.GetCount(),
GetName() strings,
); GetStyle(),
wxDefaultValidator,
GetName());
// step through children myself (again.) // step through children myself (again.)
wxXmlNode *n = GetParamNode(wxT("content")); wxXmlNode *n = GetParamNode(wxT("content"));

View File

@ -48,16 +48,19 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxChoice *control = wxStaticCast(m_instance, wxChoice);
wxChoice *control = new wxChoice(m_parentAsWindow, if (!control)
GetID(), control = new wxChoice;
GetPosition(), GetSize(),
strList.GetCount(), control->Create(m_parentAsWindow,
strings, GetID(),
GetStyle(), GetPosition(), GetSize(),
wxDefaultValidator, strList.GetCount(),
GetName() strings,
); GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -54,16 +54,20 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
} }
wxComboBox *control = new wxComboBox(m_parentAsWindow, wxComboBox *control = wxStaticCast(m_instance, wxComboBox);
GetID(),
GetText(wxT("value")), if (!control)
GetPosition(), GetSize(), control = new wxComboBox;
strList.GetCount(),
strings, control->Create(m_parentAsWindow,
GetStyle(), GetID(),
wxDefaultValidator, GetText(wxT("value")),
GetName() GetPosition(), GetSize(),
); strList.GetCount(),
strings,
GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -58,8 +58,10 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE), GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE),
GetName()); GetName());
dlg->SetClientSize(GetSize()); if (HasParam(wxT("size")))
dlg->Move(GetPosition()); dlg->SetClientSize(GetSize());
if (HasParam(wxT("pos")))
dlg->Move(GetPosition());
SetupWindow(dlg); SetupWindow(dlg);
CreateChildren(dlg); CreateChildren(dlg);

View File

@ -59,17 +59,19 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
frame->Create(m_parentAsWindow, frame->Create(m_parentAsWindow,
GetID(), GetID(),
GetText(_T("title")), GetText(wxT("title")),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
GetStyle(_T("style"), wxDEFAULT_FRAME_STYLE), GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE),
GetName()); GetName());
frame->SetClientSize(GetSize()); if (HasParam(wxT("size")))
frame->Move(GetPosition()); frame->SetClientSize(GetSize());
if (HasParam(wxT("pos")))
frame->Move(GetPosition());
SetupWindow(frame); SetupWindow(frame);
CreateChildren(frame); CreateChildren(frame);
if (GetBool(_("centered"), FALSE)) if (GetBool(wxT("centered"), FALSE))
frame->Centre(); frame->Centre();
return frame; return frame;
@ -79,7 +81,7 @@ wxObject *wxFrameXmlHandler::DoCreateResource()
bool wxFrameXmlHandler::CanHandle(wxXmlNode *node) bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
{ {
return IsOfClass(node, _T("wxFrame")); return IsOfClass(node, wxT("wxFrame"));
} }

View File

@ -36,14 +36,18 @@ wxGaugeXmlHandler::wxGaugeXmlHandler()
wxObject *wxGaugeXmlHandler::DoCreateResource() wxObject *wxGaugeXmlHandler::DoCreateResource()
{ {
wxGauge *control = new wxGauge(m_parentAsWindow, wxGauge *control = wxStaticCast(m_instance, wxGauge);
GetID(),
GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE), if (!control)
GetPosition(), GetSize(), control = new wxGauge;
GetStyle(),
wxDefaultValidator, control->Create(m_parentAsWindow,
GetName() GetID(),
); GetLong( wxT("range"), wxGAUGE_DEFAULT_RANGE),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if( HasParam( wxT("value") )) if( HasParam( wxT("value") ))
{ {

View File

@ -30,28 +30,29 @@
wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
: wxXmlResourceHandler() : wxXmlResourceHandler()
{ {
ADD_STYLE( wxHW_SCROLLBAR_NEVER ); ADD_STYLE(wxHW_SCROLLBAR_NEVER);
ADD_STYLE( wxHW_SCROLLBAR_AUTO ); ADD_STYLE(wxHW_SCROLLBAR_AUTO);
AddWindowStyles(); AddWindowStyles();
} }
wxObject *wxHtmlWindowXmlHandler::DoCreateResource() wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
{ {
wxHtmlWindow *control = new wxHtmlWindow(m_parentAsWindow, wxHtmlWindow *control = wxStaticCast(m_instance, wxHtmlWindow);
GetID(),
GetPosition(), GetSize(),
GetStyle( wxT("style" ), wxHW_SCROLLBAR_AUTO),
GetName()
);
if( HasParam( wxT("borders") )) 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(); wxFileSystem& fsys = GetCurFileSystem();
wxFSFile *f = fsys.OpenFile(url); wxFSFile *f = fsys.OpenFile(url);
@ -64,9 +65,9 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
control->LoadPage(url); 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); SetupWindow(control);

View File

@ -54,16 +54,19 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxListBox *control = wxStaticCast(m_instance, wxListBox);
wxListBox *control = new wxListBox(m_parentAsWindow, if (!control)
GetID(), control = new wxListBox;
GetPosition(), GetSize(),
strList.GetCount(), control->Create(m_parentAsWindow,
strings, GetID(),
GetStyle(), GetPosition(), GetSize(),
wxDefaultValidator, strList.GetCount(),
GetName() strings,
); GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -46,12 +46,18 @@ wxListCtrlXmlHandler::wxListCtrlXmlHandler()
wxObject *wxListCtrlXmlHandler::DoCreateResource() wxObject *wxListCtrlXmlHandler::DoCreateResource()
{ {
wxListCtrl *list = new wxListCtrl(m_parentAsWindow, wxListCtrl *list = wxStaticCast(m_instance, wxListCtrl);
GetID(),
GetPosition(), GetSize(), if (!list)
GetStyle(), list = new wxListCtrl;
wxDefaultValidator,
GetName()); list->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
/* TODO: columns definition */ /* TODO: columns definition */
SetupWindow(list); SetupWindow(list);

View File

@ -21,6 +21,7 @@
#include "wx/xrc/xh_menu.h" #include "wx/xrc/xh_menu.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/frame.h"
wxMenuXmlHandler::wxMenuXmlHandler() : wxMenuXmlHandler::wxMenuXmlHandler() :
@ -105,13 +106,6 @@ bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler() wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
{ {
ADD_STYLE(wxMB_DOCKABLE); ADD_STYLE(wxMB_DOCKABLE);
@ -123,6 +117,14 @@ wxObject *wxMenuBarXmlHandler::DoCreateResource()
{ {
wxMenuBar *menubar = new wxMenuBar(GetStyle()); wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(menubar); CreateChildren(menubar);
if (m_parentAsWindow)
{
wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
if (parentFrame)
parentFrame->SetMenuBar(menubar);
}
return menubar; return menubar;
} }

View File

@ -45,6 +45,9 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
{ {
wxXmlNode *n = GetParamNode(wxT("object")); wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n) if (n)
{ {
bool old_ins = m_isInside; bool old_ins = m_isInside;
@ -68,12 +71,17 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
} }
else { else {
wxNotebook *nb = new wxNotebook(m_parentAsWindow, wxNotebook *nb = wxStaticCast(m_instance, wxNotebook);
GetID(),
GetPosition(), GetSize(), if ( !nb )
GetStyle( wxT("style" )), nb = new wxNotebook;
GetName());
nb->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle( wxT("style" )),
GetName());
wxNotebook *old_par = m_notebook; wxNotebook *old_par = m_notebook;
m_notebook = nb; m_notebook = nb;
bool old_ins = m_isInside; bool old_ins = m_isInside;

View File

@ -38,18 +38,15 @@ wxObject *wxPanelXmlHandler::DoCreateResource()
{ {
wxPanel *panel = wxDynamicCast(m_instance, wxPanel); wxPanel *panel = wxDynamicCast(m_instance, wxPanel);
if (panel == NULL) if (!panel)
panel = new wxPanel(m_parentAsWindow, panel = new wxPanel;
GetID(),
GetPosition(), GetSize(), panel->Create(m_parentAsWindow,
GetStyle(wxT("style"), wxTAB_TRAVERSAL), GetID(),
GetName()); GetPosition(), GetSize(),
else GetStyle(wxT("style"), wxTAB_TRAVERSAL),
panel->Create(m_parentAsWindow, GetName());
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxTAB_TRAVERSAL),
GetName());
SetupWindow(panel); SetupWindow(panel);
CreateChildren(panel); CreateChildren(panel);

View File

@ -40,14 +40,18 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
* normal radio button. * normal radio button.
*/ */
wxRadioButton *control = new wxRadioButton(m_parentAsWindow, wxRadioButton *control = wxStaticCast(m_instance, wxRadioButton);
GetID(),
GetText(wxT("label")), if (!control)
GetPosition(), GetSize(), control = new wxRadioButton;
GetStyle(),
wxDefaultValidator, control->Create(m_parentAsWindow,
GetName() GetID(),
); GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetValue( GetBool(wxT("value"), 0)); control->SetValue( GetBool(wxT("value"), 0));
SetupWindow(control); SetupWindow(control);

View File

@ -53,18 +53,21 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
strings[i]=strList[i]; strings[i]=strList[i];
} }
wxRadioBox *control = wxStaticCast(m_instance, wxRadioBox);
wxRadioBox *control = new wxRadioBox(m_parentAsWindow, if (!control)
GetID(), control = new wxRadioBox;
GetText(wxT("label")),
GetPosition(), GetSize(), control->Create(m_parentAsWindow,
strList.GetCount(), GetID(),
strings, GetText(wxT("label")),
GetLong( wxT("dimension"), 1 ), GetPosition(), GetSize(),
GetStyle(), strList.GetCount(),
wxDefaultValidator, strings,
GetName() GetLong(wxT("dimension"), 1),
); GetStyle(),
wxDefaultValidator,
GetName());
if( selection != -1 ) if( selection != -1 )
control->SetSelection( selection ); control->SetSelection( selection );

View File

@ -33,13 +33,18 @@ wxScrollBarXmlHandler::wxScrollBarXmlHandler()
wxObject *wxScrollBarXmlHandler::DoCreateResource() wxObject *wxScrollBarXmlHandler::DoCreateResource()
{ {
wxScrollBar *control = new wxScrollBar(m_parentAsWindow, wxScrollBar *control = wxStaticCast(m_instance, wxScrollBar);
GetID(),
GetPosition(), GetSize(), if (!control)
GetStyle(), control = new wxScrollBar;
wxDefaultValidator,
GetName() control->Create(m_parentAsWindow,
); GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
control->SetScrollbar(GetLong( wxT("value"), 0), control->SetScrollbar(GetLong( wxT("value"), 0),
GetLong( wxT("thumbsize"),1), GetLong( wxT("thumbsize"),1),
GetLong( wxT("range"), 10), GetLong( wxT("range"), 10),

View File

@ -78,6 +78,9 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
{ {
wxXmlNode *n = GetParamNode(wxT("object")); wxXmlNode *n = GetParamNode(wxT("object"));
if ( !n )
n = GetParamNode(wxT("object_ref"));
if (n) if (n)
{ {
bool old_ins = m_isInside; bool old_ins = m_isInside;

View File

@ -42,16 +42,20 @@ wxSliderXmlHandler::wxSliderXmlHandler()
wxObject *wxSliderXmlHandler::DoCreateResource() wxObject *wxSliderXmlHandler::DoCreateResource()
{ {
wxSlider *control = new wxSlider(m_parentAsWindow, wxSlider *control = wxStaticCast(m_instance, wxSlider);
GetID(),
GetLong( wxT("value"), wxSL_DEFAULT_VALUE), if (!control)
GetLong( wxT("min"), wxSL_DEFAULT_MIN), control = new wxSlider;
GetLong( wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(), control->Create(m_parentAsWindow,
GetStyle(), GetID(),
wxDefaultValidator, GetLong(wxT("value"), wxSL_DEFAULT_VALUE),
GetName() GetLong(wxT("min"), wxSL_DEFAULT_MIN),
); GetLong(wxT("max"), wxSL_DEFAULT_MAX),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
if( HasParam( wxT("tickfreq") )) if( HasParam( wxT("tickfreq") ))
{ {

View File

@ -36,12 +36,16 @@ wxSpinButtonXmlHandler::wxSpinButtonXmlHandler()
wxObject *wxSpinButtonXmlHandler::DoCreateResource() wxObject *wxSpinButtonXmlHandler::DoCreateResource()
{ {
wxSpinButton *control = new wxSpinButton(m_parentAsWindow, wxSpinButton *control = wxStaticCast(m_instance, wxSpinButton);
GetID(),
GetPosition(), GetSize(), if (!control)
GetStyle( wxT("style"), wxSP_VERTICAL | wxSP_ARROW_KEYS ), control = new wxSpinButton;
GetName()
); 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->SetValue( GetLong( wxT("value"), wxSP_DEFAULT_VALUE) );
control->SetRange( GetLong( wxT("min"), wxSP_DEFAULT_MIN), control->SetRange( GetLong( wxT("min"), wxSP_DEFAULT_MIN),

View File

@ -30,13 +30,18 @@ wxStaticBitmapXmlHandler::wxStaticBitmapXmlHandler()
wxObject *wxStaticBitmapXmlHandler::DoCreateResource() wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
{ {
wxStaticBitmap *bmp = new wxStaticBitmap(m_parentAsWindow, wxStaticBitmap *bmp = wxStaticCast(m_instance, wxStaticBitmap);
GetID(),
GetBitmap(wxT("bitmap"), GetSize()), if (!bmp)
GetPosition(), GetSize(), bmp = new wxStaticBitmap;
GetStyle(),
GetName() bmp->Create(m_parentAsWindow,
); GetID(),
GetBitmap(wxT("bitmap"), GetSize()),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(bmp); SetupWindow(bmp);
return bmp; return bmp;

View File

@ -30,13 +30,18 @@ wxStaticBoxXmlHandler::wxStaticBoxXmlHandler()
wxObject *wxStaticBoxXmlHandler::DoCreateResource() wxObject *wxStaticBoxXmlHandler::DoCreateResource()
{ {
wxStaticBox *box = new wxStaticBox(m_parentAsWindow, wxStaticBox *box = wxStaticCast(m_instance, wxStaticBox);
GetID(),
GetText(wxT("label")), if (!box)
GetPosition(), GetSize(), box = new wxStaticBox;
GetStyle(),
GetName() box->Create(m_parentAsWindow,
); GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(box); SetupWindow(box);
return box; return box;

View File

@ -34,12 +34,17 @@ wxStaticLineXmlHandler::wxStaticLineXmlHandler()
wxObject *wxStaticLineXmlHandler::DoCreateResource() wxObject *wxStaticLineXmlHandler::DoCreateResource()
{ {
wxStaticLine *line = new wxStaticLine(m_parentAsWindow, wxStaticLine *line = wxStaticCast(m_instance, wxStaticLine);
GetID(),
GetPosition(), GetSize(), if (!line)
GetStyle(wxT("style"), wxLI_HORIZONTAL), line = new wxStaticLine;
GetName()
); line->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxLI_HORIZONTAL),
GetName());
SetupWindow(line); SetupWindow(line);
return line; return line;

View File

@ -34,13 +34,18 @@ wxStaticTextXmlHandler::wxStaticTextXmlHandler()
wxObject *wxStaticTextXmlHandler::DoCreateResource() wxObject *wxStaticTextXmlHandler::DoCreateResource()
{ {
wxStaticText *text = new wxStaticText(m_parentAsWindow, wxStaticText *text = wxStaticCast(m_instance, wxStaticText);
GetID(),
GetText(wxT("label")), if (!text)
GetPosition(), GetSize(), text = new wxStaticText;
GetStyle(),
GetName() text->Create(m_parentAsWindow,
); GetID(),
GetText(wxT("label")),
GetPosition(), GetSize(),
GetStyle(),
GetName());
SetupWindow(text); SetupWindow(text);
return text; return text;

View File

@ -35,14 +35,19 @@ wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
wxObject *wxTextCtrlXmlHandler::DoCreateResource() wxObject *wxTextCtrlXmlHandler::DoCreateResource()
{ {
wxTextCtrl *text = new wxTextCtrl(m_parentAsWindow, wxTextCtrl *text = wxStaticCast(m_instance, wxTextCtrl);
GetID(),
GetText(wxT("value")), if ( !text )
GetPosition(), GetSize(), text = new wxTextCtrl;
GetStyle(),
wxDefaultValidator, text->Create( m_parentAsWindow,
GetName() GetID(),
); GetText(wxT("value")),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName() );
SetupWindow(text); SetupWindow(text);
return text; return text;

View File

@ -21,7 +21,7 @@
#include "wx/xrc/xh_toolb.h" #include "wx/xrc/xh_toolb.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/frame.h"
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
@ -66,12 +66,18 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
#ifdef __WXMSW__ #ifdef __WXMSW__
if (!(style & wxNO_BORDER)) style |= wxNO_BORDER; if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
#endif #endif
wxToolBar *toolbar = new wxToolBar(m_parentAsWindow,
GetID(), wxToolBar *toolbar = wxStaticCast(m_instance, wxToolBar);
GetPosition(),
GetSize(), if ( !toolbar )
style, toolbar = new wxToolBar;
GetName());
toolbar->Create(m_parentAsWindow,
GetID(),
GetPosition(),
GetSize(),
style,
GetName());
wxSize bmpsize = GetSize(wxT("bitmapsize")); wxSize bmpsize = GetSize(wxT("bitmapsize"));
if (!(bmpsize == wxDefaultSize)) if (!(bmpsize == wxDefaultSize))
@ -87,6 +93,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
toolbar->SetToolSeparation(separation); toolbar->SetToolSeparation(separation);
wxXmlNode *children_node = GetParamNode(wxT("object")); wxXmlNode *children_node = GetParamNode(wxT("object"));
if (!children_node)
children_node = GetParamNode(wxT("object_ref"));
if (children_node == NULL) return toolbar; if (children_node == NULL) return toolbar;
m_isInside = TRUE; m_isInside = TRUE;
@ -96,8 +105,8 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE && if ((n->GetType() == wxXML_ELEMENT_NODE) &&
n->GetName() == wxT("object")) (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref")))
{ {
wxObject *created = CreateResFromNode(n, toolbar, NULL); wxObject *created = CreateResFromNode(n, toolbar, NULL);
wxControl *control = wxDynamicCast(created, wxControl); wxControl *control = wxDynamicCast(created, wxControl);
@ -113,6 +122,15 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
m_toolbar = NULL; m_toolbar = NULL;
toolbar->Realize(); 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; return toolbar;
} }
} }

View File

@ -35,13 +35,18 @@ wxTreeCtrlXmlHandler::wxTreeCtrlXmlHandler()
wxObject *wxTreeCtrlXmlHandler::DoCreateResource() wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
{ {
wxTreeCtrl *tree = new wxTreeCtrl(m_parentAsWindow, wxTreeCtrl *tree = wxStaticCast(m_instance, wxTreeCtrl);
GetID(),
GetPosition(), GetSize(), if (!tree)
GetStyle(), tree = new wxTreeCtrl;
wxDefaultValidator,
GetName()); tree->Create( m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(),
wxDefaultValidator,
GetName());
SetupWindow(tree); SetupWindow(tree);
return tree; return tree;