File: wx.html.HtmlCell.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (820 lines) | stat: -rw-r--r-- 20,484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.html.HtmlCell:

==========================================================================================================================================
|phoenix_title|  **wx.html.HtmlCell**
==========================================================================================================================================

Internal data structure.          

It represents fragments of parsed HTML page, the so-called **cell**  - a word, picture, table, horizontal line and so on. It is used by :ref:`wx.html.HtmlWindow`  and :ref:`wx.html.HtmlWinParser`  to represent HTML page in memory. 

You can divide cells into two groups : `visible`  cells with non-zero width and height and `helper`  cells (usually with zero width and height) that perform special actions such as color or font change. 







         



.. seealso:: :ref:`Cells and Containers <cells and containers>`, :ref:`wx.html.HtmlContainerCell`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>HtmlCell</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.html.HtmlCell_inheritance.png" alt="Inheritance diagram of HtmlCell" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Object.html" title="wx.Object" alt="" coords="28,5,109,35"/> <area shape="rect" id="node2" href="wx.html.HtmlCell.html" title="wx.html.HtmlCell" alt="" coords="5,83,133,112"/> </map> 
   </p>

|


|sub_classes| Known Subclasses
==============================

:ref:`wx.html.HtmlColourCell`, :ref:`wx.html.HtmlContainerCell`, :ref:`wx.html.HtmlFontCell`, :ref:`wx.html.HtmlWidgetCell`, :ref:`wx.html.HtmlWordCell`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.html.HtmlCell.__init__`                                               Constructor.
:meth:`~wx.html.HtmlCell.AdjustPagebreak`                                        This method is used to adjust pagebreak position.
:meth:`~wx.html.HtmlCell.ConvertToText`                                          Converts the cell into text representation.
:meth:`~wx.html.HtmlCell.Draw`                                                   Renders the cell.
:meth:`~wx.html.HtmlCell.DrawInvisible`                                          This method is called instead of :meth:`~HtmlCell.Draw`   when the cell is certainly out of the screen (and thus invisible).
:meth:`~wx.html.HtmlCell.Find`                                                   Returns pointer to itself if this cell matches condition (or if any of the cells following in the list matches), ``None`` otherwise.
:meth:`~wx.html.HtmlCell.FindCellByPos`                                          Find a cell inside this cell positioned at the given coordinates (relative to this's positions).
:meth:`~wx.html.HtmlCell.GetDescent`                                             Returns descent value of the cell (m_Descent member).
:meth:`~wx.html.HtmlCell.GetFirstChild`                                          Returns pointer to the first cell in the list.
:meth:`~wx.html.HtmlCell.GetHeight`                                              Returns height of the cell (m_Height member).
:meth:`~wx.html.HtmlCell.GetId`                                                  Returns unique cell identifier if there is any, the empty string otherwise.
:meth:`~wx.html.HtmlCell.GetLink`                                                Returns hypertext link if associated with this cell or ``None`` otherwise.
:meth:`~wx.html.HtmlCell.GetMouseCursor`                                         Returns cursor to show when mouse pointer is over the cell.
:meth:`~wx.html.HtmlCell.GetMouseCursorAt`                                       Returns cursor to show when mouse pointer is over the specified point.
:meth:`~wx.html.HtmlCell.GetNext`                                                Returns pointer to the next cell in list (see :ref:`htmlcell.h`  if you're interested in details).
:meth:`~wx.html.HtmlCell.GetParent`                                              Returns pointer to parent container.
:meth:`~wx.html.HtmlCell.GetPosX`                                                Returns X position within parent (the value is relative to parent's upper left corner).
:meth:`~wx.html.HtmlCell.GetPosY`                                                Returns Y position within parent (the value is relative to parent's upper left corner).
:meth:`~wx.html.HtmlCell.GetWidth`                                               Returns width of the cell (m_Width member).
:meth:`~wx.html.HtmlCell.Layout`                                                 Layouts the cell.
:meth:`~wx.html.HtmlCell.ProcessMouseClick`                                      This function is simple event handler.
:meth:`~wx.html.HtmlCell.SetId`                                                  Sets unique cell identifier.
:meth:`~wx.html.HtmlCell.SetLink`                                                Sets the hypertext link associated with this cell.
:meth:`~wx.html.HtmlCell.SetNext`                                                Sets the next cell in the list.
:meth:`~wx.html.HtmlCell.SetParent`                                              Sets parent container of this cell.
:meth:`~wx.html.HtmlCell.SetPos`                                                 Sets the cell's position within parent container.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.html.HtmlCell.Descent`                                                See :meth:`~wx.html.HtmlCell.GetDescent`
:attr:`~wx.html.HtmlCell.FirstChild`                                             See :meth:`~wx.html.HtmlCell.GetFirstChild`
:attr:`~wx.html.HtmlCell.Height`                                                 See :meth:`~wx.html.HtmlCell.GetHeight`
:attr:`~wx.html.HtmlCell.Id`                                                     See :meth:`~wx.html.HtmlCell.GetId` and :meth:`~wx.html.HtmlCell.SetId`
:attr:`~wx.html.HtmlCell.Link`                                                   See :meth:`~wx.html.HtmlCell.GetLink` and :meth:`~wx.html.HtmlCell.SetLink`
:attr:`~wx.html.HtmlCell.Next`                                                   See :meth:`~wx.html.HtmlCell.GetNext` and :meth:`~wx.html.HtmlCell.SetNext`
:attr:`~wx.html.HtmlCell.Parent`                                                 See :meth:`~wx.html.HtmlCell.GetParent` and :meth:`~wx.html.HtmlCell.SetParent`
:attr:`~wx.html.HtmlCell.PosX`                                                   See :meth:`~wx.html.HtmlCell.GetPosX`
:attr:`~wx.html.HtmlCell.PosY`                                                   See :meth:`~wx.html.HtmlCell.GetPosY`
:attr:`~wx.html.HtmlCell.Width`                                                  See :meth:`~wx.html.HtmlCell.GetWidth`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.html.HtmlCell(Object)

   **Possible constructors**::

       HtmlCell()
       
   
   Internal data structure.



   .. method:: __init__(self)

      Constructor.                   





   .. method:: AdjustPagebreak(self, pagebreak, known_pagebreaks, pageHeight)

      This method is used to adjust pagebreak position.                  

      The first parameter is a variable that contains the y-coordinate of the page break (= horizontal line that should not be crossed by words, images etc.). If this cell cannot be divided into two pieces (each one on another page) then it either moves the pagebreak a few pixels up, if possible, or, if the cell cannot fit on the page at all, then the cell is forced to split unconditionally. 

      Returns ``True`` if pagebreak was modified, ``False`` otherwise. 




      :param `pagebreak`: position in pixel of the pagebreak.  
      :type `pagebreak`: int
      :param `known_pagebreaks`: the list of the previous pagebreaks  
      :type `known_pagebreaks`: list of integers
      :param `pageHeight`: the height in pixel of the page drawable area  
      :type `pageHeight`: int










      :rtype: `tuple`



      ::

          ret_value, kp = container.AdjustPagebreak(p, kp, ph)
          while ret_value:
              ret_value, kp = container.AdjustPagebreak(p, kp, ph)

                  



      :returns: 

         ( `bool`, `pagebreak` ) 








   .. method:: ConvertToText(self, sel)

      Converts the cell into text representation.                  

      If sel != ``None`` then only part of the cell inside the selection is converted.                  


      :param `sel`: 
      :type `sel`: wx.html.HtmlSelection




      :rtype: `string`








   .. method:: Draw(self, dc, x, y, view_y1, view_y2, info)

      Renders the cell.                  




      :param `dc`: Device context to which the cell is to be drawn.   
      :type `dc`: wx.DC
      :param `x`: 
      :type `x`: int
      :param `y`: Coordinates of parent's upper left corner (origin). You must add this to m_PosX,m_PosY when passing coordinates to dc's methods Example: ::

              dc.DrawText("hello", x + cell.PosX, y + cell.PosY)


      :type `y`: int
      :param `view_y1`: y-coord of the first line visible in window. This is used to optimize rendering speed.   
      :type `view_y1`: int
      :param `view_y2`: y-coord of the last line visible in window. This is used to optimize rendering speed.   
      :type `view_y2`: int
      :param `info`: Additional information for the rendering of the cell.   
      :type `info`: wx.html.HtmlRenderingInfo












                  





   .. method:: DrawInvisible(self, dc, x, y, info)

      This method is called instead of :meth:`Draw`   when the cell is certainly out of the screen (and thus invisible).                  

      This is not nonsense - some tags (like :ref:`wx.html.HtmlColourCell`  or font setter) must be drawn even if they are invisible! 




      :param `dc`: Device context to which the cell is to be drawn.   
      :type `dc`: wx.DC
      :param `x`: 
      :type `x`: int
      :param `y`: Coordinates of parent's upper left corner. You must add this to m_PosX,m_PosY when passing coordinates to dc's methods Example: ::

              dc.DrawText("hello", x + cell.PosX, y + cell.PosY)


      :type `y`: int
      :param `info`: Additional information for the rendering of the cell.   
      :type `info`: wx.html.HtmlRenderingInfo








                  





   .. method:: Find(self, condition, param)

      Returns pointer to itself if this cell matches condition (or if any of the cells following in the list matches), ``None`` otherwise.                  

      (In other words if you call top-level container's :meth:`Find`   it will return pointer to the first cell that matches the condition) 

      It is recommended way how to obtain pointer to particular cell or to cell of some type (e.g. HtmlAnchorCell reacts on ``wx.html.HTML_COND_ISANCHOR`` condition). 




      :param `condition`: Unique integer identifier of condition   
      :type `condition`: int
      :param `param`: Optional parameters   
      :type `param`: string








      :rtype: :ref:`wx.html.HtmlCell`



                  





   .. method:: FindCellByPos(self, x, y, flags=HTML_FIND_EXACT)

      Find a cell inside this cell positioned at the given coordinates (relative to this's positions).                  

      Returns ``None`` if no such cell exists. The flag can be used to specify whether to look for terminal or nonterminal cells or both. In either case, returned cell is deepest cell in cells tree that contains [x,y].                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      :param `flags`: 




      :rtype: :ref:`wx.html.HtmlCell`








   .. method:: GetDescent(self)

      Returns descent value of the cell (m_Descent member).                  

      See explanation: 

      .. figure:: _static/images/overviews/htmlcell_descent.png
         :align: center


      |

                 

      :rtype: `int`








   .. method:: GetFirstChild(self)

      Returns pointer to the first cell in the list.                  

      You can then use child's :meth:`GetNext`   method to obtain pointer to the next cell in list. 

                

      :rtype: :ref:`wx.html.HtmlCell`







      .. note:: 

         This shouldn't be used by the end user. If you need some way of finding particular cell in the list, try :meth:`Find`   method instead.   








   .. method:: GetHeight(self)

      Returns height of the cell (m_Height member).                  

      :rtype: `int`








   .. method:: GetId(self)

      Returns unique cell identifier if there is any, the empty string otherwise.                  

      :rtype: `string`








   .. method:: GetLink(self, x=0, y=0)

      Returns hypertext link if associated with this cell or ``None`` otherwise.                  

      See :ref:`wx.html.HtmlLinkInfo`. (Note: this makes sense only for visible tags). 




      :param `x`: 
      :type `x`: int
      :param `y`: Coordinates of position where the user pressed mouse button. These coordinates are used e.g. by ``COLORMAP``. Values are relative to the upper left corner of ``THIS`` cell (i.e. from 0 to m_Width or m_Height)   
      :type `y`: int






      :rtype: :ref:`wx.html.HtmlLinkInfo`



                  





   .. method:: GetMouseCursor(self, window)

      Returns cursor to show when mouse pointer is over the cell.                  




      :param `window`: interface to the parent HTML window  
      :type `window`: wx.html.HtmlWindowInterface






      :rtype: :ref:`Cursor`



                  



      .. seealso:: :meth:`GetMouseCursorAt`     








   .. method:: GetMouseCursorAt(self, window, rePos)

      Returns cursor to show when mouse pointer is over the specified point.                  

      This function should be overridden instead of :meth:`GetMouseCursorAt`   if the cursor should depend on the exact position of the mouse in the window. 




      :param `window`: interface to the parent HTML window   
      :type `window`: wx.html.HtmlWindowInterface
      :param `rePos`: Position to show cursor.  
      :type `rePos`: wx.Point








      :rtype: :ref:`Cursor`



                  



      .. versionadded:: 3.0   








   .. method:: GetNext(self)

      Returns pointer to the next cell in list (see :ref:`htmlcell.h`  if you're interested in details).                  

      :rtype: :ref:`wx.html.HtmlCell`








   .. method:: GetParent(self)

      Returns pointer to parent container.                  

      :rtype: :ref:`wx.html.HtmlContainerCell`








   .. method:: GetPosX(self)

      Returns X position within parent (the value is relative to parent's upper left corner).                  

      The returned value is meaningful only if parent's :meth:`Layout`   was called before!                  

      :rtype: `int`








   .. method:: GetPosY(self)

      Returns Y position within parent (the value is relative to parent's upper left corner).                  

      The returned value is meaningful only if parent's :meth:`Layout`   was called before!                  

      :rtype: `int`








   .. method:: GetWidth(self)

      Returns width of the cell (m_Width member).                  

      :rtype: `int`








   .. method:: Layout(self, w)

      Layouts the cell.                  

      This method performs two actions:

      - adjusts the cell's width according to the fact that maximal possible width is `w`  (this has sense when working with horizontal lines, tables etc.) 
      - prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members) based on actual width `w`   




      It must be called before displaying cells structure because m_PosX and m_PosY are undefined (or invalid) before calling :meth:`Layout` .                  


      :param `w`: 
      :type `w`: int







   .. method:: ProcessMouseClick(self, window, pos, event)

      This function is simple event handler.                  

      Each time the user clicks mouse button over a cell within :ref:`wx.html.HtmlWindow`  this method of that cell is called. Default behaviour is to call :meth:`wx.html.HtmlWindow.LoadPage` . 




      :param `window`: interface to the parent HTML window   
      :type `window`: wx.html.HtmlWindowInterface
      :param `pos`: coordinates of mouse click (this is relative to cell's origin   
      :type `pos`: wx.Point
      :param `event`: mouse event that triggered the call  
      :type `event`: wx.MouseEvent










      :rtype: `bool`



                  



      :returns: 

         ``True`` if a link was clicked, ``False`` otherwise.  







      .. versionadded:: 2.7.0 
         (before OnMouseClick() method served a similar purpose).  







      .. note:: 

         If you need more "advanced" event handling you should use HtmlBinderCell instead.   








   .. method:: SetId(self, id)

      Sets unique cell identifier.                  

      Default value is no identifier, i.e. empty string.                  


      :param `id`: 
      :type `id`: string







   .. method:: SetLink(self, link)

      Sets the hypertext link associated with this cell.                  

      (Default value is :ref:`wx.html.HtmlLinkInfo`("", "") (no link))                  


      :param `link`: 
      :type `link`: wx.html.HtmlLinkInfo







   .. method:: SetNext(self, cell)

      Sets the next cell in the list.                  

      This shouldn't be called by user - it is to be used only by :meth:`wx.html.HtmlContainerCell.InsertCell` .                  


      :param `cell`: 
      :type `cell`: wx.html.HtmlCell







   .. method:: SetParent(self, p)

      Sets parent container of this cell.                  

      This is called from :meth:`wx.html.HtmlContainerCell.InsertCell` .                  


      :param `p`: 
      :type `p`: wx.html.HtmlContainerCell







   .. method:: SetPos(self, x, y)

      Sets the cell's position within parent container.                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int







   .. attribute:: Descent

      See :meth:`~wx.html.HtmlCell.GetDescent`


   .. attribute:: FirstChild

      See :meth:`~wx.html.HtmlCell.GetFirstChild`


   .. attribute:: Height

      See :meth:`~wx.html.HtmlCell.GetHeight`


   .. attribute:: Id

      See :meth:`~wx.html.HtmlCell.GetId` and :meth:`~wx.html.HtmlCell.SetId`


   .. attribute:: Link

      See :meth:`~wx.html.HtmlCell.GetLink` and :meth:`~wx.html.HtmlCell.SetLink`


   .. attribute:: Next

      See :meth:`~wx.html.HtmlCell.GetNext` and :meth:`~wx.html.HtmlCell.SetNext`


   .. attribute:: Parent

      See :meth:`~wx.html.HtmlCell.GetParent` and :meth:`~wx.html.HtmlCell.SetParent`


   .. attribute:: PosX

      See :meth:`~wx.html.HtmlCell.GetPosX`


   .. attribute:: PosY

      See :meth:`~wx.html.HtmlCell.GetPosY`


   .. attribute:: Width

      See :meth:`~wx.html.HtmlCell.GetWidth`