1#file: constants.py
2#Copyright (C) 2008 FunnyMan3595
3#This file is part of Endgame: Singularity.
4
5#Endgame: Singularity is free software; you can redistribute it and/or modify
6#it under the terms of the GNU General Public License as published by
7#the Free Software Foundation; either version 2 of the License, or
8#(at your option) any later version.
9
10#Endgame: Singularity is distributed in the hope that it will be useful,
11#but WITHOUT ANY WARRANTY; without even the implied warranty of
12#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13#GNU General Public License for more details.
14
15#You should have received a copy of the GNU General Public License
16#along with Endgame: Singularity; if not, write to the Free Software
17#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19#This file contains GUI constants.
20
21# Anchor positions, border sided.
22TOP, MID, BOTTOM = range(3)
23LEFT, CENTER, RIGHT = range(3,6)
24TOP_LEFT = (TOP, LEFT)
25TOP_CENTER = (TOP, CENTER)
26TOP_RIGHT = (TOP, RIGHT)
27MID_LEFT = (MID, LEFT)
28MID_CENTER = (MID, CENTER)
29MID_RIGHT = (MID, RIGHT)
30BOTTOM_LEFT = (BOTTOM, LEFT)
31BOTTOM_CENTER = (BOTTOM, CENTER)
32BOTTOM_RIGHT = (BOTTOM, RIGHT)
33
34# All border sides
35ALL = (TOP, BOTTOM, LEFT, RIGHT)
36
37
38# Used when an unambiguous "No Result" return is required.  (None may have a
39# meaning.)
40
41class _NoResult(object):
42    def __eq__(self, other):
43        return type(self) == type(other)
44    def __ne__(self, other):
45        return type(self) != type(other)
46
47NO_RESULT = _NoResult()
48
49
50# Handler types.
51KEY, KEYDOWN, KEYUP, CLICK, DOUBLECLICK, MOUSEMOTION, DRAG, TICK, MOUSEWHEEL = range(9)
52
53
54# Handler "errors", used to throw a return value up several levels.
55class Handled(Exception): pass
56class ExitDialog(Exception): pass
57
58# Key constants for XO-1 buttons.
59XO1_X = object()
60XO1_O = object()
61XO1_SQUARE = object()
62
63# Characters set
64DIGIT_CHARS = set('0123456789')
65