3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.tizenopensource.org/license
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include <Elementary.h>
23 #include <ui-gadget-module.h>
25 #include <memo_string.h>
26 #include <extended-elm.h>
27 #include <supplement.h>
28 #include <memo-assist.h>
29 #include <memo-genlist.h>
30 #include <memo-assist.h>
32 #include <memo_autolink.h>
35 typedef struct __detail_view_t {
37 Evas_Object *navigator;
38 Evas_Object *ctrl_bar;
39 Evas_Object *body_main;
43 /* add more variables here */
47 static void _on_quit(void *data, Evas_Object *obj, void *event_info)
50 detail_view_t *dv = (detail_view_t *)data;
51 ug_data_t *ugd = dv->ugd;
52 ug_destroy_me(ugd->ug);
55 static void _on_entry_resize(void *data, Evas_Object *obj, void *event_info)
57 LOGD("---------------_on_entry_resize");
58 detail_view_t *dv = (detail_view_t *)data;
59 elm_entry_entry_set(dv->entry, dv->content);
63 static void _create_detail_layout(detail_view_t *dv)
65 ug_data_t *ugd = dv->ugd;
66 Evas_Object *content = NULL;
67 memo_data_t *md = memo_get_data(dv->index);
69 /* add navigationbar */
70 dv->navigator = elm_naviframe_add(ugd->base);
73 dv->body_main = elm_layout_create(dv->navigator, EDJ_FILE, "detail_frame");
76 memo_time_format(ugd->buf, MEMO_BUFFER_SIZE, md->modi_time);
77 edje_object_part_text_set(_EDJ(dv->body_main), "elm.text.date", ugd->buf);
80 snprintf(ugd->buf, MEMO_BUFFER_SIZE, "/opt/apps/org.tizen.memo/data/doodle/%d.png", (int)md->id);
81 content = elm_swallowed_icon(dv->body_main, "elm.swallow.content", ugd->buf);
83 char buf[MEMO_BUFFER_SIZE];
85 autolink_add_anchor(elm_entry_utf8_to_markup
87 unsigned char *color = (unsigned char *)&md->font_color;
88 snprintf(buf, MEMO_BUFFER_SIZE,
89 "<font_size=%d><color=#%02x%02x%02x>",
90 md->font_size, color[2], color[1], color[0]);
91 g_string_prepend(text, buf);
93 Evas_Object *sc = NULL;
94 sc = elm_swallowed_scroller(dv->body_main, "elm.swallow.content");
95 content = elm_entry_create(dv->body_main, text->str);
96 dv->content = strdup(text->str);
97 evas_object_smart_callback_add(content, "anchor,clicked", autolink_anchor_clicked_cb, ug_get_parent_layout(ugd->ug));
98 evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99 evas_object_size_hint_align_set(content, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
100 elm_entry_editable_set(content, EINA_FALSE);
101 elm_entry_autocapital_type_set(content, ELM_AUTOCAPITAL_TYPE_SENTENCE);
102 elm_object_content_set(sc, content);
104 evas_object_render_flush_hook(dv->entry, _on_entry_resize, dv);
106 g_string_free(text, TRUE);
108 edje_object_signal_emit(_EDJ(dv->body_main), "sig_text_mode", "");
114 Elm_Object_Item *navi_it = elm_naviframe_item_push(dv->navigator, MEMO_I18N_MEMO, NULL, NULL, dv->body_main, NULL);
115 Evas_Object *ctrl_bar = memo_controlbar_add(dv->navigator);
116 elm_toolbar_item_append(ctrl_bar, NULL, MEMO_I18N_QUIT, _on_quit, dv);
117 elm_object_item_part_content_set(navi_it, "controlbar", ctrl_bar);
120 void *memo_load_detail_view(ug_data_t *ugd, service_h service)
122 detail_view_t *dv = SMALLOC(detail_view_t);
123 RETVIF(dv == NULL, NULL);
128 service_get_extra_data(service, "index", &str);
130 dv->index = atoi(str);
138 _create_detail_layout(dv);
139 elm_object_part_content_set(ugd->base, "elm.swallow.content", dv->navigator);