Class: Wx::XmlResource

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/xml_resource.rb

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)

See Also:

  • Based Resource System (XRC)
  • File Format

Requires:

  • USE_XRC

Class Method Summary collapse

Instance Method Summary collapse

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.

Overloads:

  • #initialize(filemask, flags = Wx::XmlResourceFlags::XRC_USE_LOCALE, domain = ('')) ⇒ Wx::XmlResource

    Constructor.

    Parameters:

    • filemask (String)

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

    • flags (Integer) (defaults to: Wx::XmlResourceFlags::XRC_USE_LOCALE)

      One or more value of the Wx::XmlResourceFlags enumeration.

    • domain (String) (defaults to: (''))

      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.

  • #initialize(flags = Wx::XmlResourceFlags::XRC_USE_LOCALE, domain = ('')) ⇒ Wx::XmlResource

    Constructor.

    Parameters:

    • flags (Integer) (defaults to: Wx::XmlResourceFlags::XRC_USE_LOCALE)

      One or more value of the Wx::XmlResourceFlags enumeration.

    • domain (String) (defaults to: (''))

      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.



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

Parameters:



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.

Parameters:

  • numId (Integer)

Returns:

  • (String)


323
# File 'lib/wx/doc/gen/xml_resource.rb', line 323

def self.find_xrcid_by_id(numId) end

.getWx::XmlResource

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

Returns:



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.

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.

Parameters:

  • str_id (String)
  • value_if_not_found (Integer) (defaults to: Wx::StandardID::ID_NONE)

Returns:

  • (Integer)


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

Parameters:

Returns:



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

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

  • major (Integer)
  • minor (Integer)
  • release (Integer)
  • revision (Integer)

Returns:

  • (Integer)


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.

Parameters:

  • feature (String)


85
# File 'lib/wx/doc/gen/xml_resource.rb', line 85

def enable_feature(feature) end

#get_domainWx::String Also known as: domain

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

Returns:

  • (Wx::String)


89
# File 'lib/wx/doc/gen/xml_resource.rb', line 89

def get_domain; end

#get_flagsInteger Also known as: flags

Returns flags, which may be a bitlist of Wx::XmlResourceFlags enumeration values.

Returns:

  • (Integer)


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.

Parameters:

  • name (String)

    The name of the resource which must be unique for this function to work correctly, if there is more than one resource with the given name the choice of the one returned by this function is undefined.

Returns:



104
# File 'lib/wx/doc/gen/xml_resource.rb', line 104

def get_resource_node(name) end

#get_versionInteger Also known as: version

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

Returns:

  • (Integer)


109
# File 'lib/wx/doc/gen/xml_resource.rb', line 109

def get_version; end

#init_all_handlersvoid

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
Note:

If Setup::USE_FILESYSTEM is enabled, this method understands FileSystem URLs.

Note:

If you are sure that the argument is name of single XRC file (rather than an URL or a wildcard), use #load_file instead.

Parameters:

  • filemask (String)

Returns:

  • (Boolean)

See Also:



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.

Parameters:

  • dirname (String)

Returns:

  • (Boolean)

See Also:



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.

Parameters:

  • name (String)

Returns:



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

Parameters:

Returns:



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

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

  • file (String)

Returns:

  • (Boolean)

See Also:



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

Parameters:

Returns:



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

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

  • name (String)

Returns:



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.

Parameters:

  • name (String)

Returns:



221
# File 'lib/wx/doc/gen/xml_resource.rb', line 221

def load_menu(name) end

#load_menu_bar(parent, name) ⇒ Wx::MenuBar #load_menu_bar(name) ⇒ Wx::MenuBar

Overloads:



233
# File 'lib/wx/doc/gen/xml_resource.rb', line 233

def load_menu_bar(*args) end

#load_object(parent, name, classname) ⇒ Wx::Object #load_object(instance, parent, name, classname) ⇒ Boolean

Overloads:

  • #load_object(parent, name, classname) ⇒ Wx::Object

    Load an object from the resource specifying both the resource name and the class name.

    The first overload lets you load nonstandard container windows and returns nil on failure. The second one lets you finish the creation of an existing instance and returns false on failure. In either case, only the resources defined at the top level of XRC files can be loaded by this function, use #load_object_recursively if you need to load an object defined deeper in the hierarchy.

    Parameters:

    • parent (Wx::Window)
    • name (String)
    • classname (String)

    Returns:

  • #load_object(instance, parent, name, classname) ⇒ Boolean

    Parameters:

    Returns:

    • (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

Overloads:

  • #load_object_recursively(parent, name, classname) ⇒ Wx::Object

    Load an object from anywhere in the resource tree.

    These methods are similar to #load_object but may be used to load an object from anywhere in the resource tree and not only the top level. Note that you will very rarely need to do this as in normal use the entire container window (defined at the top level) is loaded and not its individual children but this method can be useful in some particular situations.

    Parameters:

    • parent (Wx::Window)
    • name (String)
    • classname (String)

    Returns:

  • #load_object_recursively(instance, parent, name, classname) ⇒ Boolean

    Parameters:

    Returns:

    • (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.

Parameters:

Returns:



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.

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

Returns:



289
# File 'lib/wx/doc/gen/xml_resource.rb', line 289

def load_tool_bar(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.

Parameters:

  • domain (String)


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

Parameters:

  • flags (Integer)


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.

Parameters:

  • filename (String)

Returns:

  • (Boolean)


308
# File 'lib/wx/doc/gen/xml_resource.rb', line 308

def unload(filename) end