## wxXmlResource

This is the main class for interacting with the XML-based resource system.

The class holds XML resources from one or more .xml files, binary files or zip archive files.

See XML-based resource system overview for details.

Derived from

wxObject

Include files

<wx/xrc/xmlres.h>

Constants

    enum wxXmlResourceFlags
    {
        wxXRC_USE_LOCALE     = 1,
        wxXRC_NO_SUBCLASSING = 2,
        wxXRC_NO_RELOADING   = 4
    };

Members

wxXmlResource::wxXmlResource
wxXmlResource::~wxXmlResource
wxXmlResource::AddHandler
wxXmlResource::AttachUnknownControl
wxXmlResource::ClearHandlers
wxXmlResource::CompareVersion
wxXmlResource::Get
wxXmlResource::GetFlags
wxXmlResource::GetVersion
wxXmlResource::GetXRCID
wxXmlResource::InitAllHandlers
wxXmlResource::Load
wxXmlResource::LoadBitmap
wxXmlResource::LoadDialog
wxXmlResource::LoadFrame
wxXmlResource::LoadIcon
wxXmlResource::LoadMenu
wxXmlResource::LoadMenuBar
wxXmlResource::LoadPanel
wxXmlResource::LoadToolBar
wxXmlResource::Set
wxXmlResource::SetFlags
wxXmlResource::Unload
wxXmlResource::GetDomain
wxXmlResource::SetDomain

### wxXmlResource::wxXmlResource

wxXmlResource(const wxString& filemask, int flags = wxXRC_USE_LOCALE, const wxString domain = wxEmptyString)

Constructor.

filemask

The XRC file, archive file, or wildcard specification that will be used to load all resource files inside a zip archive.

flags

wxXRC_USE_LOCALE: translatable strings will be translated via _(). wxXRC_NO_SUBCLASSING: subclass property of object nodes will be ignored (useful for previews in XRC editors).

domain

The name of the gettext catalog to search for translatable strings. By default all loaded catalogs will be searched. This provides a way to allow the strings to only come from a specific catalog.

wxXmlResource(int flags = wxXRC_USE_LOCALE, const wxString domain = wxEmptyString)

Constructor.

flags

wxXRC_USE_LOCALE: translatable strings will be translated via _(). wxXRC_NO_SUBCLASSING: subclass property of object nodes will be ignored (useful for previews in XRC editors). wxXRC_NO_RELOADING will prevent the XRC files from being reloaded from disk in case they have been modified there since being last loaded (may slightly speed up loading them).

domain

The name of the gettext catalog to search for translatable strings. By default all loaded catalogs will be searched. This provides a way to allow the strings to only come from a specific catalog.

### wxXmlResource::~wxXmlResource

~wxXmlResource()

Destructor.

### wxXmlResource::AddHandler

void AddHandler(wxXmlResourceHandler* handler)

Initializes only a specific handler (or custom handler). Convention says that the handler name is equal to the control's name plus 'XmlHandler', for example wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. The XML resource compiler (wxxrc) can create include file that contains initialization code for all controls used within the resource. Note that this handler should be allocated on the heap, since it will be delete by ClearHandlers later.

### wxXmlResource::AttachUnknownControl

bool AttachUnknownControl(const wxString& name, wxWindow* control, wxWindow* parent = NULL)

Attaches an unknown control to the given panel/window/dialog. Unknown controls are used in conjunction with <object class="unknown">.

### wxXmlResource::ClearHandlers

void ClearHandlers()

Removes all handlers and deletes them (this means that any handlers added using AddHandler must be allocated on the heap).

### wxXmlResource::CompareVersion

int CompareVersion(int major, int minor, int release, int revision) const

Compares the XRC version to the argument. Returns -1 if the XRC version is less than the argument, +1 if greater, and 0 if they equal.

### wxXmlResource::Get

wxXmlResource* Get()

Gets the global resources object or creates one if none exists.

### wxXmlResource::GetFlags

int GetFlags()

Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING.

### wxXmlResource::GetVersion

long GetVersion() const

Returns version information (a.b.c.d = d+ 256*c + 256``2*b + 256``3*a).

### wxXmlResource::GetXRCID

int GetXRCID(const wxChar* str_id, int value_if_not_found = -2)

Returns a numeric ID that is equivalent to the string ID used in an XML resource. If an unknown str_id is requested (i.e. other than wxID_XXX or integer), a new record is created which associates the given string with a number. If value_if_not_found is `wxID_NONE`, the number is obtained via wxNewId(). Otherwise value_if_not_found is used. Macro `XRCID(name)` is provided for convenient use in event tables.

### wxXmlResource::InitAllHandlers

void InitAllHandlers()

Initializes handlers for all supported controls/windows. This will make the executable quite big because it forces linking against most of the wxWidgets library.

### wxXmlResource::Load

bool Load(const wxString& filemask)

Loads resources from XML files that match given filemask. This method understands VFS (see filesys.h).

### wxXmlResource::LoadBitmap

wxBitmap LoadBitmap(const wxString& name)

Loads a bitmap resource from a file.

### wxXmlResource::LoadDialog

wxDialog* LoadDialog(wxWindow* parent, const wxString& name)

Loads a dialog. dlg points to a parent window (if any).

bool LoadDialog(wxDialog* dlg, wxWindow* parent, const wxString& name)

Loads a dialog. dlg points to parent window (if any).

This form is used to finish creation of an already existing instance (the main reason for this is that you may want to use derived class with a new event table).

Example:

      MyDialog dlg;
      wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
      dlg->ShowModal();

### wxXmlResource::LoadFrame

bool LoadFrame(wxFrame* frame, wxWindow* parent, const wxString& name)

Loads a frame.

### wxXmlResource::LoadIcon

wxIcon LoadIcon(const wxString& name)

Loads an icon resource from a file.

### wxXmlResource::LoadMenu

wxMenu* LoadMenu(const wxString& name)

Loads menu from resource. Returns NULL on failure.

### wxXmlResource::LoadMenuBar

wxMenuBar* LoadMenuBar(wxWindow* parent, const wxString& name)

Loads a menubar from resource. Returns NULL on failure.

wxMenuBar* LoadMenuBar(const wxString& name)

Loads a menubar from resource. Returns NULL on failure.

### wxXmlResource::LoadPanel

wxPanel* LoadPanel(wxWindow* parent, const wxString& name)

Loads a panel. panel points to parent window (if any).

bool LoadPanel(wxPanel* panel, wxWindow* parent, const wxString& name)

Loads a panel. panel points to parent window (if any). This form is used to finish creation of an already existing instance.

### wxXmlResource::LoadToolBar

wxToolBar* LoadToolBar(wxWindow* parent, const wxString& name)

Loads a toolbar.

### wxXmlResource::Set

wxXmlResource* Set(wxXmlResource* res)

Sets the global resources object and returns a pointer to the previous one (may be NULL).

### wxXmlResource::SetFlags

void SetFlags(int flags)

Sets flags (bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING).

### wxXmlResource::Unload

bool Unload(const wxString& filename)

This function unloads a resource previously loaded by Load().

Returns `true` if the resource was successfully unloaded and `false` if it hasn't been found in the list of loaded resources.

### wxXmlResource::GetDomain

wxChar* GetDomain()

Returns the domain (message catalog) that will be used to load translatable strings in the XRC.

### wxXmlResource::SetDomain

wxChar* SetDomain(const wxChar* domain)

Sets the domain (message catalog) that will be used to load translatable strings in the XRC.