def DoDrawCloseBtn(self, gcdc, button, rect): """Draw the close button on the segment @param gcdc: Device Context @param button: Segment Dict @param rect: Segment Rect """ if button.Options & SEGBTN_OPT_CLOSEBTNL: x = rect.x + 8 y = rect.y + 6 else: x = (rect.x + rect.Width) - 8 y = rect.y + 6 color = self._scolor2 if button.Selected: color = AdjustColour(color, -25) if button.XState == SEGMENT_STATE_X: color = AdjustColour(color, -20) gcdc.SetPen(wx.Pen(AdjustColour(color, -30))) brect = wx.Rect(x-3, y-3, 8, 8) bmp = DrawCircleCloseBmp(color, wx.WHITE) gcdc.DrawBitmap(bmp, brect.x, brect.y) button.XButton = brect return
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=CTRLBAR_STYLE_DEFAULT, name=SEGBAR_NAME_STR): super(SegmentBar, self).__init__(parent, id, pos, size, style, name) # Attributes self._buttons = list() # list of _SegmentButtons self._segsize = (0, 0) self._selected = -1 self._scolor1 = AdjustColour(self._color, -20) self._scolor2 = AdjustColour(self._color2, -20) self._spen = wx.Pen(AdjustColour(self._pen.GetColour(), -25)) self._x_clicked_before = False self._tip_timer = wx.Timer(self) if wx.Platform == '__WXMAC__': self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) # Event Handlers self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_ENTER_WINDOW, self.OnLeave) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_TIMER, self.OnTipTimer, self._tip_timer) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=CTRLBAR_STYLE_DEFAULT, name=SEGBAR_NAME_STR): ControlBar.__init__(self, parent, id, pos, size, style, name) # Attributes self._buttons = list() self._segsize = (0, 0) self._selected = -1 self._scolor1 = AdjustColour(self._color, -20) self._scolor2 = AdjustColour(self._color2, -20) self._spen = wx.Pen(AdjustColour(self._pen.GetColour(), -25)) self._x_clicked_before = False if wx.Platform == '__WXMAC__': self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) # Event Handlers self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=CTRLBAR_STYLE_DEFAULT, name=CTRLBAR_NAME_STR): super(ControlBar, self).__init__(parent, id, pos, size, wx.TAB_TRAVERSAL | wx.NO_BORDER, name) tsz_orient = wx.HORIZONTAL msz_orient = wx.VERTICAL if style & CTRLBAR_STYLE_VERTICAL: tsz_orient = wx.VERTICAL msz_orient = wx.HORIZONTAL # Attributes self._style = style self._sizer = wx.BoxSizer(tsz_orient) self._tools = dict(simple=list()) self._spacing = (5, 5) # Drawing related color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE) if wx.Platform != '__WXMAC__': self._color2 = AdjustColour(color, 15) self._color = AdjustColour(color, -10) else: self._color2 = AdjustColour(color, 15) self._color = AdjustColour(color, -20) pcolor = tuple([min(190, x) for x in AdjustColour(self._color, -25)]) self._pen = wx.Pen(pcolor, 1) # Setup msizer = wx.BoxSizer(msz_orient) spacer = (0, 0) msizer.Add(spacer, 0) msizer.Add(self._sizer, 1, wx.EXPAND) msizer.Add(spacer, 0) self.SetSizer(msizer) # Event Handlers self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_BUTTON, self._DispatchEvent)
def DoDrawCloseBtn(self, gcdc, button, rect): """Draw the close button on the segment @param dc: Device Context @param button: Segment Dict @param rect: Segment Rect """ brush = gcdc.GetBrush() if button['selected']: gcdc.SetBrush(wx.Brush(self._scolor2)) else: gcdc.SetBrush(wx.Brush(self._color2)) if button['opts'] & SEGBTN_OPT_CLOSEBTNL: x = rect.x + 8 y = rect.y + 6 else: x = (rect.x + rect.width) - 8 y = rect.y + 6 # gcdc.DrawCircle(x, y, 5) # Draw the X pen = gcdc.GetPen() brect = wx.Rect(x - 3, y - 3, 8, 8) if self._x_state == SEGMENT_STATE_X: color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT) gcdc.SetBrush(wx.Brush(color)) gcdc.SetPen(wx.Pen(AdjustColour(color, -20))) else: gcdc.SetPen(wx.TRANSPARENT_PEN) gcdc.DrawRectangleRect(brect) gcdc.SetPen(wx.BLACK_PEN) gcdc.DrawLine(brect.x + 1, brect.y + 1, brect.x + brect.width - 1, brect.y + brect.height - 1) gcdc.DrawLine(brect.x + brect.width - 1, brect.y + 1, brect.x + 1, brect.y + brect.height - 1) gcdc.SetBrush(brush) gcdc.SetPen(pen) button['xbtn'] = brect