1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Load wx widgets from external DLLs
7 // Created: 04-Dec-2001
9 // Copyright: (c) 2001 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include "dllwidget.h"
21 //---------------------------------------------------------------------------
24 %include my_typemaps.i
30 //---------------------------------------------------------------------------
34 wxDllWidget can be used to embed a wxWindow implemented in C++ in your
35 wxPython application without the need to write a SWIG interface. Widget's code
36 is stored in shared library or DLL that exports DLL_WidgetFactory symbol
37 and loaded at runtime. All you have to do is to pass the name of DLL and the class
38 to create to wxDllWidget's ctor.
40 Runtime-loadable widget must have HandleCommand method (see the example) that is
41 used to communicate with Python app. You call wxDllWidget.SendCommand(cmd,param) from
42 Python and it in turn calls HandleCommand of the loaded widget.
44 You must use DECLARE_DLL_WIDGET, BEGIN_WIDGET_LIBRARY, END_WIDGET_LIBRARY and
45 REGISTER_WIDGET macros in your C++ module in order to provide all the meat
50 #define CMD_MAKEWHITE 1
52 class MyWindow : public wxWindow
55 MyWindow(wxWindow *parent, long style)
56 : wxWindow(parent, -1) {}
58 int HandleCommand(int cmd, const wxString& param)
60 if (cmd == CMD_MAKEWHITE)
61 SetBackgroundColour(*wxWHITE);
65 DECLARE_DLL_WIDGET(MyWindow)
67 class MyCanvasWindow : public wxScrolledWindow
71 DECLARE_DLL_WIDGET(MyCanvasWindow)
73 BEGIN_WIDGET_LIBRARY()
74 REGISTER_WIDGET(MyWindow)
75 REGISTER_WIDGET(MyCanvasWindow)
80 class wxDllWidget : public wxPanel
83 wxDllWidget(wxWindow *parent,
85 const wxString& dllName = wxEmptyString,
86 const wxString& className = wxEmptyString,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& size = wxDefaultSize,
91 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
95 int SendCommand(int cmd, const wxString& param = wxEmptyString);
96 wxWindow* GetWidgetWindow();
98 static wxString GetDllExt();
101 //---------------------------------------------------------------------------
105 wxClassInfo::CleanUpClasses();
106 wxClassInfo::InitializeClasses();
111 //---------------------------------------------------------------------------