110 if self.Block is not None: |
110 if self.Block is not None: |
111 min_width, min_height = self.Block.GetMinSize() |
111 min_width, min_height = self.Block.GetMinSize() |
112 width = max(self.MinBlockSize[0], min_width) |
112 width = max(self.MinBlockSize[0], min_width) |
113 height = max(self.MinBlockSize[1], min_height) |
113 height = max(self.MinBlockSize[1], min_height) |
114 self.Block.SetSize(width, height) |
114 self.Block.SetSize(width, height) |
115 clientsize = self.Preview.GetClientSize() |
115 client_size = self.Preview.GetClientSize() |
116 x = (clientsize.width - width) / 2 |
116 if (width * 1.2 > client_size.width or |
117 y = (clientsize.height - height) / 2 |
117 height * 1.2 > client_size.height): |
|
118 scale = max(float(width) / client_size.width, |
|
119 float(height) / client_size.height) * 1.2 |
|
120 x = int(client_size.width * scale - width) / 2 |
|
121 y = int(client_size.height * scale - height) / 2 |
|
122 else: |
|
123 x = (client_size.width - width) / 2 |
|
124 y = (client_size.height - height) / 2 |
|
125 scale = 1.0 |
|
126 dc.SetUserScale(1.0 / scale, 1.0 / scale) |
118 self.Block.SetPosition(x, y) |
127 self.Block.SetPosition(x, y) |
119 self.Block.Draw(dc) |
128 self.Block.Draw(dc) |
120 |
129 |
121 def OnPaint(self, event): |
130 def OnPaint(self, event): |
122 self.RefreshPreview() |
131 self.RefreshPreview() |