]> git.saurik.com Git - wxWidgets.git/blob - include/wx/htmllbox.h
Build fix after last commit.
[wxWidgets.git] / include / wx / htmllbox.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/htmllbox.h
3 // Purpose: wxHtmlListBox is a listbox whose items are wxHtmlCells
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 31.05.03
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_HTMLLBOX_H_
13 #define _WX_HTMLLBOX_H_
14
15 #include "wx/vlbox.h" // base class
16
17 #if wxUSE_FILESYSTEM
18 #include "wx/filesys.h"
19 #endif // wxUSE_FILESYSTEM
20
21 class WXDLLIMPEXP_HTML wxHtmlCell;
22 class WXDLLIMPEXP_HTML wxHtmlWinParser;
23 class WXDLLIMPEXP_HTML wxHtmlListBoxCache;
24 class WXDLLIMPEXP_HTML wxHtmlListBoxStyle;
25
26 // ----------------------------------------------------------------------------
27 // wxHtmlListBox
28 // ----------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_HTML wxHtmlListBox : public wxVListBox
31 {
32 DECLARE_ABSTRACT_CLASS(wxHtmlListBox)
33 public:
34 // constructors and such
35 // ---------------------
36
37 // default constructor, you must call Create() later
38 wxHtmlListBox() { Init(); }
39
40 // normal constructor which calls Create() internally
41 wxHtmlListBox(wxWindow *parent,
42 wxWindowID id = wxID_ANY,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = 0,
46 const wxString& name = wxVListBoxNameStr)
47 {
48 Init();
49
50 (void)Create(parent, id, pos, size, style, name);
51 }
52
53 // really creates the control and sets the initial number of items in it
54 // (which may be changed later with SetItemCount())
55 //
56 // the only special style which may be specified here is wxLB_MULTIPLE
57 //
58 // returns true on success or false if the control couldn't be created
59 bool Create(wxWindow *parent,
60 wxWindowID id = wxID_ANY,
61 const wxPoint& pos = wxDefaultPosition,
62 const wxSize& size = wxDefaultSize,
63 long style = 0,
64 const wxString& name = wxVListBoxNameStr);
65
66 // destructor cleans up whatever resources we use
67 virtual ~wxHtmlListBox();
68
69 // override some base class virtuals
70 virtual void RefreshLine(size_t line);
71 virtual void RefreshLines(size_t from, size_t to);
72 virtual void RefreshAll();
73 virtual void SetItemCount(size_t count);
74
75
76 #if wxUSE_FILESYSTEM
77 // retrieve the file system used by the wxHtmlWinParser: if you use
78 // relative paths in your HTML, you should use its ChangePathTo() method
79 wxFileSystem& GetFileSystem() { return m_filesystem; }
80 const wxFileSystem& GetFileSystem() const { return m_filesystem; }
81 #endif // wxUSE_FILESYSTEM
82
83 protected:
84 // this method must be implemented in the derived class and should return
85 // the body (i.e. without <html>) of the HTML for the given item
86 virtual wxString OnGetItem(size_t n) const = 0;
87
88 // this function may be overridden to decorate HTML returned by OnGetItem()
89 virtual wxString OnGetItemMarkup(size_t n) const;
90
91
92 // this method allows to customize the selection appearance: it may be used
93 // to specify the colour of the text which normally has the given colour
94 // colFg when it is inside the selection
95 //
96 // by default, the original colour is not used at all and all text has the
97 // same (default for this system) colour inside selection
98 virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
99
100 // this is the same as GetSelectedTextColour() but allows to customize the
101 // background colour -- this is even more rarely used as you can change it
102 // globally using SetSelectionBackground()
103 virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;
104
105
106 // we implement both of these functions in terms of OnGetItem(), they are
107 // not supposed to be overridden by our descendants
108 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
109 virtual wxCoord OnMeasureItem(size_t n) const;
110
111
112 // event handlers
113 void OnSize(wxSizeEvent& event);
114
115
116 // common part of all ctors
117 void Init();
118
119 // ensure that the given item is cached
120 void CacheItem(size_t n) const;
121
122 private:
123 // this class caches the pre-parsed HTML to speed up display
124 wxHtmlListBoxCache *m_cache;
125
126 // HTML parser we use
127 wxHtmlWinParser *m_htmlParser;
128
129 #if wxUSE_FILESYSTEM
130 // file system used by m_htmlParser
131 wxFileSystem m_filesystem;
132 #endif // wxUSE_FILESYSTEM
133
134 // rendering style for the parser which allows us to customize our colours
135 wxHtmlListBoxStyle *m_htmlRendStyle;
136
137
138 // it calls our GetSelectedTextColour() and GetSelectedTextBgColour()
139 friend class wxHtmlListBoxStyle;
140
141
142 DECLARE_EVENT_TABLE()
143 DECLARE_NO_COPY_CLASS(wxHtmlListBox)
144 };
145
146 #endif // _WX_HTMLLBOX_H_
147