]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxXmlResource::FindXRCIDById() (#10026)
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Oct 2008 11:44:10 +0000 (11:44 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Oct 2008 11:44:10 +0000 (11:44 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/xrc/xmlres.h
interface/wx/xrc/xmlres.h
src/xrc/xmlres.cpp

index 8bffb9f548c74cd13851a379e746be6ed50b70f7..7d29dd260d14a5a2d25348b0d2c932572d54cefa 100644 (file)
@@ -209,6 +209,15 @@ public:
     // version for internal use only
     static int DoGetXRCID(const char *str_id, int value_if_not_found = wxID_NONE);
 
+
+    // Find the string ID with the given numeric value, returns an empty string
+    // if no such ID is found.
+    //
+    // Notice that unlike GetXRCID(), which is fast, this operation is slow as
+    // it checks all the IDs used in XRC.
+    static wxString FindXRCIDById(int numId);
+
+
     // Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a).
     long GetVersion() const { return m_version; }
 
index 6849341886ab15fbee6e5868254c1db54678e901..92bfc64eabfdd33f7d796d503fa8050b7f8b626c 100644 (file)
@@ -108,6 +108,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 wxXmlResource::FindXRCIDById(int numId);
+
     /**
         Gets the global resources object or creates one if none exists.
     */
index efee9e17e5ac5336510610f6dec9a134564b0eea..bd6c432084c198afc52744fa24cdaf87783fb2ef 100644 (file)
@@ -1625,6 +1625,20 @@ int wxXmlResource::DoGetXRCID(const char *str_id, int value_if_not_found)
     return XRCID_Lookup(str_id, value_if_not_found);
 }
 
+/* static */
+wxString wxXmlResource::FindXRCIDById(int numId)
+{
+    for ( int i = 0; i < XRCID_TABLE_SIZE; i++ )
+    {
+        for ( XRCID_record *rec = XRCID_Records[i]; rec; rec = rec->next )
+        {
+            if ( rec->id == numId )
+                return wxString(rec->key);
+        }
+    }
+
+    return wxString();
+}
 
 static void CleanXRCID_Record(XRCID_record *rec)
 {