File: wx.RendererNative.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 (764 lines) | stat: -rw-r--r-- 22,227 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
.. 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.RendererNative:

==========================================================================================================================================
|phoenix_title|  **wx.RendererNative**
==========================================================================================================================================

First, a brief introduction to :ref:`wx.RendererNative`  and why it is needed.          

Usually wxWidgets uses the underlying low level GUI system to draw all the controls - this is what we mean when we say that it is a "native" framework. However not all controls exist under all (or even any) platforms and in this case wxWidgets provides a default, generic, implementation of them written in wxWidgets itself. 

These controls don't have the native appearance if only the standard line drawing and other graphics primitives are used, because the native appearance is different under different platforms while the lines are always drawn in the same way. 

This is why we have renderers: :ref:`wx.RendererNative`  is a class which virtualizes the drawing, i.e. it abstracts the drawing operations and allows you to draw say, a button, without caring about exactly how this is done. Of course, as we can draw the button differently in different renderers, this also allows us to emulate the native look and feel. 

So the renderers work by exposing a large set of high-level drawing functions which are used by the generic controls. There is always a default global renderer but it may be changed or extended by the user, see :ref:`Render Sample <render sample>`. 

All drawing functions take some standard parameters: 



- `win`  - The window being drawn. It is normally not used and when it is it should only be used as a generic :ref:`wx.Window`  (in order to get its low level handle, for example), but you should not assume that it is of some given type as the same renderer function may be reused for drawing different kinds of control.  
- `dc`  - The :ref:`wx.DC`  to draw on. Only this device context should be used for drawing. It is not necessary to restore pens and brushes for it on function exit but, on the other hand, you shouldn't assume that it is in any specific state on function entry: the rendering functions should always prepare it.  
- `rect`  - The bounding rectangle for the element to be drawn.  
- `flags`  - The optional flags (none by default) which can be a combination of the ``CONTROL_FLAGS``. 

Note that each drawing function restores the
:ref:`wx.DC`  attributes if it changes them, so it is safe to assume that the same pen, brush and colours that were active before the call to this function are still in effect after it. 









|

|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>RendererNative</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.RendererNative_inheritance.png" alt="Inheritance diagram of RendererNative" 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.RendererNative.html" title="wx.RendererNative" alt="" coords="5,5,144,35"/> </map> 
   </p>

|


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

:ref:`wx.DelegateRendererNative`

|


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

================================================================================ ================================================================================
:meth:`~wx.RendererNative.DrawCheckBox`                                          Draw a check box.
:meth:`~wx.RendererNative.DrawChoice`                                            Draw a native :ref:`wx.Choice`.
:meth:`~wx.RendererNative.DrawComboBox`                                          Draw a native :ref:`wx.ComboBox`.
:meth:`~wx.RendererNative.DrawComboBoxDropButton`                                Draw a button like the one used by :ref:`wx.ComboBox`  to show a drop down window.
:meth:`~wx.RendererNative.DrawDropArrow`                                         Draw a drop down arrow that is suitable for use outside a combo box.
:meth:`~wx.RendererNative.DrawFocusRect`                                         Draw a focus rectangle using the specified rectangle.
:meth:`~wx.RendererNative.DrawHeaderButton`                                      Draw the header control button (used, for example, by :ref:`wx.ListCtrl`).
:meth:`~wx.RendererNative.DrawHeaderButtonContents`                              Draw the contents of a header control button (label, sort arrows, etc.).
:meth:`~wx.RendererNative.DrawItemSelectionRect`                                 Draw a selection rectangle underneath the text as used e.g.
:meth:`~wx.RendererNative.DrawPushButton`                                        Draw a blank push button that looks very similar to :ref:`wx.Button`.
:meth:`~wx.RendererNative.DrawRadioBitmap`                                       Draw a native :ref:`wx.RadioButton`  bitmap.
:meth:`~wx.RendererNative.DrawSplitterBorder`                                    Draw the border for sash window: this border must be such that the sash drawn by :meth:`~RendererNative.DrawSplitterSash`   blends into it well.
:meth:`~wx.RendererNative.DrawSplitterSash`                                      Draw a sash.
:meth:`~wx.RendererNative.DrawTextCtrl`                                          Draw a native :ref:`wx.TextCtrl`  frame.
:meth:`~wx.RendererNative.DrawTitleBarBitmap`                                    Draw a title bar button in the given state.
:meth:`~wx.RendererNative.DrawTreeItemButton`                                    Draw the expanded/collapsed icon for a tree control item.
:meth:`~wx.RendererNative.Get`                                                   Return the currently used renderer.
:meth:`~wx.RendererNative.GetCheckBoxSize`                                       Returns the size of a check box.
:meth:`~wx.RendererNative.GetDefault`                                            Return the default (native) implementation for this platform :meth:`~RendererNative.Set`   in which case the return value of this method may be different from the return value of :meth:`~RendererNative.Get` .
:meth:`~wx.RendererNative.GetGeneric`                                            Return the generic implementation of the renderer.
:meth:`~wx.RendererNative.GetHeaderButtonHeight`                                 Returns the height of a header button, either a fixed platform height if available, or a generic height based on the `win`  window's font.
:meth:`~wx.RendererNative.GetHeaderButtonMargin`                                 Returns the horizontal margin on the left and right sides of header button's label.
:meth:`~wx.RendererNative.GetSplitterParams`                                     Get the splitter parameters, see :ref:`wx.SplitterRenderParams`.
:meth:`~wx.RendererNative.GetVersion`                                            This function is used for version checking: :meth:`~RendererNative.Load`   refuses to load any shared libraries implementing an older or incompatible version.
:meth:`~wx.RendererNative.Load`                                                  Load the renderer from the specified ``DLL``, the returned pointer must be deleted by caller if not ``None`` when it is not used any more.
:meth:`~wx.RendererNative.Set`                                                   Set the renderer to use, passing ``None`` reverts to using the default renderer (the global renderer must always exist).
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.RendererNative.Version`                                               See :meth:`~wx.RendererNative.GetVersion`
================================================================================ ================================================================================


|


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


.. class:: wx.RendererNative(object)

   First, a brief introduction to RendererNative and why it is needed.



   .. method:: DrawCheckBox(self, win, dc, rect, flags=0)

      Draw a check box.                  

      `flags`  may have the  ``CONTROL_CHECKED`` ,   ``CONTROL_CURRENT``   or   ``CONTROL_UNDETERMINED``   bit set, see  ``CONTROL_FLAGS``.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawChoice(self, win, dc, rect, flags=0)

      Draw a native :ref:`wx.Choice`.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawComboBox(self, win, dc, rect, flags=0)

      Draw a native :ref:`wx.ComboBox`.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawComboBoxDropButton(self, win, dc, rect, flags=0)

      Draw a button like the one used by :ref:`wx.ComboBox`  to show a drop down window.                  

      The usual appearance is a downwards pointing arrow. 

      `flags`  may have the  ``CONTROL_PRESSED``   or   ``CONTROL_CURRENT``   bit set, see  ``CONTROL_FLAGS``.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawDropArrow(self, win, dc, rect, flags=0)

      Draw a drop down arrow that is suitable for use outside a combo box.                  

      Arrow will have transparent background. 

      `rect`  is not entirely filled by the arrow. Instead, you should use bounding rectangle of a drop down button which arrow matches the size you need. 

      `flags`  may have the  ``CONTROL_PRESSED``   or   ``CONTROL_CURRENT``   bit set, see  ``CONTROL_FLAGS``.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawFocusRect(self, win, dc, rect, flags=0)

      Draw a focus rectangle using the specified rectangle.                  

      :ref:`wx.ListCtrl`. 

      The only supported flags is  ``CONTROL_SELECTED``   for items which are selected. see  ``CONTROL_FLAGS``.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawHeaderButton(self, win, dc, rect, flags=0, sortArrow=HDR_SORT_ICON_NONE, params=None)

      Draw the header control button (used, for example, by :ref:`wx.ListCtrl`).                  

      Depending on platforms the `flags`  parameter may support the  ``CONTROL_SELECTED``       ``CONTROL_DISABLED``   and   ``CONTROL_CURRENT``   bits, see  ``CONTROL_FLAGS``. 

                


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int
      :param `sortArrow`: 
      :type `sortArrow`: wx.HeaderSortIconType
      :param `params`: 
      :type `params`: wx.HeaderButtonParams




      :rtype: `int`







      :returns: 

         The optimal width to contain the unabbreviated label text or bitmap, the sort arrow if present, and internal margins.   








   .. method:: DrawHeaderButtonContents(self, win, dc, rect, flags=0, sortArrow=HDR_SORT_ICON_NONE, params=None)

      Draw the contents of a header control button (label, sort arrows, etc.).                  

      This function is normally only called by :meth:`DrawHeaderButton` . 

      Depending on platforms the `flags`  parameter may support the  ``CONTROL_SELECTED``       ``CONTROL_DISABLED``   and   ``CONTROL_CURRENT``   bits, see  ``CONTROL_FLAGS``. 

                


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int
      :param `sortArrow`: 
      :type `sortArrow`: wx.HeaderSortIconType
      :param `params`: 
      :type `params`: wx.HeaderButtonParams




      :rtype: `int`







      :returns: 

         The optimal width to contain the unabbreviated label text or bitmap, the sort arrow if present, and internal margins.   








   .. method:: DrawItemSelectionRect(self, win, dc, rect, flags=0)

      Draw a selection rectangle underneath the text as used e.g.                  

      in a :ref:`wx.ListCtrl`. 

      The supported `flags`  are  ``CONTROL_SELECTED``   for items which are selected (e.g. often a blue rectangle) and   ``CONTROL_CURRENT``   for the item that has the focus (often a dotted line around the item's text).   ``CONTROL_FOCUSED``   may be used to indicate if the control has the focus (otherwise the selection rectangle is e.g. often grey and not blue). This may be ignored by the renderer or deduced by the code directly from the  `win`.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawPushButton(self, win, dc, rect, flags=0)

      Draw a blank push button that looks very similar to :ref:`wx.Button`.                  

      `flags`  may have the  ``CONTROL_PRESSED`` ,   ``CONTROL_CURRENT``   or   ``CONTROL_ISDEFAULT``   bit set, see  ``CONTROL_FLAGS``.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawRadioBitmap(self, win, dc, rect, flags=0)

      Draw a native :ref:`wx.RadioButton`  bitmap.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawSplitterBorder(self, win, dc, rect, flags=0)

      Draw the border for sash window: this border must be such that the sash drawn by :meth:`DrawSplitterSash`   blends into it well.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawSplitterSash(self, win, dc, size, position, orient, flags=0)

      Draw a sash.                  

      The `orient`  parameter defines whether the sash should be vertical or horizontal and how the `position`  should be interpreted.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `size`: 
      :type `size`: wx.Size
      :param `position`: 
      :type `position`: int
      :param `orient`: 
      :type `orient`: wx.Orientation
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawTextCtrl(self, win, dc, rect, flags=0)

      Draw a native :ref:`wx.TextCtrl`  frame.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: DrawTitleBarBitmap(self, win, dc, rect, button, flags=0)

      Draw a title bar button in the given state.                  

      This function is currently only available under MSW and OS X (and only for ``wx.TITLEBAR_BUTTON_CLOSE`` under the latter), its best replacement for the other platforms is to use :ref:`wx.ArtProvider`  to retrieve the bitmaps for  ``ART_HELP``   and   ``ART_CLOSE``   (but not any other title bar buttons and not for any state but normal, i.e. not pressed and not current one). 

      The presence of this function is indicated by  ``HAS_DRAW_TITLE_BAR_BITMAP``   symbol being defined. 

      Also notice that ``PNG`` handler must be enabled using :meth:`wx.Image.AddHandler`   to use this function under OS X currently as the bitmaps are embedded in the library itself in ``PNG`` format. 

                


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `button`: 
      :type `button`: wx.TitleBarButton
      :param `flags`: 
      :type `flags`: int






      .. versionadded:: 2.9.1 
     








   .. method:: DrawTreeItemButton(self, win, dc, rect, flags=0)

      Draw the expanded/collapsed icon for a tree control item.                  

      To draw an expanded button the `flags`  parameter must contain  ``CONTROL_EXPANDED``   bit, see  ``CONTROL_FLAGS``.                  


      :param `win`: 
      :type `win`: wx.Window
      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. staticmethod:: Get()

      Return the currently used renderer.                  

      :rtype: :ref:`wx.RendererNative`








   .. method:: GetCheckBoxSize(self, win)

      Returns the size of a check box.                  

      The `win`  parameter is not used currently and can be ``None``.                  


      :param `win`: 
      :type `win`: wx.Window




      :rtype: :ref:`wx.Size`








   .. staticmethod:: GetDefault()

      Return the default (native) implementation for this platform :meth:`Set`   in which case the return value of this method may be different from the return value of :meth:`Get` .                  

      :rtype: :ref:`wx.RendererNative`








   .. staticmethod:: GetGeneric()

      Return the generic implementation of the renderer.                  

      Under some platforms, this is the default renderer implementation, others have platform-specific default renderer which can be retrieved by calling :meth:`GetDefault` .                  

      :rtype: :ref:`wx.RendererNative`








   .. method:: GetHeaderButtonHeight(self, win)

      Returns the height of a header button, either a fixed platform height if available, or a generic height based on the `win`  window's font.                  


      :param `win`: 
      :type `win`: wx.Window




      :rtype: `int`








   .. method:: GetHeaderButtonMargin(self, win)

      Returns the horizontal margin on the left and right sides of header button's label.                  

                


      :param `win`: 
      :type `win`: wx.Window




      :rtype: `int`







      .. versionadded:: 2.9.2 
     








   .. method:: GetSplitterParams(self, win)

      Get the splitter parameters, see :ref:`wx.SplitterRenderParams`.                  

      The `win`  parameter should be a :ref:`wx.SplitterWindow`.                  


      :param `win`: 
      :type `win`: wx.Window




      :rtype: :ref:`wx.SplitterRenderParams`








   .. method:: GetVersion(self)

      This function is used for version checking: :meth:`Load`   refuses to load any shared libraries implementing an older or incompatible version.                  

                

      :rtype: :ref:`wx.RendererVersion`







      .. note:: 

         The implementation of this method is always the same in all renderers (simply construct :ref:`wx.RendererVersion`  using the  ``RendererVersion::Current_XXX``   values), but it has to be in the derived, not base, class, to detect mismatches between the renderers versions and so you have to implement it anew in all renderers.    








   .. staticmethod:: Load(name)

      Load the renderer from the specified ``DLL``, the returned pointer must be deleted by caller if not ``None`` when it is not used any more.                  

      The `name`  should be just the base name of the renderer and not the full name of the ``DLL`` file which is constructed differently (using :meth:`DynamicLibrary.CanonicalizePluginName` ) on different systems.                  


      :param `name`: 
      :type `name`: string




      :rtype: :ref:`wx.RendererNative`








   .. staticmethod:: Set(renderer)

      Set the renderer to use, passing ``None`` reverts to using the default renderer (the global renderer must always exist).                  

      Return the previous renderer used with :meth:`Set`   or ``None`` if none.                  


      :param `renderer`: 
      :type `renderer`: wx.RendererNative




      :rtype: :ref:`wx.RendererNative`








   .. attribute:: Version

      See :meth:`~wx.RendererNative.GetVersion`