]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIHtmlBrowser.h
174258cb16f17c0ff89fc71211b546774a2b7f95
[bbtk.git] / kernel / src / bbtkWxGUIHtmlBrowser.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxGUIHtmlBrowser.h,v $
4   Language:  C++
5   Date:      $Date: 2008/11/24 15:45:48 $
6   Version:   $Revision: 1.7 $
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
62   class WxHtmlWindow : public virtual wxHtmlWindow
63   {
64   public:
65     WxHtmlWindow( wxWindow *parent, int id, WxGUIHtmlBrowser* browser, wxSize size) 
66       : wxHtmlWindow(parent, id, 
67                      wxDefaultPosition, 
68                      size,
69                      wxHW_SCROLLBAR_AUTO, 
70                   _T("bbtk::WxGUIHtmlBrowser")),
71               mBrowser(browser)
72     {
73                 std::cout << "ctor"<<std::endl;
74      SetBorders(30);
75     };
76     //    wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,const wxString& url, wxString *redirect);
77 //   virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
78
79 //EED2  void OnSize( wxSizeEvent&);
80
81
82   private: 
83     WxGUIHtmlBrowser* mBrowser;
84
85    // any class wishing to process wxWidgets events must use this macro
86 //EED2    DECLARE_EVENT_TABLE()  
87
88   };
89
90 //      typedef wxHtmlWindow WxHtmlWindow;
91   
92         
93 #define THE_HTML_WINDOW_CLASS wxHtmlWindow
94         
95   /// Abstract class which defines the callbacks invoked by WxGUIHtmlBrowser
96   class WxGUIHtmlBrowserUser 
97   {
98   public :
99     WxGUIHtmlBrowserUser() {}
100     virtual ~WxGUIHtmlBrowserUser() {}
101     
102     virtual bool WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target) 
103     { return true; }
104   };
105   
106  
107
108   // class WxGUIConsole;
109
110   
111   class BBTK_EXPORT WxGUIHtmlBrowser : public wxPanel
112   {
113   public:
114     WxGUIHtmlBrowser ( wxWindow *parent, wxSize size, 
115                        WxGUIHtmlBrowserUser* = 0 );
116  
117     bool GoTo(std::string&);
118     void GoHome();
119
120     void OnBackButton(wxCommandEvent& );
121     void OnForwardButton(wxCommandEvent& );
122     void OnHomeButton(wxCommandEvent& );
123     void OnReloadButton(wxCommandEvent& );
124     //   void OnRunButton(wxCommandEvent& );
125     void OnLinkClicked(wxHtmlLinkEvent& );
126         void OnLinkClicked2(const wxHtmlLinkInfo& );
127     void OnURLEnter( wxCommandEvent&);
128     void OnSize( wxSizeEvent&);
129
130     void UpdateURL();
131     //  void OnCell(wxHtmlCellEvent& );
132
133     void SetSize( wxSize );
134
135     std::string GetCurrentPage();
136
137   private:
138     THE_HTML_WINDOW_CLASS * mwxHtmlWindow;
139     wxTextCtrl* mwxURL;
140     wxButton* mwxBackButton;
141     wxButton* mwxForwardButton;
142     wxButton* mwxHomeButton;
143     wxButton* mwxReloadButton;
144     //    wxButton* mwxRunButton;
145     
146     WxGUIHtmlBrowserUser* mUser;
147     
148    // any class wishing to process wxWidgets events must use this macro
149     DECLARE_EVENT_TABLE()  
150   };
151
152 }
153 #endif
154
155 #endif