]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/xrc/xrc.i
Removed obsolete -WE flags from WIN32 BC++ makefiles
[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 "export.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
93 // Loads toolbar
94 wxToolBar *LoadToolBar(wxWindow *parent, const wxString& name);
95
96 // Loads dialog. dlg points to parent window (if any). Second form
97 // is used to finish creation of already existing instance (main reason
98 // for this is that you may want to use derived class with new event table)
99 // Example (typical usage):
100 // MyDialog dlg;
101 // wxTheXmlResource->LoadDialog(&dlg, mainFrame, "my_dialog");
102 // dlg->ShowModal();
103 wxDialog *LoadDialog(wxWindow *parent, const wxString& name);
104 %name(LoadOnDialog)bool LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name);
105
106 // Loads panel. panel points to parent window (if any). Second form
107 // is used to finish creation of already existing instance.
108 wxPanel *LoadPanel(wxWindow *parent, const wxString& name);
109 %name(LoadOnPanel)bool LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name);
110
111 bool LoadFrame(wxFrame* frame, wxWindow *parent, const wxString& name);
112
113 // Loads bitmap or icon resource from file:
114 wxBitmap LoadBitmap(const wxString& name);
115 wxIcon LoadIcon(const wxString& name);
116
117 // Attaches unknown control into given panel/window/dialog:
118 // (unknown controls are used in conjunction with <object class="unknown">)
119 bool AttachUnknownControl(const wxString& name, wxWindow *control,
120 wxWindow *parent = NULL);
121
122 // Returns numeric ID that is equivalent to string id used in XML
123 // resource. To be used in event tables
124 // Macro XMLID is provided for convenience
125 static int GetXRCID(const char *str_id);
126
127 // Returns version info (a.b.c.d = d+ 256*c + 256^2*b + 256^3*a)
128 long GetVersion() const;
129
130 // Compares resources version to argument. Returns -1 if resources version
131 // is less than the argument, +1 if greater and 0 if they equal.
132 int CompareVersion(int major, int minor, int release, int revision) const;
133
134
135 // Gets global resources object or create one if none exists
136 static wxXmlResource *Get();
137 // Sets global resources object and returns pointer to previous one (may be NULL).
138 static wxXmlResource *Set(wxXmlResource *res);
139
140 };
141
142 //----------------------------------------------------------------------
143
144 %pragma(python) code = "
145 def XRCID(str_id):
146 return wxXmlResource_GetXRCID(str_id)
147
148 def XRCCTRL(window, str_id, *ignoreargs):
149 return window.FindWindowById(XRCID(str_id))
150
151 XMLID = XRCID
152 XMLCTRL = XRCCTRL
153 "
154
155 //----------------------------------------------------------------------
156
157 // TODO: Add wxXmlResourceHandler and allow it to be derived from.
158
159 //----------------------------------------------------------------------
160
161 %init %{
162
163 wxClassInfo::CleanUpClasses();
164 wxClassInfo::InitializeClasses();
165
166 wxXmlInitResourceModule();
167 wxXmlResource::Get()->InitAllHandlers();
168
169 %}
170
171 //----------------------------------------------------------------------
172 // This file gets appended to the shadow class file.
173 //----------------------------------------------------------------------
174
175 %pragma(python) include="_xrcextras.py";
176
177