sync RTGUI with github(https://github.com/RT-Thread/RTGUI) 9ae08379da5b698d6facc40bd0415de2e254ae9c

As always, full log is in GitHub.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2449 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz@gmail.com 2012-11-26 02:42:52 +00:00
parent 9789907ca1
commit 62447b2cd8
131 changed files with 50561 additions and 49024 deletions

View File

@ -32,6 +32,7 @@ common/hz12font.c
common/hz16font.c common/hz16font.c
common/framebuffer_driver.c common/framebuffer_driver.c
common/pixel_driver.c common/pixel_driver.c
common/rtgui_mv_model.c
""") """)
server_src = Split(""" server_src = Split("""
@ -68,10 +69,17 @@ widgets/window.c
widgets/panel.c widgets/panel.c
widgets/groupbox.c widgets/groupbox.c
widgets/edit.c widgets/edit.c
widgets/mv_view.c
widgets/plot.c widgets/plot.c
widgets/plot_curve.c widgets/plot_curve.c
""") """)
if GetDepend('RTGUI_USING_FONT_COMPACT'):
import stract_cjk
common_src.append('common/font_cmp_hz16.c')
common_src.append('common/font_cmp_hz12.c')
RegisterPreBuildingAction(stract_cjk.gen_cmp_font_file)
# The set of source files associated with this SConscript file. # The set of source files associated with this SConscript file.
src = common_src + server_src + widgets_src src = common_src + server_src + widgets_src

View File

@ -13,217 +13,218 @@
*/ */
#include <rtgui/font.h> #include <rtgui/font.h>
const rt_uint8_t asc12_font[] = { const rt_uint8_t asc12_font[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, {
0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81,
0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff,
0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00,
0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c,
0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18,
0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x3c, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x3c,
0xc3, 0xff, 0xff, 0xff, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99,
0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0xc3, 0xff, 0xff, 0xff, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00,
0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30,
0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67,
0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x06, 0x0e, 0x1e, 0x3e, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00,
0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x06, 0x0e, 0x1e, 0x3e,
0x18, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c,
0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0xc6, 0x60, 0x38, 0x6c, 0x18, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00,
0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0xc6, 0x60, 0x38, 0x6c,
0xfe, 0xfe, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe,
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xfe, 0xfe, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00,
0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18,
0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00,
0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00,
0x10, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x48, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x28, 0x7c, 0x28, 0x7c, 0x28, 0x50, 0x50, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x48, 0x48, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x40, 0x40, 0x38, 0x48, 0x70, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x50, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x28, 0x7c, 0x28, 0x7c, 0x28, 0x50, 0x50, 0x00, 0x00,
0x0c, 0x70, 0x08, 0x14, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x20, 0x20, 0x54, 0x48, 0x00, 0x10, 0x38, 0x40, 0x40, 0x38, 0x48, 0x70, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x50, 0x20,
0x34, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x70, 0x08, 0x14, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x20, 0x20, 0x54, 0x48,
0x00, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, 0x20, 0x20, 0x10, 0x34, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00, 0x10, 0x7c, 0x10, 0x28, 0x28, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, 0x20, 0x20, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xfc, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00, 0x10, 0x7c, 0x10, 0x28, 0x28, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x10, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0xfc, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x10, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x00, 0x00,
0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x08, 0x10, 0x20, 0x44, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x10,
0x7c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x18, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x08, 0x10, 0x20, 0x44,
0x00, 0x0c, 0x14, 0x14, 0x24, 0x44, 0x7c, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x20, 0x20, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x04, 0x18, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00,
0x38, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x40, 0x78, 0x44, 0x44, 0x44, 0x00, 0x0c, 0x14, 0x14, 0x24, 0x44, 0x7c, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x20, 0x20,
0x38, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x44, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x38, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x40, 0x78, 0x44, 0x44, 0x44,
0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x44, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00,
0x44, 0x3c, 0x04, 0x08, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x30, 0x20, 0x00, 0x00, 0x44, 0x3c, 0x04, 0x08, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30,
0x00, 0x00, 0x0c, 0x10, 0x60, 0x80, 0x60, 0x10, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x30, 0x20, 0x00, 0x00,
0x7c, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x18, 0x04, 0x18, 0x20, 0x00, 0x00, 0x0c, 0x10, 0x60, 0x80, 0x60, 0x10, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x04, 0x08, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x18, 0x04, 0x18, 0x20,
0x38, 0x44, 0x44, 0x4c, 0x54, 0x54, 0x4c, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, 0x30, 0x10, 0x28, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x04, 0x08, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00,
0x28, 0x28, 0x7c, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x44, 0x44, 0x78, 0x44, 0x44, 0x44, 0x38, 0x44, 0x44, 0x4c, 0x54, 0x54, 0x4c, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, 0x30, 0x10, 0x28,
0xf8, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x40, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, 0x28, 0x28, 0x7c, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x44, 0x44, 0x78, 0x44, 0x44, 0x44,
0x00, 0xf0, 0x48, 0x44, 0x44, 0x44, 0x44, 0x48, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x44, 0x50, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x40, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
0x70, 0x50, 0x40, 0x44, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x20, 0x28, 0x38, 0x28, 0x20, 0x20, 0x00, 0xf0, 0x48, 0x44, 0x44, 0x44, 0x44, 0x48, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x44, 0x50,
0x70, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x40, 0x40, 0x4c, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x70, 0x50, 0x40, 0x44, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x20, 0x28, 0x38, 0x28, 0x20, 0x20,
0x00, 0xec, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x40, 0x40, 0x4c, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x08, 0x08, 0x08, 0x48, 0x48, 0x48, 0x00, 0xec, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x10, 0x10,
0x30, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x48, 0x50, 0x70, 0x48, 0x44, 0xe4, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x08, 0x08, 0x08, 0x48, 0x48, 0x48,
0x00, 0x70, 0x20, 0x20, 0x20, 0x20, 0x24, 0x24, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xec, 0x6c, 0x6c, 0x30, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x48, 0x50, 0x70, 0x48, 0x44, 0xe4, 0x00, 0x00, 0x00,
0x54, 0x54, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0xec, 0x64, 0x64, 0x54, 0x54, 0x54, 0x4c, 0x00, 0x70, 0x20, 0x20, 0x20, 0x20, 0x24, 0x24, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xec, 0x6c, 0x6c,
0xec, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x54, 0x54, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0xec, 0x64, 0x64, 0x54, 0x54, 0x54, 0x4c,
0x00, 0x78, 0x24, 0x24, 0x24, 0x38, 0x20, 0x20, 0x70, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
0x44, 0x44, 0x44, 0x44, 0x38, 0x1c, 0x00, 0x00, 0x00, 0xf8, 0x44, 0x44, 0x44, 0x78, 0x48, 0x44, 0x00, 0x78, 0x24, 0x24, 0x24, 0x38, 0x20, 0x20, 0x70, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x34, 0x4c, 0x40, 0x38, 0x04, 0x04, 0x64, 0x58, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x1c, 0x00, 0x00, 0x00, 0xf8, 0x44, 0x44, 0x44, 0x78, 0x48, 0x44,
0x00, 0xfc, 0x90, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x34, 0x4c, 0x40, 0x38, 0x04, 0x04, 0x64, 0x58, 0x00, 0x00, 0x00,
0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0x28, 0x28, 0x28, 0x10, 0x00, 0xfc, 0x90, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44,
0x10, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0x54, 0x54, 0x54, 0x54, 0x28, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0x28, 0x28, 0x28, 0x10,
0x00, 0xc4, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0xc4, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0x54, 0x54, 0x54, 0x54, 0x28, 0x00, 0x00, 0x00,
0x28, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x44, 0x08, 0x10, 0x10, 0x20, 0x44, 0x00, 0xc4, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0xc4, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x28,
0x7c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x28, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x44, 0x08, 0x10, 0x10, 0x20, 0x44,
0x00, 0x40, 0x20, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x08, 0x08, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x10, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x38, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x10, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00,
0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
0x44, 0x3c, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, 0x44, 0x3c, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44,
0x00, 0x0c, 0x04, 0x34, 0x4c, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
0x44, 0x7c, 0x40, 0x40, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x00, 0x0c, 0x04, 0x34, 0x4c, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x4c, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x38, 0x00, 0x44, 0x7c, 0x40, 0x40, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20,
0x00, 0xc0, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x70, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x4c, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x38, 0x00,
0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x00, 0xc0, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0xec, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x70,
0x08, 0x08, 0x70, 0x00, 0x00, 0xc0, 0x40, 0x5c, 0x48, 0x70, 0x50, 0x48, 0xdc, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x78, 0x08, 0x08, 0x08, 0x08,
0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x08, 0x08, 0x70, 0x00, 0x00, 0xc0, 0x40, 0x5c, 0x48, 0x70, 0x50, 0x48, 0xdc, 0x00, 0x00, 0x00,
0x54, 0x54, 0x54, 0x54, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x64, 0x44, 0x44, 0x44, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8,
0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x54, 0x54, 0x54, 0x54, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x64, 0x44, 0x44, 0x44,
0x00, 0x00, 0x00, 0xd8, 0x64, 0x44, 0x44, 0x44, 0x78, 0x40, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x34, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
0x4c, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x30, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xd8, 0x64, 0x44, 0x44, 0x44, 0x78, 0x40, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x34,
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x38, 0x04, 0x44, 0x78, 0x00, 0x00, 0x00, 0x4c, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x30, 0x20, 0x20, 0x20,
0x00, 0x00, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x44, 0x38, 0x04, 0x44, 0x78, 0x00, 0x00, 0x00,
0x44, 0x44, 0x44, 0x4c, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0x28, 0x28, 0x00, 0x00, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x54, 0x54, 0x54, 0x28, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x4c, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x44, 0x28, 0x28,
0x00, 0x00, 0x00, 0xcc, 0x48, 0x30, 0x30, 0x48, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0x44, 0x54, 0x54, 0x54, 0x28, 0x00, 0x00, 0x00,
0x44, 0x24, 0x28, 0x18, 0x10, 0x10, 0x78, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x48, 0x10, 0x20, 0x44, 0x00, 0x00, 0x00, 0xcc, 0x48, 0x30, 0x30, 0x48, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec,
0x7c, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x10, 0x10, 0x20, 0x10, 0x10, 0x10, 0x08, 0x00, 0x44, 0x24, 0x28, 0x18, 0x10, 0x10, 0x78, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x48, 0x10, 0x20, 0x44,
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x10, 0x10, 0x20, 0x10, 0x10, 0x10, 0x08, 0x00,
0x10, 0x10, 0x08, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x58, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x58, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
const struct rtgui_font_bitmap asc12 = const struct rtgui_font_bitmap asc12 =
{ {
asc12_font, /* bmp */ asc12_font, /* bmp */
RT_NULL, /* each character width, NULL for fixed font */ RT_NULL, /* each character width, NULL for fixed font */
RT_NULL, /* offset for each character */ RT_NULL, /* offset for each character */
6, /* width */ 6, /* width */
12, /* height */ 12, /* height */
0, /* first char */ 0, /* first char */
255 /* last char */ 255 /* last char */
}; };
struct rtgui_font rtgui_font_asc12 = struct rtgui_font rtgui_font_asc12 =
{ {
"asc", /* family */ "asc", /* family */
12, /* height */ 12, /* height */
1, /* refer count */ 1, /* refer count */
&bmp_font_engine, /* font engine */ &bmp_font_engine, /* font engine */
(struct rtgui_font_bitmap *)&asc12, /* font private data */ (struct rtgui_font_bitmap *) &asc12, /* font private data */
}; };

View File

@ -14,283 +14,284 @@
#include <rtgui/font.h> #include <rtgui/font.h>
#ifdef RTGUI_USING_FONT16 #ifdef RTGUI_USING_FONT16
const unsigned char asc16_font[] = { const unsigned char asc16_font[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, {
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00,
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 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, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x30, 0x18, 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, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00,
0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00,
0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00,
0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x76, 0x36, 0x7e, 0xd8, 0xd8, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x76, 0x36, 0x7e, 0xd8, 0xd8, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00,
0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x18, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00,
0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xdc, 0x86, 0x0c, 0x18, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x9e, 0x3e, 0x06, 0x06, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xdc, 0x86, 0x0c, 0x18, 0x3e, 0x00, 0x00,
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x9e, 0x3e, 0x06, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 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, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
struct rtgui_font_bitmap asc16 = struct rtgui_font_bitmap asc16 =
{ {
(const rt_uint8_t*)asc16_font, /* bmp */ (const rt_uint8_t *)asc16_font, /* bmp */
RT_NULL, /* each character width, NULL for fixed font */ RT_NULL, /* each character width, NULL for fixed font */
RT_NULL, /* offset for each character */ RT_NULL, /* offset for each character */
8, /* width */ 8, /* width */
16, /* height */ 16, /* height */
0, /* first char */ 0, /* first char */
255 /* last char */ 255 /* last char */
}; };
struct rtgui_font rtgui_font_asc16 = struct rtgui_font rtgui_font_asc16 =
{ {
"asc", /* family */ "asc", /* family */
16, /* height */ 16, /* height */
1, /* refer count */ 1, /* refer count */
&bmp_font_engine, /* font engine */ &bmp_font_engine, /* font engine */
&asc16, /* font private data */ &asc16, /* font private data */
}; };
/* size = 4096 bytes */ /* size = 4096 bytes */

View File

@ -1,373 +1,379 @@
/* /*
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2012-01-24 onelife add one more blit table which exchanges the * 2012-01-24 onelife add one more blit table which exchanges the
* positions of R and B color components in output * positions of R and B color components in output
*/ */
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/blit.h> #include <rtgui/blit.h>
/* 2 bpp to 1 bpp */ /* 2 bpp to 1 bpp */
static void rtgui_blit_line_2_1(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_2_1(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
return; return;
} }
/* 3 bpp to 1 bpp */ /* 3 bpp to 1 bpp */
static void rtgui_blit_line_3_1(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_3_1(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
line = line / 3; line = line / 3;
while (line) while (line)
{ {
*dst_ptr = (rt_uint8_t)(((*src_ptr & 0x00E00000)>>16)| *dst_ptr = (rt_uint8_t)(((*src_ptr & 0x00E00000) >> 16) |
((*(src_ptr + 1) & 0x0000E000)>>11) | ((*(src_ptr + 1) & 0x0000E000) >> 11) |
((*(src_ptr + 2) & 0x000000C0)>>6)); ((*(src_ptr + 2) & 0x000000C0) >> 6));
src_ptr += 3; src_ptr += 3;
dst_ptr ++; dst_ptr ++;
line --; line --;
} }
return; return;
} }
/* 4 bpp to 1 bpp */ /* 4 bpp to 1 bpp */
static void rtgui_blit_line_4_1(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_4_1(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
struct _color {rt_uint8_t r, g, b, a;} *c; struct _color
{
rt_uint8_t r, g, b, a;
} *c;
c = (struct _color*)src_ptr; c = (struct _color *)src_ptr;
while (line-- > 0) while (line-- > 0)
{ {
*dst_ptr = (c->r & 0xe0) | (c->g & 0xc0) >> 3 | (c->b & 0xe0) >> 5 ; *dst_ptr = (c->r & 0xe0) | (c->g & 0xc0) >> 3 | (c->b & 0xe0) >> 5 ;
c ++; c ++;
dst_ptr ++; dst_ptr ++;
} }
} }
/* 1 bpp to 2 bpp */ /* 1 bpp to 2 bpp */
static void rtgui_blit_line_1_2(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_1_2(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
return; return;
} }
/* 3 bpp to 2 bpp */ /* 3 bpp to 2 bpp */
static void rtgui_blit_line_3_2(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_3_2(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
rt_uint16_t* dst; rt_uint16_t *dst;
dst = (rt_uint16_t*)dst_ptr; dst = (rt_uint16_t *)dst_ptr;
line = line / 3; line = line / 3;
while (line) while (line)
{ {
*dst = (((*(src_ptr + 2) << 8) & 0x0000F800) | *dst = (((*(src_ptr + 2) << 8) & 0x0000F800) |
((*(src_ptr + 1) << 3) & 0x000007E0) | ((*(src_ptr + 1) << 3) & 0x000007E0) |
((*src_ptr >> 3) & 0x0000001F)); ((*src_ptr >> 3) & 0x0000001F));
src_ptr += 3; src_ptr += 3;
dst ++; dst ++;
line --; line --;
} }
return; return;
} }
/* 4 bpp to 2 bpp */ /* 4 bpp to 2 bpp */
static void rtgui_blit_line_4_2(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_4_2(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
struct _color {rt_uint8_t r, g, b, a;} *c; struct _color
rt_uint16_t* ptr; {
rt_uint8_t r, g, b, a;
} *c;
rt_uint16_t *ptr;
c = (struct _color*)src_ptr; c = (struct _color *)src_ptr;
ptr = (rt_uint16_t*)dst_ptr; ptr = (rt_uint16_t *)dst_ptr;
line = line / 4; line = line / 4;
while (line-- > 0) while (line-- > 0)
{ {
*ptr = ((c->r & 0xf8) << 8) | ((c->g & 0xfc) << 3) | (c->b >> 3); *ptr = ((c->r & 0xf8) << 8) | ((c->g & 0xfc) << 3) | (c->b >> 3);
c ++; c ++;
ptr ++; ptr ++;
} }
} }
static void rtgui_blit_line_1_3(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_1_3(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
return; return;
} }
#define HI 1 #define HI 1
#define LO 0 #define LO 0
/* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */ /* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */
static const rt_uint32_t RGB565_RGBA8888_LUT[512] = static const rt_uint32_t RGB565_RGBA8888_LUT[512] =
{ {
0x000000ff, 0x00000000, 0x000008ff, 0x00200000, 0x000000ff, 0x00000000, 0x000008ff, 0x00200000,
0x000010ff, 0x00400000, 0x000018ff, 0x00610000, 0x000010ff, 0x00400000, 0x000018ff, 0x00610000,
0x000020ff, 0x00810000, 0x000029ff, 0x00a10000, 0x000020ff, 0x00810000, 0x000029ff, 0x00a10000,
0x000031ff, 0x00c20000, 0x000039ff, 0x00e20000, 0x000031ff, 0x00c20000, 0x000039ff, 0x00e20000,
0x000041ff, 0x08000000, 0x00004aff, 0x08200000, 0x000041ff, 0x08000000, 0x00004aff, 0x08200000,
0x000052ff, 0x08400000, 0x00005aff, 0x08610000, 0x000052ff, 0x08400000, 0x00005aff, 0x08610000,
0x000062ff, 0x08810000, 0x00006aff, 0x08a10000, 0x000062ff, 0x08810000, 0x00006aff, 0x08a10000,
0x000073ff, 0x08c20000, 0x00007bff, 0x08e20000, 0x000073ff, 0x08c20000, 0x00007bff, 0x08e20000,
0x000083ff, 0x10000000, 0x00008bff, 0x10200000, 0x000083ff, 0x10000000, 0x00008bff, 0x10200000,
0x000094ff, 0x10400000, 0x00009cff, 0x10610000, 0x000094ff, 0x10400000, 0x00009cff, 0x10610000,
0x0000a4ff, 0x10810000, 0x0000acff, 0x10a10000, 0x0000a4ff, 0x10810000, 0x0000acff, 0x10a10000,
0x0000b4ff, 0x10c20000, 0x0000bdff, 0x10e20000, 0x0000b4ff, 0x10c20000, 0x0000bdff, 0x10e20000,
0x0000c5ff, 0x18000000, 0x0000cdff, 0x18200000, 0x0000c5ff, 0x18000000, 0x0000cdff, 0x18200000,
0x0000d5ff, 0x18400000, 0x0000deff, 0x18610000, 0x0000d5ff, 0x18400000, 0x0000deff, 0x18610000,
0x0000e6ff, 0x18810000, 0x0000eeff, 0x18a10000, 0x0000e6ff, 0x18810000, 0x0000eeff, 0x18a10000,
0x0000f6ff, 0x18c20000, 0x0000ffff, 0x18e20000, 0x0000f6ff, 0x18c20000, 0x0000ffff, 0x18e20000,
0x000400ff, 0x20000000, 0x000408ff, 0x20200000, 0x000400ff, 0x20000000, 0x000408ff, 0x20200000,
0x000410ff, 0x20400000, 0x000418ff, 0x20610000, 0x000410ff, 0x20400000, 0x000418ff, 0x20610000,
0x000420ff, 0x20810000, 0x000429ff, 0x20a10000, 0x000420ff, 0x20810000, 0x000429ff, 0x20a10000,
0x000431ff, 0x20c20000, 0x000439ff, 0x20e20000, 0x000431ff, 0x20c20000, 0x000439ff, 0x20e20000,
0x000441ff, 0x29000000, 0x00044aff, 0x29200000, 0x000441ff, 0x29000000, 0x00044aff, 0x29200000,
0x000452ff, 0x29400000, 0x00045aff, 0x29610000, 0x000452ff, 0x29400000, 0x00045aff, 0x29610000,
0x000462ff, 0x29810000, 0x00046aff, 0x29a10000, 0x000462ff, 0x29810000, 0x00046aff, 0x29a10000,
0x000473ff, 0x29c20000, 0x00047bff, 0x29e20000, 0x000473ff, 0x29c20000, 0x00047bff, 0x29e20000,
0x000483ff, 0x31000000, 0x00048bff, 0x31200000, 0x000483ff, 0x31000000, 0x00048bff, 0x31200000,
0x000494ff, 0x31400000, 0x00049cff, 0x31610000, 0x000494ff, 0x31400000, 0x00049cff, 0x31610000,
0x0004a4ff, 0x31810000, 0x0004acff, 0x31a10000, 0x0004a4ff, 0x31810000, 0x0004acff, 0x31a10000,
0x0004b4ff, 0x31c20000, 0x0004bdff, 0x31e20000, 0x0004b4ff, 0x31c20000, 0x0004bdff, 0x31e20000,
0x0004c5ff, 0x39000000, 0x0004cdff, 0x39200000, 0x0004c5ff, 0x39000000, 0x0004cdff, 0x39200000,
0x0004d5ff, 0x39400000, 0x0004deff, 0x39610000, 0x0004d5ff, 0x39400000, 0x0004deff, 0x39610000,
0x0004e6ff, 0x39810000, 0x0004eeff, 0x39a10000, 0x0004e6ff, 0x39810000, 0x0004eeff, 0x39a10000,
0x0004f6ff, 0x39c20000, 0x0004ffff, 0x39e20000, 0x0004f6ff, 0x39c20000, 0x0004ffff, 0x39e20000,
0x000800ff, 0x41000000, 0x000808ff, 0x41200000, 0x000800ff, 0x41000000, 0x000808ff, 0x41200000,
0x000810ff, 0x41400000, 0x000818ff, 0x41610000, 0x000810ff, 0x41400000, 0x000818ff, 0x41610000,
0x000820ff, 0x41810000, 0x000829ff, 0x41a10000, 0x000820ff, 0x41810000, 0x000829ff, 0x41a10000,
0x000831ff, 0x41c20000, 0x000839ff, 0x41e20000, 0x000831ff, 0x41c20000, 0x000839ff, 0x41e20000,
0x000841ff, 0x4a000000, 0x00084aff, 0x4a200000, 0x000841ff, 0x4a000000, 0x00084aff, 0x4a200000,
0x000852ff, 0x4a400000, 0x00085aff, 0x4a610000, 0x000852ff, 0x4a400000, 0x00085aff, 0x4a610000,
0x000862ff, 0x4a810000, 0x00086aff, 0x4aa10000, 0x000862ff, 0x4a810000, 0x00086aff, 0x4aa10000,
0x000873ff, 0x4ac20000, 0x00087bff, 0x4ae20000, 0x000873ff, 0x4ac20000, 0x00087bff, 0x4ae20000,
0x000883ff, 0x52000000, 0x00088bff, 0x52200000, 0x000883ff, 0x52000000, 0x00088bff, 0x52200000,
0x000894ff, 0x52400000, 0x00089cff, 0x52610000, 0x000894ff, 0x52400000, 0x00089cff, 0x52610000,
0x0008a4ff, 0x52810000, 0x0008acff, 0x52a10000, 0x0008a4ff, 0x52810000, 0x0008acff, 0x52a10000,
0x0008b4ff, 0x52c20000, 0x0008bdff, 0x52e20000, 0x0008b4ff, 0x52c20000, 0x0008bdff, 0x52e20000,
0x0008c5ff, 0x5a000000, 0x0008cdff, 0x5a200000, 0x0008c5ff, 0x5a000000, 0x0008cdff, 0x5a200000,
0x0008d5ff, 0x5a400000, 0x0008deff, 0x5a610000, 0x0008d5ff, 0x5a400000, 0x0008deff, 0x5a610000,
0x0008e6ff, 0x5a810000, 0x0008eeff, 0x5aa10000, 0x0008e6ff, 0x5a810000, 0x0008eeff, 0x5aa10000,
0x0008f6ff, 0x5ac20000, 0x0008ffff, 0x5ae20000, 0x0008f6ff, 0x5ac20000, 0x0008ffff, 0x5ae20000,
0x000c00ff, 0x62000000, 0x000c08ff, 0x62200000, 0x000c00ff, 0x62000000, 0x000c08ff, 0x62200000,
0x000c10ff, 0x62400000, 0x000c18ff, 0x62610000, 0x000c10ff, 0x62400000, 0x000c18ff, 0x62610000,
0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000, 0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000,
0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000, 0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000,
0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000, 0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000,
0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000, 0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000,
0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000, 0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000,
0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000, 0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000,
0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000, 0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000,
0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000, 0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000,
0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000, 0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000,
0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000, 0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000,
0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000, 0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000,
0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000, 0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000,
0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000, 0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000,
0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000, 0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000,
0x001000ff, 0x83000000, 0x001008ff, 0x83200000, 0x001000ff, 0x83000000, 0x001008ff, 0x83200000,
0x001010ff, 0x83400000, 0x001018ff, 0x83610000, 0x001010ff, 0x83400000, 0x001018ff, 0x83610000,
0x001020ff, 0x83810000, 0x001029ff, 0x83a10000, 0x001020ff, 0x83810000, 0x001029ff, 0x83a10000,
0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000, 0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000,
0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000, 0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000,
0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000, 0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000,
0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000, 0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000,
0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000, 0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000,
0x001083ff, 0x94000000, 0x00108bff, 0x94200000, 0x001083ff, 0x94000000, 0x00108bff, 0x94200000,
0x001094ff, 0x94400000, 0x00109cff, 0x94610000, 0x001094ff, 0x94400000, 0x00109cff, 0x94610000,
0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000, 0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000,
0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000, 0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000,
0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000, 0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000,
0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000, 0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000,
0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000, 0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000,
0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000, 0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000,
0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000, 0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000,
0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000, 0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000,
0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000, 0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000,
0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000, 0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000,
0x001441ff, 0xac000000, 0x00144aff, 0xac200000, 0x001441ff, 0xac000000, 0x00144aff, 0xac200000,
0x001452ff, 0xac400000, 0x00145aff, 0xac610000, 0x001452ff, 0xac400000, 0x00145aff, 0xac610000,
0x001462ff, 0xac810000, 0x00146aff, 0xaca10000, 0x001462ff, 0xac810000, 0x00146aff, 0xaca10000,
0x001473ff, 0xacc20000, 0x00147bff, 0xace20000, 0x001473ff, 0xacc20000, 0x00147bff, 0xace20000,
0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000, 0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000,
0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000, 0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000,
0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000, 0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000,
0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000, 0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000,
0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000, 0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000,
0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000, 0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000,
0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000, 0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000,
0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000, 0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000,
0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000, 0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000,
0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000, 0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000,
0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000, 0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000,
0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000, 0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000,
0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000, 0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000,
0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000, 0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000,
0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000, 0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000,
0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000, 0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000,
0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000, 0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000,
0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000, 0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000,
0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000, 0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000,
0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000, 0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000,
0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000, 0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000,
0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000, 0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000,
0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000, 0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000,
0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000, 0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000,
0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000, 0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000,
0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000, 0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000,
0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000, 0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000,
0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000, 0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000,
0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000, 0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000,
0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000, 0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000,
0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000, 0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000,
0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000, 0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000,
0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000, 0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000,
0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000, 0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000,
0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000, 0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000,
0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000, 0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000,
0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000, 0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000,
0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000, 0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000,
0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000, 0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000,
0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000, 0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000,
}; };
static void rtgui_blit_line_2_3(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_2_3(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
rt_uint16_t *src; rt_uint16_t *src;
rt_uint32_t *dst; rt_uint32_t *dst;
src = (rt_uint16_t*)src_ptr; src = (rt_uint16_t *)src_ptr;
dst = (rt_uint32_t*)dst_ptr; dst = (rt_uint32_t *)dst_ptr;
line = line / 2; line = line / 2;
while (line) while (line)
{ {
*dst++ = RGB565_RGBA8888_LUT[src[LO]*2] + RGB565_RGBA8888_LUT[src[HI]*2+1]; *dst++ = RGB565_RGBA8888_LUT[src[LO] * 2] + RGB565_RGBA8888_LUT[src[HI] * 2 + 1];
line--; line--;
src ++; src ++;
} }
} }
void rtgui_blit_line_direct(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) void rtgui_blit_line_direct(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
rt_memcpy(dst_ptr, src_ptr, line); rt_memcpy(dst_ptr, src_ptr, line);
} }
/* convert 4bpp to 3bpp */ /* convert 4bpp to 3bpp */
static void rtgui_blit_line_4_3(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_4_3(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
line = line / 4; line = line / 4;
while (line) while (line)
{ {
*dst_ptr++ = *src_ptr++; *dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++; *dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++; *dst_ptr++ = *src_ptr++;
src_ptr ++; src_ptr ++;
line --; line --;
} }
} }
static void rtgui_blit_line_1_4(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_1_4(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
} }
static void rtgui_blit_line_2_4(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_2_4(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
} }
/* convert 3bpp to 4bpp */ /* convert 3bpp to 4bpp */
static void rtgui_blit_line_3_4(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_3_4(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
line = line / 4; line = line / 4;
while (line) while (line)
{ {
*dst_ptr++ = *src_ptr++; *dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++; *dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++; *dst_ptr++ = *src_ptr++;
*dst_ptr++ = 0; *dst_ptr++ = 0;
line --; line --;
} }
} }
static const rtgui_blit_line_func _blit_table[5][5] = static const rtgui_blit_line_func _blit_table[5][5] =
{ {
/* 0_0, 1_0, 2_0, 3_0, 4_0 */ /* 0_0, 1_0, 2_0, 3_0, 4_0 */
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL }, {RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
/* 0_1, 1_1, 2_1, 3_1, 4_1 */ /* 0_1, 1_1, 2_1, 3_1, 4_1 */
{RT_NULL, rtgui_blit_line_direct, rtgui_blit_line_2_1, rtgui_blit_line_3_1, rtgui_blit_line_4_1 }, {RT_NULL, rtgui_blit_line_direct, rtgui_blit_line_2_1, rtgui_blit_line_3_1, rtgui_blit_line_4_1 },
/* 0_2, 1_2, 2_2, 3_2, 4_2 */ /* 0_2, 1_2, 2_2, 3_2, 4_2 */
{RT_NULL, rtgui_blit_line_1_2, rtgui_blit_line_direct, rtgui_blit_line_3_2, rtgui_blit_line_4_2 }, {RT_NULL, rtgui_blit_line_1_2, rtgui_blit_line_direct, rtgui_blit_line_3_2, rtgui_blit_line_4_2 },
/* 0_3, 1_3, 2_3, 3_3, 4_3 */ /* 0_3, 1_3, 2_3, 3_3, 4_3 */
{RT_NULL, rtgui_blit_line_1_3, rtgui_blit_line_2_3, rtgui_blit_line_direct, rtgui_blit_line_4_3 }, {RT_NULL, rtgui_blit_line_1_3, rtgui_blit_line_2_3, rtgui_blit_line_direct, rtgui_blit_line_4_3 },
/* 0_4, 1_4, 2_4, 3_4, 4_4 */ /* 0_4, 1_4, 2_4, 3_4, 4_4 */
{RT_NULL, rtgui_blit_line_1_4, rtgui_blit_line_2_4, rtgui_blit_line_3_4, rtgui_blit_line_direct }, {RT_NULL, rtgui_blit_line_1_4, rtgui_blit_line_2_4, rtgui_blit_line_3_4, rtgui_blit_line_direct },
}; };
rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp) rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp)
{ {
RT_ASSERT(dst_bpp>0 && dst_bpp < 5); RT_ASSERT(dst_bpp > 0 && dst_bpp < 5);
RT_ASSERT(src_bpp>0 && src_bpp < 5); RT_ASSERT(src_bpp > 0 && src_bpp < 5);
return _blit_table[dst_bpp][src_bpp]; return _blit_table[dst_bpp][src_bpp];
} }
static void rtgui_blit_line_3_2_inv(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) static void rtgui_blit_line_3_2_inv(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
rt_uint16_t* dst; rt_uint16_t *dst;
dst = (rt_uint16_t*)dst_ptr; dst = (rt_uint16_t *)dst_ptr;
line = line / 3; line = line / 3;
while (line) while (line)
{ {
*dst = (((*src_ptr << 8) & 0x0000F800) | *dst = (((*src_ptr << 8) & 0x0000F800) |
((*(src_ptr + 1) << 3) & 0x000007E0) | ((*(src_ptr + 1) << 3) & 0x000007E0) |
((*(src_ptr + 2) >> 3) & 0x0000001F)); ((*(src_ptr + 2) >> 3) & 0x0000001F));
src_ptr += 3; src_ptr += 3;
dst ++; dst ++;
line --; line --;
} }
return; return;
} }
void rtgui_blit_line_2_2_inv(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line) void rtgui_blit_line_2_2_inv(rt_uint8_t *dst_ptr, rt_uint8_t *src_ptr, int line)
{ {
rt_uint16_t *dst, *src; rt_uint16_t *dst, *src;
dst = (rt_uint16_t *)dst_ptr; dst = (rt_uint16_t *)dst_ptr;
src = (rt_uint16_t *)src_ptr; src = (rt_uint16_t *)src_ptr;
line = line / 2; line = line / 2;
while (line) while (line)
{ {
*dst = ((*src << 11) & 0xF800) | (*src & 0x07E0) | ((*src >> 11) & 0x001F); *dst = ((*src << 11) & 0xF800) | (*src & 0x07E0) | ((*src >> 11) & 0x001F);
src ++; src ++;
dst ++; dst ++;
line --; line --;
} }
} }
static const rtgui_blit_line_func _blit_table_inv[5][5] = static const rtgui_blit_line_func _blit_table_inv[5][5] =
{ {
/* 0_0, 1_0, 2_0, 3_0, 4_0 */ /* 0_0, 1_0, 2_0, 3_0, 4_0 */
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL }, {RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
/* 0_1, 1_1, 2_1, 3_1, 4_1 */ /* 0_1, 1_1, 2_1, 3_1, 4_1 */
{RT_NULL, rtgui_blit_line_direct, rtgui_blit_line_2_1, rtgui_blit_line_3_1, rtgui_blit_line_4_1 }, {RT_NULL, rtgui_blit_line_direct, rtgui_blit_line_2_1, rtgui_blit_line_3_1, rtgui_blit_line_4_1 },
/* 0_2, 1_2, 2_2, 3_2, 4_2 */ /* 0_2, 1_2, 2_2, 3_2, 4_2 */
{RT_NULL, rtgui_blit_line_1_2, rtgui_blit_line_2_2_inv, rtgui_blit_line_3_2_inv, rtgui_blit_line_4_2 }, {RT_NULL, rtgui_blit_line_1_2, rtgui_blit_line_2_2_inv, rtgui_blit_line_3_2_inv, rtgui_blit_line_4_2 },
/* 0_3, 1_3, 2_3, 3_3, 4_3 */ /* 0_3, 1_3, 2_3, 3_3, 4_3 */
{RT_NULL, rtgui_blit_line_1_3, rtgui_blit_line_2_3, rtgui_blit_line_direct, rtgui_blit_line_4_3 }, {RT_NULL, rtgui_blit_line_1_3, rtgui_blit_line_2_3, rtgui_blit_line_direct, rtgui_blit_line_4_3 },
/* 0_4, 1_4, 2_4, 3_4, 4_4 */ /* 0_4, 1_4, 2_4, 3_4, 4_4 */
{RT_NULL, rtgui_blit_line_1_4, rtgui_blit_line_2_4, rtgui_blit_line_3_4, rtgui_blit_line_direct }, {RT_NULL, rtgui_blit_line_1_4, rtgui_blit_line_2_4, rtgui_blit_line_3_4, rtgui_blit_line_direct },
}; };
rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp) rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp)
{ {
RT_ASSERT(dst_bpp>0 && dst_bpp < 5); RT_ASSERT(dst_bpp > 0 && dst_bpp < 5);
RT_ASSERT(src_bpp>0 && src_bpp < 5); RT_ASSERT(src_bpp > 0 && src_bpp < 5);
return _blit_table_inv[dst_bpp][src_bpp]; return _blit_table_inv[dst_bpp][src_bpp];
} }

View File

@ -13,18 +13,18 @@
*/ */
#include <rtgui/color.h> #include <rtgui/color.h>
const rtgui_color_t red = RTGUI_RGB(0xff, 0x00, 0x00); const rtgui_color_t red = RTGUI_RGB(0xff, 0x00, 0x00);
const rtgui_color_t green = RTGUI_RGB(0x00, 0xff, 0x00); const rtgui_color_t green = RTGUI_RGB(0x00, 0xff, 0x00);
const rtgui_color_t blue = RTGUI_RGB(0x00, 0x00, 0xff); const rtgui_color_t blue = RTGUI_RGB(0x00, 0x00, 0xff);
const rtgui_color_t black = RTGUI_RGB(0x00, 0x00, 0x00); const rtgui_color_t black = RTGUI_RGB(0x00, 0x00, 0x00);
const rtgui_color_t white = RTGUI_RGB(0xff, 0xff, 0xff); const rtgui_color_t white = RTGUI_RGB(0xff, 0xff, 0xff);
const rtgui_color_t high_light = RTGUI_RGB(0xff, 0xff, 0xff); const rtgui_color_t high_light = RTGUI_RGB(0xff, 0xff, 0xff);
const rtgui_color_t dark_grey = RTGUI_RGB(0x7f, 0x7f, 0x7f); const rtgui_color_t dark_grey = RTGUI_RGB(0x7f, 0x7f, 0x7f);
const rtgui_color_t light_grey = RTGUI_RGB(0xc0, 0xc0, 0xc0); const rtgui_color_t light_grey = RTGUI_RGB(0xc0, 0xc0, 0xc0);
#define RTGUI_RGB_R(c) ((c) & 0xff) #define RTGUI_RGB_R(c) ((c) & 0xff)
#define RTGUI_RGB_G(c) (((c) >> 8) & 0xff) #define RTGUI_RGB_G(c) (((c) >> 8) & 0xff)
#define RTGUI_RGB_B(c) (((c) >> 16) & 0xff) #define RTGUI_RGB_B(c) (((c) >> 16) & 0xff)
#define RTGUI_RGB_A(c) (((c) >> 24) & 0xff) #define RTGUI_RGB_A(c) (((c) >> 24) & 0xff)

File diff suppressed because it is too large Load Diff

View File

@ -18,328 +18,328 @@
#include <rtgui/color.h> #include <rtgui/color.h>
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#define hw_driver (rtgui_graphic_driver_get_default()) #define hw_driver (rtgui_graphic_driver_get_default())
#define RTGUI_BLENDMODE_NONE 0x00 #define RTGUI_BLENDMODE_NONE 0x00
#define RTGUI_BLENDMODE_BLEND 0x01 #define RTGUI_BLENDMODE_BLEND 0x01
#define RTGUI_BLENDMODE_ADD 0x02 #define RTGUI_BLENDMODE_ADD 0x02
#define RTGUI_BLENDMODE_MOD 0x03 #define RTGUI_BLENDMODE_MOD 0x03
struct rtgui_dc_buffer struct rtgui_dc_buffer
{ {
struct rtgui_dc parent; struct rtgui_dc parent;
/* graphic context */ /* graphic context */
rtgui_gc_t gc; rtgui_gc_t gc;
/* pixel format */ /* pixel format */
rt_uint8_t pixel_format; rt_uint8_t pixel_format;
rt_uint8_t blend_mode; rt_uint8_t blend_mode;
/* width and height */ /* width and height */
rt_uint16_t width, height; rt_uint16_t width, height;
rt_uint16_t pitch; rt_uint16_t pitch;
/* blit info */ /* blit info */
rtgui_region_t clip; rtgui_region_t clip;
/* pixel data */ /* pixel data */
rt_uint8_t* pixel; rt_uint8_t *pixel;
}; };
static rt_bool_t rtgui_dc_buffer_fini(struct rtgui_dc* dc); static rt_bool_t rtgui_dc_buffer_fini(struct rtgui_dc *dc);
static void rtgui_dc_buffer_draw_point(struct rtgui_dc* dc, int x, int y); static void rtgui_dc_buffer_draw_point(struct rtgui_dc *dc, int x, int y);
static void rtgui_dc_buffer_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); static void rtgui_dc_buffer_draw_color_point(struct rtgui_dc *dc, int x, int y, rtgui_color_t color);
static void rtgui_dc_buffer_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2); static void rtgui_dc_buffer_draw_vline(struct rtgui_dc *dc, int x, int y1, int y2);
static void rtgui_dc_buffer_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y); static void rtgui_dc_buffer_draw_hline(struct rtgui_dc *dc, int x1, int x2, int y);
static void rtgui_dc_buffer_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect); static void rtgui_dc_buffer_fill_rect(struct rtgui_dc *dc, struct rtgui_rect *rect);
static void rtgui_dc_buffer_blit_line(struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data); static void rtgui_dc_buffer_blit_line(struct rtgui_dc *self, int x1, int x2, int y, rt_uint8_t *line_data);
static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_point, static void rtgui_dc_buffer_blit(struct rtgui_dc *self, struct rtgui_point *dc_point,
struct rtgui_dc* dest, rtgui_rect_t* rect); struct rtgui_dc *dest, rtgui_rect_t *rect);
static void rtgui_dc_buffer_set_gc (struct rtgui_dc* dc, rtgui_gc_t *gc); static void rtgui_dc_buffer_set_gc(struct rtgui_dc *dc, rtgui_gc_t *gc);
static rtgui_gc_t* rtgui_dc_buffer_get_gc(struct rtgui_dc* dc); static rtgui_gc_t *rtgui_dc_buffer_get_gc(struct rtgui_dc *dc);
static rt_bool_t rtgui_dc_buffer_get_visible(struct rtgui_dc* dc); static rt_bool_t rtgui_dc_buffer_get_visible(struct rtgui_dc *dc);
static void rtgui_dc_buffer_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); static void rtgui_dc_buffer_get_rect(struct rtgui_dc *dc, rtgui_rect_t *rect);
const static struct rtgui_dc_engine dc_buffer_engine = const static struct rtgui_dc_engine dc_buffer_engine =
{ {
rtgui_dc_buffer_draw_point, rtgui_dc_buffer_draw_point,
rtgui_dc_buffer_draw_color_point, rtgui_dc_buffer_draw_color_point,
rtgui_dc_buffer_draw_vline, rtgui_dc_buffer_draw_vline,
rtgui_dc_buffer_draw_hline, rtgui_dc_buffer_draw_hline,
rtgui_dc_buffer_fill_rect, rtgui_dc_buffer_fill_rect,
rtgui_dc_buffer_blit_line, rtgui_dc_buffer_blit_line,
rtgui_dc_buffer_blit, rtgui_dc_buffer_blit,
rtgui_dc_buffer_set_gc, rtgui_dc_buffer_set_gc,
rtgui_dc_buffer_get_gc, rtgui_dc_buffer_get_gc,
rtgui_dc_buffer_get_visible, rtgui_dc_buffer_get_visible,
rtgui_dc_buffer_get_rect, rtgui_dc_buffer_get_rect,
rtgui_dc_buffer_fini, rtgui_dc_buffer_fini,
}; };
struct rtgui_dc* rtgui_dc_buffer_create(int w, int h) struct rtgui_dc *rtgui_dc_buffer_create(int w, int h)
{ {
struct rtgui_dc_buffer* dc; struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)rtgui_malloc(sizeof(struct rtgui_dc_buffer)); dc = (struct rtgui_dc_buffer *)rtgui_malloc(sizeof(struct rtgui_dc_buffer));
dc->parent.type = RTGUI_DC_BUFFER; dc->parent.type = RTGUI_DC_BUFFER;
dc->parent.engine = &dc_buffer_engine; dc->parent.engine = &dc_buffer_engine;
dc->gc.foreground = default_foreground; dc->gc.foreground = default_foreground;
dc->gc.background = default_background; dc->gc.background = default_background;
dc->gc.font = rtgui_font_default(); dc->gc.font = rtgui_font_default();
dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP; dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
dc->width = w; dc->width = w;
dc->height = h; dc->height = h;
dc->pitch = w * sizeof(rtgui_color_t); dc->pitch = w *sizeof(rtgui_color_t);
rtgui_region_init(&(dc->clip)); rtgui_region_init(&(dc->clip));
dc->pixel = rtgui_malloc(h * dc->pitch); dc->pixel = rtgui_malloc(h * dc->pitch);
rt_memset(dc->pixel, 0, h * dc->pitch); rt_memset(dc->pixel, 0, h * dc->pitch);
return &(dc->parent); return &(dc->parent);
} }
rt_uint8_t* rtgui_dc_buffer_get_pixel(struct rtgui_dc* dc) rt_uint8_t *rtgui_dc_buffer_get_pixel(struct rtgui_dc *dc)
{ {
struct rtgui_dc_buffer* dc_buffer; struct rtgui_dc_buffer *dc_buffer;
dc_buffer = (struct rtgui_dc_buffer*)dc; dc_buffer = (struct rtgui_dc_buffer *)dc;
return dc_buffer->pixel; return dc_buffer->pixel;
} }
static rt_bool_t rtgui_dc_buffer_fini(struct rtgui_dc* dc) static rt_bool_t rtgui_dc_buffer_fini(struct rtgui_dc *dc)
{ {
struct rtgui_dc_buffer* buffer = (struct rtgui_dc_buffer*)dc; struct rtgui_dc_buffer *buffer = (struct rtgui_dc_buffer *)dc;
if (dc->type != RTGUI_DC_BUFFER) return RT_FALSE; if (dc->type != RTGUI_DC_BUFFER) return RT_FALSE;
rtgui_free(buffer->pixel); rtgui_free(buffer->pixel);
buffer->pixel = RT_NULL; buffer->pixel = RT_NULL;
return RT_TRUE; return RT_TRUE;
} }
static void rtgui_dc_buffer_draw_point(struct rtgui_dc* self, int x, int y) static void rtgui_dc_buffer_draw_point(struct rtgui_dc *self, int x, int y)
{ {
rtgui_color_t* ptr; rtgui_color_t *ptr;
struct rtgui_dc_buffer* dc; struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self; dc = (struct rtgui_dc_buffer *)self;
/* does not draw point out of dc */ /* does not draw point out of dc */
if ((x > dc->width) || (y > dc->height)) return ; if ((x > dc->width) || (y > dc->height)) return ;
/* note: there is no parameter check in this function */
ptr = (rtgui_color_t*)(dc->pixel + y * dc->pitch + x * sizeof(rtgui_color_t));
*ptr = dc->gc.foreground; /* note: there is no parameter check in this function */
ptr = (rtgui_color_t *)(dc->pixel + y * dc->pitch + x * sizeof(rtgui_color_t));
*ptr = dc->gc.foreground;
} }
static void rtgui_dc_buffer_draw_color_point(struct rtgui_dc* self, int x, int y, rtgui_color_t color) static void rtgui_dc_buffer_draw_color_point(struct rtgui_dc *self, int x, int y, rtgui_color_t color)
{ {
rtgui_color_t* ptr; rtgui_color_t *ptr;
struct rtgui_dc_buffer* dc; struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self; dc = (struct rtgui_dc_buffer *)self;
/* note: there is no parameter check in this function */ /* note: there is no parameter check in this function */
ptr = (rtgui_color_t*)(dc->pixel + y * dc->pitch + x * sizeof(rtgui_color_t)); ptr = (rtgui_color_t *)(dc->pixel + y * dc->pitch + x * sizeof(rtgui_color_t));
*ptr = color; *ptr = color;
} }
static void rtgui_dc_buffer_draw_vline(struct rtgui_dc* self, int x, int y1, int y2) static void rtgui_dc_buffer_draw_vline(struct rtgui_dc *self, int x, int y1, int y2)
{ {
rtgui_color_t* ptr; rtgui_color_t *ptr;
register rt_base_t index; register rt_base_t index;
struct rtgui_dc_buffer* dc; struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self; dc = (struct rtgui_dc_buffer *)self;
if (x >= dc->width) return; if (x >= dc->width) return;
if (y1 > dc->height) y1 = dc->height; if (y1 > dc->height) y1 = dc->height;
if (y2 > dc->height) y2 = dc->height; if (y2 > dc->height) y2 = dc->height;
ptr = (rtgui_color_t*)(dc->pixel + y1 * dc->pitch + x * sizeof(rtgui_color_t)); ptr = (rtgui_color_t *)(dc->pixel + y1 * dc->pitch + x * sizeof(rtgui_color_t));
for (index = y1; index < y2; index ++) for (index = y1; index < y2; index ++)
{ {
/* draw this point */ /* draw this point */
*ptr = dc->gc.foreground; *ptr = dc->gc.foreground;
ptr += dc->width; ptr += dc->width;
} }
} }
static void rtgui_dc_buffer_draw_hline(struct rtgui_dc* self, int x1, int x2, int y) static void rtgui_dc_buffer_draw_hline(struct rtgui_dc *self, int x1, int x2, int y)
{ {
rtgui_color_t* ptr; rtgui_color_t *ptr;
register rt_base_t index; register rt_base_t index;
struct rtgui_dc_buffer* dc; struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self; dc = (struct rtgui_dc_buffer *)self;
if (y >= dc->height) return; if (y >= dc->height) return;
if (x1 > dc->width) x1 = dc->width; if (x1 > dc->width) x1 = dc->width;
if (x2 > dc->width) x2 = dc->width; if (x2 > dc->width) x2 = dc->width;
ptr = (rtgui_color_t*)(dc->pixel + y * dc->pitch + x1 * sizeof(rtgui_color_t)); ptr = (rtgui_color_t *)(dc->pixel + y * dc->pitch + x1 * sizeof(rtgui_color_t));
for (index = x1; index < x2; index ++) for (index = x1; index < x2; index ++)
{ {
/* draw this point */ /* draw this point */
*ptr++ = dc->gc.foreground; *ptr++ = dc->gc.foreground;
} }
} }
static void rtgui_dc_buffer_fill_rect (struct rtgui_dc* self, struct rtgui_rect* rect) static void rtgui_dc_buffer_fill_rect(struct rtgui_dc *self, struct rtgui_rect *rect)
{ {
rtgui_color_t foreground; rtgui_color_t foreground;
rtgui_rect_t r; rtgui_rect_t r;
struct rtgui_dc_buffer* dc; struct rtgui_dc_buffer *dc;
r = *rect; r = *rect;
dc = (struct rtgui_dc_buffer*)self; dc = (struct rtgui_dc_buffer *)self;
if (r.x1 > dc->width) r.x1 = dc->width; if (r.x1 > dc->width) r.x1 = dc->width;
if (r.x2 > dc->width) r.x2 = dc->width; if (r.x2 > dc->width) r.x2 = dc->width;
if (r.y1 > dc->height) r.y1 = dc->height; if (r.y1 > dc->height) r.y1 = dc->height;
if (r.y2 > dc->height) r.y2 = dc->height; if (r.y2 > dc->height) r.y2 = dc->height;
/* save foreground color */
foreground = RTGUI_DC_FC(self);
/* set background color as foreground color */ /* save foreground color */
RTGUI_DC_FC(self) = RTGUI_DC_BC(self); foreground = RTGUI_DC_FC(self);
/* fill first line */ /* set background color as foreground color */
rtgui_dc_buffer_draw_hline(&(dc->parent), r.x1, r.x2, r.y1); RTGUI_DC_FC(self) = RTGUI_DC_BC(self);
/* memory copy other lines */ /* fill first line */
if (r.y2 > r.y1) rtgui_dc_buffer_draw_hline(&(dc->parent), r.x1, r.x2, r.y1);
{
register rt_base_t index;
for (index = r.y1 + 1; index < r.y2; index ++)
{
rt_memcpy(dc->pixel + index * dc->pitch,
dc->pixel + r.y1 * dc->pitch,
(r.x2 - r.x1) * sizeof(rtgui_color_t));
}
}
/* restore foreground color */ /* memory copy other lines */
RTGUI_DC_FC(self) = foreground; if (r.y2 > r.y1)
{
register rt_base_t index;
for (index = r.y1 + 1; index < r.y2; index ++)
{
rt_memcpy(dc->pixel + index * dc->pitch,
dc->pixel + r.y1 * dc->pitch,
(r.x2 - r.x1) * sizeof(rtgui_color_t));
}
}
/* restore foreground color */
RTGUI_DC_FC(self) = foreground;
} }
/* blit a dc to a hardware dc */ /* blit a dc to a hardware dc */
static void rtgui_dc_buffer_blit(struct rtgui_dc* self, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) static void rtgui_dc_buffer_blit(struct rtgui_dc *self, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect)
{ {
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self; struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;
if (dc_point == RT_NULL) dc_point = &rtgui_empty_point; if (dc_point == RT_NULL) dc_point = &rtgui_empty_point;
if (rtgui_dc_get_visible(dest) == RT_FALSE) return; if (rtgui_dc_get_visible(dest) == RT_FALSE) return;
if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT)) if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT))
{ {
rt_uint8_t *line_ptr, *pixels; rt_uint8_t *line_ptr, *pixels;
rt_uint16_t rect_width, rect_height, index, pitch; rt_uint16_t rect_width, rect_height, index, pitch;
rtgui_blit_line_func blit_line; rtgui_blit_line_func blit_line;
/* calculate correct width and height */ /* calculate correct width and height */
if (rtgui_rect_width(*rect) > (dc->width - dc_point->x)) if (rtgui_rect_width(*rect) > (dc->width - dc_point->x))
rect_width = dc->width - dc_point->x; rect_width = dc->width - dc_point->x;
else else
rect_width = rtgui_rect_width(*rect); rect_width = rtgui_rect_width(*rect);
if (rtgui_rect_height(*rect) > (dc->height - dc_point->y)) if (rtgui_rect_height(*rect) > (dc->height - dc_point->y))
rect_height = dc->height - dc_point->y; rect_height = dc->height - dc_point->y;
else else
rect_height = rtgui_rect_height(*rect); rect_height = rtgui_rect_height(*rect);
/* prepare pixel line */ /* prepare pixel line */
pixels = dc->pixel + dc_point->y * dc->pitch + dc_point->x * sizeof(rtgui_color_t); pixels = dc->pixel + dc_point->y * dc->pitch + dc_point->x * sizeof(rtgui_color_t);
if (hw_driver->bits_per_pixel == sizeof(rtgui_color_t) * 8) if (hw_driver->bits_per_pixel == sizeof(rtgui_color_t) * 8)
{ {
/* it's the same byte per pixel, draw it directly */ /* it's the same byte per pixel, draw it directly */
for (index = rect->y1; index < rect->y1 + rect_height; index++) for (index = rect->y1; index < rect->y1 + rect_height; index++)
{ {
dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, pixels); dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, pixels);
pixels += dc->width * sizeof(rtgui_color_t); pixels += dc->width * sizeof(rtgui_color_t);
} }
} }
else else
{ {
/* get blit line function */ /* get blit line function */
blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel/8, 4); blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel / 8, 4);
/* calculate pitch */ /* calculate pitch */
pitch = rect_width * sizeof(rtgui_color_t); pitch = rect_width * sizeof(rtgui_color_t);
/* create line buffer */ /* create line buffer */
line_ptr = (rt_uint8_t*) rtgui_malloc(rect_width * hw_driver->bits_per_pixel/8); line_ptr = (rt_uint8_t *) rtgui_malloc(rect_width * hw_driver->bits_per_pixel / 8);
/* draw each line */ /* draw each line */
for (index = rect->y1; index < rect->y1 + rect_height; index ++) for (index = rect->y1; index < rect->y1 + rect_height; index ++)
{ {
/* blit on line buffer */ /* blit on line buffer */
blit_line(line_ptr, (rt_uint8_t*)pixels, pitch); blit_line(line_ptr, (rt_uint8_t *)pixels, pitch);
pixels += dc->width * sizeof(rtgui_color_t); pixels += dc->width * sizeof(rtgui_color_t);
/* draw on hardware dc */ /* draw on hardware dc */
dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, line_ptr); dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, line_ptr);
} }
/* release line buffer */ /* release line buffer */
rtgui_free(line_ptr); rtgui_free(line_ptr);
} }
} }
} }
static void rtgui_dc_buffer_blit_line(struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data) static void rtgui_dc_buffer_blit_line(struct rtgui_dc *self, int x1, int x2, int y, rt_uint8_t *line_data)
{ {
rtgui_color_t* color_ptr; rtgui_color_t *color_ptr;
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self; struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;
RT_ASSERT(dc != RT_NULL); RT_ASSERT(dc != RT_NULL);
RT_ASSERT(line_data != RT_NULL); RT_ASSERT(line_data != RT_NULL);
/* out of range */ /* out of range */
if ((x1 > dc->width) || (y > dc->height)) return; if ((x1 > dc->width) || (y > dc->height)) return;
/* check range */ /* check range */
if (x2 > dc->width) x2 = dc->width; if (x2 > dc->width) x2 = dc->width;
color_ptr = (rtgui_color_t*)(dc->pixel + y * dc->pitch + x1 * sizeof(rtgui_color_t)); color_ptr = (rtgui_color_t *)(dc->pixel + y * dc->pitch + x1 * sizeof(rtgui_color_t));
rt_memcpy(color_ptr, line_data, (x2 - x1) * sizeof(rtgui_color_t)); rt_memcpy(color_ptr, line_data, (x2 - x1) * sizeof(rtgui_color_t));
} }
static void rtgui_dc_buffer_set_gc(struct rtgui_dc* self, rtgui_gc_t *gc) static void rtgui_dc_buffer_set_gc(struct rtgui_dc *self, rtgui_gc_t *gc)
{ {
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self; struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;
dc->gc = *gc; dc->gc = *gc;
} }
static rtgui_gc_t *rtgui_dc_buffer_get_gc(struct rtgui_dc* self) static rtgui_gc_t *rtgui_dc_buffer_get_gc(struct rtgui_dc *self)
{ {
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self; struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;
return &dc->gc; return &dc->gc;
} }
static rt_bool_t rtgui_dc_buffer_get_visible(struct rtgui_dc* dc) static rt_bool_t rtgui_dc_buffer_get_visible(struct rtgui_dc *dc)
{ {
return RT_TRUE; return RT_TRUE;
} }
static void rtgui_dc_buffer_get_rect(struct rtgui_dc* self, rtgui_rect_t* rect) static void rtgui_dc_buffer_get_rect(struct rtgui_dc *self, rtgui_rect_t *rect)
{ {
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self; struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;
rect->x1 = rect->y1 = 0; rect->x1 = rect->y1 = 0;
rect->x2 = dc->width; rect->x2 = dc->width;
rect->y2 = dc->height; rect->y2 = dc->height;
} }

View File

@ -11,8 +11,8 @@
* Date Author Notes * Date Author Notes
* 2009-10-16 Bernard first version * 2009-10-16 Bernard first version
* 2010-08-09 Bernard rename hardware dc to client dc * 2010-08-09 Bernard rename hardware dc to client dc
* 2010-09-13 Bernard fix rtgui_dc_client_blit_line issue, which found * 2010-09-13 Bernard fix rtgui_dc_client_blit_line issue, which found
* by appele * by appele
* 2010-09-14 Bernard fix vline and hline coordinate issue * 2010-09-14 Bernard fix vline and hline coordinate issue
*/ */
#include <rtgui/dc.h> #include <rtgui/dc.h>
@ -27,522 +27,522 @@
#include <rtgui/widgets/window.h> #include <rtgui/widgets/window.h>
#include <rtgui/widgets/title.h> #include <rtgui/widgets/title.h>
static void rtgui_dc_client_draw_point(struct rtgui_dc* dc, int x, int y); static void rtgui_dc_client_draw_point(struct rtgui_dc *dc, int x, int y);
static void rtgui_dc_client_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); static void rtgui_dc_client_draw_color_point(struct rtgui_dc *dc, int x, int y, rtgui_color_t color);
static void rtgui_dc_client_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y); static void rtgui_dc_client_draw_hline(struct rtgui_dc *dc, int x1, int x2, int y);
static void rtgui_dc_client_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2); static void rtgui_dc_client_draw_vline(struct rtgui_dc *dc, int x, int y1, int y2);
static void rtgui_dc_client_fill_rect (struct rtgui_dc* dc, rtgui_rect_t* rect); static void rtgui_dc_client_fill_rect(struct rtgui_dc *dc, rtgui_rect_t *rect);
static void rtgui_dc_client_blit_line (struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data); static void rtgui_dc_client_blit_line(struct rtgui_dc *self, int x1, int x2, int y, rt_uint8_t *line_data);
static void rtgui_dc_client_blit (struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect); static void rtgui_dc_client_blit(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect);
static void rtgui_dc_client_set_gc (struct rtgui_dc* dc, rtgui_gc_t *gc); static void rtgui_dc_client_set_gc(struct rtgui_dc *dc, rtgui_gc_t *gc);
static rtgui_gc_t *rtgui_dc_client_get_gc (struct rtgui_dc* dc); static rtgui_gc_t *rtgui_dc_client_get_gc(struct rtgui_dc *dc);
static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc); static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc *dc);
static rt_bool_t rtgui_dc_client_get_visible(struct rtgui_dc* dc); static rt_bool_t rtgui_dc_client_get_visible(struct rtgui_dc *dc);
static void rtgui_dc_client_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); static void rtgui_dc_client_get_rect(struct rtgui_dc *dc, rtgui_rect_t *rect);
#define hw_driver (rtgui_graphic_driver_get_default()) #define hw_driver (rtgui_graphic_driver_get_default())
#define dc_set_foreground(c) dc->gc.foreground = c #define dc_set_foreground(c) dc->gc.foreground = c
#define dc_set_background(c) dc->gc.background = c #define dc_set_background(c) dc->gc.background = c
#define _int_swap(x, y) do {x ^= y; y ^= x; x ^= y;} while (0) #define _int_swap(x, y) do {x ^= y; y ^= x; x ^= y;} while (0)
struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) struct rtgui_dc *rtgui_dc_begin_drawing(rtgui_widget_t *owner)
{ {
struct rtgui_dc* dc; struct rtgui_dc *dc;
RT_ASSERT(owner != RT_NULL); RT_ASSERT(owner != RT_NULL);
rtgui_screen_lock(RT_WAITING_FOREVER); rtgui_screen_lock(RT_WAITING_FOREVER);
if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) && if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) &&
rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK) rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK)
dc = rtgui_dc_hw_create(owner); dc = rtgui_dc_hw_create(owner);
else else
dc = rtgui_dc_client_create(owner); dc = rtgui_dc_client_create(owner);
if (dc == RT_NULL) rtgui_screen_unlock(); if (dc == RT_NULL) rtgui_screen_unlock();
return dc; return dc;
} }
RTM_EXPORT(rtgui_dc_begin_drawing); RTM_EXPORT(rtgui_dc_begin_drawing);
void rtgui_dc_end_drawing(struct rtgui_dc* dc) void rtgui_dc_end_drawing(struct rtgui_dc *dc)
{ {
dc->engine->fini(dc); dc->engine->fini(dc);
rtgui_screen_unlock(); rtgui_screen_unlock();
} }
RTM_EXPORT(rtgui_dc_end_drawing); RTM_EXPORT(rtgui_dc_end_drawing);
const struct rtgui_dc_engine dc_client_engine = const struct rtgui_dc_engine dc_client_engine =
{ {
rtgui_dc_client_draw_point, rtgui_dc_client_draw_point,
rtgui_dc_client_draw_color_point, rtgui_dc_client_draw_color_point,
rtgui_dc_client_draw_vline, rtgui_dc_client_draw_vline,
rtgui_dc_client_draw_hline, rtgui_dc_client_draw_hline,
rtgui_dc_client_fill_rect, rtgui_dc_client_fill_rect,
rtgui_dc_client_blit_line, rtgui_dc_client_blit_line,
rtgui_dc_client_blit, rtgui_dc_client_blit,
rtgui_dc_client_set_gc, rtgui_dc_client_set_gc,
rtgui_dc_client_get_gc, rtgui_dc_client_get_gc,
rtgui_dc_client_get_visible, rtgui_dc_client_get_visible,
rtgui_dc_client_get_rect, rtgui_dc_client_get_rect,
rtgui_dc_client_fini, rtgui_dc_client_fini,
}; };
void rtgui_dc_client_init(rtgui_widget_t* owner) void rtgui_dc_client_init(rtgui_widget_t *owner)
{ {
struct rtgui_dc* dc; struct rtgui_dc *dc;
RT_ASSERT(owner != RT_NULL); RT_ASSERT(owner != RT_NULL);
dc = RTGUI_WIDGET_DC(owner); dc = RTGUI_WIDGET_DC(owner);
dc->type = RTGUI_DC_CLIENT; dc->type = RTGUI_DC_CLIENT;
dc->engine = &dc_client_engine; dc->engine = &dc_client_engine;
} }
extern struct rt_mutex cursor_mutex; extern struct rt_mutex cursor_mutex;
extern void rtgui_mouse_show_cursor(void); extern void rtgui_mouse_show_cursor(void);
extern void rtgui_mouse_hide_cursor(void); extern void rtgui_mouse_hide_cursor(void);
struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner) struct rtgui_dc *rtgui_dc_client_create(rtgui_widget_t *owner)
{ {
struct rtgui_dc* dc; struct rtgui_dc *dc;
rtgui_widget_t* widget; rtgui_widget_t *widget;
/* adjudge owner */ /* adjudge owner */
if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL; if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
if (!RTGUI_IS_WIN(owner->toplevel)) return RT_NULL; if (!RTGUI_IS_WIN(owner->toplevel)) return RT_NULL;
dc = RTGUI_WIDGET_DC(owner); dc = RTGUI_WIDGET_DC(owner);
/* set init visible as true */ /* set init visible as true */
RTGUI_WIDGET_DC_SET_VISIBLE(owner); RTGUI_WIDGET_DC_SET_VISIBLE(owner);
/* check widget visible */ /* check widget visible */
widget = owner; widget = owner;
while (widget != RT_NULL) while (widget != RT_NULL)
{ {
if (RTGUI_WIDGET_IS_HIDE(widget)) if (RTGUI_WIDGET_IS_HIDE(widget))
{ {
RTGUI_WIDGET_DC_SET_UNVISIBLE(owner); RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
return RT_NULL; return RT_NULL;
} }
widget = widget->parent; widget = widget->parent;
} }
if (RTGUI_IS_WINTITLE(owner->toplevel)) if (RTGUI_IS_WINTITLE(owner->toplevel))
{ {
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing ++; top->drawing ++;
if (top->drawing == 1) if (top->drawing == 1)
{ {
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
#ifdef _WIN32 #ifdef _WIN32_NATIVE
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER); rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
rt_kprintf("hide cursor\n"); rt_kprintf("hide cursor\n");
rtgui_mouse_hide_cursor(); rtgui_mouse_hide_cursor();
#else #else
/* hide cursor */ /* hide cursor */
rtgui_mouse_hide_cursor(); rtgui_mouse_hide_cursor();
#endif #endif
#endif #endif
} }
} }
else if (RTGUI_IS_APP(owner->toplevel)) else if (RTGUI_IS_APP(owner->toplevel))
{ {
RT_ASSERT(0); RT_ASSERT(0);
} }
else if (RTGUI_IS_WIN(owner->toplevel)) else if (RTGUI_IS_WIN(owner->toplevel))
{ {
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing ++; top->drawing ++;
if (top->drawing == 1) if (top->drawing == 1)
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER); rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
rt_kprintf("hide cursor\n"); rt_kprintf("hide cursor\n");
rtgui_mouse_hide_cursor(); rtgui_mouse_hide_cursor();
#endif #endif
#else #else
/* send draw begin to server */ /* send draw begin to server */
struct rtgui_event_update_begin eupdate; struct rtgui_event_update_begin eupdate;
RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate)); RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
eupdate.rect = RTGUI_WIDGET(top)->extent; eupdate.rect = RTGUI_WIDGET(top)->extent;
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate)); rtgui_server_post_event((struct rtgui_event *)&eupdate, sizeof(eupdate));
#endif #endif
} }
} }
return dc; return dc;
} }
static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc) static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc *dc)
{ {
rtgui_widget_t* owner; rtgui_widget_t *owner;
if (dc == RT_NULL || dc->type != RTGUI_DC_CLIENT) return RT_FALSE;
/* get owner */ if (dc == RT_NULL || dc->type != RTGUI_DC_CLIENT) return RT_FALSE;
owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type);
if (RTGUI_IS_WINTITLE(owner->toplevel)) /* get owner */
{ owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type);
/* update title extent */
struct rtgui_win* top = RTGUI_WIN(owner->toplevel);
top->drawing --; if (RTGUI_IS_WINTITLE(owner->toplevel))
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) {
{ /* update title extent */
#ifdef _WIN32 struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing --;
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
{
#ifdef _WIN32_NATIVE
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_release(&cursor_mutex); rt_mutex_release(&cursor_mutex);
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
rt_kprintf("show cursor\n"); rt_kprintf("show cursor\n");
#endif #endif
/* update screen */ /* update screen */
rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent)); rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#else #else
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
#endif #endif
/* update screen */ /* update screen */
rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent)); rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#endif #endif
} }
} }
else if (RTGUI_IS_APP(owner->toplevel) || else if (RTGUI_IS_APP(owner->toplevel) ||
RTGUI_IS_WIN(owner->toplevel)) RTGUI_IS_WIN(owner->toplevel))
{ {
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing --; top->drawing --;
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_release(&cursor_mutex); rt_mutex_release(&cursor_mutex);
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
rt_kprintf("show cursor\n"); rt_kprintf("show cursor\n");
#endif #endif
/* update screen */ /* update screen */
rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent)); rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#else #else
/* send to server to end drawing */ /* send to server to end drawing */
struct rtgui_event_update_end eupdate; struct rtgui_event_update_end eupdate;
RTGUI_EVENT_UPDATE_END_INIT(&(eupdate)); RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
eupdate.rect = owner->extent; eupdate.rect = owner->extent;
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate)); rtgui_server_post_event((struct rtgui_event *)&eupdate, sizeof(eupdate));
#endif #endif
} }
} }
return RT_TRUE; return RT_TRUE;
} }
/* /*
* draw a logic point on device * draw a logic point on device
*/ */
static void rtgui_dc_client_draw_point(struct rtgui_dc* self, int x, int y) static void rtgui_dc_client_draw_point(struct rtgui_dc *self, int x, int y)
{ {
rtgui_rect_t rect; rtgui_rect_t rect;
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
x = x + owner->extent.x1; /* get owner */
y = y + owner->extent.y1; owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
if (rtgui_region_contains_point(&(owner->clip), x, y, &rect) == RT_EOK) x = x + owner->extent.x1;
{ y = y + owner->extent.y1;
/* draw this point */
hw_driver->ops->set_pixel(&(owner->gc.foreground), x, y); if (rtgui_region_contains_point(&(owner->clip), x, y, &rect) == RT_EOK)
} {
/* draw this point */
hw_driver->ops->set_pixel(&(owner->gc.foreground), x, y);
}
} }
static void rtgui_dc_client_draw_color_point(struct rtgui_dc* self, int x, int y, rtgui_color_t color) static void rtgui_dc_client_draw_color_point(struct rtgui_dc *self, int x, int y, rtgui_color_t color)
{ {
rtgui_rect_t rect; rtgui_rect_t rect;
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
x = x + owner->extent.x1; /* get owner */
y = y + owner->extent.y1; owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
if (rtgui_region_contains_point(&(owner->clip), x, y, &rect) == RT_EOK) x = x + owner->extent.x1;
{ y = y + owner->extent.y1;
/* draw this point */
hw_driver->ops->set_pixel(&color, x, y); if (rtgui_region_contains_point(&(owner->clip), x, y, &rect) == RT_EOK)
} {
/* draw this point */
hw_driver->ops->set_pixel(&color, x, y);
}
} }
/* /*
* draw a logic vertical line on device * draw a logic vertical line on device
*/ */
static void rtgui_dc_client_draw_vline(struct rtgui_dc* self, int x, int y1, int y2) static void rtgui_dc_client_draw_vline(struct rtgui_dc *self, int x, int y1, int y2)
{ {
register rt_base_t index; register rt_base_t index;
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
x = x + owner->extent.x1; /* get owner */
y1 = y1 + owner->extent.y1; owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
y2 = y2 + owner->extent.y1; if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
if (y1 > y2) _int_swap(y1, y2);
if (owner->clip.data == RT_NULL) x = x + owner->extent.x1;
{ y1 = y1 + owner->extent.y1;
rtgui_rect_t* prect; y2 = y2 + owner->extent.y1;
if (y1 > y2) _int_swap(y1, y2);
prect = &(owner->clip.extents); if (owner->clip.data == RT_NULL)
{
rtgui_rect_t *prect;
/* calculate vline intersect */ prect = &(owner->clip.extents);
if (prect->x1 > x || prect->x2 <= x) return;
if (prect->y2 <= y1 || prect->y1 > y2) return;
if (prect->y1 > y1) y1 = prect->y1; /* calculate vline intersect */
if (prect->y2 < y2) y2 = prect->y2; if (prect->x1 > x || prect->x2 <= x) return;
if (prect->y2 <= y1 || prect->y1 > y2) return;
/* draw vline */ if (prect->y1 > y1) y1 = prect->y1;
hw_driver->ops->draw_vline(&(owner->gc.foreground), x, y1, y2); if (prect->y2 < y2) y2 = prect->y2;
}
else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++)
{
rtgui_rect_t* prect;
register rt_base_t draw_y1, draw_y2;
prect = ((rtgui_rect_t *)(owner->clip.data + index + 1)); /* draw vline */
draw_y1 = y1; hw_driver->ops->draw_vline(&(owner->gc.foreground), x, y1, y2);
draw_y2 = y2; }
else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++)
{
rtgui_rect_t *prect;
register rt_base_t draw_y1, draw_y2;
/* calculate vline clip */ prect = ((rtgui_rect_t *)(owner->clip.data + index + 1));
if (prect->x1 > x || prect->x2 <= x) continue; draw_y1 = y1;
if (prect->y2 <= y1 || prect->y1 > y2) continue; draw_y2 = y2;
if (prect->y1 > y1) draw_y1 = prect->y1; /* calculate vline clip */
if (prect->y2 < y2) draw_y2 = prect->y2; if (prect->x1 > x || prect->x2 <= x) continue;
if (prect->y2 <= y1 || prect->y1 > y2) continue;
/* draw vline */ if (prect->y1 > y1) draw_y1 = prect->y1;
hw_driver->ops->draw_vline(&(owner->gc.foreground), x, draw_y1, draw_y2); if (prect->y2 < y2) draw_y2 = prect->y2;
}
/* draw vline */
hw_driver->ops->draw_vline(&(owner->gc.foreground), x, draw_y1, draw_y2);
}
} }
/* /*
* draw a logic horizontal line on device * draw a logic horizontal line on device
*/ */
static void rtgui_dc_client_draw_hline(struct rtgui_dc* self, int x1, int x2, int y) static void rtgui_dc_client_draw_hline(struct rtgui_dc *self, int x1, int x2, int y)
{ {
register rt_base_t index; register rt_base_t index;
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
/* convert logic to device */ /* get owner */
x1 = x1 + owner->extent.x1; owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
x2 = x2 + owner->extent.x1; if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
if (x1 > x2) _int_swap(x1, x2);
y = y + owner->extent.y1;
if (owner->clip.data == RT_NULL) /* convert logic to device */
{ x1 = x1 + owner->extent.x1;
rtgui_rect_t* prect; x2 = x2 + owner->extent.x1;
if (x1 > x2) _int_swap(x1, x2);
y = y + owner->extent.y1;
prect = &(owner->clip.extents); if (owner->clip.data == RT_NULL)
{
rtgui_rect_t *prect;
/* calculate vline intersect */ prect = &(owner->clip.extents);
if (prect->y1 > y || prect->y2 <= y ) return;
if (prect->x2 <= x1 || prect->x1 > x2) return;
if (prect->x1 > x1) x1 = prect->x1; /* calculate vline intersect */
if (prect->x2 < x2) x2 = prect->x2; if (prect->y1 > y || prect->y2 <= y) return;
if (prect->x2 <= x1 || prect->x1 > x2) return;
/* draw hline */ if (prect->x1 > x1) x1 = prect->x1;
hw_driver->ops->draw_hline(&(owner->gc.foreground), x1, x2, y); if (prect->x2 < x2) x2 = prect->x2;
}
else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++)
{
rtgui_rect_t* prect;
register rt_base_t draw_x1, draw_x2;
prect = ((rtgui_rect_t *)(owner->clip.data + index + 1)); /* draw hline */
draw_x1 = x1; hw_driver->ops->draw_hline(&(owner->gc.foreground), x1, x2, y);
draw_x2 = x2; }
else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++)
{
rtgui_rect_t *prect;
register rt_base_t draw_x1, draw_x2;
/* calculate hline clip */ prect = ((rtgui_rect_t *)(owner->clip.data + index + 1));
if (prect->y1 > y || prect->y2 <= y ) continue; draw_x1 = x1;
if (prect->x2 <= x1 || prect->x1 > x2) continue; draw_x2 = x2;
if (prect->x1 > x1) draw_x1 = prect->x1; /* calculate hline clip */
if (prect->x2 < x2) draw_x2 = prect->x2; if (prect->y1 > y || prect->y2 <= y) continue;
if (prect->x2 <= x1 || prect->x1 > x2) continue;
/* draw hline */ if (prect->x1 > x1) draw_x1 = prect->x1;
hw_driver->ops->draw_hline(&(owner->gc.foreground), draw_x1, draw_x2, y); if (prect->x2 < x2) draw_x2 = prect->x2;
}
/* draw hline */
hw_driver->ops->draw_hline(&(owner->gc.foreground), draw_x1, draw_x2, y);
}
} }
static void rtgui_dc_client_fill_rect (struct rtgui_dc* self, struct rtgui_rect* rect) static void rtgui_dc_client_fill_rect(struct rtgui_dc *self, struct rtgui_rect *rect)
{ {
rtgui_color_t foreground; rtgui_color_t foreground;
register rt_base_t index; register rt_base_t index;
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
/* save foreground color */ /* get owner */
foreground = owner->gc.foreground; owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
/* set background color as foreground color */ /* save foreground color */
owner->gc.foreground = owner->gc.background; foreground = owner->gc.foreground;
/* fill rect */ /* set background color as foreground color */
for (index = rect->y1; index < rect->y2; index ++) owner->gc.foreground = owner->gc.background;
{
rtgui_dc_client_draw_hline(self, rect->x1, rect->x2, index);
}
/* restore foreground color */ /* fill rect */
owner->gc.foreground = foreground; for (index = rect->y1; index < rect->y2; index ++)
{
rtgui_dc_client_draw_hline(self, rect->x1, rect->x2, index);
}
/* restore foreground color */
owner->gc.foreground = foreground;
} }
static void rtgui_dc_client_blit_line (struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data) static void rtgui_dc_client_blit_line(struct rtgui_dc *self, int x1, int x2, int y, rt_uint8_t *line_data)
{ {
register rt_base_t index; register rt_base_t index;
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */ /* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return; if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
/* convert logic to device */ /* convert logic to device */
x1 = x1 + owner->extent.x1; x1 = x1 + owner->extent.x1;
x2 = x2 + owner->extent.x1; x2 = x2 + owner->extent.x1;
if (x1 > x2) _int_swap(x1, x2); if (x1 > x2) _int_swap(x1, x2);
y = y + owner->extent.y1; y = y + owner->extent.y1;
if (rtgui_region_is_flat(&(owner->clip)) == RT_EOK) if (rtgui_region_is_flat(&(owner->clip)) == RT_EOK)
{ {
rtgui_rect_t* prect; rtgui_rect_t *prect;
int offset = 0; int offset = 0;
prect = &(owner->clip.extents); prect = &(owner->clip.extents);
/* calculate vline intersect */ /* calculate vline intersect */
if (prect->y1 > y || prect->y2 <= y ) return; if (prect->y1 > y || prect->y2 <= y) return;
if (prect->x2 <= x1 || prect->x1 > x2) return; if (prect->x2 <= x1 || prect->x1 > x2) return;
if (prect->x1 > x1) x1 = prect->x1; if (prect->x1 > x1) x1 = prect->x1;
if (prect->x2 < x2) x2 = prect->x2; if (prect->x2 < x2) x2 = prect->x2;
/* patch note: /* patch note:
* We need to adjust the offset when update widget clip! * We need to adjust the offset when update widget clip!
* Of course at ordinary times for 0. General */ * Of course at ordinary times for 0. General */
offset = owner->clip.extents.x1 - owner->extent.x1; offset = owner->clip.extents.x1 - owner->extent.x1;
offset = offset * hw_driver->bits_per_pixel/8; offset = offset * hw_driver->bits_per_pixel / 8;
/* draw hline */ /* draw hline */
hw_driver->ops->draw_raw_hline(line_data+offset, x1, x2, y); hw_driver->ops->draw_raw_hline(line_data + offset, x1, x2, y);
} }
else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++) else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++)
{ {
rtgui_rect_t* prect; rtgui_rect_t *prect;
register rt_base_t draw_x1, draw_x2; register rt_base_t draw_x1, draw_x2;
prect = ((rtgui_rect_t *)(owner->clip.data + index + 1)); prect = ((rtgui_rect_t *)(owner->clip.data + index + 1));
draw_x1 = x1; draw_x1 = x1;
draw_x2 = x2; draw_x2 = x2;
/* calculate hline clip */ /* calculate hline clip */
if (prect->y1 > y || prect->y2 <= y ) continue; if (prect->y1 > y || prect->y2 <= y) continue;
if (prect->x2 <= x1 || prect->x1 > x2) continue; if (prect->x2 <= x1 || prect->x1 > x2) continue;
if (prect->x1 > x1) draw_x1 = prect->x1; if (prect->x1 > x1) draw_x1 = prect->x1;
if (prect->x2 < x2) draw_x2 = prect->x2; if (prect->x2 < x2) draw_x2 = prect->x2;
/* draw hline */ /* draw hline */
hw_driver->ops->draw_raw_hline(line_data + (draw_x1 - x1) * hw_driver->bits_per_pixel/8, draw_x1, draw_x2, y); hw_driver->ops->draw_raw_hline(line_data + (draw_x1 - x1) * hw_driver->bits_per_pixel / 8, draw_x1, draw_x2, y);
} }
} }
static void rtgui_dc_client_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) static void rtgui_dc_client_blit(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect)
{ {
/* not blit in hardware dc */ /* not blit in hardware dc */
return ; return ;
} }
static void rtgui_dc_client_set_gc(struct rtgui_dc* self, rtgui_gc_t *gc) static void rtgui_dc_client_set_gc(struct rtgui_dc *self, rtgui_gc_t *gc)
{ {
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */ /* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
owner->gc = *gc; owner->gc = *gc;
} }
static rtgui_gc_t* rtgui_dc_client_get_gc(struct rtgui_dc* self) static rtgui_gc_t *rtgui_dc_client_get_gc(struct rtgui_dc *self)
{ {
rtgui_widget_t *owner; rtgui_widget_t *owner;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
/* get owner */ /* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
return &(owner->gc); return &(owner->gc);
} }
static rt_bool_t rtgui_dc_client_get_visible(struct rtgui_dc* self) static rt_bool_t rtgui_dc_client_get_visible(struct rtgui_dc *self)
{ {
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return RT_FALSE; if (self == RT_NULL) return RT_FALSE;
/* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_FALSE;
return RT_TRUE; /* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_FALSE;
return RT_TRUE;
} }
static void rtgui_dc_client_get_rect(struct rtgui_dc* self, rtgui_rect_t* rect) static void rtgui_dc_client_get_rect(struct rtgui_dc *self, rtgui_rect_t *rect)
{ {
rtgui_widget_t *owner; rtgui_widget_t *owner;
if (self == RT_NULL) return; if (self == RT_NULL) return;
/* get owner */ /* get owner */
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type); owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
rtgui_widget_get_rect(owner, rect); rtgui_widget_get_rect(owner, rect);
} }

View File

@ -22,363 +22,358 @@
#include <rtgui/widgets/window.h> #include <rtgui/widgets/window.h>
#include <rtgui/widgets/title.h> #include <rtgui/widgets/title.h>
#define _int_swap(x, y) do {x ^= y; y ^= x; x ^= y;} while (0) #define _int_swap(x, y) do {x ^= y; y ^= x; x ^= y;} while (0)
static void rtgui_dc_hw_draw_point(struct rtgui_dc* dc, int x, int y); static void rtgui_dc_hw_draw_point(struct rtgui_dc *dc, int x, int y);
static void rtgui_dc_hw_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); static void rtgui_dc_hw_draw_color_point(struct rtgui_dc *dc, int x, int y, rtgui_color_t color);
static void rtgui_dc_hw_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y); static void rtgui_dc_hw_draw_hline(struct rtgui_dc *dc, int x1, int x2, int y);
static void rtgui_dc_hw_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2); static void rtgui_dc_hw_draw_vline(struct rtgui_dc *dc, int x, int y1, int y2);
static void rtgui_dc_hw_fill_rect (struct rtgui_dc* dc, rtgui_rect_t* rect); static void rtgui_dc_hw_fill_rect(struct rtgui_dc *dc, rtgui_rect_t *rect);
static void rtgui_dc_hw_blit_line (struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data); static void rtgui_dc_hw_blit_line(struct rtgui_dc *self, int x1, int x2, int y, rt_uint8_t *line_data);
static void rtgui_dc_hw_blit (struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect); static void rtgui_dc_hw_blit(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect);
static void rtgui_dc_hw_set_gc (struct rtgui_dc* dc, rtgui_gc_t *gc); static void rtgui_dc_hw_set_gc(struct rtgui_dc *dc, rtgui_gc_t *gc);
static rtgui_gc_t *rtgui_dc_hw_get_gc (struct rtgui_dc* dc); static rtgui_gc_t *rtgui_dc_hw_get_gc(struct rtgui_dc *dc);
static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc); static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc *dc);
static rt_bool_t rtgui_dc_hw_get_visible(struct rtgui_dc* dc); static rt_bool_t rtgui_dc_hw_get_visible(struct rtgui_dc *dc);
static void rtgui_dc_hw_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); static void rtgui_dc_hw_get_rect(struct rtgui_dc *dc, rtgui_rect_t *rect);
struct rtgui_dc_hw struct rtgui_dc_hw
{ {
struct rtgui_dc parent; struct rtgui_dc parent;
rtgui_widget_t *owner; rtgui_widget_t *owner;
const struct rtgui_graphic_driver* hw_driver; const struct rtgui_graphic_driver *hw_driver;
}; };
const struct rtgui_dc_engine dc_hw_engine = const struct rtgui_dc_engine dc_hw_engine =
{ {
rtgui_dc_hw_draw_point, rtgui_dc_hw_draw_point,
rtgui_dc_hw_draw_color_point, rtgui_dc_hw_draw_color_point,
rtgui_dc_hw_draw_vline, rtgui_dc_hw_draw_vline,
rtgui_dc_hw_draw_hline, rtgui_dc_hw_draw_hline,
rtgui_dc_hw_fill_rect, rtgui_dc_hw_fill_rect,
rtgui_dc_hw_blit_line, rtgui_dc_hw_blit_line,
rtgui_dc_hw_blit, rtgui_dc_hw_blit,
rtgui_dc_hw_set_gc, rtgui_dc_hw_set_gc,
rtgui_dc_hw_get_gc, rtgui_dc_hw_get_gc,
rtgui_dc_hw_get_visible, rtgui_dc_hw_get_visible,
rtgui_dc_hw_get_rect, rtgui_dc_hw_get_rect,
rtgui_dc_hw_fini, rtgui_dc_hw_fini,
}; };
extern struct rt_mutex cursor_mutex; extern struct rt_mutex cursor_mutex;
extern void rtgui_mouse_show_cursor(void); extern void rtgui_mouse_show_cursor(void);
extern void rtgui_mouse_hide_cursor(void); extern void rtgui_mouse_hide_cursor(void);
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner) struct rtgui_dc *rtgui_dc_hw_create(rtgui_widget_t *owner)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
rtgui_widget_t* widget; rtgui_widget_t *widget;
/* adjudge owner */ /* adjudge owner */
if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL; if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
if (!RTGUI_IS_WIN(owner->toplevel)) return RT_NULL; if (!RTGUI_IS_WIN(owner->toplevel)) return RT_NULL;
/* set init visible as true */ /* set init visible as true */
RTGUI_WIDGET_DC_SET_VISIBLE(owner); RTGUI_WIDGET_DC_SET_VISIBLE(owner);
/* check widget visible */ /* check widget visible */
widget = owner; widget = owner;
while (widget != RT_NULL) while (widget != RT_NULL)
{ {
if (RTGUI_WIDGET_IS_HIDE(widget)) if (RTGUI_WIDGET_IS_HIDE(widget))
{ {
RTGUI_WIDGET_DC_SET_UNVISIBLE(owner); RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
return RT_NULL; return RT_NULL;
} }
widget = widget->parent; widget = widget->parent;
} }
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_NULL; if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_NULL;
/* create DC */ /* create DC */
dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw)); dc = (struct rtgui_dc_hw *) rtgui_malloc(sizeof(struct rtgui_dc_hw));
dc->parent.type = RTGUI_DC_HW; dc->parent.type = RTGUI_DC_HW;
dc->parent.engine = &dc_hw_engine; dc->parent.engine = &dc_hw_engine;
dc->owner = owner; dc->owner = owner;
dc->hw_driver = rtgui_graphic_driver_get_default(); dc->hw_driver = rtgui_graphic_driver_get_default();
if (RTGUI_IS_WINTITLE(owner->toplevel)) if (RTGUI_IS_WINTITLE(owner->toplevel))
{ {
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing ++; top->drawing ++;
if (top->drawing == 1) if (top->drawing == 1)
{ {
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
#ifdef _WIN32 #ifdef _WIN32_NATIVE
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER); rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
rt_kprintf("hide cursor\n"); rt_kprintf("hide cursor\n");
rtgui_mouse_hide_cursor(); rtgui_mouse_hide_cursor();
#else #else
/* hide cursor */ /* hide cursor */
rtgui_mouse_hide_cursor(); rtgui_mouse_hide_cursor();
#endif #endif
#endif #endif
} }
} }
else if (RTGUI_IS_APP(owner->toplevel) || else if (RTGUI_IS_APP(owner->toplevel) ||
RTGUI_IS_WIN(owner->toplevel)) RTGUI_IS_WIN(owner->toplevel))
{ {
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing ++; top->drawing ++;
if (top->drawing == 1) if (top->drawing == 1)
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER); rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
rt_kprintf("hide cursor\n"); rt_kprintf("hide cursor\n");
rtgui_mouse_hide_cursor(); rtgui_mouse_hide_cursor();
#endif #endif
#else #else
/* send draw begin to server */ /* send draw begin to server */
struct rtgui_event_update_begin eupdate; struct rtgui_event_update_begin eupdate;
RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate)); RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
eupdate.rect = RTGUI_WIDGET(top)->extent; eupdate.rect = RTGUI_WIDGET(top)->extent;
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate)); rtgui_server_post_event((struct rtgui_event *)&eupdate, sizeof(eupdate));
#endif #endif
} }
} }
return &(dc->parent); return &(dc->parent);
} }
static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc) static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc *dc)
{ {
rtgui_widget_t* owner; rtgui_widget_t *owner;
struct rtgui_dc_hw* self; struct rtgui_dc_hw *self;
if (dc == RT_NULL || dc->type != RTGUI_DC_HW) return RT_FALSE; if (dc == RT_NULL || dc->type != RTGUI_DC_HW) return RT_FALSE;
self = (struct rtgui_dc_hw*)dc; self = (struct rtgui_dc_hw *)dc;
/* get owner */ /* get owner */
owner = self->owner; owner = self->owner;
if (RTGUI_IS_WINTITLE(owner->toplevel)) if (RTGUI_IS_WINTITLE(owner->toplevel))
{ {
/* update title extent */ /* update title extent */
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing --; top->drawing --;
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_release(&cursor_mutex); rt_mutex_release(&cursor_mutex);
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
rt_kprintf("show cursor\n"); rt_kprintf("show cursor\n");
#endif #endif
/* update screen */ /* update screen */
rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent)); rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#else #else
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
#endif #endif
/* update screen */ /* update screen */
rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent)); rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#endif #endif
} }
} }
else if (RTGUI_IS_APP(owner->toplevel) || else if (RTGUI_IS_APP(owner->toplevel) ||
RTGUI_IS_WIN(owner->toplevel)) RTGUI_IS_WIN(owner->toplevel))
{ {
struct rtgui_win* top = RTGUI_WIN(owner->toplevel); struct rtgui_win *top = RTGUI_WIN(owner->toplevel);
top->drawing --; top->drawing --;
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_release(&cursor_mutex); rt_mutex_release(&cursor_mutex);
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
rt_kprintf("show cursor\n"); rt_kprintf("show cursor\n");
#endif #endif
/* update screen */ /* update screen */
rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent)); rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#else #else
/* send to server to end drawing */ /* send to server to end drawing */
struct rtgui_event_update_end eupdate; struct rtgui_event_update_end eupdate;
RTGUI_EVENT_UPDATE_END_INIT(&(eupdate)); RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
eupdate.rect = owner->extent; eupdate.rect = owner->extent;
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate)); rtgui_server_post_event((struct rtgui_event *)&eupdate, sizeof(eupdate));
#endif #endif
} }
} }
/* release hardware dc */ /* release hardware dc */
rtgui_free(self); rtgui_free(self);
return RT_TRUE; return RT_TRUE;
} }
/* /*
* draw a logic point on device * draw a logic point on device
*/ */
static void rtgui_dc_hw_draw_point(struct rtgui_dc* self, int x, int y) static void rtgui_dc_hw_draw_point(struct rtgui_dc *self, int x, int y)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
x = x + dc->owner->extent.x1; x = x + dc->owner->extent.x1;
#if (0) /* Please yourself to decide whether to use it*/ y = y + dc->owner->extent.y1;
if(x < dc->owner->extent.x1 || x >= dc->owner->extent.x2) return;
#endif /* draw this point */
y = y + dc->owner->extent.y1; dc->hw_driver->ops->set_pixel(&(dc->owner->gc.foreground), x, y);
#if (0)
if(y < dc->owner->extent.y1 || y >= dc->owner->extent.y2) return;
#endif
/* draw this point */
dc->hw_driver->ops->set_pixel(&(dc->owner->gc.foreground), x, y);
} }
static void rtgui_dc_hw_draw_color_point(struct rtgui_dc* self, int x, int y, rtgui_color_t color) static void rtgui_dc_hw_draw_color_point(struct rtgui_dc *self, int x, int y, rtgui_color_t color)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
x = x + dc->owner->extent.x1; x = x + dc->owner->extent.x1;
y = y + dc->owner->extent.y1; y = y + dc->owner->extent.y1;
/* draw this point */ /* draw this point */
dc->hw_driver->ops->set_pixel(&color, x, y); dc->hw_driver->ops->set_pixel(&color, x, y);
} }
/* /*
* draw a logic vertical line on device * draw a logic vertical line on device
*/ */
static void rtgui_dc_hw_draw_vline(struct rtgui_dc* self, int x, int y1, int y2) static void rtgui_dc_hw_draw_vline(struct rtgui_dc *self, int x, int y1, int y2)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
x = x + dc->owner->extent.x1; x = x + dc->owner->extent.x1;
y1 = y1 + dc->owner->extent.y1; y1 = y1 + dc->owner->extent.y1;
y2 = y2 + dc->owner->extent.y1; y2 = y2 + dc->owner->extent.y1;
if (y1 > y2) _int_swap(y1, y2); if (y1 > y2) _int_swap(y1, y2);
/* draw vline */ /* draw vline */
dc->hw_driver->ops->draw_vline(&(dc->owner->gc.foreground), x, y1, y2); dc->hw_driver->ops->draw_vline(&(dc->owner->gc.foreground), x, y1, y2);
} }
/* /*
* draw a logic horizontal line on device * draw a logic horizontal line on device
*/ */
static void rtgui_dc_hw_draw_hline(struct rtgui_dc* self, int x1, int x2, int y) static void rtgui_dc_hw_draw_hline(struct rtgui_dc *self, int x1, int x2, int y)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
/* convert logic to device */ /* convert logic to device */
x1 = x1 + dc->owner->extent.x1; x1 = x1 + dc->owner->extent.x1;
x2 = x2 + dc->owner->extent.x1; x2 = x2 + dc->owner->extent.x1;
if (x1 > x2) _int_swap(x1, x2); if (x1 > x2) _int_swap(x1, x2);
y = y + dc->owner->extent.y1; y = y + dc->owner->extent.y1;
/* draw hline */ /* draw hline */
dc->hw_driver->ops->draw_hline(&(dc->owner->gc.foreground), x1, x2, y); dc->hw_driver->ops->draw_hline(&(dc->owner->gc.foreground), x1, x2, y);
} }
static void rtgui_dc_hw_fill_rect (struct rtgui_dc* self, struct rtgui_rect* rect) static void rtgui_dc_hw_fill_rect(struct rtgui_dc *self, struct rtgui_rect *rect)
{ {
rtgui_color_t color; rtgui_color_t color;
register rt_base_t index, x1, x2; register rt_base_t index, x1, x2;
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
/* get background color */ /* get background color */
color = dc->owner->gc.background; color = dc->owner->gc.background;
/* convert logic to device */ /* convert logic to device */
x1 = rect->x1 + dc->owner->extent.x1; x1 = rect->x1 + dc->owner->extent.x1;
x2 = rect->x2 + dc->owner->extent.x1; x2 = rect->x2 + dc->owner->extent.x1;
/* fill rect */ /* fill rect */
for (index = dc->owner->extent.y1 + rect->y1; index < dc->owner->extent.y1 + rect->y2; index ++) for (index = dc->owner->extent.y1 + rect->y1; index < dc->owner->extent.y1 + rect->y2; index ++)
{ {
dc->hw_driver->ops->draw_hline(&color, x1, x2, index); dc->hw_driver->ops->draw_hline(&color, x1, x2, index);
} }
} }
static void rtgui_dc_hw_blit_line (struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data) static void rtgui_dc_hw_blit_line(struct rtgui_dc *self, int x1, int x2, int y, rt_uint8_t *line_data)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
/* convert logic to device */ /* convert logic to device */
x1 = x1 + dc->owner->extent.x1; x1 = x1 + dc->owner->extent.x1;
x2 = x2 + dc->owner->extent.x1; x2 = x2 + dc->owner->extent.x1;
if (x1 > x2) _int_swap(x1, x2); if (x1 > x2) _int_swap(x1, x2);
y = y + dc->owner->extent.y1; y = y + dc->owner->extent.y1;
dc->hw_driver->ops->draw_raw_hline(line_data, x1, x2, y); dc->hw_driver->ops->draw_raw_hline(line_data, x1, x2, y);
} }
static void rtgui_dc_hw_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) static void rtgui_dc_hw_blit(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect)
{ {
/* not blit in hardware dc */ /* not blit in hardware dc */
return ; return ;
} }
static void rtgui_dc_hw_set_gc(struct rtgui_dc* self, rtgui_gc_t *gc) static void rtgui_dc_hw_set_gc(struct rtgui_dc *self, rtgui_gc_t *gc)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
/* set gc */ /* set gc */
dc->owner->gc = *gc; dc->owner->gc = *gc;
} }
static rtgui_gc_t* rtgui_dc_hw_get_gc(struct rtgui_dc* self) static rtgui_gc_t *rtgui_dc_hw_get_gc(struct rtgui_dc *self)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
return &(dc->owner->gc); return &(dc->owner->gc);
} }
static rt_bool_t rtgui_dc_hw_get_visible(struct rtgui_dc* self) static rt_bool_t rtgui_dc_hw_get_visible(struct rtgui_dc *self)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
if (!RTGUI_WIDGET_IS_DC_VISIBLE(dc->owner)) return RT_FALSE; if (!RTGUI_WIDGET_IS_DC_VISIBLE(dc->owner)) return RT_FALSE;
return RT_TRUE; return RT_TRUE;
} }
static void rtgui_dc_hw_get_rect(struct rtgui_dc* self, rtgui_rect_t* rect) static void rtgui_dc_hw_get_rect(struct rtgui_dc *self, rtgui_rect_t *rect)
{ {
struct rtgui_dc_hw* dc; struct rtgui_dc_hw *dc;
RT_ASSERT(self != RT_NULL); RT_ASSERT(self != RT_NULL);
dc = (struct rtgui_dc_hw*) self; dc = (struct rtgui_dc_hw *) self;
/* get owner */ /* get owner */
rtgui_widget_get_rect(dc->owner, rect); rtgui_widget_get_rect(dc->owner, rect);
} }

View File

@ -19,79 +19,79 @@
/* standard file read/write */ /* standard file read/write */
struct rtgui_filerw_stdio struct rtgui_filerw_stdio
{ {
/* inherit from rtgui_filerw */ /* inherit from rtgui_filerw */
struct rtgui_filerw parent; struct rtgui_filerw parent;
int fd; int fd;
rt_bool_t eof; rt_bool_t eof;
}; };
static int stdio_seek(struct rtgui_filerw *context, rt_off_t offset, int whence) static int stdio_seek(struct rtgui_filerw *context, rt_off_t offset, int whence)
{ {
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
int stdio_whence[3] = {SEEK_SET, SEEK_CUR, SEEK_END}; int stdio_whence[3] = {SEEK_SET, SEEK_CUR, SEEK_END};
if (whence < RTGUI_FILE_SEEK_SET || whence > RTGUI_FILE_SEEK_END) if (whence < RTGUI_FILE_SEEK_SET || whence > RTGUI_FILE_SEEK_END)
{ {
return -1; return -1;
} }
return lseek(stdio_filerw->fd, offset, stdio_whence[whence]); return lseek(stdio_filerw->fd, offset, stdio_whence[whence]);
} }
static int stdio_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_size_t maxnum) static int stdio_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_size_t maxnum)
{ {
int result; int result;
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
/* end of file */ struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
if (stdio_filerw->eof == RT_TRUE) return -1;
result = read(stdio_filerw->fd, ptr, size * maxnum); /* end of file */
if (result == 0) stdio_filerw->eof = RT_TRUE; if (stdio_filerw->eof == RT_TRUE) return -1;
return result; result = read(stdio_filerw->fd, ptr, size * maxnum);
if (result == 0) stdio_filerw->eof = RT_TRUE;
return result;
} }
static int stdio_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num) static int stdio_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num)
{ {
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
return write(stdio_filerw->fd, (char*)ptr, size * num); return write(stdio_filerw->fd, (char *)ptr, size * num);
} }
static int stdio_tell(struct rtgui_filerw* context) static int stdio_tell(struct rtgui_filerw *context)
{ {
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
return lseek(stdio_filerw->fd, 0, SEEK_CUR); return lseek(stdio_filerw->fd, 0, SEEK_CUR);
} }
static int stdio_eof(struct rtgui_filerw* context) static int stdio_eof(struct rtgui_filerw *context)
{ {
int result; int result;
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
if (stdio_filerw->eof == RT_TRUE) result = 1; if (stdio_filerw->eof == RT_TRUE) result = 1;
else result = -1; else result = -1;
return result; return result;
} }
static int stdio_close(struct rtgui_filerw *context) static int stdio_close(struct rtgui_filerw *context)
{ {
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
if (stdio_filerw) if (stdio_filerw)
{ {
close(stdio_filerw->fd); close(stdio_filerw->fd);
rtgui_free(stdio_filerw); rtgui_free(stdio_filerw);
return 0; return 0;
} }
return -1; return -1;
} }
#endif #endif
@ -99,249 +99,266 @@ static int stdio_close(struct rtgui_filerw *context)
/* memory file read/write */ /* memory file read/write */
struct rtgui_filerw_mem struct rtgui_filerw_mem
{ {
/* inherit from rtgui_filerw */ /* inherit from rtgui_filerw */
struct rtgui_filerw parent; struct rtgui_filerw parent;
const rt_uint8_t *mem_base, *mem_position, *mem_end; const rt_uint8_t *mem_base, *mem_position, *mem_end;
}; };
static int mem_seek(struct rtgui_filerw *context, rt_off_t offset, int whence) static int mem_seek(struct rtgui_filerw *context, rt_off_t offset, int whence)
{ {
const rt_uint8_t* newpos; const rt_uint8_t *newpos;
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context; struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
RT_ASSERT(mem != RT_NULL); RT_ASSERT(mem != RT_NULL);
switch (whence) { switch (whence)
case RTGUI_FILE_SEEK_SET: {
newpos = mem->mem_base + offset; case RTGUI_FILE_SEEK_SET:
break; newpos = mem->mem_base + offset;
break;
case RTGUI_FILE_SEEK_CUR: case RTGUI_FILE_SEEK_CUR:
newpos = mem->mem_position + offset; newpos = mem->mem_position + offset;
break; break;
case RTGUI_FILE_SEEK_END: case RTGUI_FILE_SEEK_END:
newpos = mem->mem_end + offset; newpos = mem->mem_end + offset;
break; break;
default: default:
return -1; return -1;
} }
if ( newpos < mem->mem_base ) if (newpos < mem->mem_base)
newpos = mem->mem_base; newpos = mem->mem_base;
if ( newpos > mem->mem_end ) if (newpos > mem->mem_end)
newpos = mem->mem_end; newpos = mem->mem_end;
mem->mem_position = newpos; mem->mem_position = newpos;
return mem->mem_position- mem->mem_base; return mem->mem_position - mem->mem_base;
} }
static int mem_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_size_t maxnum) static int mem_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_size_t maxnum)
{ {
int total_bytes; int total_bytes;
int mem_available; int mem_available;
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context; struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
total_bytes = (maxnum * size); total_bytes = (maxnum * size);
if ( (maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != size) ) if ((maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != size))
{ {
return -1; return -1;
} }
mem_available = mem->mem_end - mem->mem_position; mem_available = mem->mem_end - mem->mem_position;
if (total_bytes > mem_available) if (total_bytes > mem_available)
total_bytes = mem_available; total_bytes = mem_available;
rt_memcpy(ptr, mem->mem_position, total_bytes); rt_memcpy(ptr, mem->mem_position, total_bytes);
mem->mem_position += total_bytes; mem->mem_position += total_bytes;
return (total_bytes / size); return (total_bytes / size);
} }
static int mem_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num) static int mem_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num)
{ {
return 0; /* not support memory write */ return 0; /* not support memory write */
} }
static int mem_tell(struct rtgui_filerw* context) static int mem_tell(struct rtgui_filerw *context)
{ {
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context; struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
return mem->mem_position - mem->mem_base; return mem->mem_position - mem->mem_base;
} }
static int mem_eof(struct rtgui_filerw* context) static int mem_eof(struct rtgui_filerw *context)
{ {
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context; struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
return mem->mem_position >= mem->mem_end; return mem->mem_position >= mem->mem_end;
} }
static int mem_close(struct rtgui_filerw *context) static int mem_close(struct rtgui_filerw *context)
{ {
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context; struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
if (mem != RT_NULL) if (mem != RT_NULL)
{ {
rtgui_free(mem); rtgui_free(mem);
return 0; return 0;
} }
return -1; return -1;
} }
const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context) const rt_uint8_t *rtgui_filerw_mem_getdata(struct rtgui_filerw *context)
{ {
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context; struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
/* check whether it's a memory filerw */ /* check whether it's a memory filerw */
if (mem->parent.read != mem_read) return RT_NULL; if (mem->parent.read != mem_read) return RT_NULL;
return mem->mem_base; return mem->mem_base;
} }
/* file read/write public interface */ /* file read/write public interface */
#ifdef RTGUI_USING_DFS_FILERW #ifdef RTGUI_USING_DFS_FILERW
static int parse_mode(const char *mode) static int parse_mode(const char *mode)
{ {
int f=0; int f = 0;
for (;;)
{
switch (*mode)
{
case 0: return f;
case 'b': f|=O_BINARY;break;
case 'r': f=O_RDONLY; break;
case 'w': f=O_WRONLY|O_CREAT|O_TRUNC; break;
case 'a': f=O_WRONLY|O_CREAT|O_APPEND; break;
case '+': f=(f&(~O_WRONLY))|O_RDWR; break;
}
++mode; for (;;)
} {
switch (*mode)
{
case 0:
return f;
case 'b':
f |= O_BINARY;
break;
case 'r':
f = O_RDONLY;
break;
case 'w':
f = O_WRONLY | O_CREAT | O_TRUNC;
break;
case 'a':
f = O_WRONLY | O_CREAT | O_APPEND;
break;
case '+':
f = (f & (~O_WRONLY)) | O_RDWR;
break;
}
++mode;
}
} }
struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* mode) struct rtgui_filerw *rtgui_filerw_create_file(const char *filename, const char *mode)
{ {
int fd; int fd;
struct rtgui_filerw_stdio *rw; struct rtgui_filerw_stdio *rw;
RT_ASSERT(filename != RT_NULL); RT_ASSERT(filename != RT_NULL);
rw = RT_NULL; rw = RT_NULL;
#ifdef _WIN32 #ifdef _WIN32_NATIVE
fd = _open(filename, parse_mode(mode), 0); fd = _open(filename, parse_mode(mode), 0);
#else #else
fd = open(filename, parse_mode(mode), 0); fd = open(filename, parse_mode(mode), 0);
#endif #endif
if ( fd >= 0 ) if (fd >= 0)
{ {
rw = (struct rtgui_filerw_stdio*) rtgui_malloc(sizeof(struct rtgui_filerw_stdio)); rw = (struct rtgui_filerw_stdio *) rtgui_malloc(sizeof(struct rtgui_filerw_stdio));
if (rw != RT_NULL) if (rw != RT_NULL)
{ {
rw->parent.seek = stdio_seek; rw->parent.seek = stdio_seek;
rw->parent.read = stdio_read; rw->parent.read = stdio_read;
rw->parent.write = stdio_write; rw->parent.write = stdio_write;
rw->parent.tell = stdio_tell; rw->parent.tell = stdio_tell;
rw->parent.close = stdio_close; rw->parent.close = stdio_close;
rw->parent.eof = stdio_eof; rw->parent.eof = stdio_eof;
rw->fd = fd; rw->fd = fd;
rw->eof = RT_FALSE; rw->eof = RT_FALSE;
} }
} }
return &(rw->parent); return &(rw->parent);
} }
int rtgui_filerw_unlink(const char *filename) int rtgui_filerw_unlink(const char *filename)
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
return _unlink(filename); return _unlink(filename);
#else #else
return unlink(filename); #ifndef RT_USING_DFS
/* no unlink function */
return -1;
#else
return unlink(filename);
#endif
#endif #endif
} }
#endif #endif
struct rtgui_filerw* rtgui_filerw_create_mem(const rt_uint8_t* mem, rt_size_t size) struct rtgui_filerw *rtgui_filerw_create_mem(const rt_uint8_t *mem, rt_size_t size)
{ {
struct rtgui_filerw_mem* rw; struct rtgui_filerw_mem *rw;
RT_ASSERT(mem != RT_NULL); RT_ASSERT(mem != RT_NULL);
rw = (struct rtgui_filerw_mem*) rtgui_malloc(sizeof(struct rtgui_filerw_mem)); rw = (struct rtgui_filerw_mem *) rtgui_malloc(sizeof(struct rtgui_filerw_mem));
if (rw != RT_NULL) if (rw != RT_NULL)
{ {
rw->parent.seek = mem_seek; rw->parent.seek = mem_seek;
rw->parent.read = mem_read; rw->parent.read = mem_read;
rw->parent.write = mem_write; rw->parent.write = mem_write;
rw->parent.tell = mem_tell; rw->parent.tell = mem_tell;
rw->parent.eof = mem_eof; rw->parent.eof = mem_eof;
rw->parent.close = mem_close; rw->parent.close = mem_close;
rw->mem_base = mem; rw->mem_base = mem;
rw->mem_position = mem; rw->mem_position = mem;
rw->mem_end = mem + size; rw->mem_end = mem + size;
} }
return &(rw->parent); return &(rw->parent);
} }
int rtgui_filerw_seek(struct rtgui_filerw* context, rt_off_t offset, int whence) int rtgui_filerw_seek(struct rtgui_filerw *context, rt_off_t offset, int whence)
{ {
RT_ASSERT(context != RT_NULL); RT_ASSERT(context != RT_NULL);
return context->seek(context, offset, whence); return context->seek(context, offset, whence);
} }
int rtgui_filerw_read(struct rtgui_filerw* context, void* buffer, rt_size_t size, rt_size_t count) int rtgui_filerw_read(struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count)
{ {
RT_ASSERT(context != RT_NULL); RT_ASSERT(context != RT_NULL);
return context->read(context, buffer, size, count); return context->read(context, buffer, size, count);
} }
int rtgui_filerw_write(struct rtgui_filerw* context, const void* buffer, rt_size_t size, rt_size_t count) int rtgui_filerw_write(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count)
{ {
RT_ASSERT(context != RT_NULL); RT_ASSERT(context != RT_NULL);
return context->write(context, buffer, size, count); return context->write(context, buffer, size, count);
} }
int rtgui_filerw_eof (struct rtgui_filerw* context) int rtgui_filerw_eof(struct rtgui_filerw *context)
{ {
RT_ASSERT(context != RT_NULL); RT_ASSERT(context != RT_NULL);
return context->eof(context); return context->eof(context);
} }
int rtgui_filerw_tell(struct rtgui_filerw* context) int rtgui_filerw_tell(struct rtgui_filerw *context)
{ {
RT_ASSERT(context != RT_NULL); RT_ASSERT(context != RT_NULL);
return context->tell(context); return context->tell(context);
} }
int rtgui_filerw_close(struct rtgui_filerw* context) int rtgui_filerw_close(struct rtgui_filerw *context)
{ {
int result; int result;
RT_ASSERT(context != RT_NULL); RT_ASSERT(context != RT_NULL);
/* close context */ /* close context */
result = context->close(context); result = context->close(context);
if (result != 0) if (result != 0)
{ {
/* close file failed */ /* close file failed */
return -1; return -1;
} }
return 0; return 0;
} }

View File

@ -15,7 +15,7 @@
#include <rtgui/dc.h> #include <rtgui/dc.h>
static rtgui_list_t _rtgui_font_list; static rtgui_list_t _rtgui_font_list;
static struct rtgui_font* rtgui_default_font; static struct rtgui_font *rtgui_default_font;
extern struct rtgui_font rtgui_font_asc16; extern struct rtgui_font rtgui_font_asc16;
extern struct rtgui_font rtgui_font_arial16; extern struct rtgui_font rtgui_font_arial16;
@ -28,131 +28,131 @@ extern struct rtgui_font rtgui_font_hz12;
void rtgui_font_system_init() void rtgui_font_system_init()
{ {
rtgui_list_init(&(_rtgui_font_list)); rtgui_list_init(&(_rtgui_font_list));
/* set default font to NULL */ /* set default font to NULL */
rtgui_default_font = RT_NULL; rtgui_default_font = RT_NULL;
#ifdef RTGUI_USING_FONT16 #ifdef RTGUI_USING_FONT16
rtgui_font_system_add_font(&rtgui_font_asc16); rtgui_font_system_add_font(&rtgui_font_asc16);
#ifdef RTGUI_USING_FONTHZ #ifdef RTGUI_USING_FONTHZ
rtgui_font_system_add_font(&rtgui_font_hz16); rtgui_font_system_add_font(&rtgui_font_hz16);
#endif #endif
#endif #endif
#ifdef RTGUI_USING_FONT12 #ifdef RTGUI_USING_FONT12
rtgui_font_system_add_font(&rtgui_font_asc12); rtgui_font_system_add_font(&rtgui_font_asc12);
#ifdef RTGUI_USING_FONTHZ #ifdef RTGUI_USING_FONTHZ
rtgui_font_system_add_font(&rtgui_font_hz12); rtgui_font_system_add_font(&rtgui_font_hz12);
#endif #endif
#endif #endif
#ifdef RTGUI_USING_FONT12 #ifdef RTGUI_USING_FONT12
if (rtgui_default_font == RT_NULL) if (rtgui_default_font == RT_NULL)
rtgui_font_set_defaut(&rtgui_font_asc12); rtgui_font_set_defaut(&rtgui_font_asc12);
#endif #endif
#ifdef RTGUI_USING_FONT16 #ifdef RTGUI_USING_FONT16
if (rtgui_default_font == RT_NULL) if (rtgui_default_font == RT_NULL)
rtgui_font_set_defaut(&rtgui_font_asc16); rtgui_font_set_defaut(&rtgui_font_asc16);
#endif #endif
} }
void rtgui_font_system_add_font(struct rtgui_font* font) void rtgui_font_system_add_font(struct rtgui_font *font)
{ {
rtgui_list_init(&(font->list)); rtgui_list_init(&(font->list));
rtgui_list_append(&_rtgui_font_list, &(font->list)); rtgui_list_append(&_rtgui_font_list, &(font->list));
/* init font */ /* init font */
if (font->engine->font_init != RT_NULL) if (font->engine->font_init != RT_NULL)
font->engine->font_init(font); font->engine->font_init(font);
/* first refer, load it */ /* first refer, load it */
if (font->engine->font_load != RT_NULL) if (font->engine->font_load != RT_NULL)
font->engine->font_load(font); font->engine->font_load(font);
} }
void rtgui_font_system_remove_font(struct rtgui_font* font) void rtgui_font_system_remove_font(struct rtgui_font *font)
{ {
rtgui_list_remove(&_rtgui_font_list, &(font->list)); rtgui_list_remove(&_rtgui_font_list, &(font->list));
} }
struct rtgui_font* rtgui_font_default() struct rtgui_font *rtgui_font_default()
{ {
return rtgui_default_font; return rtgui_default_font;
} }
void rtgui_font_set_defaut(struct rtgui_font* font) void rtgui_font_set_defaut(struct rtgui_font *font)
{ {
rtgui_default_font = font; rtgui_default_font = font;
} }
struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height) struct rtgui_font *rtgui_font_refer(const char *family, rt_uint16_t height)
{ {
/* search font */ /* search font */
struct rtgui_list_node* node; struct rtgui_list_node *node;
struct rtgui_font* font; struct rtgui_font *font;
rtgui_list_foreach(node, &_rtgui_font_list) rtgui_list_foreach(node, &_rtgui_font_list)
{ {
font = rtgui_list_entry(node, struct rtgui_font, list); font = rtgui_list_entry(node, struct rtgui_font, list);
if ((rt_strncmp((const char*)font->family, (const char*)family, RTGUI_NAME_MAX) == 0) && if ((rt_strncmp(font->family, family, RTGUI_NAME_MAX) == 0) &&
font->height == height) font->height == height)
{ {
font->refer_count ++; font->refer_count ++;
return font; return font;
} }
} }
return RT_NULL; return RT_NULL;
} }
void rtgui_font_derefer(struct rtgui_font* font) void rtgui_font_derefer(struct rtgui_font *font)
{ {
RT_ASSERT(font != RT_NULL); RT_ASSERT(font != RT_NULL);
font->refer_count --; font->refer_count --;
/* no refer, remove font */ /* no refer, remove font */
if (font->refer_count == 0) if (font->refer_count == 0)
{ {
rtgui_font_system_remove_font(font); rtgui_font_system_remove_font(font);
} }
} }
/* draw a text */ /* draw a text */
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) void rtgui_font_draw(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect)
{ {
RT_ASSERT(font != RT_NULL); RT_ASSERT(font != RT_NULL);
if (font->engine != RT_NULL && if (font->engine != RT_NULL &&
font->engine->font_draw_text != RT_NULL) font->engine->font_draw_text != RT_NULL)
{ {
font->engine->font_draw_text(font, dc, text, len, rect); font->engine->font_draw_text(font, dc, text, len, rect);
} }
} }
int rtgui_font_get_string_width(struct rtgui_font* font, const char* text) int rtgui_font_get_string_width(struct rtgui_font *font, const char *text)
{ {
rtgui_rect_t rect; rtgui_rect_t rect;
/* get metrics */ /* get metrics */
rtgui_font_get_metrics(font, text, &rect); rtgui_font_get_metrics(font, text, &rect);
return rect.x2 - rect.x1; return rect.x2 - rect.x1;
} }
void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect) void rtgui_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect)
{ {
RT_ASSERT(font != RT_NULL); RT_ASSERT(font != RT_NULL);
if (font->engine != RT_NULL && if (font->engine != RT_NULL &&
font->engine->font_get_metrics != RT_NULL) font->engine->font_get_metrics != RT_NULL)
{ {
font->engine->font_get_metrics(font, text, rect); font->engine->font_get_metrics(font, text, rect);
} }
else else
{ {
/* no font engine found, set rect to zero */ /* no font engine found, set rect to zero */
rt_memset(rect, 0, sizeof(rtgui_rect_t)); rt_memset(rect, 0, sizeof(rtgui_rect_t));
} }
} }

View File

@ -16,168 +16,169 @@
/* bitmap font private data */ /* bitmap font private data */
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect); static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect);
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect); static void rtgui_bitmap_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect);
const struct rtgui_font_engine bmp_font_engine = const struct rtgui_font_engine bmp_font_engine =
{ {
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
rtgui_bitmap_font_draw_text, rtgui_bitmap_font_draw_text,
rtgui_bitmap_font_get_metrics rtgui_bitmap_font_get_metrics
}; };
void rtgui_bitmap_font_draw_char(struct rtgui_font_bitmap* font, struct rtgui_dc* dc, const char ch, void rtgui_bitmap_font_draw_char(struct rtgui_font_bitmap *font, struct rtgui_dc *dc, const char ch,
rtgui_rect_t* rect) rtgui_rect_t *rect)
{ {
rtgui_color_t bc; rtgui_color_t bc;
const rt_uint8_t* font_ptr; const rt_uint8_t *font_ptr;
rt_uint16_t x, y, w, h, style; rt_uint16_t x, y, w, h, style;
register rt_base_t i, j, /*k,*/ word_bytes; register rt_base_t i, j, /*k,*/ word_bytes;
/* check first and last char */ /* check first and last char */
if (ch < font->first_char || ch > font->last_char) return; if (ch < font->first_char || ch > font->last_char) return;
/* get text style */ /* get text style */
style = rtgui_dc_get_gc(dc)->textstyle; style = rtgui_dc_get_gc(dc)->textstyle;
bc = rtgui_dc_get_gc(dc)->background; bc = rtgui_dc_get_gc(dc)->background;
x = rect->x1; x = rect->x1;
y = rect->y1; y = rect->y1;
/* get width */ /* get width */
if (font->char_width == RT_NULL) if (font->char_width == RT_NULL)
{ {
word_bytes = (((font->width - 1) / 8) + 1); word_bytes = (((font->width - 1) / 8) + 1);
font_ptr = font->bmp + (ch - font->first_char) * word_bytes * font->height; font_ptr = font->bmp + (ch - font->first_char) * word_bytes * font->height;
} }
else else
{ {
word_bytes = ((font->char_width[ch - font->first_char] - 1)/8) + 1; word_bytes = ((font->char_width[ch - font->first_char] - 1) / 8) + 1;
font_ptr = font->bmp + font->offset[ch - font->first_char]; font_ptr = font->bmp + font->offset[ch - font->first_char];
} }
w = (font->width + x > rect->x2) ? rect->x2 - rect->x1 : font->width; w = (font->width + x > rect->x2) ? rect->x2 - rect->x1 : font->width;
h = (font->height + y > rect->y2) ? rect->y2 - rect->y1 : font->height; h = (font->height + y > rect->y2) ? rect->y2 - rect->y1 : font->height;
for(i = 0; i < h; i++) for (i = 0; i < h; i++)
{ {
rt_uint8_t chr; rt_uint8_t chr;
const rt_uint8_t *ptr = font_ptr + i * word_bytes; const rt_uint8_t *ptr = font_ptr + i * word_bytes;
for(j = 0; j < w; j++) for (j = 0; j < w; j++)
{ {
if(j % 8 == 0)chr = *ptr++; if (j % 8 == 0)chr = *ptr++;
if(chr & 0x80) if (chr & 0x80)
rtgui_dc_draw_point(dc, j + x, i + y); rtgui_dc_draw_point(dc, j + x, i + y);
else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND) else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND)
rtgui_dc_draw_color_point(dc, j + x, i + y, bc); rtgui_dc_draw_color_point(dc, j + x, i + y, bc);
chr <<= 1; chr <<= 1;
} }
} }
} }
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc,
const char* text, rt_ubase_t len, struct rtgui_rect* rect) const char *text, rt_ubase_t len, struct rtgui_rect *rect)
{ {
rt_uint32_t length; rt_uint32_t length;
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data); struct rtgui_font_bitmap *bmp_font = (struct rtgui_font_bitmap *)(font->data);
#ifdef RTGUI_USING_FONTHZ #ifdef RTGUI_USING_FONTHZ
struct rtgui_font* hz_font; struct rtgui_font *hz_font;
RT_ASSERT(bmp_font != RT_NULL); RT_ASSERT(bmp_font != RT_NULL);
if (rect->y1 > rect->y2) return; if (rect->y1 > rect->y2) return;
hz_font = rtgui_font_refer("hz", font->height); hz_font = rtgui_font_refer("hz", font->height);
while ((rect->x1 < rect->x2) && len) while ((rect->x1 < rect->x2) && len)
{ {
length = 0; length = 0;
while ((rt_uint8_t)*(text + length) >= 0x80) length ++; /* it's not a ascii character */ while ((rt_uint8_t) * (text + length) >= 0x80) length ++; /* it's not a ascii character */
if (length > 0) if (length > 0)
{ {
if (hz_font != RT_NULL) rtgui_font_draw(hz_font, dc, text, length, rect); if (hz_font != RT_NULL) rtgui_font_draw(hz_font, dc, text, length, rect);
text += length; text += length;
len -= length; len -= length;
} }
length = 0; length = 0;
while (((rt_uint8_t)*(text + length) < 0x80) && *(text + length)) length ++; while (((rt_uint8_t) * (text + length) < 0x80) && *(text + length)) length ++;
if (length > 0) if (length > 0)
{ {
len -= length; len -= length;
while (length-- && rect->x1 < rect->x2) while (length-- && rect->x1 < rect->x2)
{ {
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect); rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect);
/* move x to next character */ /* move x to next character */
if (bmp_font->char_width == RT_NULL) if (bmp_font->char_width == RT_NULL)
rect->x1 += bmp_font->width; rect->x1 += bmp_font->width;
else else
rect->x1 += bmp_font->char_width[*text - bmp_font->first_char]; rect->x1 += bmp_font->char_width[*text - bmp_font->first_char];
text ++; text ++;
} }
} }
} }
if (hz_font != RT_NULL) rtgui_font_derefer(hz_font); if (hz_font != RT_NULL) rtgui_font_derefer(hz_font);
#else #else
if (rect->y1 > rect->y2) return; if (rect->y1 > rect->y2) return;
while ((rect->x1 < rect->x2) && len) while ((rect->x1 < rect->x2) && len)
{ {
length = 0; length = 0;
while (((rt_uint8_t)*(text + length) < 0x80) && *(text + length)) length ++; while (((rt_uint8_t) * (text + length) < 0x80) && *(text + length)) length ++;
if (length > 0) if (length > 0)
{ {
len -= length; len -= length;
while (length-- && rect->x1 < rect->x2) while (length-- && rect->x1 < rect->x2)
{ {
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect); rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect);
/* move x to next character */ /* move x to next character */
if (bmp_font->char_width == RT_NULL) if (bmp_font->char_width == RT_NULL)
rect->x1 += bmp_font->width; rect->x1 += bmp_font->width;
else else
rect->x1 += bmp_font->char_width[*text - bmp_font->first_char]; rect->x1 += bmp_font->char_width[*text - bmp_font->first_char];
text ++; text ++;
} }
} }
} }
#endif #endif
} }
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect) static void rtgui_bitmap_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect)
{ {
rt_uint32_t length; rt_uint32_t length;
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data); struct rtgui_font_bitmap *bmp_font = (struct rtgui_font_bitmap *)(font->data);
RT_ASSERT(bmp_font != RT_NULL); RT_ASSERT(bmp_font != RT_NULL);
/* set init metrics rect */ /* set init metrics rect */
rect->x1 = rect->y1 = 0;rect->x2 = 0; rect->x1 = rect->y1 = 0;
rect->y2 = bmp_font->height; rect->x2 = 0;
rect->y2 = bmp_font->height;
while (*text) while (*text)
{ {
length = 0; length = 0;
while ((rt_uint8_t)*(text + length) >= 0x80) length ++; /* it's not a ascii character */ while ((rt_uint8_t) * (text + length) >= 0x80) length ++; /* it's not a ascii character */
rect->x2 += (font->height/2) * length; rect->x2 += (font->height / 2) * length;
text += length; text += length;
length = 0; length = 0;
while (((rt_uint8_t)*(text + length) < 0x80) && *(text + length)) length ++; while (((rt_uint8_t) * (text + length) < 0x80) && *(text + length)) length ++;
if (bmp_font->char_width != NULL) if (bmp_font->char_width != NULL)
{ {
/* get width for each character */ /* get width for each character */
while (*text && ((rt_uint8_t)*text < 0x80)) while (*text && ((rt_uint8_t)*text < 0x80))
{ {
rect->x2 += bmp_font->char_width[*text - bmp_font->first_char]; rect->x2 += bmp_font->char_width[*text - bmp_font->first_char];
text ++; text ++;
} }
} }
else else
{ {
/* set metrics rect */ /* set metrics rect */
rect->x2 += bmp_font->width * length; rect->x2 += bmp_font->width * length;
text += length; text += length;
} }
} }
} }

View File

@ -5,233 +5,235 @@
#include <freetype/freetype.h> #include <freetype/freetype.h>
#include <freetype/ftglyph.h> #include <freetype/ftglyph.h>
static void rtgui_freetype_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect); static void rtgui_freetype_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect);
static void rtgui_freetype_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect); static void rtgui_freetype_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect);
struct rtgui_font_engine freetype_font_engine = struct rtgui_font_engine freetype_font_engine =
{ {
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
rtgui_freetype_font_draw_text, rtgui_freetype_font_draw_text,
rtgui_freetype_font_get_metrics rtgui_freetype_font_get_metrics
}; };
struct rtgui_freetype_font struct rtgui_freetype_font
{ {
int bold; int bold;
int italic; int italic;
FT_Face face; FT_Face face;
FT_Library library; FT_Library library;
}; };
static void gbk_to_unicode(rt_uint16_t *unicode, const unsigned char *text, int len) static void gbk_to_unicode(rt_uint16_t *unicode, const unsigned char *text, int len)
{ {
int i; int i;
unsigned short wch; unsigned short wch;
extern unsigned short ff_convert(unsigned short wch, int direction); extern unsigned short ff_convert(unsigned short wch, int direction);
for (i = 0; i < len; ) for (i = 0; i < len;)
{ {
if (*text < 0x80) if (*text < 0x80)
{ {
wch = *text; wch = *text;
*unicode = ff_convert(wch, 1); *unicode = ff_convert(wch, 1);
text ++; text ++;
i ++; i ++;
} }
else else
{ {
wch = wch = *(text + 1) | (*text << 8); wch = wch = *(text + 1) | (*text << 8);
*unicode = ff_convert(wch, 1); *unicode = ff_convert(wch, 1);
text += 2; text += 2;
i += 2; i += 2;
} }
unicode ++; unicode ++;
} }
*unicode = '\0'; *unicode = '\0';
} }
static void rtgui_freetype_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) static void rtgui_freetype_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect)
{ {
int index = 0; int index = 0;
FT_Error err = 0; FT_Error err = 0;
rt_uint16_t *text_short, *text_ptr; rt_uint16_t *text_short, *text_ptr;
struct rtgui_freetype_font* freetype; struct rtgui_freetype_font *freetype;
RT_ASSERT(font != RT_NULL); RT_ASSERT(font != RT_NULL);
freetype = (struct rtgui_freetype_font*) font->data; freetype = (struct rtgui_freetype_font *) font->data;
RT_ASSERT(freetype != RT_NULL); RT_ASSERT(freetype != RT_NULL);
/* allocate unicode buffer */ /* allocate unicode buffer */
text_short = (rt_uint16_t*)rtgui_malloc((len + 1)* 2); text_short = (rt_uint16_t *)rtgui_malloc((len + 1) * 2);
if (text_short == RT_NULL) return ; /* out of memory */ if (text_short == RT_NULL) return ; /* out of memory */
/* convert gbk to unicode */ /* convert gbk to unicode */
gbk_to_unicode(text_short, text, len); gbk_to_unicode(text_short, text, len);
text_ptr = text_short; text_ptr = text_short;
while (*text_ptr) while (*text_ptr)
{ {
index = FT_Get_Char_Index(freetype->face, *text_ptr); index = FT_Get_Char_Index(freetype->face, *text_ptr);
err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT|FT_LOAD_RENDER); err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT | FT_LOAD_RENDER);
if (err == 0) if (err == 0)
{ {
int rows, x; int rows, x;
rt_uint8_t* ptr; rt_uint8_t *ptr;
/* render font */ /* render font */
ptr = (rt_uint8_t*)freetype->face->glyph->bitmap.buffer; ptr = (rt_uint8_t *)freetype->face->glyph->bitmap.buffer;
for (rows = 0; rows < freetype->face->glyph->bitmap.rows; rows ++)
for (x = 0; x < freetype->face->glyph->bitmap.width; x++)
{
if (*ptr > 0)
rtgui_dc_draw_color_point(dc, rect->x1 + x, rect->y1 + rows, RTGUI_RGB(0xff - *ptr, 0xff - *ptr, 0xff - *ptr));
ptr ++;
}
}
text_ptr ++; for (rows = 0; rows < freetype->face->glyph->bitmap.rows; rows ++)
rect->x1 += freetype->face->glyph->bitmap.width; for (x = 0; x < freetype->face->glyph->bitmap.width; x++)
} {
if (*ptr > 0)
rtgui_dc_draw_color_point(dc, rect->x1 + x, rect->y1 + rows, RTGUI_RGB(0xff - *ptr, 0xff - *ptr, 0xff - *ptr));
ptr ++;
}
}
/* release unicode buffer */ text_ptr ++;
rtgui_free(text_short); rect->x1 += freetype->face->glyph->bitmap.width;
}
/* release unicode buffer */
rtgui_free(text_short);
} }
static void rtgui_freetype_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect) static void rtgui_freetype_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect)
{ {
int index = 0, len; int index = 0, len;
FT_Error err = 0; FT_Error err = 0;
rt_uint16_t w = 0, h = 0; rt_uint16_t w = 0, h = 0;
rt_uint16_t *text_short, *text_ptr; rt_uint16_t *text_short, *text_ptr;
struct rtgui_freetype_font* freetype; struct rtgui_freetype_font *freetype;
RT_ASSERT(font != RT_NULL);
RT_ASSERT(rect != RT_NULL);
freetype = (struct rtgui_freetype_font*) font->data;
RT_ASSERT(freetype != RT_NULL);
len = strlen(text); RT_ASSERT(font != RT_NULL);
memset(rect, 0, sizeof(struct rtgui_rect)); RT_ASSERT(rect != RT_NULL);
freetype = (struct rtgui_freetype_font *) font->data;
RT_ASSERT(freetype != RT_NULL);
/* allocate unicode buffer */ len = strlen(text);
text_short = (rt_uint16_t*)rtgui_malloc((len + 1)* 2); memset(rect, 0, sizeof(struct rtgui_rect));
if (text_short == RT_NULL) return ; /* out of memory */
/* convert gbk to unicode */ /* allocate unicode buffer */
gbk_to_unicode(text_short, text, len); text_short = (rt_uint16_t *)rtgui_malloc((len + 1) * 2);
text_ptr = text_short; if (text_short == RT_NULL) return ; /* out of memory */
while (*text_ptr) /* convert gbk to unicode */
{ gbk_to_unicode(text_short, text, len);
index = FT_Get_Char_Index(freetype->face, *text_ptr); text_ptr = text_short;
err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT);
if (err == 0) while (*text_ptr)
{ {
w += freetype->face->glyph->bitmap.width; index = FT_Get_Char_Index(freetype->face, *text_ptr);
if (freetype->face->glyph->bitmap.rows > h) err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT);
{
h = freetype->face->glyph->bitmap.rows;
}
}
text_ptr ++; if (err == 0)
} {
w += freetype->face->glyph->bitmap.width;
if (freetype->face->glyph->bitmap.rows > h)
{
h = freetype->face->glyph->bitmap.rows;
}
}
rect->x1 = 0; rect->y1 = 0; text_ptr ++;
rect->x2 = w; rect->y2 = h; }
/* release unicode buffer */ rect->x1 = 0;
rtgui_free(text_short); rect->y1 = 0;
rect->x2 = w;
rect->y2 = h;
/* release unicode buffer */
rtgui_free(text_short);
} }
rtgui_font_t* rtgui_freetype_font_create(const char* filename, int bold, int italic, rt_size_t size) rtgui_font_t *rtgui_freetype_font_create(const char *filename, int bold, int italic, rt_size_t size)
{ {
FT_Error err = 0; FT_Error err = 0;
struct rtgui_font* font; struct rtgui_font *font;
font = (struct rtgui_font*) rtgui_malloc (sizeof(struct rtgui_font)); font = (struct rtgui_font *) rtgui_malloc(sizeof(struct rtgui_font));
if (font != RT_NULL) if (font != RT_NULL)
{ {
struct rtgui_freetype_font* freetype; struct rtgui_freetype_font *freetype;
freetype = (struct rtgui_freetype_font*) rtgui_malloc (sizeof(struct rtgui_freetype_font)); freetype = (struct rtgui_freetype_font *) rtgui_malloc(sizeof(struct rtgui_freetype_font));
if (freetype == RT_NULL) if (freetype == RT_NULL)
{ {
rtgui_free(font); rtgui_free(font);
font = RT_NULL; font = RT_NULL;
} }
else else
{ {
err = FT_Init_FreeType(&freetype->library); err = FT_Init_FreeType(&freetype->library);
if((err = FT_New_Face(freetype->library, filename, 0, &freetype->face))) if ((err = FT_New_Face(freetype->library, filename, 0, &freetype->face)))
{ {
FT_Done_FreeType(freetype->library); FT_Done_FreeType(freetype->library);
rtgui_free(font); rtgui_free(font);
font = RT_NULL; font = RT_NULL;
} }
else else
{ {
err = FT_Select_Charmap(freetype->face, ft_encoding_unicode); err = FT_Select_Charmap(freetype->face, ft_encoding_unicode);
if(err) if (err)
{ {
err = FT_Select_Charmap(freetype->face, ft_encoding_latin_1 ); err = FT_Select_Charmap(freetype->face, ft_encoding_latin_1);
} }
err = FT_Set_Pixel_Sizes(freetype->face, 0, size); err = FT_Set_Pixel_Sizes(freetype->face, 0, size);
if (err != 0) if (err != 0)
{ {
rtgui_free(font); rtgui_free(font);
font = RT_NULL; font = RT_NULL;
FT_Done_FreeType(freetype->library); FT_Done_FreeType(freetype->library);
rtgui_free(freetype); rtgui_free(freetype);
return RT_NULL; return RT_NULL;
} }
freetype->bold = bold; freetype->bold = bold;
freetype->italic = italic; freetype->italic = italic;
rt_kprintf("fonfile:%s\n", filename); rt_kprintf("fonfile:%s\n", filename);
rt_kprintf("font family_name:%s\n", freetype->face->family_name); rt_kprintf("font family_name:%s\n", freetype->face->family_name);
rt_kprintf("font style_name:%s\n", freetype->face->style_name); rt_kprintf("font style_name:%s\n", freetype->face->style_name);
/* set user data */ /* set user data */
font->data = freetype; font->data = freetype;
font->family = rt_strdup(freetype->face->family_name); font->family = rt_strdup(freetype->face->family_name);
font->height = (rt_uint16_t)size; font->height = (rt_uint16_t)size;
font->refer_count = 0; font->refer_count = 0;
font->engine = &freetype_font_engine; font->engine = &freetype_font_engine;
/* add to system */ /* add to system */
rtgui_font_system_add_font(font); rtgui_font_system_add_font(font);
} }
} }
} }
return font; return font;
} }
void rtgui_freetype_font_destroy(rtgui_font_t* font) void rtgui_freetype_font_destroy(rtgui_font_t *font)
{ {
struct rtgui_freetype_font* freetype; struct rtgui_freetype_font *freetype;
RT_ASSERT(font != RT_NULL);
freetype = (struct rtgui_freetype_font*) font->data;
RT_ASSERT(freetype != RT_NULL);
rtgui_font_system_remove_font(font); RT_ASSERT(font != RT_NULL);
freetype = (struct rtgui_freetype_font *) font->data;
RT_ASSERT(freetype != RT_NULL);
FT_Done_Face (freetype->face); rtgui_font_system_remove_font(font);
FT_Done_FreeType(freetype->library);
rtgui_free(freetype); FT_Done_Face(freetype->face);
rtgui_free(font); FT_Done_FreeType(freetype->library);
rtgui_free(freetype);
rtgui_free(font);
} }
#endif #endif

View File

@ -4,123 +4,156 @@
#ifdef RTGUI_USING_HZ_BMP #ifdef RTGUI_USING_HZ_BMP
static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect); static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect);
static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect); static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect);
const struct rtgui_font_engine hz_bmp_font_engine = const struct rtgui_font_engine hz_bmp_font_engine =
{ {
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
rtgui_hz_bitmap_font_draw_text, rtgui_hz_bitmap_font_draw_text,
rtgui_hz_bitmap_font_get_metrics rtgui_hz_bitmap_font_get_metrics
}; };
static void _rtgui_hz_bitmap_font_draw_text(struct rtgui_font_bitmap* bmp_font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) #ifdef RTGUI_USING_FONT_COMPACT
extern rt_uint32_t rtgui_font_mph12(const rt_uint16_t key);
extern rt_uint32_t rtgui_font_mph16(const rt_uint16_t key);
rt_inline const rt_uint8_t *_rtgui_hz_bitmap_get_font_ptr(struct rtgui_font_bitmap *bmp_font,
rt_uint8_t *str,
rt_base_t font_bytes)
{ {
rt_uint8_t* str; rt_uint16_t cha = *(rt_uint16_t *)str;
rtgui_color_t bc; int idx;
rt_uint16_t style;
register rt_base_t h, word_bytes, font_bytes;
RT_ASSERT(bmp_font != RT_NULL); if (bmp_font->height == 16)
idx = rtgui_font_mph16(cha);
else // asume the height is 12
idx = rtgui_font_mph12(cha);
/* get text style */ /* don't access beyond the data */
style = rtgui_dc_get_gc(dc)->textstyle; if (idx < 0)
bc = rtgui_dc_get_gc(dc)->background; idx = 0;
/* drawing height */ /* get font pixel data */
h = (bmp_font->height + rect->y1 > rect->y2)? rect->y2 - rect->y1 : bmp_font->height; return bmp_font->bmp + idx * font_bytes;
word_bytes = (bmp_font->width + 7)/8; }
font_bytes = word_bytes * bmp_font->height; #else
rt_inline const rt_uint8_t *_rtgui_hz_bitmap_get_font_ptr(struct rtgui_font_bitmap *bmp_font,
rt_uint8_t *str,
rt_base_t font_bytes)
{
rt_ubase_t sect, index;
str = (rt_uint8_t*)text; /* calculate section and index */
sect = *str - 0xA0;
index = *(str + 1) - 0xA0;
while (len > 0 && rect->x1 < rect->x2) /* get font pixel data */
{ return bmp_font->bmp + (94 * (sect - 1) + (index - 1)) * font_bytes;
const rt_uint8_t* font_ptr; }
rt_ubase_t sect, index; #endif
register rt_base_t i, j, k;
/* calculate section and index */ static void _rtgui_hz_bitmap_font_draw_text(struct rtgui_font_bitmap *bmp_font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect)
sect = *str - 0xA0; {
index = *(str+1) - 0xA0; rtgui_color_t bc;
rt_uint16_t style;
rt_uint8_t *str;
register rt_base_t h, word_bytes, font_bytes;
/* get font pixel data */ RT_ASSERT(bmp_font != RT_NULL);
font_ptr = bmp_font->bmp + (94 * (sect - 1) + (index - 1)) * font_bytes;
/* draw word */
for (i=0; i < h; i ++)
{
for (j=0; j < word_bytes; j++)
for (k=0; k < 8; k++)
{
if ( ((font_ptr[i*word_bytes + j] >> (7-k)) & 0x01) != 0 &&
(rect->x1 + 8 * j + k < rect->x2))
{
rtgui_dc_draw_point(dc, rect->x1 + 8*j + k, rect->y1 + i);
}
else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND)
{
rtgui_dc_draw_color_point(dc, rect->x1 + 8*j + k, rect->y1 + i, bc);
}
}
}
/* move x to next character */ /* get text style */
rect->x1 += bmp_font->width; style = rtgui_dc_get_gc(dc)->textstyle;
str += 2; bc = rtgui_dc_get_gc(dc)->background;
len -= 2;
} /* drawing height */
h = (bmp_font->height + rect->y1 > rect->y2) ? rect->y2 - rect->y1 : bmp_font->height;
word_bytes = (bmp_font->width + 7) / 8;
font_bytes = word_bytes * bmp_font->height;
str = (rt_uint8_t *)text;
while (len > 0 && rect->x1 < rect->x2)
{
const rt_uint8_t *font_ptr;
register rt_base_t i, j, k;
/* get font pixel data */
font_ptr = _rtgui_hz_bitmap_get_font_ptr(bmp_font, str, font_bytes);
/* draw word */
for (i = 0; i < h; i ++)
{
for (j = 0; j < word_bytes; j++)
for (k = 0; k < 8; k++)
{
if (((font_ptr[i * word_bytes + j] >> (7 - k)) & 0x01) != 0 &&
(rect->x1 + 8 * j + k < rect->x2))
{
rtgui_dc_draw_point(dc, rect->x1 + 8 * j + k, rect->y1 + i);
}
else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND)
{
rtgui_dc_draw_color_point(dc, rect->x1 + 8 * j + k, rect->y1 + i, bc);
}
}
}
/* move x to next character */
rect->x1 += bmp_font->width;
str += 2;
len -= 2;
}
} }
static void rtgui_hz_bitmap_font_draw_text (struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t length, struct rtgui_rect* rect) static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t length, struct rtgui_rect *rect)
{ {
rt_uint32_t len; rt_uint32_t len;
struct rtgui_font *efont; struct rtgui_font *efont;
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data); struct rtgui_font_bitmap *bmp_font = (struct rtgui_font_bitmap *)(font->data);
RT_ASSERT(dc != RT_NULL); RT_ASSERT(dc != RT_NULL);
/* get English font */ /* get English font */
efont = rtgui_font_refer("asc", bmp_font->height); efont = rtgui_font_refer("asc", bmp_font->height);
if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */ if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */
while (length > 0) while (length > 0)
{ {
len = 0; len = 0;
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len) && len < length) len ++; while (((rt_uint8_t) * (text + len)) < 0x80 && *(text + len) && len < length) len ++;
/* draw text with English font */ /* draw text with English font */
if (len > 0) if (len > 0)
{ {
rtgui_font_draw(efont, dc, text, len, rect); rtgui_font_draw(efont, dc, text, len, rect);
text += len; text += len;
length -= len; length -= len;
} }
len = 0; len = 0;
while (((rt_uint8_t)*(text + len)) >= 0x80 && len < length) len ++; while (((rt_uint8_t) * (text + len)) >= 0x80 && len < length) len ++;
if (len > 0) if (len > 0)
{ {
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect); _rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect);
text += len; text += len;
length -= len; length -= len;
} }
} }
rtgui_font_derefer(efont); rtgui_font_derefer(efont);
} }
static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect) static void rtgui_hz_bitmap_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect)
{ {
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data); struct rtgui_font_bitmap *bmp_font = (struct rtgui_font_bitmap *)(font->data);
RT_ASSERT(bmp_font != RT_NULL); RT_ASSERT(bmp_font != RT_NULL);
/* set metrics rect */ /* set metrics rect */
rect->x1 = rect->y1 = 0; rect->x1 = rect->y1 = 0;
/* Chinese font is always fixed font */ /* Chinese font is always fixed font */
rect->x2 = (rt_int16_t)(bmp_font->width * rt_strlen((const char*)text)); rect->x2 = (rt_int16_t)(bmp_font->width * rt_strlen((const char *)text));
rect->y2 = bmp_font->height; rect->y2 = bmp_font->height;
} }
#endif #endif

View File

@ -7,27 +7,27 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#ifdef RTGUI_USING_HZ_FILE #ifdef RTGUI_USING_HZ_FILE
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <io.h> #include <io.h>
#define open _open #define open _open
#define close _close #define close _close
#define read _read #define read _read
#define write _write #define write _write
#define unlink _unlink #define unlink _unlink
#else #else
#include <dfs_posix.h> #include <dfs_posix.h>
#endif #endif
#define HZ_CACHE_MAX 64 #define HZ_CACHE_MAX 64
static int _font_cache_compare(struct hz_cache* node1, struct hz_cache* node2); static int _font_cache_compare(struct hz_cache *node1, struct hz_cache *node2);
static void rtgui_hz_file_font_load(struct rtgui_font* font); static void rtgui_hz_file_font_load(struct rtgui_font *font);
static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect); static void rtgui_hz_file_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect);
static void rtgui_hz_file_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect); static void rtgui_hz_file_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect);
const struct rtgui_font_engine rtgui_hz_file_font_engine = const struct rtgui_font_engine rtgui_hz_file_font_engine =
{ {
RT_NULL, RT_NULL,
@ -37,9 +37,9 @@ const struct rtgui_font_engine rtgui_hz_file_font_engine =
}; };
SPLAY_PROTOTYPE(cache_tree, hz_cache, hz_node, _font_cache_compare); SPLAY_PROTOTYPE(cache_tree, hz_cache, hz_node, _font_cache_compare);
SPLAY_GENERATE (cache_tree, hz_cache, hz_node, _font_cache_compare); SPLAY_GENERATE(cache_tree, hz_cache, hz_node, _font_cache_compare);
static int _font_cache_compare(struct hz_cache* cache_1, struct hz_cache* cache_2) static int _font_cache_compare(struct hz_cache *cache_1, struct hz_cache *cache_2)
{ {
if (cache_1->hz_id > cache_2->hz_id) return 1; if (cache_1->hz_id > cache_2->hz_id) return 1;
if (cache_1->hz_id < cache_2->hz_id) return -1; if (cache_1->hz_id < cache_2->hz_id) return -1;
@ -47,7 +47,7 @@ static int _font_cache_compare(struct hz_cache* cache_1, struct hz_cache* cache_
return 0; return 0;
} }
static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t hz_id) static rt_uint8_t *_font_cache_get(struct rtgui_hz_file_font *font, rt_uint16_t hz_id)
{ {
rt_uint32_t seek; rt_uint32_t seek;
struct hz_cache *cache, search; struct hz_cache *cache, search;
@ -64,14 +64,14 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
rtgui_exit_critical(); rtgui_exit_critical();
/* found it */ /* found it */
return (rt_uint8_t*)(cache + 1); return (rt_uint8_t *)(cache + 1);
} }
/* exit critical */ /* exit critical */
rtgui_exit_critical(); rtgui_exit_critical();
/* can not find it, load to cache */ /* can not find it, load to cache */
cache = (struct hz_cache*) rtgui_malloc(sizeof(struct hz_cache) + font->font_data_size); cache = (struct hz_cache *) rtgui_malloc(sizeof(struct hz_cache) + font->font_data_size);
if (cache == RT_NULL) if (cache == RT_NULL)
return RT_NULL; /* no memory yet */ return RT_NULL; /* no memory yet */
@ -81,8 +81,8 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
/* read hz font data */ /* read hz font data */
if ((lseek(font->fd, seek, SEEK_SET) < 0) || if ((lseek(font->fd, seek, SEEK_SET) < 0) ||
read(font->fd, (char*)(cache + 1), font->font_data_size) != read(font->fd, (char *)(cache + 1), font->font_data_size) !=
font->font_data_size) font->font_data_size)
{ {
rtgui_free(cache); rtgui_free(cache);
return RT_NULL; return RT_NULL;
@ -94,7 +94,7 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
if (font->cache_size >= HZ_CACHE_MAX) if (font->cache_size >= HZ_CACHE_MAX)
{ {
/* remove a cache */ /* remove a cache */
struct hz_cache* left; struct hz_cache *left;
left = font->cache_root.sph_root; left = font->cache_root.sph_root;
while (SPLAY_LEFT(left, hz_node) != RT_NULL) left = SPLAY_LEFT(left, hz_node); while (SPLAY_LEFT(left, hz_node) != RT_NULL) left = SPLAY_LEFT(left, hz_node);
@ -111,20 +111,20 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
/* exit critical */ /* exit critical */
rtgui_exit_critical(); rtgui_exit_critical();
return (rt_uint8_t*)(cache + 1); return (rt_uint8_t *)(cache + 1);
} }
static void rtgui_hz_file_font_load(struct rtgui_font* font) static void rtgui_hz_file_font_load(struct rtgui_font *font)
{ {
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data; struct rtgui_hz_file_font *hz_file_font = (struct rtgui_hz_file_font *)font->data;
RT_ASSERT(hz_file_font != RT_NULL); RT_ASSERT(hz_file_font != RT_NULL);
hz_file_font->fd = open(hz_file_font->font_fn, O_RDONLY, 0); hz_file_font->fd = open(hz_file_font->font_fn, O_RDONLY, 0);
} }
static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect) static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font *hz_file_font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect)
{ {
rt_uint8_t* str; rt_uint8_t *str;
rtgui_color_t bc; rtgui_color_t bc;
rt_uint16_t style; rt_uint16_t style;
register rt_base_t h, word_bytes; register rt_base_t h, word_bytes;
@ -134,34 +134,34 @@ static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_fon
bc = rtgui_dc_get_gc(dc)->background; bc = rtgui_dc_get_gc(dc)->background;
/* drawing height */ /* drawing height */
h = (hz_file_font->font_size + rect->y1 > rect->y2)? h = (hz_file_font->font_size + rect->y1 > rect->y2) ?
rect->y2 - rect->y1 : hz_file_font->font_size; rect->y2 - rect->y1 : hz_file_font->font_size;
word_bytes = (hz_file_font->font_size + 7) / 8; word_bytes = (hz_file_font->font_size + 7) / 8;
str = (rt_uint8_t*)text; str = (rt_uint8_t *)text;
while (len > 0 && rect->x1 < rect->x2) while (len > 0 && rect->x1 < rect->x2)
{ {
const rt_uint8_t* font_ptr; const rt_uint8_t *font_ptr;
register rt_base_t i, j, k; register rt_base_t i, j, k;
/* get font pixel data */ /* get font pixel data */
font_ptr = _font_cache_get(hz_file_font, *str | (*(str+1) << 8)); font_ptr = _font_cache_get(hz_file_font, *str | (*(str + 1) << 8));
/* draw word */ /* draw word */
for (i=0; i < h; i ++) for (i = 0; i < h; i ++)
{ {
for (j=0; j < word_bytes; j++) for (j = 0; j < word_bytes; j++)
for (k=0; k < 8; k++) for (k = 0; k < 8; k++)
{ {
if ( ((font_ptr[i*word_bytes + j] >> (7-k)) & 0x01) != 0 && if (((font_ptr[i * word_bytes + j] >> (7 - k)) & 0x01) != 0 &&
(rect->x1 + 8 * j + k < rect->x2)) (rect->x1 + 8 * j + k < rect->x2))
{ {
rtgui_dc_draw_point(dc, rect->x1 + 8*j + k, rect->y1 + i); rtgui_dc_draw_point(dc, rect->x1 + 8 * j + k, rect->y1 + i);
} }
else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND) else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND)
{ {
rtgui_dc_draw_color_point(dc, rect->x1 + 8*j + k, rect->y1 + i, bc); rtgui_dc_draw_color_point(dc, rect->x1 + 8 * j + k, rect->y1 + i, bc);
} }
} }
} }
@ -173,11 +173,11 @@ static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_fon
} }
} }
static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t length, struct rtgui_rect* rect) static void rtgui_hz_file_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t length, struct rtgui_rect *rect)
{ {
rt_uint32_t len; rt_uint32_t len;
struct rtgui_font *efont; struct rtgui_font *efont;
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data; struct rtgui_hz_file_font *hz_file_font = (struct rtgui_hz_file_font *)font->data;
RT_ASSERT(dc != RT_NULL); RT_ASSERT(dc != RT_NULL);
RT_ASSERT(hz_file_font != RT_NULL); RT_ASSERT(hz_file_font != RT_NULL);
@ -189,7 +189,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
while (length > 0) while (length > 0)
{ {
len = 0; len = 0;
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len) && len < length) len ++; while (((rt_uint8_t) * (text + len)) < 0x80 && *(text + len) && len < length) len ++;
/* draw text with English font */ /* draw text with English font */
if (len > 0) if (len > 0)
{ {
@ -200,7 +200,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
} }
len = 0; len = 0;
while (((rt_uint8_t)*(text + len)) >= 0x80 && len < length) len ++; while (((rt_uint8_t) * (text + len)) >= 0x80 && len < length) len ++;
if (len > 0) if (len > 0)
{ {
_rtgui_hz_file_font_draw_text(hz_file_font, dc, text, len, rect); _rtgui_hz_file_font_draw_text(hz_file_font, dc, text, len, rect);
@ -213,14 +213,14 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
rtgui_font_derefer(efont); rtgui_font_derefer(efont);
} }
static void rtgui_hz_file_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect) static void rtgui_hz_file_font_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect)
{ {
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data; struct rtgui_hz_file_font *hz_file_font = (struct rtgui_hz_file_font *)font->data;
RT_ASSERT(hz_file_font != RT_NULL); RT_ASSERT(hz_file_font != RT_NULL);
/* set metrics rect */ /* set metrics rect */
rect->x1 = rect->y1 = 0; rect->x1 = rect->y1 = 0;
rect->x2 = (rt_int16_t)(hz_file_font->font_size/2 * rt_strlen((const char*)text)); rect->x2 = (rt_int16_t)(hz_file_font->font_size / 2 * rt_strlen((const char *)text));
rect->y2 = hz_file_font->font_size; rect->y2 = hz_file_font->font_size;
} }
#endif #endif

View File

@ -0,0 +1,35 @@
/* adapted from utils/perfect_hash/example1-C/states-tmpl.c */
#include <rtthread.h>
#include <string.h>
static const rt_uint32_t T1[] = { $S1 };
static const rt_uint32_t T2[] = { $S2 };
static const rt_uint16_t G[] = { $G };
static rt_uint32_t hash_g(const rt_uint16_t key, const rt_uint32_t *T)
{
rt_uint32_t sum = (T[0] * (key & 0xFF) + T[1] * (key >> 8)) % $NG;
return G[sum % $NG];
}
static rt_uint32_t perfect_hash(const rt_uint16_t key)
{
return (hash_g(key, T1) + hash_g(key, T2)) % $NG;
}
rt_uint32_t rtgui_font_mph${height}(const rt_uint16_t key)
{
rt_uint32_t hash_value = perfect_hash(key);
/*rt_kprintf("hash 0x7684 is %d", perfect_hash(0x7684));*/
/*RT_ASSERT(K[hash_value] == key);*/
/* NOTE: we trust you will not feed invalid data into me. So there is no
* more sanity check which will consume more flash and memory. */
if (hash_value < $NK)
return hash_value;
return -1;
}
const unsigned char hz${height}_font[] = { $font_data };

View File

@ -1,225 +1,225 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#include <rtgui/driver.h> #include <rtgui/driver.h>
#define GET_PIXEL(dst, x, y, type) \ #define GET_PIXEL(dst, x, y, type) \
(type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * ((dst)->bits_per_pixel/8)) (type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * ((dst)->bits_per_pixel/8))
static void _rgb565_set_pixel(rtgui_color_t *c, int x, int y) static void _rgb565_set_pixel(rtgui_color_t *c, int x, int y)
{ {
*GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565(*c); *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565(*c);
} }
static void _rgb565_get_pixel(rtgui_color_t *c, int x, int y) static void _rgb565_get_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t); pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t);
/* get pixel from color */ /* get pixel from color */
*c = rtgui_color_from_565(pixel); *c = rtgui_color_from_565(pixel);
} }
static void _rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_ubase_t index; rt_ubase_t index;
rt_uint16_t pixel; rt_uint16_t pixel;
rt_uint16_t *pixel_ptr; rt_uint16_t *pixel_ptr;
/* get pixel from color */ /* get pixel from color */
pixel = rtgui_color_to_565(*c); pixel = rtgui_color_to_565(*c);
/* get pixel pointer in framebuffer */ /* get pixel pointer in framebuffer */
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t); pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
for (index = x1; index < x2; index ++) for (index = x1; index < x2; index ++)
{ {
*pixel_ptr = pixel; *pixel_ptr = pixel;
pixel_ptr ++; pixel_ptr ++;
} }
} }
static void _rgb565_draw_vline(rtgui_color_t *c, int x , int y1, int y2) static void _rgb565_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
{ {
rt_uint8_t *dst; rt_uint8_t *dst;
rt_uint16_t pixel; rt_uint16_t pixel;
rt_ubase_t index; rt_ubase_t index;
pixel = rtgui_color_to_565(*c); pixel = rtgui_color_to_565(*c);
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t); dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
for (index = y1; index < y2; index ++) for (index = y1; index < y2; index ++)
{ {
*(rt_uint16_t*)dst = pixel; *(rt_uint16_t *)dst = pixel;
dst += rtgui_graphic_get_device()->pitch; dst += rtgui_graphic_get_device()->pitch;
} }
} }
static void _rgb565p_set_pixel(rtgui_color_t *c, int x, int y) static void _rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
{ {
*GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565p(*c); *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565p(*c);
} }
static void _rgb565p_get_pixel(rtgui_color_t *c, int x, int y) static void _rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t); pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t);
/* get pixel from color */ /* get pixel from color */
*c = rtgui_color_from_565p(pixel); *c = rtgui_color_from_565p(pixel);
} }
static void _rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_ubase_t index; rt_ubase_t index;
rt_uint16_t pixel; rt_uint16_t pixel;
rt_uint16_t *pixel_ptr; rt_uint16_t *pixel_ptr;
/* get pixel from color */ /* get pixel from color */
pixel = rtgui_color_to_565p(*c); pixel = rtgui_color_to_565p(*c);
/* get pixel pointer in framebuffer */ /* get pixel pointer in framebuffer */
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t); pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
for (index = x1; index < x2; index ++) for (index = x1; index < x2; index ++)
{ {
*pixel_ptr = pixel; *pixel_ptr = pixel;
pixel_ptr ++; pixel_ptr ++;
} }
} }
static void _rgb565p_draw_vline(rtgui_color_t *c, int x , int y1, int y2) static void _rgb565p_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
{ {
rt_uint8_t *dst; rt_uint8_t *dst;
rt_uint16_t pixel; rt_uint16_t pixel;
rt_ubase_t index; rt_ubase_t index;
pixel = rtgui_color_to_565p(*c); pixel = rtgui_color_to_565p(*c);
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t); dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
for (index = y1; index < y2; index ++) for (index = y1; index < y2; index ++)
{ {
*(rt_uint16_t*)dst = pixel; *(rt_uint16_t *)dst = pixel;
dst += rtgui_graphic_get_device()->pitch; dst += rtgui_graphic_get_device()->pitch;
} }
} }
/* draw raw hline */ /* draw raw hline */
static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y) static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
{ {
rt_uint8_t *dst; rt_uint8_t *dst;
dst = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t); dst = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t);
rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8)); rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel / 8));
} }
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops = const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
{ {
_rgb565_set_pixel, _rgb565_set_pixel,
_rgb565_get_pixel, _rgb565_get_pixel,
_rgb565_draw_hline, _rgb565_draw_hline,
_rgb565_draw_vline, _rgb565_draw_vline,
framebuffer_draw_raw_hline, framebuffer_draw_raw_hline,
}; };
const struct rtgui_graphic_driver_ops _framebuffer_rgb565p_ops = const struct rtgui_graphic_driver_ops _framebuffer_rgb565p_ops =
{ {
_rgb565p_set_pixel, _rgb565p_set_pixel,
_rgb565p_get_pixel, _rgb565p_get_pixel,
_rgb565p_draw_hline, _rgb565p_draw_hline,
_rgb565p_draw_vline, _rgb565p_draw_vline,
framebuffer_draw_raw_hline, framebuffer_draw_raw_hline,
}; };
#define FRAMEBUFFER (rtgui_graphic_get_device()->framebuffer) #define FRAMEBUFFER (rtgui_graphic_get_device()->framebuffer)
#define MONO_PIXEL(framebuffer, x, y) \ #define MONO_PIXEL(framebuffer, x, y) \
((rt_uint8_t**)(framebuffer))[y/8][x] ((rt_uint8_t**)(framebuffer))[y/8][x]
static void _mono_set_pixel(rtgui_color_t *c, int x, int y) static void _mono_set_pixel(rtgui_color_t *c, int x, int y)
{ {
if (*c == white) if (*c == white)
MONO_PIXEL(FRAMEBUFFER, x, y) &= ~(1 << (y%8)); MONO_PIXEL(FRAMEBUFFER, x, y) &= ~(1 << (y % 8));
else else
MONO_PIXEL(FRAMEBUFFER, x, y) |= (1 << (y%8)); MONO_PIXEL(FRAMEBUFFER, x, y) |= (1 << (y % 8));
} }
static void _mono_get_pixel(rtgui_color_t *c, int x, int y) static void _mono_get_pixel(rtgui_color_t *c, int x, int y)
{ {
if (MONO_PIXEL(FRAMEBUFFER, x, y) & (1 << (y%8))) if (MONO_PIXEL(FRAMEBUFFER, x, y) & (1 << (y % 8)))
*c = black; *c = black;
else else
*c = white; *c = white;
} }
static void _mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_ubase_t index; rt_ubase_t index;
if (*c == white) if (*c == white)
for (index = x1; index < x2; index ++) for (index = x1; index < x2; index ++)
{ {
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8)); MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y % 8));
} }
else else
for (index = x1; index < x2; index ++) for (index = x1; index < x2; index ++)
{ {
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8)); MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y % 8));
} }
} }
static void _mono_draw_vline(rtgui_color_t *c, int x , int y1, int y2) static void _mono_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
{ {
rt_ubase_t index; rt_ubase_t index;
if (*c == white) if (*c == white)
for (index = y1; index < y2; index ++) for (index = y1; index < y2; index ++)
{ {
MONO_PIXEL(FRAMEBUFFER, x, index) &= ~(1 << (index%8)); MONO_PIXEL(FRAMEBUFFER, x, index) &= ~(1 << (index % 8));
} }
else else
for (index = y1; index < y2; index ++) for (index = y1; index < y2; index ++)
{ {
MONO_PIXEL(FRAMEBUFFER, x, index) |= (1 << (index%8)); MONO_PIXEL(FRAMEBUFFER, x, index) |= (1 << (index % 8));
} }
} }
/* draw raw hline */ /* draw raw hline */
static void _mono_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y) static void _mono_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
{ {
rt_ubase_t index; rt_ubase_t index;
for (index = x1; index < x2; index ++) for (index = x1; index < x2; index ++)
{ {
if (pixels[index/8] && (1 << (index % 8))) if (pixels[index / 8] && (1 << (index % 8)))
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8)); MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y % 8));
else else
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8)); MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y % 8));
} }
} }
const struct rtgui_graphic_driver_ops _framebuffer_mono_ops = const struct rtgui_graphic_driver_ops _framebuffer_mono_ops =
{ {
_mono_set_pixel, _mono_set_pixel,
_mono_get_pixel, _mono_get_pixel,
_mono_draw_hline, _mono_draw_hline,
_mono_draw_vline, _mono_draw_vline,
_mono_draw_raw_hline, _mono_draw_raw_hline,
}; };
const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format) const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format)
{ {
switch (pixel_format) switch (pixel_format)
{ {
case RTGRAPHIC_PIXEL_FORMAT_MONO: case RTGRAPHIC_PIXEL_FORMAT_MONO:
return &_framebuffer_mono_ops; return &_framebuffer_mono_ops;
case RTGRAPHIC_PIXEL_FORMAT_GRAY4: case RTGRAPHIC_PIXEL_FORMAT_GRAY4:
break; break;
case RTGRAPHIC_PIXEL_FORMAT_GRAY16: case RTGRAPHIC_PIXEL_FORMAT_GRAY16:
break; break;
case RTGRAPHIC_PIXEL_FORMAT_RGB565: case RTGRAPHIC_PIXEL_FORMAT_RGB565:
return &_framebuffer_rgb565_ops; return &_framebuffer_rgb565_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB565P: case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
return &_framebuffer_rgb565p_ops; return &_framebuffer_rgb565p_ops;
} }
return RT_NULL; return RT_NULL;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,9 @@
#include <rtgui/image_container.h> #include <rtgui/image_container.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
#define strncasecmp strnicmp
#endif
#ifdef RTGUI_IMAGE_XPM #ifdef RTGUI_IMAGE_XPM
#include <rtgui/image_xpm.h> #include <rtgui/image_xpm.h>
@ -41,297 +44,303 @@ static rtgui_list_t _rtgui_system_image_list = {RT_NULL};
/* initialize rtgui image system */ /* initialize rtgui image system */
void rtgui_system_image_init(void) void rtgui_system_image_init(void)
{ {
/* always support HDC image */ /* always support HDC image */
rtgui_image_hdc_init(); rtgui_image_hdc_init();
#ifdef RTGUI_IMAGE_XPM #ifdef RTGUI_IMAGE_XPM
rtgui_image_xpm_init(); rtgui_image_xpm_init();
#endif #endif
#ifdef RTGUI_IMAGE_BMP #ifdef RTGUI_IMAGE_BMP
rtgui_image_bmp_init(); rtgui_image_bmp_init();
#endif #endif
#if (defined(RTGUI_IMAGE_JPEG) || defined(RTGUI_IMAGE_TJPGD)) #if (defined(RTGUI_IMAGE_JPEG) || defined(RTGUI_IMAGE_TJPGD))
rtgui_image_jpeg_init(); rtgui_image_jpeg_init();
#endif #endif
#ifdef RTGUI_IMAGE_PNG #ifdef RTGUI_IMAGE_PNG
rtgui_image_png_init(); rtgui_image_png_init();
#endif #endif
#ifdef RTGUI_IMAGE_CONTAINER #ifdef RTGUI_IMAGE_CONTAINER
/* initialize image container */ /* initialize image container */
rtgui_system_image_container_init(RT_FALSE); rtgui_system_image_container_init(RT_FALSE);
#endif #endif
} }
static struct rtgui_image_engine* rtgui_image_get_engine(const char* type) static struct rtgui_image_engine *rtgui_image_get_engine(const char *type)
{ {
struct rtgui_list_node *node; struct rtgui_list_node *node;
struct rtgui_image_engine *engine; struct rtgui_image_engine *engine;
rtgui_list_foreach(node, &_rtgui_system_image_list) rtgui_list_foreach(node, &_rtgui_system_image_list)
{ {
engine = rtgui_list_entry(node, struct rtgui_image_engine, list); engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
if (strncasecmp(engine->name, type, strlen(engine->name)) ==0) if (strncasecmp(engine->name, type, strlen(engine->name)) == 0)
return engine; return engine;
} }
return RT_NULL; return RT_NULL;
} }
#if defined(RTGUI_USING_DFS_FILERW) #if defined(RTGUI_USING_DFS_FILERW)
struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn) struct rtgui_image_engine *rtgui_image_get_engine_by_filename(const char *fn)
{ {
struct rtgui_list_node *node; struct rtgui_list_node *node;
struct rtgui_image_engine *engine; struct rtgui_image_engine *engine;
const char* ext; const char *ext;
ext = fn + rt_strlen(fn); ext = fn + rt_strlen(fn);
while (ext != fn) while (ext != fn)
{ {
if (*ext == '.') { ext ++; break; } if (*ext == '.')
ext --; {
} ext ++;
if (ext == fn) return RT_NULL; /* no ext */ break;
}
ext --;
}
if (ext == fn) return RT_NULL; /* no ext */
rtgui_list_foreach(node, &_rtgui_system_image_list) rtgui_list_foreach(node, &_rtgui_system_image_list)
{ {
engine = rtgui_list_entry(node, struct rtgui_image_engine, list); engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
if (strncasecmp(engine->name, ext, strlen(engine->name)) == 0) if (strncasecmp(engine->name, ext, strlen(engine->name)) == 0)
return engine; return engine;
} }
return RT_NULL; return RT_NULL;
} }
RTM_EXPORT(rtgui_image_get_engine_by_filename); RTM_EXPORT(rtgui_image_get_engine_by_filename);
struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load) struct rtgui_image *rtgui_image_create_from_file(const char *type, const char *filename, rt_bool_t load)
{ {
struct rtgui_filerw* filerw; struct rtgui_filerw *filerw;
struct rtgui_image_engine* engine; struct rtgui_image_engine *engine;
struct rtgui_image* image = RT_NULL; struct rtgui_image *image = RT_NULL;
/* create filerw context */ /* create filerw context */
filerw = rtgui_filerw_create_file(filename, "rb"); filerw = rtgui_filerw_create_file(filename, "rb");
if (filerw == RT_NULL) return RT_NULL; if (filerw == RT_NULL) return RT_NULL;
/* get image engine */ /* get image engine */
engine = rtgui_image_get_engine(type); engine = rtgui_image_get_engine(type);
if (engine == RT_NULL) if (engine == RT_NULL)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
if (engine->image_check(filerw) == RT_TRUE) if (engine->image_check(filerw) == RT_TRUE)
{ {
image = (struct rtgui_image*) rtgui_malloc(sizeof(struct rtgui_image)); image = (struct rtgui_image *) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL) if (image == RT_NULL)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
image->palette = RT_NULL; image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE) if (engine->image_load(image, filerw, load) != RT_TRUE)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
/* set image engine */ /* set image engine */
image->engine = engine; image->engine = engine;
} }
else else
{ {
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
} }
return image; return image;
} }
RTM_EXPORT(rtgui_image_create_from_file); RTM_EXPORT(rtgui_image_create_from_file);
struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load) struct rtgui_image *rtgui_image_create(const char *filename, rt_bool_t load)
{ {
struct rtgui_filerw* filerw; struct rtgui_filerw *filerw;
struct rtgui_image_engine* engine; struct rtgui_image_engine *engine;
struct rtgui_image* image = RT_NULL; struct rtgui_image *image = RT_NULL;
/* create filerw context */ /* create filerw context */
filerw = rtgui_filerw_create_file(filename, "rb"); filerw = rtgui_filerw_create_file(filename, "rb");
if (filerw == RT_NULL) return RT_NULL; if (filerw == RT_NULL) return RT_NULL;
/* get image engine */ /* get image engine */
engine = rtgui_image_get_engine_by_filename(filename); engine = rtgui_image_get_engine_by_filename(filename);
if (engine == RT_NULL) if (engine == RT_NULL)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
if (engine->image_check(filerw) == RT_TRUE) if (engine->image_check(filerw) == RT_TRUE)
{ {
image = (struct rtgui_image*) rtgui_malloc(sizeof(struct rtgui_image)); image = (struct rtgui_image *) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL) if (image == RT_NULL)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
image->palette = RT_NULL; image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE) if (engine->image_load(image, filerw, load) != RT_TRUE)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
/* set image engine */ /* set image engine */
image->engine = engine; image->engine = engine;
} }
else else
{ {
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
} }
return image; return image;
} }
RTM_EXPORT(rtgui_image_create); RTM_EXPORT(rtgui_image_create);
#endif #endif
struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load) struct rtgui_image *rtgui_image_create_from_mem(const char *type, const rt_uint8_t *data, rt_size_t length, rt_bool_t load)
{ {
struct rtgui_filerw* filerw; struct rtgui_filerw *filerw;
struct rtgui_image_engine* engine; struct rtgui_image_engine *engine;
struct rtgui_image* image = RT_NULL; struct rtgui_image *image = RT_NULL;
/* create filerw context */ /* create filerw context */
filerw = rtgui_filerw_create_mem(data, length); filerw = rtgui_filerw_create_mem(data, length);
if (filerw == RT_NULL) return RT_NULL; if (filerw == RT_NULL) return RT_NULL;
/* get image engine */ /* get image engine */
engine = rtgui_image_get_engine(type); engine = rtgui_image_get_engine(type);
if (engine == RT_NULL) if (engine == RT_NULL)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
if (engine->image_check(filerw) == RT_TRUE) if (engine->image_check(filerw) == RT_TRUE)
{ {
image = (struct rtgui_image*) rtgui_malloc(sizeof(struct rtgui_image)); image = (struct rtgui_image *) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL) if (image == RT_NULL)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
image->palette = RT_NULL; image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE) if (engine->image_load(image, filerw, load) != RT_TRUE)
{ {
/* close filerw context */ /* close filerw context */
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
return RT_NULL; return RT_NULL;
} }
/* set image engine */ /* set image engine */
image->engine = engine; image->engine = engine;
} }
else else
{ {
rtgui_filerw_close(filerw); rtgui_filerw_close(filerw);
} }
return image; return image;
} }
RTM_EXPORT(rtgui_image_create_from_mem); RTM_EXPORT(rtgui_image_create_from_mem);
void rtgui_image_destroy(struct rtgui_image* image) void rtgui_image_destroy(struct rtgui_image *image)
{ {
RT_ASSERT(image != RT_NULL); RT_ASSERT(image != RT_NULL);
image->engine->image_unload(image); image->engine->image_unload(image);
if (image->palette != RT_NULL) if (image->palette != RT_NULL)
rtgui_free(image->palette); rtgui_free(image->palette);
rtgui_free(image); rtgui_free(image);
} }
RTM_EXPORT(rtgui_image_destroy); RTM_EXPORT(rtgui_image_destroy);
/* register an image engine */ /* register an image engine */
void rtgui_image_register_engine(struct rtgui_image_engine* engine) void rtgui_image_register_engine(struct rtgui_image_engine *engine)
{ {
RT_ASSERT(engine!= RT_NULL); RT_ASSERT(engine != RT_NULL);
rtgui_list_append(&_rtgui_system_image_list, &(engine->list)); rtgui_list_append(&_rtgui_system_image_list, &(engine->list));
} }
RTM_EXPORT(rtgui_image_register_engine); RTM_EXPORT(rtgui_image_register_engine);
void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect) void rtgui_image_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect)
{ {
RT_ASSERT(dc != RT_NULL); RT_ASSERT(dc != RT_NULL);
RT_ASSERT(rect != RT_NULL); RT_ASSERT(rect != RT_NULL);
if (rtgui_dc_get_visible(dc) != RT_TRUE) return; if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
if (image != RT_NULL && image->engine != RT_NULL) if (image != RT_NULL && image->engine != RT_NULL)
{ {
/* use image engine to blit */ /* use image engine to blit */
image->engine->image_blit(image, dc, rect); image->engine->image_blit(image, dc, rect);
} }
} }
RTM_EXPORT(rtgui_image_blit); RTM_EXPORT(rtgui_image_blit);
struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors) struct rtgui_image_palette *rtgui_image_palette_create(rt_uint32_t ncolors)
{ {
struct rtgui_image_palette* palette = RT_NULL; struct rtgui_image_palette *palette = RT_NULL;
if (ncolors > 0) if (ncolors > 0)
{ {
palette = (struct rtgui_image_palette*) rtgui_malloc(sizeof(struct rtgui_image_palette) + palette = (struct rtgui_image_palette *) rtgui_malloc(sizeof(struct rtgui_image_palette) +
sizeof(rtgui_color_t) * ncolors); sizeof(rtgui_color_t) * ncolors);
if (palette != RT_NULL) palette->colors = (rtgui_color_t*)(palette + 1); if (palette != RT_NULL) palette->colors = (rtgui_color_t *)(palette + 1);
} }
return palette; return palette;
} }
RTM_EXPORT(rtgui_image_palette_create); RTM_EXPORT(rtgui_image_palette_create);
void rtgui_image_get_rect(struct rtgui_image* image, struct rtgui_rect* rect) void rtgui_image_get_rect(struct rtgui_image *image, struct rtgui_rect *rect)
{ {
RT_ASSERT(image != RT_NULL); RT_ASSERT(image != RT_NULL);
RT_ASSERT(rect != RT_NULL); RT_ASSERT(rect != RT_NULL);
rect->x1 = 0; rect->y1 = 0; rect->x1 = 0;
rect->x2 = image->w; rect->y2 = image->h; rect->y1 = 0;
rect->x2 = image->w;
rect->y2 = image->h;
} }
RTM_EXPORT(rtgui_image_get_rect); RTM_EXPORT(rtgui_image_get_rect);
rtgui_image_t* rtgui_image_zoom(rtgui_image_t* image, float scalew, float scaleh, rt_uint32_t mode) rtgui_image_t *rtgui_image_zoom(rtgui_image_t *image, float scalew, float scaleh, rt_uint32_t mode)
{ {
if (image != RT_NULL && image->engine != RT_NULL) if (image != RT_NULL && image->engine != RT_NULL)
{ {
return image->engine->image_zoom(image, scalew, scaleh, mode); return image->engine->image_zoom(image, scalew, scaleh, mode);
} }
return RT_NULL; return RT_NULL;
} }
RTM_EXPORT(rtgui_image_zoom); RTM_EXPORT(rtgui_image_zoom);
rtgui_image_t* rtgui_image_rotate(rtgui_image_t* image, float angle) rtgui_image_t *rtgui_image_rotate(rtgui_image_t *image, float angle)
{ {
if (image != RT_NULL && image->engine != RT_NULL) if (image != RT_NULL && image->engine != RT_NULL)
{ {
return image->engine->image_rotate(image, angle); return image->engine->image_rotate(image, angle);
} }
return RT_NULL; return RT_NULL;
} }
RTM_EXPORT(rtgui_image_rotate); RTM_EXPORT(rtgui_image_rotate);

View File

@ -46,9 +46,9 @@ static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw *file);
static rt_bool_t rtgui_image_bmp_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load); static rt_bool_t rtgui_image_bmp_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
static void rtgui_image_bmp_unload(struct rtgui_image *image); static void rtgui_image_bmp_unload(struct rtgui_image *image);
static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect); static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
static struct rtgui_image* rtgui_image_bmp_zoom(struct rtgui_image* image, static struct rtgui_image *rtgui_image_bmp_zoom(struct rtgui_image *image,
float scalew, float scaleh, rt_uint32_t mode); float scalew, float scaleh, rt_uint32_t mode);
static struct rtgui_image* rtgui_image_bmp_rotate(struct rtgui_image* image, float angle); static struct rtgui_image *rtgui_image_bmp_rotate(struct rtgui_image *image, float angle);
struct rtgui_image_engine rtgui_image_bmp_engine = struct rtgui_image_engine rtgui_image_bmp_engine =
{ {
@ -58,8 +58,8 @@ struct rtgui_image_engine rtgui_image_bmp_engine =
rtgui_image_bmp_load, rtgui_image_bmp_load,
rtgui_image_bmp_unload, rtgui_image_bmp_unload,
rtgui_image_bmp_blit, rtgui_image_bmp_blit,
rtgui_image_bmp_zoom, rtgui_image_bmp_zoom,
rtgui_image_bmp_rotate rtgui_image_bmp_rotate
}; };
static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw *file) static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw *file)
@ -572,7 +572,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc,
{ {
int hdelta = image->h - rtgui_rect_height(*dst_rect); int hdelta = image->h - rtgui_rect_height(*dst_rect);
if (rtgui_filerw_seek(bmp->filerw, hdelta * (bmp->pitch + bmp->pad) * (1 << bmp->scale), if (rtgui_filerw_seek(bmp->filerw, hdelta * (bmp->pitch + bmp->pad) * (1 << bmp->scale),
RTGUI_FILE_SEEK_CUR) < 0) RTGUI_FILE_SEEK_CUR) < 0)
{ {
error = RT_TRUE; error = RT_TRUE;
break; break;
@ -607,8 +607,8 @@ static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc,
} }
wrkBuffer = (rt_uint8_t *)rtgui_malloc( wrkBuffer = (rt_uint8_t *)rtgui_malloc(
(BMP_WORKING_BUFFER_SIZE > bmp->pitch) ? \ (BMP_WORKING_BUFFER_SIZE > bmp->pitch) ? \
bmp->pitch : BMP_WORKING_BUFFER_SIZE); bmp->pitch : BMP_WORKING_BUFFER_SIZE);
if (wrkBuffer == RT_NULL) if (wrkBuffer == RT_NULL)
{ {
rt_kprintf("BMP err: no mem (%d)\n", BMP_WORKING_BUFFER_SIZE); rt_kprintf("BMP err: no mem (%d)\n", BMP_WORKING_BUFFER_SIZE);
@ -841,49 +841,49 @@ static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc,
*/ */
void rtgui_image_bmp_header_cfg(struct rtgui_image_bmp_header *bhr, rt_int32_t w, rt_int32_t h, rt_uint16_t bits_per_pixel) void rtgui_image_bmp_header_cfg(struct rtgui_image_bmp_header *bhr, rt_int32_t w, rt_int32_t h, rt_uint16_t bits_per_pixel)
{ {
int image_size = w * h * bits_per_pixel/8; int image_size = w * h * bits_per_pixel / 8;
int header_size = sizeof(struct rtgui_image_bmp_header); int header_size = sizeof(struct rtgui_image_bmp_header);
bhr->bfType = 0x4d42; /* BM */ bhr->bfType = 0x4d42; /* BM */
bhr->bfSize = header_size + image_size; /* data size */ bhr->bfSize = header_size + image_size; /* data size */
bhr->bfReserved1 = 0; bhr->bfReserved1 = 0;
bhr->bfReserved2 = 0; bhr->bfReserved2 = 0;
bhr->bfOffBits = header_size; bhr->bfOffBits = header_size;
bhr->biSize = 40; /* sizeof BITMAPINFOHEADER */ bhr->biSize = 40; /* sizeof BITMAPINFOHEADER */
bhr->biWidth = w; bhr->biWidth = w;
bhr->biHeight = h; bhr->biHeight = h;
bhr->biPlanes = 1; bhr->biPlanes = 1;
bhr->biBitCount = bits_per_pixel; bhr->biBitCount = bits_per_pixel;
bhr->biCompression = BI_BITFIELDS; bhr->biCompression = BI_BITFIELDS;
bhr->biSizeImage = image_size; bhr->biSizeImage = image_size;
bhr->biXPelsPerMeter = 0; bhr->biXPelsPerMeter = 0;
bhr->biYPelsPerMeter = 0; bhr->biYPelsPerMeter = 0;
bhr->biClrUsed = 0; bhr->biClrUsed = 0;
bhr->biClrImportant = 0; bhr->biClrImportant = 0;
if(bhr->biBitCount == 16 && bhr->biCompression == BI_BITFIELDS) if (bhr->biBitCount == 16 && bhr->biCompression == BI_BITFIELDS)
{ {
bhr->bfSize += 12; bhr->bfSize += 12;
bhr->bfOffBits += 12; bhr->bfOffBits += 12;
} }
} }
#ifdef RTGUI_USING_DFS_FILERW #ifdef RTGUI_USING_DFS_FILERW
#define WRITE_CLUSTER_SIZE 2048 #define WRITE_CLUSTER_SIZE 2048
void bmp_align_write(struct rtgui_filerw *file, char *dest, char *src, rt_int32_t len, rt_int32_t *count) void bmp_align_write(struct rtgui_filerw *file, char *dest, char *src, rt_int32_t len, rt_int32_t *count)
{ {
rt_int32_t len_bak = len; rt_int32_t len_bak = len;
while(len) while (len)
{ {
if(*count >= WRITE_CLUSTER_SIZE) if (*count >= WRITE_CLUSTER_SIZE)
{ {
rtgui_filerw_write(file, dest, WRITE_CLUSTER_SIZE, 1); rtgui_filerw_write(file, dest, WRITE_CLUSTER_SIZE, 1);
*count = 0; *count = 0;
} }
*(dest + *count) = *(src + (len_bak-len)); *(dest + *count) = *(src + (len_bak - len));
len --; len --;
(*count) ++; (*count) ++;
} }
} }
/* /*
@ -892,116 +892,116 @@ void bmp_align_write(struct rtgui_filerw *file, char *dest, char *src, rt_int32_
*/ */
void screenshot(const char *filename) void screenshot(const char *filename)
{ {
struct rtgui_filerw *file; struct rtgui_filerw *file;
int w, h, i, pitch; int w, h, i, pitch;
rt_uint16_t *src; rt_uint16_t *src;
rt_uint32_t mask; rt_uint32_t mask;
struct rtgui_image_bmp_header bhr; struct rtgui_image_bmp_header bhr;
struct rtgui_graphic_driver *grp = hw_driver; struct rtgui_graphic_driver *grp = hw_driver;
#ifdef RGB_CONVERT_TO_BGR #ifdef RGB_CONVERT_TO_BGR
int j; int j;
rt_uint16_t *line_buf; rt_uint16_t *line_buf;
rt_uint16_t color, tmp; rt_uint16_t color, tmp;
#endif #endif
char *pixel_buf; char *pixel_buf;
rt_int32_t write_count=0; rt_int32_t write_count = 0;
file = rtgui_filerw_create_file(filename, "wb"); file = rtgui_filerw_create_file(filename, "wb");
if(file == RT_NULL) if (file == RT_NULL)
{ {
rt_kprintf("create file failed\n"); rt_kprintf("create file failed\n");
return; return;
} }
w = grp->width; w = grp->width;
h = grp->height; h = grp->height;
pitch = w * sizeof(rt_uint16_t); pitch = w * sizeof(rt_uint16_t);
#ifdef RGB_CONVERT_TO_BGR #ifdef RGB_CONVERT_TO_BGR
line_buf = rt_malloc(pitch); line_buf = rt_malloc(pitch);
if(line_buf == RT_NULL) if (line_buf == RT_NULL)
{ {
rt_kprintf("no memory!\n"); rt_kprintf("no memory!\n");
return; return;
} }
#endif #endif
pixel_buf = rt_malloc(WRITE_CLUSTER_SIZE); pixel_buf = rt_malloc(WRITE_CLUSTER_SIZE);
if(pixel_buf == RT_NULL) if (pixel_buf == RT_NULL)
{ {
rt_kprintf("no memory!\n"); rt_kprintf("no memory!\n");
#ifdef RGB_CONVERT_TO_BGR #ifdef RGB_CONVERT_TO_BGR
rt_free(line_buf); rt_free(line_buf);
#endif #endif
return; return;
} }
rtgui_image_bmp_header_cfg(&bhr, w, h, grp->bits_per_pixel); rtgui_image_bmp_header_cfg(&bhr, w, h, grp->bits_per_pixel);
bmp_align_write(file, pixel_buf, (char*)&bhr, bmp_align_write(file, pixel_buf, (char *)&bhr,
sizeof(struct rtgui_image_bmp_header), &write_count); sizeof(struct rtgui_image_bmp_header), &write_count);
if(bhr.biCompression == BI_BITFIELDS) if (bhr.biCompression == BI_BITFIELDS)
{ {
mask = 0xF800; /* Red Mask */ mask = 0xF800; /* Red Mask */
bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count); bmp_align_write(file, pixel_buf, (char *)&mask, 4, &write_count);
mask = 0x07E0; /* Green Mask */ mask = 0x07E0; /* Green Mask */
bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count); bmp_align_write(file, pixel_buf, (char *)&mask, 4, &write_count);
mask = 0x001F; /* Blue Mask */ mask = 0x001F; /* Blue Mask */
bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count); bmp_align_write(file, pixel_buf, (char *)&mask, 4, &write_count);
} }
rtgui_screen_lock(RT_WAITING_FOREVER); rtgui_screen_lock(RT_WAITING_FOREVER);
if(grp->framebuffer != RT_NULL) if (grp->framebuffer != RT_NULL)
{ {
src = (rt_uint16_t*)grp->framebuffer; src = (rt_uint16_t *)grp->framebuffer;
src += w * h; src += w * h;
for(i=0; i<h; i++) for (i = 0; i < h; i++)
{ {
src -= w; src -= w;
#ifdef RGB_CONVERT_TO_BGR #ifdef RGB_CONVERT_TO_BGR
for(j=0; j<w; j++) for (j = 0; j < w; j++)
{ {
tmp = *(src + j); tmp = *(src + j);
color = (tmp & 0x001F)<<11; color = (tmp & 0x001F) << 11;
color += (tmp & 0x07E0); color += (tmp & 0x07E0);
color += (tmp & 0xF800)>>11; color += (tmp & 0xF800) >> 11;
*(line_buf + i) = color; *(line_buf + i) = color;
} }
bmp_align_write(file, pixel_buf, (char*)line_buf, pitch, &write_count); bmp_align_write(file, pixel_buf, (char *)line_buf, pitch, &write_count);
#else #else
bmp_align_write(file, pixel_buf, (char*)src, pitch, &write_count); bmp_align_write(file, pixel_buf, (char *)src, pitch, &write_count);
#endif #endif
} }
} }
else else
{ {
rtgui_color_t pixel_color; rtgui_color_t pixel_color;
rt_uint16_t write_color; rt_uint16_t write_color;
int x; int x;
for(i=h-1; i>=0; i--) for (i = h - 1; i >= 0; i--)
{ {
x = 0; x = 0;
if(i%10==0)rt_kprintf(">",i); if (i % 10 == 0)rt_kprintf(">", i);
while(x < w) while (x < w)
{ {
grp->ops->get_pixel(&pixel_color, x, i); grp->ops->get_pixel(&pixel_color, x, i);
write_color = rtgui_color_to_565p(pixel_color); write_color = rtgui_color_to_565p(pixel_color);
bmp_align_write(file, pixel_buf, (char*)&write_color, bmp_align_write(file, pixel_buf, (char *)&write_color,
sizeof(rt_uint16_t), &write_count); sizeof(rt_uint16_t), &write_count);
x++; x++;
} }
} }
} }
/* write The tail of the last */ /* write The tail of the last */
if(write_count < WRITE_CLUSTER_SIZE) if (write_count < WRITE_CLUSTER_SIZE)
rtgui_filerw_write(file, pixel_buf, write_count, 1); rtgui_filerw_write(file, pixel_buf, write_count, 1);
rtgui_screen_unlock(); rtgui_screen_unlock();
#ifdef RGB_CONVERT_TO_BGR #ifdef RGB_CONVERT_TO_BGR
rt_free(line_buf); rt_free(line_buf);
#endif #endif
rt_free(pixel_buf); rt_free(pixel_buf);
rt_kprintf("bmp create succeed.\n"); rt_kprintf("bmp create succeed.\n");
rtgui_filerw_close(file); rtgui_filerw_close(file);
} }
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
#include <finsh.h> #include <finsh.h>
@ -1012,152 +1012,154 @@ FINSH_FUNCTION_EXPORT(screenshot, usage: screenshot(filename));
* image zoom in, zoom out interface * image zoom in, zoom out interface
* Support 16/24 bits format image * Support 16/24 bits format image
*/ */
static struct rtgui_image* rtgui_image_bmp_zoom(struct rtgui_image* image, static struct rtgui_image *rtgui_image_bmp_zoom(struct rtgui_image *image,
float scalew, float scaleh, rt_uint32_t mode) float scalew, float scaleh, rt_uint32_t mode)
{ {
struct rtgui_image *d_img; struct rtgui_image *d_img;
struct rtgui_image_bmp *bmp, *d_bmp; struct rtgui_image_bmp *bmp, *d_bmp;
int bitcount, nbytes, i, j; int bitcount, nbytes, i, j;
int sw, sh, dw, dh; int sw, sh, dw, dh;
int dest_buff_size; int dest_buff_size;
int src_line_size, dest_line_size; int src_line_size, dest_line_size;
char *src_buf; char *src_buf;
char *des_buf; char *des_buf;
bmp = (struct rtgui_image_bmp*)image->data; bmp = (struct rtgui_image_bmp *)image->data;
src_buf = bmp->pixels; src_buf = bmp->pixels;
sw = bmp->w; sw = bmp->w;
sh = bmp->h; sh = bmp->h;
bitcount = bmp->bit_per_pixel; bitcount = bmp->bit_per_pixel;
if(bitcount != 16 && bitcount != 24) if (bitcount != 16 && bitcount != 24)
{ {
rt_kprintf("Does not support %d bits format\n", bitcount); rt_kprintf("Does not support %d bits format\n", bitcount);
return RT_NULL; return RT_NULL;
} }
nbytes = bitcount / 8; nbytes = bitcount / 8;
src_line_size = sw * nbytes; src_line_size = sw *nbytes;
dw = (int)(sw / scalew); dw = (int)(sw / scalew);
dh = (int)(sh / scaleh); dh = (int)(sh / scaleh);
d_img = rt_malloc(sizeof(struct rtgui_image)); d_img = rt_malloc(sizeof(struct rtgui_image));
if(d_img == RT_NULL) if (d_img == RT_NULL)
{ {
rt_kprintf("Not enough memory allocation IMG!\n"); rt_kprintf("Not enough memory allocation IMG!\n");
return RT_NULL; return RT_NULL;
} }
d_img->w = dw; d_img->w = dw;
d_img->h = dh; d_img->h = dh;
d_img->engine = &rtgui_image_bmp_engine; d_img->engine = &rtgui_image_bmp_engine;
d_img->palette = RT_NULL; d_img->palette = RT_NULL;
/* config dest bmp data */ /* config dest bmp data */
dest_line_size = ((dw * bitcount + (bitcount-1)) / bitcount) * nbytes; dest_line_size = ((dw * bitcount + (bitcount - 1)) / bitcount) *nbytes;
dest_buff_size = dest_line_size * dh; dest_buff_size = dest_line_size *dh;
d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp)); d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp));
if(d_bmp == RT_NULL) if (d_bmp == RT_NULL)
{ {
rt_free(d_img); rt_free(d_img);
rt_kprintf("Not enough memory allocation BMP!\n"); rt_kprintf("Not enough memory allocation BMP!\n");
return RT_NULL; return RT_NULL;
} }
d_bmp->w = dw; d_bmp->w = dw;
d_bmp->h = dh; d_bmp->h = dh;
d_bmp->bit_per_pixel = bitcount; d_bmp->bit_per_pixel = bitcount;
d_bmp->pixel_offset = 54; /* insignificant parameter */ d_bmp->pixel_offset = 54; /* insignificant parameter */
d_bmp->filerw = RT_NULL; d_bmp->filerw = RT_NULL;
d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */ d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */
d_bmp->pitch = d_bmp->w * nbytes; d_bmp->pitch = d_bmp->w *nbytes;
d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch%4)) : 0); d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch % 4)) : 0);
d_bmp->scale = 0; d_bmp->scale = 0;
d_bmp->pixels = rt_malloc(dest_buff_size); d_bmp->pixels = rt_malloc(dest_buff_size);
if(d_bmp->pixels == RT_NULL) if (d_bmp->pixels == RT_NULL)
{ {
rt_free(d_img); rt_free(d_img);
rt_free(d_bmp); rt_free(d_bmp);
rt_kprintf("Not enough memory allocation BMP data!\n"); rt_kprintf("Not enough memory allocation BMP data!\n");
return RT_NULL; return RT_NULL;
} }
des_buf = d_bmp->pixels; des_buf = d_bmp->pixels;
if (mode == RTGUI_IMG_ZOOM_NEAREST) if (mode == RTGUI_IMG_ZOOM_NEAREST)
{ {
for (i = 0; i < dh; i++) for (i = 0; i < dh; i++)
{ {
int src_th = (int)(scaleh * i + 0.5); int src_th = (int)(scaleh * i + 0.5);
for (j = 0; j < dw; j++) for (j = 0; j < dw; j++)
{ {
int src_tw = (int)(scalew * j + 0.5); int src_tw = (int)(scalew * j + 0.5);
rt_memcpy (&des_buf[i * dest_line_size] + j * nbytes, rt_memcpy(&des_buf[i * dest_line_size] + j * nbytes,
&src_buf[src_th * src_line_size] + src_tw * nbytes, &src_buf[src_th * src_line_size] + src_tw * nbytes,
nbytes); nbytes);
} }
} }
} }
else if (mode == RTGUI_IMG_ZOOM_BILINEAR) else if (mode == RTGUI_IMG_ZOOM_BILINEAR)
{ {
/* /*
** known: (i,j), (i+1,j), (i,j+1), (i+1,j+1), u, v ** known: (i,j), (i+1,j), (i,j+1), (i+1,j+1), u, v
** float coord: (i+u, j+v) ** float coord: (i+u, j+v)
** f(i+u,j+v) = (1-u)(1-v)f(i,j) + (1-u)vf(i,j+1) + u(1-v)f(i+1,j) + uvf(i+1,j+1) ** f(i+u,j+v) = (1-u)(1-v)f(i,j) + (1-u)vf(i,j+1) + u(1-v)f(i+1,j) + uvf(i+1,j+1)
*/ */
for (i = 0; i < dh; i++) for (i = 0; i < dh; i++)
{ {
int y = (int)(scaleh * i); int y = (int)(scaleh * i);
float u = (float)(scaleh * i - y); float u = (float)(scaleh * i - y);
unsigned char c1, c2, c3, c4; unsigned char c1, c2, c3, c4;
for (j = 0; j < dw; j++) for (j = 0; j < dw; j++)
{ {
int x = (int)(scalew * j); int x = (int)(scalew * j);
float v = (float)(scalew * j - x); float v = (float)(scalew * j - x);
if(bitcount == 16) if (bitcount == 16)
{ /* Each color component is calculated separately */ {
rt_uint32_t cc1,cc2,cc3,cc4; /* Each color component is calculated separately */
unsigned char r, g, b; rt_uint32_t cc1, cc2, cc3, cc4;
cc1 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf + unsigned char r, g, b;
src_line_size * y + nbytes * x )); cc1 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
cc2 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf + src_line_size * y + nbytes * x));
src_line_size * y + nbytes * (x+1))); cc2 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
cc3 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf + src_line_size * y + nbytes * (x + 1)));
src_line_size * (y+1) + nbytes * x )); cc3 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
cc4 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf + src_line_size * (y + 1) + nbytes * x));
src_line_size * (y+1) + nbytes * (x+1))); cc4 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
src_line_size * (y + 1) + nbytes * (x + 1)));
r = (unsigned char)((1-u)*(1-v)*(float)RTGUI_RGB_R(cc1) + r = (unsigned char)((1 - u) * (1 - v) * (float)RTGUI_RGB_R(cc1) +
(1-u)*v*(float)RTGUI_RGB_R(cc2) + u*(1-v)*(float)RTGUI_RGB_R(cc3) + (1 - u) * v * (float)RTGUI_RGB_R(cc2) + u * (1 - v) * (float)RTGUI_RGB_R(cc3) +
u*v*(float)RTGUI_RGB_R(cc4)); u * v * (float)RTGUI_RGB_R(cc4));
g = (unsigned char)((1-u)*(1-v)*(float)RTGUI_RGB_G(cc1) + g = (unsigned char)((1 - u) * (1 - v) * (float)RTGUI_RGB_G(cc1) +
(1-u)*v*(float)RTGUI_RGB_G(cc2) + u*(1-v)*(float)RTGUI_RGB_G(cc3) + (1 - u) * v * (float)RTGUI_RGB_G(cc2) + u * (1 - v) * (float)RTGUI_RGB_G(cc3) +
u*v*(float)RTGUI_RGB_G(cc4)); u * v * (float)RTGUI_RGB_G(cc4));
b = (unsigned char)((1-u)*(1-v)*(float)RTGUI_RGB_B(cc1) + b = (unsigned char)((1 - u) * (1 - v) * (float)RTGUI_RGB_B(cc1) +
(1-u)*v*(float)RTGUI_RGB_B(cc2) + u*(1-v)*(float)RTGUI_RGB_B(cc3) + (1 - u) * v * (float)RTGUI_RGB_B(cc2) + u * (1 - v) * (float)RTGUI_RGB_B(cc3) +
u*v*(float)RTGUI_RGB_B(cc4)); u * v * (float)RTGUI_RGB_B(cc4));
*(rt_uint16_t*)(des_buf + i * dest_line_size + j * nbytes) =
rtgui_color_to_565p(RTGUI_RGB(r, g, b));
}
else if(bitcount == 24)
{
int k;
for (k = 0; k < 3; k++)
{ /* 24 bits color is 3 bytes R:G:B */
c1 = (src_buf[src_line_size * y + nbytes * x + k]);
c2 = (src_buf[src_line_size * y + nbytes * (x+1) + k]);
c3 = (src_buf[src_line_size * (y+1) + nbytes * x + k]);
c4 = (src_buf[src_line_size * (y+1) + nbytes * (x+1) + k]);
des_buf[i * dest_line_size + j * nbytes + k] = (unsigned char) *(rt_uint16_t *)(des_buf + i * dest_line_size + j * nbytes) =
((1-u)*(1-v)*(float)c1 + (1-u)*v*(float)c2 + u*(1-v)*(float)c3 + u*v*(float)c4); rtgui_color_to_565p(RTGUI_RGB(r, g, b));
} }
} else if (bitcount == 24)
} {
} int k;
} for (k = 0; k < 3; k++)
d_img->data = d_bmp; {
/* 24 bits color is 3 bytes R:G:B */
c1 = (src_buf[src_line_size * y + nbytes * x + k]);
c2 = (src_buf[src_line_size * y + nbytes * (x + 1) + k]);
c3 = (src_buf[src_line_size * (y + 1) + nbytes * x + k]);
c4 = (src_buf[src_line_size * (y + 1) + nbytes * (x + 1) + k]);
return d_img; des_buf[i * dest_line_size + j * nbytes + k] = (unsigned char)
} ((1 - u) * (1 - v) * (float)c1 + (1 - u) * v * (float)c2 + u * (1 - v) * (float)c3 + u * v * (float)c4);
}
}
}
}
}
d_img->data = d_bmp;
return d_img;
}
#include <math.h> #include <math.h>
#ifndef M_PI #ifndef M_PI
@ -1169,129 +1171,131 @@ static struct rtgui_image* rtgui_image_bmp_zoom(struct rtgui_image* image,
*/ */
rt_inline rtgui_point_t _rotate_pos(rtgui_point_t o, rtgui_point_t p, float sina, float cosa) rt_inline rtgui_point_t _rotate_pos(rtgui_point_t o, rtgui_point_t p, float sina, float cosa)
{ {
rtgui_point_t rp; rtgui_point_t rp;
float dx, dy; float dx, dy;
dx = p.x - o.x; dx = p.x - o.x;
dy = p.y - o.y; dy = p.y - o.y;
rp.x = (float)o.x + dx * cosa + dy * sina; rp.x = (float)o.x + dx * cosa + dy * sina;
rp.y = (float)o.y + dy * cosa - dx * sina; rp.y = (float)o.y + dy * cosa - dx * sina;
return rp; return rp;
} }
/* /*
* image rotate interface, rotate direction: clockwise * image rotate interface, rotate direction: clockwise
* Support 16/24 bits format image * Support 16/24 bits format image
*/ */
static struct rtgui_image* rtgui_image_bmp_rotate(struct rtgui_image* image, float angle) static struct rtgui_image *rtgui_image_bmp_rotate(struct rtgui_image *image, float angle)
{ {
float age, sina, cosa; float age, sina, cosa;
rtgui_point_t o, p, cp; rtgui_point_t o, p, cp;
rtgui_rect_t rect; rtgui_rect_t rect;
struct rtgui_image *d_img; struct rtgui_image *d_img;
struct rtgui_image_bmp *bmp, *d_bmp; struct rtgui_image_bmp *bmp, *d_bmp;
int bitcount, nbytes, i, j; int bitcount, nbytes, i, j;
int sw, sh, dw, dh; int sw, sh, dw, dh;
int dest_buff_size; int dest_buff_size;
int src_line_size, dest_line_size; int src_line_size, dest_line_size;
char *src_buf; char *src_buf;
char *des_buf; char *des_buf;
/* rt_tick_t tick = rt_tick_get(); */ /* rt_tick_t tick = rt_tick_get(); */
bmp = (struct rtgui_image_bmp*)image->data; bmp = (struct rtgui_image_bmp *)image->data;
src_buf = bmp->pixels; src_buf = bmp->pixels;
sw = bmp->w; sw = bmp->w;
sh = bmp->h; sh = bmp->h;
bitcount = bmp->bit_per_pixel; bitcount = bmp->bit_per_pixel;
if(bitcount != 16 && bitcount != 24) if (bitcount != 16 && bitcount != 24)
{ {
rt_kprintf("Does not support %d bits format\n", bitcount); rt_kprintf("Does not support %d bits format\n", bitcount);
return RT_NULL; return RT_NULL;
} }
nbytes = bitcount / 8; nbytes = bitcount / 8;
src_line_size = sw * nbytes; src_line_size = sw *nbytes;
/* convert angle to radians */
age = angle * M_PI / 180.0;
sina = sin(age);
cosa = cos(age);
/* /* convert angle to radians */
** known: a, b, angle; age = angle *M_PI / 180.0;
** solve: aa = a*abs(cos(angle)) + b*abs(sin(angle)); sina = sin(age);
** solve: bb = b*abs(cos(angle)) + a*abs(sin(angle)); cosa = cos(age);
*/
dw = (int)(sw * fabs(cosa) + sh * fabs(sina));
dh = (int)(sh * fabs(cosa) + sw * fabs(sina));
rect.x1 = rect.y1 = 0;
rect.x2 = sw; rect.y2 = sh;
d_img = rt_malloc(sizeof(struct rtgui_image)); /*
if(d_img == RT_NULL) ** known: a, b, angle;
{ ** solve: aa = a*abs(cos(angle)) + b*abs(sin(angle));
rt_kprintf("Not enough memory allocation IMG!\n"); ** solve: bb = b*abs(cos(angle)) + a*abs(sin(angle));
return RT_NULL; */
} dw = (int)(sw *fabs(cosa) + sh *fabs(sina));
d_img->w = dw; dh = (int)(sh *fabs(cosa) + sw *fabs(sina));
d_img->h = dh; rect.x1 = rect.y1 = 0;
d_img->engine = &rtgui_image_bmp_engine; rect.x2 = sw;
d_img->palette = RT_NULL; rect.y2 = sh;
/* config dest bmp data */ d_img = rt_malloc(sizeof(struct rtgui_image));
dest_line_size = ((dw * bitcount + (bitcount-1)) / bitcount) * nbytes; if (d_img == RT_NULL)
dest_buff_size = dest_line_size * dh; {
d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp)); rt_kprintf("Not enough memory allocation IMG!\n");
if(d_bmp == RT_NULL) return RT_NULL;
{ }
rt_free(d_img); d_img->w = dw;
rt_kprintf("Not enough memory allocation BMP!\n"); d_img->h = dh;
return RT_NULL; d_img->engine = &rtgui_image_bmp_engine;
} d_img->palette = RT_NULL;
d_bmp->w = dw; /* config dest bmp data */
d_bmp->h = dh; dest_line_size = ((dw * bitcount + (bitcount - 1)) / bitcount) *nbytes;
d_bmp->bit_per_pixel = bitcount; dest_buff_size = dest_line_size *dh;
d_bmp->pixel_offset = 54; /* insignificant parameter */ d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp));
d_bmp->filerw = RT_NULL; if (d_bmp == RT_NULL)
d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */ {
d_bmp->pitch = d_bmp->w * nbytes; rt_free(d_img);
d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch%4)) : 0); rt_kprintf("Not enough memory allocation BMP!\n");
d_bmp->scale = 0; return RT_NULL;
d_bmp->pixels = rt_malloc(dest_buff_size); }
if(d_bmp->pixels == RT_NULL)
{ d_bmp->w = dw;
rt_free(d_img); d_bmp->h = dh;
rt_free(d_bmp); d_bmp->bit_per_pixel = bitcount;
rt_kprintf("Not enough memory allocation BMP data!\n"); d_bmp->pixel_offset = 54; /* insignificant parameter */
return RT_NULL; d_bmp->filerw = RT_NULL;
} d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */
des_buf = d_bmp->pixels; d_bmp->pitch = d_bmp->w *nbytes;
/* use white fill empty pixel */ d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch % 4)) : 0);
rt_memset(des_buf, 0xFF, dest_buff_size); d_bmp->scale = 0;
d_bmp->pixels = rt_malloc(dest_buff_size);
o.x = dw>>1; if (d_bmp->pixels == RT_NULL)
o.y = dh>>1; {
if(bitcount == 16 || bitcount == 24) rt_free(d_img);
{ rt_free(d_bmp);
for (i = 0; i < dh; i++) rt_kprintf("Not enough memory allocation BMP data!\n");
{ return RT_NULL;
for (j = 0; j < dw; j++) }
{ des_buf = d_bmp->pixels;
p.x = j; p.y = i; /* use white fill empty pixel */
cp = _rotate_pos(o, p, sina, cosa); rt_memset(des_buf, 0xFF, dest_buff_size);
cp.x -= (dw-sw)>>1;
cp.y -= (dh-sh)>>1; o.x = dw >> 1;
if(rtgui_rect_contains_point(&rect, cp.x, cp.y) != RT_EOK) o.y = dh >> 1;
continue; if (bitcount == 16 || bitcount == 24)
rt_memcpy (&des_buf[dest_line_size * i] + nbytes * j, {
&src_buf[src_line_size * cp.y] + nbytes * cp.x, nbytes); for (i = 0; i < dh; i++)
} {
} for (j = 0; j < dw; j++)
} {
d_img->data = d_bmp; p.x = j;
/* rt_kprintf("rotate use %d ticks\n", rt_tick_get()-tick); */ p.y = i;
return d_img; cp = _rotate_pos(o, p, sina, cosa);
cp.x -= (dw - sw) >> 1;
cp.y -= (dh - sh) >> 1;
if (rtgui_rect_contains_point(&rect, cp.x, cp.y) != RT_EOK)
continue;
rt_memcpy(&des_buf[dest_line_size * i] + nbytes * j,
&src_buf[src_line_size * cp.y] + nbytes * cp.x, nbytes);
}
}
}
d_img->data = d_bmp;
/* rt_kprintf("rotate use %d ticks\n", rt_tick_get()-tick); */
return d_img;
} }
void rtgui_image_bmp_init() void rtgui_image_bmp_init()

View File

@ -1,27 +1,27 @@
#include <rtgui/image_container.h> #include <rtgui/image_container.h>
#ifdef RTGUI_IMAGE_CONTAINER #ifdef RTGUI_IMAGE_CONTAINER
typedef unsigned int (*rtgui_hash_func_t) (const void* key); typedef unsigned int (*rtgui_hash_func_t)(const void *key);
typedef struct _rtgui_hash_table rtgui_hash_table_t; typedef struct _rtgui_hash_table rtgui_hash_table_t;
typedef rt_bool_t (*rtgui_equal_func_t) (const void* a, const void* b); typedef rt_bool_t (*rtgui_equal_func_t)(const void *a, const void *b);
typedef void (*rtgui_user_func_t) (const void* value, const void* data); typedef void (*rtgui_user_func_t)(const void *value, const void *data);
/* /*
*Hash tables *Hash tables
*/ */
rtgui_hash_table_t* hash_table_create(rtgui_hash_func_t hash_func, rtgui_equal_func_t key_equal_func); rtgui_hash_table_t *hash_table_create(rtgui_hash_func_t hash_func, rtgui_equal_func_t key_equal_func);
void hash_table_destroy (rtgui_hash_table_t* hash_table); void hash_table_destroy(rtgui_hash_table_t *hash_table);
void* hash_table_find (rtgui_hash_table_t* hash_table, const void* key); void *hash_table_find(rtgui_hash_table_t *hash_table, const void *key);
void hash_table_insert (rtgui_hash_table_t* hash_table, const void* key, void* value); void hash_table_insert(rtgui_hash_table_t *hash_table, const void *key, void *value);
rt_bool_t hash_table_remove (rtgui_hash_table_t* hash_table, const void* key); rt_bool_t hash_table_remove(rtgui_hash_table_t *hash_table, const void *key);
void hash_table_foreach(rtgui_hash_table_t* hash_table, rtgui_user_func_t user_func, void* data); void hash_table_foreach(rtgui_hash_table_t *hash_table, rtgui_user_func_t user_func, void *data);
unsigned int hash_table_get_size (rtgui_hash_table_t* hash_table); unsigned int hash_table_get_size(rtgui_hash_table_t *hash_table);
/* Hash Functions /* Hash Functions
*/ */
unsigned int direct_hash (const void* v); unsigned int direct_hash(const void *v);
#define HASH_TABLE_MIN_SIZE 11 #define HASH_TABLE_MIN_SIZE 11
#define HASH_TABLE_MAX_SIZE 6247 #define HASH_TABLE_MAX_SIZE 6247
@ -29,419 +29,419 @@ unsigned int direct_hash (const void* v);
typedef struct _gui_hash_node rtgui_hash_node_t; typedef struct _gui_hash_node rtgui_hash_node_t;
struct _gui_hash_node struct _gui_hash_node
{ {
void* key; void *key;
void* value; void *value;
rtgui_hash_node_t *next; rtgui_hash_node_t *next;
}; };
struct _rtgui_hash_table struct _rtgui_hash_table
{ {
rt_uint16_t size; rt_uint16_t size;
rt_uint16_t nnodes; rt_uint16_t nnodes;
rtgui_hash_node_t **nodes; rtgui_hash_node_t **nodes;
rtgui_hash_func_t hash_func; rtgui_hash_func_t hash_func;
rtgui_equal_func_t key_equal_func; rtgui_equal_func_t key_equal_func;
}; };
static const unsigned int primes[] = static const unsigned int primes[] =
{ {
11, 11,
19, 19,
37, 37,
73, 73,
109, 109,
163, 163,
251, 251,
367, 367,
557, 557,
823, 823,
1237, 1237,
1861, 1861,
2777, 2777,
4177, 4177,
6247, 6247,
/* /*
9371, 9371,
14057, 14057,
21089, 21089,
31627, 31627,
47431, 47431,
71143, 71143,
106721, 106721,
160073, 160073,
240101, 240101,
360163, 360163,
540217, 540217,
810343, 810343,
1215497, 1215497,
1823231, 1823231,
2734867, 2734867,
4102283, 4102283,
6153409, 6153409,
9230113, 9230113,
13845163, 13845163,
*/ */
}; };
static const unsigned int nprimes = sizeof (primes) / sizeof (primes[0]); static const unsigned int nprimes = sizeof(primes) / sizeof(primes[0]);
static void hash_table_resize (rtgui_hash_table_t *hash_table); static void hash_table_resize(rtgui_hash_table_t *hash_table);
static rtgui_hash_node_t** hash_table_find_node (rtgui_hash_table_t *hash_table, const void* key); static rtgui_hash_node_t **hash_table_find_node(rtgui_hash_table_t *hash_table, const void *key);
static rtgui_hash_node_t* hash_node_create (const void* key, void* value); static rtgui_hash_node_t *hash_node_create(const void *key, void *value);
static void hash_node_destroy (rtgui_hash_node_t *hash_node); static void hash_node_destroy(rtgui_hash_node_t *hash_node);
static void hash_nodes_destroy (rtgui_hash_node_t *hash_node); static void hash_nodes_destroy(rtgui_hash_node_t *hash_node);
static unsigned int primes_closest (unsigned int num); static unsigned int primes_closest(unsigned int num);
static void hash_table_needresize(rtgui_hash_table_t *hash_table); static void hash_table_needresize(rtgui_hash_table_t *hash_table);
rt_inline unsigned int primes_closest (unsigned int num) rt_inline unsigned int primes_closest(unsigned int num)
{ {
int i; int i;
for (i = 0; i < nprimes; i++) for (i = 0; i < nprimes; i++)
if (primes[i] > num) if (primes[i] > num)
return primes[i]; return primes[i];
return primes[nprimes - 1]; return primes[nprimes - 1];
} }
/* directly hash */ /* directly hash */
unsigned int direct_hash (const void* v) unsigned int direct_hash(const void *v)
{ {
return (unsigned int)v; return (unsigned int)v;
} }
rtgui_hash_table_t* hash_table_create(rtgui_hash_func_t hash_func, rtgui_equal_func_t key_equal_func) rtgui_hash_table_t *hash_table_create(rtgui_hash_func_t hash_func, rtgui_equal_func_t key_equal_func)
{ {
rtgui_hash_table_t *hash_table; rtgui_hash_table_t *hash_table;
hash_table = (rtgui_hash_table_t*) rtgui_malloc (sizeof(rtgui_hash_table_t)); hash_table = (rtgui_hash_table_t *) rtgui_malloc(sizeof(rtgui_hash_table_t));
if (hash_table != RT_NULL) if (hash_table != RT_NULL)
{ {
hash_table->size = HASH_TABLE_MIN_SIZE; hash_table->size = HASH_TABLE_MIN_SIZE;
hash_table->nnodes = 0; hash_table->nnodes = 0;
hash_table->hash_func = hash_func ? hash_func : direct_hash; hash_table->hash_func = hash_func ? hash_func : direct_hash;
hash_table->key_equal_func = key_equal_func; hash_table->key_equal_func = key_equal_func;
hash_table->nodes = (rtgui_hash_node_t **)rtgui_malloc ( sizeof(rtgui_hash_node_t*) * hash_table->size); hash_table->nodes = (rtgui_hash_node_t **)rtgui_malloc(sizeof(rtgui_hash_node_t *) * hash_table->size);
if (hash_table->nodes == RT_NULL) if (hash_table->nodes == RT_NULL)
{ {
/* no memory yet */ /* no memory yet */
rtgui_free(hash_table); rtgui_free(hash_table);
return RT_NULL; return RT_NULL;
} }
rt_memset(hash_table->nodes, 0, sizeof(rtgui_hash_node_t*) * hash_table->size); rt_memset(hash_table->nodes, 0, sizeof(rtgui_hash_node_t *) * hash_table->size);
} }
return hash_table; return hash_table;
} }
void hash_table_destroy (rtgui_hash_table_t *hash_table) void hash_table_destroy(rtgui_hash_table_t *hash_table)
{ {
unsigned int i; unsigned int i;
RT_ASSERT(hash_table != RT_NULL); RT_ASSERT(hash_table != RT_NULL);
for (i = 0; i < hash_table->size; i++) for (i = 0; i < hash_table->size; i++)
hash_nodes_destroy (hash_table->nodes[i]); hash_nodes_destroy(hash_table->nodes[i]);
rtgui_free (hash_table->nodes); rtgui_free(hash_table->nodes);
rtgui_free (hash_table); rtgui_free(hash_table);
} }
static rtgui_hash_node_t** hash_table_find_node (rtgui_hash_table_t *hash_table, const void* key) static rtgui_hash_node_t **hash_table_find_node(rtgui_hash_table_t *hash_table, const void *key)
{ {
rtgui_hash_node_t **node; rtgui_hash_node_t **node;
node = &hash_table->nodes [(* hash_table->hash_func) (key) % hash_table->size]; node = &hash_table->nodes [(* hash_table->hash_func)(key) % hash_table->size];
if (hash_table->key_equal_func) if (hash_table->key_equal_func)
while (*node && !(*hash_table->key_equal_func) ((*node)->key, key)) while (*node && !(*hash_table->key_equal_func)((*node)->key, key))
node = &(*node)->next; node = &(*node)->next;
else else
while (*node && (*node)->key != key) while (*node && (*node)->key != key)
node = &(*node)->next; node = &(*node)->next;
return node; return node;
} }
void* hash_table_find (rtgui_hash_table_t* hash_table, const void* key) void *hash_table_find(rtgui_hash_table_t *hash_table, const void *key)
{ {
rtgui_hash_node_t *node; rtgui_hash_node_t *node;
RT_ASSERT(hash_table != RT_NULL); RT_ASSERT(hash_table != RT_NULL);
RT_ASSERT(key != RT_NULL); RT_ASSERT(key != RT_NULL);
node = *hash_table_find_node (hash_table, key); node = *hash_table_find_node(hash_table, key);
if (node) return node->value; if (node) return node->value;
else return RT_NULL; else return RT_NULL;
} }
void hash_table_insert (rtgui_hash_table_t *hash_table, const void* key, void* value) void hash_table_insert(rtgui_hash_table_t *hash_table, const void *key, void *value)
{ {
rtgui_hash_node_t **node; rtgui_hash_node_t **node;
if (hash_table == RT_NULL)return; if (hash_table == RT_NULL)return;
node = hash_table_find_node (hash_table, key); node = hash_table_find_node(hash_table, key);
if (*node) if (*node)
{ {
(*node)->value = value; (*node)->value = value;
} }
else else
{ {
*node = hash_node_create (key, value); *node = hash_node_create(key, value);
hash_table->nnodes++; hash_table->nnodes++;
hash_table_needresize (hash_table); hash_table_needresize(hash_table);
} }
} }
rt_bool_t hash_table_remove (rtgui_hash_table_t *hash_table, const void* key) rt_bool_t hash_table_remove(rtgui_hash_table_t *hash_table, const void *key)
{ {
rtgui_hash_node_t **node, *dest; rtgui_hash_node_t **node, *dest;
if (hash_table == RT_NULL) return RT_FALSE; if (hash_table == RT_NULL) return RT_FALSE;
node = hash_table_find_node (hash_table, key); node = hash_table_find_node(hash_table, key);
if (*node) if (*node)
{ {
dest = *node; dest = *node;
(*node) = dest->next; (*node) = dest->next;
hash_node_destroy (dest); hash_node_destroy(dest);
hash_table->nnodes--; hash_table->nnodes--;
hash_table_needresize (hash_table); hash_table_needresize(hash_table);
return RT_TRUE; return RT_TRUE;
} }
return RT_FALSE; return RT_FALSE;
} }
void hash_table_foreach(rtgui_hash_table_t *hash_table, rtgui_user_func_t user_func, void* data) void hash_table_foreach(rtgui_hash_table_t *hash_table, rtgui_user_func_t user_func, void *data)
{ {
rtgui_hash_node_t *node; rtgui_hash_node_t *node;
int i; int i;
RT_ASSERT(hash_table != RT_NULL); RT_ASSERT(hash_table != RT_NULL);
RT_ASSERT(user_func != RT_NULL); RT_ASSERT(user_func != RT_NULL);
for (i = 0; i < hash_table->size; i++) for (i = 0; i < hash_table->size; i++)
for (node = hash_table->nodes[i]; node; node = node->next) for (node = hash_table->nodes[i]; node; node = node->next)
(* user_func) (node->value, data); (* user_func)(node->value, data);
} }
unsigned int hash_table_get_size (rtgui_hash_table_t *hash_table) unsigned int hash_table_get_size(rtgui_hash_table_t *hash_table)
{ {
if ( hash_table ==NULL ) return 0; if (hash_table == NULL) return 0;
return hash_table->nnodes; return hash_table->nnodes;
} }
static void hash_table_needresize(rtgui_hash_table_t *hash_table) static void hash_table_needresize(rtgui_hash_table_t *hash_table)
{ {
if ((hash_table->size >= 3*hash_table->nnodes && hash_table->size > HASH_TABLE_MIN_SIZE) || if ((hash_table->size >= 3 * hash_table->nnodes && hash_table->size > HASH_TABLE_MIN_SIZE) ||
(3 * hash_table->size <= hash_table->nnodes && hash_table->size < HASH_TABLE_MAX_SIZE)) (3 * hash_table->size <= hash_table->nnodes && hash_table->size < HASH_TABLE_MAX_SIZE))
hash_table_resize (hash_table); hash_table_resize(hash_table);
} }
static void hash_table_resize (rtgui_hash_table_t *hash_table) static void hash_table_resize(rtgui_hash_table_t *hash_table)
{ {
rtgui_hash_node_t **new_nodes; rtgui_hash_node_t **new_nodes;
rtgui_hash_node_t *node; rtgui_hash_node_t *node;
rtgui_hash_node_t *next; rtgui_hash_node_t *next;
unsigned int hash_val; unsigned int hash_val;
int new_size; int new_size;
int i; int i;
i = primes_closest(hash_table->nnodes); i = primes_closest(hash_table->nnodes);
new_size = i > HASH_TABLE_MAX_SIZE ? HASH_TABLE_MAX_SIZE : i < HASH_TABLE_MIN_SIZE ? HASH_TABLE_MIN_SIZE : i ; new_size = i > HASH_TABLE_MAX_SIZE ? HASH_TABLE_MAX_SIZE : i < HASH_TABLE_MIN_SIZE ? HASH_TABLE_MIN_SIZE : i ;
new_nodes = (rtgui_hash_node_t **)rtgui_malloc ( sizeof(rtgui_hash_node_t*) * new_size); new_nodes = (rtgui_hash_node_t **)rtgui_malloc(sizeof(rtgui_hash_node_t *) * new_size);
if (new_nodes == RT_NULL) return; /* no memory yet */ if (new_nodes == RT_NULL) return; /* no memory yet */
rt_memset(new_nodes, 0, sizeof(rtgui_hash_node_t*) * new_size); rt_memset(new_nodes, 0, sizeof(rtgui_hash_node_t *) * new_size);
for (i = 0; i < hash_table->size; i++) for (i = 0; i < hash_table->size; i++)
{ {
for (node = hash_table->nodes[i]; node; node = next) for (node = hash_table->nodes[i]; node; node = next)
{ {
next = node->next; next = node->next;
hash_val = (* hash_table->hash_func) (node->key) % new_size; hash_val = (* hash_table->hash_func)(node->key) % new_size;
node->next = new_nodes[hash_val]; node->next = new_nodes[hash_val];
new_nodes[hash_val] = node; new_nodes[hash_val] = node;
} }
} }
rtgui_free (hash_table->nodes); rtgui_free(hash_table->nodes);
hash_table->nodes = new_nodes; hash_table->nodes = new_nodes;
hash_table->size = new_size; hash_table->size = new_size;
} }
static rtgui_hash_node_t* hash_node_create (void* key, void* value) static rtgui_hash_node_t *hash_node_create(void *key, void *value)
{ {
rtgui_hash_node_t *hash_node; rtgui_hash_node_t *hash_node;
hash_node = (rtgui_hash_node_t*) rtgui_malloc ( sizeof(rtgui_hash_node_t) ); hash_node = (rtgui_hash_node_t *) rtgui_malloc(sizeof(rtgui_hash_node_t));
if (hash_node != RT_NULL) if (hash_node != RT_NULL)
{ {
/* set value and key */ /* set value and key */
hash_node->key = key; hash_node->key = key;
hash_node->value = value;; hash_node->value = value;;
hash_node->next = RT_NULL; hash_node->next = RT_NULL;
} }
return hash_node; return hash_node;
} }
static void hash_node_destroy (rtgui_hash_node_t *hash_node) static void hash_node_destroy(rtgui_hash_node_t *hash_node)
{ {
rtgui_free(hash_node); rtgui_free(hash_node);
} }
static void hash_nodes_destroy (rtgui_hash_node_t *hash_node) static void hash_nodes_destroy(rtgui_hash_node_t *hash_node)
{ {
if (hash_node) if (hash_node)
{ {
rtgui_hash_node_t *node = hash_node; rtgui_hash_node_t *node = hash_node;
rtgui_hash_node_t *temp; rtgui_hash_node_t *temp;
while (node->next) while (node->next)
{ {
node->key = NULL; node->key = NULL;
node->value = NULL; node->value = NULL;
temp = node; temp = node;
node = node->next; node = node->next;
rtgui_free(temp); rtgui_free(temp);
} }
node->key = NULL; node->key = NULL;
node->value = NULL; node->value = NULL;
rtgui_free(node); rtgui_free(node);
} }
} }
unsigned int string_hash_func(const void* self) unsigned int string_hash_func(const void *self)
{ {
const char *p; const char *p;
int h=0, g; int h = 0, g;
for(p = self; *p != '\0'; p += 1) for (p = self; *p != '\0'; p += 1)
{ {
h = ( h << 4 ) + *p; h = (h << 4) + *p;
if ( ( g = h & 0xf0000000 ) ) if ((g = h & 0xf0000000))
{ {
h = h ^ (g >> 24); h = h ^ (g >> 24);
h = h ^ g; h = h ^ g;
} }
} }
return h ; return h ;
} }
rt_bool_t string_equal_func(const void* a, const void* b) rt_bool_t string_equal_func(const void *a, const void *b)
{ {
const char *str1, *str2; const char *str1, *str2;
str1 = (const char*)a; str1 = (const char *)a;
str2 = (const char*)b; str2 = (const char *)b;
if (strcmp(str1, str2) == 0) return RT_TRUE; if (strcmp(str1, str2) == 0) return RT_TRUE;
return RT_FALSE; return RT_FALSE;
} }
static rtgui_hash_table_t* image_hash_table; static rtgui_hash_table_t *image_hash_table;
static rt_bool_t load_image = RT_FALSE; static rt_bool_t load_image = RT_FALSE;
void rtgui_system_image_container_init(rt_bool_t load) void rtgui_system_image_container_init(rt_bool_t load)
{ {
/* create image hash table */ /* create image hash table */
image_hash_table = hash_table_create(string_hash_func, string_equal_func); image_hash_table = hash_table_create(string_hash_func, string_equal_func);
RT_ASSERT(image_hash_table != RT_NULL); RT_ASSERT(image_hash_table != RT_NULL);
/* set load type */ /* set load type */
load_image = load; load_image = load;
} }
#ifdef RTGUI_USING_DFS_FILERW #ifdef RTGUI_USING_DFS_FILERW
rtgui_image_item_t* rtgui_image_container_get(const char* filename) rtgui_image_item_t *rtgui_image_container_get(const char *filename)
{ {
struct rtgui_image_item* item; struct rtgui_image_item *item;
item = hash_table_find(image_hash_table, filename);
if (item == RT_NULL)
{
item = (struct rtgui_image_item*) rtgui_malloc (sizeof(struct rtgui_image_item));
if (item == RT_NULL) return RT_NULL;
/* create a image object */ item = hash_table_find(image_hash_table, filename);
item->image = rtgui_image_create(filename, load_image); if (item == RT_NULL)
if (item->image == RT_NULL) {
{ item = (struct rtgui_image_item *) rtgui_malloc(sizeof(struct rtgui_image_item));
rtgui_free(item); if (item == RT_NULL) return RT_NULL;
return RT_NULL; /* create image failed */
}
item->refcount = 1; /* create a image object */
item->filename = rt_strdup(filename); item->image = rtgui_image_create(filename, load_image);
hash_table_insert(image_hash_table, item->filename, item); if (item->image == RT_NULL)
} {
else rtgui_free(item);
{ return RT_NULL; /* create image failed */
item->refcount ++; /* increase refcount */ }
}
return item; item->refcount = 1;
item->filename = rt_strdup(filename);
hash_table_insert(image_hash_table, item->filename, item);
}
else
{
item->refcount ++; /* increase refcount */
}
return item;
} }
#endif #endif
rtgui_image_item_t* rtgui_image_container_get_memref(const char* type, const rt_uint8_t* memory, rt_uint32_t length) rtgui_image_item_t *rtgui_image_container_get_memref(const char *type, const rt_uint8_t *memory, rt_uint32_t length)
{ {
char filename[32]; char filename[32];
struct rtgui_image_item* item; struct rtgui_image_item *item;
/* create filename for image identification */ /* create filename for image identification */
rt_snprintf(filename, sizeof(filename), "0x%08x_%s", memory, type); rt_snprintf(filename, sizeof(filename), "0x%08x_%s", memory, type);
/* search in container */ /* search in container */
item = hash_table_find(image_hash_table, filename); item = hash_table_find(image_hash_table, filename);
if (item == RT_NULL) if (item == RT_NULL)
{ {
item = (struct rtgui_image_item*) rtgui_malloc (sizeof(struct rtgui_image_item)); item = (struct rtgui_image_item *) rtgui_malloc(sizeof(struct rtgui_image_item));
if (item == RT_NULL) return RT_NULL; if (item == RT_NULL) return RT_NULL;
/* create image object */ /* create image object */
item->image = rtgui_image_create_from_mem(type, memory, length, load_image); item->image = rtgui_image_create_from_mem(type, memory, length, load_image);
if (item->image == RT_NULL) if (item->image == RT_NULL)
{ {
rtgui_free(item); rtgui_free(item);
return RT_NULL; /* create image failed */ return RT_NULL; /* create image failed */
} }
item->refcount = 1; item->refcount = 1;
item->filename = rt_strdup(filename); item->filename = rt_strdup(filename);
hash_table_insert(image_hash_table, item->filename, item); hash_table_insert(image_hash_table, item->filename, item);
} }
else item->refcount ++; else item->refcount ++;
return item; return item;
} }
void rtgui_image_container_put(rtgui_image_item_t* item) void rtgui_image_container_put(rtgui_image_item_t *item)
{ {
item->refcount --; item->refcount --;
if (item->refcount == 0) if (item->refcount == 0)
{ {
/* remove item from container */ /* remove item from container */
hash_table_remove(image_hash_table, item->filename); hash_table_remove(image_hash_table, item->filename);
/* destroy image and image item */ /* destroy image and image item */
rt_free(item->filename); rt_free(item->filename);
rtgui_image_destroy(item->image); rtgui_image_destroy(item->image);
rtgui_free(item); rtgui_free(item);
} }
} }
#endif #endif

View File

@ -8,158 +8,163 @@
struct rtgui_image_hdc struct rtgui_image_hdc
{ {
rt_bool_t is_loaded; rt_bool_t is_loaded;
/* hdc image information */ /* hdc image information */
rt_uint16_t byte_per_pixel; rt_uint16_t byte_per_pixel;
rt_uint16_t pitch; rt_uint16_t pitch;
rt_size_t pixel_offset; rt_size_t pixel_offset;
rt_uint8_t *pixels; rt_uint8_t *pixels;
struct rtgui_filerw* filerw; struct rtgui_filerw *filerw;
const struct rtgui_graphic_driver* hw_driver; const struct rtgui_graphic_driver *hw_driver;
}; };
static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw* file); static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw *file);
static rt_bool_t rtgui_image_hdc_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load); static rt_bool_t rtgui_image_hdc_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
static void rtgui_image_hdc_unload(struct rtgui_image* image); static void rtgui_image_hdc_unload(struct rtgui_image *image);
static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect); static void rtgui_image_hdc_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
static void rtgui_image_hdcmm_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* dst_rect); static void rtgui_image_hdcmm_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *dst_rect);
struct rtgui_image_engine rtgui_image_hdc_engine = struct rtgui_image_engine rtgui_image_hdc_engine =
{ {
"hdc", "hdc",
{ RT_NULL }, { RT_NULL },
rtgui_image_hdc_check, rtgui_image_hdc_check,
rtgui_image_hdc_load, rtgui_image_hdc_load,
rtgui_image_hdc_unload, rtgui_image_hdc_unload,
rtgui_image_hdc_blit, rtgui_image_hdc_blit,
RT_NULL, RT_NULL,
RT_NULL RT_NULL
}; };
const struct rtgui_image_engine rtgui_image_hdcmm_engine = const struct rtgui_image_engine rtgui_image_hdcmm_engine =
{ {
"hdcmm", "hdcmm",
{RT_NULL}, {RT_NULL},
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
rtgui_image_hdcmm_blit, rtgui_image_hdcmm_blit,
RT_NULL, RT_NULL,
RT_NULL RT_NULL
}; };
static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw* file) static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw *file)
{ {
int start; int start;
rt_bool_t is_HDC; rt_bool_t is_HDC;
rt_uint8_t magic[4]; rt_uint8_t magic[4];
if ( !file ) return 0; if (!file) return 0;
start = rtgui_filerw_tell(file); start = rtgui_filerw_tell(file);
/* move to the beginning of file */ /* move to the beginning of file */
rtgui_filerw_seek(file, 0, RTGUI_FILE_SEEK_SET); rtgui_filerw_seek(file, 0, RTGUI_FILE_SEEK_SET);
is_HDC = RT_FALSE; is_HDC = RT_FALSE;
if ( rtgui_filerw_read(file, magic, 1, sizeof(magic)) == sizeof(magic) ) if (rtgui_filerw_read(file, magic, 1, sizeof(magic)) == sizeof(magic))
{ {
if ( magic[0] == 'H' && if (magic[0] == 'H' &&
magic[1] == 'D' && magic[1] == 'D' &&
magic[2] == 'C' && magic[2] == 'C' &&
magic[3] == '\0' ) magic[3] == '\0')
{ {
is_HDC = RT_TRUE; is_HDC = RT_TRUE;
} }
} }
rtgui_filerw_seek(file, start, RTGUI_FILE_SEEK_SET); rtgui_filerw_seek(file, start, RTGUI_FILE_SEEK_SET);
return(is_HDC); return(is_HDC);
} }
static rt_bool_t rtgui_image_hdc_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load) static rt_bool_t rtgui_image_hdc_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load)
{ {
rt_uint32_t header[5]; rt_uint32_t header[5];
struct rtgui_image_hdc* hdc; struct rtgui_image_hdc *hdc;
hdc = (struct rtgui_image_hdc*) rtgui_malloc(sizeof(struct rtgui_image_hdc)); hdc = (struct rtgui_image_hdc *) rtgui_malloc(sizeof(struct rtgui_image_hdc));
if (hdc == RT_NULL) return RT_FALSE; if (hdc == RT_NULL) return RT_FALSE;
hdc->hw_driver = rtgui_graphic_driver_get_default(); hdc->hw_driver = rtgui_graphic_driver_get_default();
if (hdc->hw_driver == RT_NULL) { rtgui_free(hdc); return RT_FALSE; } if (hdc->hw_driver == RT_NULL)
{
rtgui_free(hdc);
return RT_FALSE;
}
rtgui_filerw_read(file, (char*)&header, 1, sizeof(header)); rtgui_filerw_read(file, (char *)&header, 1, sizeof(header));
/* set image information */ /* set image information */
image->w = (rt_uint16_t)header[1]; image->h = (rt_uint16_t)header[2]; image->w = (rt_uint16_t)header[1];
image->engine = &rtgui_image_hdc_engine; image->h = (rt_uint16_t)header[2];
image->data = hdc; image->engine = &rtgui_image_hdc_engine;
hdc->filerw = file; image->data = hdc;
hdc->byte_per_pixel = hdc->hw_driver->bits_per_pixel/8; hdc->filerw = file;
hdc->pitch = image->w * hdc->byte_per_pixel; hdc->byte_per_pixel = hdc->hw_driver->bits_per_pixel / 8;
hdc->pixel_offset = rtgui_filerw_tell(file); hdc->pitch = image->w * hdc->byte_per_pixel;
hdc->pixel_offset = rtgui_filerw_tell(file);
if (load == RT_TRUE) if (load == RT_TRUE)
{ {
/* load all pixels */ /* load all pixels */
hdc->pixels = rtgui_malloc(image->h * hdc->pitch); hdc->pixels = rtgui_malloc(image->h * hdc->pitch);
if (hdc->pixels == RT_NULL) if (hdc->pixels == RT_NULL)
{ {
/* release data */ /* release data */
rtgui_free(hdc); rtgui_free(hdc);
return RT_FALSE; return RT_FALSE;
} }
rtgui_filerw_read(hdc->filerw, hdc->pixels, 1, image->h * hdc->pitch); rtgui_filerw_read(hdc->filerw, hdc->pixels, 1, image->h * hdc->pitch);
rtgui_filerw_close(hdc->filerw); rtgui_filerw_close(hdc->filerw);
hdc->filerw = RT_NULL; hdc->filerw = RT_NULL;
hdc->pixel_offset = 0; hdc->pixel_offset = 0;
} }
else else
{ {
hdc->pixels = RT_NULL; hdc->pixels = RT_NULL;
} }
return RT_TRUE; return RT_TRUE;
} }
static void rtgui_image_hdc_unload(struct rtgui_image* image) static void rtgui_image_hdc_unload(struct rtgui_image *image)
{ {
struct rtgui_image_hdc* hdc; struct rtgui_image_hdc *hdc;
if (image != RT_NULL) if (image != RT_NULL)
{ {
hdc = (struct rtgui_image_hdc*) image->data; hdc = (struct rtgui_image_hdc *) image->data;
if (hdc->pixels != RT_NULL) rtgui_free(hdc->pixels); if (hdc->pixels != RT_NULL) rtgui_free(hdc->pixels);
if (hdc->filerw != RT_NULL) if (hdc->filerw != RT_NULL)
{ {
rtgui_filerw_close(hdc->filerw); rtgui_filerw_close(hdc->filerw);
hdc->filerw = RT_NULL; hdc->filerw = RT_NULL;
} }
/* release data */ /* release data */
rtgui_free(hdc); rtgui_free(hdc);
} }
} }
static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* dst_rect) static void rtgui_image_hdc_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *dst_rect)
{ {
rt_uint16_t y, w, h; rt_uint16_t y, w, h;
struct rtgui_image_hdc* hdc; struct rtgui_image_hdc *hdc;
RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL); RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL);
/* this dc is not visible */ /* this dc is not visible */
if (rtgui_dc_get_visible(dc) != RT_TRUE) return; if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
hdc = (struct rtgui_image_hdc*) image->data; hdc = (struct rtgui_image_hdc *) image->data;
RT_ASSERT(hdc != RT_NULL); RT_ASSERT(hdc != RT_NULL);
/* the minimum rect */ /* the minimum rect */
if (image->w < rtgui_rect_width(*dst_rect)) w = image->w; if (image->w < rtgui_rect_width(*dst_rect)) w = image->w;
else w = rtgui_rect_width(*dst_rect); else w = rtgui_rect_width(*dst_rect);
if (image->h < rtgui_rect_height(*dst_rect)) h = image->h; if (image->h < rtgui_rect_height(*dst_rect)) h = image->h;
@ -167,72 +172,72 @@ static void rtgui_image_hdc_blit(struct rtgui_image* image, struct rtgui_dc* dc,
if (hdc->pixels != RT_NULL) if (hdc->pixels != RT_NULL)
{ {
rt_uint8_t* ptr; rt_uint8_t *ptr;
/* get pixel pointer */ /* get pixel pointer */
ptr = hdc->pixels; ptr = hdc->pixels;
for (y = 0; y < h; y ++) for (y = 0; y < h; y ++)
{ {
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr); dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
ptr += hdc->pitch; ptr += hdc->pitch;
} }
} }
else else
{ {
rt_uint8_t* ptr; rt_uint8_t *ptr;
ptr = rtgui_malloc(hdc->pitch); ptr = rtgui_malloc(hdc->pitch);
if (ptr == RT_NULL) return; /* no memory */ if (ptr == RT_NULL) return; /* no memory */
/* seek to the begin of pixel data */ /* seek to the begin of pixel data */
rtgui_filerw_seek(hdc->filerw, hdc->pixel_offset, RTGUI_FILE_SEEK_SET); rtgui_filerw_seek(hdc->filerw, hdc->pixel_offset, RTGUI_FILE_SEEK_SET);
for (y = 0; y < h; y ++) for (y = 0; y < h; y ++)
{ {
/* read pixel data */ /* read pixel data */
if (rtgui_filerw_read(hdc->filerw, ptr, 1, hdc->pitch) != hdc->pitch) if (rtgui_filerw_read(hdc->filerw, ptr, 1, hdc->pitch) != hdc->pitch)
break; /* read data failed */ break; /* read data failed */
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr); dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
} }
rtgui_free(ptr); rtgui_free(ptr);
} }
} }
static void rtgui_image_hdcmm_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* dst_rect) static void rtgui_image_hdcmm_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *dst_rect)
{ {
rt_uint8_t* ptr; rt_uint8_t *ptr;
rt_uint16_t y, w, h; rt_uint16_t y, w, h;
struct rtgui_image_hdcmm* hdc; struct rtgui_image_hdcmm *hdc;
RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL); RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL);
/* this dc is not visible */ /* this dc is not visible */
if (rtgui_dc_get_visible(dc) != RT_TRUE) return; if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
hdc = (struct rtgui_image_hdcmm*) image; hdc = (struct rtgui_image_hdcmm *) image;
RT_ASSERT(hdc != RT_NULL); RT_ASSERT(hdc != RT_NULL);
/* the minimum rect */ /* the minimum rect */
if (image->w < rtgui_rect_width(*dst_rect)) w = image->w; if (image->w < rtgui_rect_width(*dst_rect)) w = image->w;
else w = rtgui_rect_width(*dst_rect); else w = rtgui_rect_width(*dst_rect);
if (image->h < rtgui_rect_height(*dst_rect)) h = image->h; if (image->h < rtgui_rect_height(*dst_rect)) h = image->h;
else h = rtgui_rect_height(*dst_rect); else h = rtgui_rect_height(*dst_rect);
/* get pixel pointer */ /* get pixel pointer */
ptr = hdc->pixels; ptr = hdc->pixels;
for (y = 0; y < h; y ++) for (y = 0; y < h; y ++)
{ {
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr); dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
ptr += hdc->pitch; ptr += hdc->pitch;
} }
} }
void rtgui_image_hdc_init() void rtgui_image_hdc_init()
{ {
/* register hdc on image system */ /* register hdc on image system */
rtgui_image_register_engine(&rtgui_image_hdc_engine); rtgui_image_register_engine(&rtgui_image_hdc_engine);
} }

View File

@ -634,11 +634,13 @@ static UINT tjpgd_out_func(JDEC *jdec, void *bitmap, JRECT *rect)
rt_uint16_t rectWidth; /* Width of source rectangular (bytes) */ rt_uint16_t rectWidth; /* Width of source rectangular (bytes) */
rt_uint8_t *src, *dst; rt_uint8_t *src, *dst;
#ifdef RTGUI_DEBUG_TJPGD
/* Put progress indicator */ /* Put progress indicator */
if (rect->left == 0) if (rect->left == 0)
{ {
rt_kprintf("\r%lu%%", (rect->top << jpeg->scale) * 100UL / jdec->height); rt_kprintf("\r%lu%%", (rect->top << jpeg->scale) * 100UL / jdec->height);
} }
#endif
/* Copy the decompressed RGB rectanglar to the frame buffer */ /* Copy the decompressed RGB rectanglar to the frame buffer */
rectWidth = (rect->right - rect->left + 1) * jpeg->byte_per_pixel; rectWidth = (rect->right - rect->left + 1) * jpeg->byte_per_pixel;
@ -747,7 +749,9 @@ static rt_bool_t rtgui_image_jpeg_check(struct rtgui_filerw *file)
is_JPG = RT_TRUE; is_JPG = RT_TRUE;
} }
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: check OK\n"); rt_kprintf("TJPGD: check OK\n");
#endif
} }
while (0); while (0);
@ -809,7 +813,9 @@ static rt_bool_t rtgui_image_jpeg_load(struct rtgui_image *image, struct rtgui_f
} }
break; break;
} }
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: prepare OK\n"); rt_kprintf("TJPGD: prepare OK\n");
#endif
image->w = (rt_uint16_t)jpeg->tjpgd.width >> jpeg->scale; image->w = (rt_uint16_t)jpeg->tjpgd.width >> jpeg->scale;
image->h = (rt_uint16_t)jpeg->tjpgd.height >> jpeg->scale; image->h = (rt_uint16_t)jpeg->tjpgd.height >> jpeg->scale;
@ -838,7 +844,9 @@ static rt_bool_t rtgui_image_jpeg_load(struct rtgui_image *image, struct rtgui_f
rtgui_filerw_close(jpeg->filerw); rtgui_filerw_close(jpeg->filerw);
jpeg->is_loaded = RT_TRUE; jpeg->is_loaded = RT_TRUE;
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: load to RAM\n"); rt_kprintf("TJPGD: load to RAM\n");
#endif
} }
res = RT_TRUE; res = RT_TRUE;
} }
@ -886,7 +894,9 @@ static void rtgui_image_jpeg_unload(struct rtgui_image *image)
} }
rt_free(jpeg); rt_free(jpeg);
} }
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: unload\n"); rt_kprintf("TJPGD: unload\n");
#endif
} }
static void rtgui_image_jpeg_blit(struct rtgui_image *image, static void rtgui_image_jpeg_blit(struct rtgui_image *image,
@ -938,7 +948,9 @@ static void rtgui_image_jpeg_blit(struct rtgui_image *image,
{ {
break; break;
} }
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: load to display\n"); rt_kprintf("TJPGD: load to display\n");
#endif
} }
else else
{ {

View File

@ -9,98 +9,98 @@
struct rtgui_image_png struct rtgui_image_png
{ {
rt_bool_t is_loaded; rt_bool_t is_loaded;
struct rtgui_filerw* filerw; struct rtgui_filerw *filerw;
/* png image information */ /* png image information */
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
rt_uint8_t *pixels; rt_uint8_t *pixels;
}; };
static rt_bool_t rtgui_image_png_check(struct rtgui_filerw* file); static rt_bool_t rtgui_image_png_check(struct rtgui_filerw *file);
static rt_bool_t rtgui_image_png_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load); static rt_bool_t rtgui_image_png_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
static void rtgui_image_png_unload(struct rtgui_image* image); static void rtgui_image_png_unload(struct rtgui_image *image);
static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect); static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
struct rtgui_image_engine rtgui_image_png_engine = struct rtgui_image_engine rtgui_image_png_engine =
{ {
"png", "png",
{ RT_NULL }, { RT_NULL },
rtgui_image_png_check, rtgui_image_png_check,
rtgui_image_png_load, rtgui_image_png_load,
rtgui_image_png_unload, rtgui_image_png_unload,
rtgui_image_png_blit, rtgui_image_png_blit,
RT_NULL, RT_NULL,
RT_NULL RT_NULL
}; };
static void rtgui_image_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) static void rtgui_image_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
struct rtgui_filerw* filerw = (struct rtgui_filerw*)png_ptr->io_ptr; struct rtgui_filerw *filerw = (struct rtgui_filerw *)png_ptr->io_ptr;
rtgui_filerw_read(filerw, data, length, 1); rtgui_filerw_read(filerw, data, length, 1);
} }
static rt_bool_t rtgui_image_png_process(png_structp png_ptr, png_infop info_ptr, struct rtgui_image_png* png) static rt_bool_t rtgui_image_png_process(png_structp png_ptr, png_infop info_ptr, struct rtgui_image_png *png)
{ {
rt_uint32_t x, y; rt_uint32_t x, y;
png_bytep row; png_bytep row;
png_bytep data; png_bytep data;
rtgui_color_t *ptr; rtgui_color_t *ptr;
row = (png_bytep) rtgui_malloc (png_get_rowbytes(png_ptr, info_ptr)); row = (png_bytep) rtgui_malloc(png_get_rowbytes(png_ptr, info_ptr));
if (row == RT_NULL) return RT_FALSE; if (row == RT_NULL) return RT_FALSE;
ptr = (rtgui_color_t *)png->pixels; ptr = (rtgui_color_t *)png->pixels;
switch (info_ptr->color_type) switch (info_ptr->color_type)
{ {
case PNG_COLOR_TYPE_RGB: case PNG_COLOR_TYPE_RGB:
for (y = 0; y < info_ptr->height; y++) for (y = 0; y < info_ptr->height; y++)
{ {
png_read_row(png_ptr, row, png_bytep_NULL); png_read_row(png_ptr, row, png_bytep_NULL);
for (x = 0; x < info_ptr->width; x++) for (x = 0; x < info_ptr->width; x++)
{
data = &(row[x * 3]);
ptr[x+y*info_ptr->width] = RTGUI_RGB(data[0], data[1], data[2]);
}
}
break;
case PNG_COLOR_TYPE_RGBA:
for (y = 0; y < info_ptr->height; y++)
{ {
png_read_row(png_ptr, row, png_bytep_NULL); data = &(row[x * 3]);
for (x = 0; x < info_ptr->width; x++)
{
data = &(row[x * 4]);
ptr[x+y*info_ptr->width] = RTGUI_ARGB((255 - data[3]), data[0], data[1], data[2]); ptr[x + y * info_ptr->width] = RTGUI_RGB(data[0], data[1], data[2]);
}
} }
}
break;
break; case PNG_COLOR_TYPE_RGBA:
for (y = 0; y < info_ptr->height; y++)
case PNG_COLOR_TYPE_PALETTE: {
for (y = 0; y < info_ptr->height; y++) png_read_row(png_ptr, row, png_bytep_NULL);
for (x = 0; x < info_ptr->width; x++)
{ {
png_read_row(png_ptr, row, png_bytep_NULL); data = &(row[x * 4]);
for (x = 0; x < info_ptr->width; x++)
{
data = &(row[x]);
ptr[x] = RTGUI_ARGB(0, info_ptr->palette[data[0]].red, ptr[x + y * info_ptr->width] = RTGUI_ARGB((255 - data[3]), data[0], data[1], data[2]);
info_ptr->palette[data[0]].green,
info_ptr->palette[data[0]].blue);
}
} }
}
default: break;
break;
case PNG_COLOR_TYPE_PALETTE:
for (y = 0; y < info_ptr->height; y++)
{
png_read_row(png_ptr, row, png_bytep_NULL);
for (x = 0; x < info_ptr->width; x++)
{
data = &(row[x]);
ptr[x] = RTGUI_ARGB(0, info_ptr->palette[data[0]].red,
info_ptr->palette[data[0]].green,
info_ptr->palette[data[0]].blue);
}
}
default:
break;
}; };
rtgui_free(row); rtgui_free(row);
@ -108,98 +108,99 @@ static rt_bool_t rtgui_image_png_process(png_structp png_ptr, png_infop info_ptr
return RT_TRUE; return RT_TRUE;
} }
static rt_bool_t rtgui_image_png_check(struct rtgui_filerw* file) static rt_bool_t rtgui_image_png_check(struct rtgui_filerw *file)
{ {
int start; int start;
rt_bool_t is_PNG; rt_bool_t is_PNG;
rt_uint8_t magic[4]; rt_uint8_t magic[4];
if ( !file ) return 0; if (!file) return 0;
start = rtgui_filerw_tell(file); start = rtgui_filerw_tell(file);
/* move to the begining of file */ /* move to the begining of file */
rtgui_filerw_seek(file, 0, SEEK_SET); rtgui_filerw_seek(file, 0, SEEK_SET);
is_PNG = RT_FALSE; is_PNG = RT_FALSE;
if ( rtgui_filerw_read(file, magic, 1, sizeof(magic)) == sizeof(magic) ) if (rtgui_filerw_read(file, magic, 1, sizeof(magic)) == sizeof(magic))
{ {
if ( magic[0] == 0x89 && if (magic[0] == 0x89 &&
magic[1] == 'P' && magic[1] == 'P' &&
magic[2] == 'N' && magic[2] == 'N' &&
magic[3] == 'G' ) magic[3] == 'G')
{ {
is_PNG = RT_TRUE; is_PNG = RT_TRUE;
} }
} }
rtgui_filerw_seek(file, start, SEEK_SET); rtgui_filerw_seek(file, start, SEEK_SET);
return(is_PNG); return(is_PNG);
} }
static rt_bool_t rtgui_image_png_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load) static rt_bool_t rtgui_image_png_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load)
{ {
png_uint_32 width; png_uint_32 width;
png_uint_32 height; png_uint_32 height;
int bit_depth; int bit_depth;
int color_type; int color_type;
double gamma; double gamma;
struct rtgui_image_png* png; struct rtgui_image_png *png;
png = (struct rtgui_image_png*) rtgui_malloc(sizeof(struct rtgui_image_png)); png = (struct rtgui_image_png *) rtgui_malloc(sizeof(struct rtgui_image_png));
png->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png->png_ptr == RT_NULL) if (png->png_ptr == RT_NULL)
{ {
rtgui_free(png); rtgui_free(png);
return RT_FALSE; return RT_FALSE;
} }
png->info_ptr = png_create_info_struct(png->png_ptr); png->info_ptr = png_create_info_struct(png->png_ptr);
if (png->info_ptr == RT_NULL) if (png->info_ptr == RT_NULL)
{ {
png_destroy_read_struct(&png->png_ptr, NULL, NULL); png_destroy_read_struct(&png->png_ptr, NULL, NULL);
rtgui_free(png); rtgui_free(png);
return RT_FALSE; return RT_FALSE;
} }
png->filerw = file; png->filerw = file;
png_set_read_fn (png->png_ptr, png->filerw, rtgui_image_png_read_data); png_set_read_fn(png->png_ptr, png->filerw, rtgui_image_png_read_data);
png_read_info(png->png_ptr, png->info_ptr); png_read_info(png->png_ptr, png->info_ptr);
png_get_IHDR(png->png_ptr, png->info_ptr, &width, &height, &bit_depth, png_get_IHDR(png->png_ptr, png->info_ptr, &width, &height, &bit_depth,
&color_type, NULL, NULL, NULL); &color_type, NULL, NULL, NULL);
/* set image information */ /* set image information */
image->w = width; image->h = height; image->w = width;
image->engine = &rtgui_image_png_engine; image->h = height;
image->data = png; image->engine = &rtgui_image_png_engine;
image->data = png;
if (bit_depth == 16) if (bit_depth == 16)
png_set_strip_16(png->png_ptr); png_set_strip_16(png->png_ptr);
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_expand(png->png_ptr); png_set_expand(png->png_ptr);
if (bit_depth < 8) if (bit_depth < 8)
png_set_expand(png->png_ptr); png_set_expand(png->png_ptr);
if (png_get_valid(png->png_ptr, png->info_ptr, PNG_INFO_tRNS)) if (png_get_valid(png->png_ptr, png->info_ptr, PNG_INFO_tRNS))
png_set_expand(png->png_ptr); png_set_expand(png->png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY || if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA) color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png->png_ptr); png_set_gray_to_rgb(png->png_ptr);
/* Ignore background color */ /* Ignore background color */
/* set gamma conversion */ /* set gamma conversion */
if (png_get_gAMA(png->png_ptr, png->info_ptr, &gamma)) if (png_get_gAMA(png->png_ptr, png->info_ptr, &gamma))
png_set_gamma(png->png_ptr, (double)2.2, gamma); png_set_gamma(png->png_ptr, (double)2.2, gamma);
png_read_update_info(png->png_ptr, png->info_ptr); png_read_update_info(png->png_ptr, png->info_ptr);
if (load == RT_TRUE) if (load == RT_TRUE)
{ {
/* load all pixels */ /* load all pixels */
png->pixels = rtgui_malloc(image->w * image->h * sizeof(rtgui_color_t)); png->pixels = rtgui_malloc(image->w * image->h * sizeof(rtgui_color_t));
if (png->pixels == RT_NULL) if (png->pixels == RT_NULL)
{ {
png_read_end(png->png_ptr, RT_NULL); png_read_end(png->png_ptr, RT_NULL);
/* destroy png struct */ /* destroy png struct */
@ -209,111 +210,112 @@ static rt_bool_t rtgui_image_png_load(struct rtgui_image* image, struct rtgui_fi
/* release data */ /* release data */
rtgui_free(png); rtgui_free(png);
return RT_FALSE; return RT_FALSE;
} }
rtgui_image_png_process(png->png_ptr, png->info_ptr, png); rtgui_image_png_process(png->png_ptr, png->info_ptr, png);
} }
else else
{ {
png->pixels = RT_NULL; png->pixels = RT_NULL;
} }
return RT_TRUE; return RT_TRUE;
} }
static void rtgui_image_png_unload(struct rtgui_image* image) static void rtgui_image_png_unload(struct rtgui_image *image)
{ {
struct rtgui_image_png* png; struct rtgui_image_png *png;
if (image != RT_NULL) if (image != RT_NULL)
{ {
png = (struct rtgui_image_png*) image->data; png = (struct rtgui_image_png *) image->data;
png_read_end(png->png_ptr, RT_NULL); png_read_end(png->png_ptr, RT_NULL);
/* destroy png struct */ /* destroy png struct */
png_destroy_info_struct(png->png_ptr, &png->info_ptr); png_destroy_info_struct(png->png_ptr, &png->info_ptr);
png_destroy_read_struct(&png->png_ptr, RT_NULL, RT_NULL); png_destroy_read_struct(&png->png_ptr, RT_NULL, RT_NULL);
if (png->pixels != RT_NULL) rtgui_free(png->pixels); if (png->pixels != RT_NULL) rtgui_free(png->pixels);
/* release data */ /* release data */
rtgui_free(png); rtgui_free(png);
} }
} }
static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect) static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect)
{ {
struct rtgui_graphic_driver* hwdev = rtgui_graphic_get_device(); struct rtgui_graphic_driver *hwdev = rtgui_graphic_get_device();
rt_uint16_t x, y, w, h; rt_uint16_t x, y, w, h;
rtgui_color_t* ptr; rtgui_color_t *ptr;
struct rtgui_image_png* png; struct rtgui_image_png *png;
int fg_maxsample; int fg_maxsample;
int ialpha; int ialpha;
float alpha; float alpha;
rtgui_color_t color; rtgui_color_t color;
rtgui_color_t c, bgcolor; rtgui_color_t c, bgcolor;
int fc[3], bc[3]; int fc[3], bc[3];
RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL); RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL);
RT_ASSERT(image->data != RT_NULL); RT_ASSERT(image->data != RT_NULL);
png = (struct rtgui_image_png*) image->data; png = (struct rtgui_image_png *) image->data;
if (image->w < rtgui_rect_width(*rect)) w = image->w; if (image->w < rtgui_rect_width(*rect)) w = image->w;
else w = rtgui_rect_width(*rect); else w = rtgui_rect_width(*rect);
if (image->h < rtgui_rect_height(*rect)) h = image->h; if (image->h < rtgui_rect_height(*rect)) h = image->h;
else h = rtgui_rect_height(*rect); else h = rtgui_rect_height(*rect);
fg_maxsample = (1 << png->info_ptr->bit_depth) - 1; fg_maxsample = (1 << png->info_ptr->bit_depth) - 1;
if (png->pixels != RT_NULL) if (png->pixels != RT_NULL)
{ {
ptr = (rtgui_color_t*)png->pixels; ptr = (rtgui_color_t *)png->pixels;
bgcolor = rtgui_color_from_565(RTGUI_DC_BC(dc)); bgcolor = rtgui_color_from_565(RTGUI_DC_BC(dc));
bc[0] = RTGUI_RGB_R(bgcolor); bc[0] = RTGUI_RGB_R(bgcolor);
bc[1] = RTGUI_RGB_G(bgcolor); bc[1] = RTGUI_RGB_G(bgcolor);
bc[2] = RTGUI_RGB_B(bgcolor); bc[2] = RTGUI_RGB_B(bgcolor);
/* draw each point within dc */ /* draw each point within dc */
for (y = 0; y < h; y ++) for (y = 0; y < h; y ++)
{ {
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
{ {
c = *ptr; c = *ptr;
ialpha = RTGUI_RGB_A(c); ialpha = RTGUI_RGB_A(c);
if(ialpha == 0) if (ialpha == 0)
{ {
/* /*
* Foreground image is transparent hear. * Foreground image is transparent hear.
* If the background image is already in the frame * If the background image is already in the frame
* buffer, there is nothing to do. * buffer, there is nothing to do.
*/ */
} }
else if (ialpha == fg_maxsample) else if (ialpha == fg_maxsample)
{ {
/* /*
* Copy foreground pixel to frame buffer. * Copy foreground pixel to frame buffer.
*/ */
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, c); rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, c);
} }
else else
{ /* output = alpha * foreground + (1-alpha) * background */ {
/* /* output = alpha * foreground + (1-alpha) * background */
* Compositing is necessary. /*
* Get floating-point alpha and its complement. * Compositing is necessary.
* Note: alpha is always linear: gamma does not * Get floating-point alpha and its complement.
* affect it. * Note: alpha is always linear: gamma does not
*/ * affect it.
fc[0] = RTGUI_RGB_R(c); */
fc[1] = RTGUI_RGB_G(c); fc[0] = RTGUI_RGB_R(c);
fc[2] = RTGUI_RGB_B(c); fc[1] = RTGUI_RGB_G(c);
fc[2] = RTGUI_RGB_B(c);
alpha = (float) ialpha / fg_maxsample;
color = RTGUI_RGB( (rt_uint8_t)(fc[0]*alpha + bc[0]*(1-alpha)), alpha = (float) ialpha / fg_maxsample;
(rt_uint8_t)(fc[1]*alpha + bc[1]*(1-alpha)), color = RTGUI_RGB((rt_uint8_t)(fc[0] * alpha + bc[0] * (1 - alpha)),
(rt_uint8_t)(fc[2]*alpha + bc[2]*(1-alpha))); (rt_uint8_t)(fc[1] * alpha + bc[1] * (1 - alpha)),
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, color); (rt_uint8_t)(fc[2] * alpha + bc[2] * (1 - alpha)));
} rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, color);
}
/* move to next color buffer */ /* move to next color buffer */
ptr ++; ptr ++;
} }
@ -324,7 +326,7 @@ static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc,
png_bytep row; png_bytep row;
png_bytep data; png_bytep data;
row = (png_bytep) rtgui_malloc (png_get_rowbytes(png->png_ptr, png->info_ptr)); row = (png_bytep) rtgui_malloc(png_get_rowbytes(png->png_ptr, png->info_ptr));
if (row == RT_NULL) return ; if (row == RT_NULL) return ;
switch (png->info_ptr->color_type) switch (png->info_ptr->color_type)
@ -338,8 +340,8 @@ static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc,
data = &(row[x * 4]); data = &(row[x * 4]);
if (data[3] != 0) if (data[3] != 0)
{ {
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1,
RTGUI_ARGB((255 - data[3]), data[0], data[1], data[2])); RTGUI_ARGB((255 - data[3]), data[0], data[1], data[2]));
} }
} }
} }
@ -355,9 +357,9 @@ static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc,
data = &(row[x]); data = &(row[x]);
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1,
RTGUI_ARGB(0, png->info_ptr->palette[data[0]].red, RTGUI_ARGB(0, png->info_ptr->palette[data[0]].red,
png->info_ptr->palette[data[0]].green, png->info_ptr->palette[data[0]].green,
png->info_ptr->palette[data[0]].blue)); png->info_ptr->palette[data[0]].blue));
} }
} }
@ -371,7 +373,7 @@ static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc,
void rtgui_image_png_init() void rtgui_image_png_init()
{ {
/* register png on image system */ /* register png on image system */
rtgui_image_register_engine(&rtgui_image_png_engine); rtgui_image_register_engine(&rtgui_image_png_engine);
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -6,198 +6,198 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#include <rtgui/driver.h> #include <rtgui/driver.h>
#define gfx_device (rtgui_graphic_get_device()->device) #define gfx_device (rtgui_graphic_get_device()->device)
#define gfx_device_ops rt_graphix_ops(gfx_device) #define gfx_device_ops rt_graphix_ops(gfx_device)
static void _pixel_mono_set_pixel(rtgui_color_t *c, int x, int y) static void _pixel_mono_set_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint8_t pixel; rt_uint8_t pixel;
pixel = rtgui_color_to_mono(*c); pixel = rtgui_color_to_mono(*c);
gfx_device_ops->set_pixel((char*)&pixel, x, y); gfx_device_ops->set_pixel((char *)&pixel, x, y);
} }
static void _pixel_rgb565p_set_pixel(rtgui_color_t *c, int x, int y) static void _pixel_rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = rtgui_color_to_565p(*c); pixel = rtgui_color_to_565p(*c);
gfx_device_ops->set_pixel((char*)&pixel, x, y); gfx_device_ops->set_pixel((char *)&pixel, x, y);
} }
static void _pixel_rgb565_set_pixel(rtgui_color_t *c, int x, int y) static void _pixel_rgb565_set_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = rtgui_color_to_565(*c); pixel = rtgui_color_to_565(*c);
gfx_device_ops->set_pixel((char*)&pixel, x, y); gfx_device_ops->set_pixel((char *)&pixel, x, y);
} }
static void _pixel_rgb888_set_pixel(rtgui_color_t *c, int x, int y) static void _pixel_rgb888_set_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint32_t pixel; rt_uint32_t pixel;
pixel = rtgui_color_to_888(*c); pixel = rtgui_color_to_888(*c);
gfx_device_ops->set_pixel((char*)&pixel, x, y); gfx_device_ops->set_pixel((char *)&pixel, x, y);
} }
static void _pixel_mono_get_pixel(rtgui_color_t *c, int x, int y) static void _pixel_mono_get_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint8_t pixel; rt_uint8_t pixel;
gfx_device_ops->get_pixel((char*)&pixel, x, y); gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_mono(pixel); *c = rtgui_color_from_mono(pixel);
} }
static void _pixel_rgb565p_get_pixel(rtgui_color_t *c, int x, int y) static void _pixel_rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
gfx_device_ops->get_pixel((char*)&pixel, x, y); gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_565p(pixel); *c = rtgui_color_from_565p(pixel);
} }
static void _pixel_rgb565_get_pixel(rtgui_color_t *c, int x, int y) static void _pixel_rgb565_get_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
gfx_device_ops->get_pixel((char*)&pixel, x, y); gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_565(pixel); *c = rtgui_color_from_565(pixel);
} }
static void _pixel_rgb888_get_pixel(rtgui_color_t *c, int x, int y) static void _pixel_rgb888_get_pixel(rtgui_color_t *c, int x, int y)
{ {
rt_uint32_t pixel; rt_uint32_t pixel;
gfx_device_ops->get_pixel((char*)&pixel, x, y); gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_888(pixel); *c = rtgui_color_from_888(pixel);
} }
static void _pixel_mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _pixel_mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_uint8_t pixel; rt_uint8_t pixel;
pixel = rtgui_color_to_mono(*c); pixel = rtgui_color_to_mono(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y); gfx_device_ops->draw_hline((char *)&pixel, x1, x2, y);
} }
static void _pixel_rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _pixel_rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = rtgui_color_to_565p(*c); pixel = rtgui_color_to_565p(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y); gfx_device_ops->draw_hline((char *)&pixel, x1, x2, y);
} }
static void _pixel_rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _pixel_rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = rtgui_color_to_565(*c); pixel = rtgui_color_to_565(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y); gfx_device_ops->draw_hline((char *)&pixel, x1, x2, y);
} }
static void _pixel_rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y) static void _pixel_rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{ {
rt_uint32_t pixel; rt_uint32_t pixel;
pixel = rtgui_color_to_888(*c); pixel = rtgui_color_to_888(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y); gfx_device_ops->draw_hline((char *)&pixel, x1, x2, y);
} }
static void _pixel_mono_draw_vline(rtgui_color_t *c, int x, int y1, int y2) static void _pixel_mono_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
{ {
rt_uint8_t pixel; rt_uint8_t pixel;
pixel = rtgui_color_to_mono(*c); pixel = rtgui_color_to_mono(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2); gfx_device_ops->draw_vline((char *)&pixel, x, y1, y2);
} }
static void _pixel_rgb565p_draw_vline(rtgui_color_t *c, int x, int y1, int y2) static void _pixel_rgb565p_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = rtgui_color_to_565p(*c); pixel = rtgui_color_to_565p(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2); gfx_device_ops->draw_vline((char *)&pixel, x, y1, y2);
} }
static void _pixel_rgb565_draw_vline(rtgui_color_t *c, int x, int y1, int y2) static void _pixel_rgb565_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = rtgui_color_to_565(*c); pixel = rtgui_color_to_565(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2); gfx_device_ops->draw_vline((char *)&pixel, x, y1, y2);
} }
static void _pixel_rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int y2) static void _pixel_rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
{ {
rt_uint32_t pixel; rt_uint32_t pixel;
pixel = rtgui_color_to_888(*c); pixel = rtgui_color_to_888(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2); gfx_device_ops->draw_vline((char *)&pixel, x, y1, y2);
} }
static void _pixel_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y) static void _pixel_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
{ {
if (x2 > x1) if (x2 > x1)
gfx_device_ops->blit_line((char*)pixels, x1, y, (x2 - x1)); gfx_device_ops->blit_line((char *)pixels, x1, y, (x2 - x1));
else else
gfx_device_ops->blit_line((char*)pixels, x2, y, (x1 - x2)); gfx_device_ops->blit_line((char *)pixels, x2, y, (x1 - x2));
} }
/* pixel device */ /* pixel device */
const struct rtgui_graphic_driver_ops _pixel_mono_ops = const struct rtgui_graphic_driver_ops _pixel_mono_ops =
{ {
_pixel_mono_set_pixel, _pixel_mono_set_pixel,
_pixel_mono_get_pixel, _pixel_mono_get_pixel,
_pixel_mono_draw_hline, _pixel_mono_draw_hline,
_pixel_mono_draw_vline, _pixel_mono_draw_vline,
_pixel_draw_raw_hline, _pixel_draw_raw_hline,
}; };
const struct rtgui_graphic_driver_ops _pixel_rgb565p_ops = const struct rtgui_graphic_driver_ops _pixel_rgb565p_ops =
{ {
_pixel_rgb565p_set_pixel, _pixel_rgb565p_set_pixel,
_pixel_rgb565p_get_pixel, _pixel_rgb565p_get_pixel,
_pixel_rgb565p_draw_hline, _pixel_rgb565p_draw_hline,
_pixel_rgb565p_draw_vline, _pixel_rgb565p_draw_vline,
_pixel_draw_raw_hline, _pixel_draw_raw_hline,
}; };
const struct rtgui_graphic_driver_ops _pixel_rgb565_ops = const struct rtgui_graphic_driver_ops _pixel_rgb565_ops =
{ {
_pixel_rgb565_set_pixel, _pixel_rgb565_set_pixel,
_pixel_rgb565_get_pixel, _pixel_rgb565_get_pixel,
_pixel_rgb565_draw_hline, _pixel_rgb565_draw_hline,
_pixel_rgb565_draw_vline, _pixel_rgb565_draw_vline,
_pixel_draw_raw_hline, _pixel_draw_raw_hline,
}; };
const struct rtgui_graphic_driver_ops _pixel_rgb888_ops = const struct rtgui_graphic_driver_ops _pixel_rgb888_ops =
{ {
_pixel_rgb888_set_pixel, _pixel_rgb888_set_pixel,
_pixel_rgb888_get_pixel, _pixel_rgb888_get_pixel,
_pixel_rgb888_draw_hline, _pixel_rgb888_draw_hline,
_pixel_rgb888_draw_vline, _pixel_rgb888_draw_vline,
_pixel_draw_raw_hline, _pixel_draw_raw_hline,
}; };
const struct rtgui_graphic_driver_ops *rtgui_pixel_device_get_ops(int pixel_format) const struct rtgui_graphic_driver_ops *rtgui_pixel_device_get_ops(int pixel_format)
{ {
switch (pixel_format) switch (pixel_format)
{ {
case RTGRAPHIC_PIXEL_FORMAT_MONO: case RTGRAPHIC_PIXEL_FORMAT_MONO:
return &_pixel_mono_ops; return &_pixel_mono_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
return &_pixel_rgb565_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
return &_pixel_rgb565p_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB888:
return &_pixel_rgb888_ops;
}
return RT_NULL; case RTGRAPHIC_PIXEL_FORMAT_RGB565:
return &_pixel_rgb565_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
return &_pixel_rgb565p_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB888:
return &_pixel_rgb888_ops;
}
return RT_NULL;
} }

File diff suppressed because it is too large Load Diff

View File

@ -19,359 +19,368 @@
static void _rtgui_app_constructor(struct rtgui_app *app) static void _rtgui_app_constructor(struct rtgui_app *app)
{ {
/* set event handler */ /* set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(app), rtgui_object_set_event_handler(RTGUI_OBJECT(app),
rtgui_app_event_handler); rtgui_app_event_handler);
app->name = RT_NULL; app->name = RT_NULL;
app->icon = RT_NULL; app->icon = RT_NULL;
/* set EXITED so we can destroy an application that just created */ /* set EXITED so we can destroy an application that just created */
app->state_flag = RTGUI_APP_FLAG_EXITED; app->state_flag = RTGUI_APP_FLAG_EXITED;
app->ref_count = 0; app->ref_count = 0;
app->exit_code = 0; app->exit_code = 0;
app->tid = RT_NULL; app->tid = RT_NULL;
app->server = RT_NULL; app->server = RT_NULL;
app->mq = RT_NULL; app->mq = RT_NULL;
app->modal_object = RT_NULL; app->modal_object = RT_NULL;
app->main_object = RT_NULL; app->main_object = RT_NULL;
app->on_idle = RT_NULL; app->on_idle = RT_NULL;
} }
static void _rtgui_app_destructor(struct rtgui_app *app) static void _rtgui_app_destructor(struct rtgui_app *app)
{ {
RT_ASSERT(app != RT_NULL); RT_ASSERT(app != RT_NULL);
rt_free(app->name); rt_free(app->name);
app->name = RT_NULL; app->name = RT_NULL;
} }
DEFINE_CLASS_TYPE(application, "application", DEFINE_CLASS_TYPE(application, "application",
RTGUI_OBJECT_TYPE, RTGUI_OBJECT_TYPE,
_rtgui_app_constructor, _rtgui_app_constructor,
_rtgui_app_destructor, _rtgui_app_destructor,
sizeof(struct rtgui_app)); sizeof(struct rtgui_app));
struct rtgui_app* rtgui_app_create( struct rtgui_app *rtgui_app_create(
rt_thread_t tid, rt_thread_t tid,
const char *title) const char *title)
{ {
rt_thread_t srv_tid; rt_thread_t srv_tid;
struct rtgui_app *app; struct rtgui_app *app;
struct rtgui_event_application event; struct rtgui_event_application event;
RT_ASSERT(tid != RT_NULL); RT_ASSERT(tid != RT_NULL);
RT_ASSERT(title != RT_NULL); RT_ASSERT(title != RT_NULL);
/* create application */ /* create application */
app = RTGUI_APP(rtgui_object_create(RTGUI_APP_TYPE)); app = RTGUI_APP(rtgui_object_create(RTGUI_APP_TYPE));
if (app == RT_NULL) if (app == RT_NULL)
return RT_NULL; return RT_NULL;
/* one thread only can create one rtgui application */ /* one thread only can create one rtgui application */
RT_ASSERT(tid->user_data == 0); RT_ASSERT(tid->user_data == 0);
app->tid = tid; app->tid = tid;
/* set user thread */ /* set user thread */
tid->user_data = (rt_uint32_t)app; tid->user_data = (rt_uint32_t)app;
app->mq = rt_mq_create("rtgui", sizeof(union rtgui_event_generic), 32, RT_IPC_FLAG_FIFO); app->mq = rt_mq_create("rtgui", sizeof(union rtgui_event_generic), 32, RT_IPC_FLAG_FIFO);
if (app->mq == RT_NULL) if (app->mq == RT_NULL)
{ {
rt_kprintf("create msgq failed.\n"); rt_kprintf("create msgq failed.\n");
goto __mq_err; goto __mq_err;
} }
/* set application title */ /* set application title */
app->name = (unsigned char*)rt_strdup((char*)title); app->name = (unsigned char *)rt_strdup((char *)title);
if (app->name == RT_NULL) if (app->name == RT_NULL)
goto __err; goto __err;
/* send a message to notify rtgui server */ /* send a message to notify rtgui server */
srv_tid = rtgui_get_server(); srv_tid = rtgui_get_server();
if (srv_tid == RT_NULL) if (srv_tid == RT_NULL)
{ {
rt_kprintf("gui server is not running.\n"); rt_kprintf("gui server is not running.\n");
goto __err; goto __err;
} }
/* create the rtgui server application */ /* create the rtgui server application */
if (srv_tid == rt_thread_self()) if (srv_tid == rt_thread_self())
return app; return app;
RTGUI_EVENT_APP_CREATE_INIT(&event); RTGUI_EVENT_APP_CREATE_INIT(&event);
event.app = app; event.app = app;
/* notify rtgui server to one application has been created */ /* notify rtgui server to one application has been created */
if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) == RT_EOK) if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) == RT_EOK)
{ {
return app; return app;
} }
__err: __err:
__mq_err: __mq_err:
rtgui_object_destroy(RTGUI_OBJECT(app)); rtgui_object_destroy(RTGUI_OBJECT(app));
tid->user_data = 0; tid->user_data = 0;
return RT_NULL; return RT_NULL;
} }
RTM_EXPORT(rtgui_app_create); RTM_EXPORT(rtgui_app_create);
#define _rtgui_application_check(app) \ #define _rtgui_application_check(app) \
do { \ do { \
RT_ASSERT(app != RT_NULL); \ RT_ASSERT(app != RT_NULL); \
RT_ASSERT(app->tid != RT_NULL); \ RT_ASSERT(app->tid != RT_NULL); \
RT_ASSERT(app->tid->user_data != 0); \ RT_ASSERT(app->tid->user_data != 0); \
RT_ASSERT(app->mq != RT_NULL); \ RT_ASSERT(app->mq != RT_NULL); \
} while (0) } while (0)
void rtgui_app_destroy(struct rtgui_app *app) void rtgui_app_destroy(struct rtgui_app *app)
{ {
rt_thread_t srv_tid; rt_thread_t srv_tid;
_rtgui_application_check(app); _rtgui_application_check(app);
if (!(app->state_flag & RTGUI_APP_FLAG_EXITED)) if (!(app->state_flag & RTGUI_APP_FLAG_EXITED))
{ {
rt_kprintf("cannot destroy a running application: %s.\n", rt_kprintf("cannot destroy a running application: %s.\n",
app->name); app->name);
return; return;
} }
/* send a message to notify rtgui server */ /* send a message to notify rtgui server */
srv_tid = rtgui_get_server(); srv_tid = rtgui_get_server();
if (srv_tid != rt_thread_self()) /* must not the server thread */ if (srv_tid != rt_thread_self()) /* must not the server thread */
{ {
struct rtgui_event_application event; struct rtgui_event_application event;
RTGUI_EVENT_APP_DESTROY_INIT(&event); RTGUI_EVENT_APP_DESTROY_INIT(&event);
event.app = app; event.app = app;
if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) != RT_EOK) if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) != RT_EOK)
{ {
rt_kprintf("destroy an application in server failed\n"); rt_kprintf("destroy an application in server failed\n");
return ; return ;
} }
} }
app->tid->user_data = 0; app->tid->user_data = 0;
rt_mq_delete(app->mq); rt_mq_delete(app->mq);
rtgui_object_destroy(RTGUI_OBJECT(app)); rtgui_object_destroy(RTGUI_OBJECT(app));
} }
RTM_EXPORT(rtgui_app_destroy); RTM_EXPORT(rtgui_app_destroy);
struct rtgui_app* rtgui_app_self(void) struct rtgui_app *rtgui_app_self(void)
{ {
struct rtgui_app *app; struct rtgui_app *app;
rt_thread_t self; rt_thread_t self;
/* get current thread */ /* get current thread */
self = rt_thread_self(); self = rt_thread_self();
app = (struct rtgui_app*)(self->user_data); app = (struct rtgui_app *)(self->user_data);
return app; return app;
} }
RTM_EXPORT(rtgui_app_self); RTM_EXPORT(rtgui_app_self);
void rtgui_app_set_onidle(rtgui_idle_func_t onidle) void rtgui_app_set_onidle(rtgui_idle_func_t onidle)
{ {
struct rtgui_app *app; struct rtgui_app *app;
app = rtgui_app_self(); app = rtgui_app_self();
if (app != RT_NULL) if (app != RT_NULL)
app->on_idle = onidle; app->on_idle = onidle;
} }
RTM_EXPORT(rtgui_app_set_onidle); RTM_EXPORT(rtgui_app_set_onidle);
rtgui_idle_func_t rtgui_app_get_onidle(void) rtgui_idle_func_t rtgui_app_get_onidle(void)
{ {
struct rtgui_app *app; struct rtgui_app *app;
app = rtgui_app_self(); app = rtgui_app_self();
if (app != RT_NULL) if (app != RT_NULL)
return app->on_idle; return app->on_idle;
else else
return RT_NULL; return RT_NULL;
} }
RTM_EXPORT(rtgui_app_get_onidle); RTM_EXPORT(rtgui_app_get_onidle);
rt_inline rt_bool_t _rtgui_application_dest_handle( rt_inline rt_bool_t _rtgui_application_dest_handle(
struct rtgui_app *app, struct rtgui_app *app,
struct rtgui_event *event) struct rtgui_event *event)
{ {
struct rtgui_event_win* wevent = (struct rtgui_event_win*)event; struct rtgui_event_win *wevent = (struct rtgui_event_win *)event;
struct rtgui_object* dest_object = RTGUI_OBJECT(wevent->wid); struct rtgui_object *dest_object = RTGUI_OBJECT(wevent->wid);
if (dest_object != RT_NULL) if (dest_object != RT_NULL)
{ {
if (dest_object->event_handler != RT_NULL) if (dest_object->event_handler != RT_NULL)
return dest_object->event_handler(RTGUI_OBJECT(dest_object), event); return dest_object->event_handler(RTGUI_OBJECT(dest_object), event);
else else
return RT_FALSE; return RT_FALSE;
} }
else else
{ {
rt_kprintf("RTGUI ERROR:server sent a event(%d) without wid\n", event->type); rt_kprintf("RTGUI ERROR:server sent a event(%d) without wid\n", event->type);
return RT_FALSE; return RT_FALSE;
} }
} }
rt_bool_t rtgui_app_event_handler(struct rtgui_object* object, rtgui_event_t* event) rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *event)
{ {
struct rtgui_app* app; struct rtgui_app *app;
RT_ASSERT(object != RT_NULL); RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL); RT_ASSERT(event != RT_NULL);
app = RTGUI_APP(object); app = RTGUI_APP(object);
switch (event->type) switch (event->type)
{ {
case RTGUI_EVENT_PAINT: case RTGUI_EVENT_PAINT:
case RTGUI_EVENT_CLIP_INFO: case RTGUI_EVENT_CLIP_INFO:
case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_ACTIVATE:
case RTGUI_EVENT_WIN_DEACTIVATE: case RTGUI_EVENT_WIN_DEACTIVATE:
case RTGUI_EVENT_WIN_CLOSE: case RTGUI_EVENT_WIN_CLOSE:
case RTGUI_EVENT_WIN_MOVE: case RTGUI_EVENT_WIN_MOVE:
case RTGUI_EVENT_KBD: case RTGUI_EVENT_KBD:
_rtgui_application_dest_handle(app, event); _rtgui_application_dest_handle(app, event);
break; break;
case RTGUI_EVENT_APP_ACTIVATE: case RTGUI_EVENT_APP_ACTIVATE:
if (app->main_object != RT_NULL) if (app->main_object != RT_NULL)
{
rtgui_win_activate(RTGUI_WIN(app->main_object));
if (app->modal_object != RT_NULL)
rtgui_win_activate(RTGUI_WIN(app->modal_object));
}
else if (app->modal_object != RT_NULL)
{
rtgui_win_activate(RTGUI_WIN(app->modal_object));
}
break;
case RTGUI_EVENT_APP_DESTROY:
rtgui_app_exit(app, 0);
break;
case RTGUI_EVENT_MOUSE_BUTTON:
case RTGUI_EVENT_MOUSE_MOTION:
{
struct rtgui_event_win* wevent = (struct rtgui_event_win*)event;
struct rtgui_object* dest_object = RTGUI_OBJECT(wevent->wid);
// FIXME: let application determine the dest_wiget but not in sever
// so we can combine this handler with above one
if (app->modal_object != RT_NULL &&
dest_object != app->modal_object)
{
// rt_kprintf("discard event %s that is not sent to modal object\n",
// event_string[event->type]);
}
else
{
_rtgui_application_dest_handle(app, event);
}
}
break;
case RTGUI_EVENT_TIMER:
{
struct rtgui_timer* timer;
struct rtgui_event_timer* etimer = (struct rtgui_event_timer*) event;
timer = etimer->timer;
if (timer->timeout != RT_NULL)
{
/* call timeout function */
timer->timeout(timer, timer->user_data);
}
}
break;
case RTGUI_EVENT_COMMAND:
{ {
struct rtgui_event_command *ecmd = (struct rtgui_event_command*)event; rtgui_win_activate(RTGUI_WIN(app->main_object));
if (app->modal_object != RT_NULL)
if (ecmd->wid != RT_NULL) rtgui_win_activate(RTGUI_WIN(app->modal_object));
return _rtgui_application_dest_handle(app, event);
} }
} else if (app->modal_object != RT_NULL)
{
rtgui_win_activate(RTGUI_WIN(app->modal_object));
}
break;
return rtgui_object_event_handler(object, event); case RTGUI_EVENT_APP_DESTROY:
rtgui_app_exit(app, 0);
break;
case RTGUI_EVENT_MOUSE_BUTTON:
case RTGUI_EVENT_MOUSE_MOTION:
{
struct rtgui_event_win *wevent = (struct rtgui_event_win *)event;
struct rtgui_object *dest_object = RTGUI_OBJECT(wevent->wid);
// FIXME: let application determine the dest_wiget but not in sever
// so we can combine this handler with above one
if (app->modal_object != RT_NULL &&
dest_object != app->modal_object)
{
// rt_kprintf("discard event %s that is not sent to modal object\n",
// event_string[event->type]);
}
else
{
_rtgui_application_dest_handle(app, event);
}
}
break;
case RTGUI_EVENT_TIMER:
{
struct rtgui_timer *timer;
struct rtgui_event_timer *etimer = (struct rtgui_event_timer *) event;
timer = etimer->timer;
if (timer->timeout != RT_NULL)
{
/* call timeout function */
timer->timeout(timer, timer->user_data);
}
}
break;
case RTGUI_EVENT_MV_MODEL:
{
struct rtgui_event_mv_model *emodel = (struct rtgui_event_mv_model *)event;
RT_ASSERT(emodel->view);
return rtgui_object_handle(RTGUI_OBJECT(emodel->view), event);
}
case RTGUI_EVENT_COMMAND:
{
struct rtgui_event_command *ecmd = (struct rtgui_event_command *)event;
if (ecmd->wid != RT_NULL)
return _rtgui_application_dest_handle(app, event);
}
default:
return rtgui_object_event_handler(object, event);
}
return RT_TRUE;
} }
rt_inline void _rtgui_application_event_loop(struct rtgui_app *app) rt_inline void _rtgui_application_event_loop(struct rtgui_app *app)
{ {
rt_err_t result; rt_err_t result;
rt_uint16_t current_ref; rt_uint16_t current_ref;
struct rtgui_event *event; struct rtgui_event *event;
_rtgui_application_check(app); _rtgui_application_check(app);
/* point to event buffer */ /* point to event buffer */
event = (struct rtgui_event*)app->event_buffer; event = (struct rtgui_event *)app->event_buffer;
current_ref = ++app->ref_count; current_ref = ++app->ref_count;
while (current_ref <= app->ref_count) while (current_ref <= app->ref_count)
{ {
RT_ASSERT(current_ref == app->ref_count); RT_ASSERT(current_ref == app->ref_count);
if (app->on_idle != RT_NULL) if (app->on_idle != RT_NULL)
{ {
result = rtgui_recv_nosuspend(event, sizeof(union rtgui_event_generic)); result = rtgui_recv_nosuspend(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK) if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event); RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
else if (result == -RT_ETIMEOUT) else if (result == -RT_ETIMEOUT)
app->on_idle(RTGUI_OBJECT(app), RT_NULL); app->on_idle(RTGUI_OBJECT(app), RT_NULL);
} }
else else
{ {
result = rtgui_recv(event, sizeof(union rtgui_event_generic)); result = rtgui_recv(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK) if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event); RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
} }
} }
} }
rt_base_t rtgui_app_run(struct rtgui_app *app) rt_base_t rtgui_app_run(struct rtgui_app *app)
{ {
_rtgui_application_check(app); _rtgui_application_check(app);
app->state_flag &= ~RTGUI_APP_FLAG_EXITED; app->state_flag &= ~RTGUI_APP_FLAG_EXITED;
_rtgui_application_event_loop(app); _rtgui_application_event_loop(app);
if (app->ref_count == 0) if (app->ref_count == 0)
app->state_flag |= RTGUI_APP_FLAG_EXITED; app->state_flag |= RTGUI_APP_FLAG_EXITED;
return app->exit_code; return app->exit_code;
} }
RTM_EXPORT(rtgui_app_run); RTM_EXPORT(rtgui_app_run);
void rtgui_app_exit(struct rtgui_app* app, rt_uint16_t code) void rtgui_app_exit(struct rtgui_app *app, rt_uint16_t code)
{ {
--app->ref_count; --app->ref_count;
app->exit_code = code; app->exit_code = code;
} }
RTM_EXPORT(rtgui_app_exit); RTM_EXPORT(rtgui_app_exit);
void rtgui_app_activate(struct rtgui_app *app) void rtgui_app_activate(struct rtgui_app *app)
{ {
struct rtgui_event_application event; struct rtgui_event_application event;
RTGUI_EVENT_APP_ACTIVATE_INIT(&event); RTGUI_EVENT_APP_ACTIVATE_INIT(&event);
event.app = app; event.app = app;
rtgui_send(app->tid, RTGUI_EVENT(&event), sizeof(struct rtgui_event_application)); rtgui_send(app->tid, RTGUI_EVENT(&event), sizeof(struct rtgui_event_application));
} }
RTM_EXPORT(rtgui_app_activate); RTM_EXPORT(rtgui_app_activate);
void rtgui_app_close(struct rtgui_app *app) void rtgui_app_close(struct rtgui_app *app)
{ {
struct rtgui_event_application event; struct rtgui_event_application event;
RTGUI_EVENT_APP_DESTROY_INIT(&event); RTGUI_EVENT_APP_DESTROY_INIT(&event);
event.app = app; event.app = app;
rtgui_send(app->tid, RTGUI_EVENT(&event), sizeof(struct rtgui_event_application)); rtgui_send(app->tid, RTGUI_EVENT(&event), sizeof(struct rtgui_event_application));
} }
RTM_EXPORT(rtgui_app_close); RTM_EXPORT(rtgui_app_close);
@ -380,35 +389,35 @@ RTM_EXPORT(rtgui_app_close);
*/ */
rt_err_t rtgui_app_set_as_wm(void) rt_err_t rtgui_app_set_as_wm(void)
{ {
rt_thread_t srv_tid; rt_thread_t srv_tid;
struct rtgui_event_set_wm event; struct rtgui_event_set_wm event;
struct rtgui_app* app; struct rtgui_app *app;
srv_tid = rtgui_get_server(); srv_tid = rtgui_get_server();
app = rtgui_app_self(); app = rtgui_app_self();
if (app != RT_NULL && srv_tid != RT_NULL) if (app != RT_NULL && srv_tid != RT_NULL)
{ {
/* notify rtgui server, this is a window manager */ /* notify rtgui server, this is a window manager */
RTGUI_EVENT_SET_WM_INIT(&event); RTGUI_EVENT_SET_WM_INIT(&event);
event.app = app; event.app = app;
rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)); rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event));
return RT_EOK; return RT_EOK;
} }
return RT_ERROR; return RT_ERROR;
} }
RTM_EXPORT(rtgui_app_set_as_wm); RTM_EXPORT(rtgui_app_set_as_wm);
void rtgui_app_set_main_win(struct rtgui_win* win) void rtgui_app_set_main_win(struct rtgui_win *win)
{ {
struct rtgui_app *app; struct rtgui_app *app;
app = rtgui_app_self(); app = rtgui_app_self();
if (app != RT_NULL) if (app != RT_NULL)
{ {
app->main_object = RTGUI_OBJECT(win); app->main_object = RTGUI_OBJECT(win);
} }
} }
RTM_EXPORT(rtgui_app_set_main_win); RTM_EXPORT(rtgui_app_set_main_win);

View File

@ -0,0 +1,454 @@
/*
* File : rtgui_mv_model.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-09-15 Grissiom first version
*/
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_app.h>
#include <rtgui/rtgui_object.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/rtgui_mv_model.h>
#include <rtgui/widgets/mv_view.h>
#include <rtgui/widgets/window.h>
static void _rtgui_mv_model_bare_remove(struct rtgui_mv_model *model, struct rtgui_mv_view *view);
static void _rtgui_mv_view_bare_remove(struct rtgui_mv_view *view, struct rtgui_mv_model *model);
static rt_bool_t _rtgui_mv_model_notify_view(struct rtgui_mv_model *model,
struct rtgui_mv_view *view,
struct rtgui_event_mv_model *emodel);
static void _rtgui_mv_model_constructor(struct rtgui_mv_model *model)
{
model->dimension = 0;
model->length = 0;
model->data = RT_NULL;
model->view_number = 0;
model->view = RT_NULL;
/* currently not interested in any event */
rtgui_object_set_event_handler(RTGUI_OBJECT(model), RT_NULL);
}
static void _rtgui_mv_model_destructor(struct rtgui_mv_model *model)
{
if (model->view_number == 1)
{
rtgui_mv_model_remove_view(model, model->view);
}
else if (model->view_number > 1)
{
int i;
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
for (i = 0; i < model->view_number; i++)
{
rtgui_mv_model_remove_view(model, view_arr[i]);
}
}
if (model->dimension > 1)
rtgui_free(model->data);
}
DEFINE_CLASS_TYPE(mv_model, "mv_model",
RTGUI_OBJECT_TYPE,
_rtgui_mv_model_constructor,
_rtgui_mv_model_destructor,
sizeof(struct rtgui_mv_model));
struct rtgui_mv_model *rtgui_mv_model_create(rt_uint16_t dimension)
{
struct rtgui_mv_model *model;
RT_ASSERT(dimension);
model = RTGUI_MV_MODEL(rtgui_object_create(RTGUI_MV_MODEL_TYPE));
if (model == RT_NULL)
return RT_NULL;
if (rtgui_mv_model_set_dimension(model, dimension) != RT_EOK)
{
rtgui_object_destroy(RTGUI_OBJECT(model));
return RT_NULL;
}
return model;
}
RTM_EXPORT(rtgui_mv_model_create);
rt_err_t rtgui_mv_model_set_dimension(struct rtgui_mv_model *model, rt_uint16_t dimension)
{
if (dimension == 1)
{
if (model->dimension > 1)
rtgui_free(model->data);
model->data = RT_NULL;
}
else
{
void *data;
if (model->dimension > 1)
rtgui_free(model->data);
data = rtgui_malloc(sizeof(void *)*dimension);
if (data == RT_NULL)
{
return -RT_ENOMEM;
}
rt_memset(data, 0, sizeof(void *)*dimension);
model->data = data;
}
model->dimension = dimension;
return RT_EOK;
}
RTM_EXPORT(rtgui_mv_model_set_dimension);
void rtgui_mv_model_destroy(struct rtgui_mv_model *model)
{
rtgui_object_destroy(RTGUI_OBJECT(model));
}
RTM_EXPORT(rtgui_mv_model_destroy);
rt_err_t rtgui_mv_model_add_view(struct rtgui_mv_model *model, struct rtgui_mv_view *view)
{
RT_ASSERT(model);
if (view == RT_NULL)
return RT_EOK;
/* add view to model */
if (model->view_number == 0)
{
model->view = view;
}
else if (model->view_number == 1)
{
/* create the array of view pointers */
struct rtgui_mv_view **new_view;
if (view == model->view)
return RT_EOK;
new_view = rtgui_malloc(2 * sizeof(struct rtgui_mv_view *));
if (new_view == RT_NULL)
return -RT_ENOMEM;
new_view[0] = model->view;
new_view[1] = view;
model->view = new_view;
}
else
{
int i;
struct rtgui_mv_view **new_view;
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
for (i = 0; i < model->view_number; i++)
{
if (view == view_arr[i])
return RT_EOK;
}
new_view = rtgui_realloc(model->view,
(model->view_number + 1) * sizeof(struct rtgui_mv_view *));
if (new_view == RT_NULL)
return -RT_ENOMEM;
new_view[model->view_number] = view;
model->view = new_view;
}
model->view_number++;
/* add model to view. Roll back previous action on fail. */
if (view->model_number == 0)
{
view->model = model;
}
else if (view->model_number == 1)
{
struct rtgui_mv_model **new_arr = rtgui_malloc(2 * sizeof(struct rtgui_mv_model *));
if (new_arr == RT_NULL)
{
_rtgui_mv_model_bare_remove(model, view);
return -RT_ENOMEM;
}
new_arr[0] = view->model;
new_arr[1] = model;
view->model = new_arr;
}
else
{
struct rtgui_mv_model **new_arr = rtgui_realloc(view->model,
(view->model_number + 1) * sizeof(struct rtgui_mv_model *));
if (new_arr == RT_NULL)
{
_rtgui_mv_model_bare_remove(model, view);
return -RT_ENOMEM;
}
new_arr[view->model_number] = model;
view->model = new_arr;
}
view->model_number++;
return RT_EOK;
}
RTM_EXPORT(rtgui_mv_model_add_view);
static void _rtgui_mv_model_bare_remove(struct rtgui_mv_model *model, struct rtgui_mv_view *view)
{
int i;
if (model->view_number == 1)
{
if (model->view == view)
{
model->view_number--;
model->view = RT_NULL;
}
return;
}
for (i = 0; i < model->view_number; i++)
{
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
if (view == view_arr[i])
break;
}
/* no match */
if (i == model->view_number)
{
return;
}
else if (model->view_number == 2)
{
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
struct rtgui_mv_view *the_view = view_arr[(i + 1) % 2];
rtgui_free(model->view);
model->view = the_view;
model->view_number--;
return;
}
else
{
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
void *new_view;
for (; i < model->view_number - 1; i++)
{
view_arr[i] = view_arr[i + 1];
}
new_view = rtgui_realloc(model->view,
(model->view_number - 1) * sizeof(struct rtgui_mv_view *));
/* no need to be panic on OOM error. The original array is still there
* and we can operate it safely. So just ignore the NULL value returned
* by realloc. */
if (new_view != RT_NULL)
model->view = new_view;
model->view_number--;
return;
}
}
static void _rtgui_mv_view_bare_remove(struct rtgui_mv_view *view, struct rtgui_mv_model *model)
{
int i;
struct rtgui_mv_model **model_arr = (struct rtgui_mv_model **)(view)->model;
if (view->model_number == 1)
{
if (view->model == model)
{
view->model_number--;
view->model = RT_NULL;
}
return;
}
for (i = 0; i < view->model_number; i++)
{
if (model == model_arr[i])
break;
}
/* no match */
if (i == view->model_number)
{
return;
}
else if (view->model_number == 2)
{
struct rtgui_mv_model **model_arr = (struct rtgui_mv_model **)(view)->model;
struct rtgui_mv_model *the_model = model_arr[(i + 1) % 2];
rtgui_free(view->model);
view->model = the_model;
view->model_number--;
return;
}
else
{
struct rtgui_mv_model **model_arr = (struct rtgui_mv_model **)(view)->model;
void *new_model;
for (; i < view->model_number - 1; i++)
{
model_arr[i] = model_arr[i + 1];
}
new_model = rtgui_realloc(view->model,
(view->model_number - 1) * sizeof(struct rtgui_mv_model *));
/* no need to be panic on OOM error. The original array is still there
* and we can operate it safely. So just ignore the NULL value returned
* by realloc. */
if (new_model != RT_NULL)
view->model = new_model;
view->model_number--;
return;
}
}
void rtgui_mv_model_remove_view(struct rtgui_mv_model *model, struct rtgui_mv_view *view)
{
RT_ASSERT(model);
if (view == RT_NULL)
return;
if (model->length > 0)
{
struct rtgui_event_mv_model emodel;
RTGUI_EVENT_MV_MODEL_DELETED_INIT(&emodel);
emodel.first_data_changed_idx = 0;
emodel.last_data_changed_idx = model->length;
/* rtgui_mv_model_remove_view is to be called in thread context.
* Besides, it is called by _rtgui_mv_view_destructor which means the
* view will be invalid in the future. So we should call the event
* handler immediately. */
RTGUI_OBJECT(view)->event_handler(RTGUI_OBJECT(view), (struct rtgui_event *)&emodel);
}
_rtgui_mv_model_bare_remove(model, view);
_rtgui_mv_view_bare_remove(view, model);
}
RTM_EXPORT(rtgui_mv_model_remove_view);
rt_bool_t rtgui_mv_model_has_view(struct rtgui_mv_model *model, struct rtgui_mv_view *view)
{
RT_ASSERT(model);
if (view == RT_NULL || model->view_number == 0)
return RT_FALSE;
if (model->view_number == 1)
{
return model->view == view;
}
else
{
int i;
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
for (i = 0; i < model->view_number; i++)
{
if (view == view_arr[i])
return RT_TRUE;
}
return RT_FALSE;
}
}
RTM_EXPORT(rtgui_mv_model_has_view);
void rtgui_mv_model_set_data(struct rtgui_mv_model *model, rt_uint16_t dim, void *p)
{
RT_ASSERT(model);
RT_ASSERT(dim < model->dimension);
if (model->dimension == 1)
{
model->data = p;
return;
}
else
{
void **d_arr = (void **)model->data;
d_arr[dim] = p;
}
}
RTM_EXPORT(rtgui_mv_model_set_data);
void *rtgui_mv_model_get_data(struct rtgui_mv_model *model, rt_uint16_t dim)
{
RT_ASSERT(model);
RT_ASSERT(dim < model->dimension);
if (model->dimension == 1)
{
return model->data;
}
else
{
void **d_arr = (void **)model->data;
return d_arr[dim];
}
}
RTM_EXPORT(rtgui_mv_model_get_data);
static rt_bool_t _rtgui_mv_model_notify_view(struct rtgui_mv_model *model,
struct rtgui_mv_view *view,
struct rtgui_event_mv_model *emodel)
{
rt_thread_t target = RTGUI_WIDGET(view)->toplevel->app->tid;
emodel->model = model;
emodel->view = view;
return rtgui_send(target, (struct rtgui_event *)emodel, sizeof(*emodel));
}
void rtgui_mv_model_notify(struct rtgui_mv_model *model,
struct rtgui_event_mv_model *em)
{
/* model and view may not be in the same thread. Actually, model may not
* belong to any RTGUI thread. So we have to notify the views by sending
* events to the thread directly. */
if (model->view_number == 1)
{
struct rtgui_mv_view *view = (struct rtgui_mv_view *)model->view;
_rtgui_mv_model_notify_view(model, view, em);
}
else
{
int i;
struct rtgui_mv_view **view_arr = (struct rtgui_mv_view **)(model)->view;
for (i = 0; i < model->view_number; i++)
{
_rtgui_mv_model_notify_view(model, view_arr[i], em);
}
}
}
RTM_EXPORT(rtgui_mv_model_notify);

View File

@ -17,185 +17,191 @@
static void _rtgui_object_constructor(rtgui_object_t *object) static void _rtgui_object_constructor(rtgui_object_t *object)
{ {
if (!object) if (!object)
return; return;
object->flag = RTGUI_OBJECT_FLAG_NONE; object->flag = RTGUI_OBJECT_FLAG_NONE;
} }
/* Destroys the object */ /* Destroys the object */
static void _rtgui_object_destructor(rtgui_object_t *object) static void _rtgui_object_destructor(rtgui_object_t *object)
{ {
/* nothing */ /* nothing */
} }
DEFINE_CLASS_TYPE(object, "object", DEFINE_CLASS_TYPE(object, "object",
RT_NULL, RT_NULL,
_rtgui_object_constructor, _rtgui_object_constructor,
_rtgui_object_destructor, _rtgui_object_destructor,
sizeof(struct rtgui_object)); sizeof(struct rtgui_object));
RTM_EXPORT(_rtgui_object); RTM_EXPORT(_rtgui_object);
void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object) void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object)
{ {
/* first call parent's type */ /* first call parent's type */
if (type->parent != RT_NULL) if (type->parent != RT_NULL)
rtgui_type_object_construct(type->parent, object); rtgui_type_object_construct(type->parent, object);
if (type->constructor) type->constructor(object); if (type->constructor) type->constructor(object);
} }
void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object) void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object)
{ {
const rtgui_type_t *t; const rtgui_type_t *t;
t = type; t = type;
while (t) while (t)
{ {
if (t->destructor) t->destructor(object); if (t->destructor) t->destructor(object);
t = t->parent; t = t->parent;
} }
} }
rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent) rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent)
{ {
const rtgui_type_t *t; const rtgui_type_t *t;
t = type;
while (t)
{
if (t == parent) return RT_TRUE;
t = t->parent;
}
return RT_FALSE; t = type;
while (t)
{
if (t == parent) return RT_TRUE;
t = t->parent;
}
return RT_FALSE;
} }
const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type) const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type)
{ {
return type->parent; return type->parent;
} }
const char *rtgui_type_name_get(const rtgui_type_t *type) const char *rtgui_type_name_get(const rtgui_type_t *type)
{ {
if (!type) return RT_NULL; if (!type) return RT_NULL;
return type->name; return type->name;
} }
#ifdef RTGUI_OBJECT_TRACE #ifdef RTGUI_OBJECT_TRACE
struct rtgui_object_information struct rtgui_object_information
{ {
rt_uint32_t objs_number; rt_uint32_t objs_number;
rt_uint32_t allocated_size; rt_uint32_t allocated_size;
rt_uint32_t max_allocated; rt_uint32_t max_allocated;
}; };
struct rtgui_object_information obj_info = {0, 0, 0}; struct rtgui_object_information obj_info = {0, 0, 0};
#endif #endif
/** /**
* @brief Creates a new object: it calls the corresponding constructors (from the constructor of the base class to the * @brief Creates a new object: it calls the corresponding constructors
* constructor of the more derived class) and then sets the values of the given properties * (from the constructor of the base class to the constructor of the more
* derived class) and then sets the values of the given properties
*
* @param object_type the type of object to create * @param object_type the type of object to create
* @return Returns the new Etk_Object of type @a object_type * @return the created object
*/ */
rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type) rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type)
{ {
rtgui_object_t *new_object; rtgui_object_t *new_object;
if (!object_type) if (!object_type)
return RT_NULL; return RT_NULL;
new_object = rtgui_malloc(object_type->size); new_object = rtgui_malloc(object_type->size);
if (new_object == RT_NULL) return RT_NULL; if (new_object == RT_NULL) return RT_NULL;
#ifdef RTGUI_OBJECT_TRACE #ifdef RTGUI_OBJECT_TRACE
obj_info.objs_number ++; obj_info.objs_number ++;
obj_info.allocated_size += object_type->size; obj_info.allocated_size += object_type->size;
if (obj_info.allocated_size > obj_info.max_allocated) if (obj_info.allocated_size > obj_info.max_allocated)
obj_info.max_allocated = obj_info.allocated_size; obj_info.max_allocated = obj_info.allocated_size;
#endif #endif
new_object->type = object_type; new_object->type = object_type;
rtgui_type_object_construct(object_type, new_object); rtgui_type_object_construct(object_type, new_object);
return new_object; return new_object;
} }
RTM_EXPORT(rtgui_object_create); RTM_EXPORT(rtgui_object_create);
/** /**
* @brief Destroys the object: it first sets the weak-pointers to RT_NULL, emits the "destroyed" signal, and then * @brief Destroys the object.
* queues the object in the list of objects to free. Thus, the destructors will only be called at the beginning of the *
* next main loop iteration (from the destructor of the more derived class to the destructor of the ultimate base class). * The object destructors will be called in inherited type order.
*
* @param object the object to destroy * @param object the object to destroy
* @warning You should not assume that this function will call directly the destructors of the object!
*/ */
void rtgui_object_destroy(rtgui_object_t *object) void rtgui_object_destroy(rtgui_object_t *object)
{ {
if (!object || object->flag & RTGUI_OBJECT_FLAG_STATIC) if (!object || object->flag & RTGUI_OBJECT_FLAG_STATIC)
return; return;
#ifdef RTGUI_OBJECT_TRACE #ifdef RTGUI_OBJECT_TRACE
obj_info.objs_number --; obj_info.objs_number --;
obj_info.allocated_size -= object->type->size; obj_info.allocated_size -= object->type->size;
#endif #endif
/* call destructor */ /* call destructor */
RT_ASSERT(object->type != RT_NULL); RT_ASSERT(object->type != RT_NULL);
rtgui_type_destructors_call(object->type, object); rtgui_type_destructors_call(object->type, object);
/* release object */ /* release object */
rtgui_free(object); rtgui_free(object);
} }
RTM_EXPORT(rtgui_object_destroy); RTM_EXPORT(rtgui_object_destroy);
/** /**
* @brief Checks if @a object can be cast to @a type. * @brief Checks if the object can be cast to the specified type.
* If @a object doesn't inherit from @a type, a warning is displayed in the console but the object is returned anyway. *
* If the object doesn't inherit from the specified type, a warning
* is displayed in the console but the object is returned anyway.
*
* @param object the object to cast * @param object the object to cast
* @param type the type to which we cast the object * @param type the type to which we cast the object
* @return Returns the object * @return Returns the object
* @note You usually do not need to call this function, use specific macros instead (ETK_IS_WIDGET() for example)
*/ */
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_type, const char* func, int line) rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_type, const char *func, int line)
{ {
if (!obj) return RT_NULL; if (!obj) return RT_NULL;
if (!rtgui_type_inherits_from(obj->type, obj_type)) if (!rtgui_type_inherits_from(obj->type, obj_type))
{ {
rt_kprintf("%s[%d]: Invalid cast from \"%s\" to \"%s\"\n", func, line, rtgui_type_name_get(obj->type), rtgui_type_name_get(obj_type)); rt_kprintf("%s[%d]: Invalid cast from \"%s\" to \"%s\"\n", func, line,
rtgui_type_name_get(obj->type), rtgui_type_name_get(obj_type));
} }
return obj; return obj;
} }
RTM_EXPORT(rtgui_object_check_cast); RTM_EXPORT(rtgui_object_check_cast);
/** /**
* @brief Gets the type of the object * @brief Gets the type of the object
*
* @param object an object * @param object an object
* @return Returns the type of @a object (RT_NULL on failure) * @return the type of the object (RT_NULL on failure)
*/ */
const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object) const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object)
{ {
if (!object) return RT_NULL; if (!object) return RT_NULL;
return object->type; return object->type;
} }
RTM_EXPORT(rtgui_object_object_type_get); RTM_EXPORT(rtgui_object_object_type_get);
void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler) void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler)
{ {
RT_ASSERT(object != RT_NULL); RT_ASSERT(object != RT_NULL);
object->event_handler = handler; object->event_handler = handler;
} }
RTM_EXPORT(rtgui_object_set_event_handler); RTM_EXPORT(rtgui_object_set_event_handler);
rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event* event) rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event *event)
{ {
return RT_FALSE; return RT_FALSE;
} }
RTM_EXPORT(rtgui_object_event_handler); RTM_EXPORT(rtgui_object_event_handler);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,290 +2,293 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
/* Internal states that the parser can be in at any given time. */ /* Internal states that the parser can be in at any given time. */
enum { enum
STAT_START = 0, /* starting base state, default state */ {
STAT_TEXT, /* text state */ STAT_START = 0, /* starting base state, default state */
STAT_START_TAG, /* start tag state */ STAT_TEXT, /* text state */
STAT_START_TAGNAME, /* start tagname state */ STAT_START_TAG, /* start tag state */
STAT_START_TAGNAME_END, /* start tagname ending state */ STAT_START_TAGNAME, /* start tagname state */
STAT_END_TAG, /* end tag state */ STAT_START_TAGNAME_END, /* start tagname ending state */
STAT_END_TAGNAME, /* end tag tagname state */ STAT_END_TAG, /* end tag state */
STAT_END_TAGNAME_END, /* end tag tagname ending */ STAT_END_TAGNAME, /* end tag tagname state */
STAT_EMPTY_TAG, /* empty tag state */ STAT_END_TAGNAME_END, /* end tag tagname ending */
STAT_SPACE, /* linear whitespace state */ STAT_EMPTY_TAG, /* empty tag state */
STAT_ATTR_NAME, /* attribute name state */ STAT_SPACE, /* linear whitespace state */
STAT_ATTR_NAME_END, /* attribute name ending state */ STAT_ATTR_NAME, /* attribute name state */
STAT_ATTR_VAL, /* attribute value starting state */ STAT_ATTR_NAME_END, /* attribute name ending state */
STAT_ATTR_VAL2, /* attribute value state */ STAT_ATTR_VAL, /* attribute value starting state */
STAT_ERROR /* error state */ STAT_ATTR_VAL2, /* attribute value state */
STAT_ERROR /* error state */
}; };
/* character classes that we will match against; This could be expanded if /* character classes that we will match against; This could be expanded if
need be, however, we are aiming for simple. */ need be, however, we are aiming for simple. */
enum { enum
CLASS_TYPE_NONE = 0, /* matches nothing, a base state */ {
CLASS_TYPE_LEFT_ANGLE, /* matches start tag '<' */ CLASS_TYPE_NONE = 0, /* matches nothing, a base state */
CLASS_TYPE_SLASH, /* matches forward slash */ CLASS_TYPE_LEFT_ANGLE, /* matches start tag '<' */
CLASS_TYPE_RIGHT_ANGLE, /* matches end tag '>' */ CLASS_TYPE_SLASH, /* matches forward slash */
CLASS_TYPE_EQUALS, /* matches equals sign */ CLASS_TYPE_RIGHT_ANGLE, /* matches end tag '>' */
CLASS_TYPE_QUOTE, /* matches double-quotes */ CLASS_TYPE_EQUALS, /* matches equals sign */
CLASS_TYPE_LETTERS, /* matches a-zA-Z letters and digits 0-9 */ CLASS_TYPE_QUOTE, /* matches double-quotes */
CLASS_TYPE_SPACE, /* matches whitespace */ CLASS_TYPE_LETTERS, /* matches a-zA-Z letters and digits 0-9 */
CLASS_TYPE_ANY /* matches any ASCII character; will match all CLASS_TYPE_SPACE, /* matches whitespace */
above classes */ CLASS_TYPE_ANY /* matches any ASCII character; will match all
above classes */
}; };
/* xml state transition table */ /* xml state transition table */
struct rtgui_xml_state struct rtgui_xml_state
{ {
rt_uint8_t state; rt_uint8_t state;
rt_uint8_t class_type; rt_uint8_t class_type;
rt_uint8_t next_state; rt_uint8_t next_state;
rt_uint8_t event; rt_uint8_t event;
}; };
/* Note: States must be grouped in match order AND grouped together! */ /* Note: States must be grouped in match order AND grouped together! */
static const struct rtgui_xml_state RTGUI_XML_STATES [] = { static const struct rtgui_xml_state RTGUI_XML_STATES [] =
/* [0-2] starting state, which also serves as the default state in case {
of error */ /* [0-2] starting state, which also serves as the default state in case
{ STAT_START, CLASS_TYPE_SPACE, STAT_SPACE, EVENT_NONE }, of error */
{ STAT_START, CLASS_TYPE_LEFT_ANGLE, STAT_START_TAG, EVENT_NONE }, { STAT_START, CLASS_TYPE_SPACE, STAT_SPACE, EVENT_NONE },
{ STAT_START, CLASS_TYPE_ANY, STAT_TEXT, EVENT_COPY }, { STAT_START, CLASS_TYPE_LEFT_ANGLE, STAT_START_TAG, EVENT_NONE },
{ STAT_START, CLASS_TYPE_ANY, STAT_TEXT, EVENT_COPY },
/* [3-5] space state handles linear white space */ /* [3-5] space state handles linear white space */
{ STAT_SPACE, CLASS_TYPE_SPACE, STAT_SPACE, EVENT_NONE }, { STAT_SPACE, CLASS_TYPE_SPACE, STAT_SPACE, EVENT_NONE },
{ STAT_SPACE, CLASS_TYPE_LEFT_ANGLE, STAT_START_TAG, EVENT_TEXT }, { STAT_SPACE, CLASS_TYPE_LEFT_ANGLE, STAT_START_TAG, EVENT_TEXT },
{ STAT_SPACE, CLASS_TYPE_ANY, STAT_TEXT, EVENT_COPY }, { STAT_SPACE, CLASS_TYPE_ANY, STAT_TEXT, EVENT_COPY },
/* [6-8] handle start tag */ /* [6-8] handle start tag */
{ STAT_START_TAG, CLASS_TYPE_LETTERS, STAT_START_TAGNAME, EVENT_COPY }, { STAT_START_TAG, CLASS_TYPE_LETTERS, STAT_START_TAGNAME, EVENT_COPY },
{ STAT_START_TAG, CLASS_TYPE_SLASH, STAT_END_TAG, EVENT_COPY }, { STAT_START_TAG, CLASS_TYPE_SLASH, STAT_END_TAG, EVENT_COPY },
/* below added since some individuals get a little carried away with /* below added since some individuals get a little carried away with
spacing around tag names, e.g. < tag > */ spacing around tag names, e.g. < tag > */
{ STAT_START_TAG, CLASS_TYPE_SPACE, STAT_START_TAG, EVENT_NONE }, { STAT_START_TAG, CLASS_TYPE_SPACE, STAT_START_TAG, EVENT_NONE },
/* [9-12] handle start tag name */ /* [9-12] handle start tag name */
{ STAT_START_TAGNAME, CLASS_TYPE_LETTERS, STAT_START_TAGNAME, EVENT_NONE }, { STAT_START_TAGNAME, CLASS_TYPE_LETTERS, STAT_START_TAGNAME, EVENT_NONE },
{ STAT_START_TAGNAME, CLASS_TYPE_SPACE, STAT_START_TAGNAME_END, EVENT_START }, { STAT_START_TAGNAME, CLASS_TYPE_SPACE, STAT_START_TAGNAME_END, EVENT_START },
/* below added for tags without any space between tag and ending /* below added for tags without any space between tag and ending
slash, e.g., <br/> */ slash, e.g., <br/> */
{ STAT_START_TAGNAME, CLASS_TYPE_SLASH, STAT_EMPTY_TAG, EVENT_END }, { STAT_START_TAGNAME, CLASS_TYPE_SLASH, STAT_EMPTY_TAG, EVENT_END },
{ STAT_START_TAGNAME, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_START }, { STAT_START_TAGNAME, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_START },
/* [13-16] handle start tag name end */ /* [13-16] handle start tag name end */
{ STAT_START_TAGNAME_END, CLASS_TYPE_LETTERS, STAT_ATTR_NAME, EVENT_COPY }, { STAT_START_TAGNAME_END, CLASS_TYPE_LETTERS, STAT_ATTR_NAME, EVENT_COPY },
/* below added to handle additional space in between attribute value /* below added to handle additional space in between attribute value
pairs in start tags, e.g., <tag attr="2" attr2="test" > */ pairs in start tags, e.g., <tag attr="2" attr2="test" > */
{ STAT_START_TAGNAME_END, CLASS_TYPE_SPACE, STAT_START_TAGNAME_END, EVENT_NONE }, { STAT_START_TAGNAME_END, CLASS_TYPE_SPACE, STAT_START_TAGNAME_END, EVENT_NONE },
{ STAT_START_TAGNAME_END, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_START }, { STAT_START_TAGNAME_END, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_START },
/* below supports tags that are self-closing, e.g., <br /> */ /* below supports tags that are self-closing, e.g., <br /> */
{ STAT_START_TAGNAME_END, CLASS_TYPE_SLASH, STAT_EMPTY_TAG, EVENT_COPY }, { STAT_START_TAGNAME_END, CLASS_TYPE_SLASH, STAT_EMPTY_TAG, EVENT_COPY },
/* [17] handle empty tags, e.g., <br /> */ /* [17] handle empty tags, e.g., <br /> */
{ STAT_EMPTY_TAG, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_END }, { STAT_EMPTY_TAG, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_END },
/* [18] handle end tag, e.g., <tag /> */ /* [18] handle end tag, e.g., <tag /> */
{ STAT_END_TAG, CLASS_TYPE_LETTERS, STAT_END_TAGNAME, EVENT_NONE }, { STAT_END_TAG, CLASS_TYPE_LETTERS, STAT_END_TAGNAME, EVENT_NONE },
/* [19-21] handle end tag name */ /* [19-21] handle end tag name */
{ STAT_END_TAGNAME, CLASS_TYPE_LETTERS, STAT_END_TAGNAME, EVENT_NONE }, { STAT_END_TAGNAME, CLASS_TYPE_LETTERS, STAT_END_TAGNAME, EVENT_NONE },
{ STAT_END_TAGNAME, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_END }, { STAT_END_TAGNAME, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_END },
/* below adds support for spaces at the end of an end tag (before /* below adds support for spaces at the end of an end tag (before
closing bracket) */ closing bracket) */
{ STAT_END_TAGNAME, CLASS_TYPE_SPACE, STAT_END_TAGNAME_END, EVENT_END }, { STAT_END_TAGNAME, CLASS_TYPE_SPACE, STAT_END_TAGNAME_END, EVENT_END },
/* [22] handle ending of end tag name */ /* [22] handle ending of end tag name */
{ STAT_END_TAGNAME_END, CLASS_TYPE_SPACE, STAT_END_TAGNAME_END, EVENT_NONE }, { STAT_END_TAGNAME_END, CLASS_TYPE_SPACE, STAT_END_TAGNAME_END, EVENT_NONE },
{ STAT_END_TAGNAME_END, CLASS_TYPE_RIGHT_ANGLE,STAT_START, EVENT_NONE }, { STAT_END_TAGNAME_END, CLASS_TYPE_RIGHT_ANGLE, STAT_START, EVENT_NONE },
/* [23-25] handle text */ /* [23-25] handle text */
{ STAT_TEXT, CLASS_TYPE_SPACE, STAT_SPACE, EVENT_NONE }, { STAT_TEXT, CLASS_TYPE_SPACE, STAT_SPACE, EVENT_NONE },
{ STAT_TEXT, CLASS_TYPE_LEFT_ANGLE, STAT_START_TAG, EVENT_TEXT }, { STAT_TEXT, CLASS_TYPE_LEFT_ANGLE, STAT_START_TAG, EVENT_TEXT },
{ STAT_TEXT, CLASS_TYPE_ANY, STAT_TEXT, EVENT_NONE }, { STAT_TEXT, CLASS_TYPE_ANY, STAT_TEXT, EVENT_NONE },
/* [26-30] handle attribute names */ /* [26-30] handle attribute names */
{ STAT_ATTR_NAME, CLASS_TYPE_LETTERS, STAT_ATTR_NAME, EVENT_COPY }, { STAT_ATTR_NAME, CLASS_TYPE_LETTERS, STAT_ATTR_NAME, EVENT_COPY },
/* below add support for space before the equals sign, e.g, <tag /* below add support for space before the equals sign, e.g, <tag
attr ="2"> */ attr ="2"> */
{ STAT_ATTR_NAME, CLASS_TYPE_SPACE, STAT_ATTR_NAME_END, EVENT_NAME }, { STAT_ATTR_NAME, CLASS_TYPE_SPACE, STAT_ATTR_NAME_END, EVENT_NAME },
{ STAT_ATTR_NAME, CLASS_TYPE_EQUALS, STAT_ATTR_VAL, EVENT_NAME }, { STAT_ATTR_NAME, CLASS_TYPE_EQUALS, STAT_ATTR_VAL, EVENT_NAME },
/* [31-33] attribute name end */ /* [31-33] attribute name end */
{ STAT_ATTR_NAME_END, CLASS_TYPE_SPACE, STAT_ATTR_NAME_END, EVENT_NONE }, { STAT_ATTR_NAME_END, CLASS_TYPE_SPACE, STAT_ATTR_NAME_END, EVENT_NONE },
{ STAT_ATTR_NAME_END, CLASS_TYPE_LETTERS, STAT_ATTR_NAME, EVENT_COPY }, { STAT_ATTR_NAME_END, CLASS_TYPE_LETTERS, STAT_ATTR_NAME, EVENT_COPY },
{ STAT_ATTR_NAME_END, CLASS_TYPE_EQUALS, STAT_ATTR_VAL, EVENT_NONE }, { STAT_ATTR_NAME_END, CLASS_TYPE_EQUALS, STAT_ATTR_VAL, EVENT_NONE },
/* [34-35] handle attribute values, initial quote and spaces */ /* [34-35] handle attribute values, initial quote and spaces */
{ STAT_ATTR_VAL, CLASS_TYPE_QUOTE, STAT_ATTR_VAL2, EVENT_NONE }, { STAT_ATTR_VAL, CLASS_TYPE_QUOTE, STAT_ATTR_VAL2, EVENT_NONE },
/* below handles initial spaces before quoted attribute value */ /* below handles initial spaces before quoted attribute value */
{ STAT_ATTR_VAL, CLASS_TYPE_SPACE, STAT_ATTR_VAL, EVENT_NONE }, { STAT_ATTR_VAL, CLASS_TYPE_SPACE, STAT_ATTR_VAL, EVENT_NONE },
/* [36-37] handle actual attribute values */ /* [36-37] handle actual attribute values */
{ STAT_ATTR_VAL2, CLASS_TYPE_QUOTE, STAT_START_TAGNAME_END, EVENT_VAL }, { STAT_ATTR_VAL2, CLASS_TYPE_QUOTE, STAT_START_TAGNAME_END, EVENT_VAL },
{ STAT_ATTR_VAL2, CLASS_TYPE_LETTERS, STAT_ATTR_VAL2, EVENT_COPY }, { STAT_ATTR_VAL2, CLASS_TYPE_LETTERS, STAT_ATTR_VAL2, EVENT_COPY },
{ STAT_ATTR_VAL2, CLASS_TYPE_SLASH, STAT_ATTR_VAL2, EVENT_NONE }, { STAT_ATTR_VAL2, CLASS_TYPE_SLASH, STAT_ATTR_VAL2, EVENT_NONE },
/* End of table marker */ /* End of table marker */
{ STAT_ERROR, CLASS_TYPE_NONE, STAT_ERROR, EVENT_NONE } { STAT_ERROR, CLASS_TYPE_NONE, STAT_ERROR, EVENT_NONE }
}; };
struct rtgui_xml struct rtgui_xml
{ {
/* event handler */ /* event handler */
rtgui_xml_event_handler_t event_handler; rtgui_xml_event_handler_t event_handler;
void* user; void *user;
char* buffer; /* xml buffer */ char *buffer; /* xml buffer */
rt_size_t buffer_size; /* buffer size */ rt_size_t buffer_size; /* buffer size */
rt_size_t position; /* current position in buffer */ rt_size_t position; /* current position in buffer */
rt_uint16_t state, event; /* current state and event */ rt_uint16_t state, event; /* current state and event */
rt_bool_t copy; /* copy text into tmp buffer */ rt_bool_t copy; /* copy text into tmp buffer */
rt_bool_t halt; /* halt parsing of document */ rt_bool_t halt; /* halt parsing of document */
}; };
rtgui_xml_t* rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler, rtgui_xml_t *rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler,
void* user) void *user)
{ {
rtgui_xml_t* xml = (rtgui_xml_t*) rtgui_malloc(sizeof(struct rtgui_xml)); rtgui_xml_t *xml = (rtgui_xml_t *) rtgui_malloc(sizeof(struct rtgui_xml));
rt_memset(xml, 0, sizeof(rtgui_xml_t)); rt_memset(xml, 0, sizeof(rtgui_xml_t));
xml->event_handler = handler; xml->event_handler = handler;
xml->user = user; xml->user = user;
/* create buffer */ /* create buffer */
xml->buffer_size = buffer_size; xml->buffer_size = buffer_size;
xml->buffer = (char*)rtgui_malloc(xml->buffer_size); xml->buffer = (char *)rtgui_malloc(xml->buffer_size);
return xml; return xml;
} }
void rtgui_xml_destroy(rtgui_xml_t* xml) void rtgui_xml_destroy(rtgui_xml_t *xml)
{ {
if(xml) if (xml)
{ {
rtgui_free(xml->buffer); rtgui_free(xml->buffer);
rtgui_free(xml); rtgui_free(xml);
} }
} }
const char* rtgui_xml_event_str(rt_uint8_t event) const char *rtgui_xml_event_str(rt_uint8_t event)
{ {
switch(event) switch (event)
{ {
case EVENT_START: case EVENT_START:
return "start tag"; return "start tag";
case EVENT_END: case EVENT_END:
return "end tag"; return "end tag";
case EVENT_TEXT: case EVENT_TEXT:
return "text"; return "text";
case EVENT_NAME: case EVENT_NAME:
return "attr name"; return "attr name";
case EVENT_VAL: case EVENT_VAL:
return "attr val"; return "attr val";
case EVENT_END_DOC: case EVENT_END_DOC:
return "end document"; return "end document";
default: default:
break; break;
} }
return "err"; return "err";
} }
int rtgui_xml_parse(rtgui_xml_t* xml, const char* buf, rt_size_t len) int rtgui_xml_parse(rtgui_xml_t *xml, const char *buf, rt_size_t len)
{ {
int i, j, c, match; int i, j, c, match;
#define is_space(ch) \ #define is_space(ch) \
((rt_uint32_t)(ch - 9) < 5u || ch == ' ') ((rt_uint32_t)(ch - 9) < 5u || ch == ' ')
#define is_alpha(ch) \ #define is_alpha(ch) \
((rt_uint32_t)((ch | 0x20) - 'a') < 26u) ((rt_uint32_t)((ch | 0x20) - 'a') < 26u)
#define is_digit(ch) \ #define is_digit(ch) \
((rt_uint32_t)(ch - '0') < 10u) ((rt_uint32_t)(ch - '0') < 10u)
#define is_letters(ch) \ #define is_letters(ch) \
(is_alpha(ch) || is_digit(ch) || (ch == '.')) (is_alpha(ch) || is_digit(ch) || (ch == '.'))
for(i=0; i<len; i++) for (i = 0; i < len; i++)
{ {
if(xml->halt) break; if (xml->halt) break;
c = buf[i] & 0xff; c = buf[i] & 0xff;
/* search in state table */ /* search in state table */
for(j=0, match = 0; RTGUI_XML_STATES[j].state != STAT_ERROR; j++) for (j = 0, match = 0; RTGUI_XML_STATES[j].state != STAT_ERROR; j++)
{ {
if(RTGUI_XML_STATES[j].state != xml->state) if (RTGUI_XML_STATES[j].state != xml->state)
continue; continue;
switch(RTGUI_XML_STATES[j].class_type) switch (RTGUI_XML_STATES[j].class_type)
{ {
case CLASS_TYPE_LETTERS: case CLASS_TYPE_LETTERS:
match = is_letters(c); match = is_letters(c);
break; break;
case CLASS_TYPE_LEFT_ANGLE: case CLASS_TYPE_LEFT_ANGLE:
match = (c == '<'); match = (c == '<');
break; break;
case CLASS_TYPE_SLASH: case CLASS_TYPE_SLASH:
match = (c == '/'); match = (c == '/');
break; break;
case CLASS_TYPE_RIGHT_ANGLE: case CLASS_TYPE_RIGHT_ANGLE:
match = (c == '>'); match = (c == '>');
break; break;
case CLASS_TYPE_EQUALS: case CLASS_TYPE_EQUALS:
match = (c == '='); match = (c == '=');
break; break;
case CLASS_TYPE_QUOTE: case CLASS_TYPE_QUOTE:
match = (c == '"'); match = (c == '"');
break; break;
case CLASS_TYPE_SPACE: case CLASS_TYPE_SPACE:
match = is_space(c); match = is_space(c);
break; break;
case CLASS_TYPE_ANY: case CLASS_TYPE_ANY:
match = 1; match = 1;
break; break;
default: default:
break; break;
} }
/* we matched a character class */ /* we matched a character class */
if(match) if (match)
{ {
if(RTGUI_XML_STATES[j].event == EVENT_COPY) if (RTGUI_XML_STATES[j].event == EVENT_COPY)
{ {
xml->copy = RT_TRUE; xml->copy = RT_TRUE;
} }
else if(RTGUI_XML_STATES[j].event != EVENT_NONE) else if (RTGUI_XML_STATES[j].event != EVENT_NONE)
{ {
if(xml->copy == RT_TRUE) if (xml->copy == RT_TRUE)
{ {
/* basically we are guaranteed never to have an event of /* basically we are guaranteed never to have an event of
type EVENT_COPY or EVENT_NONE here. */ type EVENT_COPY or EVENT_NONE here. */
xml->event = RTGUI_XML_STATES[j].event; xml->event = RTGUI_XML_STATES[j].event;
xml->buffer[xml->position] = 0; /* make a string */ xml->buffer[xml->position] = 0; /* make a string */
if(!xml->event_handler(RTGUI_XML_STATES[j].event, if (!xml->event_handler(RTGUI_XML_STATES[j].event,
xml->buffer, xml->position , xml->buffer, xml->position ,
xml->user)) xml->user))
{ {
xml->halt = 1; /* stop parsing from here out */ xml->halt = 1; /* stop parsing from here out */
} }
xml->position = 0; xml->position = 0;
xml->copy = RT_FALSE; xml->copy = RT_FALSE;
} }
} }
if(xml->copy == RT_TRUE) if (xml->copy == RT_TRUE)
{ {
/* check to see if we have room; one less for trailing /* check to see if we have room; one less for trailing
nul */ nul */
if(xml->position < xml->buffer_size-1) if (xml->position < xml->buffer_size - 1)
{ {
xml->buffer[xml->position] = buf[i]; xml->buffer[xml->position] = buf[i];
xml->position++; xml->position++;
} }
} }
xml->state = RTGUI_XML_STATES[j].next_state; /* change state */ xml->state = RTGUI_XML_STATES[j].next_state; /* change state */
break; /* break out of loop though state search */ break; /* break out of loop though state search */
} }
} }
} }
return !xml->halt; return !xml->halt;
} }

View File

@ -3,7 +3,7 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
typedef void (*rtgui_blit_line_func)(rt_uint8_t* dst, rt_uint8_t* src, int line); typedef void (*rtgui_blit_line_func)(rt_uint8_t *dst, rt_uint8_t *src, int line);
rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp); rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp);
rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp); rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp);

View File

@ -17,17 +17,17 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#define RTGUI_ARGB(a, r, g, b) \ #define RTGUI_ARGB(a, r, g, b) \
((rtgui_color_t)(((rt_uint8_t)(r)|\ ((rtgui_color_t)(((rt_uint8_t)(r)|\
(((unsigned)(rt_uint8_t)(g))<<8))|\ (((unsigned)(rt_uint8_t)(g))<<8))|\
(((unsigned long)(rt_uint8_t)(b))<<16)|\ (((unsigned long)(rt_uint8_t)(b))<<16)|\
(((unsigned long)(rt_uint8_t)(a))<<24))) (((unsigned long)(rt_uint8_t)(a))<<24)))
#define RTGUI_RGB(r, g, b) RTGUI_ARGB(255, (r), (g), (b)) #define RTGUI_RGB(r, g, b) RTGUI_ARGB(255, (r), (g), (b))
#define RTGUI_RGB_R(c) ((c) & 0xff) #define RTGUI_RGB_R(c) ((c) & 0xff)
#define RTGUI_RGB_G(c) (((c) >> 8) & 0xff) #define RTGUI_RGB_G(c) (((c) >> 8) & 0xff)
#define RTGUI_RGB_B(c) (((c) >> 16) & 0xff) #define RTGUI_RGB_B(c) (((c) >> 16) & 0xff)
#define RTGUI_RGB_A(c) (((c) >> 24) & 0xff) #define RTGUI_RGB_A(c) (((c) >> 24) & 0xff)
extern const rtgui_color_t default_foreground; extern const rtgui_color_t default_foreground;
extern const rtgui_color_t default_background; extern const rtgui_color_t default_background;
@ -49,90 +49,90 @@ extern const rtgui_color_t light_grey;
/* convert rtgui color to mono */ /* convert rtgui color to mono */
rt_inline rt_uint8_t rtgui_color_to_mono(rtgui_color_t c) rt_inline rt_uint8_t rtgui_color_to_mono(rtgui_color_t c)
{ {
rt_uint8_t pixel; rt_uint8_t pixel;
pixel = (RTGUI_RGB_R(c) | RTGUI_RGB_G(c) | RTGUI_RGB_B(c)) ? 0x01 : 0x00; pixel = (RTGUI_RGB_R(c) | RTGUI_RGB_G(c) | RTGUI_RGB_B(c)) ? 0x01 : 0x00;
return pixel; return pixel;
} }
rt_inline rtgui_color_t rtgui_color_from_mono(rt_uint8_t pixel) rt_inline rtgui_color_t rtgui_color_from_mono(rt_uint8_t pixel)
{ {
rtgui_color_t color; rtgui_color_t color;
if (pixel) if (pixel)
{ {
color = white; color = white;
} }
else else
{ {
color = black; color = black;
} }
return color; return color;
} }
/* convert rtgui color to BBBBBGGGGGGRRRRR */ /* convert rtgui color to BBBBBGGGGGGRRRRR */
rt_inline rt_uint16_t rtgui_color_to_565(rtgui_color_t c) rt_inline rt_uint16_t rtgui_color_to_565(rtgui_color_t c)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = (rt_uint16_t)(((RTGUI_RGB_B(c)>> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_R(c) >> 3)); pixel = (rt_uint16_t)(((RTGUI_RGB_B(c) >> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_R(c) >> 3));
return pixel; return pixel;
} }
rt_inline rtgui_color_t rtgui_color_from_565(rt_uint16_t pixel) rt_inline rtgui_color_t rtgui_color_from_565(rt_uint16_t pixel)
{ {
rt_uint16_t r, g, b; rt_uint16_t r, g, b;
rtgui_color_t color; rtgui_color_t color;
r = pixel & 0x1f; r = pixel & 0x1f;
g = (pixel >> 5) & 0x3f; g = (pixel >> 5) & 0x3f;
b = (pixel >> 11) & 0x1f; b = (pixel >> 11) & 0x1f;
color = r * 255 / 31 + ((g * 255 / 63) << 8) + ((b * 255 / 31) << 16); color = r * 255 / 31 + ((g * 255 / 63) << 8) + ((b * 255 / 31) << 16);
return color; return color;
} }
/* convert rtgui color to RRRRRGGGGGGBBBBB */ /* convert rtgui color to RRRRRGGGGGGBBBBB */
rt_inline rt_uint16_t rtgui_color_to_565p(rtgui_color_t c) rt_inline rt_uint16_t rtgui_color_to_565p(rtgui_color_t c)
{ {
rt_uint16_t pixel; rt_uint16_t pixel;
pixel = (rt_uint16_t)(((RTGUI_RGB_R(c) >> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_B(c)>> 3)); pixel = (rt_uint16_t)(((RTGUI_RGB_R(c) >> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_B(c) >> 3));
return pixel; return pixel;
} }
rt_inline rtgui_color_t rtgui_color_from_565p(rt_uint16_t pixel) rt_inline rtgui_color_t rtgui_color_from_565p(rt_uint16_t pixel)
{ {
rt_uint8_t r, g, b; rt_uint8_t r, g, b;
rtgui_color_t color; rtgui_color_t color;
r = (pixel >> 11) & 0x1f; r = (pixel >> 11) & 0x1f;
g = (pixel >> 5) & 0x3f; g = (pixel >> 5) & 0x3f;
b = pixel & 0x1f; b = pixel & 0x1f;
color = r * 255 / 31 + ((g * 255 / 63) << 8) + ((b * 255 / 31) << 16); color = r * 255 / 31 + ((g * 255 / 63) << 8) + ((b * 255 / 31) << 16);
return color; return color;
} }
/* convert rtgui color to RGB */ /* convert rtgui color to RGB */
rt_inline rt_uint32_t rtgui_color_to_888(rtgui_color_t c) rt_inline rt_uint32_t rtgui_color_to_888(rtgui_color_t c)
{ {
rt_uint32_t pixel; rt_uint32_t pixel;
pixel = RTGUI_RGB_R(c) << 16 | RTGUI_RGB_G(c) << 8 | RTGUI_RGB_B(c); pixel = RTGUI_RGB_R(c) << 16 | RTGUI_RGB_G(c) << 8 | RTGUI_RGB_B(c);
return pixel; return pixel;
} }
rt_inline rtgui_color_t rtgui_color_from_888(rt_uint32_t pixel) rt_inline rtgui_color_t rtgui_color_from_888(rt_uint32_t pixel)
{ {
rtgui_color_t color; rtgui_color_t color;
color = RTGUI_RGB(((pixel >> 16) & 0xff), ((pixel >> 8) & 0xff), pixel & 0xff); color = RTGUI_RGB(((pixel >> 16) & 0xff), ((pixel >> 8) & 0xff), pixel & 0xff);
return color; return color;
} }
#endif #endif

View File

@ -21,91 +21,91 @@
enum rtgui_dc_type enum rtgui_dc_type
{ {
RTGUI_DC_HW, RTGUI_DC_HW,
RTGUI_DC_CLIENT, RTGUI_DC_CLIENT,
RTGUI_DC_BUFFER, RTGUI_DC_BUFFER,
}; };
struct rtgui_dc_engine struct rtgui_dc_engine
{ {
/* interface */ /* interface */
void (*draw_point)(struct rtgui_dc* dc, int x, int y); void (*draw_point)(struct rtgui_dc *dc, int x, int y);
void (*draw_color_point)(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); void (*draw_color_point)(struct rtgui_dc *dc, int x, int y, rtgui_color_t color);
void (*draw_vline)(struct rtgui_dc* dc, int x, int y1, int y2); void (*draw_vline)(struct rtgui_dc *dc, int x, int y1, int y2);
void (*draw_hline)(struct rtgui_dc* dc, int x1, int x2, int y); void (*draw_hline)(struct rtgui_dc *dc, int x1, int x2, int y);
void (*fill_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect); void (*fill_rect)(struct rtgui_dc *dc, rtgui_rect_t *rect);
void (*blit_line) (struct rtgui_dc* dc, int x1, int x2, int y, rt_uint8_t* line_data); void (*blit_line)(struct rtgui_dc *dc, int x1, int x2, int y, rt_uint8_t *line_data);
void (*blit )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect); void (*blit)(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect);
/* set and get graphic context */ /* set and get graphic context */
void (*set_gc)(struct rtgui_dc* dc, struct rtgui_gc *gc); void (*set_gc)(struct rtgui_dc *dc, struct rtgui_gc *gc);
struct rtgui_gc* (*get_gc)(struct rtgui_dc* dc); struct rtgui_gc *(*get_gc)(struct rtgui_dc *dc);
/* get dc visible */ /* get dc visible */
rt_bool_t (*get_visible)(struct rtgui_dc* dc); rt_bool_t (*get_visible)(struct rtgui_dc *dc);
/* get dc rect */ /* get dc rect */
void (*get_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect); void (*get_rect)(struct rtgui_dc *dc, rtgui_rect_t *rect);
rt_bool_t (*fini )(struct rtgui_dc* dc); rt_bool_t (*fini)(struct rtgui_dc *dc);
}; };
/* the abstract device context */ /* the abstract device context */
struct rtgui_dc struct rtgui_dc
{ {
/* type of device context */ /* type of device context */
rt_uint32_t type; rt_uint32_t type;
/* dc engine */ /* dc engine */
const struct rtgui_dc_engine* engine; const struct rtgui_dc_engine *engine;
}; };
#define RTGUI_DC_FC(dc) (rtgui_dc_get_gc(dc)->foreground) #define RTGUI_DC_FC(dc) (rtgui_dc_get_gc(dc)->foreground)
#define RTGUI_DC_BC(dc) (rtgui_dc_get_gc(dc)->background) #define RTGUI_DC_BC(dc) (rtgui_dc_get_gc(dc)->background)
#define RTGUI_DC_FONT(dc) (rtgui_dc_get_gc(dc)->font) #define RTGUI_DC_FONT(dc) (rtgui_dc_get_gc(dc)->font)
#define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign) #define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign)
/* create a buffer dc */ /* create a buffer dc */
struct rtgui_dc* rtgui_dc_buffer_create(int width, int height); struct rtgui_dc *rtgui_dc_buffer_create(int width, int height);
rt_uint8_t* rtgui_dc_buffer_get_pixel(struct rtgui_dc* dc); rt_uint8_t *rtgui_dc_buffer_get_pixel(struct rtgui_dc *dc);
/* begin and end a drawing */ /* begin and end a drawing */
struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner); struct rtgui_dc *rtgui_dc_begin_drawing(rtgui_widget_t *owner);
void rtgui_dc_end_drawing(struct rtgui_dc* dc); void rtgui_dc_end_drawing(struct rtgui_dc *dc);
/* destroy a dc */ /* destroy a dc */
void rtgui_dc_destory(struct rtgui_dc* dc); void rtgui_dc_destory(struct rtgui_dc *dc);
void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2); void rtgui_dc_draw_line(struct rtgui_dc *dc, int x1, int y1, int x2, int y2);
void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect); void rtgui_dc_draw_rect(struct rtgui_dc *dc, struct rtgui_rect *rect);
void rtgui_dc_fill_rect_forecolor(struct rtgui_dc* dc, struct rtgui_rect* rect); void rtgui_dc_fill_rect_forecolor(struct rtgui_dc *dc, struct rtgui_rect *rect);
void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r); void rtgui_dc_draw_round_rect(struct rtgui_dc *dc, struct rtgui_rect *rect, int r);
void rtgui_dc_fill_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r); void rtgui_dc_fill_round_rect(struct rtgui_dc *dc, struct rtgui_rect *rect, int r);
void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r1, rt_int16_t r2, rt_int16_t start, rt_int16_t end); void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r1, rt_int16_t r2, rt_int16_t start, rt_int16_t end);
void rtgui_dc_draw_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end); void rtgui_dc_draw_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
void rtgui_dc_fill_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end); void rtgui_dc_fill_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect); void rtgui_dc_draw_text(struct rtgui_dc *dc, const char *text, struct rtgui_rect *rect);
void rtgui_dc_draw_text_stroke (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect, void rtgui_dc_draw_text_stroke(struct rtgui_dc *dc, const char *text, struct rtgui_rect *rect,
rtgui_color_t color_stroke, rtgui_color_t color_core); rtgui_color_t color_stroke, rtgui_color_t color_core);
void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data); void rtgui_dc_draw_mono_bmp(struct rtgui_dc *dc, int x, int y, int w, int h, const rt_uint8_t *data);
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data); void rtgui_dc_draw_byte(struct rtgui_dc *dc, int x, int y, int h, const rt_uint8_t *data);
void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data); void rtgui_dc_draw_word(struct rtgui_dc *dc, int x, int y, int h, const rt_uint8_t *data);
void rtgui_dc_draw_border(struct rtgui_dc* dc, rtgui_rect_t* rect, int flag); void rtgui_dc_draw_border(struct rtgui_dc *dc, rtgui_rect_t *rect, int flag);
void rtgui_dc_draw_horizontal_line(struct rtgui_dc* dc, int x1, int x2, int y); void rtgui_dc_draw_horizontal_line(struct rtgui_dc *dc, int x1, int x2, int y);
void rtgui_dc_draw_vertical_line(struct rtgui_dc* dc, int x, int y1, int y2); void rtgui_dc_draw_vertical_line(struct rtgui_dc *dc, int x, int y1, int y2);
void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); void rtgui_dc_draw_focus_rect(struct rtgui_dc *dc, rtgui_rect_t *rect);
void rtgui_dc_draw_polygon(struct rtgui_dc* dc, const int *vx, const int *vy, int count); void rtgui_dc_draw_polygon(struct rtgui_dc *dc, const int *vx, const int *vy, int count);
void rtgui_dc_fill_polygon(struct rtgui_dc* dc, const int* vx, const int* vy, int count); void rtgui_dc_fill_polygon(struct rtgui_dc *dc, const int *vx, const int *vy, int count);
void rtgui_dc_draw_circle(struct rtgui_dc* dc, int x, int y, int r); void rtgui_dc_draw_circle(struct rtgui_dc *dc, int x, int y, int r);
void rtgui_dc_fill_circle(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t r); void rtgui_dc_fill_circle(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r);
void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end); void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
void rtgui_dc_draw_ellipse(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry); void rtgui_dc_draw_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry); void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
/* /*
@ -118,81 +118,81 @@ void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_i
/* /*
* draw a point on dc * draw a point on dc
*/ */
rt_inline void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y) rt_inline void rtgui_dc_draw_point(struct rtgui_dc *dc, int x, int y)
{ {
dc->engine->draw_point(dc, x, y); dc->engine->draw_point(dc, x, y);
} }
/* /*
* draw a color point on dc * draw a color point on dc
*/ */
rt_inline void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color) rt_inline void rtgui_dc_draw_color_point(struct rtgui_dc *dc, int x, int y, rtgui_color_t color)
{ {
dc->engine->draw_color_point(dc, x, y, color); dc->engine->draw_color_point(dc, x, y, color);
} }
/* /*
* draw a vertical line on dc * draw a vertical line on dc
*/ */
rt_inline void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2) rt_inline void rtgui_dc_draw_vline(struct rtgui_dc *dc, int x, int y1, int y2)
{ {
dc->engine->draw_vline(dc, x, y1, y2); dc->engine->draw_vline(dc, x, y1, y2);
} }
/* /*
* draw a horizontal line on dc * draw a horizontal line on dc
*/ */
rt_inline void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y) rt_inline void rtgui_dc_draw_hline(struct rtgui_dc *dc, int x1, int x2, int y)
{ {
dc->engine->draw_hline(dc, x1, x2, y); dc->engine->draw_hline(dc, x1, x2, y);
} }
/* /*
* fill a rect with background color * fill a rect with background color
*/ */
rt_inline void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) rt_inline void rtgui_dc_fill_rect(struct rtgui_dc *dc, struct rtgui_rect *rect)
{ {
dc->engine->fill_rect(dc, rect); dc->engine->fill_rect(dc, rect);
} }
/* /*
* blit a dc on hardware dc * blit a dc on hardware dc
*/ */
rt_inline void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) rt_inline void rtgui_dc_blit(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect)
{ {
dc->engine->blit(dc, dc_point, dest, rect); dc->engine->blit(dc, dc_point, dest, rect);
} }
/* /*
* set gc of dc * set gc of dc
*/ */
rt_inline void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc) rt_inline void rtgui_dc_set_gc(struct rtgui_dc *dc, rtgui_gc_t *gc)
{ {
dc->engine->set_gc(dc, gc); dc->engine->set_gc(dc, gc);
} }
/* /*
* get gc of dc * get gc of dc
*/ */
rt_inline rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc) rt_inline rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc *dc)
{ {
return dc->engine->get_gc(dc); return dc->engine->get_gc(dc);
} }
/* /*
* get visible status of dc * get visible status of dc
*/ */
rt_inline rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc) rt_inline rt_bool_t rtgui_dc_get_visible(struct rtgui_dc *dc)
{ {
return dc->engine->get_visible(dc); return dc->engine->get_visible(dc);
} }
/* /*
* get rect of dc * get rect of dc
*/ */
rt_inline void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect) rt_inline void rtgui_dc_get_rect(struct rtgui_dc *dc, rtgui_rect_t *rect)
{ {
dc->engine->get_rect(dc, rect); dc->engine->get_rect(dc, rect);
} }
#endif #endif

View File

@ -20,8 +20,8 @@
#include <rtgui/dc.h> #include <rtgui/dc.h>
/* create a hardware dc */ /* create a hardware dc */
struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner); struct rtgui_dc *rtgui_dc_client_create(rtgui_widget_t *owner);
void rtgui_dc_client_init(rtgui_widget_t* owner); void rtgui_dc_client_init(rtgui_widget_t *owner);
#endif #endif

View File

@ -18,7 +18,7 @@
#include <rtgui/dc.h> #include <rtgui/dc.h>
/* create a hardware dc */ /* create a hardware dc */
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner); struct rtgui_dc *rtgui_dc_hw_create(rtgui_widget_t *owner);
#endif #endif

View File

@ -30,87 +30,87 @@
extern "C" { extern "C" {
#endif #endif
struct rtgui_dlist_node struct rtgui_dlist_node
{ {
struct rtgui_dlist_node *next; /* point to next node. */ struct rtgui_dlist_node *next; /* point to next node. */
struct rtgui_dlist_node *prev; /* point to prev node. */ struct rtgui_dlist_node *prev; /* point to prev node. */
}; };
/** /**
* @brief initialize a list * @brief initialize a list
* *
* @param l list to be initialized * @param l list to be initialized
*/ */
rt_inline void rtgui_dlist_init(struct rtgui_dlist_node *l) rt_inline void rtgui_dlist_init(struct rtgui_dlist_node *l)
{ {
l->next = l->prev = l; l->next = l->prev = l;
} }
/** /**
* @brief insert a node after a list * @brief insert a node after a list
* *
* @param l list to insert it * @param l list to insert it
* @param n new node to be inserted * @param n new node to be inserted
*/ */
rt_inline void rtgui_dlist_insert_after(struct rtgui_dlist_node *l, struct rtgui_dlist_node *n) rt_inline void rtgui_dlist_insert_after(struct rtgui_dlist_node *l, struct rtgui_dlist_node *n)
{ {
l->next->prev = n; l->next->prev = n;
n->next = l->next; n->next = l->next;
l->next = n; l->next = n;
n->prev = l; n->prev = l;
} }
/** /**
* @brief insert a node before a list * @brief insert a node before a list
* *
* @param n new node to be inserted * @param n new node to be inserted
* @param l list to insert it * @param l list to insert it
*/ */
rt_inline void rtgui_dlist_insert_before(struct rtgui_dlist_node *l, struct rtgui_dlist_node *n) rt_inline void rtgui_dlist_insert_before(struct rtgui_dlist_node *l, struct rtgui_dlist_node *n)
{ {
l->prev->next = n; l->prev->next = n;
n->prev = l->prev; n->prev = l->prev;
l->prev = n; l->prev = n;
n->next = l; n->next = l;
} }
/** /**
* @brief remove node from list. * @brief remove node from list.
* @param n the node to remove from the list. * @param n the node to remove from the list.
*/ */
rt_inline void rtgui_dlist_remove(struct rtgui_dlist_node *n) rt_inline void rtgui_dlist_remove(struct rtgui_dlist_node *n)
{ {
n->next->prev = n->prev; n->next->prev = n->prev;
n->prev->next = n->next; n->prev->next = n->next;
rtgui_dlist_init(n); rtgui_dlist_init(n);
} }
/** /**
* @brief tests whether a list is empty * @brief tests whether a list is empty
* @param l the list to test. * @param l the list to test.
*/ */
rt_inline int rtgui_dlist_isempty(const struct rtgui_dlist_node *l) rt_inline int rtgui_dlist_isempty(const struct rtgui_dlist_node *l)
{ {
return l->next == l; return l->next == l;
} }
/** /**
* @brief get the struct for this entry * @brief get the struct for this entry
* @param node the entry point * @param node the entry point
* @param type the type of structure * @param type the type of structure
* @param member the name of list in structure * @param member the name of list in structure
*/ */
#define rtgui_dlist_entry(node, type, member) \ #define rtgui_dlist_entry(node, type, member) \
((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))
/* the direction can only be next or prev. If you want to iterate the list in /* the direction can only be next or prev. If you want to iterate the list in
* normal order, use next. If you want to iterate the list with reverse order, * normal order, use next. If you want to iterate the list with reverse order,
* use prev.*/ * use prev.*/
#define rtgui_dlist_foreach(node, list, direction) \ #define rtgui_dlist_foreach(node, list, direction) \
for ((node) = (list)->direction; (node) != list; (node) = (node)->direction) for ((node) = (list)->direction; (node) != list; (node) = (node)->direction)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -19,49 +19,49 @@
struct rtgui_graphic_driver_ops struct rtgui_graphic_driver_ops
{ {
/* set and get pixel in (x, y) */ /* set and get pixel in (x, y) */
void (*set_pixel) (rtgui_color_t *c, int x, int y); void (*set_pixel)(rtgui_color_t *c, int x, int y);
void (*get_pixel) (rtgui_color_t *c, int x, int y); void (*get_pixel)(rtgui_color_t *c, int x, int y);
void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y); void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y);
void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2); void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2);
/* draw raw hline */ /* draw raw hline */
void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y); void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
}; };
struct rtgui_graphic_driver struct rtgui_graphic_driver
{ {
/* pixel format and byte per pixel */ /* pixel format and byte per pixel */
rt_uint8_t pixel_format; rt_uint8_t pixel_format;
rt_uint8_t bits_per_pixel; rt_uint8_t bits_per_pixel;
rt_uint16_t pitch; rt_uint16_t pitch;
/* screen width and height */ /* screen width and height */
rt_uint16_t width; rt_uint16_t width;
rt_uint16_t height; rt_uint16_t height;
/* framebuffer address and ops */ /* framebuffer address and ops */
volatile rt_uint8_t *framebuffer; volatile rt_uint8_t *framebuffer;
rt_device_t device; rt_device_t device;
const struct rtgui_graphic_driver_ops *ops; const struct rtgui_graphic_driver_ops *ops;
}; };
void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver); void rtgui_graphic_driver_add(const struct rtgui_graphic_driver *driver);
struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void); struct rtgui_graphic_driver *rtgui_graphic_driver_get_default(void);
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect); void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect); void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver); rt_uint8_t *rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver *driver);
rt_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void); rt_uint8_t *rtgui_graphic_driver_get_default_framebuffer(void);
rt_err_t rtgui_graphic_set_device(rt_device_t device); rt_err_t rtgui_graphic_set_device(rt_device_t device);
rt_inline struct rtgui_graphic_driver* rtgui_graphic_get_device() rt_inline struct rtgui_graphic_driver *rtgui_graphic_get_device()
{ {
extern struct rtgui_graphic_driver _driver; extern struct rtgui_graphic_driver _driver;
return &_driver; return &_driver;
} }
#endif #endif

View File

@ -21,87 +21,89 @@
* rtgui_event_generic */ * rtgui_event_generic */
enum _rtgui_event_type enum _rtgui_event_type
{ {
/* applications event */ /* applications event */
RTGUI_EVENT_APP_CREATE, /* create an application */ RTGUI_EVENT_APP_CREATE, /* create an application */
RTGUI_EVENT_APP_DESTROY, /* destroy an application */ RTGUI_EVENT_APP_DESTROY, /* destroy an application */
RTGUI_EVENT_APP_ACTIVATE, /* activate an application */ RTGUI_EVENT_APP_ACTIVATE, /* activate an application */
/* window event */ /* window event */
RTGUI_EVENT_WIN_CREATE, /* create a window */ RTGUI_EVENT_WIN_CREATE, /* create a window */
RTGUI_EVENT_WIN_DESTROY, /* destroy a window */ RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
RTGUI_EVENT_WIN_SHOW, /* show a window */ RTGUI_EVENT_WIN_SHOW, /* show a window */
RTGUI_EVENT_WIN_HIDE, /* hide a window */ RTGUI_EVENT_WIN_HIDE, /* hide a window */
RTGUI_EVENT_WIN_ACTIVATE, /* activate a window */ RTGUI_EVENT_WIN_ACTIVATE, /* activate a window */
RTGUI_EVENT_WIN_DEACTIVATE, /* deactivate a window */ RTGUI_EVENT_WIN_DEACTIVATE, /* deactivate a window */
RTGUI_EVENT_WIN_CLOSE, /* close a window */ RTGUI_EVENT_WIN_CLOSE, /* close a window */
RTGUI_EVENT_WIN_MOVE, /* move a window */ RTGUI_EVENT_WIN_MOVE, /* move a window */
RTGUI_EVENT_WIN_RESIZE, /* resize a window */ RTGUI_EVENT_WIN_RESIZE, /* resize a window */
RTGUI_EVENT_WIN_MODAL_ENTER, /* the window is entering modal mode. RTGUI_EVENT_WIN_MODAL_ENTER, /* the window is entering modal mode.
This event should be sent after the This event should be sent after the
window got setup and before the window got setup and before the
application got setup. */ application got setup. */
/* WM event */ /* WM event */
RTGUI_EVENT_SET_WM, /* set window manager */ RTGUI_EVENT_SET_WM, /* set window manager */
RTGUI_EVENT_UPDATE_BEGIN, /* update a rect */ RTGUI_EVENT_UPDATE_BEGIN, /* update a rect */
RTGUI_EVENT_UPDATE_END, /* update a rect */ RTGUI_EVENT_UPDATE_END, /* update a rect */
RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */ RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */
RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect */ RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect */
RTGUI_EVENT_SHOW, /* the widget is going to be shown */ RTGUI_EVENT_SHOW, /* the widget is going to be shown */
RTGUI_EVENT_HIDE, /* the widget is going to be hidden */ RTGUI_EVENT_HIDE, /* the widget is going to be hidden */
RTGUI_EVENT_PAINT, /* paint on screen */ RTGUI_EVENT_PAINT, /* paint on screen */
RTGUI_EVENT_TIMER, /* timer */ RTGUI_EVENT_TIMER, /* timer */
RTGUI_EVENT_UPDATE_TOPLVL, /* update the toplevel */ RTGUI_EVENT_UPDATE_TOPLVL, /* update the toplevel */
/* clip rect information */ /* clip rect information */
RTGUI_EVENT_CLIP_INFO, /* clip rect info */ RTGUI_EVENT_CLIP_INFO, /* clip rect info */
/* mouse and keyboard event */ /* mouse and keyboard event */
RTGUI_EVENT_MOUSE_MOTION, /* mouse motion */ RTGUI_EVENT_MOUSE_MOTION, /* mouse motion */
RTGUI_EVENT_MOUSE_BUTTON, /* mouse button info */ RTGUI_EVENT_MOUSE_BUTTON, /* mouse button info */
RTGUI_EVENT_KBD, /* keyboard info */ RTGUI_EVENT_KBD, /* keyboard info */
/* user command event */ /* widget event */
RTGUI_EVENT_COMMAND=0x0100, /* user command */ RTGUI_EVENT_FOCUSED, /* widget focused */
RTGUI_EVENT_SCROLLED, /* scroll bar scrolled */
RTGUI_EVENT_RESIZE, /* widget resize */
RTGUI_EVENT_SELECTED, /* widget selected */
RTGUI_EVENT_UNSELECTED, /* widget un-selected */
RTGUI_EVENT_MV_MODEL, /* data of a model has been changed */
/* widget event */ /* user command event. It should always be the last command type. */
RTGUI_EVENT_FOCUSED, /* widget focused */ RTGUI_EVENT_COMMAND = 0x0100, /* user command */
RTGUI_EVENT_SCROLLED, /* scroll bar scrolled */
RTGUI_EVENT_RESIZE, /* widget resize */
RTGUI_EVENT_SELECTED, /* widget selected */
RTGUI_EVENT_UNSELECTED, /* widget un-selected */
}; };
typedef enum _rtgui_event_type rtgui_event_type; typedef enum _rtgui_event_type rtgui_event_type;
enum { enum
RTGUI_STATUS_OK = 0, /* status ok */ {
RTGUI_STATUS_ERROR, /* generic error */ RTGUI_STATUS_OK = 0, /* status ok */
RTGUI_STATUS_NRC, /* no resource */ RTGUI_STATUS_ERROR, /* generic error */
RTGUI_STATUS_NRC, /* no resource */
}; };
struct rtgui_event struct rtgui_event
{ {
/* the event type */ /* the event type */
rt_uint16_t type; enum _rtgui_event_type type;
/* user field of event */ /* user field of event */
rt_uint16_t user; rt_uint16_t user;
/* the event sender */ /* the event sender */
rt_thread_t sender; rt_thread_t sender;
/* mailbox to acknowledge request */ /* mailbox to acknowledge request */
rt_mailbox_t ack; rt_mailbox_t ack;
}; };
typedef struct rtgui_event rtgui_event_t; typedef struct rtgui_event rtgui_event_t;
#define RTGUI_EVENT(e) ((struct rtgui_event*)(e)) #define RTGUI_EVENT(e) ((struct rtgui_event*)(e))
#define RTGUI_EVENT_INIT(e, t) do \ #define RTGUI_EVENT_INIT(e, t) do \
{ \ { \
(e)->type = (t); \ (e)->type = (t); \
(e)->user = 0; \ (e)->user = 0; \
(e)->sender = rt_thread_self(); \ (e)->sender = rt_thread_self(); \
(e)->ack = RT_NULL; \ (e)->ack = RT_NULL; \
} while (0) } while (0)
/* /*
@ -109,9 +111,9 @@ typedef struct rtgui_event rtgui_event_t;
*/ */
struct rtgui_event_application struct rtgui_event_application
{ {
struct rtgui_event parent; struct rtgui_event parent;
struct rtgui_app* app; struct rtgui_app *app;
}; };
/* gui application init */ /* gui application init */
@ -123,40 +125,40 @@ struct rtgui_event_application
* RTGUI Window Event * RTGUI Window Event
*/ */
#define _RTGUI_EVENT_WIN_ELEMENTS \ #define _RTGUI_EVENT_WIN_ELEMENTS \
struct rtgui_event parent; \ struct rtgui_event parent; \
struct rtgui_win *wid; struct rtgui_win *wid;
/* /*
* RTGUI Window Event * RTGUI Window Event
*/ */
struct rtgui_event_win struct rtgui_event_win
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
}; };
struct rtgui_event_win_create struct rtgui_event_win_create
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
struct rtgui_win *parent_window; struct rtgui_win *parent_window;
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
/* the window title */ /* the window title */
rt_uint8_t title[RTGUI_NAME_MAX]; rt_uint8_t title[RTGUI_NAME_MAX];
/* the window extent */ /* the window extent */
struct rtgui_rect extent; struct rtgui_rect extent;
#endif #endif
}; };
struct rtgui_event_win_move struct rtgui_event_win_move
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
rt_int16_t x, y; rt_int16_t x, y;
}; };
struct rtgui_event_win_resize struct rtgui_event_win_resize
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
rtgui_rect_t rect; rtgui_rect_t rect;
}; };
#define rtgui_event_win_destroy rtgui_event_win #define rtgui_event_win_destroy rtgui_event_win
@ -184,159 +186,159 @@ struct rtgui_event_win_resize
*/ */
struct rtgui_event_set_wm struct rtgui_event_set_wm
{ {
struct rtgui_event parent; struct rtgui_event parent;
struct rtgui_app *app; struct rtgui_app *app;
}; };
#define RTGUI_EVENT_SET_WM_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SET_WM); #define RTGUI_EVENT_SET_WM_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SET_WM);
/* /*
* RTGUI Other Event * RTGUI Other Event
*/ */
struct rtgui_event_update_begin struct rtgui_event_update_begin
{ {
struct rtgui_event parent; struct rtgui_event parent;
/* the update rect */ /* the update rect */
rtgui_rect_t rect; rtgui_rect_t rect;
}; };
struct rtgui_event_update_end struct rtgui_event_update_end
{ {
struct rtgui_event parent; struct rtgui_event parent;
/* the update rect */ /* the update rect */
rtgui_rect_t rect; rtgui_rect_t rect;
}; };
struct rtgui_event_monitor struct rtgui_event_monitor
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
/* the monitor rect */ /* the monitor rect */
rtgui_rect_t rect; rtgui_rect_t rect;
}; };
struct rtgui_event_paint struct rtgui_event_paint
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
rtgui_rect_t rect; /* rect to be updated */ rtgui_rect_t rect; /* rect to be updated */
}; };
struct rtgui_timer; struct rtgui_timer;
struct rtgui_event_timer struct rtgui_event_timer
{ {
struct rtgui_event parent; struct rtgui_event parent;
struct rtgui_timer *timer; struct rtgui_timer *timer;
}; };
typedef struct rtgui_event_timer rtgui_event_timer_t; typedef struct rtgui_event_timer rtgui_event_timer_t;
struct rtgui_event_clip_info struct rtgui_event_clip_info
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
/* the number of rects */ /* the number of rects */
//rt_uint32_t num_rect; //rt_uint32_t num_rect;
/* rtgui_rect_t *rects */ /* rtgui_rect_t *rects */
}; };
#define RTGUI_EVENT_GET_RECT(e, i) &(((rtgui_rect_t*)(e + 1))[i]) #define RTGUI_EVENT_GET_RECT(e, i) &(((rtgui_rect_t*)(e + 1))[i])
#define RTGUI_EVENT_UPDATE_BEGIN_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_BEGIN) #define RTGUI_EVENT_UPDATE_BEGIN_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_BEGIN)
#define RTGUI_EVENT_UPDATE_END_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_END) #define RTGUI_EVENT_UPDATE_END_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_END)
#define RTGUI_EVENT_MONITOR_ADD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_ADD) #define RTGUI_EVENT_MONITOR_ADD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_ADD)
#define RTGUI_EVENT_MONITOR_REMOVE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_REMOVE) #define RTGUI_EVENT_MONITOR_REMOVE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_REMOVE)
#define RTGUI_EVENT_CLIP_INFO_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_CLIP_INFO) #define RTGUI_EVENT_CLIP_INFO_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_CLIP_INFO)
#define RTGUI_EVENT_PAINT_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PAINT) #define RTGUI_EVENT_PAINT_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PAINT)
#define RTGUI_EVENT_TIMER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TIMER) #define RTGUI_EVENT_TIMER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TIMER)
#define rtgui_event_show rtgui_event #define rtgui_event_show rtgui_event
#define rtgui_event_hide rtgui_event #define rtgui_event_hide rtgui_event
#define RTGUI_EVENT_SHOW_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_SHOW) #define RTGUI_EVENT_SHOW_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_SHOW)
#define RTGUI_EVENT_HIDE_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_HIDE) #define RTGUI_EVENT_HIDE_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_HIDE)
struct rtgui_event_update_toplvl struct rtgui_event_update_toplvl
{ {
struct rtgui_event parent; struct rtgui_event parent;
struct rtgui_win *toplvl; struct rtgui_win *toplvl;
}; };
#define RTGUI_EVENT_UPDATE_TOPLVL_INIT(e) \ #define RTGUI_EVENT_UPDATE_TOPLVL_INIT(e) \
do { \ do { \
RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_TOPLVL); \ RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_TOPLVL); \
(e)->toplvl = RT_NULL; \ (e)->toplvl = RT_NULL; \
} while (0) } while (0)
/* /*
* RTGUI Mouse and Keyboard Event * RTGUI Mouse and Keyboard Event
*/ */
struct rtgui_event_mouse struct rtgui_event_mouse
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
rt_uint16_t x, y; rt_uint16_t x, y;
rt_uint16_t button; rt_uint16_t button;
}; };
#define RTGUI_MOUSE_BUTTON_LEFT 0x01 #define RTGUI_MOUSE_BUTTON_LEFT 0x01
#define RTGUI_MOUSE_BUTTON_RIGHT 0x02 #define RTGUI_MOUSE_BUTTON_RIGHT 0x02
#define RTGUI_MOUSE_BUTTON_MIDDLE 0x03 #define RTGUI_MOUSE_BUTTON_MIDDLE 0x03
#define RTGUI_MOUSE_BUTTON_WHEELUP 0x04 #define RTGUI_MOUSE_BUTTON_WHEELUP 0x04
#define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08 #define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08
#define RTGUI_MOUSE_BUTTON_DOWN 0x10 #define RTGUI_MOUSE_BUTTON_DOWN 0x10
#define RTGUI_MOUSE_BUTTON_UP 0x20 #define RTGUI_MOUSE_BUTTON_UP 0x20
struct rtgui_event_kbd struct rtgui_event_kbd
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
rt_uint16_t type; /* key down or up */ rt_uint16_t type; /* key down or up */
rt_uint16_t key; /* current key */ rt_uint16_t key; /* current key */
rt_uint16_t mod; /* current key modifiers */ rt_uint16_t mod; /* current key modifiers */
rt_uint16_t unicode; /* translated character */ rt_uint16_t unicode; /* translated character */
}; };
#define RTGUI_KBD_IS_SET_CTRL(e) ((e)->mod & (RTGUI_KMOD_LCTRL | RTGUI_KMOD_RCTRL))) #define RTGUI_KBD_IS_SET_CTRL(e) ((e)->mod & (RTGUI_KMOD_LCTRL | RTGUI_KMOD_RCTRL)))
#define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT)) #define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT))
#define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT)) #define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
#define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP) #define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
#define RTGUI_KBD_IS_DOWN(e) ((e)->type == RTGUI_KEYDOWN) #define RTGUI_KBD_IS_DOWN(e) ((e)->type == RTGUI_KEYDOWN)
#define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION) #define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION)
#define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON) #define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON)
#define RTGUI_EVENT_KBD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_KBD) #define RTGUI_EVENT_KBD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_KBD)
struct rtgui_event_command struct rtgui_event_command
{ {
_RTGUI_EVENT_WIN_ELEMENTS _RTGUI_EVENT_WIN_ELEMENTS
/* command type */ /* command type */
rt_int32_t type; rt_int32_t type;
/* command id */ /* command id */
rt_int32_t command_id; rt_int32_t command_id;
/* command string */ /* command string */
char command_string[RTGUI_NAME_MAX]; char command_string[RTGUI_NAME_MAX];
}; };
#define RTGUI_EVENT_COMMAND_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_COMMAND) #define RTGUI_EVENT_COMMAND_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_COMMAND)
#define RTGUI_CMD_UNKNOWN 0x00 #define RTGUI_CMD_UNKNOWN 0x00
#define RTGUI_CMD_WM_CLOSE 0x10 #define RTGUI_CMD_WM_CLOSE 0x10
#define RTGUI_CMD_USER_INT 0x20 #define RTGUI_CMD_USER_INT 0x20
#define RTGUI_CMD_USER_STRING 0x21 #define RTGUI_CMD_USER_STRING 0x21
/************************************************************************/ /************************************************************************/
/* Widget Event */ /* Widget Event */
/************************************************************************/ /************************************************************************/
#define RTGUI_WIDGET_EVENT_INIT(e, t) do \ #define RTGUI_WIDGET_EVENT_INIT(e, t) do \
{ \ { \
(e)->type = (t); \ (e)->type = (t); \
(e)->sender = RT_NULL; \ (e)->sender = RT_NULL; \
(e)->ack = RT_NULL; \ (e)->ack = RT_NULL; \
} while (0) } while (0)
/* /*
@ -352,7 +354,7 @@ struct rtgui_event_scrollbar
#define RTGUI_SCROLL_LINEDOWN 0x02 #define RTGUI_SCROLL_LINEDOWN 0x02
#define RTGUI_SCROLL_PAGEUP 0x03 #define RTGUI_SCROLL_PAGEUP 0x03
#define RTGUI_SCROLL_PAGEDOWN 0x04 #define RTGUI_SCROLL_PAGEDOWN 0x04
#define RTGUI_EVENT_SCROLLED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SCROLLED) #define RTGUI_EVENT_SCROLLED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SCROLLED)
/* /*
* RTGUI Widget Focused Event * RTGUI Widget Focused Event
@ -361,55 +363,102 @@ struct rtgui_event_focused
{ {
struct rtgui_event parent; struct rtgui_event parent;
struct rtgui_widget* widget; struct rtgui_widget *widget;
}; };
#define RTGUI_EVENT_FOCUSED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_FOCUSED) #define RTGUI_EVENT_FOCUSED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_FOCUSED)
/* /*
* RTGUI Widget Resize Event * RTGUI Widget Resize Event
*/ */
struct rtgui_event_resize struct rtgui_event_resize
{ {
struct rtgui_event parent; struct rtgui_event parent;
rt_int16_t x, y; rt_int16_t x, y;
rt_int16_t w, h; rt_int16_t w, h;
}; };
#define RTGUI_EVENT_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_RESIZE) #define RTGUI_EVENT_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_RESIZE)
/*
* RTGUI Model/View Event
*/
enum rtgui_event_model_mode
{
RTGUI_MV_DATA_ADDED,
RTGUI_MV_DATA_CHANGED,
RTGUI_MV_DATA_DELETED,
};
struct rtgui_event_mv_model
{
struct rtgui_event parent;
struct rtgui_mv_model *model;
struct rtgui_mv_view *view;
rt_size_t first_data_changed_idx;
rt_size_t last_data_changed_idx;
};
#define _RTGUI_EVENT_MV_INIT_TYPE(T) \
rt_inline void RTGUI_EVENT_MV_MODEL_##T##_INIT(struct rtgui_event_mv_model *e) \
{ \
RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MV_MODEL); \
(e)->parent.user = RTGUI_MV_DATA_##T; \
} \
/* useless struct to allow trailing semicolon */ \
struct dummy
_RTGUI_EVENT_MV_INIT_TYPE(ADDED);
_RTGUI_EVENT_MV_INIT_TYPE(CHANGED);
_RTGUI_EVENT_MV_INIT_TYPE(DELETED);
#undef _RTGUI_EVENT_MV_INIT_TYPE
#define _RTGUI_EVENT_MV_IS_TYPE(T) \
rt_inline rt_bool_t RTGUI_EVENT_MV_MODEL_IS_##T(struct rtgui_event_mv_model *e) \
{ \
return e->parent.user == RTGUI_MV_DATA_##T; \
} \
/* useless struct to allow trailing semicolon */ \
struct dummy
_RTGUI_EVENT_MV_IS_TYPE(ADDED);
_RTGUI_EVENT_MV_IS_TYPE(CHANGED);
_RTGUI_EVENT_MV_IS_TYPE(DELETED);
#undef _RTGUI_EVENT_MV_IS_TYPE
#undef _RTGUI_EVENT_WIN_ELEMENTS #undef _RTGUI_EVENT_WIN_ELEMENTS
union rtgui_event_generic union rtgui_event_generic
{ {
struct rtgui_event base; struct rtgui_event base;
struct rtgui_event_application app_create; struct rtgui_event_application app_create;
struct rtgui_event_application app_destroy; struct rtgui_event_application app_destroy;
struct rtgui_event_application app_activate; struct rtgui_event_application app_activate;
struct rtgui_event_set_wm set_wm; struct rtgui_event_set_wm set_wm;
struct rtgui_event_win win_base; struct rtgui_event_win win_base;
struct rtgui_event_win_create win_create; struct rtgui_event_win_create win_create;
struct rtgui_event_win_move win_move; struct rtgui_event_win_move win_move;
struct rtgui_event_win_resize win_resize; struct rtgui_event_win_resize win_resize;
struct rtgui_event_win_destroy win_destroy; struct rtgui_event_win_destroy win_destroy;
struct rtgui_event_win_show win_show; struct rtgui_event_win_show win_show;
struct rtgui_event_win_hide win_hide; struct rtgui_event_win_hide win_hide;
struct rtgui_event_win_activate win_activate; struct rtgui_event_win_activate win_activate;
struct rtgui_event_win_deactivate win_deactivate; struct rtgui_event_win_deactivate win_deactivate;
struct rtgui_event_win_close win_close; struct rtgui_event_win_close win_close;
struct rtgui_event_win_modal_enter win_modal_enter; struct rtgui_event_win_modal_enter win_modal_enter;
struct rtgui_event_update_begin update_begin; struct rtgui_event_update_begin update_begin;
struct rtgui_event_update_end update_end; struct rtgui_event_update_end update_end;
struct rtgui_event_monitor monitor; struct rtgui_event_monitor monitor;
struct rtgui_event_paint paint; struct rtgui_event_paint paint;
struct rtgui_event_timer timer; struct rtgui_event_timer timer;
struct rtgui_event_update_toplvl update_toplvl; struct rtgui_event_update_toplvl update_toplvl;
struct rtgui_event_clip_info clip_info; struct rtgui_event_clip_info clip_info;
struct rtgui_event_mouse mouse; struct rtgui_event_mouse mouse;
struct rtgui_event_kbd kbd; struct rtgui_event_kbd kbd;
struct rtgui_event_command command; struct rtgui_event_scrollbar scrollbar;
struct rtgui_event_scrollbar scrollbar; struct rtgui_event_focused focused;
struct rtgui_event_focused focused; struct rtgui_event_resize resize;
struct rtgui_event_resize resize; struct rtgui_event_mv_model model;
struct rtgui_event_command command;
}; };
#endif #endif

View File

@ -14,8 +14,8 @@
#ifndef __RTGUI_FILERW_H__ #ifndef __RTGUI_FILERW_H__
#define __RTGUI_FILERW_H__ #define __RTGUI_FILERW_H__
#ifdef RTGUI_USING_DFS_FILERW #ifdef RTGUI_USING_DFS_FILERW
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#pragma warning(disable: 4996) #pragma warning(disable: 4996)
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
@ -28,33 +28,33 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#define RTGUI_FILE_SEEK_SET 0 #define RTGUI_FILE_SEEK_SET 0
#define RTGUI_FILE_SEEK_CUR 1 #define RTGUI_FILE_SEEK_CUR 1
#define RTGUI_FILE_SEEK_END 2 #define RTGUI_FILE_SEEK_END 2
struct rtgui_filerw struct rtgui_filerw
{ {
int (*seek) (struct rtgui_filerw *context, rt_off_t offset, int whence); int (*seek)(struct rtgui_filerw *context, rt_off_t offset, int whence);
int (*read) (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count); int (*read)(struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
int (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count); int (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int (*tell) (struct rtgui_filerw *context); int (*tell)(struct rtgui_filerw *context);
int (*eof) (struct rtgui_filerw *context); int (*eof)(struct rtgui_filerw *context);
int (*close)(struct rtgui_filerw *context); int (*close)(struct rtgui_filerw *context);
}; };
typedef struct rtgui_filerw rtgui_filerw_t; typedef struct rtgui_filerw rtgui_filerw_t;
struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* mode); struct rtgui_filerw *rtgui_filerw_create_file(const char *filename, const char *mode);
struct rtgui_filerw* rtgui_filerw_create_mem(const rt_uint8_t* mem, rt_size_t size); struct rtgui_filerw *rtgui_filerw_create_mem(const rt_uint8_t *mem, rt_size_t size);
int rtgui_filerw_seek (struct rtgui_filerw* context, rt_off_t offset, int whence); int rtgui_filerw_seek(struct rtgui_filerw *context, rt_off_t offset, int whence);
int rtgui_filerw_read (struct rtgui_filerw* context, void* buffer, rt_size_t size, rt_size_t count); int rtgui_filerw_read(struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
int rtgui_filerw_write(struct rtgui_filerw* context, const void* buffer, rt_size_t size, rt_size_t count); int rtgui_filerw_write(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int rtgui_filerw_tell (struct rtgui_filerw* context); int rtgui_filerw_tell(struct rtgui_filerw *context);
int rtgui_filerw_eof (struct rtgui_filerw* context); int rtgui_filerw_eof(struct rtgui_filerw *context);
int rtgui_filerw_close(struct rtgui_filerw* context); int rtgui_filerw_close(struct rtgui_filerw *context);
int rtgui_filerw_unlink(const char *filename); int rtgui_filerw_unlink(const char *filename);
/* get memory data from filerw memory object */ /* get memory data from filerw memory object */
const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context); const rt_uint8_t *rtgui_filerw_mem_getdata(struct rtgui_filerw *context);
#endif #endif

View File

@ -23,13 +23,13 @@ struct rtgui_rect;
struct rtgui_font_engine struct rtgui_font_engine
{ {
/* font engine function */ /* font engine function */
void (*font_init)(struct rtgui_font* font); void (*font_init)(struct rtgui_font *font);
void (*font_load)(struct rtgui_font* font); void (*font_load)(struct rtgui_font *font);
void (*font_draw_text)(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, void (*font_draw_text)(struct rtgui_font *font, struct rtgui_dc *dc, const char *text,
rt_ubase_t len, struct rtgui_rect* rect); rt_ubase_t len, struct rtgui_rect *rect);
void (*font_get_metrics)(struct rtgui_font* font, const char* text, struct rtgui_rect* rect); void (*font_get_metrics)(struct rtgui_font *font, const char *text, struct rtgui_rect *rect);
}; };
/* /*
@ -37,15 +37,15 @@ struct rtgui_font_engine
*/ */
struct rtgui_font_bitmap struct rtgui_font_bitmap
{ {
const rt_uint8_t* bmp; /* bitmap font data */ const rt_uint8_t *bmp; /* bitmap font data */
const rt_uint8_t* char_width; /* each character width, NULL for fixed font */ const rt_uint8_t *char_width; /* each character width, NULL for fixed font */
const rt_uint32_t* offset; /* offset for each character */ const rt_uint32_t *offset; /* offset for each character */
rt_uint16_t width; /* font width */ rt_uint16_t width; /* font width */
rt_uint16_t height; /* font height */ rt_uint16_t height; /* font height */
rt_uint8_t first_char; rt_uint8_t first_char;
rt_uint8_t last_char; rt_uint8_t last_char;
}; };
extern const struct rtgui_font_engine bmp_font_engine; extern const struct rtgui_font_engine bmp_font_engine;
@ -65,50 +65,54 @@ struct rtgui_hz_file_font
/* font size */ /* font size */
rt_uint16_t font_size; rt_uint16_t font_size;
rt_uint16_t font_data_size; rt_uint16_t font_data_size;
/* file descriptor */ /* file descriptor */
int fd; int fd;
/* font file name */ /* font file name */
const char* font_fn; const char *font_fn;
}; };
extern const struct rtgui_font_engine rtgui_hz_file_font_engine; extern const struct rtgui_font_engine rtgui_hz_file_font_engine;
struct rtgui_font struct rtgui_font
{ {
/* font name */ /* font name */
char* family; char *family;
/* font height */ /* font height */
rt_uint16_t height; rt_uint16_t height;
/* refer count */ /* refer count */
rt_uint32_t refer_count; rt_uint32_t refer_count;
/* font engine */ /* font engine */
const struct rtgui_font_engine* engine; const struct rtgui_font_engine *engine;
/* font private data */ /* font private data */
void* data; void *data;
/* the font list */ /* the font list */
rtgui_list_t list; rtgui_list_t list;
}; };
typedef struct rtgui_font rtgui_font_t; typedef struct rtgui_font rtgui_font_t;
void rtgui_font_system_init(void); void rtgui_font_system_init(void);
void rtgui_font_system_add_font(struct rtgui_font* font); void rtgui_font_system_add_font(struct rtgui_font *font);
void rtgui_font_system_remove_font(struct rtgui_font* font); void rtgui_font_system_remove_font(struct rtgui_font *font);
struct rtgui_font* rtgui_font_default(void); struct rtgui_font *rtgui_font_default(void);
void rtgui_font_set_defaut(struct rtgui_font* font); void rtgui_font_set_defaut(struct rtgui_font *font);
struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height); struct rtgui_font *rtgui_font_refer(const char *family, rt_uint16_t height);
void rtgui_font_derefer(struct rtgui_font* font); void rtgui_font_derefer(struct rtgui_font *font);
/* draw a text */ /* draw a text */
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect); void rtgui_font_draw(struct rtgui_font *font, struct rtgui_dc *dc, const char *text, rt_ubase_t len, struct rtgui_rect *rect);
int rtgui_font_get_string_width(struct rtgui_font* font, const char* text); int rtgui_font_get_string_width(struct rtgui_font *font, const char *text);
void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, struct rtgui_rect* rect); void rtgui_font_get_metrics(struct rtgui_font *font, const char *text, struct rtgui_rect *rect);
/* used by stract font */
#define FONT_BMP_DATA_BEGIN
#define FONT_BMP_DATA_END
#endif #endif

View File

@ -4,7 +4,7 @@
#include <rtgui/dc.h> #include <rtgui/dc.h>
#include <rtgui/font.h> #include <rtgui/font.h>
rtgui_font_t* rtgui_freetype_font_create(const char* filename, int bold, int italic, rt_size_t size); rtgui_font_t *rtgui_freetype_font_create(const char *filename, int bold, int italic, rt_size_t size);
void rtgui_freetype_font_destroy(rtgui_font_t* font); void rtgui_freetype_font_destroy(rtgui_font_t *font);
#endif #endif

View File

@ -19,48 +19,48 @@
#include <rtgui/region.h> #include <rtgui/region.h>
enum rtgui_img_zoom enum rtgui_img_zoom
{ {
RTGUI_IMG_ZOOM_NEAREST, RTGUI_IMG_ZOOM_NEAREST,
RTGUI_IMG_ZOOM_BILINEAR RTGUI_IMG_ZOOM_BILINEAR
}; };
struct rtgui_image; struct rtgui_image;
struct rtgui_image_engine struct rtgui_image_engine
{ {
const char* name; const char *name;
struct rtgui_list_node list; struct rtgui_list_node list;
/* image engine function */ /* image engine function */
rt_bool_t (*image_check)(struct rtgui_filerw* file); rt_bool_t (*image_check)(struct rtgui_filerw *file);
rt_bool_t (*image_load)(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load); rt_bool_t (*image_load)(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
void (*image_unload)(struct rtgui_image* image); void (*image_unload)(struct rtgui_image *image);
void (*image_blit)(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect); void (*image_blit)(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
struct rtgui_image* (*image_zoom)(struct rtgui_image* image, float scalew, float scaleh, rt_uint32_t mode); struct rtgui_image *(*image_zoom)(struct rtgui_image *image, float scalew, float scaleh, rt_uint32_t mode);
struct rtgui_image* (*image_rotate)(struct rtgui_image* image, float angle); struct rtgui_image *(*image_rotate)(struct rtgui_image *image, float angle);
}; };
struct rtgui_image_palette struct rtgui_image_palette
{ {
rtgui_color_t* colors; rtgui_color_t *colors;
rt_uint32_t ncolors; rt_uint32_t ncolors;
}; };
typedef struct rtgui_image_palette rtgui_image_palette_t; typedef struct rtgui_image_palette rtgui_image_palette_t;
struct rtgui_image struct rtgui_image
{ {
/* image metrics */ /* image metrics */
rt_uint16_t w, h; rt_uint16_t w, h;
/* image engine */ /* image engine */
const struct rtgui_image_engine* engine; const struct rtgui_image_engine *engine;
/* image palette */ /* image palette */
rtgui_image_palette_t* palette; rtgui_image_palette_t *palette;
/* image private data */ /* image private data */
void* data; void *data;
}; };
typedef struct rtgui_image rtgui_image_t; typedef struct rtgui_image rtgui_image_t;
@ -68,24 +68,24 @@ typedef struct rtgui_image rtgui_image_t;
void rtgui_system_image_init(void); void rtgui_system_image_init(void);
#if defined(RTGUI_USING_DFS_FILERW) #if defined(RTGUI_USING_DFS_FILERW)
struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn); struct rtgui_image_engine *rtgui_image_get_engine_by_filename(const char *fn);
struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load); struct rtgui_image *rtgui_image_create_from_file(const char *type, const char *filename, rt_bool_t load);
struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load); struct rtgui_image *rtgui_image_create(const char *filename, rt_bool_t load);
#endif #endif
struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load); struct rtgui_image *rtgui_image_create_from_mem(const char *type, const rt_uint8_t *data, rt_size_t length, rt_bool_t load);
void rtgui_image_destroy(struct rtgui_image* image); void rtgui_image_destroy(struct rtgui_image *image);
/* get image's rect */ /* get image's rect */
void rtgui_image_get_rect(struct rtgui_image* image, struct rtgui_rect* rect); void rtgui_image_get_rect(struct rtgui_image *image, struct rtgui_rect *rect);
/* register an image engine */ /* register an image engine */
void rtgui_image_register_engine(struct rtgui_image_engine* engine); void rtgui_image_register_engine(struct rtgui_image_engine *engine);
/* blit an image on DC */ /* blit an image on DC */
void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect); void rtgui_image_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors); struct rtgui_image_palette *rtgui_image_palette_create(rt_uint32_t ncolors);
rtgui_image_t* rtgui_image_zoom(rtgui_image_t* image, float scalew, float scaleh, rt_uint32_t mode); rtgui_image_t *rtgui_image_zoom(rtgui_image_t *image, float scalew, float scaleh, rt_uint32_t mode);
rtgui_image_t* rtgui_image_rotate(rtgui_image_t* image, float angle); rtgui_image_t *rtgui_image_rotate(rtgui_image_t *image, float angle);
#endif #endif

View File

@ -18,27 +18,27 @@
struct rtgui_image_bmp_header struct rtgui_image_bmp_header
{ {
/* The Win32 BMP file header (14 bytes) */ /* The Win32 BMP file header (14 bytes) */
rt_uint16_t bfType; rt_uint16_t bfType;
rt_uint32_t bfSize; rt_uint32_t bfSize;
rt_uint16_t bfReserved1; rt_uint16_t bfReserved1;
rt_uint16_t bfReserved2; rt_uint16_t bfReserved2;
rt_uint32_t bfOffBits; rt_uint32_t bfOffBits;
/* The Win32 BITMAPINFOHEADER struct (40 bytes) */ /* The Win32 BITMAPINFOHEADER struct (40 bytes) */
rt_uint32_t biSize; rt_uint32_t biSize;
rt_int32_t biWidth; rt_int32_t biWidth;
rt_int32_t biHeight; rt_int32_t biHeight;
rt_uint16_t biPlanes; rt_uint16_t biPlanes;
rt_uint16_t biBitCount; rt_uint16_t biBitCount;
rt_uint32_t biCompression; rt_uint32_t biCompression;
rt_uint32_t biSizeImage; rt_uint32_t biSizeImage;
rt_int32_t biXPelsPerMeter; rt_int32_t biXPelsPerMeter;
rt_int32_t biYPelsPerMeter; rt_int32_t biYPelsPerMeter;
rt_uint32_t biClrUsed; rt_uint32_t biClrUsed;
rt_uint32_t biClrImportant; rt_uint32_t biClrImportant;
}; };
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#pragma warning(disable : 4103) #pragma warning(disable : 4103)
#endif #endif
void rtgui_image_bmp_init(void); void rtgui_image_bmp_init(void);

View File

@ -8,20 +8,20 @@
/* image item in image container */ /* image item in image container */
struct rtgui_image_item struct rtgui_image_item
{ {
rtgui_image_t *image; rtgui_image_t *image;
char *filename; char *filename;
rt_uint32_t refcount; rt_uint32_t refcount;
}; };
typedef struct rtgui_image_item rtgui_image_item_t; typedef struct rtgui_image_item rtgui_image_item_t;
void rtgui_system_image_container_init(rt_bool_t load); void rtgui_system_image_container_init(rt_bool_t load);
#ifdef RTGUI_USING_DFS_FILERW #ifdef RTGUI_USING_DFS_FILERW
rtgui_image_item_t* rtgui_image_container_get(const char* filename); rtgui_image_item_t *rtgui_image_container_get(const char *filename);
#endif #endif
rtgui_image_item_t* rtgui_image_container_get_from_mem(const rt_uint8_t* mem, const char* type, rt_uint32_t len); rtgui_image_item_t *rtgui_image_container_get_from_mem(const rt_uint8_t *mem, const char *type, rt_uint32_t len);
void rtgui_image_container_put(rtgui_image_item_t* item); void rtgui_image_container_put(rtgui_image_item_t *item);
#endif #endif
#endif #endif

View File

@ -18,20 +18,20 @@
struct rtgui_image_hdcmm struct rtgui_image_hdcmm
{ {
struct rtgui_image parent; struct rtgui_image parent;
/* hdc image information */ /* hdc image information */
rt_uint16_t byte_per_pixel; rt_uint16_t byte_per_pixel;
rt_uint16_t pitch; rt_uint16_t pitch;
rt_uint8_t *pixels; rt_uint8_t *pixels;
}; };
void rtgui_image_hdc_init(void); void rtgui_image_hdc_init(void);
extern const struct rtgui_image_engine rtgui_image_hdcmm_engine; extern const struct rtgui_image_engine rtgui_image_hdcmm_engine;
#define HDC_HEADER_SIZE (5 * 4) #define HDC_HEADER_SIZE (5 * 4)
#define RTGUI_IMAGE_HDC_DEF(bpp, w, h, pixels) \ #define RTGUI_IMAGE_HDC_DEF(bpp, w, h, pixels) \
{{w, h, &rtgui_image_hdcmm_engine, RT_NULL}, bpp, (bpp * w), ((rt_uint8_t*)pixels + HDC_HEADER_SIZE)} {{w, h, &rtgui_image_hdcmm_engine, RT_NULL}, bpp, (bpp * w), ((rt_uint8_t*)pixels + HDC_HEADER_SIZE)}
#endif #endif

View File

@ -17,277 +17,279 @@
/* The keyboard key have been cleverly chosen to map to ASCII */ /* The keyboard key have been cleverly chosen to map to ASCII */
typedef enum typedef enum
{ {
RTGUIK_UNKNOWN = 0, RTGUIK_UNKNOWN = 0,
RTGUIK_FIRST = 0, RTGUIK_FIRST = 0,
RTGUIK_BACKSPACE = 8, RTGUIK_BACKSPACE = 8,
RTGUIK_TAB = 9, RTGUIK_TAB = 9,
RTGUIK_CLEAR = 12, RTGUIK_CLEAR = 12,
RTGUIK_RETURN = 13, RTGUIK_RETURN = 13,
RTGUIK_PAUSE = 19, RTGUIK_PAUSE = 19,
RTGUIK_ESCAPE = 27, RTGUIK_ESCAPE = 27,
RTGUIK_SPACE = 32, RTGUIK_SPACE = 32,
RTGUIK_EXCLAIM = 33, RTGUIK_EXCLAIM = 33,
RTGUIK_QUOTEDBL = 34, RTGUIK_QUOTEDBL = 34,
RTGUIK_HASH = 35, RTGUIK_HASH = 35,
RTGUIK_DOLLAR = 36, RTGUIK_DOLLAR = 36,
RTGUIK_AMPERSAND = 38, RTGUIK_AMPERSAND = 38,
RTGUIK_QUOTE = 39, RTGUIK_QUOTE = 39,
RTGUIK_LEFTPAREN = 40, RTGUIK_LEFTPAREN = 40,
RTGUIK_RIGHTPAREN = 41, RTGUIK_RIGHTPAREN = 41,
RTGUIK_ASTERISK = 42, RTGUIK_ASTERISK = 42,
RTGUIK_PLUS = 43, RTGUIK_PLUS = 43,
RTGUIK_COMMA = 44, RTGUIK_COMMA = 44,
RTGUIK_MINUS = 45, RTGUIK_MINUS = 45,
RTGUIK_PERIOD = 46, RTGUIK_PERIOD = 46,
RTGUIK_SLASH = 47, RTGUIK_SLASH = 47,
RTGUIK_0 = 48, RTGUIK_0 = 48,
RTGUIK_1 = 49, RTGUIK_1 = 49,
RTGUIK_2 = 50, RTGUIK_2 = 50,
RTGUIK_3 = 51, RTGUIK_3 = 51,
RTGUIK_4 = 52, RTGUIK_4 = 52,
RTGUIK_5 = 53, RTGUIK_5 = 53,
RTGUIK_6 = 54, RTGUIK_6 = 54,
RTGUIK_7 = 55, RTGUIK_7 = 55,
RTGUIK_8 = 56, RTGUIK_8 = 56,
RTGUIK_9 = 57, RTGUIK_9 = 57,
RTGUIK_COLON = 58, RTGUIK_COLON = 58,
RTGUIK_SEMICOLON = 59, RTGUIK_SEMICOLON = 59,
RTGUIK_LESS = 60, RTGUIK_LESS = 60,
RTGUIK_EQUALS = 61, RTGUIK_EQUALS = 61,
RTGUIK_GREATER = 62, RTGUIK_GREATER = 62,
RTGUIK_QUESTION = 63, RTGUIK_QUESTION = 63,
RTGUIK_AT = 64, RTGUIK_AT = 64,
/* /*
Skip uppercase letters Skip uppercase letters
*/ */
RTGUIK_LEFTBRACKET = 91, RTGUIK_LEFTBRACKET = 91,
RTGUIK_BACKSLASH = 92, RTGUIK_BACKSLASH = 92,
RTGUIK_RIGHTBRACKET = 93, RTGUIK_RIGHTBRACKET = 93,
RTGUIK_CARET = 94, RTGUIK_CARET = 94,
RTGUIK_UNDERSCORE = 95, RTGUIK_UNDERSCORE = 95,
RTGUIK_BACKQUOTE = 96, RTGUIK_BACKQUOTE = 96,
RTGUIK_a = 97, RTGUIK_a = 97,
RTGUIK_b = 98, RTGUIK_b = 98,
RTGUIK_c = 99, RTGUIK_c = 99,
RTGUIK_d = 100, RTGUIK_d = 100,
RTGUIK_e = 101, RTGUIK_e = 101,
RTGUIK_f = 102, RTGUIK_f = 102,
RTGUIK_g = 103, RTGUIK_g = 103,
RTGUIK_h = 104, RTGUIK_h = 104,
RTGUIK_i = 105, RTGUIK_i = 105,
RTGUIK_j = 106, RTGUIK_j = 106,
RTGUIK_k = 107, RTGUIK_k = 107,
RTGUIK_l = 108, RTGUIK_l = 108,
RTGUIK_m = 109, RTGUIK_m = 109,
RTGUIK_n = 110, RTGUIK_n = 110,
RTGUIK_o = 111, RTGUIK_o = 111,
RTGUIK_p = 112, RTGUIK_p = 112,
RTGUIK_q = 113, RTGUIK_q = 113,
RTGUIK_r = 114, RTGUIK_r = 114,
RTGUIK_s = 115, RTGUIK_s = 115,
RTGUIK_t = 116, RTGUIK_t = 116,
RTGUIK_u = 117, RTGUIK_u = 117,
RTGUIK_v = 118, RTGUIK_v = 118,
RTGUIK_w = 119, RTGUIK_w = 119,
RTGUIK_x = 120, RTGUIK_x = 120,
RTGUIK_y = 121, RTGUIK_y = 121,
RTGUIK_z = 122, RTGUIK_z = 122,
RTGUIK_DELETE = 127, RTGUIK_DELETE = 127,
/* International keyboard */ /* International keyboard */
RTGUIK_WORLD_0 = 160, /* 0xA0 */ RTGUIK_WORLD_0 = 160, /* 0xA0 */
RTGUIK_WORLD_1 = 161, RTGUIK_WORLD_1 = 161,
RTGUIK_WORLD_2 = 162, RTGUIK_WORLD_2 = 162,
RTGUIK_WORLD_3 = 163, RTGUIK_WORLD_3 = 163,
RTGUIK_WORLD_4 = 164, RTGUIK_WORLD_4 = 164,
RTGUIK_WORLD_5 = 165, RTGUIK_WORLD_5 = 165,
RTGUIK_WORLD_6 = 166, RTGUIK_WORLD_6 = 166,
RTGUIK_WORLD_7 = 167, RTGUIK_WORLD_7 = 167,
RTGUIK_WORLD_8 = 168, RTGUIK_WORLD_8 = 168,
RTGUIK_WORLD_9 = 169, RTGUIK_WORLD_9 = 169,
RTGUIK_WORLD_10 = 170, RTGUIK_WORLD_10 = 170,
RTGUIK_WORLD_11 = 171, RTGUIK_WORLD_11 = 171,
RTGUIK_WORLD_12 = 172, RTGUIK_WORLD_12 = 172,
RTGUIK_WORLD_13 = 173, RTGUIK_WORLD_13 = 173,
RTGUIK_WORLD_14 = 174, RTGUIK_WORLD_14 = 174,
RTGUIK_WORLD_15 = 175, RTGUIK_WORLD_15 = 175,
RTGUIK_WORLD_16 = 176, RTGUIK_WORLD_16 = 176,
RTGUIK_WORLD_17 = 177, RTGUIK_WORLD_17 = 177,
RTGUIK_WORLD_18 = 178, RTGUIK_WORLD_18 = 178,
RTGUIK_WORLD_19 = 179, RTGUIK_WORLD_19 = 179,
RTGUIK_WORLD_20 = 180, RTGUIK_WORLD_20 = 180,
RTGUIK_WORLD_21 = 181, RTGUIK_WORLD_21 = 181,
RTGUIK_WORLD_22 = 182, RTGUIK_WORLD_22 = 182,
RTGUIK_WORLD_23 = 183, RTGUIK_WORLD_23 = 183,
RTGUIK_WORLD_24 = 184, RTGUIK_WORLD_24 = 184,
RTGUIK_WORLD_25 = 185, RTGUIK_WORLD_25 = 185,
RTGUIK_WORLD_26 = 186, RTGUIK_WORLD_26 = 186,
RTGUIK_WORLD_27 = 187, RTGUIK_WORLD_27 = 187,
RTGUIK_WORLD_28 = 188, RTGUIK_WORLD_28 = 188,
RTGUIK_WORLD_29 = 189, RTGUIK_WORLD_29 = 189,
RTGUIK_WORLD_30 = 190, RTGUIK_WORLD_30 = 190,
RTGUIK_WORLD_31 = 191, RTGUIK_WORLD_31 = 191,
RTGUIK_WORLD_32 = 192, RTGUIK_WORLD_32 = 192,
RTGUIK_WORLD_33 = 193, RTGUIK_WORLD_33 = 193,
RTGUIK_WORLD_34 = 194, RTGUIK_WORLD_34 = 194,
RTGUIK_WORLD_35 = 195, RTGUIK_WORLD_35 = 195,
RTGUIK_WORLD_36 = 196, RTGUIK_WORLD_36 = 196,
RTGUIK_WORLD_37 = 197, RTGUIK_WORLD_37 = 197,
RTGUIK_WORLD_38 = 198, RTGUIK_WORLD_38 = 198,
RTGUIK_WORLD_39 = 199, RTGUIK_WORLD_39 = 199,
RTGUIK_WORLD_40 = 200, RTGUIK_WORLD_40 = 200,
RTGUIK_WORLD_41 = 201, RTGUIK_WORLD_41 = 201,
RTGUIK_WORLD_42 = 202, RTGUIK_WORLD_42 = 202,
RTGUIK_WORLD_43 = 203, RTGUIK_WORLD_43 = 203,
RTGUIK_WORLD_44 = 204, RTGUIK_WORLD_44 = 204,
RTGUIK_WORLD_45 = 205, RTGUIK_WORLD_45 = 205,
RTGUIK_WORLD_46 = 206, RTGUIK_WORLD_46 = 206,
RTGUIK_WORLD_47 = 207, RTGUIK_WORLD_47 = 207,
RTGUIK_WORLD_48 = 208, RTGUIK_WORLD_48 = 208,
RTGUIK_WORLD_49 = 209, RTGUIK_WORLD_49 = 209,
RTGUIK_WORLD_50 = 210, RTGUIK_WORLD_50 = 210,
RTGUIK_WORLD_51 = 211, RTGUIK_WORLD_51 = 211,
RTGUIK_WORLD_52 = 212, RTGUIK_WORLD_52 = 212,
RTGUIK_WORLD_53 = 213, RTGUIK_WORLD_53 = 213,
RTGUIK_WORLD_54 = 214, RTGUIK_WORLD_54 = 214,
RTGUIK_WORLD_55 = 215, RTGUIK_WORLD_55 = 215,
RTGUIK_WORLD_56 = 216, RTGUIK_WORLD_56 = 216,
RTGUIK_WORLD_57 = 217, RTGUIK_WORLD_57 = 217,
RTGUIK_WORLD_58 = 218, RTGUIK_WORLD_58 = 218,
RTGUIK_WORLD_59 = 219, RTGUIK_WORLD_59 = 219,
RTGUIK_WORLD_60 = 220, RTGUIK_WORLD_60 = 220,
RTGUIK_WORLD_61 = 221, RTGUIK_WORLD_61 = 221,
RTGUIK_WORLD_62 = 222, RTGUIK_WORLD_62 = 222,
RTGUIK_WORLD_63 = 223, RTGUIK_WORLD_63 = 223,
RTGUIK_WORLD_64 = 224, RTGUIK_WORLD_64 = 224,
RTGUIK_WORLD_65 = 225, RTGUIK_WORLD_65 = 225,
RTGUIK_WORLD_66 = 226, RTGUIK_WORLD_66 = 226,
RTGUIK_WORLD_67 = 227, RTGUIK_WORLD_67 = 227,
RTGUIK_WORLD_68 = 228, RTGUIK_WORLD_68 = 228,
RTGUIK_WORLD_69 = 229, RTGUIK_WORLD_69 = 229,
RTGUIK_WORLD_70 = 230, RTGUIK_WORLD_70 = 230,
RTGUIK_WORLD_71 = 231, RTGUIK_WORLD_71 = 231,
RTGUIK_WORLD_72 = 232, RTGUIK_WORLD_72 = 232,
RTGUIK_WORLD_73 = 233, RTGUIK_WORLD_73 = 233,
RTGUIK_WORLD_74 = 234, RTGUIK_WORLD_74 = 234,
RTGUIK_WORLD_75 = 235, RTGUIK_WORLD_75 = 235,
RTGUIK_WORLD_76 = 236, RTGUIK_WORLD_76 = 236,
RTGUIK_WORLD_77 = 237, RTGUIK_WORLD_77 = 237,
RTGUIK_WORLD_78 = 238, RTGUIK_WORLD_78 = 238,
RTGUIK_WORLD_79 = 239, RTGUIK_WORLD_79 = 239,
RTGUIK_WORLD_80 = 240, RTGUIK_WORLD_80 = 240,
RTGUIK_WORLD_81 = 241, RTGUIK_WORLD_81 = 241,
RTGUIK_WORLD_82 = 242, RTGUIK_WORLD_82 = 242,
RTGUIK_WORLD_83 = 243, RTGUIK_WORLD_83 = 243,
RTGUIK_WORLD_84 = 244, RTGUIK_WORLD_84 = 244,
RTGUIK_WORLD_85 = 245, RTGUIK_WORLD_85 = 245,
RTGUIK_WORLD_86 = 246, RTGUIK_WORLD_86 = 246,
RTGUIK_WORLD_87 = 247, RTGUIK_WORLD_87 = 247,
RTGUIK_WORLD_88 = 248, RTGUIK_WORLD_88 = 248,
RTGUIK_WORLD_89 = 249, RTGUIK_WORLD_89 = 249,
RTGUIK_WORLD_90 = 250, RTGUIK_WORLD_90 = 250,
RTGUIK_WORLD_91 = 251, RTGUIK_WORLD_91 = 251,
RTGUIK_WORLD_92 = 252, RTGUIK_WORLD_92 = 252,
RTGUIK_WORLD_93 = 253, RTGUIK_WORLD_93 = 253,
RTGUIK_WORLD_94 = 254, RTGUIK_WORLD_94 = 254,
RTGUIK_WORLD_95 = 255, /* 0xFF */ RTGUIK_WORLD_95 = 255, /* 0xFF */
/* Numeric keypad */ /* Numeric keypad */
RTGUIK_KP0 = 256, RTGUIK_KP0 = 256,
RTGUIK_KP1 = 257, RTGUIK_KP1 = 257,
RTGUIK_KP2 = 258, RTGUIK_KP2 = 258,
RTGUIK_KP3 = 259, RTGUIK_KP3 = 259,
RTGUIK_KP4 = 260, RTGUIK_KP4 = 260,
RTGUIK_KP5 = 261, RTGUIK_KP5 = 261,
RTGUIK_KP6 = 262, RTGUIK_KP6 = 262,
RTGUIK_KP7 = 263, RTGUIK_KP7 = 263,
RTGUIK_KP8 = 264, RTGUIK_KP8 = 264,
RTGUIK_KP9 = 265, RTGUIK_KP9 = 265,
RTGUIK_KP_PERIOD = 266, RTGUIK_KP_PERIOD = 266,
RTGUIK_KP_DIVIDE = 267, RTGUIK_KP_DIVIDE = 267,
RTGUIK_KP_MULTIPLY = 268, RTGUIK_KP_MULTIPLY = 268,
RTGUIK_KP_MINUS = 269, RTGUIK_KP_MINUS = 269,
RTGUIK_KP_PLUS = 270, RTGUIK_KP_PLUS = 270,
RTGUIK_KP_ENTER = 271, RTGUIK_KP_ENTER = 271,
RTGUIK_KP_EQUALS = 272, RTGUIK_KP_EQUALS = 272,
/* Arrows + Home/End pad */ /* Arrows + Home/End pad */
RTGUIK_UP = 273, RTGUIK_UP = 273,
RTGUIK_DOWN = 274, RTGUIK_DOWN = 274,
RTGUIK_RIGHT = 275, RTGUIK_RIGHT = 275,
RTGUIK_LEFT = 276, RTGUIK_LEFT = 276,
RTGUIK_INSERT = 277, RTGUIK_INSERT = 277,
RTGUIK_HOME = 278, RTGUIK_HOME = 278,
RTGUIK_END = 279, RTGUIK_END = 279,
RTGUIK_PAGEUP = 280, RTGUIK_PAGEUP = 280,
RTGUIK_PAGEDOWN = 281, RTGUIK_PAGEDOWN = 281,
/* Function keys */ /* Function keys */
RTGUIK_F1 = 282, RTGUIK_F1 = 282,
RTGUIK_F2 = 283, RTGUIK_F2 = 283,
RTGUIK_F3 = 284, RTGUIK_F3 = 284,
RTGUIK_F4 = 285, RTGUIK_F4 = 285,
RTGUIK_F5 = 286, RTGUIK_F5 = 286,
RTGUIK_F6 = 287, RTGUIK_F6 = 287,
RTGUIK_F7 = 288, RTGUIK_F7 = 288,
RTGUIK_F8 = 289, RTGUIK_F8 = 289,
RTGUIK_F9 = 290, RTGUIK_F9 = 290,
RTGUIK_F10 = 291, RTGUIK_F10 = 291,
RTGUIK_F11 = 292, RTGUIK_F11 = 292,
RTGUIK_F12 = 293, RTGUIK_F12 = 293,
RTGUIK_F13 = 294, RTGUIK_F13 = 294,
RTGUIK_F14 = 295, RTGUIK_F14 = 295,
RTGUIK_F15 = 296, RTGUIK_F15 = 296,
/* Key state modifier keys */ /* Key state modifier keys */
RTGUIK_NUMLOCK = 300, RTGUIK_NUMLOCK = 300,
RTGUIK_CAPSLOCK = 301, RTGUIK_CAPSLOCK = 301,
RTGUIK_SCROLLOCK = 302, RTGUIK_SCROLLOCK = 302,
RTGUIK_RSHIFT = 303, RTGUIK_RSHIFT = 303,
RTGUIK_LSHIFT = 304, RTGUIK_LSHIFT = 304,
RTGUIK_RCTRL = 305, RTGUIK_RCTRL = 305,
RTGUIK_LCTRL = 306, RTGUIK_LCTRL = 306,
RTGUIK_RALT = 307, RTGUIK_RALT = 307,
RTGUIK_LALT = 308, RTGUIK_LALT = 308,
RTGUIK_RMETA = 309, RTGUIK_RMETA = 309,
RTGUIK_LMETA = 310, RTGUIK_LMETA = 310,
RTGUIK_LSUPER = 311, /* Left "Windows" key */ RTGUIK_LSUPER = 311, /* Left "Windows" key */
RTGUIK_RSUPER = 312, /* Right "Windows" key */ RTGUIK_RSUPER = 312, /* Right "Windows" key */
RTGUIK_MODE = 313, /* "Alt Gr" key */ RTGUIK_MODE = 313, /* "Alt Gr" key */
RTGUIK_COMPOSE = 314, /* Multi-key compose key */ RTGUIK_COMPOSE = 314, /* Multi-key compose key */
/* Miscellaneous function keys */ /* Miscellaneous function keys */
RTGUIK_HELP = 315, RTGUIK_HELP = 315,
RTGUIK_PRINT = 316, RTGUIK_PRINT = 316,
RTGUIK_SYSREQ = 317, RTGUIK_SYSREQ = 317,
RTGUIK_BREAK = 318, RTGUIK_BREAK = 318,
RTGUIK_MENU = 319, RTGUIK_MENU = 319,
RTGUIK_POWER = 320, /* Power key */ RTGUIK_POWER = 320, /* Power key */
RTGUIK_LAST RTGUIK_LAST
} RTGUI_KBD_KEY; } RTGUI_KBD_KEY;
/* Enumeration of valid key mods (possibly OR'd together) */ /* Enumeration of valid key mods (possibly OR'd together) */
typedef enum { typedef enum
RTGUI_KMOD_NONE = 0x0000, {
RTGUI_KMOD_LSHIFT = 0x0001, RTGUI_KMOD_NONE = 0x0000,
RTGUI_KMOD_RSHIFT = 0x0002, RTGUI_KMOD_LSHIFT = 0x0001,
RTGUI_KMOD_LCTRL = 0x0040, RTGUI_KMOD_RSHIFT = 0x0002,
RTGUI_KMOD_RCTRL = 0x0080, RTGUI_KMOD_LCTRL = 0x0040,
RTGUI_KMOD_LALT = 0x0100, RTGUI_KMOD_RCTRL = 0x0080,
RTGUI_KMOD_RALT = 0x0200, RTGUI_KMOD_LALT = 0x0100,
RTGUI_KMOD_LMETA = 0x0400, RTGUI_KMOD_RALT = 0x0200,
RTGUI_KMOD_RMETA = 0x0800, RTGUI_KMOD_LMETA = 0x0400,
RTGUI_KMOD_NUM = 0x1000, RTGUI_KMOD_RMETA = 0x0800,
RTGUI_KMOD_CAPS = 0x2000, RTGUI_KMOD_NUM = 0x1000,
RTGUI_KMOD_MODE = 0x4000, RTGUI_KMOD_CAPS = 0x2000,
RTGUI_KMOD_RESERVED = 0x8000 RTGUI_KMOD_MODE = 0x4000,
RTGUI_KMOD_RESERVED = 0x8000
} RTGUI_KBD_MOD; } RTGUI_KBD_MOD;
typedef enum { typedef enum
RTGUI_KEYDOWN, /* Keys pressed */ {
RTGUI_KEYUP, /* Keys released */ RTGUI_KEYDOWN, /* Keys pressed */
RTGUI_KEYUP, /* Keys released */
} RTGUI_KBD_TYPE; } RTGUI_KBD_TYPE;
#endif #endif

View File

@ -18,49 +18,49 @@
struct rtgui_list_node struct rtgui_list_node
{ {
struct rtgui_list_node* next; struct rtgui_list_node *next;
}; };
typedef struct rtgui_list_node rtgui_list_t; typedef struct rtgui_list_node rtgui_list_t;
rt_inline void rtgui_list_init(rtgui_list_t *l) rt_inline void rtgui_list_init(rtgui_list_t *l)
{ {
l->next = (struct rtgui_list_node *)0; l->next = (struct rtgui_list_node *)0;
} }
rt_inline void rtgui_list_append(rtgui_list_t *l, rtgui_list_t *n) rt_inline void rtgui_list_append(rtgui_list_t *l, rtgui_list_t *n)
{ {
struct rtgui_list_node* node; struct rtgui_list_node *node;
node = l; node = l;
while (node->next) node = node->next; while (node->next) node = node->next;
/* append the node to the tail */ /* append the node to the tail */
node->next = n; node->next = n;
n->next = (struct rtgui_list_node*) 0; n->next = (struct rtgui_list_node *) 0;
} }
rt_inline void rtgui_list_insert(rtgui_list_t *l, rtgui_list_t *n) rt_inline void rtgui_list_insert(rtgui_list_t *l, rtgui_list_t *n)
{ {
n->next = l->next; n->next = l->next;
l->next = n; l->next = n;
} }
rt_inline rtgui_list_t* rtgui_list_remove(rtgui_list_t *l, rtgui_list_t *n) rt_inline rtgui_list_t *rtgui_list_remove(rtgui_list_t *l, rtgui_list_t *n)
{ {
/* remove slist head */ /* remove slist head */
struct rtgui_list_node* node = l; struct rtgui_list_node *node = l;
while (node->next && node->next != n) node = node->next; while (node->next && node->next != n) node = node->next;
/* remove node */ /* remove node */
if (node->next != (rtgui_list_t *)0) node->next = node->next->next; if (node->next != (rtgui_list_t *)0) node->next = node->next->next;
return l; return l;
} }
#define rtgui_list_entry(node, type, member) \ #define rtgui_list_entry(node, type, member) \
((type *)((char*)(node)-(unsigned long)(&((type *)0)->member))) ((type *)((char*)(node)-(unsigned long)(&((type *)0)->member)))
#define rtgui_list_foreach(node, list) \ #define rtgui_list_foreach(node, list) \
for ((node) = (list)->next; (node) != RT_NULL; (node) = (node)->next) for ((node) = (list)->next; (node) != RT_NULL; (node) = (node)->next)
#endif #endif

View File

@ -20,81 +20,81 @@
extern "C" { extern "C" {
#endif #endif
typedef struct rtgui_region_data rtgui_region_data_t; typedef struct rtgui_region_data rtgui_region_data_t;
struct rtgui_region_data struct rtgui_region_data
{ {
rt_uint32_t size; rt_uint32_t size;
rt_uint32_t numRects; rt_uint32_t numRects;
/* XXX: And why, exactly, do we have this bogus struct definition? */ /* XXX: And why, exactly, do we have this bogus struct definition? */
/* rtgui_rect_t rects[size]; in memory but not explicitly declared */ /* rtgui_rect_t rects[size]; in memory but not explicitly declared */
}; };
typedef struct rtgui_region typedef struct rtgui_region
{ {
rtgui_rect_t extents; rtgui_rect_t extents;
rtgui_region_data_t *data; rtgui_region_data_t *data;
}rtgui_region_t; } rtgui_region_t;
typedef enum typedef enum
{ {
RTGUI_REGION_STATUS_FAILURE, RTGUI_REGION_STATUS_FAILURE,
RTGUI_REGION_STATUS_SUCCESS RTGUI_REGION_STATUS_SUCCESS
}rtgui_region_status_t; } rtgui_region_status_t;
/* creation/destruction */ /* creation/destruction */
void rtgui_region_init(rtgui_region_t *region); void rtgui_region_init(rtgui_region_t *region);
void rtgui_region_init_rect(rtgui_region_t *region, void rtgui_region_init_rect(rtgui_region_t *region,
int x, int y, unsigned int width, unsigned int height); int x, int y, unsigned int width, unsigned int height);
void rtgui_region_init_with_extents(rtgui_region_t *region, const rtgui_rect_t *extents); void rtgui_region_init_with_extents(rtgui_region_t *region, const rtgui_rect_t *extents);
void rtgui_region_fini (rtgui_region_t *region); void rtgui_region_fini(rtgui_region_t *region);
void rtgui_region_translate (rtgui_region_t *region, int x, int y); void rtgui_region_translate(rtgui_region_t *region, int x, int y);
rtgui_region_status_t rtgui_region_copy (rtgui_region_t *dest, rtgui_region_t *source); rtgui_region_status_t rtgui_region_copy(rtgui_region_t *dest, rtgui_region_t *source);
rtgui_region_status_t rtgui_region_intersect (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2); rtgui_region_status_t rtgui_region_intersect(rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2);
rtgui_region_status_t rtgui_region_intersect_rect (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *rect); rtgui_region_status_t rtgui_region_intersect_rect(rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *rect);
rtgui_region_status_t rtgui_region_union (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2); rtgui_region_status_t rtgui_region_union(rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2);
rtgui_region_status_t rtgui_region_union_rect(rtgui_region_t *dest, rtgui_region_t *source, rtgui_rect_t* rect); rtgui_region_status_t rtgui_region_union_rect(rtgui_region_t *dest, rtgui_region_t *source, rtgui_rect_t *rect);
rtgui_region_status_t rtgui_region_subtract (rtgui_region_t *regD, rtgui_region_t *regM, rtgui_region_t *regS); rtgui_region_status_t rtgui_region_subtract(rtgui_region_t *regD, rtgui_region_t *regM, rtgui_region_t *regS);
rtgui_region_status_t rtgui_region_subtract_rect (rtgui_region_t *regD, rtgui_region_t *regM, rtgui_rect_t* rect); rtgui_region_status_t rtgui_region_subtract_rect(rtgui_region_t *regD, rtgui_region_t *regM, rtgui_rect_t *rect);
rtgui_region_status_t rtgui_region_inverse (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *invRect); rtgui_region_status_t rtgui_region_inverse(rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *invRect);
int rtgui_region_num_rects (rtgui_region_t *region); int rtgui_region_num_rects(rtgui_region_t *region);
rtgui_rect_t* rtgui_region_rects (rtgui_region_t *region); rtgui_rect_t *rtgui_region_rects(rtgui_region_t *region);
#define RTGUI_REGION_OUT 0 #define RTGUI_REGION_OUT 0
#define RTGUI_REGION_IN 1 #define RTGUI_REGION_IN 1
#define RTGUI_REGION_PART 2 #define RTGUI_REGION_PART 2
int rtgui_region_contains_point (rtgui_region_t *region, int x, int y, rtgui_rect_t *box); int rtgui_region_contains_point(rtgui_region_t *region, int x, int y, rtgui_rect_t *box);
int rtgui_region_contains_rectangle (rtgui_region_t *rtgui_region_t, rtgui_rect_t *prect); int rtgui_region_contains_rectangle(rtgui_region_t *rtgui_region_t, rtgui_rect_t *prect);
int rtgui_region_not_empty (rtgui_region_t *region); int rtgui_region_not_empty(rtgui_region_t *region);
rtgui_rect_t *rtgui_region_extents (rtgui_region_t *region); rtgui_rect_t *rtgui_region_extents(rtgui_region_t *region);
rtgui_region_status_t rtgui_region_append (rtgui_region_t *dest, rtgui_region_t *region); rtgui_region_status_t rtgui_region_append(rtgui_region_t *dest, rtgui_region_t *region);
rtgui_region_status_t rtgui_region_validate (rtgui_region_t *badreg, int *pOverlap); rtgui_region_status_t rtgui_region_validate(rtgui_region_t *badreg, int *pOverlap);
void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t* rect); void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t *rect);
void rtgui_region_empty (rtgui_region_t *region); void rtgui_region_empty(rtgui_region_t *region);
void rtgui_region_dump(rtgui_region_t* region); void rtgui_region_dump(rtgui_region_t *region);
int rtgui_region_is_flat(rtgui_region_t* region); int rtgui_region_is_flat(rtgui_region_t *region);
/* rect functions */ /* rect functions */
extern rtgui_rect_t rtgui_empty_rect; extern rtgui_rect_t rtgui_empty_rect;
void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y); void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y);
void rtgui_rect_moveto_align(rtgui_rect_t *rect, rtgui_rect_t *to, int align); void rtgui_rect_moveto_align(rtgui_rect_t *rect, rtgui_rect_t *to, int align);
void rtgui_rect_inflate(rtgui_rect_t *rect, int d); void rtgui_rect_inflate(rtgui_rect_t *rect, int d);
void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest); void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest);
int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y); int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y);
int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2); int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2);
int rtgui_rect_is_equal(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2); int rtgui_rect_is_equal(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2);
rt_bool_t rtgui_rect_is_empty(const rtgui_rect_t *rect); rt_bool_t rtgui_rect_is_empty(const rtgui_rect_t *rect);
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)
} }

View File

@ -17,9 +17,9 @@
#include <rtthread.h> #include <rtthread.h>
#include <rtgui/rtgui_config.h> #include <rtgui/rtgui_config.h>
#define RT_INT16_MAX 32767 #define RT_INT16_MAX 32767
#define RT_INT16_MIN (-RT_INT16_MAX-1) #define RT_INT16_MIN (-RT_INT16_MAX-1)
#define RTGUI_NOT_FOUND (-1) #define RTGUI_NOT_FOUND (-1)
struct rtgui_event; struct rtgui_event;
@ -29,15 +29,15 @@ struct rtgui_win;
struct rtgui_font; struct rtgui_font;
typedef struct rtgui_win rtgui_win_t; typedef struct rtgui_win rtgui_win_t;
typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object* object, struct rtgui_event* event); typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object *object, struct rtgui_event *event);
typedef void (*rtgui_onbutton_func_t)(struct rtgui_object* object, struct rtgui_event* event); typedef void (*rtgui_onbutton_func_t)(struct rtgui_object *object, struct rtgui_event *event);
/** /**
* Coordinate point * Coordinate point
*/ */
struct rtgui_point struct rtgui_point
{ {
rt_int16_t x, y; rt_int16_t x, y;
}; };
typedef struct rtgui_point rtgui_point_t; typedef struct rtgui_point rtgui_point_t;
extern rtgui_point_t rtgui_empty_point; extern rtgui_point_t rtgui_empty_point;
@ -47,11 +47,11 @@ extern rtgui_point_t rtgui_empty_point;
*/ */
struct rtgui_rect struct rtgui_rect
{ {
rt_int16_t x1, y1, x2, y2; rt_int16_t x1, y1, x2, y2;
}; };
typedef struct rtgui_rect rtgui_rect_t; typedef struct rtgui_rect rtgui_rect_t;
#define rtgui_rect_width(r) ((r).x2 - (r).x1) #define rtgui_rect_width(r) ((r).x2 - (r).x1)
#define rtgui_rect_height(r) ((r).y2 - (r).y1) #define rtgui_rect_height(r) ((r).y2 - (r).y1)
typedef unsigned long rtgui_color_t; typedef unsigned long rtgui_color_t;
@ -60,82 +60,82 @@ typedef unsigned long rtgui_color_t;
*/ */
struct rtgui_gc struct rtgui_gc
{ {
/* foreground and background color */ /* foreground and background color */
rtgui_color_t foreground, background; rtgui_color_t foreground, background;
/* text style */ /* text style */
rt_uint16_t textstyle; rt_uint16_t textstyle;
/* text align */ /* text align */
rt_uint16_t textalign; rt_uint16_t textalign;
/* font */ /* font */
struct rtgui_font* font; struct rtgui_font *font;
}; };
typedef struct rtgui_gc rtgui_gc_t; typedef struct rtgui_gc rtgui_gc_t;
enum RTGUI_MARGIN_STYLE enum RTGUI_MARGIN_STYLE
{ {
RTGUI_MARGIN_LEFT = 0x01, RTGUI_MARGIN_LEFT = 0x01,
RTGUI_MARGIN_RIGHT = 0x02, RTGUI_MARGIN_RIGHT = 0x02,
RTGUI_MARGIN_TOP = 0x04, RTGUI_MARGIN_TOP = 0x04,
RTGUI_MARGIN_BOTTOM = 0x08, RTGUI_MARGIN_BOTTOM = 0x08,
RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM
}; };
/** /**
* Border style * Border style
*/ */
enum RTGUI_BORDER_STYLE enum RTGUI_BORDER_STYLE
{ {
RTGUI_BORDER_NONE = 0, RTGUI_BORDER_NONE = 0,
RTGUI_BORDER_SIMPLE, RTGUI_BORDER_SIMPLE,
RTGUI_BORDER_RAISE, RTGUI_BORDER_RAISE,
RTGUI_BORDER_SUNKEN, RTGUI_BORDER_SUNKEN,
RTGUI_BORDER_BOX, RTGUI_BORDER_BOX,
RTGUI_BORDER_STATIC, RTGUI_BORDER_STATIC,
RTGUI_BORDER_EXTRA, RTGUI_BORDER_EXTRA,
RTGUI_BORDER_UP, RTGUI_BORDER_UP,
RTGUI_BORDER_DOWN RTGUI_BORDER_DOWN
}; };
#define RTGUI_BORDER_DEFAULT_WIDTH 2 #define RTGUI_BORDER_DEFAULT_WIDTH 2
#define RTGUI_WIDGET_DEFAULT_MARGIN 3 #define RTGUI_WIDGET_DEFAULT_MARGIN 3
/** /**
* Orientation * Orientation
*/ */
enum RTGUI_ORIENTATION enum RTGUI_ORIENTATION
{ {
RTGUI_HORIZONTAL = 0x01, RTGUI_HORIZONTAL = 0x01,
RTGUI_VERTICAL = 0x02, RTGUI_VERTICAL = 0x02,
RTGUI_ORIENTATION_BOTH = RTGUI_HORIZONTAL | RTGUI_VERTICAL RTGUI_ORIENTATION_BOTH = RTGUI_HORIZONTAL | RTGUI_VERTICAL
}; };
enum RTGUI_ALIGN enum RTGUI_ALIGN
{ {
RTGUI_ALIGN_NOT = 0x00, RTGUI_ALIGN_NOT = 0x00,
RTGUI_ALIGN_CENTER_HORIZONTAL = 0x01, RTGUI_ALIGN_CENTER_HORIZONTAL = 0x01,
RTGUI_ALIGN_LEFT = RTGUI_ALIGN_NOT, RTGUI_ALIGN_LEFT = RTGUI_ALIGN_NOT,
RTGUI_ALIGN_TOP = RTGUI_ALIGN_NOT, RTGUI_ALIGN_TOP = RTGUI_ALIGN_NOT,
RTGUI_ALIGN_RIGHT = 0x02, RTGUI_ALIGN_RIGHT = 0x02,
RTGUI_ALIGN_BOTTOM = 0x04, RTGUI_ALIGN_BOTTOM = 0x04,
RTGUI_ALIGN_CENTER_VERTICAL = 0x08, RTGUI_ALIGN_CENTER_VERTICAL = 0x08,
RTGUI_ALIGN_CENTER = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL, RTGUI_ALIGN_CENTER = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL,
RTGUI_ALIGN_EXPAND = 0x10, RTGUI_ALIGN_EXPAND = 0x10,
RTGUI_ALIGN_STRETCH = 0x20, RTGUI_ALIGN_STRETCH = 0x20,
}; };
enum RTGUI_TEXTSTYLE enum RTGUI_TEXTSTYLE
{ {
RTGUI_TEXTSTYLE_NORMAL = 0x00, RTGUI_TEXTSTYLE_NORMAL = 0x00,
RTGUI_TEXTSTYLE_DRAW_BACKGROUND = 0x01, RTGUI_TEXTSTYLE_DRAW_BACKGROUND = 0x01,
RTGUI_TEXTSTYLE_SHADOW = 0x02, RTGUI_TEXTSTYLE_SHADOW = 0x02,
RTGUI_TEXTSTYLE_OUTLINE = 0x04, RTGUI_TEXTSTYLE_OUTLINE = 0x04,
}; };
enum RTGUI_MODAL_CODE enum RTGUI_MODAL_CODE
{ {
RTGUI_MODAL_OK, RTGUI_MODAL_OK,
RTGUI_MODAL_CANCEL RTGUI_MODAL_CANCEL
}; };
typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t; typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;

View File

@ -31,42 +31,42 @@ DECLARE_CLASS_TYPE(application);
enum rtgui_app_flag enum rtgui_app_flag
{ {
RTGUI_APP_FLAG_EXITED = 0x04, RTGUI_APP_FLAG_EXITED = 0x04,
RTGUI_APP_FLAG_SHOWN = 0x08 RTGUI_APP_FLAG_SHOWN = 0x08
}; };
typedef void (*rtgui_idle_func_t)(struct rtgui_object *obj, struct rtgui_event *event); typedef void (*rtgui_idle_func_t)(struct rtgui_object *obj, struct rtgui_event *event);
struct rtgui_app struct rtgui_app
{ {
struct rtgui_object parent; struct rtgui_object parent;
/* application name */ /* application name */
unsigned char *name; unsigned char *name;
struct rtgui_image* icon; struct rtgui_image *icon;
enum rtgui_app_flag state_flag; enum rtgui_app_flag state_flag;
rt_uint16_t ref_count; rt_uint16_t ref_count;
rt_uint16_t exit_code; rt_uint16_t exit_code;
/* the thread id */ /* the thread id */
rt_thread_t tid; rt_thread_t tid;
/* the RTGUI server id */ /* the RTGUI server id */
rt_thread_t server; rt_thread_t server;
/* the message queue of thread */ /* the message queue of thread */
rt_mq_t mq; rt_mq_t mq;
/* event buffer */ /* event buffer */
rt_uint8_t event_buffer[sizeof(union rtgui_event_generic)]; rt_uint8_t event_buffer[sizeof(union rtgui_event_generic)];
/* if not RT_NULL, the application is in modal state by modal_object. If is /* if not RT_NULL, the application is in modal state by modal_object. If is
* RT_NULL, nothing modal windows. */ * RT_NULL, nothing modal windows. */
struct rtgui_object *modal_object; struct rtgui_object *modal_object;
struct rtgui_object *main_object; struct rtgui_object *main_object;
/* on idle event handler */ /* on idle event handler */
rtgui_idle_func_t on_idle; rtgui_idle_func_t on_idle;
}; };
/** /**

View File

@ -18,67 +18,34 @@
/* RTGUI options */ /* RTGUI options */
#ifdef _WIN32 #ifndef RT_USING_DFS
/* name length of RTGUI object */ #undef RTGUI_USING_DFS_FILERW
#define RTGUI_NAME_MAX 12 #undef RTGUI_USING_HZ_FILE
/* support 16 weight font */
#define RTGUI_USING_FONT16
/* support Chinese font */
#define RTGUI_USING_FONTHZ
/* support FreeType TTF font */
//#define RTGUI_USING_TTF
/* use small size in RTGUI */
#define RTGUI_USING_SMALL_SIZE
/* use mouse cursor */
/* #define RTGUI_USING_MOUSE_CURSOR */
/* default font size in RTGUI */
#define RTGUI_DEFAULT_FONT_SIZE 12
#define RTGUI_USING_STDIO_FILERW
#define RTGUI_USING_DFS_FILERW
#define RTGUI_IMAGE_CONTAINER
#define RTGUI_IMAGE_XPM
#define RTGUI_IMAGE_BMP
#define RTGUI_IMAGE_PNG
// #define RTGUI_IMAGE_JPEG
// #define RTGUI_IMAGE_TJPGD
#define RTGUI_USING_FONT12
#define RTGUI_USING_HZ_BMP
#define RTGUI_MEM_TRACE
#define RTGUI_USING_WINMOVE
#define RTGUI_USING_NOTEBOOK_IMAGE
// #define RTGUI_USING_HZ_FILE
#else
/* native running under RT-Thread */
#ifndef RT_USING_DFS
#undef RTGUI_USING_DFS_FILERW
#undef RTGUI_USING_HZ_FILE
#endif
#endif #endif
#if RTGUI_DEFAULT_FONT_SIZE == 0 #if RTGUI_DEFAULT_FONT_SIZE == 0
#define RTGUI_DEFAULT_FONT_SIZE 12 #define RTGUI_DEFAULT_FONT_SIZE 12
#endif #endif
#define RTGUI_SVR_THREAD_PRIORITY 15 #define RTGUI_SVR_THREAD_PRIORITY 15
#define RTGUI_SVR_THREAD_TIMESLICE 5 #define RTGUI_SVR_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE #ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_SVR_THREAD_STACK_SIZE 1024 #define RTGUI_SVR_THREAD_STACK_SIZE 1024
#else #else
#define RTGUI_SVR_THREAD_STACK_SIZE 2048 #define RTGUI_SVR_THREAD_STACK_SIZE 2048
#endif #endif
#define RTGUI_APP_THREAD_PRIORITY 25 #define RTGUI_APP_THREAD_PRIORITY 25
#define RTGUI_APP_THREAD_TIMESLICE 5 #define RTGUI_APP_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE #ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_APP_THREAD_STACK_SIZE 1024 #define RTGUI_APP_THREAD_STACK_SIZE 1024
#else #else
#define RTGUI_APP_THREAD_STACK_SIZE 2048 #define RTGUI_APP_THREAD_STACK_SIZE 2048
#endif #endif
#define RTGUI_USING_CAST_CHECK #define RTGUI_USING_CAST_CHECK
//#define RTGUI_USING_DESKTOP_WINDOW //#define RTGUI_USING_DESKTOP_WINDOW
#undef RTGUI_USING_SMALL_SIZE //#undef RTGUI_USING_SMALL_SIZE
#endif #endif

View File

@ -0,0 +1,58 @@
/*
* File : rtgui_mv_model.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-09-15 Grissiom first version
*/
#ifndef __RTGUI_MV_MODEL_H__
#define __RTGUI_MV_MODEL_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/mv_view.h>
DECLARE_CLASS_TYPE(mv_model);
/** Gets the type of a mv_model */
#define RTGUI_MV_MODEL_TYPE (RTGUI_TYPE(mv_model))
/** Casts the object to an mv_model */
#define RTGUI_MV_MODEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MV_MODEL_TYPE, struct rtgui_mv_model))
/** Checks if the object is an mv_model */
#define RTGUI_IS_MV_MODEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MV_MODEL_TYPE))
struct rtgui_mv_model
{
struct rtgui_object parent;
rt_uint16_t dimension;
rt_uint16_t view_number;
/* the length of data */
rt_uint16_t length;
/* if the dimension is 1, the data is the pointer to the data. If the
* dimension is more than 1, data is a pointer to a array of pointers to
* data. */
void *data;
/* the content of view is like the content of data. If a model has more
* then one view, view is pointed to an array of pointers to views. */
void *view;
};
struct rtgui_mv_model *rtgui_mv_model_create(rt_uint16_t dimension);
void rtgui_mv_model_destroy(struct rtgui_mv_model *model);
rt_err_t rtgui_mv_model_set_dimension(struct rtgui_mv_model *model, rt_uint16_t dimension);
rt_err_t rtgui_mv_model_add_view(struct rtgui_mv_model *, struct rtgui_mv_view *);
void rtgui_mv_model_remove_view(struct rtgui_mv_model *, struct rtgui_mv_view *);
rt_bool_t rtgui_mv_model_has_view(struct rtgui_mv_model *model, struct rtgui_mv_view *view);
void rtgui_mv_model_set_data(struct rtgui_mv_model *model, rt_uint16_t dim, void *p);
void *rtgui_mv_model_get_data(struct rtgui_mv_model *model, rt_uint16_t dim);
void rtgui_mv_model_notify(struct rtgui_mv_model *model, struct rtgui_event_mv_model *em);
#endif /* end of include guard: __RTGUI_MV_MODEL_H__ */

View File

@ -22,124 +22,124 @@
extern "C" { extern "C" {
#endif #endif
/* rtgui object type */ /* rtgui object type */
#define RTGUI_CONTAINER_OF(obj, type, member) \ #define RTGUI_CONTAINER_OF(obj, type, member) \
((type *)((char *)(obj) - (unsigned long)(&((type *)0)->member))) ((type *)((char *)(obj) - (unsigned long)(&((type *)0)->member)))
/** Casts the function pointer to an rtgui_constructor */ /** Casts the function pointer to an rtgui_constructor */
#define RTGUI_CONSTRUCTOR(constructor) ((rtgui_constructor_t)(constructor)) #define RTGUI_CONSTRUCTOR(constructor) ((rtgui_constructor_t)(constructor))
/** Casts the function pointer to an rtgui_constructor */ /** Casts the function pointer to an rtgui_constructor */
#define RTGUI_DESTRUCTOR(destructor) ((rtgui_destructor_t)(destructor)) #define RTGUI_DESTRUCTOR(destructor) ((rtgui_destructor_t)(destructor))
/* pre-definition */ /* pre-definition */
struct rtgui_object; struct rtgui_object;
typedef struct rtgui_object rtgui_object_t; typedef struct rtgui_object rtgui_object_t;
typedef void (*rtgui_constructor_t)(rtgui_object_t *object); typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
typedef void (*rtgui_destructor_t)(rtgui_object_t *object); typedef void (*rtgui_destructor_t)(rtgui_object_t *object);
/* rtgui type structure */ /* rtgui type structure */
struct rtgui_type struct rtgui_type
{ {
/* type name */ /* type name */
char* name; char *name;
/* parent type link */ /* parent type link */
struct rtgui_type *parent; struct rtgui_type *parent;
/* constructor and destructor */ /* constructor and destructor */
rtgui_constructor_t constructor; rtgui_constructor_t constructor;
rtgui_destructor_t destructor; rtgui_destructor_t destructor;
/* size of type */ /* size of type */
int size; int size;
}; };
typedef struct rtgui_type rtgui_type_t; typedef struct rtgui_type rtgui_type_t;
#define RTGUI_TYPE(type) (struct rtgui_type*)&(_rtgui_##type) #define RTGUI_TYPE(type) (struct rtgui_type*)&(_rtgui_##type)
#define DECLARE_CLASS_TYPE(type) extern const struct rtgui_type _rtgui_##type #define DECLARE_CLASS_TYPE(type) extern const struct rtgui_type _rtgui_##type
#define DEFINE_CLASS_TYPE(type, name, parent, constructor, destructor, size) \ #define DEFINE_CLASS_TYPE(type, name, parent, constructor, destructor, size) \
const struct rtgui_type _rtgui_##type = { \ const struct rtgui_type _rtgui_##type = { \
name, \ name, \
parent, \ parent, \
RTGUI_CONSTRUCTOR(constructor), \ RTGUI_CONSTRUCTOR(constructor), \
RTGUI_DESTRUCTOR(destructor), \ RTGUI_DESTRUCTOR(destructor), \
size } size }
void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object); void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object);
void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object); void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object);
rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent); rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent);
const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type); const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type);
const char *rtgui_type_name_get(const rtgui_type_t *type); const char *rtgui_type_name_get(const rtgui_type_t *type);
const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object); const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object);
#ifdef RTGUI_USING_CAST_CHECK #ifdef RTGUI_USING_CAST_CHECK
#define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \ #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \
((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type), __FUNCTION__, __LINE__)) ((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type), __FUNCTION__, __LINE__))
#else #else
#define RTGUI_OBJECT_CAST(obj, obj_type, c_type) ((c_type *)(obj)) #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) ((c_type *)(obj))
#endif #endif
#define RTGUI_OBJECT_CHECK_TYPE(_obj, _type) \ #define RTGUI_OBJECT_CHECK_TYPE(_obj, _type) \
(rtgui_type_inherits_from(((rtgui_object_t *)(_obj))->type, (_type))) (rtgui_type_inherits_from(((rtgui_object_t *)(_obj))->type, (_type)))
DECLARE_CLASS_TYPE(object); DECLARE_CLASS_TYPE(object);
/** Gets the type of an object */ /** Gets the type of an object */
#define RTGUI_OBJECT_TYPE RTGUI_TYPE(object) #define RTGUI_OBJECT_TYPE RTGUI_TYPE(object)
/** Casts the object to an rtgui_object_t */ /** Casts the object to an rtgui_object_t */
#define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, struct rtgui_object)) #define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, struct rtgui_object))
/** Checks if the object is an rtgui_Object */ /** Checks if the object is an rtgui_Object */
#define RTGUI_IS_OBJECT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_OBJECT_TYPE)) #define RTGUI_IS_OBJECT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_OBJECT_TYPE))
enum rtgui_object_flag enum rtgui_object_flag
{ {
RTGUI_OBJECT_FLAG_NONE = 0x00, RTGUI_OBJECT_FLAG_NONE = 0x00,
RTGUI_OBJECT_FLAG_STATIC = 0x01, RTGUI_OBJECT_FLAG_STATIC = 0x01,
RTGUI_OBJECT_FLAG_DISABLED = 0x02 RTGUI_OBJECT_FLAG_DISABLED = 0x02
}; };
/* rtgui base object */ /* rtgui base object */
struct rtgui_object struct rtgui_object
{ {
/* object type */ /* object type */
const rtgui_type_t* type; const rtgui_type_t *type;
/* the event handler */ /* the event handler */
rtgui_event_handler_ptr event_handler; rtgui_event_handler_ptr event_handler;
enum rtgui_object_flag flag; enum rtgui_object_flag flag;
}; };
rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type); rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type);
void rtgui_object_destroy(rtgui_object_t *object); void rtgui_object_destroy(rtgui_object_t *object);
/* set the event handler of object */ /* set the event handler of object */
void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler); void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler);
/* object default event handler */ /* object default event handler */
rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event* event); rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event *event);
/* helper micro. widget event handlers could use this. */ /* helper micro. widget event handlers could use this. */
#define RTGUI_WIDGET_EVENT_HANDLER_PREPARE \ #define RTGUI_WIDGET_EVENT_HANDLER_PREPARE \
struct rtgui_widget *widget; \ struct rtgui_widget *widget; \
RT_ASSERT(object != RT_NULL); \ RT_ASSERT(object != RT_NULL); \
RT_ASSERT(event != RT_NULL); \ RT_ASSERT(event != RT_NULL); \
widget = RTGUI_WIDGET(object); \ widget = RTGUI_WIDGET(object); \
/* supress compiler warning */ \ /* supress compiler warning */ \
widget = widget; widget = widget;
/** handle @param event on @param object's own event handler /** handle @param event on @param object's own event handler
* *
* If the @param object does not have an event handler, which means the object * If the @param object does not have an event handler, which means the object
* does not interested in any event, it will return RT_FALSE. Otherwise, the * does not interested in any event, it will return RT_FALSE. Otherwise, the
* return code of that handler is returned. * return code of that handler is returned.
*/ */
rt_inline rt_bool_t rtgui_object_handle(struct rtgui_object *object, struct rtgui_event *event) rt_inline rt_bool_t rtgui_object_handle(struct rtgui_object *object, struct rtgui_event *event)
{ {
if (object->event_handler) if (object->event_handler)
return object->event_handler(object, event); return object->event_handler(object, event);
return RT_FALSE; return RT_FALSE;
} }
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type, const char* func, int line); rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type, const char *func, int line);
rtgui_type_t *rtk_object_object_type_get(rtgui_object_t *object); rtgui_type_t *rtk_object_object_type_get(rtgui_object_t *object);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -22,21 +22,21 @@
/* top window definitions in server */ /* top window definitions in server */
enum rtgui_topwin_flag enum rtgui_topwin_flag
{ {
WINTITLE_NO = 0x01, WINTITLE_NO = 0x01,
WINTITLE_BORDER = 0x02, WINTITLE_BORDER = 0x02,
WINTITLE_ACTIVATE = 0x04, WINTITLE_ACTIVATE = 0x04,
WINTITLE_CLOSEBOX = 0x08, WINTITLE_CLOSEBOX = 0x08,
WINTITLE_MOVE = 0x0C, WINTITLE_MOVE = 0x0C,
WINTITLE_CB_PRESSED = 0x10, WINTITLE_CB_PRESSED = 0x10,
WINTITLE_NOFOCUS = 0x20, WINTITLE_NOFOCUS = 0x20,
/* window is hidden by default */ /* window is hidden by default */
WINTITLE_SHOWN = 0x40, WINTITLE_SHOWN = 0x40,
/* window is modaled by other window */ /* window is modaled by other window */
WINTITLE_MODALED = 0x80, WINTITLE_MODALED = 0x80,
/* window is modaling other window */ /* window is modaling other window */
WINTITLE_MODALING = 0x100, WINTITLE_MODALING = 0x100,
WINTITLE_ONTOP = 0x200, WINTITLE_ONTOP = 0x200,
WINTITLE_ONBTM = 0x400, WINTITLE_ONBTM = 0x400,
}; };
#define WINTITLE_HEIGHT 20 #define WINTITLE_HEIGHT 20
@ -46,31 +46,31 @@ enum rtgui_topwin_flag
struct rtgui_topwin struct rtgui_topwin
{ {
/* the window flag */ /* the window flag */
enum rtgui_topwin_flag flag; enum rtgui_topwin_flag flag;
/* event mask */ /* event mask */
rt_uint32_t mask; rt_uint32_t mask;
struct rtgui_wintitle* title; struct rtgui_wintitle *title;
/* the window id */ /* the window id */
struct rtgui_win* wid; struct rtgui_win *wid;
/* the thread id */ /* the thread id */
rt_thread_t tid; rt_thread_t tid;
/* the extent information */ /* the extent information */
rtgui_rect_t extent; rtgui_rect_t extent;
struct rtgui_topwin *parent; struct rtgui_topwin *parent;
/* we need to iterate the topwin list with usual order(get target window) /* we need to iterate the topwin list with usual order(get target window)
* or reversely(painting). So it's better to use a double linked list */ * or reversely(painting). So it's better to use a double linked list */
struct rtgui_dlist_node list; struct rtgui_dlist_node list;
struct rtgui_dlist_node child_list; struct rtgui_dlist_node child_list;
/* the monitor rect list */ /* the monitor rect list */
rtgui_list_t monitor_list; rtgui_list_t monitor_list;
}; };
typedef struct rtgui_topwin rtgui_topwin_t; typedef struct rtgui_topwin rtgui_topwin_t;
@ -79,8 +79,8 @@ void rtgui_topwin_init(void);
void rtgui_server_init(void); void rtgui_server_init(void);
/* post an event to server */ /* post an event to server */
void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size); void rtgui_server_post_event(struct rtgui_event *event, rt_size_t size);
rt_err_t rtgui_server_post_event_sync(struct rtgui_event* event, rt_size_t size); rt_err_t rtgui_server_post_event_sync(struct rtgui_event *event, rt_size_t size);
#endif #endif

View File

@ -22,40 +22,40 @@ struct rtgui_event;
struct rtgui_widget; struct rtgui_widget;
struct rtgui_timer; struct rtgui_timer;
typedef void (*rtgui_timeout_func)(struct rtgui_timer* timer, void* parameter); typedef void (*rtgui_timeout_func)(struct rtgui_timer *timer, void *parameter);
struct rtgui_timer struct rtgui_timer
{ {
/* context thread id */ /* context thread id */
rt_thread_t tid; rt_thread_t tid;
/* rt timer */ /* rt timer */
struct rt_timer timer; struct rt_timer timer;
/* timeout function and user data */ /* timeout function and user data */
rtgui_timeout_func timeout; rtgui_timeout_func timeout;
void* user_data; void *user_data;
}; };
typedef struct rtgui_timer rtgui_timer_t; typedef struct rtgui_timer rtgui_timer_t;
rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_base_t flag, rtgui_timeout_func timeout, void* parameter); rtgui_timer_t *rtgui_timer_create(rt_int32_t time, rt_base_t flag, rtgui_timeout_func timeout, void *parameter);
void rtgui_timer_destory(rtgui_timer_t* timer); void rtgui_timer_destory(rtgui_timer_t *timer);
void rtgui_timer_start(rtgui_timer_t* timer); void rtgui_timer_start(rtgui_timer_t *timer);
void rtgui_timer_stop (rtgui_timer_t* timer); void rtgui_timer_stop(rtgui_timer_t *timer);
/* rtgui system initialization function */ /* rtgui system initialization function */
void rtgui_system_server_init(void); void rtgui_system_server_init(void);
void* rtgui_malloc(rt_size_t size); void *rtgui_malloc(rt_size_t size);
void rtgui_free(void* ptr); void rtgui_free(void *ptr);
void* rtgui_realloc(void* ptr, rt_size_t size); void *rtgui_realloc(void *ptr, rt_size_t size);
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#define rtgui_enter_critical() #define rtgui_enter_critical()
#define rtgui_exit_critical() #define rtgui_exit_critical()
#else #else
#define rtgui_enter_critical rt_enter_critical #define rtgui_enter_critical rt_enter_critical
#define rtgui_exit_critical rt_exit_critical #define rtgui_exit_critical rt_exit_critical
#endif #endif
rt_thread_t rtgui_get_server(void); rt_thread_t rtgui_get_server(void);
@ -67,12 +67,12 @@ void rtgui_screen_lock(rt_int32_t timeout);
void rtgui_screen_unlock(void); void rtgui_screen_unlock(void);
struct rtgui_event; struct rtgui_event;
rt_err_t rtgui_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size); rt_err_t rtgui_send(rt_thread_t tid, struct rtgui_event *event, rt_size_t event_size);
rt_err_t rtgui_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size); rt_err_t rtgui_send_urgent(rt_thread_t tid, struct rtgui_event *event, rt_size_t event_size);
rt_err_t rtgui_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size); rt_err_t rtgui_send_sync(rt_thread_t tid, struct rtgui_event *event, rt_size_t event_size);
rt_err_t rtgui_ack(struct rtgui_event* event, rt_int32_t status); rt_err_t rtgui_ack(struct rtgui_event *event, rt_int32_t status);
rt_err_t rtgui_recv(struct rtgui_event* event, rt_size_t event_size); rt_err_t rtgui_recv(struct rtgui_event *event, rt_size_t event_size);
rt_err_t rtgui_recv_nosuspend(struct rtgui_event* event, rt_size_t event_size); rt_err_t rtgui_recv_nosuspend(struct rtgui_event *event, rt_size_t event_size);
rt_err_t rtgui_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size); rt_err_t rtgui_recv_filter(rt_uint32_t type, struct rtgui_event *event, rt_size_t event_size);
#endif #endif

View File

@ -17,11 +17,11 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/rtgui_server.h> #include <rtgui/rtgui_server.h>
#define CHECK_BOX_W 13 #define CHECK_BOX_W 13
#define CHECK_BOX_H 13 #define CHECK_BOX_H 13
#define RADIO_BOX_W 12 #define RADIO_BOX_W 12
#define RADIO_BOX_H 12 #define RADIO_BOX_H 12
#include <rtgui/widgets/label.h> #include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h> #include <rtgui/widgets/button.h>
@ -38,27 +38,26 @@
extern "C" { extern "C" {
#endif #endif
void rtgui_system_theme_init(void); void rtgui_system_theme_init(void);
void rtgui_theme_draw_win(struct rtgui_topwin* win); void rtgui_theme_draw_win(struct rtgui_topwin *win);
void rtgui_theme_draw_button(rtgui_button_t* btn); void rtgui_theme_draw_button(rtgui_button_t *btn);
void rtgui_theme_draw_label(rtgui_label_t* label); void rtgui_theme_draw_label(rtgui_label_t *label);
void rtgui_theme_draw_textbox(rtgui_textbox_t* box); void rtgui_theme_draw_textbox(rtgui_textbox_t *box);
void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox); void rtgui_theme_draw_iconbox(rtgui_iconbox_t *iconbox);
void rtgui_theme_draw_checkbox(rtgui_checkbox_t* checkbox); void rtgui_theme_draw_checkbox(rtgui_checkbox_t *checkbox);
void rtgui_theme_draw_radiobutton(struct rtgui_radiobox* radiobox, rt_uint16_t item); void rtgui_theme_draw_radiobutton(struct rtgui_radiobox *radiobox, rt_uint16_t item);
void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox); void rtgui_theme_draw_radiobox(struct rtgui_radiobox *radiobox);
void rtgui_theme_draw_slider(struct rtgui_slider* slider); void rtgui_theme_draw_slider(struct rtgui_slider *slider);
void rtgui_theme_draw_scrollbar(struct rtgui_scrollbar* bar); void rtgui_theme_draw_progressbar(struct rtgui_progressbar *bar);
void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar); void rtgui_theme_draw_staticline(struct rtgui_staticline *staticline);
void rtgui_theme_draw_staticline(struct rtgui_staticline* staticline);
rt_uint16_t rtgui_theme_get_selected_height(void); rt_uint16_t rtgui_theme_get_selected_height(void);
void rtgui_theme_draw_selected(struct rtgui_dc* dc, rtgui_rect_t *rect); void rtgui_theme_draw_selected(struct rtgui_dc *dc, rtgui_rect_t *rect);
rtgui_color_t rtgui_theme_default_bc(void); rtgui_color_t rtgui_theme_default_bc(void);
rtgui_color_t rtgui_theme_default_fc(void); rtgui_color_t rtgui_theme_default_fc(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -5,30 +5,31 @@
/* Types of events: start element, end element, text, attr name, attr /* Types of events: start element, end element, text, attr name, attr
val and start/end document. Other events can be ignored! */ val and start/end document. Other events can be ignored! */
enum { enum
EVENT_START = 0, /* Start tag */ {
EVENT_END, /* End tag */ EVENT_START = 0, /* Start tag */
EVENT_TEXT, /* Text */ EVENT_END, /* End tag */
EVENT_NAME, /* Attribute name */ EVENT_TEXT, /* Text */
EVENT_VAL, /* Attribute value */ EVENT_NAME, /* Attribute name */
EVENT_END_DOC, /* End of document */ EVENT_VAL, /* Attribute value */
EVENT_COPY, /* Internal only; copies to internal buffer */ EVENT_END_DOC, /* End of document */
EVENT_NONE /* Internal only; should never see this event */ EVENT_COPY, /* Internal only; copies to internal buffer */
EVENT_NONE /* Internal only; should never see this event */
}; };
/* xml structure typedef */ /* xml structure typedef */
typedef struct rtgui_xml rtgui_xml_t; typedef struct rtgui_xml rtgui_xml_t;
typedef int (*rtgui_xml_event_handler_t)(rt_uint8_t event, const char* text, rt_size_t len, void* user); typedef int (*rtgui_xml_event_handler_t)(rt_uint8_t event, const char *text, rt_size_t len, void *user);
/* create a xml parser context */ /* create a xml parser context */
rtgui_xml_t* rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler, void* user); rtgui_xml_t *rtgui_xml_create(rt_size_t buffer_size, rtgui_xml_event_handler_t handler, void *user);
/* destroy a xml parser context */ /* destroy a xml parser context */
void rtgui_xml_destroy(rtgui_xml_t* rtgui_xml); void rtgui_xml_destroy(rtgui_xml_t *rtgui_xml);
/* parse xml buffer */ /* parse xml buffer */
int rtgui_xml_parse(rtgui_xml_t* rtgui_xml, const char* buf, rt_size_t len); int rtgui_xml_parse(rtgui_xml_t *rtgui_xml, const char *buf, rt_size_t len);
/* event string */ /* event string */
const char* rtgui_xml_event_str(rt_uint8_t event); const char *rtgui_xml_event_str(rt_uint8_t event);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -22,31 +22,31 @@
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(box); DECLARE_CLASS_TYPE(box);
/** Gets the type of a box */ /** Gets the type of a box */
#define RTGUI_BOX_TYPE (RTGUI_TYPE(box)) #define RTGUI_BOX_TYPE (RTGUI_TYPE(box))
/** Casts the object to an rtgui_box */ /** Casts the object to an rtgui_box */
#define RTGUI_BOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BOX_TYPE, rtgui_box_t)) #define RTGUI_BOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BOX_TYPE, rtgui_box_t))
/** Checks if the object is an rtgui_box */ /** Checks if the object is an rtgui_box */
#define RTGUI_IS_BOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BOX_TYPE)) #define RTGUI_IS_BOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BOX_TYPE))
struct rtgui_box struct rtgui_box
{ {
struct rtgui_object parent; struct rtgui_object parent;
rt_uint16_t orient; rt_uint16_t orient;
rt_uint16_t border_size; rt_uint16_t border_size;
struct rtgui_container* container; struct rtgui_container *container;
}; };
typedef struct rtgui_box rtgui_box_t; typedef struct rtgui_box rtgui_box_t;
struct rtgui_box* rtgui_box_create(int orientation, int border_size); struct rtgui_box *rtgui_box_create(int orientation, int border_size);
void rtgui_box_destroy(struct rtgui_box* box); void rtgui_box_destroy(struct rtgui_box *box);
void rtgui_box_layout(rtgui_box_t* box); void rtgui_box_layout(rtgui_box_t *box);
void rtgui_box_layout_rect(rtgui_box_t* box, struct rtgui_rect* rect); void rtgui_box_layout_rect(rtgui_box_t *box, struct rtgui_rect *rect);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -22,57 +22,57 @@
extern "C" { extern "C" {
#endif #endif
/** /**
* @defgroup rtgui_button * @defgroup rtgui_button
* @{ * @{
*/ */
DECLARE_CLASS_TYPE(button); DECLARE_CLASS_TYPE(button);
/** Gets the type of a button */ /** Gets the type of a button */
#define RTGUI_BUTTON_TYPE (RTGUI_TYPE(button)) #define RTGUI_BUTTON_TYPE (RTGUI_TYPE(button))
/** Casts the object to an rtgui_button */ /** Casts the object to an rtgui_button */
#define RTGUI_BUTTON(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BUTTON_TYPE, rtgui_button_t)) #define RTGUI_BUTTON(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BUTTON_TYPE, rtgui_button_t))
/** Checks if the object is an rtgui_button */ /** Checks if the object is an rtgui_button */
#define RTGUI_IS_BUTTON(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BUTTON_TYPE)) #define RTGUI_IS_BUTTON(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BUTTON_TYPE))
#define RTGUI_BUTTON_FLAG_PRESS 0x01 #define RTGUI_BUTTON_FLAG_PRESS 0x01
#define RTGUI_BUTTON_FLAG_DEFAULT 0x02 #define RTGUI_BUTTON_FLAG_DEFAULT 0x02
#define RTGUI_BUTTON_TYPE_NORMAL 0x00 #define RTGUI_BUTTON_TYPE_NORMAL 0x00
#define RTGUI_BUTTON_TYPE_PUSH 0x10 #define RTGUI_BUTTON_TYPE_PUSH 0x10
/* /*
* the button widget * the button widget
*/ */
struct rtgui_button struct rtgui_button
{ {
/* inherit from label */ /* inherit from label */
struct rtgui_label parent; struct rtgui_label parent;
/* button flag */ /* button flag */
rt_base_t flag; rt_base_t flag;
/* pressed and unpressed image */ /* pressed and unpressed image */
rtgui_image_t *pressed_image, *unpressed_image; rtgui_image_t *pressed_image, *unpressed_image;
/* click button event handler */ /* click button event handler */
rtgui_onbutton_func_t on_button; rtgui_onbutton_func_t on_button;
}; };
typedef struct rtgui_button rtgui_button_t; typedef struct rtgui_button rtgui_button_t;
rtgui_button_t* rtgui_button_create(const char* text); rtgui_button_t *rtgui_button_create(const char *text);
rtgui_button_t* rtgui_pushbutton_create(const char* text); rtgui_button_t *rtgui_pushbutton_create(const char *text);
void rtgui_button_destroy(rtgui_button_t* btn); void rtgui_button_destroy(rtgui_button_t *btn);
void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image); void rtgui_button_set_pressed_image(rtgui_button_t *btn, rtgui_image_t *image);
void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image); void rtgui_button_set_unpressed_image(rtgui_button_t *btn, rtgui_image_t *image);
void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func); void rtgui_button_set_onbutton(rtgui_button_t *btn, rtgui_onbutton_func_t func);
rt_bool_t rtgui_button_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_button_event_handler(struct rtgui_object *object, struct rtgui_event *event);
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -14,30 +14,30 @@ DECLARE_CLASS_TYPE(checkbox);
/** Checks if the object is an rtgui_button */ /** Checks if the object is an rtgui_button */
#define RTGUI_IS_CHECKBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CHECKBOX_TYPE)) #define RTGUI_IS_CHECKBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CHECKBOX_TYPE))
#define RTGUI_CHECKBOX_STATUS_CHECKED 0 #define RTGUI_CHECKBOX_STATUS_CHECKED 0
#define RTGUI_CHECKBOX_STATUS_UNCHECKED 1 #define RTGUI_CHECKBOX_STATUS_UNCHECKED 1
struct rtgui_checkbox struct rtgui_checkbox
{ {
/* inherit from label */ /* inherit from label */
struct rtgui_label parent; struct rtgui_label parent;
/* check box status */ /* check box status */
rt_uint8_t status_down; rt_uint8_t status_down;
/* click button event handler */ /* click button event handler */
rtgui_onbutton_func_t on_button; rtgui_onbutton_func_t on_button;
}; };
typedef struct rtgui_checkbox rtgui_checkbox_t; typedef struct rtgui_checkbox rtgui_checkbox_t;
rtgui_checkbox_t* rtgui_checkbox_create(const char* text, rt_bool_t checked); rtgui_checkbox_t *rtgui_checkbox_create(const char *text, rt_bool_t checked);
void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox); void rtgui_checkbox_destroy(rtgui_checkbox_t *checkbox);
void rtgui_checkbox_set_checked(rtgui_checkbox_t* checkbox, rt_bool_t checked); void rtgui_checkbox_set_checked(rtgui_checkbox_t *checkbox, rt_bool_t checked);
rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t* checkbox); rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t *checkbox);
void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func); void rtgui_checkbox_set_onbutton(rtgui_checkbox_t *checkbox, rtgui_onbutton_func_t func);
rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
#endif #endif

View File

@ -14,36 +14,36 @@ DECLARE_CLASS_TYPE(combobox);
/** Checks if the object is a rtgui_combobox */ /** Checks if the object is a rtgui_combobox */
#define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE)) #define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
#define RTGUI_COMBOBOX_WIDTH 75 #define RTGUI_COMBOBOX_WIDTH 75
#define RTGUI_COMBOBOX_HEIGHT 20 #define RTGUI_COMBOBOX_HEIGHT 20
#define RTGUI_COMBOBOX_BUTTON_WIDTH 18 #define RTGUI_COMBOBOX_BUTTON_WIDTH 18
struct rtgui_combobox struct rtgui_combobox
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* widget private data */ /* widget private data */
/* pull down window */ /* pull down window */
struct rtgui_win* pd_win; struct rtgui_win *pd_win;
rt_bool_t pd_pressed; rt_bool_t pd_pressed;
/* combobox items */ /* combobox items */
struct rtgui_listbox_item* items; struct rtgui_listbox_item *items;
rt_uint16_t items_count; rt_uint16_t items_count;
rt_uint16_t current_item; rt_uint16_t current_item;
/* call back */ /* call back */
rtgui_event_handler_ptr on_selected; rtgui_event_handler_ptr on_selected;
}; };
typedef struct rtgui_combobox rtgui_combobox_t; typedef struct rtgui_combobox rtgui_combobox_t;
rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t counter, struct rtgui_rect* rect); rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item *items, rt_uint16_t counter, struct rtgui_rect *rect);
void rtgui_combobox_destroy(rtgui_combobox_t* box); void rtgui_combobox_destroy(rtgui_combobox_t *box);
rt_bool_t rtgui_combobox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_combobox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
struct rtgui_listbox_item* rtgui_combox_get_select(struct rtgui_combobox* box); struct rtgui_listbox_item *rtgui_combox_get_select(struct rtgui_combobox *box);
void rtgui_combobox_set_onselected(struct rtgui_combobox* box, rtgui_event_handler_ptr func); void rtgui_combobox_set_onselected(struct rtgui_combobox *box, rtgui_event_handler_ptr func);
#endif #endif

View File

@ -21,46 +21,46 @@
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(container); DECLARE_CLASS_TYPE(container);
/** Gets the type of a container */ /** Gets the type of a container */
#define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container)) #define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container))
/** Casts the object to an rtgui_container */ /** Casts the object to an rtgui_container */
#define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t)) #define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
/** Checks if the object is an rtgui_container */ /** Checks if the object is an rtgui_container */
#define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE)) #define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))
/* /*
* the container widget * the container widget
*/ */
struct rtgui_container struct rtgui_container
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* layout box */ /* layout box */
struct rtgui_box* layout_box; struct rtgui_box *layout_box;
rtgui_list_t children; rtgui_list_t children;
}; };
typedef struct rtgui_container rtgui_container_t; typedef struct rtgui_container rtgui_container_t;
rtgui_container_t* rtgui_container_create(void); rtgui_container_t *rtgui_container_create(void);
void rtgui_container_destroy(rtgui_container_t* container); void rtgui_container_destroy(rtgui_container_t *container);
rt_bool_t rtgui_container_event_handler(struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t rtgui_container_event_handler(struct rtgui_object *widget, struct rtgui_event *event);
/* set layout box */ /* set layout box */
void rtgui_container_set_box(struct rtgui_container* container, struct rtgui_box* box); void rtgui_container_set_box(struct rtgui_container *container, struct rtgui_box *box);
void rtgui_container_layout(struct rtgui_container* container); void rtgui_container_layout(struct rtgui_container *container);
void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child); void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t *child);
void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child); void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t *child);
void rtgui_container_destroy_children(rtgui_container_t *container); void rtgui_container_destroy_children(rtgui_container_t *container);
rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container); rtgui_widget_t *rtgui_container_get_first_child(rtgui_container_t *container);
rt_bool_t rtgui_container_event_handler(struct rtgui_object* widget, rtgui_event_t* event); rt_bool_t rtgui_container_event_handler(struct rtgui_object *widget, rtgui_event_t *event);
rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event); rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t *event);
rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse* event); rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse *event);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -21,91 +21,91 @@
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(edit); DECLARE_CLASS_TYPE(edit);
/** Gets the type of a edit */ /** Gets the type of a edit */
#define RTGUI_EDIT_TYPE (RTGUI_TYPE(edit)) #define RTGUI_EDIT_TYPE (RTGUI_TYPE(edit))
/** Casts the object to a rtgui_edit */ /** Casts the object to a rtgui_edit */
#define RTGUI_EDIT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_EDIT_TYPE, struct rtgui_edit)) #define RTGUI_EDIT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_EDIT_TYPE, struct rtgui_edit))
/** Checks if the object is a rtgui_edit */ /** Checks if the object is a rtgui_edit */
#define RTGUI_IS_EDIT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_EDIT_TYPE)) #define RTGUI_IS_EDIT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_EDIT_TYPE))
#define RTGUI_EDIT_NONE 0x00 #define RTGUI_EDIT_NONE 0x00
#define RTGUI_EDIT_CARET 0x01 #define RTGUI_EDIT_CARET 0x01
#define RTGUI_EDIT_VSCROLL 0x02 #define RTGUI_EDIT_VSCROLL 0x02
#define RTGUI_EDIT_HSCROLL 0x04 #define RTGUI_EDIT_HSCROLL 0x04
#define RTGUI_EDIT_SHIFT 0x10 #define RTGUI_EDIT_SHIFT 0x10
#define RTGUI_EDIT_CTRL 0x20 #define RTGUI_EDIT_CTRL 0x20
#define RTGUI_EDIT_ALT 0x40 #define RTGUI_EDIT_ALT 0x40
#define RTGUI_EDIT_CAPSLOCK 0x80 #define RTGUI_EDIT_CAPSLOCK 0x80
#define RTGUI_EDIT_NUMLOCK 0x100 #define RTGUI_EDIT_NUMLOCK 0x100
struct edit_update struct edit_update
{ {
/* rt_uint32_t type; */ /* update type */ /* rt_uint32_t type; */ /* update type */
rtgui_point_t start, end; /* update area */ rtgui_point_t start, end; /* update area */
}; };
struct edit_line struct edit_line
{ {
rt_int16_t zsize; /* zone size */ rt_int16_t zsize; /* zone size */
rt_int16_t len; rt_int16_t len;
struct edit_line *prev; struct edit_line *prev;
struct edit_line *next; struct edit_line *next;
char *text; char *text;
}; };
struct rtgui_edit struct rtgui_edit
{ {
/* inherit from container */ /* inherit from container */
rtgui_container_t parent; rtgui_container_t parent;
/* edit flag */ /* edit flag */
rt_uint32_t flag; rt_uint32_t flag;
rt_int16_t max_rows, max_cols; rt_int16_t max_rows, max_cols;
rt_int16_t row_per_page, col_per_page; rt_int16_t row_per_page, col_per_page;
rtgui_point_t upleft; rtgui_point_t upleft;
rtgui_point_t visual; rtgui_point_t visual;
rt_uint8_t tabsize; rt_uint8_t tabsize;
rt_uint8_t item_height; rt_uint8_t item_height;
rt_uint8_t font_width,font_height; rt_uint8_t font_width, font_height;
rt_uint8_t margin; rt_uint8_t margin;
rt_int16_t bzsize; /* base zone size */ rt_int16_t bzsize; /* base zone size */
struct rtgui_timer *caret_timer; struct rtgui_timer *caret_timer;
rtgui_color_t *caret; rtgui_color_t *caret;
rtgui_rect_t caret_rect; rtgui_rect_t caret_rect;
struct edit_update update; struct edit_update update;
char *update_buf; /* speed up renewal process */ char *update_buf; /* speed up renewal process */
struct rtgui_dc *dbl_buf; struct rtgui_dc *dbl_buf;
struct edit_line *head; struct edit_line *head;
struct edit_line *tail; struct edit_line *tail;
struct edit_line *first_line; struct edit_line *first_line;
#ifdef RTGUI_EDIT_USING_SCROLL #ifdef RTGUI_EDIT_USING_SCROLL
struct rtgui_scrollbar *hscroll; struct rtgui_scrollbar *hscroll;
struct rtgui_scrollbar *vscroll; struct rtgui_scrollbar *vscroll;
#endif #endif
}; };
rt_bool_t rtgui_edit_append_line(struct rtgui_edit *edit, const char *text); rt_bool_t rtgui_edit_append_line(struct rtgui_edit *edit, const char *text);
rt_bool_t rtgui_edit_insert_line(struct rtgui_edit *edit, struct edit_line *p, char *text); rt_bool_t rtgui_edit_insert_line(struct rtgui_edit *edit, struct edit_line *p, char *text);
rt_bool_t rtgui_edit_delete_line(struct rtgui_edit *edit, struct edit_line *line); rt_bool_t rtgui_edit_delete_line(struct rtgui_edit *edit, struct edit_line *line);
rt_bool_t rtgui_edit_connect_line(struct rtgui_edit *edit, struct edit_line *line, struct edit_line *connect); rt_bool_t rtgui_edit_connect_line(struct rtgui_edit *edit, struct edit_line *line, struct edit_line *connect);
void _rtgui_edit_constructor(struct rtgui_edit *box); void _rtgui_edit_constructor(struct rtgui_edit *box);
void _rtgui_edit_deconstructor(struct rtgui_edit *textbox); void _rtgui_edit_deconstructor(struct rtgui_edit *textbox);
struct rtgui_edit* rtgui_edit_create(struct rtgui_container* container, int left, int top, int w, int h); struct rtgui_edit *rtgui_edit_create(struct rtgui_container *container, int left, int top, int w, int h);
void rtgui_edit_destroy(struct rtgui_edit *edit); void rtgui_edit_destroy(struct rtgui_edit *edit);
void rtgui_edit_update(struct rtgui_edit *edit); void rtgui_edit_update(struct rtgui_edit *edit);
void rtgui_edit_ondraw(struct rtgui_edit *edit); void rtgui_edit_ondraw(struct rtgui_edit *edit);
rt_bool_t rtgui_edit_event_handler(struct rtgui_object* object, rtgui_event_t* event); rt_bool_t rtgui_edit_event_handler(struct rtgui_object *object, rtgui_event_t *event);
void rtgui_edit_set_text(struct rtgui_edit *edit, const char* text); void rtgui_edit_set_text(struct rtgui_edit *edit, const char *text);
rtgui_point_t rtgui_edit_get_current_point(struct rtgui_edit *edit); rtgui_point_t rtgui_edit_get_current_point(struct rtgui_edit *edit);
rt_uint32_t rtgui_edit_get_mem_consume(struct rtgui_edit *edit); rt_uint32_t rtgui_edit_get_mem_consume(struct rtgui_edit *edit);
rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename); rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename);
rt_bool_t rtgui_edit_saveas_file(struct rtgui_edit *edit, const char *filename); rt_bool_t rtgui_edit_saveas_file(struct rtgui_edit *edit, const char *filename);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -8,10 +8,10 @@
#define RTGUI_FITEM_DIR 0x1 #define RTGUI_FITEM_DIR 0x1
struct rtgui_file_item struct rtgui_file_item
{ {
char* name; char *name;
rt_uint32_t type; rt_uint32_t type;
rt_uint32_t size; rt_uint32_t size;
}; };
DECLARE_CLASS_TYPE(filelist); DECLARE_CLASS_TYPE(filelist);
@ -24,35 +24,35 @@ DECLARE_CLASS_TYPE(filelist);
struct rtgui_filelist_view struct rtgui_filelist_view
{ {
struct rtgui_container parent; struct rtgui_container parent;
/* widget private data */ /* widget private data */
/* current directory */ /* current directory */
char* current_directory; char *current_directory;
char* pattern; char *pattern;
/* the number of item in a page */ /* the number of item in a page */
rt_uint16_t page_items; rt_uint16_t page_items;
rt_uint16_t items_count; rt_uint16_t items_count;
/* the selected item */ /* the selected item */
rt_uint16_t current_item; rt_uint16_t current_item;
/* items array */ /* items array */
struct rtgui_file_item *items; struct rtgui_file_item *items;
}; };
typedef struct rtgui_filelist_view rtgui_filelist_view_t; typedef struct rtgui_filelist_view rtgui_filelist_view_t;
rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory, rtgui_filelist_view_t *rtgui_filelist_view_create(const char *directory,
const char* pattern, const char *pattern,
const rtgui_rect_t* rect); const rtgui_rect_t *rect);
void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view); void rtgui_filelist_view_destroy(rtgui_filelist_view_t *view);
rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory); void rtgui_filelist_view_set_directory(rtgui_filelist_view_t *view, const char *directory);
void rtgui_filelist_view_get_fullpath(rtgui_filelist_view_t* view, char* path, rt_size_t len); void rtgui_filelist_view_get_fullpath(rtgui_filelist_view_t *view, char *path, rt_size_t len);
#endif #endif
#endif #endif

View File

@ -28,45 +28,45 @@ DECLARE_CLASS_TYPE(groupbox);
/** Checks if the object is an rtgui_groupbox */ /** Checks if the object is an rtgui_groupbox */
#define RTGUI_IS_GROUPBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_GROUPBOX_TYPE)) #define RTGUI_IS_GROUPBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_GROUPBOX_TYPE))
typedef void (*widget_select_t)(struct rtgui_widget* widget, rt_bool_t selected); typedef void (*widget_select_t)(struct rtgui_widget *widget, rt_bool_t selected);
/* /*
* the groupbox widget * the groupbox widget
* *
* The Group Box is a container widget, in which user can place some other widget into it. * The Group Box is a container widget, in which user can place some other widget into it.
* However, the current selected in group box must be notified by user: * However, the current selected in group box must be notified by user:
* - invoke rtgui_groupbox_select_widget to notify group box the current selected widget; * - invoke rtgui_groupbox_select_widget to notify group box the current selected widget;
* - when a widget has been selected, group box invokes groupbox->select_func to change * - when a widget has been selected, group box invokes groupbox->select_func to change
* the status of widget, for example un-select this widget. * the status of widget, for example un-select this widget.
*/ */
struct rtgui_groupbox struct rtgui_groupbox
{ {
struct rtgui_panel parent; struct rtgui_panel parent;
char* label; char *label;
struct rtgui_box *box; struct rtgui_box *box;
struct rtgui_widget *selected; struct rtgui_widget *selected;
widget_select_t select_func; widget_select_t select_func;
rtgui_event_handler_ptr on_selected; rtgui_event_handler_ptr on_selected;
}; };
typedef struct rtgui_groupbox rtgui_groupbox_t; typedef struct rtgui_groupbox rtgui_groupbox_t;
rtgui_groupbox_t* rtgui_groupbox_create(const char* label, struct rtgui_rect *rect, int style, widget_select_t select_func); rtgui_groupbox_t *rtgui_groupbox_create(const char *label, struct rtgui_rect *rect, int style, widget_select_t select_func);
void rtgui_groupbox_destroy(rtgui_groupbox_t* groupbox); void rtgui_groupbox_destroy(rtgui_groupbox_t *groupbox);
void rtgui_groupbox_layout(struct rtgui_groupbox *box); void rtgui_groupbox_layout(struct rtgui_groupbox *box);
void rtgui_groupbox_add_widget(struct rtgui_groupbox *box, struct rtgui_widget *widget); void rtgui_groupbox_add_widget(struct rtgui_groupbox *box, struct rtgui_widget *widget);
void rtgui_groupbox_select_widget(struct rtgui_groupbox *box, struct rtgui_widget *widget); void rtgui_groupbox_select_widget(struct rtgui_groupbox *box, struct rtgui_widget *widget);
struct rtgui_widget* rtgui_groupbox_get_selected(struct rtgui_groupbox *box); struct rtgui_widget *rtgui_groupbox_get_selected(struct rtgui_groupbox *box);
rt_bool_t rtgui_groupbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_groupbox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
rt_inline void rtgui_groupbox_set_onselected(struct rtgui_groupbox* box, rtgui_event_handler_ptr on_selected) rt_inline void rtgui_groupbox_set_onselected(struct rtgui_groupbox *box, rtgui_event_handler_ptr on_selected)
{ {
RT_ASSERT(box != RT_NULL); RT_ASSERT(box != RT_NULL);
box->on_selected = on_selected; box->on_selected = on_selected;
} }
#endif #endif

View File

@ -26,31 +26,31 @@ DECLARE_CLASS_TYPE(iconbox);
/** Checks if the object is a rtgui_iconbox */ /** Checks if the object is a rtgui_iconbox */
#define RTGUI_IS_ICONBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ICONBOX_TYPE)) #define RTGUI_IS_ICONBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ICONBOX_TYPE))
#define RTGUI_ICONBOX_NOTEXT 0x00 #define RTGUI_ICONBOX_NOTEXT 0x00
#define RTGUI_ICONBOX_TEXT_RIGHT 0x01 #define RTGUI_ICONBOX_TEXT_RIGHT 0x01
#define RTGUI_ICONBOX_TEXT_BELOW 0x02 #define RTGUI_ICONBOX_TEXT_BELOW 0x02
struct rtgui_iconbox struct rtgui_iconbox
{ {
/* inherit from widget */ /* inherit from widget */
struct rtgui_widget parent; struct rtgui_widget parent;
/* widget private data */ /* widget private data */
struct rtgui_image* image; struct rtgui_image *image;
char *text; char *text;
rt_ubase_t text_position; rt_ubase_t text_position;
rt_bool_t selected; rt_bool_t selected;
}; };
typedef struct rtgui_iconbox rtgui_iconbox_t; typedef struct rtgui_iconbox rtgui_iconbox_t;
struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const char* text, int position); struct rtgui_iconbox *rtgui_iconbox_create(struct rtgui_image *image, const char *text, int position);
void rtgui_iconbox_destroy(struct rtgui_iconbox* iconbox); void rtgui_iconbox_destroy(struct rtgui_iconbox *iconbox);
rt_bool_t rtgui_iconbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_iconbox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_iconbox_set_text_position(struct rtgui_iconbox* iconbox, int position); void rtgui_iconbox_set_text_position(struct rtgui_iconbox *iconbox, int position);
void rtgui_iconbox_set_selected(struct rtgui_iconbox* iconbox, rt_bool_t selected); void rtgui_iconbox_set_selected(struct rtgui_iconbox *iconbox, rt_bool_t selected);
#endif #endif

View File

@ -31,19 +31,19 @@ DECLARE_CLASS_TYPE(label);
*/ */
struct rtgui_label struct rtgui_label
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* label */ /* label */
char* text; char *text;
}; };
typedef struct rtgui_label rtgui_label_t; typedef struct rtgui_label rtgui_label_t;
rtgui_label_t* rtgui_label_create(const char* text); rtgui_label_t *rtgui_label_create(const char *text);
void rtgui_label_destroy(rtgui_label_t* label); void rtgui_label_destroy(rtgui_label_t *label);
rt_bool_t rtgui_label_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_label_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_label_set_text(rtgui_label_t* label, const char* text); void rtgui_label_set_text(rtgui_label_t *label, const char *text);
char* rtgui_label_get_text(rtgui_label_t* label); char *rtgui_label_get_text(rtgui_label_t *label);
#endif #endif

View File

@ -21,11 +21,11 @@
#include <rtgui/widgets/container.h> #include <rtgui/widgets/container.h>
typedef void (*item_action)(struct rtgui_widget* widget, void* parameter); typedef void (*item_action)(struct rtgui_widget *widget, void *parameter);
struct rtgui_list_item struct rtgui_list_item
{ {
char* name; char *name;
rtgui_image_t *image; rtgui_image_t *image;
item_action action; item_action action;
void *parameter; void *parameter;
@ -39,38 +39,38 @@ DECLARE_CLASS_TYPE(listview);
/** Checks if the object is a filelist view */ /** Checks if the object is a filelist view */
#define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE)) #define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE))
#define RTGUI_LIST_VIEW_LIST 0x00 #define RTGUI_LIST_VIEW_LIST 0x00
#define RTGUI_LIST_VIEW_ICON 0x01 #define RTGUI_LIST_VIEW_ICON 0x01
#define RTGUI_LIST_VIEW_REPORT 0x02 #define RTGUI_LIST_VIEW_REPORT 0x02
struct rtgui_list_view struct rtgui_list_view
{ {
struct rtgui_container parent; struct rtgui_container parent;
/* widget private data */ /* widget private data */
/* list item */ /* list item */
const struct rtgui_list_item* items; const struct rtgui_list_item *items;
/* layout flag */ /* layout flag */
rt_uint16_t flag; rt_uint16_t flag;
/* total number of items */ /* total number of items */
rt_uint16_t items_count; rt_uint16_t items_count;
/* the number of item in a page */ /* the number of item in a page */
rt_uint16_t page_items; rt_uint16_t page_items;
/* current item */ /* current item */
rt_int16_t current_item; rt_int16_t current_item;
/* icon layout */ /* icon layout */
rt_uint8_t row_items, col_items; rt_uint8_t row_items, col_items;
}; };
typedef struct rtgui_list_view rtgui_list_view_t; typedef struct rtgui_list_view rtgui_list_view_t;
rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count, rtgui_list_view_t *rtgui_list_view_create(const struct rtgui_list_item *items, rt_uint16_t count,
rtgui_rect_t *rect, rt_uint16_t flag); rtgui_rect_t *rect, rt_uint16_t flag);
void rtgui_list_view_destroy(rtgui_list_view_t* view); void rtgui_list_view_destroy(rtgui_list_view_t *view);
rt_bool_t rtgui_list_view_event_handler(struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t rtgui_list_view_event_handler(struct rtgui_object *widget, struct rtgui_event *event);
#endif #endif

View File

@ -22,31 +22,31 @@
struct rtgui_listbox_item struct rtgui_listbox_item
{ {
char* name; char *name;
rtgui_image_t *image; rtgui_image_t *image;
}; };
DECLARE_CLASS_TYPE(listbox); DECLARE_CLASS_TYPE(listbox);
/** Gets the type of a list box */ /** Gets the type of a list box */
#define RTGUI_LISTBOX_TYPE (RTGUI_TYPE(listbox)) #define RTGUI_LISTBOX_TYPE (RTGUI_TYPE(listbox))
/** Casts the object to a filelist */ /** Casts the object to a filelist */
#define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t)) #define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
/** Checks if the object is a filelist box */ /** Checks if the object is a filelist box */
#define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE)) #define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE))
struct rtgui_listbox struct rtgui_listbox
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* widget private data */ /* widget private data */
/* listbox item */ /* listbox item */
const struct rtgui_listbox_item* items; const struct rtgui_listbox_item *items;
/* item event handler */ /* item event handler */
rtgui_event_handler_ptr on_item; rtgui_event_handler_ptr on_item;
/* total number of items */ /* total number of items */
rt_uint16_t items_count; rt_uint16_t items_count;
/* the number of item in a page */ /* the number of item in a page */
rt_uint16_t page_items; rt_uint16_t page_items;
/* current item */ /* current item */
@ -54,14 +54,14 @@ struct rtgui_listbox
}; };
typedef struct rtgui_listbox rtgui_listbox_t; typedef struct rtgui_listbox rtgui_listbox_t;
rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count, rtgui_listbox_t *rtgui_listbox_create(const struct rtgui_listbox_item *items, rt_uint16_t count,
rtgui_rect_t *rect); rtgui_rect_t *rect);
void rtgui_listbox_destroy(rtgui_listbox_t* box); void rtgui_listbox_destroy(rtgui_listbox_t *box);
rt_bool_t rtgui_listbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_listbox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_event_handler_ptr func); void rtgui_listbox_set_onitem(rtgui_listbox_t *box, rtgui_event_handler_ptr func);
void rtgui_listbox_set_items(rtgui_listbox_t* box, struct rtgui_listbox_item* items, rt_uint16_t count); void rtgui_listbox_set_items(rtgui_listbox_t *box, struct rtgui_listbox_item *items, rt_uint16_t count);
void rtgui_listbox_set_current_item(rtgui_listbox_t* box, int index); void rtgui_listbox_set_current_item(rtgui_listbox_t *box, int index);
#endif #endif

View File

@ -22,44 +22,45 @@
DECLARE_CLASS_TYPE(listctrl); DECLARE_CLASS_TYPE(listctrl);
/** Gets the type of a listctrl */ /** Gets the type of a listctrl */
#define RTGUI_LISTCTRL_TYPE (RTGUI_TYPE(listctrl)) #define RTGUI_LISTCTRL_TYPE (RTGUI_TYPE(listctrl))
/** Casts the object to a listctrl */ /** Casts the object to a listctrl */
#define RTGUI_LISTCTRL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTCTRL_TYPE, rtgui_listctrl_t)) #define RTGUI_LISTCTRL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTCTRL_TYPE, rtgui_listctrl_t))
/** Checks if the object is a listctrl */ /** Checks if the object is a listctrl */
#define RTGUI_IS_LISTCTRL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTCTRL_TYPE)) #define RTGUI_IS_LISTCTRL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTCTRL_TYPE))
struct rtgui_listctrl struct rtgui_listctrl
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* widget private data */ /* widget private data */
/* listctrl items */ /* listctrl items */
rt_uint32_t items; void *items;
/* total number of items */ /* total number of items */
rt_uint16_t items_count; rt_uint16_t items_count;
/* the number of item in a page */ /* the number of item in a page */
rt_uint16_t page_items; rt_uint16_t page_items;
/* current item */ /* current item */
rt_int16_t current_item; rt_int16_t current_item;
rt_uint16_t item_height; rt_uint16_t item_height;
/* item event handler */ /* item event handler */
rtgui_event_handler_ptr on_item; rtgui_event_handler_ptr on_item;
void (*on_item_draw)(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index); void (*on_item_draw)(struct rtgui_listctrl *list, struct rtgui_dc *dc, rtgui_rect_t *rect, rt_uint16_t index);
}; };
typedef struct rtgui_listctrl rtgui_listctrl_t; typedef struct rtgui_listctrl rtgui_listctrl_t;
typedef void (*rtgui_onitem_draw_t)(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index); typedef void (*rtgui_onitem_draw_t)(struct rtgui_listctrl *list, struct rtgui_dc *dc, rtgui_rect_t *rect, rt_uint16_t index);
rtgui_listctrl_t* rtgui_listctrl_create(rt_uint32_t items, rt_uint16_t count, rtgui_listctrl_t *rtgui_listctrl_create(void *items, rt_uint16_t count,
rtgui_rect_t *rect, rtgui_onitem_draw_t ondraw); rtgui_rect_t *rect, rtgui_onitem_draw_t ondraw);
void rtgui_listctrl_destroy(rtgui_listctrl_t* ctrl); void rtgui_listctrl_destroy(rtgui_listctrl_t *ctrl);
rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_listctrl_set_onitem(rtgui_listctrl_t* ctrl, rtgui_event_handler_ptr func); void rtgui_listctrl_set_onitem(rtgui_listctrl_t *ctrl, rtgui_event_handler_ptr func);
void rtgui_listctrl_set_items(rtgui_listctrl_t* ctrl, rt_uint32_t items, rt_uint16_t count); void rtgui_listctrl_set_items(rtgui_listctrl_t *ctrl, void *items, rt_uint16_t count);
rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t* ctrl, rt_uint16_t item, rtgui_rect_t* item_rect); void rtgui_listctrl_set_current_item(struct rtgui_listctrl *ctrl, rt_uint16_t index);
void rtgui_listctrl_set_itemheight(struct rtgui_listctrl* ctrl, int height); rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t *ctrl, rt_uint16_t item, rtgui_rect_t *item_rect);
void rtgui_listctrl_set_itemheight(struct rtgui_listctrl *ctrl, int height);
#endif #endif

View File

@ -8,28 +8,28 @@
/* rtgui menu item */ /* rtgui menu item */
enum rtgui_menu_item_type enum rtgui_menu_item_type
{ {
RTGUI_ITEM_NORMAL, RTGUI_ITEM_NORMAL,
RTGUI_ITEM_CHECK, RTGUI_ITEM_CHECK,
RTGUI_ITEM_SUBMENU, RTGUI_ITEM_SUBMENU,
RTGUI_ITEM_SEPARATOR RTGUI_ITEM_SEPARATOR
}; };
typedef enum rtgui_menu_item_type rtgui_menu_item_type_t; typedef enum rtgui_menu_item_type rtgui_menu_item_type_t;
struct rtgui_menu_item struct rtgui_menu_item
{ {
rtgui_menu_item_type_t type; rtgui_menu_item_type_t type;
/* menu text label */ /* menu text label */
const char* label; const char *label;
/* menu image */ /* menu image */
rtgui_image_t *image; rtgui_image_t *image;
/* sub-menu item */ /* sub-menu item */
const struct rtgui_menu_item_t *submenu; const struct rtgui_menu_item_t *submenu;
rt_uint16_t submenu_count; rt_uint16_t submenu_count;
/* menu action */ /* menu action */
rt_bool_t (*on_menuaction)(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t (*on_menuaction)(struct rtgui_object *object, struct rtgui_event *event);
}; };
typedef struct rtgui_menu_item rtgui_menu_item_t; typedef struct rtgui_menu_item rtgui_menu_item_t;
@ -41,38 +41,38 @@ DECLARE_CLASS_TYPE(menu);
/** Checks if the object is an rtgui_menu */ /** Checks if the object is an rtgui_menu */
#define RTGUI_IS_MENU(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MENU_TYPE)) #define RTGUI_IS_MENU(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MENU_TYPE))
#define RTGUI_MENU_DEFAULT_WIDTH 100 #define RTGUI_MENU_DEFAULT_WIDTH 100
struct rtgui_menu struct rtgui_menu
{ {
/* inherited from window */ /* inherited from window */
struct rtgui_win parent; struct rtgui_win parent;
/* menu items */ /* menu items */
const struct rtgui_menu_item *items; const struct rtgui_menu_item *items;
rt_uint16_t items_count; rt_uint16_t items_count;
/* parent menu */ /* parent menu */
struct rtgui_menu *parent_menu; struct rtgui_menu *parent_menu;
struct rtgui_menu *sub_menu; struct rtgui_menu *sub_menu;
/* menu item list control */ /* menu item list control */
struct rtgui_listctrl *items_list; struct rtgui_listctrl *items_list;
/* pop event handle */ /* pop event handle */
rtgui_event_handler_ptr on_menupop; rtgui_event_handler_ptr on_menupop;
rtgui_event_handler_ptr on_menuhide; rtgui_event_handler_ptr on_menuhide;
}; };
typedef struct rtgui_menu rtgui_menu_t; typedef struct rtgui_menu rtgui_menu_t;
struct rtgui_menu* rtgui_menu_create(const char* title, struct rtgui_menu* parent_menu, struct rtgui_menu *rtgui_menu_create(const char *title, struct rtgui_menu *parent_menu,
const struct rtgui_menu_item* items, rt_uint16_t count); const struct rtgui_menu_item *items, rt_uint16_t count);
void rtgui_menu_destroy(struct rtgui_menu* menu); void rtgui_menu_destroy(struct rtgui_menu *menu);
void rtgui_menu_set_onmenupop(struct rtgui_menu* menu, rtgui_event_handler_ptr handler); void rtgui_menu_set_onmenupop(struct rtgui_menu *menu, rtgui_event_handler_ptr handler);
void rtgui_menu_set_onmenuhide(struct rtgui_menu* menu, rtgui_event_handler_ptr handler); void rtgui_menu_set_onmenuhide(struct rtgui_menu *menu, rtgui_event_handler_ptr handler);
void rtgui_menu_pop(struct rtgui_menu* menu, int x, int y); void rtgui_menu_pop(struct rtgui_menu *menu, int x, int y);
void rtgui_menu_hiden(struct rtgui_menu* menu); void rtgui_menu_hiden(struct rtgui_menu *menu);
#endif #endif

View File

@ -0,0 +1,44 @@
/*
* File : mv_view.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-09-15 Grissiom first version
*/
#ifndef __MV_VIEW_H__
#define __MV_VIEW_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(mv_view);
/** Gets the type of a mv_view */
#define RTGUI_MV_VIEW_TYPE (RTGUI_TYPE(mv_view))
/** Casts the object to an mv_view */
#define RTGUI_MV_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MV_VIEW_TYPE, struct rtgui_mv_view))
/** Checks if the object is an mv_view */
#define RTGUI_IS_MV_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MV_VIEW_TYPE))
struct rtgui_mv_view
{
struct rtgui_widget parent;
rt_uint16_t model_number;
/* if the model_number is 1, the model is the pointer to the model. If the
* model_number is more than 1, model is a pointer to a array of pointers
* to model. */
void *model;
};
struct rtgui_mv_view *rtgui_mv_view_create(void);
void rtgui_mv_view_destroy(struct rtgui_mv_view *view);
struct rtgui_mv_model *rtgui_mv_view_foreach_in_model(struct rtgui_mv_view *view, rt_uint32_t *iter);
#endif /* end of include guard: __MV_VIEW_H__ */

View File

@ -13,60 +13,60 @@ DECLARE_CLASS_TYPE(notebook);
/** Checks if the object is a notebook control */ /** Checks if the object is a notebook control */
#define RTGUI_IS_NOTEBOOK(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_NOTEBOOK_TYPE)) #define RTGUI_IS_NOTEBOOK(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_NOTEBOOK_TYPE))
#define RTGUI_NOTEBOOK_TOP 0x00 #define RTGUI_NOTEBOOK_TOP 0x00
#define RTGUI_NOTEBOOK_BOTTOM 0x01 #define RTGUI_NOTEBOOK_BOTTOM 0x01
#define RTGUI_NOTEBOOK_NOTAB 0x02 #define RTGUI_NOTEBOOK_NOTAB 0x02
#define RTGUI_NOTEBOOK_LEFT 0x03 #define RTGUI_NOTEBOOK_LEFT 0x03
#define RTGUI_NOTEBOOK_RIGHT 0x04 #define RTGUI_NOTEBOOK_RIGHT 0x04
struct rtgui_notebook_tab; struct rtgui_notebook_tab;
struct rtgui_notebook struct rtgui_notebook
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
rt_uint8_t flag; rt_uint8_t flag;
/* widget private data */ /* widget private data */
struct rtgui_notebook_tab *childs; struct rtgui_notebook_tab *childs;
rt_uint16_t count; rt_uint16_t count;
rt_int16_t current; rt_int16_t current;
rt_uint16_t tab_w, tab_h; rt_uint16_t tab_w, tab_h;
}; };
struct rtgui_notebook* rtgui_notebook_create(const rtgui_rect_t* rect, rt_uint8_t style); struct rtgui_notebook *rtgui_notebook_create(const rtgui_rect_t *rect, rt_uint8_t style);
void rtgui_notebook_destroy(struct rtgui_notebook* notebook); void rtgui_notebook_destroy(struct rtgui_notebook *notebook);
rt_inline void rtgui_notebook_set_tab_height(struct rtgui_notebook *notebook, rt_uint16_t height) rt_inline void rtgui_notebook_set_tab_height(struct rtgui_notebook *notebook, rt_uint16_t height)
{ {
RT_ASSERT(notebook != RT_NULL); RT_ASSERT(notebook != RT_NULL);
notebook->tab_h = height; notebook->tab_h = height;
} }
rt_inline void rtgui_notebook_set_tab_width(struct rtgui_notebook *notebook, rt_uint16_t width) rt_inline void rtgui_notebook_set_tab_width(struct rtgui_notebook *notebook, rt_uint16_t width)
{ {
RT_ASSERT(notebook != RT_NULL); RT_ASSERT(notebook != RT_NULL);
notebook->tab_w = width; notebook->tab_w = width;
} }
void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child); void rtgui_notebook_add(struct rtgui_notebook *notebook, const char *label, struct rtgui_widget *child);
#ifdef RTGUI_USING_NOTEBOOK_IMAGE #ifdef RTGUI_USING_NOTEBOOK_IMAGE
void rtgui_notebook_add_image(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child, void rtgui_notebook_add_image(struct rtgui_notebook *notebook, const char *label, struct rtgui_widget *child,
struct rtgui_image *pressed_image, struct rtgui_image *unpressed_image); struct rtgui_image *pressed_image, struct rtgui_image *unpressed_image);
#endif #endif
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index); void rtgui_notebook_remove(struct rtgui_notebook *notebook, rt_uint16_t index);
struct rtgui_widget* rtgui_notebook_get_current(struct rtgui_notebook* notebook); struct rtgui_widget *rtgui_notebook_get_current(struct rtgui_notebook *notebook);
rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook* notebook); rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook *notebook);
int rtgui_notebook_get_count(struct rtgui_notebook* notebook); int rtgui_notebook_get_count(struct rtgui_notebook *notebook);
void rtgui_notebook_get_client_rect(struct rtgui_notebook* notebook, struct rtgui_rect *rect); void rtgui_notebook_get_client_rect(struct rtgui_notebook *notebook, struct rtgui_rect *rect);
void rtgui_notebook_set_current(struct rtgui_notebook* notebook, struct rtgui_widget* child); void rtgui_notebook_set_current(struct rtgui_notebook *notebook, struct rtgui_widget *child);
void rtgui_notebook_set_current_by_index(struct rtgui_notebook* notebook, rt_uint16_t index); void rtgui_notebook_set_current_by_index(struct rtgui_notebook *notebook, rt_uint16_t index);
struct rtgui_widget* rtgui_notebook_get_widget_at(struct rtgui_notebook* notebook, rt_uint16_t index); struct rtgui_widget *rtgui_notebook_get_widget_at(struct rtgui_notebook *notebook, rt_uint16_t index);
rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t rtgui_notebook_event_handler(struct rtgui_object *widget, struct rtgui_event *event);
#endif #endif

View File

@ -31,21 +31,21 @@ DECLARE_CLASS_TYPE(panel);
*/ */
struct rtgui_panel struct rtgui_panel
{ {
struct rtgui_container parent; struct rtgui_container parent;
int border_style; int border_style;
}; };
typedef struct rtgui_panel rtgui_panel_t; typedef struct rtgui_panel rtgui_panel_t;
rtgui_panel_t* rtgui_panel_create(int border_style); rtgui_panel_t *rtgui_panel_create(int border_style);
void rtgui_panel_destroy(rtgui_panel_t* panel); void rtgui_panel_destroy(rtgui_panel_t *panel);
rt_inline void rtgui_panel_set_border(struct rtgui_panel* panel, int border_style) rt_inline void rtgui_panel_set_border(struct rtgui_panel *panel, int border_style)
{ {
RT_ASSERT(panel != RT_NULL); RT_ASSERT(panel != RT_NULL);
panel->border_style = border_style; panel->border_style = border_style;
} }
rt_bool_t rtgui_panel_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_panel_event_handler(struct rtgui_object *object, struct rtgui_event *event);
#endif #endif

View File

@ -16,6 +16,7 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
#include <rtgui/widgets/mv_view.h>
#include <rtgui/widgets/plot_curve.h> #include <rtgui/widgets/plot_curve.h>
DECLARE_CLASS_TYPE(plot); DECLARE_CLASS_TYPE(plot);
@ -27,17 +28,10 @@ DECLARE_CLASS_TYPE(plot);
/** Checks if the object is an rtgui_plot */ /** Checks if the object is an rtgui_plot */
#define RTGUI_IS_PLOT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PLOT_TYPE)) #define RTGUI_IS_PLOT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PLOT_TYPE))
struct rtgui_plot_curve_container enum rtgui_plot_type
{ {
struct rtgui_plot_curve *curve; RTGUI_PLOT_TYPE_SCAN,
struct rtgui_plot_curve_container *next; RTGUI_PLOT_TYPE_INCREMENTAL,
};
enum rtgui_plot_flag
{
RTGUI_PLOT_INCREMENTAL,
RTGUI_PLOT_MOVING_WINDOW,
RTGUI_PLOT_SCAN,
}; };
/* /*
@ -45,20 +39,21 @@ enum rtgui_plot_flag
*/ */
struct rtgui_plot struct rtgui_plot
{ {
struct rtgui_widget parent; struct rtgui_mv_view parent;
enum rtgui_plot_flag pflag; enum rtgui_plot_type ptype;
rt_uint16_t scale_x;
rt_uint16_t scale_y;
struct rtgui_point base_point; rtgui_plot_curve_dtype base_x;
struct rtgui_plot_curve_container curve_container; rtgui_plot_curve_dtype base_y;
}; };
struct rtgui_plot *rtgui_plot_create(struct rtgui_plot_curve*); struct rtgui_plot *rtgui_plot_create(void);
void rtgui_plot_destroy(struct rtgui_plot *plot); void rtgui_plot_destroy(struct rtgui_plot *plot);
void rtgui_plot_set_base_point(struct rtgui_plot *plot, rt_uint16_t x, rt_uint16_t y); void rtgui_plot_set_base(struct rtgui_plot *plot,
void rtgui_plot_append_curve(struct rtgui_plot *plot, struct rtgui_plot_curve *curve); rtgui_plot_curve_dtype x, rtgui_plot_curve_dtype y);
void rtgui_plot_remove_curve(struct rtgui_plot *plot, struct rtgui_plot_curve *curve);
rt_bool_t rtgui_plot_event_handler(struct rtgui_object *object, struct rtgui_event *event); rt_bool_t rtgui_plot_event_handler(struct rtgui_object *object, struct rtgui_event *event);

View File

@ -15,6 +15,7 @@
#define __RTGUI_PLOT_CURVE_H__ #define __RTGUI_PLOT_CURVE_H__
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/rtgui_mv_model.h>
DECLARE_CLASS_TYPE(plot_curve); DECLARE_CLASS_TYPE(plot_curve);
@ -31,15 +32,20 @@ DECLARE_CLASS_TYPE(plot_curve);
struct rtgui_plot_curve struct rtgui_plot_curve
{ {
struct rtgui_object parent; struct rtgui_mv_model parent;
rtgui_color_t color; rtgui_color_t color;
rt_size_t length; rtgui_plot_curve_dtype min_x, max_x;
rtgui_plot_curve_dtype *x_data; rtgui_plot_curve_dtype min_y, max_y;
rtgui_plot_curve_dtype *y_data;
}; };
struct rtgui_plot_curve *rtgui_plot_curve_create(void); struct rtgui_plot_curve *rtgui_plot_curve_create(void);
void rtgui_plot_curve_destroy(struct rtgui_plot_curve *curve); void rtgui_plot_curve_destroy(struct rtgui_plot_curve *curve);
void rtgui_plot_curve_set_x(struct rtgui_plot_curve *curve, void *p);
void *rtgui_plot_curve_get_x(struct rtgui_plot_curve *curve);
void rtgui_plot_curve_set_y(struct rtgui_plot_curve *curve, void *p);
void *rtgui_plot_curve_get_y(struct rtgui_plot_curve *curve);
#endif #endif

View File

@ -17,20 +17,20 @@ DECLARE_CLASS_TYPE(progressbar);
struct rtgui_progressbar struct rtgui_progressbar
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
int orient; int orient;
int range; int range;
int position; int position;
}; };
typedef struct rtgui_progressbar rtgui_progressbar_t; typedef struct rtgui_progressbar rtgui_progressbar_t;
struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range, rtgui_rect_t* r); struct rtgui_progressbar *rtgui_progressbar_create(int orientation, int range, rtgui_rect_t *r);
void rtgui_progressbar_destroy(struct rtgui_progressbar* p_bar); void rtgui_progressbar_destroy(struct rtgui_progressbar *p_bar);
rt_bool_t rtgui_progressbar_event_handler(struct rtgui_object* object, rt_bool_t rtgui_progressbar_event_handler(struct rtgui_object *object,
struct rtgui_event* event); struct rtgui_event *event);
void rtgui_progressbar_set_value(struct rtgui_progressbar *p_bar, int value); void rtgui_progressbar_set_value(struct rtgui_progressbar *p_bar, int value);
int rtgui_progressbar_get_value(struct rtgui_progressbar *p_bar); int rtgui_progressbar_get_value(struct rtgui_progressbar *p_bar);

View File

@ -14,32 +14,32 @@ DECLARE_CLASS_TYPE(radiobox);
struct rtgui_radiobox struct rtgui_radiobox
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* widget private data */ /* widget private data */
char* text; /* radio box label */ char *text; /* radio box label */
/* box orient */ /* box orient */
rt_uint8_t orient; rt_uint8_t orient;
/* item size */ /* item size */
rt_uint8_t item_size; rt_uint8_t item_size;
char** items; char **items;
rt_uint16_t item_count; rt_uint16_t item_count;
rt_int16_t item_selection; rt_int16_t item_selection;
}; };
typedef struct rtgui_radiobox rtgui_radiobox_t; typedef struct rtgui_radiobox rtgui_radiobox_t;
struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number); struct rtgui_radiobox *rtgui_radiobox_create(const char *label, int orient, char **radio_items, int number);
void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox); void rtgui_radiobox_destroy(struct rtgui_radiobox *radiobox);
void rtgui_radiobox_set_selection(struct rtgui_radiobox* radiobox, int selection); void rtgui_radiobox_set_selection(struct rtgui_radiobox *radiobox, int selection);
int rtgui_radiobox_get_selection(struct rtgui_radiobox* radiobox); int rtgui_radiobox_get_selection(struct rtgui_radiobox *radiobox);
rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_radiobox_set_orientation(struct rtgui_radiobox* radiobox, int orientation); void rtgui_radiobox_set_orientation(struct rtgui_radiobox *radiobox, int orientation);
#endif #endif

View File

@ -14,14 +14,15 @@
#ifndef __RTGUI_SCROLLBAR_H__ #ifndef __RTGUI_SCROLLBAR_H__
#define __RTGUI_SCROLLBAR_H__ #define __RTGUI_SCROLLBAR_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
#include <rtgui/widgets/container.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(scrollbar); DECLARE_CLASS_TYPE(scrollbar);
/** Gets the type of a scrollbar */ /** Gets the type of a scrollbar */
#define RTGUI_SCROLLBAR_TYPE (RTGUI_TYPE(scrollbar)) #define RTGUI_SCROLLBAR_TYPE (RTGUI_TYPE(scrollbar))
/** Casts the object to an rtgui_scrollbar */ /** Casts the object to an rtgui_scrollbar */
@ -29,58 +30,60 @@ DECLARE_CLASS_TYPE(scrollbar);
/** Checks if the object is an rtgui_scrollbar */ /** Checks if the object is an rtgui_scrollbar */
#define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE)) #define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE))
#define RTGUI_DEFAULT_SB_WIDTH 100 #define RTGUI_DEFAULT_SB_WIDTH 16
#define RTGUI_DEFAULT_SB_HEIGHT 16
/* scrollbar status/positions*/ /* scrollbar status/positions*/
#define SBS_UNKNOWN 0x0000 #define SBS_UNKNOWN 0x0000
#define SBS_LEFTARROW 0x0001 #define SBS_LEFTARROW 0x0001
#define SBS_RIGHTARROW 0x0002 #define SBS_RIGHTARROW 0x0002
#define SBS_LEFTSPACE 0x0004 #define SBS_LEFTSPACE 0x0004 /* Need mouse_motion event */
#define SBS_RIGHTSPACE 0x0008 #define SBS_RIGHTSPACE 0x0008 /* Need mouse_motion event */
#define SBS_HORZTHUMB 0x0010 #define SBS_HORZTHUMB 0x0010 /* Need mouse_motion event */
#define SBS_UPARROW 0x0020 #define SBS_UPARROW 0x0020
#define SBS_DOWNARROW 0x0040 #define SBS_DOWNARROW 0x0040
#define SBS_UPSPACE 0x0080 #define SBS_UPSPACE 0x0080 /* Need mouse_motion event */
#define SBS_DOWNSPACE 0x0100 #define SBS_DOWNSPACE 0x0100 /* Need mouse_motion event */
#define SBS_VERTTHUMB 0x0200 #define SBS_VERTTHUMB 0x0200 /* Need mouse_motion event */
#define SBS_UPTHUMB 0x0400 /* Need mouse_motion event */
#define SBS_DOWNTHUMB 0x0800 /* Need mouse_motion event */
#define SBS_LEFTTHUMB 0x1000 /* Need mouse_motion event */
#define SBS_RIGHTTHUMB 0x2000 /* Need mouse_motion event */
struct rtgui_scrollbar struct rtgui_scrollbar
{ {
/* inherit from widget */ /* inherit from widget */
struct rtgui_widget parent; rtgui_widget_t parent;
rt_uint8_t orient; rt_uint8_t orient;
rt_uint8_t status; rt_uint32_t status;
/* page_step = width of scrollbar */ /* page_step = display lines of scrollbar */
/* thumb size = line_step * page_step / (page_step - (button width * 2)) */ /* thumb_len = line_step * page_step / (page_step - (button width * 2)) */
rt_int16_t line_step, page_step; rt_int16_t line_step, page_step;
rt_int16_t value, thumb_len,thumb_w;
rt_int16_t thumb_position, thumb_size;
/* position 1:1 width of scrollbar */ /* position 1:1 width of scrollbar */
rt_int16_t min_position, max_position; rt_int16_t count;
rtgui_event_handler_ptr on_scroll; rtgui_widget_t *widget_link;/* be connected widget */
rt_bool_t (*on_scroll) (rtgui_object_t *obj, rtgui_event_t* event);
}; };
typedef struct rtgui_scrollbar rtgui_scrollbar_t; typedef struct rtgui_scrollbar rtgui_scrollbar_t;
struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r); rtgui_scrollbar_t* rtgui_scrollbar_create(rtgui_container_t *container,int left,int top,int w,int len,int orient);
void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar); void rtgui_scrollbar_destroy(rtgui_scrollbar_t* bar);
void rtgui_scrollbar_ondraw(rtgui_scrollbar_t* bar);
void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *erect);
void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect); void rtgui_scrollbar_set_range(rtgui_scrollbar_t* bar, int count);
void rtgui_scrollbar_set_value(rtgui_scrollbar_t* bar, rt_int16_t value);
void rtgui_scrollbar_set_range(struct rtgui_scrollbar* bar, int min, int max); void rtgui_scrollbar_set_onscroll(rtgui_scrollbar_t* bar, rtgui_event_handler_ptr handler);
rt_int16_t rtgui_scrollbar_get_value(struct rtgui_scrollbar* bar); void rtgui_scrollbar_set_orientation(rtgui_scrollbar_t* bar, int orient);
void rtgui_scrollbar_set_value(struct rtgui_scrollbar* bar, rt_int16_t position); void rtgui_scrollbar_set_page_step(rtgui_scrollbar_t* bar, int step);
void rtgui_scrollbar_set_line_step(rtgui_scrollbar_t* bar, int step);
void rtgui_scrollbar_set_onscroll(struct rtgui_scrollbar* bar, rtgui_event_handler_ptr handler); rt_bool_t rtgui_scrollbar_event_handler(rtgui_object_t *obj, rtgui_event_t* event);
void rtgui_scrollbar_set_orientation(struct rtgui_scrollbar* bar, int orientation); void rtgui_scrollbar_hide(rtgui_scrollbar_t* bar);
void rtgui_scrollbar_set_page_step(struct rtgui_scrollbar* bar, int step);
void rtgui_scrollbar_set_line_step(struct rtgui_scrollbar* bar, int step);
rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_object* object, struct rtgui_event* event);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -27,27 +27,27 @@ DECLARE_CLASS_TYPE(slider);
struct rtgui_slider struct rtgui_slider
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* widget private data */ /* widget private data */
rt_size_t min, max, value, ticks; rt_size_t min, max, value, ticks;
rt_size_t thumb_width; rt_size_t thumb_width;
int orient; int orient;
void (*on_changed)(struct rtgui_widget* widget, struct rtgui_event *event); void (*on_changed)(struct rtgui_widget *widget, struct rtgui_event *event);
}; };
typedef struct rtgui_slider rtgui_slider_t; typedef struct rtgui_slider rtgui_slider_t;
struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient); struct rtgui_slider *rtgui_slider_create(rt_size_t min, rt_size_t max, int orient);
void rtgui_slider_destroy(struct rtgui_slider* slider); void rtgui_slider_destroy(struct rtgui_slider *slider);
rt_bool_t rtgui_slider_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_slider_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_slider_set_range(struct rtgui_slider* slider, rt_size_t min, rt_size_t max); void rtgui_slider_set_range(struct rtgui_slider *slider, rt_size_t min, rt_size_t max);
void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value); void rtgui_slider_set_value(struct rtgui_slider *slider, rt_size_t value);
void rtgui_slider_set_orientation(struct rtgui_slider* slider, int orientation); void rtgui_slider_set_orientation(struct rtgui_slider *slider, int orientation);
rt_size_t rtgui_slider_get_value(struct rtgui_slider* slider); rt_size_t rtgui_slider_get_value(struct rtgui_slider *slider);
#endif #endif

View File

@ -18,18 +18,18 @@ DECLARE_CLASS_TYPE(staticline);
struct rtgui_staticline struct rtgui_staticline
{ {
/* inherit from widget */ /* inherit from widget */
struct rtgui_widget parent; struct rtgui_widget parent;
int orient; int orient;
}; };
typedef struct rtgui_staticline rtgui_staticline_t; typedef struct rtgui_staticline rtgui_staticline_t;
rtgui_staticline_t *rtgui_staticline_create(int orientation); rtgui_staticline_t *rtgui_staticline_create(int orientation);
void rtgui_staticline_destroy(rtgui_staticline_t* staticline); void rtgui_staticline_destroy(rtgui_staticline_t *staticline);
rt_bool_t rtgui_staticline_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_staticline_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_staticline_set_orientation(rtgui_staticline_t* staticline, int orientation); void rtgui_staticline_set_orientation(rtgui_staticline_t *staticline, int orientation);
#endif #endif

View File

@ -1,16 +1,16 @@
/* /*
* File : textbox.h * File : textbox.h
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE * http://www.rt-thread.org/license/LICENSE
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2009-10-16 Bernard first version * 2009-10-16 Bernard first version
*/ */
#ifndef __RTGUI_TEXTBOX_H__ #ifndef __RTGUI_TEXTBOX_H__
#define __RTGUI_TEXTBOX_H__ #define __RTGUI_TEXTBOX_H__
@ -31,17 +31,17 @@ DECLARE_CLASS_TYPE(textbox);
/** Checks if the object is a rtgui_textbox_t */ /** Checks if the object is a rtgui_textbox_t */
#define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE)) #define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE))
#define RTGUI_TEXTBOX_DEFAULT_WIDTH 80 #define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20 #define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
#define RTGUI_TEXTBOX_SINGLE 0x00 #define RTGUI_TEXTBOX_SINGLE 0x00
#define RTGUI_TEXTBOX_MULTI 0x01 /* multiline */ #define RTGUI_TEXTBOX_MULTI 0x01 /* multiline */
#define RTGUI_TEXTBOX_MASK 0x02 /* ciphertext */ #define RTGUI_TEXTBOX_MASK 0x02 /* ciphertext */
#define RTGUI_TEXTBOX_DIGIT 0x04 /* digit */ #define RTGUI_TEXTBOX_DIGIT 0x04 /* digit */
#define RTGUI_TEXTBOX_CARET_SHOW 0x10 #define RTGUI_TEXTBOX_CARET_SHOW 0x10
#define RTGUI_TEXTBOX_CARET_STAT 0x20 /* unused */ #define RTGUI_TEXTBOX_CARET_STAT 0x20 /* unused */
#define RTGUI_TEXTBOX_LINE_MAX 128 /* text line cache */ #define RTGUI_TEXTBOX_LINE_MAX 128 /* text line cache */
struct rtgui_textbox struct rtgui_textbox
{ {
@ -53,8 +53,10 @@ struct rtgui_textbox
/* current line and position */ /* current line and position */
rt_uint16_t line, line_begin, position, line_length; rt_uint16_t line, line_begin, position, line_length;
rt_uint16_t dis_length; /*may be display length.*/ rt_uint16_t dis_length; /*may be display length.*/
char* text; rt_uint16_t first_pos;
char mask_char;
char *text;
rt_size_t font_width; rt_size_t font_width;
rtgui_timer_t *caret_timer; rtgui_timer_t *caret_timer;
@ -62,23 +64,24 @@ struct rtgui_textbox
rtgui_rect_t caret_rect; rtgui_rect_t caret_rect;
/* textbox private data */ /* textbox private data */
rt_bool_t (*on_enter) (struct rtgui_textbox *box, rtgui_event_t* event); rt_bool_t (*on_enter)(struct rtgui_textbox *box, rtgui_event_t *event);
}; };
typedef struct rtgui_textbox rtgui_textbox_t; typedef struct rtgui_textbox rtgui_textbox_t;
struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint32_t flag); rtgui_textbox_t *rtgui_textbox_create(const char *text, rt_uint32_t flag);
void rtgui_textbox_destroy(struct rtgui_textbox* box); void rtgui_textbox_destroy(struct rtgui_textbox *box);
rt_bool_t rtgui_textbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_textbox_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_textbox_set_value(struct rtgui_textbox* box, const char* text); void rtgui_textbox_set_value(struct rtgui_textbox *box, const char *text);
const char* rtgui_textbox_get_value(struct rtgui_textbox* box); const char *rtgui_textbox_get_value(struct rtgui_textbox *box);
void rtgui_textbox_set_mask_char(rtgui_textbox_t *box, const char ch);
const char rtgui_textbox_get_mask_char(rtgui_textbox_t *box);
void rtgui_textbox_set_line_length(struct rtgui_textbox *box, rt_size_t length);
void rtgui_textbox_set_line_length(struct rtgui_textbox* box, rt_size_t length); void rtgui_textbox_get_edit_rect(struct rtgui_textbox *box, rtgui_rect_t *rect);
void rtgui_textbox_get_edit_rect(struct rtgui_textbox *box,rtgui_rect_t *rect); void rtgui_textbox_ondraw(rtgui_textbox_t *box);
void rtgui_textbox_ondraw(rtgui_textbox_t* box);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -20,45 +20,45 @@
extern "C" { extern "C" {
#endif #endif
/** /**
* @defgroup rtgui_textview * @defgroup rtgui_textview
* @{ * @{
*/ */
DECLARE_CLASS_TYPE(textview); DECLARE_CLASS_TYPE(textview);
/** Gets the type of a textview */ /** Gets the type of a textview */
#define RTGUI_TEXTVIEW_TYPE (RTGUI_TYPE(textview)) #define RTGUI_TEXTVIEW_TYPE (RTGUI_TYPE(textview))
/** Casts the object to an rtgui_textview */ /** Casts the object to an rtgui_textview */
#define RTGUI_TEXTVIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTVIEW_TYPE, rtgui_textview_t)) #define RTGUI_TEXTVIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTVIEW_TYPE, rtgui_textview_t))
/** Checks if the object is an rtgui_textview */ /** Checks if the object is an rtgui_textview */
#define RTGUI_IS_TEXTVIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTVIEW_TYPE)) #define RTGUI_IS_TEXTVIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTVIEW_TYPE))
/* /*
* the textview widget * the textview widget
*/ */
struct rtgui_textview struct rtgui_textview
{ {
/* inherit from widget */ /* inherit from widget */
struct rtgui_widget parent; struct rtgui_widget parent;
rt_uint16_t line_width; rt_uint16_t line_width;
rt_uint16_t line_count; rt_uint16_t line_count;
char* lines; char *lines;
rt_int16_t line_current; rt_int16_t line_current;
rt_uint16_t line_page_count; rt_uint16_t line_page_count;
}; };
typedef struct rtgui_textview rtgui_textview_t; typedef struct rtgui_textview rtgui_textview_t;
rtgui_textview_t* rtgui_textview_create(const char* text, const rtgui_rect_t *rect); rtgui_textview_t *rtgui_textview_create(const char *text, const rtgui_rect_t *rect);
void rtgui_textview_destroy(rtgui_textview_t* textview); void rtgui_textview_destroy(rtgui_textview_t *textview);
rt_bool_t rtgui_textview_event_handler(struct rtgui_object* object, struct rtgui_event* event); rt_bool_t rtgui_textview_event_handler(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_textview_set_text(rtgui_textview_t* textview, const char* text); void rtgui_textview_set_text(rtgui_textview_t *textview, const char *text);
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -26,19 +26,19 @@ DECLARE_CLASS_TYPE(wintitle);
struct rtgui_wintitle struct rtgui_wintitle
{ {
struct rtgui_widget parent; struct rtgui_widget parent;
/* title */ /* title */
char* title; char *title;
}; };
typedef struct rtgui_wintitle rtgui_wintitle_t; typedef struct rtgui_wintitle rtgui_wintitle_t;
rtgui_wintitle_t* rtgui_wintitle_create(struct rtgui_win *window, const char* title); rtgui_wintitle_t *rtgui_wintitle_create(struct rtgui_win *window, const char *title);
void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle); void rtgui_wintitle_destroy(rtgui_wintitle_t *wintitle);
rt_bool_t rtgui_wintile_event_handler(rtgui_widget_t* widget, rtgui_event_t* event); rt_bool_t rtgui_wintile_event_handler(rtgui_widget_t *widget, rtgui_event_t *event);
void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const char* title); void rtgui_wintitle_set_title(rtgui_wintitle_t *wintitle, const char *title);
char *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle); char *rtgui_wintitle_get_title(rtgui_wintitle_t *wintitle);
#endif #endif

View File

@ -25,176 +25,176 @@
extern "C" { extern "C" {
#endif #endif
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000 #define RTGUI_WIDGET_FLAG_DEFAULT 0x0000
#define RTGUI_WIDGET_FLAG_SHOWN 0x0001 #define RTGUI_WIDGET_FLAG_SHOWN 0x0001
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002 #define RTGUI_WIDGET_FLAG_DISABLE 0x0002
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004 #define RTGUI_WIDGET_FLAG_FOCUS 0x0004
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008 #define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010 #define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100 #define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
/* rtgui widget attribute */ /* rtgui widget attribute */
#define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w)->gc.foreground) #define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w)->gc.foreground)
#define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w)->gc.background) #define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w)->gc.background)
#define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w)->gc.textalign) #define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w)->gc.textalign)
#define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w)->gc.font) #define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w)->gc.font)
#define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w)->flag) #define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w)->flag)
#define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w)->align) #define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w)->align)
#define RTGUI_WIDGET_BORDER(w) (RTGUI_WIDGET(w)->border) #define RTGUI_WIDGET_BORDER(w) (RTGUI_WIDGET(w)->border)
#define RTGUI_WIDGET_BORDER_STYLE(w) (RTGUI_WIDGET(w)->border_style) #define RTGUI_WIDGET_BORDER_STYLE(w) (RTGUI_WIDGET(w)->border_style)
#define RTGUI_WIDGET_UNHIDE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_SHOWN #define RTGUI_WIDGET_UNHIDE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_SHOWN
#define RTGUI_WIDGET_HIDE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_SHOWN #define RTGUI_WIDGET_HIDE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_SHOWN
#define RTGUI_WIDGET_IS_HIDE(w) (!(RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_SHOWN)) #define RTGUI_WIDGET_IS_HIDE(w) (!(RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_SHOWN))
#define RTGUI_WIDGET_ENABLE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_DISABLE #define RTGUI_WIDGET_ENABLE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_DISABLE
#define RTGUI_WIDGET_DISABLE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_DISABLE #define RTGUI_WIDGET_DISABLE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_DISABLE
#define RTGUI_WIDGET_IS_ENABLE(w) (!((RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_DISABLE))) #define RTGUI_WIDGET_IS_ENABLE(w) (!((RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_DISABLE)))
#define RTGUI_WIDGET_UNFOCUS(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_FOCUS #define RTGUI_WIDGET_UNFOCUS(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_FOCUS
#define RTGUI_WIDGET_FOCUS(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_FOCUS #define RTGUI_WIDGET_FOCUS(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_FOCUS
#define RTGUI_WIDGET_IS_FOCUSED(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_FOCUS) #define RTGUI_WIDGET_IS_FOCUSED(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_FOCUS)
#define RTGUI_WIDGET_IS_FOCUSABLE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_FOCUSABLE) #define RTGUI_WIDGET_IS_FOCUSABLE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_FOCUSABLE)
#define RTGUI_WIDGET_IS_DC_VISIBLE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_DC_VISIBLE) #define RTGUI_WIDGET_IS_DC_VISIBLE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_DC_VISIBLE)
#define RTGUI_WIDGET_DC_SET_VISIBLE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_DC_VISIBLE #define RTGUI_WIDGET_DC_SET_VISIBLE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_DC_VISIBLE
#define RTGUI_WIDGET_DC_SET_UNVISIBLE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_DC_VISIBLE #define RTGUI_WIDGET_DC_SET_UNVISIBLE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_DC_VISIBLE
#define RTGUI_WIDGET_DC(w) ((struct rtgui_dc*)&((w)->dc_type)) #define RTGUI_WIDGET_DC(w) ((struct rtgui_dc*)&((w)->dc_type))
DECLARE_CLASS_TYPE(widget); DECLARE_CLASS_TYPE(widget);
/** Gets the type of a widget */ /** Gets the type of a widget */
#define RTGUI_WIDGET_TYPE (RTGUI_TYPE(widget)) #define RTGUI_WIDGET_TYPE (RTGUI_TYPE(widget))
/** Casts the object to a rtgui_widget */ /** Casts the object to a rtgui_widget */
#define RTGUI_WIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIDGET_TYPE, rtgui_widget_t)) #define RTGUI_WIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIDGET_TYPE, rtgui_widget_t))
/** Check if the object is a rtgui_widget */ /** Check if the object is a rtgui_widget */
#define RTGUI_IS_WIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIDGET_TYPE)) #define RTGUI_IS_WIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIDGET_TYPE))
/* /*
* the base widget object * the base widget object
*/ */
struct rtgui_widget struct rtgui_widget
{ {
/* inherit from rtgui_object */ /* inherit from rtgui_object */
struct rtgui_object object; struct rtgui_object object;
/* the widget that contains this widget */ /* the widget that contains this widget */
struct rtgui_widget *parent; struct rtgui_widget *parent;
/* the window that contains this widget */ /* the window that contains this widget */
struct rtgui_win *toplevel; struct rtgui_win *toplevel;
/* the widget children and sibling */ /* the widget children and sibling */
rtgui_list_t sibling; rtgui_list_t sibling;
/* widget flag */ /* widget flag */
rt_int32_t flag; rt_int32_t flag;
/* hardware device context */ /* hardware device context */
rt_uint32_t dc_type; rt_uint32_t dc_type;
const struct rtgui_dc_engine* dc_engine; const struct rtgui_dc_engine *dc_engine;
/* the graphic context of widget */ /* the graphic context of widget */
rtgui_gc_t gc; rtgui_gc_t gc;
/* the widget extent */ /* the widget extent */
rtgui_rect_t extent; rtgui_rect_t extent;
/* minimal width and height of widget */ /* minimal width and height of widget */
rt_int16_t mini_width, mini_height; rt_int16_t mini_width, mini_height;
/* widget align */ /* widget align */
rt_int32_t align; rt_int32_t align;
rt_uint16_t border; rt_uint16_t border;
rt_uint16_t border_style; rt_uint16_t border_style;
/* the rect clip */ /* the rect clip */
rtgui_region_t clip; rtgui_region_t clip;
/* call back */ /* call back */
rt_bool_t (*on_focus_in) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_focus_in)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_focus_out) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_focus_out)(struct rtgui_object *widget, struct rtgui_event *event);
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
rt_bool_t (*on_draw) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_draw)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_mouseclick) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_mouseclick)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_key) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_key)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_size) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_size)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_command) (struct rtgui_object* widget, struct rtgui_event* event); rt_bool_t (*on_command)(struct rtgui_object *widget, struct rtgui_event *event);
#endif #endif
/* user private data */ /* user private data */
rt_uint32_t user_data; rt_uint32_t user_data;
}; };
typedef struct rtgui_widget rtgui_widget_t; typedef struct rtgui_widget rtgui_widget_t;
rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type); rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type);
void rtgui_widget_destroy(rtgui_widget_t* widget); void rtgui_widget_destroy(rtgui_widget_t *widget);
rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* event); rt_bool_t rtgui_widget_event_handler(struct rtgui_object *object, rtgui_event_t *event);
/* focus and unfocus */ /* focus and unfocus */
void rtgui_widget_focus(rtgui_widget_t * widget); void rtgui_widget_focus(rtgui_widget_t *widget);
void rtgui_widget_unfocus(rtgui_widget_t *widget); void rtgui_widget_unfocus(rtgui_widget_t *widget);
/* event handler for each command */ /* event handler for each command */
void rtgui_widget_set_onfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_onfocus(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onunfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_onunfocus(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
void rtgui_widget_set_ondraw(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_ondraw(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onmouseclick(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_onmouseclick(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onkey(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_onkey(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onsize(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_onsize(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
void rtgui_widget_set_oncommand(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_oncommand(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
#endif #endif
/* get and set rect of widget */ /* get and set rect of widget */
void rtgui_widget_get_rect(rtgui_widget_t* widget, rtgui_rect_t *rect); void rtgui_widget_get_rect(rtgui_widget_t *widget, rtgui_rect_t *rect);
void rtgui_widget_set_border(rtgui_widget_t* widget, rt_uint32_t style); void rtgui_widget_set_border(rtgui_widget_t *widget, rt_uint32_t style);
void rtgui_widget_set_rect(rtgui_widget_t* widget, const rtgui_rect_t* rect); void rtgui_widget_set_rect(rtgui_widget_t *widget, const rtgui_rect_t *rect);
void rtgui_widget_set_rectangle(rtgui_widget_t* widget, int x, int y, int width, int height); void rtgui_widget_set_rectangle(rtgui_widget_t *widget, int x, int y, int width, int height);
void rtgui_widget_get_extent(rtgui_widget_t* widget, rtgui_rect_t *rect); void rtgui_widget_get_extent(rtgui_widget_t *widget, rtgui_rect_t *rect);
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
void rtgui_widget_set_miniwidth(rtgui_widget_t* widget, int width); void rtgui_widget_set_miniwidth(rtgui_widget_t *widget, int width);
void rtgui_widget_set_miniheight(rtgui_widget_t* widget, int height); void rtgui_widget_set_miniheight(rtgui_widget_t *widget, int height);
#endif #endif
void rtgui_widget_set_parent(rtgui_widget_t* widget, rtgui_widget_t* parent); void rtgui_widget_set_parent(rtgui_widget_t *widget, rtgui_widget_t *parent);
/* get the physical position of a logic point on widget */ /* get the physical position of a logic point on widget */
void rtgui_widget_point_to_device(rtgui_widget_t * widget, rtgui_point_t * point); void rtgui_widget_point_to_device(rtgui_widget_t *widget, rtgui_point_t *point);
/* get the physical position of a logic rect on widget */ /* get the physical position of a logic rect on widget */
void rtgui_widget_rect_to_device(rtgui_widget_t * widget, rtgui_rect_t * rect); void rtgui_widget_rect_to_device(rtgui_widget_t *widget, rtgui_rect_t *rect);
/* get the logic position of a physical point on widget */ /* get the logic position of a physical point on widget */
void rtgui_widget_point_to_logic(rtgui_widget_t* widget, rtgui_point_t * point); void rtgui_widget_point_to_logic(rtgui_widget_t *widget, rtgui_point_t *point);
/* get the logic position of a physical rect on widget */ /* get the logic position of a physical rect on widget */
void rtgui_widget_rect_to_logic(rtgui_widget_t* widget, rtgui_rect_t* rect); void rtgui_widget_rect_to_logic(rtgui_widget_t *widget, rtgui_rect_t *rect);
/* move widget and its children to a logic point */ /* move widget and its children to a logic point */
void rtgui_widget_move_to_logic(rtgui_widget_t* widget, int dx, int dy); void rtgui_widget_move_to_logic(rtgui_widget_t *widget, int dx, int dy);
/* update the clip info of widget */ /* update the clip info of widget */
void rtgui_widget_update_clip(rtgui_widget_t* widget); void rtgui_widget_update_clip(rtgui_widget_t *widget);
/* get the toplevel widget of widget */ /* get the toplevel widget of widget */
struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget); struct rtgui_win *rtgui_widget_get_toplevel(rtgui_widget_t *widget);
rt_bool_t rtgui_widget_onupdate_toplvl(struct rtgui_object *object, struct rtgui_event *event); rt_bool_t rtgui_widget_onupdate_toplvl(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_show(rtgui_widget_t* widget); void rtgui_widget_show(rtgui_widget_t *widget);
rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event); rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_hide(rtgui_widget_t* widget); void rtgui_widget_hide(rtgui_widget_t *widget);
rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event); rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_update(rtgui_widget_t* widget); void rtgui_widget_update(rtgui_widget_t *widget);
/* get parent color */ /* get parent color */
rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t* widget); rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t *widget);
rtgui_color_t rtgui_widget_get_parent_background(rtgui_widget_t* widget); rtgui_color_t rtgui_widget_get_parent_background(rtgui_widget_t *widget);
/* get the next sibling of widget */ /* get the next sibling of widget */
rtgui_widget_t* rtgui_widget_get_next_sibling(rtgui_widget_t* widget); rtgui_widget_t *rtgui_widget_get_next_sibling(rtgui_widget_t *widget);
/* get the prev sibling of widget */ /* get the prev sibling of widget */
rtgui_widget_t* rtgui_widget_get_prev_sibling(rtgui_widget_t* widget); rtgui_widget_t *rtgui_widget_get_prev_sibling(rtgui_widget_t *widget);
/* dump widget information */ /* dump widget information */
void rtgui_widget_dump(rtgui_widget_t* widget); void rtgui_widget_dump(rtgui_widget_t *widget);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -28,37 +28,37 @@ DECLARE_CLASS_TYPE(win);
/** Checks if the object is an rtgui_win */ /** Checks if the object is an rtgui_win */
#define RTGUI_IS_WIN(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIN_TYPE)) #define RTGUI_IS_WIN(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIN_TYPE))
#define RTGUI_WIN_STYLE_NO_FOCUS 0x0001 /* non-focused window */ #define RTGUI_WIN_STYLE_NO_FOCUS 0x0001 /* non-focused window */
#define RTGUI_WIN_STYLE_NO_TITLE 0x0002 /* no title window */ #define RTGUI_WIN_STYLE_NO_TITLE 0x0002 /* no title window */
#define RTGUI_WIN_STYLE_NO_BORDER 0x0004 /* no border window */ #define RTGUI_WIN_STYLE_NO_BORDER 0x0004 /* no border window */
#define RTGUI_WIN_STYLE_CLOSEBOX 0x0008 /* window has the close button */ #define RTGUI_WIN_STYLE_CLOSEBOX 0x0008 /* window has the close button */
#define RTGUI_WIN_STYLE_MINIBOX 0x0010 /* window has the mini button */ #define RTGUI_WIN_STYLE_MINIBOX 0x0010 /* window has the mini button */
#define RTGUI_WIN_STYLE_DESTROY_ON_CLOSE 0x0020 /* window is destroyed when closed */ #define RTGUI_WIN_STYLE_DESTROY_ON_CLOSE 0x0020 /* window is destroyed when closed */
#define RTGUI_WIN_STYLE_ONTOP 0x0040 /* window is in the top layer */ #define RTGUI_WIN_STYLE_ONTOP 0x0040 /* window is in the top layer */
#define RTGUI_WIN_STYLE_ONBTM 0x0080 /* window is in the bottom layer */ #define RTGUI_WIN_STYLE_ONBTM 0x0080 /* window is in the bottom layer */
#define RTGUI_WIN_STYLE_MAINWIN 0x0106 /* window is a main window */ #define RTGUI_WIN_STYLE_MAINWIN 0x0106 /* window is a main window */
#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX) #define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
enum rtgui_win_flag enum rtgui_win_flag
{ {
RTGUI_WIN_FLAG_INIT = 0x00, /* init state */ RTGUI_WIN_FLAG_INIT = 0x00, /* init state */
RTGUI_WIN_FLAG_MODAL = 0x01, /* modal mode window */ RTGUI_WIN_FLAG_MODAL = 0x01, /* modal mode window */
RTGUI_WIN_FLAG_CLOSED = 0x02, /* window is closed */ RTGUI_WIN_FLAG_CLOSED = 0x02, /* window is closed */
RTGUI_WIN_FLAG_ACTIVATE = 0x04, /* window is activated */ RTGUI_WIN_FLAG_ACTIVATE = 0x04, /* window is activated */
RTGUI_WIN_FLAG_UNDER_MODAL = 0x08, /* window is under modal RTGUI_WIN_FLAG_UNDER_MODAL = 0x08, /* window is under modal
show(modaled by other) */ show(modaled by other) */
RTGUI_WIN_FLAG_CONNECTED = 0x10, /* connected to server */ RTGUI_WIN_FLAG_CONNECTED = 0x10, /* connected to server */
/* window is event_key dispatcher(dispatch it to the focused widget in /* window is event_key dispatcher(dispatch it to the focused widget in
* current window) _and_ a key handler(it should be able to handle keys * current window) _and_ a key handler(it should be able to handle keys
* such as ESC). Both of dispatching and handling are in the same * such as ESC). Both of dispatching and handling are in the same
* function(rtgui_win_event_handler). So we have to distinguish between the * function(rtgui_win_event_handler). So we have to distinguish between the
* two modes. * two modes.
* *
* If this flag is set, we are in key-handling mode. * If this flag is set, we are in key-handling mode.
*/ */
RTGUI_WIN_FLAG_HANDLE_KEY = 0x20 RTGUI_WIN_FLAG_HANDLE_KEY = 0x20
}; };
struct rtgui_win_title; struct rtgui_win_title;
@ -66,54 +66,57 @@ struct rtgui_win_area;
struct rtgui_win struct rtgui_win
{ {
/* inherit from container */ /* inherit from container */
rtgui_container_t parent; rtgui_container_t parent;
/* drawing count */ /* drawing count */
rt_base_t drawing; rt_base_t drawing;
/* parent window. RT_NULL if the window is a top level window */ /* parent window. RT_NULL if the window is a top level window */
struct rtgui_win *parent_window; struct rtgui_win *parent_window;
/* the widget that will grab the focus in current window */ /* the widget that will grab the focus in current window */
struct rtgui_widget *focused_widget; struct rtgui_widget *focused_widget;
/* window style */ /* which app I belong */
rt_uint16_t style; struct rtgui_app *app;
/* window state flag */ /* window style */
enum rtgui_win_flag flag; rt_uint16_t style;
rtgui_modal_code_t modal_code; /* window state flag */
enum rtgui_win_flag flag;
/* last mouse event handled widget */ rtgui_modal_code_t modal_code;
rtgui_widget_t* last_mevent_widget;
/* window title */ /* last mouse event handled widget */
char* title; rtgui_widget_t *last_mevent_widget;
/* call back */ /* window title */
rt_bool_t (*on_activate) (struct rtgui_object* widget, struct rtgui_event* event); char *title;
rt_bool_t (*on_deactivate) (struct rtgui_object* widget, struct rtgui_event* event);
rt_bool_t (*on_close) (struct rtgui_object* widget, struct rtgui_event* event);
/* the key is sent to the focused widget by default. If the focused widget
* and all of it's parents didn't handle the key event, it will be handled
* by @func on_key
*
* If you want to handle key event on your own, it's better to overload
* this function other than handle EVENT_KBD in event_handler.
*/
rt_bool_t (*on_key) (struct rtgui_object* widget, struct rtgui_event* event);
/* reserved user data */ /* call back */
rt_uint32_t user_data; rt_bool_t (*on_activate)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_deactivate)(struct rtgui_object *widget, struct rtgui_event *event);
rt_bool_t (*on_close)(struct rtgui_object *widget, struct rtgui_event *event);
/* the key is sent to the focused widget by default. If the focused widget
* and all of it's parents didn't handle the key event, it will be handled
* by @func on_key
*
* If you want to handle key event on your own, it's better to overload
* this function other than handle EVENT_KBD in event_handler.
*/
rt_bool_t (*on_key)(struct rtgui_object *widget, struct rtgui_event *event);
/* reserved user data */
rt_uint32_t user_data;
}; };
rtgui_win_t* rtgui_win_create(struct rtgui_win *parent_window, const char* title, rtgui_win_t *rtgui_win_create(struct rtgui_win *parent_window, const char *title,
rtgui_rect_t *rect, rt_uint16_t style); rtgui_rect_t *rect, rt_uint16_t style);
rtgui_win_t* rtgui_mainwin_create(struct rtgui_win *parent_window, const char* title, rt_uint16_t style); rtgui_win_t *rtgui_mainwin_create(struct rtgui_win *parent_window, const char *title, rt_uint16_t style);
void rtgui_win_destroy(rtgui_win_t* win); void rtgui_win_destroy(rtgui_win_t *win);
/** Close window. /** Close window.
* *
@ -124,30 +127,30 @@ void rtgui_win_destroy(rtgui_win_t* win);
* *
* \sa rtgui_win_set_onclose . * \sa rtgui_win_set_onclose .
*/ */
rt_bool_t rtgui_win_close(struct rtgui_win* win); rt_bool_t rtgui_win_close(struct rtgui_win *win);
rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal); rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal);
void rtgui_win_hiden(rtgui_win_t* win); void rtgui_win_hiden(rtgui_win_t *win);
void rtgui_win_end_modal(rtgui_win_t* win, rtgui_modal_code_t modal_code); void rtgui_win_end_modal(rtgui_win_t *win, rtgui_modal_code_t modal_code);
rt_err_t rtgui_win_activate(struct rtgui_win *win); rt_err_t rtgui_win_activate(struct rtgui_win *win);
rt_bool_t rtgui_win_is_activated(struct rtgui_win* win); rt_bool_t rtgui_win_is_activated(struct rtgui_win *win);
void rtgui_win_move(struct rtgui_win* win, int x, int y); void rtgui_win_move(struct rtgui_win *win, int x, int y);
/* reset extent of window */ /* reset extent of window */
void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect); void rtgui_win_set_rect(rtgui_win_t *win, rtgui_rect_t *rect);
void rtgui_win_update_clip(struct rtgui_win* win); void rtgui_win_update_clip(struct rtgui_win *win);
void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler); void rtgui_win_set_onactivate(rtgui_win_t *win, rtgui_event_handler_ptr handler);
void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler); void rtgui_win_set_ondeactivate(rtgui_win_t *win, rtgui_event_handler_ptr handler);
void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler); void rtgui_win_set_onclose(rtgui_win_t *win, rtgui_event_handler_ptr handler);
void rtgui_win_set_onkey(rtgui_win_t* win, rtgui_event_handler_ptr handler); void rtgui_win_set_onkey(rtgui_win_t *win, rtgui_event_handler_ptr handler);
rt_bool_t rtgui_win_event_handler(struct rtgui_object* win, struct rtgui_event* event); rt_bool_t rtgui_win_event_handler(struct rtgui_object *win, struct rtgui_event *event);
void rtgui_win_event_loop(rtgui_win_t* wnd); void rtgui_win_event_loop(rtgui_win_t *wnd);
void rtgui_win_set_title(rtgui_win_t* win, const char *title); void rtgui_win_set_title(rtgui_win_t *win, const char *title);
char* rtgui_win_get_title(rtgui_win_t* win); char *rtgui_win_get_title(rtgui_win_t *win);
#endif #endif

View File

@ -20,82 +20,83 @@ extern const struct rtgui_graphic_driver_ops *rtgui_pixel_device_get_ops(int pix
extern const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format); extern const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format);
/* get default driver */ /* get default driver */
struct rtgui_graphic_driver* rtgui_graphic_driver_get_default() struct rtgui_graphic_driver *rtgui_graphic_driver_get_default()
{ {
return &_driver; return &_driver;
} }
RTM_EXPORT(rtgui_graphic_driver_get_default); RTM_EXPORT(rtgui_graphic_driver_get_default);
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect) void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect)
{ {
RT_ASSERT(rect != RT_NULL); RT_ASSERT(rect != RT_NULL);
RT_ASSERT(driver != RT_NULL); RT_ASSERT(driver != RT_NULL);
rect->x1 = rect->y1 = 0; rect->x1 = rect->y1 = 0;
rect->x2 = driver->width; rect->x2 = driver->width;
rect->y2 = driver->height; rect->y2 = driver->height;
} }
RTM_EXPORT(rtgui_graphic_driver_get_rect); RTM_EXPORT(rtgui_graphic_driver_get_rect);
rt_err_t rtgui_graphic_set_device(rt_device_t device) rt_err_t rtgui_graphic_set_device(rt_device_t device)
{ {
rt_err_t result; rt_err_t result;
struct rt_device_graphic_info info; struct rt_device_graphic_info info;
/* get framebuffer address */ /* get framebuffer address */
result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info); result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
if (result != RT_EOK) if (result != RT_EOK)
{ {
/* get device information failed */ /* get device information failed */
return -RT_ERROR; return -RT_ERROR;
} }
/* initialize framebuffer driver */ /* initialize framebuffer driver */
_driver.device = device; _driver.device = device;
_driver.pixel_format = info.pixel_format; _driver.pixel_format = info.pixel_format;
_driver.bits_per_pixel = info.bits_per_pixel; _driver.bits_per_pixel = info.bits_per_pixel;
_driver.width = info.width; _driver.width = info.width;
_driver.height = info.height; _driver.height = info.height;
_driver.pitch = _driver.width * _driver.bits_per_pixel/8; _driver.pitch = _driver.width * _driver.bits_per_pixel / 8;
_driver.framebuffer = info.framebuffer; _driver.framebuffer = info.framebuffer;
if (info.framebuffer != RT_NULL) if (info.framebuffer != RT_NULL)
{ {
/* is a frame buffer device */ /* is a frame buffer device */
_driver.ops = rtgui_framebuffer_get_ops(_driver.pixel_format); _driver.ops = rtgui_framebuffer_get_ops(_driver.pixel_format);
} }
else else
{ {
/* is a pixel device */ /* is a pixel device */
_driver.ops = rtgui_pixel_device_get_ops(_driver.pixel_format); _driver.ops = rtgui_pixel_device_get_ops(_driver.pixel_format);
} }
return RT_EOK; return RT_EOK;
} }
RTM_EXPORT(rtgui_graphic_set_device); RTM_EXPORT(rtgui_graphic_set_device);
/* screen update */ /* screen update */
void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect) void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect)
{ {
struct rt_device_rect_info rect_info; struct rt_device_rect_info rect_info;
rect_info.x = rect->x1; rect_info.y = rect->y1; rect_info.x = rect->x1;
rect_info.width = rect->x2 - rect->x1; rect_info.y = rect->y1;
rect_info.height = rect->y2 - rect->y1; rect_info.width = rect->x2 - rect->x1;
rt_device_control(driver->device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info); rect_info.height = rect->y2 - rect->y1;
rt_device_control(driver->device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
} }
RTM_EXPORT(rtgui_graphic_driver_screen_update); RTM_EXPORT(rtgui_graphic_driver_screen_update);
/* get video frame buffer */ /* get video frame buffer */
rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver) rt_uint8_t *rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver *driver)
{ {
return (rt_uint8_t*)driver->framebuffer; return (rt_uint8_t *)driver->framebuffer;
} }
RTM_EXPORT(rtgui_graphic_driver_get_framebuffer); RTM_EXPORT(rtgui_graphic_driver_get_framebuffer);
rt_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void) rt_uint8_t *rtgui_graphic_driver_get_default_framebuffer(void)
{ {
return rtgui_graphic_driver_get_framebuffer(&_driver); return rtgui_graphic_driver_get_framebuffer(&_driver);
} }
RTM_EXPORT(rtgui_graphic_driver_get_default_framebuffer); RTM_EXPORT(rtgui_graphic_driver_get_default_framebuffer);

File diff suppressed because it is too large Load Diff

View File

@ -20,11 +20,11 @@
struct rtgui_mouse_monitor struct rtgui_mouse_monitor
{ {
/* event rect */ /* event rect */
rtgui_rect_t rect; rtgui_rect_t rect;
/* node list */ /* node list */
rtgui_list_t list; rtgui_list_t list;
}; };
typedef struct rtgui_mouse_monitor rtgui_mouse_monitor_t; typedef struct rtgui_mouse_monitor rtgui_mouse_monitor_t;
@ -33,22 +33,22 @@ void rtgui_mouse_fini(void);
void rtgui_mouse_moveto(int x, int y); void rtgui_mouse_moveto(int x, int y);
void rtgui_mouse_set_cursor_enable(rt_bool_t enable); void rtgui_mouse_set_cursor_enable(rt_bool_t enable);
void rtgui_mouse_set_cursor(rtgui_image_t* cursor); void rtgui_mouse_set_cursor(rtgui_image_t *cursor);
void rtgui_mouse_get_cursor_rect(rtgui_rect_t* rect); void rtgui_mouse_get_cursor_rect(rtgui_rect_t *rect);
void rtgui_mouse_show_cursor(void); void rtgui_mouse_show_cursor(void);
void rtgui_mouse_hide_cursor(void); void rtgui_mouse_hide_cursor(void);
rt_bool_t rtgui_mouse_is_intersect(rtgui_rect_t* r); rt_bool_t rtgui_mouse_is_intersect(rtgui_rect_t *r);
#ifdef RTGUI_USING_WINMOVE #ifdef RTGUI_USING_WINMOVE
rt_bool_t rtgui_winrect_is_moved(void); rt_bool_t rtgui_winrect_is_moved(void);
void rtgui_winrect_set(struct rtgui_topwin* topwin); void rtgui_winrect_set(struct rtgui_topwin *topwin);
rt_bool_t rtgui_winrect_moved_done(rtgui_rect_t* winrect, struct rtgui_topwin** topwin); rt_bool_t rtgui_winrect_moved_done(rtgui_rect_t *winrect, struct rtgui_topwin **topwin);
#endif #endif
void rtgui_mouse_monitor_append(rtgui_list_t* head, rtgui_rect_t* rect); void rtgui_mouse_monitor_append(rtgui_list_t *head, rtgui_rect_t *rect);
void rtgui_mouse_monitor_remove(rtgui_list_t* head, rtgui_rect_t* rect); void rtgui_mouse_monitor_remove(rtgui_list_t *head, rtgui_rect_t *rect);
rt_bool_t rtgui_mouse_monitor_contains_point(rtgui_list_t* head, int x, int y); rt_bool_t rtgui_mouse_monitor_contains_point(rtgui_list_t *head, int x, int y);
#endif #endif

View File

@ -27,174 +27,174 @@ static struct rt_thread *rtgui_server_tid;
static struct rtgui_app *rtgui_server_application = RT_NULL; static struct rtgui_app *rtgui_server_application = RT_NULL;
static struct rtgui_app *rtgui_wm_application = RT_NULL; static struct rtgui_app *rtgui_wm_application = RT_NULL;
void rtgui_server_handle_update(struct rtgui_event_update_end* event) void rtgui_server_handle_update(struct rtgui_event_update_end *event)
{ {
struct rtgui_graphic_driver* driver; struct rtgui_graphic_driver *driver;
driver = rtgui_graphic_driver_get_default(); driver = rtgui_graphic_driver_get_default();
if (driver != RT_NULL) if (driver != RT_NULL)
{ {
rtgui_graphic_driver_screen_update(driver, &(event->rect)); rtgui_graphic_driver_screen_update(driver, &(event->rect));
} }
} }
void rtgui_server_handle_monitor_add(struct rtgui_event_monitor* event) void rtgui_server_handle_monitor_add(struct rtgui_event_monitor *event)
{ {
/* add monitor rect to top window list */ /* add monitor rect to top window list */
rtgui_topwin_append_monitor_rect(event->wid, &(event->rect)); rtgui_topwin_append_monitor_rect(event->wid, &(event->rect));
} }
void rtgui_server_handle_monitor_remove(struct rtgui_event_monitor* event) void rtgui_server_handle_monitor_remove(struct rtgui_event_monitor *event)
{ {
/* add monitor rect to top window list */ /* add monitor rect to top window list */
rtgui_topwin_remove_monitor_rect(event->wid, &(event->rect)); rtgui_topwin_remove_monitor_rect(event->wid, &(event->rect));
} }
void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse* event) void rtgui_server_handle_mouse_btn(struct rtgui_event_mouse *event)
{ {
struct rtgui_topwin* wnd; struct rtgui_topwin *wnd;
/* re-init to server thread */ /* re-init to server thread */
RTGUI_EVENT_MOUSE_BUTTON_INIT(event); RTGUI_EVENT_MOUSE_BUTTON_INIT(event);
#ifdef RTGUI_USING_WINMOVE #ifdef RTGUI_USING_WINMOVE
if (rtgui_winrect_is_moved() && if (rtgui_winrect_is_moved() &&
event->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP)) event->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP))
{ {
struct rtgui_topwin* topwin; struct rtgui_topwin *topwin;
rtgui_rect_t rect; rtgui_rect_t rect;
if (rtgui_winrect_moved_done(&rect, &topwin) == RT_TRUE) if (rtgui_winrect_moved_done(&rect, &topwin) == RT_TRUE)
{ {
struct rtgui_event_win_move ewin; struct rtgui_event_win_move ewin;
/* move window */ /* move window */
RTGUI_EVENT_WIN_MOVE_INIT(&ewin); RTGUI_EVENT_WIN_MOVE_INIT(&ewin);
ewin.wid = topwin->wid; ewin.wid = topwin->wid;
if (topwin->title != RT_NULL) if (topwin->title != RT_NULL)
{ {
if (topwin->flag & WINTITLE_BORDER) if (topwin->flag & WINTITLE_BORDER)
{ {
ewin.x = rect.x1 + WINTITLE_BORDER_SIZE; ewin.x = rect.x1 + WINTITLE_BORDER_SIZE;
ewin.y = rect.y1 + WINTITLE_BORDER_SIZE; ewin.y = rect.y1 + WINTITLE_BORDER_SIZE;
} }
if (!(topwin->flag & WINTITLE_NO)) ewin.y += WINTITLE_HEIGHT; if (!(topwin->flag & WINTITLE_NO)) ewin.y += WINTITLE_HEIGHT;
} }
else else
{ {
ewin.x = rect.x1; ewin.x = rect.x1;
ewin.y = rect.y1; ewin.y = rect.y1;
} }
/* send to client thread */ /* send to client thread */
rtgui_send(topwin->tid, &(ewin.parent), sizeof(ewin)); rtgui_send(topwin->tid, &(ewin.parent), sizeof(ewin));
return; return;
} }
} }
#endif #endif
/* get the wnd which contains the mouse */ /* get the wnd which contains the mouse */
wnd = rtgui_topwin_get_wnd_no_modaled(event->x, event->y); wnd = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
if (wnd != RT_NULL) if (wnd != RT_NULL)
{ {
event->wid = wnd->wid; event->wid = wnd->wid;
if (rtgui_topwin_get_focus() != wnd) if (rtgui_topwin_get_focus() != wnd)
{ {
/* raise this window */ /* raise this window */
rtgui_topwin_activate_topwin(wnd); rtgui_topwin_activate_topwin(wnd);
} }
if (wnd->title != RT_NULL && if (wnd->title != RT_NULL &&
rtgui_rect_contains_point(&(RTGUI_WIDGET(wnd->title)->extent), event->x, event->y) == RT_EOK) rtgui_rect_contains_point(&(RTGUI_WIDGET(wnd->title)->extent), event->x, event->y) == RT_EOK)
{ {
rtgui_topwin_title_onmouse(wnd, event); rtgui_topwin_title_onmouse(wnd, event);
} }
else else
{ {
/* send mouse event to thread */ /* send mouse event to thread */
rtgui_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_mouse)); rtgui_send(wnd->tid, (struct rtgui_event *)event, sizeof(struct rtgui_event_mouse));
} }
return ; return ;
} }
} }
static struct rtgui_topwin* last_monitor_topwin = RT_NULL; static struct rtgui_topwin *last_monitor_topwin = RT_NULL;
void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse* event) void rtgui_server_handle_mouse_motion(struct rtgui_event_mouse *event)
{ {
/* the topwin contains current mouse */ /* the topwin contains current mouse */
struct rtgui_topwin* win = RT_NULL; struct rtgui_topwin *win = RT_NULL;
/* re-init mouse event */ /* re-init mouse event */
RTGUI_EVENT_MOUSE_MOTION_INIT(event); RTGUI_EVENT_MOUSE_MOTION_INIT(event);
win = rtgui_topwin_get_wnd_no_modaled(event->x, event->y); win = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
if (win != RT_NULL && win->monitor_list.next != RT_NULL) if (win != RT_NULL && win->monitor_list.next != RT_NULL)
{ {
// FIXME: // FIXME:
/* check whether the monitor exist */ /* check whether the monitor exist */
if (rtgui_mouse_monitor_contains_point(&(win->monitor_list), if (rtgui_mouse_monitor_contains_point(&(win->monitor_list),
event->x, event->y) != RT_TRUE) event->x, event->y) != RT_TRUE)
{ {
win = RT_NULL; win = RT_NULL;
} }
} }
if (last_monitor_topwin != RT_NULL) if (last_monitor_topwin != RT_NULL)
{ {
event->wid = last_monitor_topwin->wid; event->wid = last_monitor_topwin->wid;
/* send mouse motion event */ /* send mouse motion event */
rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse)); rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
} }
if (last_monitor_topwin != win) if (last_monitor_topwin != win)
{ {
last_monitor_topwin = win; last_monitor_topwin = win;
if (last_monitor_topwin != RT_NULL) if (last_monitor_topwin != RT_NULL)
{ {
event->wid = last_monitor_topwin->wid; event->wid = last_monitor_topwin->wid;
/* send mouse motion event */ /* send mouse motion event */
rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse)); rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
} }
} }
/* move mouse to (x, y) */ /* move mouse to (x, y) */
rtgui_mouse_moveto(event->x, event->y); rtgui_mouse_moveto(event->x, event->y);
} }
void rtgui_server_handle_kbd(struct rtgui_event_kbd* event) void rtgui_server_handle_kbd(struct rtgui_event_kbd *event)
{ {
struct rtgui_topwin* wnd; struct rtgui_topwin *wnd;
/* re-init to server thread */ /* re-init to server thread */
RTGUI_EVENT_KBD_INIT(event); RTGUI_EVENT_KBD_INIT(event);
/* todo: handle input method and global shortcut */ /* todo: handle input method and global shortcut */
wnd = rtgui_topwin_get_focus(); wnd = rtgui_topwin_get_focus();
if (wnd != RT_NULL) if (wnd != RT_NULL)
{ {
RT_ASSERT(wnd->flag & WINTITLE_ACTIVATE) RT_ASSERT(wnd->flag & WINTITLE_ACTIVATE)
/* send to focus window */ /* send to focus window */
event->wid = wnd->wid; event->wid = wnd->wid;
/* send keyboard event to thread */ /* send keyboard event to thread */
rtgui_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_kbd)); rtgui_send(wnd->tid, (struct rtgui_event *)event, sizeof(struct rtgui_event_kbd));
return; return;
} }
} }
#ifdef _WIN32 #ifdef _WIN32_NATIVE
#include <windows.h> #include <windows.h>
#endif #endif
static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object, static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
struct rtgui_event *event) struct rtgui_event *event)
{ {
RT_ASSERT(object != RT_NULL); RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL); RT_ASSERT(event != RT_NULL);
@ -203,107 +203,107 @@ static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
switch (event->type) switch (event->type)
{ {
case RTGUI_EVENT_APP_CREATE: case RTGUI_EVENT_APP_CREATE:
case RTGUI_EVENT_APP_DESTROY: case RTGUI_EVENT_APP_DESTROY:
if (rtgui_wm_application != RT_NULL) if (rtgui_wm_application != RT_NULL)
{ {
/* forward event to wm application */ /* forward event to wm application */
rtgui_send(rtgui_wm_application->tid, event, sizeof(struct rtgui_event_application)); rtgui_send(rtgui_wm_application->tid, event, sizeof(struct rtgui_event_application));
} }
else else
{ {
/* always ack with OK */ /* always ack with OK */
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
} }
break; break;
/* mouse and keyboard event */ /* mouse and keyboard event */
case RTGUI_EVENT_MOUSE_MOTION: case RTGUI_EVENT_MOUSE_MOTION:
/* handle mouse motion event */ /* handle mouse motion event */
rtgui_server_handle_mouse_motion((struct rtgui_event_mouse*)event); rtgui_server_handle_mouse_motion((struct rtgui_event_mouse *)event);
break; break;
case RTGUI_EVENT_MOUSE_BUTTON: case RTGUI_EVENT_MOUSE_BUTTON:
/* handle mouse button */ /* handle mouse button */
rtgui_server_handle_mouse_btn((struct rtgui_event_mouse*)event); rtgui_server_handle_mouse_btn((struct rtgui_event_mouse *)event);
break; break;
case RTGUI_EVENT_KBD: case RTGUI_EVENT_KBD:
/* handle keyboard event */ /* handle keyboard event */
rtgui_server_handle_kbd((struct rtgui_event_kbd*)event); rtgui_server_handle_kbd((struct rtgui_event_kbd *)event);
break; break;
/* window event */ /* window event */
case RTGUI_EVENT_WIN_CREATE: case RTGUI_EVENT_WIN_CREATE:
if (rtgui_topwin_add((struct rtgui_event_win_create*)event) == RT_EOK) if (rtgui_topwin_add((struct rtgui_event_win_create *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_SHOW: case RTGUI_EVENT_WIN_SHOW:
if (rtgui_topwin_show((struct rtgui_event_win*)event) == RT_EOK) if (rtgui_topwin_show((struct rtgui_event_win *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_HIDE: case RTGUI_EVENT_WIN_HIDE:
if (rtgui_topwin_hide((struct rtgui_event_win*)event) == RT_EOK) if (rtgui_topwin_hide((struct rtgui_event_win *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_MOVE: case RTGUI_EVENT_WIN_MOVE:
if (rtgui_topwin_move((struct rtgui_event_win_move*)event) == RT_EOK) if (rtgui_topwin_move((struct rtgui_event_win_move *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_MODAL_ENTER: case RTGUI_EVENT_WIN_MODAL_ENTER:
if (rtgui_topwin_modal_enter((struct rtgui_event_win_modal_enter*)event) == RT_EOK) if (rtgui_topwin_modal_enter((struct rtgui_event_win_modal_enter *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_ACTIVATE:
if (rtgui_topwin_activate((struct rtgui_event_win_activate*)event) == RT_EOK) if (rtgui_topwin_activate((struct rtgui_event_win_activate *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_DESTROY: case RTGUI_EVENT_WIN_DESTROY:
if (last_monitor_topwin != RT_NULL && if (last_monitor_topwin != RT_NULL &&
last_monitor_topwin->wid == ((struct rtgui_event_win*)event)->wid) last_monitor_topwin->wid == ((struct rtgui_event_win *)event)->wid)
last_monitor_topwin = RT_NULL; last_monitor_topwin = RT_NULL;
if (rtgui_topwin_remove(((struct rtgui_event_win*)event)->wid) == RT_EOK) if (rtgui_topwin_remove(((struct rtgui_event_win *)event)->wid) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
else else
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
break; break;
case RTGUI_EVENT_WIN_RESIZE: case RTGUI_EVENT_WIN_RESIZE:
rtgui_topwin_resize(((struct rtgui_event_win_resize*)event)->wid, rtgui_topwin_resize(((struct rtgui_event_win_resize *)event)->wid,
&(((struct rtgui_event_win_resize*)event)->rect)); &(((struct rtgui_event_win_resize *)event)->rect));
break; break;
case RTGUI_EVENT_SET_WM: case RTGUI_EVENT_SET_WM:
if (rtgui_wm_application != RT_NULL) if (rtgui_wm_application != RT_NULL)
{ {
rtgui_ack(event, RTGUI_STATUS_ERROR); rtgui_ack(event, RTGUI_STATUS_ERROR);
} }
else else
{ {
struct rtgui_event_set_wm *set_wm; struct rtgui_event_set_wm *set_wm;
set_wm = (struct rtgui_event_set_wm*) event; set_wm = (struct rtgui_event_set_wm *) event;
rtgui_wm_application = set_wm->app; rtgui_wm_application = set_wm->app;
rtgui_ack(event, RTGUI_STATUS_OK); rtgui_ack(event, RTGUI_STATUS_OK);
} }
break; break;
/* other event */ /* other event */
case RTGUI_EVENT_COMMAND: case RTGUI_EVENT_COMMAND:
@ -318,7 +318,7 @@ static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
case RTGUI_EVENT_UPDATE_END: case RTGUI_EVENT_UPDATE_END:
/* handle screen update */ /* handle screen update */
rtgui_server_handle_update((struct rtgui_event_update_end*)event); rtgui_server_handle_update((struct rtgui_event_update_end *)event);
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
/* show cursor */ /* show cursor */
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
@ -327,36 +327,39 @@ static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
case RTGUI_EVENT_MONITOR_ADD: case RTGUI_EVENT_MONITOR_ADD:
/* handle mouse monitor */ /* handle mouse monitor */
rtgui_server_handle_monitor_add((struct rtgui_event_monitor*)event); rtgui_server_handle_monitor_add((struct rtgui_event_monitor *)event);
break; break;
default:
rt_kprintf("RTGUI: wrong event sent to server: %d", event->type);
return RT_FALSE;
} }
return RT_TRUE; return RT_TRUE;
} }
/** /**
* rtgui server thread's entry * rtgui server thread's entry
*/ */
static void rtgui_server_entry(void* parameter) static void rtgui_server_entry(void *parameter)
{ {
#ifdef _WIN32 #ifdef _WIN32_NATIVE
/* set the server thread to highest */ /* set the server thread to highest */
HANDLE hCurrentThread = GetCurrentThread(); HANDLE hCurrentThread = GetCurrentThread();
SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST); SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST);
#endif #endif
/* create rtgui server application */ /* create rtgui server application */
rtgui_server_application = rtgui_app_create(rtgui_server_tid, rtgui_server_application = rtgui_app_create(rtgui_server_tid,
"rtgui"); "rtgui");
if (rtgui_server_application == RT_NULL) if (rtgui_server_application == RT_NULL)
return; return;
rtgui_object_set_event_handler(RTGUI_OBJECT(rtgui_server_application), rtgui_object_set_event_handler(RTGUI_OBJECT(rtgui_server_application),
rtgui_server_event_handler); rtgui_server_event_handler);
/* init mouse and show */ /* init mouse and show */
rtgui_mouse_init(); rtgui_mouse_init();
#ifdef RTGUI_USING_MOUSE_CURSOR #ifdef RTGUI_USING_MOUSE_CURSOR
rtgui_mouse_show_cursor(); rtgui_mouse_show_cursor();
#endif #endif
rtgui_app_run(rtgui_server_application); rtgui_app_run(rtgui_server_application);
@ -365,23 +368,23 @@ static void rtgui_server_entry(void* parameter)
rtgui_server_application = RT_NULL; rtgui_server_application = RT_NULL;
} }
void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size) void rtgui_server_post_event(struct rtgui_event *event, rt_size_t size)
{ {
if (rtgui_server_tid != RT_NULL) if (rtgui_server_tid != RT_NULL)
rtgui_send(rtgui_server_tid, event, size); rtgui_send(rtgui_server_tid, event, size);
else else
rt_kprintf("post when server is not running\n"); rt_kprintf("post when server is not running\n");
} }
rt_err_t rtgui_server_post_event_sync(struct rtgui_event* event, rt_size_t size) rt_err_t rtgui_server_post_event_sync(struct rtgui_event *event, rt_size_t size)
{ {
if (rtgui_server_tid != RT_NULL) if (rtgui_server_tid != RT_NULL)
return rtgui_send_sync(rtgui_server_tid, event, size); return rtgui_send_sync(rtgui_server_tid, event, size);
else else
{ {
rt_kprintf("post when server is not running\n"); rt_kprintf("post when server is not running\n");
return -RT_ENOSYS; return -RT_ENOSYS;
} }
} }
void rtgui_server_init(void) void rtgui_server_init(void)
@ -389,13 +392,13 @@ void rtgui_server_init(void)
if (rtgui_server_tid != RT_NULL) if (rtgui_server_tid != RT_NULL)
return; return;
rtgui_server_tid = rt_thread_create("rtgui", rtgui_server_tid = rt_thread_create("rtgui",
rtgui_server_entry, RT_NULL, rtgui_server_entry, RT_NULL,
RTGUI_SVR_THREAD_STACK_SIZE, RTGUI_SVR_THREAD_STACK_SIZE,
RTGUI_SVR_THREAD_PRIORITY, RTGUI_SVR_THREAD_PRIORITY,
RTGUI_SVR_THREAD_TIMESLICE); RTGUI_SVR_THREAD_TIMESLICE);
/* start rtgui server thread */ /* start rtgui server thread */
if (rtgui_server_tid != RT_NULL) if (rtgui_server_tid != RT_NULL)
rt_thread_startup(rtgui_server_tid); rt_thread_startup(rtgui_server_tid);
} }

File diff suppressed because it is too large Load Diff

View File

@ -21,37 +21,37 @@
#include <rtgui/rtgui_server.h> #include <rtgui/rtgui_server.h>
/* add or remove a top win */ /* add or remove a top win */
rt_err_t rtgui_topwin_add(struct rtgui_event_win_create* event); rt_err_t rtgui_topwin_add(struct rtgui_event_win_create *event);
rt_err_t rtgui_topwin_remove(struct rtgui_win* wid); rt_err_t rtgui_topwin_remove(struct rtgui_win *wid);
rt_err_t rtgui_topwin_activate(struct rtgui_event_win_activate* event); rt_err_t rtgui_topwin_activate(struct rtgui_event_win_activate *event);
rt_err_t rtgui_topwin_activate_topwin(struct rtgui_topwin* win); rt_err_t rtgui_topwin_activate_topwin(struct rtgui_topwin *win);
/* show a window */ /* show a window */
rt_err_t rtgui_topwin_show(struct rtgui_event_win* event); rt_err_t rtgui_topwin_show(struct rtgui_event_win *event);
/* hide a window */ /* hide a window */
rt_err_t rtgui_topwin_hide(struct rtgui_event_win* event); rt_err_t rtgui_topwin_hide(struct rtgui_event_win *event);
/* move a window */ /* move a window */
rt_err_t rtgui_topwin_move(struct rtgui_event_win_move* event); rt_err_t rtgui_topwin_move(struct rtgui_event_win_move *event);
/* resize a window */ /* resize a window */
void rtgui_topwin_resize(struct rtgui_win* wid, rtgui_rect_t* r); void rtgui_topwin_resize(struct rtgui_win *wid, rtgui_rect_t *r);
/* a window is entering modal mode */ /* a window is entering modal mode */
rt_err_t rtgui_topwin_modal_enter(struct rtgui_event_win_modal_enter* event); rt_err_t rtgui_topwin_modal_enter(struct rtgui_event_win_modal_enter *event);
/* get window at (x, y) */ /* get window at (x, y) */
struct rtgui_topwin* rtgui_topwin_get_wnd(int x, int y); struct rtgui_topwin *rtgui_topwin_get_wnd(int x, int y);
struct rtgui_topwin* rtgui_topwin_get_wnd_no_modaled(int x, int y); struct rtgui_topwin *rtgui_topwin_get_wnd_no_modaled(int x, int y);
//void rtgui_topwin_deactivate_win(struct rtgui_topwin* win); //void rtgui_topwin_deactivate_win(struct rtgui_topwin* win);
/* window title */ /* window title */
void rtgui_topwin_title_ondraw(struct rtgui_topwin* win); void rtgui_topwin_title_ondraw(struct rtgui_topwin *win);
void rtgui_topwin_title_onmouse(struct rtgui_topwin* win, struct rtgui_event_mouse* event); void rtgui_topwin_title_onmouse(struct rtgui_topwin *win, struct rtgui_event_mouse *event);
/* monitor rect */ /* monitor rect */
void rtgui_topwin_append_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect); void rtgui_topwin_append_monitor_rect(struct rtgui_win *wid, rtgui_rect_t *rect);
void rtgui_topwin_remove_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect); void rtgui_topwin_remove_monitor_rect(struct rtgui_win *wid, rtgui_rect_t *rect);
/* get the topwin that is currently focused */ /* get the topwin that is currently focused */
struct rtgui_topwin* rtgui_topwin_get_focus(void); struct rtgui_topwin *rtgui_topwin_get_focus(void);
#endif #endif

View File

@ -16,273 +16,273 @@
static void _rtgui_box_constructor(rtgui_box_t *box) static void _rtgui_box_constructor(rtgui_box_t *box)
{ {
/* init widget and set event handler */ /* init widget and set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(box), RT_NULL); rtgui_object_set_event_handler(RTGUI_OBJECT(box), RT_NULL);
/* set proper of control */ /* set proper of control */
box->orient = RTGUI_HORIZONTAL; box->orient = RTGUI_HORIZONTAL;
box->border_size = RTGUI_BORDER_DEFAULT_WIDTH; box->border_size = RTGUI_BORDER_DEFAULT_WIDTH;
box->container = RT_NULL; box->container = RT_NULL;
} }
DEFINE_CLASS_TYPE(box, "box", DEFINE_CLASS_TYPE(box, "box",
RTGUI_OBJECT_TYPE, RTGUI_OBJECT_TYPE,
_rtgui_box_constructor, _rtgui_box_constructor,
RT_NULL, RT_NULL,
sizeof(struct rtgui_box)); sizeof(struct rtgui_box));
struct rtgui_box* rtgui_box_create(int orientation, int border_size) struct rtgui_box *rtgui_box_create(int orientation, int border_size)
{ {
struct rtgui_box* box; struct rtgui_box *box;
box = (struct rtgui_box*) rtgui_object_create (RTGUI_BOX_TYPE); box = (struct rtgui_box *) rtgui_object_create(RTGUI_BOX_TYPE);
if (box != RT_NULL) if (box != RT_NULL)
{ {
box->orient = orientation; box->orient = orientation;
box->border_size = border_size; box->border_size = border_size;
} }
return box; return box;
} }
RTM_EXPORT(rtgui_box_create); RTM_EXPORT(rtgui_box_create);
void rtgui_box_destroy(struct rtgui_box* box) void rtgui_box_destroy(struct rtgui_box *box)
{ {
rtgui_object_destroy(RTGUI_OBJECT(box)); rtgui_object_destroy(RTGUI_OBJECT(box));
} }
RTM_EXPORT(rtgui_box_destroy); RTM_EXPORT(rtgui_box_destroy);
static void rtgui_box_layout_vertical(struct rtgui_box* box, struct rtgui_rect* extent) static void rtgui_box_layout_vertical(struct rtgui_box *box, struct rtgui_rect *extent)
{ {
rtgui_list_t *node; rtgui_list_t *node;
rt_int32_t box_width; rt_int32_t box_width;
rt_int32_t space_count; rt_int32_t space_count;
rt_int32_t next_x, next_y; rt_int32_t next_x, next_y;
rt_int32_t total_height, space_height; rt_int32_t total_height, space_height;
struct rtgui_event_resize size_event; struct rtgui_event_resize size_event;
/* prepare the resize event */
RTGUI_EVENT_RESIZE_INIT(&size_event);
/* find spaces */ /* prepare the resize event */
space_count = 0; RTGUI_EVENT_RESIZE_INIT(&size_event);
total_height = 0;
space_height = 0;
rtgui_list_foreach(node, &(box->container->children)) /* find spaces */
{ space_count = 0;
rtgui_widget_t* widget = rtgui_list_entry(node, struct rtgui_widget, sibling); total_height = 0;
if (widget->align & RTGUI_ALIGN_STRETCH) space_count ++; space_height = 0;
else total_height += widget->mini_height;
}
/* calculate the height for each spaces */ rtgui_list_foreach(node, &(box->container->children))
if (space_count != 0) {
{ rtgui_widget_t *widget = rtgui_list_entry(node, struct rtgui_widget, sibling);
space_height = (rtgui_rect_height(*extent) - total_height - (box->border_size << 1)) / space_count; if (widget->align & RTGUI_ALIGN_STRETCH) space_count ++;
} else total_height += widget->mini_height;
}
/* init (x, y) and box width */ /* calculate the height for each spaces */
next_x = extent->x1 + box->border_size; if (space_count != 0)
next_y = extent->y1 + box->border_size; {
box_width = rtgui_rect_width(*extent) - (box->border_size << 1); space_height = (rtgui_rect_height(*extent) - total_height - (box->border_size << 1)) / space_count;
}
/* layout each widget */ /* init (x, y) and box width */
rtgui_list_foreach(node, &(box->container->children)) next_x = extent->x1 + box->border_size;
{ next_y = extent->y1 + box->border_size;
struct rtgui_rect *rect; box_width = rtgui_rect_width(*extent) - (box->border_size << 1);
rtgui_widget_t* widget = rtgui_list_entry(node, struct rtgui_widget, sibling);
/* get extent of widget */ /* layout each widget */
rect = &(widget->extent); rtgui_list_foreach(node, &(box->container->children))
{
struct rtgui_rect *rect;
rtgui_widget_t *widget = rtgui_list_entry(node, struct rtgui_widget, sibling);
/* reset rect */ /* get extent of widget */
rtgui_rect_moveto(rect, -rect->x1, -rect->y1); rect = &(widget->extent);
rect->x2 = widget->mini_width;
rect->y2 = widget->mini_height;
/* left in default */ /* reset rect */
rtgui_rect_moveto(rect, next_x, next_y); rtgui_rect_moveto(rect, -rect->x1, -rect->y1);
rect->x2 = widget->mini_width;
rect->y2 = widget->mini_height;
if (widget->align & RTGUI_ALIGN_EXPAND) /* left in default */
{ rtgui_rect_moveto(rect, next_x, next_y);
/* expand on horizontal */
rect->x2 = rect->x1 + (rt_int16_t)box_width;
}
if (widget->align & RTGUI_ALIGN_CENTER_VERTICAL)
{
/* center */
rt_uint32_t mid;
mid = box_width - rtgui_rect_width(*rect); if (widget->align & RTGUI_ALIGN_EXPAND)
mid = mid /2; {
/* expand on horizontal */
rect->x2 = rect->x1 + (rt_int16_t)box_width;
}
if (widget->align & RTGUI_ALIGN_CENTER_VERTICAL)
{
/* center */
rt_uint32_t mid;
rect->x1 = next_x + mid; mid = box_width - rtgui_rect_width(*rect);
rect->x2 = next_x + box_width - mid; mid = mid / 2;
}
else if (widget->align & RTGUI_ALIGN_RIGHT)
{
/* right */
rect->x1 = next_x + box_width - rtgui_rect_width(*rect);
rect->x2 = next_x + box_width;
}
if (widget->align & RTGUI_ALIGN_STRETCH) rect->x1 = next_x + mid;
{ rect->x2 = next_x + box_width - mid;
rect->y2 = rect->y1 + space_height; }
} else if (widget->align & RTGUI_ALIGN_RIGHT)
{
/* right */
rect->x1 = next_x + box_width - rtgui_rect_width(*rect);
rect->x2 = next_x + box_width;
}
/* process resize event */ if (widget->align & RTGUI_ALIGN_STRETCH)
size_event.x = rect->x1; {
size_event.y = rect->y1; rect->y2 = rect->y1 + space_height;
size_event.w = rect->x2 - rect->x1; }
size_event.h = rect->y2 - rect->y1;
RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget),
&size_event.parent);
/* point to next height */ /* process resize event */
next_y = rect->y2 + box->border_size; size_event.x = rect->x1;
} size_event.y = rect->y1;
size_event.w = rect->x2 - rect->x1;
size_event.h = rect->y2 - rect->y1;
RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget),
&size_event.parent);
/* point to next height */
next_y = rect->y2 + box->border_size;
}
} }
static void rtgui_box_layout_horizontal(struct rtgui_box* box, struct rtgui_rect* extent) static void rtgui_box_layout_horizontal(struct rtgui_box *box, struct rtgui_rect *extent)
{ {
rtgui_list_t *node; rtgui_list_t *node;
rt_int32_t box_height; rt_int32_t box_height;
rt_int32_t space_count; rt_int32_t space_count;
rt_int32_t next_x, next_y; rt_int32_t next_x, next_y;
rt_int32_t total_width, space_width; rt_int32_t total_width, space_width;
struct rtgui_event_resize size_event; struct rtgui_event_resize size_event;
/* prepare the resize event */ /* prepare the resize event */
RTGUI_EVENT_RESIZE_INIT(&size_event); RTGUI_EVENT_RESIZE_INIT(&size_event);
/* find spaces */ /* find spaces */
space_count = 0; space_count = 0;
total_width = 0; total_width = 0;
space_width = 0; space_width = 0;
rtgui_list_foreach(node, &(box->container->children)) rtgui_list_foreach(node, &(box->container->children))
{ {
rtgui_widget_t* widget = rtgui_list_entry(node, struct rtgui_widget, sibling); rtgui_widget_t *widget = rtgui_list_entry(node, struct rtgui_widget, sibling);
if (widget->align & RTGUI_ALIGN_STRETCH) space_count ++; if (widget->align & RTGUI_ALIGN_STRETCH) space_count ++;
else total_width += widget->mini_width; else total_width += widget->mini_width;
} }
if (space_count != 0) if (space_count != 0)
{ {
/* calculate the height for each spaces */ /* calculate the height for each spaces */
space_width = (rtgui_rect_width(*extent) - total_width) / space_count; space_width = (rtgui_rect_width(*extent) - total_width) / space_count;
} }
/* init (x, y) and box height */ /* init (x, y) and box height */
next_x = extent->x1 + box->border_size; next_x = extent->x1 + box->border_size;
next_y = extent->y1 + box->border_size; next_y = extent->y1 + box->border_size;
box_height = rtgui_rect_height(*extent) - (box->border_size << 1); box_height = rtgui_rect_height(*extent) - (box->border_size << 1);
/* layout each widget */ /* layout each widget */
rtgui_list_foreach(node, &(box->container->children)) rtgui_list_foreach(node, &(box->container->children))
{ {
rtgui_rect_t *rect; rtgui_rect_t *rect;
rtgui_widget_t* widget = rtgui_list_entry(node, struct rtgui_widget, sibling); rtgui_widget_t *widget = rtgui_list_entry(node, struct rtgui_widget, sibling);
/* get extent of widget */ /* get extent of widget */
rect = &(widget->extent); rect = &(widget->extent);
/* reset rect */ /* reset rect */
rtgui_rect_moveto(rect, -rect->x1, -rect->y1); rtgui_rect_moveto(rect, -rect->x1, -rect->y1);
rect->x2 = widget->mini_width; rect->x2 = widget->mini_width;
rect->y2 = widget->mini_height; rect->y2 = widget->mini_height;
/* top in default */ /* top in default */
rtgui_rect_moveto(rect, next_x, next_y); rtgui_rect_moveto(rect, next_x, next_y);
if (widget->align & RTGUI_ALIGN_EXPAND) if (widget->align & RTGUI_ALIGN_EXPAND)
{ {
/* expand on vertical */ /* expand on vertical */
rect->y2 = rect->y1 + box_height; rect->y2 = rect->y1 + box_height;
} }
if (widget->align & RTGUI_ALIGN_CENTER_HORIZONTAL) if (widget->align & RTGUI_ALIGN_CENTER_HORIZONTAL)
{ {
/* center */ /* center */
rt_uint32_t mid; rt_uint32_t mid;
mid = box_height - rtgui_rect_height(*rect); mid = box_height - rtgui_rect_height(*rect);
mid = mid /2; mid = mid / 2;
rect->y1 = next_y + mid; rect->y1 = next_y + mid;
rect->y2 = next_y + box_height - mid; rect->y2 = next_y + box_height - mid;
} }
else if (widget->align & RTGUI_ALIGN_RIGHT) else if (widget->align & RTGUI_ALIGN_RIGHT)
{ {
/* right */ /* right */
rect->y1 = next_y + box_height - rtgui_rect_height(*rect); rect->y1 = next_y + box_height - rtgui_rect_height(*rect);
rect->y2 = next_y + box_height; rect->y2 = next_y + box_height;
} }
if (widget->align & RTGUI_ALIGN_STRETCH) if (widget->align & RTGUI_ALIGN_STRETCH)
{ {
rect->x2 = rect->x1 + space_width; rect->x2 = rect->x1 + space_width;
} }
/* process resize event */ /* process resize event */
size_event.x = rect->x1; size_event.x = rect->x1;
size_event.y = rect->y1; size_event.y = rect->y1;
size_event.w = rect->x2 - rect->x1; size_event.w = rect->x2 - rect->x1;
size_event.h = rect->y2 - rect->y1; size_event.h = rect->y2 - rect->y1;
RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget), RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget),
&size_event.parent); &size_event.parent);
/* point to next width */ /* point to next width */
next_x = rect->x2 + box->border_size; next_x = rect->x2 + box->border_size;
} }
} }
void rtgui_box_layout(rtgui_box_t* box) void rtgui_box_layout(rtgui_box_t *box)
{ {
struct rtgui_rect extent; struct rtgui_rect extent;
RT_ASSERT(box != RT_NULL); RT_ASSERT(box != RT_NULL);
if (box->container == RT_NULL) return; if (box->container == RT_NULL) return;
rtgui_widget_get_extent(RTGUI_WIDGET(box->container), &extent); rtgui_widget_get_extent(RTGUI_WIDGET(box->container), &extent);
if (box->orient & RTGUI_VERTICAL) if (box->orient & RTGUI_VERTICAL)
{ {
rtgui_box_layout_vertical(box, &extent); rtgui_box_layout_vertical(box, &extent);
} }
else else
{ {
rtgui_box_layout_horizontal(box, &extent); rtgui_box_layout_horizontal(box, &extent);
} }
/* update box and its children clip */ /* update box and its children clip */
if (!RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(box->container))) if (!RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(box->container)))
{ {
rtgui_widget_update_clip(RTGUI_WIDGET(box->container)); rtgui_widget_update_clip(RTGUI_WIDGET(box->container));
} }
} }
RTM_EXPORT(rtgui_box_layout); RTM_EXPORT(rtgui_box_layout);
void rtgui_box_layout_rect(rtgui_box_t* box, struct rtgui_rect* rect) void rtgui_box_layout_rect(rtgui_box_t *box, struct rtgui_rect *rect)
{ {
RT_ASSERT(box != RT_NULL); RT_ASSERT(box != RT_NULL);
if (box->container == RT_NULL) return; if (box->container == RT_NULL) return;
if (box->orient & RTGUI_VERTICAL) if (box->orient & RTGUI_VERTICAL)
{ {
rtgui_box_layout_vertical(box, rect); rtgui_box_layout_vertical(box, rect);
} }
else else
{ {
rtgui_box_layout_horizontal(box, rect); rtgui_box_layout_horizontal(box, rect);
} }
/* update box and its children clip */ /* update box and its children clip */
if (!RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(box->container))) if (!RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(box->container)))
{ {
rtgui_widget_update_clip(RTGUI_WIDGET(box->container)); rtgui_widget_update_clip(RTGUI_WIDGET(box->container));
} }
} }
RTM_EXPORT(rtgui_box_layout_rect); RTM_EXPORT(rtgui_box_layout_rect);

View File

@ -16,276 +16,276 @@
#include <rtgui/widgets/button.h> #include <rtgui/widgets/button.h>
#include <rtgui/widgets/window.h> #include <rtgui/widgets/window.h>
static rt_bool_t rtgui_button_onunfocus(struct rtgui_object* object, rtgui_event_t* event); static rt_bool_t rtgui_button_onunfocus(struct rtgui_object *object, rtgui_event_t *event);
static void _rtgui_button_constructor(rtgui_button_t *button) static void _rtgui_button_constructor(rtgui_button_t *button)
{ {
/* init widget and set event handler */ /* init widget and set event handler */
RTGUI_WIDGET(button)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; RTGUI_WIDGET(button)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(button), rtgui_button_event_handler); rtgui_object_set_event_handler(RTGUI_OBJECT(button), rtgui_button_event_handler);
rtgui_widget_set_onunfocus(RTGUI_WIDGET(button), rtgui_button_onunfocus); rtgui_widget_set_onunfocus(RTGUI_WIDGET(button), rtgui_button_onunfocus);
/* un-press button */ /* un-press button */
button->flag = 0; button->flag = 0;
/* set flag and on_button event handler */ /* set flag and on_button event handler */
button->pressed_image = RT_NULL; button->pressed_image = RT_NULL;
button->unpressed_image = RT_NULL; button->unpressed_image = RT_NULL;
button->on_button = RT_NULL; button->on_button = RT_NULL;
/* set gc */ /* set gc */
RTGUI_WIDGET_FOREGROUND(button) = default_foreground; RTGUI_WIDGET_FOREGROUND(button) = default_foreground;
RTGUI_WIDGET_BACKGROUND(button) = RTGUI_RGB(212, 208, 200); RTGUI_WIDGET_BACKGROUND(button) = RTGUI_RGB(212, 208, 200);
RTGUI_WIDGET_TEXTALIGN(button) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(button) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
} }
static void _rtgui_button_destructor(rtgui_button_t *button) static void _rtgui_button_destructor(rtgui_button_t *button)
{ {
if (button->pressed_image != RT_NULL) if (button->pressed_image != RT_NULL)
{ {
rtgui_image_destroy(button->pressed_image); rtgui_image_destroy(button->pressed_image);
button->pressed_image = RT_NULL; button->pressed_image = RT_NULL;
} }
if (button->unpressed_image != RT_NULL) if (button->unpressed_image != RT_NULL)
{ {
rtgui_image_destroy(button->unpressed_image); rtgui_image_destroy(button->unpressed_image);
button->unpressed_image = RT_NULL; button->unpressed_image = RT_NULL;
} }
} }
DEFINE_CLASS_TYPE(button, "button", DEFINE_CLASS_TYPE(button, "button",
RTGUI_LABEL_TYPE, RTGUI_LABEL_TYPE,
_rtgui_button_constructor, _rtgui_button_constructor,
_rtgui_button_destructor, _rtgui_button_destructor,
sizeof(struct rtgui_button)); sizeof(struct rtgui_button));
rt_bool_t rtgui_button_event_handler(struct rtgui_object* object, struct rtgui_event* event) rt_bool_t rtgui_button_event_handler(struct rtgui_object *object, struct rtgui_event *event)
{ {
struct rtgui_widget *widget; struct rtgui_widget *widget;
struct rtgui_button *btn; struct rtgui_button *btn;
RT_ASSERT(object != RT_NULL); RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL); RT_ASSERT(event != RT_NULL);
widget = RTGUI_WIDGET(object); widget = RTGUI_WIDGET(object);
btn = RTGUI_BUTTON(widget); btn = RTGUI_BUTTON(widget);
switch (event->type) switch (event->type)
{ {
case RTGUI_EVENT_PAINT: case RTGUI_EVENT_PAINT:
rtgui_theme_draw_button(btn); rtgui_theme_draw_button(btn);
break; break;
case RTGUI_EVENT_KBD: case RTGUI_EVENT_KBD:
{ {
struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*) event; struct rtgui_event_kbd *ekbd = (struct rtgui_event_kbd *) event;
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE)) if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE))
{ {
if (RTGUI_KBD_IS_DOWN(ekbd)) if (RTGUI_KBD_IS_DOWN(ekbd))
{ {
btn->flag |= RTGUI_BUTTON_FLAG_PRESS; btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
} }
else else
{ {
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS; btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
} }
/* draw button */ /* draw button */
rtgui_theme_draw_button(btn); rtgui_theme_draw_button(btn);
if ((btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL)) if ((btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
{ {
/* call on button handler */ /* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event); btn->on_button(RTGUI_OBJECT(widget), event);
} }
} }
} }
break; break;
case RTGUI_EVENT_MOUSE_BUTTON: case RTGUI_EVENT_MOUSE_BUTTON:
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
{ {
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event; struct rtgui_event_mouse *emouse = (struct rtgui_event_mouse *)event;
/* it's not this widget event, clean status */ /* it's not this widget event, clean status */
if (rtgui_rect_contains_point(&(RTGUI_WIDGET(btn)->extent), if (rtgui_rect_contains_point(&(RTGUI_WIDGET(btn)->extent),
emouse->x, emouse->y) != RT_EOK) emouse->x, emouse->y) != RT_EOK)
{ {
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS; btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
/* draw button */ /* draw button */
rtgui_theme_draw_button(btn); rtgui_theme_draw_button(btn);
break; break;
} }
if (btn->flag & RTGUI_BUTTON_TYPE_PUSH) if (btn->flag & RTGUI_BUTTON_TYPE_PUSH)
{ {
/* it's a push button */ /* it's a push button */
if (emouse->button & RTGUI_MOUSE_BUTTON_UP) if (emouse->button & RTGUI_MOUSE_BUTTON_UP)
{ {
if (btn->flag & RTGUI_BUTTON_FLAG_PRESS) if (btn->flag & RTGUI_BUTTON_FLAG_PRESS)
{ {
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS; btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
} }
else else
{ {
btn->flag |= RTGUI_BUTTON_FLAG_PRESS; btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
} }
/* draw button */ /* draw button */
rtgui_theme_draw_button(btn); rtgui_theme_draw_button(btn);
if (btn->on_button != RT_NULL) if (btn->on_button != RT_NULL)
{ {
/* call on button handler */ /* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event); btn->on_button(RTGUI_OBJECT(widget), event);
} }
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
/* invokes call back */ /* invokes call back */
if (widget->on_mouseclick != RT_NULL && if (widget->on_mouseclick != RT_NULL &&
emouse->button & RTGUI_MOUSE_BUTTON_UP) emouse->button & RTGUI_MOUSE_BUTTON_UP)
return widget->on_mouseclick(RTGUI_OBJECT(widget), event); return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
#endif #endif
} }
} }
else else
{ {
if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT) if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT)
{ {
/* set the last mouse event handled widget */ /* set the last mouse event handled widget */
struct rtgui_win* win; struct rtgui_win *win;
win = RTGUI_WIN(RTGUI_WIDGET(btn)->toplevel); win = RTGUI_WIN(RTGUI_WIDGET(btn)->toplevel);
win->last_mevent_widget = RTGUI_WIDGET(btn); win->last_mevent_widget = RTGUI_WIDGET(btn);
/* it's a normal button */ /* it's a normal button */
if (emouse->button & RTGUI_MOUSE_BUTTON_DOWN) if (emouse->button & RTGUI_MOUSE_BUTTON_DOWN)
{ {
btn->flag |= RTGUI_BUTTON_FLAG_PRESS; btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
} }
else else
{ {
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS; btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
} }
/* draw button */ /* draw button */
rtgui_theme_draw_button(btn); rtgui_theme_draw_button(btn);
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
/* invokes call back */ /* invokes call back */
if (widget->on_mouseclick != RT_NULL && if (widget->on_mouseclick != RT_NULL &&
emouse->button & RTGUI_MOUSE_BUTTON_UP) emouse->button & RTGUI_MOUSE_BUTTON_UP)
return widget->on_mouseclick(RTGUI_OBJECT(widget), event); return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
#endif #endif
if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL)) if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
{ {
/* call on button handler */ /* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event); btn->on_button(RTGUI_OBJECT(widget), event);
} }
} }
} }
return RT_TRUE; return RT_TRUE;
} }
default: default:
return rtgui_widget_event_handler(object, event); return rtgui_widget_event_handler(object, event);
} }
return RT_FALSE; return RT_FALSE;
} }
RTM_EXPORT(rtgui_button_event_handler); RTM_EXPORT(rtgui_button_event_handler);
rtgui_button_t* rtgui_button_create(const char* text) rtgui_button_t *rtgui_button_create(const char *text)
{ {
struct rtgui_button* btn; struct rtgui_button *btn;
btn = (struct rtgui_button*) rtgui_widget_create (RTGUI_BUTTON_TYPE); btn = (struct rtgui_button *) rtgui_widget_create(RTGUI_BUTTON_TYPE);
if (btn != RT_NULL) if (btn != RT_NULL)
{ {
rtgui_rect_t rect; rtgui_rect_t rect;
/* set default rect */ /* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect); rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1); rect.x2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1); rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rtgui_widget_set_rect(RTGUI_WIDGET(btn), &rect); rtgui_widget_set_rect(RTGUI_WIDGET(btn), &rect);
rtgui_label_set_text(RTGUI_LABEL(btn), text); rtgui_label_set_text(RTGUI_LABEL(btn), text);
} }
return btn; return btn;
} }
RTM_EXPORT(rtgui_button_create); RTM_EXPORT(rtgui_button_create);
rtgui_button_t* rtgui_pushbutton_create(const char* text) rtgui_button_t *rtgui_pushbutton_create(const char *text)
{ {
rtgui_button_t* btn; rtgui_button_t *btn;
btn = rtgui_button_create(text); btn = rtgui_button_create(text);
if (btn != RT_NULL) btn->flag |= RTGUI_BUTTON_TYPE_PUSH; if (btn != RT_NULL) btn->flag |= RTGUI_BUTTON_TYPE_PUSH;
return btn; return btn;
} }
RTM_EXPORT(rtgui_pushbutton_create); RTM_EXPORT(rtgui_pushbutton_create);
void rtgui_button_destroy(rtgui_button_t* btn) void rtgui_button_destroy(rtgui_button_t *btn)
{ {
rtgui_widget_destroy(RTGUI_WIDGET(btn)); rtgui_widget_destroy(RTGUI_WIDGET(btn));
} }
RTM_EXPORT(rtgui_button_destroy); RTM_EXPORT(rtgui_button_destroy);
void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image) void rtgui_button_set_pressed_image(rtgui_button_t *btn, rtgui_image_t *image)
{ {
RT_ASSERT(btn != RT_NULL); RT_ASSERT(btn != RT_NULL);
btn->pressed_image = image; btn->pressed_image = image;
} }
RTM_EXPORT(rtgui_button_set_pressed_image); RTM_EXPORT(rtgui_button_set_pressed_image);
void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image) void rtgui_button_set_unpressed_image(rtgui_button_t *btn, rtgui_image_t *image)
{ {
RT_ASSERT(btn != RT_NULL); RT_ASSERT(btn != RT_NULL);
btn->unpressed_image = image; btn->unpressed_image = image;
} }
RTM_EXPORT(rtgui_button_set_unpressed_image); RTM_EXPORT(rtgui_button_set_unpressed_image);
void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func) void rtgui_button_set_onbutton(rtgui_button_t *btn, rtgui_onbutton_func_t func)
{ {
RT_ASSERT(btn != RT_NULL); RT_ASSERT(btn != RT_NULL);
btn->on_button = func; btn->on_button = func;
} }
RTM_EXPORT(rtgui_button_set_onbutton); RTM_EXPORT(rtgui_button_set_onbutton);
static rt_bool_t rtgui_button_onunfocus(struct rtgui_object* object, rtgui_event_t* event) static rt_bool_t rtgui_button_onunfocus(struct rtgui_object *object, rtgui_event_t *event)
{ {
rtgui_rect_t rect; rtgui_rect_t rect;
rtgui_widget_t *widget; rtgui_widget_t *widget;
struct rtgui_dc *dc; struct rtgui_dc *dc;
RT_ASSERT(object); RT_ASSERT(object);
widget = RTGUI_WIDGET(object); widget = RTGUI_WIDGET(object);
dc = rtgui_dc_begin_drawing(widget); dc = rtgui_dc_begin_drawing(widget);
if(dc == RT_NULL) return RT_FALSE; if (dc == RT_NULL) return RT_FALSE;
rtgui_widget_get_rect(widget, &rect);
if(!RTGUI_WIDGET_IS_FOCUSED(widget)) rtgui_widget_get_rect(widget, &rect);
{
/* only clear focus rect */
rtgui_color_t color;
rtgui_rect_inflate(&rect, -2);
color = RTGUI_DC_FC(dc);
RTGUI_DC_FC(dc) = RTGUI_DC_BC(dc);
rtgui_dc_draw_focus_rect(dc, &rect);
RTGUI_DC_FC(dc) = color;
}
rtgui_dc_end_drawing(dc); if (!RTGUI_WIDGET_IS_FOCUSED(widget))
return RT_TRUE; {
/* only clear focus rect */
rtgui_color_t color;
rtgui_rect_inflate(&rect, -2);
color = RTGUI_DC_FC(dc);
RTGUI_DC_FC(dc) = RTGUI_DC_BC(dc);
rtgui_dc_draw_focus_rect(dc, &rect);
RTGUI_DC_FC(dc) = color;
}
rtgui_dc_end_drawing(dc);
return RT_TRUE;
} }

View File

@ -4,149 +4,149 @@
static void _rtgui_checkbox_constructor(rtgui_checkbox_t *box) static void _rtgui_checkbox_constructor(rtgui_checkbox_t *box)
{ {
/* init widget and set event handler */ /* init widget and set event handler */
RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_checkbox_event_handler); rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_checkbox_event_handler);
/* set status */ /* set status */
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED; box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
box->on_button = RT_NULL; box->on_button = RT_NULL;
/* set default gc */ /* set default gc */
RTGUI_WIDGET_TEXTALIGN(box) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(box) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
} }
DEFINE_CLASS_TYPE(checkbox, "checkbox", DEFINE_CLASS_TYPE(checkbox, "checkbox",
RTGUI_LABEL_TYPE, RTGUI_LABEL_TYPE,
_rtgui_checkbox_constructor, _rtgui_checkbox_constructor,
RT_NULL, RT_NULL,
sizeof(struct rtgui_checkbox)); sizeof(struct rtgui_checkbox));
void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func) void rtgui_checkbox_set_onbutton(rtgui_checkbox_t *checkbox, rtgui_onbutton_func_t func)
{ {
RT_ASSERT(checkbox != RT_NULL); RT_ASSERT(checkbox != RT_NULL);
checkbox->on_button = func; checkbox->on_button = func;
} }
rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object* object, struct rtgui_event* event) rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object *object, struct rtgui_event *event)
{ {
struct rtgui_checkbox *box; struct rtgui_checkbox *box;
RTGUI_WIDGET_EVENT_HANDLER_PREPARE RTGUI_WIDGET_EVENT_HANDLER_PREPARE
box = RTGUI_CHECKBOX(object); box = RTGUI_CHECKBOX(object);
switch (event->type) switch (event->type)
{ {
case RTGUI_EVENT_PAINT: case RTGUI_EVENT_PAINT:
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
if (widget->on_draw != RT_NULL) if (widget->on_draw != RT_NULL)
{ {
return widget->on_draw(RTGUI_OBJECT(widget), event); return widget->on_draw(RTGUI_OBJECT(widget), event);
} }
else else
#endif #endif
rtgui_theme_draw_checkbox(box); rtgui_theme_draw_checkbox(box);
break; break;
case RTGUI_EVENT_MOUSE_BUTTON: case RTGUI_EVENT_MOUSE_BUTTON:
{ {
if (RTGUI_WIDGET_IS_ENABLE(widget) && !RTGUI_WIDGET_IS_HIDE(widget)) if (RTGUI_WIDGET_IS_ENABLE(widget) && !RTGUI_WIDGET_IS_HIDE(widget))
{ {
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event; struct rtgui_event_mouse *emouse = (struct rtgui_event_mouse *)event;
if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT && if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT &&
emouse->button & RTGUI_MOUSE_BUTTON_UP) emouse->button & RTGUI_MOUSE_BUTTON_UP)
{ {
/* set focus */ /* set focus */
rtgui_widget_focus(widget); rtgui_widget_focus(widget);
if (box->status_down & RTGUI_CHECKBOX_STATUS_UNCHECKED) if (box->status_down & RTGUI_CHECKBOX_STATUS_UNCHECKED)
{ {
/* check it */ /* check it */
box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED; box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
} }
else else
{ {
/* un-check it */ /* un-check it */
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED; box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
} }
} }
/* draw checkbox */ /* draw checkbox */
rtgui_theme_draw_checkbox(box); rtgui_theme_draw_checkbox(box);
#ifndef RTGUI_USING_SMALL_SIZE #ifndef RTGUI_USING_SMALL_SIZE
/* call user callback */ /* call user callback */
if (widget->on_mouseclick != RT_NULL) if (widget->on_mouseclick != RT_NULL)
{ {
return widget->on_mouseclick(RTGUI_OBJECT(widget), event); return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
} }
#endif #endif
if (box->on_button != RT_NULL) if (box->on_button != RT_NULL)
{ {
box->on_button(RTGUI_OBJECT(widget), event); box->on_button(RTGUI_OBJECT(widget), event);
return RT_TRUE; return RT_TRUE;
} }
} }
return RT_TRUE; return RT_TRUE;
} }
default: default:
return rtgui_widget_event_handler(object, event); return rtgui_widget_event_handler(object, event);
} }
return RT_FALSE; return RT_FALSE;
} }
struct rtgui_checkbox* rtgui_checkbox_create(const char* text, rt_bool_t checked) struct rtgui_checkbox *rtgui_checkbox_create(const char *text, rt_bool_t checked)
{ {
struct rtgui_checkbox* box; struct rtgui_checkbox *box;
box = (struct rtgui_checkbox*) rtgui_widget_create (RTGUI_CHECKBOX_TYPE); box = (struct rtgui_checkbox *) rtgui_widget_create(RTGUI_CHECKBOX_TYPE);
if (box != RT_NULL) if (box != RT_NULL)
{ {
rtgui_rect_t rect; rtgui_rect_t rect;
/* set default rect */ /* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect); rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += RTGUI_BORDER_DEFAULT_WIDTH + 5 + (RTGUI_BORDER_DEFAULT_WIDTH << 1); rect.x2 += RTGUI_BORDER_DEFAULT_WIDTH + 5 + (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1); rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect); rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);
rtgui_label_set_text(RTGUI_LABEL(box), text); rtgui_label_set_text(RTGUI_LABEL(box), text);
if (checked == RT_TRUE)
box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
else
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
}
return box; if (checked == RT_TRUE)
box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
else
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
}
return box;
} }
void rtgui_checkbox_destroy(rtgui_checkbox_t* box) void rtgui_checkbox_destroy(rtgui_checkbox_t *box)
{ {
rtgui_widget_destroy(RTGUI_WIDGET(box)); rtgui_widget_destroy(RTGUI_WIDGET(box));
} }
void rtgui_checkbox_set_checked(rtgui_checkbox_t* checkbox, rt_bool_t checked) void rtgui_checkbox_set_checked(rtgui_checkbox_t *checkbox, rt_bool_t checked)
{ {
RT_ASSERT(checkbox != RT_NULL); RT_ASSERT(checkbox != RT_NULL);
if (checked == RT_TRUE) if (checked == RT_TRUE)
checkbox->status_down = RTGUI_CHECKBOX_STATUS_CHECKED; checkbox->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
else else
checkbox->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED; checkbox->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
} }
rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t* checkbox) rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t *checkbox)
{ {
RT_ASSERT(checkbox != RT_NULL); RT_ASSERT(checkbox != RT_NULL);
if (checkbox->status_down == RTGUI_CHECKBOX_STATUS_CHECKED) if (checkbox->status_down == RTGUI_CHECKBOX_STATUS_CHECKED)
return RT_TRUE; return RT_TRUE;
return RT_FALSE; return RT_FALSE;
} }

Some files were not shown because too many files have changed in this diff Show More