]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/analogclock/helpers.py
Added SetSashPosition
[wxWidgets.git] / wxPython / wx / lib / analogclock / helpers.py
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.
6
7 from time import strftime, localtime
8 import math
9 import wx
10
11 from styles import *
12
13 #----------------------------------------------------------------------
14
15 _targets = [HOUR, MINUTE, SECOND]
16
17 #----------------------------------------------------------------------
18
19 class Element:
20 """Base class for face, hands and tick marks."""
21
22 def __init__(self, idx=0, pos=None, size=None, offset=0, clocksize=None,
23 scale=1, rotate=False, kind=""):
24
25 self.idx = idx
26 self.pos = pos
27 self.size = size
28 self.offset = offset
29 self.clocksize = clocksize
30 self.scale = scale
31 self.rotate = rotate
32 self.kind = kind
33
34 self.text = None
35 self.angfac = [6, 30][self.kind == "hours"]
36
37
38 def _pol2rect(self, m, t):
39 return m * math.cos(math.radians(t)), m * math.sin(math.radians(t))
40
41
42 def _rect2pol(self, x, y):
43 return math.hypot(x, y), math.degrees(math.atan2(y, x))
44
45
46 def DrawRotated(self, dc, offset=0):
47 pass
48
49
50 def DrawStraight(self, dc, offset=0):
51 pass
52
53
54 def Draw(self, dc, offset=0):
55 if self.rotate:
56 self.DrawRotated(dc, offset)
57 else:
58 self.DrawStraight(dc, offset)
59
60
61 def RecalcCoords(self, clocksize, centre, scale):
62 pass
63
64
65 def GetSize(self):
66 return self.size
67
68
69 def GetOffset(self):
70 return self.offset
71
72
73 def GetIsRotated(self, rotate):
74 return self.rotate
75
76
77 def GetMaxSize(self, scale=1):
78 return self.size * scale
79
80
81 def GetScale(self):
82 return self.scale
83
84
85 def SetIsRotated(self, rotate):
86 self.rotate = rotate
87
88
89 def GetMaxSize(self, scale=1):
90 return self.size * scale
91
92
93 def GetPolygon(self):
94 return self.polygon
95
96
97 def SetPosition(self, pos):
98 self.pos = pos
99
100
101 def SetSize(self, size):
102 self.size = size
103
104
105 def SetOffset(self, offset):
106 self.offset = offset
107
108
109 def SetClockSize(self, clocksize):
110 self.clocksize = clocksize
111
112
113 def SetScale(self, scale):
114 self.scale = scale
115
116
117 def SetIsRotated(self, rotate):
118 self.rotate = rotate
119
120
121 def SetPolygon(self, polygon):
122 self.polygon = polygon
123
124 #----------------------------------------------------------------------
125
126 class ElementWithDyer(Element):
127 """Base class for clock face and hands."""
128
129 def __init__(self, **kwargs):
130 self.dyer = kwargs.pop("dyer", Dyer())
131 Element.__init__(self, **kwargs)
132
133
134 def GetFillColour(self):
135 return self.dyer.GetFillColour()
136
137
138 def GetBorderColour(self):
139 return self.dyer.GetBorderColour()
140
141
142 def GetBorderWidth(self):
143 return self.dyer.GetBorderWidth()
144
145
146 def GetShadowColour(self):
147 return self.dyer.GetShadowColour()
148
149
150 def SetFillColour(self, colour):
151 self.dyer.SetFillColour(colour)
152
153
154 def SetBorderColour(self, colour):
155 self.dyer.SetBorderColour(colour)
156
157
158 def SetBorderWidth(self, width):
159 self.dyer.SetBorderWidth(width)
160
161
162 def SetShadowColour(self, colour):
163 self.dyer.SetShadowColour(colour)
164
165 #----------------------------------------------------------------------
166
167 class Face(ElementWithDyer):
168 """Holds info about the clock face."""
169
170 def __init__(self, **kwargs):
171 ElementWithDyer.__init__(self, **kwargs)
172
173
174 def Draw(self, dc):
175 self.dyer.Select(dc)
176 dc.DrawCircle(self.pos.x, self.pos.y, self.radius)
177
178
179 def RecalcCoords(self, clocksize, centre, scale):
180 self.radius = min(clocksize.Get()) / 2. - self.dyer.width / 2.
181 self.pos = centre
182
183 #----------------------------------------------------------------------
184
185 class Hand(ElementWithDyer):
186 """Holds info about a clock hand."""
187
188 def __init__(self, **kwargs):
189 self.lenfac = kwargs.pop("lenfac")
190 ElementWithDyer.__init__(self, **kwargs)
191
192 self.SetPolygon([[-1, 0], [0, -1], [1, 0], [0, 4]])
193
194
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])
200
201 for i, (x, y) in enumerate(polygon):
202 x *= self.scale * self.size
203 y *= vscale * self.lenfac
204 m, t = self._rect2pol(x, y)
205 polygon[i] = self._pol2rect(m, t - angle)
206
207 dc.DrawPolygon(polygon, centre.x + offset, centre.y + offset)
208
209
210 def RecalcCoords(self, clocksize, centre, scale):
211 self.pos = centre
212 self.scale = scale
213
214 #----------------------------------------------------------------------
215
216 class TickSquare(Element):
217 """Holds info about a tick mark."""
218
219 def __init__(self, **kwargs):
220 Element.__init__(self, **kwargs)
221
222
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.
227
228 dc.DrawRectangle(x + offset, y + offset, width, height)
229
230 #----------------------------------------------------------------------
231
232 class TickCircle(Element):
233 """Holds info about a tick mark."""
234
235 def __init__(self, **kwargs):
236 Element.__init__(self, **kwargs)
237
238
239 def Draw(self, dc, offset=0):
240 radius = self.size * self.scale / 2.
241 x = self.pos.x
242 y = self.pos.y
243
244 dc.DrawCircle(x + offset, y + offset, radius)
245
246 #----------------------------------------------------------------------
247
248 class TickPoly(Element):
249 """Holds info about a tick mark."""
250
251 def __init__(self, **kwargs):
252 Element.__init__(self, **kwargs)
253
254 self.SetPolygon([[0, 1], [1, 0], [2, 1], [1, 5]])
255
256
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]
262
263 width = max([x for x, y in polygon])
264 height = max([y for x, y in polygon])
265
266 return polygon, width, height
267
268
269 def DrawStraight(self, dc, offset=0):
270 polygon, width, height = self._calcPolygon()
271
272 x = self.pos.x - width / 2.
273 y = self.pos.y - height / 2.
274
275 dc.DrawPolygon(polygon, x + offset, y + offset)
276
277
278 def DrawRotated(self, dc, offset=0):
279 polygon, width, height = self._calcPolygon()
280
281 angle = 360 - self.angfac * (self.idx + 1)
282 r = math.radians(angle)
283
284 for i in range(len(polygon)):
285 m, t = self._rect2pol(*polygon[i])
286 t -= angle
287 polygon[i] = self._pol2rect(m, t)
288
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.
291
292 dc.DrawPolygon(polygon, x + offset, y + offset)
293
294 #----------------------------------------------------------------------
295
296 class TickDecimal(Element):
297 """Holds info about a tick mark."""
298
299 def __init__(self, **kwargs):
300 Element.__init__(self, **kwargs)
301
302 self.text = "%s" % (self.idx + 1)
303
304
305 def DrawStraight(self, dc, offset=0):
306 width, height = dc.GetTextExtent(self.text)
307
308 x = self.pos.x - width / 2.
309 y = self.pos.y - height / 2.
310
311 dc.DrawText(self.text, x + offset, y + offset)
312
313
314 def DrawRotated(self, dc, offset=0):
315 width, height = dc.GetTextExtent(self.text)
316
317 angle = 360 - self.angfac * (self.idx + 1)
318 r = math.radians(angle)
319
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.
322
323 dc.DrawRotatedText(self.text, x + offset, y + offset, angle)
324
325
326 #----------------------------------------------------------------------
327
328 class TickRoman(TickDecimal):
329 """Holds info about a tick mark."""
330
331 def __init__(self, **kwargs):
332 TickDecimal.__init__(self, **kwargs)
333
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]
346
347 #----------------------------------------------------------------------
348
349 class TickBinary(TickDecimal):
350 """Holds info about a tick mark."""
351
352 def __init__(self, **kwargs):
353 TickDecimal.__init__(self, **kwargs)
354
355 def d2b(n, b=""):
356 while n > 0:
357 b = str(n % 2) + b; n = n >> 1
358 return b.zfill(4)
359
360 self.text = d2b(self.idx + 1)
361
362 #----------------------------------------------------------------------
363
364 class TickHex(TickDecimal):
365 """Holds info about a tick mark."""
366
367 def __init__(self, **kwargs):
368 TickDecimal.__init__(self, **kwargs)
369
370 self.text = hex(self.idx + 1)[2:].upper()
371
372 #----------------------------------------------------------------------
373
374 class TickNone(Element):
375 """Holds info about a tick mark."""
376
377 def __init__(self, **kwargs):
378 Element.__init__(self, **kwargs)
379
380
381 def Draw(self, dc, offset=0):
382 pass
383
384 #----------------------------------------------------------------------
385
386 class Dyer:
387 """Stores info about colours and borders of clock Elements."""
388
389 def __init__(self, border=None, width=0, fill=None, shadow=None):
390 """
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
395 """
396
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)
403 self.width = width
404
405
406 def Select(self, dc, shadow=False):
407 """Selects the current settings into the dc."""
408
409 if not shadow:
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)
413 else:
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)
417
418
419 def GetFillColour(self):
420 return self.fill
421
422
423 def GetBorderColour(self):
424 return self.border
425
426
427 def GetBorderWidth(self):
428 return self.width
429
430
431 def GetShadowColour(self):
432 return self.shadow
433
434
435 def SetFillColour(self, colour):
436 self.fill = colour
437
438
439 def SetBorderColour(self, colour):
440 self.border = colour
441
442
443 def SetBorderWidth(self, width):
444 self.width = width
445
446
447 def SetShadowColour(self, colour):
448 self.shadow = colour
449
450 #----------------------------------------------------------------------
451
452 class HandSet:
453 """Manages the set of hands."""
454
455 def __init__(self, parent, h, m, s):
456 self.parent = parent
457
458 self.hands = [h, m, s]
459 self.radius = 1
460 self.centre = wx.Point(1, 1)
461
462
463 def _draw(self, dc, shadow=False):
464 ends = [int(x) for x in strftime("%I %M %S", localtime()).split()]
465
466 flags = [self.parent.clockStyle & flag \
467 for flag in self.parent.allHandStyles]
468
469 a_hand = self.hands[0]
470
471 if shadow:
472 offset = self.parent.shadowOffset * a_hand.GetScale()
473 else:
474 offset = 0
475
476 for i, hand in enumerate(self.hands):
477 # Is this hand supposed to be drawn?
478 if flags[i]:
479 idx = ends[i]
480 # Is this the hours hand?
481 if i == 0:
482 idx = idx * 5 + ends[1] / 12
483 # Adjust idx offset and prevent exceptions on leap seconds.
484 idx = idx - 1
485 if idx < 0 or idx > 59:
486 idx = 59
487 angle = math.radians(180 - 6 * (idx + 1))
488
489 hand.dyer.Select(dc, shadow)
490 hand.Draw(dc, (self.radius, self.centre, angle), offset)
491
492
493 def Draw(self, dc):
494 if self.parent.clockStyle & SHOW_SHADOWS:
495 self._draw(dc, True)
496 self._draw(dc)
497
498
499 def RecalcCoords(self, clocksize, centre, scale):
500 self.centre = centre
501 [hand.RecalcCoords(clocksize, centre, scale) for hand in self.hands]
502
503
504 def SetMaxRadius(self, radius):
505 self.radius = radius
506
507
508 def GetSize(self, target):
509 r = []
510 for i, hand in enumerate(self.hands):
511 if _targets[i] & target:
512 r.append(hand.GetSize())
513 return tuple(r)
514
515
516 def GetFillColour(self, target):
517 r = []
518 for i, hand in enumerate(self.hands):
519 if _targets[i] & target:
520 r.append(hand.GetFillColour())
521 return tuple(r)
522
523
524 def GetBorderColour(self, target):
525 r = []
526 for i, hand in enumerate(self.hands):
527 if _targets[i] & target:
528 r.append(hand.GetBorderColour())
529 return tuple(r)
530
531
532 def GetBorderWidth(self, target):
533 r = []
534 for i, hand in enumerate(self.hands):
535 if _targets[i] & target:
536 r.append(hand.GetBorderWidth())
537 return tuple(r)
538
539
540 def GetShadowColour(self):
541 r = []
542 for i, hand in enumerate(self.hands):
543 if _targets[i] & target:
544 r.append(hand.GetShadowColour())
545 return tuple(r)
546
547
548 def SetSize(self, size, target):
549 for i, hand in enumerate(self.hands):
550 if _targets[i] & target:
551 hand.SetSize(size)
552
553
554 def SetFillColour(self, colour, target):
555 for i, hand in enumerate(self.hands):
556 if _targets[i] & target:
557 hand.SetFillColour(colour)
558
559
560 def SetBorderColour(self, colour, target):
561 for i, hand in enumerate(self.hands):
562 if _targets[i] & target:
563 hand.SetBorderColour(colour)
564
565
566 def SetBorderWidth(self, width, target):
567 for i, hand in enumerate(self.hands):
568 if _targets[i] & target:
569 hand.SetBorderWidth(width)
570
571
572 def SetShadowColour(self, colour):
573 for i, hand in enumerate(self.hands):
574 hand.SetShadowColour(colour)
575
576 #----------------------------------------------------------------------
577
578 class TickSet:
579 """Manages a set of tick marks."""
580
581 def __init__(self, parent, **kwargs):
582 self.parent = parent
583 self.dyer = Dyer()
584 self.noe = {"minutes": 60, "hours": 12}[kwargs["kind"]]
585 self.font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
586
587 style = kwargs.pop("style")
588 self.kwargs = kwargs
589 self.SetStyle(style)
590
591
592 def _draw(self, dc, shadow=False):
593 dc.SetFont(self.font)
594
595 a_tick = self.ticks[0]
596
597 if shadow:
598 offset = self.parent.shadowOffset * a_tick.GetScale()
599 else:
600 offset = 0
601
602 clockStyle = self.parent.clockStyle
603
604 for idx, tick in self.ticks.items():
605 draw = False
606
607 # Are we a set of hours?
608 if self.noe == 12:
609 # Should we show all hours ticks?
610 if clockStyle & SHOW_HOURS_TICKS:
611 draw = True
612 # Or is this tick a quarter and should we show only quarters?
613 elif clockStyle & SHOW_QUARTERS_TICKS and not (idx + 1) % 3.:
614 draw = True
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:
620 draw = True
621 # Right, sir. I promise I won't overlap any tick.
622 else:
623 # Ensure that this tick won't overlap an hour tick.
624 if clockStyle & SHOW_HOURS_TICKS:
625 if (idx + 1) % 5.:
626 draw = True
627 # Ensure that this tick won't overlap a quarter tick.
628 elif clockStyle & SHOW_QUARTERS_TICKS:
629 if (idx + 1) % 15.:
630 draw = True
631 # We're not drawing quarters nor hours, so we can draw all
632 # minutes ticks.
633 else:
634 draw = True
635
636 if draw:
637 tick.Draw(dc, offset)
638
639
640 def Draw(self, dc):
641 if self.parent.clockStyle & SHOW_SHADOWS:
642 self.dyer.Select(dc, True)
643 self._draw(dc, True)
644 self.dyer.Select(dc)
645 self._draw(dc)
646
647
648 def RecalcCoords(self, clocksize, centre, scale):
649 a_tick = self.ticks[0]
650
651 size = a_tick.GetMaxSize(scale)
652 maxsize = size
653
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)
657 dc = wx.MemoryDC()
658 dc.SelectObject(wx.EmptyBitmap(*clocksize.Get()))
659 dc.SetFont(self.font)
660 maxsize = size
661 for tick in self.ticks.values():
662 maxsize = max(*(dc.GetTextExtent(tick.text) + (maxsize,)))
663
664 radius = self.radius = min(clocksize.Get()) / 2. - \
665 self.dyer.width / 2. - \
666 maxsize / 2. - \
667 a_tick.GetOffset() * scale - \
668 self.parent.shadowOffset * scale
669
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]
675
676 for i, tick in self.ticks.items():
677 tick.SetClockSize(clocksize)
678 tick.SetScale(scale)
679
680 deg = 180 - angfac * (i + 1)
681 angle = math.radians(deg)
682
683 x = centre.x + radius * math.sin(angle)
684 y = centre.y + radius * math.cos(angle)
685
686 tick.SetPosition(wx.Point(x, y))
687
688
689 def GetSize(self):
690 return self.kwargs["size"]
691
692
693 def GetFillColour(self):
694 return self.dyer.GetFillColour()
695
696
697 def GetBorderColour(self):
698 return self.dyer.GetBorderColour()
699
700
701 def GetBorderWidth(self):
702 return self.dyer.GetBorderWidth()
703
704
705 def GetPolygon(self):
706 a_tick = self.ticks.values()[0]
707 return a_tick.GetPolygon()
708
709
710 def GetFont(self):
711 return self.font
712
713
714 def GetOffset(self):
715 a_tick = self.ticks[0]
716 return a_tick.GetOffset()
717
718
719 def GetShadowColour(self):
720 return self.dyer.GetShadowColour()
721
722
723 def GetIsRotated(self):
724 a_tick = self.ticks[0]
725 return a_tick.GetIsRotated()
726
727
728 def GetStyle(self):
729 return self.style
730
731
732 def SetSize(self, size):
733 self.kwargs["size"] = size
734 [tick.SetSize(size) for tick in self.ticks.values()]
735
736
737 def SetFillColour(self, colour):
738 self.dyer.SetFillColour(colour)
739
740
741 def SetBorderColour(self, colour):
742 self.dyer.SetBorderColour(colour)
743
744
745 def SetBorderWidth(self, width):
746 self.dyer.SetBorderWidth(width)
747
748
749 def SetPolygon(self, polygon):
750 [tick.SetPolygon(polygon) for tick in self.ticks.values()]
751
752
753 def SetFont(self, font):
754 self.font = font
755
756
757 def SetOffset(self, offset):
758 self.kwargs["offset"] = offset
759 [tick.SetOffset(offset) for tick in self.ticks.values()]
760
761
762 def SetShadowColour(self, colour):
763 self.dyer.SetShadowColour(colour)
764
765
766 def SetIsRotated(self, rotate):
767 self.kwargs["rotate"] = rotate
768 [tick.SetIsRotated(rotate) for tick in self.ticks.values()]
769
770
771 def SetStyle(self, style):
772 self.style = style
773 tickclass = allTickStyles[style]
774 self.kwargs["rotate"] = self.parent.clockStyle & ROTATE_TICKS
775
776 self.ticks = {}
777 for i in range(self.noe):
778 self.kwargs["idx"] = i
779 self.ticks[i] = tickclass(**self.kwargs)
780
781 #----------------------------------------------------------------------
782
783 class Box:
784 """Gathers info about the clock face and tick sets."""
785
786 def __init__(self, parent, Face, TicksM, TicksH):
787 self.parent = parent
788 self.Face = Face
789 self.TicksH = TicksH
790 self.TicksM = TicksM
791
792
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)
798
799 mgt = self.TicksM.ticks[59]
800 my = mgt.pos.y + mgt.GetMaxSize(scale) + bw
801
802 hgt = self.TicksH.ticks[11]
803 hy = hgt.pos.y + hgt.GetMaxSize(scale) + bw
804
805 niceradius = centre.y - max(my, hy)
806 return niceradius
807
808
809 def Draw(self, dc):
810 [getattr(self, attr).Draw(dc) \
811 for attr in ["Face", "TicksM", "TicksH"]]
812
813
814 def RecalcCoords(self, size, centre, scale):
815 [getattr(self, attr).RecalcCoords(size, centre, scale) \
816 for attr in ["Face", "TicksH", "TicksM"]]
817
818
819 def GetTickSize(self, target):
820 r = []
821 for i, attr in enumerate(["TicksH", "TicksM"]):
822 if _targets[i] & target:
823 tick = getattr(self, attr)
824 r.append(tick.GetSize())
825 return tuple(r)
826
827
828 def GetTickFillColour(self, target):
829 r = []
830 for i, attr in enumerate(["TicksH", "TicksM"]):
831 if _targets[i] & target:
832 tick = getattr(self, attr)
833 r.append(tick.GetFillColour())
834 return tuple(r)
835
836
837 def GetTickBorderColour(self, target):
838 r = []
839 for i, attr in enumerate(["TicksH", "TicksM"]):
840 if _targets[i] & target:
841 tick = getattr(self, attr)
842 r.append(tick.GetBorderColour())
843 return tuple(r)
844
845
846 def GetTickBorderWidth(self, target):
847 r = []
848 for i, attr in enumerate(["TicksH", "TicksM"]):
849 if _targets[i] & target:
850 tick = getattr(self, attr)
851 r.append(tick.GetBorderWidth())
852 return tuple(r)
853
854
855 def GetTickPolygon(self, target):
856 r = []
857 for i, attr in enumerate(["TicksH", "TicksM"]):
858 if _targets[i] & target:
859 tick = getattr(self, attr)
860 r.append(tick.GetPolygon())
861 return tuple(r)
862
863
864 def GetTickFont(self, target):
865 r = []
866 for i, attr in enumerate(["TicksH", "TicksM"]):
867 if _targets[i] & target:
868 tick = getattr(self, attr)
869 r.append(tick.GetFont())
870 return tuple(r)
871
872
873 def GetIsRotated(self):
874 a_tickset = self.TicksH
875 return a_tickset.GetIsRotated()
876
877
878 def GetTickOffset(self, target):
879 r = []
880 for i, attr in enumerate(["TicksH", "TicksM"]):
881 if _targets[i] & target:
882 tick = getattr(self, attr)
883 r.append(tick.GetOffset())
884 return tuple(r)
885
886
887 def GetShadowColour(self):
888 a_tickset = self.TicksH
889 return a_tickset.GetShadowColour()
890
891
892 def GetTickStyle(self, target):
893 r = []
894 for i, attr in enumerate(["TicksH", "TicksM"]):
895 if _targets[i] & target:
896 tick = getattr(self, attr)
897 r.append(tick.GetStyle())
898 return tuple(r)
899
900
901 def SetTickSize(self, size, target):
902 for i, attr in enumerate(["TicksH", "TicksM"]):
903 if _targets[i] & target:
904 tick = getattr(self, attr)
905 tick.SetSize(size)
906
907
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)
913
914
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)
920
921
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)
927
928
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)
934
935
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))
942
943
944 def SetIsRotated(self, rotate):
945 [getattr(self, attr).SetIsRotated(rotate) \
946 for attr in ["TicksH", "TicksM"]]
947
948
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)
954
955
956 def SetShadowColour(self, colour):
957 for attr in ["TicksH", "TicksM"]:
958 tick = getattr(self, attr)
959 tick.SetShadowColour(colour)
960
961
962 def SetTickStyle(self, style, target):
963 for i, attr in enumerate(["TicksH", "TicksM"]):
964 if _targets[i] & target:
965 tick = getattr(self, attr)
966 tick.SetStyle(style)
967
968 #----------------------------------------------------------------------
969
970 # Relationship between styles and ticks class names.
971 allTickStyles = {TICKS_BINARY: TickBinary,
972 TICKS_CIRCLE: TickCircle,
973 TICKS_DECIMAL: TickDecimal,
974 TICKS_HEX: TickHex,
975 TICKS_NONE: TickNone,
976 TICKS_POLY: TickPoly,
977 TICKS_ROMAN: TickRoman,
978 TICKS_SQUARE: TickSquare}
979
980
981 #
982 ##
983 ### eof