// Destructor.
~wxXmlResource();
-
+
// Loads resources from XML files that match given filemask.
// This method understands VFS (see filesys.h).
bool Load(const wxString& filemask);
// 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();
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);
int CompareVersion(int major, int minor, int release, int revision) const
{ return GetVersion() -
(major*256*256*256 + minor*256*256 + release*256 + revision); }
-
+
//// Singleton accessors.
-
+
// Gets the global resources object or creates one if none exists.
static wxXmlResource *Get();
#endif
friend class wxXmlResourceHandler;
-
+
// singleton instance:
static wxXmlResource *ms_instance;
};
void wxXmlInitResourceModule();
-/* -------------------------------------------------------------------------
+/* -------------------------------------------------------------------------
Backward compatibility macros. Do *NOT* use, they may disappear in future
versions of the XRC library!
------------------------------------------------------------------------- */
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_dlg.h"
#endif
}
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(),
GetText(wxT("title")),
SetupWindow(dlg);
CreateChildren(dlg);
-
+
if (GetBool(wxT("centered"), FALSE))
dlg->Centre();
-
+
return dlg;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_frame.h"
#endif
}
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(),
GetText(wxT("title")),
SetupWindow(frame);
CreateChildren(frame);
-
+
if (GetBool(wxT("centered"), FALSE))
frame->Centre();
-
+
return frame;
}
handler->SetParentResource(this);
}
+void wxXmlResource::InsertHandler(wxXmlResourceHandler *handler)
+{
+ m_handlers.Insert(handler);
+ handler->SetParentResource(this);
+}
+
void wxXmlResource::ClearHandlers()
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;
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)
{
-wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
+wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
const wxArtClient& defaultArtClient,
wxSize size)
{
if ( !sid.empty() )
{
wxString scl = bmpNode->GetPropVal(wxT("stock_client"), defaultArtClient);
- wxBitmap stockArt =
+ wxBitmap stockArt =
wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid),
wxART_MAKE_CLIENT_ID_FROM_STR(scl),
size);
}
}
- /* ...or load the bitmap from file: */
+ /* ...or load the bitmap from file: */
wxString name = GetParamValue(param);
- if (name.IsEmpty()) return wxNullBitmap;
+ if (name.IsEmpty()) return wxNullBitmap;
#if wxUSE_FILESYSTEM
wxFSFile *fsfile = GetCurFileSystem().OpenFile(name);
if (fsfile == NULL)
-wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
+wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
const wxArtClient& defaultArtClient,
wxSize size)
{
// Destructor.
~wxXmlResource();
-
+
// Loads resources from XML files that match given filemask.
// This method understands VFS (see filesys.h).
bool Load(const wxString& filemask);
// 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();
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);
int CompareVersion(int major, int minor, int release, int revision) const
{ return GetVersion() -
(major*256*256*256 + minor*256*256 + release*256 + revision); }
-
+
//// Singleton accessors.
-
+
// Gets the global resources object or creates one if none exists.
static wxXmlResource *Get();
#endif
friend class wxXmlResourceHandler;
-
+
// singleton instance:
static wxXmlResource *ms_instance;
};
void wxXmlInitResourceModule();
-/* -------------------------------------------------------------------------
+/* -------------------------------------------------------------------------
Backward compatibility macros. Do *NOT* use, they may disappear in future
versions of the XRC library!
------------------------------------------------------------------------- */
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_dlg.h"
#endif
}
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(),
GetText(wxT("title")),
SetupWindow(dlg);
CreateChildren(dlg);
-
+
if (GetBool(wxT("centered"), FALSE))
dlg->Centre();
-
+
return dlg;
}
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
+
#ifdef __GNUG__
#pragma implementation "xh_frame.h"
#endif
}
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(),
GetText(wxT("title")),
SetupWindow(frame);
CreateChildren(frame);
-
+
if (GetBool(wxT("centered"), FALSE))
frame->Centre();
-
+
return frame;
}
handler->SetParentResource(this);
}
+void wxXmlResource::InsertHandler(wxXmlResourceHandler *handler)
+{
+ m_handlers.Insert(handler);
+ handler->SetParentResource(this);
+}
+
void wxXmlResource::ClearHandlers()
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;
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)
{
-wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
+wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
const wxArtClient& defaultArtClient,
wxSize size)
{
if ( !sid.empty() )
{
wxString scl = bmpNode->GetPropVal(wxT("stock_client"), defaultArtClient);
- wxBitmap stockArt =
+ wxBitmap stockArt =
wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid),
wxART_MAKE_CLIENT_ID_FROM_STR(scl),
size);
}
}
- /* ...or load the bitmap from file: */
+ /* ...or load the bitmap from file: */
wxString name = GetParamValue(param);
- if (name.IsEmpty()) return wxNullBitmap;
+ if (name.IsEmpty()) return wxNullBitmap;
#if wxUSE_FILESYSTEM
wxFSFile *fsfile = GetCurFileSystem().OpenFile(name);
if (fsfile == NULL)
-wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
+wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
const wxArtClient& defaultArtClient,
wxSize size)
{