elua: elm test entry
This commit is contained in:
parent
e6278f346f
commit
b3c36138f9
|
@ -8,6 +8,7 @@ local M = {}
|
||||||
|
|
||||||
ffi.cdef [[
|
ffi.cdef [[
|
||||||
typedef struct Evas_Object Evas_Object;
|
typedef struct Evas_Object Evas_Object;
|
||||||
|
typedef unsigned char Eina_Bool;
|
||||||
|
|
||||||
typedef void(*Evas_Smart_Cb)(void *data, Evas_Object *obj, void *event_info);
|
typedef void(*Evas_Smart_Cb)(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
|
||||||
|
@ -22,11 +23,18 @@ ffi.cdef [[
|
||||||
Evas_Object *elm_label_add(Evas_Object *parent);
|
Evas_Object *elm_label_add(Evas_Object *parent);
|
||||||
Evas_Object *elm_button_add(Evas_Object *parent);
|
Evas_Object *elm_button_add(Evas_Object *parent);
|
||||||
Evas_Object *elm_box_add(Evas_Object *parent);
|
Evas_Object *elm_box_add(Evas_Object *parent);
|
||||||
|
Evas_Object *elm_entry_add(Evas_Object *parent);
|
||||||
void elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj);
|
void elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj);
|
||||||
|
void elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line);
|
||||||
|
void elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll);
|
||||||
|
void elm_entry_entry_set(Evas_Object *obj, const char *entry);
|
||||||
|
const char *elm_entry_entry_get(const Evas_Object *obj);
|
||||||
void elm_object_part_text_set(Evas_Object *obj, const char *part, const char *text);
|
void elm_object_part_text_set(Evas_Object *obj, const char *part, const char *text);
|
||||||
|
void elm_object_focus_set(Evas_Object *obj, Eina_Bool focus);
|
||||||
|
|
||||||
void evas_object_show(Evas_Object *obj);
|
void evas_object_show(Evas_Object *obj);
|
||||||
void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y);
|
void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y);
|
||||||
|
void evas_object_size_hint_align_set(Evas_Object *obj, double x, double y);
|
||||||
void evas_object_resize(Evas_Object *obj, int w, int h);
|
void evas_object_resize(Evas_Object *obj, int w, int h);
|
||||||
|
|
||||||
void evas_object_smart_callback_add(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data);
|
void evas_object_smart_callback_add(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data);
|
||||||
|
@ -53,6 +61,9 @@ local Evas_Object = util.Object:clone {
|
||||||
size_hint_weight_set = function(self, x, y)
|
size_hint_weight_set = function(self, x, y)
|
||||||
evas.evas_object_size_hint_weight_set(self.__o, x, y)
|
evas.evas_object_size_hint_weight_set(self.__o, x, y)
|
||||||
end,
|
end,
|
||||||
|
size_hint_align_set = function(self, x, y)
|
||||||
|
evas.evas_object_size_hint_align_set(self.__o, x, y)
|
||||||
|
end,
|
||||||
smart_callback_add = function(self, ev, cb)
|
smart_callback_add = function(self, ev, cb)
|
||||||
local cbt = callbacks[cb]
|
local cbt = callbacks[cb]
|
||||||
if not cbt then
|
if not cbt then
|
||||||
|
@ -101,8 +112,8 @@ M.Label = Evas_Object:clone {
|
||||||
self.__o = elm.elm_label_add(parent.__o)
|
self.__o = elm.elm_label_add(parent.__o)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
text_set = function(self, label)
|
text_set = function(self, label, part)
|
||||||
elm.elm_object_part_text_set(self.__o, nil, label)
|
elm.elm_object_part_text_set(self.__o, part, label)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +122,8 @@ M.Button = Evas_Object:clone {
|
||||||
self.__o = elm.elm_button_add(parent.__o)
|
self.__o = elm.elm_button_add(parent.__o)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
text_set = function(self, label)
|
text_set = function(self, label, part)
|
||||||
elm.elm_object_part_text_set(self.__o, nil, label)
|
elm.elm_object_part_text_set(self.__o, part, label)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +137,36 @@ M.Box = Evas_Object:clone {
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M.Entry = Evas_Object:clone {
|
||||||
|
__ctor = function(self, parent)
|
||||||
|
self.__o = elm.elm_entry_add(parent.__o)
|
||||||
|
end,
|
||||||
|
|
||||||
|
single_line_set = function(self, v)
|
||||||
|
elm.elm_entry_single_line_set(self.__o, v)
|
||||||
|
end,
|
||||||
|
|
||||||
|
scrollable_set = function(self, v)
|
||||||
|
elm.elm_entry_scrollable_set(self.__o, v)
|
||||||
|
end,
|
||||||
|
|
||||||
|
focus_set = function(self, v)
|
||||||
|
elm.elm_object_focus_set(self.__o, v)
|
||||||
|
end,
|
||||||
|
|
||||||
|
text_set = function(self, label, part)
|
||||||
|
elm.elm_object_part_text_set(self.__o, part, label)
|
||||||
|
end,
|
||||||
|
|
||||||
|
entry_set = function(self, v)
|
||||||
|
elm.elm_entry_entry_set(self.__o, v)
|
||||||
|
end,
|
||||||
|
|
||||||
|
entry_get = function(self, v)
|
||||||
|
return elm.elm_entry_entry_get(self.__o)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
M.exit = function()
|
M.exit = function()
|
||||||
elm.elm_exit()
|
elm.elm_exit()
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,21 +38,26 @@ lbl:text_set("Lua runtime test")
|
||||||
bx:pack_end(lbl)
|
bx:pack_end(lbl)
|
||||||
lbl:show()
|
lbl:show()
|
||||||
|
|
||||||
local counter = nil
|
local entry
|
||||||
local step = 5
|
|
||||||
|
|
||||||
local btn = elm.Button(win)
|
local btn = elm.Button(win)
|
||||||
btn:text_set("Reset counter")
|
btn:text_set("Reset counter")
|
||||||
bx:pack_end(btn)
|
bx:pack_end(btn)
|
||||||
btn:smart_callback_add("clicked", function()
|
btn:smart_callback_add("clicked", function()
|
||||||
if not counter then
|
lbl:text_set(entry:entry_get())
|
||||||
btn:text_set("Add " .. step)
|
|
||||||
end
|
|
||||||
counter = counter and (counter + step) or 0
|
|
||||||
lbl:text_set(tostring(counter))
|
|
||||||
end)
|
end)
|
||||||
btn:show()
|
btn:show()
|
||||||
|
|
||||||
|
entry = elm.Entry(win)
|
||||||
|
entry:single_line_set(true)
|
||||||
|
entry:scrollable_set(true)
|
||||||
|
entry:focus_set(true)
|
||||||
|
entry:entry_set("Hello world")
|
||||||
|
entry:size_hint_weight_set(1.0, 1.0)
|
||||||
|
entry:size_hint_align_set(-1.0, -1.0)
|
||||||
|
entry:show()
|
||||||
|
bx:pack_end(entry)
|
||||||
|
|
||||||
win:resize(360, 360)
|
win:resize(360, 360)
|
||||||
win:show()
|
win:show()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue