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