2 * Copyright (c) 2012 - 2014 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 #include "encode_default_configure.h"
19 #include "xmlresource.h"
20 #include "resource_storage_impl.h"
21 using namespace xmlresource;
23 #include "put_record.h"
24 #include "_auto_metadata.h"
25 static void _encode_color(ResourceStorage& storage, const SclColor& color, int width) {
26 if (width <= 0) return;
28 storage.put<sint_t>(color.r, width);
29 storage.put<sint_t>(color.g, width);
30 storage.put<sint_t>(color.b, width);
31 storage.put<sint_t>(color.a, width);
34 encode_default_configure_record(ResourceStorage& storage, const PSclDefaultConfigure cur, const Default_configure_width& record_width) {
36 storage.put<sint_t>((int)cur->display_mode, record_width.display_mode);
39 storage.encode_string(cur->input_mode, record_width.input_mode);
41 //image_file_base_path
42 storage.encode_string(cur->image_file_base_path, record_width.image_file_base_path);
45 storage.put<sint_t>(cur->target_screen_width, record_width.target_screen_width);
47 //target_screen_height
48 storage.put<sint_t>(cur->target_screen_height, record_width.target_screen_height);
50 //auto_detect_landscape
51 storage.put<sint_t>(cur->auto_detect_landscape, record_width.auto_detect_landscape);
53 //use_magnifier_window
54 storage.put<sint_t>(cur->use_magnifier_window, record_width.use_magnifier_window);
57 storage.put<sint_t>(cur->use_auto_popup, record_width.use_auto_popup);
60 storage.put<sint_t>(cur->use_zoom_window, record_width.use_zoom_window);
63 storage.put<sint_t>(cur->on_error_noti_send, record_width.on_error_noti_send);
66 storage.put<sint_t>(cur->use_word_deletion, record_width.use_word_deletion);
69 storage.put<sint_t>(cur->sw_button_style, record_width.sw_button_style);
72 for (int i = 0; i < DISPLAYMODE_MAX; ++i) {
73 storage.put<sint_t>((int)cur->touch_offset_level[i], record_width.touch_offset_level);
77 for (int i = 0; i < DISPLAYMODE_MAX; ++i) {
78 storage.put<sint_t>((int)cur->touch_offset[i].x, record_width.touch_offset);
79 storage.put<sint_t>((int)cur->touch_offset[i].y, record_width.touch_offset);
83 storage.encode_string(cur->default_sub_layout, record_width.default_sub_layout);
85 //use_actual_dim_window
86 storage.put<sint_t>(cur->use_actual_dim_window, record_width.use_actual_dim_window);
89 _encode_color(storage, cur->dim_color, record_width.dim_color);
93 encode_default_configure_file(ResourceStorage& storage, IMetaData_Helper& md_helper) {
94 int init_size = storage.get_size();
96 XMLResource *xmlresource = XMLResource::get_instance();
97 PSclDefaultConfigure defaultConfigure = xmlresource->get_default_configure();
99 #ifdef __SCL_TXT_DEBUG
100 put_default_configure(ENCODE, *defaultConfigure);
103 Default_configure_width record_width;
104 set_default_configure_width(md_helper, record_width);
107 encode_default_configure_record(storage, defaultConfigure, record_width);
109 int size = storage.get_size() - init_size;
110 storage.random_put<sint_t>(size, 8, init_size);
111 return storage.get_size();
115 encode_default_configure_file(const char* file, IMetaData_Helper& md_helper) {
118 ResourceStorage storage;
119 encode_default_configure_file(storage, md_helper);
120 storage.toFile(file);
122 return storage.get_size();
126 encode_default_configure_file(const char* file, int& offset, IMetaData_Helper& md_helper) {
129 ResourceStorage storage;
130 encode_default_configure_file(storage, md_helper);
131 storage.toFile(file, offset);
133 return storage.get_size();