Class: Wx::XmlResource
Overview
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 XmlResource.get getter.
Category: XML Based Resource System (XRC)
Class Method Summary collapse
-
.add_subclass_factory(factory) ⇒ void
Registers subclasses factory for use in XRC.
-
.find_xrcid_by_id(numId) ⇒ String
Returns a string ID corresponding to the given numeric ID.
-
.get ⇒ Wx::XmlResource
Gets the global resources object or creates one if none exists.
-
.get_xrcid(str_id, value_if_not_found = Wx::StandardID::ID_NONE) ⇒ Integer
Returns a numeric ID that is equivalent to the string ID used in an XML resource.
-
.set(res) ⇒ Wx::XmlResource
Sets the global resources object and returns a pointer to the previous one (may be NULL).
Instance Method Summary collapse
-
#attach_unknown_control(name, control, parent = nil) ⇒ Boolean
Attaches an unknown control to the given panel/window/dialog.
-
#compare_version(major, minor, release, revision) ⇒ Integer
Compares the XRC version to the argument.
-
#get_domain ⇒ Wx::String
(also: #domain)
Returns the domain (message catalog) that will be used to load translatable strings in the XRC.
-
#get_flags ⇒ Integer
(also: #flags)
Returns flags, which may be a bitlist of XmlResourceFlags enumeration values.
-
#get_resource_node(name) ⇒ Wx::XmlNode
(also: #resource_node)
Returns the XmlNode containing the definition of the object with the given name or NULL.
-
#get_version ⇒ Integer
(also: #version)
Returns version information (a.b.c.d = d + 256c + 2562b + 2563*a).
-
#init_all_handlers ⇒ void
Initializes handlers for all supported controls/windows.
-
#initialize(*args) ⇒ XmlResource
constructor
A new instance of XmlResource.
-
#load(filemask) ⇒ Boolean
Loads resources from XML files that match given filemask.
-
#load_all_files(dirname) ⇒ Boolean
Loads all .xrc files from directory dirname.
-
#load_bitmap(name) ⇒ Wx::Bitmap
Loads a bitmap resource from a file.
-
#load_dialog(parent, name) ⇒ Wx::Dialog
Loads a dialog.
-
#load_dialog_subclass(dlg, parent, name) ⇒ Boolean
Loads a dialog.
-
#load_file(file) ⇒ Boolean
Simpler form of #load for loading a single XRC file.
-
#load_frame(parent, name) ⇒ Wx::Frame
Loads a frame from the resource.
-
#load_frame_subclass(frame, parent, name) ⇒ Boolean
Loads the contents of a frame onto an existing Frame.
-
#load_icon(name) ⇒ Wx::Icon
Loads an icon resource from a file.
-
#load_menu(name) ⇒ Wx::Menu
Loads menu from resource.
- #load_menu_bar(*args) ⇒ Object
- #load_object(*args) ⇒ Object
- #load_object_recursively(*args) ⇒ Object
-
#load_panel(parent, name) ⇒ Wx::Panel
Loads a panel.
-
#load_panel_subclass(panel, parent, name) ⇒ Boolean
Loads a panel.
-
#load_tool_bar(parent, name) ⇒ Wx::ToolBar
Loads a toolbar.
-
#set_domain(domain) ⇒ void
(also: #domain=)
Sets the domain (message catalog) that will be used to load translatable strings in the XRC.
-
#set_flags(flags) ⇒ void
(also: #flags=)
Sets flags (bitlist of XmlResourceFlags enumeration values).
-
#unload(filename) ⇒ Boolean
This function unloads a resource previously loaded by #load.
Methods inherited from Object
#clone, #dup, #is_same_as, #un_share
Constructor Details
#initialize(filemask, flags = Wx::XmlResourceFlags::XRC_USE_LOCALE, domain = ('')) ⇒ Wx::XmlResource #initialize(flags = Wx::XmlResourceFlags::XRC_USE_LOCALE, domain = ('')) ⇒ Wx::XmlResource
Returns a new instance of XmlResource.
58 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 58 def initialize(*args) end |
Class Method Details
.add_subclass_factory(factory) ⇒ void
This method returns an undefined value.
Registers subclasses factory for use in XRC.
This is useful only for language bindings developers who need a way to implement subclassing in wxWidgets ports that don’t support RTTI (e.g. Python).
307 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 307 def self.add_subclass_factory(factory) end |
.find_xrcid_by_id(numId) ⇒ String
Returns a string ID corresponding to the given numeric ID.
The string returned is such that calling get_xrcid with it as parameter yields numId. If there is no string identifier corresponding to the given numeric one, an empty string is returned. Notice that, unlike get_xrcid, this function is slow as it checks all of the identifiers used in XRC.
315 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 315 def self.find_xrcid_by_id(numId) end |
.get ⇒ Wx::XmlResource
Gets the global resources object or creates one if none exists.
319 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 319 def self.get; end |
.get_xrcid(str_id, value_if_not_found = Wx::StandardID::ID_NONE) ⇒ 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 ID_XXX or integer), a new record is created which associates the given string with a number. If value_if_not_found is StandardID::ID_NONE, the number is obtained via new_id. Otherwise value_if_not_found is used. Macro XRCID(name)
is provided for convenient use in event tables.
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.
335 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 335 def self.get_xrcid(str_id, value_if_not_found=Wx::StandardID::ID_NONE) end |
.set(res) ⇒ Wx::XmlResource
Sets the global resources object and returns a pointer to the previous one (may be NULL).
340 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 340 def self.set(res) end |
Instance Method Details
#attach_unknown_control(name, control, parent = nil) ⇒ Boolean
Attaches an unknown control to the given panel/window/dialog.
Unknown controls are used in conjunction with <object class=“unknown”>.
67 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 67 def attach_unknown_control(name, control, parent=nil) end |
#compare_version(major, minor, release, 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.
77 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 77 def compare_version(major, minor, release, revision) end |
#get_domain ⇒ Wx::String Also known as: domain
Returns the domain (message catalog) that will be used to load translatable strings in the XRC.
81 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 81 def get_domain; end |
#get_flags ⇒ Integer Also known as: flags
Returns flags, which may be a bitlist of Wx::XmlResourceFlags enumeration values.
86 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 86 def get_flags; end |
#get_resource_node(name) ⇒ Wx::XmlNode Also known as: resource_node
Returns the Wx::XmlNode containing the definition of the object with the given name or NULL.
This function recursively searches all the loaded XRC files for an object with the specified name. If the object is found, the Wx::XmlNode corresponding to it is returned, so this function can be used to access additional information defined in the XRC file and not used by Wx::XmlResource itself, e.g. contents of application-specific XML tags.
The node corresponding to the resource with the given name or NULL.
96 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 96 def get_resource_node(name) end |
#get_version ⇒ Integer Also known as: version
Returns version information (a.b.c.d = d + 256c + 2562b + 2563*a).
101 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 101 def get_version; end |
#init_all_handlers ⇒ void
This method returns an undefined value.
Initializes handlers for all supported controls/windows.
This will make the executable quite big because it forces linking against most of the wxWidgets library.
108 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 108 def init_all_handlers; end |
#load(filemask) ⇒ Boolean
Loads resources from XML files that match given filemask.
Example:
if !Wx::XmlResource.get.load('rc/*.xrc')
Wx.log_error("Couldn't load resources!")
end
If Setup::USE_FILESYSTEM is enabled, this method understands FileSystem URLs.
If you are sure that the argument is name of single XRC file (rather than an URL or a wildcard), use #load_file instead.
134 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 134 def load(filemask) end |
#load_all_files(dirname) ⇒ Boolean
Loads all .xrc files from directory dirname.
Tries to load as many files as possible; if there’s an error while loading one file, it still attempts to load other files.
153 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 153 def load_all_files(dirname) end |
#load_bitmap(name) ⇒ Wx::Bitmap
Loads a bitmap resource from a file.
158 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 158 def load_bitmap(name) end |
#load_dialog(parent, name) ⇒ Wx::Dialog
Loads a dialog.
parent points to parent window (if any).
166 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 166 def load_dialog(parent, name) end |
#load_dialog_subclass(dlg, parent, name) ⇒ Boolean
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:
dlg = MyDialog.new
Wx::XmlResource.get.load_dialog_subclass(dlg, main_frame, 'my_dialog')
dlg.show_modal
dlg.destroy
184 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 184 def load_dialog_subclass(dlg, parent, name) end |
#load_file(file) ⇒ Boolean
Simpler form of #load for loading a single XRC file.
144 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 144 def load_file(file) end |
#load_frame(parent, name) ⇒ Wx::Frame
Loads a frame from the resource.
parent points to parent window (if any).
192 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 192 def load_frame(parent, name) end |
#load_frame_subclass(frame, parent, name) ⇒ Boolean
Loads the contents of a frame onto an existing Frame.
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).
201 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 201 def load_frame_subclass(frame, parent, name) end |
#load_icon(name) ⇒ Wx::Icon
Loads an icon resource from a file.
206 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 206 def load_icon(name) end |
#load_menu(name) ⇒ Wx::Menu
Loads menu from resource.
Returns NULL on failure.
213 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 213 def (name) end |
#load_menu_bar(parent, name) ⇒ Wx::MenuBar #load_menu_bar(name) ⇒ Wx::MenuBar
225 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 225 def (*args) end |
#load_object(parent, name, classname) ⇒ Wx::Object #load_object(instance, parent, name, classname) ⇒ Boolean
242 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 242 def load_object(*args) end |
#load_object_recursively(parent, name, classname) ⇒ Wx::Object #load_object_recursively(instance, parent, name, classname) ⇒ Boolean
258 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 258 def load_object_recursively(*args) end |
#load_panel(parent, name) ⇒ Wx::Panel
Loads a panel.
parent points to the parent window.
266 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 266 def load_panel(parent, name) end |
#load_panel_subclass(panel, parent, name) ⇒ Boolean
Loads a panel.
parent points to the parent window. This form is used to finish creation of an already existing instance.
275 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 275 def load_panel_subclass(panel, parent, name) end |
#load_tool_bar(parent, name) ⇒ Wx::ToolBar
Loads a toolbar.
281 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 281 def (parent, name) end |
#set_domain(domain) ⇒ void Also known as: domain=
This method returns an undefined value.
Sets the domain (message catalog) that will be used to load translatable strings in the XRC.
286 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 286 def set_domain(domain) end |
#set_flags(flags) ⇒ void Also known as: flags=
This method returns an undefined value.
Sets flags (bitlist of Wx::XmlResourceFlags enumeration values).
292 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 292 def set_flags(flags) end |
#unload(filename) ⇒ Boolean
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.
300 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 300 def unload(filename) end |