| 1 | /* |
|---|
| 2 | SDL_textmanager |
|---|
| 3 | Copyright (C) 2004 Kazunori Itoyanagi |
|---|
| 4 | |
|---|
| 5 | This library is free software; you can redistribute it and/or |
|---|
| 6 | modify it under the terms of the GNU Library General Public |
|---|
| 7 | License as published by the Free Software Foundation; either |
|---|
| 8 | version 2 of the License, or (at your option) any later version. |
|---|
| 9 | |
|---|
| 10 | This library 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 GNU |
|---|
| 13 | Library General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU Library General Public |
|---|
| 16 | License along with this library; if not, write to the Free |
|---|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | ITOYANAGI Kazunori |
|---|
| 20 | itkz@users.sourceforge.jp |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #ifndef _SDL_textmanager_H_ |
|---|
| 24 | #define _SDL_textmanager_H_ |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | #include <stdio.h> |
|---|
| 28 | |
|---|
| 29 | #include "SDL_version.h" |
|---|
| 30 | #include "SDL.h" |
|---|
| 31 | |
|---|
| 32 | #include "begin_code.h" |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | #define INPUT_METHOD_MAJOR_VERSION 0 |
|---|
| 37 | #define INPUT_METHOD_MINOR_VERSION 1 |
|---|
| 38 | #define INPUT_METHOD_PATCHLEVEL 0 |
|---|
| 39 | |
|---|
| 40 | /* This macro can be used to fill a version structure with the compile-time |
|---|
| 41 | * version of the SDL_textmanager library. |
|---|
| 42 | */ |
|---|
| 43 | #define TEXTMANAGER_VERSION(X) \ |
|---|
| 44 | { \ |
|---|
| 45 | (X)->major = INPUT_METHOD_MAJOR_VERSION; \ |
|---|
| 46 | (X)->minor = INPUT_METHOD_MINOR_VERSION; \ |
|---|
| 47 | (X)->patch = INPUT_METHOD_PATCHLEVEL; \ |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | /* Set up for C function definitions, even when using C++ */ |
|---|
| 52 | #ifdef __cplusplus |
|---|
| 53 | extern "C" { |
|---|
| 54 | #endif |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | /* public ... for Applications */ |
|---|
| 61 | |
|---|
| 62 | typedef enum |
|---|
| 63 | { |
|---|
| 64 | INPUT_METHOD_MESSAGE_NO_EXIST = 0, |
|---|
| 65 | INPUT_METHOD_MESSAGE_IM_ON, |
|---|
| 66 | INPUT_METHOD_MESSAGE_IM_CHANGE, |
|---|
| 67 | INPUT_METHOD_MESSAGE_IM_RESULT, |
|---|
| 68 | INPUT_METHOD_MESSAGE_IM_OFF, |
|---|
| 69 | INPUT_METHOD_MESSAGE_CHAR, |
|---|
| 70 | INPUT_METHOD_MESSAGE_DEAD_CHAR |
|---|
| 71 | } TextManager_Message; |
|---|
| 72 | |
|---|
| 73 | typedef enum |
|---|
| 74 | { |
|---|
| 75 | INPUT_METHOD_SUCCESS = 0, |
|---|
| 76 | INPUT_METHOD_ERROR_ALREADY_INIT, |
|---|
| 77 | INPUT_METHOD_ERROR_ALLOCATED_MEMORY, |
|---|
| 78 | INPUT_METHOD_ERROR_NO_STRING, |
|---|
| 79 | INPUT_METHOD_ERROR_UNKNOWN_MESSAGE, |
|---|
| 80 | INPUT_METHOD_ERROR_SDL_NO_INIT, |
|---|
| 81 | INPUT_METHOD_ERROR_NO_INIT, |
|---|
| 82 | INPUT_METHOD_ERROR_SYSTEM_SPECIFIC, |
|---|
| 83 | INPUT_METHOD_ERROR_ALREADY_VALIDATED, |
|---|
| 84 | INPUT_METHOD_ERROR_ALREADY_INVALIDATED, |
|---|
| 85 | INPUT_METHOD_ERROR_NOT_AVAILABLE, |
|---|
| 86 | INPUT_METHOD_ERROR_INVALID_BOOTSTRAP |
|---|
| 87 | } TextManager_Result; |
|---|
| 88 | |
|---|
| 89 | typedef enum |
|---|
| 90 | { |
|---|
| 91 | DEAD_CHAR_NON = 0, |
|---|
| 92 | DEAD_CHAR_GRAVE, |
|---|
| 93 | DEAD_CHAR_ACUTE, |
|---|
| 94 | DEAD_CHAR_CIRCUMFLEX, |
|---|
| 95 | DEAD_CHAR_TILDE, |
|---|
| 96 | DEAD_CHAR_MACRON, |
|---|
| 97 | DEAD_CHAR_BREVE, |
|---|
| 98 | DEAD_CHAR_ABOVE_DOT, |
|---|
| 99 | DEAD_CHAR_DIAERESIS, |
|---|
| 100 | DEAD_CHAR_ABOVE_RING, |
|---|
| 101 | DEAD_CHAR_DOUBLE_ACUTE, |
|---|
| 102 | DEAD_CHAR_CARON, |
|---|
| 103 | DEAD_CHAR_CEDILLA, |
|---|
| 104 | DEAD_CHAR_OGONEK, |
|---|
| 105 | DEAD_CHAR_IOTA, |
|---|
| 106 | DEAD_CHAR_VOICED_SOUND, |
|---|
| 107 | DEAD_CHAR_SEMIVOICED_SOUND, |
|---|
| 108 | DEAD_CHAR_BELOW_DOT, |
|---|
| 109 | DEAD_CHAR_HOOK, |
|---|
| 110 | DEAD_CHAR_HORN |
|---|
| 111 | } TextManager_DeadChar; |
|---|
| 112 | |
|---|
| 113 | /* |
|---|
| 114 | typedef enum |
|---|
| 115 | { |
|---|
| 116 | INPUT_METHOD_STATUS_ON, |
|---|
| 117 | INPUT_METHOD_STATUS_OFF |
|---|
| 118 | } TextManager_Status; |
|---|
| 119 | */ |
|---|
| 120 | |
|---|
| 121 | extern DECLSPEC TextManager_Result SDLCALL TextManager_Init(void); |
|---|
| 122 | |
|---|
| 123 | extern DECLSPEC int SDLCALL TextManager_GetEventNumber(void); |
|---|
| 124 | extern DECLSPEC void SDLCALL TextManager_MoveNextEvent(void); |
|---|
| 125 | extern DECLSPEC TextManager_Message SDLCALL TextManager_GetCurrentMessage(void); |
|---|
| 126 | extern DECLSPEC Uint16 * SDLCALL TextManager_GetCurrentEditingString(void); |
|---|
| 127 | extern DECLSPEC Uint16 SDLCALL TextManager_GetCurrentChar(void); |
|---|
| 128 | extern DECLSPEC TextManager_DeadChar SDLCALL TextManager_GetCurrentDeadChar(void); |
|---|
| 129 | extern DECLSPEC int SDLCALL TextManager_GetCurrentCursorPosition(void); |
|---|
| 130 | extern DECLSPEC int SDLCALL TextManager_GetCurrentCompositionPosition(void); |
|---|
| 131 | extern DECLSPEC int SDLCALL TextManager_GetCurrentCompositionLength(void); |
|---|
| 132 | extern DECLSPEC void SDLCALL TextManager_Reset(void); |
|---|
| 133 | extern DECLSPEC TextManager_Result SDLCALL TextManager_Validate(void); |
|---|
| 134 | extern DECLSPEC TextManager_Result SDLCALL TextManager_Invalidate(void); |
|---|
| 135 | extern DECLSPEC Uint16 * SDLCALL TextManager_GetTextManagerName(void); |
|---|
| 136 | |
|---|
| 137 | extern DECLSPEC Uint16 SDLCALL TextManager_CombineDeadKey( |
|---|
| 138 | TextManager_DeadChar deadChar, Uint16 character); |
|---|
| 139 | |
|---|
| 140 | extern DECLSPEC void SDLCALL TextManager_Quit(void); |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | /* protected? ... for add other Input Methods */ |
|---|
| 147 | |
|---|
| 148 | #define INPUT_METHOD_NAME_STRING_LENGTH 256 |
|---|
| 149 | |
|---|
| 150 | typedef struct _SDL_TextManager |
|---|
| 151 | { |
|---|
| 152 | SDL_bool (*available)(void); |
|---|
| 153 | TextManager_Result (*init)(void); |
|---|
| 154 | void (*quit)(void); |
|---|
| 155 | void (*reset)(void); |
|---|
| 156 | TextManager_Result (*validate)(void); |
|---|
| 157 | TextManager_Result (*invalidate)(void); |
|---|
| 158 | |
|---|
| 159 | /* |
|---|
| 160 | Return value is Input Manager name in Unicode. |
|---|
| 161 | You have to set string to `TextManagerName' and |
|---|
| 162 | return this in get_name(), |
|---|
| 163 | because get_name() is a possible |
|---|
| 164 | to call without init() and quit(), |
|---|
| 165 | and so even if use malloc() to string, no time to free(). |
|---|
| 166 | */ |
|---|
| 167 | Uint16 *(*get_name)(void); |
|---|
| 168 | Uint16 TextManagerName[INPUT_METHOD_NAME_STRING_LENGTH]; |
|---|
| 169 | /* |
|---|
| 170 | TextManager_Status (*get_status)(void); |
|---|
| 171 | void (*set_status)(TextManager_Status status); |
|---|
| 172 | */ |
|---|
| 173 | } SDL_TextManager; |
|---|
| 174 | |
|---|
| 175 | extern DECLSPEC TextManager_Result SDLCALL TextManager_PostIMOnEvent(void); |
|---|
| 176 | extern DECLSPEC TextManager_Result SDLCALL TextManager_PostIMOffEvent(void); |
|---|
| 177 | extern DECLSPEC TextManager_Result SDLCALL TextManager_PostIMChangeEvent( |
|---|
| 178 | Uint16 *editingString, |
|---|
| 179 | int cursorPosition, |
|---|
| 180 | int compositionPosition, |
|---|
| 181 | int compositionLength); |
|---|
| 182 | extern DECLSPEC TextManager_Result SDLCALL TextManager_PostIMResultEvent( |
|---|
| 183 | Uint16 *editingString); |
|---|
| 184 | extern DECLSPEC TextManager_Result TextManager_PostCharEvent(Uint16 unicode); |
|---|
| 185 | extern DECLSPEC TextManager_Result TextManager_PostDeadCharEvent( |
|---|
| 186 | TextManager_DeadChar deadCharacter); |
|---|
| 187 | extern DECLSPEC TextManager_Result SDLCALL TextManager_InitFromOther( |
|---|
| 188 | SDL_TextManager textManager); |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | /* private */ |
|---|
| 195 | |
|---|
| 196 | #ifdef ENABLE_WIN32 |
|---|
| 197 | extern SDL_TextManager TextManager_win32; |
|---|
| 198 | #endif |
|---|
| 199 | #ifdef ENABLE_XIM |
|---|
| 200 | extern SDL_TextManager TextManager_xim; |
|---|
| 201 | #endif |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | /* Ends C function definitions when using C++ */ |
|---|
| 208 | #ifdef __cplusplus |
|---|
| 209 | } |
|---|
| 210 | #endif |
|---|
| 211 | |
|---|
| 212 | #include "close_code.h" |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | #endif |
|---|