a359433af8729919bfddecd3c4c0d7e7451ad7a1
[framework/uifw/libscl-ui.git] / scl / scluiimpl.cpp
1 /*
2  * Copyright 2012-2013 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  *
16  */
17
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 #include "scluiimpl.h"
22 #include "scldebug.h"
23 #include "scluibuilder.h"
24 #include "sclcontroller.h"
25 #include "sclresourcecache.h"
26 #include "sclerroradjustment.h"
27 #include "sclres_manager.h"
28 #include "scleventhandler.h"
29
30 using namespace scl;
31
32 CSCLUIImpl* CSCLUIImpl::m_instance = NULL; /* For singleton */
33
34 CSCLUIImpl::CSCLUIImpl()
35 {
36     SCL_DEBUG();
37
38     /*CSCLUIBuilder *builder = CSCLUIBuilder::get_instance();
39     CSCLController *controller = CSCLController::get_instance();
40     if (builder && controller) {
41         builder->init(SCLWINDOW_INVALID);
42         controller->init();
43     }*/
44 }
45
46 CSCLUIImpl::~CSCLUIImpl()
47 {
48     SCL_DEBUG();
49 }
50
51 CSCLUIImpl*
52 CSCLUIImpl::get_instance()
53 {
54     if (!m_instance) {
55         m_instance = new CSCLUIImpl();
56     }
57     return (CSCLUIImpl*)m_instance;
58 }
59
60 sclboolean CSCLUIImpl::init(sclwindow parent, const SCLParserType parser_type, const char *entry_filepath)
61 {
62     SCL_DEBUG();
63
64     SCL_DEBUG_ELAPASED_TIME_START();
65
66     SclResParserManager *sclres_manager = SclResParserManager::get_instance();
67     CSCLUIBuilder *builder = CSCLUIBuilder::get_instance();
68     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
69     CSCLUtils *utils = CSCLUtils::get_instance();
70
71     if (sclres_manager && builder && cache && utils) {
72         sclres_manager->init(parser_type, entry_filepath);
73
74         utils->init();
75         cache->init();
76         builder->init(parent);
77
78         PSclDefaultConfigure default_configure = sclres_manager->get_default_configure();
79         if (default_configure) {
80             set_cur_sublayout(default_configure->default_sub_layout);
81         }
82
83         m_initialized = TRUE;
84     }
85
86     SCL_DEBUG_ELAPASED_TIME_END();
87
88     return TRUE;
89 }
90
91 /**
92  * Shows the SCL main window
93  * For displaying the SCL UI, you should explicitly call this function after CSCLUIImpl class is created
94  */
95 void
96 //CSCLUIImpl::show(sclboolean auto_relocate /* = TRUE */ )
97 CSCLUIImpl::show()
98 {
99     SCL_DEBUG();
100
101     sclboolean ret = FALSE;
102
103     if (m_initialized) {
104         CSCLUtils *utils = CSCLUtils::get_instance();
105         CSCLWindows *windows = CSCLWindows::get_instance();
106         CSCLContext *context = CSCLContext::get_instance();
107         CSCLController *controller = CSCLController::get_instance();
108
109         if (windows && controller && context) {
110             //if (auto_relocate) {
111             if (TRUE) {
112                 /* Let's relocate our base window - bottomed center aligned */
113                 sclint width, height;
114                 //get_layout_size(&width, &height);
115                 SclRectangle rect = get_main_window_rect();
116
117                 sclint scrx, scry;
118                 utils->get_screen_resolution(&scrx, &scry);
119
120                 sclint pos_x = (scrx - rect.width) / 2;
121                 sclint pos_y = (scry - rect.height);
122
123                 windows->move_window(windows->get_base_window(), pos_x, pos_y);
124             }
125
126             sclwindow window = windows->get_base_window();
127             controller->handle_engine_signal(SCL_SIG_SHOW);
128             windows->show_window(window);
129         }
130     }
131 }
132
133 /**
134  * Hides the SCL main window
135  * The real hide action does not work about base window because that is child of the active window
136  */
137 void
138 CSCLUIImpl::hide()
139 {
140     SCL_DEBUG();
141
142     sclboolean ret = FALSE;
143
144     if (m_initialized) {
145         CSCLController *controller = CSCLController::get_instance();
146         CSCLWindows *windows = CSCLWindows::get_instance();
147         if (controller && windows) {
148             controller->handle_engine_signal(SCL_SIG_HIDE);
149             windows->hide_window(windows->get_base_window());
150         }
151     }
152 }
153
154
155 /**
156  * Regists an event callback function
157  * so that the user which uses SCL can recevies all events occuring in running
158  */
159 void
160 CSCLUIImpl::set_ui_event_callback(ISCLUIEventCallback *callback, const sclchar *input_mode)
161 {
162     SCL_DEBUG();
163
164     sclboolean ret = FALSE;
165
166     if (m_initialized) {
167         CSCLEventHandler *handler = CSCLEventHandler::get_instance();
168         if (handler) {
169             handler->set_event_callback(callback, input_mode);
170         }
171     }
172 }
173
174 /**
175  * Sets the current input mode to the given mode
176  * @Usage
177  * gCore->set_input_mode("INPUT_MODE_SYMBOL");
178  */
179 sclboolean
180 CSCLUIImpl::set_input_mode(const sclchar *input_mode)
181 {
182     SCL_DEBUG();
183     SCL_DEBUG_ELAPASED_TIME_START();
184
185     sclboolean ret = FALSE;
186
187     if (m_initialized) {
188         CSCLController *controller = CSCLController::get_instance();
189         CSCLWindows *windows = CSCLWindows::get_instance();
190         CSCLEventHandler *handler = CSCLEventHandler::get_instance();
191
192         scl8 mode = NOT_USED;
193
194         SclResParserManager *sclres_manager = SclResParserManager::get_instance();
195         if (sclres_manager) {
196             mode = sclres_manager->get_inputmode_id(input_mode);
197         }
198
199         if (controller && windows && handler && mode != NOT_USED) {
200             handler->set_input_mode(input_mode);
201             ret = controller->process_input_mode_change(mode);
202             windows->update_window(windows->get_base_window());
203         }
204     }
205
206     SCL_DEBUG_ELAPASED_TIME_END();
207     return ret;
208 }
209
210 /**
211  * Sets the current rotation
212  */
213 sclboolean
214 CSCLUIImpl::set_rotation(SCLRotation rotation)
215 {
216     SCL_DEBUG();
217
218     sclboolean ret = FALSE;
219
220     if (m_initialized) {
221         CSCLUtils *utils = CSCLUtils::get_instance();
222         CSCLWindows *windows = CSCLWindows::get_instance();
223         CSCLController *controller = CSCLController::get_instance();
224
225         if (utils && windows && controller) {
226             ret = controller->process_rotation_change(rotation);
227
228             //if (auto_relocate) {
229             if (TRUE) {
230                 /* Let's relocate our base window - bottomed center aligned */
231                 sclint width, height;
232                 //get_layout_size(&width, &height);
233                 SclRectangle rect = get_main_window_rect();
234
235                 sclint scrx, scry;
236                 utils->get_screen_resolution(&scrx, &scry);
237
238                 sclint pos_x = (scrx - rect.width) / 2;
239                 sclint pos_y = (scry - rect.height);
240
241                 windows->move_window(windows->get_base_window(), pos_x, pos_y);
242             }
243         }
244     }
245
246     return ret;
247 }
248
249 /**
250  * Returns the current rotation
251  */
252 SCLRotation
253 CSCLUIImpl::get_rotation()
254 {
255     SCL_DEBUG();
256
257     SCLRotation ret = ROTATION_0;
258
259     CSCLContext *context = CSCLContext::get_instance();
260     if (context) {
261         ret = context->get_rotation();
262     }
263
264     return ret;
265 }
266
267 /**
268  * Returns the current display mode
269  */
270 SCLDisplayMode
271 CSCLUIImpl::get_display_mode()
272 {
273     SCL_DEBUG();
274
275     SCLDisplayMode ret = DISPLAYMODE_MAX;
276     if (m_initialized) {
277         CSCLContext *context = CSCLContext::get_instance();
278         if (context) {
279             ret = context->get_display_mode();
280         }
281     }
282     return ret;
283 }
284
285 /**
286  * Returns the current input mode
287  */
288 const sclchar*
289 CSCLUIImpl::get_input_mode()
290 {
291     SCL_DEBUG();
292
293     const sclchar *ret = NULL;
294     if (m_initialized) {
295         CSCLContext *context = CSCLContext::get_instance();
296         SclResParserManager *sclres_manager = SclResParserManager::get_instance();
297         if (context && sclres_manager) {
298             scl8 inputmode_id = context->get_input_mode();
299             ret = sclres_manager->get_inputmode_name(inputmode_id);
300         }
301     }
302     return ret;
303 }
304
305
306
307 /**
308  * Sets a private key to the current context
309  * The other properties except given parameters will keep to the orginal value.
310  * @Usage
311  * gCore->set_private_key(INPUT_MODE_NUMBER, LYT_PORTRAIT_NOW_3x4, 0, "private", 999, TRUE);
312  *
313  * @param fRedraw If true, it will redraw the current key
314  */
315 sclint
316 CSCLUIImpl::set_private_key(const sclchar* custom_id, sclchar* label, sclchar* imagelabel[SCL_BUTTON_STATE_MAX], sclchar* imagebg[SCL_BUTTON_STATE_MAX], sclulong key_event, sclchar *key_value, sclboolean fRedraw)
317 {
318     SCL_DEBUG();
319     sclint ret = NOT_USED;
320     if (m_initialized) {
321         CSCLWindows *windows = CSCLWindows::get_instance();
322         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
323         if (windows && cache) {
324             ret = cache->set_private_key((sclchar*)custom_id, label, imagelabel, imagebg,
325                 key_event, key_value, fRedraw, windows->get_update_pending());
326         }
327     }
328     return ret;
329 }
330
331
332 /**
333 * Unsets a private key to the current context
334 */
335 void
336 CSCLUIImpl::unset_private_key(const sclchar* custom_id)
337 {
338     SCL_DEBUG();
339     sclboolean ret = FALSE;
340
341     if (m_initialized) {
342         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
343         if (cache) {
344             cache->unset_private_key(custom_id);
345         }
346     }
347 }
348
349 /**
350 * Sets the current theme
351 */
352 /* FIXME : If setting themename is not allowed before initializing,
353            the default theme has to be loaded regardless of current theme name
354            and the appropriate current theme has to be loaded afterwards, which is very inefficient */
355 sclboolean
356 CSCLUIImpl::set_cur_themename(const sclchar *themename)
357 {
358     sclboolean ret = FALSE;
359
360     if (m_initialized) {
361         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
362         CSCLWindows *windows = CSCLWindows::get_instance();
363         if (cache && windows) {
364             cache->set_cur_themename(themename);
365             windows->update_window(windows->get_base_window());
366             int loop = 0;
367             sclwindow window;
368             do {
369                 window = windows->get_nth_popup_window(loop);
370                 if (window) {
371                     windows->update_window(window);
372                 }
373                 loop++;
374             } while (window);
375         }
376         ret = TRUE;
377     }
378
379     return ret;
380 }
381
382 SCLShiftState
383 CSCLUIImpl::get_shift_state()
384 {
385     SCLShiftState ret = SCL_SHIFT_STATE_OFF;
386     if (m_initialized) {
387         CSCLContext *context = CSCLContext::get_instance();
388         if (context) {
389             ret = context->get_shift_state();
390         }
391     }
392     return ret;
393 }
394
395 void
396 CSCLUIImpl::set_shift_state(SCLShiftState state)
397 {
398     if (m_initialized) {
399         CSCLUtils *utils = CSCLUtils::get_instance();
400         CSCLContext *context = CSCLContext::get_instance();
401         CSCLWindows *windows = CSCLWindows::get_instance();
402
403         /*inform the client that the shift state changed */
404         CSCLEventHandler *handler = CSCLEventHandler::get_instance();
405         if (handler) {
406             SCLEventReturnType ret = handler->on_event_notification(SCL_UINOTITYPE_SHIFT_STATE_CHANGE, state);
407             if (ret == SCL_EVENT_DONE) {
408                 return;
409             }
410         }
411
412         if (context && windows && utils) {
413             SCLShiftState current_state = context->get_shift_state();
414             context->set_shift_state(state);
415             if (state != current_state) {
416                 windows->update_window(windows->get_base_window());
417             }
418             if (context->get_tts_enabled()) {
419                 if (state == SCL_SHIFT_STATE_ON) {
420                     utils->play_tts(SCL_SHIFT_STATE_ON_HINT_STRING);
421                 } else if (state == SCL_SHIFT_STATE_LOCK) {
422                     utils->play_tts(SCL_SHIFT_STATE_LOCK_HINT_STRING);
423                 } else {
424                     utils->play_tts(SCL_SHIFT_STATE_OFF_HINT_STRING);
425                 }
426             }
427         }
428     }
429 }
430
431 /**
432  * This function will be called by the user which uses SCL when the context of the focus application is changed
433  * ISE user should explicitly call this function when the context of application is changed.
434  * For instance, focus-changed, application-changed,, and so on.
435  * This function will call CSCLController to init the related variables.
436  */
437 void
438 CSCLUIImpl::notify_app_focus_changed()
439 {
440     SCL_DEBUG();
441     sclboolean ret = FALSE;
442
443     if (m_initialized) {
444         CSCLController *controller = CSCLController::get_instance();
445         if (controller) {
446             controller->handle_engine_signal(SCL_SIG_FOCUS_CHANGE);
447         }
448     }
449 }
450
451 void
452 CSCLUIImpl::reset_popup_timeout()
453 {
454     SCL_DEBUG();
455     sclboolean ret = FALSE;
456
457     if (m_initialized) {
458         CSCLEvents *events = CSCLEvents::get_instance();
459         CSCLWindows *windows = CSCLWindows::get_instance();
460
461         if (events && windows) {
462             events->destroy_timer(SCL_TIMER_POPUP_TIMEOUT);
463
464             sclbyte index = 0;
465             sclboolean timerset = FALSE;
466             sclwindow window = SCLWINDOW_INVALID;
467             SclWindowContext *winctx = NULL;
468             do {
469                 window = windows->get_nth_window_in_Z_order_list(index);
470                 //winctx = windows->get_window_context(window, FALSE);
471                 winctx = windows->get_window_context(window);
472                 if (winctx) {
473                     if (winctx->timeout != 0) {
474                         events->create_timer(SCL_TIMER_POPUP_TIMEOUT, winctx->timeout, 0, TRUE);
475                         timerset = TRUE;
476                     }
477                     index++;
478                 }
479             } while (index < MAX_ZORDER_NUM && window != SCLWINDOW_INVALID && !timerset);
480         }
481     }
482 }
483
484 void
485 CSCLUIImpl::close_all_popups()
486 {
487     SCL_DEBUG();
488     sclboolean ret = FALSE;
489
490     if (m_initialized) {
491         CSCLWindows *windows = CSCLWindows::get_instance();
492         if (windows) {
493             windows->close_all_popups();
494         }
495     }
496 }
497
498 /**
499  * Returns a scale rate (see default screen resolution in sclconfig.h file)
500  */
501 sclfloat
502 CSCLUIImpl::get_scale_rate()
503 {
504     sclfloat ret = 0.0f;
505     if (m_initialized) {
506         CSCLUtils *utils = CSCLUtils::get_instance();
507         if (utils) {
508             ret = utils->get_smallest_scale_rate();
509         }
510     }
511     return ret;
512 }
513
514 /**
515  * Returns a calculated x value according to the current screen resolution
516  */
517 scl16
518 CSCLUIImpl::get_scale_x(scl16 x)
519 {
520     scl16 ret = 0;
521     if (m_initialized) {
522         CSCLUtils *utils = CSCLUtils::get_instance();
523         if (utils) {
524             ret = utils->get_scale_x(x);
525         }
526     }
527     return ret;
528 }
529
530 /**
531  * Returns a calculated y value according to the current screen resolution
532  */
533 scl16
534 CSCLUIImpl::get_scale_y(scl16 y)
535 {
536     scl16 ret = 0;
537     if (m_initialized) {
538         CSCLUtils *utils = CSCLUtils::get_instance();
539         if (utils) {
540             ret = utils->get_scale_y(y);
541         }
542     }
543     return ret;
544 }
545
546 /**
547  * Returns the scl base window size
548  */
549 SclRectangle
550 CSCLUIImpl::get_main_window_rect()
551 {
552     SclRectangle ret = {0};
553
554     if (m_initialized) {
555         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
556         CSCLWindows *windows = CSCLWindows::get_instance();
557         if (cache && windows) {
558             //const SclLayout *layout  = cache->get_cur_layout(windows->get_base_window());
559             SclWindowContext *winctx = windows->get_window_context(windows->get_base_window());
560             if (winctx) {
561                 ret.x = winctx->geometry.x;
562                 ret.y = winctx->geometry.y;
563                 ret.width = winctx->geometry.width;
564                 ret.height = winctx->geometry.height;
565             }
566         }
567     }
568
569     return ret;
570 }
571
572 /**
573  * Returns the scl base window size
574  */
575 SclSize
576 CSCLUIImpl::get_input_mode_size(const sclchar *input_mode, SCLDisplayMode display_mode)
577 {
578     SclSize ret = {0};
579
580     if (m_initialized) {
581         CSCLUtils *utils = CSCLUtils::get_instance();
582         SclResParserManager *sclres_manager = SclResParserManager::get_instance();
583         if (utils && sclres_manager) {
584             const PSclInputModeConfigure sclres_input_mode_configure = sclres_manager->get_input_mode_configure_table();
585             const PSclLayout sclres_layout = sclres_manager->get_layout_table();
586             sclint inputmode = sclres_manager->get_inputmode_id(input_mode);
587             sclint layout = sclres_manager->get_layout_id(
588                 sclres_input_mode_configure[inputmode].layouts[display_mode]);
589
590             ret.width = sclres_layout[layout].width;
591             ret.height = sclres_layout[layout].height;
592         }
593     }
594
595     return ret;
596 }
597
598 /**
599 * Returns the screen resolution
600 */
601 void
602 CSCLUIImpl::get_screen_resolution(sclint *width, sclint *height)
603 {
604     sclboolean ret = FALSE;
605
606     if (m_initialized) {
607         CSCLUtils *utils = CSCLUtils::get_instance();
608         if (utils && width && height) {
609             utils->get_screen_resolution(width, height);
610         }
611     }
612 }
613
614
615
616 void
617 CSCLUIImpl::set_debug_mode(SCLDebugMode mode)
618 {
619     sclboolean ret = FALSE;
620
621     if (m_initialized) {
622         CSCLController *controller = CSCLController::get_instance();
623         if (controller) {
624             controller->set_debug_mode(mode);
625         }
626     }
627 }
628
629 SCLDebugMode
630 CSCLUIImpl::get_debug_mode()
631 {
632     SCLDebugMode ret = DEBUGMODE_DISABLED;
633     if (m_initialized) {
634         CSCLController *controller = CSCLController::get_instance();
635         if (controller) {
636             ret = controller->get_debug_mode();
637         }
638     }
639     return ret;
640 }
641
642 void
643 CSCLUIImpl::set_update_pending(sclboolean pend)
644 {
645     sclboolean ret = FALSE;
646
647     if (m_initialized) {
648         CSCLWindows *windows = CSCLWindows::get_instance();
649         if (windows) {
650             windows->set_update_pending(pend);
651         }
652     }
653 }
654
655 void
656 CSCLUIImpl::enable_button(const sclchar* custom_id, sclboolean enabled)
657 {
658     sclboolean ret = FALSE;
659
660     if (m_initialized) {
661         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
662         if (cache) {
663             cache->enable_button(custom_id, enabled);
664         }
665     }
666 }
667
668 sclint
669 CSCLUIImpl::get_multi_touch_context_num()
670 {
671     sclint ret = 0;
672
673     if (m_initialized) {
674         CSCLContext *context = CSCLContext::get_instance();
675         if (context) {
676             ret = context->get_multi_touch_context_num();
677         }
678     }
679     return ret;
680 }
681
682 sclboolean
683 CSCLUIImpl::get_multi_touch_event(sclint seqorder, SclUIEventDesc *desc)
684 {
685     sclboolean ret = FALSE;
686
687     if (m_initialized) {
688         CSCLContext *context = CSCLContext::get_instance();
689         if (context) {
690             ret = context->get_multi_touch_event(seqorder, desc);
691         }
692     }
693     return ret;
694 }
695
696 sclboolean
697 CSCLUIImpl::set_longkey_duration(scllong msc)
698 {
699     sclboolean ret = FALSE;
700
701     if (m_initialized) {
702         CSCLController *controller = CSCLController::get_instance();
703         if (controller) {
704             ret = controller->set_longkey_duration(msc);
705         }
706     }
707     return ret;
708 }
709
710 sclboolean
711 CSCLUIImpl::set_longkey_cancel_dist(sclshort dist)
712 {
713     sclboolean ret = FALSE;
714
715     if (m_initialized) {
716         CSCLController *controller = CSCLController::get_instance();
717         if (controller) {
718             ret = controller->set_longkey_cancel_dist(dist);
719         }
720     }
721     return ret;
722 }
723
724 sclboolean
725 CSCLUIImpl::set_repeatkey_duration(scllong msc)
726 {
727     sclboolean ret = FALSE;
728
729     if (m_initialized) {
730         CSCLController *controller = CSCLController::get_instance();
731         if (controller) {
732             ret = controller->set_repeatkey_duration(msc);
733         }
734     }
735     return ret;
736 }
737
738 sclboolean
739 CSCLUIImpl::set_autopoup_key_duration(scllong msc)
740 {
741     sclboolean ret = FALSE;
742
743     if (m_initialized) {
744         CSCLController *controller = CSCLController::get_instance();
745         if (controller) {
746             ret = controller->set_autopopup_key_duration(msc);
747         }
748     }
749     return ret;
750 }
751
752 sclboolean
753 CSCLUIImpl::set_button_delay_duration(scllong msc)
754 {
755     sclboolean ret = FALSE;
756
757     if (m_initialized) {
758         CSCLController *controller = CSCLController::get_instance();
759         if (controller) {
760             ret = controller->set_button_delay_duration(msc);
761         }
762     }
763     return ret;
764 }
765
766 void
767 CSCLUIImpl::enable_magnifier(sclboolean enabled)
768 {
769     sclboolean ret = FALSE;
770
771     if (m_initialized) {
772         CSCLContext *context = CSCLContext::get_instance();
773         if (context) {
774             context->set_magnifier_enabled(enabled);
775         }
776     }
777 }
778
779 void
780 CSCLUIImpl::enable_sound(sclboolean enabled)
781 {
782     sclboolean ret = FALSE;
783
784     if (m_initialized) {
785         CSCLContext *context = CSCLContext::get_instance();
786         if (context) {
787             context->set_sound_enabled(enabled);
788         }
789     }
790 }
791
792 void
793 CSCLUIImpl::enable_vibration(sclboolean enabled)
794 {
795     sclboolean ret = FALSE;
796
797     if (m_initialized) {
798         CSCLContext *context = CSCLContext::get_instance();
799         if (context) {
800             context->set_vibration_enabled(enabled);
801         }
802     }
803 }
804
805 void
806 CSCLUIImpl::enable_tts(sclboolean enabled)
807 {
808     sclboolean ret = FALSE;
809
810     if (m_initialized) {
811         CSCLContext *context = CSCLContext::get_instance();
812         if (context) {
813             context->set_tts_enabled(enabled);
814         }
815     }
816 }
817
818 void
819 CSCLUIImpl::enable_shift_multi_touch(sclboolean enabled)
820 {
821     sclboolean ret = FALSE;
822
823     if (m_initialized) {
824         CSCLContext *context = CSCLContext::get_instance();
825         if (context) {
826             context->set_shift_multi_touch_enabled(enabled);
827         }
828     }
829 }
830
831 void
832 CSCLUIImpl::enable_touch_offset(sclboolean enabled)
833 {
834     CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
835     if (adjustment) {
836         adjustment->enable_touch_offset(enabled);
837     }
838 }
839
840 void
841 CSCLUIImpl::disable_input_events(sclboolean disabled)
842 {
843     sclboolean ret = FALSE;
844
845     if (m_initialized) {
846         CSCLController *controller = CSCLController::get_instance();
847         if (controller) {
848             controller->disable_input_events(disabled);
849         }
850     }
851 }
852
853 sclboolean
854 CSCLUIImpl::set_cur_sublayout(const sclchar *sub_layout_name)
855 {
856     sclboolean ret = FALSE;
857
858     if (m_initialized) {
859         CSCLContext *context = CSCLContext::get_instance();
860         CSCLWindows *windows = CSCLWindows::get_instance();
861         if (context && windows) {
862             ret = context->set_cur_sublayout(sub_layout_name);
863             windows->update_window(windows->get_base_window());
864         }
865     }
866     return ret;
867 }
868
869 const sclchar*
870 CSCLUIImpl::get_cur_sublayout()
871 {
872     sclchar* ret = NULL;
873     if (m_initialized) {
874         CSCLContext *context = CSCLContext::get_instance();
875         if (context) {
876             ret = context->get_cur_sublayout();
877         }
878     }
879     return ret;
880 }
881
882 void
883 CSCLUIImpl::set_custom_magnifier_label(scltouchdevice touch_id, sclint index, const sclchar* label)
884 {
885     if (m_initialized) {
886         CSCLContext *context = CSCLContext::get_instance();
887         if (context) {
888             context->set_custom_magnifier_label(touch_id, index, label);
889         }
890     }
891 }
892
893 void
894 CSCLUIImpl::set_string_substitution(const sclchar *original, const sclchar *substitute)
895 {
896     if (m_initialized) {
897         CSCLWindows *windows = CSCLWindows::get_instance();
898         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
899         if (cache && windows) {
900             cache->set_string_substitution(original, substitute);
901             windows->update_window(windows->get_base_window());
902         }
903     }
904 }
905
906 void
907 CSCLUIImpl::unset_string_substitution(const sclchar *original)
908 {
909     if (m_initialized) {
910         CSCLWindows *windows = CSCLWindows::get_instance();
911         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
912         if (cache && windows) {
913             cache->unset_string_substitution(original);
914             windows->update_window(windows->get_base_window());
915         }
916     }
917 }
918
919 void
920 CSCLUIImpl::set_caps_mode(sclint mode) {
921     m_caps_mode = mode;
922     if (get_shift_state() != SCL_SHIFT_STATE_LOCK) {
923         set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
924     }
925 }
926
927 sclint
928 CSCLUIImpl::get_caps_mode() {
929     return m_caps_mode;
930 }