]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/html/htmlcell.h
add WX_CLEAR_ARRAY test
[wxWidgets.git] / interface / wx / html / htmlcell.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: html/htmlcell.h
5bddd46d 3// Purpose: interface of wxHtml*Cell
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHtmlColourCell
7c913512
FM
11
12 This cell changes the colour of either the background or the foreground.
13
23324ae1 14 @library{wxhtml}
8067ee11 15 @category{html}
23324ae1
FM
16*/
17class wxHtmlColourCell : public wxHtmlCell
18{
19public:
20 /**
21 Constructor.
8067ee11 22
7c913512 23 @param clr
4cc4bfaf 24 The color
7c913512 25 @param flags
4cc4bfaf 26 Can be one of following:
5bddd46d
FM
27 - wxHTML_CLR_FOREGROUND: change color of text
28 - wxHTML_CLR_BACKGROUND: change background color
23324ae1 29 */
8067ee11 30 wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
23324ae1
FM
31};
32
33
e54c96f1 34
23324ae1
FM
35/**
36 @class wxHtmlWidgetCell
7c913512 37
23324ae1 38 wxHtmlWidgetCell is a class that provides a connection between HTML cells and
5bddd46d
FM
39 widgets (an object derived from wxWindow).
40 You can use it to display things like forms, input boxes etc. in an HTML window.
7c913512 41
23324ae1 42 wxHtmlWidgetCell takes care of resizing and moving window.
7c913512 43
23324ae1 44 @library{wxhtml}
5bddd46d 45 @category{html}
23324ae1
FM
46*/
47class wxHtmlWidgetCell : public wxHtmlCell
48{
49public:
50 /**
51 Constructor.
8067ee11 52
7c913512 53 @param wnd
5bddd46d
FM
54 Connected window. It is parent window @b must be the wxHtmlWindow object
55 within which it is displayed!
7c913512 56 @param w
4cc4bfaf
FM
57 Floating width. If non-zero width of wnd window is adjusted so that it is
58 always w percents of parent container's width. (For example w = 100 means
5bddd46d 59 that the window will always have same width as parent container).
23324ae1
FM
60 */
61 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
62};
63
64
e54c96f1 65
23324ae1
FM
66/**
67 @class wxHtmlCell
7c913512 68
5bddd46d
FM
69 Internal data structure. It represents fragments of parsed HTML page, the
70 so-called @b cell - a word, picture, table, horizontal line and so on.
71 It is used by wxHtmlWindow and wxHtmlWinParser to represent HTML page in memory.
7c913512 72
23324ae1 73 You can divide cells into two groups : @e visible cells with non-zero width and
5bddd46d
FM
74 height and @e helper cells (usually with zero width and height) that perform
75 special actions such as color or font change.
7c913512 76
23324ae1 77 @library{wxhtml}
5bddd46d 78 @category{html}
7c913512 79
5bddd46d 80 @see @ref overview_html_cells, wxHtmlContainerCell
23324ae1
FM
81*/
82class wxHtmlCell : public wxObject
83{
84public:
85 /**
86 Constructor.
87 */
88 wxHtmlCell();
89
90 /**
5bddd46d
FM
91 This method is used to adjust pagebreak position.
92 The parameter is variable that contains y-coordinate of page break
93 (= horizontal line that should not be crossed by words, images etc.).
94 If this cell cannot be divided into two pieces (each one on another page)
95 then it moves the pagebreak few pixels up.
96 Returns @true if pagebreak was modified, @false otherwise.
97
23324ae1 98 Usage:
5bddd46d
FM
99 @code
100 while (container->AdjustPagebreak(&p)) {}
101 @endcode
23324ae1 102 */
4cc4bfaf 103 virtual bool AdjustPagebreak(int* pagebreak);
23324ae1
FM
104
105 /**
106 Renders the cell.
8067ee11 107
7c913512 108 @param dc
4cc4bfaf 109 Device context to which the cell is to be drawn
7c913512 110 @param x,y
4cc4bfaf
FM
111 Coordinates of parent's upper left corner (origin). You must
112 add this to m_PosX,m_PosY when passing coordinates to dc's methods
5bddd46d
FM
113 Example:
114 @code
115 dc->DrawText("hello", x + m_PosX, y + m_PosY)
116 @endcode
7c913512 117 @param view_y1
5bddd46d
FM
118 y-coord of the first line visible in window.
119 This is used to optimize rendering speed
7c913512 120 @param view_y2
5bddd46d
FM
121 y-coord of the last line visible in window.
122 This is used to optimize rendering speed
23324ae1 123 */
5bddd46d 124 virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
23324ae1
FM
125
126 /**
5bddd46d
FM
127 This method is called instead of Draw() when the cell is certainly out of
128 the screen (and thus invisible). This is not nonsense - some tags (like
129 wxHtmlColourCell or font setter) must be drawn even if they are invisible!
8067ee11 130
7c913512 131 @param dc
5bddd46d 132 Device context to which the cell is to be drawn.
7c913512 133 @param x,y
4cc4bfaf
FM
134 Coordinates of parent's upper left corner. You must
135 add this to m_PosX,m_PosY when passing coordinates to dc's methods
5bddd46d
FM
136 Example:
137 @code
138 dc->DrawText("hello", x + m_PosX, y + m_PosY)
139 @endcode
23324ae1
FM
140 */
141 virtual void DrawInvisible(wxDC& dc, int x, int y);
142
143 /**
5bddd46d
FM
144 Returns pointer to itself if this cell matches condition (or if any of the
145 cells following in the list matches), @NULL otherwise.
146 (In other words if you call top-level container's Find() it will
23324ae1 147 return pointer to the first cell that matches the condition)
5bddd46d 148
23324ae1 149 It is recommended way how to obtain pointer to particular cell or
5bddd46d
FM
150 to cell of some type (e.g. wxHtmlAnchorCell reacts on wxHTML_COND_ISANCHOR
151 condition).
8067ee11 152
7c913512 153 @param condition
4cc4bfaf 154 Unique integer identifier of condition
7c913512 155 @param param
4cc4bfaf 156 Optional parameters
23324ae1 157 */
adaaa686 158 virtual const wxHtmlCell* Find(int condition, const void* param) const;
23324ae1
FM
159
160 /**
7c913512 161 Returns descent value of the cell (m_Descent member).
23324ae1 162 See explanation:
5bddd46d 163 @image html descent.png
23324ae1 164 */
328f5751 165 int GetDescent() const;
23324ae1
FM
166
167 /**
168 Returns pointer to the first cell in the list.
5bddd46d
FM
169 You can then use child's GetNext() method to obtain pointer to the next
170 cell in list.
171
cdbcf4c2 172 @note This shouldn't be used by the end user. If you need some way of
5bddd46d 173 finding particular cell in the list, try Find() method instead.
23324ae1 174 */
adaaa686 175 virtual wxHtmlCell* GetFirstChild() const;
23324ae1
FM
176
177 /**
178 Returns height of the cell (m_Height member).
179 */
328f5751 180 int GetHeight() const;
23324ae1
FM
181
182 /**
5bddd46d 183 Returns unique cell identifier if there is any, the empty string otherwise.
23324ae1 184 */
328f5751 185 virtual wxString GetId() const;
23324ae1
FM
186
187 /**
188 Returns hypertext link if associated with this cell or @NULL otherwise.
5bddd46d 189 See wxHtmlLinkInfo. (Note: this makes sense only for visible tags).
8067ee11 190
7c913512 191 @param x,y
4cc4bfaf
FM
192 Coordinates of position where the user pressed mouse button.
193 These coordinates are used e.g. by COLORMAP. Values are relative to the
194 upper left corner of THIS cell (i.e. from 0 to m_Width or m_Height)
23324ae1 195 */
328f5751 196 virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0) const;
23324ae1
FM
197
198 /**
199 Returns cursor to show when mouse pointer is over the cell.
8067ee11 200
7c913512 201 @param window
4cc4bfaf 202 interface to the parent HTML window
23324ae1 203 */
adaaa686 204 virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window) const;
23324ae1
FM
205
206 /**
207 Returns pointer to the next cell in list (see htmlcell.h if you're
208 interested in details).
209 */
328f5751 210 wxHtmlCell* GetNext() const;
23324ae1
FM
211
212 /**
213 Returns pointer to parent container.
214 */
328f5751 215 wxHtmlContainerCell* GetParent() const;
23324ae1
FM
216
217 /**
218 Returns X position within parent (the value is relative to parent's
219 upper left corner). The returned value is meaningful only if
220 parent's Layout() was called before!
221 */
328f5751 222 int GetPosX() const;
23324ae1
FM
223
224 /**
225 Returns Y position within parent (the value is relative to parent's
226 upper left corner). The returned value is meaningful only if
227 parent's Layout() was called before!
228 */
328f5751 229 int GetPosY() const;
23324ae1
FM
230
231 /**
232 Returns width of the cell (m_Width member).
233 */
328f5751 234 int GetWidth() const;
23324ae1
FM
235
236 /**
237 This method performs two actions:
5bddd46d
FM
238 -# adjusts the cell's width according to the fact that maximal possible
239 width is @e w. (this has sense when working with horizontal lines, tables etc.)
240 -# prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
241 based on actual width @e w
242
243 It must be called before displaying cells structure because m_PosX and
244 m_PosY are undefined (or invalid) before calling Layout().
23324ae1
FM
245 */
246 virtual void Layout(int w);
247
248 /**
5bddd46d
FM
249 This function is simple event handler.
250 Each time the user clicks mouse button over a cell within wxHtmlWindow
251 this method of that cell is called.
252 Default behavior is to call wxHtmlWindow::LoadPage.
8067ee11 253
7c913512 254 @param window
4cc4bfaf 255 interface to the parent HTML window
7c913512 256 @param pos
4cc4bfaf 257 coordinates of mouse click (this is relative to cell's origin
7c913512 258 @param event
4cc4bfaf 259 mouse event that triggered the call
8067ee11 260
d29a9a8a 261 @return @true if a link was clicked, @false otherwise.
5bddd46d
FM
262
263 @since 2.7.0 (before OnMouseClick() method served a similar purpose).
264
265 @note
266 If you need more "advanced" event handling you should use wxHtmlBinderCell instead.
23324ae1
FM
267 */
268 virtual bool ProcessMouseClick(wxHtmlWindowInterface* window,
269 const wxPoint& pos,
270 const wxMouseEvent& event);
271
272 /**
273 Sets unique cell identifier. Default value is no identifier, i.e. empty string.
274 */
275 void SetId(const wxString& id);
276
277 /**
5bddd46d
FM
278 Sets the hypertext link associated with this cell.
279 (Default value is wxHtmlLinkInfo("", "") (no link))
23324ae1
FM
280 */
281 void SetLink(const wxHtmlLinkInfo& link);
282
283 /**
284 Sets the next cell in the list. This shouldn't be called by user - it is
285 to be used only by wxHtmlContainerCell::InsertCell.
286 */
287 void SetNext(wxHtmlCell cell);
288
289 /**
5bddd46d
FM
290 Sets parent container of this cell.
291 This is called from wxHtmlContainerCell::InsertCell.
23324ae1
FM
292 */
293 void SetParent(wxHtmlContainerCell p);
294
295 /**
296 Sets the cell's position within parent container.
297 */
adaaa686 298 virtual void SetPos(int x, int y);
23324ae1
FM
299};
300
301
e54c96f1 302
23324ae1
FM
303/**
304 @class wxHtmlContainerCell
7c913512 305
23324ae1
FM
306 The wxHtmlContainerCell class is an implementation of a cell that may
307 contain more cells in it. It is heavily used in the wxHTML layout algorithm.
7c913512 308
23324ae1 309 @library{wxhtml}
5bddd46d 310 @category{html}
7c913512 311
5bddd46d 312 @see @ref overview_html_cells
23324ae1
FM
313*/
314class wxHtmlContainerCell : public wxHtmlCell
315{
316public:
317 /**
4cc4bfaf 318 Constructor. @a parent is pointer to parent container or @NULL.
23324ae1 319 */
8067ee11 320 wxHtmlContainerCell(wxHtmlContainerCell* parent);
23324ae1
FM
321
322 /**
323 Returns container's horizontal alignment.
324 */
328f5751 325 int GetAlignHor() const;
23324ae1
FM
326
327 /**
328 Returns container's vertical alignment.
329 */
328f5751 330 int GetAlignVer() const;
23324ae1
FM
331
332 /**
333 Returns the background colour of the container or @c wxNullColour if no
5bddd46d 334 background colour is set.
23324ae1
FM
335 */
336 wxColour GetBackgroundColour();
337
338 /**
4cc4bfaf 339 Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
5bddd46d
FM
340
341 @note You must call GetIndentUnits() with same @a ind parameter in order
342 to correctly interpret the returned integer value.
343 It is NOT always in pixels!
23324ae1 344 */
328f5751 345 int GetIndent(int ind) const;
23324ae1
FM
346
347 /**
4cc4bfaf 348 Returns the units of indentation for @a ind where @a ind is one
23324ae1
FM
349 of the @b wxHTML_INDENT_* constants.
350 */
328f5751 351 int GetIndentUnits(int ind) const;
23324ae1
FM
352
353 /**
5bddd46d 354 Inserts a new cell into the container.
23324ae1
FM
355 */
356 void InsertCell(wxHtmlCell cell);
357
358 /**
359 Sets the container's alignment (both horizontal and vertical) according to
5bddd46d
FM
360 the values stored in @e tag. (Tags @c ALIGN parameter is extracted.)
361 In fact it is only a front-end to SetAlignHor() and SetAlignVer().
23324ae1
FM
362 */
363 void SetAlign(const wxHtmlTag& tag);
364
365 /**
5bddd46d
FM
366 Sets the container's @e horizontal alignment.
367 During wxHtmlCell::Layout each line is aligned according to @a al value.
8067ee11 368
7c913512 369 @param al
4cc4bfaf 370 new horizontal alignment. May be one of these values:
5bddd46d
FM
371 - wxHTML_ALIGN_LEFT: lines are left-aligned (default)
372 - wxHTML_ALIGN_JUSTIFY: lines are justified
373 - wxHTML_ALIGN_CENTER: lines are centered
374 - wxHTML_ALIGN_RIGHT: lines are right-aligned
23324ae1
FM
375 */
376 void SetAlignHor(int al);
377
378 /**
379 Sets the container's @e vertical alignment. This is per-line alignment!
8067ee11 380
7c913512 381 @param al
4cc4bfaf 382 new vertical alignment. May be one of these values:
5bddd46d
FM
383 - wxHTML_ALIGN_BOTTOM: cells are over the line (default)
384 - wxHTML_ALIGN_CENTER: cells are centered on line
385 - wxHTML_ALIGN_TOP: cells are under the line
8067ee11 386
5bddd46d 387 @image html alignv.png
23324ae1
FM
388 */
389 void SetAlignVer(int al);
390
391 /**
392 Sets the background colour for this container.
393 */
394 void SetBackgroundColour(const wxColour& clr);
395
396 /**
397 Sets the border (frame) colours. A border is a rectangle around the container.
8067ee11 398
7c913512 399 @param clr1
4cc4bfaf 400 Colour of top and left lines
7c913512 401 @param clr2
4cc4bfaf 402 Colour of bottom and right lines
23324ae1
FM
403 */
404 void SetBorder(const wxColour& clr1, const wxColour& clr2);
405
406 /**
407 Sets the indentation (free space between borders of container and subcells).
8067ee11 408
5bddd46d
FM
409 @image html indent.png
410
7c913512 411 @param i
4cc4bfaf 412 Indentation value.
7c913512 413 @param what
4cc4bfaf
FM
414 Determines which of the four borders we're setting. It is OR
415 combination of following constants:
5bddd46d
FM
416 - wxHTML_INDENT_TOP: top border
417 - wxHTML_INDENT_BOTTOM: bottom
418 - wxHTML_INDENT_LEFT: left
419 - wxHTML_INDENT_RIGHT: right
420 - wxHTML_INDENT_HORIZONTAL: left and right
421 - wxHTML_INDENT_VERTICAL: top and bottom
422 - wxHTML_INDENT_ALL: all 4 borders
7c913512 423 @param units
5bddd46d
FM
424 Units of i. This parameter affects interpretation of value.
425 - wxHTML_UNITS_PIXELS: @a i is number of pixels
426 - wxHTML_UNITS_PERCENT: @a i is interpreted as percents of width
427 of parent container
23324ae1
FM
428 */
429 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
430
431 /**
432 Sets minimal height of the container.
5bddd46d
FM
433 When container's wxHtmlCell::Layout is called, m_Height is set depending
434 on layout of subcells to the height of area covered by layed-out subcells.
435 Calling this method guarantees you that the height of container is never
436 smaller than @a h - even if the subcells cover much smaller area.
8067ee11 437
7c913512 438 @param h
4cc4bfaf 439 The minimal height.
7c913512 440 @param align
4cc4bfaf 441 If height of the container is lower than the minimum height, empty space
5bddd46d
FM
442 must be inserted somewhere in order to ensure minimal height.
443 This parameter is one of @c wxHTML_ALIGN_TOP, @c wxHTML_ALIGN_BOTTOM,
444 @c wxHTML_ALIGN_CENTER. It refers to the contents, not to the
4cc4bfaf 445 empty place.
23324ae1
FM
446 */
447 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
448
23324ae1
FM
449 /**
450 Sets floating width adjustment.
5bddd46d 451
23324ae1
FM
452 The normal behaviour of container is that its width is the same as the width of
453 parent container (and thus you can have only one sub-container per line).
5bddd46d 454 You can change this by setting the floating width adjustment.
8067ee11 455
7c913512 456 @param w
4cc4bfaf 457 Width of the container. If the value is negative it means
5bddd46d
FM
458 complement to full width of parent container.
459 E.g. @code SetWidthFloat(-50, wxHTML_UNITS_PIXELS) @endcode sets the
460 width of container to parent's width minus 50 pixels. This is useful when
461 creating tables - you can call SetWidthFloat(50) and SetWidthFloat(-50).
7c913512 462 @param units
4cc4bfaf 463 Units of w This parameter affects the interpretation of value.
5bddd46d
FM
464 - wxHTML_UNITS_PIXELS: @a w is number of pixels
465 - wxHTML_UNITS_PERCENT: @a w is interpreted as percents of width
466 of parent container
467 */
468 void SetWidthFloat(int w, int units);
8067ee11 469
5bddd46d
FM
470 /**
471 Sets floating width adjustment.
8067ee11 472
5bddd46d
FM
473 The normal behaviour of container is that its width is the same as the width of
474 parent container (and thus you can have only one sub-container per line).
475 You can change this by setting the floating width adjustment.
8067ee11 476
7c913512 477 @param tag
5bddd46d
FM
478 In the second version of method, @a w and @a units info is extracted
479 from tag's WIDTH parameter.
480 @param pixel_scale
481 This is number of real pixels that equals to 1 HTML pixel.
23324ae1 482 */
7c913512
FM
483 void SetWidthFloat(const wxHtmlTag& tag,
484 double pixel_scale = 1.0);
23324ae1
FM
485};
486
487
e54c96f1 488
23324ae1
FM
489/**
490 @class wxHtmlLinkInfo
7c913512 491
5bddd46d
FM
492 This class stores all necessary information about hypertext links
493 (as represented by \<A\> tag in HTML documents).
494 In current implementation it stores URL and target frame name.
495
496 @note Frames are not currently supported by wxHTML!
7c913512 497
23324ae1 498 @library{wxhtml}
5bddd46d 499 @category{html}
23324ae1
FM
500*/
501class wxHtmlLinkInfo : public wxObject
502{
503public:
23324ae1 504 /**
5bddd46d 505 Default ctor.
23324ae1
FM
506 */
507 wxHtmlLinkInfo();
5bddd46d
FM
508
509 /**
510 Construct hypertext link from HREF (aka URL) and TARGET (name of target frame).
511 */
7c913512
FM
512 wxHtmlLinkInfo(const wxString& href,
513 const wxString& target = wxEmptyString);
23324ae1
FM
514
515 /**
5bddd46d
FM
516 Return pointer to event that generated OnLinkClicked() event.
517 Valid only within wxHtmlWindow::OnLinkClicked, @NULL otherwise.
23324ae1 518 */
adaaa686 519 const wxMouseEvent* GetEvent() const;
23324ae1
FM
520
521 /**
5bddd46d 522 Return @e HREF value of the \<A\> tag.
23324ae1 523 */
adaaa686 524 wxString GetHref() const;
23324ae1
FM
525
526 /**
5bddd46d
FM
527 Return pointer to the cell that was clicked.
528 Valid only within wxHtmlWindow::OnLinkClicked, @NULL otherwise.
23324ae1 529 */
adaaa686 530 const wxHtmlCell* GetHtmlCell() const;
23324ae1
FM
531
532 /**
5bddd46d
FM
533 Return @e TARGET value of the \<A\> tag (this value is used to specify
534 in which frame should be the page pointed by @ref GetHref() Href opened).
23324ae1 535 */
adaaa686 536 wxString GetTarget() const;
23324ae1 537};
e54c96f1 538