X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/273b399fe994271e79229943eed3746fd5389742..3ed884a0b80d3a43c2b999596eebb574e9f00075:/contrib/include/wx/xrc/xmlres.h?ds=sidebyside diff --git a/contrib/include/wx/xrc/xmlres.h b/contrib/include/wx/xrc/xmlres.h index ca3bdd2a9c..0962b297aa 100644 --- a/contrib/include/wx/xrc/xmlres.h +++ b/contrib/include/wx/xrc/xmlres.h @@ -24,6 +24,7 @@ #include "wx/filesys.h" #include "wx/bitmap.h" #include "wx/icon.h" +#include "wx/artprov.h" #include "wx/xrc/xml.h" @@ -110,7 +111,7 @@ public: // Destructor. ~wxXmlResource(); - + // Loads resources from XML files that match given filemask. // This method understands VFS (see filesys.h). bool Load(const wxString& filemask); @@ -127,6 +128,9 @@ public: // all controls used within the resource. void AddHandler(wxXmlResourceHandler *handler); + // Add a new handler at the begining of the handler list + void InsertHandler(wxXmlResourceHandler *handler); + // Removes all handlers void ClearHandlers(); @@ -164,8 +168,20 @@ public: bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name); // Loads a frame. + wxFrame *LoadFrame(wxWindow* parent, const wxString& name); bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name); + // Load an object from the resource specifying both the resource name and + // the classname. This lets you load nonstandard container windows. + wxObject *LoadObject(wxWindow *parent, const wxString& name, + const wxString& classname); + + // Load an object from the resource specifying both the resource name and + // the classname. This form lets you finish the creation of an existing + // instance. + bool LoadObject(wxObject *instance, wxWindow *parent, const wxString& name, + const wxString& classname); + // Loads a bitmap resource from a file. wxBitmap LoadBitmap(const wxString& name); @@ -179,8 +195,8 @@ public: // Returns a numeric ID that is equivalent to the string id used in an XML // resource. To be used in event tables. - // Macro XMLID is provided for convenience - static int GetXMLID(const wxChar *str_id); + // Macro XRCID is provided for convenience + static int GetXRCID(const wxChar *str_id); // Returns version information (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a). long GetVersion() const { return m_version; } @@ -190,15 +206,18 @@ public: int CompareVersion(int major, int minor, int release, int revision) const { return GetVersion() - (major*256*256*256 + minor*256*256 + release*256 + revision); } - + //// Singleton accessors. - + // Gets the global resources object or creates one if none exists. static wxXmlResource *Get(); // Sets the global resources object and returns a pointer to the previous one (may be NULL). static wxXmlResource *Set(wxXmlResource *res); + // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING. + int GetFlags() { return m_flags; } + protected: // Scans the resources list for unloaded files and loads them. Also reloads // files that have been modified since last loading. @@ -213,9 +232,6 @@ protected: // Creates a resource from information in the given node. wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL); - // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING. - int GetFlags() { return m_flags; } - private: long m_version; @@ -228,7 +244,7 @@ private: #endif friend class wxXmlResourceHandler; - + // singleton instance: static wxXmlResource *ms_instance; }; @@ -239,14 +255,14 @@ private: // wxWindows event tables. // Example: // BEGIN_EVENT_TABLE(MyFrame, wxFrame) -// EVT_MENU(XMLID("quit"), MyFrame::OnQuit) -// EVT_MENU(XMLID("about"), MyFrame::OnAbout) -// EVT_MENU(XMLID("new"), MyFrame::OnNew) -// EVT_MENU(XMLID("open"), MyFrame::OnOpen) +// EVT_MENU(XRCID("quit"), MyFrame::OnQuit) +// EVT_MENU(XRCID("about"), MyFrame::OnAbout) +// EVT_MENU(XRCID("new"), MyFrame::OnNew) +// EVT_MENU(XRCID("open"), MyFrame::OnOpen) // END_EVENT_TABLE() -#define XMLID(str_id) \ - wxXmlResource::GetXMLID(wxT(str_id)) +#define XRCID(str_id) \ + wxXmlResource::GetXRCID(wxT(str_id)) // This macro returns pointer to particular control in dialog @@ -255,14 +271,14 @@ private: // Example: // wxDialog dlg; // wxXmlResource::Get()->LoadDialog(&dlg, mainFrame, "my_dialog"); -// XMLCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value")); +// XRCCTRL(dlg, "my_textctrl", wxTextCtrl)->SetValue(wxT("default value")); #ifdef __WXDEBUG__ -#define XMLCTRL(window, id, type) \ - (wxDynamicCast((window).FindWindow(XMLID(id)), type)) +#define XRCCTRL(window, id, type) \ + (wxDynamicCast((window).FindWindow(XRCID(id)), type)) #else -#define XMLCTRL(window, id, type) \ - ((type*)((window).FindWindow(XMLID(id)))) +#define XRCCTRL(window, id, type) \ + ((type*)((window).FindWindow(XRCID(id)))) #endif // wxXmlResourceHandler is an abstract base class for resource handlers @@ -344,11 +360,11 @@ protected: // Gets text from param and does some conversions: // - replaces \n, \r, \t by respective chars (according to C syntax) - // - replaces $ by & and $$ by $ (needed for $File => &File because of XML) + // - replaces _ by & and __ by _ (needed for _File => &File because of XML) // - calls wxGetTranslations (unless disabled in wxXmlResource) - wxString GetText(const wxString& param); + wxString GetText(const wxString& param, bool translate = TRUE); - // Returns the XMLID. + // Returns the XRCID. int GetID(); // Returns the resource name. @@ -374,10 +390,12 @@ protected: // Gets a bitmap. wxBitmap GetBitmap(const wxString& param = wxT("bitmap"), + const wxArtClient& defaultArtClient = wxART_OTHER, wxSize size = wxDefaultSize); // Gets an icon. wxIcon GetIcon(const wxString& param = wxT("icon"), + const wxArtClient& defaultArtClient = wxART_OTHER, wxSize size = wxDefaultSize); // Gets a font. @@ -420,13 +438,15 @@ protected: void wxXmlInitResourceModule(); -/* ------------------------------------------------------------------------- +/* ------------------------------------------------------------------------- Backward compatibility macros. Do *NOT* use, they may disappear in future versions of the XRC library! ------------------------------------------------------------------------- */ #define ADD_STYLE XRC_ADD_STYLE #define wxTheXmlResource wxXmlResource::Get() - +#define XMLID XRCID +#define XMLCTRL XRCCTRL +#define GetXMLID GetXRCID #endif // _WX_XMLRES_H_