]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/xrc/xrc.i
Moved tools to be a Python package in wxPython.tools, added scripts to
[wxWidgets.git] / wxPython / contrib / xrc / xrc.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xrc.i
3 // Purpose: Wrappers for the XML based Resource system
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 4-June-2001
8 // RCS-ID: $Id$
9 // Copyright: (c) 2001 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module xrc
14
15
16 %{
17 #include "wxPython.h"
18 #include "wx/xrc/xmlres.h"
19 %}
20
21 //---------------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 %extern wx.i
27 %extern windows.i
28 %extern _defs.i
29 %extern events.i
30 %extern controls.i
31
32
33 //---------------------------------------------------------------------------
34
35 enum wxXmlResourceFlags
36 {
37 wxXRC_USE_LOCALE = 1,
38 wxXRC_NO_SUBCLASSING = 2
39 };
40
41
42 // This class holds XML resources from one or more .xml files
43 // (or derived forms, either binary or zipped -- see manual for
44 // details).
45
46 class wxXmlResource : public wxObject
47 {
48 public:
49 // Ctor.
50 // Flags: wxXRC_USE_LOCALE
51 // translatable strings will be translated via _()
52 // wxXRC_NO_SUBCLASSING
53 // subclass property of object nodes will be ignored
54 // (useful for previews in XRC editors)
55 %name(wxXmlResourceEmpty)wxXmlResource(int flags = wxXRC_USE_LOCALE); // TODO, a better %name
56
57 %addmethods {
58 wxXmlResource(const wxString* filemask, int flags = wxXRC_USE_LOCALE) {
59 wxXmlResource* res = new wxXmlResource(*filemask, flags);
60 res->InitAllHandlers();
61 return res;
62 }
63 }
64
65 ~wxXmlResource();
66
67
68 // Loads resources from XML files that match given filemask.
69 // This method understands VFS (see filesys.h).
70 bool Load(const wxString& filemask);
71
72 // Initialize handlers for all supported controls/windows. This will
73 // make the executable quite big because it forces linking against
74 // most of wxWin library
75 void InitAllHandlers();
76
77 // Initialize only specific handler (or custom handler). Convention says
78 // that handler name is equal to control's name plus 'XmlHandler', e.g.
79 // wxTextCtrlXmlHandler, wxHtmlWindowXmlHandler. XML resource compiler
80 // (xmlres) can create include file that contains initialization code for
81 // all controls used within the resource.
82 void AddHandler(wxXmlResourceHandler *handler);
83
84 // Removes all handlers
85 void ClearHandlers();
86
87 // Loads menu from resource. Returns NULL on failure.
88 wxMenu *LoadMenu(const wxString& name);
89
90 // Loads menubar from resource. Returns NULL on failure.
91 wxMenuBar *LoadMenuBar(const wxString& name);
92 %name(LoadMenuBarOnFrame) wxMenuBar *LoadMenuBar(wxWindow *parent, const wxString& name);
93
94
95 // Loads toolbar
96 wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
97
98 // Loads dialog. dlg points to parent window (if any). Second form
99 // is used to finish creation of already existing instance (main reason
100 // for this is that you may want to use derived class with new event table)
101 // Example (typical usage):
102 // MyDialog dlg;
103 // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
104 // dlg->ShowModal();
105 wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
106 %name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
107
108 // Loads panel. panel points to parent window (if any). Second form
109 // is used to finish creation of already existing instance.
110 wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
111 %name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
112
113 bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
114
115 // Loads bitmap or icon resource from file:
116 wxBitmap LoadBitmap(const wxString& name);
117 wxIcon LoadIcon(const wxString& name);
118
119 // Attaches unknown control into given panel/window/dialog:
120 // (unknown controls are used in conjunction with <object class="unknown">)
121 bool AttachUnknownControl(const wxString& name, wxWindow *control,
122 wxWindow *parent = NULL);
123
124 // Returns numeric ID that is equivalent to string id used in XML
125 // resource. To be used in event tables
126 // Macro XMLID is provided for convenience
127 static int GetXRCID(const wxString& str_id);
128
129 // Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
130 long GetVersion() const;
131
132 // Compares resources version to argument. Returns -1 if resources version
133 // is less than the argument, +1 if greater and 0 if they equal.
134 int CompareVersion(int major, int minor, int release, int revision) const;
135
136
137 // Gets global resources object or create one if none exists
138 static wxXmlResource *Get();
139 // Sets global resources object and returns pointer to previous one (may be NULL).
140 static wxXmlResource *Set(wxXmlResource *res);
141
142 };
143
144 //----------------------------------------------------------------------
145
146 %pragma(python) code = "
147 def XRCID(str_id):
148 return wxXmlResource_GetXRCID(str_id)
149
150 def XRCCTRL(window, str_id, *ignoreargs):
151 return window.FindWindowById(XRCID(str_id))
152
153 XMLID = XRCID
154 XMLCTRL = XRCCTRL
155 "
156
157 //----------------------------------------------------------------------
158
159 // TODO: Add wxXmlResourceHandler and allow it to be derived from.
160
161 //----------------------------------------------------------------------
162
163 %init %{
164
165 wxClassInfo::CleanUpClasses();
166 wxClassInfo::InitializeClasses();
167
168 wxXmlInitResourceModule();
169 wxXmlResource::Get()->InitAllHandlers();
170
171 %}
172
173 //----------------------------------------------------------------------
174 // This file gets appended to the shadow class file.
175 //----------------------------------------------------------------------
176
177 %pragma(python) include="_xrcextras.py";
178
179