fix prevent issue
[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             if (sclres_input_mode_configure && sclres_layout) {
588                 sclint layout = sclres_manager->get_layout_id(
589                         sclres_input_mode_configure[inputmode].layouts[display_mode]);
590
591                 ret.width = sclres_layout[layout].width;
592                 ret.height = sclres_layout[layout].height;
593             }
594         }
595     }
596
597     return ret;
598 }
599
600 /**
601 * Returns the screen resolution
602 */
603 void
604 CSCLUIImpl::get_screen_resolution(sclint *width, sclint *height)
605 {
606     sclboolean ret = FALSE;
607
608     if (m_initialized) {
609         CSCLUtils *utils = CSCLUtils::get_instance();
610         if (utils && width && height) {
611             utils->get_screen_resolution(width, height);
612         }
613     }
614 }
615
616
617
618 void
619 CSCLUIImpl::set_debug_mode(SCLDebugMode mode)
620 {
621     sclboolean ret = FALSE;
622
623     if (m_initialized) {
624         CSCLController *controller = CSCLController::get_instance();
625         if (controller) {
626             controller->set_debug_mode(mode);
627         }
628     }
629 }
630
631 SCLDebugMode
632 CSCLUIImpl::get_debug_mode()
633 {
634     SCLDebugMode ret = DEBUGMODE_DISABLED;
635     if (m_initialized) {
636         CSCLController *controller = CSCLController::get_instance();
637         if (controller) {
638             ret = controller->get_debug_mode();
639         }
640     }
641     return ret;
642 }
643
644 void
645 CSCLUIImpl::set_update_pending(sclboolean pend)
646 {
647     sclboolean ret = FALSE;
648
649     if (m_initialized) {
650         CSCLWindows *windows = CSCLWindows::get_instance();
651         if (windows) {
652             windows->set_update_pending(pend);
653         }
654     }
655 }
656
657 void
658 CSCLUIImpl::enable_button(const sclchar* custom_id, sclboolean enabled)
659 {
660     sclboolean ret = FALSE;
661
662     if (m_initialized) {
663         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
664         if (cache) {
665             cache->enable_button(custom_id, enabled);
666         }
667     }
668 }
669
670 sclint
671 CSCLUIImpl::get_multi_touch_context_num()
672 {
673     sclint ret = 0;
674
675     if (m_initialized) {
676         CSCLContext *context = CSCLContext::get_instance();
677         if (context) {
678             ret = context->get_multi_touch_context_num();
679         }
680     }
681     return ret;
682 }
683
684 sclboolean
685 CSCLUIImpl::get_multi_touch_event(sclint seqorder, SclUIEventDesc *desc)
686 {
687     sclboolean ret = FALSE;
688
689     if (m_initialized) {
690         CSCLContext *context = CSCLContext::get_instance();
691         if (context) {
692             ret = context->get_multi_touch_event(seqorder, desc);
693         }
694     }
695     return ret;
696 }
697
698 sclboolean
699 CSCLUIImpl::set_longkey_duration(scllong msc)
700 {
701     sclboolean ret = FALSE;
702
703     if (m_initialized) {
704         CSCLController *controller = CSCLController::get_instance();
705         if (controller) {
706             ret = controller->set_longkey_duration(msc);
707         }
708     }
709     return ret;
710 }
711
712 sclboolean
713 CSCLUIImpl::set_longkey_cancel_dist(sclshort dist)
714 {
715     sclboolean ret = FALSE;
716
717     if (m_initialized) {
718         CSCLController *controller = CSCLController::get_instance();
719         if (controller) {
720             ret = controller->set_longkey_cancel_dist(dist);
721         }
722     }
723     return ret;
724 }
725
726 sclboolean
727 CSCLUIImpl::set_repeatkey_duration(scllong msc)
728 {
729     sclboolean ret = FALSE;
730
731     if (m_initialized) {
732         CSCLController *controller = CSCLController::get_instance();
733         if (controller) {
734             ret = controller->set_repeatkey_duration(msc);
735         }
736     }
737     return ret;
738 }
739
740 sclboolean
741 CSCLUIImpl::set_autopoup_key_duration(scllong msc)
742 {
743     sclboolean ret = FALSE;
744
745     if (m_initialized) {
746         CSCLController *controller = CSCLController::get_instance();
747         if (controller) {
748             ret = controller->set_autopopup_key_duration(msc);
749         }
750     }
751     return ret;
752 }
753
754 sclboolean
755 CSCLUIImpl::set_button_delay_duration(scllong msc)
756 {
757     sclboolean ret = FALSE;
758
759     if (m_initialized) {
760         CSCLController *controller = CSCLController::get_instance();
761         if (controller) {
762             ret = controller->set_button_delay_duration(msc);
763         }
764     }
765     return ret;
766 }
767
768 void
769 CSCLUIImpl::enable_magnifier(sclboolean enabled)
770 {
771     sclboolean ret = FALSE;
772
773     if (m_initialized) {
774         CSCLContext *context = CSCLContext::get_instance();
775         if (context) {
776             context->set_magnifier_enabled(enabled);
777         }
778     }
779 }
780
781 void
782 CSCLUIImpl::enable_sound(sclboolean enabled)
783 {
784     sclboolean ret = FALSE;
785
786     if (m_initialized) {
787         CSCLContext *context = CSCLContext::get_instance();
788         if (context) {
789             context->set_sound_enabled(enabled);
790         }
791     }
792 }
793
794 void
795 CSCLUIImpl::enable_vibration(sclboolean enabled)
796 {
797     sclboolean ret = FALSE;
798
799     if (m_initialized) {
800         CSCLContext *context = CSCLContext::get_instance();
801         if (context) {
802             context->set_vibration_enabled(enabled);
803         }
804     }
805 }
806
807 void
808 CSCLUIImpl::enable_tts(sclboolean enabled)
809 {
810     sclboolean ret = FALSE;
811
812     if (m_initialized) {
813         CSCLContext *context = CSCLContext::get_instance();
814         if (context) {
815             context->set_tts_enabled(enabled);
816         }
817     }
818 }
819
820 void
821 CSCLUIImpl::enable_shift_multi_touch(sclboolean enabled)
822 {
823     sclboolean ret = FALSE;
824
825     if (m_initialized) {
826         CSCLContext *context = CSCLContext::get_instance();
827         if (context) {
828             context->set_shift_multi_touch_enabled(enabled);
829         }
830     }
831 }
832
833 void
834 CSCLUIImpl::enable_touch_offset(sclboolean enabled)
835 {
836     CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
837     if (adjustment) {
838         adjustment->enable_touch_offset(enabled);
839     }
840 }
841
842 void
843 CSCLUIImpl::disable_input_events(sclboolean disabled)
844 {
845     sclboolean ret = FALSE;
846
847     if (m_initialized) {
848         CSCLController *controller = CSCLController::get_instance();
849         if (controller) {
850             controller->disable_input_events(disabled);
851         }
852     }
853 }
854
855 sclboolean
856 CSCLUIImpl::set_cur_sublayout(const sclchar *sub_layout_name)
857 {
858     sclboolean ret = FALSE;
859
860     if (m_initialized) {
861         CSCLContext *context = CSCLContext::get_instance();
862         CSCLWindows *windows = CSCLWindows::get_instance();
863         if (context && windows) {
864             ret = context->set_cur_sublayout(sub_layout_name);
865             windows->update_window(windows->get_base_window());
866         }
867     }
868     return ret;
869 }
870
871 const sclchar*
872 CSCLUIImpl::get_cur_sublayout()
873 {
874     sclchar* ret = NULL;
875     if (m_initialized) {
876         CSCLContext *context = CSCLContext::get_instance();
877         if (context) {
878             ret = context->get_cur_sublayout();
879         }
880     }
881     return ret;
882 }
883
884 void
885 CSCLUIImpl::set_custom_magnifier_label(scltouchdevice touch_id, sclint index, const sclchar* label)
886 {
887     if (m_initialized) {
888         CSCLContext *context = CSCLContext::get_instance();
889         if (context) {
890             context->set_custom_magnifier_label(touch_id, index, label);
891         }
892     }
893 }
894
895 void
896 CSCLUIImpl::set_string_substitution(const sclchar *original, const sclchar *substitute)
897 {
898     if (m_initialized) {
899         CSCLWindows *windows = CSCLWindows::get_instance();
900         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
901         if (cache && windows) {
902             cache->set_string_substitution(original, substitute);
903             windows->update_window(windows->get_base_window());
904         }
905     }
906 }
907
908 void
909 CSCLUIImpl::unset_string_substitution(const sclchar *original)
910 {
911     if (m_initialized) {
912         CSCLWindows *windows = CSCLWindows::get_instance();
913         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
914         if (cache && windows) {
915             cache->unset_string_substitution(original);
916             windows->update_window(windows->get_base_window());
917         }
918     }
919 }
920
921 void
922 CSCLUIImpl::set_caps_mode(sclint mode) {
923     m_caps_mode = mode;
924     if (get_shift_state() != SCL_SHIFT_STATE_LOCK) {
925         set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF);
926     }
927 }
928
929 sclint
930 CSCLUIImpl::get_caps_mode() {
931     return m_caps_mode;
932 }