1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     Embedding Apple's WebKit in wxWidgets
 
   5 // Author:      Robin Dunn / Kevin Ollivier
 
   7 // Created:     18-Oct-2004
 
   9 // Copyright:   (c) 2004 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  14 "wx.webkit.WebKitCtrl for Mac OSX."
 
  17 %module(package="wx", docstring=DOCSTRING) webkit
 
  21 #include "wx/wxPython/wxPython.h"
 
  22 #include "wx/wxPython/pyclasses.h"
 
  23 #include "wx/wxPython/pyistream.h"
 
  25 #ifdef __WXMAC__  // avoid a bug in Carbon headers
 
  30 #include "wx/html/webkit.h"
 
  34 //---------------------------------------------------------------------------
 
  37 %pythoncode { wx = _core }
 
  38 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
 
  41 %include _webkit_rename.i
 
  43 //---------------------------------------------------------------------------
 
  45 // Put some wx default wxChar* values into wxStrings.
 
  46 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
 
  47 MAKE_CONST_WXSTRING2(WebKitNameStr, wxT("webkitctrl"))
 
  54 // a dummy class for ports that don't have wxWebKitCtrl
 
  55 class wxWebKitCtrl : public wxControl
 
  58     wxWebKitCtrl(wxWindow *parent,
 
  60                  const wxString& strURL,
 
  61                  const wxPoint& pos = wxDefaultPosition,
 
  62                  const wxSize& size = wxDefaultSize, long style = 0,
 
  63                  const wxValidator& validator = wxDefaultValidator,
 
  64                  const wxString& name = wxPyWebKitNameStr)
 
  65     { wxPyRaiseNotImplemented(); }
 
  67     wxWebKitCtrl() { wxPyRaiseNotImplemented(); }
 
  69     bool Create(wxWindow *parent,
 
  71                 const wxString& strURL,
 
  72                 const wxPoint& pos = wxDefaultPosition,
 
  73                 const wxSize& size = wxDefaultSize, long style = 0,
 
  74                 const wxValidator& validator = wxDefaultValidator,
 
  75                 const wxString& name = wxPyWebKitNameStr)
 
  78     void LoadURL(const wxString &url) {}
 
  80     bool CanGoBack() { return false; }
 
  81     bool CanGoForward() { return false; }
 
  82     bool GoBack() { return false; }
 
  83     bool GoForward() { return false; }
 
  86     bool CanGetPageSource() { return false; }
 
  87     wxString GetPageSource() { return wxEmptyString; }
 
  88     void SetPageSource(wxString& source, const wxString& baseUrl = wxEmptyString) {}
 
  89     wxString GetPageURL()   { return wxEmptyString; }
 
  90     wxString GetPageTitle() { return wxEmptyString; }
 
  95     wxWEBKIT_STATE_START = 0,
 
  96     wxWEBKIT_STATE_NEGOTIATING = 0,
 
  97     wxWEBKIT_STATE_REDIRECTING = 0,
 
  98     wxWEBKIT_STATE_TRANSFERRING = 0,
 
  99     wxWEBKIT_STATE_STOP = 0,
 
 100     wxWEBKIT_STATE_FAILED = 0,
 
 102     wxEVT_WEBKIT_STATE_CHANGED = 0
 
 105 class wxWebKitStateChangedEvent : public wxCommandEvent
 
 108     wxWebKitStateChangedEvent( wxWindow* win =  NULL )
 
 109     { wxPyRaiseNotImplemented(); }
 
 111     int GetState() { return 0; }
 
 112     void SetState(const int state) {}
 
 113     wxString GetURL() { return wxEmptyString; }
 
 114     void SetURL(const wxString& url) {}
 
 121 // Now define it for SWIG, using either the real class or the dummy above.
 
 123 MustHaveApp(wxWebKitCtrl);
 
 125 class wxWebKitCtrl : public wxControl
 
 128     %pythonAppend wxWebKitCtrl         "self._setOORInfo(self)"
 
 129     %pythonAppend wxWebKitCtrl()       ""
 
 131     wxWebKitCtrl(wxWindow *parent,
 
 132                     wxWindowID winID = -1,
 
 133                     const wxString& strURL = wxPyEmptyString,
 
 134                     const wxPoint& pos = wxDefaultPosition,
 
 135                     const wxSize& size = wxDefaultSize, long style = 0,
 
 136                     const wxValidator& validator = wxDefaultValidator,
 
 137                     const wxString& name = wxPyWebKitNameStr);
 
 139     %RenameCtor(PreWebKitCtrl, wxWebKitCtrl());
 
 142     bool Create(wxWindow *parent,
 
 143                 wxWindowID winID = -1,
 
 144                 const wxString& strURL = wxPyEmptyString,
 
 145                 const wxPoint& pos = wxDefaultPosition,
 
 146                 const wxSize& size = wxDefaultSize, long style = 0,
 
 147                 const wxValidator& validator = wxDefaultValidator,
 
 148                 const wxString& name = wxPyWebKitNameStr);
 
 150     void LoadURL(const wxString &url);
 
 158     bool CanGetPageSource();
 
 159     wxString GetPageSource();
 
 160     void SetPageSource(wxString& source, const wxString& baseUrl = wxPyEmptyString);
 
 161     wxString GetPageURL();
 
 162     wxString GetPageTitle();
 
 166 //---------------------------------------------------------------------------
 
 170     wxWEBKIT_STATE_START,
 
 171     wxWEBKIT_STATE_NEGOTIATING,
 
 172     wxWEBKIT_STATE_REDIRECTING,
 
 173     wxWEBKIT_STATE_TRANSFERRING,
 
 175     wxWEBKIT_STATE_FAILED,
 
 179 %constant wxEventType wxEVT_WEBKIT_STATE_CHANGED;
 
 182 class wxWebKitStateChangedEvent : public wxCommandEvent
 
 185     wxWebKitStateChangedEvent( wxWindow* win =  NULL );
 
 188     void SetState(const int state);
 
 190     void SetURL(const wxString& url);
 
 195     EVT_WEBKIT_STATE_CHANGED = wx.PyEventBinder(wxEVT_WEBKIT_STATE_CHANGED)
 
 199 //---------------------------------------------------------------------------
 
 205 //---------------------------------------------------------------------------