[GRASS-SVN] r73364 - in grass/trunk/gui/wxpython: gui_core psmap

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 18 20:03:26 PDT 2018


Author: annakrat
Date: 2018-09-18 20:03:26 -0700 (Tue, 18 Sep 2018)
New Revision: 73364

Modified:
   grass/trunk/gui/wxpython/gui_core/wrap.py
   grass/trunk/gui/wxpython/psmap/frame.py
Log:
wxGUI: fix #3649

Modified: grass/trunk/gui/wxpython/gui_core/wrap.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/wrap.py	2018-09-17 21:19:07 UTC (rev 73363)
+++ grass/trunk/gui/wxpython/gui_core/wrap.py	2018-09-19 03:03:26 UTC (rev 73364)
@@ -351,6 +351,19 @@
             super(PseudoDC, self).EndDrawing()
 
 
+class ClientDC(wx.ClientDC):
+    """Wrapper around wx.ClientDC to have more control
+    over the widget on different platforms/wxpython versions"""
+    def __init__(self, *args, **kwargs):
+        super(ClientDC, self).__init__(*args, **kwargs)
+
+    def GetFullMultiLineTextExtent(self, string, font=None):
+        if wxPythonPhoenix:
+            return super(ClientDC, self).GetFullMultiLineTextExtent(string, font)
+        else:
+            return super(ClientDC, self).GetMultiLineTextExtent(string, font)
+
+
 class Rect(wx.Rect):
     """Wrapper around wx.Rect to have more control
     over the widget on different platforms/wxpython versions"""

Modified: grass/trunk/gui/wxpython/psmap/frame.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/frame.py	2018-09-17 21:19:07 UTC (rev 73363)
+++ grass/trunk/gui/wxpython/psmap/frame.py	2018-09-19 03:03:26 UTC (rev 73364)
@@ -42,7 +42,7 @@
 from gui_core.forms import GUI
 from gui_core.dialogs import HyperlinkDialog
 from gui_core.ghelp import ShowAboutDialog
-from gui_core.wrap import PseudoDC, Rect, StockCursor, EmptyBitmap
+from gui_core.wrap import ClientDC, PseudoDC, Rect, StockCursor, EmptyBitmap
 from psmap.menudata import PsMapMenuData
 from gui_core.toolbars import ToolSwitcher
 
@@ -914,13 +914,13 @@
         """Estimates bounding rectangle of text"""
         #fontsize = str(fontsize if fontsize >= 4 else 4)
         # dc created because of method GetTextExtent, which pseudoDC lacks
-        dc = wx.ClientDC(self)
+        dc = ClientDC(self)
 
         fn = self.makePSFont(textDict)
 
         try:
             dc.SetFont(fn)
-            w, h, lh = dc.GetMultiLineTextExtent(textDict['text'])
+            w, h, lh = dc.GetFullMultiLineTextExtent(textDict['text'])
             return (w, h)
         except:
             return (0, 0)
@@ -1900,7 +1900,7 @@
 
                     # update paper coordinates
                     points[self.currentLinePoint] = self.CanvasPaperCoordinates(
-                        rect=Rect(pos, (0, 0)), canvasToPaper=True)[:2]
+                        rect=Rect(pos[0], pos[1], 0, 0), canvasToPaper=True)[:2]
 
                 self.RedrawSelectBox(self.dragId)
 
@@ -2186,7 +2186,7 @@
 
         if pdctype == 'rectText':
             # dc created because of method GetTextExtent, which pseudoDC lacks
-            dc = wx.ClientDC(self)
+            dc = ClientDC(self)
             font = dc.GetFont()
             size = 10
             font.SetPointSize(size)
@@ -2194,7 +2194,7 @@
             dc.SetFont(font)
             pdc.SetFont(font)
             text = '\n'.join(self.itemLabels[drawid])
-            w, h = dc.GetMultiLineTextExtent(text)
+            w, h, lh = dc.GetFullMultiLineTextExtent(text)
             textExtent = (w, h)
             textRect = Rect(0, 0, *textExtent).CenterIn(bb)
             r = map(int, bb)
@@ -2407,7 +2407,7 @@
             # draw small marks signalizing resizing
             if self.instruction[id].type in ('map', 'rectangle'):
                 controlP = self.pdcObj.GetIdBounds(id).GetBottomRight()
-                rect = Rect(controlP, self.resizeBoxSize)
+                rect = Rect(controlP[0], controlP[1], self.resizeBoxSize[0], self.resizeBoxSize[1])
                 self.Draw(
                     pen=self.pen['resize'],
                     brush=self.brush['resize'],
@@ -2424,9 +2424,9 @@
                 p2Canvas = self.CanvasPaperCoordinates(
                     rect=Rect2DPS(p2Paper, (0, 0)), canvasToPaper=False)[:2]
                 rect = []
-                box = Rect(self.resizeBoxSize)
-                rect.append(box.CenterIn(Rect(p1Canvas, wx.Size())))
-                rect.append(box.CenterIn(Rect(p2Canvas, wx.Size())))
+                box = Rect(0, 0, self.resizeBoxSize[0], self.resizeBoxSize[1])
+                rect.append(box.CenterIn(Rect(p1Canvas[0], p1Canvas[1], 0, 0)))
+                rect.append(box.CenterIn(Rect(p2Canvas[0], p2Canvas[1], 0, 0)))
                 for i, point in enumerate((p1Canvas, p2Canvas)):
                     self.Draw(
                         pen=self.pen['resize'],



More information about the grass-commit mailing list