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 nil).
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.
-
#enable_feature(feature) ⇒ void
Add a feature considered to be enabled.
-
#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 nil.
-
#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).
315 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 315 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.
323 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 323 def self.find_xrcid_by_id(numId) end |
.get ⇒ Wx::XmlResource
Gets the global resources object or creates one if none exists.
327 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 327 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.
343 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 343 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 nil).
348 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 348 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 |
#enable_feature(feature) ⇒ void
This method returns an undefined value.
Add a feature considered to be enabled.
Objects in XRC documents may have a “feature” attribute, as explained in the Feature-specific Content. By default, none of the features is enabled and so all objects with this attribute are discarded. Calling this function marks the given feature as being enabled and affects the subsequent calls to load_document and related functions, which will keep, rather than discard, any nodes using the given feature string in their “feature” attribute. This function can be called multiple times to enable more than one feature.
85 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 85 def enable_feature(feature) 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.
89 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 89 def get_domain; end |
#get_flags ⇒ Integer Also known as: flags
Returns flags, which may be a bitlist of Wx::XmlResourceFlags enumeration values.
94 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 94 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 nil.
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 nil.
104 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 104 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).
109 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 109 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.
116 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 116 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.
142 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 142 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.
161 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 161 def load_all_files(dirname) end |
#load_bitmap(name) ⇒ Wx::Bitmap
Loads a bitmap resource from a file.
166 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 166 def load_bitmap(name) end |
#load_dialog(parent, name) ⇒ Wx::Dialog
Loads a dialog.
parent points to parent window (if any).
174 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 174 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
192 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 192 def load_dialog_subclass(dlg, parent, name) end |
#load_file(file) ⇒ Boolean
Simpler form of #load for loading a single XRC file.
152 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 152 def load_file(file) end |
#load_frame(parent, name) ⇒ Wx::Frame
Loads a frame from the resource.
parent points to parent window (if any).
200 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 200 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).
209 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 209 def load_frame_subclass(frame, parent, name) end |
#load_icon(name) ⇒ Wx::Icon
Loads an icon resource from a file.
214 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 214 def load_icon(name) end |
#load_menu(name) ⇒ Wx::Menu
Loads menu from resource.
Returns nil on failure.
221 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 221 def (name) end |
#load_menu_bar(parent, name) ⇒ Wx::MenuBar #load_menu_bar(name) ⇒ Wx::MenuBar
233 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 233 def (*args) end |
#load_object(parent, name, classname) ⇒ Wx::Object #load_object(instance, parent, name, classname) ⇒ Boolean
250 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 250 def load_object(*args) end |
#load_object_recursively(parent, name, classname) ⇒ Wx::Object #load_object_recursively(instance, parent, name, classname) ⇒ Boolean
266 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 266 def load_object_recursively(*args) end |
#load_panel(parent, name) ⇒ Wx::Panel
Loads a panel.
parent points to the parent window.
274 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 274 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.
283 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 283 def load_panel_subclass(panel, parent, name) end |
#load_tool_bar(parent, name) ⇒ Wx::ToolBar
Loads a toolbar.
289 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 289 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.
294 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 294 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).
300 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 300 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.
308 |
# File 'lib/wx/doc/gen/xml_resource.rb', line 308 def unload(filename) end |