webkit.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/html/webkit.h
  3. // Purpose: wxWebKitCtrl - embeddable web kit control
  4. // Author: Jethro Grassie / Kevin Ollivier
  5. // Modified by:
  6. // Created: 2004-4-16
  7. // Copyright: (c) Jethro Grassie / Kevin Ollivier
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_WEBKIT_H
  11. #define _WX_WEBKIT_H
  12. /**
  13. @class wxWebKitCtrl
  14. This control is a native wrapper around the Safari web browsing
  15. engine. This wrapper differs from the one in wxWebView in that this
  16. version supports functionality specific to WebKit, such as having
  17. RunScript return a value, which is a very critical feature in many web
  18. embedding scenarios.
  19. This class is only available on OSX.
  20. **/
  21. class wxWebKitCtrl : public wxControl
  22. {
  23. public:
  24. wxWebKitCtrl();
  25. wxWebKitCtrl(wxWindow *parent,
  26. wxWindowID winid,
  27. const wxString& strURL,
  28. const wxPoint& pos = wxDefaultPosition,
  29. const wxSize& size = wxDefaultSize, long style = 0,
  30. const wxValidator& validator = wxDefaultValidator,
  31. const wxString& name = wxWebKitCtrlNameStr);
  32. bool Create(wxWindow *parent,
  33. wxWindowID winid,
  34. const wxString& strURL,
  35. const wxPoint& pos = wxDefaultPosition,
  36. const wxSize& size = wxDefaultSize, long style = 0,
  37. const wxValidator& validator = wxDefaultValidator,
  38. const wxString& name = wxWebKitCtrlNameStr);
  39. virtual ~wxWebKitCtrl();
  40. void LoadURL(const wxString &url);
  41. bool CanGoBack();
  42. bool CanGoForward();
  43. bool GoBack();
  44. bool GoForward();
  45. void Reload();
  46. void Stop();
  47. bool CanGetPageSource();
  48. wxString GetPageSource();
  49. void SetPageSource(const wxString& source, const wxString& baseUrl = wxEmptyString);
  50. wxString GetPageURL();
  51. void SetPageTitle(const wxString& title);
  52. wxString GetPageTitle();
  53. // since these worked in 2.6, add wrappers
  54. void SetTitle(const wxString& title);
  55. wxString GetTitle();
  56. wxString GetSelection();
  57. bool CanIncreaseTextSize();
  58. void IncreaseTextSize();
  59. bool CanDecreaseTextSize();
  60. void DecreaseTextSize();
  61. void Print(bool showPrompt = false);
  62. void MakeEditable(bool enable = true);
  63. bool IsEditable();
  64. wxString RunScript(const wxString& javascript);
  65. void SetScrollPos(int pos);
  66. int GetScrollPos();
  67. };
  68. // ----------------------------------------------------------------------------
  69. // Web Kit Events
  70. // ----------------------------------------------------------------------------
  71. enum {
  72. wxWEBKIT_STATE_START = 1,
  73. wxWEBKIT_STATE_NEGOTIATING = 2,
  74. wxWEBKIT_STATE_REDIRECTING = 4,
  75. wxWEBKIT_STATE_TRANSFERRING = 8,
  76. wxWEBKIT_STATE_STOP = 16,
  77. wxWEBKIT_STATE_FAILED = 32
  78. };
  79. enum {
  80. wxWEBKIT_NAV_LINK_CLICKED = 1,
  81. wxWEBKIT_NAV_BACK_NEXT = 2,
  82. wxWEBKIT_NAV_FORM_SUBMITTED = 4,
  83. wxWEBKIT_NAV_RELOAD = 8,
  84. wxWEBKIT_NAV_FORM_RESUBMITTED = 16,
  85. wxWEBKIT_NAV_OTHER = 32
  86. };
  87. class wxWebKitBeforeLoadEvent : public wxCommandEvent
  88. {
  89. public:
  90. bool IsCancelled();
  91. void Cancel(bool cancel = true);
  92. wxString GetURL();
  93. void SetURL(const wxString& url);
  94. void SetNavigationType(int navType);
  95. int GetNavigationType();
  96. wxWebKitBeforeLoadEvent( wxWindow* win = 0 );
  97. };
  98. class wxWebKitStateChangedEvent : public wxCommandEvent
  99. {
  100. public:
  101. int GetState();
  102. void SetState(const int state);
  103. wxString GetURL();
  104. void SetURL(const wxString& url);
  105. wxWebKitStateChangedEvent( wxWindow* win = 0 );
  106. };
  107. class wxWebKitNewWindowEvent : public wxCommandEvent
  108. {
  109. public:
  110. wxString GetURL() const;
  111. void SetURL(const wxString& url);
  112. wxString GetTargetName() const;
  113. void SetTargetName(const wxString& name);
  114. wxWebKitNewWindowEvent( wxWindow* win = 0 );
  115. };
  116. wxEventType wxEVT_WEBKIT_STATE_CHANGED;
  117. wxEventType wxEVT_WEBKIT_BEFORE_LOAD;
  118. wxEventType wxEVT_WEBKIT_NEW_WINDOW;
  119. #endif
  120. // _WX_WEBKIT_H_