Public Member Functions | Protected Member Functions

# wxXmlResourceHandler Class Reference
[XML Based Resource System (XRC)]

`#include <wx/xrc/xmlres.h>`

Inheritance diagram for wxXmlResourceHandler:
[legend]

## Detailed Description

wxSizerXmlHandler is a class for resource handlers capable of creating a wxSizer object from an XML node.

wxXmlResourceHandler is an abstract base class for resource handlers capable of creating a control from an XML node.

See also:
  wxXmlResourceHandler, wxSizer

##

Library: wxXRC
Category: XML Based Resource System (XRC)

See XML Based Resource System (XRC) for details.

##

Library: wxXRC
Category: XML Based Resource System (XRC)

## Public Member Functions
| wxXmlResourceHandler ()
| Default constructor.
virtual | ~wxXmlResourceHandler ()
| Destructor.
wxObject * | CreateResource (wxXmlNode *node, wxObject *parent, wxObject *instance)
| Creates an object (menu, dialog, control, ...) from an XML node.
virtual wxObject * | DoCreateResource ()=0
| Called from CreateResource after variables were filled.
virtual bool | CanHandle (wxXmlNode *node)=0
| Returns true if it understands this node and can create a resource from it, false otherwise.
void | SetParentResource (wxXmlResource *res)
| Sets the parent resource.
## Protected Member Functions
void | AddStyle (const wxString &name, int value)
| Add a style flag (e.g.
void | AddWindowStyles ()
| Add styles common to all wxWindow-derived classes.
void | CreateChildren (wxObject *parent, bool this_hnd_only=false)
| Creates children.
void | CreateChildrenPrivately (wxObject *parent, wxXmlNode *rootnode=NULL)
| Helper function.
wxObject * | CreateResFromNode (wxXmlNode *node, wxObject *parent, wxObject *instance=NULL)
| Creates a resource from a node.
wxAnimation | GetAnimation (const wxString &param="animation")
| Creates an animation (see wxAnimation) from the filename specified in param.
wxBitmap | GetBitmap (const wxString &param="bitmap", const wxArtClient &defaultArtClient=wxART_OTHER, wxSize size=wxDefaultSize)
| Gets a bitmap.
wxBitmap | GetBitmap (const wxXmlNode *node, const wxArtClient &defaultArtClient=wxART_OTHER, wxSize size=wxDefaultSize)
| Gets a bitmap from an XmlNode.
bool | GetBool (const wxString &param, bool defaultv=false)
| Gets a bool flag (1, t, yes, on, true are true, everything else is false).
wxColour | GetColour (const wxString &param, const wxColour &defaultColour=wxNullColour)
| Gets colour in HTML syntax (#RRGGBB).
wxFileSystem & | GetCurFileSystem ()
| Returns the current file system.
wxCoord | GetDimension (const wxString &param, wxCoord defaultv=0, wxWindow *windowToUse=0)
| Gets a dimension (may be in dialog units).
wxFont | GetFont (const wxString &param="font")
| Gets a font.
int | GetID ()
| Returns the XRCID.
wxIcon | GetIcon (const wxString &param="icon", const wxArtClient &defaultArtClient=wxART_OTHER, wxSize size=wxDefaultSize)
| Returns an icon.
wxIcon | GetIcon (const wxXmlNode *node, const wxArtClient &defaultArtClient=wxART_OTHER, wxSize size=wxDefaultSize)
| Gets an icon from an XmlNode.
wxIconBundle | GetIconBundle (const wxString &param, const wxArtClient &defaultArtClient=wxART_OTHER)
| Returns an icon bundle.
wxImageList * | GetImageList (const wxString &param=wxT("imagelist"))
| Creates an image list from the param markup data.
long | GetLong (const wxString &param, long defaultv=0)
| Gets the integer value from the parameter.
wxString | GetName ()
| Returns the resource name.
wxString | GetNodeContent (wxXmlNode *node)
| Gets node content from wxXML_ENTITY_NODE.
wxXmlNode * | GetParamNode (const wxString &param)
| Finds the node or returns NULL.
wxString | GetParamValue (const wxString &param)
| Finds the parameter value or returns the empty string.
wxString | GetParamValue (const wxXmlNode *node)
| Returns the node parameter value.
wxPoint | GetPosition (const wxString &param="pos")
| Gets the position (may be in dialog units).
wxSize | GetSize (const wxString &param="size", wxWindow *windowToUse=0)
| Gets the size (may be in dialog units).
int | GetStyle (const wxString &param="style", int defaults=0)
| Gets style flags from text in form "flag | flag2| flag3 |..." Only understands flags added with AddStyle().
wxString | GetText (const wxString &param, bool translate=true)
| Gets text from param and does some conversions: replaces \n, \r, \t by respective characters (according to C syntax) replaces `$` by `and` `$$` by `$` (needed for `_File` to `File` translation because of XML syntax) calls wxGetTranslations (unless disabled in wxXmlResource).
bool | HasParam (const wxString &param)
| Check to see if a parameter exists.
bool | IsOfClass (wxXmlNode *node, const wxString &classname)
| Convenience function.
void | SetupWindow (wxWindow *wnd)
| Sets common window options.
void | ReportError (wxXmlNode *context, const wxString &message)
| Reports error in XRC resources to the user.
void | ReportError (const wxString &message)
| Like ReportError(wxXmlNode*, const wxString&), but uses the node of currently processed object (m_node) as the context.
void | ReportParamError (const wxString &param, const wxString &message)
| Like ReportError(wxXmlNode*, const wxString&), but uses the node of parameter param of the currently processed object as the context.

List of all members.

## Constructor & Destructor Documentation

wxXmlResourceHandler::wxXmlResourceHandler | ( |  | ) |

Default constructor.

virtual wxXmlResourceHandler::~wxXmlResourceHandler | ( |  | ) | `[virtual]`

Destructor.

## Member Function Documentation

void wxXmlResourceHandler::AddStyle | ( | const wxString & | name,
|  | int | value |
| ) |  |  | `[protected]`

Add a style flag (e.g.

`wxMB_DOCKABLE`) to the list of flags understood by this handler.

void wxXmlResourceHandler::AddWindowStyles | ( |  | ) | `[protected]`

Add styles common to all wxWindow-derived classes.

virtual bool wxXmlResourceHandler::CanHandle | ( | wxXmlNode * | node | ) | `[pure virtual]`

Returns true if it understands this node and can create a resource from it, false otherwise.

Note:
  You must not call any wxXmlResourceHandler methods except IsOfClass() from this method! The instance is not yet initialized with node data at the time CanHandle() is called and it is only safe to operate on node directly or to call IsOfClass().

Implemented in wxSizerXmlHandler.

void wxXmlResourceHandler::CreateChildren | ( | wxObject * | parent,
|  | bool | this_hnd_only = `false` |
| ) |  |  | `[protected]`

Creates children.

void wxXmlResourceHandler::CreateChildrenPrivately | ( | wxObject * | parent,
|  | wxXmlNode * | rootnode = `NULL` |
| ) |  |  | `[protected]`

Helper function.

wxObject* wxXmlResourceHandler::CreateResFromNode | ( | wxXmlNode * | node,
|  | wxObject * | parent,
|  | wxObject * | instance = `NULL` |
| ) |  |  | `[protected]`

Creates a resource from a node.

wxObject* wxXmlResourceHandler::CreateResource | ( | wxXmlNode * | node,
|  | wxObject * | parent,
|  | wxObject * | instance |
| ) |  |  |

Creates an object (menu, dialog, control, ...) from an XML node.

Should check for validity. parent is a higher-level object (usually window, dialog or panel) that is often necessary to create the resource.

If instance is non-NULL it should not create a new instance via 'new' but should rather use this one, and call its Create method.

virtual wxObject* wxXmlResourceHandler::DoCreateResource | ( |  | ) | `[pure virtual]`

Called from CreateResource after variables were filled.

Implemented in wxSizerXmlHandler.

wxAnimation wxXmlResourceHandler::GetAnimation | ( | const wxString & | param = `"animation"` | ) | `[protected]`

Creates an animation (see wxAnimation) from the filename specified in param.

wxBitmap wxXmlResourceHandler::GetBitmap | ( | const wxString & | param = `"bitmap"`,
|  | const wxArtClient & | defaultArtClient = `wxART_OTHER`,
|  | wxSize | size = `wxDefaultSize` |
| ) |  |  | `[protected]`

Gets a bitmap.

wxBitmap wxXmlResourceHandler::GetBitmap | ( | const wxXmlNode * | node,
|  | const wxArtClient & | defaultArtClient = `wxART_OTHER`,
|  | wxSize | size = `wxDefaultSize` |
| ) |  |  | `[protected]`

Gets a bitmap from an XmlNode.

Since:
  2.9.1

bool wxXmlResourceHandler::GetBool | ( | const wxString & | param,
|  | bool | defaultv = `false` |
| ) |  |  | `[protected]`

Gets a bool flag (1, t, yes, on, true are true, everything else is false).

wxColour wxXmlResourceHandler::GetColour | ( | const wxString & | param,
|  | const wxColour & | defaultColour = `wxNullColour` |
| ) |  |  | `[protected]`

Gets colour in HTML syntax (#RRGGBB).

wxFileSystem& wxXmlResourceHandler::GetCurFileSystem | ( |  | ) | `[protected]`

Returns the current file system.

wxCoord wxXmlResourceHandler::GetDimension | ( | const wxString & | param,
|  | wxCoord | defaultv = `0`,
|  | wxWindow * | windowToUse = `0` |
| ) |  |  | `[protected]`

Gets a dimension (may be in dialog units).

wxFont wxXmlResourceHandler::GetFont | ( | const wxString & | param = `"font"` | ) | `[protected]`

Gets a font.

wxIcon wxXmlResourceHandler::GetIcon | ( | const wxString & | param = `"icon"`,
|  | const wxArtClient & | defaultArtClient = `wxART_OTHER`,
|  | wxSize | size = `wxDefaultSize` |
| ) |  |  | `[protected]`

Returns an icon.

wxIcon wxXmlResourceHandler::GetIcon | ( | const wxXmlNode * | node,
|  | const wxArtClient & | defaultArtClient = `wxART_OTHER`,
|  | wxSize | size = `wxDefaultSize` |
| ) |  |  | `[protected]`

Gets an icon from an XmlNode.

Since:
  2.9.1

wxIconBundle wxXmlResourceHandler::GetIconBundle | ( | const wxString & | param,
|  | const wxArtClient & | defaultArtClient = `wxART_OTHER` |
| ) |  |  | `[protected]`

Returns an icon bundle.

Note:
  Bundles can be loaded either with stock IDs or from files that contain more than one image (e.g. Windows icon files). If a file contains only single image, a bundle with only one icon will be created.

Since:
  2.9.0

int wxXmlResourceHandler::GetID | ( |  | ) | `[protected]`

Returns the XRCID.

wxImageList* wxXmlResourceHandler::GetImageList | ( | const wxString & | param = `wxT("imagelist")` | ) | `[protected]`

Creates an image list from the param markup data.

Returns:
  The new instance of wxImageList or NULL if no data is found.

Since:
  2.9.1

long wxXmlResourceHandler::GetLong | ( | const wxString & | param,
|  | long | defaultv = `0` |
| ) |  |  | `[protected]`

Gets the integer value from the parameter.

wxString wxXmlResourceHandler::GetName | ( |  | ) | `[protected]`

Returns the resource name.

wxString wxXmlResourceHandler::GetNodeContent | ( | wxXmlNode * | node | ) | `[protected]`

Gets node content from wxXML_ENTITY_NODE.

wxXmlNode* wxXmlResourceHandler::GetParamNode | ( | const wxString & | param | ) | `[protected]`

Finds the node or returns NULL.

wxString wxXmlResourceHandler::GetParamValue | ( | const wxString & | param | ) | `[protected]`

Finds the parameter value or returns the empty string.

wxString wxXmlResourceHandler::GetParamValue | ( | const wxXmlNode * | node | ) | `[protected]`

Returns the node parameter value.

Since:
  2.9.1

wxPoint wxXmlResourceHandler::GetPosition | ( | const wxString & | param = `"pos"` | ) | `[protected]`

Gets the position (may be in dialog units).

wxSize wxXmlResourceHandler::GetSize | ( | const wxString & | param = `"size"`,
|  | wxWindow * | windowToUse = `0` |
| ) |  |  | `[protected]`

Gets the size (may be in dialog units).

int wxXmlResourceHandler::GetStyle | ( | const wxString & | param = `"style"`,
|  | int | defaults = `0` |
| ) |  |  | `[protected]`

Gets style flags from text in form "flag | flag2| flag3 |..." Only understands flags added with AddStyle().

wxString wxXmlResourceHandler::GetText | ( | const wxString & | param,
|  | bool | translate = `true` |
| ) |  |  | `[protected]`

Gets text from param and does some conversions:

- replaces \n, \r, \t by respective characters (according to C syntax)
- replaces `$` by `and` `$$` by `$` (needed for `_File` to `File` translation because of XML syntax)
- calls wxGetTranslations (unless disabled in wxXmlResource).

bool wxXmlResourceHandler::HasParam | ( | const wxString & | param | ) | `[protected]`

Check to see if a parameter exists.

bool wxXmlResourceHandler::IsOfClass | ( | wxXmlNode * | node,
|  | const wxString & | classname |
| ) |  |  | `[protected]`

Convenience function.

Returns true if the node has a property class equal to classname, e.g. object class="wxDialog".

void wxXmlResourceHandler::ReportError | ( | const wxString & | message | ) | `[protected]`

Like ReportError(wxXmlNode*, const wxString&), but uses the node of currently processed object (m_node) as the context.

Since:
  2.9.0

void wxXmlResourceHandler::ReportError | ( | wxXmlNode * | context,
|  | const wxString & | message |
| ) |  |  | `[protected]`

Reports error in XRC resources to the user.

See wxXmlResource::ReportError() for more information.

Since:
  2.9.0

void wxXmlResourceHandler::ReportParamError | ( | const wxString & | param,
|  | const wxString & | message |
| ) |  |  | `[protected]`

Like ReportError(wxXmlNode*, const wxString&), but uses the node of parameter param of the currently processed object as the context.

This is convenience function for reporting errors in particular parameters.

Since:
  2.9.0

void wxXmlResourceHandler::SetParentResource | ( | wxXmlResource * | res | ) |

Sets the parent resource.

void wxXmlResourceHandler::SetupWindow | ( | wxWindow * | wnd | ) | `[protected]`

Sets common window options.

|  | [ top ]