]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlcell.h | |
3 | // Purpose: wxHtmlCell class is used by wxHtmlWindow/wxHtmlWinParser | |
4 | // as a basic visual element of HTML page | |
5 | // Author: Vaclav Slavik | |
69941f05 | 6 | // RCS-ID: $Id$ |
a99798d2 | 7 | // Copyright: (c) 1999-2003 Vaclav Slavik |
65571936 | 8 | // Licence: wxWindows licence |
5526e819 VS |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
69941f05 VS |
11 | #ifndef _WX_HTMLCELL_H_ |
12 | #define _WX_HTMLCELL_H_ | |
5526e819 | 13 | |
5526e819 | 14 | #include "wx/defs.h" |
5526e819 | 15 | |
4dcaf11a | 16 | #if wxUSE_HTML |
5526e819 | 17 | |
4dcaf11a RR |
18 | #include "wx/html/htmltag.h" |
19 | #include "wx/html/htmldefs.h" | |
20 | #include "wx/window.h" | |
5526e819 | 21 | |
846914d1 | 22 | |
6acba9a7 VS |
23 | class WXDLLIMPEXP_HTML wxHtmlLinkInfo; |
24 | class WXDLLIMPEXP_HTML wxHtmlCell; | |
25 | class WXDLLIMPEXP_HTML wxHtmlContainerCell; | |
5526e819 | 26 | |
f65a786f VS |
27 | |
28 | // wxHtmlSelection is data holder with information about text selection. | |
29 | // Selection is defined by two positions (beginning and end of the selection) | |
30 | // and two leaf(!) cells at these positions. | |
6acba9a7 | 31 | class WXDLLIMPEXP_HTML wxHtmlSelection |
f65a786f VS |
32 | { |
33 | public: | |
6953da00 | 34 | wxHtmlSelection() |
f65a786f | 35 | : m_fromPos(wxDefaultPosition), m_toPos(wxDefaultPosition), |
a99798d2 | 36 | m_fromPrivPos(wxDefaultPosition), m_toPrivPos(wxDefaultPosition), |
f65a786f VS |
37 | m_fromCell(NULL), m_toCell(NULL) {} |
38 | ||
1338c59a VS |
39 | void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell, |
40 | const wxPoint& toPos, const wxHtmlCell *toCell); | |
41 | void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell); | |
6953da00 | 42 | |
7d96264c VZ |
43 | const wxHtmlCell *GetFromCell() const { return m_fromCell; } |
44 | const wxHtmlCell *GetToCell() const { return m_toCell; } | |
6953da00 | 45 | |
a99798d2 | 46 | // these values are in absolute coordinates: |
f65a786f VS |
47 | const wxPoint& GetFromPos() const { return m_fromPos; } |
48 | const wxPoint& GetToPos() const { return m_toPos; } | |
6953da00 | 49 | |
a99798d2 VS |
50 | // these are From/ToCell's private data |
51 | const wxPoint& GetFromPrivPos() const { return m_fromPrivPos; } | |
52 | const wxPoint& GetToPrivPos() const { return m_toPrivPos; } | |
53 | void SetFromPrivPos(const wxPoint& pos) { m_fromPrivPos = pos; } | |
54 | void SetToPrivPos(const wxPoint& pos) { m_toPrivPos = pos; } | |
1338c59a | 55 | void ClearPrivPos() { m_toPrivPos = m_fromPrivPos = wxDefaultPosition; } |
f65a786f | 56 | |
6953da00 WS |
57 | bool IsEmpty() const |
58 | { return m_fromPos == wxDefaultPosition && | |
f65a786f VS |
59 | m_toPos == wxDefaultPosition; } |
60 | ||
61 | private: | |
a99798d2 VS |
62 | wxPoint m_fromPos, m_toPos; |
63 | wxPoint m_fromPrivPos, m_toPrivPos; | |
1338c59a | 64 | const wxHtmlCell *m_fromCell, *m_toCell; |
f65a786f VS |
65 | }; |
66 | ||
67 | ||
68 | ||
69 | enum wxHtmlSelectionState | |
70 | { | |
71 | wxHTML_SEL_OUT, // currently rendered cell is outside the selection | |
72 | wxHTML_SEL_IN, // ... is inside selection | |
73 | wxHTML_SEL_CHANGING // ... is the cell on which selection state changes | |
74 | }; | |
75 | ||
76 | // Selection state is passed to wxHtmlCell::Draw so that it can render itself | |
77 | // differently e.g. when inside text selection or outside it. | |
6acba9a7 | 78 | class WXDLLIMPEXP_HTML wxHtmlRenderingState |
f65a786f VS |
79 | { |
80 | public: | |
ed9d5d17 | 81 | wxHtmlRenderingState() : m_selState(wxHTML_SEL_OUT) {} |
f65a786f | 82 | |
6953da00 | 83 | void SetSelectionState(wxHtmlSelectionState s) { m_selState = s; } |
f65a786f VS |
84 | wxHtmlSelectionState GetSelectionState() const { return m_selState; } |
85 | ||
86 | void SetFgColour(const wxColour& c) { m_fgColour = c; } | |
87 | const wxColour& GetFgColour() const { return m_fgColour; } | |
88 | void SetBgColour(const wxColour& c) { m_bgColour = c; } | |
89 | const wxColour& GetBgColour() const { return m_bgColour; } | |
6953da00 | 90 | |
f65a786f | 91 | private: |
f65a786f VS |
92 | wxHtmlSelectionState m_selState; |
93 | wxColour m_fgColour, m_bgColour; | |
94 | }; | |
95 | ||
ed9d5d17 VS |
96 | |
97 | // HTML rendering customization. This class is used when rendering wxHtmlCells | |
a99798d2 | 98 | // as a callback: |
6acba9a7 | 99 | class WXDLLIMPEXP_HTML wxHtmlRenderingStyle |
ed9d5d17 VS |
100 | { |
101 | public: | |
ed62f740 | 102 | virtual ~wxHtmlRenderingStyle() {} |
ed9d5d17 VS |
103 | virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0; |
104 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0; | |
105 | }; | |
106 | ||
a99798d2 | 107 | // Standard style: |
6acba9a7 | 108 | class WXDLLIMPEXP_HTML wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle |
ed9d5d17 VS |
109 | { |
110 | public: | |
111 | virtual wxColour GetSelectedTextColour(const wxColour& clr); | |
112 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr); | |
113 | }; | |
114 | ||
115 | ||
116 | // Information given to cells when drawing them. Contains rendering state, | |
117 | // selection information and rendering style object that can be used to | |
118 | // customize the output. | |
6acba9a7 | 119 | class WXDLLIMPEXP_HTML wxHtmlRenderingInfo |
ed9d5d17 VS |
120 | { |
121 | public: | |
122 | wxHtmlRenderingInfo() : m_selection(NULL), m_style(NULL) {} | |
123 | ||
124 | void SetSelection(wxHtmlSelection *s) { m_selection = s; } | |
125 | wxHtmlSelection *GetSelection() const { return m_selection; } | |
6953da00 | 126 | |
ed9d5d17 VS |
127 | void SetStyle(wxHtmlRenderingStyle *style) { m_style = style; } |
128 | wxHtmlRenderingStyle& GetStyle() { return *m_style; } | |
129 | ||
130 | wxHtmlRenderingState& GetState() { return m_state; } | |
6953da00 | 131 | |
ed9d5d17 VS |
132 | protected: |
133 | wxHtmlSelection *m_selection; | |
134 | wxHtmlRenderingStyle *m_style; | |
135 | wxHtmlRenderingState m_state; | |
136 | }; | |
137 | ||
138 | ||
f65a786f VS |
139 | // Flags for wxHtmlCell::FindCellByPos |
140 | enum | |
141 | { | |
adf2eb2d VS |
142 | wxHTML_FIND_EXACT = 1, |
143 | wxHTML_FIND_NEAREST_BEFORE = 2, | |
1338c59a | 144 | wxHTML_FIND_NEAREST_AFTER = 4 |
f65a786f VS |
145 | }; |
146 | ||
147 | ||
61233023 VS |
148 | |
149 | ||
f65a786f | 150 | // --------------------------------------------------------------------------- |
5526e819 | 151 | // wxHtmlCell |
f65a786f VS |
152 | // Internal data structure. It represents fragments of parsed |
153 | // HTML page - a word, picture, table, horizontal line and so | |
154 | // on. It is used by wxHtmlWindow to represent HTML page in | |
155 | // memory. | |
156 | // --------------------------------------------------------------------------- | |
5526e819 VS |
157 | |
158 | ||
6acba9a7 | 159 | class WXDLLIMPEXP_HTML wxHtmlCell : public wxObject |
5526e819 | 160 | { |
97494971 VS |
161 | public: |
162 | wxHtmlCell(); | |
163 | virtual ~wxHtmlCell(); | |
164 | ||
165 | void SetParent(wxHtmlContainerCell *p) {m_Parent = p;} | |
166 | wxHtmlContainerCell *GetParent() const {return m_Parent;} | |
167 | ||
168 | int GetPosX() const {return m_PosX;} | |
169 | int GetPosY() const {return m_PosY;} | |
170 | int GetWidth() const {return m_Width;} | |
6953da00 | 171 | |
ca16b7a9 VS |
172 | // Returns the maximum possible length of the cell. |
173 | // Call Layout at least once before using GetMaxTotalWidth() | |
174 | virtual int GetMaxTotalWidth() const { return m_Width; } | |
175 | ||
97494971 VS |
176 | int GetHeight() const {return m_Height;} |
177 | int GetDescent() const {return m_Descent;} | |
d50d561a | 178 | |
b87dd6f5 VS |
179 | // Formatting cells are not visible on the screen, they only alter |
180 | // renderer's state. | |
181 | bool IsFormattingCell() const { return m_Width == 0 && m_Height == 0; } | |
182 | ||
8938133d VS |
183 | const wxString& GetId() const { return m_id; } |
184 | void SetId(const wxString& id) { m_id = id; } | |
97494971 | 185 | |
f65a786f VS |
186 | // returns the link associated with this cell. The position is position |
187 | // within the cell so it varies from 0 to m_Width, from 0 to m_Height | |
61233023 VS |
188 | virtual wxHtmlLinkInfo* GetLink(int WXUNUSED(x) = 0, |
189 | int WXUNUSED(y) = 0) const | |
97494971 VS |
190 | { return m_Link; } |
191 | ||
77bae5e2 VS |
192 | // Returns cursor to be used when mouse is over the cell: |
193 | virtual wxCursor GetCursor() const; | |
194 | ||
61233023 | 195 | // return next cell among parent's cells |
97494971 | 196 | wxHtmlCell *GetNext() const {return m_Next;} |
61233023 VS |
197 | // returns first child cell (if there are any, i.e. if this is container): |
198 | virtual wxHtmlCell* GetFirstChild() const { return NULL; } | |
97494971 | 199 | |
f6010d8f | 200 | // members writing methods |
97494971 VS |
201 | virtual void SetPos(int x, int y) {m_PosX = x, m_PosY = y;} |
202 | void SetLink(const wxHtmlLinkInfo& link); | |
203 | void SetNext(wxHtmlCell *cell) {m_Next = cell;} | |
204 | ||
f65a786f VS |
205 | // 1. adjust cell's width according to the fact that maximal possible width |
206 | // is w. (this has sense when working with horizontal lines, tables | |
207 | // etc.) | |
208 | // 2. prepare layout (=fill-in m_PosX, m_PosY (and sometime m_Height) | |
209 | // members) = place items to fit window, according to the width w | |
97494971 VS |
210 | virtual void Layout(int w); |
211 | ||
212 | // renders the cell | |
f65a786f VS |
213 | virtual void Draw(wxDC& WXUNUSED(dc), |
214 | int WXUNUSED(x), int WXUNUSED(y), | |
215 | int WXUNUSED(view_y1), int WXUNUSED(view_y2), | |
ed9d5d17 | 216 | wxHtmlRenderingInfo& WXUNUSED(info)) {} |
97494971 | 217 | |
f65a786f VS |
218 | // proceed drawing actions in case the cell is not visible (scrolled out of |
219 | // screen). This is needed to change fonts, colors and so on. | |
220 | virtual void DrawInvisible(wxDC& WXUNUSED(dc), | |
221 | int WXUNUSED(x), int WXUNUSED(y), | |
ed9d5d17 | 222 | wxHtmlRenderingInfo& WXUNUSED(info)) {} |
97494971 VS |
223 | |
224 | // This method returns pointer to the FIRST cell for that | |
225 | // the condition | |
226 | // is true. It first checks if the condition is true for this | |
227 | // cell and then calls m_Next->Find(). (Note: it checks | |
228 | // all subcells if the cell is container) | |
229 | // Condition is unique condition identifier (see htmldefs.h) | |
230 | // (user-defined condition IDs should start from 10000) | |
231 | // and param is optional parameter | |
232 | // Example : m_Cell->Find(wxHTML_COND_ISANCHOR, "news"); | |
233 | // returns pointer to anchor news | |
234 | virtual const wxHtmlCell* Find(int condition, const void* param) const; | |
235 | ||
236 | // This function is called when mouse button is clicked over the cell. | |
f6010d8f | 237 | // |
97494971 VS |
238 | // Parent is pointer to wxHtmlWindow that generated the event |
239 | // HINT: if this handling is not enough for you you should use | |
f7b23958 | 240 | // wxHtmlWidgetCell |
97494971 VS |
241 | virtual void OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event); |
242 | ||
f65a786f VS |
243 | // This method used to adjust pagebreak position. The parameter is variable |
244 | // that contains y-coordinate of page break (= horizontal line that should | |
245 | // not be crossed by words, images etc.). If this cell cannot be divided | |
97494971 VS |
246 | // into two pieces (each one on another page) then it moves the pagebreak |
247 | // few pixels up. | |
248 | // | |
249 | // Returned value : true if pagebreak was modified, false otherwise | |
250 | // Usage : while (container->AdjustPagebreak(&p)) {} | |
f65a786f VS |
251 | virtual bool AdjustPagebreak(int *pagebreak, |
252 | int *known_pagebreaks = NULL, | |
253 | int number_of_pages = 0) const; | |
97494971 VS |
254 | |
255 | // Sets cell's behaviour on pagebreaks (see AdjustPagebreak). Default | |
256 | // is true - the cell can be split on two pages | |
79d6c018 | 257 | void SetCanLiveOnPagebreak(bool can) { m_CanLiveOnPagebreak = can; } |
6953da00 | 258 | |
8ba2f3ec VS |
259 | // Can the line be broken before this cell? |
260 | virtual bool IsLinebreakAllowed() const | |
261 | { return !IsFormattingCell(); } | |
97494971 | 262 | |
f6010d8f VZ |
263 | // Returns true for simple == terminal cells, i.e. not composite ones. |
264 | // This if for internal usage only and may disappear in future versions! | |
d53c798c | 265 | virtual bool IsTerminalCell() const { return true; } |
f6010d8f | 266 | |
f65a786f VS |
267 | // Find a cell inside this cell positioned at the given coordinates |
268 | // (relative to this's positions). Returns NULL if no such cell exists. | |
269 | // The flag can be used to specify whether to look for terminal or | |
270 | // nonterminal cells or both. In either case, returned cell is deepest | |
271 | // cell in cells tree that contains [x,y]. | |
272 | virtual wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y, | |
adf2eb2d VS |
273 | unsigned flags = wxHTML_FIND_EXACT) const; |
274 | ||
275 | // Returns absolute position of the cell on HTML canvas | |
276 | wxPoint GetAbsPos() const; | |
277 | ||
278 | // Returns first (last) terminal cell inside this cell. It may return NULL, | |
279 | // but it is rare -- only if there are no terminals in the tree. | |
6953da00 | 280 | virtual wxHtmlCell *GetFirstTerminal() const |
adf2eb2d | 281 | { return wxConstCast(this, wxHtmlCell); } |
6953da00 | 282 | virtual wxHtmlCell *GetLastTerminal() const |
adf2eb2d | 283 | { return wxConstCast(this, wxHtmlCell); } |
f6010d8f | 284 | |
61233023 VS |
285 | // Returns cell's depth, i.e. how far under the root cell it is |
286 | // (if it is the root, depth is 0) | |
287 | unsigned GetDepth() const; | |
6953da00 | 288 | |
61233023 VS |
289 | // Returns true if the cell appears before 'cell' in natural order of |
290 | // cells (= as they are read). If cell A is (grand)parent of cell B, | |
291 | // then both A.IsBefore(B) and B.IsBefore(A) always return true. | |
292 | bool IsBefore(wxHtmlCell *cell) const; | |
6953da00 | 293 | |
61233023 VS |
294 | // Converts the cell into text representation. If sel != NULL then |
295 | // only part of the cell inside the selection is converted. | |
296 | virtual wxString ConvertToText(wxHtmlSelection *WXUNUSED(sel)) const | |
297 | { return wxEmptyString; } | |
298 | ||
97494971 VS |
299 | protected: |
300 | wxHtmlCell *m_Next; | |
301 | // pointer to the next cell | |
302 | wxHtmlContainerCell *m_Parent; | |
f6010d8f | 303 | // pointer to parent cell |
97494971 VS |
304 | long m_Width, m_Height, m_Descent; |
305 | // dimensions of fragment | |
306 | // m_Descent is used to position text&images.. | |
307 | long m_PosX, m_PosY; | |
308 | // position where the fragment is drawn | |
309 | wxHtmlLinkInfo *m_Link; | |
f6010d8f | 310 | // destination address if this fragment is hypertext link, NULL otherwise |
97494971 VS |
311 | bool m_CanLiveOnPagebreak; |
312 | // true if this cell can be placed on pagebreak, false otherwise | |
8938133d VS |
313 | wxString m_id; |
314 | // unique identifier of the cell, generated from "id" property of tags | |
22f3361e | 315 | |
4f44ea36 | 316 | DECLARE_ABSTRACT_CLASS(wxHtmlCell) |
22f3361e | 317 | DECLARE_NO_COPY_CLASS(wxHtmlCell) |
5526e819 VS |
318 | }; |
319 | ||
320 | ||
321 | ||
322 | ||
61233023 | 323 | // ---------------------------------------------------------------------------- |
5526e819 | 324 | // Inherited cells: |
61233023 | 325 | // ---------------------------------------------------------------------------- |
5526e819 VS |
326 | |
327 | ||
61233023 | 328 | // ---------------------------------------------------------------------------- |
5526e819 VS |
329 | // wxHtmlWordCell |
330 | // Single word in input stream. | |
61233023 | 331 | // ---------------------------------------------------------------------------- |
5526e819 | 332 | |
6acba9a7 | 333 | class WXDLLIMPEXP_HTML wxHtmlWordCell : public wxHtmlCell |
5526e819 | 334 | { |
97494971 | 335 | public: |
fbfb8bcc | 336 | wxHtmlWordCell(const wxString& word, const wxDC& dc); |
f65a786f | 337 | void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
ed9d5d17 | 338 | wxHtmlRenderingInfo& info); |
77bae5e2 | 339 | wxCursor GetCursor() const; |
61233023 | 340 | wxString ConvertToText(wxHtmlSelection *sel) const; |
8ba2f3ec VS |
341 | bool IsLinebreakAllowed() const { return m_allowLinebreak; } |
342 | ||
343 | void SetPreviousWord(wxHtmlWordCell *cell); | |
60e87cb1 | 344 | |
97494971 | 345 | protected: |
fbfb8bcc VZ |
346 | void SetSelectionPrivPos(const wxDC& dc, wxHtmlSelection *s) const; |
347 | void Split(const wxDC& dc, | |
169ee861 | 348 | const wxPoint& selFrom, const wxPoint& selTo, |
a99798d2 | 349 | unsigned& pos1, unsigned& pos2) const; |
6953da00 | 350 | |
97494971 | 351 | wxString m_Word; |
8ba2f3ec | 352 | bool m_allowLinebreak; |
fc7a2a60 | 353 | |
4f44ea36 | 354 | DECLARE_ABSTRACT_CLASS(wxHtmlWordCell) |
fc7a2a60 | 355 | DECLARE_NO_COPY_CLASS(wxHtmlWordCell) |
5526e819 VS |
356 | }; |
357 | ||
358 | ||
359 | ||
360 | ||
361 | ||
f65a786f VS |
362 | // Container contains other cells, thus forming tree structure of rendering |
363 | // elements. Basic code of layout algorithm is contained in this class. | |
6acba9a7 | 364 | class WXDLLIMPEXP_HTML wxHtmlContainerCell : public wxHtmlCell |
5526e819 | 365 | { |
97494971 VS |
366 | public: |
367 | wxHtmlContainerCell(wxHtmlContainerCell *parent); | |
368 | ~wxHtmlContainerCell(); | |
369 | ||
370 | virtual void Layout(int w); | |
f65a786f | 371 | virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
ed9d5d17 | 372 | wxHtmlRenderingInfo& info); |
f65a786f | 373 | virtual void DrawInvisible(wxDC& dc, int x, int y, |
ed9d5d17 | 374 | wxHtmlRenderingInfo& info); |
f2034f1b | 375 | virtual bool AdjustPagebreak(int *pagebreak, int *known_pagebreaks = NULL, int number_of_pages = 0) const; |
97494971 VS |
376 | |
377 | // insert cell at the end of m_Cells list | |
378 | void InsertCell(wxHtmlCell *cell); | |
379 | ||
380 | // sets horizontal/vertical alignment | |
381 | void SetAlignHor(int al) {m_AlignHor = al; m_LastLayout = -1;} | |
382 | int GetAlignHor() const {return m_AlignHor;} | |
383 | void SetAlignVer(int al) {m_AlignVer = al; m_LastLayout = -1;} | |
384 | int GetAlignVer() const {return m_AlignVer;} | |
385 | ||
386 | // sets left-border indentation. units is one of wxHTML_UNITS_* constants | |
387 | // what is combination of wxHTML_INDENT_* | |
388 | void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS); | |
389 | // returns the indentation. ind is one of wxHTML_INDENT_* constants | |
390 | int GetIndent(int ind) const; | |
391 | // returns type of value returned by GetIndent(ind) | |
392 | int GetIndentUnits(int ind) const; | |
393 | ||
394 | // sets alignment info based on given tag's params | |
395 | void SetAlign(const wxHtmlTag& tag); | |
396 | // sets floating width adjustment | |
397 | // (examples : 32 percent of parent container, | |
398 | // -15 pixels percent (this means 100 % - 15 pixels) | |
399 | void SetWidthFloat(int w, int units) {m_WidthFloat = w; m_WidthFloatUnits = units; m_LastLayout = -1;} | |
400 | void SetWidthFloat(const wxHtmlTag& tag, double pixel_scale = 1.0); | |
401 | // sets minimal height of this container. | |
402 | void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP) {m_MinHeight = h; m_MinHeightAlign = align; m_LastLayout = -1;} | |
403 | ||
d53c798c | 404 | void SetBackgroundColour(const wxColour& clr) {m_UseBkColour = true; m_BkColour = clr;} |
2b5f62a0 VZ |
405 | // returns background colour (of wxNullColour if none set), so that widgets can |
406 | // adapt to it: | |
407 | wxColour GetBackgroundColour(); | |
d53c798c | 408 | void SetBorder(const wxColour& clr1, const wxColour& clr2) {m_UseBorder = true; m_BorderColour1 = clr1, m_BorderColour2 = clr2;} |
97494971 VS |
409 | virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0) const; |
410 | virtual const wxHtmlCell* Find(int condition, const void* param) const; | |
411 | virtual void OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event); | |
412 | ||
61233023 VS |
413 | virtual wxHtmlCell* GetFirstChild() const { return m_Cells; } |
414 | #if WXWIN_COMPATIBILITY_2_4 | |
415 | wxDEPRECATED( wxHtmlCell* GetFirstCell() const ); | |
416 | #endif | |
97494971 | 417 | |
f6010d8f | 418 | // see comment in wxHtmlCell about this method |
d53c798c | 419 | virtual bool IsTerminalCell() const { return false; } |
f6010d8f | 420 | |
f65a786f | 421 | virtual wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y, |
adf2eb2d | 422 | unsigned flags = wxHTML_FIND_EXACT) const; |
6953da00 | 423 | |
adf2eb2d VS |
424 | virtual wxHtmlCell *GetFirstTerminal() const; |
425 | virtual wxHtmlCell *GetLastTerminal() const; | |
6953da00 WS |
426 | |
427 | ||
ace0fab4 VS |
428 | // Removes indentation on top or bottom of the container (i.e. above or |
429 | // below first/last terminal cell). For internal use only. | |
430 | void RemoveExtraSpacing(bool top, bool bottom); | |
f6010d8f | 431 | |
ca16b7a9 VS |
432 | // Returns the maximum possible length of the container. |
433 | // Call Layout at least once before using GetMaxTotalWidth() | |
434 | virtual int GetMaxTotalWidth() const { return m_MaxTotalWidth; } | |
435 | ||
f65a786f | 436 | protected: |
ed9d5d17 | 437 | void UpdateRenderingStatePre(wxHtmlRenderingInfo& info, |
f65a786f | 438 | wxHtmlCell *cell) const; |
ed9d5d17 | 439 | void UpdateRenderingStatePost(wxHtmlRenderingInfo& info, |
f65a786f | 440 | wxHtmlCell *cell) const; |
6953da00 | 441 | |
97494971 VS |
442 | protected: |
443 | int m_IndentLeft, m_IndentRight, m_IndentTop, m_IndentBottom; | |
444 | // indentation of subcells. There is always m_Indent pixels | |
445 | // big space between given border of the container and the subcells | |
446 | // it m_Indent < 0 it is in PERCENTS, otherwise it is in pixels | |
447 | int m_MinHeight, m_MinHeightAlign; | |
448 | // minimal height. | |
449 | wxHtmlCell *m_Cells, *m_LastCell; | |
450 | // internal cells, m_Cells points to the first of them, m_LastCell to the last one. | |
451 | // (LastCell is needed only to speed-up InsertCell) | |
452 | int m_AlignHor, m_AlignVer; | |
453 | // alignment horizontal and vertical (left, center, right) | |
454 | int m_WidthFloat, m_WidthFloatUnits; | |
455 | // width float is used in adjustWidth | |
456 | bool m_UseBkColour; | |
457 | wxColour m_BkColour; | |
458 | // background color of this container | |
459 | bool m_UseBorder; | |
460 | wxColour m_BorderColour1, m_BorderColour2; | |
461 | // borders color of this container | |
462 | int m_LastLayout; | |
463 | // if != -1 then call to Layout may be no-op | |
464 | // if previous call to Layout has same argument | |
ca16b7a9 VS |
465 | int m_MaxTotalWidth; |
466 | // Maximum possible length if ignoring line wrap | |
22f3361e | 467 | |
6953da00 | 468 | |
4f44ea36 | 469 | DECLARE_ABSTRACT_CLASS(wxHtmlContainerCell) |
22f3361e | 470 | DECLARE_NO_COPY_CLASS(wxHtmlContainerCell) |
5526e819 VS |
471 | }; |
472 | ||
61233023 VS |
473 | #if WXWIN_COMPATIBILITY_2_4 |
474 | inline wxHtmlCell* wxHtmlContainerCell::GetFirstCell() const | |
475 | { return GetFirstChild(); } | |
476 | #endif | |
5526e819 VS |
477 | |
478 | ||
479 | ||
480 | ||
61233023 | 481 | // --------------------------------------------------------------------------- |
5526e819 VS |
482 | // wxHtmlColourCell |
483 | // Color changer. | |
61233023 | 484 | // --------------------------------------------------------------------------- |
5526e819 | 485 | |
6acba9a7 | 486 | class WXDLLIMPEXP_HTML wxHtmlColourCell : public wxHtmlCell |
5526e819 | 487 | { |
97494971 VS |
488 | public: |
489 | wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND) : wxHtmlCell() {m_Colour = clr; m_Flags = flags;} | |
f65a786f | 490 | virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
ed9d5d17 | 491 | wxHtmlRenderingInfo& info); |
f65a786f | 492 | virtual void DrawInvisible(wxDC& dc, int x, int y, |
ed9d5d17 | 493 | wxHtmlRenderingInfo& info); |
97494971 VS |
494 | |
495 | protected: | |
496 | wxColour m_Colour; | |
497 | unsigned m_Flags; | |
fc7a2a60 | 498 | |
4f44ea36 | 499 | DECLARE_ABSTRACT_CLASS(wxHtmlColourCell) |
fc7a2a60 | 500 | DECLARE_NO_COPY_CLASS(wxHtmlColourCell) |
5526e819 VS |
501 | }; |
502 | ||
503 | ||
504 | ||
505 | ||
506 | //-------------------------------------------------------------------------------- | |
507 | // wxHtmlFontCell | |
508 | // Sets actual font used for text rendering | |
509 | //-------------------------------------------------------------------------------- | |
510 | ||
6acba9a7 | 511 | class WXDLLIMPEXP_HTML wxHtmlFontCell : public wxHtmlCell |
5526e819 | 512 | { |
97494971 VS |
513 | public: |
514 | wxHtmlFontCell(wxFont *font) : wxHtmlCell() { m_Font = (*font); } | |
f65a786f | 515 | virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
ed9d5d17 | 516 | wxHtmlRenderingInfo& info); |
f65a786f | 517 | virtual void DrawInvisible(wxDC& dc, int x, int y, |
ed9d5d17 | 518 | wxHtmlRenderingInfo& info); |
60e87cb1 | 519 | |
97494971 VS |
520 | protected: |
521 | wxFont m_Font; | |
fc7a2a60 | 522 | |
4f44ea36 | 523 | DECLARE_ABSTRACT_CLASS(wxHtmlFontCell) |
fc7a2a60 | 524 | DECLARE_NO_COPY_CLASS(wxHtmlFontCell) |
5526e819 VS |
525 | }; |
526 | ||
527 | ||
528 | ||
529 | ||
530 | ||
531 | ||
532 | //-------------------------------------------------------------------------------- | |
533 | // wxHtmlwidgetCell | |
534 | // This cell is connected with wxWindow object | |
535 | // You can use it to insert windows into HTML page | |
536 | // (buttons, input boxes etc.) | |
537 | //-------------------------------------------------------------------------------- | |
538 | ||
6acba9a7 | 539 | class WXDLLIMPEXP_HTML wxHtmlWidgetCell : public wxHtmlCell |
5526e819 | 540 | { |
97494971 VS |
541 | public: |
542 | // !!! wnd must have correct parent! | |
543 | // if w != 0 then the m_Wnd has 'floating' width - it adjust | |
544 | // it's width according to parent container's width | |
545 | // (w is percent of parent's width) | |
546 | wxHtmlWidgetCell(wxWindow *wnd, int w = 0); | |
547 | ~wxHtmlWidgetCell() { m_Wnd->Destroy(); } | |
f65a786f | 548 | virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
ed9d5d17 | 549 | wxHtmlRenderingInfo& info); |
f65a786f | 550 | virtual void DrawInvisible(wxDC& dc, int x, int y, |
ed9d5d17 | 551 | wxHtmlRenderingInfo& info); |
97494971 VS |
552 | virtual void Layout(int w); |
553 | ||
554 | protected: | |
555 | wxWindow* m_Wnd; | |
556 | int m_WidthFloat; | |
557 | // width float is used in adjustWidth (it is in percents) | |
22f3361e | 558 | |
4f44ea36 | 559 | DECLARE_ABSTRACT_CLASS(wxHtmlWidgetCell) |
22f3361e | 560 | DECLARE_NO_COPY_CLASS(wxHtmlWidgetCell) |
5526e819 VS |
561 | }; |
562 | ||
563 | ||
564 | ||
846914d1 VS |
565 | //-------------------------------------------------------------------------------- |
566 | // wxHtmlLinkInfo | |
567 | // Internal data structure. It represents hypertext link | |
568 | //-------------------------------------------------------------------------------- | |
569 | ||
6acba9a7 | 570 | class WXDLLIMPEXP_HTML wxHtmlLinkInfo : public wxObject |
846914d1 | 571 | { |
97494971 VS |
572 | public: |
573 | wxHtmlLinkInfo() : wxObject() | |
574 | { m_Href = m_Target = wxEmptyString; m_Event = NULL, m_Cell = NULL; } | |
575 | wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString) : wxObject() | |
576 | { m_Href = href; m_Target = target; m_Event = NULL, m_Cell = NULL; } | |
577 | wxHtmlLinkInfo(const wxHtmlLinkInfo& l) : wxObject() | |
578 | { m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event; | |
579 | m_Cell = l.m_Cell; } | |
580 | wxHtmlLinkInfo& operator=(const wxHtmlLinkInfo& l) | |
581 | { m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event; | |
582 | m_Cell = l.m_Cell; return *this; } | |
583 | ||
584 | void SetEvent(const wxMouseEvent *e) { m_Event = e; } | |
585 | void SetHtmlCell(const wxHtmlCell *e) { m_Cell = e; } | |
586 | ||
587 | wxString GetHref() const { return m_Href; } | |
588 | wxString GetTarget() const { return m_Target; } | |
589 | const wxMouseEvent* GetEvent() const { return m_Event; } | |
590 | const wxHtmlCell* GetHtmlCell() const { return m_Cell; } | |
591 | ||
592 | private: | |
593 | wxString m_Href, m_Target; | |
594 | const wxMouseEvent *m_Event; | |
595 | const wxHtmlCell *m_Cell; | |
846914d1 VS |
596 | }; |
597 | ||
598 | ||
599 | ||
61233023 VS |
600 | // ---------------------------------------------------------------------------- |
601 | // wxHtmlTerminalCellsInterator | |
602 | // ---------------------------------------------------------------------------- | |
603 | ||
6acba9a7 | 604 | class WXDLLIMPEXP_HTML wxHtmlTerminalCellsInterator |
61233023 VS |
605 | { |
606 | public: | |
607 | wxHtmlTerminalCellsInterator(const wxHtmlCell *from, const wxHtmlCell *to) | |
608 | : m_to(to), m_pos(from) {} | |
609 | ||
c9c61efb | 610 | operator bool() const { return m_pos != NULL; } |
61233023 VS |
611 | const wxHtmlCell* operator++(); |
612 | const wxHtmlCell* operator->() const { return m_pos; } | |
613 | const wxHtmlCell* operator*() const { return m_pos; } | |
614 | ||
615 | private: | |
616 | const wxHtmlCell *m_to, *m_pos; | |
617 | }; | |
618 | ||
619 | ||
846914d1 VS |
620 | |
621 | #endif // wxUSE_HTML | |
5526e819 | 622 | |
69941f05 | 623 | #endif // _WX_HTMLCELL_H_ |
5526e819 | 624 |