File: wx.BitmapBundleImpl.DoGetPreferredSize.1.py

package info (click to toggle)
wxpython4.0 4.2.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 218,584 kB
  • sloc: cpp: 962,669; python: 231,226; ansic: 170,755; makefile: 51,757; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (28 lines) | stat: -rw-r--r-- 1,069 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 means 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)