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