parent
f5b21a1738
commit
c0fd5ab12f
|
@ -633,21 +633,38 @@ static void
|
||||||
my_entry_bt_1(void *data, Evas_Object *obj, void *event_info)
|
my_entry_bt_1(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Evas_Object *en = data;
|
Evas_Object *en = data;
|
||||||
|
elm_entry_entry_set(en, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_entry_bt_2(void *data, Evas_Object *obj, void *event_info)
|
my_entry_bt_2(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Evas_Object *en = data;
|
Evas_Object *en = data;
|
||||||
printf("TEXT:\n");
|
const char *s = elm_entry_entry_get(en);
|
||||||
printf("%s\n",
|
printf("ENTRY:\n");
|
||||||
elm_entry_entry_get(en));
|
if (s) printf("%s\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
my_entry_bt_3(void *data, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Evas_Object *en = data;
|
||||||
|
const char *s = elm_entry_selection_get(en);
|
||||||
|
printf("SELECTION:\n");
|
||||||
|
if (s) printf("%s\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
my_entry_bt_4(void *data, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Evas_Object *en = data;
|
||||||
|
elm_entry_entry_insert(en, "Insert some <b>BOLD</> text");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
my_bt_13(void *data, Evas_Object *obj, void *event_info)
|
my_bt_13(void *data, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Evas_Object *win, *bg, *bx, *bt, *en;
|
Evas_Object *win, *bg, *bx, *bx2, *bt, *en;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
|
win = elm_win_add(NULL, "entry", ELM_WIN_BASIC);
|
||||||
|
@ -664,30 +681,59 @@ my_bt_13(void *data, Evas_Object *obj, void *event_info)
|
||||||
elm_win_resize_object_add(win, bx);
|
elm_win_resize_object_add(win, bx);
|
||||||
evas_object_show(bx);
|
evas_object_show(bx);
|
||||||
|
|
||||||
bt = elm_button_add(win);
|
|
||||||
elm_button_label_set(bt, "Clear");
|
|
||||||
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_1, en);
|
|
||||||
elm_box_pack_end(bx, bt);
|
|
||||||
evas_object_show(bt);
|
|
||||||
|
|
||||||
en = elm_entry_add(win);
|
en = elm_entry_add(win);
|
||||||
elm_entry_entry_set(en,
|
elm_entry_entry_set(en,
|
||||||
"This is an entry widget in this window that<br>"
|
"This is an entry widget in this window that<br>"
|
||||||
"uses markup <b>like this</b> for styling and<br>"
|
"uses markup <b>like this</> for styling and<br>"
|
||||||
"formatting <em>like this</em>, as well as<br>"
|
"formatting <em>like this</>, as well as<br>"
|
||||||
"<a href=X><link>links in the text</link></a>, so enter text<br>"
|
"<+a href=X><link>links in the text</></>, so enter text<br>"
|
||||||
"in here to edit it.");
|
"in here to edit it.");
|
||||||
evas_object_size_hint_weight_set(en, 1.0, 1.0);
|
evas_object_size_hint_weight_set(en, 1.0, 1.0);
|
||||||
evas_object_size_hint_align_set(en, -1.0, -1.0);
|
evas_object_size_hint_align_set(en, -1.0, -1.0);
|
||||||
elm_box_pack_end(bx, en);
|
elm_box_pack_end(bx, en);
|
||||||
evas_object_show(en);
|
evas_object_show(en);
|
||||||
|
|
||||||
|
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);
|
bt = elm_button_add(win);
|
||||||
elm_button_label_set(bt, "Print");
|
elm_button_label_set(bt, "Print");
|
||||||
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_2, en);
|
evas_object_smart_callback_add(bt, "clicked", my_entry_bt_2, en);
|
||||||
elm_box_pack_end(bx, bt);
|
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);
|
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);
|
elm_widget_focus_set(en, 1);
|
||||||
|
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
|
|
|
@ -181,8 +181,12 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EAPI Evas_Object *elm_entry_add(Evas_Object *parent);
|
EAPI Evas_Object *elm_entry_add(Evas_Object *parent);
|
||||||
EAPI void elm_entry_entry_set(Evas_Object *obj, const char *entry);
|
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_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);
|
||||||
|
/* smart callbacks called:
|
||||||
|
*/
|
||||||
|
|
||||||
// FIXME: fixes to do
|
// FIXME: fixes to do
|
||||||
// * current sizing tree inefficient
|
// * current sizing tree inefficient
|
||||||
|
|
|
@ -10,6 +10,15 @@ struct _Widget_Data
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(Evas_Object *obj);
|
static void _sizing_eval(Evas_Object *obj);
|
||||||
|
static void _on_focus_hook(void *data, Evas_Object *obj);
|
||||||
|
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);
|
||||||
|
static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_del_hook(Evas_Object *obj)
|
_del_hook(Evas_Object *obj)
|
||||||
|
@ -36,6 +45,70 @@ _on_focus_hook(void *data, Evas_Object *obj)
|
||||||
evas_object_focus_set(wd->ent, 1);
|
evas_object_focus_set(wd->ent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_entry_changed(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, "changed", NULL);
|
||||||
|
_sizing_eval(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_selection_start(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, "selection,start", NULL);
|
||||||
|
// FIXME: x clipboard/copy & paste - do
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_selection_changed(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, "selection,changed", NULL);
|
||||||
|
// FIXME: x clipboard/copy & paste - do
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_selection_cleared(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, "selection,cleared", NULL);
|
||||||
|
// FIXME: x clipboard/copy & paste - do
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = elm_widget_data_get(data);
|
||||||
|
// FIXME: x clipboard/copy and paste - request
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_entry_copy_notify(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, "changed", NULL);
|
||||||
|
// FIXME: x clipboard/copy & paste - do
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_entry_cut_notify(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, "changed", NULL);
|
||||||
|
// FIXME: x clipboard/copy & paste - do
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_signal_cursor_changed(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, "cursor,changed", NULL);
|
||||||
|
// FIXME: handle auto-scroll within parent (get cursor - if not visible
|
||||||
|
// jump so it is)
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_entry_add(Evas_Object *parent)
|
elm_entry_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +126,14 @@ elm_entry_add(Evas_Object *parent)
|
||||||
|
|
||||||
wd->ent = edje_object_add(e);
|
wd->ent = edje_object_add(e);
|
||||||
_elm_theme_set(wd->ent, "entry", "base", "default");
|
_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);
|
||||||
|
edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text", _signal_selection_changed, obj);
|
||||||
|
edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text", _signal_selection_cleared, obj);
|
||||||
|
edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text", _signal_entry_paste_request, obj);
|
||||||
|
edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text", _signal_entry_copy_notify, obj);
|
||||||
|
edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text", _signal_entry_cut_notify, obj);
|
||||||
|
edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text", _signal_cursor_changed, obj);
|
||||||
elm_widget_resize_object_set(obj, wd->ent);
|
elm_widget_resize_object_set(obj, wd->ent);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -71,3 +152,19 @@ elm_entry_entry_get(Evas_Object *obj)
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
return edje_object_part_text_get(wd->ent, "elm.text");
|
return edje_object_part_text_get(wd->ent, "elm.text");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI const char *
|
||||||
|
elm_entry_selection_get(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
|
return edje_object_part_text_selection_get(wd->ent, "elm.text");
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
elm_entry_entry_insert(Evas_Object *obj, const char *entry)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
|
edje_object_part_text_insert(wd->ent, "elm.text", entry);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue