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