xCHM  1.23
chmhtmlwindow.h
1 /*
2 
3  Copyright (C) 2003 - 2013 Razvan Cojocaru <rzvncj@gmail.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  MA 02110-1301, USA.
19 
20 */
21 
22 
23 #ifndef __CHMHTMLWINDOW_H_
24 #define __CHMHTMLWINDOW_H_
25 
26 
27 #include <wx/html/htmlwin.h>
28 #include <wx/treectrl.h>
29 #include <wx/menu.h>
30 #include <wx/notebook.h>
31 #include <chmfinddialog.h>
32 
33 
34 
36 enum {
37  ID_CopySel = 1216,
38  ID_CopyLink,
39  ID_SaveLinkAs,
40  ID_PopupForward,
41  ID_PopupBack,
42  ID_PopupFind,
43  ID_PopupFullScreen,
44  ID_OpenInNewTab,
45 };
46 
47 
49 class CHMFrame;
50 
51 
62 class CHMHtmlWindow : public wxHtmlWindow {
63 
64 public:
72  CHMHtmlWindow(wxWindow *parent, wxTreeCtrl *tc, CHMFrame* frame);
73 
76  virtual void OnSetTitle(const wxString& title);
78  bool LoadPage(const wxString& location);
79 
86  void SetSync(bool value) { _syncTree = value; }
87 
93  bool IsCaller() const { return _found; }
94 
95 public:
109  wxHtmlCell* FindFirst(wxHtmlCell* parent, const wxString& word,
110  bool wholeWords, bool caseSensitive);
111 
116  wxHtmlCell* FindNext(wxHtmlCell *start,
117  const wxString& word, bool wholeWords,
118  bool caseSensitive);
119 
121  void ClearSelection();
122 
123  // Needs to be public, cause I call it from CHMHtmlFrame.
125  void OnFind(wxCommandEvent& event);
126 
128  void OnCopy(wxCommandEvent& event);
129 
130 protected:
132  void OnForward(wxCommandEvent& event);
133 
135  void OnBack(wxCommandEvent& event);
136 
138  void OnCopyLink(wxCommandEvent& event);
139 
141  void OnSaveLinkAs(wxCommandEvent& event);
142 
144  void OnChar(wxKeyEvent &event);
145 
147  void OnSize(wxSizeEvent& event);
148 
150  void OnOpenInNewTab(wxCommandEvent& event);
151 
153  void OnToggleFullScreen(wxCommandEvent& event);
154 
155 protected:
157  void OnRightClick(wxMouseEvent& event);
158 
160  void OnLinkClicked(const wxHtmlLinkInfo& link);
161 
162 private:
164  void Sync(wxTreeItemId root, const wxString& page);
165 
167  wxString GetPrefix(const wxString& location) const;
168 
169 private:
170  wxTreeCtrl *_tcl;
171  bool _syncTree;
172  bool _found;
173  wxMenu *_menu;
174  CHMFrame *_frame;
175  wxString _link;
176  CHMFindDialog* _fdlg;
177 
178 private:
179  DECLARE_EVENT_TABLE()
180 };
181 
182 
183 
184 #endif // __CHMHTMLWINDOW_H_
185 
186 
187 /*
188  Local Variables:
189  mode: c++
190  c-basic-offset: 8
191  tab-width: 8
192  c-indent-comments-syntactically-p: t
193  c-tab-always-indent: t
194  indent-tabs-mode: t
195  End:
196 */
197 
198 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
199 
Dialog for finding a word in the currently displayed page.
Definition: chmfinddialog.h:45
wxWidgets HTML widget class.
Definition: chmhtmlwindow.h:49
void OnToggleFullScreen(wxCommandEvent &event)
Called when the &#39;Toggle fullscreen&#39; is selected from the popup menu.
Definition: chmhtmlwindow.cpp:389
CHMHtmlWindow(wxWindow *parent, wxTreeCtrl *tc, CHMFrame *frame)
Initializes the widget.
Definition: chmhtmlwindow.cpp:42
bool LoadPage(const wxString &location)
Override. Looks up the wanted page in the tree and selects it.
Definition: chmhtmlwindow.cpp:70
void OnOpenInNewTab(wxCommandEvent &event)
Called when the user selects &#39;Save link as&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:378
void ClearSelection()
Clears the current selection.
Definition: chmhtmlwindow.cpp:239
wxHtmlCell * FindNext(wxHtmlCell *start, const wxString &word, bool wholeWords, bool caseSensitive)
Same as FindFirst(), but continues the search from start (start is considered in the search process)...
Definition: chmhtmlwindow.cpp:213
Custom HTML widget class. Needed for sychnronization between the topics tree control and the currentl...
Definition: chmhtmlwindow.h:62
void OnForward(wxCommandEvent &event)
Called when the user selects &#39;Forward&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:269
void OnRightClick(wxMouseEvent &event)
Called when the user right clicks the HTML window.
Definition: chmhtmlwindow.cpp:345
void OnCopy(wxCommandEvent &event)
Called when the user selects &#39;Copy&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:246
void OnChar(wxKeyEvent &event)
Called when the user presses a key.
Definition: chmhtmlwindow.cpp:395
void OnCopyLink(wxCommandEvent &event)
Called when the user selects &#39;Copy link&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:293
~CHMHtmlWindow()
Destructor. Deletes heap objects allocated in the constructor.
Definition: chmhtmlwindow.cpp:63
void OnLinkClicked(const wxHtmlLinkInfo &link)
Overridden. Called when the user clicks on a link.
Definition: chmhtmlwindow.cpp:137
wxString GetPrefix(const wxString &location) const
Helper. Returns the prefix of the currently loaded page.
Definition: chmhtmlwindow.cpp:130
void OnFind(wxCommandEvent &event)
Called when the user selects &#39;Find&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:252
The frame, owner of the wxHtmlWindow, contents tree control and all the other nifty stuff...
Definition: chmframe.h:97
wxHtmlCell * FindFirst(wxHtmlCell *parent, const wxString &word, bool wholeWords, bool caseSensitive)
Finds the first occurence of word in the displayed page.
Definition: chmhtmlwindow.cpp:148
bool IsCaller() const
Definition: chmhtmlwindow.h:93
void Sync(wxTreeItemId root, const wxString &page)
Helper. Recursively looks for the opened page in the tree.
Definition: chmhtmlwindow.cpp:101
void SetSync(bool value)
Dictates the behaviour of LoadPage(). If SetSync() has been called with a true parameter, the tree control will be updated by LoadPage(). Otherwise, it will not be updated.
Definition: chmhtmlwindow.h:86
void OnBack(wxCommandEvent &event)
Called when the user selects &#39;Back&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:275
void OnSize(wxSizeEvent &event)
Called on widget resize.
Definition: chmhtmlwindow.cpp:281
void OnSaveLinkAs(wxCommandEvent &event)
Called when the user selects &#39;Save link as&#39; from the popup menu.
Definition: chmhtmlwindow.cpp:302