3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.1 (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://floralicense.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 */
48 static void _on_quit(void *data, Evas_Object *obj, void *event_info)
51 detail_view_t *dv = (detail_view_t *)data;
52 ug_data_t *ugd = dv->ugd;
53 ug_destroy_me(ugd->ug);
56 static void _on_entry_resize(void *data, Evas_Object *obj, void *event_info)
58 LOGD("---------------_on_entry_resize");
59 detail_view_t *dv = (detail_view_t *)data;
60 elm_entry_entry_set(dv->entry, dv->content);
64 static void _create_text_viewer_layout(detail_view_t *dv)
66 dv->body_main = elm_layout_create(dv->navigator, EDJ_FILE, "detail_frame");
68 memo_time_format(dv->ugd->buf, MEMO_BUFFER_SIZE, dv->md->modi_time);
69 edje_object_part_text_set(_EDJ(dv->body_main), "elm.text.date", dv->ugd->buf);
72 char buf[MEMO_BUFFER_SIZE];
74 autolink_add_anchor(elm_entry_utf8_to_markup
76 unsigned char *color = (unsigned char *)&md->font_color;
77 snprintf(buf, MEMO_BUFFER_SIZE,
78 "<font_size=%d><color=#%02x%02x%02x>",
79 md->font_size, color[2], color[1], color[0]);
80 g_string_prepend(text, buf);
81 g_string_free(text, TRUE);
84 char * markup = elm_entry_utf8_to_markup
87 Evas_Object *sc = NULL;
88 sc = elm_swallowed_scroller(dv->body_main, "elm.swallow.content");
89 Evas_Object * content = elm_entry_create(dv->body_main, markup);
90 dv->content = strdup(markup);
92 //evas_object_smart_callback_add(content, "anchor,clicked", autolink_anchor_clicked_cb, ug_get_parent_layout(ugd->ug));
93 evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
94 evas_object_size_hint_align_set(content, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
95 elm_entry_editable_set(content, EINA_FALSE);
96 elm_entry_autocapital_type_set(content, ELM_AUTOCAPITAL_TYPE_SENTENCE);
97 elm_object_content_set(sc, content);
99 evas_object_render_flush_hook(dv->entry, _on_entry_resize, dv);
101 edje_object_signal_emit(_EDJ(dv->body_main), "sig_text_mode", "");
104 static void _create_doodle_viewer_layout(detail_view_t *dv)
106 dv->body_main = elm_layout_create(dv->navigator, EDJ_FILE, "doodle_viewer");
109 memo_time_format(dv->ugd->buf, MEMO_BUFFER_SIZE, dv->md->modi_time);
110 edje_object_part_text_set(elm_layout_edje_get(dv->body_main), "elm.text.date", dv->ugd->buf);
113 snprintf(dv->ugd->buf, MEMO_BUFFER_SIZE, DOODLEDIR "/%d.png", dv->md->id);
114 Evas_Object * doodle = elm_swallowed_icon(dv->body_main, "elm.swallow.doodle", dv->ugd->buf);
117 Evas_Object *eo = elm_swallowed_layout(dv->body_main, "elm.swallow.comment", EDJ_FILE, "doodle_comment");
118 Evas_Object *ef = elm_entry_add(eo);
119 elm_object_part_content_set(eo, "elm.swallow.editfield", ef);
121 elm_entry_editable_set(ef, EINA_FALSE);
122 elm_entry_single_line_set(ef, EINA_TRUE);
123 elm_entry_scrollable_set(ef, EINA_TRUE);
125 elm_entry_cnp_mode_set(dv->entry, ELM_CNP_MODE_PLAINTEXT);
126 memo_comment_recover(dv->entry, dv->md->comment);
129 static void _create_detail_layout(detail_view_t *dv)
131 dv->md = memo_get_data(dv->index);
133 /* add navigationbar */
134 dv->navigator = elm_naviframe_add(dv->ugd->base);
135 if (dv->md != NULL) {
136 if(!dv->md->has_doodle) {
137 _create_text_viewer_layout(dv);
139 _create_doodle_viewer_layout(dv);
141 memo_free_data(dv->md);
145 Evas_Object *btn = elm_button_add(dv->navigator);
146 evas_object_smart_callback_add(btn, "clicked", _on_quit, dv);
147 elm_object_style_set(btn, "naviframe/back_btn/default");
149 Elm_Object_Item *navi_it = memo_naviframe_item_push(dv->navigator, MEMO_I18N_MEMO, btn, NULL, dv->body_main, NULL);
152 void *memo_load_detail_view(ug_data_t *ugd, service_h service)
154 detail_view_t *dv = SMALLOC(detail_view_t);
155 RETVIF(dv == NULL, NULL);
160 service_get_extra_data(service, "index", &str);
161 LOGD("index = [%s]",str);
163 dv->index = atoi(str);
171 _create_detail_layout(dv);
172 elm_object_part_content_set(ugd->base, "elm.swallow.content", dv->navigator);