so much more - valgrind complaints fixed in many places, leaks

and anchorblock/view are working...



SVN revision: 37081
This commit is contained in:
Carsten Haitzler 2008-10-25 02:11:06 +00:00
parent 9b290646e9
commit 6f493e0ee1
15 changed files with 976 additions and 39 deletions

View File

@ -2812,6 +2812,93 @@ collections {
}
}
group { name: "elm/entry/base-single-noedit/default";
parts {
part { name: "elm.text";
type: TEXTBLOCK;
mouse_events: 1;
scale: 1;
entry_mode: PLAIN;
multiline: 0;
source: "elm/entry/selection/default"; // selection under
source4: "elm/entry/cursor/default"; // cursorover
source5: "elm/entry/anchor/default"; // anchor under
description { state: "default" 0.0;
text {
style: "entry_single_textblock_style";
min: 1 1;
}
}
}
}
programs {
program { name: "focus";
signal: "load";
source: "";
action: FOCUS_SET;
target: "elm.text";
}
}
}
group { name: "elm/entry/base-noedit/default";
parts {
part { name: "elm.text";
type: TEXTBLOCK;
mouse_events: 1;
scale: 1;
entry_mode: PLAIN;
multiline: 1;
source: "elm/entry/selection/default"; // selection under
source4: "elm/entry/cursor/default"; // cursorover
source5: "elm/entry/anchor/default"; // anchor under
description { state: "default" 0.0;
text {
style: "entry_textblock_style";
min: 0 1;
}
}
}
}
programs {
program { name: "focus";
signal: "load";
source: "";
action: FOCUS_SET;
target: "elm.text";
}
}
}
group { name: "elm/entry/base-nowrap-noedit/default";
parts {
part { name: "elm.text";
type: TEXTBLOCK;
mouse_events: 1;
scale: 1;
entry_mode: PLAIN;
multiline: 1;
source: "elm/entry/selection/default"; // selection under
source4: "elm/entry/cursor/default"; // cursorover
source5: "elm/entry/anchor/default"; // anchor under
description { state: "default" 0.0;
text {
style: "entry_textblock_style";
min: 1 1;
}
}
}
}
programs {
program { name: "focus";
signal: "load";
source: "";
action: FOCUS_SET;
target: "elm.text";
}
}
}
group { name: "elm/entry/base-password/default";
parts {
part { name: "elm.text";

View File

@ -494,7 +494,7 @@ my_bt_11(void *data, Evas_Object *obj, void *event_info)
evas_object_show(bt);
elm_hover_parent_set(hv, win);
elm_hover_target_set(hv, bt);
bt = elm_button_add(win);
elm_button_label_set(bt, "Popup");
elm_hover_content_set(hv, "middle", bt);
@ -508,6 +508,7 @@ my_bt_11(void *data, Evas_Object *obj, void *event_info)
elm_icon_scale_set(ic, 0, 0);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
bt = elm_button_add(win);
elm_button_label_set(bt, "Top 1");
elm_box_pack_end(bx, bt);
@ -520,6 +521,7 @@ my_bt_11(void *data, Evas_Object *obj, void *event_info)
elm_button_label_set(bt, "Top 3");
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(bx);
elm_hover_content_set(hv, "top", bx);
@ -537,7 +539,7 @@ my_bt_11(void *data, Evas_Object *obj, void *event_info)
elm_button_label_set(bt, "Right");
elm_hover_content_set(hv, "right", bt);
evas_object_show(bt);
evas_object_size_hint_min_set(bg, 160, 160);
evas_object_size_hint_max_set(bg, 640, 640);
evas_object_resize(win, 320, 320);
@ -859,19 +861,19 @@ my_bt_14(void *data, Evas_Object *obj, void *event_info)
static void
my_notepad_bt_1(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *en = data;
Evas_Object *np = data;
}
static void
my_notepad_bt_2(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *en = data;
Evas_Object *np = data;
}
static void
my_notepad_bt_3(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *en = data;
Evas_Object *np = data;
}
static void
@ -953,6 +955,271 @@ my_bt_15(void *data, Evas_Object *obj, void *event_info)
evas_object_show(win);
}
static void
my_anchorview_bt(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *av = data;
elm_anchorview_hover_end(av);
}
static void
my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *av = data;
Elm_Entry_Anchorview_Info *ei = event_info;
Evas_Object *bt, *bx;
bt = elm_button_add(obj);
elm_button_label_set(bt, ei->name);
elm_hover_content_set(ei->hover, "middle", bt);
evas_object_show(bt);
// hints as to where we probably should put hover contents (buttons etc.).
if (ei->hover_top)
{
bx = elm_box_add(obj);
bt = elm_button_add(obj);
elm_button_label_set(bt, "Top 1");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_button_label_set(bt, "Top 2");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_button_label_set(bt, "Top 3");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
elm_hover_content_set(ei->hover, "top", bx);
evas_object_show(bx);
}
if (ei->hover_bottom)
{
bt = elm_button_add(obj);
elm_button_label_set(bt, "Bot");
elm_hover_content_set(ei->hover, "bottom", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
}
if (ei->hover_left)
{
bt = elm_button_add(obj);
elm_button_label_set(bt, "Left");
elm_hover_content_set(ei->hover, "left", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
}
if (ei->hover_right)
{
bt = elm_button_add(obj);
elm_button_label_set(bt, "Right");
elm_hover_content_set(ei->hover, "right", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
}
}
static void
my_bt_16(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *win, *bg, *av;
char buf[PATH_MAX];
win = elm_win_add(NULL, "anchorview", ELM_WIN_BASIC);
elm_win_title_set(win, "Anchorview");
elm_win_autodel_set(win, 1);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, 1.0, 1.0);
evas_object_show(bg);
av = elm_anchorview_add(win);
elm_anchorview_hover_style_set(av, "popout");
elm_anchorview_hover_parent_set(av, win);
elm_anchorview_text_set(av,
"This is an entry widget in this window that<br>"
"uses markup <b>like this</> for styling and<br>"
"formatting <em>like this</>, as well as<br>"
"<a href=X><link>links in the text</></a>, so enter text<br>"
"in here to edit it. By the way, links are<br>"
"called <a href=anc-02>Anchors</a> so you will need<br>"
"to refer to them this way.");
evas_object_size_hint_weight_set(av, 1.0, 1.0);
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorview_anchor, av);
elm_win_resize_object_add(win, av);
evas_object_show(av);
evas_object_resize(win, 320, 300);
// FIXME: not exported
elm_widget_focus_set(win, 1);
evas_object_show(win);
}
static void
my_anchorblock_bt(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *av = data;
elm_anchorblock_hover_end(av);
}
static void
my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *av = data;
Elm_Entry_Anchorblock_Info *ei = event_info;
Evas_Object *bt, *bx;
bt = elm_button_add(obj);
elm_button_label_set(bt, ei->name);
elm_hover_content_set(ei->hover, "middle", bt);
evas_object_show(bt);
// hints as to where we probably should put hover contents (buttons etc.).
if (ei->hover_top)
{
bx = elm_box_add(obj);
bt = elm_button_add(obj);
elm_button_label_set(bt, "Top 1");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_button_label_set(bt, "Top 2");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_button_label_set(bt, "Top 3");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
elm_hover_content_set(ei->hover, "top", bx);
evas_object_show(bx);
}
if (ei->hover_bottom)
{
bt = elm_button_add(obj);
elm_button_label_set(bt, "Bot");
elm_hover_content_set(ei->hover, "bottom", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
}
if (ei->hover_left)
{
bt = elm_button_add(obj);
elm_button_label_set(bt, "Left");
elm_hover_content_set(ei->hover, "left", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
}
if (ei->hover_right)
{
bt = elm_button_add(obj);
elm_button_label_set(bt, "Right");
elm_hover_content_set(ei->hover, "right", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
}
}
static void
my_bt_17(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *win, *bg, *av, *sc, *bx, *fr;
char buf[PATH_MAX];
win = elm_win_add(NULL, "anchorblock", ELM_WIN_BASIC);
elm_win_title_set(win, "Anchorblock");
elm_win_autodel_set(win, 1);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, 1.0, 1.0);
evas_object_show(bg);
sc = elm_scroller_add(win);
evas_object_size_hint_weight_set(sc, 1.0, 1.0);
elm_win_resize_object_add(win, sc);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, 1.0, 0.0);
evas_object_size_hint_align_set(bx, -1.0, -1.0);
elm_scroller_content_set(sc, bx);
evas_object_show(bx);
fr = elm_frame_add(win);
elm_frame_label_set(fr, "Message 3");
evas_object_size_hint_weight_set(fr, 1.0, 0.0);
evas_object_size_hint_align_set(fr, -1.0,-1.0);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
elm_anchorblock_text_set(av,
"Hi there. This is the most recent message in the "
"list of messages. It has one <a href=tel:+614321234>+61 432 1234</a> "
"(phone number) to click on.");
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
elm_frame_content_set(fr, av);
evas_object_show(av);
elm_box_pack_end(bx, fr);
evas_object_show(fr);
fr = elm_frame_add(win);
elm_frame_label_set(fr, "Message 2");
evas_object_size_hint_weight_set(fr, 1.0, 0.0);
evas_object_size_hint_align_set(fr, -1.0,-1.0);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
elm_anchorblock_text_set(av,
"Hey what are you doing? This is the second last message "
"Hi there. This is the most recent message in the "
"list. It's a longer one so it can wrap more and "
"contains a <a href=contact:john>John</a> contact "
"link in it to test popups on links. The idea is that "
"all SMS's are scanned for things that look like phone "
"numbers or names that are in your contacts list, and "
"if they are, they become clickable links that pop up "
"a menus of obvious actions to perform on this piece "
"of information. This of course can be later explicitly "
"done by links maybe running local apps or even being "
"web URL's too that launch the web browser and point it "
"to that URL.");
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
elm_frame_content_set(fr, av);
evas_object_show(av);
elm_box_pack_end(bx, fr);
evas_object_show(fr);
fr = elm_frame_add(win);
elm_frame_label_set(fr, "Message 1");
evas_object_size_hint_weight_set(fr, 1.0, 0.0);
evas_object_size_hint_align_set(fr, -1.0,-1.0);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
elm_anchorblock_text_set(av,
"This is a short message");
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
elm_frame_content_set(fr, av);
evas_object_show(av);
elm_box_pack_end(bx, fr);
evas_object_show(fr);
evas_object_show(sc);
evas_object_resize(win, 320, 300);
// FIXME: not exported
elm_widget_focus_set(win, 1);
evas_object_show(win);
}
static void
my_win_main(void)
{
@ -1151,6 +1418,20 @@ my_win_main(void)
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_button_label_set(bt, "Anchorview");
evas_object_smart_callback_add(bt, "clicked", my_bt_16, NULL);
evas_object_size_hint_align_set(bt, -1.0, 0.0);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_button_label_set(bt, "Anchorblock");
evas_object_smart_callback_add(bt, "clicked", my_bt_17, NULL);
evas_object_size_hint_align_set(bt, -1.0, 0.0);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
/* set an initial window size */
evas_object_resize(win, 320, 520);
/* show the window */

View File

@ -181,8 +181,16 @@ extern "C" {
EAPI void elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content);
EAPI void elm_hover_style_set(Evas_Object *obj, const char *style);
/* smart callbacks called:
* "clicked" - the user clicked the empty space in the hover to dismiss
*/
typedef struct _Elm_Entry_Anchor_Info Elm_Entry_Anchor_Info;
struct _Elm_Entry_Anchor_Info
{
const char *name;
int button;
Evas_Coord x, y, w, h;
};
EAPI Evas_Object *elm_entry_add(Evas_Object *parent);
EAPI void elm_entry_single_line_set(Evas_Object *obj, Evas_Bool single_line);
EAPI void elm_entry_password_set(Evas_Object *obj, Evas_Bool password);
@ -191,6 +199,7 @@ extern "C" {
EAPI const char *elm_entry_selection_get(Evas_Object *obj);
EAPI void elm_entry_entry_insert(Evas_Object *obj, const char *entry);
EAPI void elm_entry_line_wrap_set(Evas_Object *obj, Evas_Bool wrap);
EAPI void elm_entry_editable_set(Evas_Object *obj, Evas_Bool editable);
/* smart callbacks called:
* "changed" - the text content changed
* "selection,start" - the user started selecting text
@ -200,7 +209,7 @@ extern "C" {
* "selection,copy" - the user copied the text
* "selection,cut" - the user cut the text
* "cursor,changed" - the cursor changed position
* "anchor,X,clicked,N" - achor called 'X' was clicked with button 'N'
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchor_Info
* "activated" - when the enter key is pressed (useful for single line)
*/
@ -216,7 +225,51 @@ extern "C" {
EAPI void elm_notepad_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format);
/* smart callbacks called:
*/
typedef struct _Elm_Entry_Anchorview_Info Elm_Entry_Anchorview_Info;
struct _Elm_Entry_Anchorview_Info
{
const char *name;
int button;
Evas_Object *hover;
struct {
Evas_Coord x, y, w, h;
} anchor, hover_parent;
Evas_Bool hover_left : 1;
Evas_Bool hover_right : 1;
Evas_Bool hover_top : 1;
Evas_Bool hover_bottom : 1;
};
EAPI Evas_Object *elm_anchorview_add(Evas_Object *parent);
EAPI void elm_anchorview_text_set(Evas_Object *obj, const char *text);
EAPI void elm_anchorview_hover_style_set(Evas_Object *obj, const char *style);
EAPI void elm_anchorview_hover_end(Evas_Object *obj);
/* smart callbacks called:
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchorview_Info
*/
typedef struct _Elm_Entry_Anchorblock_Info Elm_Entry_Anchorblock_Info;
struct _Elm_Entry_Anchorblock_Info
{
const char *name;
int button;
Evas_Object *hover;
struct {
Evas_Coord x, y, w, h;
} anchor, hover_parent;
Evas_Bool hover_left : 1;
Evas_Bool hover_right : 1;
Evas_Bool hover_top : 1;
Evas_Bool hover_bottom : 1;
};
EAPI Evas_Object *elm_anchorblock_add(Evas_Object *parent);
EAPI void elm_anchorblock_text_set(Evas_Object *obj, const char *text);
EAPI void elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style);
EAPI void elm_anchorblock_hover_end(Evas_Object *obj);
/* smart callbacks called:
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchorblock_Info
*/
// FIXME: fixes to do
// * current sizing tree inefficient

View File

@ -37,6 +37,8 @@ elm_contact.c \
elm_contactlist.c \
\
elc_notepad.c \
elc_anchorview.c \
elc_anchorblock.c \
\
els_pan.c \
els_pan.h \

View File

@ -0,0 +1,191 @@
#include <Elementary.h>
#include "elm_priv.h"
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
{
Evas_Object *entry;
Evas_Object *hover_parent;
Evas_Object *pop, *hover;
const char *hover_style;
};
static void _del_pre_hook(Evas_Object *obj);
static void _del_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _on_focus_hook(void *data, Evas_Object *obj);
static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void
_del_pre_hook(Evas_Object *obj)
{
elm_anchorblock_hover_end(obj);
elm_anchorblock_hover_parent_set(obj, NULL);
}
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover_style) eina_stringshare_del(wd->hover_style);
free(wd);
}
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
evas_object_size_hint_min_get(wd->entry, &minw, &minh);
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, maxw, maxh);
}
static void
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
_sizing_eval(data);
}
static void
_hover_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
wd->hover = NULL;
}
static void
_hover_clicked(void *data, Evas_Object *obj, void *event_info)
{
elm_anchorblock_hover_end(data);
}
static void
_anchor_clicked(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Elm_Entry_Anchor_Info *info = event_info;
Evas_Object *hover_parent;
Elm_Entry_Anchorblock_Info ei;
Evas_Coord x, w, y, h, px, py;
wd->pop = elm_icon_add(obj);
evas_object_move(wd->pop, info->x, info->y);
evas_object_resize(wd->pop, info->w, info->h);
wd->hover = elm_hover_add(obj);
if (wd->hover_style) elm_hover_style_set(wd->hover, wd->hover_style);
hover_parent = wd->hover_parent;
if (!hover_parent) hover_parent = obj;
elm_hover_parent_set(wd->hover, hover_parent);
elm_hover_target_set(wd->hover, wd->pop);
ei.name = info->name;
ei.button = info->button;
ei.hover = wd->hover;
ei.anchor.x = info->x;
ei.anchor.y = info->y;
ei.anchor.w = info->w;
ei.anchor.h = info->h;
evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
ei.hover_parent.x = x;
ei.hover_parent.y = y;
ei.hover_parent.w = w;
ei.hover_parent.h = h;
px = info->x + (info->w / 2);
py = info->y + (info->h / 2);
ei.hover_left = 1;
if (px < (x + (w / 3))) ei.hover_left = 0;
ei.hover_right = 1;
if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
ei.hover_top = 1;
if (py < (y + (h / 3))) ei.hover_top = 0;
ei.hover_bottom = 1;
if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
evas_object_smart_callback_call(data, "anchor,clicked", &ei);
evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, data);
evas_object_show(wd->hover);
}
static void
_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
wd->hover_parent = NULL;
}
EAPI Evas_Object *
elm_anchorblock_add(Evas_Object *parent)
{
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
wd = ELM_NEW(Widget_Data);
e = evas_object_evas_get(parent);
obj = elm_widget_add(e);
elm_widget_data_set(obj, wd);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_del_hook_set(obj, _del_hook);
wd->entry = elm_entry_add(parent);
elm_widget_resize_object_set(obj, wd->entry);
elm_entry_editable_set(wd->entry, 0);
evas_object_size_hint_weight_set(wd->entry, 1.0, 1.0);
evas_object_size_hint_align_set(wd->entry, -1.0, -1.0);
evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
elm_entry_entry_set(wd->entry, "");
evas_object_smart_callback_add(wd->entry, "anchor,clicked", _anchor_clicked, obj);
_sizing_eval(obj);
return obj;
}
EAPI void
elm_anchorblock_text_set(Evas_Object *obj, const char *text)
{
Widget_Data *wd = elm_widget_data_get(obj);
elm_entry_entry_set(wd->entry, text);
if (wd->hover) evas_object_del(wd->hover);
if (wd->pop) evas_object_del(wd->pop);
wd->hover = NULL;
wd->pop = NULL;
_sizing_eval(obj);
}
EAPI void
elm_anchorblock_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover_parent)
evas_object_event_callback_del(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del);
wd->hover_parent = parent;
if (wd->hover_parent)
evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
}
EAPI void
elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover_style) eina_stringshare_del(wd->hover_style);
wd->hover_style = NULL;
if (style) wd->hover_style = eina_stringshare_add(style);
}
EAPI void
elm_anchorblock_hover_end(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover) evas_object_del(wd->hover);
if (wd->pop) evas_object_del(wd->pop);
wd->hover = NULL;
wd->pop = NULL;
}

View File

@ -0,0 +1,186 @@
#include <Elementary.h>
#include "elm_priv.h"
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
{
Evas_Object *scroller, *entry;
Evas_Object *hover_parent;
Evas_Object *pop, *hover;
const char *hover_style;
};
static void _del_pre_hook(Evas_Object *obj);
static void _del_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _on_focus_hook(void *data, Evas_Object *obj);
static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void
_del_pre_hook(Evas_Object *obj)
{
elm_anchorview_hover_end(obj);
elm_anchorview_hover_parent_set(obj, NULL);
}
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover_style) eina_stringshare_del(wd->hover_style);
free(wd);
}
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, maxw, maxh);
}
static void
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
_sizing_eval(data);
}
static void
_hover_clicked(void *data, Evas_Object *obj, void *event_info)
{
elm_anchorview_hover_end(data);
}
static void
_anchor_clicked(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
Elm_Entry_Anchor_Info *info = event_info;
Evas_Object *hover_parent;
Elm_Entry_Anchorview_Info ei;
Evas_Coord x, w, y, h, px, py;
wd->pop = elm_icon_add(obj);
evas_object_move(wd->pop, info->x, info->y);
evas_object_resize(wd->pop, info->w, info->h);
wd->hover = elm_hover_add(obj);
if (wd->hover_style) elm_hover_style_set(wd->hover, wd->hover_style);
hover_parent = wd->hover_parent;
if (!hover_parent) hover_parent = obj;
elm_hover_parent_set(wd->hover, hover_parent);
elm_hover_target_set(wd->hover, wd->pop);
ei.name = info->name;
ei.button = info->button;
ei.hover = wd->hover;
ei.anchor.x = info->x;
ei.anchor.y = info->y;
ei.anchor.w = info->w;
ei.anchor.h = info->h;
evas_object_geometry_get(hover_parent, &x, &y, &w, &h);
ei.hover_parent.x = x;
ei.hover_parent.y = y;
ei.hover_parent.w = w;
ei.hover_parent.h = h;
px = info->x + (info->w / 2);
py = info->y + (info->h / 2);
ei.hover_left = 1;
if (px < (x + (w / 3))) ei.hover_left = 0;
ei.hover_right = 1;
if (px > (x + ((w * 2) / 3))) ei.hover_right = 0;
ei.hover_top = 1;
if (py < (y + (h / 3))) ei.hover_top = 0;
ei.hover_bottom = 1;
if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0;
evas_object_smart_callback_call(data, "anchor,clicked", &ei);
evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, data);
evas_object_show(wd->hover);
}
static void
_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
wd->hover_parent = NULL;
}
EAPI Evas_Object *
elm_anchorview_add(Evas_Object *parent)
{
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
wd = ELM_NEW(Widget_Data);
e = evas_object_evas_get(parent);
obj = elm_widget_add(e);
elm_widget_data_set(obj, wd);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_del_hook_set(obj, _del_hook);
wd->scroller = elm_scroller_add(parent);
elm_widget_resize_object_set(obj, wd->scroller);
wd->entry = elm_entry_add(parent);
elm_entry_editable_set(wd->entry, 0);
evas_object_size_hint_weight_set(wd->entry, 1.0, 1.0);
evas_object_size_hint_align_set(wd->entry, -1.0, -1.0);
elm_scroller_content_set(wd->scroller, wd->entry);
evas_object_show(wd->entry);
evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
elm_entry_entry_set(wd->entry, "");
evas_object_smart_callback_add(wd->entry, "anchor,clicked", _anchor_clicked, obj);
_sizing_eval(obj);
return obj;
}
EAPI void
elm_anchorview_text_set(Evas_Object *obj, const char *text)
{
Widget_Data *wd = elm_widget_data_get(obj);
elm_entry_entry_set(wd->entry, text);
if (wd->hover) evas_object_del(wd->hover);
if (wd->pop) evas_object_del(wd->pop);
wd->hover = NULL;
wd->pop = NULL;
_sizing_eval(obj);
}
EAPI void
elm_anchorview_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover_parent)
evas_object_event_callback_del(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del);
wd->hover_parent = parent;
if (wd->hover_parent)
evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL, _parent_del, obj);
}
EAPI void
elm_anchorview_hover_style_set(Evas_Object *obj, const char *style)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover_style) eina_stringshare_del(wd->hover_style);
wd->hover_style = NULL;
if (style) wd->hover_style = eina_stringshare_add(style);
}
EAPI void
elm_anchorview_hover_end(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->hover) evas_object_del(wd->hover);
if (wd->pop) evas_object_del(wd->pop);
wd->hover = NULL;
wd->pop = NULL;
}

View File

@ -69,7 +69,6 @@ elm_box_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
wd->box = _els_smart_box_add(e);
elm_widget_sub_object_add(obj, wd->box);
evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
elm_widget_resize_object_set(obj, wd->box);

View File

@ -11,6 +11,7 @@ struct _Widget_Data
Evas_Bool linewrap : 1;
Evas_Bool single_line : 1;
Evas_Bool password : 1;
Evas_Bool editable : 1;
Ecore_Job *deferred_recalc_job;
};
@ -90,6 +91,8 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
if (wd->linewrap) _sizing_eval(data);
Evas_Coord ww, hh;
evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
}
static void
@ -160,7 +163,7 @@ _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const
// FIXME: handle auto-scroll within parent (get cursor - if not visible
// jump so it is)
edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
printf("CURSOR: @%i+%i %ix%i\n", cx, cy, cw, ch);
// printf("CURSOR: @%i+%i %ix%i\n", cx, cy, cw, ch);
elm_widget_show_region_set(data, cx, cy, cw, ch);
}
@ -168,22 +171,23 @@ static void
_signal_anchor_down(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
printf("DOWN %s\n", emission);
// printf("DOWN %s\n", emission);
}
static void
_signal_anchor_up(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
Elm_Entry_Anchor_Info ei;
char *buf, *buf2, *p, *p2, *n;
int buflen;
printf("UP %s\n", emission);
// printf("UP %s\n", emission);
p = strrchr(emission, ',');
if (p)
{
Eina_List *geoms;
n = p + 1;
buflen = 200 + strlen(n);
buf = alloca(buflen);
p2 = p -1;
while (p2 >= emission)
{
@ -194,8 +198,32 @@ _signal_anchor_up(void *data, Evas_Object *obj, const char *emission, const char
buf2 = alloca(5 + p - p2);
strncpy(buf2, p2, p - p2);
buf2[p - p2] = 0;
snprintf(buf, buflen, "anchor,%s,clicked,%s", buf2, n);
evas_object_smart_callback_call(data, buf, NULL);
ei.name = n;
ei.button = atoi(buf2);
ei.x = ei.y = ei.w = ei.h = 0;
geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
if (geoms)
{
Evas_Textblock_Rectangle *r;
Eina_List *l;
Evas_Coord px, py, x, y;
evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
EINA_LIST_FOREACH(geoms, l, r)
{
if (((r->x + x) <= px) && ((r->y + y) <= py) &&
((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
{
ei.x = r->x + x;
ei.y = r->y + y;
ei.w = r->w;
ei.h = r->h;
break;
}
}
}
evas_object_smart_callback_call(data, "anchor,clicked", &ei);
}
}
@ -203,21 +231,21 @@ static void
_signal_anchor_move(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
printf("MOVE %s\n", emission);
// printf("MOVE %s\n", emission);
}
static void
_signal_anchor_in(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
printf("IN %s\n", emission);
// printf("IN %s\n", emission);
}
static void
_signal_anchor_out(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
printf("OUT %s\n", emission);
// printf("OUT %s\n", emission);
}
static void
@ -243,6 +271,7 @@ elm_entry_add(Evas_Object *parent)
elm_widget_can_focus_set(obj, 1);
wd->linewrap = 1;
wd->editable = 1;
wd->ent = edje_object_add(e);
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
@ -266,6 +295,39 @@ elm_entry_add(Evas_Object *parent)
return obj;
}
static const char *
_getbase(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->editable)
{
if (wd->password) return "base-password";
else
{
if (wd->single_line) return "base-single";
else
{
if (wd->linewrap) return "base";
else return "base-nowrap";
}
}
}
else
{
if (wd->password) return "base-password";
else
{
if (wd->single_line) return "base-single-noedit";
else
{
if (wd->linewrap) return "base-noedit";
else return "base-nowrap-noedit";
}
}
}
return "base";
}
EAPI void
elm_entry_single_line_set(Evas_Object *obj, Evas_Bool single_line)
{
@ -276,8 +338,7 @@ elm_entry_single_line_set(Evas_Object *obj, Evas_Bool single_line)
wd->linewrap = 0;
t = elm_entry_entry_get(obj);
if (t) t = strdup(t);
if (!wd->single_line) _elm_theme_set(wd->ent, "entry", "base", "default");
else _elm_theme_set(wd->ent, "entry", "base-single", "default");
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
elm_entry_entry_set(obj, t);
if (t) free(t);
_sizing_eval(obj);
@ -294,8 +355,7 @@ elm_entry_password_set(Evas_Object *obj, Evas_Bool password)
wd->linewrap = 0;
t = elm_entry_entry_get(obj);
if (t) t = strdup(t);
if (!wd->password) _elm_theme_set(wd->ent, "entry", "base", "default");
else _elm_theme_set(wd->ent, "entry", "base-password", "default");
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
elm_entry_entry_set(obj, t);
if (t) free(t);
_sizing_eval(obj);
@ -308,12 +368,14 @@ elm_entry_entry_set(Evas_Object *obj, const char *entry)
edje_object_part_text_set(wd->ent, "elm.text", entry);
// debug
#if 0
{
Eina_List *l, *an;
an = edje_object_part_text_anchor_list_get(wd->ent, "elm.text");
for (l = an; l; l = l->next)
printf("ANCHOR: %s\n", l->data);
}
#endif
wd->changed = 1;
_sizing_eval(obj);
}
@ -350,8 +412,22 @@ elm_entry_line_wrap_set(Evas_Object *obj, Evas_Bool wrap)
wd->linewrap = wrap;
t = elm_entry_entry_get(obj);
if (t) t = strdup(t);
if (wd->linewrap) _elm_theme_set(wd->ent, "entry", "base", "default");
else _elm_theme_set(wd->ent, "entry", "base-nowrap", "default");
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
elm_entry_entry_set(obj, t);
if (t) free(t);
_sizing_eval(obj);
}
EAPI void
elm_entry_editable_set(Evas_Object *obj, Evas_Bool editable)
{
Widget_Data *wd = elm_widget_data_get(obj);
char *t;
if (wd->editable == editable) return;
wd->editable = editable;
t = elm_entry_entry_get(obj);
if (t) t = strdup(t);
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
elm_entry_entry_set(obj, t);
if (t) free(t);
_sizing_eval(obj);

View File

@ -19,17 +19,26 @@ struct _Subinfo
Evas_Object *obj;
};
static void _del_pre_hook(Evas_Object *obj);
static void _del_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
static void _hov_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void
_del_hook(Evas_Object *obj)
_del_pre_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
elm_hover_target_set(obj, NULL);
elm_hover_parent_set(obj, NULL);
evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_MOVE, _hov_move);
evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize);
evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_SHOW, _hov_show);
evas_object_event_callback_del(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide);
while (wd->subs)
{
Subinfo *si = wd->subs->data;
@ -37,6 +46,12 @@ _del_hook(Evas_Object *obj)
evas_stringshare_del(si->swallow);
free(si);
}
}
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
free(wd);
}
@ -112,8 +127,11 @@ _hov_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
// FIXME: use signals for show for hov
evas_object_show(wd->cov);
edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
if (wd->cov)
{
evas_object_show(wd->cov);
edje_object_signal_emit(wd->cov, "elm,action,show", "elm");
}
for (l = wd->subs; l; l = l->next)
{
Subinfo *si = l->data;
@ -133,8 +151,11 @@ _hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
Widget_Data *wd = elm_widget_data_get(data);
Eina_List *l;
// FIXME: use signals for hide for hov
edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
evas_object_hide(wd->cov);
if (wd->cov)
{
edje_object_signal_emit(wd->cov, "elm,action,hide", "elm");
evas_object_hide(wd->cov);
}
for (l = wd->subs; l; l = l->next)
{
Subinfo *si = l->data;
@ -207,6 +228,7 @@ elm_hover_add(Evas_Object *parent)
e = evas_object_evas_get(parent);
obj = elm_widget_add(e);
elm_widget_data_set(obj, wd);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_del_hook_set(obj, _del_hook);
wd->hov = evas_object_rectangle_add(e);
@ -279,7 +301,7 @@ elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_SHOW, _parent_show, obj);
evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_HIDE, _parent_hide, obj);
evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_DEL, _parent_del, obj);
elm_widget_sub_object_add(parent, obj);
// elm_widget_sub_object_add(parent, obj);
}
_sizing_eval(obj);
}
@ -307,6 +329,7 @@ elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conten
{
elm_widget_sub_object_add(obj, content);
edje_object_part_swallow(wd->cov, buf, content);
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
si = ELM_NEW(Subinfo);

View File

@ -42,6 +42,7 @@ int _elm_theme_icon_set(Evas_Object *o, const char *group, const char *style);
/* FIXME: should this be public? for now - private (but public symbols) */
EAPI Evas_Object *elm_widget_add(Evas *evas);
EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
EAPI void elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
EAPI void elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
EAPI void elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
EAPI void elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));

View File

@ -69,7 +69,6 @@ elm_table_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
wd->tbl = _els_smart_table_add(e);
elm_widget_sub_object_add(obj, wd->tbl);
evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
elm_widget_resize_object_set(obj, wd->tbl);

View File

@ -15,6 +15,7 @@ struct _Smart_Data
Evas_Object *resize_obj;
Evas_Object *hover_obj;
void (*del_func) (Evas_Object *obj);
void (*del_pre_func) (Evas_Object *obj);
void (*focus_func) (Evas_Object *obj);
void (*activate_func) (Evas_Object *obj);
void (*disable_func) (Evas_Object *obj);
@ -81,6 +82,13 @@ elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
sd->del_func = func;
}
EAPI void
elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
{
API_ENTRY return;
sd->del_pre_func = func;
}
EAPI void
elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
{
@ -170,6 +178,11 @@ elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj)
{
if (elm_widget_can_focus_get(sobj)) sd->child_can_focus = 0;
}
if (!strcmp(evas_object_type_get(sobj), SMART_NAME))
{
sd = evas_object_smart_data_get(sobj);
if (sd) sd->parent_obj = NULL;
}
evas_object_smart_callback_call(obj, "sub-object-del", sobj);
}
@ -186,6 +199,7 @@ elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
sd->resize_obj = sobj;
if (sd->resize_obj)
{
evas_object_clip_set(sobj, evas_object_clip_get(obj));
evas_object_smart_member_add(sobj, obj);
evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN, _sub_obj_mouse_down, sd);
@ -547,7 +561,7 @@ _smart_del(Evas_Object *obj)
Evas_Object *sobj;
INTERNAL_ENTRY;
if (sd->del_func) sd->del_func(obj);
if (sd->del_pre_func) sd->del_pre_func(obj);
if (sd->resize_obj)
{
evas_object_event_callback_del(sd->resize_obj, EVAS_CALLBACK_DEL, _sub_obj_del);
@ -567,6 +581,7 @@ _smart_del(Evas_Object *obj)
evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL, _sub_obj_del);
evas_object_del(sobj);
}
if (sd->del_func) sd->del_func(obj);
free(sd);
}

View File

@ -43,6 +43,7 @@ static void
_elm_win_resize(Ecore_Evas *ee)