1 # AnalogClock's base classes 
   2 #   E. A. Tacao <e.a.tacao |at| estadao.com.br> 
   3 #   http://j.domaindlx.com/elements28/wxpython/ 
   4 #   15 Fev 2006, 22:00 GMT-03:00 
   5 # Distributed under the wxWidgets license. 
   7 from time 
import strftime
, localtime
 
  13 #---------------------------------------------------------------------- 
  15 _targets 
= [HOUR
, MINUTE
, SECOND
] 
  17 #---------------------------------------------------------------------- 
  20     """Base class for face, hands and tick marks.""" 
  22     def __init__(self
, idx
=0, pos
=None, size
=None, offset
=0, clocksize
=None, 
  23                  scale
=1, rotate
=False, kind
=""): 
  29         self
.clocksize 
= clocksize
 
  35         self
.angfac 
= [6, 30][self
.kind 
== "hours"] 
  38     def _pol2rect(self
, m
, t
): 
  39         return m 
* math
.cos(math
.radians(t
)), m 
* math
.sin(math
.radians(t
)) 
  42     def _rect2pol(self
, x
, y
): 
  43         return math
.hypot(x
, y
), math
.degrees(math
.atan2(y
, x
)) 
  46     def DrawRotated(self
, dc
, offset
=0): 
  50     def DrawStraight(self
, dc
, offset
=0): 
  54     def Draw(self
, dc
, offset
=0): 
  56             self
.DrawRotated(dc
, offset
) 
  58             self
.DrawStraight(dc
, offset
) 
  61     def RecalcCoords(self
, clocksize
, centre
, scale
): 
  73     def GetIsRotated(self
, rotate
): 
  77     def GetMaxSize(self
, scale
=1): 
  78         return self
.size 
* scale
 
  85     def SetIsRotated(self
, rotate
): 
  89     def GetMaxSize(self
, scale
=1): 
  90         return self
.size 
* scale
 
  97     def SetPosition(self
, pos
): 
 101     def SetSize(self
, size
): 
 105     def SetOffset(self
, offset
): 
 109     def SetClockSize(self
, clocksize
): 
 110         self
.clocksize 
= clocksize
 
 113     def SetScale(self
, scale
): 
 117     def SetIsRotated(self
, rotate
): 
 121     def SetPolygon(self
, polygon
): 
 122         self
.polygon 
= polygon
 
 124 #---------------------------------------------------------------------- 
 126 class ElementWithDyer(Element
): 
 127     """Base class for clock face and hands.""" 
 129     def __init__(self
, **kwargs
): 
 130         self
.dyer 
= kwargs
.pop("dyer", Dyer()) 
 131         Element
.__init
__(self
, **kwargs
) 
 134     def GetFillColour(self
): 
 135         return self
.dyer
.GetFillColour() 
 138     def GetBorderColour(self
): 
 139         return self
.dyer
.GetBorderColour() 
 142     def GetBorderWidth(self
): 
 143         return self
.dyer
.GetBorderWidth() 
 146     def GetShadowColour(self
): 
 147         return self
.dyer
.GetShadowColour() 
 150     def SetFillColour(self
, colour
): 
 151         self
.dyer
.SetFillColour(colour
) 
 154     def SetBorderColour(self
, colour
): 
 155         self
.dyer
.SetBorderColour(colour
) 
 158     def SetBorderWidth(self
, width
): 
 159         self
.dyer
.SetBorderWidth(width
) 
 162     def SetShadowColour(self
, colour
): 
 163         self
.dyer
.SetShadowColour(colour
) 
 165 #---------------------------------------------------------------------- 
 167 class Face(ElementWithDyer
): 
 168     """Holds info about the clock face.""" 
 170     def __init__(self
, **kwargs
): 
 171         ElementWithDyer
.__init
__(self
, **kwargs
) 
 176         dc
.DrawCircle(self
.pos
.x
, self
.pos
.y
, self
.radius
) 
 179     def RecalcCoords(self
, clocksize
, centre
, scale
): 
 180         self
.radius 
= min(clocksize
.Get()) / 2. - self
.dyer
.width 
/ 2. 
 183 #---------------------------------------------------------------------- 
 185 class Hand(ElementWithDyer
): 
 186     """Holds info about a clock hand.""" 
 188     def __init__(self
, **kwargs
): 
 189         self
.lenfac 
= kwargs
.pop("lenfac") 
 190         ElementWithDyer
.__init
__(self
, **kwargs
) 
 192         self
.SetPolygon([[-1, 0], [0, -1], [1, 0], [0, 4]]) 
 195     def Draw(self
, dc
, end
, offset
=0): 
 196         radius
, centre
, r 
= end
 
 197         angle 
= math
.degrees(r
) 
 198         polygon 
= self
.polygon
[:] 
 199         vscale 
= radius 
/ max([y 
for x
, y 
in polygon
]) 
 201         for i
, (x
, y
) in enumerate(polygon
): 
 202             x 
*= self
.scale 
* self
.size
 
 203             y 
*= vscale 
* self
.lenfac
 
 204             m
, t 
= self
._rect
2pol
(x
, y
) 
 205             polygon
[i
] = self
._pol
2rect
(m
, t 
- angle
) 
 207         dc
.DrawPolygon(polygon
, centre
.x 
+ offset
, centre
.y 
+ offset
) 
 210     def RecalcCoords(self
, clocksize
, centre
, scale
): 
 214 #---------------------------------------------------------------------- 
 216 class TickSquare(Element
): 
 217     """Holds info about a tick mark.""" 
 219     def __init__(self
, **kwargs
): 
 220         Element
.__init
__(self
, **kwargs
) 
 223     def Draw(self
, dc
, offset
=0): 
 224         width 
= height 
= self
.size 
* self
.scale
 
 225         x 
= self
.pos
.x 
- width 
/ 2. 
 226         y 
= self
.pos
.y 
- height 
/ 2. 
 228         dc
.DrawRectangle(x 
+ offset
, y 
+ offset
, width
, height
) 
 230 #---------------------------------------------------------------------- 
 232 class TickCircle(Element
): 
 233     """Holds info about a tick mark.""" 
 235     def __init__(self
, **kwargs
): 
 236         Element
.__init
__(self
, **kwargs
) 
 239     def Draw(self
, dc
, offset
=0): 
 240         radius 
= self
.size 
* self
.scale 
/ 2. 
 244         dc
.DrawCircle(x 
+ offset
, y 
+ offset
, radius
) 
 246 #---------------------------------------------------------------------- 
 248 class TickPoly(Element
): 
 249     """Holds info about a tick mark.""" 
 251     def __init__(self
, **kwargs
): 
 252         Element
.__init
__(self
, **kwargs
) 
 254         self
.SetPolygon([[0, 1], [1, 0], [2, 1], [1, 5]]) 
 257     def _calcPolygon(self
): 
 258         width 
= max([x 
for x
, y 
in self
.polygon
]) 
 259         height 
= max([y 
for x
, y 
in self
.polygon
]) 
 260         tscale 
= self
.size 
/ max(width
, height
) * self
.scale
 
 261         polygon 
= [(x 
* tscale
, y 
* tscale
) for x
, y 
in self
.polygon
] 
 263         width 
= max([x 
for x
, y 
in polygon
]) 
 264         height 
= max([y 
for x
, y 
in polygon
]) 
 266         return polygon
, width
, height
 
 269     def DrawStraight(self
, dc
, offset
=0): 
 270         polygon
, width
, height 
= self
._calcPolygon
() 
 272         x 
= self
.pos
.x 
- width 
/ 2. 
 273         y 
= self
.pos
.y 
- height 
/ 2. 
 275         dc
.DrawPolygon(polygon
, x 
+ offset
, y 
+ offset
) 
 278     def DrawRotated(self
, dc
, offset
=0): 
 279         polygon
, width
, height 
= self
._calcPolygon
() 
 281         angle 
= 360 - self
.angfac 
* (self
.idx 
+ 1) 
 282         r 
= math
.radians(angle
) 
 284         for i 
in range(len(polygon
)): 
 285             m
, t 
= self
._rect
2pol
(*polygon
[i
]) 
 287             polygon
[i
] = self
._pol
2rect
(m
, t
) 
 289         x 
= self
.pos
.x 
- math
.cos(r
) * width 
/ 2. - math
.sin(r
) * height 
/ 2. 
 290         y 
= self
.pos
.y 
- math
.cos(r
) * height 
/ 2. + math
.sin(r
) * width 
/ 2. 
 292         dc
.DrawPolygon(polygon
, x 
+ offset
, y 
+ offset
) 
 294 #---------------------------------------------------------------------- 
 296 class TickDecimal(Element
): 
 297     """Holds info about a tick mark.""" 
 299     def __init__(self
, **kwargs
): 
 300         Element
.__init
__(self
, **kwargs
) 
 302         self
.text 
= "%s" % (self
.idx 
+ 1) 
 305     def DrawStraight(self
, dc
, offset
=0): 
 306         width
, height 
= dc
.GetTextExtent(self
.text
) 
 308         x 
= self
.pos
.x 
- width 
/ 2. 
 309         y 
= self
.pos
.y 
- height 
/ 2. 
 311         dc
.DrawText(self
.text
, x 
+ offset
, y 
+ offset
) 
 314     def DrawRotated(self
, dc
, offset
=0): 
 315         width
, height 
= dc
.GetTextExtent(self
.text
) 
 317         angle 
= 360 - self
.angfac 
* (self
.idx 
+ 1) 
 318         r 
= math
.radians(angle
) 
 320         x 
= self
.pos
.x 
- math
.cos(r
) * width 
/ 2. - math
.sin(r
) * height 
/ 2. 
 321         y 
= self
.pos
.y 
- math
.cos(r
) * height 
/ 2. + math
.sin(r
) * width 
/ 2. 
 323         dc
.DrawRotatedText(self
.text
, x 
+ offset
, y 
+ offset
, angle
) 
 326 #---------------------------------------------------------------------- 
 328 class TickRoman(TickDecimal
): 
 329     """Holds info about a tick mark.""" 
 331     def __init__(self
, **kwargs
): 
 332         TickDecimal
.__init
__(self
, **kwargs
) 
 334         self
.text 
= ["I","II","III","IV","V",                 \
 
 335                      "VI","VII","VIII","IX","X",              \
 
 336                      "XI","XII","XIII","XIV","XV",            \
 
 337                      "XVI","XVII","XVIII","XIX","XX",         \
 
 338                      "XXI","XXII","XXIII","XXIV","XXV",       \
 
 339                      "XXVI","XXVII","XXVIII","XXIX","XXX",    \
 
 340                      "XXXI","XXXII","XXXIII","XXXIV","XXXV",  \
 
 341                      "XXXVI","XXXVII","XXXVIII","XXXIX","XL", \
 
 342                      "XLI","XLII","XLIII","XLIV","XLV",       \
 
 343                      "XLVI","XLVII","XLVIII","XLIX","L",      \
 
 344                      "LI","LII","LIII","LIV","LV",            \
 
 345                      "LVI","LVII","LVIII","LIX","LX"][self
.idx
] 
 347 #---------------------------------------------------------------------- 
 349 class TickBinary(TickDecimal
): 
 350     """Holds info about a tick mark.""" 
 352     def __init__(self
, **kwargs
): 
 353         TickDecimal
.__init
__(self
, **kwargs
) 
 357                 b 
= str(n 
% 2) + b
; n 
= n 
>> 1 
 360         self
.text 
= d2b(self
.idx 
+ 1) 
 362 #---------------------------------------------------------------------- 
 364 class TickHex(TickDecimal
): 
 365     """Holds info about a tick mark.""" 
 367     def __init__(self
, **kwargs
): 
 368         TickDecimal
.__init
__(self
, **kwargs
) 
 370         self
.text 
= hex(self
.idx 
+ 1)[2:].upper() 
 372 #---------------------------------------------------------------------- 
 374 class TickNone(Element
): 
 375     """Holds info about a tick mark.""" 
 377     def __init__(self
, **kwargs
): 
 378         Element
.__init
__(self
, **kwargs
) 
 381     def Draw(self
, dc
, offset
=0): 
 384 #---------------------------------------------------------------------- 
 387     """Stores info about colours and borders of clock Elements.""" 
 389     def __init__(self
, border
=None, width
=0, fill
=None, shadow
=None): 
 391         self.border (wx.Colour)  border colour 
 392         self.width  (int)        border width 
 393         self.fill   (wx.Colour)  fill colour 
 394         self.shadow (wx.Colour)  shadow colour 
 397         self
.border 
= border 
or \
 
 398                       wx
.SystemSettings
.GetColour(wx
.SYS_COLOUR_WINDOWTEXT
) 
 399         self
.fill   
= fill 
or \
 
 400                       wx
.SystemSettings
.GetColour(wx
.SYS_COLOUR_WINDOWTEXT
) 
 401         self
.shadow 
= shadow 
or \
 
 402                       wx
.SystemSettings
.GetColour(wx
.SYS_COLOUR_3DSHADOW
) 
 406     def Select(self
, dc
, shadow
=False): 
 407         """Selects the current settings into the dc.""" 
 410             dc
.SetPen(wx
.Pen(self
.border
, self
.width
, wx
.SOLID
)) 
 411             dc
.SetBrush(wx
.Brush(self
.fill
, wx
.SOLID
)) 
 412             dc
.SetTextForeground(self
.fill
) 
 414             dc
.SetPen(wx
.Pen(self
.shadow
, self
.width
, wx
.SOLID
)) 
 415             dc
.SetBrush(wx
.Brush(self
.shadow
, wx
.SOLID
)) 
 416             dc
.SetTextForeground(self
.shadow
) 
 419     def GetFillColour(self
): 
 423     def GetBorderColour(self
): 
 427     def GetBorderWidth(self
): 
 431     def GetShadowColour(self
): 
 435     def SetFillColour(self
, colour
): 
 439     def SetBorderColour(self
, colour
): 
 443     def SetBorderWidth(self
, width
): 
 447     def SetShadowColour(self
, colour
): 
 450 #---------------------------------------------------------------------- 
 453     """Manages the set of hands.""" 
 455     def __init__(self
, parent
, h
, m
, s
): 
 458         self
.hands 
= [h
, m
, s
] 
 460         self
.centre 
= wx
.Point(1, 1) 
 463     def _draw(self
, dc
, shadow
=False): 
 464         ends 
= [int(x
) for x 
in strftime("%I %M %S", localtime()).split()] 
 466         flags 
= [self
.parent
.clockStyle 
& flag \
 
 467                  for flag 
in self
.parent
.allHandStyles
] 
 469         a_hand 
= self
.hands
[0] 
 472             offset 
= self
.parent
.shadowOffset 
* a_hand
.GetScale() 
 476         for i
, hand 
in enumerate(self
.hands
): 
 477             # Is this hand supposed to be drawn? 
 480                 # Is this the hours hand? 
 482                     idx 
= idx 
* 5 + ends
[1] / 12 - 1 
 483                 # else prevent exceptions on leap seconds 
 484                 elif idx 
<= 0 or idx 
> 60: 
 486                 # and adjust idx offset for minutes and non-leap seconds  
 489                 angle 
= math
.radians(180 - 6 * (idx 
+ 1)) 
 491                 hand
.dyer
.Select(dc
, shadow
) 
 492                 hand
.Draw(dc
, (self
.radius
, self
.centre
, angle
), offset
) 
 496         if self
.parent
.clockStyle 
& SHOW_SHADOWS
: 
 501     def RecalcCoords(self
, clocksize
, centre
, scale
): 
 503         [hand
.RecalcCoords(clocksize
, centre
, scale
) for hand 
in self
.hands
] 
 506     def SetMaxRadius(self
, radius
): 
 510     def GetSize(self
, target
): 
 512         for i
, hand 
in enumerate(self
.hands
): 
 513             if _targets
[i
] & target
: 
 514                 r
.append(hand
.GetSize()) 
 518     def GetFillColour(self
, target
): 
 520         for i
, hand 
in enumerate(self
.hands
): 
 521             if _targets
[i
] & target
: 
 522                 r
.append(hand
.GetFillColour()) 
 526     def GetBorderColour(self
, target
): 
 528         for i
, hand 
in enumerate(self
.hands
): 
 529             if _targets
[i
] & target
: 
 530                 r
.append(hand
.GetBorderColour()) 
 534     def GetBorderWidth(self
, target
): 
 536         for i
, hand 
in enumerate(self
.hands
): 
 537             if _targets
[i
] & target
: 
 538                 r
.append(hand
.GetBorderWidth()) 
 542     def GetShadowColour(self
): 
 544         for i
, hand 
in enumerate(self
.hands
): 
 545             if _targets
[i
] & target
: 
 546                 r
.append(hand
.GetShadowColour()) 
 550     def SetSize(self
, size
, target
): 
 551         for i
, hand 
in enumerate(self
.hands
): 
 552             if _targets
[i
] & target
: 
 556     def SetFillColour(self
, colour
, target
): 
 557         for i
, hand 
in enumerate(self
.hands
): 
 558             if _targets
[i
] & target
: 
 559                 hand
.SetFillColour(colour
) 
 562     def SetBorderColour(self
, colour
, target
): 
 563         for i
, hand 
in enumerate(self
.hands
): 
 564             if _targets
[i
] & target
: 
 565                 hand
.SetBorderColour(colour
) 
 568     def SetBorderWidth(self
, width
, target
): 
 569         for i
, hand 
in enumerate(self
.hands
): 
 570             if _targets
[i
] & target
: 
 571                 hand
.SetBorderWidth(width
) 
 574     def SetShadowColour(self
, colour
): 
 575         for i
, hand 
in enumerate(self
.hands
): 
 576             hand
.SetShadowColour(colour
) 
 578 #---------------------------------------------------------------------- 
 581     """Manages a set of tick marks.""" 
 583     def __init__(self
, parent
, **kwargs
): 
 586         self
.noe 
= {"minutes": 60, "hours": 12}
[kwargs
["kind"]] 
 587         self
.font 
= wx
.SystemSettings
.GetFont(wx
.SYS_DEFAULT_GUI_FONT
) 
 589         style 
= kwargs
.pop("style") 
 594     def _draw(self
, dc
, shadow
=False): 
 595         dc
.SetFont(self
.font
) 
 597         a_tick 
= self
.ticks
[0] 
 600             offset 
= self
.parent
.shadowOffset 
* a_tick
.GetScale() 
 604         clockStyle 
= self
.parent
.clockStyle
 
 606         for idx
, tick 
in self
.ticks
.items(): 
 609             # Are we a set of hours? 
 611                 # Should we show all hours ticks? 
 612                 if clockStyle 
& SHOW_HOURS_TICKS
: 
 614                 # Or is this tick a quarter and should we show only quarters? 
 615                 elif clockStyle 
& SHOW_QUARTERS_TICKS 
and not (idx 
+ 1) % 3.: 
 617             # Are we a set of minutes and minutes should be shown? 
 618             elif self
.noe 
== 60 and clockStyle 
& SHOW_MINUTES_TICKS
: 
 619                 # If this tick occupies the same position of an hour/quarter 
 620                 # tick, should we still draw it anyway? 
 621                 if clockStyle 
& OVERLAP_TICKS
: 
 623                 # Right, sir. I promise I won't overlap any tick. 
 625                     # Ensure that this tick won't overlap an hour tick. 
 626                     if clockStyle 
& SHOW_HOURS_TICKS
: 
 629                     # Ensure that this tick won't overlap a quarter tick. 
 630                     elif clockStyle 
& SHOW_QUARTERS_TICKS
: 
 633                     # We're not drawing quarters nor hours, so we can draw all 
 639                 tick
.Draw(dc
, offset
) 
 643         if self
.parent
.clockStyle 
& SHOW_SHADOWS
: 
 644             self
.dyer
.Select(dc
, True) 
 650     def RecalcCoords(self
, clocksize
, centre
, scale
): 
 651         a_tick 
= self
.ticks
[0] 
 653         size 
= a_tick
.GetMaxSize(scale
) 
 656         # Try to find a 'good' max size for text-based ticks. 
 657         if a_tick
.text 
is not None: 
 658             self
.font
.SetPointSize(size
) 
 660             dc
.SelectObject(wx
.EmptyBitmap(*clocksize
.Get())) 
 661             dc
.SetFont(self
.font
) 
 663             for tick 
in self
.ticks
.values(): 
 664                 maxsize 
= max(*(dc
.GetTextExtent(tick
.text
) + (maxsize
,))) 
 666         radius 
= self
.radius 
= min(clocksize
.Get()) / 2. - \
 
 667                                self
.dyer
.width 
/ 2. - \
 
 669                                a_tick
.GetOffset() * scale 
- \
 
 670                                self
.parent
.shadowOffset 
* scale
 
 672         # If we are a set of hours, the number of elements of this tickset is  
 673         # 12 and ticks are separated by a distance of 30 degrees; 
 674         # if we are a set of minutes, the number of elements of this tickset is 
 675         # 60 and ticks are separated by a distance of 6 degrees. 
 676         angfac 
= [6, 30][self
.noe 
== 12] 
 678         for i
, tick 
in self
.ticks
.items(): 
 679             tick
.SetClockSize(clocksize
) 
 682             deg 
= 180 - angfac 
* (i 
+ 1) 
 683             angle 
= math
.radians(deg
) 
 685             x 
= centre
.x 
+ radius 
* math
.sin(angle
) 
 686             y 
= centre
.y 
+ radius 
* math
.cos(angle
) 
 688             tick
.SetPosition(wx
.Point(x
, y
)) 
 692         return self
.kwargs
["size"] 
 695     def GetFillColour(self
): 
 696         return self
.dyer
.GetFillColour() 
 699     def GetBorderColour(self
): 
 700         return self
.dyer
.GetBorderColour() 
 703     def GetBorderWidth(self
): 
 704         return self
.dyer
.GetBorderWidth() 
 707     def GetPolygon(self
): 
 708         a_tick 
= self
.ticks
.values()[0] 
 709         return a_tick
.GetPolygon() 
 717         a_tick 
= self
.ticks
[0] 
 718         return a_tick
.GetOffset() 
 721     def GetShadowColour(self
): 
 722         return self
.dyer
.GetShadowColour() 
 725     def GetIsRotated(self
): 
 726         a_tick 
= self
.ticks
[0] 
 727         return a_tick
.GetIsRotated() 
 734     def SetSize(self
, size
): 
 735         self
.kwargs
["size"] = size
 
 736         [tick
.SetSize(size
) for tick 
in self
.ticks
.values()] 
 739     def SetFillColour(self
, colour
): 
 740         self
.dyer
.SetFillColour(colour
) 
 743     def SetBorderColour(self
, colour
): 
 744         self
.dyer
.SetBorderColour(colour
) 
 747     def SetBorderWidth(self
, width
): 
 748         self
.dyer
.SetBorderWidth(width
) 
 751     def SetPolygon(self
, polygon
): 
 752         [tick
.SetPolygon(polygon
) for tick 
in self
.ticks
.values()] 
 755     def SetFont(self
, font
): 
 759     def SetOffset(self
, offset
): 
 760         self
.kwargs
["offset"] = offset
 
 761         [tick
.SetOffset(offset
) for tick 
in self
.ticks
.values()] 
 764     def SetShadowColour(self
, colour
): 
 765         self
.dyer
.SetShadowColour(colour
) 
 768     def SetIsRotated(self
, rotate
): 
 769         self
.kwargs
["rotate"] = rotate
 
 770         [tick
.SetIsRotated(rotate
) for tick 
in self
.ticks
.values()] 
 773     def SetStyle(self
, style
): 
 775         tickclass 
= allTickStyles
[style
] 
 776         self
.kwargs
["rotate"] = self
.parent
.clockStyle 
& ROTATE_TICKS
 
 779         for i 
in range(self
.noe
): 
 780             self
.kwargs
["idx"] = i
 
 781             self
.ticks
[i
] = tickclass(**self
.kwargs
) 
 783 #---------------------------------------------------------------------- 
 786     """Gathers info about the clock face and tick sets.""" 
 788     def __init__(self
, parent
, Face
, TicksM
, TicksH
): 
 795     def GetNiceRadiusForHands(self
, centre
): 
 796         a_tick 
= self
.TicksM
.ticks
[0] 
 797         scale 
= a_tick
.GetScale() 
 798         bw 
= max(self
.TicksH
.dyer
.width 
/ 2. * scale
, 
 799                  self
.TicksM
.dyer
.width 
/ 2. * scale
) 
 801         mgt 
= self
.TicksM
.ticks
[59] 
 802         my 
= mgt
.pos
.y 
+ mgt
.GetMaxSize(scale
) + bw
 
 804         hgt 
= self
.TicksH
.ticks
[11] 
 805         hy 
= hgt
.pos
.y 
+ hgt
.GetMaxSize(scale
) + bw
 
 807         niceradius 
= centre
.y 
- max(my
, hy
) 
 812         [getattr(self
, attr
).Draw(dc
) \
 
 813          for attr 
in ["Face", "TicksM", "TicksH"]] 
 816     def RecalcCoords(self
, size
, centre
, scale
): 
 817         [getattr(self
, attr
).RecalcCoords(size
, centre
, scale
) \
 
 818          for attr 
in ["Face", "TicksH", "TicksM"]] 
 821     def GetTickSize(self
, target
): 
 823         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 824             if _targets
[i
] & target
: 
 825                 tick 
= getattr(self
, attr
) 
 826                 r
.append(tick
.GetSize()) 
 830     def GetTickFillColour(self
, target
): 
 832         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 833             if _targets
[i
] & target
: 
 834                 tick 
= getattr(self
, attr
) 
 835                 r
.append(tick
.GetFillColour()) 
 839     def GetTickBorderColour(self
, target
): 
 841         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 842             if _targets
[i
] & target
: 
 843                 tick 
= getattr(self
, attr
) 
 844                 r
.append(tick
.GetBorderColour()) 
 848     def GetTickBorderWidth(self
, target
): 
 850         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 851             if _targets
[i
] & target
: 
 852                 tick 
= getattr(self
, attr
) 
 853                 r
.append(tick
.GetBorderWidth()) 
 857     def GetTickPolygon(self
, target
): 
 859         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 860             if _targets
[i
] & target
: 
 861                 tick 
= getattr(self
, attr
) 
 862                 r
.append(tick
.GetPolygon()) 
 866     def GetTickFont(self
, target
): 
 868         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 869             if _targets
[i
] & target
: 
 870                 tick 
= getattr(self
, attr
) 
 871                 r
.append(tick
.GetFont()) 
 875     def GetIsRotated(self
): 
 876         a_tickset 
= self
.TicksH
 
 877         return a_tickset
.GetIsRotated() 
 880     def GetTickOffset(self
, target
): 
 882         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 883             if _targets
[i
] & target
: 
 884                 tick 
= getattr(self
, attr
) 
 885                 r
.append(tick
.GetOffset()) 
 889     def GetShadowColour(self
): 
 890         a_tickset 
= self
.TicksH
 
 891         return a_tickset
.GetShadowColour() 
 894     def GetTickStyle(self
, target
): 
 896         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 897             if _targets
[i
] & target
: 
 898                 tick 
= getattr(self
, attr
) 
 899                 r
.append(tick
.GetStyle()) 
 903     def SetTickSize(self
, size
, target
): 
 904         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 905             if _targets
[i
] & target
: 
 906                 tick 
= getattr(self
, attr
) 
 910     def SetTickFillColour(self
, colour
, target
): 
 911         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 912             if _targets
[i
] & target
: 
 913                 tick 
= getattr(self
, attr
) 
 914                 tick
.SetFillColour(colour
) 
 917     def SetTickBorderColour(self
, colour
, target
): 
 918         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 919             if _targets
[i
] & target
: 
 920                 tick 
= getattr(self
, attr
) 
 921                 tick
.SetBorderColour(colour
) 
 924     def SetTickBorderWidth(self
, width
, target
): 
 925         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 926             if _targets
[i
] & target
: 
 927                 tick 
= getattr(self
, attr
) 
 928                 tick
.SetBorderWidth(width
) 
 931     def SetTickPolygon(self
, polygon
, target
): 
 932         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 933             if _targets
[i
] & target
: 
 934                 tick 
= getattr(self
, attr
) 
 935                 tick
.SetPolygon(polygon
) 
 938     def SetTickFont(self
, font
, target
): 
 939         fs 
= font
.GetNativeFontInfoDesc() 
 940         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 941             if _targets
[i
] & target
: 
 942                 tick 
= getattr(self
, attr
) 
 943                 tick
.SetFont(wx
.FontFromNativeInfoString(fs
)) 
 946     def SetIsRotated(self
, rotate
): 
 947         [getattr(self
, attr
).SetIsRotated(rotate
) \
 
 948          for attr 
in ["TicksH", "TicksM"]] 
 951     def SetTickOffset(self
, offset
, target
): 
 952         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 953             if _targets
[i
] & target
: 
 954                 tick 
= getattr(self
, attr
) 
 955                 tick
.SetOffset(offset
) 
 958     def SetShadowColour(self
, colour
): 
 959         for attr 
in ["TicksH", "TicksM"]: 
 960             tick 
= getattr(self
, attr
) 
 961             tick
.SetShadowColour(colour
) 
 964     def SetTickStyle(self
, style
, target
): 
 965         for i
, attr 
in enumerate(["TicksH", "TicksM"]): 
 966             if _targets
[i
] & target
: 
 967                 tick 
= getattr(self
, attr
) 
 970 #---------------------------------------------------------------------- 
 972 # Relationship between styles and ticks class names. 
 973 allTickStyles 
= {TICKS_BINARY
:  TickBinary
, 
 974                  TICKS_CIRCLE
:  TickCircle
, 
 975                  TICKS_DECIMAL
: TickDecimal
, 
 977                  TICKS_NONE
:    TickNone
, 
 978                  TICKS_POLY
:    TickPoly
, 
 979                  TICKS_ROMAN
:   TickRoman
, 
 980                  TICKS_SQUARE
:  TickSquare
}