]> git.saurik.com Git - wxWidgets.git/blame - include/wx/htmllbox.h
moved wxSTRINGIZE to defs.h and made it work with macro argument, so that it can...
[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
bc55e31b 16#include "wx/html/htmlwin.h"
e0c6027b 17
2d814c19
VZ
18#if wxUSE_FILESYSTEM
19 #include "wx/filesys.h"
20#endif // wxUSE_FILESYSTEM
21
6acba9a7
VS
22class WXDLLIMPEXP_HTML wxHtmlCell;
23class WXDLLIMPEXP_HTML wxHtmlWinParser;
24class WXDLLIMPEXP_HTML wxHtmlListBoxCache;
25class WXDLLIMPEXP_HTML wxHtmlListBoxStyle;
e0c6027b
VZ
26
27// ----------------------------------------------------------------------------
28// wxHtmlListBox
29// ----------------------------------------------------------------------------
30
bc55e31b
VS
31class WXDLLIMPEXP_HTML wxHtmlListBox : public wxVListBox,
32 public wxHtmlWindowInterface,
31297dbb 33 public wxHtmlWindowMouseHelper
e0c6027b 34{
0c8392ca 35 DECLARE_ABSTRACT_CLASS(wxHtmlListBox)
e0c6027b
VZ
36public:
37 // constructors and such
38 // ---------------------
39
40 // default constructor, you must call Create() later
bc55e31b 41 wxHtmlListBox();
e0c6027b
VZ
42
43 // normal constructor which calls Create() internally
44 wxHtmlListBox(wxWindow *parent,
45 wxWindowID id = wxID_ANY,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
e0c6027b 48 long style = 0,
bc55e31b 49 const wxString& name = wxVListBoxNameStr);
e0c6027b
VZ
50
51 // really creates the control and sets the initial number of items in it
52 // (which may be changed later with SetItemCount())
53 //
43e319a3 54 // the only special style which may be specified here is wxLB_MULTIPLE
e0c6027b
VZ
55 //
56 // returns true on success or false if the control couldn't be created
57 bool Create(wxWindow *parent,
58 wxWindowID id = wxID_ANY,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize,
e0c6027b
VZ
61 long style = 0,
62 const wxString& name = wxVListBoxNameStr);
63
64 // destructor cleans up whatever resources we use
65 virtual ~wxHtmlListBox();
66
03495767 67 // override some base class virtuals
5c2a509f
VZ
68 virtual void RefreshLine(size_t line);
69 virtual void RefreshLines(size_t from, size_t to);
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
bc55e31b
VS
81 virtual void OnInternalIdle();
82
e0c6027b
VZ
83protected:
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
9a9b4940
VZ
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
e0c6027b
VZ
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
bc55e31b
VS
111 // This method may be overriden to handle clicking on a link in
112 // the listbox. By default, clicking links is ignored.
113 virtual void OnLinkClicked(size_t WXUNUSED(n),
114 const wxHtmlLinkInfo& WXUNUSED(link)) {}
e0c6027b 115
5ecdc7ab
VZ
116 // event handlers
117 void OnSize(wxSizeEvent& event);
bc55e31b
VS
118 void OnMouseMove(wxMouseEvent& event);
119 void OnLeftDown(wxMouseEvent& event);
5ecdc7ab
VZ
120
121
e0c6027b
VZ
122 // common part of all ctors
123 void Init();
124
125 // ensure that the given item is cached
126 void CacheItem(size_t n) const;
127
bc55e31b
VS
128private:
129 // wxHtmlWindowInterface methods:
130 virtual void SetHTMLWindowTitle(const wxString& title);
131 virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link);
132 virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
133 const wxString& url,
134 wxString *redirect) const;
135 virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
136 const wxPoint& pos) const;
137 virtual wxWindow* GetHTMLWindow();
138 virtual wxColour GetHTMLBackgroundColour() const;
139 virtual void SetHTMLBackgroundColour(const wxColour& clr);
140 virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
141 virtual void SetHTMLStatusText(const wxString& text);
88a1b648 142 virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
bc55e31b
VS
143
144 // returns index of item that contains given HTML cell
145 size_t GetItemForCell(const wxHtmlCell *cell) const;
146
147 // return physical coordinates of root wxHtmlCell of n-th item
148 wxPoint GetRootCellCoords(size_t n) const;
149
150 // Converts physical coordinates stored in @a pos into coordinates
151 // relative to the root cell of the item under mouse cursor, if any. If no
152 // cell is found under the cursor, returns false. Otherwise stores the new
153 // coordinates back into @a pos and pointer to the cell under cursor into
154 // @a cell and returns true.
155 bool PhysicalCoordsToCell(wxPoint& pos, wxHtmlCell*& cell) const;
156
157 // The opposite of PhysicalCoordsToCell: converts coordinates relative to
158 // given cell to physical coordinates in the window
159 wxPoint CellCoordsToPhysical(const wxPoint& pos, wxHtmlCell *cell) const;
160
e0c6027b 161private:
9a9b4940 162 // this class caches the pre-parsed HTML to speed up display
e0c6027b
VZ
163 wxHtmlListBoxCache *m_cache;
164
165 // HTML parser we use
166 wxHtmlWinParser *m_htmlParser;
5ecdc7ab 167
2d814c19
VZ
168#if wxUSE_FILESYSTEM
169 // file system used by m_htmlParser
170 wxFileSystem m_filesystem;
171#endif // wxUSE_FILESYSTEM
172
9a9b4940
VZ
173 // rendering style for the parser which allows us to customize our colours
174 wxHtmlListBoxStyle *m_htmlRendStyle;
175
176
177 // it calls our GetSelectedTextColour() and GetSelectedTextBgColour()
178 friend class wxHtmlListBoxStyle;
bc55e31b 179 friend class wxHtmlListBoxWinInterface;
9a9b4940 180
5ecdc7ab
VZ
181
182 DECLARE_EVENT_TABLE()
27d0dcd0 183 DECLARE_NO_COPY_CLASS(wxHtmlListBox)
e0c6027b
VZ
184};
185
186#endif // _WX_HTMLLBOX_H_
187