Mercurial > pyntnclick
comparison gamelib/widgets.py @ 465:03dcb25d8370
Slightly prettier Close button labels.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Sun, 29 Aug 2010 01:36:04 +0200 |
parents | ece69836f00a |
children | c72946d3a59a |
comparison
equal
deleted
inserted
replaced
464:54853e61b149 | 465:03dcb25d8370 |
---|---|
8 import albow.controls | 8 import albow.controls |
9 import albow.menu | 9 import albow.menu |
10 from albow.resource import get_font, get_image | 10 from albow.resource import get_font, get_image |
11 from pygame.color import Color | 11 from pygame.color import Color |
12 from pygame.rect import Rect | 12 from pygame.rect import Rect |
13 from pygame.draw import lines | |
13 from pygame import mouse | 14 from pygame import mouse |
14 | 15 |
15 from constants import BUTTON_SIZE | 16 from constants import BUTTON_SIZE |
16 from cursor import CursorWidget | 17 from cursor import CursorWidget |
17 | 18 |
72 | 73 |
73 | 74 |
74 class BoomButton(BoomLabel): | 75 class BoomButton(BoomLabel): |
75 | 76 |
76 def __init__(self, text, action, screen): | 77 def __init__(self, text, action, screen): |
77 super(BoomLabel, self).__init__(text, font=get_font(20, 'Vera.ttf')) | 78 super(BoomLabel, self).__init__(text, font=get_font(20, 'Vera.ttf'), margin=4) |
78 self.bg_color = (0, 0, 0) | 79 self.bg_color = (0, 0, 0) |
80 self._frame_color = Color(50, 50, 50) | |
79 self.action = action | 81 self.action = action |
80 self.screen = screen | 82 self.screen = screen |
81 | 83 |
82 def mouse_down(self, event): | 84 def mouse_down(self, event): |
83 self.action() | 85 self.action() |
84 self.screen.state_widget.mouse_move(event) | 86 self.screen.state_widget.mouse_move(event) |
85 | 87 |
86 def mouse_move(self, event): | 88 def mouse_move(self, event): |
87 self.screen.state.highlight_override = True | 89 self.screen.state.highlight_override = True |
90 | |
91 def draw(self, surface): | |
92 super(BoomButton, self).draw(surface) | |
93 r = surface.get_rect() | |
94 w = 2 | |
95 top, bottom, left, right = r.top, r.bottom, r.left, r.right | |
96 lines(surface, self._frame_color, False, [ | |
97 (left, bottom), (left, top), (right-w, top), (right-w, bottom) | |
98 ], w) | |
88 | 99 |
89 | 100 |
90 class MessageDialog(BoomLabel, CursorWidget): | 101 class MessageDialog(BoomLabel, CursorWidget): |
91 | 102 |
92 def __init__(self, screen, text, wrap_width, style=None, **kwds): | 103 def __init__(self, screen, text, wrap_width, style=None, **kwds): |