Tizen 2.0 Release
[profile/ivi/libscl-ui.git] / binary_xmlresource / autopopup_configure_bin_parser.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 "autopopup_configure_bin_parser.h"
19 #include <assert.h>
20 using namespace std;
21 #include "put_record.h"
22
23 AutoPopup_Configure_Bin_Parser* AutoPopup_Configure_Bin_Parser::m_instance = NULL;
24
25 AutoPopup_Configure_Bin_Parser::AutoPopup_Configure_Bin_Parser() {
26     memset((void*)&m_autopopup_configure, 0x00, sizeof(SclAutoPopupConfigure));
27 }
28
29 AutoPopup_Configure_Bin_Parser::~AutoPopup_Configure_Bin_Parser() {
30 }
31
32 AutoPopup_Configure_Bin_Parser* AutoPopup_Configure_Bin_Parser::get_instance() {
33     if (m_instance == NULL) {
34         m_instance = new AutoPopup_Configure_Bin_Parser();
35     }
36     return m_instance;
37 }
38
39 void
40 AutoPopup_Configure_Bin_Parser::decode_color(SclColor& color, int width) {
41     if (width <= 0) return;
42
43     color.r = m_storage.get<sint_t>(width);
44     color.g = m_storage.get<sint_t>(width);
45     color.b = m_storage.get<sint_t>(width);
46     color.a = m_storage.get<sint_t>(width);
47 }
48
49 void AutoPopup_Configure_Bin_Parser::init(const FileStorage& storage, int offset, int size, IParserInfo_Provider* parser_info_provider) {
50     m_storage.set_str_provider(parser_info_provider);
51     m_storage.get_storage(storage, offset, size);
52     this->parser_info_provider = parser_info_provider;
53
54     parsing_autopopup_configure();
55 }
56
57 void AutoPopup_Configure_Bin_Parser::parsing_autopopup_configure() {
58     Autopopup_configure_width record_width;
59     set_autopopup_configure_width(*parser_info_provider, record_width);
60
61     PSclAutoPopupConfigure cur = &m_autopopup_configure;
62
63     // skip data_size
64     m_storage.advance(8);
65
66     //bg_image_path
67     m_storage.get_str(&(cur->bg_image_path), record_width.bg_image_path, m_string_collector);
68
69     //bg_color
70     decode_color(cur->bg_color, record_width.bg_color);
71     //double value
72         cur->bg_line_width = m_storage.get<float_t>(record_width.bg_line_width);
73
74     //bg_line_color
75         decode_color(cur->bg_line_color, record_width.bg_line_color);
76
77     //bg_padding
78     cur->bg_padding = m_storage.get<sint_t>(record_width.bg_padding);
79
80     //button_image_path
81     for (int i = 0; i < SCL_BUTTON_STATE_MAX; ++i) {
82         m_storage.get_str(&(cur->button_image_path[i]), record_width.button_image_path, m_string_collector);
83     }
84
85     //sw_button_style
86     cur->sw_button_style = m_storage.get<sint_t>(record_width.sw_button_style);
87
88     //button_width
89     cur->button_width = m_storage.get<sint_t>(record_width.button_width);
90
91     //button_height
92     cur->button_height = m_storage.get<sint_t>(record_width.button_height);
93
94     //button_spacing
95     cur->button_spacing = m_storage.get<sint_t>(record_width.button_spacing);
96
97     m_storage.get_str(&(cur->label_type), record_width.label_type, m_string_collector);
98
99     for (int i = 0; i < MAX_WND_DECORATOR; ++i) {
100         m_storage.get_str(&(cur->decoration_image_path[i]), record_width.decoration_image_path, m_string_collector);
101     }
102
103     //decoration_size
104     cur->decoration_size = m_storage.get<sint_t>(record_width.decoration_size);
105
106     //max_column
107     cur->max_column = m_storage.get<sint_t>(record_width.max_column);
108
109     //add_grab_left
110     cur->add_grab_left = m_storage.get<sint_t>(record_width.add_grab_left);
111
112     //add_grab_right
113     cur->add_grab_right = m_storage.get<sint_t>(record_width.add_grab_right);
114
115     //add_grab_top
116     cur->add_grab_top = m_storage.get<sint_t>(record_width.add_grab_top);
117
118     //add_grab_bottom
119     cur->add_grab_bottom = m_storage.get<sint_t>(record_width.add_grab_bottom);
120 #ifdef __SCL_TXT_DEBUG
121     put_autopopup_configure(DECODE, m_autopopup_configure);
122 #endif
123 }
124
125 PSclAutoPopupConfigure AutoPopup_Configure_Bin_Parser::get_autopopup_configure() {
126     return &m_autopopup_configure;
127 }