Ejemplo n.º 1
0
    def _on_paint(self, event):
        w, h = self.panel.GetSize()
        self.rect = wx.Rect(0, 0, w, h)
        pdc = wx.PaintDC(self.panel)
        try:
            dc = wx.GCDC(pdc)
        except:
            dc = pdc
        pdc.BeginDrawing()
        dc.BeginDrawing()

        #----- colors definition
        border_color = const.UI_COLORS['hover_solid_border']
        bg_color = const.UI_COLORS['bg']
        light_bg_color = const.mix_colors((255, 255, 255), bg_color, 100)
        dark_bg_color = const.mix_colors((0, 0, 0), bg_color, 5)
        grad_start = wx.Colour(0, 0, 0, 10)
        grad_end = wx.Colour(0, 0, 0, 0)

        if self.active:
            #----- draw border
            pdc.SetBrush(wx.TRANSPARENT_BRUSH)
            pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
            pdc.DrawRoundedRectangle(-3, 0, w, h, 3.0)
            #----- draw icon
            y = TAB_PADDING
            x = (TAB_WIDTH - self.icon.GetSize()[1]) / 2
            dc.DrawBitmap(self.icon, x, y, True)
            #----- draw text
            y += 3 + self.icon.GetSize()[0]
            txt_h = self._get_text_size(self.text, self.active)[1]
            x = (TAB_WIDTH - txt_h) / 2 + txt_h
            if is_msw(): x += 3
            font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
            if config.tabs_use_bold:
                font.SetWeight(wx.FONTWEIGHT_BOLD)
            if config.tabs_fontsize:
                if font.IsUsingSizeInPixels():
                    font.SetPixelSize(config.tabs_fontsize)
                else:
                    font.SetPointSize(config.tabs_fontsize)
            pdc.SetFont(font)
            pdc.DrawRotatedText(self.text, x, y, 270)
            #----- draw button
            y += self._get_text_size(self.text, self.active)[0]
            x = (TAB_WIDTH - self.inactive_close_but.GetSize()[0]) / 2
            if not self.active: x -= 1
            if self.but_active:
                dc.DrawBitmap(self.close_but, x, y, True)
                if self.but_pressed: dc.DrawBitmap(self.close_but, x, y, True)
            else: dc.DrawBitmap(self.inactive_close_but, x, y, True)
            but_w, but_h = self.inactive_close_but.GetSize()
            self.but_rect = wx.Rect(x, y, but_w, but_h)
        else:
            #----- draw border
            pdc.SetBrush(wx.TRANSPARENT_BRUSH)
            pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
            pdc.DrawRoundedRectangle(-5, 0, w, h, 3.0)
            pdc.SetPen(
                wx.Pen(wx.Colour(*const.UI_COLORS['hover_solid_border']), 1))
            pdc.DrawLine(0, 0, 0, h)
            #----- draw icon
            y = TAB_PADDING
            x = (TAB_WIDTH - self.icon.GetSize()[1]) / 2 - 1
            dc.DrawBitmap(self.icon, x, y, True)
            #----- draw text
            y += 3 + self.icon.GetSize()[0]
            txt_h = self._get_text_size(self.text, self.active)[1]
            x = (TAB_WIDTH - txt_h) / 2 + txt_h - 1
            if is_msw(): x += 3
            font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
            if config.tabs_fontsize:
                if font.IsUsingSizeInPixels():
                    font.SetPixelSize(config.tabs_fontsize)
                else:
                    font.SetPointSize(config.tabs_fontsize)
            pdc.SetFont(font)
            pdc.DrawRotatedText(self.text, x, y, 270)
            #----- draw button
            y += self._get_text_size(self.text, self.active)[0]
            x = (TAB_WIDTH - self.inactive_close_but.GetSize()[0]) / 2
            if not self.active: x -= 1
            if self.but_active:
                dc.DrawBitmap(self.close_but, x, y, True)
                if self.but_pressed: dc.DrawBitmap(self.close_but, x, y, True)
            else: dc.DrawBitmap(self.inactive_close_but, x, y, True)
            but_w, but_h = self.inactive_close_but.GetSize()
            self.but_rect = wx.Rect(x, y, but_w, but_h)
            #----- shadow
            color1 = wx.Colour(0, 0, 0, 20)
            color2 = wx.Colour(0, 0, 0, 0)
            rect = wx.Rect(0, 0, w / 2, h)
            dc.GradientFillLinear(rect, color1, color2, nDirection=wx.EAST)

        if not pdc == dc:
            dc.EndDrawing()
            pdc.EndDrawing()
        else:
            dc.EndDrawing()
        pdc = dc = None
Ejemplo n.º 2
0
	def _on_paint(self, event):
		w, h = self.panel.GetSize()
		self.rect = wx.Rect(0, 0, w, h)
		pdc = wx.PaintDC(self.panel)
		try:dc = wx.GCDC(pdc)
		except:dc = pdc
		pdc.BeginDrawing()
		dc.BeginDrawing()

		#----- colors definition
		border_color = const.UI_COLORS['hover_solid_border']
		bg_color = const.UI_COLORS['bg']
		light_bg_color = const.mix_colors((255, 255, 255), bg_color, 100)
		dark_bg_color = const.mix_colors((0, 0, 0), bg_color, 5)
		grad_start = wx.Colour(0, 0, 0, 10)
		grad_end = wx.Colour(0, 0, 0, 0)

		if self.active:
			#----- draw border
			pdc.SetBrush(wx.TRANSPARENT_BRUSH)
			pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
			pdc.DrawRoundedRectangle(-3, 0, w, h, 3.0)
			#----- draw icon
			y = TAB_PADDING
			x = (TAB_WIDTH - self.icon.GetSize()[1]) / 2
			dc.DrawBitmap(self.icon, x, y, True)
			#----- draw text
			y += 3 + self.icon.GetSize()[0]
			txt_h = self._get_text_size(self.text, self.active)[1]
			x = (TAB_WIDTH - txt_h) / 2 + txt_h - 2
			font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
			if config.tabs_use_bold:
				font.SetWeight(wx.FONTWEIGHT_BOLD)
			if config.tabs_fontsize:
				if font.IsUsingSizeInPixels():
					font.SetPixelSize(config.tabs_fontsize)
				else:
					font.SetPointSize(config.tabs_fontsize)
			pdc.SetFont(font)
			pdc.DrawRotatedText(self.text, x, y, 270)
			#----- draw button
			y += self._get_text_size(self.text, self.active)[0]
			x = (TAB_WIDTH - self.inactive_close_but.GetSize()[0]) / 2
			if not self.active:x -= 1
			if self.but_active:
				dc.DrawBitmap(self.close_but, x, y, True)
				if self.but_pressed: dc.DrawBitmap(self.close_but, x, y, True)
			else: dc.DrawBitmap(self.inactive_close_but, x, y, True)
			but_w, but_h = self.inactive_close_but.GetSize()
			self.but_rect = wx.Rect(x, y, but_w, but_h)
		else:
			#----- draw border
			pdc.SetBrush(wx.TRANSPARENT_BRUSH)
			pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
			pdc.DrawRoundedRectangle(-5, 0, w, h, 3.0)
			pdc.SetPen(wx.Pen(wx.Colour(*const.UI_COLORS['hover_solid_border']), 1))
			pdc.DrawLine(0, 0, 0, h)
			#----- draw icon
			y = TAB_PADDING
			x = (TAB_WIDTH - self.icon.GetSize()[1]) / 2 - 1
			dc.DrawBitmap(self.icon, x, y, True)
			#----- draw text
			y += 3 + self.icon.GetSize()[0]
			txt_h = self._get_text_size(self.text, self.active)[1]
			x = (TAB_WIDTH - txt_h) / 2 + txt_h - 3
			font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
			if config.tabs_fontsize:
				if font.IsUsingSizeInPixels():
					font.SetPixelSize(config.tabs_fontsize)
				else:
					font.SetPointSize(config.tabs_fontsize)
			pdc.SetFont(font)
			pdc.DrawRotatedText(self.text, x, y, 270)
			#----- draw button
			y += self._get_text_size(self.text, self.active)[0]
			x = (TAB_WIDTH - self.inactive_close_but.GetSize()[0]) / 2
			if not self.active:x -= 1
			if self.but_active:
				dc.DrawBitmap(self.close_but, x, y, True)
				if self.but_pressed: dc.DrawBitmap(self.close_but, x, y, True)
			else: dc.DrawBitmap(self.inactive_close_but, x, y, True)
			but_w, but_h = self.inactive_close_but.GetSize()
			self.but_rect = wx.Rect(x, y, but_w, but_h)
			#----- shadow
			color1 = wx.Colour(0, 0, 0, 20)
			color2 = wx.Colour(0, 0, 0, 0)
			rect = wx.Rect(0, 0, w / 2, h)
			dc.GradientFillLinear(rect, color1, color2, nDirection=wx.EAST)


		if not pdc == dc:
			dc.EndDrawing()
			pdc.EndDrawing()
		else:
			dc.EndDrawing()
		pdc = dc = None
Ejemplo n.º 3
0
    def _on_paint(self, event):
        w, h = self.panel.GetSize()
        self.rect = wx.Rect(0, 0, w, h)
        pdc = wx.PaintDC(self.panel)
        try:
            dc = wx.GCDC(pdc)
        except:
            dc = pdc
        pdc.BeginDrawing()
        dc.BeginDrawing()

        dc.SetBrush(wx.Brush(wx.Colour(*const.UI_COLORS['bg'])))
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, w, h)

        # ----- colors definition
        border_color = const.UI_COLORS['hover_solid_border']
        bg_color = const.UI_COLORS['bg']
        light_bg_color = const.mix_colors((255, 255, 255), bg_color, 100)
        dark_bg_color = const.mix_colors((0, 0, 0), bg_color, 5)
        grad_start = wx.Colour(0, 0, 0, 10)
        grad_end = wx.Colour(0, 0, 0, 0)
        # ----- draw gradient
        rect = wx.Rect(0, 0, w, h / 2)
        dc.GradientFillLinear(rect, grad_start, grad_end, nDirection=wx.SOUTH)

        if self.active:
            # ----- draw background
            dc.SetBrush(wx.Brush(wx.Colour(*light_bg_color)))
            dc.SetPen(wx.TRANSPARENT_PEN)
            dc.DrawRoundedRectangle(0, 3, w, h + 5, 3.0)
            # ----- draw border
            pdc.SetBrush(wx.TRANSPARENT_BRUSH)
            pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
            pdc.DrawRoundedRectangle(0, 3, w, h + 5, 3.0)
            # ----- draw gradient
            rect = wx.Rect(0, h / 2, w, h / 2)
            dc.GradientFillLinear(rect, grad_start, grad_end,
                                  nDirection=wx.NORTH)
            dc.GradientFillLinear(rect, grad_start, grad_end,
                                  nDirection=wx.NORTH)
        else:
            # ----- draw background
            dc.SetBrush(wx.Brush(wx.Colour(*dark_bg_color)))
            dc.SetPen(wx.TRANSPARENT_PEN)
            dc.DrawRoundedRectangle(1, 5, w - 2, h + 5, 3.0)
            # ----- draw border
            pdc.SetBrush(wx.TRANSPARENT_BRUSH)
            pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
            pdc.DrawRoundedRectangle(1, 5, w - 2, h + 5, 3.0)

            # ----- draw gradient
            rect = wx.Rect(0, h / 2, w, h / 2)
            dc.GradientFillLinear(rect, grad_start, grad_end,
                                  nDirection=wx.NORTH)
            dc.GradientFillLinear(rect, grad_start, grad_end,
                                  nDirection=wx.NORTH)

            # ----- draw bottom line
            pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
            pdc.DrawLine(0, h - 1, w, h - 1)

        # ----- draw top line
        pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
        pdc.DrawLine(0, 0, w, 0)
        # ----- draw icon
        x = TAB_PADDING
        y = (TAB_HEIGHT - self.icon.GetSize()[1]) / 2 + 3
        if not self.active:
            y += 1
        dc.DrawBitmap(self.icon, x, y, True)
        # ----- draw text
        x += 3 + self.icon.GetSize()[0]
        y = (
                TAB_HEIGHT - self._get_text_size(self.text, self.active)[
                    1]) / 2 + 3
        if not self.active:
            y += 1
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        if self.active and config.tabs_use_bold:
            font.SetWeight(wx.FONTWEIGHT_BOLD)
        if config.tabs_fontsize:
            if font.IsUsingSizeInPixels():
                font.SetPixelSize(config.tabs_fontsize)
            else:
                font.SetPointSize(config.tabs_fontsize)
        pdc.SetFont(font)
        pdc.DrawText(self.text, x, y)
        # ----- draw button
        x += self._get_text_size(self.text, self.active)[0]
        y = (TAB_HEIGHT - self.inactive_close_but.GetSize()[1]) / 2 + 3
        if not self.active:
            y += 1
        if self.but_active:
            dc.DrawBitmap(self.close_but, x, y, True)
            if self.but_pressed:
                dc.DrawBitmap(self.close_but, x, y, True)
        else:
            dc.DrawBitmap(self.inactive_close_but, x, y, True)
        but_w, but_h = self.inactive_close_but.GetSize()
        self.but_rect = wx.Rect(x, y, but_w, but_h)

        if not pdc == dc:
            dc.EndDrawing()
            pdc.EndDrawing()
        else:
            dc.EndDrawing()
Ejemplo n.º 4
0
	def _on_paint(self, event):
		w, h = self.panel.GetSize()
		self.rect = wx.Rect(0, 0, w, h)
		pdc = wx.PaintDC(self.panel)
		try:dc = wx.GCDC(pdc)
		except:dc = pdc
		pdc.BeginDrawing()
		dc.BeginDrawing()

		#----- colors definition
		border_color = const.UI_COLORS['hover_solid_border']
		bg_color = const.UI_COLORS['bg']
		light_bg_color = const.mix_colors((255, 255, 255), bg_color, 100)
		dark_bg_color = const.mix_colors((0, 0, 0), bg_color, 5)
		grad_start = wx.Colour(0, 0, 0, 10)
		grad_end = wx.Colour(0, 0, 0, 0)
		#----- draw gradient
		rect = wx.Rect(0, 0, w, h / 2)
		dc.GradientFillLinear(rect, grad_start, grad_end, nDirection=wx.SOUTH)

		if self.active:
			#----- draw background
			dc.SetBrush(wx.Brush(wx.Colour(*light_bg_color)))
			dc.SetPen(wx.TRANSPARENT_PEN)
			dc.DrawRoundedRectangle(0, 3, w, h + 5, 3.0)
			#----- draw border
			pdc.SetBrush(wx.TRANSPARENT_BRUSH)
			pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
			pdc.DrawRoundedRectangle(0, 3, w, h + 5, 3.0)
			#----- draw gradient
			rect = wx.Rect(0, h / 2, w, h / 2)
			dc.GradientFillLinear(rect, grad_start, grad_end, nDirection=wx.NORTH)
			dc.GradientFillLinear(rect, grad_start, grad_end, nDirection=wx.NORTH)
		else:
			#----- draw background
			dc.SetBrush(wx.Brush(wx.Colour(*dark_bg_color)))
			dc.SetPen(wx.TRANSPARENT_PEN)
			dc.DrawRoundedRectangle(1, 5, w - 2, h + 5, 3.0)
			#----- draw border
			pdc.SetBrush(wx.TRANSPARENT_BRUSH)
			pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
			pdc.DrawRoundedRectangle(1, 5, w - 2, h + 5, 3.0)

			#----- draw gradient
			rect = wx.Rect(0, h / 2, w, h / 2)
			dc.GradientFillLinear(rect, grad_start, grad_end, nDirection=wx.NORTH)
			dc.GradientFillLinear(rect, grad_start, grad_end, nDirection=wx.NORTH)

			#----- draw bottom line
			pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
			pdc.DrawLine(0, h - 1, w , h - 1)

		#----- draw top line
		pdc.SetPen(wx.Pen(wx.Colour(*border_color), 1))
		pdc.DrawLine(0, 0, w , 0)
		#----- draw icon
		x = TAB_PADDING
		y = (TAB_HEIGHT - self.icon.GetSize()[1]) / 2 + 3
		if not self.active:y += 1
		dc.DrawBitmap(self.icon, x, y, True)
		#----- draw text
		x += 3 + self.icon.GetSize()[0]
		y = (TAB_HEIGHT - self._get_text_size(self.text, self.active)[1]) / 2 + 3
		if not self.active:y += 1
		font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
		if self.active and config.tabs_use_bold:
			font.SetWeight(wx.FONTWEIGHT_BOLD)
		if config.tabs_fontsize:
			if font.IsUsingSizeInPixels():
				font.SetPixelSize(config.tabs_fontsize)
			else:
				font.SetPointSize(config.tabs_fontsize)
		pdc.SetFont(font)
		pdc.DrawText(self.text, x, y)
		#----- draw button
		x += self._get_text_size(self.text, self.active)[0]
		y = (TAB_HEIGHT - self.inactive_close_but.GetSize()[1]) / 2 + 3
		if not self.active:y += 1
		if self.but_active:
			dc.DrawBitmap(self.close_but, x, y, True)
			if self.but_pressed: dc.DrawBitmap(self.close_but, x, y, True)
		else: dc.DrawBitmap(self.inactive_close_but, x, y, True)
		but_w, but_h = self.inactive_close_but.GetSize()
		self.but_rect = wx.Rect(x, y, but_w, but_h)

		if not pdc == dc:
			dc.EndDrawing()
			pdc.EndDrawing()
		else:
			dc.EndDrawing()
		pdc = dc = None