]> git.saurik.com Git - wxWidgets.git/blob - interface/html/htmlcell.h
wxUniv compilation fix for gs_windowHandles assignment
[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
27 @param flags
28 Can be one of following:
29
30 wxHTML_CLR_FOREGROUND
31
32
33 change color of text
34
35 wxHTML_CLR_BACKGROUND
36
37
38 change background color
39 */
40 wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
41 };
42
43
44 /**
45 @class wxHtmlWidgetCell
46 @headerfile htmlcell.h wx/html/htmlcell.h
47
48 wxHtmlWidgetCell is a class that provides a connection between HTML cells and
49 widgets (an object derived
50 from wxWindow). You can use it to display things like forms, input boxes etc.
51 in an HTML window.
52
53 wxHtmlWidgetCell takes care of resizing and moving window.
54
55 @library{wxhtml}
56 @category{FIXME}
57 */
58 class wxHtmlWidgetCell : public wxHtmlCell
59 {
60 public:
61 /**
62 Constructor.
63
64 @param wnd
65 Connected window. It is parent window must be the wxHtmlWindow object within
66 which it is displayed!
67
68 @param w
69 Floating width. If non-zero width of wnd window is adjusted so that it is
70 always w percents of parent container's width. (For example w = 100 means that
71 the window
72 will always have same width as parent container)
73 */
74 wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
75 };
76
77
78 /**
79 @class wxHtmlCell
80 @headerfile htmlcell.h wx/html/htmlcell.h
81
82 Internal data structure. It represents fragments of parsed HTML
83 page, the so-called @b cell - a word, picture, table, horizontal line and so on.
84 It is used by wxHtmlWindow and
85 wxHtmlWinParser to represent HTML page in memory.
86
87 You can divide cells into two groups : @e visible cells with non-zero width and
88 height and @e helper cells (usually with zero width and height) that
89 perform special actions such as color or font change.
90
91 @library{wxhtml}
92 @category{FIXME}
93
94 @seealso
95 @ref overview_cells "Cells Overview", wxHtmlContainerCell
96 */
97 class wxHtmlCell : public wxObject
98 {
99 public:
100 /**
101 Constructor.
102 */
103 wxHtmlCell();
104
105 /**
106 This method is used to adjust pagebreak position. The parameter is
107 variable that contains y-coordinate of page break (= horizontal line that
108 should not be crossed by words, images etc.). If this cell cannot be divided
109 into two pieces (each one on another page) then it moves the pagebreak
110 few pixels up.
111
112 Returns @true if pagebreak was modified, @false otherwise
113
114 Usage:
115 */
116 virtual bool AdjustPagebreak(int * pagebreak);
117
118 /**
119 Renders the cell.
120
121 @param dc
122 Device context to which the cell is to be drawn
123
124 @param x,y
125 Coordinates of parent's upper left corner (origin). You must
126 add this to m_PosX,m_PosY when passing coordinates to dc's methods
127 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
128
129 @param view_y1
130 y-coord of the first line visible in window. This is
131 used to optimize rendering speed
132
133 @param view_y2
134 y-coord of the last line visible in window. This is
135 used to optimize rendering speed
136 */
137 virtual void Draw(wxDC& dc, int x, int y, int view_y1,
138 int view_y2);
139
140 /**
141 This method is called instead of Draw() when the
142 cell is certainly out of the screen (and thus invisible). This is not
143 nonsense - some tags (like wxHtmlColourCell
144 or font setter) must be drawn even if they are invisible!
145
146 @param dc
147 Device context to which the cell is to be drawn
148
149 @param x,y
150 Coordinates of parent's upper left corner. You must
151 add this to m_PosX,m_PosY when passing coordinates to dc's methods
152 Example : dc - DrawText("hello", x + m_PosX, y + m_PosY)
153 */
154 virtual void DrawInvisible(wxDC& dc, int x, int y);
155
156 /**
157 Returns pointer to itself if this cell matches condition (or if any of the cells
158 following in the list matches), @NULL otherwise.
159 (In other words if you call top-level container's Find it will
160 return pointer to the first cell that matches the condition)
161
162 It is recommended way how to obtain pointer to particular cell or
163 to cell of some type (e.g. wxHtmlAnchorCell reacts on
164 wxHTML_COND_ISANCHOR condition)
165
166 @param condition
167 Unique integer identifier of condition
168
169 @param param
170 Optional parameters
171 */
172 virtual const wxHtmlCell* Find(int condition, const void* param);
173
174 /**
175 Returns descent value of the cell (m_Descent member).
176 See explanation:
177 */
178 int GetDescent();
179
180 /**
181 Returns pointer to the first cell in the list.
182 You can then use child's GetNext()
183 method to obtain pointer to the next cell in list.
184
185 @b Note: This shouldn't be used by the end user. If you need some way of
186 finding particular cell in the list, try Find() method
187 instead.
188 */
189 wxHtmlCell* GetFirstChild();
190
191 /**
192 Returns height of the cell (m_Height member).
193 */
194 int GetHeight();
195
196 /**
197 Returns unique cell identifier if there is any, empty string otherwise.
198 */
199 virtual wxString GetId();
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
206 @param x,y
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)
210 */
211 virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
212
213 /**
214 Returns cursor to show when mouse pointer is over the cell.
215
216 @param window
217 interface to the parent HTML window
218 */
219 virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window);
220
221 /**
222 Returns pointer to the next cell in list (see htmlcell.h if you're
223 interested in details).
224 */
225 wxHtmlCell* GetNext();
226
227 /**
228 Returns pointer to parent container.
229 */
230 wxHtmlContainerCell* GetParent();
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 */
237 int GetPosX();
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 */
244 int GetPosY();
245
246 /**
247 Returns width of the cell (m_Width member).
248 */
249 int GetWidth();
250
251 /**
252 This method performs two actions:
253
254 adjusts the cell's width according to the fact that maximal possible width is
255 @e w.
256 (this has sense when working with horizontal lines, tables etc.)
257 prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
258 based on actual width @e w
259
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
275 @param pos
276 coordinates of mouse click (this is relative to cell's origin
277
278 @param event
279 mouse event that triggered the call
280
281 @returns @true if a link was clicked, @false otherwise.
282 */
283 virtual bool ProcessMouseClick(wxHtmlWindowInterface* window,
284 const wxPoint& pos,
285 const wxMouseEvent& event);
286
287 /**
288 Sets unique cell identifier. Default value is no identifier, i.e. empty string.
289 */
290 void SetId(const wxString& id);
291
292 /**
293 Sets the hypertext link associated with this cell. (Default value
294 is wxHtmlLinkInfo("", "") (no link))
295 */
296 void SetLink(const wxHtmlLinkInfo& link);
297
298 /**
299 Sets the next cell in the list. This shouldn't be called by user - it is
300 to be used only by wxHtmlContainerCell::InsertCell.
301 */
302 void SetNext(wxHtmlCell cell);
303
304 /**
305 Sets parent container of this cell. This is called from
306 wxHtmlContainerCell::InsertCell.
307 */
308 void SetParent(wxHtmlContainerCell p);
309
310 /**
311 Sets the cell's position within parent container.
312 */
313 void SetPos(int x, int y);
314 };
315
316
317 /**
318 @class wxHtmlContainerCell
319 @headerfile htmlcell.h wx/html/htmlcell.h
320
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.
323
324 @library{wxhtml}
325 @category{FIXME}
326
327 @seealso
328 @ref overview_cells "Cells Overview"
329 */
330 class wxHtmlContainerCell : public wxHtmlCell
331 {
332 public:
333 /**
334 Constructor. @e parent is pointer to parent container or @NULL.
335 */
336 wxHtmlContainerCell(wxHtmlContainerCell parent);
337
338 /**
339 Returns container's horizontal alignment.
340 */
341 int GetAlignHor();
342
343 /**
344 Returns container's vertical alignment.
345 */
346 int GetAlignVer();
347
348 /**
349 Returns the background colour of the container or @c wxNullColour if no
350 background
351 colour is set.
352 */
353 wxColour GetBackgroundColour();
354
355 /**
356 Returns the indentation. @e ind is one of the @b wxHTML_INDENT_* constants.
357
358 @b Note: You must call GetIndentUnits()
359 with same @e ind parameter in order to correctly interpret the returned integer
360 value.
361 It is NOT always in pixels!
362 */
363 int GetIndent(int ind);
364
365 /**
366 Returns the units of indentation for @e ind where @e ind is one
367 of the @b wxHTML_INDENT_* constants.
368 */
369 int GetIndentUnits(int ind);
370
371 /**
372 Inserts new cell into the container.
373 */
374 void InsertCell(wxHtmlCell cell);
375
376 /**
377 Sets the container's alignment (both horizontal and vertical) according to
378 the values stored in @e tag. (Tags @c ALIGN parameter is extracted.) In fact
379 it is only a front-end to SetAlignHor()
380 and SetAlignVer().
381 */
382 void SetAlign(const wxHtmlTag& tag);
383
384 /**
385 Sets the container's @e horizontal alignment. During wxHtmlCell::Layout
386 each line is aligned according to @e al value.
387
388 @param al
389 new horizontal alignment. May be one of these values:
390
391 wxHTML_ALIGN_LEFT
392
393
394 lines are left-aligned (default)
395
396 wxHTML_ALIGN_JUSTIFY
397
398
399 lines are justified
400
401 wxHTML_ALIGN_CENTER
402
403
404 lines are centered
405
406 wxHTML_ALIGN_RIGHT
407
408
409 lines are right-aligned
410 */
411 void SetAlignHor(int al);
412
413 /**
414 Sets the container's @e vertical alignment. This is per-line alignment!
415
416 @param al
417 new vertical alignment. May be one of these values:
418
419 wxHTML_ALIGN_BOTTOM
420
421
422 cells are over the line (default)
423
424 wxHTML_ALIGN_CENTER
425
426
427 cells are centered on line
428
429 wxHTML_ALIGN_TOP
430
431
432 cells are under the line
433 */
434 void SetAlignVer(int al);
435
436 /**
437 Sets the background colour for this container.
438 */
439 void SetBackgroundColour(const wxColour& clr);
440
441 /**
442 Sets the border (frame) colours. A border is a rectangle around the container.
443
444 @param clr1
445 Colour of top and left lines
446
447 @param clr2
448 Colour of bottom and right lines
449 */
450 void SetBorder(const wxColour& clr1, const wxColour& clr2);
451
452 /**
453 Sets the indentation (free space between borders of container and subcells).
454
455 @param i
456 Indentation value.
457
458 @param what
459 Determines which of the four borders we're setting. It is OR
460 combination of following constants:
461
462 wxHTML_INDENT_TOP
463
464
465 top border
466
467 wxHTML_INDENT_BOTTOM
468
469
470 bottom
471
472 wxHTML_INDENT_LEFT
473
474
475 left
476
477 wxHTML_INDENT_RIGHT
478
479
480 right
481
482 wxHTML_INDENT_HORIZONTAL
483
484
485 left and right
486
487 wxHTML_INDENT_VERTICAL
488
489
490 top and bottom
491
492 wxHTML_INDENT_ALL
493
494
495 all 4 borders
496
497
498 @param units
499 Units of i. This parameter affects interpretation of value.
500
501 wxHTML_UNITS_PIXELS
502
503
504 i is number of pixels
505
506 wxHTML_UNITS_PERCENT
507
508
509 i is interpreted as percents of width
510 of parent container
511 */
512 void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
513
514 /**
515 Sets minimal height of the container.
516
517 When container's wxHtmlCell::Layout is called, m_Height
518 is set depending on layout of subcells to the height of area covered
519 by layed-out subcells. Calling this method guarantees you that the height
520 of container is never smaller than @e h - even if the subcells cover
521 much smaller area.
522
523 @param h
524 The minimal height.
525
526 @param align
527 If height of the container is lower than the minimum height, empty space must
528 be inserted
529 somewhere in order to ensure minimal height. This parameter is one of
530 wxHTML_ALIGN_TOP,
531 wxHTML_ALIGN_BOTTOM, wxHTML_ALIGN_CENTER. It refers to the contents, not to the
532 empty place.
533 */
534 void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
535
536 //@{
537 /**
538 Sets floating width adjustment.
539
540 The normal behaviour of container is that its width is the same as the width of
541 parent container (and thus you can have only one sub-container per line).
542 You can change this by setting FWA.
543
544 @e pixel_scale is number of real pixels that equals to 1 HTML pixel.
545
546 @param w
547 Width of the container. If the value is negative it means
548 complement to full width of parent container (e.g.
549 SetWidthFloat(-50, wxHTML_UNITS_PIXELS) sets the width
550 of container to parent's width minus 50 pixels. This is useful when
551 creating tables - you can call SetWidthFloat(50) and SetWidthFloat(-50))
552
553 @param units
554 Units of w This parameter affects the interpretation of value.
555
556 wxHTML_UNITS_PIXELS
557
558
559 w is number of pixels
560
561 wxHTML_UNITS_PERCENT
562
563
564 w is interpreted as percents of width
565 of parent container
566
567 @param tag
568 In the second version of method, w and units
569 info is extracted from tag's WIDTH parameter.
570 */
571 void SetWidthFloat(int w, int units);
572 void SetWidthFloat(const wxHtmlTag& tag,
573 double pixel_scale = 1.0);
574 //@}
575 };
576
577
578 /**
579 @class wxHtmlLinkInfo
580 @headerfile htmlcell.h wx/html/htmlcell.h
581
582 This class stores all necessary information about hypertext
583 links (as represented by @c A tag in HTML documents). In
584 current implementation it stores URL and target frame name.
585 @e Note that frames are not currently supported by wxHTML!
586
587 @library{wxhtml}
588 @category{FIXME}
589 */
590 class wxHtmlLinkInfo : public wxObject
591 {
592 public:
593 //@{
594 /**
595 Construct hypertext link from HREF (aka URL) and TARGET (name of target
596 frame).
597 */
598 wxHtmlLinkInfo();
599 wxHtmlLinkInfo(const wxString& href,
600 const wxString& target = wxEmptyString);
601 //@}
602
603 /**
604 Return pointer to event that generated OnLinkClicked event. Valid
605 only within wxHtmlWindow::OnLinkClicked,
606 @NULL otherwise.
607 */
608 const wxMouseEvent * GetEvent();
609
610 /**
611 Return @e HREF value of the @c A tag.
612 */
613 wxString GetHref();
614
615 /**
616 Return pointer to the cell that was clicked. Valid
617 only within wxHtmlWindow::OnLinkClicked,
618 @NULL otherwise.
619 */
620 const wxHtmlCell * GetHtmlCell();
621
622 /**
623 Return @e TARGET value of the @c A tag (this value
624 is used to specify in which frame should be the page pointed
625 by @ref gethref() Href opened).
626 */
627 wxString GetTarget();
628 };