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