Finally, some OpenGL work.
[krufty_fps.git] / pygame_gui / widgets.xml
blobf70749009f1af9edcd6897169c31f91ea0ac6217
1 <?xml version="1.0" encoding="UTF-8"?>
2 <widgets>
4   <images>
6     <image>
7       <filename>button_bottom.png</filename>
8       <name>button_bottom_png</name>
9     </image>
11     <image>
12       <filename>button_left_bottom.png</filename>
13       <name>button_left_bottom_png</name>
14     </image>
16     <image>
17       <filename>button_left.png</filename>
18       <name>button_left_png</name>
19     </image>
21     <image>
22       <filename>button_left_top.png</filename>
23       <name>button_left_top_png</name>
24     </image>
26     <image>
27       <filename>button.png</filename>
28       <name>button_png</name>
29     </image>
31     <image>
32       <filename>button_right_bottom.png</filename>
33       <name>button_right_bottom_png</name>
34     </image>
36     <image>
37       <filename>button_right.png</filename>
38       <name>button_right_png</name>
39     </image>
41     <image>
42       <filename>button_right_top.png</filename>
43       <name>button_right_top_png</name>
44     </image>
46     <image>
47       <filename>button_top.png</filename>
48       <name>button_top_png</name>
49     </image>
51     <image>
52       <filename>button_bottom_pressed.png</filename>
53       <name>button_bottom_pressed_png</name>
54     </image>
56     <image>
57       <filename>button_left_bottom_pressed.png</filename>
58       <name>button_left_bottom_pressed_png</name>
59     </image>
61     <image>
62       <filename>button_left_pressed.png</filename>
63       <name>button_left_pressed_png</name>
64     </image>
66     <image>
67       <filename>button_left_top_pressed.png</filename>
68       <name>button_left_top_pressed_png</name>
69     </image>
71     <image>
72       <filename>button_right_bottom_pressed.png</filename>
73       <name>button_right_bottom_pressed_png</name>
74     </image>
76     <image>
77       <filename>button_right_pressed.png</filename>
78       <name>button_right_pressed_png</name>
79     </image>
81     <image>
82       <filename>button_right_top_pressed.png</filename>
83       <name>button_right_top_pressed_png</name>
84     </image>
86     <image>
87       <filename>button_top_pressed.png</filename>
88       <name>button_top_pressed_png</name>
89     </image>
91     <image>
92       <filename>button_center.png</filename>
93       <name>button_center_png</name>
94     </image>
96     <image>
97       <filename>textbox_bottom.png</filename>
98       <name>textbox_bottom_png</name>
99     </image>
101     <image>
102       <filename>textbox_left_bottom.png</filename>
103       <name>textbox_left_bottom_png</name>
104     </image>
106     <image>
107       <filename>textbox_left.png</filename>
108       <name>textbox_left_png</name>
109     </image>
111     <image>
112       <filename>textbox_left_top.png</filename>
113       <name>textbox_left_top_png</name>
114     </image>
116     <image>
117       <filename>textbox_right_bottom.png</filename>
118       <name>textbox_right_bottom_png</name>
119     </image>
121     <image>
122       <filename>textbox_right.png</filename>
123       <name>textbox_right_png</name>
124     </image>
126     <image>
127       <filename>textbox_right_top.png</filename>
128       <name>textbox_right_top_png</name>
129     </image>
131     <image>
132       <filename>textbox_top.png</filename>
133       <name>textbox_top_png</name>
134     </image>
136     <image>
137       <filename>textbox_center.png</filename>
138       <name>textbox_center_png</name>
139     </image>
141   </images>
143   <widget>
145     <name>label</name>
147     <parameter name="width" default="kill" type="int" />
148     <parameter name="height" default="kill" type="int" />
149     <parameter name="text" default="" />
151     <part>
152       <name>label_text</name>
153       <type>text:direct</type>
154       <source>text</source>
156       <position>0, 0</position>
157       <size>width, height</size>
158     </part>
160   </widget>
162   <widget>
164     <name>button</name>
166     <parameter name="width" default="kill" type="int" />
167     <parameter name="height" default="kill" type="int" />
168     <parameter name="text" default="" />
170     <part>
171       <name>button_center</name>
172       <type>image</type>
173       <source>button_center_png</source>
174       <zindex>0</zindex>
176         <position>button_left_top_png.get_width(), button_left_top_png.get_height()</position>
177         <size>width - (button_right_top_png.get_width() + button_left_top_png.get_width()), height - (button_right_bottom_png.get_height() + button_right_top_png.get_height())</size>
178     </part>
180     <part>
181       <name>button_text</name>
182       <type>text</type>
183       <source>text</source>
184       <zindex>1</zindex>
186       <position>[(width / 2) - (button_text.get_width() / 2), (height / 2) - (button_text.get_height() / 2)]</position>
187       <size>width, height</size>
188     </part>
190     <part>
191       <name>button_left_top</name>
192       <type>image</type>
193       <source>button_left_top_png</source>
194       <zindex>1</zindex>
196       <position>0, 0</position>
197       <size>button_left_top_png.get_width(), button_left_top_png.get_height()</size>
198     </part>
200     <part>
201       <name>button_top</name>
202       <type>image</type>
203       <source>button_top_png</source>
204       <zindex>1</zindex>
206       <position>button_left_top_png.get_width(), 0</position>
207       <size>width - (button_left_top_png.get_width() + button_right_top_png.get_width()), button_top_png.get_height()</size>
208     </part>
210     <part>
211       <name>button_right_top</name>
212       <type>image</type>
213       <source>button_right_top_png</source>
214       <zindex>1</zindex>
216       <position>width - button_right_top_png.get_width(), 0</position>
217       <size>button_right_top_png.get_width(), button_right_top_png.get_height()</size>
218     </part>
220     <part>
221       <name>button_right</name>
222       <type>image</type>
223       <source>button_right_png</source>
224       <zindex>1</zindex>
226       <position>width - button_right_png.get_width(), button_right_top_png.get_height()</position>
227       <size>button_right_png.get_width(), height - (button_right_top_png.get_height() + button_right_bottom_png.get_height())</size>
228     </part>
230     <part>
231       <name>button_right_bottom</name>
232       <type>image</type>
233       <source>button_right_bottom_png</source>
234       <zindex>1</zindex>
236       <position>width - button_right_bottom_png.get_width(), height - button_right_bottom_png.get_height()</position>
237       <size>button_right_bottom_png.get_width(), button_right_bottom_png.get_height()</size>
238     </part>
240     <part>
241       <name>button_bottom</name>
242       <type>image</type>
243       <source>button_bottom_png</source>
244       <zindex>1</zindex>
246       <position>button_left_top_png.get_width(), height - button_bottom_png.get_height()</position>
247       <size>width - (button_left_top_png.get_width() + button_right_top_png.get_width()), button_bottom_png.get_height()</size>
248     </part>
250     <part>
251       <name>button_left_bottom</name>
252       <type>image</type>
253       <source>button_left_bottom_png</source>
254       <zindex>1</zindex>
256       <position>0, height - button_left_bottom_png.get_height()</position>
257       <size>button_left_bottom_png.get_width(), button_left_top_png.get_height()</size>
258     </part>
260     <part>
261       <name>button_left</name>
262       <type>image</type>
263       <source>button_left_png</source>
264       <zindex>1</zindex>
266       <position>0, button_left_top_png.get_height()</position>
267       <size>button_left_png.get_width(), height - (button_left_top_png.get_height() + button_left_bottom_png.get_height())</size>
268     </part>
270     <behavior>
271       <on_event>MOUSEBUTTONUP</on_event>
273       <do>self.setPart('button_bottom', 'button_bottom_png')
274 self.setPart('button_left_bottom', 'button_left_bottom_png')
275 self.setPart('button_left', 'button_left_png')
276 self.setPart('button_left_top', 'button_left_top_png')
277 self.setPart('button_right_bottom', 'button_right_bottom_png')
278 self.setPart('button_right', 'button_right_png')
279 self.setPart('button_right_top', 'button_right_top_png')
280 self.setPart('button_top', 'button_top_png')
281 self.raiseEvent('BUTTON_CLICKED', {})</do>
283     </behavior>
285     <behavior>
286       <on_event>MOUSEBUTTONDOWN</on_event>
288       <do>self.setPart('button_bottom', 'button_bottom_pressed_png')
289 self.setPart('button_left_bottom', 'button_left_bottom_pressed_png')
290 self.setPart('button_left', 'button_left_pressed_png')
291 self.setPart('button_left_top', 'button_left_top_pressed_png')
292 self.setPart('button_right_bottom', 'button_right_bottom_pressed_png')
293 self.setPart('button_right', 'button_right_pressed_png')
294 self.setPart('button_right_top', 'button_right_top_pressed_png')
295 self.setPart('button_top', 'button_top_pressed_png')
296 </do>
298     </behavior>
300   </widget>
302   <widget>
304     <name>textbox</name>
306     <parameter name="width" default="kill" type="int" />
307     <parameter name="height" default="25" type="int" />
308     <parameter name="text" default="" />
310     <parameter name="render_text" default=" " />
312     <parameter name="insertion_mark" default="|" />
313     <parameter name="insertion_position" default="0" type="int" />
315     <parameter name="text_left" type="int" default="2" />
316     <parameter name="text_top" type="int" default="2" />
318     <part>
319       <name>contents</name>
320       <type>text</type>
321       <source>render_text</source>
323       <position>textbox_left_top_png.get_width() + self.params['parameters']['text_left'], textbox_left_top_png.get_height() + self.params['parameters']['text_top']</position>
324       <size>width, height</size>
326       <!--
327         width - (textbox_left_top_png.get_width() + textbox_right_top_png.get_width() + 4), height - (textbox_left_top_png.get_height() + textbox_right_top_png.get_height() + 4)
328         -->
329     </part>
331     <part>
332       <name>textbox_left_top</name>
333       <type>image</type>
334       <source>textbox_left_top_png</source>
336       <position>0, 0</position>
337       <size>textbox_left_top_png.get_width() , textbox_left_top_png.get_height()</size>
338     </part>
341     <part>
342       <name>textbox_top</name>
343       <type>image</type>
344       <source>textbox_top_png</source>
346       <position>textbox_left_top_png.get_width(), 0</position>
347       <size>width - (textbox_left_top_png.get_width() + textbox_right_top_png.get_width()), textbox_top_png.get_height()</size>
348     </part>
350     <part>
351       <name>textbox_right_top</name>
352       <type>image</type>
353       <source>textbox_right_top_png</source>
355       <position>width - textbox_right_top_png.get_width(), 0</position>
356       <size>textbox_right_top_png.get_width(), textbox_right_top_png.get_height()</size>
357     </part>
359     <part>
360       <name>textbox_right</name>
361       <type>image</type>
362       <source>textbox_right_png</source>
364       <position>width - textbox_right_png.get_width(), textbox_right_top_png.get_height()</position>
365       <size>textbox_right_png.get_width(), height - (textbox_right_top_png.get_height() + textbox_right_bottom_png.get_height())</size>
366     </part>
368     <part>
369       <name>textbox_right_bottom</name>
370       <type>image</type>
371       <source>textbox_right_bottom_png</source>
373       <position>width - textbox_right_bottom_png.get_width(), height - textbox_right_bottom_png.get_height()</position>
374       <size>textbox_right_bottom_png.get_width(), textbox_right_bottom_png.get_height()</size>
375     </part>
377     <part>
378       <name>textbox_bottom</name>
379       <type>image</type>
380       <source>textbox_bottom_png</source>
382       <position>textbox_left_top_png.get_width(), height - textbox_bottom_png.get_height()</position>
383       <size>width - (textbox_left_top_png.get_width() + textbox_right_top_png.get_width()), textbox_bottom_png.get_height()</size>
384     </part>
386     <part>
387       <name>textbox_left_bottom</name>
388       <type>image</type>
389       <source>textbox_left_bottom_png</source>
391       <position>0, height - textbox_left_bottom_png.get_height()</position>
392       <size>textbox_left_bottom_png.get_width(), textbox_left_top_png.get_height()</size>
393     </part>
395     <part>
396       <name>textbox_left</name>
397       <type>image</type>
398       <source>textbox_left_png</source>
400       <position>0, textbox_left_top_png.get_height()</position>
401       <size>textbox_left_png.get_width(), height - (textbox_left_top_png.get_height() + textbox_left_bottom_png.get_height())</size>
402     </part>
404     <part>
405       <name>textbox_center</name>
406       <type>image</type>
407       <source>textbox_center_png</source>
409       <position>textbox_left_top_png.get_width(), textbox_left_top_png.get_height()</position>
410       <size>width - textbox_right_top_png.get_width() , height - textbox_right_bottom_png.get_height() - 1</size>
411     </part>
413     <behavior>
415       <on_event>KEYDOWN</on_event>
417       <do>
419 letter = the_event['data']['unicode']
420 the_number = the_event['data']['key']
421 key_mod = the_event['data']['mod']
423 cur_pos = self.params['parameters']['insertion_position']
425 temp_array = array.array('u', self.params['parameters']['text'].decode())
427 if the_number == 8:
428     if len(temp_array):
429        if cur_pos != 0:
430            temp_array.pop(cur_pos)
431            cur_pos -= 1
432        else:
433            temp_array.pop(0)
435 if the_number == 127:
436     if cur_pos + 1 != len(temp_array):
437         if len(temp_array):
438             temp_array.pop(cur_pos + 1)
440 if letter in letters or letter in punctuation or letter in digits or letter == ' ':
441     if the_number == 308 or the_number == 303 or the_number == 277 or the_number == 300 or the_number == 302:
442         pass
444     elif the_number &gt;= 300 and the_number &lt;= 314:
445         pass
447     elif the_number &gt;= 282 and the_number &lt;= 293:
448         pass
450     elif the_number == 274 or the_number == 273 or the_number == 9:
451         pass
453     elif the_number == 276:
454         if cur_pos == 0:
455             cur_pos = 0
456         else:
457             cur_pos -= 1
459     elif the_number == 275:
460         if cur_pos == len(temp_array) - 1:
461             pass
462         else:
463             cur_pos += 1
465     elif len(temp_array) == 0:
466         temp_array.append(letter.decode())
467         cur_pos = 0
469     elif cur_pos == 0 and not len(temp_array):
470         temp_array.append(letter.decode())
471         cur_pos += 1
473     elif len(temp_array) - 1 == cur_pos:
474         temp_array.append(letter.decode())
475         cur_pos += 1
477     else:
478         temp_array.insert(cur_pos + 1, letter.decode())
479         cur_pos += 1
481 self.params['parameters']['insertion_position'] = cur_pos
482 self.params['parameters']['text'] = temp_array.tounicode()
483 temp_array.insert(self.params['parameters']['insertion_position'] + 1, self.params['parameters']['insertion_mark'])
485 prerender = self.the_gui_system.the_font.size(temp_array.tounicode().encode())
486 width = self.params['parameters']['width']
488 if width &lt; prerender[0]:
489     if len(temp_array):
490         ratio_text = float(cur_pos) / float(len(temp_array))
492         if ratio_text > (width / prerender[0]):
493             self.params['parameters']['text_left'] = (ratio_text * width) - (ratio_text * prerender[0])
494 else:
495     self.params['parameters']['text_left'] = 2
497 self.params['parameters']['render_text'] = temp_array.tounicode().encode()
499 self.raiseEvent('KEYDOWN', the_event['data'])
501 </do>
503     </behavior>
505     <behavior>
507       <on_event>KEYSTILLDOWN</on_event>
509       <do>
510 #self.event(the_event)
512 #print "debug", the_event['data']
514 self.event({'type': 'KEYDOWN', 'data': the_event['data']})
515 </do>
517     </behavior>
519   </widget>
521 </widgets>