]> git.saurik.com Git - wxWidgets.git/blame - interface/html/htmlcell.h
remove wxTextAttr::CreateFont(); return wxNullFont from GetFont() if we have no font...
[wxWidgets.git] / interface / html / htmlcell.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: html/htmlcell.h
3// Purpose: documentation for wxHtmlColourCell class
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHtmlColourCell
11 @headerfile htmlcell.h wx/html/htmlcell.h
7c913512
FM
12
13 This cell changes the colour of either the background or the foreground.
14
23324ae1
FM
15 @library{wxhtml}
16 @category{FIXME}
17*/
18class wxHtmlColourCell : public wxHtmlCell
19{
20public:
21 /**
22 Constructor.
23
7c913512 24 @param clr
4cc4bfaf 25 The color
7c913512 26 @param flags
4cc4bfaf
FM
27 Can be one of following:
28
29
30
31
32
33
34 wxHTML_CLR_FOREGROUND
35
36
37
23324ae1 38
4cc4bfaf 39 change color of text
23324ae1
FM
40
41
23324ae1 42
23324ae1
FM
43
44
4cc4bfaf
FM
45 wxHTML_CLR_BACKGROUND
46
47
48
49
50 change background color
23324ae1
FM
51 */
52 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
53};
54
55
56/**
57 @class wxHtmlWidgetCell
58 @headerfile htmlcell.h wx/html/htmlcell.h
7c913512 59
23324ae1
FM
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.
63 in an HTML window.
7c913512 64
23324ae1 65 wxHtmlWidgetCell takes care of resizing and moving window.
7c913512 66
23324ae1
FM
67 @library{wxhtml}
68 @category{FIXME}
69*/
70class wxHtmlWidgetCell : public wxHtmlCell
71{
72public:
73 /**
74 Constructor.
75
7c913512 76 @param wnd
4cc4bfaf
FM
77 Connected window. It is parent window must be the wxHtmlWindow object within
78 which it is displayed!
7c913512 79 @param w
4cc4bfaf
FM
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
82 that the window
83 will always have same width as parent container)
23324ae1
FM
84 */
85 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
86};
87
88
89/**
90 @class wxHtmlCell
91 @headerfile htmlcell.h wx/html/htmlcell.h
7c913512 92
23324ae1
FM
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.
7c913512 95 It is used by wxHtmlWindow and
23324ae1 96 wxHtmlWinParser to represent HTML page in memory.
7c913512 97
23324ae1
FM
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.
7c913512 101
23324ae1
FM
102 @library{wxhtml}
103 @category{FIXME}
7c913512 104
23324ae1
FM
105 @seealso
106 @ref overview_cells "Cells Overview", wxHtmlContainerCell
107*/
108class wxHtmlCell : public wxObject
109{
110public:
111 /**
112 Constructor.
113 */
114 wxHtmlCell();
115
116 /**
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
121 few pixels up.
23324ae1 122 Returns @true if pagebreak was modified, @false otherwise
23324ae1
FM
123 Usage:
124 */
4cc4bfaf 125 virtual bool AdjustPagebreak(int* pagebreak);
23324ae1
FM
126
127 /**
128 Renders the cell.
129
7c913512 130 @param dc
4cc4bfaf 131 Device context to which the cell is to be drawn
7c913512 132 @param x,y
4cc4bfaf
FM
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)
7c913512 136 @param view_y1
4cc4bfaf
FM
137 y-coord of the first line visible in window. This is
138 used to optimize rendering speed
7c913512 139 @param view_y2
4cc4bfaf
FM
140 y-coord of the last line visible in window. This is
141 used to optimize rendering speed
23324ae1
FM
142 */
143 virtual void Draw(wxDC& dc, int x, int y, int view_y1,
144 int view_y2);
145
146 /**
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!
151
7c913512 152 @param dc
4cc4bfaf 153 Device context to which the cell is to be drawn
7c913512 154 @param x,y
4cc4bfaf
FM
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)
23324ae1
FM
158 */
159 virtual void DrawInvisible(wxDC& dc, int x, int y);
160
161 /**
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)
23324ae1
FM
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)
169
7c913512 170 @param condition
4cc4bfaf 171 Unique integer identifier of condition
7c913512 172 @param param
4cc4bfaf 173 Optional parameters
23324ae1
FM
174 */
175 virtual const wxHtmlCell* Find(int condition, const void* param);
176
177 /**
7c913512 178 Returns descent value of the cell (m_Descent member).
23324ae1
FM
179 See explanation:
180 */
181 int GetDescent();
182
183 /**
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.
23324ae1
FM
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
189 instead.
190 */
191 wxHtmlCell* GetFirstChild();
192
193 /**
194 Returns height of the cell (m_Height member).
195 */
196 int GetHeight();
197
198 /**
199 Returns unique cell identifier if there is any, empty string otherwise.
200 */
201 virtual wxString GetId();
202
203 /**
204 Returns hypertext link if associated with this cell or @NULL otherwise.
205 See wxHtmlLinkInfo.
206 (Note: this makes sense only for visible tags).
207
7c913512 208 @param x,y
4cc4bfaf
FM
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)
23324ae1
FM
212 */
213 virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
214
215 /**
216 Returns cursor to show when mouse pointer is over the cell.
217
7c913512 218 @param window
4cc4bfaf 219 interface to the parent HTML window
23324ae1
FM
220 */
221 virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window);
222
223 /**
224 Returns pointer to the next cell in list (see htmlcell.h if you're
225 interested in details).
226 */
227 wxHtmlCell* GetNext();
228
229 /**
230 Returns pointer to parent container.
231 */
232 wxHtmlContainerCell* GetParent();
233
234 /**
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!
238 */
239 int GetPosX();
240
241 /**
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!
245 */
246 int GetPosY();
247
248 /**
249 Returns width of the cell (m_Width member).
250 */
251 int GetWidth();
252
253 /**
254 This method performs two actions:
23324ae1
FM
255 adjusts the cell's width according to the fact that maximal possible width is
256 @e w.
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
23324ae1
FM
260 It must be called before displaying cells structure because
261 m_PosX and m_PosY are undefined (or invalid)
262 before calling Layout.
263 */
264 virtual void Layout(int w);
265
266 /**
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.
271
7c913512 272 @param window
4cc4bfaf 273 interface to the parent HTML window
7c913512 274 @param pos
4cc4bfaf 275 coordinates of mouse click (this is relative to cell's origin
7c913512 276 @param event
4cc4bfaf 277 mouse event that triggered the call
23324ae1
FM
278
279 @returns @true if a link was clicked, @false otherwise.
280 */
281 virtual bool ProcessMouseClick(wxHtmlWindowInterface* window,
282 const wxPoint& pos,
283 const wxMouseEvent& event);
284
285 /**
286 Sets unique cell identifier. Default value is no identifier, i.e. empty string.
287 */
288 void SetId(const wxString& id);
289
290 /**
291 Sets the hypertext link associated with this cell. (Default value
292 is wxHtmlLinkInfo("", "") (no link))
293 */
294 void SetLink(const wxHtmlLinkInfo& link);
295
296 /**
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.
299 */
300 void SetNext(wxHtmlCell cell);
301
302 /**
303 Sets parent container of this cell. This is called from
304 wxHtmlContainerCell::InsertCell.
305 */
306 void SetParent(wxHtmlContainerCell p);
307
308 /**
309 Sets the cell's position within parent container.
310 */
311 void SetPos(int x, int y);
312};
313
314
315/**
316 @class wxHtmlContainerCell
317 @headerfile htmlcell.h wx/html/htmlcell.h
7c913512 318
23324ae1
FM
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.
7c913512 321
23324ae1
FM
322 @library{wxhtml}
323 @category{FIXME}
7c913512 324
23324ae1
FM
325 @seealso
326 @ref overview_cells "Cells Overview"
327*/
328class wxHtmlContainerCell : public wxHtmlCell
329{
330public:
331 /**
4cc4bfaf 332 Constructor. @a parent is pointer to parent container or @NULL.
23324ae1
FM
333 */
334 wxHtmlContainerCell(wxHtmlContainerCell parent);
335
336 /**
337 Returns container's horizontal alignment.
338 */
339 int GetAlignHor();
340
341 /**
342 Returns container's vertical alignment.
343 */
344 int GetAlignVer();
345
346 /**
347 Returns the background colour of the container or @c wxNullColour if no
348 background
349 colour is set.
350 */
351 wxColour GetBackgroundColour();
352
353 /**
4cc4bfaf 354 Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
7c913512 355 @b Note: You must call GetIndentUnits()
4cc4bfaf 356 with same @a ind parameter in order to correctly interpret the returned integer
23324ae1
FM
357 value.
358 It is NOT always in pixels!
359 */
360 int GetIndent(int ind);
361
362 /**
4cc4bfaf 363 Returns the units of indentation for @a ind where @a ind is one
23324ae1
FM
364 of the @b wxHTML_INDENT_* constants.
365 */
366 int GetIndentUnits(int ind);
367
368 /**
369 Inserts new cell into the container.
370 */
371 void InsertCell(wxHtmlCell cell);
372
373 /**
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
7c913512 376 it is only a front-end to SetAlignHor()
23324ae1
FM
377 and SetAlignVer().
378 */
379 void SetAlign(const wxHtmlTag& tag);
380
381 /**
7c913512 382 Sets the container's @e horizontal alignment. During wxHtmlCell::Layout
4cc4bfaf 383 each line is aligned according to @a al value.
23324ae1 384
7c913512 385 @param al
4cc4bfaf
FM
386 new horizontal alignment. May be one of these values:
387
388
389
390
391
392
393 wxHTML_ALIGN_LEFT
394
395
23324ae1 396
23324ae1 397
4cc4bfaf 398 lines are left-aligned (default)
23324ae1 399
23324ae1 400
23324ae1
FM
401
402
23324ae1 403
4cc4bfaf 404 wxHTML_ALIGN_JUSTIFY
23324ae1
FM
405
406
23324ae1 407
23324ae1 408
4cc4bfaf 409 lines are justified
23324ae1 410
4cc4bfaf
FM
411
412
413
414
415 wxHTML_ALIGN_CENTER
416
417
418
419
420 lines are centered
421
422
423
424
425
426 wxHTML_ALIGN_RIGHT
427
428
429
430
431 lines are right-aligned
23324ae1
FM
432 */
433 void SetAlignHor(int al);
434
435 /**
436 Sets the container's @e vertical alignment. This is per-line alignment!
437
7c913512 438 @param al
4cc4bfaf
FM
439 new vertical alignment. May be one of these values:
440
441
442
443
444
445
446 wxHTML_ALIGN_BOTTOM
447
448
449
450
451 cells are over the line (default)
452
453
454
455
456
457 wxHTML_ALIGN_CENTER
458
459
460
461
462 cells are centered on line
23324ae1 463
23324ae1
FM
464
465
23324ae1 466
23324ae1 467
4cc4bfaf 468 wxHTML_ALIGN_TOP
23324ae1 469
23324ae1 470
23324ae1
FM
471
472
4cc4bfaf 473 cells are under the line
23324ae1
FM
474 */
475 void SetAlignVer(int al);
476
477 /**
478 Sets the background colour for this container.
479 */
480 void SetBackgroundColour(const wxColour& clr);
481
482 /**
483 Sets the border (frame) colours. A border is a rectangle around the container.
484
7c913512 485 @param clr1
4cc4bfaf 486 Colour of top and left lines
7c913512 487 @param clr2
4cc4bfaf 488 Colour of bottom and right lines
23324ae1
FM
489 */
490 void SetBorder(const wxColour& clr1, const wxColour& clr2);
491
492 /**
493 Sets the indentation (free space between borders of container and subcells).
494
7c913512 495 @param i
4cc4bfaf 496 Indentation value.
7c913512 497 @param what
4cc4bfaf
FM
498 Determines which of the four borders we're setting. It is OR
499 combination of following constants:
500
501
502
503
504
505
506 wxHTML_INDENT_TOP
507
508
509
510
511 top border
512
513
514
515
516
517 wxHTML_INDENT_BOTTOM
518
519
520
521
522 bottom
523
524
525
526
527
528 wxHTML_INDENT_LEFT
529
530
531
532
533 left
534
535
536
537
538
539 wxHTML_INDENT_RIGHT
540
541
23324ae1 542
23324ae1 543
4cc4bfaf 544 right
23324ae1 545
23324ae1 546
23324ae1
FM
547
548
23324ae1 549
4cc4bfaf 550 wxHTML_INDENT_HORIZONTAL
23324ae1
FM
551
552
23324ae1 553
23324ae1 554
4cc4bfaf 555 left and right
23324ae1 556
23324ae1 557
23324ae1
FM
558
559
23324ae1 560
4cc4bfaf 561 wxHTML_INDENT_VERTICAL
23324ae1
FM
562
563
23324ae1 564
23324ae1 565
4cc4bfaf 566 top and bottom
23324ae1 567
23324ae1
FM
568
569
4cc4bfaf
FM
570
571
572 wxHTML_INDENT_ALL
573
574
575
576
577 all 4 borders
7c913512 578 @param units
4cc4bfaf
FM
579 Units of i. This parameter affects interpretation of value.
580
581
582
583
584
585
586 wxHTML_UNITS_PIXELS
587
588
589
590
591 i is number of pixels
592
593
23324ae1 594
23324ae1
FM
595
596
4cc4bfaf 597 wxHTML_UNITS_PERCENT
23324ae1 598
23324ae1
FM
599
600
4cc4bfaf
FM
601
602 i is interpreted as percents of width
603 of parent container
23324ae1
FM
604 */
605 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
606
607 /**
608 Sets minimal height of the container.
23324ae1
FM
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
4cc4bfaf 612 of container is never smaller than @a h - even if the subcells cover
23324ae1
FM
613 much smaller area.
614
7c913512 615 @param h
4cc4bfaf 616 The minimal height.
7c913512 617 @param align
4cc4bfaf
FM
618 If height of the container is lower than the minimum height, empty space
619 must be inserted
620 somewhere in order to ensure minimal height. This parameter is one of
23324ae1 621 wxHTML_ALIGN_TOP,
4cc4bfaf
FM
622 wxHTML_ALIGN_BOTTOM, wxHTML_ALIGN_CENTER. It refers to the contents, not to
623 the
624 empty place.
23324ae1
FM
625 */
626 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
627
628 //@{
629 /**
630 Sets floating width adjustment.
23324ae1
FM
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.
4cc4bfaf 634 @a pixel_scale is number of real pixels that equals to 1 HTML pixel.
23324ae1 635
7c913512 636 @param w
4cc4bfaf
FM
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))
7c913512 642 @param units
4cc4bfaf
FM
643 Units of w This parameter affects the interpretation of value.
644
645
646
647
648
649
650 wxHTML_UNITS_PIXELS
651
652
653
654
655 w is number of pixels
656
657
23324ae1 658
23324ae1
FM
659
660
4cc4bfaf 661 wxHTML_UNITS_PERCENT
23324ae1 662
23324ae1
FM
663
664
23324ae1 665
4cc4bfaf
FM
666 w is interpreted as percents of width
667 of parent container
7c913512 668 @param tag
4cc4bfaf
FM
669 In the second version of method, w and units
670 info is extracted from tag's WIDTH parameter.
23324ae1
FM
671 */
672 void SetWidthFloat(int w, int units);
7c913512
FM
673 void SetWidthFloat(const wxHtmlTag& tag,
674 double pixel_scale = 1.0);
23324ae1
FM
675 //@}
676};
677
678
679/**
680 @class wxHtmlLinkInfo
681 @headerfile htmlcell.h wx/html/htmlcell.h
7c913512 682
23324ae1 683 This class stores all necessary information about hypertext
7c913512
FM
684 links (as represented by @c A tag in HTML documents). In
685 current implementation it stores URL and target frame name.
23324ae1 686 @e Note that frames are not currently supported by wxHTML!
7c913512 687
23324ae1
FM
688 @library{wxhtml}
689 @category{FIXME}
690*/
691class wxHtmlLinkInfo : public wxObject
692{
693public:
694 //@{
695 /**
696 Construct hypertext link from HREF (aka URL) and TARGET (name of target
697 frame).
698 */
699 wxHtmlLinkInfo();
7c913512
FM
700 wxHtmlLinkInfo(const wxString& href,
701 const wxString& target = wxEmptyString);
23324ae1
FM
702 //@}
703
704 /**
705 Return pointer to event that generated OnLinkClicked event. Valid
706 only within wxHtmlWindow::OnLinkClicked,
707 @NULL otherwise.
708 */
4cc4bfaf 709 const wxMouseEvent* GetEvent();
23324ae1
FM
710
711 /**
712 Return @e HREF value of the @c A tag.
713 */
714 wxString GetHref();
715
716 /**
717 Return pointer to the cell that was clicked. Valid
718 only within wxHtmlWindow::OnLinkClicked,
719 @NULL otherwise.
720 */
4cc4bfaf 721 const wxHtmlCell* GetHtmlCell();
23324ae1
FM
722
723 /**
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).
727 */
728 wxString GetTarget();
729};