Added generic LoadObject methods that can load any classtype from a
resources and return it as a wxObject (Assuming there is a handler for it.) Enabled wxFrames and wxDialogs to be loaded using a new instance rather than only with existing instances. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -128,6 +128,9 @@ public:
|
||||
// all controls used within the resource.
|
||||
void AddHandler(wxXmlResourceHandler *handler);
|
||||
|
||||
// Add a new handler at the begining of the handler list
|
||||
void InsertHandler(wxXmlResourceHandler *handler);
|
||||
|
||||
// Removes all handlers
|
||||
void ClearHandlers();
|
||||
|
||||
@@ -165,8 +168,20 @@ public:
|
||||
bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads a frame.
|
||||
wxFrame *LoadFrame(wxWindow* parent, const wxString& name);
|
||||
bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Load an object from the resource specifying both the resource name and
|
||||
// the classname. This lets you load nonstandard container windows.
|
||||
wxObject *LoadObject(wxWindow *parent, const wxString& name,
|
||||
const wxString& classname);
|
||||
|
||||
// Load an object from the resource specifying both the resource name and
|
||||
// the classname. This form lets you finish the creation of an existing
|
||||
// instance.
|
||||
bool LoadObject(wxObject *instance, wxWindow *parent, const wxString& name,
|
||||
const wxString& classname);
|
||||
|
||||
// Loads a bitmap resource from a file.
|
||||
wxBitmap LoadBitmap(const wxString& name);
|
||||
|
||||
|
@@ -47,9 +47,7 @@ wxDialogXmlHandler::wxDialogXmlHandler() : wxXmlResourceHandler()
|
||||
|
||||
wxObject *wxDialogXmlHandler::DoCreateResource()
|
||||
{
|
||||
wxDialog *dlg = wxDynamicCast(m_instance, wxDialog);
|
||||
|
||||
wxASSERT_MSG(dlg, _("XRC resource: Cannot create dialog without instance."));
|
||||
XRC_MAKE_INSTANCE(dlg, wxDialog);
|
||||
|
||||
dlg->Create(m_parentAsWindow,
|
||||
GetID(),
|
||||
|
@@ -52,9 +52,7 @@ wxFrameXmlHandler::wxFrameXmlHandler() : wxXmlResourceHandler()
|
||||
|
||||
wxObject *wxFrameXmlHandler::DoCreateResource()
|
||||
{
|
||||
wxFrame *frame = wxDynamicCast(m_instance, wxFrame);
|
||||
|
||||
wxASSERT_MSG(frame, _("XRC resource: Cannot create dialog without instance."));
|
||||
XRC_MAKE_INSTANCE(frame, wxFrame);
|
||||
|
||||
frame->Create(m_parentAsWindow,
|
||||
GetID(),
|
||||
|
@@ -132,6 +132,12 @@ void wxXmlResource::AddHandler(wxXmlResourceHandler *handler)
|
||||
handler->SetParentResource(this);
|
||||
}
|
||||
|
||||
void wxXmlResource::InsertHandler(wxXmlResourceHandler *handler)
|
||||
{
|
||||
m_handlers.Insert(handler);
|
||||
handler->SetParentResource(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxXmlResource::ClearHandlers()
|
||||
@@ -188,6 +194,11 @@ bool wxXmlResource::LoadPanel(wxPanel *panel, wxWindow *parent, const wxString&
|
||||
return CreateResFromNode(FindResource(name, wxT("wxPanel")), parent, panel) != NULL;
|
||||
}
|
||||
|
||||
wxFrame *wxXmlResource::LoadFrame(wxWindow* parent, const wxString& name)
|
||||
{
|
||||
return (wxFrame*)CreateResFromNode(FindResource(name, wxT("wxFrame")), parent, NULL);
|
||||
}
|
||||
|
||||
bool wxXmlResource::LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name)
|
||||
{
|
||||
return CreateResFromNode(FindResource(name, wxT("wxFrame")), parent, frame) != NULL;
|
||||
@@ -213,6 +224,18 @@ wxIcon wxXmlResource::LoadIcon(const wxString& name)
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
wxObject *wxXmlResource::LoadObject(wxWindow *parent, const wxString& name, const wxString& classname)
|
||||
{
|
||||
return CreateResFromNode(FindResource(name, classname), parent, NULL);
|
||||
}
|
||||
|
||||
bool wxXmlResource::LoadObject(wxObject *instance, wxWindow *parent, const wxString& name, const wxString& classname)
|
||||
{
|
||||
return CreateResFromNode(FindResource(name, classname), parent, instance) != NULL;
|
||||
}
|
||||
|
||||
|
||||
bool wxXmlResource::AttachUnknownControl(const wxString& name,
|
||||
wxWindow *control, wxWindow *parent)
|
||||
{
|
||||
|
@@ -128,6 +128,9 @@ public:
|
||||
// all controls used within the resource.
|
||||
void AddHandler(wxXmlResourceHandler *handler);
|
||||
|
||||
// Add a new handler at the begining of the handler list
|
||||
void InsertHandler(wxXmlResourceHandler *handler);
|
||||
|
||||
// Removes all handlers
|
||||
void ClearHandlers();
|
||||
|
||||
@@ -165,8 +168,20 @@ public:
|
||||
bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Loads a frame.
|
||||
wxFrame *LoadFrame(wxWindow* parent, const wxString& name);
|
||||
bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
|
||||
|
||||
// Load an object from the resource specifying both the resource name and
|
||||
// the classname. This lets you load nonstandard container windows.
|
||||
wxObject *LoadObject(wxWindow *parent, const wxString& name,
|
||||
const wxString& classname);
|
||||
|
||||
// Load an object from the resource specifying both the resource name and
|
||||
// the classname. This form lets you finish the creation of an existing
|
||||
// instance.
|
||||
bool LoadObject(wxObject *instance, wxWindow *parent, const wxString& name,
|
||||
const wxString& classname);
|
||||
|
||||
// Loads a bitmap resource from a file.
|
||||
wxBitmap LoadBitmap(const wxString& name);
|
||||
|
||||
|
@@ -47,9 +47,7 @@ wxDialogXmlHandler::wxDialogXmlHandler() : wxXmlResourceHandler()
|
||||
|
||||
wxObject *wxDialogXmlHandler::DoCreateResource()
|
||||
{
|
||||
wxDialog *dlg = wxDynamicCast(m_instance, wxDialog);
|
||||
|
||||
wxASSERT_MSG(dlg, _("XRC resource: Cannot create dialog without instance."));
|
||||
XRC_MAKE_INSTANCE(dlg, wxDialog);
|
||||
|
||||
dlg->Create(m_parentAsWindow,
|
||||
GetID(),
|
||||
|
@@ -52,9 +52,7 @@ wxFrameXmlHandler::wxFrameXmlHandler() : wxXmlResourceHandler()
|
||||
|
||||
wxObject *wxFrameXmlHandler::DoCreateResource()
|
||||
{
|
||||
wxFrame *frame = wxDynamicCast(m_instance, wxFrame);
|
||||
|
||||
wxASSERT_MSG(frame, _("XRC resource: Cannot create dialog without instance."));
|
||||
XRC_MAKE_INSTANCE(frame, wxFrame);
|
||||
|
||||
frame->Create(m_parentAsWindow,
|
||||
GetID(),
|
||||
|
@@ -132,6 +132,12 @@ void wxXmlResource::AddHandler(wxXmlResourceHandler *handler)
|
||||
handler->SetParentResource(this);
|
||||
}
|
||||
|
||||
void wxXmlResource::InsertHandler(wxXmlResourceHandler *handler)
|
||||
{
|
||||
m_handlers.Insert(handler);
|
||||
handler->SetParentResource(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wxXmlResource::ClearHandlers()
|
||||
@@ -188,6 +194,11 @@ bool wxXmlResource::LoadPanel(wxPanel *panel, wxWindow *parent, const wxString&
|
||||
return CreateResFromNode(FindResource(name, wxT("wxPanel")), parent, panel) != NULL;
|
||||
}
|
||||
|
||||
wxFrame *wxXmlResource::LoadFrame(wxWindow* parent, const wxString& name)
|
||||
{
|
||||
return (wxFrame*)CreateResFromNode(FindResource(name, wxT("wxFrame")), parent, NULL);
|
||||
}
|
||||
|
||||
bool wxXmlResource::LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name)
|
||||
{
|
||||
return CreateResFromNode(FindResource(name, wxT("wxFrame")), parent, frame) != NULL;
|
||||
@@ -213,6 +224,18 @@ wxIcon wxXmlResource::LoadIcon(const wxString& name)
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
||||
wxObject *wxXmlResource::LoadObject(wxWindow *parent, const wxString& name, const wxString& classname)
|
||||
{
|
||||
return CreateResFromNode(FindResource(name, classname), parent, NULL);
|
||||
}
|
||||
|
||||
bool wxXmlResource::LoadObject(wxObject *instance, wxWindow *parent, const wxString& name, const wxString& classname)
|
||||
{
|
||||
return CreateResFromNode(FindResource(name, classname), parent, instance) != NULL;
|
||||
}
|
||||
|
||||
|
||||
bool wxXmlResource::AttachUnknownControl(const wxString& name,
|
||||
wxWindow *control, wxWindow *parent)
|
||||
{
|
||||
|
Reference in New Issue
Block a user