Reload xml files when resolution gets changed
[platform/core/uifw/libscl-ui.git] / xml2binary / encode_magnifier_configure.cpp
1 /*
2  * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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 "encode_magnifier_configure.h"
19 #include "xmlresource.h"
20 #include "resource_storage_impl.h"
21 #include "put_record.h"
22 #include "_auto_metadata.h"
23 using namespace xmlresource;
24 static void
25 encode_magnifier_configure_record(ResourceStorage& storage, const PSclMagnifierWndConfigure cur, const Magnifier_configure_width& record_width) {
26     //style
27     storage.put<sint_t>(cur->style, record_width.style);
28     //width
29     storage.put<sint_t>(cur->width, record_width.width);
30     //height
31     storage.put<sint_t>(cur->height, record_width.height);
32     //label_area_record.left
33     storage.put<sint_t>(cur->label_area_rect.left, record_width.label_area_rect);
34     //label_area_rect.right
35     storage.put<sint_t>(cur->label_area_rect.right, record_width.label_area_rect);
36
37     //label_area_record.top
38     storage.put<sint_t>(cur->label_area_rect.top, record_width.label_area_rect);
39     //label_area_rect.bottom
40     storage.put<sint_t>(cur->label_area_rect.bottom, record_width.label_area_rect);
41     //bg_image_path
42     storage.encode_string(cur->bg_image_path, record_width.bg_image_path);
43
44     //bg_shift_image_path
45     storage.encode_string(cur->bg_shift_image_path, record_width.bg_shift_image_path);
46
47     //bg_shift_lock_image_path
48     storage.encode_string(cur->bg_shift_lock_image_path, record_width.bg_shift_lock_image_path);
49
50     //bg_long_key_image_path
51     storage.encode_string(cur->bg_long_key_image_path, record_width.bg_long_key_image_path);
52     //use_actual_window
53     storage.put<sint_t>(cur->use_actual_window, record_width.use_actual_window);
54     //label_name
55     storage.encode_string(cur->label_type, record_width.label_type);
56     //padding_x
57     storage.put<sint_t>(cur->padding_x, record_width.padding_x);
58     //padding_y
59     storage.put<sint_t>(cur->padding_y, record_width.padding_y);
60     //show_shift_label
61     storage.put<sint_t>(cur->show_shift_label, record_width.show_shift_label);
62 }
63
64 int
65 encode_magnifier_configure_file(ResourceStorage& storage, IMetaData_Helper& md_helper) {
66     int init_size = storage.get_size();
67
68     XMLResource *xmlresource = XMLResource::get_instance();
69     PSclMagnifierWndConfigure magnifierConfigure = xmlresource->get_magnifier_configure();
70
71
72 #ifdef __SCL_TXT_DEBUG
73     put_magnifier_wnd_configure(ENCODE, *magnifierConfigure);
74
75 #endif
76     Magnifier_configure_width record_width;
77     set_magnifier_configure_width(md_helper, record_width);
78
79     storage.reserve(8);
80     encode_magnifier_configure_record(storage, magnifierConfigure, record_width);
81
82     int advance_size = storage.get_size() - init_size;
83
84     storage.random_put<sint_t>(advance_size, 8, init_size);
85
86     return storage.get_size();
87 }
88
89 int
90 encode_magnifier_configure_file(const char* file, int& offset, IMetaData_Helper& md_helper) {
91     if (!file) return 0;
92
93
94     ResourceStorage storage;
95     encode_magnifier_configure_file(storage, md_helper);
96     storage.toFile(file, offset);
97
98     return storage.get_size();
99 }
100
101 int
102 encode_magnifier_configure_file(const char* file, IMetaData_Helper& md_helper) {
103     if (!file) return 0;
104
105
106     ResourceStorage storage;
107     encode_magnifier_configure_file(storage, md_helper);
108     storage.toFile(file);
109
110     return storage.get_size();
111 }