Mercurial > boomslang
comparison gamelib/widgets.py @ 217:146cec58ddd8
Highlight detailed view close button
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Thu, 26 Aug 2010 20:26:41 +0200 |
parents | 20998c650ce1 |
children | 3cedc4f95925 |
comparison
equal
deleted
inserted
replaced
216:f7dc767dd971 | 217:146cec58ddd8 |
---|---|
4 """Custom Albow widgets""" | 4 """Custom Albow widgets""" |
5 | 5 |
6 import textwrap | 6 import textwrap |
7 | 7 |
8 import albow.controls | 8 import albow.controls |
9 from albow.resource import get_font | |
9 from pygame.color import Color | 10 from pygame.color import Color |
10 from pygame.locals import BLEND_ADD | 11 from pygame.locals import BLEND_ADD |
11 | 12 |
12 from cursor import CursorWidget | 13 from cursor import CursorWidget |
13 | 14 |
34 self.bg_color = bg_color | 35 self.bg_color = bg_color |
35 | 36 |
36 def _draw_all_no_bg(self, surface): | 37 def _draw_all_no_bg(self, surface): |
37 pass | 38 pass |
38 | 39 |
40 class BoomButton(BoomLabel): | |
41 | |
42 def __init__(self, text, action, screen): | |
43 super(BoomLabel, self).__init__(text, font=get_font(20, 'Vera.ttf')) | |
44 self.bg_color = (0, 0, 0) | |
45 self.action = action | |
46 self.screen = screen | |
47 | |
48 def mouse_down(self, event): | |
49 self.action() | |
50 self.screen.state_widget.mouse_move(event) | |
51 | |
52 def mouse_move(self, event): | |
53 pos = self.parent.global_to_local(event.pos) | |
54 if self.rect.collidepoint(pos): | |
55 self.screen.cursor_highlight(True) | |
56 | |
39 | 57 |
40 class MessageDialog(BoomLabel, CursorWidget): | 58 class MessageDialog(BoomLabel, CursorWidget): |
41 | 59 |
42 def __init__(self, screen, text, wrap_width, style=None, **kwds): | 60 def __init__(self, screen, text, wrap_width, style=None, **kwds): |
43 CursorWidget.__init__(self, screen) | 61 CursorWidget.__init__(self, screen) |