1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/htmlcell.h
3 // Purpose: interface of wxHtmlColourCell
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
);
58 @class wxHtmlWidgetCell
59 @headerfile htmlcell.h wx/html/htmlcell.h
61 wxHtmlWidgetCell is a class that provides a connection between HTML cells and
62 widgets (an object derived
63 from wxWindow). You can use it to display things like forms, input boxes etc.
66 wxHtmlWidgetCell takes care of resizing and moving window.
71 class wxHtmlWidgetCell
: public wxHtmlCell
78 Connected window. It is parent window must be the wxHtmlWindow object within
79 which it is displayed!
81 Floating width. If non-zero width of wnd window is adjusted so that it is
82 always w percents of parent container's width. (For example w = 100 means
84 will always have same width as parent container)
86 wxHtmlWidgetCell(wxWindow
* wnd
, int w
= 0);
93 @headerfile htmlcell.h wx/html/htmlcell.h
95 Internal data structure. It represents fragments of parsed HTML
96 page, the so-called @b cell - a word, picture, table, horizontal line and so on.
97 It is used by wxHtmlWindow and
98 wxHtmlWinParser to represent HTML page in memory.
100 You can divide cells into two groups : @e visible cells with non-zero width and
101 height and @e helper cells (usually with zero width and height) that
102 perform special actions such as color or font change.
107 @see @ref overview_cells "Cells Overview", wxHtmlContainerCell
109 class wxHtmlCell
: public wxObject
118 This method is used to adjust pagebreak position. The parameter is
119 variable that contains y-coordinate of page break (= horizontal line that
120 should not be crossed by words, images etc.). If this cell cannot be divided
121 into two pieces (each one on another page) then it moves the pagebreak
123 Returns @true if pagebreak was modified, @false otherwise
126 virtual bool AdjustPagebreak(int* pagebreak
);
132 Device context to which the cell is to be drawn
134 Coordinates of parent's upper left corner (origin). You must
135 add this to m_PosX,m_PosY when passing coordinates to dc's methods
136 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
138 y-coord of the first line visible in window. This is
139 used to optimize rendering speed
141 y-coord of the last line visible in window. This is
142 used to optimize rendering speed
144 virtual void Draw(wxDC
& dc
, int x
, int y
, int view_y1
,
148 This method is called instead of Draw() when the
149 cell is certainly out of the screen (and thus invisible). This is not
150 nonsense - some tags (like wxHtmlColourCell
151 or font setter) must be drawn even if they are invisible!
154 Device context to which the cell is to be drawn
156 Coordinates of parent's upper left corner. You must
157 add this to m_PosX,m_PosY when passing coordinates to dc's methods
158 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
160 virtual void DrawInvisible(wxDC
& dc
, int x
, int y
);
163 Returns pointer to itself if this cell matches condition (or if any of the cells
164 following in the list matches), @NULL otherwise.
165 (In other words if you call top-level container's Find it will
166 return pointer to the first cell that matches the condition)
167 It is recommended way how to obtain pointer to particular cell or
168 to cell of some type (e.g. wxHtmlAnchorCell reacts on
169 wxHTML_COND_ISANCHOR condition)
172 Unique integer identifier of condition
176 virtual const wxHtmlCell
* Find(int condition
, const void* param
);
179 Returns descent value of the cell (m_Descent member).
182 int GetDescent() const;
185 Returns pointer to the first cell in the list.
186 You can then use child's GetNext()
187 method to obtain pointer to the next cell in list.
188 @note This shouldn't be used by the end user. If you need some way of
189 finding particular cell in the list, try Find() method
192 wxHtmlCell
* GetFirstChild();
195 Returns height of the cell (m_Height member).
197 int GetHeight() const;
200 Returns unique cell identifier if there is any, empty string otherwise.
202 virtual wxString
GetId() const;
205 Returns hypertext link if associated with this cell or @NULL otherwise.
207 (Note: this makes sense only for visible tags).
210 Coordinates of position where the user pressed mouse button.
211 These coordinates are used e.g. by COLORMAP. Values are relative to the
212 upper left corner of THIS cell (i.e. from 0 to m_Width or m_Height)
214 virtual wxHtmlLinkInfo
* GetLink(int x
= 0, int y
= 0) const;
217 Returns cursor to show when mouse pointer is over the cell.
220 interface to the parent HTML window
222 virtual wxCursor
GetMouseCursor(wxHtmlWindowInterface
* window
);
225 Returns pointer to the next cell in list (see htmlcell.h if you're
226 interested in details).
228 wxHtmlCell
* GetNext() const;
231 Returns pointer to parent container.
233 wxHtmlContainerCell
* GetParent() const;
236 Returns X position within parent (the value is relative to parent's
237 upper left corner). The returned value is meaningful only if
238 parent's Layout() was called before!
243 Returns Y position within parent (the value is relative to parent's
244 upper left corner). The returned value is meaningful only if
245 parent's Layout() was called before!
250 Returns width of the cell (m_Width member).
252 int GetWidth() const;
255 This method performs two actions:
256 adjusts the cell's width according to the fact that maximal possible width is
258 (this has sense when working with horizontal lines, tables etc.)
259 prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
260 based on actual width @e w
261 It must be called before displaying cells structure because
262 m_PosX and m_PosY are undefined (or invalid)
263 before calling Layout.
265 virtual void Layout(int w
);
268 This function is simple event handler. Each time the user clicks mouse button
269 over a cell within wxHtmlWindow this method of that
270 cell is called. Default behavior is to call
271 wxHtmlWindow::LoadPage.
274 interface to the parent HTML window
276 coordinates of mouse click (this is relative to cell's origin
278 mouse event that triggered the call
280 @returns @true if a link was clicked, @false otherwise.
282 virtual bool ProcessMouseClick(wxHtmlWindowInterface
* window
,
284 const wxMouseEvent
& event
);
287 Sets unique cell identifier. Default value is no identifier, i.e. empty string.
289 void SetId(const wxString
& id
);
292 Sets the hypertext link associated with this cell. (Default value
293 is wxHtmlLinkInfo("", "") (no link))
295 void SetLink(const wxHtmlLinkInfo
& link
);
298 Sets the next cell in the list. This shouldn't be called by user - it is
299 to be used only by wxHtmlContainerCell::InsertCell.
301 void SetNext(wxHtmlCell cell
);
304 Sets parent container of this cell. This is called from
305 wxHtmlContainerCell::InsertCell.
307 void SetParent(wxHtmlContainerCell p
);
310 Sets the cell's position within parent container.
312 void SetPos(int x
, int y
);
318 @class wxHtmlContainerCell
319 @headerfile htmlcell.h wx/html/htmlcell.h
321 The wxHtmlContainerCell class is an implementation of a cell that may
322 contain more cells in it. It is heavily used in the wxHTML layout algorithm.
327 @see @ref overview_cells "Cells Overview"
329 class wxHtmlContainerCell
: public wxHtmlCell
333 Constructor. @a parent is pointer to parent container or @NULL.
335 wxHtmlContainerCell(wxHtmlContainerCell parent
);
338 Returns container's horizontal alignment.
340 int GetAlignHor() const;
343 Returns container's vertical alignment.
345 int GetAlignVer() const;
348 Returns the background colour of the container or @c wxNullColour if no
352 wxColour
GetBackgroundColour();
355 Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
356 @note You must call GetIndentUnits()
357 with same @a ind parameter in order to correctly interpret the returned integer
359 It is NOT always in pixels!
361 int GetIndent(int ind
) const;
364 Returns the units of indentation for @a ind where @a ind is one
365 of the @b wxHTML_INDENT_* constants.
367 int GetIndentUnits(int ind
) const;
370 Inserts new cell into the container.
372 void InsertCell(wxHtmlCell cell
);
375 Sets the container's alignment (both horizontal and vertical) according to
376 the values stored in @e tag. (Tags @c ALIGN parameter is extracted.) In fact
377 it is only a front-end to SetAlignHor()
380 void SetAlign(const wxHtmlTag
& tag
);
383 Sets the container's @e horizontal alignment. During wxHtmlCell::Layout
384 each line is aligned according to @a al value.
387 new horizontal alignment. May be one of these values:
399 lines are left-aligned (default)
432 lines are right-aligned
434 void SetAlignHor(int al
);
437 Sets the container's @e vertical alignment. This is per-line alignment!
440 new vertical alignment. May be one of these values:
452 cells are over the line (default)
463 cells are centered on line
474 cells are under the line
476 void SetAlignVer(int al
);
479 Sets the background colour for this container.
481 void SetBackgroundColour(const wxColour
& clr
);
484 Sets the border (frame) colours. A border is a rectangle around the container.
487 Colour of top and left lines
489 Colour of bottom and right lines
491 void SetBorder(const wxColour
& clr1
, const wxColour
& clr2
);
494 Sets the indentation (free space between borders of container and subcells).
499 Determines which of the four borders we're setting. It is OR
500 combination of following constants:
551 wxHTML_INDENT_HORIZONTAL
562 wxHTML_INDENT_VERTICAL
580 Units of i. This parameter affects interpretation of value.
592 i is number of pixels
603 i is interpreted as percents of width
606 void SetIndent(int i
, int what
, int units
= wxHTML_UNITS_PIXELS
);
609 Sets minimal height of the container.
610 When container's wxHtmlCell::Layout is called, m_Height
611 is set depending on layout of subcells to the height of area covered
612 by layed-out subcells. Calling this method guarantees you that the height
613 of container is never smaller than @a h - even if the subcells cover
619 If height of the container is lower than the minimum height, empty space
621 somewhere in order to ensure minimal height. This parameter is one of
623 wxHTML_ALIGN_BOTTOM, wxHTML_ALIGN_CENTER. It refers to the contents, not to
627 void SetMinHeight(int h
, int align
= wxHTML_ALIGN_TOP
);
631 Sets floating width adjustment.
632 The normal behaviour of container is that its width is the same as the width of
633 parent container (and thus you can have only one sub-container per line).
634 You can change this by setting FWA.
635 @a pixel_scale is number of real pixels that equals to 1 HTML pixel.
638 Width of the container. If the value is negative it means
639 complement to full width of parent container (e.g.
640 SetWidthFloat(-50, wxHTML_UNITS_PIXELS) sets the width
641 of container to parent's width minus 50 pixels. This is useful when
642 creating tables - you can call SetWidthFloat(50) and SetWidthFloat(-50))
644 Units of w This parameter affects the interpretation of value.
656 w is number of pixels
667 w is interpreted as percents of width
670 In the second version of method, w and units
671 info is extracted from tag's WIDTH parameter.
673 void SetWidthFloat(int w
, int units
);
674 void SetWidthFloat(const wxHtmlTag
& tag
,
675 double pixel_scale
= 1.0);
682 @class wxHtmlLinkInfo
683 @headerfile htmlcell.h wx/html/htmlcell.h
685 This class stores all necessary information about hypertext
686 links (as represented by @c A tag in HTML documents). In
687 current implementation it stores URL and target frame name.
688 @e Note that frames are not currently supported by wxHTML!
693 class wxHtmlLinkInfo
: public wxObject
698 Construct hypertext link from HREF (aka URL) and TARGET (name of target
702 wxHtmlLinkInfo(const wxString
& href
,
703 const wxString
& target
= wxEmptyString
);
707 Return pointer to event that generated OnLinkClicked event. Valid
708 only within wxHtmlWindow::OnLinkClicked,
711 const wxMouseEvent
* GetEvent();
714 Return @e HREF value of the @c A tag.
719 Return pointer to the cell that was clicked. Valid
720 only within wxHtmlWindow::OnLinkClicked,
723 const wxHtmlCell
* GetHtmlCell();
726 Return @e TARGET value of the @c A tag (this value
727 is used to specify in which frame should be the page pointed
728 by @ref gethref() Href opened).
730 wxString
GetTarget();