2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
10 //==========================================================================
12 * @file CicoComponentimplementation.cpp
14 * @brief This file is implimentation of CicoStatusBarClockComponent class
15 * and CicoNotificationPanelComponent class
17 //==========================================================================
24 #include "CicoComponentImplementation.h"
27 #define IMG_DIR "/usr/apps/org.tizen.ico.statusbar/res/images/"
28 #define THEME_PATH "/usr/apps/org.tizen.ico.statusbar/res/themes/statusbar.edj"
30 /* Theme group name */
31 #define THEME_CLOCK_NAME "ClockImage"
32 #define THEME_NOTIFICATION_NAME "Notification"
34 // set image file path of clock
35 static const char *clock_image_path[] = {
48 IMG_DIR"time_ten.png",
52 /* define of special image index */
53 #define TIME_IMAGE_AM (10)
54 #define TIME_IMAGE_PM (11)
55 #define TIME_IMAGE_SP (12)
57 /* array of clock object name */
58 static const char *clock_image_object[] = {
68 /*--------------------------------------------------------------------------*/
70 * @brief default constructor
75 /*--------------------------------------------------------------------------*/
76 CicoStatusBarClockComponent::CicoStatusBarClockComponent()
80 /*--------------------------------------------------------------------------*/
87 /*--------------------------------------------------------------------------*/
88 CicoStatusBarClockComponent::~CicoStatusBarClockComponent()
92 /*--------------------------------------------------------------------------*/
94 * @brief initialize of clock component
96 * @param[in] windowobj
99 * @return true: success false: failed
101 /*--------------------------------------------------------------------------*/
103 CicoStatusBarClockComponent::Initialize(Evas_Object *windowobj, Evas *evas)
105 ICO_TRA("CicoStatusBarClockComponent::Initialize Enter");
107 /* initialize display clock image */
109 for(i=0; i<CLOCK_OBJECT_COUNT; i++ ){
110 last_clock_image[i] = -1;
113 /* make TimeImage object */
114 evasobj_=edje_object_add(evas);
115 if (!edje_object_file_set(evasobj_, THEME_PATH, THEME_CLOCK_NAME )) {
116 Edje_Load_Error err = edje_object_load_error_get(evasobj_);
117 const char *errmsg = edje_load_error_str(err);
118 ICO_ERR("could not load 'main' from statusbar.edj: %s",
123 /* move TimeImage to UpRight of window */
124 /* Do not need this process , if positiong of UpRight enabled with .EDC file */
126 Evas_Coord w_width=0;
127 Evas_Object* obj = NULL;
128 evas_object_geometry_get( windowobj, &x, &y, &w_width, &h );
129 evas_object_resize( evasobj_, w_width, h );
130 obj = (Evas_Object*)edje_object_part_object_get(evasobj_,"MIN1_img" );
131 evas_object_geometry_get( obj, &x, &y, &w, &h );
132 Evas_Coord offset = w_width - x - w;
134 for ( i=0; i<CLOCK_OBJECT_COUNT; i++ ) {
135 obj = (Evas_Object*)edje_object_part_object_get(
136 evasobj_, clock_image_object[i] );
138 evas_object_geometry_get( obj, &x, &y, &w, &h );
139 evas_object_move( obj, x+offset , y);
143 /* initial display */
147 ICO_TRA("CicoStatusBarClockComponent::Initialize Leave");
151 /*--------------------------------------------------------------------------*/
153 * @brief update of clock component
156 * @return true: success false: failed
158 /*--------------------------------------------------------------------------*/
160 CicoStatusBarClockComponent::Update()
162 //ICO_TRA("CicoStatusBarClockComponent::Update Enter");
163 if (evasobj_ == NULL) {
168 nowtime = std::time(NULL);
169 std::tm *tm = std::localtime(&nowtime);
170 int min = tm->tm_min;
171 int hour = tm->tm_hour;
173 /* Make now clock image tabel */
174 int now_clock_image[CLOCK_OBJECT_COUNT];
176 now_clock_image[0]=TIME_IMAGE_PM;
179 now_clock_image[0]=TIME_IMAGE_AM;
181 time_t hour_m = hour % 12;
182 now_clock_image[1]=hour_m / 10;
183 now_clock_image[2]=hour_m % 10;
184 now_clock_image[3]=TIME_IMAGE_SP;
185 now_clock_image[4]=min / 10;
186 now_clock_image[5]=min % 10;
188 /* Set now clock image */
190 for ( i=0; i<CLOCK_OBJECT_COUNT; i++ ) {
192 /* if now clock image different last clock */
193 if ( now_clock_image[i] != last_clock_image[i] ) {
195 Evas_Object* obj = NULL;
196 obj = (Evas_Object*)edje_object_part_object_get(
197 evasobj_,clock_image_object[i] );
199 ICO_DBG("SetNotification image set[%s][%s]",clock_image_object[i],clock_image_path[i]);
200 evas_object_image_file_set(obj, clock_image_path[now_clock_image[i]], NULL);
203 ICO_DBG("SetNotification image set error[object not found]" );
205 last_clock_image[i] = now_clock_image[i];
209 //ICO_TRA("CicoStatusBarClockComponent::Update Leave(true)");
213 /*--------------------------------------------------------------------------*/
215 * @brief get clock start position
217 * @param[out] x X axis
218 * @param[out] y Y axis
219 * @return true: success false: failed
221 /*--------------------------------------------------------------------------*/
223 CicoStatusBarClockComponent::GetClockStart( Evas_Coord *x_ret, Evas_Coord *y_ret)
225 ICO_TRA("CicoStatusBarClockComponent::GetClockStart Enter");
226 if (evasobj_ == NULL) {
227 ICO_TRA("CicoStatusBarClockComponent::GetClockStart Leave(false)");
231 Evas_Object* obj = NULL;
232 obj = (Evas_Object*)edje_object_part_object_get(
233 evasobj_, clock_image_object[0] );
235 ICO_TRA("CicoStatusBarClockComponent::GetClockStart Leave(false)");
240 evas_object_geometry_get( obj, &x, &y, &w, &h );
244 ICO_TRA("CicoStatusBarClockComponent::GetClockStart Leave(true)");
248 /*--------------------------------------------------------------------------*/
250 * @brief default constructor
255 /*--------------------------------------------------------------------------*/
256 CicoNotificationPanelComponent::CicoNotificationPanelComponent()
261 /*--------------------------------------------------------------------------*/
268 /*--------------------------------------------------------------------------*/
269 CicoNotificationPanelComponent::~CicoNotificationPanelComponent()
273 /*--------------------------------------------------------------------------*/
275 * @brief initialize of notification component
278 * @return true: success false: failed
280 /*--------------------------------------------------------------------------*/
282 CicoNotificationPanelComponent::Initialize(Evas_Object *window, Evas *evas)
284 ICO_TRA("CicoNotificationPanelComponent::Initialize Enter");
286 if (evasobj_ != NULL) {
287 ICO_TRA("CicoNotificationPanelComponent::Initialize Levae(false)");
291 if (window == NULL) {
292 ICO_TRA("CicoNotificationPanelComponent::Initialize Levae(false)");
296 /* create Notification object */
297 ICO_DBG("Create Text Module end");
298 evasobj_=edje_object_add(evas);
299 if (!edje_object_file_set(evasobj_, THEME_PATH, THEME_NOTIFICATION_NAME)) {
300 Edje_Load_Error err = edje_object_load_error_get(evasobj_);
301 const char *errmsg = edje_load_error_str(err);
302 ICO_ERR("could not load 'main' from statusbar.edj: %s",
307 evas_object_geometry_get( window, &x, &y, &w, &h );
308 evas_object_resize( evasobj_, w, h );
310 /* initial display */
314 ICO_TRA("CicoNotificationPanelComponent::Initialize Levae(true)");
318 /*--------------------------------------------------------------------------*/
320 * @brief set notification panel
323 * @param[in] iconpaht
324 * @param[in] soundpath
325 * @return true: success false: failed
327 /*--------------------------------------------------------------------------*/
329 CicoNotificationPanelComponent::SetNotification(const char *text,
330 const char *iconpath,
331 const char *soundpath)
333 ICO_TRA("CicoNotificationPanelComponent::SetNotification Enter"
334 "(text=%s icon=%s sound=%s)", text, iconpath, soundpath);
337 if (iconpath != NULL) {
338 Evas_Object* obj = NULL;
339 obj = (Evas_Object*)edje_object_part_object_get(
340 evasobj_, "noti_image");
342 ICO_DBG("SetNotification image set[%s]",iconpath);
343 evas_object_image_file_set(obj, iconpath, NULL);
346 ICO_DBG("SetNotification image set error[object not found]" );
357 ICO_TRA("CicoNotificationPanelComponent::SetNotification Leave");
360 //--------------------------------------------------------------------------
362 * @brief set text to Content_text
364 * @return true: success
366 //--------------------------------------------------------------------------
368 CicoNotificationPanelComponent::SetText(const char *text)
370 ICO_TRA("CicoNotificationPanelComponent::SetText Enter(text=%s)", text? text:"NULL");
371 if ( text == NULL ) {
372 edje_object_part_text_set(evasobj_, "content_text", "");
375 edje_object_part_text_set(evasobj_, "content_text", text);
377 ICO_TRA("CicoNotificationPanelComponent::SetText Leave");
381 //--------------------------------------------------------------------------
383 * @brief set text to Content_text
385 * @return true: success
387 //--------------------------------------------------------------------------
389 CicoNotificationPanelComponent::SetTextEndPosition( Evas_Coord x_end, Evas_Coord y_end)
391 ICO_TRA("CicoNotificationPanelComponent::SetTextEndPosition Enter(%d,%d)",x_end,y_end);
393 if (evasobj_ == NULL) {
394 ICO_TRA("CicoNotificationPanelComponent::SetTextEndPosition Leave(false)");
398 Evas_Object* obj = NULL;
399 obj = (Evas_Object*)edje_object_part_object_get(
400 evasobj_, "content_text" );
402 ICO_TRA("CicoNotificationPanelComponent::SetTextEndPosition Leave(false)");
407 evas_object_geometry_get( obj, &x, &y, &w, &h );
408 evas_object_resize( evasobj_, x_end, h );
409 ICO_TRA("CicoNotificationPanelComponent::text width %d -> %d",w, x_end - x -1);
410 evas_object_resize( obj, x_end - x -1, h );
411 edje_object_calc_force( obj );
413 ICO_TRA("CicoNotificationPanelComponent::SetTextEndPosition Leave" );
416 // vim: set expandtab ts=4 sw=4: