]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/xrc/xmlres.h
a few more member groups, in line with the real header's groups
[wxWidgets.git] / interface / wx / xrc / xmlres.h
index a178f1a0dc3dff64b0e5ff641951ce5de98d8211..849b932ea6562a43047295601602fee6dc6cd6d4 100644 (file)
@@ -31,7 +31,10 @@ enum wxXmlResourceFlags
     The class holds XML resources from one or more .xml files, binary files or zip
     archive files.
 
-    @see @ref overview_xrc, @ref xrc_format
+    Note that this is a singleton class and you'll never allocate/deallocate it.
+    Just use the static wxXmlResource::Get() getter.
+
+    @see @ref overview_xrc, @ref overview_xrcformat
 
     @library{wxxrc}
     @category{xrc}
@@ -39,7 +42,6 @@ enum wxXmlResourceFlags
 class wxXmlResource : public wxObject
 {
 public:
-    //@{
     /**
         Constructor.
 
@@ -55,10 +57,20 @@ public:
     */
     wxXmlResource(const wxString& filemask,
                   int flags = wxXRC_USE_LOCALE,
-                  const wxString domain = wxEmptyString);
+                  const wxString& domain = wxEmptyString);
+
+    /**
+        Constructor.
+
+        @param flags
+            One or more value of the ::wxXmlResourceFlags enumeration.
+        @param domain
+            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.
+    */
     wxXmlResource(int flags = wxXRC_USE_LOCALE,
-                  const wxString domain = wxEmptyString);
-    //@}
+                  const wxString& domain = wxEmptyString);
 
     /**
         Destructor.
@@ -99,6 +111,20 @@ public:
     */
     int CompareVersion(int major, int minor, int release, int revision) const;
 
+    /**
+        Returns a string ID corresponding to the given numeric ID.
+
+        The string returned is such that calling GetXRCID() with it as
+        parameter yields @a numId. If there is no string identifier
+        corresponding to the given numeric one, an empty string is returned.
+
+        Notice that, unlike GetXRCID(), this function is slow as it checks all
+        of the identifiers used in XRC.
+
+        @since 2.9.0
+     */
+    static wxString FindXRCIDById(int numId);
+
     /**
         Gets the global resources object or creates one if none exists.
     */
@@ -108,7 +134,7 @@ public:
         Returns the domain (message catalog) that will be used to load
         translatable strings in the XRC.
     */
-    wxChar* GetDomain();
+    const wxString& GetDomain() const;
 
     /**
         Returns flags, which may be a bitlist of ::wxXmlResourceFlags
@@ -143,7 +169,14 @@ public:
 
     /**
         Loads resources from XML files that match given filemask.
-        This method understands VFS (see filesys.h).
+
+        Example:
+        @code
+            if (!wxXmlResource::Get()->Load("rc/*.xrc"))
+                wxLogError("Couldn't load resources!");
+        @endcode
+
+        This method understands VFS (see wxFileSystem::FindFirst).
     */
     bool Load(const wxString& filemask);
 
@@ -166,7 +199,7 @@ public:
 
         @code
           MyDialog dlg;
-          wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
+          wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog");
           dlg.ShowModal();
         @endcode
     */
@@ -238,7 +271,7 @@ public:
         Sets the domain (message catalog) that will be used to load
         translatable strings in the XRC.
     */
-    wxChar* SetDomain(const wxChar* domain);
+    void SetDomain(const wxString& domain);
 
     /**
         Sets flags (bitlist of ::wxXmlResourceFlags enumeration values).
@@ -281,15 +314,21 @@ public:
     virtual ~wxXmlResourceHandler();
 
     /**
-        Add a style flag (e.g. @c wxMB_DOCKABLE) to the list of flags
-        understood by this handler.
+        Creates an object (menu, dialog, control, ...) from an XML node.
+        Should check for validity. @a parent is a higher-level object
+        (usually window, dialog or panel) that is often necessary to
+        create the resource.
+
+        If @b instance is non-@NULL it should not create a new instance via
+        'new' but should rather use this one, and call its Create method.
     */
-    void AddStyle(const wxString& name, int value);
+    wxObject* CreateResource(wxXmlNode* node, wxObject* parent,
+                             wxObject* instance);
 
     /**
-        Add styles common to all wxWindow-derived classes.
+        Called from CreateResource after variables were filled.
     */
-    void AddWindowStyles();
+    virtual wxObject* DoCreateResource() = 0;
 
     /**
         Returns @true if it understands this node and can create
@@ -301,7 +340,26 @@ public:
         at the time CanHandle() is called and it is only safe to operate on
         node directly or to call IsOfClass().
     */
-    bool CanHandle(wxXmlNode* node);
+    virtual bool CanHandle(wxXmlNode* node) = 0;
+
+    /**
+        Sets the parent resource.
+    */
+    void SetParentResource(wxXmlResource* res);
+
+
+protected:
+
+    /**
+        Add a style flag (e.g. @c wxMB_DOCKABLE) to the list of flags
+        understood by this handler.
+    */
+    void AddStyle(const wxString& name, int value);
+
+    /**
+        Add styles common to all wxWindow-derived classes.
+    */
+    void AddWindowStyles();
 
     /**
         Creates children.
@@ -320,32 +378,17 @@ public:
     wxObject* CreateResFromNode(wxXmlNode* node, wxObject* parent,
                                 wxObject* instance = NULL);
 
-    /**
-        Creates an object (menu, dialog, control, ...) from an XML node.
-        Should check for validity. @a parent is a higher-level object
-        (usually window, dialog or panel) that is often necessary to
-        create the resource.
-
-        If @b instance is non-@NULL it should not create a new instance via 'new'
-        but should rather use this one, and call its Create method.
-    */
-    wxObject* CreateResource(wxXmlNode* node, wxObject* parent,
-                             wxObject* instance);
-
-    /**
-        Called from CreateResource after variables were filled.
-    */
-    wxObject* DoCreateResource();
-
     /**
         Creates an animation (see wxAnimation) from the filename specified in @a param.
     */
-    wxAnimation GetAnimation(const wxString& param = wxT("animation"));
+    wxAnimation GetAnimation(const wxString& param = "animation");
 
     /**
         Gets a bitmap.
     */
-    wxBitmap GetBitmap(const wxString& param = wxT("bitmap"), wxSize size = wxDefaultSize);
+    wxBitmap GetBitmap(const wxString& param = "bitmap",
+                       const wxArtClient& defaultArtClient = wxART_OTHER,
+                       wxSize size = wxDefaultSize);
 
     /**
         Gets a bool flag (1, t, yes, on, true are @true, everything else is @false).
@@ -361,17 +404,18 @@ public:
     /**
         Returns the current file system.
     */
-    wxFileSystem GetCurFileSystem();
+    wxFileSystem& GetCurFileSystem();
 
     /**
         Gets a dimension (may be in dialog units).
     */
-    wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0);
+    wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0,
+                         wxWindow* windowToUse = 0);
 
     /**
         Gets a font.
     */
-    wxFont GetFont();
+    wxFont GetFont(const wxString& param = "font");
 
     /**
         Returns the XRCID.
@@ -381,7 +425,9 @@ public:
     /**
         Returns an icon.
     */
-    wxIcon GetIcon(const wxString& param = wxT("icon"), wxSize size = wxDefaultSize);
+    wxIcon GetIcon(const wxString& param = "icon",
+                   const wxArtClient& defaultArtClient = wxART_OTHER,
+                   wxSize size = wxDefaultSize);
 
     /**
         Gets the integer value from the parameter.
@@ -411,18 +457,18 @@ public:
     /**
         Gets the position (may be in dialog units).
     */
-    wxPoint GetPosition(const wxString& param = wxT("pos"));
+    wxPoint GetPosition(const wxString& param = "pos");
 
     /**
         Gets the size (may be in dialog units).
     */
-    wxSize GetSize(const wxString& param = wxT("size"));
+    wxSize GetSize(const wxString& param = "size", wxWindow* windowToUse = 0);
 
     /**
         Gets style flags from text in form "flag | flag2| flag3 |..."
         Only understands flags added with AddStyle().
     */
-    int GetStyle(const wxString& param = wxT("style"), int defaults = 0);
+    int GetStyle(const wxString& param = "style", int defaults = 0);
 
     /**
         Gets text from param and does some conversions:
@@ -431,7 +477,7 @@ public:
           translation because of XML syntax)
         - calls wxGetTranslations (unless disabled in wxXmlResource)
     */
-    wxString GetText(const wxString& param);
+    wxString GetText(const wxString& param, bool translate = true);
 
     /**
         Check to see if a parameter exists.
@@ -445,11 +491,6 @@ public:
     */
     bool IsOfClass(wxXmlNode* node, const wxString& classname);
 
-    /**
-        Sets the parent resource.
-    */
-    void SetParentResource(wxXmlResource* res);
-
     /**
         Sets common window options.
     */