|
32 | 32 | from wxhelper import wx_colour, wx_bitmap
|
33 | 33 | import sys
|
34 | 34 | PY3 = sys.version_info.major > 2
|
| 35 | +WX4 = wx.version().startswith('4') |
35 | 36 |
|
36 | 37 | # 1.3.6.2 [JWdJ] 2015-02-12 tags evaluated only once
|
37 | 38 | svg_namespace = 'http://www.w3.org/2000/svg'
|
@@ -307,7 +308,7 @@ def __init__(self, can_draw_sharps_and_flats):
|
307 | 308 | self.empty_page = SvgPage(self, None)
|
308 | 309 | self.buffer = None
|
309 | 310 | # 1.3.6.2 [JWdJ] 2015-02-12 Added voicecolor
|
310 |
| - self.highlight_color = '#ee0000' |
| 311 | + self.highlight_color = '#00cc00' # '#ee0000' |
311 | 312 | self.default_transform = None
|
312 | 313 | #self.update_buffer(self.empty_page)
|
313 | 314 | if wx.Platform == "__WXMAC__":
|
@@ -592,22 +593,42 @@ def set_stroke(self, dc, svg_stroke, line_width=1.0, linecap='butt', dasharray=N
|
592 | 593 | pen = self.stroke_cache.get(key)
|
593 | 594 | if pen is None:
|
594 | 595 | if svg_stroke == 'none':
|
595 |
| - pen = self.renderer.CreatePen(wx.NullPen) |
| 596 | + if WX4: |
| 597 | + pen = self.renderer.CreatePen(wx.GraphicsPenInfo()) |
| 598 | + else: |
| 599 | + pen = self.renderer.CreatePen(wx.NullPen) |
596 | 600 | else:
|
597 |
| - wxpen = wx.Pen(wx_colour(svg_stroke), line_width) |
598 |
| - if linecap == 'butt': |
599 |
| - wxpen.SetCap(wx.CAP_BUTT) |
600 |
| - elif linecap == 'round': |
601 |
| - wxpen.SetCap(wx.CAP_ROUND) |
| 601 | + if WX4: |
| 602 | + wxpen = wx.GraphicsPenInfo(wx_colour(svg_stroke)).Width(line_width) |
| 603 | + if linecap == 'butt': |
| 604 | + wxpen.Cap(wx.CAP_BUTT) |
| 605 | + elif linecap == 'round': |
| 606 | + wxpen.Cap(wx.CAP_ROUND) |
| 607 | + else: |
| 608 | + raise Exception('linecap %s not supported yet' % linecap) |
| 609 | + # if dasharray: |
| 610 | + # # 1.3.6.3 [JWDJ] 2015-3 dasharray is always a tuple, never a str or unicode |
| 611 | + # #if type(dasharray) in (str, unicode): |
| 612 | + # # dasharray = [int(x.strip()) for x in dasharray.split(',')] |
| 613 | + # wxpen.Dashes(list(dasharray)) |
| 614 | + # wxpen.Style(wx.USER_DASH) |
| 615 | + wxpen.Join(wx.JOIN_MITER) |
602 | 616 | else:
|
603 |
| - raise Exception('linecap %s not supported yet' % linecap) |
604 |
| - if dasharray: |
605 |
| - # 1.3.6.3 [JWDJ] 2015-3 dasharray is always a tuple, never a str or unicode |
606 |
| - #if type(dasharray) in (str, unicode): |
607 |
| - # dasharray = [int(x.strip()) for x in dasharray.split(',')] |
608 |
| - wxpen.SetDashes(list(dasharray)) |
609 |
| - wxpen.SetStyle(wx.USER_DASH) |
610 |
| - wxpen.SetJoin(wx.JOIN_MITER) |
| 617 | + wxpen = wx.Pen(wx_colour(svg_stroke), line_width) |
| 618 | + if linecap == 'butt': |
| 619 | + wxpen.SetCap(wx.CAP_BUTT) |
| 620 | + elif linecap == 'round': |
| 621 | + wxpen.SetCap(wx.CAP_ROUND) |
| 622 | + else: |
| 623 | + raise Exception('linecap %s not supported yet' % linecap) |
| 624 | + if dasharray: |
| 625 | + # 1.3.6.3 [JWDJ] 2015-3 dasharray is always a tuple, never a str or unicode |
| 626 | + #if type(dasharray) in (str, unicode): |
| 627 | + # dasharray = [int(x.strip()) for x in dasharray.split(',')] |
| 628 | + wxpen.SetDashes(list(dasharray)) |
| 629 | + wxpen.SetStyle(wx.USER_DASH) |
| 630 | + wxpen.SetJoin(wx.JOIN_MITER) |
| 631 | + |
611 | 632 | pen = self.renderer.CreatePen(wxpen)
|
612 | 633 | self.stroke_cache[key] = pen
|
613 | 634 | dc.SetPen(pen)
|
@@ -752,7 +773,7 @@ def draw_svg_element(self, page, dc, svg_element, highlight, current_color):
|
752 | 773 | ##print repr(text), font_face, attr.get('font-size'), attr.get('font-weight')
|
753 | 774 | wxfont = wx.Font(font_size, font_family, style, weight, False, font_face, wx.FONTENCODING_DEFAULT)
|
754 | 775 | if wx.VERSION >= (3, 0) or '__WXMSW__' in wx.PlatformInfo:
|
755 |
| - wxfont.SetPixelSize((font_size, font_size)) |
| 776 | + wxfont.SetPixelSize(wx.Size(0, font_size)) |
756 | 777 | y += 1
|
757 | 778 | else:
|
758 | 779 | wxfont.SetPointSize(font_size)
|
|
0 commit comments