def SetColor(self, id, colour): """ Sets the colour of a certain setting. :param integer `id`: can be one of the colour values in `Metric Ordinals`; :param `colour`: the new value of the setting. :type `colour`: :class:`Colour` or tuple or integer """ if isinstance(colour, basestring): colour = wx.NamedColour(colour) elif isinstance(colour, types.TupleType): colour = wx.Colour(*colour) elif isinstance(colour, types.IntType): colour = wx.ColourRGB(colour) if id == AUI_DOCKART_BACKGROUND_COLOUR: self._background_brush.SetColour(colour) elif id == AUI_DOCKART_BACKGROUND_GRADIENT_COLOUR: self._background_gradient_colour = colour elif id == AUI_DOCKART_SASH_COLOUR: self._sash_brush.SetColour(colour) elif id == AUI_DOCKART_INACTIVE_CAPTION_COLOUR: self._inactive_caption_colour = colour if not self._custom_pane_bitmaps and wx.Platform == "__WXMAC__": # No custom bitmaps for the pane close button # Change the MAC close bitmap colour self._inactive_close_bitmap = DrawMACCloseButton( wx.WHITE, colour) elif id == AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR: self._inactive_caption_gradient_colour = colour elif id == AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR: self._inactive_caption_text_colour = colour elif id == AUI_DOCKART_ACTIVE_CAPTION_COLOUR: self._active_caption_colour = colour if not self._custom_pane_bitmaps and wx.Platform == "__WXMAC__": # No custom bitmaps for the pane close button # Change the MAC close bitmap colour self._active_close_bitmap = DrawMACCloseButton( wx.WHITE, colour) elif id == AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR: self._active_caption_gradient_colour = colour elif id == AUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR: self._active_caption_text_colour = colour elif id == AUI_DOCKART_BORDER_COLOUR: self._border_pen.SetColour(colour) elif id == AUI_DOCKART_GRIPPER_COLOUR: self._gripper_brush.SetColour(colour) self._gripper_pen1.SetColour(StepColour(colour, 40)) self._gripper_pen2.SetColour(StepColour(colour, 60)) elif id == AUI_DOCKART_HINT_WINDOW_COLOUR: self._hint_background_colour = colour else: raise Exception("Invalid Colour Ordinal.")
def SetDefaultColours(self, base_colour=None): """ Sets the default colours, which are calculated from the given base colour. :param `base_colour`: an instance of :class:`Colour`. If defaulted to ``None``, a colour is generated accordingly to the platform and theme. """ if base_colour is None: base_colour = GetBaseColour() darker1_colour = StepColour(base_colour, 85) darker2_colour = StepColour(base_colour, 75) darker3_colour = StepColour(base_colour, 60) darker4_colour = StepColour(base_colour, 40) self._background_colour = base_colour self._background_gradient_colour = StepColour(base_colour, 180) self._inactive_caption_colour = darker1_colour self._inactive_caption_gradient_colour = StepColour(base_colour, 97) self._sash_brush = wx.Brush(base_colour) self._background_brush = wx.Brush(base_colour) self._border_pen = wx.Pen(darker2_colour) self._gripper_brush = wx.Brush(base_colour) self._gripper_pen1 = wx.Pen(darker4_colour) self._gripper_pen2 = wx.Pen(darker3_colour) self._gripper_pen3 = wx.WHITE_PEN self._hint_background_colour = colourHintBackground
def Init(self): """ Initializes the dock art. """ base_colour = GetBaseColour() darker1_colour = StepColour(base_colour, 85) darker2_colour = StepColour(base_colour, 75) darker3_colour = StepColour(base_colour, 60) darker4_colour = StepColour(base_colour, 40) self._background_colour = base_colour self._background_gradient_colour = StepColour(base_colour, 180) isMac = wx.Platform == "__WXMAC__" if isMac: self._active_caption_colour = wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT) else: self._active_caption_colour = wx.SystemSettings.GetColour( wx.SYS_COLOUR_ACTIVECAPTION) self._active_caption_gradient_colour = LightContrastColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)) self._active_caption_text_colour = wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHTTEXT) self._inactive_caption_colour = darker1_colour self._inactive_caption_gradient_colour = StepColour(base_colour, 97) self._inactive_caption_text_colour = wx.BLACK self._sash_brush = wx.Brush(base_colour) self._background_brush = wx.Brush(base_colour) self._border_pen = wx.Pen(darker2_colour) self._gripper_brush = wx.Brush(base_colour) self._gripper_pen1 = wx.Pen(darker4_colour) self._gripper_pen2 = wx.Pen(darker3_colour) self._gripper_pen3 = wx.WHITE_PEN
def DrawPaneButton(self, dc, window, button, button_state, _rect, pane): """ Draws a pane button in the pane caption area. :param `dc`: a `wx.DC` device context; :param `window`: an instance of `wx.Window`; :param `button`: the button to be drawn; :param `button_state`: the pane button state; :param `_rect`: the pane caption rectangle; :param `pane`: the pane for which the button is drawn. """ if not pane: return if button == AUI_BUTTON_CLOSE: if pane.state & optionActive: bmp = self._active_close_bitmap else: bmp = self._inactive_close_bitmap elif button == AUI_BUTTON_PIN: if pane.state & optionActive: bmp = self._active_pin_bitmap else: bmp = self._inactive_pin_bitmap elif button == AUI_BUTTON_MAXIMIZE_RESTORE: if pane.IsMaximized(): if pane.state & optionActive: bmp = self._active_restore_bitmap else: bmp = self._inactive_restore_bitmap else: if pane.state & optionActive: bmp = self._active_maximize_bitmap else: bmp = self._inactive_maximize_bitmap elif button == AUI_BUTTON_MINIMIZE: if pane.state & optionActive: bmp = self._active_minimize_bitmap else: bmp = self._inactive_minimize_bitmap isVertical = pane.HasCaptionLeft() rect = wx.Rect(*_rect) if isVertical: old_x = rect.x rect.x = rect.x + (rect.width / 2) - (bmp.GetWidth() / 2) rect.width = old_x + rect.width - rect.x - 1 else: old_y = rect.y rect.y = rect.y + (rect.height / 2) - (bmp.GetHeight() / 2) rect.height = old_y + rect.height - rect.y - 1 if button_state == AUI_BUTTON_STATE_PRESSED: rect.x += 1 rect.y += 1 if button_state in [AUI_BUTTON_STATE_HOVER, AUI_BUTTON_STATE_PRESSED]: if pane.state & optionActive: dc.SetBrush( wx.Brush(StepColour(self._active_caption_colour, 120))) dc.SetPen(wx.Pen(StepColour(self._active_caption_colour, 70))) else: dc.SetBrush( wx.Brush(StepColour(self._inactive_caption_colour, 120))) dc.SetPen(wx.Pen(StepColour(self._inactive_caption_colour, 70))) if wx.Platform != "__WXMAC__": # draw the background behind the button dc.DrawRectangle(rect.x, rect.y, 15, 15) else: # Darker the bitmap a bit bmp = DarkenBitmap( bmp, self._active_caption_colour, StepColour(self._active_caption_colour, 110)) if isVertical: bmp = wx.ImageFromBitmap(bmp).Rotate90( clockwise=False).ConvertToBitmap() # draw the button itself dc.DrawBitmap(bmp, rect.x, rect.y, True)