mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30:07 +01:00
Populate wx.svg with _nanosvg enum values.
This is for compatibility with wxpython 4.2.2 and any version compiled with cython 3.1. Added test cases for these enum values.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from unittests import wtc
|
from unittests import wtc
|
||||||
import wx
|
import wx
|
||||||
import sys
|
import wx.svg
|
||||||
import os
|
import os
|
||||||
|
|
||||||
fileName = 'svgtest.svg'
|
fileName = 'svgtest.svg'
|
||||||
@@ -15,8 +15,44 @@ class SvgDCTests(wtc.WidgetTestCase):
|
|||||||
dc.DrawLine(0,0, 50,50)
|
dc.DrawLine(0,0, 50,50)
|
||||||
del dc
|
del dc
|
||||||
|
|
||||||
|
self.img = wx.svg.SVGimage.CreateFromFile(fileName)
|
||||||
|
|
||||||
|
dc = wx.ClientDC(self.frame)
|
||||||
|
dc.SetBackground(wx.Brush('white'))
|
||||||
|
dc.Clear()
|
||||||
|
|
||||||
|
dcdim = min(self.frame.Size.width, self.frame.Size.height)
|
||||||
|
imgdim = min(self.img.width, self.img.height)
|
||||||
|
scale = dcdim / imgdim
|
||||||
|
|
||||||
|
ctx = wx.GraphicsContext.Create(dc)
|
||||||
|
self.img.RenderToGC(ctx, scale)
|
||||||
|
|
||||||
os.remove(fileName)
|
os.remove(fileName)
|
||||||
|
|
||||||
|
def test_SvgDC2(self):
|
||||||
|
assert wx.svg.SVGpaintType.SVG_PAINT_NONE == wx.svg.SVG_PAINT_NONE
|
||||||
|
assert wx.svg.SVGpaintType.SVG_PAINT_COLOR == wx.svg.SVG_PAINT_COLOR
|
||||||
|
assert wx.svg.SVGpaintType.SVG_PAINT_LINEAR_GRADIENT == wx.svg.SVG_PAINT_LINEAR_GRADIENT
|
||||||
|
assert wx.svg.SVGpaintType.SVG_PAINT_RADIAL_GRADIENT == wx.svg.SVG_PAINT_RADIAL_GRADIENT
|
||||||
|
|
||||||
|
assert wx.svg.SVGspreadType.SVG_SPREAD_PAD == wx.svg.SVG_SPREAD_PAD
|
||||||
|
assert wx.svg.SVGspreadType.SVG_SPREAD_REFLECT == wx.svg.SVG_SPREAD_REFLECT
|
||||||
|
assert wx.svg.SVGspreadType.SVG_SPREAD_REPEAT == wx.svg.SVG_SPREAD_REPEAT
|
||||||
|
|
||||||
|
assert wx.svg.SVGlineJoin.SVG_JOIN_MITER == wx.svg.SVG_JOIN_MITER
|
||||||
|
assert wx.svg.SVGlineJoin.SVG_JOIN_ROUND == wx.svg.SVG_JOIN_ROUND
|
||||||
|
assert wx.svg.SVGlineJoin.SVG_JOIN_BEVEL == wx.svg.SVG_JOIN_BEVEL
|
||||||
|
|
||||||
|
assert wx.svg.SVGlineCap.SVG_CAP_BUTT == wx.svg.SVG_CAP_BUTT
|
||||||
|
assert wx.svg.SVGlineCap.SVG_CAP_ROUND == wx.svg.SVG_CAP_ROUND
|
||||||
|
assert wx.svg.SVGlineCap.SVG_CAP_SQUARE == wx.svg.SVG_CAP_SQUARE
|
||||||
|
|
||||||
|
assert wx.svg.SVGfillRule.SVG_FILLRULE_NONZERO == wx.svg.SVG_FILLRULE_NONZERO
|
||||||
|
assert wx.svg.SVGfillRule.SVG_FILLRULE_EVENODD == wx.svg.SVG_FILLRULE_EVENODD
|
||||||
|
|
||||||
|
assert wx.svg.SVGflags.SVG_FLAGS_VISIBLE == wx.svg.SVG_FLAGS_VISIBLE
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,15 @@ cpdef enum SVGfillRule:
|
|||||||
cpdef enum SVGflags:
|
cpdef enum SVGflags:
|
||||||
SVG_FLAGS_VISIBLE = NSVG_FLAGS_VISIBLE
|
SVG_FLAGS_VISIBLE = NSVG_FLAGS_VISIBLE
|
||||||
|
|
||||||
|
# Populate the module namespace with enum values to keep compatibility with packages
|
||||||
|
# compiled with cython > 3.1 (see https://github.com/cython/cython/issues/4571)
|
||||||
|
globals().update(getattr(SVGpaintType, "__members__"))
|
||||||
|
globals().update(getattr(SVGspreadType, "__members__"))
|
||||||
|
globals().update(getattr(SVGlineJoin, "__members__"))
|
||||||
|
globals().update(getattr(SVGlineCap, "__members__"))
|
||||||
|
globals().update(getattr(SVGfillRule, "__members__"))
|
||||||
|
globals().update(getattr(SVGflags, "__members__"))
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Cython classes for wrapping the nanosvg structs
|
# Cython classes for wrapping the nanosvg structs
|
||||||
|
|||||||
Reference in New Issue
Block a user