]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/xrc/xrc.i
New wxActiveX code from Lindsay and added ability to load page from stream
[wxWidgets.git] / wxPython / contrib / xrc / xrc.i
CommitLineData
d56cebe7
RD
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%{
6e2129f9 17#include "wxPython.h"
d56cebe7
RD
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
b5a5d647
RD
35enum wxXmlResourceFlags
36{
37 wxXRC_USE_LOCALE = 1,
38 wxXRC_NO_SUBCLASSING = 2
39};
40
41
d56cebe7
RD
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
46class wxXmlResource : public wxObject
47{
48public:
b5a5d647
RD
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
d56cebe7
RD
56
57 %addmethods {
b5a5d647
RD
58 wxXmlResource(const wxString* filemask, int flags = wxXRC_USE_LOCALE) {
59 wxXmlResource* res = new wxXmlResource(*filemask, flags);
d56cebe7
RD
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
1496068d 125 static int GetXRCID(const wxString& str_id);
d56cebe7
RD
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
d56cebe7 134
ce914f73
RD
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);
d56cebe7 139
ce914f73 140};
d56cebe7
RD
141
142//----------------------------------------------------------------------
143
144%pragma(python) code = "
c6c593e8
RD
145def XRCID(str_id):
146 return wxXmlResource_GetXRCID(str_id)
d56cebe7 147
c6c593e8
RD
148def XRCCTRL(window, str_id, *ignoreargs):
149 return window.FindWindowById(XRCID(str_id))
d56cebe7 150
c6c593e8
RD
151XMLID = XRCID
152XMLCTRL = XRCCTRL
d56cebe7
RD
153"
154
155//----------------------------------------------------------------------
156
ce914f73 157// TODO: Add wxXmlResourceHandler and allow it to be derived from.
d56cebe7
RD
158
159//----------------------------------------------------------------------
160
161%init %{
162
163 wxClassInfo::CleanUpClasses();
164 wxClassInfo::InitializeClasses();
165
d56cebe7 166 wxXmlInitResourceModule();
ce914f73 167 wxXmlResource::Get()->InitAllHandlers();
d56cebe7
RD
168
169%}
170
ce914f73
RD
171//----------------------------------------------------------------------
172// This file gets appended to the shadow class file.
173//----------------------------------------------------------------------
174
175%pragma(python) include="_xrcextras.py";
176
177