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