82ce6c52e206af5994def24c45d27d71aa7e557a
[profile/ivi/ico-uxf-homescreen.git] / src / statusbar / CicoCommonWindow.cpp
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 #include <algorithm>
11
12 #include <ico_log.h>
13 #include "CicoCommonWindow.h"
14
15 //--------------------------------------------------------------------------
16 /**
17  *  @brief  default constructor
18  *
19  *  @param[in]  none
20  *  @return     none
21  */
22 //--------------------------------------------------------------------------
23 CicoCommonWindow::CicoCommonWindow()
24     : window_(NULL), windowobj_(NULL),
25       posx_(0), posy_(0), width_(0), height_(0)
26 {
27 }
28
29 //--------------------------------------------------------------------------
30 /**
31  *  @brief  destructor
32  *
33  *  @param[in]  none
34  *  @return     none
35  */
36 //--------------------------------------------------------------------------
37 CicoCommonWindow::~CicoCommonWindow()
38 {
39 }
40
41 //--------------------------------------------------------------------------
42 /**
43  *  @brief  terminate the window
44  *
45  *  @param[in]  none
46  *  @return true on success, false on error
47  */
48 //--------------------------------------------------------------------------
49 bool
50 CicoCommonWindow::Terminate(void)
51 {
52     ICO_TRA("CicoCommonWindow::Terminate Enter");
53     std::list<CicoCommonComponent*>::iterator itr, itr_end;
54     itr_end = componentlist_.end();
55     for (itr = componentlist_.begin(); itr != itr_end; itr++) {
56         delete (*itr);
57     }
58     componentlist_.clear();
59     ICO_TRA("CicoCommonWindow::Terminate Leave");
60     return true;
61 }
62
63 //--------------------------------------------------------------------------
64 /**
65  *  @brief  show the window
66  *
67  *  @param[in]  none
68  *  @return     none
69  */
70 //--------------------------------------------------------------------------
71 void
72 CicoCommonWindow::Show(void)
73 {
74     ICO_TRA("CicoCommonWindow::Show Enter");
75     ecore_evas_show(window_);
76     if (windowobj_ != NULL) {
77         evas_object_show(windowobj_);
78         std::list<CicoCommonComponent*>::iterator itr, itr_end;
79         itr_end = componentlist_.end();
80         for (itr = componentlist_.begin(); itr != itr_end; itr++) {
81             (*itr)->Show();
82         }
83     }
84     ICO_TRA("CicoCommonWindow::Show Leave");
85 }
86
87 //--------------------------------------------------------------------------
88 /**
89  *  @brief  hide the window
90  *
91  *  @param[in]  none
92  *  @return     none
93  */
94 //--------------------------------------------------------------------------
95 void
96 CicoCommonWindow::Hide(void)
97 {
98     ICO_TRA("CicoCommonWindow::Hide Enter");
99     ecore_evas_hide(window_);
100     if (windowobj_ != NULL) {
101         evas_object_hide(windowobj_);
102         std::list<CicoCommonComponent*>::iterator itr, itr_end;
103         itr_end = componentlist_.end();
104         for (itr = componentlist_.begin(); itr != itr_end; itr++) {
105             (*itr)->Hide();
106         }
107     }
108     ICO_TRA("CicoCommonWindow::Show Enter");
109 }
110
111 //--------------------------------------------------------------------------
112 /**
113  *  @brief  set position of the window
114  *
115  *  @param[in]  x   position x
116  *  @param[in]  y   position y
117  *  @return     none
118  */
119 //--------------------------------------------------------------------------
120 void
121 CicoCommonWindow::SetPos(int x, int y)
122 {
123     posx_ = x;
124     posy_ = y;
125     ecore_evas_move(window_, posx_, posy_);
126     if (windowobj_ != NULL) {
127         evas_object_move(windowobj_, posx_, posy_);
128         std::list<CicoCommonComponent*>::iterator itr, itr_end;
129         itr_end = componentlist_.end();
130         for (itr = componentlist_.begin(); itr != itr_end; itr++) {
131             (*itr)->SetPos(posx_, posy_);
132         }
133     }
134 }
135
136 //--------------------------------------------------------------------------
137 /**
138  *  @brief  set size of the window
139  *
140  *  @param[in]  w   window width
141  *  @param[in]  h   window height
142  *  @return     none
143  */
144 //--------------------------------------------------------------------------
145 void
146 CicoCommonWindow::SetSize(int w, int h)
147 {
148     width_ = w;
149     height_ = h;
150     ecore_evas_resize(window_, width_, height_);
151     if (windowobj_ != NULL) {
152         evas_object_resize(windowobj_, width_, height_);
153         std::list<CicoCommonComponent*>::iterator itr, itr_end;
154         itr_end = componentlist_.end();
155         for (itr = componentlist_.begin(); itr != itr_end; itr++) {
156             (*itr)->SetSize(width_, height_);
157         }
158     }
159 }
160
161 //--------------------------------------------------------------------------
162 /**
163  *  @brief  set component
164  *
165  *  @param [in] component   the object of component
166  *  @return     none
167  */
168 //--------------------------------------------------------------------------
169 void
170 CicoCommonWindow::SetComponent(CicoCommonComponent *component)
171 {
172     componentlist_.push_back(component);
173 }
174
175 //--------------------------------------------------------------------------
176 /**
177  *  @brief  unset component
178  *
179  *  @param [in] component   the object of component
180  *  @return     none
181  */
182 //--------------------------------------------------------------------------
183 void
184 CicoCommonWindow::UnsetComponent(CicoCommonComponent *component)
185 {
186     componentlist_.remove(component);
187 }
188 // vim: set expandtab ts=4 sw=4: