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:



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.

Parameters:

  • numId (Integer)

Returns:

  • (String)


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

def self.find_xrcid_by_id(numId) end

.getWx::XmlResource

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

Returns:



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.

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)


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

Parameters:

Returns:



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

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

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


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

def get_domain; end

#get_flagsInteger Also known as: flags

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

Returns:

  • (Integer)


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.

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:



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

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)


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

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.



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



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.

Parameters:

  • dirname (String)

Returns:

  • (Boolean)

See Also:



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.

Parameters:

  • name (String)

Returns:



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

Parameters:

Returns:



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

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

  • file (String)

Returns:

  • (Boolean)

See Also:



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

Parameters:

Returns:



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

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

  • name (String)

Returns:



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.

Parameters:

  • name (String)

Returns:



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

def load_menu(name) end

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

Overloads:



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

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


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

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)


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.

Parameters:

Returns:



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.

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

Returns:



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

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)


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

Parameters:

  • flags (Integer)


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.

Parameters:

  • filename (String)

Returns:

  • (Boolean)


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

def unload(filename) end