]> git.saurik.com Git - wxWidgets.git/blame - include/wx/htmllbox.h
Add new methods to transform coordinates expressed in Cocoa's bounds rect to
[wxWidgets.git] / include / wx / htmllbox.h
CommitLineData
e0c6027b
VZ
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$
77ffb593 8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 9// Licence: wxWindows licence
e0c6027b
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_HTMLLBOX_H_
13#define _WX_HTMLLBOX_H_
14
15#include "wx/vlbox.h" // base class
16
2d814c19
VZ
17#if wxUSE_FILESYSTEM
18 #include "wx/filesys.h"
19#endif // wxUSE_FILESYSTEM
20
6acba9a7
VS
21class WXDLLIMPEXP_HTML wxHtmlCell;
22class WXDLLIMPEXP_HTML wxHtmlWinParser;
23class WXDLLIMPEXP_HTML wxHtmlListBoxCache;
24class WXDLLIMPEXP_HTML wxHtmlListBoxStyle;
e0c6027b
VZ
25
26// ----------------------------------------------------------------------------
27// wxHtmlListBox
28// ----------------------------------------------------------------------------
29
6acba9a7 30class WXDLLIMPEXP_HTML wxHtmlListBox : public wxVListBox
e0c6027b 31{
0c8392ca 32 DECLARE_ABSTRACT_CLASS(wxHtmlListBox)
e0c6027b
VZ
33public:
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,
e0c6027b
VZ
45 long style = 0,
46 const wxString& name = wxVListBoxNameStr)
47 {
48 Init();
49
43e319a3 50 (void)Create(parent, id, pos, size, style, name);
e0c6027b
VZ
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 //
43e319a3 56 // the only special style which may be specified here is wxLB_MULTIPLE
e0c6027b
VZ
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,
e0c6027b
VZ
63 long style = 0,
64 const wxString& name = wxVListBoxNameStr);
65
66 // destructor cleans up whatever resources we use
67 virtual ~wxHtmlListBox();
68
03495767 69 // override some base class virtuals
5ecdc7ab 70 virtual void RefreshAll();
03495767 71 virtual void SetItemCount(size_t count);
5ecdc7ab 72
2d814c19
VZ
73
74#if wxUSE_FILESYSTEM
75 // retrieve the file system used by the wxHtmlWinParser: if you use
76 // relative paths in your HTML, you should use its ChangePathTo() method
77 wxFileSystem& GetFileSystem() { return m_filesystem; }
78 const wxFileSystem& GetFileSystem() const { return m_filesystem; }
79#endif // wxUSE_FILESYSTEM
80
e0c6027b
VZ
81protected:
82 // this method must be implemented in the derived class and should return
83 // the body (i.e. without <html>) of the HTML for the given item
84 virtual wxString OnGetItem(size_t n) const = 0;
85
86 // this function may be overridden to decorate HTML returned by OnGetItem()
87 virtual wxString OnGetItemMarkup(size_t n) const;
88
89
9a9b4940
VZ
90 // this method allows to customize the selection appearance: it may be used
91 // to specify the colour of the text which normally has the given colour
92 // colFg when it is inside the selection
93 //
94 // by default, the original colour is not used at all and all text has the
95 // same (default for this system) colour inside selection
96 virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
97
98 // this is the same as GetSelectedTextColour() but allows to customize the
99 // background colour -- this is even more rarely used as you can change it
100 // globally using SetSelectionBackground()
101 virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;
102
103
e0c6027b
VZ
104 // we implement both of these functions in terms of OnGetItem(), they are
105 // not supposed to be overridden by our descendants
106 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
107 virtual wxCoord OnMeasureItem(size_t n) const;
108
109
5ecdc7ab
VZ
110 // event handlers
111 void OnSize(wxSizeEvent& event);
112
113
e0c6027b
VZ
114 // common part of all ctors
115 void Init();
116
117 // ensure that the given item is cached
118 void CacheItem(size_t n) const;
119
120private:
9a9b4940 121 // this class caches the pre-parsed HTML to speed up display
e0c6027b
VZ
122 wxHtmlListBoxCache *m_cache;
123
124 // HTML parser we use
125 wxHtmlWinParser *m_htmlParser;
5ecdc7ab 126
2d814c19
VZ
127#if wxUSE_FILESYSTEM
128 // file system used by m_htmlParser
129 wxFileSystem m_filesystem;
130#endif // wxUSE_FILESYSTEM
131
9a9b4940
VZ
132 // rendering style for the parser which allows us to customize our colours
133 wxHtmlListBoxStyle *m_htmlRendStyle;
134
135
136 // it calls our GetSelectedTextColour() and GetSelectedTextBgColour()
137 friend class wxHtmlListBoxStyle;
138
5ecdc7ab
VZ
139
140 DECLARE_EVENT_TABLE()
27d0dcd0 141 DECLARE_NO_COPY_CLASS(wxHtmlListBox)
e0c6027b
VZ
142};
143
144#endif // _WX_HTMLLBOX_H_
145