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
483 # Adjust idx offset and prevent exceptions on leap seconds.
485 if idx
< 0 or idx
> 59:
487 angle
= math
.radians(180 - 6 * (idx
+ 1))
489 hand
.dyer
.Select(dc
, shadow
)
490 hand
.Draw(dc
, (self
.radius
, self
.centre
, angle
), offset
)
494 if self
.parent
.clockStyle
& SHOW_SHADOWS
:
499 def RecalcCoords(self
, clocksize
, centre
, scale
):
501 [hand
.RecalcCoords(clocksize
, centre
, scale
) for hand
in self
.hands
]
504 def SetMaxRadius(self
, radius
):
508 def GetSize(self
, target
):
510 for i
, hand
in enumerate(self
.hands
):
511 if _targets
[i
] & target
:
512 r
.append(hand
.GetSize())
516 def GetFillColour(self
, target
):
518 for i
, hand
in enumerate(self
.hands
):
519 if _targets
[i
] & target
:
520 r
.append(hand
.GetFillColour())
524 def GetBorderColour(self
, target
):
526 for i
, hand
in enumerate(self
.hands
):
527 if _targets
[i
] & target
:
528 r
.append(hand
.GetBorderColour())
532 def GetBorderWidth(self
, target
):
534 for i
, hand
in enumerate(self
.hands
):
535 if _targets
[i
] & target
:
536 r
.append(hand
.GetBorderWidth())
540 def GetShadowColour(self
):
542 for i
, hand
in enumerate(self
.hands
):
543 if _targets
[i
] & target
:
544 r
.append(hand
.GetShadowColour())
548 def SetSize(self
, size
, target
):
549 for i
, hand
in enumerate(self
.hands
):
550 if _targets
[i
] & target
:
554 def SetFillColour(self
, colour
, target
):
555 for i
, hand
in enumerate(self
.hands
):
556 if _targets
[i
] & target
:
557 hand
.SetFillColour(colour
)
560 def SetBorderColour(self
, colour
, target
):
561 for i
, hand
in enumerate(self
.hands
):
562 if _targets
[i
] & target
:
563 hand
.SetBorderColour(colour
)
566 def SetBorderWidth(self
, width
, target
):
567 for i
, hand
in enumerate(self
.hands
):
568 if _targets
[i
] & target
:
569 hand
.SetBorderWidth(width
)
572 def SetShadowColour(self
, colour
):
573 for i
, hand
in enumerate(self
.hands
):
574 hand
.SetShadowColour(colour
)
576 #----------------------------------------------------------------------
579 """Manages a set of tick marks."""
581 def __init__(self
, parent
, **kwargs
):
584 self
.noe
= {"minutes": 60, "hours": 12}
[kwargs
["kind"]]
585 self
.font
= wx
.SystemSettings
.GetFont(wx
.SYS_DEFAULT_GUI_FONT
)
587 style
= kwargs
.pop("style")
592 def _draw(self
, dc
, shadow
=False):
593 dc
.SetFont(self
.font
)
595 a_tick
= self
.ticks
[0]
598 offset
= self
.parent
.shadowOffset
* a_tick
.GetScale()
602 clockStyle
= self
.parent
.clockStyle
604 for idx
, tick
in self
.ticks
.items():
607 # Are we a set of hours?
609 # Should we show all hours ticks?
610 if clockStyle
& SHOW_HOURS_TICKS
:
612 # Or is this tick a quarter and should we show only quarters?
613 elif clockStyle
& SHOW_QUARTERS_TICKS
and not (idx
+ 1) % 3.:
615 # Are we a set of minutes and minutes should be shown?
616 elif self
.noe
== 60 and clockStyle
& SHOW_MINUTES_TICKS
:
617 # If this tick occupies the same position of an hour/quarter
618 # tick, should we still draw it anyway?
619 if clockStyle
& OVERLAP_TICKS
:
621 # Right, sir. I promise I won't overlap any tick.
623 # Ensure that this tick won't overlap an hour tick.
624 if clockStyle
& SHOW_HOURS_TICKS
:
627 # Ensure that this tick won't overlap a quarter tick.
628 elif clockStyle
& SHOW_QUARTERS_TICKS
:
631 # We're not drawing quarters nor hours, so we can draw all
637 tick
.Draw(dc
, offset
)
641 if self
.parent
.clockStyle
& SHOW_SHADOWS
:
642 self
.dyer
.Select(dc
, True)
648 def RecalcCoords(self
, clocksize
, centre
, scale
):
649 a_tick
= self
.ticks
[0]
651 size
= a_tick
.GetMaxSize(scale
)
654 # Try to find a 'good' max size for text-based ticks.
655 if a_tick
.text
is not None:
656 self
.font
.SetPointSize(size
)
658 dc
.SelectObject(wx
.EmptyBitmap(*clocksize
.Get()))
659 dc
.SetFont(self
.font
)
661 for tick
in self
.ticks
.values():
662 maxsize
= max(*(dc
.GetTextExtent(tick
.text
) + (maxsize
,)))
664 radius
= self
.radius
= min(clocksize
.Get()) / 2. - \
665 self
.dyer
.width
/ 2. - \
667 a_tick
.GetOffset() * scale
- \
668 self
.parent
.shadowOffset
* scale
670 # If we are a set of hours, the number of elements of this tickset is
671 # 12 and ticks are separated by a distance of 30 degrees;
672 # if we are a set of minutes, the number of elements of this tickset is
673 # 60 and ticks are separated by a distance of 6 degrees.
674 angfac
= [6, 30][self
.noe
== 12]
676 for i
, tick
in self
.ticks
.items():
677 tick
.SetClockSize(clocksize
)
680 deg
= 180 - angfac
* (i
+ 1)
681 angle
= math
.radians(deg
)
683 x
= centre
.x
+ radius
* math
.sin(angle
)
684 y
= centre
.y
+ radius
* math
.cos(angle
)
686 tick
.SetPosition(wx
.Point(x
, y
))
690 return self
.kwargs
["size"]
693 def GetFillColour(self
):
694 return self
.dyer
.GetFillColour()
697 def GetBorderColour(self
):
698 return self
.dyer
.GetBorderColour()
701 def GetBorderWidth(self
):
702 return self
.dyer
.GetBorderWidth()
705 def GetPolygon(self
):
706 a_tick
= self
.ticks
.values()[0]
707 return a_tick
.GetPolygon()
715 a_tick
= self
.ticks
[0]
716 return a_tick
.GetOffset()
719 def GetShadowColour(self
):
720 return self
.dyer
.GetShadowColour()
723 def GetIsRotated(self
):
724 a_tick
= self
.ticks
[0]
725 return a_tick
.GetIsRotated()
732 def SetSize(self
, size
):
733 self
.kwargs
["size"] = size
734 [tick
.SetSize(size
) for tick
in self
.ticks
.values()]
737 def SetFillColour(self
, colour
):
738 self
.dyer
.SetFillColour(colour
)
741 def SetBorderColour(self
, colour
):
742 self
.dyer
.SetBorderColour(colour
)
745 def SetBorderWidth(self
, width
):
746 self
.dyer
.SetBorderWidth(width
)
749 def SetPolygon(self
, polygon
):
750 [tick
.SetPolygon(polygon
) for tick
in self
.ticks
.values()]
753 def SetFont(self
, font
):
757 def SetOffset(self
, offset
):
758 self
.kwargs
["offset"] = offset
759 [tick
.SetOffset(offset
) for tick
in self
.ticks
.values()]
762 def SetShadowColour(self
, colour
):
763 self
.dyer
.SetShadowColour(colour
)
766 def SetIsRotated(self
, rotate
):
767 self
.kwargs
["rotate"] = rotate
768 [tick
.SetIsRotated(rotate
) for tick
in self
.ticks
.values()]
771 def SetStyle(self
, style
):
773 tickclass
= allTickStyles
[style
]
774 self
.kwargs
["rotate"] = self
.parent
.clockStyle
& ROTATE_TICKS
777 for i
in range(self
.noe
):
778 self
.kwargs
["idx"] = i
779 self
.ticks
[i
] = tickclass(**self
.kwargs
)
781 #----------------------------------------------------------------------
784 """Gathers info about the clock face and tick sets."""
786 def __init__(self
, parent
, Face
, TicksM
, TicksH
):
793 def GetNiceRadiusForHands(self
, centre
):
794 a_tick
= self
.TicksM
.ticks
[0]
795 scale
= a_tick
.GetScale()
796 bw
= max(self
.TicksH
.dyer
.width
/ 2. * scale
,
797 self
.TicksM
.dyer
.width
/ 2. * scale
)
799 mgt
= self
.TicksM
.ticks
[59]
800 my
= mgt
.pos
.y
+ mgt
.GetMaxSize(scale
) + bw
802 hgt
= self
.TicksH
.ticks
[11]
803 hy
= hgt
.pos
.y
+ hgt
.GetMaxSize(scale
) + bw
805 niceradius
= centre
.y
- max(my
, hy
)
810 [getattr(self
, attr
).Draw(dc
) \
811 for attr
in ["Face", "TicksM", "TicksH"]]
814 def RecalcCoords(self
, size
, centre
, scale
):
815 [getattr(self
, attr
).RecalcCoords(size
, centre
, scale
) \
816 for attr
in ["Face", "TicksH", "TicksM"]]
819 def GetTickSize(self
, target
):
821 for i
, attr
in enumerate(["TicksH", "TicksM"]):
822 if _targets
[i
] & target
:
823 tick
= getattr(self
, attr
)
824 r
.append(tick
.GetSize())
828 def GetTickFillColour(self
, target
):
830 for i
, attr
in enumerate(["TicksH", "TicksM"]):
831 if _targets
[i
] & target
:
832 tick
= getattr(self
, attr
)
833 r
.append(tick
.GetFillColour())
837 def GetTickBorderColour(self
, target
):
839 for i
, attr
in enumerate(["TicksH", "TicksM"]):
840 if _targets
[i
] & target
:
841 tick
= getattr(self
, attr
)
842 r
.append(tick
.GetBorderColour())
846 def GetTickBorderWidth(self
, target
):
848 for i
, attr
in enumerate(["TicksH", "TicksM"]):
849 if _targets
[i
] & target
:
850 tick
= getattr(self
, attr
)
851 r
.append(tick
.GetBorderWidth())
855 def GetTickPolygon(self
, target
):
857 for i
, attr
in enumerate(["TicksH", "TicksM"]):
858 if _targets
[i
] & target
:
859 tick
= getattr(self
, attr
)
860 r
.append(tick
.GetPolygon())
864 def GetTickFont(self
, target
):
866 for i
, attr
in enumerate(["TicksH", "TicksM"]):
867 if _targets
[i
] & target
:
868 tick
= getattr(self
, attr
)
869 r
.append(tick
.GetFont())
873 def GetIsRotated(self
):
874 a_tickset
= self
.TicksH
875 return a_tickset
.GetIsRotated()
878 def GetTickOffset(self
, target
):
880 for i
, attr
in enumerate(["TicksH", "TicksM"]):
881 if _targets
[i
] & target
:
882 tick
= getattr(self
, attr
)
883 r
.append(tick
.GetOffset())
887 def GetShadowColour(self
):
888 a_tickset
= self
.TicksH
889 return a_tickset
.GetShadowColour()
892 def GetTickStyle(self
, target
):
894 for i
, attr
in enumerate(["TicksH", "TicksM"]):
895 if _targets
[i
] & target
:
896 tick
= getattr(self
, attr
)
897 r
.append(tick
.GetStyle())
901 def SetTickSize(self
, size
, target
):
902 for i
, attr
in enumerate(["TicksH", "TicksM"]):
903 if _targets
[i
] & target
:
904 tick
= getattr(self
, attr
)
908 def SetTickFillColour(self
, colour
, target
):
909 for i
, attr
in enumerate(["TicksH", "TicksM"]):
910 if _targets
[i
] & target
:
911 tick
= getattr(self
, attr
)
912 tick
.SetFillColour(colour
)
915 def SetTickBorderColour(self
, colour
, target
):
916 for i
, attr
in enumerate(["TicksH", "TicksM"]):
917 if _targets
[i
] & target
:
918 tick
= getattr(self
, attr
)
919 tick
.SetBorderColour(colour
)
922 def SetTickBorderWidth(self
, width
, target
):
923 for i
, attr
in enumerate(["TicksH", "TicksM"]):
924 if _targets
[i
] & target
:
925 tick
= getattr(self
, attr
)
926 tick
.SetBorderWidth(width
)
929 def SetTickPolygon(self
, polygon
, target
):
930 for i
, attr
in enumerate(["TicksH", "TicksM"]):
931 if _targets
[i
] & target
:
932 tick
= getattr(self
, attr
)
933 tick
.SetPolygon(polygon
)
936 def SetTickFont(self
, font
, target
):
937 fs
= font
.GetNativeFontInfoDesc()
938 for i
, attr
in enumerate(["TicksH", "TicksM"]):
939 if _targets
[i
] & target
:
940 tick
= getattr(self
, attr
)
941 tick
.SetFont(wx
.FontFromNativeInfoString(fs
))
944 def SetIsRotated(self
, rotate
):
945 [getattr(self
, attr
).SetIsRotated(rotate
) \
946 for attr
in ["TicksH", "TicksM"]]
949 def SetTickOffset(self
, offset
, target
):
950 for i
, attr
in enumerate(["TicksH", "TicksM"]):
951 if _targets
[i
] & target
:
952 tick
= getattr(self
, attr
)
953 tick
.SetOffset(offset
)
956 def SetShadowColour(self
, colour
):
957 for attr
in ["TicksH", "TicksM"]:
958 tick
= getattr(self
, attr
)
959 tick
.SetShadowColour(colour
)
962 def SetTickStyle(self
, style
, target
):
963 for i
, attr
in enumerate(["TicksH", "TicksM"]):
964 if _targets
[i
] & target
:
965 tick
= getattr(self
, attr
)
968 #----------------------------------------------------------------------
970 # Relationship between styles and ticks class names.
971 allTickStyles
= {TICKS_BINARY
: TickBinary
,
972 TICKS_CIRCLE
: TickCircle
,
973 TICKS_DECIMAL
: TickDecimal
,
975 TICKS_NONE
: TickNone
,
976 TICKS_POLY
: TickPoly
,
977 TICKS_ROMAN
: TickRoman
,
978 TICKS_SQUARE
: TickSquare
}