File: wx.html.HtmlWinParser.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 (738 lines) | stat: -rw-r--r-- 19,827 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
.. 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.HtmlWinParser:

==========================================================================================================================================
|phoenix_title|  **wx.html.HtmlWinParser**
==========================================================================================================================================

This class is derived from :ref:`wx.html.HtmlParser`  and its main goal is to parse HTML input so that it can be displayed in :ref:`wx.html.HtmlWindow`.          

It uses a special :ref:`wx.html.HtmlWinTagHandler`. 







         



.. note:: 

   The product of parsing is a :ref:`wx.html.HtmlCell`  (resp. HtmlContainer) object.  







.. seealso:: :ref:`Tag Handlers <tag handlers>`    







|

|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>HtmlWinParser</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.HtmlWinParser_inheritance.png" alt="Inheritance diagram of HtmlWinParser" 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.html.HtmlParser.html" title="wx.html.HtmlParser" alt="" coords="16,5,163,35"/> <area shape="rect" id="node2" href="wx.html.HtmlWinParser.html" title="wx.html.HtmlWinParser" alt="" coords="5,83,173,112"/> </map> 
   </p>

|


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

================================================================================ ================================================================================
:meth:`~wx.html.HtmlWinParser.__init__`                                          Constructor.
:meth:`~wx.html.HtmlWinParser.CloseContainer`                                    Closes the container, sets actual container to the parent one and returns pointer to it (see :ref:`Cells and Containers <cells and containers>`).
:meth:`~wx.html.HtmlWinParser.CreateCurrentFont`                                 Creates font based on current setting (see :meth:`~HtmlWinParser.SetFontSize` , :meth:`~HtmlWinParser.SetFontBold` , :meth:`~HtmlWinParser.SetFontItalic` , :meth:`~HtmlWinParser.SetFontFixed` , :meth:`wx.html.HtmlWinParser.SetFontUnderlined` ) and returns pointer to it.
:meth:`~wx.html.HtmlWinParser.GetActualColor`                                    Returns actual text colour.
:meth:`~wx.html.HtmlWinParser.GetAlign`                                          Returns default horizontal alignment.
:meth:`~wx.html.HtmlWinParser.GetCharHeight`                                     Returns (average) int height in standard font.
:meth:`~wx.html.HtmlWinParser.GetCharWidth`                                      Returns average int width in standard font.
:meth:`~wx.html.HtmlWinParser.GetContainer`                                      Returns pointer to the currently opened container (see :ref:`Cells and Containers <cells and containers>`).
:meth:`~wx.html.HtmlWinParser.GetDC`                                             Returns pointer to the DC used during parsing.
:meth:`~wx.html.HtmlWinParser.GetFontBold`                                       Returns ``True`` if actual font is bold, ``False`` otherwise.
:meth:`~wx.html.HtmlWinParser.GetFontFace`                                       Returns actual font face name.
:meth:`~wx.html.HtmlWinParser.GetFontFixed`                                      Returns ``True`` if actual font is fixed face, ``False`` otherwise.
:meth:`~wx.html.HtmlWinParser.GetFontItalic`                                     Returns ``True`` if actual font is italic, ``False`` otherwise.
:meth:`~wx.html.HtmlWinParser.GetFontSize`                                       Returns actual font size (HTML size varies from -2 to +4)
:meth:`~wx.html.HtmlWinParser.GetFontUnderlined`                                 Returns ``True`` if actual font is underlined, ``False`` otherwise.
:meth:`~wx.html.HtmlWinParser.GetLink`                                           Returns actual hypertext link.
:meth:`~wx.html.HtmlWinParser.GetLinkColor`                                      Returns the colour of hypertext link text.
:meth:`~wx.html.HtmlWinParser.GetWindowInterface`                                Returns associated window (:ref:`wx.html.HtmlWindow`).
:meth:`~wx.html.HtmlWinParser.OpenContainer`                                     Opens new container and returns pointer to it (see :ref:`Cells and Containers <cells and containers>`).
:meth:`~wx.html.HtmlWinParser.SetActualColor`                                    Sets actual text colour.
:meth:`~wx.html.HtmlWinParser.SetAlign`                                          Sets default horizontal alignment (see :meth:`wx.html.HtmlContainerCell.SetAlignHor` ).
:meth:`~wx.html.HtmlWinParser.SetContainer`                                      Allows you to directly set opened container.
:meth:`~wx.html.HtmlWinParser.SetDC`                                             Sets the DC.
:meth:`~wx.html.HtmlWinParser.SetFontBold`                                       Sets bold flag of actualfont.
:meth:`~wx.html.HtmlWinParser.SetFontFace`                                       Sets current font face to `face`.
:meth:`~wx.html.HtmlWinParser.SetFontFixed`                                      Sets fixed face flag of actualfont.
:meth:`~wx.html.HtmlWinParser.SetFontItalic`                                     Sets italic flag of actualfont.
:meth:`~wx.html.HtmlWinParser.SetFontSize`                                       Sets actual font size (HTML size varies from 1 to 7).
:meth:`~wx.html.HtmlWinParser.SetFontUnderlined`                                 Sets underlined flag of actualfont.
:meth:`~wx.html.HtmlWinParser.SetFonts`                                          Sets fonts.
:meth:`~wx.html.HtmlWinParser.SetLink`                                           Sets actual hypertext link.
:meth:`~wx.html.HtmlWinParser.SetLinkColor`                                      Sets colour of hypertext link.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.html.HtmlWinParser.ActualColor`                                       See :meth:`~wx.html.HtmlWinParser.GetActualColor` and :meth:`~wx.html.HtmlWinParser.SetActualColor`
:attr:`~wx.html.HtmlWinParser.Align`                                             See :meth:`~wx.html.HtmlWinParser.GetAlign` and :meth:`~wx.html.HtmlWinParser.SetAlign`
:attr:`~wx.html.HtmlWinParser.CharHeight`                                        See :meth:`~wx.html.HtmlWinParser.GetCharHeight`
:attr:`~wx.html.HtmlWinParser.CharWidth`                                         See :meth:`~wx.html.HtmlWinParser.GetCharWidth`
:attr:`~wx.html.HtmlWinParser.Container`                                         See :meth:`~wx.html.HtmlWinParser.GetContainer` and :meth:`~wx.html.HtmlWinParser.SetContainer`
:attr:`~wx.html.HtmlWinParser.DC`                                                See :meth:`~wx.html.HtmlWinParser.GetDC` and :meth:`~wx.html.HtmlWinParser.SetDC`
:attr:`~wx.html.HtmlWinParser.FontBold`                                          See :meth:`~wx.html.HtmlWinParser.GetFontBold` and :meth:`~wx.html.HtmlWinParser.SetFontBold`
:attr:`~wx.html.HtmlWinParser.FontFace`                                          See :meth:`~wx.html.HtmlWinParser.GetFontFace` and :meth:`~wx.html.HtmlWinParser.SetFontFace`
:attr:`~wx.html.HtmlWinParser.FontFixed`                                         See :meth:`~wx.html.HtmlWinParser.GetFontFixed` and :meth:`~wx.html.HtmlWinParser.SetFontFixed`
:attr:`~wx.html.HtmlWinParser.FontItalic`                                        See :meth:`~wx.html.HtmlWinParser.GetFontItalic` and :meth:`~wx.html.HtmlWinParser.SetFontItalic`
:attr:`~wx.html.HtmlWinParser.FontSize`                                          See :meth:`~wx.html.HtmlWinParser.GetFontSize` and :meth:`~wx.html.HtmlWinParser.SetFontSize`
:attr:`~wx.html.HtmlWinParser.FontUnderlined`                                    See :meth:`~wx.html.HtmlWinParser.GetFontUnderlined` and :meth:`~wx.html.HtmlWinParser.SetFontUnderlined`
:attr:`~wx.html.HtmlWinParser.Link`                                              See :meth:`~wx.html.HtmlWinParser.GetLink` and :meth:`~wx.html.HtmlWinParser.SetLink`
:attr:`~wx.html.HtmlWinParser.LinkColor`                                         See :meth:`~wx.html.HtmlWinParser.GetLinkColor` and :meth:`~wx.html.HtmlWinParser.SetLinkColor`
:attr:`~wx.html.HtmlWinParser.WindowInterface`                                   See :meth:`~wx.html.HtmlWinParser.GetWindowInterface`
================================================================================ ================================================================================


|


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


.. class:: wx.html.HtmlWinParser(HtmlParser)

   **Possible constructors**::

       HtmlWinParser(wndIface=None)
       
   
   This class is derived from HtmlParser and its main goal is to parse
   HTML input so that it can be displayed in HtmlWindow.



   .. method:: __init__(self, wndIface=None)

      Constructor.                  

      Don't use the default one, use the constructor with `wndIface`  parameter (`wndIface`  is a pointer to interface object for the associated :ref:`wx.html.HtmlWindow`  or other HTML rendering window such as :ref:`wx.html.HtmlListBox`).                  


      :param `wndIface`: 
      :type `wndIface`: wx.html.HtmlWindowInterface







   .. method:: CloseContainer(self)

      Closes the container, sets actual container to the parent one and returns pointer to it (see :ref:`Cells and Containers <cells and containers>`).                  

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








   .. method:: CreateCurrentFont(self)

      Creates font based on current setting (see :meth:`SetFontSize` , :meth:`SetFontBold` , :meth:`SetFontItalic` , :meth:`SetFontFixed` , :meth:`wx.html.HtmlWinParser.SetFontUnderlined` ) and returns pointer to it.                  

      If the font was already created only a pointer is returned.                  

      :rtype: :ref:`Font`








   .. method:: GetActualColor(self)

      Returns actual text colour.                  

      :rtype: :ref:`Colour`








   .. method:: GetAlign(self)

      Returns default horizontal alignment.                  

      :rtype: `int`








   .. method:: GetCharHeight(self)

      Returns (average) int height in standard font.                  

      It is used as DC-independent metrics. 

                

      :rtype: `int`







      .. note:: 

         This function doesn't return the `actual`  height. If you want to know the height of the current font, call  GetDC->:meth:`GetCharHeight` .    








   .. method:: GetCharWidth(self)

      Returns average int width in standard font.                  

      It is used as DC-independent metrics. 

                

      :rtype: `int`







      .. note:: 

         This function doesn't return the `actual`  width. If you want to know the height of the current font, call  GetDC->:meth:`GetCharWidth` .    








   .. method:: GetContainer(self)

      Returns pointer to the currently opened container (see :ref:`Cells and Containers <cells and containers>`).                  

      Common use: ::

          self.WParser.GetContainer().InsertCell(html_cell)

                 

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








   .. method:: GetDC(self)

      Returns pointer to the DC used during parsing.                  

      :rtype: :ref:`DC`








   .. method:: GetFontBold(self)

      Returns ``True`` if actual font is bold, ``False`` otherwise.                  

      :rtype: `int`








   .. method:: GetFontFace(self)

      Returns actual font face name.                  

      :rtype: `string`








   .. method:: GetFontFixed(self)

      Returns ``True`` if actual font is fixed face, ``False`` otherwise.                  

      :rtype: `int`








   .. method:: GetFontItalic(self)

      Returns ``True`` if actual font is italic, ``False`` otherwise.                  

      :rtype: `int`








   .. method:: GetFontSize(self)

      Returns actual font size (HTML size varies from -2 to +4)                  

      :rtype: `int`








   .. method:: GetFontUnderlined(self)

      Returns ``True`` if actual font is underlined, ``False`` otherwise.                  

      :rtype: `int`








   .. method:: GetLink(self)

      Returns actual hypertext link.                  

      (This value has a non-empty :meth:`wx.html.HtmlLinkInfo.GetHref`   Href string if the parser is between <A> and </A> tags, EmptyString otherwise.)                  

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








   .. method:: GetLinkColor(self)

      Returns the colour of hypertext link text.                  

      :rtype: :ref:`Colour`








   .. method:: GetWindowInterface(self)

      Returns associated window (:ref:`wx.html.HtmlWindow`).                  

      This may be ``None``! (You should always test if it is non-NULL. For example  ``TITLE``   handler sets window title only if some window is associated, otherwise it does nothing.                   

      :rtype: :ref:`wx.html.HtmlWindowInterface`








   .. method:: OpenContainer(self)

      Opens new container and returns pointer to it (see :ref:`Cells and Containers <cells and containers>`).                  

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








   .. method:: SetActualColor(self, clr)

      Sets actual text colour.                  

      Note: this DOESN'T change the colour! You must create :ref:`wx.html.HtmlColourCell`  yourself.                  


      :param `clr`: 
      :type `clr`: wx.Colour







   .. method:: SetAlign(self, a)

      Sets default horizontal alignment (see :meth:`wx.html.HtmlContainerCell.SetAlignHor` ).                  

      Alignment of newly opened container is set to this value.                  


      :param `a`: 
      :type `a`: int







   .. method:: SetContainer(self, c)

      Allows you to directly set opened container.                  

      This is not recommended - you should use :meth:`OpenContainer`   wherever possible.                  


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




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








   .. method:: SetDC(self, dc, pixel_scale=1.0e+0)

      Sets the DC.                  

      This must be called before :meth:`wx.html.HtmlParser.Parse` ! 

      `pixel_scale`  can be used when rendering to high-resolution DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in HTML are given in pixels                  


      :param `dc`: 
      :type `dc`: wx.DC
      :param `pixel_scale`: 
      :type `pixel_scale`: float







   .. method:: SetFontBold(self, x)

      Sets bold flag of actualfont.                  

      `x`  is either ``True`` of ``False``.                  


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







   .. method:: SetFontFace(self, face)

      Sets current font face to `face`.                  

      This affects either fixed size font or proportional, depending on context (whether the parser is inside  ``<TT>``   tag or not).                   


      :param `face`: 
      :type `face`: string







   .. method:: SetFontFixed(self, x)

      Sets fixed face flag of actualfont.                  

      `x`  is either ``True`` of ``False``.                  


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







   .. method:: SetFontItalic(self, x)

      Sets italic flag of actualfont.                  

      `x`  is either ``True`` of ``False``.                  


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







   .. method:: SetFontSize(self, s)

      Sets actual font size (HTML size varies from 1 to 7).                  


      :param `s`: 
      :type `s`: int







   .. method:: SetFontUnderlined(self, x)

      Sets underlined flag of actualfont.                  

      `x`  is either ``True`` of ``False``.                  


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







   .. method:: SetFonts(self, normal_face, fixed_face, sizes)

      Sets fonts.                  

      See :meth:`wx.html.HtmlWindow.SetFonts`   for detailed description.                  


      :param `normal_face`: 
      :type `normal_face`: string
      :param `fixed_face`: 
      :type `fixed_face`: string
      :param `sizes`: 
      :type `sizes`: list of integers







   .. method:: SetLink(self, link)

      Sets actual hypertext link.                  

      Empty link is represented by :ref:`wx.html.HtmlLinkInfo`  with `Href`  equal to EmptyString.                  


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







   .. method:: SetLinkColor(self, clr)

      Sets colour of hypertext link.                  


      :param `clr`: 
      :type `clr`: wx.Colour







   .. attribute:: ActualColor

      See :meth:`~wx.html.HtmlWinParser.GetActualColor` and :meth:`~wx.html.HtmlWinParser.SetActualColor`


   .. attribute:: Align

      See :meth:`~wx.html.HtmlWinParser.GetAlign` and :meth:`~wx.html.HtmlWinParser.SetAlign`


   .. attribute:: CharHeight

      See :meth:`~wx.html.HtmlWinParser.GetCharHeight`


   .. attribute:: CharWidth

      See :meth:`~wx.html.HtmlWinParser.GetCharWidth`


   .. attribute:: Container

      See :meth:`~wx.html.HtmlWinParser.GetContainer` and :meth:`~wx.html.HtmlWinParser.SetContainer`


   .. attribute:: DC

      See :meth:`~wx.html.HtmlWinParser.GetDC` and :meth:`~wx.html.HtmlWinParser.SetDC`


   .. attribute:: FontBold

      See :meth:`~wx.html.HtmlWinParser.GetFontBold` and :meth:`~wx.html.HtmlWinParser.SetFontBold`


   .. attribute:: FontFace

      See :meth:`~wx.html.HtmlWinParser.GetFontFace` and :meth:`~wx.html.HtmlWinParser.SetFontFace`


   .. attribute:: FontFixed

      See :meth:`~wx.html.HtmlWinParser.GetFontFixed` and :meth:`~wx.html.HtmlWinParser.SetFontFixed`


   .. attribute:: FontItalic

      See :meth:`~wx.html.HtmlWinParser.GetFontItalic` and :meth:`~wx.html.HtmlWinParser.SetFontItalic`


   .. attribute:: FontSize

      See :meth:`~wx.html.HtmlWinParser.GetFontSize` and :meth:`~wx.html.HtmlWinParser.SetFontSize`


   .. attribute:: FontUnderlined

      See :meth:`~wx.html.HtmlWinParser.GetFontUnderlined` and :meth:`~wx.html.HtmlWinParser.SetFontUnderlined`


   .. attribute:: Link

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


   .. attribute:: LinkColor

      See :meth:`~wx.html.HtmlWinParser.GetLinkColor` and :meth:`~wx.html.HtmlWinParser.SetLinkColor`


   .. attribute:: WindowInterface

      See :meth:`~wx.html.HtmlWinParser.GetWindowInterface`