X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d56cebe7a497773d8753ea2ab874c4445bac18dc..73adcb015064cf4276cb38dc394011f1b4c82036:/wxPython/contrib/xrc/xrc.i diff --git a/wxPython/contrib/xrc/xrc.i b/wxPython/contrib/xrc/xrc.i index 13b1fe766f..59d26bf353 100644 --- a/wxPython/contrib/xrc/xrc.i +++ b/wxPython/contrib/xrc/xrc.i @@ -14,148 +14,53 @@ %{ -#include "export.h" -#include "wx/xrc/xmlres.h" -%} - -//--------------------------------------------------------------------------- - -%include typemaps.i -%include my_typemaps.i +#include "wx/wxPython/wxPython.h" +#include "wx/wxPython/pyclasses.h" +#include "wx/wxPython/pyistream.h" -%extern wx.i -%extern windows.i -%extern _defs.i -%extern events.i -%extern controls.i +#include +#include +%} //--------------------------------------------------------------------------- -// This class holds XML resources from one or more .xml files -// (or derived forms, either binary or zipped -- see manual for -// details). - -class wxXmlResource : public wxObject -{ -public: - // Ctor. If use_locale is TRUE, translatable strings are - // translated via _(). You can disable it by passing use_locale=FALSE - // (for example if you provide resource file for each locale) - %name(wxXmlResourceEmpty)wxXmlResource(bool use_locale = TRUE); // TODO, a better %name - - %addmethods { - wxXmlResource(const wxString* filemask, bool use_locale = TRUE) { - wxXmlResource* res = new wxXmlResource(*filemask, use_locale); - res->InitAllHandlers(); - return res; - } - } - - ~wxXmlResource(); - - - // Loads resources from XML files that match given filemask. - // This method understands VFS (see filesys.h). - bool Load(const wxString& filemask); - - // Initialize handlers for all supported controls/windows. This will - // make the executable quite big because it forces linking against - // most of wxWin library - void InitAllHandlers(); - - // Initialize only specific handler (or custom handler). Convention says - // that handler name is equal to control's name plus 'XmlHandler', e.g. - // wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler - // (xmlres) can create include file that contains initialization code for - // all controls used within the resource. - void AddHandler(wxXmlResourceHandler *handler); - - // Removes all handlers - void ClearHandlers(); - - // Loads menu from resource. Returns NULL on failure. - wxMenu *LoadMenu(const wxString& name); - - // Loads menubar from resource. Returns NULL on failure. - wxMenuBar *LoadMenuBar(const wxString& name); +%import core.i +%pythoncode { wx = core } - // Loads toolbar - wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name); - // Loads dialog. dlg points to parent window (if any). Second form - // is used to finish creation of already existing instance (main reason - // for this is that you may want to use derived class with new event table) - // Example (typical usage): - // MyDialog dlg; - // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog"); - // dlg->ShowModal(); - wxDialog *LoadDialog(wxWindow *parent, const wxString& name); - %name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name); +MAKE_CONST_WXSTRING_NOSWIG(EmptyString); +MAKE_CONST_WXSTRING2(UTF8String, wxT("UTF-8")); +MAKE_CONST_WXSTRING2(StyleString, wxT("style")); +MAKE_CONST_WXSTRING2(SizeString, wxT("size")); +MAKE_CONST_WXSTRING2(PosString, wxT("pos")); +MAKE_CONST_WXSTRING2(BitmapString, wxT("bitmap")); +MAKE_CONST_WXSTRING2(IconString, wxT("icon")); +MAKE_CONST_WXSTRING2(FontString, wxT("font")); - // Loads panel. panel points to parent window (if any). Second form - // is used to finish creation of already existing instance. - wxPanel *LoadPanel(wxWindow *parent, const wxString& name); - %name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name); - bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name); +%include _xrc_rename.i - // Loads bitmap or icon resource from file: - wxBitmap LoadBitmap(const wxString& name); - wxIcon LoadIcon(const wxString& name); - // Attaches unknown control into given panel/window/dialog: - // (unknown controls are used in conjunction with ) - bool AttachUnknownControl(const wxString& name, wxWindow *control, - wxWindow *parent = NULL); +// Include all the files that make up this module +%include _xmlres.i +%include _xmlsub.i +%include _xml.i +%include _xmlhandler.i - // Returns numeric ID that is equivalent to string id used in XML - // resource. To be used in event tables - // Macro XMLID is provided for convenience - static int GetXMLID(const char *str_id); - // Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a) - long GetVersion() const; - // Compares resources version to argument. Returns -1 if resources version - // is less than the argument, +1 if greater and 0 if they equal. - int CompareVersion(int major, int minor, int release, int revision) const; - -}; - -//---------------------------------------------------------------------- - -%readonly -// Global instance of resource class. For your convenience. -wxXmlResource *wxTheXmlResource; -%readwrite - -//---------------------------------------------------------------------- - -%pragma(python) code = " -def XMLID(str_id): - return wxXmlResource_GetXMLID(str_id) - -def XMLCTRL(window, str_id, *args): - return window.FindWindowById(XMLID(str_id)) - -" - -//---------------------------------------------------------------------- - -// TODO: Add wxXmlResourceHandler and etc. - -//---------------------------------------------------------------------- +//--------------------------------------------------------------------------- %init %{ - wxClassInfo::CleanUpClasses(); - wxClassInfo::InitializeClasses(); - - wxXmlInitXmlModule(); wxXmlInitResourceModule(); - wxTheXmlResource->InitAllHandlers(); + wxXmlResource::Get()->InitAllHandlers(); %} + +%pythoncode "_xrc_ex.py"; + + //---------------------------------------------------------------------------