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 //----------------------------------------------------------------------
 
  33     // Put some wx default wxChar* values into wxStrings.
 
  34     static const wxString wxPyEmptyString(wxT(""));
 
  37 //---------------------------------------------------------------------------
 
  41 wxDllWidget can be used to embed a wxWindow implemented in C++ in your
 
  42 wxPython application without the need to write a SWIG interface. Widget's code
 
  43 is stored in shared library or DLL that exports DLL_WidgetFactory symbol
 
  44 and loaded at runtime. All you have to do is to pass the name of DLL and the class
 
  45 to create to wxDllWidget's ctor.
 
  47 Runtime-loadable widget must have HandleCommand method (see the example) that is
 
  48 used to communicate with Python app. You call wxDllWidget.SendCommand(cmd,param) from
 
  49 Python and it in turn calls HandleCommand of the loaded widget.
 
  51 You must use DECLARE_DLL_WIDGET, BEGIN_WIDGET_LIBRARY, END_WIDGET_LIBRARY and
 
  52 REGISTER_WIDGET macros in your C++ module in order to provide all the meat
 
  57     #define CMD_MAKEWHITE     1
 
  59     class MyWindow : public wxWindow
 
  62         MyWindow(wxWindow *parent, long style)
 
  63             : wxWindow(parent, -1) {}
 
  65         int HandleCommand(int cmd, const wxString& param)
 
  67             if (cmd == CMD_MAKEWHITE)
 
  68                 SetBackgroundColour(*wxWHITE);
 
  72     DECLARE_DLL_WIDGET(MyWindow)
 
  74     class MyCanvasWindow : public wxScrolledWindow
 
  78     DECLARE_DLL_WIDGET(MyCanvasWindow)
 
  80     BEGIN_WIDGET_LIBRARY()
 
  81         REGISTER_WIDGET(MyWindow)
 
  82         REGISTER_WIDGET(MyCanvasWindow)
 
  87 class wxDllWidget : public wxPanel
 
  90     wxDllWidget(wxWindow *parent,
 
  92                 const wxString& dllName = wxPyEmptyString,
 
  93                 const wxString& className = wxPyEmptyString,
 
  94                 const wxPoint& pos = wxDefaultPosition,
 
  95                 const wxSize& size = wxDefaultSize,
 
  98     %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
 
 102     int SendCommand(int cmd, const wxString& param = wxPyEmptyString);
 
 103     wxWindow* GetWidgetWindow();
 
 105     static wxString GetDllExt();
 
 108 //---------------------------------------------------------------------------
 
 112     wxClassInfo::CleanUpClasses();
 
 113     wxClassInfo::InitializeClasses();
 
 118 //---------------------------------------------------------------------------