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()
{
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);

View File

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

View File

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

View File

@ -45,16 +45,19 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
strings[i]=strList[i];
}
wxCheckListBox *control = wxStaticCast(m_instance, wxCheckListBox);
wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
strList.GetCount(),
strings,
GetStyle(),
wxDefaultValidator,
GetName()
);
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"));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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()
);
{
wxHtmlWindow *control = wxStaticCast(m_instance, wxHtmlWindow);
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();
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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,16 +45,19 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
strings[i]=strList[i];
}
wxCheckListBox *control = wxStaticCast(m_instance, wxCheckListBox);
wxCheckListBox *control = new wxCheckListBox(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
strList.GetCount(),
strings,
GetStyle(),
wxDefaultValidator,
GetName()
);
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"));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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()
);
{
wxHtmlWindow *control = wxStaticCast(m_instance, wxHtmlWindow);
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();
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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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