1 /* This file is part of SDL_him - SDL Hildon Input Method addon
2 * Copyright (C) 2010 Javier S. Pedro
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA or see <http://www.gnu.org/licenses/>.
23 /* Set up for C function definitions, even when using C++ */
28 /* Equivalent (and binary compatible) to HildonIMTrigger */
29 typedef enum HIM_Trigger
31 HIM_TRIGGER_NONE = -1,
37 /* Equivalent (and binary compatible) to HildonGtkInputMode */
41 HIM_MODE_ALPHA = 1 << 0,
42 HIM_MODE_NUMERIC = 1 << 1,
43 HIM_MODE_SPECIAL = 1 << 2,
44 HIM_MODE_HEXA = 1 << 3,
45 HIM_MODE_TELE = 1 << 4,
47 HIM_MODE_FULL = (HIM_MODE_ALPHA | HIM_MODE_NUMERIC | HIM_MODE_SPECIAL),
49 /** This is a special SDL_him setting which causes it to keep sending
50 SDL_KEYDOWN events on most "normal" keys.
52 HIM_MODE_NO_FILTER = 1 << 10,
54 HIM_MODE_MULTILINE = 1 << 28,
55 HIM_MODE_INVISIBLE = 1 << 29,
56 HIM_MODE_AUTOCAP = 1 << 30,
57 HIM_MODE_DICTIONARY = 1 << 31
60 #define HIM_TEXTEVENT_SIZE 32
61 typedef struct HIM_TextEvent {
66 #define HIM_TEXTINPUTEVENT_TEXT_SIZE (32-2)
67 #define HIM_TEXTINPUTEVENT 1
68 typedef struct HIM_TextInputEvent {
71 char text[HIM_TEXTINPUTEVENT_TEXT_SIZE];
74 #define HIM_TEXTEDITINGEVENT_TEXT_SIZE (32-2)
75 #define HIM_TEXTEDITINGEVENT 2
76 typedef struct HIM_TextEditingEvent {
79 char text[HIM_TEXTEDITINGEVENT_TEXT_SIZE];
80 } HIM_TextEditingEvent;
82 #define HIM_SPECIALKEYEVENT 3
83 typedef struct HIM_SpecialKeyEvent {
87 } HIM_SpecialKeyEvent;
89 #define HIM_CURSORMOVEEVENT 4
90 typedef struct HIM_CursorMoveEvent {
95 } HIM_CursorMoveEvent;
97 #define HIM_REQUESTSURROUNDINGEVENT 5
98 typedef struct HIM_RequestSurroundingEvent {
102 } HIM_RequestSurroundingEvent;
104 #define HIM_CLIPBOARDEVENT 6
105 typedef enum HIM_ClipboardAction {
106 HIM_CLIPBOARD_NONE = 0,
110 HIM_CLIPBOARD_REQUEST_SELECTION
111 } HIM_ClipboardAction;
112 typedef struct HIM_ClipboardEvent {
115 HIM_ClipboardAction action;
116 } HIM_ClipboardEvent;
118 /** Invoke after SDL_Init.
120 @param event event identifier to bind the library to
121 (SDL_USEREVENT through SDL_NUMEVENTS-1)
122 @return 0 if SDL_him was initialized correctly.
124 extern DECLSPEC int SDLCALL HIM_Init(Uint32 flags, Uint8 event);
126 /** Invoke after SDL_Quit. */
127 extern DECLSPEC void SDLCALL HIM_Quit();
129 extern DECLSPEC void SDLCALL HIM_Enable(HIM_Mode mode);
130 extern DECLSPEC void SDLCALL HIM_Disable();
132 extern DECLSPEC void SDLCALL HIM_ShowKeyboard(HIM_Trigger reason);
133 extern DECLSPEC void SDLCALL HIM_HideKeyboard();
136 Call before handling any SDL_Event (or use SDL_SetEventFilter).
137 @param event the SDL_Event you were about to handle.
138 @return 1 if the event was filtered and should not be handled by your app.
140 extern DECLSPEC int SDLCALL HIM_FilterEvent(const SDL_Event *event);
143 Call in the RequestSurrounding event handler.
145 @param cursor where the cursor is, relative to text.
147 extern DECLSPEC void SDLCALL HIM_SendSurrounding
148 (const char * text, unsigned long cursor);
151 Call in the ClipboardRequestSelection event handler.
152 @param text the selected text
154 extern DECLSPEC void SDLCALL HIM_SendSelection
157 /* Ends C function definitions when using C++ */