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);
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);
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);
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"));
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 );
}
- 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 );
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);
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;
bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
{
- return IsOfClass(node, _T("wxFrame"));
+ return IsOfClass(node, wxT("wxFrame"));
}
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") ))
{
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);
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);
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 );
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);
#include "wx/xrc/xh_menu.h"
#include "wx/menu.h"
+#include "wx/frame.h"
wxMenuXmlHandler::wxMenuXmlHandler() :
-
-
-
-
-
-
-
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
{
ADD_STYLE(wxMB_DOCKABLE);
{
wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(menubar);
+
+ if (m_parentAsWindow)
+ {
+ wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
+ if (parentFrame)
+ parentFrame->SetMenuBar(menubar);
+ }
+
return menubar;
}
{
wxXmlNode *n = GetParamNode(wxT("object"));
+ if ( !n )
+ n = GetParamNode(wxT("object_ref"));
+
if (n)
{
bool old_ins = m_isInside;
}
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;
{
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);
* 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);
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 );
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),
{
wxXmlNode *n = GetParamNode(wxT("object"));
+ if ( !n )
+ n = GetParamNode(wxT("object_ref"));
+
if (n)
{
bool old_ins = m_isInside;
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") ))
{
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),
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;
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;
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;
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;
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;
#include "wx/xrc/xh_toolb.h"
#include "wx/toolbar.h"
-
+#include "wx/frame.h"
#if wxUSE_TOOLBAR
#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))
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;
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);
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;
}
}
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;
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);
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);
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);
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"));
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 );
}
- 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 );
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);
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;
bool wxFrameXmlHandler::CanHandle(wxXmlNode *node)
{
- return IsOfClass(node, _T("wxFrame"));
+ return IsOfClass(node, wxT("wxFrame"));
}
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") ))
{
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);
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);
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 );
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);
#include "wx/xrc/xh_menu.h"
#include "wx/menu.h"
+#include "wx/frame.h"
wxMenuXmlHandler::wxMenuXmlHandler() :
-
-
-
-
-
-
-
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
{
ADD_STYLE(wxMB_DOCKABLE);
{
wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(menubar);
+
+ if (m_parentAsWindow)
+ {
+ wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
+ if (parentFrame)
+ parentFrame->SetMenuBar(menubar);
+ }
+
return menubar;
}
{
wxXmlNode *n = GetParamNode(wxT("object"));
+ if ( !n )
+ n = GetParamNode(wxT("object_ref"));
+
if (n)
{
bool old_ins = m_isInside;
}
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;
{
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);
* 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);
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 );
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),
{
wxXmlNode *n = GetParamNode(wxT("object"));
+ if ( !n )
+ n = GetParamNode(wxT("object_ref"));
+
if (n)
{
bool old_ins = m_isInside;
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") ))
{
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),
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;
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;
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;
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;
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;
#include "wx/xrc/xh_toolb.h"
#include "wx/toolbar.h"
-
+#include "wx/frame.h"
#if wxUSE_TOOLBAR
#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))
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;
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);
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;
}
}
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;