Mercurial > fife-parpg
comparison ext/guichan-0.8.2/include/guichan/key.hpp @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 /* _______ __ __ __ ______ __ __ _______ __ __ | |
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ | |
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / | |
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / | |
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / | |
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / | |
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ | |
8 * | |
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson | |
10 * | |
11 * | |
12 * Per Larsson a.k.a finalman | |
13 * Olof Naessén a.k.a jansem/yakslem | |
14 * | |
15 * Visit: http://guichan.sourceforge.net | |
16 * | |
17 * License: (BSD) | |
18 * Redistribution and use in source and binary forms, with or without | |
19 * modification, are permitted provided that the following conditions | |
20 * are met: | |
21 * 1. Redistributions of source code must retain the above copyright | |
22 * notice, this list of conditions and the following disclaimer. | |
23 * 2. Redistributions in binary form must reproduce the above copyright | |
24 * notice, this list of conditions and the following disclaimer in | |
25 * the documentation and/or other materials provided with the | |
26 * distribution. | |
27 * 3. Neither the name of Guichan nor the names of its contributors may | |
28 * be used to endorse or promote products derived from this software | |
29 * without specific prior written permission. | |
30 * | |
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
42 */ | |
43 | |
44 #ifndef GCN_KEY_HPP | |
45 #define GCN_KEY_HPP | |
46 | |
47 #include "guichan/platform.hpp" | |
48 | |
49 // windows.h defines DELETE which breaks this file as we have a constant named | |
50 // DELETE, hence we undefine DELETE if it is defined and hope people don't use | |
51 // that windows define with Guichan. | |
52 #if defined (_WIN32) && defined(DELETE) | |
53 #undef DELETE | |
54 #endif | |
55 | |
56 namespace gcn | |
57 { | |
58 /** | |
59 * Represents a key or a character. | |
60 */ | |
61 class GCN_CORE_DECLSPEC Key | |
62 { | |
63 public: | |
64 | |
65 /** | |
66 * Constructor. | |
67 * | |
68 * @param value The ascii or enum value for the key. | |
69 */ | |
70 Key(int value = 0); | |
71 | |
72 /** | |
73 * Checks if a key is a character. | |
74 * | |
75 * @return True if the key is a letter, number or whitespace, | |
76 * false otherwise. | |
77 */ | |
78 bool isCharacter() const; | |
79 | |
80 /** | |
81 * Checks if a key is a number. | |
82 * | |
83 * @return True if the key is a number (0-9), | |
84 * false otherwise. | |
85 */ | |
86 bool isNumber() const; | |
87 | |
88 /** | |
89 * Checks if a key is a letter. | |
90 * | |
91 * @return True if the key is a letter (a-z,A-Z), | |
92 * false otherwise. | |
93 */ | |
94 bool isLetter() const; | |
95 | |
96 /** | |
97 * Gets the value of the key. If an ascii value exists it | |
98 * will be returned. Otherwise an enum value will be returned. | |
99 * | |
100 * @return the value of the key. | |
101 */ | |
102 int getValue() const; | |
103 | |
104 /** | |
105 * Compares two keys. | |
106 * | |
107 * @param key The key to compare this key with. | |
108 * @return True if the keys are equal, false otherwise. | |
109 */ | |
110 bool operator==(const Key& key) const; | |
111 | |
112 /** | |
113 * Compares two keys. | |
114 * | |
115 * @param key The key to compare this key with. | |
116 * @return True if the keys are not equal, false otherwise. | |
117 */ | |
118 bool operator!=(const Key& key) const; | |
119 | |
120 /** | |
121 * An enum with key values. | |
122 */ | |
123 enum | |
124 { | |
125 SPACE = ' ', | |
126 TAB = '\t', | |
127 ENTER = '\n', | |
128 LEFT_ALT = -1000, | |
129 RIGHT_ALT, | |
130 LEFT_SHIFT, | |
131 RIGHT_SHIFT, | |
132 LEFT_CONTROL, | |
133 RIGHT_CONTROL, | |
134 LEFT_META, | |
135 RIGHT_META, | |
136 LEFT_SUPER, | |
137 RIGHT_SUPER, | |
138 INSERT, | |
139 HOME, | |
140 PAGE_UP, | |
141 DELETE, | |
142 END, | |
143 PAGE_DOWN, | |
144 ESCAPE, | |
145 CAPS_LOCK, | |
146 BACKSPACE, | |
147 F1, | |
148 F2, | |
149 F3, | |
150 F4, | |
151 F5, | |
152 F6, | |
153 F7, | |
154 F8, | |
155 F9, | |
156 F10, | |
157 F11, | |
158 F12, | |
159 F13, | |
160 F14, | |
161 F15, | |
162 PRINT_SCREEN, | |
163 SCROLL_LOCK, | |
164 PAUSE, | |
165 NUM_LOCK, | |
166 ALT_GR, | |
167 LEFT, | |
168 RIGHT, | |
169 UP, | |
170 DOWN | |
171 }; | |
172 | |
173 protected: | |
174 /** | |
175 * Holds the value of the key. It may be an ascii value | |
176 * or an enum value. | |
177 */ | |
178 int mValue; | |
179 }; | |
180 } | |
181 | |
182 #endif // end GCN_KEY_HPP |