xCHM  1.23
chmlistctrl.h
1 /*
2 
3  Copyright (C) 2003 - 2013 Razvan Cojocaru <rzvncj@gmail.com>
4  ListDirty() patch contributed by Iulian Dragos
5  <dragosiulian@users.sourceforge.net>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  MA 02110-1301, USA.
21 
22 */
23 
24 
25 #ifndef __CHMLISTCTRL_H_
26 #define __CHMLISTCTRL_H_
27 
28 #include <wx/listbox.h>
29 #include <wx/listctrl.h>
30 #include <wx/string.h>
31 #include <wx/dynarray.h>
32 
33 
34 // Forward declarations.
35 class CHMHtmlNotebook;
36 
37 
41  CHMListPairItem(const wxString& title, const wxString& url)
42  : _title(title), _url(url) {}
43 
45  wxString _title;
47  wxString _url;
48 };
49 
50 
52 WX_DEFINE_SORTED_ARRAY(CHMListPairItem *, ItemPairArray);
53 
55 int CompareItemPairs(CHMListPairItem *item1, CHMListPairItem *item2);
56 
57 
64 class CHMListCtrl : public wxListCtrl {
66 
67 public:
76  CHMListCtrl(wxWindow *parent, CHMHtmlNotebook *nbhtml,
77  wxWindowID id = -1);
78 
80  ~CHMListCtrl();
81 
82 public:
84  void Reset();
85 
93  void AddPairItem(const wxString& title, const wxString& url);
94 
96  void LoadSelected();
97 
99  void UpdateUI();
100 
105  void FindBestMatch(const wxString& title);
106 
107 protected:
109  void OnSize(wxSizeEvent& event);
110 
112  wxString OnGetItemText(long item, long column) const;
113 
114 private:
116  void ResetItems();
117 
118 private:
119  ItemPairArray _items;
120  CHMHtmlNotebook *_nbhtml;
121  int _currentSize;
122 
123 private:
124  DECLARE_EVENT_TABLE()
125 };
126 
127 
128 #endif // __CHMLISTCTRL_H_
129 
130 
131 /*
132  Local Variables:
133  mode: c++
134  c-basic-offset: 8
135  tab-width: 8
136  c-indent-comments-syntactically-p: t
137  c-tab-always-indent: t
138  indent-tabs-mode: t
139  End:
140 */
141 
142 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
143 
CHMListCtrl(wxWindow *parent, CHMHtmlNotebook *nbhtml, wxWindowID id=-1)
Initializes the custom list control.
Definition: chmlistctrl.cpp:45
wxString _title
This will show up in the list.
Definition: chmlistctrl.h:45
void FindBestMatch(const wxString &title)
Finds the list item that is the best match.
Definition: chmlistctrl.cpp:115
void OnSize(wxSizeEvent &event)
Gets called when the widget is being resized.
Definition: chmlistctrl.cpp:152
Custom HTML notebook widget class. For tabbed viewing of a CHM file.
Definition: chmhtmlnotebook.h:49
void UpdateUI()
Should be called each time the list control&#39;s state changes.
Definition: chmlistctrl.cpp:109
void AddPairItem(const wxString &title, const wxString &url)
Adds a title:url pair to the list. The title is the part that gets displayed, the url is tha page whe...
Definition: chmlistctrl.cpp:77
wxString OnGetItemText(long item, long column) const
Gets called when an item needs to be displayed.
Definition: chmlistctrl.cpp:160
wxWidgets list control class.
List control class meant to emulate the look and feel of a wxListBox.
Definition: chmlistctrl.h:65
wxString _url
This is what the title points to.
Definition: chmlistctrl.h:47
Item to store in the virtual list control.
Definition: chmlistctrl.h:39
void ResetItems()
Delete/empty the items in the item array.
Definition: chmlistctrl.cpp:142
CHMListPairItem(const wxString &title, const wxString &url)
Trivial constructor.
Definition: chmlistctrl.h:41
~CHMListCtrl()
Cleanup.
Definition: chmlistctrl.cpp:61
void LoadSelected()
Loads the page that corresponds to the item currently selected.
Definition: chmlistctrl.cpp:84
void Reset()
Cleans up and removes all the list items.
Definition: chmlistctrl.cpp:69