Adapt auto capitalize feature
[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         if (context && windows && utils) {
403             SCLShiftState current_state = context->get_shift_state();
404             context->set_shift_state(state);
405             if (state != current_state) {
406                 windows->update_window(windows->get_base_window());
407             }
408             if (context->get_tts_enabled()) {
409                 if (state == SCL_SHIFT_STATE_ON) {
410                     utils->play_tts(SCL_SHIFT_STATE_ON_HINT_STRING);
411                 } else if (state == SCL_SHIFT_STATE_LOCK) {
412                     utils->play_tts(SCL_SHIFT_STATE_LOCK_HINT_STRING);
413                 } else {
414                     utils->play_tts(SCL_SHIFT_STATE_OFF_HINT_STRING);
415                 }
416             }
417         }
418     }
419 }
420
421 /**
422  * This function will be called by the user which uses SCL when the context of the focus application is changed
423  * ISE user should explicitly call this function when the context of application is changed.
424  * For instance, focus-changed, application-changed,, and so on.
425  * This function will call CSCLController to init the related variables.
426  */
427 void
428 CSCLUIImpl::notify_app_focus_changed()
429 {
430     SCL_DEBUG();
431     sclboolean ret = FALSE;
432
433     if (m_initialized) {
434         CSCLController *controller = CSCLController::get_instance();
435         if (controller) {
436             controller->handle_engine_signal(SCL_SIG_FOCUS_CHANGE);
437         }
438     }
439 }
440
441 void
442 CSCLUIImpl::reset_popup_timeout()
443 {
444     SCL_DEBUG();
445     sclboolean ret = FALSE;
446
447     if (m_initialized) {
448         CSCLEvents *events = CSCLEvents::get_instance();
449         CSCLWindows *windows = CSCLWindows::get_instance();
450
451         if (events && windows) {
452             events->destroy_timer(SCL_TIMER_POPUP_TIMEOUT);
453
454             sclbyte index = 0;
455             sclboolean timerset = FALSE;
456             sclwindow window = SCLWINDOW_INVALID;
457             SclWindowContext *winctx = NULL;
458             do {
459                 window = windows->get_nth_window_in_Z_order_list(index);
460                 //winctx = windows->get_window_context(window, FALSE);
461                 winctx = windows->get_window_context(window);
462                 if (winctx) {
463                     if (winctx->timeout != 0) {
464                         events->create_timer(SCL_TIMER_POPUP_TIMEOUT, winctx->timeout, 0, TRUE);
465                         timerset = TRUE;
466                     }
467                     index++;
468                 }
469             } while (index < MAX_ZORDER_NUM && window != SCLWINDOW_INVALID && !timerset);
470         }
471     }
472 }
473
474 void
475 CSCLUIImpl::close_all_popups()
476 {
477     SCL_DEBUG();
478     sclboolean ret = FALSE;
479
480     if (m_initialized) {
481         CSCLWindows *windows = CSCLWindows::get_instance();
482         if (windows) {
483             windows->close_all_popups();
484         }
485     }
486 }
487
488 /**
489  * Returns a scale rate (see default screen resolution in sclconfig.h file)
490  */
491 sclfloat
492 CSCLUIImpl::get_scale_rate()
493 {
494     sclfloat ret = 0.0f;
495     if (m_initialized) {
496         CSCLUtils *utils = CSCLUtils::get_instance();
497         if (utils) {
498             ret = utils->get_smallest_scale_rate();
499         }
500     }
501     return ret;
502 }
503
504 /**
505  * Returns a calculated x value according to the current screen resolution
506  */
507 scl16
508 CSCLUIImpl::get_scale_x(scl16 x)
509 {
510     scl16 ret = 0;
511     if (m_initialized) {
512         CSCLUtils *utils = CSCLUtils::get_instance();
513         if (utils) {
514             ret = utils->get_scale_x(x);
515         }
516     }
517     return ret;
518 }
519
520 /**
521  * Returns a calculated y value according to the current screen resolution
522  */
523 scl16
524 CSCLUIImpl::get_scale_y(scl16 y)
525 {
526     scl16 ret = 0;
527     if (m_initialized) {
528         CSCLUtils *utils = CSCLUtils::get_instance();
529         if (utils) {
530             ret = utils->get_scale_y(y);
531         }
532     }
533     return ret;
534 }
535
536 /**
537  * Returns the scl base window size
538  */
539 SclRectangle
540 CSCLUIImpl::get_main_window_rect()
541 {
542     SclRectangle ret = {0};
543
544     if (m_initialized) {
545         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
546         CSCLWindows *windows = CSCLWindows::get_instance();
547         if (cache && windows) {
548             //const SclLayout *layout  = cache->get_cur_layout(windows->get_base_window());
549             SclWindowContext *winctx = windows->get_window_context(windows->get_base_window());
550             if (winctx) {
551                 ret.x = winctx->geometry.x;
552                 ret.y = winctx->geometry.y;
553                 ret.width = winctx->geometry.width;
554                 ret.height = winctx->geometry.height;
555             }
556         }
557     }
558
559     return ret;
560 }
561
562 /**
563  * Returns the scl base window size
564  */
565 SclSize
566 CSCLUIImpl::get_input_mode_size(const sclchar *input_mode, SCLDisplayMode display_mode)
567 {
568     SclSize ret = {0};
569
570     if (m_initialized) {
571         CSCLUtils *utils = CSCLUtils::get_instance();
572         SclResParserManager *sclres_manager = SclResParserManager::get_instance();
573         if (utils && sclres_manager) {
574             const PSclInputModeConfigure sclres_input_mode_configure = sclres_manager->get_input_mode_configure_table();
575             const PSclLayout sclres_layout = sclres_manager->get_layout_table();
576             sclint inputmode = sclres_manager->get_inputmode_id(input_mode);
577             sclint layout = sclres_manager->get_layout_id(
578                 sclres_input_mode_configure[inputmode].layouts[display_mode]);
579
580             ret.width = sclres_layout[layout].width;
581             ret.height = sclres_layout[layout].height;
582         }
583     }
584
585     return ret;
586 }
587
588 /**
589 * Returns the screen resolution
590 */
591 void
592 CSCLUIImpl::get_screen_resolution(sclint *width, sclint *height)
593 {
594     sclboolean ret = FALSE;
595
596     if (m_initialized) {
597         CSCLUtils *utils = CSCLUtils::get_instance();
598         if (utils && width && height) {
599             utils->get_screen_resolution(width, height);
600         }
601     }
602 }
603
604
605
606 void
607 CSCLUIImpl::set_debug_mode(SCLDebugMode mode)
608 {
609     sclboolean ret = FALSE;
610
611     if (m_initialized) {
612         CSCLController *controller = CSCLController::get_instance();
613         if (controller) {
614             controller->set_debug_mode(mode);
615         }
616     }
617 }
618
619 SCLDebugMode
620 CSCLUIImpl::get_debug_mode()
621 {
622     SCLDebugMode ret = DEBUGMODE_DISABLED;
623     if (m_initialized) {
624         CSCLController *controller = CSCLController::get_instance();
625         if (controller) {
626             ret = controller->get_debug_mode();
627         }
628     }
629     return ret;
630 }
631
632 void
633 CSCLUIImpl::set_update_pending(sclboolean pend)
634 {
635     sclboolean ret = FALSE;
636
637     if (m_initialized) {
638         CSCLWindows *windows = CSCLWindows::get_instance();
639         if (windows) {
640             windows->set_update_pending(pend);
641         }
642     }
643 }
644
645 void
646 CSCLUIImpl::enable_button(const sclchar* custom_id, sclboolean enabled)
647 {
648     sclboolean ret = FALSE;
649
650     if (m_initialized) {
651         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
652         if (cache) {
653             cache->enable_button(custom_id, enabled);
654         }
655     }
656 }
657
658 sclint
659 CSCLUIImpl::get_multi_touch_context_num()
660 {
661     sclint ret = 0;
662
663     if (m_initialized) {
664         CSCLContext *context = CSCLContext::get_instance();
665         if (context) {
666             ret = context->get_multi_touch_context_num();
667         }
668     }
669     return ret;
670 }
671
672 sclboolean
673 CSCLUIImpl::get_multi_touch_event(sclint seqorder, SclUIEventDesc *desc)
674 {
675     sclboolean ret = FALSE;
676
677     if (m_initialized) {
678         CSCLContext *context = CSCLContext::get_instance();
679         if (context) {
680             ret = context->get_multi_touch_event(seqorder, desc);
681         }
682     }
683     return ret;
684 }
685
686 sclboolean
687 CSCLUIImpl::set_longkey_duration(scllong msc)
688 {
689     sclboolean ret = FALSE;
690
691     if (m_initialized) {
692         CSCLController *controller = CSCLController::get_instance();
693         if (controller) {
694             ret = controller->set_longkey_duration(msc);
695         }
696     }
697     return ret;
698 }
699
700 sclboolean
701 CSCLUIImpl::set_longkey_cancel_dist(sclshort dist)
702 {
703     sclboolean ret = FALSE;
704
705     if (m_initialized) {
706         CSCLController *controller = CSCLController::get_instance();
707         if (controller) {
708             ret = controller->set_longkey_cancel_dist(dist);
709         }
710     }
711     return ret;
712 }
713
714 sclboolean
715 CSCLUIImpl::set_repeatkey_duration(scllong msc)
716 {
717     sclboolean ret = FALSE;
718
719     if (m_initialized) {
720         CSCLController *controller = CSCLController::get_instance();
721         if (controller) {
722             ret = controller->set_repeatkey_duration(msc);
723         }
724     }
725     return ret;
726 }
727
728 sclboolean
729 CSCLUIImpl::set_autopoup_key_duration(scllong msc)
730 {
731     sclboolean ret = FALSE;
732
733     if (m_initialized) {
734         CSCLController *controller = CSCLController::get_instance();
735         if (controller) {
736             ret = controller->set_autopopup_key_duration(msc);
737         }
738     }
739     return ret;
740 }
741
742 sclboolean
743 CSCLUIImpl::set_button_delay_duration(scllong msc)
744 {
745     sclboolean ret = FALSE;
746
747     if (m_initialized) {
748         CSCLController *controller = CSCLController::get_instance();
749         if (controller) {
750             ret = controller->set_button_delay_duration(msc);
751         }
752     }
753     return ret;
754 }
755
756 void
757 CSCLUIImpl::enable_magnifier(sclboolean enabled)
758 {
759     sclboolean ret = FALSE;
760
761     if (m_initialized) {
762         CSCLContext *context = CSCLContext::get_instance();
763         if (context) {
764             context->set_magnifier_enabled(enabled);
765         }
766     }
767 }
768
769 void
770 CSCLUIImpl::enable_sound(sclboolean enabled)
771 {
772     sclboolean ret = FALSE;
773
774     if (m_initialized) {
775         CSCLContext *context = CSCLContext::get_instance();
776         if (context) {
777             context->set_sound_enabled(enabled);
778         }
779     }
780 }
781
782 void
783 CSCLUIImpl::enable_vibration(sclboolean enabled)
784 {
785     sclboolean ret = FALSE;
786
787     if (m_initialized) {
788         CSCLContext *context = CSCLContext::get_instance();
789         if (context) {
790             context->set_vibration_enabled(enabled);
791         }
792     }
793 }
794
795 void
796 CSCLUIImpl::enable_tts(sclboolean enabled)
797 {
798     sclboolean ret = FALSE;
799
800     if (m_initialized) {
801         CSCLContext *context = CSCLContext::get_instance();
802         if (context) {
803             context->set_tts_enabled(enabled);
804         }
805     }
806 }
807
808 void
809 CSCLUIImpl::enable_shift_multi_touch(sclboolean enabled)
810 {
811     sclboolean ret = FALSE;
812
813     if (m_initialized) {
814         CSCLContext *context = CSCLContext::get_instance();
815         if (context) {
816             context->set_shift_multi_touch_enabled(enabled);
817         }
818     }
819 }
820
821 void
822 CSCLUIImpl::enable_touch_offset(sclboolean enabled)
823 {
824     CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
825     if (adjustment) {
826         adjustment->enable_touch_offset(enabled);
827     }
828 }
829
830 void
831 CSCLUIImpl::disable_input_events(sclboolean disabled)
832 {
833     sclboolean ret = FALSE;
834
835     if (m_initialized) {
836         CSCLController *controller = CSCLController::get_instance();
837         if (controller) {
838             controller->disable_input_events(disabled);
839         }
840     }
841 }
842
843 sclboolean
844 CSCLUIImpl::set_cur_sublayout(const sclchar *sub_layout_name)
845 {
846     sclboolean ret = FALSE;
847
848     if (m_initialized) {
849         CSCLContext *context = CSCLContext::get_instance();
850         CSCLWindows *windows = CSCLWindows::get_instance();
851         if (context && windows) {
852             ret = context->set_cur_sublayout(sub_layout_name);
853             windows->update_window(windows->get_base_window());
854         }
855     }
856     return ret;
857 }
858
859 const sclchar*
860 CSCLUIImpl::get_cur_sublayout()
861 {
862     sclchar* ret = NULL;
863     if (m_initialized) {
864         CSCLContext *context = CSCLContext::get_instance();
865         if (context) {
866             ret = context->get_cur_sublayout();
867         }
868     }
869     return ret;
870 }
871
872 void
873 CSCLUIImpl::set_custom_magnifier_label(scltouchdevice touch_id, sclint index, const sclchar* label)
874 {
875     if (m_initialized) {
876         CSCLContext *context = CSCLContext::get_instance();
877         if (context) {
878             context->set_custom_magnifier_label(touch_id, index, label);
879         }
880     }
881 }
882
883 void
884 CSCLUIImpl::set_string_substitution(const sclchar *original, const sclchar *substitute)
885 {
886     if (m_initialized) {
887         CSCLWindows *windows = CSCLWindows::get_instance();
888         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
889         if (cache && windows) {
890             cache->set_string_substitution(original, substitute);
891             windows->update_window(windows->get_base_window());
892         }
893     }
894 }
895
896 void
897 CSCLUIImpl::unset_string_substitution(const sclchar *original)
898 {
899     if (m_initialized) {
900         CSCLWindows *windows = CSCLWindows::get_instance();
901         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
902         if (cache && windows) {
903             cache->unset_string_substitution(original);
904             windows->update_window(windows->get_base_window());
905         }
906     }
907 }
908
909 void
910 CSCLUIImpl::set_caps_mode(sclint mode) {
911     m_caps_mode = mode;
912     if (get_shift_state() != SCL_SHIFT_STATE_LOCK) {
913         set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
914     }
915 }
916
917 sclint
918 CSCLUIImpl::get_caps_mode() {
919     return m_caps_mode;
920 }