def OnSize(self, event=None): """ Reaply smoke and mirrors when the bar is resized """ if not self.native and isinstance(self.bg, SplitImage4): ApplySmokeAndMirrors(self, self.bg.GetBitmap(self.Size)) else: ApplySmokeAndMirrors(self)
def OnPaint(self, event): "Draws the button's background." # excape if native if self.native: event.Skip() return rect = RectS(self.Size) parent, grandparent = self.Parent, self.GrandParent if parent.__class__.__name__ == "Tab" and self.side_tabs: #Clipping the button for when partualy hidden cliptangle = RectS(self.Size) sy = self.Rect.y sw, sh = self.Size py = parent.Position.y pph = grandparent.Size.height - 16 if parent.Position.y + parent.Size.height > grandparent.Size.height-16 and \ sy + sh + py > pph: cliptangle = Rect(0, 0, sw, pph - (sy + py)) dc = wx.PaintDC(self) dc.SetClippingRect(cliptangle) else: dc = AutoBufferedPaintDC(self) # actual drawing of background currentstate=5 if self.isdown else \ 6 if self.state and self.notified else \ self.state+(self.hovered*2) if self.state else \ 0 if self.rendernative: nrect = rect if self.type == 'combo' else rect.Inflate(1, 1) #wx.RendererNative.Get().DrawPushButton(self,dc,nrect,self.backgrounds[currentstate]) part = 1 state = self.backgrounds[currentstate] self.DrawNativeLike(dc, part, state, nrect) else: background = self.backgrounds[currentstate] from cgui import SplitImage4 if isinstance(background, SplitImage4): ApplySmokeAndMirrors(self, background.GetBitmap(self.Size)) else: ApplySmokeAndMirrors(self) background.Draw(dc, rect) #TODO: Backgroundless icon buttons if not (self.type == 'combo' and self.rendernative): self.DrawContent(dc)
def OnSize(self, event): event.Skip() # if hasattr(self.spine,'framebg'): background = self.spine.framebg from cgui import SplitImage4 if isinstance(background, SplitImage4): ApplySmokeAndMirrors(self, background.GetBitmap(self.Size)) else: ApplySmokeAndMirrors(self) self.Layout()
def OnPaint(self, e): dc = wx.PaintDC(self) ApplySmokeAndMirrors(self, wx.Bitmap(r'c:\dev\digsby\res\digsbyclaus.png')) dc.SetBrush(wx.RED_BRUSH) dc.DrawRectangle(*self.ClientRect)
def set_screen_button_mode(self): b = self.buttonfor('screen') if self._screen_button_mode == 'capture': self._set_screen_button_mode('screen') f = b.Font f.SetWeight(wx.FONTWEIGHT_NORMAL) b.Font = f do(self.buttonfor(b).Enable(True) for b in self.capture_related) ApplySmokeAndMirrors(wx.GetTopLevelParent(self))
def GenBitmap(self): """ Generates a local cached bitmap from the bitmap then sets the region """ if self.rot: self.bitmap = wx.BitmapFromImage( self.bitmap.ConvertToImage().Rotate(radians(90 * self.rot), (0, 0))) if self.Size != (self.bitmap.Width + 1, self.bitmap.Height + 1): wx.PopupWindow.SetSize( self, (self.bitmap.Width + 1, self.bitmap.Height + 1)) ApplySmokeAndMirrors(self, self.bitmap)
def cuthole(ctrl): top = wx.GetTopLevelParent(ctrl) x = ctrl.ScreenRect.X - top.ScreenRect.X y = ctrl.ScreenRect.Y - top.ScreenRect.Y w, h = ctrl.ClientSize winsz = top.Size region = wx.Region(0, 0, winsz[0], y) region.UnionRect((0, 0, x, winsz[1])) region.UnionRect((x + w, y, winsz[0] - w - x, h)) region.UnionRect((0, y + h, winsz[0], winsz[1] - h - y)) ApplySmokeAndMirrors(top, region)
def Calcumalate(self): """ Calculates the positioning of all content of the button and sets the size of the button based off of these calculations """ if self.native: self.Size = self.MinSize = self.native.BestSize #self.Fit() self.Parent.Layout() ApplySmokeAndMirrors(self) return label = DeAmp(self.label) if self.icon: iconwidth, iconheight = self.icon.Width, self.icon.Height else: iconwidth, iconheight = (0, 0) if label != '': labelwidth, labelheight = GetTextExtent( label, self.Font)[0], self.Font.Height else: labelwidth, labelheight = (0, 0) self.labelsize = Size(labelwidth, labelheight) margins = self.margins sx, sy = self.padding swidth = 0 sheight = 0 #icon & label caclulations if self.icon and label != '': if self.style == HORIZONTAL: swidth += iconwidth + labelwidth + 3 * sx if iconheight > labelheight: sheight += iconheight + 2 * sy iy = sy else: sheight += labelheight + 2 * sy iy = sy + labelheight // 2 - iconheight // 2 self.iconcurser = wx.Point(sx, iy) self.labelcurser = wx.Point( self.iconcurser.x + iconwidth + sx, self.iconcurser.y + iconheight / 2 - labelheight / 2) if self.menu and not self.menubarmode and self.menuicon: swidth += self.menuicon.Width + sx self.ssize = Size(margins.left + swidth + margins.right, margins.top + sheight + margins.bottom) elif self.style == VERTICAL: labelwin = labelwidth > iconwidth if labelwin: swidth += labelwidth + 2 * sx else: swidth += iconwidth + 2 * sx sheight += iconheight + labelheight + 3 * sy lx = sx if labelwin: self.iconcurser = wx.Point( lx + labelwidth / 2 - iconwidth / 2, sy) self.labelcurser = wx.Point( lx, self.iconcurser.y + iconheight + sy) else: self.iconcurser = wx.Point(lx, sy) self.labelcurser = wx.Point( lx + iconwidth / 2 - labelwidth / 2, self.iconcurser.y + iconheight + sy) if self.menu and not self.menubarmode: swidth += self.menuicon.Width + sx self.ssize = Size(margins.left + swidth + margins.right, margins.top + sheight + margins.bottom) # Just icon caclulations elif self.icon: swidth += iconwidth + 2 * sx sheight += iconheight + 2 * sy self.iconcurser = wx.Point(sx, sy) if self.menu and not self.menubarmode: swidth += self.menuicon.Width + sx self.ssize = Size(margins.left + swidth + margins.right, margins.top + sheight + margins.bottom) # Just label caclulations elif label != '': swidth += labelwidth + 2 * sx sheight += labelheight + 2 * sy self.labelcurser = wx.Point(sx, sy) if self.menu and not self.menubarmode: swidth += self.menuicon.Width + sx self.ssize = Size(margins.left + swidth + margins.right, margins.top + sheight + margins.bottom) elif self.menu is not None and not self.menubarmode: swidth += self.menuicon.Width sheight += self.menuicon.Height self.ssize = Size(swidth + 2 * sx + margins.x, sheight + 2 * sy + margins.y) else: self.ssize = Size(16, 16) if self.staticwidth: self.ssize.width = self.staticwidth self.MinSize = self.ssize self.InvalidateBestSize() self.Parent.Layout()