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