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 "layout_bin_parser.h"
19 #include "default_configure_bin_parser.h"
20 #include "key_coordinate_frame_bin_parser.h"
23 #include "put_record.h"
31 memset(m_layout_table, 0x00, sizeof(SclLayout) * MAX_SCL_LAYOUT);
32 parser_info_provider = NULL;
37 BinLayoutParser* BinLayoutParser::
39 static BinLayoutParser instance;
42 void BinLayoutParser::
43 init(const FileStorage& storage, int offset, int size, IParserInfo_Provider* provider) {
44 m_storage.set_str_provider(provider);
45 m_storage.get_storage(storage, offset, size);
46 this->parser_info_provider = provider;
47 parsing_layout_table();
51 get_layout_index(const char *name) {
54 for (int loop = 0;loop < MAX_SCL_LAYOUT && ret == NOT_USED;loop++) {
55 if (m_layout_table[loop].name) {
56 if (strcmp(m_layout_table[loop].name, name) == 0) {
66 PSclLayout BinLayoutParser::
68 return m_layout_table;
76 PSclLayoutKeyCoordinatePointerTable BinLayoutParser::
77 get_key_coordinate_pointer_frame() {
78 BinKeyCoordFrameParser *key_coordinate_frame_bin_parser = BinKeyCoordFrameParser::get_instance();
79 return key_coordinate_frame_bin_parser->get_key_coordinate_pointer_frame();
82 void BinLayoutParser::
83 parsing_layout_table() {
84 // 4 byte (range[0-4,294,967,295))
85 const int DATA_SIZE_BYTES = 4;
86 // 1 byte (range[0-128))
87 const int REC_NUM_BYTES = 1;
88 // 2 byte (range[0-65536))
89 const int LAYOUT_REC_DATA_SIZE_BYTES = 2;
92 Layout_width record_width;
93 set_layout_width(*parser_info_provider, record_width);
96 m_storage.advance(DATA_SIZE_BYTES);
99 m_layout_size = m_storage.get<sint_t>(REC_NUM_BYTES);
101 // layout_rec_data_size
102 m_storage.advance(LAYOUT_REC_DATA_SIZE_BYTES);
104 for (int i = 0; i < m_layout_size; ++i) {
105 SclLayout& cur = m_layout_table[i];
106 decode_layout_record(cur, record_width);
108 #ifdef __SCL_TXT_DEBUG
109 put_layout_table(DECODE, m_layout_table);
115 decode_color(SclColor& color, int width) {
116 if (width <= 0) return;
118 color.r = m_storage.get<sint_t>(width);
119 color.g = m_storage.get<sint_t>(width);
120 color.b = m_storage.get<sint_t>(width);
121 color.a = m_storage.get<sint_t>(width);
123 void BinLayoutParser::
124 decode_layout_record(SclLayout& cur, const Layout_width& record_width) {
126 m_storage.get_str(&(cur.name), record_width.name, m_string_collector);
128 cur.display_mode = (SCLDisplayMode)m_storage.get<sint_t>(record_width.display_mode);
130 cur.style = (SCLLayoutStyle)m_storage.get<sint_t>(record_width.style);
132 cur.width = m_storage.get<sint_t>(record_width.width);
134 cur.height = m_storage.get<sint_t>(record_width.height);
136 cur.use_sw_button = m_storage.get<sint_t>(record_width.use_sw_button);
138 //use_magnifier_window
139 cur.use_magnifier_window = m_storage.get<sint_t>(record_width.use_magnifier_window);
142 cur.extract_background = m_storage.get<sint_t>(record_width.extract_background);
145 cur.key_width = m_storage.get<sint_t>(record_width.key_width);
147 cur.key_height = m_storage.get<sint_t>(record_width.key_height);
149 cur.key_spacing = m_storage.get<sint_t>(record_width.key_spacing);
151 cur.row_spacing = m_storage.get<sint_t>(record_width.row_spacing);
153 cur.use_sw_background = m_storage.get<sint_t>(record_width.use_sw_background);
155 decode_color(cur.bg_color, record_width.bg_color);
157 cur.bg_line_width = m_storage.get<float_t>(record_width.bg_line_width);
159 decode_color(cur.bg_line_color, record_width.bg_line_color);
162 cur.add_grab_left = m_storage.get<sint_t>(record_width.add_grab_left);
165 cur.add_grab_right = m_storage.get<sint_t>(record_width.add_grab_right);
167 cur.add_grab_top = m_storage.get<sint_t>(record_width.add_grab_top);
169 cur.add_grab_bottom = m_storage.get<sint_t>(record_width.add_grab_bottom);
171 for (int i = 0; i < SCL_BUTTON_STATE_MAX; ++i) {
172 m_storage.get_str(&(cur.image_path[i]), record_width.image_path, m_string_collector);
175 //key_background_image
176 for (int i = 0; i < SCL_SHIFT_STATE_MAX; ++i) {
177 for (int j = 0; j < SCL_BUTTON_STATE_MAX; ++j) {
178 m_storage.get_str(&(cur.key_background_image[i][j]), record_width.key_background_image, m_string_collector);
183 m_storage.get_str(&(cur.sound_style), record_width.sound_style, m_string_collector);
186 m_storage.get_str(&(cur.vibe_style), record_width.vibe_style, m_string_collector);
189 m_storage.get_str(&(cur.label_type), record_width.label_type, m_string_collector);
192 m_storage.get_str(&(cur.modifier_decorator), record_width.modifier_decorator, m_string_collector);