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