]> git.saurik.com Git - wxWidgets.git/blob - include/wx/htmllbox.h
refresh cache on size/margins change; expanded cache to contain N elements, not just one
[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 WXDLLEXPORT wxHtmlCell;
18 class WXDLLEXPORT wxHtmlWinParser;
19 class WXDLLEXPORT wxHtmlListBoxCache;
20
21 // ----------------------------------------------------------------------------
22 // wxHtmlListBox
23 // ----------------------------------------------------------------------------
24
25 class WXDLLEXPORT wxHtmlListBox : public wxVListBox
26 {
27 public:
28 // constructors and such
29 // ---------------------
30
31 // default constructor, you must call Create() later
32 wxHtmlListBox() { Init(); }
33
34 // normal constructor which calls Create() internally
35 wxHtmlListBox(wxWindow *parent,
36 wxWindowID id = wxID_ANY,
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize,
39 size_t countItems = 0,
40 long style = 0,
41 const wxString& name = wxVListBoxNameStr)
42 {
43 Init();
44
45 (void)Create(parent, id, pos, size, countItems, 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 // there are no special styles defined for wxVListBox
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 size_t countItems = 0,
59 long style = 0,
60 const wxString& name = wxVListBoxNameStr);
61
62 // destructor cleans up whatever resources we use
63 virtual ~wxHtmlListBox();
64
65 // refresh everything
66 virtual void RefreshAll();
67
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 // we implement both of these functions in terms of OnGetItem(), they are
79 // not supposed to be overridden by our descendants
80 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
81 virtual wxCoord OnMeasureItem(size_t n) const;
82
83
84 // event handlers
85 void OnSize(wxSizeEvent& event);
86
87
88 // common part of all ctors
89 void Init();
90
91 // ensure that the given item is cached
92 void CacheItem(size_t n) const;
93
94 private:
95 wxHtmlListBoxCache *m_cache;
96
97 // HTML parser we use
98 wxHtmlWinParser *m_htmlParser;
99
100
101 DECLARE_EVENT_TABLE()
102 };
103
104 #endif // _WX_HTMLLBOX_H_
105