Delete as named ico_send_inputevent tool (It is contained in weston-plugin).
[profile/ivi/ico-uxf-homescreen.git] / src / statusbar / CicoCommonComponent.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 //==========================================================================
11 /**
12  *  @file   CicoCommonComponent.cpp
13  *
14  *  @brief  This file is definition of CicoCommonComponent class
15  */
16 //==========================================================================
17
18 #include <algorithm>
19 #include <cassert>
20
21 #include <ico_log.h>
22 #include "CicoCommonComponent.h"
23
24 //--------------------------------------------------------------------------
25 /**
26  *  @brief  default constructor
27  *
28  *  @param[in]  none
29  *  @return     none
30  */
31 //--------------------------------------------------------------------------
32 CicoCommonComponent::CicoCommonComponent()
33     : posx_(0), posy_(0), width_(0), height_(0)
34 {
35     ICO_TRA("CicoCommonComponent::CicoCommonComponent Enter");
36     ICO_TRA("CicoCommonComponent::CicoCommonComponent Leave");
37 }
38
39 //--------------------------------------------------------------------------
40 /**
41  *  @brief  destructor
42  *
43  *  param[in]   none
44  *  return      none
45  */
46 //--------------------------------------------------------------------------
47 CicoCommonComponent::~CicoCommonComponent()
48 {
49     ICO_TRA("CicoCommonComponent::~CicoCommonComponent Enter");
50     ICO_TRA("CicoCommonComponent::~CicoCommonComponent Leave");
51 }
52
53 //--------------------------------------------------------------------------
54 /**
55  *  @brief terminate component
56  *
57  *  @param[in]  none
58  *  @return     bool
59  *  @retval     true: success 
60  */
61 //--------------------------------------------------------------------------
62 bool
63 CicoCommonComponent::Terminate(void)
64 {
65     ICO_TRA("CicoCommonComponent::Terminate Enter");
66     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr;
67     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr_end;
68     for (itr = modulelist_.begin(); itr != itr_end; itr++) {
69         (*itr)->Terminate();
70     }
71
72     modulelist_.clear();
73     ICO_TRA("CicoCommonComponent::Terminate Leave");
74     return true;
75 }
76
77 //--------------------------------------------------------------------------
78 /**
79  *  @brief  show component
80  *
81  * @param[in]   none
82  * @return      none
83  */
84 //--------------------------------------------------------------------------
85 void
86 CicoCommonComponent::Show(void)
87 {
88     ICO_TRA("CicoCommonComponent::Show Enter");
89
90     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr;
91     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr_end;
92     itr_end = modulelist_.end();
93     for (itr = modulelist_.begin(); itr != itr_end; itr++) {
94         (*itr)->Show();
95     }
96
97     ICO_TRA("CicoCommonComponent::Show Leave");
98 }
99
100 //--------------------------------------------------------------------------
101 /**
102  *  @brief  hide component
103  *  @param[in]   none
104  *  @return      none
105   */
106 //--------------------------------------------------------------------------
107 void
108 CicoCommonComponent::Hide(void)
109 {
110     ICO_TRA("CicoCommonComponent::Hide Enter");
111     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr;
112     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr_end;
113     itr_end = modulelist_.end();
114     for (itr = modulelist_.begin(); itr != itr_end; itr++) {
115         (*itr)->Hide();
116     }
117     ICO_TRA("CicoCommonComponent::Hide Leave");
118 }
119
120 //--------------------------------------------------------------------------
121 /**
122  *  @brief  set position of component
123  *
124  *  @param [in] x   position of x
125  *  @param [in] y   position of y
126  *  @return     none
127  */
128 //--------------------------------------------------------------------------
129 void
130 CicoCommonComponent::SetPos(int x, int y)
131 {
132     ICO_TRA("CicoCommonComponent::SetPos Enter(x/y=%d/%d)", x, y);
133     int diffx = x - posx_;
134     int diffy = y - posy_;
135     posx_ = x;
136     posy_ = y;
137     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr;
138     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr_end;
139     itr_end = modulelist_.end();
140     for (itr = modulelist_.begin(); itr != itr_end; itr++) {
141         (*itr)->Move(diffx, diffy);
142     }
143     ICO_TRA("CicoCommonComponent::SetPos Leave");
144 }
145
146 //--------------------------------------------------------------------------
147 /**
148  *  @brief  set size of component
149  *
150  *  @param [in] w   width of component
151  *  @param [in] h   height of component
152  *  @return     none
153 */
154 //--------------------------------------------------------------------------
155 void
156 CicoCommonComponent::SetSize(int w, int h)
157 {
158     ICO_TRA("CicoCommonComponent::SetSize Enter(w/h=%d/%d)", w, h);
159     double rate_w = width_ / w;
160     double rate_h = height_ / h;
161     width_ = w;
162     height_ = h;
163     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr;
164     std::list<std::shared_ptr<CicoCommonModule>>::iterator itr_end;
165     itr_end = modulelist_.end();
166     for (itr = modulelist_.begin(); itr != itr_end; itr++) {
167         (*itr)->Reallocate(posx_, posy_, rate_w, rate_h);
168 }
169     ICO_TRA("CicoCommonComponent::SetSize Leave");
170 }
171
172 //--------------------------------------------------------------------------
173 /**
174  *  @brief  pack module
175  *
176  *  @param [in] module  add module object
177  *  @return     none 
178 */
179 //--------------------------------------------------------------------------
180 void
181 CicoCommonComponent::PackModule(std::shared_ptr<CicoCommonModule> module)
182 {
183     modulelist_.push_back(module);
184 }
185
186 //--------------------------------------------------------------------------
187 /**
188  *  @brief  unpack module
189  *
190  *  @param [in] module  remove module object
191  *  @return     none
192  */
193 //--------------------------------------------------------------------------
194 void
195 CicoCommonComponent::UnpackModule(std::shared_ptr<CicoCommonModule> module)
196 {
197     modulelist_.remove(module);
198 }
199 // vim: set expandtab ts=4 sw=4: