]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIHtmlBrowser.h
14183b8fe1b597fba594008af20062b1e50872a9
[bbtk.git] / kernel / src / bbtkWxGUIHtmlBrowser.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxGUIHtmlBrowser.h,v $
4   Language:  C++
5   Date:      $Date: 2008/10/17 08:18:15 $
6   Version:   $Revision: 1.6 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  * \brief Short description in one line
34  * 
35  * Long description which 
36  * can span multiple lines
37  */
38 /**
39  * \file 
40  * \brief 
41  */
42 /**
43  * \class bbtk::
44  * \brief 
45  */
46
47 #ifdef _USE_WXWIDGETS_
48
49
50 #ifndef __bbtkWxGUIHtmlBrowser_h_INCLUDED__
51 #define __bbtkWxGUIHtmlBrowser_h_INCLUDED__
52
53 #include "bbtkWx.h"
54 #include <wx/html/htmlwin.h>
55
56 namespace bbtk
57 {
58
59   class WxGUIHtmlBrowser;
60
61   class WxHtmlWindow : public virtual wxHtmlWindow
62   {
63   public:
64     WxHtmlWindow( wxWindow *parent, int id, WxGUIHtmlBrowser* browser, wxSize size) 
65       : wxHtmlWindow(parent, id, 
66                      wxDefaultPosition, 
67                      size,
68                      wxHW_SCROLLBAR_AUTO, 
69                   _T("bbtk::WxGUIHtmlBrowser")),
70               mBrowser(browser)
71     {
72      SetBorders(30);
73     };
74     //    wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,const wxString& url, wxString *redirect);
75 //EED    virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
76
77 //EED2  void OnSize( wxSizeEvent&);
78
79
80   private: 
81     WxGUIHtmlBrowser* mBrowser;
82
83    // any class wishing to process wxWidgets events must use this macro
84 //EED2    DECLARE_EVENT_TABLE()  
85
86   };
87
88   
89   /// Abstract class which defines the callbacks invoked by WxGUIHtmlBrowser
90   class WxGUIHtmlBrowserUser 
91   {
92   public :
93     WxGUIHtmlBrowserUser() {}
94     virtual ~WxGUIHtmlBrowserUser() {}
95     
96     virtual bool WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target) 
97     { return true; }
98   };
99   
100  
101
102   // class WxGUIConsole;
103
104   
105   class BBTK_EXPORT WxGUIHtmlBrowser : public wxPanel
106   {
107   public:
108     WxGUIHtmlBrowser ( wxWindow *parent, wxSize size, 
109                        WxGUIHtmlBrowserUser* = 0 );
110  
111     bool GoTo(std::string&);
112     void GoHome();
113
114     void OnBackButton(wxCommandEvent& );
115     void OnForwardButton(wxCommandEvent& );
116     void OnHomeButton(wxCommandEvent& );
117     void OnReloadButton(wxCommandEvent& );
118     //   void OnRunButton(wxCommandEvent& );
119     void OnLinkClicked(wxHtmlLinkEvent& );
120     void OnURLEnter( wxCommandEvent&);
121     void OnSize( wxSizeEvent&);
122
123     void UpdateURL();
124     //  void OnCell(wxHtmlCellEvent& );
125
126     void SetSize( wxSize );
127
128     std::string GetCurrentPage();
129
130   private:
131     WxHtmlWindow* mwxHtmlWindow;
132     wxTextCtrl* mwxURL;
133     wxButton* mwxBackButton;
134     wxButton* mwxForwardButton;
135     wxButton* mwxHomeButton;
136     wxButton* mwxReloadButton;
137     //    wxButton* mwxRunButton;
138     
139     WxGUIHtmlBrowserUser* mUser;
140     
141    // any class wishing to process wxWidgets events must use this macro
142     DECLARE_EVENT_TABLE()  
143   };
144
145 }
146 #endif
147
148 #endif