File: WebView.xsp

package info (click to toggle)
libwx-perl 1%3A0.9909-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,912 kB
  • sloc: cpp: 9,728; perl: 8,182; ansic: 626; makefile: 41
file content (253 lines) | stat: -rw-r--r-- 7,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
%module{Wx};

##/////////////////////////////////////////////////////////////////////////////
##// Name:        webview.h
##// Purpose:     interface of wxWebView
##// Author:      wxWidgets team
##// RCS-ID:      $Id$
##// Licence:     wxWindows licence
##/////////////////////////////////////////////////////////////////////////////

#if wxUSE_WEBVIEW

%loadplugin{build::Wx::XSP::Overload};
%loadplugin{build::Wx::XSP::Enum};
%loadplugin{build::Wx::XSP::Event};

%Event{%EVT_WEB_VIEW_NAVIGATING(id, func)%}
      {wxEVT_COMMAND_WEB_VIEW_NAVIGATING};
%Event{%EVT_WEB_VIEW_NAVIGATED(id, func)%}
      {wxEVT_COMMAND_WEB_VIEW_NAVIGATED};
%Event{%EVT_WEB_VIEW_LOADED(id, func)%}
      {wxEVT_COMMAND_WEB_VIEW_LOADED};
%Event{%EVT_WEB_VIEW_ERROR(id, func)%}
      {wxEVT_COMMAND_WEB_VIEW_ERROR};
%Event{%EVT_WEB_VIEW_NEWWINDOW(id, func)%}
      {wxEVT_COMMAND_WEB_VIEW_NEWWINDOW};
%Event{%EVT_WEB_VIEW_TITLE_CHANGED(id, func)%}
      {wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED};      

%name{Wx::WebViewHistoryItem} class wxWebViewHistoryItem
{
    
%{
static void
wxWebViewHistoryItem::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}

public:

    wxWebViewHistoryItem(const wxString& url, const wxString& title);
    
    ~wxWebViewHistoryItem()
        %code%{  wxPli_thread_sv_unregister( aTHX_ "Wx::WebViewHistoryItem", THIS, ST(0) );
                 delete THIS;
               %};    
    
    wxString GetUrl();
    
    wxString GetTitle();
};

%name{Wx::WebViewHandler} class wxWebViewHandler
{
public:

    virtual wxFSFile* GetFile(const wxString &uri);

    virtual wxString GetName() const;
};

%name{Wx::WebView} class wxWebView : public %name{Wx::Control} wxControl
{
public:

    static wxWebView* NewDefault(wxWebViewBackend backend = wxWEB_VIEW_BACKEND_DEFAULT)
        %code{% RETVAL = wxWebView::New( backend ); %}
        %postcall{% wxPli_create_evthandler( aTHX_ RETVAL, "Wx::WebView" ); %};

    static wxWebView* New(wxWindow* parent,
           wxWindowID id,
           const wxString& url = wxWebViewDefaultURLStr,
           const wxPoint& pos = wxDefaultPosition,
           const wxSize& size = wxDefaultSize,
           wxWebViewBackend backend = wxWEB_VIEW_BACKEND_DEFAULT,
           long style = 0,
           const wxString& name = wxWebViewNameStr)
        %postcall{% wxPli_create_evthandler( aTHX_ RETVAL, "Wx::WebView" ); %};

    virtual bool Create(wxWindow* parent,
                        wxWindowID id,
                        const wxString& url = wxWebViewDefaultURLStr,
                        const wxPoint& pos = wxDefaultPosition,
                        const wxSize& size = wxDefaultSize,
                        long style = 0,
                        const wxString& name = wxWebViewNameStr);

    virtual wxString GetCurrentTitle() const;
    
    virtual wxString GetCurrentURL() const;
    
    virtual wxString GetPageSource() const;
  
    virtual wxString GetPageText() const;
    
    virtual bool IsBusy() const;

    virtual bool IsEditable() const;

    virtual void LoadURL(const wxString& url);

    virtual void Print();
 
    /* TODO : IMP  virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0; */
    
    virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
    
    virtual void RunScript(const wxString& javascript);
    
    virtual void SetEditable(bool enable = true);

    virtual void SetPage(const wxString& html, const wxString& baseUrl);

    %name{SetPageFH} virtual void SetPage(SV* fh, wxString baseUrl)
        %code{% wxInputStream* stream = wxPliInputStream_ctor( fh );
                THIS->SetPage( *stream, baseUrl );
                delete stream;
                %};

    virtual void Stop();

    virtual bool CanCopy() const;

    virtual bool CanCut() const;

    virtual bool CanPaste() const;

    virtual void Copy();

    virtual void Cut();

    virtual void Paste();

    virtual bool CanGoBack();

    virtual bool CanGoForward() const;

    virtual void ClearHistory();
    
    virtual void EnableHistory(bool enable = true);
    
%{

void
wxWebView::GetBackwardHistory()
  PPCODE:
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > back = THIS->GetBackwardHistory();
    size_t num = back.size();
    EXTEND( SP, (IV)num );
    for( size_t i = 0; i < num; ++i )
    {
        PUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                                      new wxWebViewHistoryItem(
                                          back[i]->GetUrl(), back[i]->GetTitle()
                                          ),
                                      "Wx::WebViewHistoryItem" ) );
    }


void
wxWebView::GetForwardHistory()
  PPCODE:
    wxVector<wxSharedPtr<wxWebViewHistoryItem> > forward = THIS->GetForwardHistory();
    size_t num = forward.size();
    EXTEND( SP, (IV)num );
    for( size_t i = 0; i < num; ++i )
    {
        PUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                                      new wxWebViewHistoryItem(
                                          forward[i]->GetUrl(), forward[i]->GetTitle()
                                          ),
                                      "Wx::WebViewHistoryItem" ) );
    }

%}    

    virtual void GoBack();

    virtual void GoForward();

    /* not quite the standard implementation but it makes
      wxWebViewHistoryItem simpler */
      
    virtual void LoadHistoryItem( wxWebViewHistoryItem* item )
        %code{% THIS->LoadURL( item->GetUrl() ); %};
    
    virtual void ClearSelection();
   
    virtual void DeleteSelection();
 
    virtual wxString GetSelectedSource() const;
  
    virtual wxString GetSelectedText() const;

    virtual bool HasSelection() const;

    virtual void SelectAll();

    virtual bool CanRedo() const;

    virtual bool CanUndo() const;

    virtual void Redo();

    virtual void Undo();

    virtual bool CanSetZoomType(wxWebViewZoomType type) const;

    virtual wxWebViewZoom GetZoom() const;

    virtual wxWebViewZoomType GetZoomType() const;

    virtual void SetZoom(wxWebViewZoom zoom);

    virtual void SetZoomType(wxWebViewZoomType zoomType);
};


%name{Wx::WebViewEvent} class wxWebViewEvent : public %name{Wx::NotifyEvent} wxNotifyEvent
{
public:
    
    %name{newDefault} wxWebViewEvent() %Overload;
    
    %name{newFull} wxWebViewEvent(wxEventType type, int id, const wxString& href,
                   const wxString& target) %Overload;

    const wxString& GetTarget() const;
    
    const wxString& GetURL() const;
};

/*
wxEventType wxEVT_COMMAND_WEB_VIEW_NAVIGATING;
wxEventType wxEVT_COMMAND_WEB_VIEW_NAVIGATED;
wxEventType wxEVT_COMMAND_WEB_VIEW_LOADED;
wxEventType wxEVT_COMMAND_WEB_VIEW_ERROR;
wxEventType wxEVT_COMMAND_WEB_VIEW_NEWWINDOW;
wxEventType wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED;
*/

%name{Wx::WebViewArchiveHandler} class wxWebViewArchiveHandler : public %name{Wx::WebViewHandler} wxWebViewHandler
{
public:
    
    wxWebViewArchiveHandler(const wxString& scheme);
    
    virtual wxFSFile* GetFile(const wxString &uri);
};

#endif