1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/htmlcell.h
3 // Purpose: interface of wxHtmlColourCell
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxHtmlColourCell
12 This cell changes the colour of either the background or the foreground.
17 class wxHtmlColourCell
: public wxHtmlCell
26 Can be one of following:
49 change background color
51 wxHtmlColourCell(wxColour clr
, int flags
= wxHTML_CLR_FOREGROUND
);
57 @class wxHtmlWidgetCell
59 wxHtmlWidgetCell is a class that provides a connection between HTML cells and
60 widgets (an object derived
61 from wxWindow). You can use it to display things like forms, input boxes etc.
64 wxHtmlWidgetCell takes care of resizing and moving window.
69 class wxHtmlWidgetCell
: public wxHtmlCell
76 Connected window. It is parent window must be the wxHtmlWindow object within
77 which it is displayed!
79 Floating width. If non-zero width of wnd window is adjusted so that it is
80 always w percents of parent container's width. (For example w = 100 means
82 will always have same width as parent container)
84 wxHtmlWidgetCell(wxWindow
* wnd
, int w
= 0);
92 Internal data structure. It represents fragments of parsed HTML
93 page, the so-called @b cell - a word, picture, table, horizontal line and so on.
94 It is used by wxHtmlWindow and
95 wxHtmlWinParser to represent HTML page in memory.
97 You can divide cells into two groups : @e visible cells with non-zero width and
98 height and @e helper cells (usually with zero width and height) that
99 perform special actions such as color or font change.
104 @see @ref overview_cells "Cells Overview", wxHtmlContainerCell
106 class wxHtmlCell
: public wxObject
115 This method is used to adjust pagebreak position. The parameter is
116 variable that contains y-coordinate of page break (= horizontal line that
117 should not be crossed by words, images etc.). If this cell cannot be divided
118 into two pieces (each one on another page) then it moves the pagebreak
120 Returns @true if pagebreak was modified, @false otherwise
123 virtual bool AdjustPagebreak(int* pagebreak
);
129 Device context to which the cell is to be drawn
131 Coordinates of parent's upper left corner (origin). You must
132 add this to m_PosX,m_PosY when passing coordinates to dc's methods
133 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
135 y-coord of the first line visible in window. This is
136 used to optimize rendering speed
138 y-coord of the last line visible in window. This is
139 used to optimize rendering speed
141 virtual void Draw(wxDC
& dc
, int x
, int y
, int view_y1
,
145 This method is called instead of Draw() when the
146 cell is certainly out of the screen (and thus invisible). This is not
147 nonsense - some tags (like wxHtmlColourCell
148 or font setter) must be drawn even if they are invisible!
151 Device context to which the cell is to be drawn
153 Coordinates of parent's upper left corner. You must
154 add this to m_PosX,m_PosY when passing coordinates to dc's methods
155 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
157 virtual void DrawInvisible(wxDC
& dc
, int x
, int y
);
160 Returns pointer to itself if this cell matches condition (or if any of the cells
161 following in the list matches), @NULL otherwise.
162 (In other words if you call top-level container's Find it will
163 return pointer to the first cell that matches the condition)
164 It is recommended way how to obtain pointer to particular cell or
165 to cell of some type (e.g. wxHtmlAnchorCell reacts on
166 wxHTML_COND_ISANCHOR condition)
169 Unique integer identifier of condition
173 virtual const wxHtmlCell
* Find(int condition
, const void* param
) const;
176 Returns descent value of the cell (m_Descent member).
179 int GetDescent() const;
182 Returns pointer to the first cell in the list.
183 You can then use child's GetNext()
184 method to obtain pointer to the next cell in list.
185 @note This shouldn't be used by the end user. If you need some way of
186 finding particular cell in the list, try Find() method
189 virtual wxHtmlCell
* GetFirstChild() const;
192 Returns height of the cell (m_Height member).
194 int GetHeight() const;
197 Returns unique cell identifier if there is any, empty string otherwise.
199 virtual wxString
GetId() const;
202 Returns hypertext link if associated with this cell or @NULL otherwise.
204 (Note: this makes sense only for visible tags).
207 Coordinates of position where the user pressed mouse button.
208 These coordinates are used e.g. by COLORMAP. Values are relative to the
209 upper left corner of THIS cell (i.e. from 0 to m_Width or m_Height)
211 virtual wxHtmlLinkInfo
* GetLink(int x
= 0, int y
= 0) const;
214 Returns cursor to show when mouse pointer is over the cell.
217 interface to the parent HTML window
219 virtual wxCursor
GetMouseCursor(wxHtmlWindowInterface
* window
) const;
222 Returns pointer to the next cell in list (see htmlcell.h if you're
223 interested in details).
225 wxHtmlCell
* GetNext() const;
228 Returns pointer to parent container.
230 wxHtmlContainerCell
* GetParent() const;
233 Returns X position within parent (the value is relative to parent's
234 upper left corner). The returned value is meaningful only if
235 parent's Layout() was called before!
240 Returns Y position within parent (the value is relative to parent's
241 upper left corner). The returned value is meaningful only if
242 parent's Layout() was called before!
247 Returns width of the cell (m_Width member).
249 int GetWidth() const;
252 This method performs two actions:
253 adjusts the cell's width according to the fact that maximal possible width is
255 (this has sense when working with horizontal lines, tables etc.)
256 prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
257 based on actual width @e w
258 It must be called before displaying cells structure because
259 m_PosX and m_PosY are undefined (or invalid)
260 before calling Layout.
262 virtual void Layout(int w
);
265 This function is simple event handler. Each time the user clicks mouse button
266 over a cell within wxHtmlWindow this method of that
267 cell is called. Default behavior is to call
268 wxHtmlWindow::LoadPage.
271 interface to the parent HTML window
273 coordinates of mouse click (this is relative to cell's origin
275 mouse event that triggered the call
277 @return @true if a link was clicked, @false otherwise.
279 virtual bool ProcessMouseClick(wxHtmlWindowInterface
* window
,
281 const wxMouseEvent
& event
);
284 Sets unique cell identifier. Default value is no identifier, i.e. empty string.
286 void SetId(const wxString
& id
);
289 Sets the hypertext link associated with this cell. (Default value
290 is wxHtmlLinkInfo("", "") (no link))
292 void SetLink(const wxHtmlLinkInfo
& link
);
295 Sets the next cell in the list. This shouldn't be called by user - it is
296 to be used only by wxHtmlContainerCell::InsertCell.
298 void SetNext(wxHtmlCell cell
);
301 Sets parent container of this cell. This is called from
302 wxHtmlContainerCell::InsertCell.
304 void SetParent(wxHtmlContainerCell p
);
307 Sets the cell's position within parent container.
309 virtual void SetPos(int x
, int y
);
315 @class wxHtmlContainerCell
317 The wxHtmlContainerCell class is an implementation of a cell that may
318 contain more cells in it. It is heavily used in the wxHTML layout algorithm.
323 @see @ref overview_cells "Cells Overview"
325 class wxHtmlContainerCell
: public wxHtmlCell
329 Constructor. @a parent is pointer to parent container or @NULL.
331 wxHtmlContainerCell(wxHtmlContainerCell parent
);
334 Returns container's horizontal alignment.
336 int GetAlignHor() const;
339 Returns container's vertical alignment.
341 int GetAlignVer() const;
344 Returns the background colour of the container or @c wxNullColour if no
348 wxColour
GetBackgroundColour();
351 Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
352 @note You must call GetIndentUnits()
353 with same @a ind parameter in order to correctly interpret the returned integer
355 It is NOT always in pixels!
357 int GetIndent(int ind
) const;
360 Returns the units of indentation for @a ind where @a ind is one
361 of the @b wxHTML_INDENT_* constants.
363 int GetIndentUnits(int ind
) const;
366 Inserts new cell into the container.
368 void InsertCell(wxHtmlCell cell
);
371 Sets the container's alignment (both horizontal and vertical) according to
372 the values stored in @e tag. (Tags @c ALIGN parameter is extracted.) In fact
373 it is only a front-end to SetAlignHor()
376 void SetAlign(const wxHtmlTag
& tag
);
379 Sets the container's @e horizontal alignment. During wxHtmlCell::Layout
380 each line is aligned according to @a al value.
383 new horizontal alignment. May be one of these values:
395 lines are left-aligned (default)
428 lines are right-aligned
430 void SetAlignHor(int al
);
433 Sets the container's @e vertical alignment. This is per-line alignment!
436 new vertical alignment. May be one of these values:
448 cells are over the line (default)
459 cells are centered on line
470 cells are under the line
472 void SetAlignVer(int al
);
475 Sets the background colour for this container.
477 void SetBackgroundColour(const wxColour
& clr
);
480 Sets the border (frame) colours. A border is a rectangle around the container.
483 Colour of top and left lines
485 Colour of bottom and right lines
487 void SetBorder(const wxColour
& clr1
, const wxColour
& clr2
);
490 Sets the indentation (free space between borders of container and subcells).
495 Determines which of the four borders we're setting. It is OR
496 combination of following constants:
547 wxHTML_INDENT_HORIZONTAL
558 wxHTML_INDENT_VERTICAL
576 Units of i. This parameter affects interpretation of value.
588 i is number of pixels
599 i is interpreted as percents of width
602 void SetIndent(int i
, int what
, int units
= wxHTML_UNITS_PIXELS
);
605 Sets minimal height of the container.
606 When container's wxHtmlCell::Layout is called, m_Height
607 is set depending on layout of subcells to the height of area covered
608 by layed-out subcells. Calling this method guarantees you that the height
609 of container is never smaller than @a h - even if the subcells cover
615 If height of the container is lower than the minimum height, empty space
617 somewhere in order to ensure minimal height. This parameter is one of
619 wxHTML_ALIGN_BOTTOM, wxHTML_ALIGN_CENTER. It refers to the contents, not to
623 void SetMinHeight(int h
, int align
= wxHTML_ALIGN_TOP
);
627 Sets floating width adjustment.
628 The normal behaviour of container is that its width is the same as the width of
629 parent container (and thus you can have only one sub-container per line).
630 You can change this by setting FWA.
631 @a pixel_scale is number of real pixels that equals to 1 HTML pixel.
634 Width of the container. If the value is negative it means
635 complement to full width of parent container (e.g.
636 SetWidthFloat(-50, wxHTML_UNITS_PIXELS) sets the width
637 of container to parent's width minus 50 pixels. This is useful when
638 creating tables - you can call SetWidthFloat(50) and SetWidthFloat(-50))
640 Units of w This parameter affects the interpretation of value.
652 w is number of pixels
663 w is interpreted as percents of width
666 In the second version of method, w and units
667 info is extracted from tag's WIDTH parameter.
669 void SetWidthFloat(int w
, int units
);
670 void SetWidthFloat(const wxHtmlTag
& tag
,
671 double pixel_scale
= 1.0);
678 @class wxHtmlLinkInfo
680 This class stores all necessary information about hypertext
681 links (as represented by @c A tag in HTML documents). In
682 current implementation it stores URL and target frame name.
683 @e Note that frames are not currently supported by wxHTML!
688 class wxHtmlLinkInfo
: public wxObject
693 Construct hypertext link from HREF (aka URL) and TARGET (name of target
697 wxHtmlLinkInfo(const wxString
& href
,
698 const wxString
& target
= wxEmptyString
);
702 Return pointer to event that generated OnLinkClicked event. Valid
703 only within wxHtmlWindow::OnLinkClicked,
706 const wxMouseEvent
* GetEvent() const;
709 Return @e HREF value of the @c A tag.
711 wxString
GetHref() const;
714 Return pointer to the cell that was clicked. Valid
715 only within wxHtmlWindow::OnLinkClicked,
718 const wxHtmlCell
* GetHtmlCell() const;
721 Return @e TARGET value of the @c A tag (this value
722 is used to specify in which frame should be the page pointed
723 by @ref gethref() Href opened).
725 wxString
GetTarget() const;