def DrawCaptionBackground(self, dc, rect, pane): """ Draws the text caption background in the pane. :param `dc`: a :class:`wx.DC` device context; :param wx.Rect `rect`: the text caption rectangle; :param `pane`: the pane for which we are drawing the caption background. """ dc.SetBrush(self._background_brush) dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height) active = ((pane.state & optionActive) and [True] or [False])[0] if self.usingTheme: rectangle = wx.Rect() rc = RECT(rectangle.x, rectangle.y, rectangle.width, rectangle.height) # If rect x/y values are negative rc.right/bottom values will overflow and winxptheme.DrawThemeBackground # will raise a TypeError. Ensure they are never negative. rect.x = max(0, rect.x) rect.y = max(0, rect.y) rc.top = rect.x rc.left = rect.y rc.right = rect.x + rect.width rc.bottom = rect.y + rect.height if active: winxptheme.DrawThemeBackground( self.hTheme1, int(dc.GetHandle()), 5, 1, (rc.top, rc.left, rc.right, rc.bottom), None) else: winxptheme.DrawThemeBackground( self.hTheme1, int(dc.GetHandle()), 5, 2, (rc.top, rc.left, rc.right, rc.bottom), None) else: AuiDefaultDockArt.DrawCaptionBackground(self, dc, rect, pane)
def DrawCaptionBackground(self, dc, rect, pane): """ Draws the text caption background in the pane. :param `dc`: a `wx.DC` device context; :param `rect`: the text caption rectangle; :param `pane`: the pane for which we are drawing the caption background. """ dc.SetBrush(self._background_brush) dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height) active = ((pane.state & optionActive) and [True] or [False])[0] if self.usingTheme: rectangle = wx.Rect() rc = RECT(rectangle.x, rectangle.y, rectangle.width, rectangle.height) rc.top = rect.x rc.left = rect.y rc.right = rect.x + rect.width rc.bottom = rect.y + rect.height if active: winxptheme.DrawThemeBackground( self.hTheme1, dc.GetHDC(), 5, 1, (rc.top, rc.left, rc.right, rc.bottom), None) else: winxptheme.DrawThemeBackground( self.hTheme1, dc.GetHDC(), 5, 2, (rc.top, rc.left, rc.right, rc.bottom), None) else: AuiDefaultDockArt.DrawCaptionBackground(self, dc, rect, pane)
def DrawCaptionBackground(self, dc, rect, active): """ Draws the text caption background in the pane. :param `dc`: a wx.DC device context; :param `rect`: the text caption rectangle; :param `active`: whether the pane is active or not. """ dc.SetBrush(self._background_brush) dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height) if self.usingTheme: rectangle = wx.Rect() rc = RECT(rectangle.x, rectangle.y, rectangle.width, rectangle.height) rc.top = rect.x rc.left = rect.y rc.right = rect.x + rect.width rc.bottom = rect.y + rect.height if active: winxptheme.DrawThemeBackground( self.hTheme1, dc.GetHDC(), 5, 1, (rc.top, rc.left, rc.right, rc.bottom), None) else: winxptheme.DrawThemeBackground( self.hTheme1, dc.GetHDC(), 5, 2, (rc.top, rc.left, rc.right, rc.bottom), None) else: AuiDefaultDockArt.DrawCaptionBackground(self, dc, rect, active)
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 self.usingTheme: hTheme = self.hTheme1 # Get the real button position (compensating for borders) drect = wx.Rect(rect.x, rect.y, self._button_size, self._button_size) # Draw the themed close button rc = RECT(0, 0, 0, 0) if pane.HasCaptionLeft(): rc.top = rect.x + self._button_border_size rc.left = int(rect.y + 1.5 * self._button_border_size) rc.right = rect.x + self._button_size + self._button_border_size rc.bottom = int(rect.y + self._button_size + 1.5 * self._button_border_size) else: rc.top = rect.x - self._button_border_size rc.left = int(rect.y + 1.5 * self._button_border_size) rc.right = rect.x + self._button_size - self._button_border_size rc.bottom = int(rect.y + self._button_size + 1.5 * self._button_border_size) if button == AUI_BUTTON_CLOSE: btntype = 19 elif button == AUI_BUTTON_PIN: btntype = 23 elif button == AUI_BUTTON_MAXIMIZE_RESTORE: if not pane.IsMaximized(): btntype = 17 else: btntype = 21 else: btntype = 15 state = 4 # CBS_DISABLED if pane.state & optionActive: if button_state == AUI_BUTTON_STATE_NORMAL: state = 1 # CBS_NORMAL elif button_state == AUI_BUTTON_STATE_HOVER: state = 2 # CBS_HOT elif button_state == AUI_BUTTON_STATE_PRESSED: state = 3 # CBS_PUSHED else: raise Exception("ERROR: Unknown State.") else: # inactive pane if button_state == AUI_BUTTON_STATE_NORMAL: state = 5 # CBS_NORMAL elif button_state == AUI_BUTTON_STATE_HOVER: state = 6 # CBS_HOT elif button_state == AUI_BUTTON_STATE_PRESSED: state = 7 # CBS_PUSHED else: raise Exception("ERROR: Unknown State.") try: winxptheme.DrawThemeBackground( hTheme, dc.GetHDC(), btntype, state, (rc.top, rc.left, rc.right, rc.bottom), None) except TypeError: return else: # Fallback to default closebutton if themes are not enabled rect2 = wx.Rect(rect.x - 4, rect.y + 2, rect.width, rect.height) AuiDefaultDockArt.DrawPaneButton(self, dc, window, button, button_state, rect2, pane)