mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
improve tests and demos
This commit is contained in:
parent
4dddb0fe3f
commit
4c570f9f04
@ -10,4 +10,5 @@
|
||||
<check_button state="unchecked" bg-color="#f0f0f0" text-color="black" icon="unchecked" />
|
||||
<radio_button state="checked" bg-color="#f0f0f0" text-color="black" icon="radio_checked" />
|
||||
<radio_button state="unchecked" bg-color="#f0f0f0" text-color="black" icon="radio_unchecked" />
|
||||
<image style_type="1:border" border-color="#000000" bg-color="#e0e0e0"/>
|
||||
|
||||
|
@ -216,4 +216,4 @@ const unsigned char image_btn_blue_n[] = {
|
||||
0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,
|
||||
0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdb,0xff,0x04,0x3d,0xdc,0xff,
|
||||
0x04,0x3d,0xdc,0xff,0x0d,0x45,0xd6,0xfe,0x34,0x5d,0xca,0xf8,0x69,0x81,0xc2,0xe6,0xab,0xaf,0xbe,0xc0,
|
||||
0xc9,0xc9,0xc9,0x8c,0xcf,0xcf,0xcf,0x58,0xd0,0xd0,0xd0,0x31,0x00,0x00,0x00,0x00,0xfd,0xfd,0xfd,0xd9,};
|
||||
0xc9,0xc9,0xc9,0x8c,0xcf,0xcf,0xcf,0x58,0xd0,0xd0,0xd0,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_radio_checked[] = {
|
||||
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,};
|
||||
0xff,0x7f,0x00,0x00,};
|
||||
|
@ -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,};
|
||||
0xff,0x7f,0x00,0x00,};
|
||||
|
@ -1,31 +1,33 @@
|
||||
const unsigned char theme_default[] = {
|
||||
0x03,0x00,0x00,0x00,0x36,0x02,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,0x0c,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
|
||||
0x6c,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x95,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0xce,0x00,0x00,0x00,
|
||||
0x02,0x00,0x0a,0x00,0xee,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x0e,0x01,0x00,0x00,0x04,0x00,0x0a,0x00,
|
||||
0x2e,0x01,0x00,0x00,0x01,0x00,0x09,0x00,0x4e,0x01,0x00,0x00,0x01,0x00,0x0d,0x00,0x6e,0x01,0x00,0x00,
|
||||
0x06,0x00,0x0f,0x00,0x96,0x01,0x00,0x00,0x07,0x00,0x0f,0x00,0xba,0x01,0x00,0x00,0x06,0x00,0x10,0x00,
|
||||
0xe0,0x01,0x00,0x00,0x07,0x00,0x10,0x00,0x0a,0x02,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
|
||||
0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,
|
||||
0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,0x73,0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,
|
||||
0x00,0xf0,0xf0,0xf0,0xff,0x02,0x00,0x00,0x00,0x80,0x80,0x80,0xff,0x09,0x00,0x00,0x00,0x80,0x80,0x80,
|
||||
0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,
|
||||
0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,0x73,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,
|
||||
0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,
|
||||
0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,
|
||||
0x00,0x00,0xe0,0xe0,0xe0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,
|
||||
0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xbe,0xbe,0xbe,0xff,0x06,0x00,
|
||||
0x00,0x00,0xd0,0xd0,0xd0,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,
|
||||
0x03,0x00,0x00,0x00,0x56,0x02,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,0x0d,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
|
||||
0x74,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x9d,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0xd6,0x00,0x00,0x00,
|
||||
0x02,0x00,0x0a,0x00,0xf6,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x16,0x01,0x00,0x00,0x04,0x00,0x0a,0x00,
|
||||
0x36,0x01,0x00,0x00,0x01,0x00,0x09,0x00,0x56,0x01,0x00,0x00,0x01,0x00,0x0d,0x00,0x76,0x01,0x00,0x00,
|
||||
0x06,0x00,0x0f,0x00,0x9e,0x01,0x00,0x00,0x07,0x00,0x0f,0x00,0xc2,0x01,0x00,0x00,0x06,0x00,0x10,0x00,
|
||||
0xe8,0x01,0x00,0x00,0x07,0x00,0x10,0x00,0x12,0x02,0x00,0x00,0x01,0x01,0x0b,0x00,0x3e,0x02,0x00,0x00,
|
||||
0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
|
||||
0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,0x73,
|
||||
0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x02,0x00,0x00,0x00,0x80,0x80,0x80,
|
||||
0xff,0x09,0x00,0x00,0x00,0x80,0x80,0x80,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x04,0x00,0x00,
|
||||
0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,0x73,0x00,0x03,0x00,
|
||||
0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,
|
||||
0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,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,0x00,0x00,0x00,0xff,0x09,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,0x0a,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,0x0a,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,0x0a,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,0x0a,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,
|
||||
0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x00,0x00,0x00,0x00,};
|
||||
0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc0,0xc0,
|
||||
0xc0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,
|
||||
0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,
|
||||
0x00,0x00,0xbe,0xbe,0xbe,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,
|
||||
0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,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,0x00,0x00,0x00,0xff,0x09,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,0x0a,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,0x0a,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,0x0a,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,0x0a,0x00,
|
||||
0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,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,0x00,0x00,0x00,0x00,};
|
||||
|
4
demos/xml/draw_type/3patch_x.xml
Normal file
4
demos/xml/draw_type/3patch_x.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="btn_blue_n" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100%" h="30" image="btn_blue_n" draw_type="3patch_x"/>
|
||||
</window>
|
4
demos/xml/draw_type/3patch_y.xml
Normal file
4
demos/xml/draw_type/3patch_y.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="btn_blue_n" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="50" h="50%" image="btn_blue_n" draw_type="3patch_y"/>
|
||||
</window>
|
4
demos/xml/draw_type/9patch.xml
Normal file
4
demos/xml/draw_type/9patch.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="btn_blue_n" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100%" h="30%" image="btn_blue_n" draw_type="9patch"/>
|
||||
</window>
|
@ -1,4 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image x="0" y="50%" w="100%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100%" h="50%" image="earth" draw_type="center"/>
|
||||
</window>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image x="0" y="50%" w="100%" h="50%" image="earth" draw_type="repeat"/>
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100%" h="50%" image="earth" draw_type="repeat"/>
|
||||
</window>
|
||||
|
4
demos/xml/draw_type/repeat_x.xml
Normal file
4
demos/xml/draw_type/repeat_x.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100%" h="50" image="earth" draw_type="repeat_x"/>
|
||||
</window>
|
4
demos/xml/draw_type/repeat_y.xml
Normal file
4
demos/xml/draw_type/repeat_y.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="50" h="50%" image="earth" draw_type="repeat_y"/>
|
||||
</window>
|
4
demos/xml/draw_type/scale.xml
Normal file
4
demos/xml/draw_type/scale.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="50%" h="50%" image="earth" draw_type="scale"/>
|
||||
</window>
|
4
demos/xml/draw_type/scale_auto.xml
Normal file
4
demos/xml/draw_type/scale_auto.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100" h="50%" image="earth" draw_type="scale_auto"/>
|
||||
</window>
|
4
demos/xml/draw_type/scale_x.xml
Normal file
4
demos/xml/draw_type/scale_x.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="50" h="50%" image="earth" draw_type="scale_x"/>
|
||||
</window>
|
4
demos/xml/draw_type/scale_y.xml
Normal file
4
demos/xml/draw_type/scale_y.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480">
|
||||
<image style="1:border" x="0" y="0" w="50%" h="50%" image="earth" draw_type="center"/>
|
||||
<image style="1:border" x="0" y="50%" w="100%" h="80" image="earth" draw_type="scale_y"/>
|
||||
</window>
|
153
lua/lftk_lua.c
153
lua/lftk_lua.c
@ -4,7 +4,9 @@
|
||||
#include "lua/lauxlib.h"
|
||||
#include "base/utf8.h"
|
||||
#include "base/array.h"
|
||||
#include "base/bitmap.h"
|
||||
#include "base/button.h"
|
||||
#include "base/canvas.h"
|
||||
#include "base/check_button.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/events.h"
|
||||
@ -27,6 +29,8 @@
|
||||
|
||||
static int wrap_button_t_get_prop(lua_State* L);
|
||||
static int wrap_button_t_set_prop(lua_State* L);
|
||||
static int wrap_canvas_t_get_prop(lua_State* L);
|
||||
static int wrap_canvas_t_set_prop(lua_State* L);
|
||||
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);
|
||||
@ -37,6 +41,8 @@ static int wrap_pointer_event_t_get_prop(lua_State* L);
|
||||
static int wrap_pointer_event_t_set_prop(lua_State* L);
|
||||
static int wrap_key_event_t_get_prop(lua_State* L);
|
||||
static int wrap_key_event_t_set_prop(lua_State* L);
|
||||
static int wrap_paint_event_t_get_prop(lua_State* L);
|
||||
static int wrap_paint_event_t_set_prop(lua_State* L);
|
||||
static int wrap_group_box_t_get_prop(lua_State* L);
|
||||
static int wrap_group_box_t_set_prop(lua_State* L);
|
||||
static int wrap_image_t_get_prop(lua_State* L);
|
||||
@ -139,6 +145,48 @@ static void button_t_init(lua_State* L) {
|
||||
luaL_openlib(L, "Button", static_funcs, 0);
|
||||
lua_settop(L, 0);
|
||||
}
|
||||
|
||||
static const struct luaL_Reg canvas_t_member_funcs[] = {{NULL, NULL}};
|
||||
|
||||
static int wrap_canvas_t_set_prop(lua_State* L) {
|
||||
canvas_t* obj = (canvas_t*)lftk_checkudata(L, 1, "canvas_t");
|
||||
const char* name = (const char*)luaL_checkstring(L, 2);
|
||||
(void)obj;
|
||||
(void)name;
|
||||
printf("%s: not supported %s\n", __func__, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wrap_canvas_t_get_prop(lua_State* L) {
|
||||
canvas_t* obj = (canvas_t*)lftk_checkudata(L, 1, "canvas_t");
|
||||
const char* name = (const char*)luaL_checkstring(L, 2);
|
||||
const luaL_Reg* ret = find_member(canvas_t_member_funcs, name);
|
||||
|
||||
(void)obj;
|
||||
(void)name;
|
||||
if (ret) {
|
||||
lua_pushcfunction(L, ret->func);
|
||||
return 1;
|
||||
} else {
|
||||
printf("%s: not supported %s\n", __func__, name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void canvas_t_init(lua_State* L) {
|
||||
static const struct luaL_Reg static_funcs[] = {{NULL, NULL}};
|
||||
|
||||
static const struct luaL_Reg index_funcs[] = {
|
||||
{"__index", wrap_canvas_t_get_prop}, {"__newindex", wrap_canvas_t_set_prop}, {NULL, NULL}};
|
||||
|
||||
luaL_newmetatable(L, "lftk.canvas_t");
|
||||
lua_pushstring(L, "__index");
|
||||
lua_pushvalue(L, -2);
|
||||
lua_settable(L, -3);
|
||||
luaL_openlib(L, NULL, index_funcs, 0);
|
||||
luaL_openlib(L, "Canvas", static_funcs, 0);
|
||||
lua_settop(L, 0);
|
||||
}
|
||||
static int wrap_check_button_create(lua_State* L) {
|
||||
widget_t* ret = NULL;
|
||||
widget_t* parent = (widget_t*)lftk_checkudata(L, 1, "widget_t");
|
||||
@ -409,6 +457,18 @@ static void event_type_t_init(lua_State* L) {
|
||||
lua_pushstring(L, "PROP_CHANGED");
|
||||
lua_pushinteger(L, EVT_PROP_CHANGED);
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_pushstring(L, "PAINT");
|
||||
lua_pushinteger(L, EVT_PAINT);
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_pushstring(L, "BEFORE_PAINT");
|
||||
lua_pushinteger(L, EVT_BEFORE_PAINT);
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_pushstring(L, "AFTER_PAINT");
|
||||
lua_pushinteger(L, EVT_AFTER_PAINT);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
static const struct luaL_Reg event_t_member_funcs[] = {{NULL, NULL}};
|
||||
@ -620,6 +680,62 @@ static void key_event_t_init(lua_State* L) {
|
||||
luaL_openlib(L, "KeyEvent", static_funcs, 0);
|
||||
lua_settop(L, 0);
|
||||
}
|
||||
static int wrap_paint_event_cast(lua_State* L) {
|
||||
paint_event_t* ret = NULL;
|
||||
event_t* event = (event_t*)lftk_checkudata(L, 1, "event_t");
|
||||
ret = (paint_event_t*)paint_event_cast(event);
|
||||
|
||||
return lftk_newuserdata(L, ret, "/paint_event_t/event_t", "lftk.paint_event_t");
|
||||
}
|
||||
|
||||
static const struct luaL_Reg paint_event_t_member_funcs[] = {{NULL, NULL}};
|
||||
|
||||
static int wrap_paint_event_t_set_prop(lua_State* L) {
|
||||
paint_event_t* obj = (paint_event_t*)lftk_checkudata(L, 1, "paint_event_t");
|
||||
const char* name = (const char*)luaL_checkstring(L, 2);
|
||||
(void)obj;
|
||||
(void)name;
|
||||
if (strcmp(name, "c") == 0) {
|
||||
printf("c is readonly\n");
|
||||
return 0;
|
||||
} else {
|
||||
return wrap_event_t_set_prop(L);
|
||||
}
|
||||
}
|
||||
|
||||
static int wrap_paint_event_t_get_prop(lua_State* L) {
|
||||
paint_event_t* obj = (paint_event_t*)lftk_checkudata(L, 1, "paint_event_t");
|
||||
const char* name = (const char*)luaL_checkstring(L, 2);
|
||||
const luaL_Reg* ret = find_member(paint_event_t_member_funcs, name);
|
||||
|
||||
(void)obj;
|
||||
(void)name;
|
||||
if (ret) {
|
||||
lua_pushcfunction(L, ret->func);
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(name, "c") == 0) {
|
||||
return lftk_newuserdata(L, obj->c, "/canvas_t", "lftk.canvas_t");
|
||||
} else {
|
||||
return wrap_event_t_get_prop(L);
|
||||
}
|
||||
}
|
||||
|
||||
static void paint_event_t_init(lua_State* L) {
|
||||
static const struct luaL_Reg static_funcs[] = {{"cast", wrap_paint_event_cast}, {NULL, NULL}};
|
||||
|
||||
static const struct luaL_Reg index_funcs[] = {{"__index", wrap_paint_event_t_get_prop},
|
||||
{"__newindex", wrap_paint_event_t_set_prop},
|
||||
{NULL, NULL}};
|
||||
|
||||
luaL_newmetatable(L, "lftk.paint_event_t");
|
||||
lua_pushstring(L, "__index");
|
||||
lua_pushvalue(L, -2);
|
||||
lua_settable(L, -3);
|
||||
luaL_openlib(L, NULL, index_funcs, 0);
|
||||
luaL_openlib(L, "PaintEvent", static_funcs, 0);
|
||||
lua_settop(L, 0);
|
||||
}
|
||||
static int wrap_group_box_create(lua_State* L) {
|
||||
widget_t* ret = NULL;
|
||||
widget_t* parent = (widget_t*)lftk_checkudata(L, 1, "widget_t");
|
||||
@ -697,8 +813,21 @@ static int wrap_image_set_image_name(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int wrap_image_set_draw_type(lua_State* L) {
|
||||
ret_t ret = 0;
|
||||
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
|
||||
image_draw_type_t draw_type = (image_draw_type_t)luaL_checkinteger(L, 2);
|
||||
ret = (ret_t)image_set_draw_type(widget, draw_type);
|
||||
|
||||
lua_pushnumber(L, (lua_Number)(ret));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg image_t_member_funcs[] = {
|
||||
{"set_image_name", wrap_image_set_image_name}, {NULL, NULL}};
|
||||
{"set_image_name", wrap_image_set_image_name},
|
||||
{"set_draw_type", wrap_image_set_draw_type},
|
||||
{NULL, NULL}};
|
||||
|
||||
static int wrap_image_t_set_prop(lua_State* L) {
|
||||
image_t* obj = (image_t*)lftk_checkudata(L, 1, "image_t");
|
||||
@ -1808,6 +1937,17 @@ static int wrap_widget_set_value(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int wrap_widget_use_style(lua_State* L) {
|
||||
ret_t ret = 0;
|
||||
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
|
||||
char* value = (char*)luaL_checkstring(L, 2);
|
||||
ret = (ret_t)widget_use_style(widget, value);
|
||||
|
||||
lua_pushnumber(L, (lua_Number)(ret));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int wrap_widget_set_text(lua_State* L) {
|
||||
ret_t ret = 0;
|
||||
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
|
||||
@ -2033,6 +2173,7 @@ static const struct luaL_Reg widget_t_member_funcs[] = {
|
||||
{"resize", wrap_widget_resize},
|
||||
{"move_resize", wrap_widget_move_resize},
|
||||
{"set_value", wrap_widget_set_value},
|
||||
{"use_style", wrap_widget_use_style},
|
||||
{"set_text", wrap_widget_set_text},
|
||||
{"get_value", wrap_widget_get_value},
|
||||
{"get_text", wrap_widget_get_text},
|
||||
@ -2078,8 +2219,8 @@ static int wrap_widget_t_set_prop(lua_State* L) {
|
||||
} else if (strcmp(name, "type") == 0) {
|
||||
printf("type is readonly\n");
|
||||
return 0;
|
||||
} else if (strcmp(name, "subtype") == 0) {
|
||||
printf("subtype is readonly\n");
|
||||
} else if (strcmp(name, "style_type") == 0) {
|
||||
printf("style_type is readonly\n");
|
||||
return 0;
|
||||
} else if (strcmp(name, "state") == 0) {
|
||||
printf("state is readonly\n");
|
||||
@ -2136,8 +2277,8 @@ static int wrap_widget_t_get_prop(lua_State* L) {
|
||||
lua_pushinteger(L, (lua_Integer)(obj->type));
|
||||
|
||||
return 1;
|
||||
} else if (strcmp(name, "subtype") == 0) {
|
||||
lua_pushinteger(L, (lua_Integer)(obj->subtype));
|
||||
} else if (strcmp(name, "style_type") == 0) {
|
||||
lua_pushinteger(L, (lua_Integer)(obj->style_type));
|
||||
|
||||
return 1;
|
||||
} else if (strcmp(name, "state") == 0) {
|
||||
@ -2252,12 +2393,14 @@ static void window_t_init(lua_State* L) {
|
||||
void luaL_openlftk(lua_State* L) {
|
||||
globals_init(L);
|
||||
button_t_init(L);
|
||||
canvas_t_init(L);
|
||||
check_button_t_init(L);
|
||||
dialog_t_init(L);
|
||||
event_type_t_init(L);
|
||||
event_t_init(L);
|
||||
pointer_event_t_init(L);
|
||||
key_event_t_init(L);
|
||||
paint_event_t_init(L);
|
||||
group_box_t_init(L);
|
||||
image_t_init(L);
|
||||
label_t_init(L);
|
||||
|
@ -114,15 +114,15 @@ typedef enum _image_draw_type_t {
|
||||
*/
|
||||
IMAGE_DRAW_9PATCH,
|
||||
/**
|
||||
* @const IMAGE_DRAW_3PATCH_H
|
||||
* @const IMAGE_DRAW_3PATCH_X
|
||||
* 水平方向3宫格显示。
|
||||
*/
|
||||
IMAGE_DRAW_3PATCH_H,
|
||||
IMAGE_DRAW_3PATCH_X,
|
||||
/**
|
||||
* @const IMAGE_DRAW_3PATCH_V
|
||||
* @const IMAGE_DRAW_3PATCH_Y
|
||||
* 垂直方向3宫格显示。
|
||||
*/
|
||||
IMAGE_DRAW_3PATCH_V
|
||||
IMAGE_DRAW_3PATCH_Y
|
||||
} image_draw_type_t;
|
||||
|
||||
END_C_DECLS
|
||||
|
@ -586,7 +586,7 @@ ret_t canvas_draw_image_repeat_y(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t canvas_draw_image_3patch_v(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
ret_t canvas_draw_image_3patch_y(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
rect_t s;
|
||||
rect_t d;
|
||||
wh_t h = 0;
|
||||
@ -637,7 +637,7 @@ ret_t canvas_draw_image_3patch_v(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t canvas_draw_image_3patch_h(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
ret_t canvas_draw_image_3patch_x(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
rect_t s;
|
||||
rect_t d;
|
||||
wh_t w = 0;
|
||||
@ -900,36 +900,35 @@ ret_t canvas_draw_image_center(canvas_t* c, bitmap_t* img, rect_t* dst) {
|
||||
}
|
||||
|
||||
ret_t canvas_draw_image_ex(canvas_t* c, bitmap_t* img, image_draw_type_t draw_type, rect_t* dst) {
|
||||
rect_t src;
|
||||
return_value_if_fail(c != NULL && img != NULL && dst != NULL, RET_BAD_PARAMS);
|
||||
|
||||
switch(draw_type) {
|
||||
switch (draw_type) {
|
||||
case IMAGE_DRAW_CENTER:
|
||||
return canvas_draw_image_center(c, img, dst);
|
||||
case IMAGE_DRAW_SCALE:
|
||||
return canvas_draw_image_scale(c, img, dst);
|
||||
case IMAGE_DRAW_SCALE_AUTO: {
|
||||
rect_t src;
|
||||
case IMAGE_DRAW_SCALE:
|
||||
rect_init(src, 0, 0, img->w, img->h);
|
||||
return canvas_draw_image(c, img, &src, dst);
|
||||
case IMAGE_DRAW_SCALE_X:
|
||||
return canvas_draw_image_scale_x(c, img, dst);
|
||||
case IMAGE_DRAW_SCALE_Y:
|
||||
return canvas_draw_image_scale_y(c, img, dst);
|
||||
case IMAGE_DRAW_REPEAT:
|
||||
return canvas_draw_image_repeat(c, img, dst);
|
||||
case IMAGE_DRAW_REPEAT_X:
|
||||
return canvas_draw_image_repeat_x(c, img, dst);
|
||||
case IMAGE_DRAW_REPEAT_Y:
|
||||
return canvas_draw_image_repeat_y(c, img, dst);
|
||||
case IMAGE_DRAW_9PATCH:
|
||||
return canvas_draw_image_9patch(c, img, dst);
|
||||
case IMAGE_DRAW_3PATCH_H:
|
||||
return canvas_draw_image_3patch_h(c, img, dst);
|
||||
case IMAGE_DRAW_3PATCH_V:
|
||||
return canvas_draw_image_3patch_v(c, img, dst);
|
||||
case IMAGE_DRAW_SCALE_AUTO: {
|
||||
return canvas_draw_image_scale(c, img, dst);
|
||||
case IMAGE_DRAW_SCALE_X:
|
||||
return canvas_draw_image_scale_x(c, img, dst);
|
||||
case IMAGE_DRAW_SCALE_Y:
|
||||
return canvas_draw_image_scale_y(c, img, dst);
|
||||
case IMAGE_DRAW_REPEAT:
|
||||
return canvas_draw_image_repeat(c, img, dst);
|
||||
case IMAGE_DRAW_REPEAT_X:
|
||||
return canvas_draw_image_repeat_x(c, img, dst);
|
||||
case IMAGE_DRAW_REPEAT_Y:
|
||||
return canvas_draw_image_repeat_y(c, img, dst);
|
||||
case IMAGE_DRAW_9PATCH:
|
||||
return canvas_draw_image_9patch(c, img, dst);
|
||||
case IMAGE_DRAW_3PATCH_X:
|
||||
return canvas_draw_image_3patch_x(c, img, dst);
|
||||
case IMAGE_DRAW_3PATCH_Y:
|
||||
return canvas_draw_image_3patch_y(c, img, dst);
|
||||
default:
|
||||
return canvas_draw_image_center(c, img, dst);
|
||||
return canvas_draw_image_center(c, img, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,11 @@ BEGIN_C_DECLS
|
||||
struct _canvas_t;
|
||||
typedef struct _canvas_t canvas_t;
|
||||
|
||||
/**
|
||||
* @class canvas_t
|
||||
* @scriptable
|
||||
* canvas类。
|
||||
*/
|
||||
struct _canvas_t {
|
||||
xy_t ox;
|
||||
xy_t oy;
|
||||
@ -79,8 +84,8 @@ ret_t canvas_draw_image(canvas_t* c, bitmap_t* img, rect_t* src, rect_t* dst);
|
||||
ret_t canvas_draw_image_at(canvas_t* c, bitmap_t* img, xy_t x, xy_t y);
|
||||
|
||||
ret_t canvas_draw_image_center(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_3patch_h(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_3patch_v(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_3patch_x(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_3patch_y(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_9patch(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_repeat(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
ret_t canvas_draw_image_repeat_x(canvas_t* c, bitmap_t* img, rect_t* dst);
|
||||
|
@ -76,9 +76,9 @@ static const key_type_value_t image_draw_type_name_value[] = {
|
||||
{"center", 0, IMAGE_DRAW_CENTER}, {"scale", 0, IMAGE_DRAW_SCALE},
|
||||
{"scale_auto", 0, IMAGE_DRAW_SCALE_AUTO}, {"scale_x", 0, IMAGE_DRAW_SCALE_X},
|
||||
{"scale_y", 0, IMAGE_DRAW_SCALE_Y}, {"repeat", 0, IMAGE_DRAW_REPEAT},
|
||||
{"repeat_x", 0, IMAGE_DRAW_REPEAT_X}, {"repeat_y", 0, IMAGE_DRAW_REPEAT_Y},
|
||||
{"9patch", 0, IMAGE_DRAW_9PATCH}, {"3patch_h", 0, IMAGE_DRAW_3PATCH_H},
|
||||
{"3patch_v", 0, IMAGE_DRAW_3PATCH_V}};
|
||||
{"repeat_x", 0, IMAGE_DRAW_REPEAT_X}, {"repeat_y", 0, IMAGE_DRAW_REPEAT_Y},
|
||||
{"9patch", 0, IMAGE_DRAW_9PATCH}, {"3patch_x", 0, IMAGE_DRAW_3PATCH_X},
|
||||
{"3patch_y", 0, IMAGE_DRAW_3PATCH_Y}};
|
||||
|
||||
const key_type_value_t* find_item(const key_type_value_t* items, uint32_t nr, const char* name) {
|
||||
uint32_t i = 0;
|
||||
|
@ -34,3 +34,12 @@ key_event_t* key_event_cast(event_t* event) {
|
||||
|
||||
return (key_event_t*)event;
|
||||
}
|
||||
|
||||
paint_event_t* paint_event_cast(event_t* event) {
|
||||
return_value_if_fail(event != NULL, NULL);
|
||||
return_value_if_fail(
|
||||
event->type == EVT_PAINT || event->type == EVT_BEFORE_PAINT || event->type == EVT_AFTER_PAINT,
|
||||
NULL);
|
||||
|
||||
return (paint_event_t*)event;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ key_event_t* key_event_cast(event_t* event);
|
||||
typedef struct _paint_event_t {
|
||||
event_t e;
|
||||
/**
|
||||
* @property {canvas_t} c
|
||||
* @property {canvas_t*} c
|
||||
* @readonly
|
||||
* canvas。
|
||||
*/
|
||||
|
@ -37,20 +37,20 @@ static ret_t image_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
color_t trans = color_init(0x00, 0x00, 0x00, 0x00);
|
||||
color_t bg = style_get_color(&(widget->style), STYLE_ID_BG_COLOR, trans);
|
||||
color_t border = style_get_color(&(widget->style), STYLE_ID_BORDER_COLOR, trans);
|
||||
if(bg.rgba.a == 0) {
|
||||
if (bg.rgba.a == 0) {
|
||||
#ifdef FAST_MODE
|
||||
if (widget->parent != NULL) {
|
||||
bg = style_get_color(&(widget->parent->style), STYLE_ID_BG_COLOR, trans);
|
||||
}
|
||||
#endif/*FAST_MODE*/
|
||||
}
|
||||
#endif /*FAST_MODE*/
|
||||
}
|
||||
|
||||
if(bg.rgba.a) {
|
||||
if (bg.rgba.a) {
|
||||
canvas_set_fill_color(c, bg);
|
||||
canvas_fill_rect(c, 0, 0, widget->w, widget->h);
|
||||
}
|
||||
|
||||
if(border.rgba.a) {
|
||||
if (border.rgba.a) {
|
||||
canvas_set_stroke_color(c, border);
|
||||
canvas_stroke_rect(c, 0, 0, widget->w, widget->h);
|
||||
}
|
||||
|
@ -33,9 +33,13 @@ uint32_t style_get_int(style_t* s, uint32_t name, uint32_t defval) {
|
||||
uint32_t iter = 0;
|
||||
uint32_t value = 0;
|
||||
const uint8_t* p = NULL;
|
||||
return_value_if_fail(s != NULL && s->data != NULL, defval);
|
||||
return_value_if_fail(s != NULL, defval);
|
||||
|
||||
p = s->data;
|
||||
if (p == NULL) {
|
||||
return defval;
|
||||
}
|
||||
|
||||
load_uint32(p, nr);
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
@ -78,7 +82,8 @@ const char* style_get_str(style_t* s, uint32_t name, const char* defval) {
|
||||
return defval;
|
||||
}
|
||||
|
||||
const uint8_t* theme_find_style(theme_t* t, uint16_t type, uint8_t subtype, uint8_t state) {
|
||||
const uint8_t* theme_find_style(theme_t* t, uint16_t widget_type, uint8_t style_type,
|
||||
uint8_t state) {
|
||||
uint32_t i = 0;
|
||||
uint32_t nr = 0;
|
||||
uint32_t iter = 0;
|
||||
@ -86,7 +91,7 @@ const uint8_t* theme_find_style(theme_t* t, uint16_t type, uint8_t subtype, uint
|
||||
uint32_t version = 0;
|
||||
uint32_t offset = 0;
|
||||
const uint8_t* p = NULL;
|
||||
uint32_t name = (type << 16) | (subtype << 8) | state;
|
||||
uint32_t name = (widget_type << 16) | (style_type << 8) | state;
|
||||
|
||||
return_value_if_fail(t != NULL && t->data != NULL, NULL);
|
||||
|
||||
|
@ -49,7 +49,8 @@ typedef struct _theme_t {
|
||||
theme_t* theme_get_default(void);
|
||||
theme_t* theme_init(const uint8_t* data);
|
||||
|
||||
const uint8_t* theme_find_style(theme_t* t, uint16_t type, uint8_t subtype, uint8_t state);
|
||||
const uint8_t* theme_find_style(theme_t* t, uint16_t widget_type, uint8_t style_type,
|
||||
uint8_t state);
|
||||
|
||||
/**
|
||||
* @enum style_type_t
|
||||
|
@ -72,6 +72,15 @@ ret_t widget_set_value(widget_t* widget, uint32_t value) {
|
||||
return widget_set_prop(widget, "value", value_set_uint32(&v, value));
|
||||
}
|
||||
|
||||
ret_t widget_use_style(widget_t* widget, const char* value) {
|
||||
return_value_if_fail(widget != NULL && value != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget->style_type = (uint8_t)atoi(value);
|
||||
widget_update_style(widget);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t widget_set_text(widget_t* widget, const wchar_t* text) {
|
||||
value_t v;
|
||||
return_value_if_fail(widget != NULL && text != NULL, RET_BAD_PARAMS);
|
||||
@ -368,6 +377,9 @@ ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||
}
|
||||
} else if (strcmp(name, "visible") == 0) {
|
||||
widget->visible = !!value_int(v);
|
||||
} else if (strcmp(name, "style") == 0 || strcmp(name, "style_type") == 0) {
|
||||
widget->style_type = value_int(v);
|
||||
widget_update_style(widget);
|
||||
} else if (strcmp(name, "enable") == 0) {
|
||||
widget->enable = !!value_int(v);
|
||||
} else if (strcmp(name, "name") == 0) {
|
||||
@ -425,6 +437,8 @@ ret_t widget_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
}
|
||||
} else if (strcmp(name, "visible") == 0) {
|
||||
value_set_bool(v, widget->visible);
|
||||
} else if (strcmp(name, "style") == 0 || strcmp(name, "style_type") == 0) {
|
||||
value_set_int(v, widget->style_type);
|
||||
} else if (strcmp(name, "enable") == 0) {
|
||||
value_set_bool(v, widget->enable);
|
||||
} else if (strcmp(name, "name") == 0) {
|
||||
@ -686,7 +700,8 @@ ret_t widget_update_style(widget_t* widget) {
|
||||
state = WIDGET_STATE_FOCUSED;
|
||||
}
|
||||
|
||||
widget->style.data = theme_find_style(theme_get_default(), widget->type, widget->subtype, state);
|
||||
widget->style.data =
|
||||
theme_find_style(theme_get_default(), widget->type, widget->style_type, state);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@ -696,7 +711,7 @@ widget_t* widget_init(widget_t* widget, widget_t* parent, uint8_t type) {
|
||||
|
||||
widget->dirty = TRUE;
|
||||
widget->type = type;
|
||||
widget->subtype = 0;
|
||||
widget->style_type = 0;
|
||||
widget->enable = TRUE;
|
||||
widget->visible = TRUE;
|
||||
widget->emitter = NULL;
|
||||
|
@ -250,11 +250,11 @@ struct _widget_t {
|
||||
*/
|
||||
uint8_t type;
|
||||
/**
|
||||
* @property {uint8_t} subtype
|
||||
* @property {uint8_t} style_type
|
||||
* @readonly
|
||||
* 子类型,仅用于控制控件的Style。
|
||||
*/
|
||||
uint8_t subtype : 4; /*for style*/
|
||||
uint8_t style_type;
|
||||
/**
|
||||
* @property {uint8_t} state
|
||||
* @readonly
|
||||
@ -433,6 +433,16 @@ ret_t widget_move_resize(widget_t* widget, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
*/
|
||||
ret_t widget_set_value(widget_t* widget, uint32_t value);
|
||||
|
||||
/**
|
||||
* @method widget_use_style
|
||||
* 使用主题。
|
||||
* @param {widget_t*} widget 控件对象。
|
||||
* @param {char*} value style的名称。名称由ID和注释两部分组成,建议用:分隔。ID为1-255之间的数字。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t widget_use_style(widget_t* widget, const char* value);
|
||||
|
||||
/**
|
||||
* @method widget_set_text
|
||||
* 设置控件的文本。只是对widget_set_prop的包装,文本的意义由子类控件决定。
|
||||
|
@ -343,7 +343,7 @@ TEST(Canvas, draw_image) {
|
||||
lcd_destroy(lcd);
|
||||
}
|
||||
|
||||
TEST(Canvas, draw_image_3patch_h) {
|
||||
TEST(Canvas, draw_image_3patch_x) {
|
||||
rect_t r;
|
||||
rect_t d;
|
||||
canvas_t c;
|
||||
@ -360,18 +360,24 @@ TEST(Canvas, draw_image_3patch_h) {
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w, img.h);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_h(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_x(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,0,32,32);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w * 3, img.h * 2);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_h(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_x(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,10,32,0,0,10,64);dg(10,0,12,32,10,0,76,64);dg(22,0,10,32,86,0,10,64);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w * 3, img.h * 2);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_3PATCH_X, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,10,32,0,0,10,64);dg(10,0,12,32,10,0,76,64);dg(22,0,10,32,86,0,10,64);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w * 3, img.h / 2);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_h(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_x(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,10,32,0,0,10,16);dg(10,0,12,32,10,0,76,16);dg(22,0,10,32,86,0,10,16);");
|
||||
|
||||
@ -380,7 +386,7 @@ TEST(Canvas, draw_image_3patch_h) {
|
||||
lcd_destroy(lcd);
|
||||
}
|
||||
|
||||
TEST(Canvas, draw_image_3patch_v) {
|
||||
TEST(Canvas, draw_image_3patch_y) {
|
||||
rect_t r;
|
||||
rect_t d;
|
||||
canvas_t c;
|
||||
@ -397,18 +403,24 @@ TEST(Canvas, draw_image_3patch_v) {
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w, img.h);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_v(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_y(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,0,32,32);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w * 2, img.h * 3);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_v(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_y(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,32,10,0,0,64,10);dg(0,10,32,12,0,10,64,76);dg(0,22,32,10,0,86,64,10);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w / 2, img.h * 3);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_v(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(canvas_draw_image_3patch_y(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,32,10,0,0,16,10);dg(0,10,32,12,0,10,16,76);dg(0,22,32,10,0,86,16,10);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w / 2, img.h * 3);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_3PATCH_Y, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,32,10,0,0,16,10);dg(0,10,32,12,0,10,16,76);dg(0,22,32,10,0,86,16,10);");
|
||||
|
||||
@ -448,6 +460,14 @@ TEST(Canvas, draw_image_9patch) {
|
||||
"10,10,54,86,10,10);dg(10,0,12,10,10,0,44,10);dg(10,22,12,10,10,86,44,10);dg(0,10,10,"
|
||||
"12,0,10,10,76);dg(22,10,10,12,54,10,10,76);dg(10,10,12,12,10,10,44,76);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w * 2, img.h * 3);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_9PATCH, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,10,10,0,0,10,10);dg(22,0,10,10,54,0,10,10);dg(0,22,10,10,0,86,10,10);dg(22,22,"
|
||||
"10,10,54,86,10,10);dg(10,0,12,10,10,0,44,10);dg(10,22,12,10,10,86,44,10);dg(0,10,10,"
|
||||
"12,0,10,10,76);dg(22,10,10,12,54,10,10,76);dg(10,10,12,12,10,10,44,76);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(d, 0, 0, img.w / 2, img.h * 3);
|
||||
ASSERT_EQ(canvas_draw_image_9patch(&c, &img, &d), RET_OK);
|
||||
@ -488,6 +508,12 @@ TEST(Canvas, draw_image_repeat_x) {
|
||||
ASSERT_EQ(canvas_draw_image_repeat_x(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,0,32,16);dg(0,0,10,32,32,0,10,16);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w + 10, img.h / 2);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_REPEAT_X, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,0,32,16);dg(0,0,10,32,32,0,10,16);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w * 2 + 10, img.h + 10);
|
||||
@ -534,6 +560,13 @@ TEST(Canvas, draw_image_repeat_y) {
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,32,32,0,0,42,32);dg(0,0,32,32,0,32,42,32);dg(0,0,32,10,0,64,42,10);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w + 10, img.h * 2 + 10);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_REPEAT_Y, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd),
|
||||
"dg(0,0,32,32,0,0,42,32);dg(0,0,32,32,0,32,42,32);dg(0,0,32,10,0,64,42,10);");
|
||||
|
||||
canvas_end_frame(&c);
|
||||
font_manager_deinit(&font_manager);
|
||||
lcd_destroy(lcd);
|
||||
@ -566,6 +599,12 @@ TEST(Canvas, draw_image_repeat) {
|
||||
ASSERT_EQ(canvas_draw_image_repeat(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,16,0,0,32,16);dg(0,0,10,16,32,0,10,16);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w + 10, img.h / 2);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_REPEAT, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,16,0,0,32,16);dg(0,0,10,16,32,0,10,16);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w * 2 + 10, img.h * 2 + 10);
|
||||
@ -613,6 +652,12 @@ TEST(Canvas, draw_image_scale_x) {
|
||||
ASSERT_EQ(canvas_draw_image_scale_x(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,0,64,64);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w * 2, img.h * 2 + 10);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_SCALE_X, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,0,64,64);");
|
||||
|
||||
canvas_end_frame(&c);
|
||||
font_manager_deinit(&font_manager);
|
||||
lcd_destroy(lcd);
|
||||
@ -651,6 +696,12 @@ TEST(Canvas, draw_image_scale_y) {
|
||||
ASSERT_EQ(canvas_draw_image_scale_y(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,27,32,0,0,64,74);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w * 2, img.h * 2 + 10);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_SCALE_Y, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,27,32,0,0,64,74);");
|
||||
|
||||
canvas_end_frame(&c);
|
||||
font_manager_deinit(&font_manager);
|
||||
lcd_destroy(lcd);
|
||||
@ -689,6 +740,12 @@ TEST(Canvas, draw_image_scale) {
|
||||
ASSERT_EQ(canvas_draw_image_scale(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,5,64,64);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w * 2, img.h * 2 + 10);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_SCALE_AUTO, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,0,5,64,64);");
|
||||
|
||||
canvas_end_frame(&c);
|
||||
font_manager_deinit(&font_manager);
|
||||
lcd_destroy(lcd);
|
||||
@ -727,6 +784,12 @@ TEST(Canvas, draw_image_center) {
|
||||
ASSERT_EQ(canvas_draw_image_center(&c, &img, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,16,21,32,32);");
|
||||
|
||||
lcd_log_reset(lcd);
|
||||
rect_init(r, 0, 0, img.w, img.h);
|
||||
rect_init(d, 0, 0, img.w * 2, img.h * 2 + 10);
|
||||
ASSERT_EQ(canvas_draw_image_ex(&c, &img, IMAGE_DRAW_CENTER, &d), RET_OK);
|
||||
ASSERT_EQ(lcd_log_get_commands(lcd), "dg(0,0,32,32,16,21,32,32);");
|
||||
|
||||
canvas_end_frame(&c);
|
||||
font_manager_deinit(&font_manager);
|
||||
lcd_destroy(lcd);
|
||||
|
@ -130,6 +130,47 @@
|
||||
"properties": [],
|
||||
"header": "base/array.h"
|
||||
},
|
||||
{
|
||||
"type": "enum",
|
||||
"header": "base/bitmap.h",
|
||||
"name": "image_draw_type_t",
|
||||
"prefix": "IMAGE_DRAW_",
|
||||
"consts": [
|
||||
{
|
||||
"name": "IMAGE_DRAW_CENTER"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_SCALE"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_SCALE_AUTO"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_SCALE_X"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_SCALE_Y"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_REPEAT"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_REPEAT_X"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_REPEAT_Y"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_9PATCH"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_3PATCH_H"
|
||||
},
|
||||
{
|
||||
"name": "IMAGE_DRAW_3PATCH_V"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "class",
|
||||
"name": "button_t",
|
||||
@ -181,6 +222,14 @@
|
||||
"properties": [],
|
||||
"header": "base/button.h"
|
||||
},
|
||||
{
|
||||
"type": "class",
|
||||
"name": "canvas_t",
|
||||
"scriptable": true,
|
||||
"methods": [],
|
||||
"properties": [],
|
||||
"header": "base/canvas.h"
|
||||
},
|
||||
{
|
||||
"type": "class",
|
||||
"name": "check_button_t",
|
||||
@ -427,6 +476,15 @@
|
||||
},
|
||||
{
|
||||
"name": "EVT_PROP_CHANGED"
|
||||
},
|
||||
{
|
||||
"name": "EVT_PAINT"
|
||||
},
|
||||
{
|
||||
"name": "EVT_BEFORE_PAINT"
|
||||
},
|
||||
{
|
||||
"name": "EVT_AFTER_PAINT"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -528,6 +586,33 @@
|
||||
],
|
||||
"header": "base/events.h"
|
||||
},
|
||||
{
|
||||
"type": "class",
|
||||
"name": "paint_event_t",
|
||||
"scriptable": true,
|
||||
"parent": "event_t",
|
||||
"methods": [
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "event_t*",
|
||||
"name": "event"
|
||||
}
|
||||
],
|
||||
"name": "paint_event_cast",
|
||||
"isConstructor": true,
|
||||
"return": "paint_event_t*"
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"type": "canvas_t*",
|
||||
"name": "c",
|
||||
"readonly": true
|
||||
}
|
||||
],
|
||||
"header": "base/events.h"
|
||||
},
|
||||
{
|
||||
"type": "class",
|
||||
"name": "group_box_t",
|
||||
@ -611,6 +696,20 @@
|
||||
],
|
||||
"name": "image_set_image_name",
|
||||
"return": "ret_t"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "widget_t*",
|
||||
"name": "widget"
|
||||
},
|
||||
{
|
||||
"type": "image_draw_type_t",
|
||||
"name": "draw_type"
|
||||
}
|
||||
],
|
||||
"name": "image_set_draw_type",
|
||||
"return": "ret_t"
|
||||
}
|
||||
],
|
||||
"properties": [],
|
||||
@ -1750,6 +1849,20 @@
|
||||
"name": "widget_set_value",
|
||||
"return": "ret_t"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "widget_t*",
|
||||
"name": "widget"
|
||||
},
|
||||
{
|
||||
"type": "char*",
|
||||
"name": "value"
|
||||
}
|
||||
],
|
||||
"name": "widget_use_style",
|
||||
"return": "ret_t"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
@ -2120,7 +2233,7 @@
|
||||
},
|
||||
{
|
||||
"type": "uint8_t",
|
||||
"name": "subtype",
|
||||
"name": "style_type",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
|
@ -25,9 +25,9 @@
|
||||
|
||||
Style::Style() {}
|
||||
|
||||
Style::Style(uint16_t type, uint8_t subtype, uint8_t state) {
|
||||
this->type = type;
|
||||
this->subtype = subtype;
|
||||
Style::Style(uint16_t widget_type, uint8_t style_type, uint8_t state) {
|
||||
this->widget_type = widget_type;
|
||||
this->style_type = style_type;
|
||||
this->state = state;
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ uint8_t* Style::Output(uint8_t* buff, uint32_t max_size) {
|
||||
|
||||
size = this->int_values.size();
|
||||
save_uint32(p, size);
|
||||
// printf(" size=%d type=%d subtype=%d state=%d\n", size, this->type, this->subtype,
|
||||
// this->state);
|
||||
// printf(" size=%d widget_type=%d style_type=%d state=%d\n", size, this->widget_type,
|
||||
// this->style_type, this->state);
|
||||
for (vector<NameIntValue>::iterator i = this->int_values.begin(); i != this->int_values.end();
|
||||
i++) {
|
||||
uint32_t name = i->name;
|
||||
@ -108,7 +108,7 @@ uint8_t* ThemeGen::Output(uint8_t* buff, uint32_t max_size) {
|
||||
p += size * 8;
|
||||
printf("size=%d\n", size);
|
||||
for (vector<Style>::iterator iter = this->styles.begin(); iter != this->styles.end(); iter++) {
|
||||
uint32_t v = (iter->type << 16) | (iter->subtype << 8) | iter->state;
|
||||
uint32_t v = (iter->widget_type << 16) | (iter->style_type << 8) | iter->state;
|
||||
uint32_t offset = p - buff;
|
||||
save_uint32(index, v);
|
||||
save_uint32(index, offset);
|
||||
|
@ -56,7 +56,7 @@ class NameStringValue {
|
||||
class Style {
|
||||
public:
|
||||
Style();
|
||||
Style(uint16_t type, uint8_t subtype, uint8_t state);
|
||||
Style(uint16_t widget_type, uint8_t style_type, uint8_t state);
|
||||
~Style();
|
||||
|
||||
bool AddInt(uint32_t name, int32_t value);
|
||||
@ -64,8 +64,8 @@ class Style {
|
||||
uint8_t* Output(uint8_t* buff, uint32_t max_size);
|
||||
|
||||
public:
|
||||
uint16_t type;
|
||||
uint8_t subtype;
|
||||
uint16_t widget_type;
|
||||
uint8_t style_type;
|
||||
uint8_t state;
|
||||
vector<NameIntValue> int_values;
|
||||
vector<NameStringValue> str_values;
|
||||
|
@ -49,11 +49,11 @@ static void xml_gen_on_start(XmlBuilder* thiz, const char* tag, const char** att
|
||||
|
||||
return_if_fail(widget_item != NULL);
|
||||
|
||||
uint8_t subtype = 0;
|
||||
uint16_t type = widget_item->value;
|
||||
uint8_t style_type = 0;
|
||||
uint16_t widget_type = widget_item->value;
|
||||
uint8_t state = WIDGET_STATE_NORMAL;
|
||||
|
||||
Style s(type, subtype, state);
|
||||
Style s(widget_type, style_type, state);
|
||||
|
||||
while (attrs[i]) {
|
||||
const char* name = attrs[i];
|
||||
@ -66,8 +66,8 @@ static void xml_gen_on_start(XmlBuilder* thiz, const char* tag, const char** att
|
||||
} else {
|
||||
printf("Not supported state: %s\n", value);
|
||||
}
|
||||
} else if (strcmp(name, "subtype") == 0) {
|
||||
s.subtype = atoi(value);
|
||||
} else if (strcmp(name, "style_type") == 0 || strcmp(name, "name") == 0) {
|
||||
s.style_type = atoi(value);
|
||||
} else {
|
||||
const key_type_value_t* item = style_id_find(name);
|
||||
if (item != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user