2 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * This file is part of the ug-memo-efl
5 * Written by Zhibin Zhou <zhibin.zhou@samsung.com>, Canjiang Lu <canjiang.lu@samsung.com>,
6 * Feng Li <feng.li@samsung.com>
8 * PROPRIETARY/CONFIDENTIAL
10 * This software is the confidential and proprietary information of
11 * SAMSUNG ELECTRONICS ("Confidential Information").
12 * You shall not disclose such Confidential Information and shall
13 * use it only in accordance with the terms of the license agreement
14 * you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no
15 * representations or warranties about the suitability
16 * of the software, either express or implied, including but not
17 * limited to the implied warranties of merchantability, fitness for a particular purpose, or non-
18 * infringement. SAMSUNG shall not be liable for any damages suffered by licensee as
19 * a result of using, modifying or distributing this software or its derivatives.
23 #include <Elementary.h>
25 #include <extended-elm.h>
27 #include <appcore-common.h>
28 #include <memo-assist.h>
29 #include <memo_string.h>
30 #include <memo-genlist.h>
32 static void _str_append_utf8(char *s, int size, const char *utf8)
35 content = elm_entry_utf8_to_markup(utf8);
36 RETIF(content == NULL);
37 sncat(s,size, content);
45 * @param [in] data user specified data
47 * @param [in] obj evas_object of elm_genlist_item
49 * @param [in] part part name in genlist group
60 char *memo_gl_label_get(void *data, Evas_Object *obj, const char *part)
62 gl_data_t *gld = (gl_data_t *)data;
63 char buf[MEMO_BUFFER_SIZE] = {0};
64 char input[MEMO_BUFFER_SIZE] = {0};
65 char output[MEMO_BUFFER_SIZE] = {0};
67 const char *pre = NULL;
69 if (!strcmp(part, "elm.text.date")) {
70 memo_time_format(buf, MEMO_BUFFER_SIZE, gld->mod_time);
72 } else if (!strcmp(part, "elm.slide.text.1")) {
73 if (gld->index == -1) {
74 return strdup(MEMO_I18N_WELCOME_TO_TIZEN_MEMO);
76 memo_data_t *md = memo_get_data(gld->index);
77 snprintf(input, MEMO_BUFFER_SIZE, "%s",
78 (md->comment == NULL ? md->content : md->comment)); /* limit input */
82 } else if (!strcmp(part, "elm.text")) {
83 if (gld->index == -1) {
84 return strdup(MEMO_I18N_WELCOME_TO_TIZEN_MEMO);
86 memo_data_t *md = memo_get_data(gld->index);
88 if (md->comment != NULL) {
89 snprintf(input, MEMO_BUFFER_SIZE, "%s", md->comment);
91 snprintf(input, MEMO_BUFFER_SIZE, "%s", md->content);
93 /* truncate to single line */
94 p = strstr(input, "\342\200\251");
96 input[p-input] = '\0';
98 /* font color information */
99 unsigned char *color = (unsigned char *)&md->font_color;
100 snprintf(output, MEMO_BUFFER_SIZE, "<color=#%02x%02x%02x>", color[2], color[1], color[0]);
101 /* append text information */
102 if (gld->search == NULL) {
103 _str_append_utf8(output, MEMO_BUFFER_SIZE, input);
106 /* search and composite */
107 p = (const char *)strcasestr(pre, gld->search);
109 /* append characters before matched string */
112 strncat(buf, pre, p-pre);
113 _str_append_utf8(output, MEMO_BUFFER_SIZE, buf);
116 sncat(output, MEMO_BUFFER_SIZE, "<color=#FF0000>");
118 strncat(buf, p, strlen(gld->search));
119 _str_append_utf8(output, MEMO_BUFFER_SIZE, buf);
120 sncat(output, MEMO_BUFFER_SIZE, "</color>");
121 /* set pointer after matched string */
122 pre = p+strlen(gld->search);
124 /* append remaining string */
125 _str_append_utf8(output, MEMO_BUFFER_SIZE, pre);
128 return strdup(output);
139 * @param [in] data user specified data
141 * @param [in] obj evas_object of elm_genlist_item
143 * @param [in] part part name in genlist group
154 Evas_Object *memo_gl_icon_get(void *data, Evas_Object *obj, const char *part)
156 gl_data_t *gld = (gl_data_t *)data;
157 char buf[MEMO_BUFFER_SIZE];
158 Evas_Object *eo = NULL;
160 if (!strcmp(part, "elm.swallow.doodle")) {
161 if (gld->has_doodle != 0) {
162 snprintf(buf, MEMO_BUFFER_SIZE, DOODLEDIR "/%d.png", gld->index);
163 eo = elm_icon_create(obj, buf);
165 } else if (!strcmp(part, "elm.swallow.check")) {
166 if (gld->index != -1) { /* only add checkbox for non-sentinel data, as required by CQ defect H0100123202 */
167 eo = elm_check_add(obj);
168 elm_check_state_pointer_set(eo, &gld->check);
169 if (gld->on_change != NULL) {
170 evas_object_smart_callback_add(eo, "changed", gld->on_change, gld);
173 } else if (!strcmp(part, "elm.slide.swallow.1")) {
174 eo = elm_button_create(obj, MEMO_I18N_DELETE, gld->on_delete, gld);
175 } else if (!strcmp(part, "elm.slide.swallow.2")) {
176 eo = elm_button_create(obj, MEMO_I18N_SHARE, gld->on_send, gld);
181 Eina_Bool memo_gl_state_get(void *data, Evas_Object *obj, const char *part)
191 * @param [in] data user specified data
193 * @param [in] obj evas_object of elm_genlist_item
204 void memo_gl_del(void *data, Evas_Object *obj)
206 gl_data_t *gld = (gl_data_t *)data;
216 * @param [in] itc handle of Elm_Genlist_Item_Class
229 void memo_gl_itc_init(Elm_Genlist_Item_Class *itc, const char *style)
231 itc->item_style = style;
232 itc->func.text_get = memo_gl_label_get;
233 itc->func.content_get = memo_gl_icon_get;
234 itc->func.state_get = memo_gl_state_get;
235 itc->func.del = memo_gl_del;
243 * @param [in] data handle of gl_data_t
245 * @param [in] md original memo record data
247 * @param [in] user_data user specified data
249 * @param [in] on_select callback function when genlist item is selected
260 void memo_gld_init(gl_data_t *data, memo_data_t *md, void *user_data, Evas_Smart_Cb on_select)
262 data->index = md->id;
263 data->has_doodle = md->has_doodle;
264 data->mod_time = md->modi_time;
265 data->on_select = on_select;
266 data->user_data = user_data;
270 * memo_gld_sentinel_create
274 * @param [in] user_data
285 gl_data_t * memo_gld_sentinel_create(void *user_data)
287 gl_data_t *data = SMALLOC(gl_data_t);
288 RETVIF(data == NULL, NULL);
290 data->mod_time = memo_get_binary_release_date();
291 data->user_data = user_data;