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 "resource_storage_impl.h"
19 #include "encode_label_properties_frame.h"
21 #include "xmlresource.h"
22 #include "put_record.h"
23 #include "_auto_metadata.h"
24 using namespace xmlresource;
26 static void _encode_color(ResourceStorage& storage, const SclColor& color, int width) {
27 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);
35 encode_label_properties_record(ResourceStorage& storage, const PSclLabelProperties cur, const Label_properties_record_width& record_width) {
36 if (cur == NULL) return;
39 storage.encode_string(cur->label_type, record_width.label_type);
42 storage.encode_string(cur->font_name, record_width.font_name);
45 storage.put<sint_t>(cur->font_size, record_width.font_size);
48 for (int i = 0; i < SCL_SHIFT_STATE_MAX; ++i) {
49 for (int j = 0; j < SCL_BUTTON_STATE_MAX; ++j) {
50 _encode_color(storage, cur->font_color[i][j], record_width.font_color);
55 storage.put<sint_t>(cur->alignment, record_width.alignment);
58 storage.put<sint_t>(cur->padding_x, record_width.padding_x);
61 storage.put<sint_t>(cur->padding_y, record_width.padding_y);
64 storage.put<sint_t>(cur->inner_width, record_width.inner_width);
67 storage.put<sint_t>(cur->inner_height, record_width.inner_height);
70 storage.put<sint_t>(cur->shadow_distance, record_width.shadow_distance);
73 storage.put<sint_t>(cur->shadow_direction, record_width.shadow_direction);
76 for (int i = 0; i < SCL_SHIFT_STATE_MAX; ++i) {
77 for (int j = 0; j < SCL_BUTTON_STATE_MAX; ++j) {
78 _encode_color(storage, cur->shadow_color[i][j], record_width.shadow_color);
84 encode_label_properties_frame_file(ResourceStorage& storage, IMetaData_Helper& md_helper) {
85 int init_size = storage.get_size();
88 const int _SIZE_WIDTH = 4;
90 XMLResource *xmlresource = XMLResource::get_instance();
91 PSclLabelPropertiesTable labelPropertiesFrame = xmlresource->get_label_properties_frame();
93 #ifdef __SCL_TXT_DEBUG
94 put_label_properties_frame(ENCODE, labelPropertiesFrame);
97 int size = xmlresource->get_labelproperty_size();
98 int maxj = MAX_SIZE_OF_LABEL_FOR_ONE;
102 storage.put<sint_t>(size, _SIZE_WIDTH);
103 storage.put<sint_t>(maxj, _SIZE_WIDTH);
105 Label_properties_record_width record_width;
106 set_label_properties_record_width(md_helper, record_width);
107 for ( int i = 0; i < size; ++i ) {
108 for ( int j = 0; j < maxj; ++j ) {
109 SclLabelProperties cur = labelPropertiesFrame[i][j];
110 encode_label_properties_record(storage, &cur, record_width);
114 int advance_size = storage.get_size() - init_size;
115 storage.random_put<sint_t>(advance_size, 8, init_size);
117 return storage.get_size();
121 encode_label_properties_frame_file(const char* file, int& offset, IMetaData_Helper& md_helper) {
125 ResourceStorage storage;
126 encode_label_properties_frame_file(storage, md_helper);
127 storage.toFile(file, offset);
129 return storage.get_size();
133 encode_label_properties_frame_file(const char* file, IMetaData_Helper& md_helper) {
137 ResourceStorage storage;
138 encode_label_properties_frame_file(storage, md_helper);
139 storage.toFile(file);
141 return storage.get_size();