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