and support password mode and proper focus on click

SVN revision: 36958
This commit is contained in:
Carsten Haitzler 2008-10-22 08:58:56 +00:00
parent 1da0b4df76
commit a3ad00322f
7 changed files with 192 additions and 12 deletions

View File

@ -146,6 +146,7 @@ collections {
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
fixed: 1 1;
visible: 0;
min: 17 17;
align: 1.0 0.0;
@ -184,6 +185,7 @@ collections {
confine: "sb_vbar";
}
description { state: "default" 0.0;
fixed: 1 1;
min: 17 17;
rel1 {
relative: 0.5 0.5;
@ -241,6 +243,7 @@ collections {
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
fixed: 1 1;
visible: 0;
min: 17 17;
align: 0.0 1.0;
@ -279,6 +282,7 @@ collections {
confine: "sb_hbar";
}
description { state: "default" 0.0;
fixed: 1 1;
min: 17 17;
rel1 {
relative: 0.5 0.5;
@ -2767,6 +2771,76 @@ collections {
}
}
group { name: "elm/entry/base-single/default";
styles
{
style { name: "entry_single_textblock_style";
base: "font=Sans font_size=10 align=left color=#000 wrap=none";
// tag: "br" "\n";
// tag: "tab" "\t";
tag: "em" "+ font=Sans:style=Oblique";
tag: "b" "+ font=Sans:style=Bold";
tag: "link" "+ color=#800 underline=on underline_color=#8008";
tag: "hilight" "+ font=Sans:style=Bold";
}
}
parts {
part { name: "elm.text";
type: TEXTBLOCK;
mouse_events: 1;
scale: 1;
entry_mode: EDITABLE;
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-password/default";
parts {
part { name: "elm.text";
type: TEXTBLOCK;
mouse_events: 1;
scale: 1;
entry_mode: PASSOWRD;
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/cursor/default";
images {
image: "cur_box.png" COMP;

View File

@ -757,6 +757,38 @@ my_bt_14(void *data, Evas_Object *obj, void *event_info)
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
sc = elm_scroller_add(win);
elm_scroller_content_min_limit(sc, 0, 1);
evas_object_size_hint_weight_set(sc, 1.0, 0.0);
evas_object_size_hint_align_set(sc, -1.0, -1.0);
elm_box_pack_end(bx, sc);
en = elm_entry_add(win);
elm_entry_single_line_set(en, 1);
elm_entry_entry_set(en, "This is a single line");
evas_object_size_hint_weight_set(en, 1.0, 1.0);
evas_object_size_hint_align_set(en, -1.0, -1.0);
elm_scroller_content_set(sc, en);
evas_object_show(en);
evas_object_show(sc);
sc = elm_scroller_add(win);
elm_scroller_content_min_limit(sc, 0, 1);
evas_object_size_hint_weight_set(sc, 1.0, 0.0);
evas_object_size_hint_align_set(sc, -1.0, -1.0);
elm_box_pack_end(bx, sc);
en = elm_entry_add(win);
elm_entry_password_set(en, 1);
elm_entry_entry_set(en, "Password here");
evas_object_size_hint_weight_set(en, 1.0, 1.0);
evas_object_size_hint_align_set(en, -1.0, -1.0);
elm_scroller_content_set(sc, en);
evas_object_show(en);
evas_object_show(sc);
sc = elm_scroller_add(win);
evas_object_size_hint_weight_set(sc, 1.0, 1.0);
evas_object_size_hint_align_set(sc, -1.0, -1.0);
@ -771,7 +803,7 @@ my_bt_14(void *data, Evas_Object *obj, void *event_info)
"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. At the end here is a really long line to test line wrapping to see if it works. But just in case this line is not long enough I will add more here to really test it out, as Elementary really needs some good testing to see if entry widgets work as advertised.");
evas_object_size_hint_weight_set(en, 1.0, 0.0);
evas_object_size_hint_weight_set(en, 1.0, 1.0);
evas_object_size_hint_align_set(en, -1.0, -1.0);
elm_scroller_content_set(sc, en);
evas_object_show(en);
@ -865,7 +897,7 @@ my_bt_15(void *data, Evas_Object *obj, void *event_info)
evas_object_show(bx);
np = elm_notepad_add(win);
elm_notepad_file_set(np, "note.txt", ELM_TEXT_FORMAT_MARKUP_UTF8);
elm_notepad_file_set(np, "note.txt", ELM_TEXT_FORMAT_PLAIN_UTF8);
evas_object_size_hint_weight_set(np, 1.0, 1.0);
evas_object_size_hint_align_set(np, -1.0, -1.0);
elm_box_pack_end(bx, np);

View File

@ -127,6 +127,7 @@ extern "C" {
EAPI Evas_Object *elm_scroller_add(Evas_Object *parent);
EAPI void elm_scroller_content_set(Evas_Object *obj, Evas_Object *child);
EAPI void elm_scroller_content_min_limit(Evas_Object *obj, Evas_Bool w, Evas_Bool h);
/* smart callbacks called:
*/
@ -183,6 +184,8 @@ extern "C" {
*/
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);
EAPI void elm_entry_entry_set(Evas_Object *obj, const char *entry);
EAPI const char *elm_entry_entry_get(Evas_Object *obj);
EAPI const char *elm_entry_selection_get(Evas_Object *obj);
@ -198,6 +201,7 @@ extern "C" {
* "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'
* "activated" - when the enter key is pressed (useful for single line)
*/
/* composite widgets - these basically put together basic widgets above

View File

@ -131,7 +131,6 @@ _load_plain_utf8(const char *file)
char str[16];
escape = evas_textblock_string_escape_get(buf + ppos, &stlen);
printf("esc = %s\n", escape);
if (escape)
text = _buf_append(text, escape, &len, &alloc);
else
@ -198,7 +197,6 @@ _save_markup_utf8(const char *file, const char *text)
fputs(text, f); // FIXME: catch error
fputs("\n", f); // FIXME: catch error
fclose(f);
printf(".. written\n");
}
static void
@ -316,7 +314,6 @@ _save(Evas_Object *obj)
_save_plain_utf8(wd->file, elm_entry_entry_get(wd->entry));
break;
case ELM_TEXT_FORMAT_MARKUP_UTF8:
printf(".. save markup\n");
_save_markup_utf8(wd->file, elm_entry_entry_get(wd->entry));
break;
default:
@ -328,7 +325,6 @@ static int
_delay_write(void *data)
{
Widget_Data *wd = elm_widget_data_get(data);
printf(".. save\n");
_save(data);
wd->delay_write = NULL;
return 0;
@ -338,7 +334,6 @@ static void
_entry_changed(void *data, Evas_Object *obj, void *event_info)
{
Widget_Data *wd = elm_widget_data_get(data);
printf(".. changed\n");
if (wd->delay_write)
{
ecore_timer_del(wd->delay_write);

View File

@ -7,8 +7,10 @@ struct _Widget_Data
{
Evas_Object *ent;
Evas_Coord lastw;
Evas_Bool changed;
Evas_Bool linewrap;
Evas_Bool changed : 1;
Evas_Bool linewrap : 1;
Evas_Bool single_line : 1;
Evas_Bool password : 1;
Ecore_Job *deferred_recalc_job;
};
@ -218,6 +220,13 @@ _signal_anchor_out(void *data, Evas_Object *obj, const char *emission, const cha
printf("OUT %s\n", emission);
}
static void
_signal_key_enter(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(data);
evas_object_smart_callback_call(data, "activated", NULL);
}
EAPI Evas_Object *
elm_entry_add(Evas_Object *parent)
{
@ -252,10 +261,47 @@ elm_entry_add(Evas_Object *parent)
edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text", _signal_anchor_move, obj);
edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text", _signal_anchor_in, obj);
edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text", _signal_anchor_out, obj);
edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text", _signal_key_enter, obj);
elm_widget_resize_object_set(obj, wd->ent);
evas_object_propagate_events_set(obj, 0);
return obj;
}
EAPI void
elm_entry_single_line_set(Evas_Object *obj, Evas_Bool single_line)
{
Widget_Data *wd = elm_widget_data_get(obj);
char *t;
if (wd->single_line == single_line) return;
wd->single_line = 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_entry_entry_set(obj, t);
if (t) free(t);
_sizing_eval(obj);
}
EAPI void
elm_entry_password_set(Evas_Object *obj, Evas_Bool password)
{
Widget_Data *wd = elm_widget_data_get(obj);
char *t;
if (wd->password == password) return;
wd->password = password;
wd->single_line = 1;
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_entry_entry_set(obj, t);
if (t) free(t);
_sizing_eval(obj);
}
EAPI void
elm_entry_entry_set(Evas_Object *obj, const char *entry)
{

View File

@ -7,6 +7,8 @@ struct _Widget_Data
{
Evas_Object *scr;
Evas_Object *content;
Evas_Bool min_w : 1;
Evas_Bool min_h : 1;
};
static void _del_hook(Evas_Object *obj);
@ -34,7 +36,7 @@ static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord vw, vh, minw, minh, maxw, maxh;
Evas_Coord vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
double xw, xy;
evas_object_size_hint_min_get(wd->content, &minw, &minh);
@ -54,6 +56,12 @@ _sizing_eval(Evas_Object *obj)
}
else if (minh > 0) vh = minh;
evas_object_resize(wd->content, vw, vh);
w = -1;
h = -1;
edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
if (wd->min_w) w = vmw + minw;
if (wd->min_h) h = vmh + minh;
evas_object_size_hint_min_set(obj, w, h);
}
static void
@ -99,8 +107,8 @@ elm_scroller_add(Evas_Object *parent)
wd->scr = elm_smart_scroller_add(e);
elm_widget_resize_object_set(obj, wd->scr);
edje_object_size_min_calc(wd->scr, &minw, &minh);
edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
@ -127,3 +135,12 @@ elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
_sizing_eval(obj);
}
}
EAPI void
elm_scroller_content_min_limit(Evas_Object *obj, Evas_Bool w, Evas_Bool h)
{
Widget_Data *wd = elm_widget_data_get(obj);
wd->min_w = w;
wd->min_h = h;
_sizing_eval(obj);
}

View File

@ -8,6 +8,7 @@ typedef struct _Smart_Data Smart_Data;
struct _Smart_Data
{
Evas_Object *obj;
Evas_Object *parent_obj;
Evas_Coord x, y, w, h;
Evas_List *subobjs;
@ -56,6 +57,14 @@ _sub_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
else sd->subobjs = evas_list_remove(sd->subobjs, obj);
}
static void
_sub_obj_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Smart_Data *sd = data;
if (obj == sd->resize_obj)
elm_widget_focus_set(sd->obj, 1);
}
/* externally accessible functions */
EAPI Evas_Object *
elm_widget_add(Evas *evas)
@ -170,6 +179,7 @@ elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
if (sd->resize_obj)
{
evas_object_event_callback_del(sd->resize_obj, EVAS_CALLBACK_DEL, _sub_obj_del);
evas_object_event_callback_del(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN, _sub_obj_mouse_down);
evas_object_smart_member_del(sd->resize_obj);
}
sd->resize_obj = sobj;
@ -177,6 +187,7 @@ elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
{
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);
_smart_reconfigure(sd);
evas_object_smart_callback_call(obj, "sub-object-add", sobj);
}
@ -520,6 +531,7 @@ _smart_add(Evas_Object *obj)
sd = calloc(1, sizeof(Smart_Data));
if (!sd) return;
sd->obj = obj;
sd->x = 0;
sd->y = 0;
sd->w = 0;