File: wx.GraphicsRenderer.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 (681 lines) | stat: -rw-r--r-- 15,554 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
.. 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.GraphicsRenderer:

==========================================================================================================================================
|phoenix_title|  **wx.GraphicsRenderer**
==========================================================================================================================================

A :ref:`wx.GraphicsRenderer`  is the instance corresponding to the rendering engine used.          

There may be multiple instances on a system, if there are different rendering engines present, but there is always only one instance per engine. This instance is pointed back to by all objects created by it (:ref:`wx.GraphicsContext`, :ref:`wx.GraphicsPath`  etc) and can be retrieved through their :meth:`wx.GraphicsObject.GetRenderer`   method. Therefore you can create an additional instance of a path etc. by calling :meth:`wx.GraphicsObject.GetRenderer`   and then using the appropriate CreateXXX() function of that renderer. 

::

        path = wx.GraphicsPath() # from somewhere
        brush = path.GetRenderer().CreateBrush(wx.BLACK_BRUSH)











|

|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>GraphicsRenderer</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.GraphicsRenderer_inheritance.png" alt="Inheritance diagram of GraphicsRenderer" 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.GraphicsRenderer.html" title="wx.GraphicsRenderer" alt="" coords="4,83,157,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="40,5,121,35"/> </map> 
   </p>

|


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

================================================================================ ================================================================================
:meth:`~wx.GraphicsRenderer.CreateBitmap`                                        Creates :ref:`wx.GraphicsBitmap`  from an existing :ref:`wx.Bitmap`.
:meth:`~wx.GraphicsRenderer.CreateBitmapFromImage`                               Creates :ref:`wx.GraphicsBitmap`  from an existing :ref:`wx.Image`.
:meth:`~wx.GraphicsRenderer.CreateBitmapFromNativeBitmap`                        Creates :ref:`wx.GraphicsBitmap`  from a native bitmap handle.
:meth:`~wx.GraphicsRenderer.CreateBrush`                                         Creates a native brush from a :ref:`wx.Brush`.
:meth:`~wx.GraphicsRenderer.CreateContext`                                       Creates a :ref:`wx.GraphicsContext`  from a :ref:`wx.Window`.
:meth:`~wx.GraphicsRenderer.CreateContextFromImage`                              Creates a :ref:`wx.GraphicsContext`  associated with a :ref:`wx.Image`.
:meth:`~wx.GraphicsRenderer.CreateContextFromNativeContext`                      Creates a :ref:`wx.GraphicsContext`  from a native context.
:meth:`~wx.GraphicsRenderer.CreateContextFromNativeWindow`                       Creates a :ref:`wx.GraphicsContext`  from a native window.
:meth:`~wx.GraphicsRenderer.CreateFont`                                          Creates a native graphics font from a :ref:`wx.Font`  and a text colour.
:meth:`~wx.GraphicsRenderer.CreateImageFromBitmap`                               Creates a :ref:`wx.Image`  from a :ref:`wx.GraphicsBitmap`.
:meth:`~wx.GraphicsRenderer.CreateLinearGradientBrush`                           Creates a native brush with a linear gradient.
:meth:`~wx.GraphicsRenderer.CreateMatrix`                                        Creates a native affine transformation matrix from the passed in values.
:meth:`~wx.GraphicsRenderer.CreateMeasuringContext`                              Creates a :ref:`wx.GraphicsContext`  that can be used for measuring texts only.
:meth:`~wx.GraphicsRenderer.CreatePath`                                          Creates a native graphics path which is initially empty.
:meth:`~wx.GraphicsRenderer.CreatePen`                                           Creates a native pen from a :ref:`wx.Pen`.
:meth:`~wx.GraphicsRenderer.CreateRadialGradientBrush`                           Creates a native brush with a radial gradient.
:meth:`~wx.GraphicsRenderer.CreateSubBitmap`                                     Extracts a sub-bitmap from an existing bitmap.
:meth:`~wx.GraphicsRenderer.GetCairoRenderer`                                    
:meth:`~wx.GraphicsRenderer.GetDefaultRenderer`                                  Returns the default renderer on this platform.
================================================================================ ================================================================================


|


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


.. class:: wx.GraphicsRenderer(Object)

   A GraphicsRenderer is the instance corresponding to the rendering
   engine used.



   .. method:: CreateBitmap(self, bitmap)

      Creates :ref:`wx.GraphicsBitmap`  from an existing :ref:`wx.Bitmap`.                  

      Returns an invalid NullGraphicsBitmap on failure.                  


      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap




      :rtype: :ref:`wx.GraphicsBitmap`








   .. method:: CreateBitmapFromImage(self, image)

      Creates :ref:`wx.GraphicsBitmap`  from an existing :ref:`wx.Image`.                  

      This method is more efficient than converting :ref:`wx.Image`  to :ref:`wx.Bitmap`  first and then calling :meth:`CreateBitmap`   but otherwise has the same effect. 

      Returns an invalid NullGraphicsBitmap on failure. 

                


      :param `image`: 
      :type `image`: wx.Image




      :rtype: :ref:`wx.GraphicsBitmap`







      .. versionadded:: 2.9.3 
     








   .. method:: CreateBitmapFromNativeBitmap(self, bitmap)

      Creates :ref:`wx.GraphicsBitmap`  from a native bitmap handle.                  

      `bitmap`  meaning is platform-dependent. Currently it's a GDI+  ``Bitmap``   pointer under MSW,   ``CGImage``   pointer under OS X or a   ``cairo_surface_t``   pointer when using Cairo under any platform. 

      Notice that this method takes ownership of `bitmap`, i.e. it will be destroyed when the returned :ref:`wx.GraphicsBitmap`  is.                  


      :param `bitmap`: 




      :rtype: :ref:`wx.GraphicsBitmap`








   .. method:: CreateBrush(self, brush)

      Creates a native brush from a :ref:`wx.Brush`.                  


      :param `brush`: 
      :type `brush`: wx.Brush




      :rtype: :ref:`wx.GraphicsBrush`








   .. method:: CreateContext(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **CreateContext** `(self, window)`
      
      Creates a :ref:`wx.GraphicsContext`  from a :ref:`wx.Window`.                  
      
      
      :param `window`: 
      :type `window`: wx.Window
      
      
      
      
      :rtype: :ref:`wx.GraphicsContext`
      
      
      
      
      
      
      
      **~~~**

      
      **CreateContext** `(self, windowDC)`
      
      Creates a :ref:`wx.GraphicsContext`  from a :ref:`wx.WindowDC`.                  
      
      
      :param `windowDC`: 
      :type `windowDC`: wx.WindowDC
      
      
      
      
      :rtype: :ref:`wx.GraphicsContext`
      
      
      
      
      
      
      
      **~~~**

      
      **CreateContext** `(self, memoryDC)`
      
      Creates a :ref:`wx.GraphicsContext`  from a :ref:`wx.MemoryDC`.                  
      
      
      :param `memoryDC`: 
      :type `memoryDC`: wx.MemoryDC
      
      
      
      
      :rtype: :ref:`wx.GraphicsContext`
      
      
      
      
      
      
      
      **~~~**

      
      **CreateContext** `(self, printerDC)`
      
      Creates a :ref:`wx.GraphicsContext`  from a :ref:`wx.PrinterDC`.                  
      
      
      :param `printerDC`: 
      :type `printerDC`: wx.PrinterDC
      
      
      
      
      :rtype: :ref:`wx.GraphicsContext`
      
      
      
      
      
      
      
      **~~~**






   .. method:: CreateContextFromImage(self, image)

      Creates a :ref:`wx.GraphicsContext`  associated with a :ref:`wx.Image`.                  

      This function is used by `Context.CreateFromImage()` and is not normally called directly. 

                


      :param `image`: 
      :type `image`: wx.Image




      :rtype: :ref:`wx.GraphicsContext`







      .. versionadded:: 2.9.3 
     








   .. method:: CreateContextFromNativeContext(self, context)

      Creates a :ref:`wx.GraphicsContext`  from a native context.                  

      This native context must be a CGContextRef for Core Graphics, a Graphics pointer for GDIPlus, or a cairo_t pointer for cairo.                  


      :param `context`: 




      :rtype: :ref:`wx.GraphicsContext`








   .. method:: CreateContextFromNativeWindow(self, window)

      Creates a :ref:`wx.GraphicsContext`  from a native window.                  


      :param `window`: 




      :rtype: :ref:`wx.GraphicsContext`








   .. method:: CreateFont(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **CreateFont** `(self, font, col=BLACK)`
      
      Creates a native graphics font from a :ref:`wx.Font`  and a text colour.                  
      
      
      :param `font`: 
      :type `font`: wx.Font
      :param `col`: 
      :type `col`: wx.Colour
      
      
      
      
      :rtype: :ref:`wx.GraphicsFont`
      
      
      
      
      
      
      
      **~~~**

      
      **CreateFont** `(self, sizeInPixels, facename, flags=FONTFLAG_DEFAULT, col=BLACK)`
      
      Creates a graphics font with the given characteristics.                  
      
      If possible, the :meth:`CreateFont`   overload taking :ref:`wx.Font`  should be used instead. The main advantage of this overload is that it can be used without X server connection under Unix when using Cairo. 
      
      
      
      
      :param `sizeInPixels`: Height of the font in user space units, i.e. normally pixels. Notice that this is different from the overload taking :ref:`wx.Font`  as :ref:`wx.Font`  size is specified in points.   
      :type `sizeInPixels`: float
      :param `facename`: The name of the font. The same font name might not be available under all platforms so the font name can also be empty to use the default platform font.   
      :type `facename`: string
      :param `flags`: Combination of FontFlag enum elements. Currently only  ``FONTFLAG_ITALIC``   and   ``FONTFLAG_BOLD``   are supported. By default the normal font version is used.    
      :type `flags`: int
      :param `col`: The font colour, black by default.  
      :type `col`: wx.Colour
      
      
      
      
      
      
      
      
      
      
      
      
      :rtype: :ref:`wx.GraphicsFont`
      
      
      
                        
      
      
      
      .. versionadded:: 2.9.3 
           
      
      
      
      
      
      
      
      **~~~**






   .. method:: CreateImageFromBitmap(self, bmp)

      Creates a :ref:`wx.Image`  from a :ref:`wx.GraphicsBitmap`.                  

      This method is used by the more convenient :meth:`wx.GraphicsBitmap.ConvertToImage` .                  


      :param `bmp`: 
      :type `bmp`: wx.GraphicsBitmap




      :rtype: :ref:`wx.Image`








   .. method:: CreateLinearGradientBrush(self, x1, y1, x2, y2, stops)

      Creates a native brush with a linear gradient.                  

      Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.                  


      :param `x1`: 
      :type `x1`: wx.Double
      :param `y1`: 
      :type `y1`: wx.Double
      :param `x2`: 
      :type `x2`: wx.Double
      :param `y2`: 
      :type `y2`: wx.Double
      :param `stops`: 
      :type `stops`: wx.GraphicsGradientStops




      :rtype: :ref:`wx.GraphicsBrush`








   .. method:: CreateMatrix(self, a=1.0, b=0.0, c=0.0, d=1.0, tx=0.0, ty=0.0)

      Creates a native affine transformation matrix from the passed in values.                  

      The defaults result in an identity matrix.                  


      :param `a`: 
      :type `a`: wx.Double
      :param `b`: 
      :type `b`: wx.Double
      :param `c`: 
      :type `c`: wx.Double
      :param `d`: 
      :type `d`: wx.Double
      :param `tx`: 
      :type `tx`: wx.Double
      :param `ty`: 
      :type `ty`: wx.Double




      :rtype: :ref:`wx.GraphicsMatrix`








   .. method:: CreateMeasuringContext(self)

      Creates a :ref:`wx.GraphicsContext`  that can be used for measuring texts only.                  

      No drawing commands are allowed.                  

      :rtype: :ref:`wx.GraphicsContext`








   .. method:: CreatePath(self)

      Creates a native graphics path which is initially empty.                  

      :rtype: :ref:`wx.GraphicsPath`








   .. method:: CreatePen(self, pen)

      Creates a native pen from a :ref:`wx.Pen`.                  


      :param `pen`: 
      :type `pen`: wx.Pen




      :rtype: :ref:`wx.GraphicsPen`








   .. method:: CreateRadialGradientBrush(self, xo, yo, xc, yc, radius, stops)

      Creates a native brush with a radial gradient.                  

      Stops support is new since wxWidgets 2.9.1, previously only the start and end colours could be specified.                  


      :param `xo`: 
      :type `xo`: wx.Double
      :param `yo`: 
      :type `yo`: wx.Double
      :param `xc`: 
      :type `xc`: wx.Double
      :param `yc`: 
      :type `yc`: wx.Double
      :param `radius`: 
      :type `radius`: wx.Double
      :param `stops`: 
      :type `stops`: wx.GraphicsGradientStops




      :rtype: :ref:`wx.GraphicsBrush`








   .. method:: CreateSubBitmap(self, bitmap, x, y, w, h)

      Extracts a sub-bitmap from an existing bitmap.                  

      Currently this function is implemented in the native MSW and OS X versions but not when using Cairo.                  


      :param `bitmap`: 
      :type `bitmap`: wx.GraphicsBitmap
      :param `x`: 
      :type `x`: wx.Double
      :param `y`: 
      :type `y`: wx.Double
      :param `w`: 
      :type `w`: wx.Double
      :param `h`: 
      :type `h`: wx.Double




      :rtype: :ref:`wx.GraphicsBitmap`








   .. staticmethod:: GetCairoRenderer()



      :rtype: :ref:`wx.GraphicsRenderer`








   .. staticmethod:: GetDefaultRenderer()

      Returns the default renderer on this platform.                  

      On OS X this is the Core Graphics (a.k.a. Quartz ``2D``) renderer, on MSW the GDIPlus renderer, and on GTK we currently default to the cairo renderer.                  

      :rtype: :ref:`wx.GraphicsRenderer`