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