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
24 #define Uses_SCIM_UTILITY
25 #define Uses_SCIM_CONFIG_BASE
26 #define Uses_SCIM_OBJECT
27 #define Uses_SCIM_POINTER
28 #define Uses_SCIM_EVENT
29 #define Uses_SCIM_HELPER
33 #include <sclcommon.h>
34 #include "sclcoretypes.h"
35 #include "sclcorecallback.h"
40 /* To use pimpl idiom */
44 * @brief The base class that provides features for a soft-keyboard
46 * This class implements all functions for working as a soft-based keyboard
51 CSCLCore(ISCLCoreEventCallback *callback);
55 * @brief Request SCLCore to initialize its components.
57 * Note that the init() / prepare() / fini() functions are not expected to be called
58 * when using run() function, since they are called automatically inside run().
63 * @brief Request SCLCore to prepare necessary resources.
68 * @brief Request SCLCore to finalize its components.
73 * @brief Request SCLCore to start its main loop.
75 * As described above, init() / prepare() / fini() functions are called automatically when necessary
80 * @brief Request ISF to reload all configuration.
85 * @brief Request ISF to read a integer value with given key name.
87 sclboolean config_read_int(const sclchar *name, sclint &value);
90 * @brief Request ISF to read a string value with given key name.
92 sclboolean config_read_string(const sclchar *name, std::string &value);
95 * @brief Request ISF to write a integer value with given key name.
97 sclboolean config_write_int(const sclchar *name, sclint value);
100 * @brief Request ISF to write a string value with given key name.
102 sclboolean config_write_string(const sclchar *name, const std::string value);
105 * @brief Request ISF to erase stored value with given key name.
107 sclboolean config_erase(const sclchar *name);
110 * @brief Request ISF to permanently writes all changes.
112 sclboolean config_flush(void);
115 * @brief Send an Event to IMEngine
117 * @param[in] ic The handle of the IMEngineInstance to receive the event.
118 * -1 means the currently focused IMEngineInstance.
119 * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
120 * @param[in] command The command to be sent.
121 * @param[in] value The value corresponding to the command.
123 void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value);
126 * @brief Send a reset keyboard Event to IMEngine
128 void reset_keyboard_ise();
131 * @brief Send a flush keyboard Event to IMEngine
133 void flush_keyboard_ise();
136 * @brief Send a KeyEvent to ISF
138 * @param[in] ic The handle of the IMEngineInstance to receive the event.
139 * -1 means the currently focused IMEngineInstance.
140 * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
141 * @param[in] keycode The KeyEvent to be sent.
142 * @param[in] keymask The modifier key mask
144 void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
147 * @brief Forward a KeyEvent to client application directly.
149 * @param[in] ic The handle of the client Input Context to receive the event.
150 * -1 means the currently focused Input Context.
151 * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match.
152 * @param[in] keycode The KeyEvent to be sent.
153 * @param[in] keymask The modifier key mask
155 void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask);
158 * @brief Commit a string to client application directly.
160 * @param[in] ic The handle of the client Input Context to receive the WideString.
161 * -1 means the currently focused Input Context.
162 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
163 * NULL means don't match.
164 * @param[in] str The UTF-8 string to be committed.
166 void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
168 void select_candidate(int index);
170 * @brief Request to show preedit string.
172 * @param[in] ic The handle of the client Input Context to receive the request.
173 * -1 means the currently focused Input Context.
174 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
175 * NULL means don't match.
177 void show_preedit_string(sclint ic, const sclchar *ic_uuid);
180 * @brief Request to show aux string.
182 void show_aux_string(void);
185 * @brief Request to show candidate string.
187 void show_candidate_string(void);
190 * @brief Request to show associate string.
192 void show_associate_string(void);
195 * @brief Request to hide preedit string.
197 * @param[in] ic The handle of the client Input Context to receive the request.
198 * -1 means the currently focused Input Context.
199 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
200 * NULL means don't match.
202 void hide_preedit_string(sclint ic, const sclchar *ic_uuid);
205 * @brief Request to hide aux string.
207 void hide_aux_string(void);
210 * @brief Request to hide candidate string.
212 void hide_candidate_string(void);
215 * @brief Request to hide associate string.
217 void hide_associate_string(void);
220 * @brief Update a new string for preedit.
222 * @param[in] ic The handle of the client Input Context to receive the WideString.
223 * -1 means the currently focused Input Context.
224 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
225 * NULL means don't match.
226 * @param[in] str The UTF-8 string to be updated.
228 void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str);
231 * @brief Update a new string for preedit.
233 * @param[in] ic The handle of the client Input Context to receive the WideString.
234 * -1 means the currently focused Input Context.
235 * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context.
236 * NULL means don't match.
237 * @param[in] str The UTF-8 string to be updated.
238 * @param[in] attrs The attribute list for preedit string.
240 void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str, const scim::AttributeList &attrs);
243 * @brief Update a cursor position in preedit string.
245 * @param[in] caret The cursor position in preedit.
247 void update_preedit_caret(sclint caret);
250 * @brief Update a new string for aux.
252 * @param[in] str The string to be updated.
253 * @param[in] attrs The attribute list for aux string.
255 //void update_aux_string (const sclchar *str, const AttributeList &attrs) const;
256 void update_aux_string(const sclchar *str);
259 * @brief Request to update candidate.
261 * @param[in] table The lookup table for candidate.
263 void update_candidate_string(const SclCandidateTable &table) const;
266 * @brief Request to update associate.
268 * @param[in] table The lookup table for associate.
270 void update_associate_string(const SclCandidateTable &table) const;
273 * @brief When the input context of ISE is changed,
274 * ISE can call this function to notify application
276 * @param[in] type type of event.
277 * @param[in] value value of event.
279 void update_input_context(sclu32 type, sclu32 value);
282 * @brief When the geometry of ISE is changed,
283 * ISE can call this function to notify application
285 * @param[in] x x position of ISE geometry.
286 * @param[in] y y position of ISE geometry.
287 * @param[in] width the width of ISE geometry.
288 * @param[in] height the height of ISE geometry.
290 void update_geometry(sclint x, sclint y, sclint width, sclint height);
293 * @brief Request to get surrounding text asynchronously.
295 * @param[in] ic_uuid The helper ISE UUID.
296 * @param[in] maxlen_before The max length of before.
297 * @param[in] maxlen_after The max length of after.
299 void get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before, sclint maxlen_after) const;
302 * @brief Request to delete surrounding text.
304 * @param[in] offset The offset for cursor position.
305 * @param[in] len The length for delete text.
307 void delete_surrounding_text(sclint offset, sclint len) const;
310 * @brief Set candidate position in screen.
312 * @param[in] left The x position in screen.
313 * @param[in] top The y position in screen.
315 void set_candidate_position(sclint left, sclint top);
318 * @brief Set soft candidate style.
320 * @param[in] enable The flag for soft candidate style.
322 void enable_soft_candidate(sclboolean enable);
325 * @brief Request to hide candidate window.
327 void candidate_hide(void);
330 * @brief Request to get candidate window size and position.
332 * @param[in] uuid The helper ISE UUID.
334 //void get_candidate_window_geometry (const String &uuid) const;
337 * @brief Set current keyboard ISE.
339 * @param[in] uuid The keyboard ISE UUID.
341 void set_keyboard_ise_by_uuid(const sclchar *uuid);
344 * @brief Request to get current keyboard ISE information.
346 * @param[in] uuid The helper ISE UUID.
348 void get_keyboard_ise(const sclchar *uuid);
351 * @brief Request to get uuid list of all keyboard ISEs.
353 * @param[in] uuid The helper ISE UUID.
355 //void get_keyboard_ise_list (const String &uuid) const;
358 * @brief This API returns the pointer to main keyboard window
360 sclwindow get_main_window();
363 * @brief This API updates the keyboard window's geometry information
365 void set_keyboard_size_hints(SclSize portrait, SclSize landscape);
368 * @brief Requests to create an option window
370 sclwindow create_option_window();
373 * @brief Requests to destroy an option window
375 void destroy_option_window(sclwindow window);
378 * @brief Request to select text.
380 * @param[in] start The start cursor position in text.
381 * @param[in] end The end cursor position in text.
383 void set_selection(sclint start, sclint end);
386 * @brief Send a private command to its connected editor.
388 * @param[in] command a command to be sent.
390 void send_private_command(const sclchar *command);
393 * @brief Request to get surrounding text synchronously.
395 * @param[in] maxlen_before The max length of before.
396 * @param[in] maxlen_after The max length of after.
397 * @param[out] text The surrounding text.
398 * @param[out] cursor The cursor position.
400 * @return 0 on success, otherwise a negative error value
402 sclint get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const;
405 * @brief Get the selected text.
407 * @param[out] text The selection text.
409 void get_selection_text(sclchar **text) const;
412 * @brief Request to hide ISE.
414 void request_ise_hide() const;
417 * @brief Commit a content URI to its connected editor.
419 * @param[in] content a content URL to be sent.
420 * @param[in] description a content description.
421 * @param[in] mime_types a MIME type string.
423 void commit_content(const sclchar *content, const sclchar *description, const sclchar *mime_types);
426 * @brief Request to update preedit string with commit.
428 void update_preedit_string_with_commit(const sclchar *preedit, const sclchar *commit, const scim::AttributeList &attrs, sclint caret);
431 * @brief Request to update recapture string.
433 void recapture_string(sclint offset, sclint len, const sclchar *preedit, const sclchar *commit, const scim::AttributeList &attrs);
436 * @brief Request to update lookup table.
438 void update_lookup_table(const scim::LookupTable &table);
441 * @brief Request to register properties.
443 void register_properties(const scim::PropertyList &properties);
446 * @brief Request to update property.
448 void update_property(const scim::Property &property);
451 * @brief Request to expand candidate.
453 void expand_candidate(void);
456 * @brief Request to contract candidate.
458 void contract_candidate(void);
461 * @brief Request to set candidate style.
463 void set_candidate_style(scim::ISF_CANDIDATE_PORTRAIT_LINE_T portrait_line, scim::ISF_CANDIDATE_MODE_T mode);
466 * @brief Request to set floating mode.
468 * @param[in] floating_mode Floating mode or not
470 void set_floating_mode(sclboolean floating_mode);
473 * @brief Request to allow the user to move floating ISE.
475 void set_floating_drag_enabled(sclboolean enabled);
478 * @brief Request to defer creating window until the window object gets accessed.
480 void set_window_creation_defer_flag(sclboolean flag);
484 CSCLCoreImpl *m_impl;
491 #endif //__SCL_CORE_H__