Don't use wx.ClientDC, just draw to the bitmap when needed, and then
use Refresh for painting. This works better on Mac.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42185
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
- dc = wx.BufferedDC(wx.ClientDC(self), self.GetClientSize())
- self.DrawHands(dc)
-
+ self.Refresh(False)
+ self.Update()
+
def _OnDestroyWindow(self, evt):
self.timer.Stop()
def _OnDestroyWindow(self, evt):
self.timer.Stop()
- """Draws clock face and tick marks."""
-
- dc = wx.BufferedDC(wx.ClientDC(self), self.GetClientSize())
- dc.BeginDrawing()
- dc.SelectObject(self.faceBitmap)
+ """Draws clock face and tick marks onto the faceBitmap."""
+ dc = wx.BufferedDC(None, self.faceBitmap)
dc.SetBackground(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
dc.Clear()
self.Box.Draw(dc)
dc.SetBackground(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
dc.Clear()
self.Box.Draw(dc)
def _drawHands(self, dc):
def _drawHands(self, dc):
Draws the face bitmap, created on the last DrawBox call, and
clock hands.
"""
Draws the face bitmap, created on the last DrawBox call, and
clock hands.
"""
dc.DrawBitmap(self.faceBitmap, 0, 0)
self.Hands.Draw(dc)
dc.DrawBitmap(self.faceBitmap, 0, 0)
self.Hands.Draw(dc)
# Public methods --------------------------------------------------
# Public methods --------------------------------------------------
return self.Box.GetTickStyle(target)
return self.Box.GetTickStyle(target)
- Overriden base wx.Window method. Forces an immediate
- recalculation and redraw of all clock elements.
+ Forces an immediate recalculation and redraw of all clock
+ elements.
size = self.GetClientSize()
if size.x < 1 or size.y < 1:
return
size = self.GetClientSize()
if size.x < 1 or size.y < 1:
return
self.RecalcCoords(size)
self.DrawBox()
self.RecalcCoords(size)
self.DrawBox()
- dc = wx.BufferedDC(wx.ClientDC(self), self.GetClientSize())
- self.DrawHands(dc)
- self.Thaw()
-
def SetHandSize(self, size, target=ALL):
"""Sets thickness of hands."""
def SetHandSize(self, size, target=ALL):
"""Sets thickness of hands."""
"""Sets sizes of ticks."""
self.Box.SetTickSize(size, target)
"""Sets sizes of ticks."""
self.Box.SetTickSize(size, target)
def SetTickFillColour(self, colour, target=ALL):
"""Sets fill colours of ticks."""
self.Box.SetTickFillColour(colour, target)
def SetTickFillColour(self, colour, target=ALL):
"""Sets fill colours of ticks."""
self.Box.SetTickFillColour(colour, target)
def SetTickBorderColour(self, colour, target=ALL):
"""Sets border colours of ticks."""
self.Box.SetTickBorderColour(colour, target)
def SetTickBorderColour(self, colour, target=ALL):
"""Sets border colours of ticks."""
self.Box.SetTickBorderColour(colour, target)
def SetTickBorderWidth(self, width, target=ALL):
"""Sets border widths of ticks."""
self.Box.SetTickBorderWidth(width, target)
def SetTickBorderWidth(self, width, target=ALL):
"""Sets border widths of ticks."""
self.Box.SetTickBorderWidth(width, target)
def SetTickPolygon(self, polygon, target=ALL):
def SetTickPolygon(self, polygon, target=ALL):
"""
self.Box.SetTickPolygon(polygon, target)
"""
self.Box.SetTickPolygon(polygon, target)
def SetTickFont(self, font, target=ALL):
def SetTickFont(self, font, target=ALL):
"""
self.Box.SetTickFont(font, target)
"""
self.Box.SetTickFont(font, target)
def SetTickOffset(self, offset, target=ALL):
"""Sets the distance of tick marks for hours from border."""
self.Box.SetTickOffset(offset, target)
def SetTickOffset(self, offset, target=ALL):
"""Sets the distance of tick marks for hours from border."""
self.Box.SetTickOffset(offset, target)
def SetFaceFillColour(self, colour):
"""Sets fill colours of watch."""
self.Box.Face.SetFillColour(colour)
def SetFaceFillColour(self, colour):
"""Sets fill colours of watch."""
self.Box.Face.SetFillColour(colour)
def SetFaceBorderColour(self, colour):
"""Sets border colours of watch."""
self.Box.Face.SetBorderColour(colour)
def SetFaceBorderColour(self, colour):
"""Sets border colours of watch."""
self.Box.Face.SetBorderColour(colour)
def SetFaceBorderWidth(self, width):
"""Sets border width of watch."""
self.Box.Face.SetBorderWidth(width)
def SetFaceBorderWidth(self, width):
"""Sets border width of watch."""
self.Box.Face.SetBorderWidth(width)
def SetShadowColour(self, colour):
def SetShadowColour(self, colour):
self.Hands.SetShadowColour(colour)
self.Box.SetShadowColour(colour)
self.Hands.SetShadowColour(colour)
self.Box.SetShadowColour(colour)
def SetClockStyle(self, style):
def SetClockStyle(self, style):
self.clockStyle = style
self.Box.SetIsRotated(style & ROTATE_TICKS)
self.clockStyle = style
self.Box.SetIsRotated(style & ROTATE_TICKS)
def SetTickStyle(self, style, target=ALL):
def SetTickStyle(self, style, target=ALL):
"""
self.Box.SetTickStyle(style, target)
"""
self.Box.SetTickStyle(style, target)
def SetBackgroundColour(self, colour):
"""Overriden base wx.Window method."""
wx.Window.SetBackgroundColour(self, colour)
def SetBackgroundColour(self, colour):
"""Overriden base wx.Window method."""
wx.Window.SetBackgroundColour(self, colour)
def SetForegroundColour(self, colour):
def SetForegroundColour(self, colour):
self.SetHandBorderColour(colour)
self.SetTickFillColour(colour)
self.SetTickBorderColour(colour)
self.SetHandBorderColour(colour)
self.SetTickFillColour(colour)
self.SetTickBorderColour(colour)
def SetWindowStyle(self, *args, **kwargs):
def SetWindowStyle(self, *args, **kwargs):