diff --git a/CHANGES.rst b/CHANGES.rst index 804dad56..40eb96fd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -140,6 +140,16 @@ Changes in this release include the following: result, instead of an integer as one would expect. Using floordiv ('//') instead, solve the problem. +* Fixed a problem in wx.lib.mixins.listctrl.TextEditMixin where the height of + the editor widget could be set to zero. (See discussion in #849) + +* Fix a bug in calculating whether a tool fits into the AuiToolBar. (#863) + +* Override SetForegroundColour and SetBackgroundColour in MaskedEditMixin (#808) + +* Add an explicit wx.GraphicsContext.Create overload for wx.AutoBufferedPaintDC. (#783) + +* Return original AGW window style in AuiToolBar.GetAGWWindowStyleFlag. (#870) 4.0.1 "Lemonade" ---------------- diff --git a/etg/graphics.py b/etg/graphics.py index a86eae18..a35a7605 100644 --- a/etg/graphics.py +++ b/etg/graphics.py @@ -47,7 +47,8 @@ def run(): module.addHeaderCode('#include ') - def markFactories(klass): + def markCreateFactories(klass): + """Mark all Create methods as factories""" for func in klass.allItems(): if isinstance(func, etgtools.FunctionDef) \ and func.name.startswith('Create') \ @@ -65,20 +66,16 @@ def run(): #--------------------------------------------- c = module.find('wxGraphicsContext') assert isinstance(c, etgtools.ClassDef) - markFactories(c) tools.removeVirtuals(c) c.abstract = True c.mustHaveApp() - - # Ensure that the target DC or image lives as long as the GC does. NOTE: - # Since the Creates are static methods there is no self to associate the - # extra reference with, but since they are factories then that extra - # reference will be held by the return value of the factory instead. - for m in c.find('Create').all(): - for p in m.items: - if 'DC' in p.name or p.name == 'image': - p.keepReference = True + c.addCppMethod('wxGraphicsContext*', 'Create', '(wxAutoBufferedPaintDC* autoPaintDC /KeepReference/)', + pyArgsString='(autoPaintDC) -> GraphicsContext', + isStatic=True, + body="""\ + return wxGraphicsContext::Create(autoPaintDC); + """) m = c.find('Create').findOverload('wxEnhMetaFileDC') m.find('metaFileDC').type = 'const wxMetafileDC&' @@ -93,6 +90,19 @@ def run(): return NULL; """) + markCreateFactories(c) + + # Ensure that the target DC or image passed to Create lives as long as the + # GC does. NOTE: Since the Creates are static methods there is no self to + # associate the extra reference with, but since they are factories then + # that extra reference will be held by the return value of the factory + # instead. + for m in c.find('Create').all(): + for p in m.items: + if 'DC' in p.name or p.name == 'image': + p.keepReference = True + + c.find('GetSize.width').out = True c.find('GetSize.height').out = True c.find('GetDPI.dpiX').out = True @@ -194,7 +204,7 @@ def run(): #--------------------------------------------- c = module.find('wxGraphicsRenderer') tools.removeVirtuals(c) - markFactories(c) + markCreateFactories(c) c.abstract = True for m in c.find('CreateContext').all(): diff --git a/unittests/test_graphics.py b/unittests/test_graphics.py index 26cb520d..fefe8ff4 100644 --- a/unittests/test_graphics.py +++ b/unittests/test_graphics.py @@ -23,6 +23,27 @@ class graphics_Tests(wtc.WidgetTestCase): gc = wx.GraphicsContext.Create(img) self.assertTrue(gc.IsOk()) + def test_gcCreate4(self): + class MyPanel(wx.Panel): + def __init__(self, parent): + super(MyPanel, self).__init__(parent) + self.SetBackgroundStyle(wx.BG_STYLE_PAINT) + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.painted = False + self.gcIsOk = False + + def OnPaint(self, evt): + dc = wx.AutoBufferedPaintDC(self) + gc = wx.GraphicsContext.Create(dc) + self.gcIsOk = gc.IsOk() + self.painted = True + + panel = MyPanel(self.frame) + self.myUpdate(panel) + self.assertTrue(panel.painted) + self.assertTrue(panel.gcIsOk) + + def test_gcCreateBitmap(self): self.waitFor(50) gc = wx.GraphicsContext.Create(self.frame) diff --git a/wscript b/wscript index ad580861..f0ae50a4 100644 --- a/wscript +++ b/wscript @@ -68,20 +68,18 @@ def configure(conf): msvc_version = str( distutils.msvc9compiler.get_build_version() ) # When building for Python 3.7 the msvc_version returned will be - # "14.1" as that is the version of the BasePlatformToolkit that - # stock Python 3.7 was built with, a.k.a v141, which is the - # default in Visual Studio 2017. However, waf is using "msvc - # 15.0" to designate that version rather than "14.1" so we'll - # need to catch that case and fix up the msvc_version - # accordingly. + # "14.1" as that is the version of the BasePlatformToolkit that stock + # Python 3.7 was built with, a.k.a v141, which is the default in + # Visual Studio 2017. However, waf is using "msvc 15.0" to designate + # that version rather than "14.1" so we'll need to catch that case and + # fix up the msvc_version accordingly. if msvc_version == "14.1" and sys.version_info >= (3,7): ##msvc_version = '15.0' - # On the other hand, microsoft says that v141 and v140 - # (Visual Studio 2015) are binary compatible, so for now - # let's just drop it back to "14.0" until I get all the - # details worked out for using VS 2017 everywhere for Python - # 3.7. + # On the other hand, microsoft says that v141 and v140 (Visual + # Studio 2015) are binary compatible, so for now let's just drop + # it back to "14.0" until I get all the details worked out for + # using VS 2017 everywhere for Python 3.7. msvc_version = '14.0' conf.env['MSVC_VERSIONS'] = ['msvc ' + msvc_version] diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index af61dc72..5f6eec67 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -1706,7 +1706,7 @@ class AuiToolBar(wx.Control): :see: :meth:`SetAGWWindowStyleFlag` for an explanation of various AGW-specific style. """ - return self._agwStyle + return self._originalStyle def SetArtProvider(self, art): @@ -2935,11 +2935,12 @@ class AuiToolBar(wx.Control): cli_w, cli_h = self.GetClientSize() rect = self._items[tool_id].sizer_item.GetRect() + dropdown_size = self._art.GetElementSize(AUI_TBART_OVERFLOW_SIZE) if self._agwStyle & AUI_TB_VERTICAL: # take the dropdown size into account if self._overflow_visible: - cli_h -= self._overflow_sizer_item.GetSize().y + cli_h -= dropdown_size if rect.y+rect.height < cli_h: return True @@ -2948,7 +2949,7 @@ class AuiToolBar(wx.Control): # take the dropdown size into account if self._overflow_visible: - cli_w -= self._overflow_sizer_item.GetSize().x + cli_w -= dropdown_size if rect.x+rect.width < cli_w: return True diff --git a/wx/lib/masked/maskededit.py b/wx/lib/masked/maskededit.py index d87769d3..a0e05122 100644 --- a/wx/lib/masked/maskededit.py +++ b/wx/lib/masked/maskededit.py @@ -3229,6 +3229,13 @@ class MaskedEditMixin: #### dbg(indent=0) return self._fields[self._lookupField[pos]] + def SetForegroundColour(self, colour): + super(MaskedEditMixin, self).SetForegroundColour(colour) + self._foregroundColour = colour + + def SetBackgroundColour(self, colour): + super(MaskedEditMixin, self).SetBackgroundColour(colour) + self._validBackgroundColour = colour def ClearValue(self): """ Blanks the current control value by replacing it with the default value.""" diff --git a/wx/lib/mixins/listctrl.py b/wx/lib/mixins/listctrl.py index 021eca8d..c0c72532 100644 --- a/wx/lib/mixins/listctrl.py +++ b/wx/lib/mixins/listctrl.py @@ -611,14 +611,15 @@ class TextEditMixin: y0 = self.GetItemRect(row)[1] - editor = self.editor - editor.SetSize(x0-scrolloffset,y0, x1,-1) + def _activate_editor(editor): + editor.SetSize(x0-scrolloffset,y0, x1,-1, wx.SIZE_USE_EXISTING) + editor.SetValue(self.GetItem(row, col).GetText()) + editor.Show() + editor.Raise() + editor.SetSelection(-1,-1) + editor.SetFocus() - editor.SetValue(self.GetItem(row, col).GetText()) - editor.Show() - editor.Raise() - editor.SetSelection(-1,-1) - editor.SetFocus() + wx.CallAfter(_activate_editor, self.editor) self.curRow = row self.curCol = col diff --git a/wx/py/introspect.py b/wx/py/introspect.py index 507400d4..d5548cd9 100644 --- a/wx/py/introspect.py +++ b/wx/py/introspect.py @@ -371,7 +371,7 @@ def getBaseObject(obj): elif callable(obj): # Get the __call__ method instead. try: - obj = obj.__call__.im_func + obj = obj.__call__.__func__ dropSelf = 1 except AttributeError: dropSelf = 0 @@ -382,7 +382,7 @@ def getBaseObject(obj): def getConstructor(obj): """Return constructor for class object, or None if there isn't one.""" try: - return obj.__init__.im_func + return obj.__init__.__func__ except AttributeError: for base in obj.__bases__: constructor = getConstructor(base)