Browse Source

wxGUI/psmap: wxPython 4 compatibility

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73463 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 6 years ago
parent
commit
b5f0a0094f

+ 1 - 1
gui/wxpython/gui_core/dialogs.py

@@ -2072,7 +2072,7 @@ class SymbolDialog(wx.Dialog):
         mainPanel = wx.Panel(self, id=wx.ID_ANY)
         mainPanel = wx.Panel(self, id=wx.ID_ANY)
         mainSizer = wx.BoxSizer(wx.VERTICAL)
         mainSizer = wx.BoxSizer(wx.VERTICAL)
         vSizer = wx.BoxSizer(wx.VERTICAL)
         vSizer = wx.BoxSizer(wx.VERTICAL)
-        fgSizer = wx.FlexGridSizer(rows=2, vgap=5, hgap=5)
+        fgSizer = wx.FlexGridSizer(rows=2, cols=2, vgap=5, hgap=5)
         self.folderChoice = wx.Choice(
         self.folderChoice = wx.Choice(
             mainPanel,
             mainPanel,
             id=wx.ID_ANY,
             id=wx.ID_ANY,

+ 6 - 0
gui/wxpython/gui_core/wrap.py

@@ -382,6 +382,12 @@ class Rect(wx.Rect):
         else:
         else:
             return wx.Rect.ContainsRect(self, rect)
             return wx.Rect.ContainsRect(self, rect)
 
 
+    def OffsetXY(self, dx, dy):
+        if wxPythonPhoenix:
+            return wx.Rect.Offset(self, dx, dy)
+        else:
+            return wx.Rect.OffsetXY(self, dx, dy)
+
 
 
 class CheckBox(wx.CheckBox):
 class CheckBox(wx.CheckBox):
     """Wrapper around wx.CheckBox to have more control
     """Wrapper around wx.CheckBox to have more control

+ 8 - 6
gui/wxpython/psmap/dialogs.py

@@ -53,10 +53,12 @@ from core import globalvar
 
 
 if globalvar.wxPythonPhoenix:
 if globalvar.wxPythonPhoenix:
     import wx.adv
     import wx.adv
-    from wx.adv import OwnerDrawnComboBox
+    from wx.adv import OwnerDrawnComboBox, ODCB_PAINTING_CONTROL, ODCB_PAINTING_SELECTED
+    from wx.adv import BitmapComboBox
 else:
 else:
     import wx.combo
     import wx.combo
-    from wx.combo import OwnerDrawnComboBox
+    from wx.combo import OwnerDrawnComboBox, ODCB_PAINTING_CONTROL, ODCB_PAINTING_SELECTED
+    from wx.combo import BitmapComboBox
 
 
 if globalvar.wxPythonPhoenix:
 if globalvar.wxPythonPhoenix:
     from wx import Validator as Validator
     from wx import Validator as Validator
@@ -176,9 +178,9 @@ class PenStyleComboBox(OwnerDrawnComboBox):
         background area of each item."""
         background area of each item."""
         # If the item is selected, or its item # iseven, or we are painting the
         # If the item is selected, or its item # iseven, or we are painting the
         # combo control itself, then use the default rendering.
         # combo control itself, then use the default rendering.
-        if (item & 1 == 0 or flags & (wx.combo.ODCB_PAINTING_CONTROL |
-                                      wx.combo.ODCB_PAINTING_SELECTED)):
-            wx.combo.OwnerDrawnComboBox.OnDrawBackground(
+        if (item & 1 == 0 or flags & (ODCB_PAINTING_CONTROL |
+                                      ODCB_PAINTING_SELECTED)):
+            OwnerDrawnComboBox.OnDrawBackground(
                 self, dc, rect, item, flags)
                 self, dc, rect, item, flags)
             return
             return
 
 
@@ -4945,7 +4947,7 @@ class ScalebarDialog(PsmapDialog):
         gridBagSizer = wx.GridBagSizer(hgap=5, vgap=5)
         gridBagSizer = wx.GridBagSizer(hgap=5, vgap=5)
 
 
         sbTypeText = StaticText(panel, id=wx.ID_ANY, label=_("Type:"))
         sbTypeText = StaticText(panel, id=wx.ID_ANY, label=_("Type:"))
-        self.sbCombo = wx.combo.BitmapComboBox(panel, style=wx.CB_READONLY)
+        self.sbCombo = BitmapComboBox(panel, style=wx.CB_READONLY)
         # only temporary, images must be moved away
         # only temporary, images must be moved away
         imagePath = os.path.join(
         imagePath = os.path.join(
             globalvar.IMGDIR, "scalebar-fancy.png"), os.path.join(
             globalvar.IMGDIR, "scalebar-fancy.png"), os.path.join(

+ 4 - 1
gui/wxpython/psmap/frame.py

@@ -2137,7 +2137,10 @@ class PsMapBufferedWindow(wx.Window):
         # redraw preview
         # redraw preview
         else:  # preview mode
         else:  # preview mode
             imageRect = self.pdcImage.GetIdBounds(self.imageId)
             imageRect = self.pdcImage.GetIdBounds(self.imageId)
-            imageRect.OffsetXY(-view[0], -view[1])
+            if globalvar.wxPythonPhoenix:
+                imageRect.Offset(-view[0], -view[1])
+            else:
+                imageRect.OffsetXY(-view[0], -view[1])
             imageRect = self.ScaleRect(rect=imageRect, scale=zoomFactor)
             imageRect = self.ScaleRect(rect=imageRect, scale=zoomFactor)
             self.DrawImage(imageRect)
             self.DrawImage(imageRect)