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