xCHM  1.23
chmsearchpanel.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 __CHMSEARCHPANEL_HPP_
24 #define __CHMSEARCHPANEL_HPP_
25 
26 
27 #include <wx/panel.h>
28 #include <wx/treectrl.h>
29 #include <wx/textctrl.h>
30 #include <wx/listctrl.h>
31 #include <wx/checkbox.h>
32 #include <wx/button.h>
33 #include <wx/listbox.h>
34 #include <wx/html/htmlwin.h>
35 #include <wx/font.h>
36 #include <wx/string.h>
37 
38 
39 // Forward declaration.
40 class CHMListCtrl;
41 class CHMHtmlNotebook;
42 
43 
50 enum {
52  ID_SearchText = 1024,
53  ID_SearchButton,
54  ID_Results,
55 };
56 
57 
59 class CHMSearchPanel : public wxPanel {
60 
61 public:
71  CHMSearchPanel(wxWindow *parent, wxTreeCtrl *topics,
72  CHMHtmlNotebook* nbhtml);
73 
76 
78  void Reset();
79 
81  void SetNewFont(const wxFont& font);
82 
83 protected:
88  void OnSearch(wxCommandEvent& event);
89 
91  void OnSearchSel(wxListEvent& event);
92 
93 private:
95  void PopulateList(wxTreeItemId root, wxString& text, bool wholeWords);
96 
98  bool TitleSearch(const wxString& title, wxString& text,
99  bool caseSensitive, bool wholeWords);
100 
102  void GetConfig();
103 
105  void SetConfig();
106 
107 private:
108  wxTreeCtrl* _tcl;
109  wxTextCtrl* _text;
110  wxCheckBox* _partial;
111  wxCheckBox* _titles;
112  wxButton* _search;
113  CHMListCtrl* _results;
114  CHMHtmlNotebook* _nbhtml;
115 
116 private:
117  DECLARE_EVENT_TABLE()
118 };
119 
120 
121 #endif // __CHMSEARCHPANEL_HPP_
122 
123 
124 /*
125  Local Variables:
126  mode: c++
127  c-basic-offset: 8
128  tab-width: 8
129  c-indent-comments-syntactically-p: t
130  c-tab-always-indent: t
131  indent-tabs-mode: t
132  End:
133 */
134 
135 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
136 
void OnSearch(wxCommandEvent &event)
Definition: chmsearchpanel.cpp:75
~CHMSearchPanel()
Calls SetConfig().
Definition: chmsearchpanel.cpp:69
void GetConfig()
Reads the search configuration from .xchm (case sensitive, etc.).
Definition: chmsearchpanel.cpp:276
void SetNewFont(const wxFont &font)
Sets the font.
Definition: chmsearchpanel.cpp:263
Custom built search panel.
Definition: chmsearchpanel.h:59
void SetConfig()
Writes the search configuration to .xchm.
Definition: chmsearchpanel.cpp:269
void OnSearchSel(wxListEvent &event)
This gets called when the user clicks on a result.
Definition: chmsearchpanel.cpp:250
CHMSearchPanel(wxWindow *parent, wxTreeCtrl *topics, CHMHtmlNotebook *nbhtml)
Initialized the search panel.
Definition: chmsearchpanel.cpp:35
Custom HTML notebook widget class. For tabbed viewing of a CHM file.
Definition: chmhtmlnotebook.h:49
bool TitleSearch(const wxString &title, wxString &text, bool caseSensitive, bool wholeWords)
Helper. Grep searches page titles for the given text.
Definition: chmsearchpanel.cpp:187
generic wxWidgets panel widget class.
Definition: chmindexpanel.h:33
void Reset()
Resets the panel (clears the result list and the textbox.)
Definition: chmsearchpanel.cpp:256
List control class meant to emulate the look and feel of a wxListBox.
Definition: chmlistctrl.h:65
void PopulateList(wxTreeItemId root, wxString &text, bool wholeWords)
Helper. Searches through the tree recursively.
Definition: chmsearchpanel.cpp:153