1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/htmlcell.h
3 // Purpose: documentation for wxHtmlColourCell class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxHtmlColourCell
11 @headerfile htmlcell.h wx/html/htmlcell.h
13 This cell changes the colour of either the background or the foreground.
18 class wxHtmlColourCell
: public wxHtmlCell
27 Can be one of following:
50 change background color
52 wxHtmlColourCell(wxColour clr
, int flags
= wxHTML_CLR_FOREGROUND
);
57 @class wxHtmlWidgetCell
58 @headerfile htmlcell.h wx/html/htmlcell.h
60 wxHtmlWidgetCell is a class that provides a connection between HTML cells and
61 widgets (an object derived
62 from wxWindow). You can use it to display things like forms, input boxes etc.
65 wxHtmlWidgetCell takes care of resizing and moving window.
70 class wxHtmlWidgetCell
: public wxHtmlCell
77 Connected window. It is parent window must be the wxHtmlWindow object within
78 which it is displayed!
80 Floating width. If non-zero width of wnd window is adjusted so that it is
81 always w percents of parent container's width. (For example w = 100 means
83 will always have same width as parent container)
85 wxHtmlWidgetCell(wxWindow
* wnd
, int w
= 0);
91 @headerfile htmlcell.h wx/html/htmlcell.h
93 Internal data structure. It represents fragments of parsed HTML
94 page, the so-called @b cell - a word, picture, table, horizontal line and so on.
95 It is used by wxHtmlWindow and
96 wxHtmlWinParser to represent HTML page in memory.
98 You can divide cells into two groups : @e visible cells with non-zero width and
99 height and @e helper cells (usually with zero width and height) that
100 perform special actions such as color or font change.
106 @ref overview_cells "Cells Overview", wxHtmlContainerCell
108 class wxHtmlCell
: public wxObject
117 This method is used to adjust pagebreak position. The parameter is
118 variable that contains y-coordinate of page break (= horizontal line that
119 should not be crossed by words, images etc.). If this cell cannot be divided
120 into two pieces (each one on another page) then it moves the pagebreak
122 Returns @true if pagebreak was modified, @false otherwise
125 virtual bool AdjustPagebreak(int* pagebreak
);
131 Device context to which the cell is to be drawn
133 Coordinates of parent's upper left corner (origin). You must
134 add this to m_PosX,m_PosY when passing coordinates to dc's methods
135 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
137 y-coord of the first line visible in window. This is
138 used to optimize rendering speed
140 y-coord of the last line visible in window. This is
141 used to optimize rendering speed
143 virtual void Draw(wxDC
& dc
, int x
, int y
, int view_y1
,
147 This method is called instead of Draw() when the
148 cell is certainly out of the screen (and thus invisible). This is not
149 nonsense - some tags (like wxHtmlColourCell
150 or font setter) must be drawn even if they are invisible!
153 Device context to which the cell is to be drawn
155 Coordinates of parent's upper left corner. You must
156 add this to m_PosX,m_PosY when passing coordinates to dc's methods
157 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
159 virtual void DrawInvisible(wxDC
& dc
, int x
, int y
);
162 Returns pointer to itself if this cell matches condition (or if any of the cells
163 following in the list matches), @NULL otherwise.
164 (In other words if you call top-level container's Find it will
165 return pointer to the first cell that matches the condition)
166 It is recommended way how to obtain pointer to particular cell or
167 to cell of some type (e.g. wxHtmlAnchorCell reacts on
168 wxHTML_COND_ISANCHOR condition)
171 Unique integer identifier of condition
175 virtual const wxHtmlCell
* Find(int condition
, const void* param
);
178 Returns descent value of the cell (m_Descent member).
181 int GetDescent() const;
184 Returns pointer to the first cell in the list.
185 You can then use child's GetNext()
186 method to obtain pointer to the next cell in list.
187 @b Note: This shouldn't be used by the end user. If you need some way of
188 finding particular cell in the list, try Find() method
191 wxHtmlCell
* GetFirstChild();
194 Returns height of the cell (m_Height member).
196 int GetHeight() const;
199 Returns unique cell identifier if there is any, empty string otherwise.
201 virtual wxString
GetId() const;
204 Returns hypertext link if associated with this cell or @NULL otherwise.
206 (Note: this makes sense only for visible tags).
209 Coordinates of position where the user pressed mouse button.
210 These coordinates are used e.g. by COLORMAP. Values are relative to the
211 upper left corner of THIS cell (i.e. from 0 to m_Width or m_Height)
213 virtual wxHtmlLinkInfo
* GetLink(int x
= 0, int y
= 0) const;
216 Returns cursor to show when mouse pointer is over the cell.
219 interface to the parent HTML window
221 virtual wxCursor
GetMouseCursor(wxHtmlWindowInterface
* window
);
224 Returns pointer to the next cell in list (see htmlcell.h if you're
225 interested in details).
227 wxHtmlCell
* GetNext() const;
230 Returns pointer to parent container.
232 wxHtmlContainerCell
* GetParent() const;
235 Returns X position within parent (the value is relative to parent's
236 upper left corner). The returned value is meaningful only if
237 parent's Layout() was called before!
242 Returns Y position within parent (the value is relative to parent's
243 upper left corner). The returned value is meaningful only if
244 parent's Layout() was called before!
249 Returns width of the cell (m_Width member).
251 int GetWidth() const;
254 This method performs two actions:
255 adjusts the cell's width according to the fact that maximal possible width is
257 (this has sense when working with horizontal lines, tables etc.)
258 prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
259 based on actual width @e w
260 It must be called before displaying cells structure because
261 m_PosX and m_PosY are undefined (or invalid)
262 before calling Layout.
264 virtual void Layout(int w
);
267 This function is simple event handler. Each time the user clicks mouse button
268 over a cell within wxHtmlWindow this method of that
269 cell is called. Default behavior is to call
270 wxHtmlWindow::LoadPage.
273 interface to the parent HTML window
275 coordinates of mouse click (this is relative to cell's origin
277 mouse event that triggered the call
279 @returns @true if a link was clicked, @false otherwise.
281 virtual bool ProcessMouseClick(wxHtmlWindowInterface
* window
,
283 const wxMouseEvent
& event
);
286 Sets unique cell identifier. Default value is no identifier, i.e. empty string.
288 void SetId(const wxString
& id
);
291 Sets the hypertext link associated with this cell. (Default value
292 is wxHtmlLinkInfo("", "") (no link))
294 void SetLink(const wxHtmlLinkInfo
& link
);
297 Sets the next cell in the list. This shouldn't be called by user - it is
298 to be used only by wxHtmlContainerCell::InsertCell.
300 void SetNext(wxHtmlCell cell
);
303 Sets parent container of this cell. This is called from
304 wxHtmlContainerCell::InsertCell.
306 void SetParent(wxHtmlContainerCell p
);
309 Sets the cell's position within parent container.
311 void SetPos(int x
, int y
);
316 @class wxHtmlContainerCell
317 @headerfile htmlcell.h wx/html/htmlcell.h
319 The wxHtmlContainerCell class is an implementation of a cell that may
320 contain more cells in it. It is heavily used in the wxHTML layout algorithm.
326 @ref overview_cells "Cells Overview"
328 class wxHtmlContainerCell
: public wxHtmlCell
332 Constructor. @a parent is pointer to parent container or @NULL.
334 wxHtmlContainerCell(wxHtmlContainerCell parent
);
337 Returns container's horizontal alignment.
339 int GetAlignHor() const;
342 Returns container's vertical alignment.
344 int GetAlignVer() const;
347 Returns the background colour of the container or @c wxNullColour if no
351 wxColour
GetBackgroundColour();
354 Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
355 @b Note: You must call GetIndentUnits()
356 with same @a ind parameter in order to correctly interpret the returned integer
358 It is NOT always in pixels!
360 int GetIndent(int ind
) const;
363 Returns the units of indentation for @a ind where @a ind is one
364 of the @b wxHTML_INDENT_* constants.
366 int GetIndentUnits(int ind
) const;
369 Inserts new cell into the container.
371 void InsertCell(wxHtmlCell cell
);
374 Sets the container's alignment (both horizontal and vertical) according to
375 the values stored in @e tag. (Tags @c ALIGN parameter is extracted.) In fact
376 it is only a front-end to SetAlignHor()
379 void SetAlign(const wxHtmlTag
& tag
);
382 Sets the container's @e horizontal alignment. During wxHtmlCell::Layout
383 each line is aligned according to @a al value.
386 new horizontal alignment. May be one of these values:
398 lines are left-aligned (default)
431 lines are right-aligned
433 void SetAlignHor(int al
);
436 Sets the container's @e vertical alignment. This is per-line alignment!
439 new vertical alignment. May be one of these values:
451 cells are over the line (default)
462 cells are centered on line
473 cells are under the line
475 void SetAlignVer(int al
);
478 Sets the background colour for this container.
480 void SetBackgroundColour(const wxColour
& clr
);
483 Sets the border (frame) colours. A border is a rectangle around the container.
486 Colour of top and left lines
488 Colour of bottom and right lines
490 void SetBorder(const wxColour
& clr1
, const wxColour
& clr2
);
493 Sets the indentation (free space between borders of container and subcells).
498 Determines which of the four borders we're setting. It is OR
499 combination of following constants:
550 wxHTML_INDENT_HORIZONTAL
561 wxHTML_INDENT_VERTICAL
579 Units of i. This parameter affects interpretation of value.
591 i is number of pixels
602 i is interpreted as percents of width
605 void SetIndent(int i
, int what
, int units
= wxHTML_UNITS_PIXELS
);
608 Sets minimal height of the container.
609 When container's wxHtmlCell::Layout is called, m_Height
610 is set depending on layout of subcells to the height of area covered
611 by layed-out subcells. Calling this method guarantees you that the height
612 of container is never smaller than @a h - even if the subcells cover
618 If height of the container is lower than the minimum height, empty space
620 somewhere in order to ensure minimal height. This parameter is one of
622 wxHTML_ALIGN_BOTTOM, wxHTML_ALIGN_CENTER. It refers to the contents, not to
626 void SetMinHeight(int h
, int align
= wxHTML_ALIGN_TOP
);
630 Sets floating width adjustment.
631 The normal behaviour of container is that its width is the same as the width of
632 parent container (and thus you can have only one sub-container per line).
633 You can change this by setting FWA.
634 @a pixel_scale is number of real pixels that equals to 1 HTML pixel.
637 Width of the container. If the value is negative it means
638 complement to full width of parent container (e.g.
639 SetWidthFloat(-50, wxHTML_UNITS_PIXELS) sets the width
640 of container to parent's width minus 50 pixels. This is useful when
641 creating tables - you can call SetWidthFloat(50) and SetWidthFloat(-50))
643 Units of w This parameter affects the interpretation of value.
655 w is number of pixels
666 w is interpreted as percents of width
669 In the second version of method, w and units
670 info is extracted from tag's WIDTH parameter.
672 void SetWidthFloat(int w
, int units
);
673 void SetWidthFloat(const wxHtmlTag
& tag
,
674 double pixel_scale
= 1.0);
680 @class wxHtmlLinkInfo
681 @headerfile htmlcell.h wx/html/htmlcell.h
683 This class stores all necessary information about hypertext
684 links (as represented by @c A tag in HTML documents). In
685 current implementation it stores URL and target frame name.
686 @e Note that frames are not currently supported by wxHTML!
691 class wxHtmlLinkInfo
: public wxObject
696 Construct hypertext link from HREF (aka URL) and TARGET (name of target
700 wxHtmlLinkInfo(const wxString
& href
,
701 const wxString
& target
= wxEmptyString
);
705 Return pointer to event that generated OnLinkClicked event. Valid
706 only within wxHtmlWindow::OnLinkClicked,
709 const wxMouseEvent
* GetEvent();
712 Return @e HREF value of the @c A tag.
717 Return pointer to the cell that was clicked. Valid
718 only within wxHtmlWindow::OnLinkClicked,
721 const wxHtmlCell
* GetHtmlCell();
724 Return @e TARGET value of the @c A tag (this value
725 is used to specify in which frame should be the page pointed
726 by @ref gethref() Href opened).
728 wxString
GetTarget();