This commit is contained in:
xianjimli 2018-04-08 07:32:48 +08:00
parent aaab737c83
commit b29773aad8
25 changed files with 1298 additions and 140 deletions

View File

@ -31,7 +31,7 @@ os.environ['LIB_DIR'] = LIB_DIR;
os.environ['LFTK_ROOT'] = LFTK_ROOT;
os.environ['GTEST_ROOT'] = GTEST_ROOT;
CCFLAGS=OS_FLAGS + ' -DLFTK_ROOT=\\\"'+LFTK_ROOT+'\\\" -DWITH_STB_IMAGE -DWITH_STB_FONT'
CCFLAGS=OS_FLAGS + ' -DLFTK_ROOT=\\\"'+LFTK_ROOT+'\\\" -DWITH_STB_IMAGE -DWITH_STB_FONT -DSDL2'
DefaultEnvironment(CCFLAGS = CCFLAGS,
CPPPATH = [LFTK_ROOT, LFTK_SRC, LFTK_3RD_ROOT, os.path.join(LFTK_3RD_ROOT, 'agg-2.5/include'), LFTK_TOOLS_ROOT] + OS_CPPPATH,
LIBS=['lftk', 'agg', 'SDL2'] + OS_LIBS,

View File

@ -118,7 +118,7 @@ ret_t application_init() {
progress_bar = progress_bar_create(win, 10, 80, 168, 20);
widget_set_value(progress_bar, 40);
// timer_add(on_timer, progress_bar, 200);
timer_add(on_timer, progress_bar, 200);
#ifndef WITH_STM32F103ZE_RAW
progress_bar_set_show_text(progress_bar, TRUE);

View File

@ -31,6 +31,16 @@
</style>
</button>
<edit>
<style name="default" border-color="#a0a0a0" text-color="black" text-align-h="left" margin="4">
<normal bg-color="#f0f0f0" />
<focused bg-color="#f0f0f0" border-color="gold"/>
<disable bg-color="gray" text-color="#d0d0d0" />
<error bg-color="#f0f0f0" text-color="red" />
<empty bg-color="#f0f0f0" text-color="#a0a0a0" />
</style>
</edit>
<label>
<style name="default">
<normal text-color="black" />

View File

@ -116,4 +116,4 @@ const unsigned char image_unchecked[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,};/*2344*/
0xff,0x7f,0x00,0x00,};/*2344*/

View File

@ -1,108 +1,122 @@
const unsigned char theme_default[] = {
0x03,0x00,0x00,0x00,0x39,0x08,0x00,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x00,0x64,0x61,0x74,0x61,
0x00,0x00,0x00,0x00,0xfd,0xfc,0xfb,0xfa,0x00,0x00,0x00,0x00,0x2f,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0x84,0x01,0x00,0x00,0x01,0x01,0x02,0x00,0x94,0x01,0x00,0x00,0x01,0x00,0x0a,0x00,0xaf,0x01,0x00,0x00,
0x02,0x00,0x0a,0x00,0xcf,0x01,0x00,0x00,0x03,0x00,0x0a,0x00,0xef,0x01,0x00,0x00,0x04,0x00,0x0a,0x00,
0x0f,0x02,0x00,0x00,0x01,0x01,0x0a,0x00,0x2f,0x02,0x00,0x00,0x02,0x01,0x0a,0x00,0x57,0x02,0x00,0x00,
0x03,0x01,0x0a,0x00,0x7f,0x02,0x00,0x00,0x01,0x02,0x0a,0x00,0xa7,0x02,0x00,0x00,0x02,0x02,0x0a,0x00,
0xcd,0x02,0x00,0x00,0x03,0x02,0x0a,0x00,0xf3,0x02,0x00,0x00,0x01,0x00,0x09,0x00,0x19,0x03,0x00,0x00,
0x01,0x01,0x09,0x00,0x29,0x03,0x00,0x00,0x01,0x02,0x09,0x00,0x39,0x03,0x00,0x00,0x01,0x03,0x09,0x00,
0x61,0x03,0x00,0x00,0x01,0x04,0x09,0x00,0x81,0x03,0x00,0x00,0x01,0x05,0x09,0x00,0xa9,0x03,0x00,0x00,
0x01,0x00,0x0d,0x00,0xd8,0x03,0x00,0x00,0x01,0x01,0x0d,0x00,0x00,0x04,0x00,0x00,0x01,0x02,0x0d,0x00,
0x34,0x04,0x00,0x00,0x01,0x00,0x13,0x00,0x7c,0x04,0x00,0x00,0x02,0x00,0x13,0x00,0x9c,0x04,0x00,0x00,
0x03,0x00,0x13,0x00,0xbc,0x04,0x00,0x00,0x01,0x01,0x13,0x00,0xdc,0x04,0x00,0x00,0x02,0x01,0x13,0x00,
0x10,0x05,0x00,0x00,0x03,0x01,0x13,0x00,0x46,0x05,0x00,0x00,0x01,0x02,0x13,0x00,0x7c,0x05,0x00,0x00,
0x02,0x02,0x13,0x00,0xc4,0x05,0x00,0x00,0x03,0x02,0x13,0x00,0x0e,0x06,0x00,0x00,0x01,0x00,0x0e,0x00,
0x58,0x06,0x00,0x00,0x01,0x01,0x0e,0x00,0x60,0x06,0x00,0x00,0x06,0x00,0x0f,0x00,0x78,0x06,0x00,0x00,
0x07,0x00,0x0f,0x00,0x9c,0x06,0x00,0x00,0x06,0x01,0x0f,0x00,0xc2,0x06,0x00,0x00,0x07,0x01,0x0f,0x00,
0xe6,0x06,0x00,0x00,0x06,0x00,0x10,0x00,0x08,0x07,0x00,0x00,0x07,0x00,0x10,0x00,0x32,0x07,0x00,0x00,
0x06,0x02,0x10,0x00,0x5e,0x07,0x00,0x00,0x07,0x02,0x10,0x00,0x72,0x07,0x00,0x00,0x06,0x03,0x10,0x00,
0x87,0x07,0x00,0x00,0x07,0x03,0x10,0x00,0x9d,0x07,0x00,0x00,0x06,0x04,0x10,0x00,0xb4,0x07,0x00,0x00,
0x07,0x04,0x10,0x00,0xc9,0x07,0x00,0x00,0x01,0x01,0x0b,0x00,0xdf,0x07,0x00,0x00,0x01,0x00,0x11,0x00,
0xf7,0x07,0x00,0x00,0x01,0x00,0x12,0x00,0x21,0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x72,0x69,0x63,0x6b,0x73,0x00,0x03,0x00,0x00,0x00,0x09,
0x03,0x00,0x00,0x00,0x51,0x09,0x00,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x00,0x64,0x61,0x74,0x61,
0x00,0x00,0x00,0x00,0xfd,0xfc,0xfb,0xfa,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0xac,0x01,0x00,0x00,0x01,0x01,0x02,0x00,0xbc,0x01,0x00,0x00,0x01,0x00,0x0a,0x00,0xd7,0x01,0x00,0x00,
0x02,0x00,0x0a,0x00,0xf7,0x01,0x00,0x00,0x03,0x00,0x0a,0x00,0x17,0x02,0x00,0x00,0x04,0x00,0x0a,0x00,
0x37,0x02,0x00,0x00,0x01,0x01,0x0a,0x00,0x57,0x02,0x00,0x00,0x02,0x01,0x0a,0x00,0x7f,0x02,0x00,0x00,
0x03,0x01,0x0a,0x00,0xa7,0x02,0x00,0x00,0x01,0x02,0x0a,0x00,0xcf,0x02,0x00,0x00,0x02,0x02,0x0a,0x00,
0xf5,0x02,0x00,0x00,0x03,0x02,0x0a,0x00,0x1b,0x03,0x00,0x00,0x01,0x00,0x0c,0x00,0x41,0x03,0x00,0x00,
0x05,0x00,0x0c,0x00,0x71,0x03,0x00,0x00,0x04,0x00,0x0c,0x00,0xa1,0x03,0x00,0x00,0x09,0x00,0x0c,0x00,
0xd1,0x03,0x00,0x00,0x08,0x00,0x0c,0x00,0x01,0x04,0x00,0x00,0x01,0x00,0x09,0x00,0x31,0x04,0x00,0x00,
0x01,0x01,0x09,0x00,0x41,0x04,0x00,0x00,0x01,0x02,0x09,0x00,0x51,0x04,0x00,0x00,0x01,0x03,0x09,0x00,
0x79,0x04,0x00,0x00,0x01,0x04,0x09,0x00,0x99,0x04,0x00,0x00,0x01,0x05,0x09,0x00,0xc1,0x04,0x00,0x00,
0x01,0x00,0x0d,0x00,0xf0,0x04,0x00,0x00,0x01,0x01,0x0d,0x00,0x18,0x05,0x00,0x00,0x01,0x02,0x0d,0x00,
0x4c,0x05,0x00,0x00,0x01,0x00,0x13,0x00,0x94,0x05,0x00,0x00,0x02,0x00,0x13,0x00,0xb4,0x05,0x00,0x00,
0x03,0x00,0x13,0x00,0xd4,0x05,0x00,0x00,0x01,0x01,0x13,0x00,0xf4,0x05,0x00,0x00,0x02,0x01,0x13,0x00,
0x28,0x06,0x00,0x00,0x03,0x01,0x13,0x00,0x5e,0x06,0x00,0x00,0x01,0x02,0x13,0x00,0x94,0x06,0x00,0x00,
0x02,0x02,0x13,0x00,0xdc,0x06,0x00,0x00,0x03,0x02,0x13,0x00,0x26,0x07,0x00,0x00,0x01,0x00,0x0e,0x00,
0x70,0x07,0x00,0x00,0x01,0x01,0x0e,0x00,0x78,0x07,0x00,0x00,0x06,0x00,0x0f,0x00,0x90,0x07,0x00,0x00,
0x07,0x00,0x0f,0x00,0xb4,0x07,0x00,0x00,0x06,0x01,0x0f,0x00,0xda,0x07,0x00,0x00,0x07,0x01,0x0f,0x00,
0xfe,0x07,0x00,0x00,0x06,0x00,0x10,0x00,0x20,0x08,0x00,0x00,0x07,0x00,0x10,0x00,0x4a,0x08,0x00,0x00,
0x06,0x02,0x10,0x00,0x76,0x08,0x00,0x00,0x07,0x02,0x10,0x00,0x8a,0x08,0x00,0x00,0x06,0x03,0x10,0x00,
0x9f,0x08,0x00,0x00,0x07,0x03,0x10,0x00,0xb5,0x08,0x00,0x00,0x06,0x04,0x10,0x00,0xcc,0x08,0x00,0x00,
0x07,0x04,0x10,0x00,0xe1,0x08,0x00,0x00,0x01,0x01,0x0b,0x00,0xf7,0x08,0x00,0x00,0x01,0x00,0x11,0x00,
0x0f,0x09,0x00,0x00,0x01,0x00,0x12,0x00,0x39,0x09,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x62,0x72,0x69,0x63,0x6b,0x73,0x00,0x03,0x00,0x00,0x00,0x0a,
0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xf0,
0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,
0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xff,0x00,0x00,0x00,0x00,0x03,
0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,
0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,
0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,
0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,
0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x01,0x00,0x00,0x00,0xbe,0xbe,0xbe,0xff,0x00,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e,0x5f,0x62,0x74,0x6e,
0x5f,0x6e,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e,0x5f,0x62,0x74,0x6e,
0x5f,0x70,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e,0x5f,0x62,0x74,0x6e,
0x5f,0x6f,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x5f,0x6e,
0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,
0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x5f,0x70,0x00,0x02,
0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x01,
0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x5f,0x6f,0x00,0x01,0x00,0x00,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e,0x5f,0x62,0x74,0x6e,
0x5f,0x6e,0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e,0x5f,0x62,0x74,0x6e,
0x5f,0x70,0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e,0x5f,0x62,0x74,0x6e,
0x5f,0x6f,0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x5f,0x6e,
0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,
0xff,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x5f,0x70,0x00,0x02,
0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x01,
0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x72,0x65,0x64,0x5f,0x62,0x74,0x6e,0x5f,0x6f,0x00,0x05,0x00,0x00,
0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x08,0x00,0x00,
0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,
0xff,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xff,0xd7,0x00,0xff,0x06,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a,0x00,0x00,
0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x08,0x00,0x00,0x00,0x02,0x00,0x00,
0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xbe,0xbe,0xbe,0xff,0x00,0x00,0x00,
0x00,0x05,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0xff,0x00,0x00,
0xff,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,
0xff,0x06,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x10,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,
0x00,0x00,0x80,0x00,0xff,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0x00,0x00,
0xff,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x0f,0x00,0x00,
0xff,0x08,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x10,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x80,0x00,
0xff,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x07,0x00,0x00,0x00,0x03,0x00,0x00,
0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x0f,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x80,0x00,0xff,0x07,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,
0xff,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x08,0x00,0x00,0x00,0x03,0x00,0x00,
0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x10,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x80,0x00,0xff,0x08,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x03,0x00,0x00,0x00,0x61,0x70,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,
0x06,0x00,0x00,0x00,0xff,0xd7,0x00,0xff,0x02,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xff,0x09,0x00,0x00,0x00,
0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,
0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,
0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,
0x06,0x00,0x00,0x00,0xff,0xd7,0x00,0xff,0x02,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xff,0x0a,0x00,0x00,0x00,
0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,0x67,0x00,0x0e,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,
0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,
0x0e,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0xa0,0xa0,0xa0,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x09,0x00,0x00,0x00,0xff,0xd7,0x00,0xff,
0xa0,0xa0,0xa0,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x0a,0x00,0x00,0x00,0xff,0xd7,0x00,0xff,
0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x02,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0x09,0x00,0x00,0x00,0xff,0xa7,0x00,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x09,0x00,0x00,0x00,
0xff,0xe7,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,
0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,
0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0x0a,0x00,0x00,0x00,0xff,0xa7,0x00,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x0a,0x00,0x00,0x00,
0xff,0xe7,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,0x67,0x00,0x0e,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,
0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,
0x67,0x00,0x0e,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x5f,0x70,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x0a,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,0x67,0x00,0x0d,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x64,0x72,0x61,0x67,0x5f,0x6f,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x0e,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,
0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,
0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,
0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,
0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x5f,0x70,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,
0x00,0x00,0x0a,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,
0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,
0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x66,0x67,0x00,0x0c,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x00,0x00,0x0b,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x62,0x67,0x00,0x0e,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x64,0x72,0x61,0x67,0x5f,0x6f,0x00,0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x0f,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,
0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,0x0e,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,
0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x00,
0x02,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,
0x0e,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,
0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x64,0x72,0x61,0x67,0x5f,0x70,0x00,0x02,0x00,0x00,0x00,0x0c,0x00,
0x00,0x00,0x0a,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,
0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x62,0x67,0x00,0x0e,0x00,0x00,0x00,0x73,0x6c,
0x69,0x64,0x65,0x72,0x5f,0x76,0x5f,0x66,0x67,0x00,0x0d,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,
0x5f,0x64,0x72,0x61,0x67,0x5f,0x6f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x0a,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,
0x0c,0x00,0x00,0x00,0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,
0x0d,0x00,0x00,0x00,0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0d,0x00,
0x00,0x00,0x75,0x6e,0x6d,0x75,0x74,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,
0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x6d,0x75,
0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x6d,0x75,
0x74,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,0x63,0x68,
0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,0x63,0x68,
0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,
0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0c,0x00,
0x00,0x00,0x6c,0x65,0x66,0x74,0x5f,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0c,0x00,
0x00,0x00,0x6c,0x65,0x66,0x74,0x5f,0x6f,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0c,
0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,
0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0d,0x00,
0x00,0x00,0x6c,0x65,0x66,0x74,0x5f,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0d,0x00,
0x00,0x00,0x6c,0x65,0x66,0x74,0x5f,0x6f,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0d,
0x00,0x00,0x00,0x6d,0x69,0x64,0x64,0x6c,0x65,0x5f,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x0c,0x00,0x00,0x00,0x6d,0x69,0x64,0x64,0x6c,0x65,0x5f,0x6f,0x66,0x66,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x72,0x69,0x67,0x68,0x74,0x5f,0x6f,0x6e,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x72,0x69,0x67,0x68,0x74,0x5f,0x6f,0x66,0x66,0x00,0x02,
0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0a,
0x00,0x00,0x00,0x64,0x69,0x61,0x6c,0x6f,0x67,0x5f,0x74,0x69,0x74,0x6c,0x65,0x00,0x0c,0x00,0x00,0x00,
0x69,0x6e,0x66,0x6f,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xed,0xed,0xed,0xff,0x09,0x00,0x00,
0x00,0xa9,0xa9,0xa0,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2133*/
0x00,0x0d,0x00,0x00,0x00,0x6d,0x69,0x64,0x64,0x6c,0x65,0x5f,0x6f,0x66,0x66,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x72,0x69,0x67,0x68,0x74,0x5f,0x6f,0x6e,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x72,0x69,0x67,0x68,0x74,0x5f,0x6f,0x66,0x66,0x00,0x02,
0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,
0x00,0x00,0x00,0x64,0x69,0x61,0x6c,0x6f,0x67,0x5f,0x74,0x69,0x74,0x6c,0x65,0x00,0x0d,0x00,0x00,0x00,
0x69,0x6e,0x66,0x6f,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xed,0xed,0xed,0xff,0x0a,0x00,0x00,
0x00,0xa9,0xa9,0xa0,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2413*/

View File

@ -11,5 +11,5 @@ const unsigned char ui_dialog1[] = {
0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x59,0x65,0x73,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0x03,0x03,
0x01,0x00,0x0a,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,
0x6d,0x65,0x00,0x63,0x61,0x6e,0x63,0x65,0x6c,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x32,0x3a,0x72,0x65,
0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x4e,0x6f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,};/*261*/
0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x4e,0x6f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0xff,};/*261*/

6
demos/xml/edit.xml Normal file
View File

@ -0,0 +1,6 @@
<window name="main" x="0" y="0" w="320" h="480">
<edit input_type="float" x="center" y="10" w="80%" h="30" text="" min="0" max="100" tips="0-100 float"/>
<edit input_type="int" x="center" y="60" w="80%" h="30" text="-123"/>
<edit input_type="text" x="center" y="110" w="80%" h="30" text="abc" tips="name"/>
<edit input_type="text" x="center" y="160" w="80%" h="30" text="abc" min="3" max="10"/>
</window>

View File

@ -6,11 +6,11 @@ function application_init()
local win = Window.open("window1");
win.inc:on(EventType.CLICK, function(evt)
win.bar1:set_value(win.bar2.value + 10);
win.bar2:set_value(win.bar2.value + 10);
end);
win.dec:on(EventType.CLICK, function(evt)
win.bar1:set_value(win.bar2.value - 10);
win.bar2:set_value(win.bar2.value - 10);
end);
Timer.add(function()

View File

@ -9,6 +9,7 @@
#include "base/canvas.h"
#include "base/check_button.h"
#include "base/dialog.h"
#include "base/edit.h"
#include "base/events.h"
#include "base/group_box.h"
#include "base/image.h"
@ -37,6 +38,8 @@ static int wrap_check_button_t_get_prop(lua_State* L);
static int wrap_check_button_t_set_prop(lua_State* L);
static int wrap_dialog_t_get_prop(lua_State* L);
static int wrap_dialog_t_set_prop(lua_State* L);
static int wrap_edit_t_get_prop(lua_State* L);
static int wrap_edit_t_set_prop(lua_State* L);
static int wrap_event_t_get_prop(lua_State* L);
static int wrap_event_t_set_prop(lua_State* L);
static int wrap_pointer_event_t_get_prop(lua_State* L);
@ -366,6 +369,166 @@ static void dialog_t_init(lua_State* L) {
luaL_openlib(L, "Dialog", static_funcs, 0);
lua_settop(L, 0);
}
static void input_type_t_init(lua_State* L) {
lua_newtable(L);
lua_setglobal(L, "InputType");
lua_getglobal(L, "InputType");
lua_pushstring(L, "TEXT");
lua_pushinteger(L, INPUT_TEXT);
lua_settable(L, -3);
lua_pushstring(L, "INT");
lua_pushinteger(L, INPUT_INT);
lua_settable(L, -3);
lua_pushstring(L, "HEX");
lua_pushinteger(L, INPUT_HEX);
lua_settable(L, -3);
lua_pushstring(L, "FLOAT");
lua_pushinteger(L, INPUT_FLOAT);
lua_settable(L, -3);
lua_pushstring(L, "EMAIL");
lua_pushinteger(L, INPUT_EMAIL);
lua_settable(L, -3);
lua_pushstring(L, "PHONE");
lua_pushinteger(L, INPUT_PHONE);
lua_settable(L, -3);
}
static int wrap_edit_create(lua_State* L) {
widget_t* ret = NULL;
widget_t* parent = (widget_t*)lftk_checkudata(L, 1, "widget_t");
xy_t x = (xy_t)luaL_checkinteger(L, 2);
xy_t y = (xy_t)luaL_checkinteger(L, 3);
wh_t w = (wh_t)luaL_checkinteger(L, 4);
wh_t h = (wh_t)luaL_checkinteger(L, 5);
ret = (widget_t*)edit_create(parent, x, y, w, h);
return lftk_newuserdata(L, ret, "/edit_t/widget_t", "lftk.edit_t");
}
static int wrap_edit_set_text_limit(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
uint32_t min = (uint32_t)luaL_checkinteger(L, 2);
uint32_t max = (uint32_t)luaL_checkinteger(L, 3);
ret = (ret_t)edit_set_text_limit(widget, min, max);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_edit_set_int_limit(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
int32_t min = (int32_t)luaL_checkinteger(L, 2);
int32_t max = (int32_t)luaL_checkinteger(L, 3);
ret = (ret_t)edit_set_int_limit(widget, min, max);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_edit_set_float_limit(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
float min = (float)luaL_checknumber(L, 2);
float max = (float)luaL_checknumber(L, 3);
float step = (float)luaL_checknumber(L, 4);
ret = (ret_t)edit_set_float_limit(widget, min, max, step);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_edit_set_readonly(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
bool_t readonly = (bool_t)lua_toboolean(L, 2);
ret = (ret_t)edit_set_readonly(widget, readonly);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_edit_set_input_type(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
input_type_t type = (input_type_t)luaL_checkinteger(L, 2);
ret = (ret_t)edit_set_input_type(widget, type);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_edit_set_input_tips(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
wchar_t* tips = (wchar_t*)lua_touserdata(L, 2);
ret = (ret_t)edit_set_input_tips(widget, tips);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static const struct luaL_Reg edit_t_member_funcs[] = {
{"set_text_limit", wrap_edit_set_text_limit},
{"set_int_limit", wrap_edit_set_int_limit},
{"set_float_limit", wrap_edit_set_float_limit},
{"set_readonly", wrap_edit_set_readonly},
{"set_input_type", wrap_edit_set_input_type},
{"set_input_tips", wrap_edit_set_input_tips},
{NULL, NULL}};
static int wrap_edit_t_set_prop(lua_State* L) {
edit_t* obj = (edit_t*)lftk_checkudata(L, 1, "edit_t");
const char* name = (const char*)luaL_checkstring(L, 2);
(void)obj;
(void)name;
return wrap_widget_t_set_prop(L);
printf("%s: not supported %s\n", __func__, name);
return 0;
}
static int wrap_edit_t_get_prop(lua_State* L) {
edit_t* obj = (edit_t*)lftk_checkudata(L, 1, "edit_t");
const char* name = (const char*)luaL_checkstring(L, 2);
const luaL_Reg* ret = find_member(edit_t_member_funcs, name);
(void)obj;
(void)name;
if (ret) {
lua_pushcfunction(L, ret->func);
return 1;
} else {
return wrap_widget_t_get_prop(L);
}
}
static void edit_t_init(lua_State* L) {
static const struct luaL_Reg static_funcs[] = {{"create", wrap_edit_create}, {NULL, NULL}};
static const struct luaL_Reg index_funcs[] = {
{"__index", wrap_edit_t_get_prop}, {"__newindex", wrap_edit_t_set_prop}, {NULL, NULL}};
luaL_newmetatable(L, "lftk.edit_t");
lua_pushstring(L, "__index");
lua_pushvalue(L, -2);
lua_settable(L, -3);
luaL_openlib(L, NULL, index_funcs, 0);
luaL_openlib(L, "Edit", static_funcs, 0);
lua_settop(L, 0);
}
static void event_type_t_init(lua_State* L) {
lua_newtable(L);
lua_setglobal(L, "EventType");
@ -399,6 +562,14 @@ static void event_type_t_init(lua_State* L) {
lua_pushinteger(L, EVT_CLICK);
lua_settable(L, -3);
lua_pushstring(L, "FOCUS");
lua_pushinteger(L, EVT_FOCUS);
lua_settable(L, -3);
lua_pushstring(L, "BLUR");
lua_pushinteger(L, EVT_BLUR);
lua_settable(L, -3);
lua_pushstring(L, "KEY_DOWN");
lua_pushinteger(L, EVT_KEY_DOWN);
lua_settable(L, -3);
@ -526,6 +697,15 @@ static int wrap_pointer_event_t_set_prop(lua_State* L) {
} else if (strcmp(name, "pressed") == 0) {
printf("pressed is readonly\n");
return 0;
} else if (strcmp(name, "alt") == 0) {
printf("alt is readonly\n");
return 0;
} else if (strcmp(name, "ctrl") == 0) {
printf("ctrl is readonly\n");
return 0;
} else if (strcmp(name, "shift") == 0) {
printf("shift is readonly\n");
return 0;
} else {
return wrap_event_t_set_prop(L);
}
@ -557,6 +737,18 @@ static int wrap_pointer_event_t_get_prop(lua_State* L) {
} else if (strcmp(name, "pressed") == 0) {
lua_pushboolean(L, (lua_Integer)(obj->pressed));
return 1;
} else if (strcmp(name, "alt") == 0) {
lua_pushboolean(L, (lua_Integer)(obj->alt));
return 1;
} else if (strcmp(name, "ctrl") == 0) {
lua_pushboolean(L, (lua_Integer)(obj->ctrl));
return 1;
} else if (strcmp(name, "shift") == 0) {
lua_pushboolean(L, (lua_Integer)(obj->shift));
return 1;
} else {
return wrap_event_t_get_prop(L);
@ -605,6 +797,9 @@ static int wrap_key_event_t_set_prop(lua_State* L) {
} else if (strcmp(name, "shift") == 0) {
printf("shift is readonly\n");
return 0;
} else if (strcmp(name, "caplock") == 0) {
printf("caplock is readonly\n");
return 0;
} else {
return wrap_event_t_set_prop(L);
}
@ -636,6 +831,10 @@ static int wrap_key_event_t_get_prop(lua_State* L) {
} else if (strcmp(name, "shift") == 0) {
lua_pushboolean(L, (lua_Integer)(obj->shift));
return 1;
} else if (strcmp(name, "caplock") == 0) {
lua_pushboolean(L, (lua_Integer)(obj->caplock));
return 1;
} else {
return wrap_event_t_get_prop(L);
@ -1899,6 +2098,14 @@ static void widget_state_t_init(lua_State* L) {
lua_pushstring(L, "STATE_UNCHECKED");
lua_pushinteger(L, WIDGET_STATE_UNCHECKED);
lua_settable(L, -3);
lua_pushstring(L, "STATE_EMPTY");
lua_pushinteger(L, WIDGET_STATE_EMPTY);
lua_settable(L, -3);
lua_pushstring(L, "STATE_ERROR");
lua_pushinteger(L, WIDGET_STATE_ERROR);
lua_settable(L, -3);
}
static void widget_type_t_init(lua_State* L) {
@ -2518,6 +2725,8 @@ void luaL_openlftk(lua_State* L) {
canvas_t_init(L);
check_button_t_init(L);
dialog_t_init(L);
input_type_t_init(L);
edit_t_init(L);
event_type_t_init(L);
event_t_init(L);
pointer_event_t_init(L);

303
src/base/edit.c Normal file
View File

@ -0,0 +1,303 @@
/**
* File: edit.h
* Author: Li XianJing <xianjimli@hotmail.com>
* Brief: edit
*
* Copyright (c) 2018 - 2018 Li XianJing <xianjimli@hotmail.com>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-04-05 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "base/mem.h"
#include "base/edit.h"
#include "base/keys.h"
#include "base/enums.h"
#include "base/events.h"
static ret_t edit_on_paint_self(widget_t* widget, canvas_t* c) {
edit_t* edit = EDIT(widget);
wstr_t* str = &(widget->text);
if (str->size == 0) {
str = &(edit->tips);
widget_set_state(widget, WIDGET_STATE_EMPTY);
}
return widget_paint_helper(widget, c, NULL, str);
}
static ret_t edit_on_key_down(widget_t* widget, key_event_t* e) {
uint32_t key = e->key;
edit_t* edit = EDIT(widget);
widget_state_t state = WIDGET_STATE_FOCUSED;
input_type_t input_type = edit->limit.type;
if (isprint(key)) {
switch (input_type) {
case INPUT_INT:
case INPUT_FLOAT: {
if (key >= FKEY_0 && key <= FKEY_9) {
wstr_push(&(widget->text), key);
} else if (widget->text.size == 0 && (key == '-' || key == '+')) {
wstr_push(&(widget->text), key);
} else if (input_type == INPUT_FLOAT && key == '.') {
if (wcschr(widget->text.str, '.') == NULL) {
wstr_push(&(widget->text), key);
}
}
break;
}
default: {
if (widget->text.size < edit->limit.t.max) {
wstr_push(&(widget->text), key);
}
}
}
} else if (key == FKEY_BACKSPACE) {
if (widget->text.size > 0) {
wstr_pop(&(widget->text));
}
}
if (widget->text.size == 0) {
state = WIDGET_STATE_EMPTY;
} else if (input_type == INPUT_TEXT && edit->limit.t.min > widget->text.size) {
state = WIDGET_STATE_ERROR;
}
widget_invalidate(widget, NULL);
widget_set_state(widget, state);
return RET_OK;
}
static ret_t edit_on_key_up(widget_t* widget, key_event_t* e) { return RET_OK; }
static ret_t edit_on_blur(edit_t* edit) {
widget_set_state(WIDGETP(edit), WIDGET_STATE_NORMAL);
return RET_OK;
}
static ret_t edit_on_event(widget_t* widget, event_t* e) {
uint16_t type = e->type;
switch (type) {
case EVT_POINTER_DOWN:
widget_set_state(widget, WIDGET_STATE_FOCUSED);
break;
case EVT_KEY_DOWN: {
key_event_t* evt = (key_event_t*)e;
edit_on_key_down(widget, evt);
break;
}
case EVT_KEY_UP: {
key_event_t* evt = (key_event_t*)e;
edit_on_key_up(widget, evt);
break;
}
case EVT_BLUR: {
edit_on_blur(EDIT(widget));
break;
}
default:
break;
}
return RET_OK;
}
ret_t edit_set_text_limit(widget_t* widget, uint32_t min, uint32_t max) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
edit->limit.t.min = min;
edit->limit.t.max = max;
edit->limit.type = INPUT_TEXT;
return RET_OK;
}
ret_t edit_set_int_limit(widget_t* widget, int32_t min, int32_t max) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
edit->limit.i.min = min;
edit->limit.i.max = max;
edit->limit.type = INPUT_INT;
return RET_OK;
}
ret_t edit_set_float_limit(widget_t* widget, float min, float max, float step) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
edit->limit.f.min = min;
edit->limit.f.max = max;
edit->limit.f.step = step;
edit->limit.type = INPUT_FLOAT;
return RET_OK;
}
ret_t edit_set_readonly(widget_t* widget, bool_t readonly) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
edit->readonly = readonly;
return RET_OK;
}
ret_t edit_set_input_type(widget_t* widget, input_type_t type) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
edit->limit.type = type;
return RET_OK;
}
ret_t edit_set_input_tips(widget_t* widget, const wchar_t* tips) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL && tips != NULL, RET_BAD_PARAMS);
return wstr_set(&(edit->tips), tips);
}
static ret_t edit_get_prop(widget_t* widget, const char* name, value_t* v) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (strcmp(name, "min") == 0) {
if (edit->limit.type == INPUT_INT) {
value_set_int(v, edit->limit.i.min);
} else if (edit->limit.type == INPUT_TEXT) {
value_set_uint32(v, edit->limit.t.min);
} else if (edit->limit.type == INPUT_FLOAT) {
value_set_float(v, edit->limit.f.min);
} else {
return RET_NOT_FOUND;
}
return RET_OK;
} else if (strcmp(name, "max") == 0) {
if (edit->limit.type == INPUT_INT) {
value_set_int(v, edit->limit.i.max);
} else if (edit->limit.type == INPUT_TEXT) {
value_set_uint32(v, edit->limit.t.max);
} else if (edit->limit.type == INPUT_FLOAT) {
value_set_float(v, edit->limit.f.max);
} else {
return RET_NOT_FOUND;
}
return RET_OK;
} else if (strcmp(name, "step") == 0) {
if (edit->limit.type == INPUT_FLOAT) {
value_set_float(v, edit->limit.f.step);
return RET_OK;
} else {
return RET_NOT_FOUND;
}
} else if (strcmp(name, "input_type") == 0) {
value_set_uint32(v, edit->limit.type);
return RET_OK;
} else if (strcmp(name, "readonly") == 0) {
value_set_bool(v, edit->readonly);
return RET_OK;
} else if (strcmp(name, "tips") == 0) {
value_set_wstr(v, edit->tips.str);
return RET_OK;
}
return RET_NOT_FOUND;
}
static ret_t edit_set_prop(widget_t* widget, const char* name, const value_t* v) {
edit_t* edit = EDIT(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (strcmp(name, "min") == 0) {
if (edit->limit.type == INPUT_INT) {
edit->limit.i.min = value_int(v);
} else if (edit->limit.type == INPUT_TEXT) {
edit->limit.t.min = value_uint32(v);
} else if (edit->limit.type == INPUT_FLOAT) {
edit->limit.f.min = value_float(v);
} else {
return RET_NOT_FOUND;
}
return RET_OK;
} else if (strcmp(name, "max") == 0) {
if (edit->limit.type == INPUT_INT) {
edit->limit.i.max = value_int(v);
} else if (edit->limit.type == INPUT_TEXT) {
edit->limit.t.max = value_uint32(v);
} else if (edit->limit.type == INPUT_FLOAT) {
edit->limit.f.max = value_float(v);
} else {
return RET_NOT_FOUND;
}
return RET_OK;
} else if (strcmp(name, "step") == 0) {
if (edit->limit.type == INPUT_FLOAT) {
edit->limit.f.step = value_float(v);
return RET_OK;
} else {
return RET_NOT_FOUND;
}
} else if (strcmp(name, "input_type") == 0) {
if (v->type == VALUE_TYPE_STRING) {
const key_type_value_t* kv = input_type_find(value_str(v));
if (kv != NULL) {
edit->limit.type = kv->value;
}
} else {
edit->limit.type = value_int(v);
}
return RET_OK;
} else if (strcmp(name, "readonly") == 0) {
edit->readonly = value_bool(v);
return RET_OK;
} else if (strcmp(name, "tips") == 0) {
if (v->type == VALUE_TYPE_STRING) {
wstr_set_utf8(&(edit->tips), value_str(v));
return RET_OK;
} else if (v->type == VALUE_TYPE_WSTRING) {
wstr_set(&(edit->tips), value_wstr(v));
return RET_OK;
}
return RET_BAD_PARAMS;
}
return RET_NOT_FOUND;
}
static const widget_vtable_t s_edit_vtable = {.on_paint_self = edit_on_paint_self,
.set_prop = edit_set_prop,
.get_prop = edit_get_prop,
.on_event = edit_on_event};
widget_t* edit_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
widget_t* widget = NULL;
edit_t* edit = MEM_ZALLOC(edit_t);
return_value_if_fail(edit != NULL, NULL);
widget = WIDGETP(edit);
widget_init(widget, parent, WIDGET_EDIT);
widget_move_resize(widget, x, y, w, h);
widget->vt = &s_edit_vtable;
edit_set_text_limit(widget, 0, 1204);
return widget;
}

189
src/base/edit.h Normal file
View File

@ -0,0 +1,189 @@
/**
* File: edit.h
* Author: Li XianJing <xianjimli@hotmail.com>
* Brief: edit
*
* Copyright (c) 2018 - 2018 Li XianJing <xianjimli@hotmail.com>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-02-06 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef LFTK_EDIT_H
#define LFTK_EDIT_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @enum input_type_t
* @scriptable
* @prefix INPUT_
*
*/
typedef enum _input_type_t {
/**
* @const INPUT_TEXT
*
*/
INPUT_TEXT = 0,
/**
* @const INPUT_INT
*
*/
INPUT_INT,
/**
* @const INPUT_HEX
* 16
*/
INPUT_HEX,
/**
* @const INPUT_FLOAT
*
*/
INPUT_FLOAT,
/**
* @const INPUT_EMAIL
*
*/
INPUT_EMAIL,
/**
* @const INPUT_PHONE
*
*/
INPUT_PHONE
} input_type_t;
typedef struct _input_limit_t {
input_type_t type;
union {
struct {
uint32_t min;
uint32_t max;
} t;
struct {
uint32_t min;
uint32_t max;
} i;
struct {
float min;
float max;
float step;
} f;
};
} input_limit_t;
/**
* @class edit_t
* @parent widget_t
* @scriptable
*
*/
typedef struct _edit_t {
widget_t widget;
uint16_t visible_end;
uint16_t visible_start;
uint16_t selected_start;
uint16_t selected_end;
point_t caret;
bool_t caret_visible;
bool_t readonly;
wstr_t tips;
input_limit_t limit;
} edit_t;
/**
* @method edit_create
* @constructor
* edit对象
* @param {widget_t*} parent
* @param {xy_t} x x坐标
* @param {xy_t} y y坐标
* @param {wh_t} w
* @param {wh_t} h
*
* @return {widget_t*}
*/
widget_t* edit_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method edit_set_text_limit
* max个字符min个字符时进入error状态
* @param {widget_t*} widget widget对象
* @param {uint32_t} min
* @param {uint32_t} max
*
* @return {ret_t} RET_OK表示成功
*/
ret_t edit_set_text_limit(widget_t* widget, uint32_t min, uint32_t max);
/**
* @method edit_set_int_limit
*
* @param {widget_t*} widget widget对象
* @param {int32_t} min
* @param {int32_t} max
*
* @return {ret_t} RET_OK表示成功
*/
ret_t edit_set_int_limit(widget_t* widget, int32_t min, int32_t max);
/**
* @method edit_set_float_limit
*
* @param {widget_t*} widget widget对象
* @param {float} min
* @param {float} max
* @param {float} step
*
* @return {ret_t} RET_OK表示成功
*/
ret_t edit_set_float_limit(widget_t* widget, float min, float max, float step);
/**
* @method edit_set_readonly
*
* @param {widget_t*} widget widget对象
* @param {bool_t} readonly
*
* @return {ret_t} RET_OK表示成功
*/
ret_t edit_set_readonly(widget_t* widget, bool_t readonly);
/**
* @method edit_set_input_type
*
* @param {widget_t*} widget widget对象
* @param {input_type_t} type
*
* @return {ret_t} RET_OK表示成功
*/
ret_t edit_set_input_type(widget_t* widget, input_type_t type);
/**
* @method edit_set_input_tips
*
* @param {widget_t*} widget widget对象
* @param {wchar_t*} tips
*
* @return {ret_t} RET_OK表示成功
*/
ret_t edit_set_input_tips(widget_t* widget, const wchar_t* tips);
#define EDIT(widget) ((edit_t*)(widget))
END_C_DECLS
#endif /*LFTK_EDIT_H*/

View File

@ -19,6 +19,7 @@
*
*/
#include "base/edit.h"
#include "base/enums.h"
#include "base/widget.h"
#include "base/resource_manager.h"
@ -51,6 +52,7 @@ static const key_type_value_t style_id_name_value[] = {
{"bg-color", TYPE_COLOR, STYLE_ID_BG_COLOR},
{"fg-color", TYPE_COLOR, STYLE_ID_FG_COLOR},
{"text-color", TYPE_COLOR, STYLE_ID_TEXT_COLOR},
{"tips-text-color", TYPE_COLOR, STYLE_ID_TIPS_TEXT_COLOR},
{"border-color", TYPE_COLOR, STYLE_ID_BORDER_COLOR},
{"font-name", TYPE_STRING, STYLE_ID_FONT_NAME},
{"font-size", TYPE_INT, STYLE_ID_FONT_SIZE},
@ -65,14 +67,20 @@ static const key_type_value_t style_id_name_value[] = {
{"margin", TYPE_INT, STYLE_ID_MARGIN}};
static const key_type_value_t widget_state_name_value[] = {
{"normal", 0, WIDGET_STATE_NORMAL}, {"over", 0, WIDGET_STATE_OVER},
{"pressed", 0, WIDGET_STATE_PRESSED}, {"disable", 0, WIDGET_STATE_DISABLE},
{"focused", 0, WIDGET_STATE_FOCUSED}, {"checked", 0, WIDGET_STATE_CHECKED},
{"unchecked", 0, WIDGET_STATE_UNCHECKED}};
{"normal", 0, WIDGET_STATE_NORMAL}, {"over", 0, WIDGET_STATE_OVER},
{"pressed", 0, WIDGET_STATE_PRESSED}, {"disable", 0, WIDGET_STATE_DISABLE},
{"focused", 0, WIDGET_STATE_FOCUSED}, {"checked", 0, WIDGET_STATE_CHECKED},
{"unchecked", 0, WIDGET_STATE_UNCHECKED}, {"error", 0, WIDGET_STATE_ERROR},
{"empty", 0, WIDGET_STATE_EMPTY}};
static const key_type_value_t align_v_name_value[] = {
{"top", 0, ALIGN_V_TOP}, {"middle", 0, ALIGN_V_MIDDLE}, {"bottom", 0, ALIGN_V_BOTTOM}};
static const key_type_value_t input_type_name_value[] = {
{"int", 0, INPUT_INT}, {"float", 0, INPUT_FLOAT}, {"text", 0, INPUT_TEXT},
{"email", 0, INPUT_EMAIL}, {"phone", 0, INPUT_PHONE},
};
static const key_type_value_t align_h_name_value[] = {
{"left", 0, ALIGN_H_LEFT}, {"center", 0, ALIGN_H_CENTER}, {"right", 0, ALIGN_H_RIGHT}};
@ -170,3 +178,7 @@ const key_type_value_t* image_draw_type_find_by_value(uint32_t value) {
return find_item_by_value(image_draw_type_name_value, ARRAY_SIZE(image_draw_type_name_value),
value);
}
const key_type_value_t* input_type_find(const char* name) {
return find_item(input_type_name_value, ARRAY_SIZE(input_type_name_value), name);
}

View File

@ -40,6 +40,7 @@ const key_type_value_t* widget_type_find_by_value(uint32_t value);
const key_type_value_t* style_id_find(const char* name);
const key_type_value_t* style_id_find_by_value(uint32_t value);
const key_type_value_t* input_type_find(const char* name);
const key_type_value_t* widget_state_find(const char* name);
const key_type_value_t* align_v_type_find(const char* name);
const key_type_value_t* align_h_type_find(const char* name);

View File

@ -69,6 +69,16 @@ typedef enum _event_type_t {
*
*/
EVT_CLICK,
/**
* @const EVT_FOCUS
*
*/
EVT_FOCUS,
/**
* @const EVT_BLUR
*
*/
EVT_BLUR,
/**
* @const EVT_KEY_DOWN
*
@ -185,6 +195,25 @@ typedef struct _pointer_event_t {
*
*/
uint8_t pressed : 1;
/**
* @property {bool_t} alt
* @readonly
* alt键是否按下
*/
uint8_t alt : 1;
/**
* @property {bool_t} ctrl
* @readonly
* ctrl键是否按下
*/
uint8_t ctrl : 1;
/**
* @property {bool_t} shift
* @readonly
* shift键是否按下
*/
uint8_t shift : 1;
} pointer_event_t;
/**
@ -207,11 +236,12 @@ pointer_event_t* pointer_event_cast(event_t* event);
typedef struct _key_event_t {
event_t e;
/**
* @property {uint8_t} key
* @property {uint32_t} key
* @readonly
*
*/
uint8_t key;
uint32_t key;
/**
* @property {bool_t} alt
* @readonly
@ -230,6 +260,12 @@ typedef struct _key_event_t {
* shift键是否按下
*/
uint8_t shift : 1;
/**
* @property {bool_t} caplock
* @readonly
* caplock键是否按下
*/
uint8_t caplock : 1;
} key_event_t;
/**

View File

@ -88,6 +88,11 @@ typedef enum _style_id_t {
*
*/
STYLE_ID_TEXT_COLOR,
/**
* @const STYLE_ID_TIPS_TEXT_COLOR
*
*/
STYLE_ID_TIPS_TEXT_COLOR,
/**
* @const STYLE_ID_TEXT_ALIGN_H
*

View File

@ -22,6 +22,7 @@
#ifndef TYPES_DEF_H
#define TYPES_DEF_H
#include <ctype.h>
#include <wchar.h>
#include <assert.h>
#include <stdint.h>

View File

@ -147,7 +147,7 @@ value_t* value_set_int32(value_t* v, int32_t value) {
}
int32_t value_int32(const value_t* v) {
return_value_if_fail(v->type == VALUE_TYPE_INT32, 0);
return_value_if_fail(v->type == VALUE_TYPE_INT32, value_int(v));
return v->value.i32;
}
@ -161,7 +161,7 @@ value_t* value_set_uint32(value_t* v, uint32_t value) {
}
uint32_t value_uint32(const value_t* v) {
return_value_if_fail(v->type == VALUE_TYPE_UINT32, 0);
return_value_if_fail(v->type == VALUE_TYPE_UINT32, value_int(v));
return v->value.u32;
}
@ -221,9 +221,47 @@ value_t* value_set_float(value_t* v, float value) {
}
float value_float(const value_t* v) {
return_value_if_fail(v->type == VALUE_TYPE_FLOAT, 0.0);
return_value_if_fail(v->type != VALUE_TYPE_INVALID, 0);
return v->value.f32;
switch (v->type) {
case VALUE_TYPE_INT8: {
return (float)v->value.i8;
}
case VALUE_TYPE_UINT8: {
return (float)v->value.u8;
}
case VALUE_TYPE_INT16: {
return (float)v->value.i16;
}
case VALUE_TYPE_UINT16: {
return (float)v->value.u16;
}
case VALUE_TYPE_INT32: {
return (float)v->value.i32;
}
case VALUE_TYPE_UINT32: {
return (float)v->value.u32;
}
case VALUE_TYPE_INT64: {
return (float)v->value.i64;
}
case VALUE_TYPE_UINT64: {
return (float)v->value.u64;
}
case VALUE_TYPE_FLOAT: {
return (float)v->value.f32;
}
case VALUE_TYPE_DOUBLE: {
return (float)v->value.f64;
}
case VALUE_TYPE_STRING: {
return ftk_atof(v->value.str);
}
default:
break;
}
return 0;
}
value_t* value_set_double(value_t* v, double value) {

View File

@ -83,9 +83,10 @@ ret_t widget_use_style(widget_t* widget, const char* value) {
}
ret_t widget_set_text(widget_t* widget, const wchar_t* text) {
return_value_if_fail(widget != NULL && text != NULL, RET_BAD_PARAMS);
value_t v;
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
return wstr_set(&(widget->text), text);
return widget_set_prop(widget, "text", value_set_wstr(&v, text));
}
uint32_t widget_get_value(widget_t* widget) {
@ -96,9 +97,10 @@ uint32_t widget_get_value(widget_t* widget) {
}
const wchar_t* widget_get_text(widget_t* widget) {
return_value_if_fail(widget != NULL, NULL);
value_t v;
return_value_if_fail(widget != NULL, 0);
return widget->text.str;
return widget_get_prop(widget, "text", &v) == RET_OK ? value_wstr(&v) : 0;
}
ret_t widget_set_name(widget_t* widget, const char* name) {
@ -178,6 +180,10 @@ ret_t widget_remove_child(widget_t* widget, widget_t* child) {
widget->target = NULL;
}
if (widget->key_target == child) {
widget->key_target = NULL;
}
return array_remove(widget->children, NULL, child) ? RET_OK : RET_NOT_FOUND;
}
@ -501,11 +507,6 @@ ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
if (str != NULL) {
strncpy(widget->name, str, NAME_LEN);
}
} else if (strcmp(name, "text") == 0) {
const wchar_t* text = value_wstr(v);
if (text != NULL) {
widget_set_text(widget, text);
}
} else {
if (widget->vt->set_prop) {
ret = widget->vt->set_prop(widget, name, v);
@ -516,6 +517,8 @@ ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
if (ret != RET_NOT_FOUND) {
widget_dispatch(widget, &e);
} else if (strcmp(name, "text") == 0) {
ret = wstr_from_value(&(widget->text), v);
}
return ret;
@ -562,11 +565,11 @@ ret_t widget_get_prop(widget_t* widget, const char* name, value_t* v) {
value_set_bool(v, widget->enable);
} else if (strcmp(name, "name") == 0) {
value_set_str(v, widget->name);
} else if (strcmp(name, "text") == 0) {
value_set_wstr(v, widget->text.str);
} else {
if (widget->vt->get_prop) {
ret = widget->vt->get_prop(widget, name, v);
} else if (strcmp(name, "text") == 0) {
value_set_wstr(v, widget->text.str);
} else {
ret = RET_NOT_FOUND;
}
@ -616,8 +619,8 @@ ret_t widget_on_keydown(widget_t* widget, key_event_t* e) {
widget_dispatch(widget, (event_t*)e);
if (widget->vt->on_keydown) {
ret = widget->vt->on_keydown(widget, e);
} else if (widget->target != NULL) {
widget_on_keydown(widget->target, e);
} else if (widget->key_target != NULL) {
widget_on_keydown(widget->key_target, e);
}
return ret;
@ -631,8 +634,8 @@ ret_t widget_on_keyup(widget_t* widget, key_event_t* e) {
widget_dispatch(widget, (event_t*)e);
if (widget->vt->on_keyup) {
ret = widget->vt->on_keyup(widget, e);
} else if (widget->target != NULL) {
widget_on_keyup(widget->target, e);
} else if (widget->key_target != NULL) {
widget_on_keyup(widget->key_target, e);
}
return ret;
@ -666,7 +669,16 @@ ret_t widget_on_pointer_down(widget_t* widget, pointer_event_t* e) {
target = widget_find_target(widget, e->x, e->y);
if (target != NULL && target->enable) {
event_t focus = {EVT_FOCUS, target};
if (widget->key_target) {
event_t blur = {EVT_BLUR, widget->key_target};
widget_dispatch(widget->key_target, &blur);
}
widget->target = target;
widget->key_target = target;
widget_dispatch(widget->key_target, &focus);
}
if (widget->target != NULL) {

View File

@ -79,7 +79,17 @@ typedef enum _widget_state_t {
* @const WIDGET_STATE_UNCHECKED
*
*/
WIDGET_STATE_UNCHECKED
WIDGET_STATE_UNCHECKED,
/**
* @const WIDGET_STATE_EMPTY
*
*/
WIDGET_STATE_EMPTY,
/**
* @const WIDGET_STATE_ERROR
*
*/
WIDGET_STATE_ERROR
} widget_state_t;
/**
@ -337,6 +347,13 @@ struct _widget_t {
*
*/
widget_t* target;
/**
* @property {widget_t*} key_target
* @readonly
* @scriptable no
*
*/
widget_t* key_target;
/**
* @property {array_t*} children
* @readonly

View File

@ -66,7 +66,7 @@ ret_t wstr_set_utf8(wstr_t* str, const char* text) {
return_value_if_fail(str != NULL && text != NULL, RET_BAD_PARAMS);
return_value_if_fail(wstr_extend(str, strlen(text) + 1) == RET_OK, RET_OOM);
utf8_to_utf16(text, str->str, str->capacity-1);
utf8_to_utf16(text, str->str, str->capacity - 1);
str->size = wcslen(str->str);
return RET_OK;
@ -155,11 +155,11 @@ ret_t wstr_from_float(wstr_t* str, float v) {
ret_t wstr_from_value(wstr_t* str, value_t* v) {
return_value_if_fail(str != NULL && v != NULL, RET_BAD_PARAMS);
if(v->type == VALUE_TYPE_STRING) {
if (v->type == VALUE_TYPE_STRING) {
return wstr_set_utf8(str, value_str(v));
} else if(v->type == VALUE_TYPE_WSTRING) {
} else if (v->type == VALUE_TYPE_WSTRING) {
return wstr_set(str, value_wstr(v));
} else if(v->type == VALUE_TYPE_FLOAT) {
} else if (v->type == VALUE_TYPE_FLOAT) {
return wstr_from_float(str, value_float(v));
} else {
return wstr_from_int(str, value_int(v));

View File

@ -19,7 +19,6 @@
*
*/
#ifndef WSTR_H
#define WSTR_H

View File

@ -29,6 +29,7 @@
#include "base/button.h"
#include "base/dialog.h"
#include "base/slider.h"
#include "base/edit.h"
#include "base/group_box.h"
#include "base/check_button.h"
#include "base/progress_bar.h"
@ -77,6 +78,9 @@ static ret_t ui_builder_default_on_widget_start(ui_builder_t* b, const widget_de
case WIDGET_LABEL:
widget = label_create(parent, x, y, w, h);
break;
case WIDGET_EDIT:
widget = edit_create(parent, x, y, w, h);
break;
case WIDGET_PROGRESS_BAR:
widget = progress_bar_create(parent, x, y, w, h);
break;
@ -118,14 +122,7 @@ static ret_t ui_builder_default_on_widget_start(ui_builder_t* b, const widget_de
static ret_t ui_builder_default_on_widget_prop(ui_builder_t* b, const char* name,
const char* value) {
value_t v;
if (strcmp(name, "text") == 0) {
wchar_t str[128];
uint32_t len = strlen(value);
return_value_if_fail(len < ARRAY_SIZE(str), RET_BAD_PARAMS);
value_set_wstr(&v, utf8_to_utf16(value, str, ARRAY_SIZE(str)));
widget_set_prop(b->widget, name, &v);
} else if (strcmp(name, "align_v") == 0) {
if (strcmp(name, "align_v") == 0) {
const key_type_value_t* item = align_v_type_find(value);
if (item != NULL) {
value_set_int(&v, item->value);

110
tests/edit_test.cc Normal file
View File

@ -0,0 +1,110 @@
#include "base/edit.h"
#include "base/canvas.h"
#include "base/widget.h"
#include "font_dummy.h"
#include "lcd_log.h"
#include "gtest/gtest.h"
#include <stdlib.h>
TEST(Edit, int) {
value_t v1;
value_t v2;
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
ASSERT_EQ(edit_set_int_limit(b, 0, 100), RET_OK);
ASSERT_EQ(widget_get_prop(b, "min", &v2), RET_OK);
ASSERT_EQ(0, value_int(&v2));
ASSERT_EQ(widget_get_prop(b, "input_type", &v2), RET_OK);
ASSERT_EQ(INPUT_INT, value_int(&v2));
ASSERT_EQ(widget_get_prop(b, "max", &v2), RET_OK);
ASSERT_EQ(100, value_int(&v2));
value_set_int(&v1, 10);
ASSERT_EQ(widget_set_prop(b, "min", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "min", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
value_set_int(&v1, 100);
ASSERT_EQ(widget_set_prop(b, "max", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "max", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
widget_destroy(b);
}
TEST(Edit, text) {
value_t v1;
value_t v2;
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
ASSERT_EQ(edit_set_text_limit(b, 0, 100), RET_OK);
ASSERT_EQ(widget_get_prop(b, "min", &v2), RET_OK);
ASSERT_EQ(0, value_int(&v2));
ASSERT_EQ(widget_get_prop(b, "input_type", &v2), RET_OK);
ASSERT_EQ(INPUT_TEXT, value_int(&v2));
ASSERT_EQ(widget_get_prop(b, "max", &v2), RET_OK);
ASSERT_EQ(100, value_int(&v2));
value_set_int(&v1, 10);
ASSERT_EQ(widget_set_prop(b, "min", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "min", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
value_set_int(&v1, 100);
ASSERT_EQ(widget_set_prop(b, "max", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "max", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
widget_destroy(b);
}
TEST(Edit, float) {
value_t v1;
value_t v2;
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
ASSERT_EQ(edit_set_float_limit(b, 0, 100, 0.1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "min", &v2), RET_OK);
ASSERT_EQ(0, value_float(&v2));
ASSERT_EQ(widget_get_prop(b, "input_type", &v2), RET_OK);
ASSERT_EQ(INPUT_FLOAT, value_int(&v2));
ASSERT_EQ(widget_get_prop(b, "max", &v2), RET_OK);
ASSERT_EQ(100, value_float(&v2));
ASSERT_EQ(widget_get_prop(b, "step", &v2), RET_OK);
ASSERT_EQ(0.1 - value_float(&v2) < 0.001, true);
value_set_int(&v1, 10);
ASSERT_EQ(widget_set_prop(b, "min", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "min", &v2), RET_OK);
ASSERT_EQ(value_float(&v1), value_float(&v2));
value_set_int(&v1, 100);
ASSERT_EQ(widget_set_prop(b, "max", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "max", &v2), RET_OK);
ASSERT_EQ(value_float(&v1), value_float(&v2));
widget_destroy(b);
}
TEST(Edit, basic) {
value_t v1;
value_t v2;
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
ASSERT_EQ(edit_set_readonly(b, TRUE), RET_OK);
ASSERT_EQ(EDIT(b)->readonly, TRUE);
value_set_bool(&v1, FALSE);
ASSERT_EQ(widget_set_prop(b, "readonly", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "readonly", &v2), RET_OK);
ASSERT_EQ(value_bool(&v1), value_bool(&v2));
widget_destroy(b);
}

View File

@ -159,16 +159,16 @@ TEST(WStr, value) {
ASSERT_EQ(wstr_from_value(&str, &v1), RET_OK);
ASSERT_EQ(wstr_to_int(&str, &vi), RET_OK);
ASSERT_EQ(value_int(&v1), vi);
value_set_float(&v1, 1234);
ASSERT_EQ(wstr_from_value(&str, &v1), RET_OK);
ASSERT_EQ(wstr_to_float(&str, &vf), RET_OK);
ASSERT_EQ(value_float(&v1), vf);
value_set_str(&v1, "a12345");
ASSERT_EQ(wstr_from_value(&str, &v1), RET_OK);
ASSERT_EQ(wcscmp(str.str, L"a12345"), 0);
value_set_wstr(&v1, L"b12345");
ASSERT_EQ(wstr_from_value(&str, &v1), RET_OK);
ASSERT_EQ(wcscmp(str.str, L"b12345"), 0);

View File

@ -392,6 +392,170 @@
"properties": [],
"header": "base/dialog.h"
},
{
"type": "enum",
"header": "base/edit.h",
"name": "input_type_t",
"prefix": "INPUT_",
"scriptable": true,
"consts": [
{
"name": "INPUT_TEXT"
},
{
"name": "INPUT_INT"
},
{
"name": "INPUT_HEX"
},
{
"name": "INPUT_FLOAT"
},
{
"name": "INPUT_EMAIL"
},
{
"name": "INPUT_PHONE"
}
]
},
{
"type": "class",
"name": "edit_t",
"parent": "widget_t",
"scriptable": true,
"methods": [
{
"params": [
{
"type": "widget_t*",
"name": "parent"
},
{
"type": "xy_t",
"name": "x"
},
{
"type": "xy_t",
"name": "y"
},
{
"type": "wh_t",
"name": "w"
},
{
"type": "wh_t",
"name": "h"
}
],
"name": "edit_create",
"isConstructor": true,
"return": "widget_t*"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "uint32_t",
"name": "min"
},
{
"type": "uint32_t",
"name": "max"
}
],
"name": "edit_set_text_limit",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "int32_t",
"name": "min"
},
{
"type": "int32_t",
"name": "max"
}
],
"name": "edit_set_int_limit",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "float",
"name": "min"
},
{
"type": "float",
"name": "max"
},
{
"type": "float",
"name": "step"
}
],
"name": "edit_set_float_limit",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "bool_t",
"name": "readonly"
}
],
"name": "edit_set_readonly",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "input_type_t",
"name": "type"
}
],
"name": "edit_set_input_type",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "wchar_t*",
"name": "tips"
}
],
"name": "edit_set_input_tips",
"return": "ret_t"
}
],
"properties": [],
"header": "base/edit.h"
},
{
"type": "enum",
"header": "base/events.h",
@ -420,6 +584,12 @@
{
"name": "EVT_CLICK"
},
{
"name": "EVT_FOCUS"
},
{
"name": "EVT_BLUR"
},
{
"name": "EVT_KEY_DOWN"
},
@ -510,6 +680,21 @@
"type": "bool_t",
"name": "pressed",
"readonly": true
},
{
"type": "bool_t",
"name": "alt",
"readonly": true
},
{
"type": "bool_t",
"name": "ctrl",
"readonly": true
},
{
"type": "bool_t",
"name": "shift",
"readonly": true
}
],
"header": "base/events.h"
@ -534,7 +719,7 @@
],
"properties": [
{
"type": "uint8_t",
"type": "uint32_t",
"name": "key",
"readonly": true
},
@ -552,6 +737,11 @@
"type": "bool_t",
"name": "shift",
"readonly": true
},
{
"type": "bool_t",
"name": "caplock",
"readonly": true
}
],
"header": "base/events.h"
@ -1134,6 +1324,9 @@
{
"name": "STYLE_ID_TEXT_COLOR"
},
{
"name": "STYLE_ID_TIPS_TEXT_COLOR"
},
{
"name": "STYLE_ID_TEXT_ALIGN_H"
},
@ -1764,6 +1957,12 @@
},
{
"name": "WIDGET_STATE_UNCHECKED"
},
{
"name": "WIDGET_STATE_EMPTY"
},
{
"name": "WIDGET_STATE_ERROR"
}
]
},