]> git.saurik.com Git - wxWidgets.git/blob - interface/html/htmlcell.h
add const qualifiers
[wxWidgets.git] / interface / html / htmlcell.h
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
12
13 This cell changes the colour of either the background or the foreground.
14
15 @library{wxhtml}
16 @category{FIXME}
17 */
18 class wxHtmlColourCell : public wxHtmlCell
19 {
20 public:
21 /**
22 Constructor.
23
24 @param clr
25 The color
26 @param flags
27 Can be one of following:
28
29
30
31
32
33
34 wxHTML_CLR_FOREGROUND
35
36
37
38
39 change color of text
40
41
42
43
44
45 wxHTML_CLR_BACKGROUND
46
47
48
49
50 change background color
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
59
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.
64
65 wxHtmlWidgetCell takes care of resizing and moving window.
66
67 @library{wxhtml}
68 @category{FIXME}
69 */
70 class wxHtmlWidgetCell : public wxHtmlCell
71 {
72 public:
73 /**
74 Constructor.
75
76 @param wnd
77 Connected window. It is parent window must be the wxHtmlWindow object within
78 which it is displayed!
79 @param w
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)
84 */
85 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
86 };
87
88
89 /**
90 @class wxHtmlCell
91 @headerfile htmlcell.h wx/html/htmlcell.h
92
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.
95 It is used by wxHtmlWindow and
96 wxHtmlWinParser to represent HTML page in memory.
97
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.
101
102 @library{wxhtml}
103 @category{FIXME}
104
105 @seealso
106 @ref overview_cells "Cells Overview", wxHtmlContainerCell
107 */
108 class wxHtmlCell : public wxObject
109 {
110 public:
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.
122 Returns @true if pagebreak was modified, @false otherwise
123 Usage:
124 */
125 virtual bool AdjustPagebreak(int* pagebreak);
126
127 /**
128 Renders the cell.
129
130 @param dc
131 Device context to which the cell is to be drawn
132 @param x,y
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)
136 @param view_y1
137 y-coord of the first line visible in window. This is
138 used to optimize rendering speed
139 @param view_y2
140 y-coord of the last line visible in window. This is
141 used to optimize rendering speed
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
152 @param dc
153 Device context to which the cell is to be drawn
154 @param x,y
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)
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)
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
170 @param condition
171 Unique integer identifier of condition
172 @param param
173 Optional parameters
174 */
175 virtual const wxHtmlCell* Find(int condition, const void* param);
176
177 /**
178 Returns descent value of the cell (m_Descent member).
179 See explanation:
180 */
181 int GetDescent() const;
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.
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() const;
197
198 /**
199 Returns unique cell identifier if there is any, empty string otherwise.
200 */
201 virtual wxString GetId() const;
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
208 @param x,y
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)
212 */
213 virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0) const;
214
215 /**
216 Returns cursor to show when mouse pointer is over the cell.
217
218 @param window
219 interface to the parent HTML window
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() const;
228
229 /**
230 Returns pointer to parent container.
231 */
232 wxHtmlContainerCell* GetParent() const;
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() const;
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() const;
247
248 /**
249 Returns width of the cell (m_Width member).
250 */
251 int GetWidth() const;
252
253 /**
254 This method performs two actions:
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
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
272 @param window
273 interface to the parent HTML window
274 @param pos
275 coordinates of mouse click (this is relative to cell's origin
276 @param event
277 mouse event that triggered the call
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
318
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.
321
322 @library{wxhtml}
323 @category{FIXME}
324
325 @seealso
326 @ref overview_cells "Cells Overview"
327 */
328 class wxHtmlContainerCell : public wxHtmlCell
329 {
330 public:
331 /**
332 Constructor. @a parent is pointer to parent container or @NULL.
333 */
334 wxHtmlContainerCell(wxHtmlContainerCell parent);
335
336 /**
337 Returns container's horizontal alignment.
338 */
339 int GetAlignHor() const;
340
341 /**
342 Returns container's vertical alignment.
343 */
344 int GetAlignVer() const;
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 /**
354 Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
355 @b Note: You must call GetIndentUnits()
356 with same @a ind parameter in order to correctly interpret the returned integer
357 value.
358 It is NOT always in pixels!
359 */
360 int GetIndent(int ind) const;
361
362 /**
363 Returns the units of indentation for @a ind where @a ind is one
364 of the @b wxHTML_INDENT_* constants.
365 */
366 int GetIndentUnits(int ind) const;
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
376 it is only a front-end to SetAlignHor()
377 and SetAlignVer().
378 */
379 void SetAlign(const wxHtmlTag& tag);
380
381 /**
382 Sets the container's @e horizontal alignment. During wxHtmlCell::Layout
383 each line is aligned according to @a al value.
384
385 @param al
386 new horizontal alignment. May be one of these values:
387
388
389
390
391
392
393 wxHTML_ALIGN_LEFT
394
395
396
397
398 lines are left-aligned (default)
399
400
401
402
403
404 wxHTML_ALIGN_JUSTIFY
405
406
407
408
409 lines are justified
410
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
432 */
433 void SetAlignHor(int al);
434
435 /**
436 Sets the container's @e vertical alignment. This is per-line alignment!
437
438 @param al
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
463
464
465
466
467
468 wxHTML_ALIGN_TOP
469
470
471
472
473 cells are under the line
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
485 @param clr1
486 Colour of top and left lines
487 @param clr2
488 Colour of bottom and right lines
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
495 @param i
496 Indentation value.
497 @param what
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
542
543
544 right
545
546
547
548
549
550 wxHTML_INDENT_HORIZONTAL
551
552
553
554
555 left and right
556
557
558
559
560
561 wxHTML_INDENT_VERTICAL
562
563
564
565
566 top and bottom
567
568
569
570
571
572 wxHTML_INDENT_ALL
573
574
575
576
577 all 4 borders
578 @param units
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
594
595
596
597 wxHTML_UNITS_PERCENT
598
599
600
601
602 i is interpreted as percents of width
603 of parent container
604 */
605 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
606
607 /**
608 Sets minimal height of the container.
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
612 of container is never smaller than @a h - even if the subcells cover
613 much smaller area.
614
615 @param h
616 The minimal height.
617 @param align
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
621 wxHTML_ALIGN_TOP,
622 wxHTML_ALIGN_BOTTOM, wxHTML_ALIGN_CENTER. It refers to the contents, not to
623 the
624 empty place.
625 */
626 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
627
628 //@{
629 /**
630 Sets floating width adjustment.
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.
634 @a pixel_scale is number of real pixels that equals to 1 HTML pixel.
635
636 @param w
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))
642 @param units
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
658
659
660
661 wxHTML_UNITS_PERCENT
662
663
664
665
666 w is interpreted as percents of width
667 of parent container
668 @param tag
669 In the second version of method, w and units
670 info is extracted from tag's WIDTH parameter.
671 */
672 void SetWidthFloat(int w, int units);
673 void SetWidthFloat(const wxHtmlTag& tag,
674 double pixel_scale = 1.0);
675 //@}
676 };
677
678
679 /**
680 @class wxHtmlLinkInfo
681 @headerfile htmlcell.h wx/html/htmlcell.h
682
683 This class stores all necessary information about hypertext
684 links (as represented by @c A tag in HTML documents). In
685 current implementation it stores URL and target frame name.
686 @e Note that frames are not currently supported by wxHTML!
687
688 @library{wxhtml}
689 @category{FIXME}
690 */
691 class wxHtmlLinkInfo : public wxObject
692 {
693 public:
694 //@{
695 /**
696 Construct hypertext link from HREF (aka URL) and TARGET (name of target
697 frame).
698 */
699 wxHtmlLinkInfo();
700 wxHtmlLinkInfo(const wxString& href,
701 const wxString& target = wxEmptyString);
702 //@}
703
704 /**
705 Return pointer to event that generated OnLinkClicked event. Valid
706 only within wxHtmlWindow::OnLinkClicked,
707 @NULL otherwise.
708 */
709 const wxMouseEvent* GetEvent();
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 */
721 const wxHtmlCell* GetHtmlCell();
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 };