diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.BitmapBundleImpl.DoGetPreferredSize.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.BitmapBundleImpl.DoGetPreferredSize.1.py new file mode 100644 index 00000000..68dd9249 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.BitmapBundleImpl.DoGetPreferredSize.1.py @@ -0,0 +1,28 @@ + + class MyCustomBitmapBundleImpl(wx.BitmapBundleImpl): + + def GetDefaultSize(): + return wx.Size(32, 32) + + def GetPreferredBitmapSizeAtScale(self, scale): + return self.DoGetPreferredSize(scale) + + def GetBitmap(self, size): + # For consistency with GetNextAvailableScale(), we must have + # bitmap variants for 32, 48 and 64px sizes. + availableSizes = [32, 48, 64] + if (size.y <= 64) + ... get the bitmap from somewhere ... + else: + n = self.GetIndexToUpscale(size) + bitmap = ... get bitmap for availableSizes[n] ... + wx.Bitmap.Rescale(bitmap, size) + return bitmap + + def GetNextAvailableScale(self, idx): + # The zero marks the end of available scales, and it this method + # won't be called again after the zero is returned. + availableScales = [1.0, 1.5, 2.0, 0] + scale = availableScales[idx] + idx += 1 + return (scale, idx) diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.MemoryDC.3.py b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.MemoryDC.3.py new file mode 100644 index 00000000..6548bb15 --- /dev/null +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.MemoryDC.3.py @@ -0,0 +1,12 @@ + + class MyWindow(wx.Window): + ... + def OnPaint(self, event): + bmp = wx.Bitmap(); + bmp.CreateWithDIPSize(self.GetClientSize(), self.GetDPIScaleFactor()) + + memdc = wx.MemoryDC(bmp) + ... use memdc to draw on the bitmap ... + + dc = wx.PaintDC(self) + dc.DrawBitmap(bmp, wx.Point(0, 0))