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