2 * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef __SCL_CORE_H__
19 #define __SCL_CORE_H__
23 #define Uses_SCIM_ATTRIBUTE
27 #include <sclcommon.h>
28 #include "sclcoretypes.h"
29 #include "sclcorecallback.h"
34 /* To use pimpl idiom */
38 * @brief The base class that provides features for a soft-keyboard
40 * This class implements all functions for working as a soft-based keyboard
45 CSCLCore(ISCLCoreEventCallback *callback);
51 * @brief Request ISF to reload all configuration.
56 * @brief Request ISF to read a integer value with given key name.
58 sclboolean config_read_int(const sclchar *name, sclint &value);
61 * @brief Request ISF to read a string value with given key name.
63 sclboolean config_read_string(const sclchar *name, std::string &value);
66 * @brief Request ISF to write a integer value with given key name.
68 sclboolean config_write_int(const sclchar *name, sclint value);
71 * @brief Request ISF to write a string value with given key name.
73 sclboolean config_write_string(const sclchar *name, const std::string value);
76 * @brief Request ISF to erase stored value with given key name.
78 sclboolean config_erase(const sclchar *name);
81 * @brief Request ISF to permanently writes all changes.
83 sclboolean config_flush(void);
86 * @brief Send an Event to IMEngine
88 * @param[in] ic The handle of the IMEngineInstance to receive the event.
89 * -1 means the currently focused IMEngineInstance.
90 * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
91 * @param[in] command The command to be sent.
92 * @param[in] value The value corresponding to the command.
94 void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value);
97 * @brief Send a reset keyboard Event to IMEngine
99 void reset_keyboard_ise();
102 * @brief Send a flush keyboard Event to IMEngine
104 void flush_keyboard_ise();
107 * @brief Send a KeyEvent to ISF
109 * @param[in] ic The handle of the IMEngineInstance to receive the event.
110 * -1 means the currently focused IMEngineInstance.
111 * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
112 * @param[in] keycode The KeyEvent to be sent.
113 * @param[in] keymask The modifier key mask
115 void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
118 * @brief Forward a KeyEvent to client application directly.
120 * @param[in] ic The handle of the client Input Context to receive the event.
121 * -1 means the currently focused Input Context.
122 * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
123 * @param[in] keycode The KeyEvent to be sent.
124 * @param[in] keymask The modifier key mask
126 void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
129 * @brief Commit a string to client application directly.
131 * @param[in] ic The handle of the client Input Context to receive the WideString.
132 * -1 means the currently focused Input Context.
133 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
134 * NULL means don't match.
135 * @param[in] str The UTF-8 string to be committed.
137 void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
139 void select_candidate(int index);
141 * @brief Request to show preedit string.
143 * @param[in] ic The handle of the client Input Context to receive the request.
144 * -1 means the currently focused Input Context.
145 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
146 * NULL means don't match.
148 void show_preedit_string(sclint ic, const sclchar *ic_uuid);
151 * @brief Request to show aux string.
153 void show_aux_string(void);
156 * @brief Request to show candidate string.
158 void show_candidate_string(void);
161 * @brief Request to show associate string.
163 void show_associate_string(void);
166 * @brief Request to hide preedit string.
168 * @param[in] ic The handle of the client Input Context to receive the request.
169 * -1 means the currently focused Input Context.
170 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
171 * NULL means don't match.
173 void hide_preedit_string(sclint ic, const sclchar *ic_uuid);
176 * @brief Request to hide aux string.
178 void hide_aux_string(void);
181 * @brief Request to hide candidate string.
183 void hide_candidate_string(void);
186 * @brief Request to hide associate string.
188 void hide_associate_string(void);
191 * @brief Update a new string for preedit.
193 * @param[in] ic The handle of the client Input Context to receive the WideString.
194 * -1 means the currently focused Input Context.
195 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
196 * NULL means don't match.
197 * @param[in] str The UTF-8 string to be updated.
199 void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
202 * @brief Update a new string for preedit.
204 * @param[in] ic The handle of the client Input Context to receive the WideString.
205 * -1 means the currently focused Input Context.
206 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
207 * NULL means don't match.
208 * @param[in] str The UTF-8 string to be updated.
209 * @param[in] attrs The attribute list for preedit string.
211 void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs);
214 * @brief Update a new string for aux.
216 * @param[in] str The string to be updated.
217 * @param[in] attrs The attribute list for aux string.
219 //void update_aux_string (const sclchar *str, const AttributeList &attrs) const;
220 void update_aux_string(const sclchar *str);
223 * @brief Request to update candidate.
225 * @param[in] table The lookup table for candidate.
227 void update_candidate_string(const SclCandidateTable &table) const;
230 * @brief Request to update associate.
232 * @param[in] table The lookup table for associate.
234 void update_associate_string(const SclCandidateTable &table) const;
237 * @brief When the input context of ISE is changed,
238 * ISE can call this function to notify application
240 * @param[in] type type of event.
241 * @param[in] value value of event.
243 void update_input_context(sclu32 type, sclu32 value);
246 * @brief When the geometry of ISE is changed,
247 * ISE can call this function to notify application
249 * @param[in] x x position of ISE geometry.
250 * @param[in] y y position of ISE geometry.
251 * @param[in] width the width of ISE geometry.
252 * @param[in] height the height of ISE geometry.
254 void update_geometry(sclint x, sclint y, sclint width, sclint height);
257 * @brief Request to get surrounding text asynchronously.
259 * @param[in] ic_uuid The helper ISE UUID.
260 * @param[in] maxlen_before The max length of before.
261 * @param[in] maxlen_after The max length of after.
263 void get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const;
266 * @brief Request to delete surrounding text.
268 * @param[in] offset The offset for cursor position.
269 * @param[in] len The length for delete text.
271 void delete_surrounding_text(sclint offset, sclint len) const;
274 * @brief Set candidate position in screen.
276 * @param[in] left The x position in screen.
277 * @param[in] top The y position in screen.
279 void set_candidate_position(sclint left, sclint top);
282 * @brief Set soft candidate style.
284 * @param[in] enable The flag for soft candidate style.
286 void enable_soft_candidate(sclboolean enable);
289 * @brief Request to hide candidate window.
291 void candidate_hide(void);
294 * @brief Request to get candidate window size and position.
296 * @param[in] uuid The helper ISE UUID.
298 //void get_candidate_window_geometry (const String &uuid) const;
301 * @brief Set current keyboard ISE.
303 * @param[in] uuid The keyboard ISE UUID.
305 void set_keyboard_ise_by_uuid(const sclchar *uuid);
308 * @brief Request to get current keyboard ISE information.
310 * @param[in] uuid The helper ISE UUID.
312 void get_keyboard_ise(const sclchar *uuid);
315 * @brief Request to get uuid list of all keyboard ISEs.
317 * @param[in] uuid The helper ISE UUID.
319 //void get_keyboard_ise_list (const String &uuid) const;
322 * @brief This API returns the pointer to main keyboard window
324 sclwindow get_main_window();
327 * @brief This API updates the keyboard window's geometry information
329 void set_keyboard_size_hints(SclSize portrait, SclSize landscape);
332 * @brief Requests to create an option window
334 sclwindow create_option_window();
337 * @brief Requests to destroy an option window
339 void destroy_option_window(sclwindow window);
342 * @brief Request to select text.
344 * @param[in] start The start cursor position in text.
345 * @param[in] end The end cursor position in text.
347 void set_selection(sclint start, sclint end);
350 * @brief Send a private command to its connected editor.
352 * @param[in] command a command to be sent.
354 void send_private_command(const sclchar *command);
357 * @brief Request to get surrounding text synchronously.
359 * @param[in] maxlen_before The max length of before.
360 * @param[in] maxlen_after The max length of after.
361 * @param[out] text The surrounding text.
362 * @param[out] cursor The cursor position.
364 * @return 0 on success, otherwise a negative error value
366 sclint get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const;
369 * @brief Get the selected text.
371 * @param[out] text The surrounding text.
373 void get_selection_text(sclchar **text) const;
376 * @brief Request to hide ISE.
378 void request_ise_hide() const;
381 * @brief Commit a content URI to its connected editor.
383 * @param[in] content a content URL to be sent.
384 * @param[in] description a content description.
385 * @param[in] mime_types a MIME type string.
387 void commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types);
390 * @brief Request to set floating mode.
392 * @param[in] floating_mode Floating mode or not
394 void set_floating_mode(sclboolean floating_mode);
396 CSCLCoreImpl *m_impl;
403 #endif //__SCL_CORE_H__