forked from enlightenment/efl
and now entry is pretty much done (no hooks to x copy/paste selections etc.
but for now that's ok) SVN revision: 36754
This commit is contained in:
parent
4c94e5067a
commit
ab493a0d00
|
@ -31,6 +31,7 @@ AC_SUBST(version_info)
|
|||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
PKG_CHECK_MODULES([ELEMENTARY], [
|
||||
eina
|
||||
eet
|
||||
evas
|
||||
ecore
|
||||
|
|
|
@ -2688,6 +2688,35 @@ collections {
|
|||
source4: "elm/entry/cursor/default"; // cursorover
|
||||
source5: "elm/entry/anchor/default"; // anchor under
|
||||
// source6: "X"; // anchor over
|
||||
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/default";
|
||||
parts {
|
||||
part { name: "elm.text";
|
||||
type: TEXTBLOCK;
|
||||
mouse_events: 1;
|
||||
scale: 1;
|
||||
entry_mode: EDITABLE;
|
||||
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";
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
#include <Elementary.h>
|
||||
|
||||
// FIXME: add more explicit tests for:
|
||||
// labels
|
||||
// frames
|
||||
// scroller
|
||||
|
||||
static void my_win_del(void *data, Evas_Object *obj, void *event_info);
|
||||
static void my_bt_1(void *data, Evas_Object *obj, void *event_info);
|
||||
static void my_win_main(void);
|
||||
|
@ -682,6 +677,7 @@ my_bt_13(void *data, Evas_Object *obj, void *event_info)
|
|||
evas_object_show(bx);
|
||||
|
||||
en = elm_entry_add(win);
|
||||
elm_entry_line_wrap_set(en, 0);
|
||||
elm_entry_entry_set(en,
|
||||
"This is an entry widget in this window that<br>"
|
||||
"uses markup <b>like this</> for styling and<br>"
|
||||
|
@ -741,6 +737,96 @@ my_bt_13(void *data, Evas_Object *obj, void *event_info)
|
|||
evas_object_show(win);
|
||||
}
|
||||
|
||||
static void
|
||||
my_bt_14(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *win, *bg, *bx, *bx2, *bt, *en, *sc;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
win = elm_win_add(NULL, "entry-scrolled", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Entry Scrolled");
|
||||
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);
|
||||
|
||||
bx = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(bx, 1.0, 1.0);
|
||||
elm_win_resize_object_add(win, bx);
|
||||
evas_object_show(bx);
|
||||
|
||||
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);
|
||||
elm_box_pack_end(bx, sc);
|
||||
|
||||
en = elm_entry_add(win);
|
||||
evas_object_propagate_events_set(en, 0);
|
||||
elm_entry_entry_set(en,
|
||||
"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. 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_align_set(en, -1.0, -1.0);
|
||||
elm_scroller_content_set(sc, en);
|
||||
evas_object_show(en);
|
||||
|
||||
evas_object_show(sc);
|
||||
|
||||
bx2 = elm_box_add(win);
|
||||
elm_box_horizontal_set(bx2, 1);
|
||||
evas_object_size_hint_weight_set(bx2, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(bx2, -1.0, -1.0);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_button_label_set(bt, "Clear");
|
||||
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_1, en);
|
||||
evas_object_size_hint_align_set(bt, -1.0, -1.0);
|
||||
evas_object_size_hint_weight_set(bt, 1.0, 0.0);
|
||||
elm_box_pack_end(bx2, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_button_label_set(bt, "Print");
|
||||
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_2, en);
|
||||
evas_object_size_hint_align_set(bt, -1.0, -1.0);
|
||||
evas_object_size_hint_weight_set(bt, 1.0, 0.0);
|
||||
elm_box_pack_end(bx2, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_button_label_set(bt, "Selection");
|
||||
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_3, en);
|
||||
evas_object_size_hint_align_set(bt, -1.0, -1.0);
|
||||
evas_object_size_hint_weight_set(bt, 1.0, 0.0);
|
||||
elm_box_pack_end(bx2, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_button_label_set(bt, "Insert");
|
||||
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_4, en);
|
||||
evas_object_size_hint_align_set(bt, -1.0, -1.0);
|
||||
evas_object_size_hint_weight_set(bt, 1.0, 0.0);
|
||||
elm_box_pack_end(bx2, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
elm_box_pack_end(bx, bx2);
|
||||
evas_object_show(bx2);
|
||||
|
||||
// HACK! not exposed! (should expose some later?)
|
||||
elm_widget_focus_set(en, 1);
|
||||
|
||||
evas_object_resize(win, 320, 300);
|
||||
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
static void
|
||||
my_win_main(void)
|
||||
{
|
||||
|
@ -925,8 +1011,15 @@ my_win_main(void)
|
|||
elm_box_pack_end(bx, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_button_label_set(bt, "Entry Scrolled");
|
||||
evas_object_smart_callback_add(bt, "clicked", my_bt_14, 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, 320);
|
||||
evas_object_resize(win, 320, 520);
|
||||
/* show the window */
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#endif
|
||||
|
||||
/* EFL headers */
|
||||
#include <Eina.h>
|
||||
#include <Eet.h>
|
||||
#include <Evas.h>
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_X.h>
|
||||
|
@ -53,7 +55,6 @@
|
|||
#include <Ecore_Job.h>
|
||||
#include <Ecore_Txt.h>
|
||||
#include <Ecore_File.h>
|
||||
#include <Eet.h>
|
||||
#include <Edje.h>
|
||||
|
||||
/* allow usage from c++ */
|
||||
|
@ -185,6 +186,7 @@ extern "C" {
|
|||
EAPI const char *elm_entry_entry_get(Evas_Object *obj);
|
||||
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);
|
||||
/* smart callbacks called:
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@ typedef struct _Widget_Data Widget_Data;
|
|||
struct _Widget_Data
|
||||
{
|
||||
Evas_Object *ent;
|
||||
Evas_Bool linewrap;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _on_focus_hook(void *data, Evas_Object *obj);
|
||||
static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
|
@ -32,11 +34,26 @@ _sizing_eval(Evas_Object *obj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
Evas_Coord resw, resh, minminw;
|
||||
|
||||
if (wd->linewrap)
|
||||
{
|
||||
evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
|
||||
resh = 0;
|
||||
minminw = 0;
|
||||
edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
|
||||
minminw = minw;
|
||||
edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
|
||||
evas_object_size_hint_min_set(obj, minminw, minh);
|
||||
evas_object_size_hint_max_set(obj, minminw, maxh);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_size_min_calc(wd->ent, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_on_focus_hook(void *data, Evas_Object *obj)
|
||||
|
@ -45,6 +62,13 @@ _on_focus_hook(void *data, Evas_Object *obj)
|
|||
evas_object_focus_set(wd->ent, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_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);
|
||||
}
|
||||
|
||||
static void
|
||||
_signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
|
@ -111,6 +135,7 @@ _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const
|
|||
// 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);
|
||||
elm_widget_show_region_set(data, cx, cy, cw, ch);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -163,7 +188,11 @@ elm_entry_add(Evas_Object *parent)
|
|||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
elm_widget_can_focus_set(obj, 1);
|
||||
|
||||
wd->linewrap = 1;
|
||||
|
||||
wd->ent = edje_object_add(e);
|
||||
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
|
||||
|
||||
_elm_theme_set(wd->ent, "entry", "base", "default");
|
||||
edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text", _signal_entry_changed, obj);
|
||||
edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text", _signal_selection_start, obj);
|
||||
|
@ -220,3 +249,18 @@ elm_entry_entry_insert(Evas_Object *obj, const char *entry)
|
|||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_entry_line_wrap_set(Evas_Object *obj, Evas_Bool wrap)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
char *t;
|
||||
if (wd->linewrap == wrap) return;
|
||||
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_entry_entry_set(obj, t);
|
||||
if (t) free(t);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ EAPI void elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (E
|
|||
EAPI void elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_data_set(Evas_Object *obj, void *data);
|
||||
EAPI void *elm_widget_data_get(Evas_Object *obj);
|
||||
EAPI void elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
|
||||
|
@ -66,6 +67,9 @@ EAPI void elm_widget_activate(Evas_Object *obj);
|
|||
EAPI void elm_widget_change(Evas_Object *obj);
|
||||
EAPI void elm_widget_disabled_set(Evas_Object *obj, int disabled);
|
||||
EAPI int elm_widget_disabled_get(Evas_Object *obj);
|
||||
EAPI void elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
|
||||
EAPI void elm_widget_show_region_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
||||
|
||||
|
||||
extern char *_elm_appname;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ struct _Widget_Data
|
|||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _show_region_hook(void *data, Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
||||
|
||||
|
@ -20,6 +21,15 @@ _del_hook(Evas_Object *obj)
|
|||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_show_region_hook(void *data, Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
Evas_Coord x, y, w, h;
|
||||
elm_widget_show_region_get(obj, &x, &y, &w, &h);
|
||||
elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
|
@ -59,6 +69,7 @@ _sub_del(void *data, Evas_Object *obj, void *event_info)
|
|||
Evas_Object *sub = event_info;
|
||||
if (sub == wd->content)
|
||||
{
|
||||
elm_widget_on_show_region_hook_set(wd->content, NULL, NULL);
|
||||
evas_object_event_callback_del
|
||||
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||
wd->content = NULL;
|
||||
|
@ -108,6 +119,7 @@ elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
|
|||
wd->content = content;
|
||||
if (content)
|
||||
{
|
||||
elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
|
||||
elm_widget_sub_object_add(obj, content);
|
||||
elm_smart_scroller_child_set(wd->scr, content);
|
||||
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
|
|
|
@ -21,7 +21,10 @@ struct _Smart_Data
|
|||
void *on_focus_data;
|
||||
void (*on_change_func) (void *data, Evas_Object *obj);
|
||||
void *on_change_data;
|
||||
void (*on_show_region_func) (void *data, Evas_Object *obj);
|
||||
void *on_show_region_data;
|
||||
void *data;
|
||||
Evas_Coord rx, ry, rw, rh;
|
||||
unsigned char can_focus : 1;
|
||||
unsigned char child_can_focus : 1;
|
||||
unsigned char focused : 1;
|
||||
|
@ -105,6 +108,14 @@ elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_O
|
|||
sd->on_change_data = data;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->on_show_region_func = func;
|
||||
sd->on_show_region_data = data;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_data_set(Evas_Object *obj, void *data)
|
||||
{
|
||||
|
@ -464,6 +475,28 @@ elm_widget_disabled_get(Evas_Object *obj)
|
|||
return sd->disabled;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if ((x == sd->rx) && (y == sd->ry) && (w == sd->rw) && (h == sd->rh)) return;
|
||||
sd->rx = x;
|
||||
sd->ry = y;
|
||||
sd->rw = w;
|
||||
sd->rh = h;
|
||||
if (sd->on_show_region_func) sd->on_show_region_func(sd->on_show_region_data, obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_show_region_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
||||
{
|
||||
API_ENTRY return;
|
||||
if (x) *x = sd->rx;
|
||||
if (y) *y = sd->ry;
|
||||
if (w) *w = sd->rw;
|
||||
if (h) *h = sd->rh;
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_smart_reconfigure(Smart_Data *sd)
|
||||
|
|
Loading…
Reference in New Issue