comparison pyntnclick/widgets/__init__.py @ 636:2748d3afcae5 pyntnclick

Excise albow. Really.
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 12 Feb 2012 00:10:17 +0200
parents 8ff93e53c882
children 2703924c8c70
comparison
equal deleted inserted replaced
635:d9623d453fd9 636:2748d3afcae5
5 5
6 """Custom Albow widgets""" 6 """Custom Albow widgets"""
7 7
8 import textwrap 8 import textwrap
9 9
10 import albow.controls
11 import albow.menu
12 from albow.resource import get_font, get_image
13 from pygame.color import Color 10 from pygame.color import Color
14 from pygame.rect import Rect 11 from pygame.rect import Rect
15 from pygame.draw import lines as draw_lines 12 from pygame.draw import lines as draw_lines
16 from pygame import mouse 13 from pygame import mouse
17 14
15 from pyntnclick.widgets.base import Widget
18 from pyntnclick.cursor import CursorWidget 16 from pyntnclick.cursor import CursorWidget
19 17
20 # XXX: Need a way to get at the constants. 18 # XXX: Need a way to get at the constants.
21 from pyntnclick.constants import GameConstants 19 from pyntnclick.constants import GameConstants
22 BUTTON_SIZE = GameConstants().button_size 20 BUTTON_SIZE = GameConstants().button_size
23 21 # XXX: Needs a way to get at resource:
24 22 from pyntnclick.resources import Resources
25 class BoomLabel(albow.controls.Label): 23 get_image = Resources("Resources").get_image
24
25
26 class BoomLabel(Widget): # WAS: albow.controls.Label):
26 27
27 trim_line_top = 0 28 trim_line_top = 0
28 29
29 def __init__(self, text, width=None, **kwds): 30 def __init__(self, text, width=None, **kwds):
30 albow.controls.Label.__init__(self, text, width, **kwds) 31 albow.controls.Label.__init__(self, text, width, **kwds)
144 145
145 def cursor_highlight(self): 146 def cursor_highlight(self):
146 return False 147 return False
147 148
148 149
149 class HandButton(albow.controls.Image): 150 class HandButton(Widget): # WAS: albow.controls.Image):
150 """The fancy hand button for the widget""" 151 """The fancy hand button for the widget"""
151 152
152 def __init__(self, action): 153 def __init__(self, action):
153 this_image = get_image('items', 'hand.png') 154 this_image = get_image('items', 'hand.png')
154 albow.controls.Image.__init__(self, image=this_image) 155 albow.controls.Image.__init__(self, image=this_image)
157 158
158 def mouse_down(self, event): 159 def mouse_down(self, event):
159 self.action() 160 self.action()
160 161
161 162
162 class PopupMenuButton(albow.controls.Button): 163 class PopupMenuButton(Widget): # WAS: albow.controls.Button):
163 164
164 def __init__(self, text, action): 165 def __init__(self, text, action):
165 albow.controls.Button.__init__(self, text, action) 166 albow.controls.Button.__init__(self, text, action)
166 167
167 self.font = get_font(16, 'Vera.ttf') 168 self.font = get_font(16, 'Vera.ttf')
168 self.set_rect(Rect(0, 0, BUTTON_SIZE, BUTTON_SIZE)) 169 self.set_rect(Rect(0, 0, BUTTON_SIZE, BUTTON_SIZE))
169 self.margin = (BUTTON_SIZE - self.font.get_linesize()) / 2 170 self.margin = (BUTTON_SIZE - self.font.get_linesize()) / 2
170 171
171 172
172 class PopupMenu(albow.menu.Menu, CursorWidget): 173 class PopupMenu(Widget): # WAS: albow.menu.Menu, CursorWidget):
173 174
174 def __init__(self, screen): 175 def __init__(self, screen):
175 CursorWidget.__init__(self, screen) 176 CursorWidget.__init__(self, screen)
176 self.screen = screen 177 self.screen = screen
177 items = [ 178 items = [
190 if item > -1: 191 if item > -1:
191 # A menu item needs to be invoked 192 # A menu item needs to be invoked
192 self.invoke_item(item) 193 self.invoke_item(item)
193 194
194 195
195 class BoomImageButton(albow.controls.Image): 196 class BoomImageButton(Widget): # WAS: albow.controls.Image):
196 """The fancy image button for the screens""" 197 """The fancy image button for the screens"""
197 198
198 FOLDER = None 199 FOLDER = None
199 200
200 def __init__(self, filename, x, y, action, enable=None): 201 def __init__(self, filename, x, y, action, enable=None):