Search documentation of wx

# View Source wxXmlResource (wx v2.4.3)

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.

Note that this is a singleton class and you'll never allocate/deallocate it. Just use the static `get/0` getter.

See:

- Overview xrc

- Overview xrcformat

wxWidgets docs: wxXmlResource

# Summary

## Types

wxXmlResource()

## Functions

attachUnknownControl(This, Name, Control)

Equivalent to `attachUnknownControl(This, Name, Control, [])`.

attachUnknownControl/4

Attaches an unknown control to the given panel/window/dialog.

clearHandlers(This)

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

compareVersion(This, Major, Minor, Release, Revision)

Compares the XRC version to the argument.

destroy(This)

Destroys the object

get()

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

getFlags(This)

Returns flags, which may be a bitlist of ?wxXmlResourceFlags enumeration values.

getVersion(This)

Returns version information (a.b.c.d = d + 256c + 2562b + 2563*a).

getXRCID(Str_id)

Equivalent to `getXRCID(Str_id, [])`.

getXRCID(Str_id, Options)

Returns a numeric ID that is equivalent to the string ID used in an XML resource.

initAllHandlers(This)

Initializes handlers for all supported controls/windows.

load(This, Filemask)

Loads resources from XML files that match given filemask.

loadBitmap(This, Name)

Loads a bitmap resource from a file.

loadDialog(This, Parent, Name)

Loads a dialog.

loadDialog(This, Dlg, Parent, Name)

Loads a dialog.

loadFrame(This, Parent, Name)

Loads a frame from the resource.

loadFrame(This, Frame, Parent, Name)

Loads the contents of a frame onto an existing `wxFrame`.

loadIcon(This, Name)

Loads an icon resource from a file.

loadMenu(This, Name)

Loads menu from resource.

loadMenuBar(This, Name)
loadMenuBar(This, Parent, Name)

Loads a menubar from resource.

loadPanel(This, Parent, Name)

Loads a panel.

loadPanel(This, Panel, Parent, Name)

Loads a panel.

loadToolBar(This, Parent, Name)

Loads a toolbar.

new()

Equivalent to `new([])`.

new(Options)

Constructor.

new(Filemask, Options)

Constructor.

set(Res)

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

setFlags(This, Flags)

Sets flags (bitlist of ?wxXmlResourceFlags enumeration values).

unload(This, Filename)

This function unloads a resource previously loaded by `load/2`.

xrcctrl(Window, Name, Type)

# Types

Link to this type

# wxXmlResource()

View Source

    -type wxXmlResource() :: wx:wx_object().

# Functions

Link to this function

# attachUnknownControl(This, Name, Control)

View Source

    -spec attachUnknownControl(This, Name, Control) -> boolean()
                                  when
                                      This :: wxXmlResource(),
                                      Name :: unicode:chardata(),
                                      Control :: wxWindow:wxWindow().

Equivalent to `attachUnknownControl(This, Name, Control, [])`.

Link to this function

# attachUnknownControl/4

View Source

    -spec attachUnknownControl(This, Name, Control, [Option]) -> boolean()
                                  when
                                      This :: wxXmlResource(),
                                      Name :: unicode:chardata(),
                                      Control :: wxWindow:wxWindow(),
                                      Option :: {parent, wxWindow:wxWindow()}.

Attaches an unknown control to the given panel/window/dialog.

Unknown controls are used in conjunction with <object class="unknown">.

Link to this function

# clearHandlers(This)

View Source

    -spec clearHandlers(This) -> ok when This :: wxXmlResource().

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

Link to this function

# compareVersion(This, Major, Minor, Release, Revision)

View Source

    -spec compareVersion(This, Major, Minor, Release, Revision) -> integer()
                            when
                                This :: wxXmlResource(),
                                Major :: integer(),
                                Minor :: integer(),
                                Release :: integer(),
                                Revision :: integer().

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 are equal.

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxXmlResource()) -> ok.

Destroys the object

Link to this function

# get()

View Source

    -spec get() -> wxXmlResource().

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

Link to this function

# getFlags(This)

View Source

    -spec getFlags(This) -> integer() when This :: wxXmlResource().

Returns flags, which may be a bitlist of ?wxXmlResourceFlags enumeration values.

Link to this function

# getVersion(This)

View Source

    -spec getVersion(This) -> integer() when This :: wxXmlResource().

Returns version information (a.b.c.d = d + 256c + 2562b + 2563*a).

Link to this function

# getXRCID(Str_id)

View Source

    -spec getXRCID(Str_id) -> integer() when Str_id :: unicode:chardata().

Equivalent to `getXRCID(Str_id, [])`.

Link to this function

# getXRCID(Str_id, Options)

View Source

    -spec getXRCID(Str_id, [Option]) -> integer()
                      when Str_id :: unicode:chardata(), Option :: {value_if_not_found, integer()}.

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 `wx_misc:newId/0`. Otherwise `value_if_not_found` is used.

Macro `XRCID(name)` is provided for convenient use in event tables.

Note: IDs returned by XRCID() cannot be used with the `EVT_*_RANGE` macros, because the order in which they are assigned to symbolic `name` values is not guaranteed.

Link to this function

# initAllHandlers(This)

View Source

    -spec initAllHandlers(This) -> ok when This :: wxXmlResource().

Initializes handlers for all supported controls/windows.

This will make the executable quite big because it forces linking against most of the wxWidgets library.

Link to this function

# load(This, Filemask)

View Source

    -spec load(This, Filemask) -> boolean() when This :: wxXmlResource(), Filemask :: unicode:chardata().

Loads resources from XML files that match given filemask.

Example:

Note: If wxUSE_FILESYS is enabled, this method understands `wxFileSystem` (not implemented in wx) URLs (see `wxFileSystem::FindFirst()` (not implemented in wx)).

Note: If you are sure that the argument is name of single XRC file (rather than an URL or a wildcard), use `LoadFile()` (not implemented in wx) instead.

Link to this function

# loadBitmap(This, Name)

View Source

    -spec loadBitmap(This, Name) -> wxBitmap:wxBitmap()
                        when This :: wxXmlResource(), Name :: unicode:chardata().

Loads a bitmap resource from a file.

Link to this function

# loadDialog(This, Parent, Name)

View Source

    -spec loadDialog(This, Parent, Name) -> wxDialog:wxDialog()
                        when
                            This :: wxXmlResource(),
                            Parent :: wxWindow:wxWindow(),
                            Name :: unicode:chardata().

Loads a dialog.

`parent` points to parent window (if any).

Link to this function

# loadDialog(This, Dlg, Parent, Name)

View Source

    -spec loadDialog(This, Dlg, Parent, Name) -> boolean()
                        when
                            This :: wxXmlResource(),
                            Dlg :: wxDialog:wxDialog(),
                            Parent :: wxWindow:wxWindow(),
                            Name :: unicode:chardata().

Loads a dialog.

`parent` 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:

Link to this function

# loadFrame(This, Parent, Name)

View Source

    -spec loadFrame(This, Parent, Name) -> wxFrame:wxFrame()
                       when
                           This :: wxXmlResource(),
                           Parent :: wxWindow:wxWindow(),
                           Name :: unicode:chardata().

Loads a frame from the resource.

`parent` points to parent window (if any).

Link to this function

# loadFrame(This, Frame, Parent, Name)

View Source

    -spec loadFrame(This, Frame, Parent, Name) -> boolean()
                       when
                           This :: wxXmlResource(),
                           Frame :: wxFrame:wxFrame(),
                           Parent :: wxWindow:wxWindow(),
                           Name :: unicode:chardata().

Loads the contents of a frame onto an existing `wxFrame`.

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).

Link to this function

# loadIcon(This, Name)

View Source

    -spec loadIcon(This, Name) -> wxIcon:wxIcon() when This :: wxXmlResource(), Name :: unicode:chardata().

Loads an icon resource from a file.

Link to this function

# loadMenu(This, Name)

View Source

    -spec loadMenu(This, Name) -> wxMenu:wxMenu() when This :: wxXmlResource(), Name :: unicode:chardata().

Loads menu from resource.

Returns NULL on failure.

Link to this function

# loadMenuBar(This, Name)

View Source

    -spec loadMenuBar(This, Name) -> wxMenuBar:wxMenuBar()
                         when This :: wxXmlResource(), Name :: unicode:chardata().

Link to this function

# loadMenuBar(This, Parent, Name)

View Source

    -spec loadMenuBar(This, Parent, Name) -> wxMenuBar:wxMenuBar()
                         when
                             This :: wxXmlResource(),
                             Parent :: wxWindow:wxWindow(),
                             Name :: unicode:chardata().

Loads a menubar from resource.

Returns NULL on failure.

Link to this function

# loadPanel(This, Parent, Name)

View Source

    -spec loadPanel(This, Parent, Name) -> wxPanel:wxPanel()
                       when
                           This :: wxXmlResource(),
                           Parent :: wxWindow:wxWindow(),
                           Name :: unicode:chardata().

Loads a panel.

`parent` points to the parent window.

Link to this function

# loadPanel(This, Panel, Parent, Name)

View Source

    -spec loadPanel(This, Panel, Parent, Name) -> boolean()
                       when
                           This :: wxXmlResource(),
                           Panel :: wxPanel:wxPanel(),
                           Parent :: wxWindow:wxWindow(),
                           Name :: unicode:chardata().

Loads a panel.

`parent` points to the parent window. This form is used to finish creation of an already existing instance.

Link to this function

# loadToolBar(This, Parent, Name)

View Source

    -spec loadToolBar(This, Parent, Name) -> wxToolBar:wxToolBar()
                         when
                             This :: wxXmlResource(),
                             Parent :: wxWindow:wxWindow(),
                             Name :: unicode:chardata().

Loads a toolbar.

Link to this function

# new()

View Source

    -spec new() -> wxXmlResource().

Equivalent to `new([])`.

Link to this function

# new(Options)

View Source

    -spec new([Option]) -> wxXmlResource() when Option :: {flags, integer()} | {domain, unicode:chardata()}.

Constructor.

Link to this function

# new(Filemask, Options)

View Source

    -spec new(Filemask, [Option]) -> wxXmlResource()
                 when
                     Filemask :: unicode:chardata(),
                     Option :: {flags, integer()} | {domain, unicode:chardata()}.

Constructor.

Link to this function

# set(Res)

View Source

    -spec set(Res) -> wxXmlResource() when Res :: wxXmlResource().

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

Link to this function

# setFlags(This, Flags)

View Source

    -spec setFlags(This, Flags) -> ok when This :: wxXmlResource(), Flags :: integer().

Sets flags (bitlist of ?wxXmlResourceFlags enumeration values).

Link to this function

# unload(This, Filename)

View Source

    -spec unload(This, Filename) -> boolean() when This :: wxXmlResource(), Filename :: unicode:chardata().

This function unloads a resource previously loaded by `load/2`.

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

Link to this function

# xrcctrl(Window, Name, Type)

View Source

    -spec xrcctrl(Window, Name, Type) -> wx:wx_object()
                     when Window :: wxWindow:wxWindow(), Name :: string(), Type :: atom().