]> git.saurik.com Git - wxWidgets.git/blob - include/wx/htmllbox.h
Added wxGUIAppTraits::GetToolkitInfo (ok?)
[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@wxwindows.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 class WXDLLIMPEXP_HTML wxHtmlCell;
18 class WXDLLIMPEXP_HTML wxHtmlWinParser;
19 class WXDLLIMPEXP_HTML wxHtmlListBoxCache;
20 class WXDLLIMPEXP_HTML wxHtmlListBoxStyle;
21
22 // ----------------------------------------------------------------------------
23 // wxHtmlListBox
24 // ----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_HTML wxHtmlListBox : public wxVListBox
27 {
28 public:
29 // constructors and such
30 // ---------------------
31
32 // default constructor, you must call Create() later
33 wxHtmlListBox() { Init(); }
34
35 // normal constructor which calls Create() internally
36 wxHtmlListBox(wxWindow *parent,
37 wxWindowID id = wxID_ANY,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = 0,
41 const wxString& name = wxVListBoxNameStr)
42 {
43 Init();
44
45 (void)Create(parent, id, pos, size, style, name);
46 }
47
48 // really creates the control and sets the initial number of items in it
49 // (which may be changed later with SetItemCount())
50 //
51 // the only special style which may be specified here is wxLB_MULTIPLE
52 //
53 // returns true on success or false if the control couldn't be created
54 bool Create(wxWindow *parent,
55 wxWindowID id = wxID_ANY,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 long style = 0,
59 const wxString& name = wxVListBoxNameStr);
60
61 // destructor cleans up whatever resources we use
62 virtual ~wxHtmlListBox();
63
64 // override some base class virtuals
65 virtual void RefreshAll();
66 virtual void SetItemCount(size_t count);
67
68 protected:
69 // this method must be implemented in the derived class and should return
70 // the body (i.e. without <html>) of the HTML for the given item
71 virtual wxString OnGetItem(size_t n) const = 0;
72
73 // this function may be overridden to decorate HTML returned by OnGetItem()
74 virtual wxString OnGetItemMarkup(size_t n) const;
75
76
77 // this method allows to customize the selection appearance: it may be used
78 // to specify the colour of the text which normally has the given colour
79 // colFg when it is inside the selection
80 //
81 // by default, the original colour is not used at all and all text has the
82 // same (default for this system) colour inside selection
83 virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
84
85 // this is the same as GetSelectedTextColour() but allows to customize the
86 // background colour -- this is even more rarely used as you can change it
87 // globally using SetSelectionBackground()
88 virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;
89
90
91 // we implement both of these functions in terms of OnGetItem(), they are
92 // not supposed to be overridden by our descendants
93 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
94 virtual wxCoord OnMeasureItem(size_t n) const;
95
96
97 // event handlers
98 void OnSize(wxSizeEvent& event);
99
100
101 // common part of all ctors
102 void Init();
103
104 // ensure that the given item is cached
105 void CacheItem(size_t n) const;
106
107 private:
108 // this class caches the pre-parsed HTML to speed up display
109 wxHtmlListBoxCache *m_cache;
110
111 // HTML parser we use
112 wxHtmlWinParser *m_htmlParser;
113
114 // rendering style for the parser which allows us to customize our colours
115 wxHtmlListBoxStyle *m_htmlRendStyle;
116
117
118 // it calls our GetSelectedTextColour() and GetSelectedTextBgColour()
119 friend class wxHtmlListBoxStyle;
120
121
122 DECLARE_EVENT_TABLE()
123 DECLARE_NO_COPY_CLASS(wxHtmlListBox)
124 };
125
126 #endif // _WX_HTMLLBOX_H_
127