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