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/framebuffer_driver.c
common/pixel_driver.c
common/rtgui_mv_model.c
""")
server_src = Split("""
@ -68,10 +69,17 @@ widgets/window.c
widgets/panel.c
widgets/groupbox.c
widgets/edit.c
widgets/mv_view.c
widgets/plot.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.
src = common_src + server_src + widgets_src

View File

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

View File

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

View File

@ -1,373 +1,379 @@
/*
* Change Logs:
* 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
*/
#include <rtgui/rtgui.h>
#include <rtgui/blit.h>
/* 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 */
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;
while (line)
{
*dst_ptr = (rt_uint8_t)(((*src_ptr & 0x00E00000)>>16)|
((*(src_ptr + 1) & 0x0000E000)>>11) |
((*(src_ptr + 2) & 0x000000C0)>>6));
line = line / 3;
while (line)
{
*dst_ptr = (rt_uint8_t)(((*src_ptr & 0x00E00000) >> 16) |
((*(src_ptr + 1) & 0x0000E000) >> 11) |
((*(src_ptr + 2) & 0x000000C0) >> 6));
src_ptr += 3;
dst_ptr ++;
line --;
}
return;
src_ptr += 3;
dst_ptr ++;
line --;
}
return;
}
/* 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;
while (line-- > 0)
{
*dst_ptr = (c->r & 0xe0) | (c->g & 0xc0) >> 3 | (c->b & 0xe0) >> 5 ;
c = (struct _color *)src_ptr;
while (line-- > 0)
{
*dst_ptr = (c->r & 0xe0) | (c->g & 0xc0) >> 3 | (c->b & 0xe0) >> 5 ;
c ++;
dst_ptr ++;
}
c ++;
dst_ptr ++;
}
}
/* 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 */
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;
line = line / 3;
while (line)
{
*dst = (((*(src_ptr + 2) << 8) & 0x0000F800) |
((*(src_ptr + 1) << 3) & 0x000007E0) |
((*src_ptr >> 3) & 0x0000001F));
dst = (rt_uint16_t *)dst_ptr;
line = line / 3;
while (line)
{
*dst = (((*(src_ptr + 2) << 8) & 0x0000F800) |
((*(src_ptr + 1) << 3) & 0x000007E0) |
((*src_ptr >> 3) & 0x0000001F));
src_ptr += 3;
dst ++;
line --;
}
src_ptr += 3;
dst ++;
line --;
}
return;
return;
}
/* 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;
rt_uint16_t* ptr;
struct _color
{
rt_uint8_t r, g, b, a;
} *c;
rt_uint16_t *ptr;
c = (struct _color*)src_ptr;
ptr = (rt_uint16_t*)dst_ptr;
c = (struct _color *)src_ptr;
ptr = (rt_uint16_t *)dst_ptr;
line = line / 4;
while (line-- > 0)
{
*ptr = ((c->r & 0xf8) << 8) | ((c->g & 0xfc) << 3) | (c->b >> 3);
line = line / 4;
while (line-- > 0)
{
*ptr = ((c->r & 0xf8) << 8) | ((c->g & 0xfc) << 3) | (c->b >> 3);
c ++;
ptr ++;
}
c ++;
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 LO 0
#define HI 1
#define LO 0
/* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */
static const rt_uint32_t RGB565_RGBA8888_LUT[512] =
{
0x000000ff, 0x00000000, 0x000008ff, 0x00200000,
0x000010ff, 0x00400000, 0x000018ff, 0x00610000,
0x000020ff, 0x00810000, 0x000029ff, 0x00a10000,
0x000031ff, 0x00c20000, 0x000039ff, 0x00e20000,
0x000041ff, 0x08000000, 0x00004aff, 0x08200000,
0x000052ff, 0x08400000, 0x00005aff, 0x08610000,
0x000062ff, 0x08810000, 0x00006aff, 0x08a10000,
0x000073ff, 0x08c20000, 0x00007bff, 0x08e20000,
0x000083ff, 0x10000000, 0x00008bff, 0x10200000,
0x000094ff, 0x10400000, 0x00009cff, 0x10610000,
0x0000a4ff, 0x10810000, 0x0000acff, 0x10a10000,
0x0000b4ff, 0x10c20000, 0x0000bdff, 0x10e20000,
0x0000c5ff, 0x18000000, 0x0000cdff, 0x18200000,
0x0000d5ff, 0x18400000, 0x0000deff, 0x18610000,
0x0000e6ff, 0x18810000, 0x0000eeff, 0x18a10000,
0x0000f6ff, 0x18c20000, 0x0000ffff, 0x18e20000,
0x000400ff, 0x20000000, 0x000408ff, 0x20200000,
0x000410ff, 0x20400000, 0x000418ff, 0x20610000,
0x000420ff, 0x20810000, 0x000429ff, 0x20a10000,
0x000431ff, 0x20c20000, 0x000439ff, 0x20e20000,
0x000441ff, 0x29000000, 0x00044aff, 0x29200000,
0x000452ff, 0x29400000, 0x00045aff, 0x29610000,
0x000462ff, 0x29810000, 0x00046aff, 0x29a10000,
0x000473ff, 0x29c20000, 0x00047bff, 0x29e20000,
0x000483ff, 0x31000000, 0x00048bff, 0x31200000,
0x000494ff, 0x31400000, 0x00049cff, 0x31610000,
0x0004a4ff, 0x31810000, 0x0004acff, 0x31a10000,
0x0004b4ff, 0x31c20000, 0x0004bdff, 0x31e20000,
0x0004c5ff, 0x39000000, 0x0004cdff, 0x39200000,
0x0004d5ff, 0x39400000, 0x0004deff, 0x39610000,
0x0004e6ff, 0x39810000, 0x0004eeff, 0x39a10000,
0x0004f6ff, 0x39c20000, 0x0004ffff, 0x39e20000,
0x000800ff, 0x41000000, 0x000808ff, 0x41200000,
0x000810ff, 0x41400000, 0x000818ff, 0x41610000,
0x000820ff, 0x41810000, 0x000829ff, 0x41a10000,
0x000831ff, 0x41c20000, 0x000839ff, 0x41e20000,
0x000841ff, 0x4a000000, 0x00084aff, 0x4a200000,
0x000852ff, 0x4a400000, 0x00085aff, 0x4a610000,
0x000862ff, 0x4a810000, 0x00086aff, 0x4aa10000,
0x000873ff, 0x4ac20000, 0x00087bff, 0x4ae20000,
0x000883ff, 0x52000000, 0x00088bff, 0x52200000,
0x000894ff, 0x52400000, 0x00089cff, 0x52610000,
0x0008a4ff, 0x52810000, 0x0008acff, 0x52a10000,
0x0008b4ff, 0x52c20000, 0x0008bdff, 0x52e20000,
0x0008c5ff, 0x5a000000, 0x0008cdff, 0x5a200000,
0x0008d5ff, 0x5a400000, 0x0008deff, 0x5a610000,
0x0008e6ff, 0x5a810000, 0x0008eeff, 0x5aa10000,
0x0008f6ff, 0x5ac20000, 0x0008ffff, 0x5ae20000,
0x000c00ff, 0x62000000, 0x000c08ff, 0x62200000,
0x000c10ff, 0x62400000, 0x000c18ff, 0x62610000,
0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000,
0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000,
0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000,
0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000,
0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000,
0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000,
0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000,
0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000,
0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000,
0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000,
0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000,
0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000,
0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000,
0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000,
0x001000ff, 0x83000000, 0x001008ff, 0x83200000,
0x001010ff, 0x83400000, 0x001018ff, 0x83610000,
0x001020ff, 0x83810000, 0x001029ff, 0x83a10000,
0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000,
0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000,
0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000,
0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000,
0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000,
0x001083ff, 0x94000000, 0x00108bff, 0x94200000,
0x001094ff, 0x94400000, 0x00109cff, 0x94610000,
0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000,
0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000,
0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000,
0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000,
0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000,
0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000,
0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000,
0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000,
0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000,
0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000,
0x001441ff, 0xac000000, 0x00144aff, 0xac200000,
0x001452ff, 0xac400000, 0x00145aff, 0xac610000,
0x001462ff, 0xac810000, 0x00146aff, 0xaca10000,
0x001473ff, 0xacc20000, 0x00147bff, 0xace20000,
0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000,
0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000,
0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000,
0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000,
0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000,
0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000,
0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000,
0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000,
0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000,
0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000,
0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000,
0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000,
0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000,
0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000,
0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000,
0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000,
0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000,
0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000,
0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000,
0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000,
0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000,
0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000,
0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000,
0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000,
0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000,
0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000,
0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000,
0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000,
0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000,
0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000,
0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000,
0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000,
0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000,
0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000,
0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000,
0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000,
0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000,
0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000,
0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000,
0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000,
0x000000ff, 0x00000000, 0x000008ff, 0x00200000,
0x000010ff, 0x00400000, 0x000018ff, 0x00610000,
0x000020ff, 0x00810000, 0x000029ff, 0x00a10000,
0x000031ff, 0x00c20000, 0x000039ff, 0x00e20000,
0x000041ff, 0x08000000, 0x00004aff, 0x08200000,
0x000052ff, 0x08400000, 0x00005aff, 0x08610000,
0x000062ff, 0x08810000, 0x00006aff, 0x08a10000,
0x000073ff, 0x08c20000, 0x00007bff, 0x08e20000,
0x000083ff, 0x10000000, 0x00008bff, 0x10200000,
0x000094ff, 0x10400000, 0x00009cff, 0x10610000,
0x0000a4ff, 0x10810000, 0x0000acff, 0x10a10000,
0x0000b4ff, 0x10c20000, 0x0000bdff, 0x10e20000,
0x0000c5ff, 0x18000000, 0x0000cdff, 0x18200000,
0x0000d5ff, 0x18400000, 0x0000deff, 0x18610000,
0x0000e6ff, 0x18810000, 0x0000eeff, 0x18a10000,
0x0000f6ff, 0x18c20000, 0x0000ffff, 0x18e20000,
0x000400ff, 0x20000000, 0x000408ff, 0x20200000,
0x000410ff, 0x20400000, 0x000418ff, 0x20610000,
0x000420ff, 0x20810000, 0x000429ff, 0x20a10000,
0x000431ff, 0x20c20000, 0x000439ff, 0x20e20000,
0x000441ff, 0x29000000, 0x00044aff, 0x29200000,
0x000452ff, 0x29400000, 0x00045aff, 0x29610000,
0x000462ff, 0x29810000, 0x00046aff, 0x29a10000,
0x000473ff, 0x29c20000, 0x00047bff, 0x29e20000,
0x000483ff, 0x31000000, 0x00048bff, 0x31200000,
0x000494ff, 0x31400000, 0x00049cff, 0x31610000,
0x0004a4ff, 0x31810000, 0x0004acff, 0x31a10000,
0x0004b4ff, 0x31c20000, 0x0004bdff, 0x31e20000,
0x0004c5ff, 0x39000000, 0x0004cdff, 0x39200000,
0x0004d5ff, 0x39400000, 0x0004deff, 0x39610000,
0x0004e6ff, 0x39810000, 0x0004eeff, 0x39a10000,
0x0004f6ff, 0x39c20000, 0x0004ffff, 0x39e20000,
0x000800ff, 0x41000000, 0x000808ff, 0x41200000,
0x000810ff, 0x41400000, 0x000818ff, 0x41610000,
0x000820ff, 0x41810000, 0x000829ff, 0x41a10000,
0x000831ff, 0x41c20000, 0x000839ff, 0x41e20000,
0x000841ff, 0x4a000000, 0x00084aff, 0x4a200000,
0x000852ff, 0x4a400000, 0x00085aff, 0x4a610000,
0x000862ff, 0x4a810000, 0x00086aff, 0x4aa10000,
0x000873ff, 0x4ac20000, 0x00087bff, 0x4ae20000,
0x000883ff, 0x52000000, 0x00088bff, 0x52200000,
0x000894ff, 0x52400000, 0x00089cff, 0x52610000,
0x0008a4ff, 0x52810000, 0x0008acff, 0x52a10000,
0x0008b4ff, 0x52c20000, 0x0008bdff, 0x52e20000,
0x0008c5ff, 0x5a000000, 0x0008cdff, 0x5a200000,
0x0008d5ff, 0x5a400000, 0x0008deff, 0x5a610000,
0x0008e6ff, 0x5a810000, 0x0008eeff, 0x5aa10000,
0x0008f6ff, 0x5ac20000, 0x0008ffff, 0x5ae20000,
0x000c00ff, 0x62000000, 0x000c08ff, 0x62200000,
0x000c10ff, 0x62400000, 0x000c18ff, 0x62610000,
0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000,
0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000,
0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000,
0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000,
0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000,
0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000,
0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000,
0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000,
0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000,
0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000,
0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000,
0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000,
0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000,
0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000,
0x001000ff, 0x83000000, 0x001008ff, 0x83200000,
0x001010ff, 0x83400000, 0x001018ff, 0x83610000,
0x001020ff, 0x83810000, 0x001029ff, 0x83a10000,
0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000,
0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000,
0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000,
0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000,
0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000,
0x001083ff, 0x94000000, 0x00108bff, 0x94200000,
0x001094ff, 0x94400000, 0x00109cff, 0x94610000,
0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000,
0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000,
0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000,
0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000,
0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000,
0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000,
0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000,
0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000,
0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000,
0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000,
0x001441ff, 0xac000000, 0x00144aff, 0xac200000,
0x001452ff, 0xac400000, 0x00145aff, 0xac610000,
0x001462ff, 0xac810000, 0x00146aff, 0xaca10000,
0x001473ff, 0xacc20000, 0x00147bff, 0xace20000,
0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000,
0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000,
0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000,
0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000,
0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000,
0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000,
0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000,
0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000,
0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000,
0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000,
0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000,
0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000,
0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000,
0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000,
0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000,
0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000,
0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000,
0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000,
0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000,
0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000,
0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000,
0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000,
0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000,
0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000,
0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000,
0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000,
0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000,
0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000,
0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000,
0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000,
0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000,
0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000,
0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000,
0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000,
0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000,
0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000,
0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000,
0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000,
0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000,
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_uint32_t *dst;
rt_uint16_t *src;
rt_uint32_t *dst;
src = (rt_uint16_t*)src_ptr;
dst = (rt_uint32_t*)dst_ptr;
src = (rt_uint16_t *)src_ptr;
dst = (rt_uint32_t *)dst_ptr;
line = line / 2;
while (line)
{
*dst++ = RGB565_RGBA8888_LUT[src[LO]*2] + RGB565_RGBA8888_LUT[src[HI]*2+1];
line--;
src ++;
}
line = line / 2;
while (line)
{
*dst++ = RGB565_RGBA8888_LUT[src[LO] * 2] + RGB565_RGBA8888_LUT[src[HI] * 2 + 1];
line--;
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 */
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;
while (line)
{
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
src_ptr ++;
line --;
}
line = line / 4;
while (line)
{
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
src_ptr ++;
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 */
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;
while (line)
{
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = 0;
line --;
}
line = line / 4;
while (line)
{
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = 0;
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 */
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
/* 0_0, 1_0, 2_0, 3_0, 4_0 */
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
};
rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp)
{
RT_ASSERT(dst_bpp>0 && dst_bpp < 5);
RT_ASSERT(src_bpp>0 && src_bpp < 5);
RT_ASSERT(dst_bpp > 0 && dst_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;
line = line / 3;
while (line)
{
*dst = (((*src_ptr << 8) & 0x0000F800) |
((*(src_ptr + 1) << 3) & 0x000007E0) |
((*(src_ptr + 2) >> 3) & 0x0000001F));
dst = (rt_uint16_t *)dst_ptr;
line = line / 3;
while (line)
{
*dst = (((*src_ptr << 8) & 0x0000F800) |
((*(src_ptr + 1) << 3) & 0x000007E0) |
((*(src_ptr + 2) >> 3) & 0x0000001F));
src_ptr += 3;
dst ++;
line --;
}
src_ptr += 3;
dst ++;
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;
dst = (rt_uint16_t *)dst_ptr;
src = (rt_uint16_t *)src_ptr;
line = line / 2;
while (line)
{
*dst = ((*src << 11) & 0xF800) | (*src & 0x07E0) | ((*src >> 11) & 0x001F);
src ++;
dst ++;
line --;
}
while (line)
{
*dst = ((*src << 11) & 0xF800) | (*src & 0x07E0) | ((*src >> 11) & 0x001F);
src ++;
dst ++;
line --;
}
}
static const rtgui_blit_line_func _blit_table_inv[5][5] =
{
/* 0_0, 1_0, 2_0, 3_0, 4_0 */
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
/* 0_0, 1_0, 2_0, 3_0, 4_0 */
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
};
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(src_bpp>0 && src_bpp < 5);
RT_ASSERT(dst_bpp > 0 && dst_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>
const rtgui_color_t red = RTGUI_RGB(0xff, 0x00, 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 black = RTGUI_RGB(0x00, 0x00, 0x00);
const rtgui_color_t white = RTGUI_RGB(0xff, 0xff, 0xff);
const rtgui_color_t red = RTGUI_RGB(0xff, 0x00, 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 black = RTGUI_RGB(0x00, 0x00, 0x00);
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 dark_grey = RTGUI_RGB(0x7f, 0x7f, 0x7f);
const rtgui_color_t light_grey = RTGUI_RGB(0xc0, 0xc0, 0xc0);
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 light_grey = RTGUI_RGB(0xc0, 0xc0, 0xc0);
#define RTGUI_RGB_R(c) ((c) & 0xff)
#define RTGUI_RGB_G(c) (((c) >> 8) & 0xff)
#define RTGUI_RGB_B(c) (((c) >> 16) & 0xff)
#define RTGUI_RGB_A(c) (((c) >> 24) & 0xff)
#define RTGUI_RGB_R(c) ((c) & 0xff)
#define RTGUI_RGB_G(c) (((c) >> 8) & 0xff)
#define RTGUI_RGB_B(c) (((c) >> 16) & 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/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_BLEND 0x01
#define RTGUI_BLENDMODE_ADD 0x02
#define RTGUI_BLENDMODE_MOD 0x03
#define RTGUI_BLENDMODE_NONE 0x00
#define RTGUI_BLENDMODE_BLEND 0x01
#define RTGUI_BLENDMODE_ADD 0x02
#define RTGUI_BLENDMODE_MOD 0x03
struct rtgui_dc_buffer
{
struct rtgui_dc parent;
struct rtgui_dc parent;
/* graphic context */
rtgui_gc_t gc;
/* graphic context */
rtgui_gc_t gc;
/* pixel format */
rt_uint8_t pixel_format;
rt_uint8_t blend_mode;
/* pixel format */
rt_uint8_t pixel_format;
rt_uint8_t blend_mode;
/* width and height */
rt_uint16_t width, height;
rt_uint16_t pitch;
/* width and height */
rt_uint16_t width, height;
rt_uint16_t pitch;
/* blit info */
rtgui_region_t clip;
/* blit info */
rtgui_region_t clip;
/* pixel data */
rt_uint8_t* pixel;
/* pixel data */
rt_uint8_t *pixel;
};
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_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_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_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,
struct rtgui_dc* dest, rtgui_rect_t* rect);
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_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_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_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,
struct rtgui_dc *dest, rtgui_rect_t *rect);
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 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 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 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);
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_color_point,
rtgui_dc_buffer_draw_vline,
rtgui_dc_buffer_draw_hline,
rtgui_dc_buffer_fill_rect,
rtgui_dc_buffer_blit_line,
rtgui_dc_buffer_blit,
rtgui_dc_buffer_draw_point,
rtgui_dc_buffer_draw_color_point,
rtgui_dc_buffer_draw_vline,
rtgui_dc_buffer_draw_hline,
rtgui_dc_buffer_fill_rect,
rtgui_dc_buffer_blit_line,
rtgui_dc_buffer_blit,
rtgui_dc_buffer_set_gc,
rtgui_dc_buffer_get_gc,
rtgui_dc_buffer_set_gc,
rtgui_dc_buffer_get_gc,
rtgui_dc_buffer_get_visible,
rtgui_dc_buffer_get_rect,
rtgui_dc_buffer_get_visible,
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->parent.type = RTGUI_DC_BUFFER;
dc->parent.engine = &dc_buffer_engine;
dc->gc.foreground = default_foreground;
dc->gc.background = default_background;
dc->gc.font = rtgui_font_default();
dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
dc = (struct rtgui_dc_buffer *)rtgui_malloc(sizeof(struct rtgui_dc_buffer));
dc->parent.type = RTGUI_DC_BUFFER;
dc->parent.engine = &dc_buffer_engine;
dc->gc.foreground = default_foreground;
dc->gc.background = default_background;
dc->gc.font = rtgui_font_default();
dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
dc->width = w;
dc->height = h;
dc->pitch = w * sizeof(rtgui_color_t);
dc->width = w;
dc->height = h;
dc->pitch = w *sizeof(rtgui_color_t);
rtgui_region_init(&(dc->clip));
rtgui_region_init(&(dc->clip));
dc->pixel = rtgui_malloc(h * dc->pitch);
rt_memset(dc->pixel, 0, h * dc->pitch);
dc->pixel = rtgui_malloc(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);
buffer->pixel = RT_NULL;
rtgui_free(buffer->pixel);
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;
struct rtgui_dc_buffer* dc;
rtgui_color_t *ptr;
struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self;
dc = (struct rtgui_dc_buffer *)self;
/* does not draw point out of dc */
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));
/* does not draw point out of dc */
if ((x > dc->width) || (y > dc->height)) return ;
*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;
struct rtgui_dc_buffer* dc;
rtgui_color_t *ptr;
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 */
ptr = (rtgui_color_t*)(dc->pixel + y * dc->pitch + x * sizeof(rtgui_color_t));
/* note: there is no parameter check in this function */
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;
register rt_base_t index;
struct rtgui_dc_buffer* dc;
rtgui_color_t *ptr;
register rt_base_t index;
struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self;
dc = (struct rtgui_dc_buffer *)self;
if (x >= dc->width) return;
if (y1 > dc->height) y1 = dc->height;
if (y2 > dc->height) y2 = dc->height;
if (x >= dc->width) return;
if (y1 > dc->height) y1 = dc->height;
if (y2 > dc->height) y2 = dc->height;
ptr = (rtgui_color_t*)(dc->pixel + y1 * dc->pitch + x * sizeof(rtgui_color_t));
for (index = y1; index < y2; index ++)
{
/* draw this point */
*ptr = dc->gc.foreground;
ptr += dc->width;
}
ptr = (rtgui_color_t *)(dc->pixel + y1 * dc->pitch + x * sizeof(rtgui_color_t));
for (index = y1; index < y2; index ++)
{
/* draw this point */
*ptr = dc->gc.foreground;
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;
register rt_base_t index;
struct rtgui_dc_buffer* dc;
rtgui_color_t *ptr;
register rt_base_t index;
struct rtgui_dc_buffer *dc;
dc = (struct rtgui_dc_buffer*)self;
if (y >= dc->height) return;
if (x1 > dc->width) x1 = dc->width;
if (x2 > dc->width) x2 = dc->width;
dc = (struct rtgui_dc_buffer *)self;
if (y >= dc->height) return;
if (x1 > dc->width) x1 = dc->width;
if (x2 > dc->width) x2 = dc->width;
ptr = (rtgui_color_t*)(dc->pixel + y * dc->pitch + x1 * sizeof(rtgui_color_t));
for (index = x1; index < x2; index ++)
{
/* draw this point */
*ptr++ = dc->gc.foreground;
}
ptr = (rtgui_color_t *)(dc->pixel + y * dc->pitch + x1 * sizeof(rtgui_color_t));
for (index = x1; index < x2; index ++)
{
/* draw this point */
*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_rect_t r;
struct rtgui_dc_buffer* dc;
rtgui_color_t foreground;
rtgui_rect_t r;
struct rtgui_dc_buffer *dc;
r = *rect;
dc = (struct rtgui_dc_buffer*)self;
if (r.x1 > dc->width) r.x1 = dc->width;
if (r.x2 > dc->width) r.x2 = dc->width;
if (r.y1 > dc->height) r.y1 = dc->height;
if (r.y2 > dc->height) r.y2 = dc->height;
/* save foreground color */
foreground = RTGUI_DC_FC(self);
r = *rect;
dc = (struct rtgui_dc_buffer *)self;
if (r.x1 > dc->width) r.x1 = dc->width;
if (r.x2 > dc->width) r.x2 = dc->width;
if (r.y1 > dc->height) r.y1 = dc->height;
if (r.y2 > dc->height) r.y2 = dc->height;
/* set background color as foreground color */
RTGUI_DC_FC(self) = RTGUI_DC_BC(self);
/* save foreground color */
foreground = RTGUI_DC_FC(self);
/* fill first line */
rtgui_dc_buffer_draw_hline(&(dc->parent), r.x1, r.x2, r.y1);
/* set background color as foreground color */
RTGUI_DC_FC(self) = RTGUI_DC_BC(self);
/* memory copy other lines */
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));
}
}
/* fill first line */
rtgui_dc_buffer_draw_hline(&(dc->parent), r.x1, r.x2, r.y1);
/* restore foreground color */
RTGUI_DC_FC(self) = foreground;
/* memory copy other lines */
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 */
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 (rtgui_dc_get_visible(dest) == RT_FALSE) return;
if (dc_point == RT_NULL) dc_point = &rtgui_empty_point;
if (rtgui_dc_get_visible(dest) == RT_FALSE) return;
if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT))
{
rt_uint8_t *line_ptr, *pixels;
rt_uint16_t rect_width, rect_height, index, pitch;
rtgui_blit_line_func blit_line;
if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT))
{
rt_uint8_t *line_ptr, *pixels;
rt_uint16_t rect_width, rect_height, index, pitch;
rtgui_blit_line_func blit_line;
/* calculate correct width and height */
if (rtgui_rect_width(*rect) > (dc->width - dc_point->x))
rect_width = dc->width - dc_point->x;
else
rect_width = rtgui_rect_width(*rect);
/* calculate correct width and height */
if (rtgui_rect_width(*rect) > (dc->width - dc_point->x))
rect_width = dc->width - dc_point->x;
else
rect_width = rtgui_rect_width(*rect);
if (rtgui_rect_height(*rect) > (dc->height - dc_point->y))
rect_height = dc->height - dc_point->y;
else
rect_height = rtgui_rect_height(*rect);
if (rtgui_rect_height(*rect) > (dc->height - dc_point->y))
rect_height = dc->height - dc_point->y;
else
rect_height = rtgui_rect_height(*rect);
/* prepare pixel line */
pixels = dc->pixel + dc_point->y * dc->pitch + dc_point->x * sizeof(rtgui_color_t);
/* prepare pixel line */
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)
{
/* it's the same byte per pixel, draw it directly */
for (index = rect->y1; index < rect->y1 + rect_height; index++)
{
dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, pixels);
pixels += dc->width * sizeof(rtgui_color_t);
}
}
else
{
/* get blit line function */
blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel/8, 4);
/* calculate pitch */
pitch = rect_width * sizeof(rtgui_color_t);
/* create line buffer */
line_ptr = (rt_uint8_t*) rtgui_malloc(rect_width * hw_driver->bits_per_pixel/8);
if (hw_driver->bits_per_pixel == sizeof(rtgui_color_t) * 8)
{
/* it's the same byte per pixel, draw it directly */
for (index = rect->y1; index < rect->y1 + rect_height; index++)
{
dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, pixels);
pixels += dc->width * sizeof(rtgui_color_t);
}
}
else
{
/* get blit line function */
blit_line = rtgui_blit_line_get(hw_driver->bits_per_pixel / 8, 4);
/* calculate pitch */
pitch = rect_width * sizeof(rtgui_color_t);
/* create line buffer */
line_ptr = (rt_uint8_t *) rtgui_malloc(rect_width * hw_driver->bits_per_pixel / 8);
/* draw each line */
for (index = rect->y1; index < rect->y1 + rect_height; index ++)
{
/* blit on line buffer */
blit_line(line_ptr, (rt_uint8_t*)pixels, pitch);
pixels += dc->width * sizeof(rtgui_color_t);
/* draw each line */
for (index = rect->y1; index < rect->y1 + rect_height; index ++)
{
/* blit on line buffer */
blit_line(line_ptr, (rt_uint8_t *)pixels, pitch);
pixels += dc->width * sizeof(rtgui_color_t);
/* draw on hardware dc */
dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, line_ptr);
}
/* draw on hardware dc */
dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, line_ptr);
}
/* release line buffer */
rtgui_free(line_ptr);
}
}
/* release line buffer */
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;
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
rtgui_color_t *color_ptr;
struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;
RT_ASSERT(dc != RT_NULL);
RT_ASSERT(line_data != RT_NULL);
RT_ASSERT(dc != RT_NULL);
RT_ASSERT(line_data != RT_NULL);
/* out of range */
if ((x1 > dc->width) || (y > dc->height)) return;
/* check range */
if (x2 > dc->width) x2 = dc->width;
/* out of range */
if ((x1 > dc->width) || (y > dc->height)) return;
/* check range */
if (x2 > dc->width) x2 = dc->width;
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));
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));
}
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->y2 = dc->height;
rect->x2 = dc->width;
rect->y2 = dc->height;
}

View File

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

View File

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

View File

@ -19,79 +19,79 @@
/* standard file read/write */
struct rtgui_filerw_stdio
{
/* inherit from rtgui_filerw */
struct rtgui_filerw parent;
/* inherit from rtgui_filerw */
struct rtgui_filerw parent;
int fd;
rt_bool_t eof;
int fd;
rt_bool_t eof;
};
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;
int stdio_whence[3] = {SEEK_SET, SEEK_CUR, SEEK_END};
struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
int stdio_whence[3] = {SEEK_SET, SEEK_CUR, SEEK_END};
if (whence < RTGUI_FILE_SEEK_SET || whence > RTGUI_FILE_SEEK_END)
{
return -1;
}
if (whence < RTGUI_FILE_SEEK_SET || whence > RTGUI_FILE_SEEK_END)
{
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)
{
int result;
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
int result;
/* end of file */
if (stdio_filerw->eof == RT_TRUE) return -1;
struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
result = read(stdio_filerw->fd, ptr, size * maxnum);
if (result == 0) stdio_filerw->eof = RT_TRUE;
/* end of file */
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)
{
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;
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
int result;
struct rtgui_filerw_stdio *stdio_filerw = (struct rtgui_filerw_stdio *)context;
if (stdio_filerw->eof == RT_TRUE) result = 1;
else result = -1;
if (stdio_filerw->eof == RT_TRUE) result = 1;
else result = -1;
return result;
return result;
}
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)
{
close(stdio_filerw->fd);
rtgui_free(stdio_filerw);
if (stdio_filerw)
{
close(stdio_filerw->fd);
rtgui_free(stdio_filerw);
return 0;
}
return 0;
}
return -1;
return -1;
}
#endif
@ -99,249 +99,266 @@ static int stdio_close(struct rtgui_filerw *context)
/* memory file read/write */
struct rtgui_filerw_mem
{
/* inherit from rtgui_filerw */
struct rtgui_filerw parent;
/* inherit from rtgui_filerw */
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)
{
const rt_uint8_t* newpos;
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
const rt_uint8_t *newpos;
struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
RT_ASSERT(mem != RT_NULL);
RT_ASSERT(mem != RT_NULL);
switch (whence) {
case RTGUI_FILE_SEEK_SET:
newpos = mem->mem_base + offset;
break;
switch (whence)
{
case RTGUI_FILE_SEEK_SET:
newpos = mem->mem_base + offset;
break;
case RTGUI_FILE_SEEK_CUR:
newpos = mem->mem_position + offset;
break;
case RTGUI_FILE_SEEK_CUR:
newpos = mem->mem_position + offset;
break;
case RTGUI_FILE_SEEK_END:
newpos = mem->mem_end + offset;
break;
case RTGUI_FILE_SEEK_END:
newpos = mem->mem_end + offset;
break;
default:
return -1;
}
default:
return -1;
}
if ( newpos < mem->mem_base )
newpos = mem->mem_base;
if (newpos < mem->mem_base)
newpos = mem->mem_base;
if ( newpos > mem->mem_end )
newpos = mem->mem_end;
if (newpos > mem->mem_end)
newpos = mem->mem_end;
mem->mem_position = newpos;
return mem->mem_position- mem->mem_base;
mem->mem_position = newpos;
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)
{
int total_bytes;
int mem_available;
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
int total_bytes;
int mem_available;
struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
total_bytes = (maxnum * size);
if ( (maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != size) )
{
return -1;
}
total_bytes = (maxnum * size);
if ((maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != size))
{
return -1;
}
mem_available = mem->mem_end - mem->mem_position;
if (total_bytes > mem_available)
total_bytes = mem_available;
mem_available = mem->mem_end - mem->mem_position;
if (total_bytes > mem_available)
total_bytes = mem_available;
rt_memcpy(ptr, mem->mem_position, total_bytes);
mem->mem_position += total_bytes;
rt_memcpy(ptr, 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)
{
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)
{
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
struct rtgui_filerw_mem *mem = (struct rtgui_filerw_mem *)context;
if (mem != RT_NULL)
{
rtgui_free(mem);
return 0;
}
if (mem != RT_NULL)
{
rtgui_free(mem);
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 */
if (mem->parent.read != mem_read) return RT_NULL;
/* check whether it's a memory filerw */
if (mem->parent.read != mem_read) return RT_NULL;
return mem->mem_base;
return mem->mem_base;
}
/* file read/write public interface */
#ifdef RTGUI_USING_DFS_FILERW
static int parse_mode(const char *mode)
{
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;
}
int f = 0;
++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;
struct rtgui_filerw_stdio *rw;
int fd;
struct rtgui_filerw_stdio *rw;
RT_ASSERT(filename != RT_NULL);
RT_ASSERT(filename != RT_NULL);
rw = RT_NULL;
#ifdef _WIN32
fd = _open(filename, parse_mode(mode), 0);
rw = RT_NULL;
#ifdef _WIN32_NATIVE
fd = _open(filename, parse_mode(mode), 0);
#else
fd = open(filename, parse_mode(mode), 0);
fd = open(filename, parse_mode(mode), 0);
#endif
if ( fd >= 0 )
{
rw = (struct rtgui_filerw_stdio*) rtgui_malloc(sizeof(struct rtgui_filerw_stdio));
if (rw != RT_NULL)
{
rw->parent.seek = stdio_seek;
rw->parent.read = stdio_read;
rw->parent.write = stdio_write;
rw->parent.tell = stdio_tell;
rw->parent.close = stdio_close;
rw->parent.eof = stdio_eof;
if (fd >= 0)
{
rw = (struct rtgui_filerw_stdio *) rtgui_malloc(sizeof(struct rtgui_filerw_stdio));
if (rw != RT_NULL)
{
rw->parent.seek = stdio_seek;
rw->parent.read = stdio_read;
rw->parent.write = stdio_write;
rw->parent.tell = stdio_tell;
rw->parent.close = stdio_close;
rw->parent.eof = stdio_eof;
rw->fd = fd;
rw->eof = RT_FALSE;
}
}
rw->fd = fd;
rw->eof = RT_FALSE;
}
}
return &(rw->parent);
return &(rw->parent);
}
int rtgui_filerw_unlink(const char *filename)
{
#ifdef _WIN32
return _unlink(filename);
#ifdef _WIN32_NATIVE
return _unlink(filename);
#else
return unlink(filename);
#ifndef RT_USING_DFS
/* no unlink function */
return -1;
#else
return unlink(filename);
#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;
RT_ASSERT(mem != RT_NULL);
struct rtgui_filerw_mem *rw;
RT_ASSERT(mem != RT_NULL);
rw = (struct rtgui_filerw_mem*) rtgui_malloc(sizeof(struct rtgui_filerw_mem));
if (rw != RT_NULL)
{
rw->parent.seek = mem_seek;
rw->parent.read = mem_read;
rw->parent.write = mem_write;
rw->parent.tell = mem_tell;
rw->parent.eof = mem_eof;
rw->parent.close = mem_close;
rw = (struct rtgui_filerw_mem *) rtgui_malloc(sizeof(struct rtgui_filerw_mem));
if (rw != RT_NULL)
{
rw->parent.seek = mem_seek;
rw->parent.read = mem_read;
rw->parent.write = mem_write;
rw->parent.tell = mem_tell;
rw->parent.eof = mem_eof;
rw->parent.close = mem_close;
rw->mem_base = mem;
rw->mem_position = mem;
rw->mem_end = mem + size;
}
rw->mem_base = mem;
rw->mem_position = mem;
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 */
result = context->close(context);
if (result != 0)
{
/* close file failed */
return -1;
}
/* close context */
result = context->close(context);
if (result != 0)
{
/* close file failed */
return -1;
}
return 0;
return 0;
}

View File

@ -15,7 +15,7 @@
#include <rtgui/dc.h>
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_arial16;
@ -28,131 +28,131 @@ extern struct rtgui_font rtgui_font_hz12;
void rtgui_font_system_init()
{
rtgui_list_init(&(_rtgui_font_list));
rtgui_list_init(&(_rtgui_font_list));
/* set default font to NULL */
rtgui_default_font = RT_NULL;
/* set default font to NULL */
rtgui_default_font = RT_NULL;
#ifdef RTGUI_USING_FONT16
rtgui_font_system_add_font(&rtgui_font_asc16);
rtgui_font_system_add_font(&rtgui_font_asc16);
#ifdef RTGUI_USING_FONTHZ
rtgui_font_system_add_font(&rtgui_font_hz16);
rtgui_font_system_add_font(&rtgui_font_hz16);
#endif
#endif
#ifdef RTGUI_USING_FONT12
rtgui_font_system_add_font(&rtgui_font_asc12);
rtgui_font_system_add_font(&rtgui_font_asc12);
#ifdef RTGUI_USING_FONTHZ
rtgui_font_system_add_font(&rtgui_font_hz12);
rtgui_font_system_add_font(&rtgui_font_hz12);
#endif
#endif
#ifdef RTGUI_USING_FONT12
if (rtgui_default_font == RT_NULL)
rtgui_font_set_defaut(&rtgui_font_asc12);
if (rtgui_default_font == RT_NULL)
rtgui_font_set_defaut(&rtgui_font_asc12);
#endif
#ifdef RTGUI_USING_FONT16
if (rtgui_default_font == RT_NULL)
rtgui_font_set_defaut(&rtgui_font_asc16);
if (rtgui_default_font == RT_NULL)
rtgui_font_set_defaut(&rtgui_font_asc16);
#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_append(&_rtgui_font_list, &(font->list));
rtgui_list_init(&(font->list));
rtgui_list_append(&_rtgui_font_list, &(font->list));
/* init font */
if (font->engine->font_init != RT_NULL)
font->engine->font_init(font);
/* init font */
if (font->engine->font_init != RT_NULL)
font->engine->font_init(font);
/* first refer, load it */
if (font->engine->font_load != RT_NULL)
font->engine->font_load(font);
/* first refer, load it */
if (font->engine->font_load != RT_NULL)
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 */
struct rtgui_list_node* node;
struct rtgui_font* font;
/* search font */
struct rtgui_list_node *node;
struct rtgui_font *font;
rtgui_list_foreach(node, &_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) &&
font->height == height)
{
font->refer_count ++;
return font;
}
}
rtgui_list_foreach(node, &_rtgui_font_list)
{
font = rtgui_list_entry(node, struct rtgui_font, list);
if ((rt_strncmp(font->family, family, RTGUI_NAME_MAX) == 0) &&
font->height == height)
{
font->refer_count ++;
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 */
if (font->refer_count == 0)
{
rtgui_font_system_remove_font(font);
}
/* no refer, remove font */
if (font->refer_count == 0)
{
rtgui_font_system_remove_font(font);
}
}
/* 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 &&
font->engine->font_draw_text != RT_NULL)
{
font->engine->font_draw_text(font, dc, text, len, rect);
}
if (font->engine != RT_NULL &&
font->engine->font_draw_text != RT_NULL)
{
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 */
rtgui_font_get_metrics(font, text, &rect);
/* get metrics */
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 &&
font->engine->font_get_metrics != RT_NULL)
{
font->engine->font_get_metrics(font, text, rect);
}
else
{
/* no font engine found, set rect to zero */
rt_memset(rect, 0, sizeof(rtgui_rect_t));
}
if (font->engine != RT_NULL &&
font->engine->font_get_metrics != RT_NULL)
{
font->engine->font_get_metrics(font, text, rect);
}
else
{
/* no font engine found, set rect to zero */
rt_memset(rect, 0, sizeof(rtgui_rect_t));
}
}

View File

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

View File

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

View File

@ -4,123 +4,156 @@
#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_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* 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);
const struct rtgui_font_engine hz_bmp_font_engine =
{
RT_NULL,
RT_NULL,
rtgui_hz_bitmap_font_draw_text,
rtgui_hz_bitmap_font_get_metrics
RT_NULL,
RT_NULL,
rtgui_hz_bitmap_font_draw_text,
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;
rtgui_color_t bc;
rt_uint16_t style;
register rt_base_t h, word_bytes, font_bytes;
rt_uint16_t cha = *(rt_uint16_t *)str;
int idx;
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 */
style = rtgui_dc_get_gc(dc)->textstyle;
bc = rtgui_dc_get_gc(dc)->background;
/* don't access beyond the data */
if (idx < 0)
idx = 0;
/* 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;
/* get font pixel data */
return bmp_font->bmp + idx * font_bytes;
}
#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)
{
const rt_uint8_t* font_ptr;
rt_ubase_t sect, index;
register rt_base_t i, j, k;
/* get font pixel data */
return bmp_font->bmp + (94 * (sect - 1) + (index - 1)) * font_bytes;
}
#endif
/* calculate section and index */
sect = *str - 0xA0;
index = *(str+1) - 0xA0;
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)
{
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 */
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);
}
}
}
RT_ASSERT(bmp_font != RT_NULL);
/* move x to next character */
rect->x1 += bmp_font->width;
str += 2;
len -= 2;
}
/* get text style */
style = rtgui_dc_get_gc(dc)->textstyle;
bc = rtgui_dc_get_gc(dc)->background;
/* 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;
struct rtgui_font *efont;
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
rt_uint32_t len;
struct rtgui_font *efont;
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 */
efont = rtgui_font_refer("asc", bmp_font->height);
if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */
/* get English font */
efont = rtgui_font_refer("asc", bmp_font->height);
if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */
while (length > 0)
{
len = 0;
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len) && len < length) len ++;
/* draw text with English font */
if (len > 0)
{
rtgui_font_draw(efont, dc, text, len, rect);
while (length > 0)
{
len = 0;
while (((rt_uint8_t) * (text + len)) < 0x80 && *(text + len) && len < length) len ++;
/* draw text with English font */
if (len > 0)
{
rtgui_font_draw(efont, dc, text, len, rect);
text += len;
length -= len;
}
text += len;
length -= len;
}
len = 0;
while (((rt_uint8_t)*(text + len)) >= 0x80 && len < length) len ++;
if (len > 0)
{
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect);
len = 0;
while (((rt_uint8_t) * (text + len)) >= 0x80 && len < length) len ++;
if (len > 0)
{
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect);
text += len;
length -= len;
}
}
text += 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 */
rect->x1 = rect->y1 = 0;
/* Chinese font is always fixed font */
rect->x2 = (rt_int16_t)(bmp_font->width * rt_strlen((const char*)text));
rect->y2 = bmp_font->height;
/* set metrics rect */
rect->x1 = rect->y1 = 0;
/* Chinese font is always fixed font */
rect->x2 = (rt_int16_t)(bmp_font->width * rt_strlen((const char *)text));
rect->y2 = bmp_font->height;
}
#endif

View File

@ -7,27 +7,27 @@
#include <rtgui/rtgui_system.h>
#ifdef RTGUI_USING_HZ_FILE
#ifdef _WIN32
#ifdef _WIN32_NATIVE
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#define open _open
#define close _close
#define read _read
#define write _write
#define unlink _unlink
#define open _open
#define close _close
#define read _read
#define write _write
#define unlink _unlink
#else
#include <dfs_posix.h>
#endif
#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_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_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_get_metrics(struct rtgui_font *font, const char *text, rtgui_rect_t *rect);
const struct rtgui_font_engine rtgui_hz_file_font_engine =
{
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_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;
@ -47,7 +47,7 @@ static int _font_cache_compare(struct hz_cache* cache_1, struct hz_cache* cache_
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;
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();
/* found it */
return (rt_uint8_t*)(cache + 1);
return (rt_uint8_t *)(cache + 1);
}
/* exit critical */
rtgui_exit_critical();
/* 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)
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 */
if ((lseek(font->fd, seek, SEEK_SET) < 0) ||
read(font->fd, (char*)(cache + 1), font->font_data_size) !=
font->font_data_size)
read(font->fd, (char *)(cache + 1), font->font_data_size) !=
font->font_data_size)
{
rtgui_free(cache);
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)
{
/* remove a cache */
struct hz_cache* left;
struct hz_cache *left;
left = font->cache_root.sph_root;
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 */
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);
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;
rt_uint16_t style;
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;
/* 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;
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)
{
const rt_uint8_t* font_ptr;
const rt_uint8_t *font_ptr;
register rt_base_t i, j, k;
/* 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 */
for (i=0; i < h; i ++)
for (i = 0; i < h; i ++)
{
for (j=0; j < word_bytes; j++)
for (k=0; k < 8; k++)
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))
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);
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);
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;
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(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)
{
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 */
if (len > 0)
{
@ -200,7 +200,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
}
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)
{
_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);
}
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);
/* set metrics rect */
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;
}
#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/driver.h>
#define GET_PIXEL(dst, x, y, type) \
(type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * ((dst)->bits_per_pixel/8))
#define GET_PIXEL(dst, x, y, type) \
(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)
{
*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)
{
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 */
*c = rtgui_color_from_565(pixel);
/* get pixel from color */
*c = rtgui_color_from_565(pixel);
}
static void _rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{
rt_ubase_t index;
rt_uint16_t pixel;
rt_uint16_t *pixel_ptr;
rt_ubase_t index;
rt_uint16_t pixel;
rt_uint16_t *pixel_ptr;
/* get pixel from color */
pixel = rtgui_color_to_565(*c);
/* get pixel from color */
pixel = rtgui_color_to_565(*c);
/* get pixel pointer in framebuffer */
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
for (index = x1; index < x2; index ++)
{
*pixel_ptr = pixel;
pixel_ptr ++;
}
/* get pixel pointer in framebuffer */
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
for (index = x1; index < x2; index ++)
{
*pixel_ptr = pixel;
pixel_ptr ++;
}
}
static void _rgb565_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
{
rt_uint8_t *dst;
rt_uint16_t pixel;
rt_ubase_t index;
rt_uint8_t *dst;
rt_uint16_t pixel;
rt_ubase_t index;
pixel = rtgui_color_to_565(*c);
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
for (index = y1; index < y2; index ++)
{
*(rt_uint16_t*)dst = pixel;
dst += rtgui_graphic_get_device()->pitch;
}
pixel = rtgui_color_to_565(*c);
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
for (index = y1; index < y2; index ++)
{
*(rt_uint16_t *)dst = pixel;
dst += rtgui_graphic_get_device()->pitch;
}
}
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)
{
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 */
*c = rtgui_color_from_565p(pixel);
/* get pixel from color */
*c = rtgui_color_from_565p(pixel);
}
static void _rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{
rt_ubase_t index;
rt_uint16_t pixel;
rt_uint16_t *pixel_ptr;
rt_ubase_t index;
rt_uint16_t pixel;
rt_uint16_t *pixel_ptr;
/* get pixel from color */
pixel = rtgui_color_to_565p(*c);
/* get pixel from color */
pixel = rtgui_color_to_565p(*c);
/* get pixel pointer in framebuffer */
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
for (index = x1; index < x2; index ++)
{
*pixel_ptr = pixel;
pixel_ptr ++;
}
/* get pixel pointer in framebuffer */
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
for (index = x1; index < x2; index ++)
{
*pixel_ptr = pixel;
pixel_ptr ++;
}
}
static void _rgb565p_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
{
rt_uint8_t *dst;
rt_uint16_t pixel;
rt_ubase_t index;
rt_uint8_t *dst;
rt_uint16_t pixel;
rt_ubase_t index;
pixel = rtgui_color_to_565p(*c);
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
for (index = y1; index < y2; index ++)
{
*(rt_uint16_t*)dst = pixel;
dst += rtgui_graphic_get_device()->pitch;
}
pixel = rtgui_color_to_565p(*c);
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
for (index = y1; index < y2; index ++)
{
*(rt_uint16_t *)dst = pixel;
dst += rtgui_graphic_get_device()->pitch;
}
}
/* draw raw hline */
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);
rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
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));
}
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
{
_rgb565_set_pixel,
_rgb565_get_pixel,
_rgb565_draw_hline,
_rgb565_draw_vline,
framebuffer_draw_raw_hline,
_rgb565_set_pixel,
_rgb565_get_pixel,
_rgb565_draw_hline,
_rgb565_draw_vline,
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_get_pixel,
_rgb565p_draw_hline,
_rgb565p_draw_vline,
framebuffer_draw_raw_hline,
_rgb565p_set_pixel,
_rgb565p_get_pixel,
_rgb565p_draw_hline,
_rgb565p_draw_vline,
framebuffer_draw_raw_hline,
};
#define FRAMEBUFFER (rtgui_graphic_get_device()->framebuffer)
#define FRAMEBUFFER (rtgui_graphic_get_device()->framebuffer)
#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)
{
if (*c == white)
MONO_PIXEL(FRAMEBUFFER, x, y) &= ~(1 << (y%8));
else
MONO_PIXEL(FRAMEBUFFER, x, y) |= (1 << (y%8));
if (*c == white)
MONO_PIXEL(FRAMEBUFFER, x, y) &= ~(1 << (y % 8));
else
MONO_PIXEL(FRAMEBUFFER, x, y) |= (1 << (y % 8));
}
static void _mono_get_pixel(rtgui_color_t *c, int x, int y)
{
if (MONO_PIXEL(FRAMEBUFFER, x, y) & (1 << (y%8)))
*c = black;
else
*c = white;
if (MONO_PIXEL(FRAMEBUFFER, x, y) & (1 << (y % 8)))
*c = black;
else
*c = white;
}
static void _mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
{
rt_ubase_t index;
if (*c == white)
for (index = x1; index < x2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8));
}
else
for (index = x1; index < x2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8));
}
rt_ubase_t index;
if (*c == white)
for (index = x1; index < x2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y % 8));
}
else
for (index = x1; index < x2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y % 8));
}
}
static void _mono_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
{
rt_ubase_t index;
if (*c == white)
for (index = y1; index < y2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, x, index) &= ~(1 << (index%8));
}
else
for (index = y1; index < y2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, x, index) |= (1 << (index%8));
}
rt_ubase_t index;
if (*c == white)
for (index = y1; index < y2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, x, index) &= ~(1 << (index % 8));
}
else
for (index = y1; index < y2; index ++)
{
MONO_PIXEL(FRAMEBUFFER, x, index) |= (1 << (index % 8));
}
}
/* draw raw hline */
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 ++)
{
if (pixels[index/8] && (1 << (index % 8)))
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8));
else
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8));
}
for (index = x1; index < x2; index ++)
{
if (pixels[index / 8] && (1 << (index % 8)))
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y % 8));
else
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_get_pixel,
_mono_draw_hline,
_mono_draw_vline,
_mono_draw_raw_hline,
_mono_set_pixel,
_mono_get_pixel,
_mono_draw_hline,
_mono_draw_vline,
_mono_draw_raw_hline,
};
const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format)
{
switch (pixel_format)
{
case RTGRAPHIC_PIXEL_FORMAT_MONO:
return &_framebuffer_mono_ops;
case RTGRAPHIC_PIXEL_FORMAT_GRAY4:
break;
case RTGRAPHIC_PIXEL_FORMAT_GRAY16:
break;
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
return &_framebuffer_rgb565_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
return &_framebuffer_rgb565p_ops;
}
switch (pixel_format)
{
case RTGRAPHIC_PIXEL_FORMAT_MONO:
return &_framebuffer_mono_ops;
case RTGRAPHIC_PIXEL_FORMAT_GRAY4:
break;
case RTGRAPHIC_PIXEL_FORMAT_GRAY16:
break;
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
return &_framebuffer_rgb565_ops;
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
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 <string.h>
#ifdef _WIN32
#define strncasecmp strnicmp
#endif
#ifdef RTGUI_IMAGE_XPM
#include <rtgui/image_xpm.h>
@ -41,297 +44,303 @@ static rtgui_list_t _rtgui_system_image_list = {RT_NULL};
/* initialize rtgui image system */
void rtgui_system_image_init(void)
{
/* always support HDC image */
rtgui_image_hdc_init();
/* always support HDC image */
rtgui_image_hdc_init();
#ifdef RTGUI_IMAGE_XPM
rtgui_image_xpm_init();
rtgui_image_xpm_init();
#endif
#ifdef RTGUI_IMAGE_BMP
rtgui_image_bmp_init();
rtgui_image_bmp_init();
#endif
#if (defined(RTGUI_IMAGE_JPEG) || defined(RTGUI_IMAGE_TJPGD))
rtgui_image_jpeg_init();
rtgui_image_jpeg_init();
#endif
#ifdef RTGUI_IMAGE_PNG
rtgui_image_png_init();
rtgui_image_png_init();
#endif
#ifdef RTGUI_IMAGE_CONTAINER
/* initialize image container */
rtgui_system_image_container_init(RT_FALSE);
/* initialize image container */
rtgui_system_image_container_init(RT_FALSE);
#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_image_engine *engine;
struct rtgui_list_node *node;
struct rtgui_image_engine *engine;
rtgui_list_foreach(node, &_rtgui_system_image_list)
{
engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
rtgui_list_foreach(node, &_rtgui_system_image_list)
{
engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
if (strncasecmp(engine->name, type, strlen(engine->name)) ==0)
return engine;
}
if (strncasecmp(engine->name, type, strlen(engine->name)) == 0)
return engine;
}
return RT_NULL;
return RT_NULL;
}
#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_image_engine *engine;
const char* ext;
struct rtgui_list_node *node;
struct rtgui_image_engine *engine;
const char *ext;
ext = fn + rt_strlen(fn);
while (ext != fn)
{
if (*ext == '.') { ext ++; break; }
ext --;
}
if (ext == fn) return RT_NULL; /* no ext */
ext = fn + rt_strlen(fn);
while (ext != fn)
{
if (*ext == '.')
{
ext ++;
break;
}
ext --;
}
if (ext == fn) return RT_NULL; /* no ext */
rtgui_list_foreach(node, &_rtgui_system_image_list)
{
engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
if (strncasecmp(engine->name, ext, strlen(engine->name)) == 0)
return engine;
}
rtgui_list_foreach(node, &_rtgui_system_image_list)
{
engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
if (strncasecmp(engine->name, ext, strlen(engine->name)) == 0)
return engine;
}
return RT_NULL;
return RT_NULL;
}
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_image_engine* engine;
struct rtgui_image* image = RT_NULL;
struct rtgui_filerw *filerw;
struct rtgui_image_engine *engine;
struct rtgui_image *image = RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_file(filename, "rb");
if (filerw == RT_NULL) return RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_file(filename, "rb");
if (filerw == RT_NULL) return RT_NULL;
/* get image engine */
engine = rtgui_image_get_engine(type);
if (engine == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* get image engine */
engine = rtgui_image_get_engine(type);
if (engine == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
if (engine->image_check(filerw) == RT_TRUE)
{
image = (struct rtgui_image*) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
if (engine->image_check(filerw) == RT_TRUE)
{
image = (struct rtgui_image *) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
return image;
return image;
}
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_image_engine* engine;
struct rtgui_image* image = RT_NULL;
struct rtgui_filerw *filerw;
struct rtgui_image_engine *engine;
struct rtgui_image *image = RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_file(filename, "rb");
if (filerw == RT_NULL) return RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_file(filename, "rb");
if (filerw == RT_NULL) return RT_NULL;
/* get image engine */
engine = rtgui_image_get_engine_by_filename(filename);
if (engine == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* get image engine */
engine = rtgui_image_get_engine_by_filename(filename);
if (engine == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
if (engine->image_check(filerw) == RT_TRUE)
{
image = (struct rtgui_image*) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
if (engine->image_check(filerw) == RT_TRUE)
{
image = (struct rtgui_image *) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
return image;
return image;
}
RTM_EXPORT(rtgui_image_create);
#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_image_engine* engine;
struct rtgui_image* image = RT_NULL;
struct rtgui_filerw *filerw;
struct rtgui_image_engine *engine;
struct rtgui_image *image = RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_mem(data, length);
if (filerw == RT_NULL) return RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_mem(data, length);
if (filerw == RT_NULL) return RT_NULL;
/* get image engine */
engine = rtgui_image_get_engine(type);
if (engine == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* get image engine */
engine = rtgui_image_get_engine(type);
if (engine == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
if (engine->image_check(filerw) == RT_TRUE)
{
image = (struct rtgui_image*) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
if (engine->image_check(filerw) == RT_TRUE)
{
image = (struct rtgui_image *) rtgui_malloc(sizeof(struct rtgui_image));
if (image == RT_NULL)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
image->palette = RT_NULL;
if (engine->image_load(image, filerw, load) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
return image;
return image;
}
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);
if (image->palette != RT_NULL)
rtgui_free(image->palette);
rtgui_free(image);
image->engine->image_unload(image);
if (image->palette != RT_NULL)
rtgui_free(image->palette);
rtgui_free(image);
}
RTM_EXPORT(rtgui_image_destroy);
/* 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);
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(rect != RT_NULL);
RT_ASSERT(dc != 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)
{
/* use image engine to blit */
image->engine->image_blit(image, dc, rect);
}
if (image != RT_NULL && image->engine != RT_NULL)
{
/* use image engine to blit */
image->engine->image_blit(image, dc, rect);
}
}
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)
{
palette = (struct rtgui_image_palette*) rtgui_malloc(sizeof(struct rtgui_image_palette) +
sizeof(rtgui_color_t) * ncolors);
if (palette != RT_NULL) palette->colors = (rtgui_color_t*)(palette + 1);
}
if (ncolors > 0)
{
palette = (struct rtgui_image_palette *) rtgui_malloc(sizeof(struct rtgui_image_palette) +
sizeof(rtgui_color_t) * ncolors);
if (palette != RT_NULL) palette->colors = (rtgui_color_t *)(palette + 1);
}
return palette;
return palette;
}
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(rect != RT_NULL);
RT_ASSERT(image != RT_NULL);
RT_ASSERT(rect != RT_NULL);
rect->x1 = 0; rect->y1 = 0;
rect->x2 = image->w; rect->y2 = image->h;
rect->x1 = 0;
rect->y1 = 0;
rect->x2 = image->w;
rect->y2 = image->h;
}
RTM_EXPORT(rtgui_image_get_rect);
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)
{
return image->engine->image_zoom(image, scalew, scaleh, mode);
}
return RT_NULL;
}
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)
{
return image->engine->image_zoom(image, scalew, scaleh, mode);
}
return RT_NULL;
}
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)
{
return image->engine->image_rotate(image, angle);
}
return RT_NULL;
if (image != RT_NULL && image->engine != RT_NULL)
{
return image->engine->image_rotate(image, angle);
}
return RT_NULL;
}
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 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 struct rtgui_image* rtgui_image_bmp_zoom(struct rtgui_image* image,
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_zoom(struct rtgui_image *image,
float scalew, float scaleh, rt_uint32_t mode);
static struct rtgui_image *rtgui_image_bmp_rotate(struct rtgui_image *image, float angle);
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_unload,
rtgui_image_bmp_blit,
rtgui_image_bmp_zoom,
rtgui_image_bmp_rotate
rtgui_image_bmp_zoom,
rtgui_image_bmp_rotate
};
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);
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;
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(
(BMP_WORKING_BUFFER_SIZE > bmp->pitch) ? \
bmp->pitch : BMP_WORKING_BUFFER_SIZE);
(BMP_WORKING_BUFFER_SIZE > bmp->pitch) ? \
bmp->pitch : BMP_WORKING_BUFFER_SIZE);
if (wrkBuffer == RT_NULL)
{
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)
{
int image_size = w * h * bits_per_pixel/8;
int header_size = sizeof(struct rtgui_image_bmp_header);
int image_size = w * h * bits_per_pixel / 8;
int header_size = sizeof(struct rtgui_image_bmp_header);
bhr->bfType = 0x4d42; /* BM */
bhr->bfSize = header_size + image_size; /* data size */
bhr->bfReserved1 = 0;
bhr->bfReserved2 = 0;
bhr->bfOffBits = header_size;
bhr->bfType = 0x4d42; /* BM */
bhr->bfSize = header_size + image_size; /* data size */
bhr->bfReserved1 = 0;
bhr->bfReserved2 = 0;
bhr->bfOffBits = header_size;
bhr->biSize = 40; /* sizeof BITMAPINFOHEADER */
bhr->biWidth = w;
bhr->biHeight = h;
bhr->biPlanes = 1;
bhr->biBitCount = bits_per_pixel;
bhr->biCompression = BI_BITFIELDS;
bhr->biSizeImage = image_size;
bhr->biXPelsPerMeter = 0;
bhr->biYPelsPerMeter = 0;
bhr->biClrUsed = 0;
bhr->biClrImportant = 0;
if(bhr->biBitCount == 16 && bhr->biCompression == BI_BITFIELDS)
{
bhr->bfSize += 12;
bhr->bfOffBits += 12;
}
bhr->biSize = 40; /* sizeof BITMAPINFOHEADER */
bhr->biWidth = w;
bhr->biHeight = h;
bhr->biPlanes = 1;
bhr->biBitCount = bits_per_pixel;
bhr->biCompression = BI_BITFIELDS;
bhr->biSizeImage = image_size;
bhr->biXPelsPerMeter = 0;
bhr->biYPelsPerMeter = 0;
bhr->biClrUsed = 0;
bhr->biClrImportant = 0;
if (bhr->biBitCount == 16 && bhr->biCompression == BI_BITFIELDS)
{
bhr->bfSize += 12;
bhr->bfOffBits += 12;
}
}
#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)
{
rt_int32_t len_bak = len;
rt_int32_t len_bak = len;
while(len)
{
if(*count >= WRITE_CLUSTER_SIZE)
{
rtgui_filerw_write(file, dest, WRITE_CLUSTER_SIZE, 1);
*count = 0;
}
*(dest + *count) = *(src + (len_bak-len));
len --;
(*count) ++;
}
while (len)
{
if (*count >= WRITE_CLUSTER_SIZE)
{
rtgui_filerw_write(file, dest, WRITE_CLUSTER_SIZE, 1);
*count = 0;
}
*(dest + *count) = *(src + (len_bak - len));
len --;
(*count) ++;
}
}
/*
@ -892,116 +892,116 @@ void bmp_align_write(struct rtgui_filerw *file, char *dest, char *src, rt_int32_
*/
void screenshot(const char *filename)
{
struct rtgui_filerw *file;
int w, h, i, pitch;
rt_uint16_t *src;
rt_uint32_t mask;
struct rtgui_image_bmp_header bhr;
struct rtgui_graphic_driver *grp = hw_driver;
struct rtgui_filerw *file;
int w, h, i, pitch;
rt_uint16_t *src;
rt_uint32_t mask;
struct rtgui_image_bmp_header bhr;
struct rtgui_graphic_driver *grp = hw_driver;
#ifdef RGB_CONVERT_TO_BGR
int j;
rt_uint16_t *line_buf;
rt_uint16_t color, tmp;
int j;
rt_uint16_t *line_buf;
rt_uint16_t color, tmp;
#endif
char *pixel_buf;
rt_int32_t write_count=0;
char *pixel_buf;
rt_int32_t write_count = 0;
file = rtgui_filerw_create_file(filename, "wb");
if(file == RT_NULL)
{
rt_kprintf("create file failed\n");
return;
}
file = rtgui_filerw_create_file(filename, "wb");
if (file == RT_NULL)
{
rt_kprintf("create file failed\n");
return;
}
w = grp->width;
h = grp->height;
w = grp->width;
h = grp->height;
pitch = w * sizeof(rt_uint16_t);
pitch = w * sizeof(rt_uint16_t);
#ifdef RGB_CONVERT_TO_BGR
line_buf = rt_malloc(pitch);
if(line_buf == RT_NULL)
{
rt_kprintf("no memory!\n");
return;
}
line_buf = rt_malloc(pitch);
if (line_buf == RT_NULL)
{
rt_kprintf("no memory!\n");
return;
}
#endif
pixel_buf = rt_malloc(WRITE_CLUSTER_SIZE);
if(pixel_buf == RT_NULL)
{
rt_kprintf("no memory!\n");
pixel_buf = rt_malloc(WRITE_CLUSTER_SIZE);
if (pixel_buf == RT_NULL)
{
rt_kprintf("no memory!\n");
#ifdef RGB_CONVERT_TO_BGR
rt_free(line_buf);
rt_free(line_buf);
#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,
sizeof(struct rtgui_image_bmp_header), &write_count);
bmp_align_write(file, pixel_buf, (char *)&bhr,
sizeof(struct rtgui_image_bmp_header), &write_count);
if(bhr.biCompression == BI_BITFIELDS)
{
mask = 0xF800; /* Red Mask */
bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count);
mask = 0x07E0; /* Green Mask */
bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count);
mask = 0x001F; /* Blue Mask */
bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count);
}
rtgui_screen_lock(RT_WAITING_FOREVER);
if(grp->framebuffer != RT_NULL)
{
src = (rt_uint16_t*)grp->framebuffer;
src += w * h;
for(i=0; i<h; i++)
{
src -= w;
if (bhr.biCompression == BI_BITFIELDS)
{
mask = 0xF800; /* Red Mask */
bmp_align_write(file, pixel_buf, (char *)&mask, 4, &write_count);
mask = 0x07E0; /* Green Mask */
bmp_align_write(file, pixel_buf, (char *)&mask, 4, &write_count);
mask = 0x001F; /* Blue Mask */
bmp_align_write(file, pixel_buf, (char *)&mask, 4, &write_count);
}
rtgui_screen_lock(RT_WAITING_FOREVER);
if (grp->framebuffer != RT_NULL)
{
src = (rt_uint16_t *)grp->framebuffer;
src += w * h;
for (i = 0; i < h; i++)
{
src -= w;
#ifdef RGB_CONVERT_TO_BGR
for(j=0; j<w; j++)
{
tmp = *(src + j);
color = (tmp & 0x001F)<<11;
color += (tmp & 0x07E0);
color += (tmp & 0xF800)>>11;
for (j = 0; j < w; j++)
{
tmp = *(src + j);
color = (tmp & 0x001F) << 11;
color += (tmp & 0x07E0);
color += (tmp & 0xF800) >> 11;
*(line_buf + i) = color;
}
bmp_align_write(file, pixel_buf, (char*)line_buf, pitch, &write_count);
*(line_buf + i) = color;
}
bmp_align_write(file, pixel_buf, (char *)line_buf, pitch, &write_count);
#else
bmp_align_write(file, pixel_buf, (char*)src, pitch, &write_count);
bmp_align_write(file, pixel_buf, (char *)src, pitch, &write_count);
#endif
}
}
else
{
rtgui_color_t pixel_color;
rt_uint16_t write_color;
int x;
for(i=h-1; i>=0; i--)
{
x = 0;
if(i%10==0)rt_kprintf(">",i);
while(x < w)
{
grp->ops->get_pixel(&pixel_color, x, i);
write_color = rtgui_color_to_565p(pixel_color);
bmp_align_write(file, pixel_buf, (char*)&write_color,
sizeof(rt_uint16_t), &write_count);
x++;
}
}
}
/* write The tail of the last */
if(write_count < WRITE_CLUSTER_SIZE)
rtgui_filerw_write(file, pixel_buf, write_count, 1);
rtgui_screen_unlock();
}
}
else
{
rtgui_color_t pixel_color;
rt_uint16_t write_color;
int x;
for (i = h - 1; i >= 0; i--)
{
x = 0;
if (i % 10 == 0)rt_kprintf(">", i);
while (x < w)
{
grp->ops->get_pixel(&pixel_color, x, i);
write_color = rtgui_color_to_565p(pixel_color);
bmp_align_write(file, pixel_buf, (char *)&write_color,
sizeof(rt_uint16_t), &write_count);
x++;
}
}
}
/* write The tail of the last */
if (write_count < WRITE_CLUSTER_SIZE)
rtgui_filerw_write(file, pixel_buf, write_count, 1);
rtgui_screen_unlock();
#ifdef RGB_CONVERT_TO_BGR
rt_free(line_buf);
rt_free(line_buf);
#endif
rt_free(pixel_buf);
rt_kprintf("bmp create succeed.\n");
rtgui_filerw_close(file);
rt_free(pixel_buf);
rt_kprintf("bmp create succeed.\n");
rtgui_filerw_close(file);
}
#ifdef RT_USING_FINSH
#include <finsh.h>
@ -1012,152 +1012,154 @@ FINSH_FUNCTION_EXPORT(screenshot, usage: screenshot(filename));
* image zoom in, zoom out interface
* Support 16/24 bits format image
*/
static struct rtgui_image* rtgui_image_bmp_zoom(struct rtgui_image* image,
float scalew, float scaleh, rt_uint32_t mode)
{
struct rtgui_image *d_img;
struct rtgui_image_bmp *bmp, *d_bmp;
int bitcount, nbytes, i, j;
int sw, sh, dw, dh;
int dest_buff_size;
int src_line_size, dest_line_size;
char *src_buf;
char *des_buf;
static struct rtgui_image *rtgui_image_bmp_zoom(struct rtgui_image *image,
float scalew, float scaleh, rt_uint32_t mode)
{
struct rtgui_image *d_img;
struct rtgui_image_bmp *bmp, *d_bmp;
int bitcount, nbytes, i, j;
int sw, sh, dw, dh;
int dest_buff_size;
int src_line_size, dest_line_size;
char *src_buf;
char *des_buf;
bmp = (struct rtgui_image_bmp*)image->data;
src_buf = bmp->pixels;
sw = bmp->w;
sh = bmp->h;
bitcount = bmp->bit_per_pixel;
if(bitcount != 16 && bitcount != 24)
{
rt_kprintf("Does not support %d bits format\n", bitcount);
return RT_NULL;
}
nbytes = bitcount / 8;
src_line_size = sw * nbytes;
bmp = (struct rtgui_image_bmp *)image->data;
src_buf = bmp->pixels;
sw = bmp->w;
sh = bmp->h;
bitcount = bmp->bit_per_pixel;
if (bitcount != 16 && bitcount != 24)
{
rt_kprintf("Does not support %d bits format\n", bitcount);
return RT_NULL;
}
nbytes = bitcount / 8;
src_line_size = sw *nbytes;
dw = (int)(sw / scalew);
dh = (int)(sh / scaleh);
dw = (int)(sw / scalew);
dh = (int)(sh / scaleh);
d_img = rt_malloc(sizeof(struct rtgui_image));
if(d_img == RT_NULL)
{
rt_kprintf("Not enough memory allocation IMG!\n");
return RT_NULL;
}
d_img->w = dw;
d_img->h = dh;
d_img->engine = &rtgui_image_bmp_engine;
d_img->palette = RT_NULL;
d_img = rt_malloc(sizeof(struct rtgui_image));
if (d_img == RT_NULL)
{
rt_kprintf("Not enough memory allocation IMG!\n");
return RT_NULL;
}
d_img->w = dw;
d_img->h = dh;
d_img->engine = &rtgui_image_bmp_engine;
d_img->palette = RT_NULL;
/* config dest bmp data */
dest_line_size = ((dw * bitcount + (bitcount-1)) / bitcount) * nbytes;
dest_buff_size = dest_line_size * dh;
d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp));
if(d_bmp == RT_NULL)
{
rt_free(d_img);
rt_kprintf("Not enough memory allocation BMP!\n");
return RT_NULL;
}
/* config dest bmp data */
dest_line_size = ((dw * bitcount + (bitcount - 1)) / bitcount) *nbytes;
dest_buff_size = dest_line_size *dh;
d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp));
if (d_bmp == RT_NULL)
{
rt_free(d_img);
rt_kprintf("Not enough memory allocation BMP!\n");
return RT_NULL;
}
d_bmp->w = dw;
d_bmp->h = dh;
d_bmp->bit_per_pixel = bitcount;
d_bmp->pixel_offset = 54; /* insignificant parameter */
d_bmp->filerw = RT_NULL;
d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */
d_bmp->pitch = d_bmp->w * nbytes;
d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch%4)) : 0);
d_bmp->scale = 0;
d_bmp->pixels = rt_malloc(dest_buff_size);
if(d_bmp->pixels == RT_NULL)
{
rt_free(d_img);
rt_free(d_bmp);
rt_kprintf("Not enough memory allocation BMP data!\n");
return RT_NULL;
}
des_buf = d_bmp->pixels;
d_bmp->w = dw;
d_bmp->h = dh;
d_bmp->bit_per_pixel = bitcount;
d_bmp->pixel_offset = 54; /* insignificant parameter */
d_bmp->filerw = RT_NULL;
d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */
d_bmp->pitch = d_bmp->w *nbytes;
d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch % 4)) : 0);
d_bmp->scale = 0;
d_bmp->pixels = rt_malloc(dest_buff_size);
if (d_bmp->pixels == RT_NULL)
{
rt_free(d_img);
rt_free(d_bmp);
rt_kprintf("Not enough memory allocation BMP data!\n");
return RT_NULL;
}
des_buf = d_bmp->pixels;
if (mode == RTGUI_IMG_ZOOM_NEAREST)
{
for (i = 0; i < dh; i++)
{
int src_th = (int)(scaleh * i + 0.5);
for (j = 0; j < dw; j++)
{
int src_tw = (int)(scalew * j + 0.5);
rt_memcpy (&des_buf[i * dest_line_size] + j * nbytes,
&src_buf[src_th * src_line_size] + src_tw * nbytes,
nbytes);
}
}
}
else if (mode == RTGUI_IMG_ZOOM_BILINEAR)
{
/*
** known: (i,j), (i+1,j), (i,j+1), (i+1,j+1), u, 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)
*/
for (i = 0; i < dh; i++)
{
int y = (int)(scaleh * i);
float u = (float)(scaleh * i - y);
unsigned char c1, c2, c3, c4;
for (j = 0; j < dw; j++)
{
int x = (int)(scalew * j);
float v = (float)(scalew * j - x);
if(bitcount == 16)
{ /* Each color component is calculated separately */
rt_uint32_t cc1,cc2,cc3,cc4;
unsigned char r, g, b;
cc1 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf +
src_line_size * y + nbytes * x ));
cc2 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf +
src_line_size * y + nbytes * (x+1)));
cc3 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf +
src_line_size * (y+1) + nbytes * x ));
cc4 = rtgui_color_from_565p(*(rt_uint16_t*)(src_buf +
src_line_size * (y+1) + nbytes * (x+1)));
if (mode == RTGUI_IMG_ZOOM_NEAREST)
{
for (i = 0; i < dh; i++)
{
int src_th = (int)(scaleh * i + 0.5);
for (j = 0; j < dw; j++)
{
int src_tw = (int)(scalew * j + 0.5);
rt_memcpy(&des_buf[i * dest_line_size] + j * nbytes,
&src_buf[src_th * src_line_size] + src_tw * nbytes,
nbytes);
}
}
}
else if (mode == RTGUI_IMG_ZOOM_BILINEAR)
{
/*
** known: (i,j), (i+1,j), (i,j+1), (i+1,j+1), u, 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)
*/
for (i = 0; i < dh; i++)
{
int y = (int)(scaleh * i);
float u = (float)(scaleh * i - y);
unsigned char c1, c2, c3, c4;
for (j = 0; j < dw; j++)
{
int x = (int)(scalew * j);
float v = (float)(scalew * j - x);
if (bitcount == 16)
{
/* Each color component is calculated separately */
rt_uint32_t cc1, cc2, cc3, cc4;
unsigned char r, g, b;
cc1 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
src_line_size * y + nbytes * x));
cc2 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
src_line_size * y + nbytes * (x + 1)));
cc3 = rtgui_color_from_565p(*(rt_uint16_t *)(src_buf +
src_line_size * (y + 1) + nbytes * x));
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) +
(1-u)*v*(float)RTGUI_RGB_R(cc2) + u*(1-v)*(float)RTGUI_RGB_R(cc3) +
u*v*(float)RTGUI_RGB_R(cc4));
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) +
u*v*(float)RTGUI_RGB_G(cc4));
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) +
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]);
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) +
u * v * (float)RTGUI_RGB_R(cc4));
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) +
u * v * (float)RTGUI_RGB_G(cc4));
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) +
u * v * (float)RTGUI_RGB_B(cc4));
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;
*(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]);
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>
#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)
{
rtgui_point_t rp;
float dx, dy;
dx = p.x - o.x;
dy = p.y - o.y;
rtgui_point_t rp;
float dx, dy;
dx = p.x - o.x;
dy = p.y - o.y;
rp.x = (float)o.x + dx * cosa + dy * sina;
rp.y = (float)o.y + dy * cosa - dx * sina;
rp.x = (float)o.x + dx * cosa + dy * sina;
rp.y = (float)o.y + dy * cosa - dx * sina;
return rp;
return rp;
}
/*
* image rotate interface, rotate direction: clockwise
* 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;
rtgui_point_t o, p, cp;
rtgui_rect_t rect;
struct rtgui_image *d_img;
struct rtgui_image_bmp *bmp, *d_bmp;
int bitcount, nbytes, i, j;
int sw, sh, dw, dh;
int dest_buff_size;
int src_line_size, dest_line_size;
char *src_buf;
char *des_buf;
/* rt_tick_t tick = rt_tick_get(); */
float age, sina, cosa;
rtgui_point_t o, p, cp;
rtgui_rect_t rect;
struct rtgui_image *d_img;
struct rtgui_image_bmp *bmp, *d_bmp;
int bitcount, nbytes, i, j;
int sw, sh, dw, dh;
int dest_buff_size;
int src_line_size, dest_line_size;
char *src_buf;
char *des_buf;
/* rt_tick_t tick = rt_tick_get(); */
bmp = (struct rtgui_image_bmp*)image->data;
src_buf = bmp->pixels;
sw = bmp->w;
sh = bmp->h;
bitcount = bmp->bit_per_pixel;
if(bitcount != 16 && bitcount != 24)
{
rt_kprintf("Does not support %d bits format\n", bitcount);
return RT_NULL;
}
nbytes = bitcount / 8;
src_line_size = sw * nbytes;
/* convert angle to radians */
age = angle * M_PI / 180.0;
sina = sin(age);
cosa = cos(age);
bmp = (struct rtgui_image_bmp *)image->data;
src_buf = bmp->pixels;
sw = bmp->w;
sh = bmp->h;
bitcount = bmp->bit_per_pixel;
if (bitcount != 16 && bitcount != 24)
{
rt_kprintf("Does not support %d bits format\n", bitcount);
return RT_NULL;
}
nbytes = bitcount / 8;
src_line_size = sw *nbytes;
/*
** known: a, b, angle;
** solve: aa = a*abs(cos(angle)) + b*abs(sin(angle));
** solve: bb = b*abs(cos(angle)) + a*abs(sin(angle));
*/
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;
/* convert angle to radians */
age = angle *M_PI / 180.0;
sina = sin(age);
cosa = cos(age);
d_img = rt_malloc(sizeof(struct rtgui_image));
if(d_img == RT_NULL)
{
rt_kprintf("Not enough memory allocation IMG!\n");
return RT_NULL;
}
d_img->w = dw;
d_img->h = dh;
d_img->engine = &rtgui_image_bmp_engine;
d_img->palette = RT_NULL;
/*
** known: a, b, angle;
** solve: aa = a*abs(cos(angle)) + b*abs(sin(angle));
** solve: bb = b*abs(cos(angle)) + a*abs(sin(angle));
*/
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;
/* config dest bmp data */
dest_line_size = ((dw * bitcount + (bitcount-1)) / bitcount) * nbytes;
dest_buff_size = dest_line_size * dh;
d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp));
if(d_bmp == RT_NULL)
{
rt_free(d_img);
rt_kprintf("Not enough memory allocation BMP!\n");
return RT_NULL;
}
d_img = rt_malloc(sizeof(struct rtgui_image));
if (d_img == RT_NULL)
{
rt_kprintf("Not enough memory allocation IMG!\n");
return RT_NULL;
}
d_img->w = dw;
d_img->h = dh;
d_img->engine = &rtgui_image_bmp_engine;
d_img->palette = RT_NULL;
d_bmp->w = dw;
d_bmp->h = dh;
d_bmp->bit_per_pixel = bitcount;
d_bmp->pixel_offset = 54; /* insignificant parameter */
d_bmp->filerw = RT_NULL;
d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */
d_bmp->pitch = d_bmp->w * nbytes;
d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch%4)) : 0);
d_bmp->scale = 0;
d_bmp->pixels = rt_malloc(dest_buff_size);
if(d_bmp->pixels == RT_NULL)
{
rt_free(d_img);
rt_free(d_bmp);
rt_kprintf("Not enough memory allocation BMP data!\n");
return RT_NULL;
}
des_buf = d_bmp->pixels;
/* use white fill empty pixel */
rt_memset(des_buf, 0xFF, dest_buff_size);
o.x = dw>>1;
o.y = dh>>1;
if(bitcount == 16 || bitcount == 24)
{
for (i = 0; i < dh; i++)
{
for (j = 0; j < dw; j++)
{
p.x = j; p.y = i;
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;
/* config dest bmp data */
dest_line_size = ((dw * bitcount + (bitcount - 1)) / bitcount) *nbytes;
dest_buff_size = dest_line_size *dh;
d_bmp = rt_malloc(sizeof(struct rtgui_image_bmp));
if (d_bmp == RT_NULL)
{
rt_free(d_img);
rt_kprintf("Not enough memory allocation BMP!\n");
return RT_NULL;
}
d_bmp->w = dw;
d_bmp->h = dh;
d_bmp->bit_per_pixel = bitcount;
d_bmp->pixel_offset = 54; /* insignificant parameter */
d_bmp->filerw = RT_NULL;
d_bmp->is_loaded = RT_TRUE; /* Don't want to loading */
d_bmp->pitch = d_bmp->w *nbytes;
d_bmp->pad = ((d_bmp->pitch % 4) ? (4 - (d_bmp->pitch % 4)) : 0);
d_bmp->scale = 0;
d_bmp->pixels = rt_malloc(dest_buff_size);
if (d_bmp->pixels == RT_NULL)
{
rt_free(d_img);
rt_free(d_bmp);
rt_kprintf("Not enough memory allocation BMP data!\n");
return RT_NULL;
}
des_buf = d_bmp->pixels;
/* use white fill empty pixel */
rt_memset(des_buf, 0xFF, dest_buff_size);
o.x = dw >> 1;
o.y = dh >> 1;
if (bitcount == 16 || bitcount == 24)
{
for (i = 0; i < dh; i++)
{
for (j = 0; j < dw; j++)
{
p.x = j;
p.y = i;
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()

View File

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

View File

@ -8,158 +8,163 @@
struct rtgui_image_hdc
{
rt_bool_t is_loaded;
rt_bool_t is_loaded;
/* hdc image information */
rt_uint16_t byte_per_pixel;
/* hdc image information */
rt_uint16_t byte_per_pixel;
rt_uint16_t pitch;
rt_size_t pixel_offset;
rt_uint8_t *pixels;
rt_size_t pixel_offset;
rt_uint8_t *pixels;
struct rtgui_filerw* filerw;
const struct rtgui_graphic_driver* hw_driver;
struct rtgui_filerw *filerw;
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_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_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 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 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_hdcmm_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *dst_rect);
struct rtgui_image_engine rtgui_image_hdc_engine =
{
"hdc",
{ RT_NULL },
rtgui_image_hdc_check,
rtgui_image_hdc_load,
rtgui_image_hdc_unload,
rtgui_image_hdc_blit,
RT_NULL,
RT_NULL
"hdc",
{ RT_NULL },
rtgui_image_hdc_check,
rtgui_image_hdc_load,
rtgui_image_hdc_unload,
rtgui_image_hdc_blit,
RT_NULL,
RT_NULL
};
const struct rtgui_image_engine rtgui_image_hdcmm_engine =
{
"hdcmm",
{RT_NULL},
RT_NULL,
RT_NULL,
RT_NULL,
rtgui_image_hdcmm_blit,
RT_NULL,
RT_NULL
"hdcmm",
{RT_NULL},
RT_NULL,
RT_NULL,
RT_NULL,
rtgui_image_hdcmm_blit,
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;
rt_bool_t is_HDC;
rt_uint8_t magic[4];
int start;
rt_bool_t is_HDC;
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 */
rtgui_filerw_seek(file, 0, RTGUI_FILE_SEEK_SET);
/* move to the beginning of file */
rtgui_filerw_seek(file, 0, RTGUI_FILE_SEEK_SET);
is_HDC = RT_FALSE;
if ( rtgui_filerw_read(file, magic, 1, sizeof(magic)) == sizeof(magic) )
{
if ( magic[0] == 'H' &&
magic[1] == 'D' &&
magic[2] == 'C' &&
magic[3] == '\0' )
{
is_HDC = RT_TRUE;
}
}
rtgui_filerw_seek(file, start, RTGUI_FILE_SEEK_SET);
is_HDC = RT_FALSE;
if (rtgui_filerw_read(file, magic, 1, sizeof(magic)) == sizeof(magic))
{
if (magic[0] == 'H' &&
magic[1] == 'D' &&
magic[2] == 'C' &&
magic[3] == '\0')
{
is_HDC = RT_TRUE;
}
}
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];
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;
hdc->hw_driver = rtgui_graphic_driver_get_default();
if (hdc->hw_driver == RT_NULL) { rtgui_free(hdc); return RT_FALSE; }
hdc->hw_driver = rtgui_graphic_driver_get_default();
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 */
image->w = (rt_uint16_t)header[1]; image->h = (rt_uint16_t)header[2];
image->engine = &rtgui_image_hdc_engine;
image->data = hdc;
hdc->filerw = file;
hdc->byte_per_pixel = hdc->hw_driver->bits_per_pixel/8;
hdc->pitch = image->w * hdc->byte_per_pixel;
hdc->pixel_offset = rtgui_filerw_tell(file);
/* set image information */
image->w = (rt_uint16_t)header[1];
image->h = (rt_uint16_t)header[2];
image->engine = &rtgui_image_hdc_engine;
image->data = hdc;
hdc->filerw = file;
hdc->byte_per_pixel = hdc->hw_driver->bits_per_pixel / 8;
hdc->pitch = image->w * hdc->byte_per_pixel;
hdc->pixel_offset = rtgui_filerw_tell(file);
if (load == RT_TRUE)
{
/* load all pixels */
hdc->pixels = rtgui_malloc(image->h * hdc->pitch);
if (hdc->pixels == RT_NULL)
{
if (load == RT_TRUE)
{
/* load all pixels */
hdc->pixels = rtgui_malloc(image->h * hdc->pitch);
if (hdc->pixels == RT_NULL)
{
/* release data */
rtgui_free(hdc);
return RT_FALSE;
}
}
rtgui_filerw_read(hdc->filerw, hdc->pixels, 1, image->h * hdc->pitch);
rtgui_filerw_close(hdc->filerw);
hdc->filerw = RT_NULL;
hdc->pixel_offset = 0;
}
else
{
hdc->pixels = RT_NULL;
}
rtgui_filerw_read(hdc->filerw, hdc->pixels, 1, image->h * hdc->pitch);
rtgui_filerw_close(hdc->filerw);
hdc->filerw = RT_NULL;
hdc->pixel_offset = 0;
}
else
{
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)
{
hdc = (struct rtgui_image_hdc*) image->data;
if (image != RT_NULL)
{
hdc = (struct rtgui_image_hdc *) image->data;
if (hdc->pixels != RT_NULL) rtgui_free(hdc->pixels);
if (hdc->filerw != RT_NULL)
{
rtgui_filerw_close(hdc->filerw);
hdc->filerw = RT_NULL;
}
if (hdc->pixels != RT_NULL) rtgui_free(hdc->pixels);
if (hdc->filerw != RT_NULL)
{
rtgui_filerw_close(hdc->filerw);
hdc->filerw = RT_NULL;
}
/* release data */
rtgui_free(hdc);
}
/* release data */
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;
struct rtgui_image_hdc* hdc;
rt_uint16_t y, w, h;
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 */
if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
/* this dc is not visible */
if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
hdc = (struct rtgui_image_hdc*) image->data;
RT_ASSERT(hdc != RT_NULL);
hdc = (struct rtgui_image_hdc *) image->data;
RT_ASSERT(hdc != RT_NULL);
/* the minimum rect */
/* the minimum rect */
if (image->w < rtgui_rect_width(*dst_rect)) w = image->w;
else w = rtgui_rect_width(*dst_rect);
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)
{
rt_uint8_t* ptr;
rt_uint8_t *ptr;
/* get pixel pointer */
ptr = hdc->pixels;
/* get pixel pointer */
ptr = hdc->pixels;
for (y = 0; y < h; y ++)
{
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
ptr += hdc->pitch;
}
for (y = 0; y < h; y ++)
{
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
ptr += hdc->pitch;
}
}
else
{
rt_uint8_t* ptr;
ptr = rtgui_malloc(hdc->pitch);
if (ptr == RT_NULL) return; /* no memory */
rt_uint8_t *ptr;
ptr = rtgui_malloc(hdc->pitch);
if (ptr == RT_NULL) return; /* no memory */
/* seek to the begin of pixel data */
rtgui_filerw_seek(hdc->filerw, hdc->pixel_offset, RTGUI_FILE_SEEK_SET);
/* seek to the begin of pixel data */
rtgui_filerw_seek(hdc->filerw, hdc->pixel_offset, RTGUI_FILE_SEEK_SET);
for (y = 0; y < h; y ++)
{
/* read pixel data */
if (rtgui_filerw_read(hdc->filerw, ptr, 1, hdc->pitch) != hdc->pitch)
break; /* read data failed */
for (y = 0; y < h; y ++)
{
/* read pixel data */
if (rtgui_filerw_read(hdc->filerw, ptr, 1, hdc->pitch) != hdc->pitch)
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_uint16_t y, w, h;
struct rtgui_image_hdcmm* hdc;
rt_uint8_t *ptr;
rt_uint16_t y, w, h;
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 */
if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
/* this dc is not visible */
if (rtgui_dc_get_visible(dc) != RT_TRUE) return;
hdc = (struct rtgui_image_hdcmm*) image;
RT_ASSERT(hdc != RT_NULL);
hdc = (struct rtgui_image_hdcmm *) image;
RT_ASSERT(hdc != RT_NULL);
/* the minimum rect */
/* the minimum rect */
if (image->w < rtgui_rect_width(*dst_rect)) w = image->w;
else w = rtgui_rect_width(*dst_rect);
if (image->h < rtgui_rect_height(*dst_rect)) h = image->h;
else h = rtgui_rect_height(*dst_rect);
/* get pixel pointer */
ptr = hdc->pixels;
/* get pixel pointer */
ptr = hdc->pixels;
for (y = 0; y < h; y ++)
{
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
ptr += hdc->pitch;
}
for (y = 0; y < h; y ++)
{
dc->engine->blit_line(dc, dst_rect->x1, dst_rect->x1 + w, dst_rect->y1 + y, ptr);
ptr += hdc->pitch;
}
}
void rtgui_image_hdc_init()
{
/* register hdc on image system */
rtgui_image_register_engine(&rtgui_image_hdc_engine);
/* register hdc on image system */
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_uint8_t *src, *dst;
#ifdef RTGUI_DEBUG_TJPGD
/* Put progress indicator */
if (rect->left == 0)
{
rt_kprintf("\r%lu%%", (rect->top << jpeg->scale) * 100UL / jdec->height);
}
#endif
/* Copy the decompressed RGB rectanglar to the frame buffer */
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;
}
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: check OK\n");
#endif
}
while (0);
@ -809,7 +813,9 @@ static rt_bool_t rtgui_image_jpeg_load(struct rtgui_image *image, struct rtgui_f
}
break;
}
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: prepare OK\n");
#endif
image->w = (rt_uint16_t)jpeg->tjpgd.width >> 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);
jpeg->is_loaded = RT_TRUE;
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: load to RAM\n");
#endif
}
res = RT_TRUE;
}
@ -886,7 +894,9 @@ static void rtgui_image_jpeg_unload(struct rtgui_image *image)
}
rt_free(jpeg);
}
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: unload\n");
#endif
}
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;
}
#ifdef RTGUI_DEBUG_TJPGD
rt_kprintf("TJPGD: load to display\n");
#endif
}
else
{

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -6,198 +6,198 @@
#include <rtgui/rtgui_system.h>
#include <rtgui/driver.h>
#define gfx_device (rtgui_graphic_get_device()->device)
#define gfx_device_ops rt_graphix_ops(gfx_device)
#define gfx_device (rtgui_graphic_get_device()->device)
#define gfx_device_ops rt_graphix_ops(gfx_device)
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);
gfx_device_ops->set_pixel((char*)&pixel, x, y);
pixel = rtgui_color_to_mono(*c);
gfx_device_ops->set_pixel((char *)&pixel, x, 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);
gfx_device_ops->set_pixel((char*)&pixel, x, y);
pixel = rtgui_color_to_565p(*c);
gfx_device_ops->set_pixel((char *)&pixel, x, 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);
gfx_device_ops->set_pixel((char*)&pixel, x, y);
pixel = rtgui_color_to_565(*c);
gfx_device_ops->set_pixel((char *)&pixel, x, 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);
gfx_device_ops->set_pixel((char*)&pixel, x, y);
pixel = rtgui_color_to_888(*c);
gfx_device_ops->set_pixel((char *)&pixel, x, 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);
*c = rtgui_color_from_mono(pixel);
gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_mono(pixel);
}
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);
*c = rtgui_color_from_565p(pixel);
gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_565p(pixel);
}
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);
*c = rtgui_color_from_565(pixel);
gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_565(pixel);
}
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);
*c = rtgui_color_from_888(pixel);
gfx_device_ops->get_pixel((char *)&pixel, x, y);
*c = rtgui_color_from_888(pixel);
}
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);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
pixel = rtgui_color_to_mono(*c);
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)
{
rt_uint16_t pixel;
rt_uint16_t pixel;
pixel = rtgui_color_to_565p(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
pixel = rtgui_color_to_565p(*c);
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)
{
rt_uint16_t pixel;
rt_uint16_t pixel;
pixel = rtgui_color_to_565(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
pixel = rtgui_color_to_565(*c);
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)
{
rt_uint32_t pixel;
rt_uint32_t pixel;
pixel = rtgui_color_to_888(*c);
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
pixel = rtgui_color_to_888(*c);
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)
{
rt_uint8_t pixel;
rt_uint8_t pixel;
pixel = rtgui_color_to_mono(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
pixel = rtgui_color_to_mono(*c);
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)
{
rt_uint16_t pixel;
rt_uint16_t pixel;
pixel = rtgui_color_to_565p(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
pixel = rtgui_color_to_565p(*c);
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)
{
rt_uint16_t pixel;
rt_uint16_t pixel;
pixel = rtgui_color_to_565(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
pixel = rtgui_color_to_565(*c);
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)
{
rt_uint32_t pixel;
rt_uint32_t pixel;
pixel = rtgui_color_to_888(*c);
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
pixel = rtgui_color_to_888(*c);
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)
{
if (x2 > x1)
gfx_device_ops->blit_line((char*)pixels, x1, y, (x2 - x1));
else
gfx_device_ops->blit_line((char*)pixels, x2, y, (x1 - x2));
if (x2 > x1)
gfx_device_ops->blit_line((char *)pixels, x1, y, (x2 - x1));
else
gfx_device_ops->blit_line((char *)pixels, x2, y, (x1 - x2));
}
/* pixel device */
const struct rtgui_graphic_driver_ops _pixel_mono_ops =
{
_pixel_mono_set_pixel,
_pixel_mono_get_pixel,
_pixel_mono_draw_hline,
_pixel_mono_draw_vline,
_pixel_draw_raw_hline,
_pixel_mono_set_pixel,
_pixel_mono_get_pixel,
_pixel_mono_draw_hline,
_pixel_mono_draw_vline,
_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_get_pixel,
_pixel_rgb565p_draw_hline,
_pixel_rgb565p_draw_vline,
_pixel_draw_raw_hline,
_pixel_rgb565p_set_pixel,
_pixel_rgb565p_get_pixel,
_pixel_rgb565p_draw_hline,
_pixel_rgb565p_draw_vline,
_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_get_pixel,
_pixel_rgb565_draw_hline,
_pixel_rgb565_draw_vline,
_pixel_draw_raw_hline,
_pixel_rgb565_set_pixel,
_pixel_rgb565_get_pixel,
_pixel_rgb565_draw_hline,
_pixel_rgb565_draw_vline,
_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_get_pixel,
_pixel_rgb888_draw_hline,
_pixel_rgb888_draw_vline,
_pixel_draw_raw_hline,
_pixel_rgb888_set_pixel,
_pixel_rgb888_get_pixel,
_pixel_rgb888_draw_hline,
_pixel_rgb888_draw_vline,
_pixel_draw_raw_hline,
};
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:
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)
{
/* set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(app),
rtgui_app_event_handler);
/* set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(app),
rtgui_app_event_handler);
app->name = RT_NULL;
app->icon = RT_NULL;
/* set EXITED so we can destroy an application that just created */
app->state_flag = RTGUI_APP_FLAG_EXITED;
app->ref_count = 0;
app->exit_code = 0;
app->tid = RT_NULL;
app->server = RT_NULL;
app->mq = RT_NULL;
app->modal_object = RT_NULL;
app->main_object = RT_NULL;
app->on_idle = RT_NULL;
app->name = RT_NULL;
app->icon = RT_NULL;
/* set EXITED so we can destroy an application that just created */
app->state_flag = RTGUI_APP_FLAG_EXITED;
app->ref_count = 0;
app->exit_code = 0;
app->tid = RT_NULL;
app->server = RT_NULL;
app->mq = RT_NULL;
app->modal_object = RT_NULL;
app->main_object = RT_NULL;
app->on_idle = RT_NULL;
}
static void _rtgui_app_destructor(struct rtgui_app *app)
{
RT_ASSERT(app != RT_NULL);
RT_ASSERT(app != RT_NULL);
rt_free(app->name);
app->name = RT_NULL;
rt_free(app->name);
app->name = RT_NULL;
}
DEFINE_CLASS_TYPE(application, "application",
RTGUI_OBJECT_TYPE,
_rtgui_app_constructor,
_rtgui_app_destructor,
sizeof(struct rtgui_app));
RTGUI_OBJECT_TYPE,
_rtgui_app_constructor,
_rtgui_app_destructor,
sizeof(struct rtgui_app));
struct rtgui_app* rtgui_app_create(
rt_thread_t tid,
const char *title)
struct rtgui_app *rtgui_app_create(
rt_thread_t tid,
const char *title)
{
rt_thread_t srv_tid;
struct rtgui_app *app;
struct rtgui_event_application event;
rt_thread_t srv_tid;
struct rtgui_app *app;
struct rtgui_event_application event;
RT_ASSERT(tid != RT_NULL);
RT_ASSERT(title != RT_NULL);
RT_ASSERT(tid != RT_NULL);
RT_ASSERT(title != RT_NULL);
/* create application */
app = RTGUI_APP(rtgui_object_create(RTGUI_APP_TYPE));
if (app == RT_NULL)
return RT_NULL;
/* create application */
app = RTGUI_APP(rtgui_object_create(RTGUI_APP_TYPE));
if (app == RT_NULL)
return RT_NULL;
/* one thread only can create one rtgui application */
RT_ASSERT(tid->user_data == 0);
app->tid = tid;
/* set user thread */
tid->user_data = (rt_uint32_t)app;
/* one thread only can create one rtgui application */
RT_ASSERT(tid->user_data == 0);
app->tid = tid;
/* set user thread */
tid->user_data = (rt_uint32_t)app;
app->mq = rt_mq_create("rtgui", sizeof(union rtgui_event_generic), 32, RT_IPC_FLAG_FIFO);
if (app->mq == RT_NULL)
{
rt_kprintf("create msgq failed.\n");
goto __mq_err;
}
app->mq = rt_mq_create("rtgui", sizeof(union rtgui_event_generic), 32, RT_IPC_FLAG_FIFO);
if (app->mq == RT_NULL)
{
rt_kprintf("create msgq failed.\n");
goto __mq_err;
}
/* set application title */
app->name = (unsigned char*)rt_strdup((char*)title);
if (app->name == RT_NULL)
goto __err;
/* set application title */
app->name = (unsigned char *)rt_strdup((char *)title);
if (app->name == RT_NULL)
goto __err;
/* send a message to notify rtgui server */
srv_tid = rtgui_get_server();
if (srv_tid == RT_NULL)
{
rt_kprintf("gui server is not running.\n");
goto __err;
}
/* send a message to notify rtgui server */
srv_tid = rtgui_get_server();
if (srv_tid == RT_NULL)
{
rt_kprintf("gui server is not running.\n");
goto __err;
}
/* create the rtgui server application */
if (srv_tid == rt_thread_self())
return app;
/* create the rtgui server application */
if (srv_tid == rt_thread_self())
return app;
RTGUI_EVENT_APP_CREATE_INIT(&event);
event.app = app;
RTGUI_EVENT_APP_CREATE_INIT(&event);
event.app = app;
/* notify rtgui server to one application has been created */
if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) == RT_EOK)
{
return app;
}
/* notify rtgui server to one application has been created */
if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) == RT_EOK)
{
return app;
}
__err:
__mq_err:
rtgui_object_destroy(RTGUI_OBJECT(app));
tid->user_data = 0;
return RT_NULL;
rtgui_object_destroy(RTGUI_OBJECT(app));
tid->user_data = 0;
return RT_NULL;
}
RTM_EXPORT(rtgui_app_create);
#define _rtgui_application_check(app) \
do { \
RT_ASSERT(app != RT_NULL); \
RT_ASSERT(app->tid != RT_NULL); \
RT_ASSERT(app->tid->user_data != 0); \
RT_ASSERT(app->mq != RT_NULL); \
} while (0)
#define _rtgui_application_check(app) \
do { \
RT_ASSERT(app != RT_NULL); \
RT_ASSERT(app->tid != RT_NULL); \
RT_ASSERT(app->tid->user_data != 0); \
RT_ASSERT(app->mq != RT_NULL); \
} while (0)
void rtgui_app_destroy(struct rtgui_app *app)
{
rt_thread_t srv_tid;
rt_thread_t srv_tid;
_rtgui_application_check(app);
if (!(app->state_flag & RTGUI_APP_FLAG_EXITED))
{
rt_kprintf("cannot destroy a running application: %s.\n",
app->name);
return;
}
if (!(app->state_flag & RTGUI_APP_FLAG_EXITED))
{
rt_kprintf("cannot destroy a running application: %s.\n",
app->name);
return;
}
/* send a message to notify rtgui server */
srv_tid = rtgui_get_server();
if (srv_tid != rt_thread_self()) /* must not the server thread */
{
struct rtgui_event_application event;
RTGUI_EVENT_APP_DESTROY_INIT(&event);
event.app = app;
/* send a message to notify rtgui server */
srv_tid = rtgui_get_server();
if (srv_tid != rt_thread_self()) /* must not the server thread */
{
struct rtgui_event_application event;
RTGUI_EVENT_APP_DESTROY_INIT(&event);
event.app = app;
if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) != RT_EOK)
{
rt_kprintf("destroy an application in server failed\n");
return ;
}
}
if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) != RT_EOK)
{
rt_kprintf("destroy an application in server failed\n");
return ;
}
}
app->tid->user_data = 0;
rt_mq_delete(app->mq);
rtgui_object_destroy(RTGUI_OBJECT(app));
app->tid->user_data = 0;
rt_mq_delete(app->mq);
rtgui_object_destroy(RTGUI_OBJECT(app));
}
RTM_EXPORT(rtgui_app_destroy);
struct rtgui_app* rtgui_app_self(void)
struct rtgui_app *rtgui_app_self(void)
{
struct rtgui_app *app;
rt_thread_t self;
struct rtgui_app *app;
rt_thread_t self;
/* get current thread */
self = rt_thread_self();
app = (struct rtgui_app*)(self->user_data);
/* get current thread */
self = rt_thread_self();
app = (struct rtgui_app *)(self->user_data);
return app;
return app;
}
RTM_EXPORT(rtgui_app_self);
void rtgui_app_set_onidle(rtgui_idle_func_t onidle)
{
struct rtgui_app *app;
struct rtgui_app *app;
app = rtgui_app_self();
if (app != RT_NULL)
app->on_idle = onidle;
app = rtgui_app_self();
if (app != RT_NULL)
app->on_idle = onidle;
}
RTM_EXPORT(rtgui_app_set_onidle);
rtgui_idle_func_t rtgui_app_get_onidle(void)
{
struct rtgui_app *app;
struct rtgui_app *app;
app = rtgui_app_self();
if (app != RT_NULL)
return app->on_idle;
else
return RT_NULL;
app = rtgui_app_self();
if (app != RT_NULL)
return app->on_idle;
else
return RT_NULL;
}
RTM_EXPORT(rtgui_app_get_onidle);
rt_inline rt_bool_t _rtgui_application_dest_handle(
struct rtgui_app *app,
struct rtgui_event *event)
struct rtgui_app *app,
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->event_handler != RT_NULL)
return dest_object->event_handler(RTGUI_OBJECT(dest_object), event);
else
return RT_FALSE;
}
else
{
rt_kprintf("RTGUI ERROR:server sent a event(%d) without wid\n", event->type);
return RT_FALSE;
}
if (dest_object != RT_NULL)
{
if (dest_object->event_handler != RT_NULL)
return dest_object->event_handler(RTGUI_OBJECT(dest_object), event);
else
return RT_FALSE;
}
else
{
rt_kprintf("RTGUI ERROR:server sent a event(%d) without wid\n", event->type);
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(event != RT_NULL);
RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL);
app = RTGUI_APP(object);
app = RTGUI_APP(object);
switch (event->type)
{
case RTGUI_EVENT_PAINT:
case RTGUI_EVENT_CLIP_INFO:
case RTGUI_EVENT_WIN_ACTIVATE:
case RTGUI_EVENT_WIN_DEACTIVATE:
case RTGUI_EVENT_WIN_CLOSE:
case RTGUI_EVENT_WIN_MOVE:
case RTGUI_EVENT_KBD:
_rtgui_application_dest_handle(app, event);
break;
switch (event->type)
{
case RTGUI_EVENT_PAINT:
case RTGUI_EVENT_CLIP_INFO:
case RTGUI_EVENT_WIN_ACTIVATE:
case RTGUI_EVENT_WIN_DEACTIVATE:
case RTGUI_EVENT_WIN_CLOSE:
case RTGUI_EVENT_WIN_MOVE:
case RTGUI_EVENT_KBD:
_rtgui_application_dest_handle(app, event);
break;
case RTGUI_EVENT_APP_ACTIVATE:
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:
case RTGUI_EVENT_APP_ACTIVATE:
if (app->main_object != RT_NULL)
{
struct rtgui_event_command *ecmd = (struct rtgui_event_command*)event;
if (ecmd->wid != RT_NULL)
return _rtgui_application_dest_handle(app, event);
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;
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_err_t result;
rt_uint16_t current_ref;
struct rtgui_event *event;
rt_err_t result;
rt_uint16_t current_ref;
struct rtgui_event *event;
_rtgui_application_check(app);
_rtgui_application_check(app);
/* point to event buffer */
event = (struct rtgui_event*)app->event_buffer;
/* point to 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)
{
RT_ASSERT(current_ref == app->ref_count);
while (current_ref <= app->ref_count)
{
RT_ASSERT(current_ref == app->ref_count);
if (app->on_idle != RT_NULL)
{
result = rtgui_recv_nosuspend(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
else if (result == -RT_ETIMEOUT)
app->on_idle(RTGUI_OBJECT(app), RT_NULL);
}
else
{
result = rtgui_recv(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
}
}
if (app->on_idle != RT_NULL)
{
result = rtgui_recv_nosuspend(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
else if (result == -RT_ETIMEOUT)
app->on_idle(RTGUI_OBJECT(app), RT_NULL);
}
else
{
result = rtgui_recv(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
}
}
}
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)
app->state_flag |= RTGUI_APP_FLAG_EXITED;
if (app->ref_count == 0)
app->state_flag |= RTGUI_APP_FLAG_EXITED;
return app->exit_code;
return app->exit_code;
}
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->exit_code = code;
--app->ref_count;
app->exit_code = code;
}
RTM_EXPORT(rtgui_app_exit);
void rtgui_app_activate(struct rtgui_app *app)
{
struct rtgui_event_application event;
struct rtgui_event_application event;
RTGUI_EVENT_APP_ACTIVATE_INIT(&event);
event.app = app;
RTGUI_EVENT_APP_ACTIVATE_INIT(&event);
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);
void rtgui_app_close(struct rtgui_app *app)
{
struct rtgui_event_application event;
struct rtgui_event_application event;
RTGUI_EVENT_APP_DESTROY_INIT(&event);
event.app = app;
RTGUI_EVENT_APP_DESTROY_INIT(&event);
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);
@ -380,35 +389,35 @@ RTM_EXPORT(rtgui_app_close);
*/
rt_err_t rtgui_app_set_as_wm(void)
{
rt_thread_t srv_tid;
struct rtgui_event_set_wm event;
struct rtgui_app* app;
rt_thread_t srv_tid;
struct rtgui_event_set_wm event;
struct rtgui_app *app;
srv_tid = rtgui_get_server();
app = rtgui_app_self();
if (app != RT_NULL && srv_tid != RT_NULL)
{
/* notify rtgui server, this is a window manager */
RTGUI_EVENT_SET_WM_INIT(&event);
event.app = app;
srv_tid = rtgui_get_server();
app = rtgui_app_self();
if (app != RT_NULL && srv_tid != RT_NULL)
{
/* notify rtgui server, this is a window manager */
RTGUI_EVENT_SET_WM_INIT(&event);
event.app = app;
rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event));
return RT_EOK;
}
rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event));
return RT_EOK;
}
return RT_ERROR;
return RT_ERROR;
}
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();
if (app != RT_NULL)
{
app->main_object = RTGUI_OBJECT(win);
}
app = rtgui_app_self();
if (app != RT_NULL)
{
app->main_object = RTGUI_OBJECT(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)
{
if (!object)
return;
if (!object)
return;
object->flag = RTGUI_OBJECT_FLAG_NONE;
object->flag = RTGUI_OBJECT_FLAG_NONE;
}
/* Destroys the object */
static void _rtgui_object_destructor(rtgui_object_t *object)
{
/* nothing */
/* nothing */
}
DEFINE_CLASS_TYPE(object, "object",
RT_NULL,
_rtgui_object_constructor,
_rtgui_object_destructor,
sizeof(struct rtgui_object));
RT_NULL,
_rtgui_object_constructor,
_rtgui_object_destructor,
sizeof(struct rtgui_object));
RTM_EXPORT(_rtgui_object);
void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object)
{
/* first call parent's type */
if (type->parent != RT_NULL)
rtgui_type_object_construct(type->parent, object);
/* first call parent's type */
if (type->parent != RT_NULL)
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)
{
const rtgui_type_t *t;
t = type;
while (t)
{
if (t->destructor) t->destructor(object);
t = t->parent;
}
const rtgui_type_t *t;
t = type;
while (t)
{
if (t->destructor) t->destructor(object);
t = t->parent;
}
}
rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent)
{
const rtgui_type_t *t;
t = type;
while (t)
{
if (t == parent) return RT_TRUE;
t = t->parent;
}
const rtgui_type_t *t;
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)
{
return type->parent;
return type->parent;
}
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
struct rtgui_object_information
{
rt_uint32_t objs_number;
rt_uint32_t allocated_size;
rt_uint32_t max_allocated;
rt_uint32_t objs_number;
rt_uint32_t allocated_size;
rt_uint32_t max_allocated;
};
struct rtgui_object_information obj_info = {0, 0, 0};
#endif
/**
* @brief Creates a new object: it calls the corresponding constructors (from the constructor of the base class to the
* constructor of the more derived class) and then sets the values of the given properties
* @brief Creates a new object: it calls the corresponding constructors
* (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
* @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 *new_object;
rtgui_object_t *new_object;
if (!object_type)
return RT_NULL;
if (!object_type)
return RT_NULL;
new_object = rtgui_malloc(object_type->size);
if (new_object == RT_NULL) return RT_NULL;
new_object = rtgui_malloc(object_type->size);
if (new_object == RT_NULL) return RT_NULL;
#ifdef RTGUI_OBJECT_TRACE
obj_info.objs_number ++;
obj_info.allocated_size += object_type->size;
if (obj_info.allocated_size > obj_info.max_allocated)
obj_info.max_allocated = obj_info.allocated_size;
obj_info.objs_number ++;
obj_info.allocated_size += object_type->size;
if (obj_info.allocated_size > obj_info.max_allocated)
obj_info.max_allocated = obj_info.allocated_size;
#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);
/**
* @brief Destroys the object: it first sets the weak-pointers to RT_NULL, emits the "destroyed" signal, and then
* 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).
* @brief Destroys the object.
*
* The object destructors will be called in inherited type order.
*
* @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)
{
if (!object || object->flag & RTGUI_OBJECT_FLAG_STATIC)
if (!object || object->flag & RTGUI_OBJECT_FLAG_STATIC)
return;
#ifdef RTGUI_OBJECT_TRACE
obj_info.objs_number --;
obj_info.allocated_size -= object->type->size;
obj_info.objs_number --;
obj_info.allocated_size -= object->type->size;
#endif
/* call destructor */
RT_ASSERT(object->type != RT_NULL);
rtgui_type_destructors_call(object->type, object);
/* call destructor */
RT_ASSERT(object->type != RT_NULL);
rtgui_type_destructors_call(object->type, object);
/* release object */
rtgui_free(object);
/* release object */
rtgui_free(object);
}
RTM_EXPORT(rtgui_object_destroy);
/**
* @brief Checks if @a object can be cast to @a type.
* If @a object doesn't inherit from @a type, a warning is displayed in the console but the object is returned anyway.
* @brief Checks if the object can be cast to the specified type.
*
* 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 type the type to which we cast 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))
{
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);
/**
* @brief Gets the type of the 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)
{
if (!object) return RT_NULL;
if (!object) return RT_NULL;
return object->type;
return object->type;
}
RTM_EXPORT(rtgui_object_object_type_get);
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);
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);

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

View File

@ -3,7 +3,7 @@
#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_inv(int dst_bpp, int src_bpp);

View File

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

View File

@ -21,91 +21,91 @@
enum rtgui_dc_type
{
RTGUI_DC_HW,
RTGUI_DC_CLIENT,
RTGUI_DC_BUFFER,
RTGUI_DC_HW,
RTGUI_DC_CLIENT,
RTGUI_DC_BUFFER,
};
struct rtgui_dc_engine
{
/* interface */
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_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 (*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 )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
/* interface */
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_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 (*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)(struct rtgui_dc *dc, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect);
/* set and get graphic context */
void (*set_gc)(struct rtgui_dc* dc, struct rtgui_gc *gc);
struct rtgui_gc* (*get_gc)(struct rtgui_dc* dc);
/* set and get graphic context */
void (*set_gc)(struct rtgui_dc *dc, struct rtgui_gc *gc);
struct rtgui_gc *(*get_gc)(struct rtgui_dc *dc);
/* get dc visible */
rt_bool_t (*get_visible)(struct rtgui_dc* dc);
/* get dc visible */
rt_bool_t (*get_visible)(struct rtgui_dc *dc);
/* get dc rect */
void (*get_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect);
/* get dc 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 */
struct rtgui_dc
{
/* type of device context */
rt_uint32_t type;
/* type of device context */
rt_uint32_t type;
/* dc engine */
const struct rtgui_dc_engine* engine;
/* dc engine */
const struct rtgui_dc_engine *engine;
};
#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_FONT(dc) (rtgui_dc_get_gc(dc)->font)
#define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign)
#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_FONT(dc) (rtgui_dc_get_gc(dc)->font)
#define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign)
/* create a buffer dc */
struct rtgui_dc* rtgui_dc_buffer_create(int width, int height);
rt_uint8_t* rtgui_dc_buffer_get_pixel(struct rtgui_dc* dc);
struct rtgui_dc *rtgui_dc_buffer_create(int width, int height);
rt_uint8_t *rtgui_dc_buffer_get_pixel(struct rtgui_dc *dc);
/* begin and end a drawing */
struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner);
void rtgui_dc_end_drawing(struct rtgui_dc* dc);
struct rtgui_dc *rtgui_dc_begin_drawing(rtgui_widget_t *owner);
void rtgui_dc_end_drawing(struct rtgui_dc *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_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_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_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_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_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_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_stroke (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect,
rtgui_color_t color_stroke, rtgui_color_t color_core);
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,
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_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_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_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_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_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect);
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_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_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_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_fill_circle(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t 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_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);
/*
@ -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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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

View File

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

View File

@ -18,7 +18,7 @@
#include <rtgui/dc.h>
/* 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

View File

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

View File

@ -19,49 +19,49 @@
struct rtgui_graphic_driver_ops
{
/* set and get pixel in (x, y) */
void (*set_pixel) (rtgui_color_t *c, int x, int y);
void (*get_pixel) (rtgui_color_t *c, int x, int y);
/* set and get pixel in (x, y) */
void (*set_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_vline)(rtgui_color_t *c, int x , int y1, int y2);
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);
/* draw raw hline */
void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
/* draw raw hline */
void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
};
struct rtgui_graphic_driver
{
/* pixel format and byte per pixel */
rt_uint8_t pixel_format;
rt_uint8_t bits_per_pixel;
rt_uint16_t pitch;
/* pixel format and byte per pixel */
rt_uint8_t pixel_format;
rt_uint8_t bits_per_pixel;
rt_uint16_t pitch;
/* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
/* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
/* framebuffer address and ops */
volatile rt_uint8_t *framebuffer;
rt_device_t device;
const struct rtgui_graphic_driver_ops *ops;
/* framebuffer address and ops */
volatile rt_uint8_t *framebuffer;
rt_device_t device;
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_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_default_framebuffer(void);
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_default_framebuffer(void);
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;
return &_driver;
extern struct rtgui_graphic_driver _driver;
return &_driver;
}
#endif

View File

@ -21,87 +21,89 @@
* rtgui_event_generic */
enum _rtgui_event_type
{
/* applications event */
RTGUI_EVENT_APP_CREATE, /* create an application */
RTGUI_EVENT_APP_DESTROY, /* destroy an application */
RTGUI_EVENT_APP_ACTIVATE, /* activate an application */
/* applications event */
RTGUI_EVENT_APP_CREATE, /* create an application */
RTGUI_EVENT_APP_DESTROY, /* destroy an application */
RTGUI_EVENT_APP_ACTIVATE, /* activate an application */
/* window event */
RTGUI_EVENT_WIN_CREATE, /* create a window */
RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
RTGUI_EVENT_WIN_SHOW, /* show a window */
RTGUI_EVENT_WIN_HIDE, /* hide a window */
RTGUI_EVENT_WIN_ACTIVATE, /* activate a window */
RTGUI_EVENT_WIN_DEACTIVATE, /* deactivate a window */
RTGUI_EVENT_WIN_CLOSE, /* close a window */
RTGUI_EVENT_WIN_MOVE, /* move a window */
RTGUI_EVENT_WIN_RESIZE, /* resize a window */
RTGUI_EVENT_WIN_MODAL_ENTER, /* the window is entering modal mode.
This event should be sent after the
window got setup and before the
application got setup. */
/* window event */
RTGUI_EVENT_WIN_CREATE, /* create a window */
RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
RTGUI_EVENT_WIN_SHOW, /* show a window */
RTGUI_EVENT_WIN_HIDE, /* hide a window */
RTGUI_EVENT_WIN_ACTIVATE, /* activate a window */
RTGUI_EVENT_WIN_DEACTIVATE, /* deactivate a window */
RTGUI_EVENT_WIN_CLOSE, /* close a window */
RTGUI_EVENT_WIN_MOVE, /* move a window */
RTGUI_EVENT_WIN_RESIZE, /* resize a window */
RTGUI_EVENT_WIN_MODAL_ENTER, /* the window is entering modal mode.
This event should be sent after the
window got setup and before the
application got setup. */
/* WM event */
RTGUI_EVENT_SET_WM, /* set window manager */
/* WM event */
RTGUI_EVENT_SET_WM, /* set window manager */
RTGUI_EVENT_UPDATE_BEGIN, /* update a rect */
RTGUI_EVENT_UPDATE_END, /* update a rect */
RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */
RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect */
RTGUI_EVENT_SHOW, /* the widget is going to be shown */
RTGUI_EVENT_HIDE, /* the widget is going to be hidden */
RTGUI_EVENT_PAINT, /* paint on screen */
RTGUI_EVENT_TIMER, /* timer */
RTGUI_EVENT_UPDATE_TOPLVL, /* update the toplevel */
RTGUI_EVENT_UPDATE_BEGIN, /* update a rect */
RTGUI_EVENT_UPDATE_END, /* update a rect */
RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */
RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect */
RTGUI_EVENT_SHOW, /* the widget is going to be shown */
RTGUI_EVENT_HIDE, /* the widget is going to be hidden */
RTGUI_EVENT_PAINT, /* paint on screen */
RTGUI_EVENT_TIMER, /* timer */
RTGUI_EVENT_UPDATE_TOPLVL, /* update the toplevel */
/* clip rect information */
RTGUI_EVENT_CLIP_INFO, /* clip rect info */
/* clip rect information */
RTGUI_EVENT_CLIP_INFO, /* clip rect info */
/* mouse and keyboard event */
RTGUI_EVENT_MOUSE_MOTION, /* mouse motion */
RTGUI_EVENT_MOUSE_BUTTON, /* mouse button info */
RTGUI_EVENT_KBD, /* keyboard info */
/* mouse and keyboard event */
RTGUI_EVENT_MOUSE_MOTION, /* mouse motion */
RTGUI_EVENT_MOUSE_BUTTON, /* mouse button info */
RTGUI_EVENT_KBD, /* keyboard info */
/* user command event */
RTGUI_EVENT_COMMAND=0x0100, /* user command */
/* widget event */
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 */
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 */
/* user command event. It should always be the last command type. */
RTGUI_EVENT_COMMAND = 0x0100, /* user command */
};
typedef enum _rtgui_event_type rtgui_event_type;
enum {
RTGUI_STATUS_OK = 0, /* status ok */
RTGUI_STATUS_ERROR, /* generic error */
RTGUI_STATUS_NRC, /* no resource */
enum
{
RTGUI_STATUS_OK = 0, /* status ok */
RTGUI_STATUS_ERROR, /* generic error */
RTGUI_STATUS_NRC, /* no resource */
};
struct rtgui_event
{
/* the event type */
rt_uint16_t type;
/* user field of event */
rt_uint16_t user;
/* the event type */
enum _rtgui_event_type type;
/* user field of event */
rt_uint16_t user;
/* the event sender */
rt_thread_t sender;
/* the event sender */
rt_thread_t sender;
/* mailbox to acknowledge request */
rt_mailbox_t ack;
/* mailbox to acknowledge request */
rt_mailbox_t ack;
};
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 \
{ \
(e)->type = (t); \
(e)->user = 0; \
(e)->sender = rt_thread_self(); \
(e)->ack = RT_NULL; \
#define RTGUI_EVENT_INIT(e, t) do \
{ \
(e)->type = (t); \
(e)->user = 0; \
(e)->sender = rt_thread_self(); \
(e)->ack = RT_NULL; \
} while (0)
/*
@ -109,9 +111,9 @@ typedef struct rtgui_event rtgui_event_t;
*/
struct rtgui_event_application
{
struct rtgui_event parent;
struct rtgui_event parent;
struct rtgui_app* app;
struct rtgui_app *app;
};
/* gui application init */
@ -123,40 +125,40 @@ struct rtgui_event_application
* RTGUI Window Event
*/
#define _RTGUI_EVENT_WIN_ELEMENTS \
struct rtgui_event parent; \
struct rtgui_win *wid;
struct rtgui_event parent; \
struct rtgui_win *wid;
/*
* RTGUI Window Event
*/
struct rtgui_event_win
{
_RTGUI_EVENT_WIN_ELEMENTS
_RTGUI_EVENT_WIN_ELEMENTS
};
struct rtgui_event_win_create
{
_RTGUI_EVENT_WIN_ELEMENTS
struct rtgui_win *parent_window;
_RTGUI_EVENT_WIN_ELEMENTS
struct rtgui_win *parent_window;
#ifndef RTGUI_USING_SMALL_SIZE
/* the window title */
rt_uint8_t title[RTGUI_NAME_MAX];
/* the window extent */
struct rtgui_rect extent;
/* the window title */
rt_uint8_t title[RTGUI_NAME_MAX];
/* the window extent */
struct rtgui_rect extent;
#endif
};
struct rtgui_event_win_move
{
_RTGUI_EVENT_WIN_ELEMENTS
rt_int16_t x, y;
_RTGUI_EVENT_WIN_ELEMENTS
rt_int16_t x, y;
};
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
@ -184,159 +186,159 @@ struct rtgui_event_win_resize
*/
struct rtgui_event_set_wm
{
struct rtgui_event parent;
struct rtgui_app *app;
struct rtgui_event parent;
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
*/
struct rtgui_event_update_begin
{
struct rtgui_event parent;
struct rtgui_event parent;
/* the update rect */
rtgui_rect_t rect;
/* the update rect */
rtgui_rect_t rect;
};
struct rtgui_event_update_end
{
struct rtgui_event parent;
struct rtgui_event parent;
/* the update rect */
rtgui_rect_t rect;
/* the update rect */
rtgui_rect_t rect;
};
struct rtgui_event_monitor
{
_RTGUI_EVENT_WIN_ELEMENTS
_RTGUI_EVENT_WIN_ELEMENTS
/* the monitor rect */
rtgui_rect_t rect;
/* the monitor rect */
rtgui_rect_t rect;
};
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_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;
struct rtgui_event_clip_info
{
_RTGUI_EVENT_WIN_ELEMENTS
_RTGUI_EVENT_WIN_ELEMENTS
/* the number of rects */
//rt_uint32_t num_rect;
/* the number of rects */
//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_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_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_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_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_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_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_TIMER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TIMER)
#define rtgui_event_show rtgui_event
#define rtgui_event_hide rtgui_event
#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_SHOW_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_SHOW)
#define RTGUI_EVENT_HIDE_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_HIDE)
struct rtgui_event_update_toplvl
{
struct rtgui_event parent;
struct rtgui_win *toplvl;
struct rtgui_event parent;
struct rtgui_win *toplvl;
};
#define RTGUI_EVENT_UPDATE_TOPLVL_INIT(e) \
do { \
RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_TOPLVL); \
(e)->toplvl = RT_NULL; \
} while (0)
#define RTGUI_EVENT_UPDATE_TOPLVL_INIT(e) \
do { \
RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_TOPLVL); \
(e)->toplvl = RT_NULL; \
} while (0)
/*
* RTGUI Mouse and Keyboard Event
*/
struct rtgui_event_mouse
{
_RTGUI_EVENT_WIN_ELEMENTS
_RTGUI_EVENT_WIN_ELEMENTS
rt_uint16_t x, y;
rt_uint16_t button;
rt_uint16_t x, y;
rt_uint16_t button;
};
#define RTGUI_MOUSE_BUTTON_LEFT 0x01
#define RTGUI_MOUSE_BUTTON_RIGHT 0x02
#define RTGUI_MOUSE_BUTTON_MIDDLE 0x03
#define RTGUI_MOUSE_BUTTON_WHEELUP 0x04
#define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08
#define RTGUI_MOUSE_BUTTON_LEFT 0x01
#define RTGUI_MOUSE_BUTTON_RIGHT 0x02
#define RTGUI_MOUSE_BUTTON_MIDDLE 0x03
#define RTGUI_MOUSE_BUTTON_WHEELUP 0x04
#define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08
#define RTGUI_MOUSE_BUTTON_DOWN 0x10
#define RTGUI_MOUSE_BUTTON_UP 0x20
#define RTGUI_MOUSE_BUTTON_DOWN 0x10
#define RTGUI_MOUSE_BUTTON_UP 0x20
struct rtgui_event_kbd
{
_RTGUI_EVENT_WIN_ELEMENTS
_RTGUI_EVENT_WIN_ELEMENTS
rt_uint16_t type; /* key down or up */
rt_uint16_t key; /* current key */
rt_uint16_t mod; /* current key modifiers */
rt_uint16_t unicode; /* translated character */
rt_uint16_t type; /* key down or up */
rt_uint16_t key; /* current key */
rt_uint16_t mod; /* current key modifiers */
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_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_UP(e) ((e)->type == RTGUI_KEYUP)
#define RTGUI_KBD_IS_DOWN(e) ((e)->type == RTGUI_KEYDOWN)
#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_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
#define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
#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_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_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_KBD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_KBD)
struct rtgui_event_command
{
_RTGUI_EVENT_WIN_ELEMENTS
_RTGUI_EVENT_WIN_ELEMENTS
/* command type */
rt_int32_t type;
/* command type */
rt_int32_t type;
/* command id */
rt_int32_t command_id;
/* command id */
rt_int32_t command_id;
/* command string */
char command_string[RTGUI_NAME_MAX];
/* command string */
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_WM_CLOSE 0x10
#define RTGUI_CMD_UNKNOWN 0x00
#define RTGUI_CMD_WM_CLOSE 0x10
#define RTGUI_CMD_USER_INT 0x20
#define RTGUI_CMD_USER_STRING 0x21
#define RTGUI_CMD_USER_INT 0x20
#define RTGUI_CMD_USER_STRING 0x21
/************************************************************************/
/* Widget Event */
/************************************************************************/
#define RTGUI_WIDGET_EVENT_INIT(e, t) do \
{ \
(e)->type = (t); \
(e)->sender = RT_NULL; \
(e)->ack = RT_NULL; \
#define RTGUI_WIDGET_EVENT_INIT(e, t) do \
{ \
(e)->type = (t); \
(e)->sender = RT_NULL; \
(e)->ack = RT_NULL; \
} while (0)
/*
@ -352,7 +354,7 @@ struct rtgui_event_scrollbar
#define RTGUI_SCROLL_LINEDOWN 0x02
#define RTGUI_SCROLL_PAGEUP 0x03
#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
@ -361,55 +363,102 @@ struct rtgui_event_focused
{
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
*/
struct rtgui_event_resize
{
struct rtgui_event parent;
rt_int16_t x, y;
rt_int16_t w, h;
struct rtgui_event parent;
rt_int16_t x, y;
rt_int16_t w, h;
};
#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
union rtgui_event_generic
{
struct rtgui_event base;
struct rtgui_event base;
struct rtgui_event_application app_create;
struct rtgui_event_application app_destroy;
struct rtgui_event_application app_activate;
struct rtgui_event_application app_create;
struct rtgui_event_application app_destroy;
struct rtgui_event_application app_activate;
struct rtgui_event_set_wm set_wm;
struct rtgui_event_win win_base;
struct rtgui_event_win_create win_create;
struct rtgui_event_win_move win_move;
struct rtgui_event_win_resize win_resize;
struct rtgui_event_win_destroy win_destroy;
struct rtgui_event_win_show win_show;
struct rtgui_event_win_hide win_hide;
struct rtgui_event_win_activate win_activate;
struct rtgui_event_win_deactivate win_deactivate;
struct rtgui_event_win_close win_close;
struct rtgui_event_win_modal_enter win_modal_enter;
struct rtgui_event_update_begin update_begin;
struct rtgui_event_update_end update_end;
struct rtgui_event_monitor monitor;
struct rtgui_event_paint paint;
struct rtgui_event_timer timer;
struct rtgui_event_update_toplvl update_toplvl;
struct rtgui_event_clip_info clip_info;
struct rtgui_event_mouse mouse;
struct rtgui_event_kbd kbd;
struct rtgui_event_command command;
struct rtgui_event_scrollbar scrollbar;
struct rtgui_event_focused focused;
struct rtgui_event_resize resize;
struct rtgui_event_set_wm set_wm;
struct rtgui_event_win win_base;
struct rtgui_event_win_create win_create;
struct rtgui_event_win_move win_move;
struct rtgui_event_win_resize win_resize;
struct rtgui_event_win_destroy win_destroy;
struct rtgui_event_win_show win_show;
struct rtgui_event_win_hide win_hide;
struct rtgui_event_win_activate win_activate;
struct rtgui_event_win_deactivate win_deactivate;
struct rtgui_event_win_close win_close;
struct rtgui_event_win_modal_enter win_modal_enter;
struct rtgui_event_update_begin update_begin;
struct rtgui_event_update_end update_end;
struct rtgui_event_monitor monitor;
struct rtgui_event_paint paint;
struct rtgui_event_timer timer;
struct rtgui_event_update_toplvl update_toplvl;
struct rtgui_event_clip_info clip_info;
struct rtgui_event_mouse mouse;
struct rtgui_event_kbd kbd;
struct rtgui_event_scrollbar scrollbar;
struct rtgui_event_focused focused;
struct rtgui_event_resize resize;
struct rtgui_event_mv_model model;
struct rtgui_event_command command;
};
#endif

View File

@ -14,8 +14,8 @@
#ifndef __RTGUI_FILERW_H__
#define __RTGUI_FILERW_H__
#ifdef RTGUI_USING_DFS_FILERW
#ifdef _WIN32
#ifdef RTGUI_USING_DFS_FILERW
#ifdef _WIN32_NATIVE
#pragma warning(disable: 4996)
#include <fcntl.h>
#include <sys/types.h>
@ -28,33 +28,33 @@
#include <rtgui/rtgui.h>
#define RTGUI_FILE_SEEK_SET 0
#define RTGUI_FILE_SEEK_CUR 1
#define RTGUI_FILE_SEEK_END 2
#define RTGUI_FILE_SEEK_SET 0
#define RTGUI_FILE_SEEK_CUR 1
#define RTGUI_FILE_SEEK_END 2
struct rtgui_filerw
{
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 (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int (*tell) (struct rtgui_filerw *context);
int (*eof) (struct rtgui_filerw *context);
int (*close)(struct rtgui_filerw *context);
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 (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int (*tell)(struct rtgui_filerw *context);
int (*eof)(struct rtgui_filerw *context);
int (*close)(struct rtgui_filerw *context);
};
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_mem(const rt_uint8_t* mem, rt_size_t size);
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);
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_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_eof (struct rtgui_filerw* context);
int rtgui_filerw_close(struct rtgui_filerw* context);
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_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_eof(struct rtgui_filerw *context);
int rtgui_filerw_close(struct rtgui_filerw *context);
int rtgui_filerw_unlink(const char *filename);
/* 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

View File

@ -23,13 +23,13 @@ struct rtgui_rect;
struct rtgui_font_engine
{
/* font engine function */
void (*font_init)(struct rtgui_font* font);
void (*font_load)(struct rtgui_font* font);
/* font engine function */
void (*font_init)(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,
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_draw_text)(struct rtgui_font *font, struct rtgui_dc *dc, const char *text,
rt_ubase_t len, 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
{
const rt_uint8_t* bmp; /* bitmap font data */
const rt_uint8_t* char_width; /* each character width, NULL for fixed font */
const rt_uint32_t* offset; /* offset for each character */
const rt_uint8_t *bmp; /* bitmap font data */
const rt_uint8_t *char_width; /* each character width, NULL for fixed font */
const rt_uint32_t *offset; /* offset for each character */
rt_uint16_t width; /* font width */
rt_uint16_t height; /* font height */
rt_uint16_t width; /* font width */
rt_uint16_t height; /* font height */
rt_uint8_t first_char;
rt_uint8_t last_char;
rt_uint8_t first_char;
rt_uint8_t last_char;
};
extern const struct rtgui_font_engine bmp_font_engine;
@ -65,50 +65,54 @@ struct rtgui_hz_file_font
/* font size */
rt_uint16_t font_size;
rt_uint16_t font_data_size;
rt_uint16_t font_data_size;
/* file descriptor */
int fd;
/* font file name */
const char* font_fn;
const char *font_fn;
};
extern const struct rtgui_font_engine rtgui_hz_file_font_engine;
struct rtgui_font
{
/* font name */
char* family;
/* font name */
char *family;
/* font height */
rt_uint16_t height;
/* font height */
rt_uint16_t height;
/* refer count */
rt_uint32_t refer_count;
/* refer count */
rt_uint32_t refer_count;
/* font engine */
const struct rtgui_font_engine* engine;
/* font engine */
const struct rtgui_font_engine *engine;
/* font private data */
void* data;
/* font private data */
void *data;
/* the font list */
rtgui_list_t list;
/* the font list */
rtgui_list_t list;
};
typedef struct rtgui_font rtgui_font_t;
void rtgui_font_system_init(void);
void rtgui_font_system_add_font(struct rtgui_font* font);
void rtgui_font_system_remove_font(struct rtgui_font* font);
struct rtgui_font* rtgui_font_default(void);
void rtgui_font_set_defaut(struct rtgui_font* font);
void rtgui_font_system_add_font(struct rtgui_font *font);
void rtgui_font_system_remove_font(struct rtgui_font *font);
struct rtgui_font *rtgui_font_default(void);
void rtgui_font_set_defaut(struct rtgui_font *font);
struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height);
void rtgui_font_derefer(struct rtgui_font* font);
struct rtgui_font *rtgui_font_refer(const char *family, rt_uint16_t height);
void rtgui_font_derefer(struct rtgui_font *font);
/* 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);
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_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);
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

View File

@ -4,7 +4,7 @@
#include <rtgui/dc.h>
#include <rtgui/font.h>
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);
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);
#endif

View File

@ -19,48 +19,48 @@
#include <rtgui/region.h>
enum rtgui_img_zoom
{
RTGUI_IMG_ZOOM_NEAREST,
RTGUI_IMG_ZOOM_BILINEAR
{
RTGUI_IMG_ZOOM_NEAREST,
RTGUI_IMG_ZOOM_BILINEAR
};
struct rtgui_image;
struct rtgui_image_engine
{
const char* name;
struct rtgui_list_node list;
const char *name;
struct rtgui_list_node list;
/* image engine function */
rt_bool_t (*image_check)(struct rtgui_filerw* file);
/* image engine function */
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);
void (*image_unload)(struct rtgui_image* image);
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_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_rotate)(struct rtgui_image* image, float angle);
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_rotate)(struct rtgui_image *image, float angle);
};
struct rtgui_image_palette
{
rtgui_color_t* colors;
rt_uint32_t ncolors;
rtgui_color_t *colors;
rt_uint32_t ncolors;
};
typedef struct rtgui_image_palette rtgui_image_palette_t;
struct rtgui_image
{
/* image metrics */
rt_uint16_t w, h;
/* image metrics */
rt_uint16_t w, h;
/* image engine */
const struct rtgui_image_engine* engine;
/* image engine */
const struct rtgui_image_engine *engine;
/* image palette */
rtgui_image_palette_t* palette;
/* image palette */
rtgui_image_palette_t *palette;
/* image private data */
void* data;
/* image private data */
void *data;
};
typedef struct rtgui_image rtgui_image_t;
@ -68,24 +68,24 @@ typedef struct rtgui_image rtgui_image_t;
void rtgui_system_image_init(void);
#if defined(RTGUI_USING_DFS_FILERW)
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(const char* filename, rt_bool_t load);
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(const char *filename, rt_bool_t load);
#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);
void rtgui_image_destroy(struct rtgui_image* image);
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);
/* 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 */
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 */
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);
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);
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);
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);
#endif

View File

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

View File

@ -8,20 +8,20 @@
/* image item in image container */
struct rtgui_image_item
{
rtgui_image_t *image;
char *filename;
rtgui_image_t *image;
char *filename;
rt_uint32_t refcount;
rt_uint32_t refcount;
};
typedef struct rtgui_image_item rtgui_image_item_t;
void rtgui_system_image_container_init(rt_bool_t load);
#ifdef RTGUI_USING_DFS_FILERW
rtgui_image_item_t* rtgui_image_container_get(const char* filename);
#ifdef RTGUI_USING_DFS_FILERW
rtgui_image_item_t *rtgui_image_container_get(const char *filename);
#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

View File

@ -18,20 +18,20 @@
struct rtgui_image_hdcmm
{
struct rtgui_image parent;
struct rtgui_image parent;
/* hdc image information */
rt_uint16_t byte_per_pixel;
/* hdc image information */
rt_uint16_t byte_per_pixel;
rt_uint16_t pitch;
rt_uint8_t *pixels;
rt_uint8_t *pixels;
};
void rtgui_image_hdc_init(void);
extern const struct rtgui_image_engine rtgui_image_hdcmm_engine;
#define HDC_HEADER_SIZE (5 * 4)
#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)}
#define HDC_HEADER_SIZE (5 * 4)
#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)}
#endif

View File

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

View File

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

View File

@ -20,81 +20,81 @@
extern "C" {
#endif
typedef struct rtgui_region_data rtgui_region_data_t;
typedef struct rtgui_region_data rtgui_region_data_t;
struct rtgui_region_data
{
rt_uint32_t size;
rt_uint32_t numRects;
/* XXX: And why, exactly, do we have this bogus struct definition? */
/* rtgui_rect_t rects[size]; in memory but not explicitly declared */
};
struct rtgui_region_data
{
rt_uint32_t size;
rt_uint32_t numRects;
/* XXX: And why, exactly, do we have this bogus struct definition? */
/* rtgui_rect_t rects[size]; in memory but not explicitly declared */
};
typedef struct rtgui_region
{
rtgui_rect_t extents;
rtgui_region_data_t *data;
}rtgui_region_t;
typedef struct rtgui_region
{
rtgui_rect_t extents;
rtgui_region_data_t *data;
} rtgui_region_t;
typedef enum
{
RTGUI_REGION_STATUS_FAILURE,
RTGUI_REGION_STATUS_SUCCESS
}rtgui_region_status_t;
typedef enum
{
RTGUI_REGION_STATUS_FAILURE,
RTGUI_REGION_STATUS_SUCCESS
} rtgui_region_status_t;
/* creation/destruction */
/* creation/destruction */
void rtgui_region_init(rtgui_region_t *region);
void rtgui_region_init_rect(rtgui_region_t *region,
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_fini (rtgui_region_t *region);
void rtgui_region_init(rtgui_region_t *region);
void rtgui_region_init_rect(rtgui_region_t *region,
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_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_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_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_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_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_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_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_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_IN 1
#define RTGUI_REGION_PART 2
#define RTGUI_REGION_OUT 0
#define RTGUI_REGION_IN 1
#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_rectangle (rtgui_region_t *rtgui_region_t, rtgui_rect_t *prect);
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_not_empty (rtgui_region_t *region);
rtgui_rect_t *rtgui_region_extents (rtgui_region_t *region);
int rtgui_region_not_empty(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_validate (rtgui_region_t *badreg, int *pOverlap);
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);
void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t* rect);
void rtgui_region_empty (rtgui_region_t *region);
void rtgui_region_dump(rtgui_region_t* region);
int rtgui_region_is_flat(rtgui_region_t* region);
void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t *rect);
void rtgui_region_empty(rtgui_region_t *region);
void rtgui_region_dump(rtgui_region_t *region);
int rtgui_region_is_flat(rtgui_region_t *region);
/* rect functions */
extern rtgui_rect_t rtgui_empty_rect;
/* rect functions */
extern rtgui_rect_t rtgui_empty_rect;
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_inflate(rtgui_rect_t *rect, int d);
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_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);
rt_bool_t rtgui_rect_is_empty(const rtgui_rect_t *rect);
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_inflate(rtgui_rect_t *rect, int d);
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_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);
rt_bool_t rtgui_rect_is_empty(const rtgui_rect_t *rect);
#if defined(__cplusplus) || defined(c_plusplus)
}

View File

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

View File

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

View File

@ -18,67 +18,34 @@
/* RTGUI options */
#ifdef _WIN32
/* name length of RTGUI object */
#define RTGUI_NAME_MAX 12
/* 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
#ifndef RT_USING_DFS
#undef RTGUI_USING_DFS_FILERW
#undef RTGUI_USING_HZ_FILE
#endif
#if RTGUI_DEFAULT_FONT_SIZE == 0
#define RTGUI_DEFAULT_FONT_SIZE 12
#endif
#define RTGUI_SVR_THREAD_PRIORITY 15
#define RTGUI_SVR_THREAD_TIMESLICE 5
#define RTGUI_SVR_THREAD_PRIORITY 15
#define RTGUI_SVR_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_SVR_THREAD_STACK_SIZE 1024
#define RTGUI_SVR_THREAD_STACK_SIZE 1024
#else
#define RTGUI_SVR_THREAD_STACK_SIZE 2048
#define RTGUI_SVR_THREAD_STACK_SIZE 2048
#endif
#define RTGUI_APP_THREAD_PRIORITY 25
#define RTGUI_APP_THREAD_TIMESLICE 5
#define RTGUI_APP_THREAD_PRIORITY 25
#define RTGUI_APP_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_APP_THREAD_STACK_SIZE 1024
#define RTGUI_APP_THREAD_STACK_SIZE 1024
#else
#define RTGUI_APP_THREAD_STACK_SIZE 2048
#define RTGUI_APP_THREAD_STACK_SIZE 2048
#endif
#define RTGUI_USING_CAST_CHECK
//#define RTGUI_USING_DESKTOP_WINDOW
#undef RTGUI_USING_SMALL_SIZE
//#undef RTGUI_USING_SMALL_SIZE
#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" {
#endif
/* rtgui object type */
#define RTGUI_CONTAINER_OF(obj, type, member) \
((type *)((char *)(obj) - (unsigned long)(&((type *)0)->member)))
/* rtgui object type */
#define RTGUI_CONTAINER_OF(obj, type, 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))
/** Casts the function pointer to an rtgui_constructor */
/** Casts the function pointer to an rtgui_constructor */
#define RTGUI_DESTRUCTOR(destructor) ((rtgui_destructor_t)(destructor))
/* pre-definition */
struct rtgui_object;
typedef struct rtgui_object rtgui_object_t;
typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
typedef void (*rtgui_destructor_t)(rtgui_object_t *object);
/* pre-definition */
struct rtgui_object;
typedef struct rtgui_object rtgui_object_t;
typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
typedef void (*rtgui_destructor_t)(rtgui_object_t *object);
/* rtgui type structure */
struct rtgui_type
{
/* type name */
char* name;
/* rtgui type structure */
struct rtgui_type
{
/* type name */
char *name;
/* parent type link */
struct rtgui_type *parent;
/* parent type link */
struct rtgui_type *parent;
/* constructor and destructor */
rtgui_constructor_t constructor;
rtgui_destructor_t destructor;
/* constructor and destructor */
rtgui_constructor_t constructor;
rtgui_destructor_t destructor;
/* size of type */
int size;
};
typedef struct rtgui_type rtgui_type_t;
#define RTGUI_TYPE(type) (struct rtgui_type*)&(_rtgui_##type)
/* size of type */
int size;
};
typedef struct rtgui_type rtgui_type_t;
#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) \
const struct rtgui_type _rtgui_##type = { \
name, \
parent, \
RTGUI_CONSTRUCTOR(constructor), \
RTGUI_DESTRUCTOR(destructor), \
size }
const struct rtgui_type _rtgui_##type = { \
name, \
parent, \
RTGUI_CONSTRUCTOR(constructor), \
RTGUI_DESTRUCTOR(destructor), \
size }
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);
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 char *rtgui_type_name_get(const rtgui_type_t *type);
const rtgui_type_t *rtgui_object_object_type_get(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);
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 char *rtgui_type_name_get(const rtgui_type_t *type);
const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object);
#ifdef RTGUI_USING_CAST_CHECK
#define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \
((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type), __FUNCTION__, __LINE__))
#define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \
((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type), __FUNCTION__, __LINE__))
#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
#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);
/** Gets the type of an object */
DECLARE_CLASS_TYPE(object);
/** Gets the type of an 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))
/** 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))
enum rtgui_object_flag
{
RTGUI_OBJECT_FLAG_NONE = 0x00,
RTGUI_OBJECT_FLAG_STATIC = 0x01,
RTGUI_OBJECT_FLAG_DISABLED = 0x02
};
enum rtgui_object_flag
{
RTGUI_OBJECT_FLAG_NONE = 0x00,
RTGUI_OBJECT_FLAG_STATIC = 0x01,
RTGUI_OBJECT_FLAG_DISABLED = 0x02
};
/* rtgui base object */
struct rtgui_object
{
/* object type */
const rtgui_type_t* type;
/* rtgui base object */
struct rtgui_object
{
/* object type */
const rtgui_type_t *type;
/* the event handler */
rtgui_event_handler_ptr event_handler;
/* the 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);
void rtgui_object_destroy(rtgui_object_t *object);
rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type);
void rtgui_object_destroy(rtgui_object_t *object);
/* set the event handler of object */
void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler);
/* object default event handler */
rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event* event);
/* helper micro. widget event handlers could use this. */
/* set the event handler of object */
void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler);
/* object default event handler */
rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event *event);
/* helper micro. widget event handlers could use this. */
#define RTGUI_WIDGET_EVENT_HANDLER_PREPARE \
struct rtgui_widget *widget; \
RT_ASSERT(object != RT_NULL); \
RT_ASSERT(event != RT_NULL); \
widget = RTGUI_WIDGET(object); \
/* supress compiler warning */ \
widget = widget;
struct rtgui_widget *widget; \
RT_ASSERT(object != RT_NULL); \
RT_ASSERT(event != RT_NULL); \
widget = RTGUI_WIDGET(object); \
/* supress compiler warning */ \
widget = widget;
/** handle @param event on @param object's own event handler
*
* 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
* return code of that handler is returned.
*/
rt_inline rt_bool_t rtgui_object_handle(struct rtgui_object *object, struct rtgui_event *event)
{
if (object->event_handler)
return object->event_handler(object, event);
return RT_FALSE;
}
/** handle @param event on @param object's own event handler
*
* 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
* return code of that handler is returned.
*/
rt_inline rt_bool_t rtgui_object_handle(struct rtgui_object *object, struct rtgui_event *event)
{
if (object->event_handler)
return object->event_handler(object, event);
return RT_FALSE;
}
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_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);
#ifdef __cplusplus
}

View File

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

View File

@ -22,40 +22,40 @@ struct rtgui_event;
struct rtgui_widget;
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
{
/* context thread id */
rt_thread_t tid;
/* rt timer */
struct rt_timer timer;
/* context thread id */
rt_thread_t tid;
/* rt timer */
struct rt_timer timer;
/* timeout function and user data */
rtgui_timeout_func timeout;
void* user_data;
/* timeout function and user data */
rtgui_timeout_func timeout;
void *user_data;
};
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);
void rtgui_timer_destory(rtgui_timer_t* timer);
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_start(rtgui_timer_t* timer);
void rtgui_timer_stop (rtgui_timer_t* timer);
void rtgui_timer_start(rtgui_timer_t *timer);
void rtgui_timer_stop(rtgui_timer_t *timer);
/* rtgui system initialization function */
void rtgui_system_server_init(void);
void* rtgui_malloc(rt_size_t size);
void rtgui_free(void* ptr);
void* rtgui_realloc(void* ptr, rt_size_t size);
void *rtgui_malloc(rt_size_t size);
void rtgui_free(void *ptr);
void *rtgui_realloc(void *ptr, rt_size_t size);
#ifdef _WIN32
#define rtgui_enter_critical()
#define rtgui_exit_critical()
#ifdef _WIN32_NATIVE
#define rtgui_enter_critical()
#define rtgui_exit_critical()
#else
#define rtgui_enter_critical rt_enter_critical
#define rtgui_exit_critical rt_exit_critical
#define rtgui_enter_critical rt_enter_critical
#define rtgui_exit_critical rt_exit_critical
#endif
rt_thread_t rtgui_get_server(void);
@ -67,12 +67,12 @@ void rtgui_screen_lock(rt_int32_t timeout);
void rtgui_screen_unlock(void);
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_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_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_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_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_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_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_filter(rt_uint32_t type, struct rtgui_event *event, rt_size_t event_size);
#endif

View File

@ -17,11 +17,11 @@
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_server.h>
#define CHECK_BOX_W 13
#define CHECK_BOX_H 13
#define CHECK_BOX_W 13
#define CHECK_BOX_H 13
#define RADIO_BOX_W 12
#define RADIO_BOX_H 12
#define RADIO_BOX_W 12
#define RADIO_BOX_H 12
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
@ -38,27 +38,26 @@
extern "C" {
#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_button(rtgui_button_t* btn);
void rtgui_theme_draw_label(rtgui_label_t* label);
void rtgui_theme_draw_textbox(rtgui_textbox_t* box);
void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox);
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_win(struct rtgui_topwin *win);
void rtgui_theme_draw_button(rtgui_button_t *btn);
void rtgui_theme_draw_label(rtgui_label_t *label);
void rtgui_theme_draw_textbox(rtgui_textbox_t *box);
void rtgui_theme_draw_iconbox(rtgui_iconbox_t *iconbox);
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_radiobox(struct rtgui_radiobox* radiobox);
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_staticline(struct rtgui_staticline* staticline);
void rtgui_theme_draw_radiobox(struct rtgui_radiobox *radiobox);
void rtgui_theme_draw_slider(struct rtgui_slider *slider);
void rtgui_theme_draw_progressbar(struct rtgui_progressbar *bar);
void rtgui_theme_draw_staticline(struct rtgui_staticline *staticline);
rt_uint16_t rtgui_theme_get_selected_height(void);
void rtgui_theme_draw_selected(struct rtgui_dc* dc, rtgui_rect_t *rect);
rt_uint16_t rtgui_theme_get_selected_height(void);
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_fc(void);
rtgui_color_t rtgui_theme_default_bc(void);
rtgui_color_t rtgui_theme_default_fc(void);
#ifdef __cplusplus
}

View File

@ -5,30 +5,31 @@
/* Types of events: start element, end element, text, attr name, attr
val and start/end document. Other events can be ignored! */
enum {
EVENT_START = 0, /* Start tag */
EVENT_END, /* End tag */
EVENT_TEXT, /* Text */
EVENT_NAME, /* Attribute name */
EVENT_VAL, /* Attribute value */
EVENT_END_DOC, /* End of document */
EVENT_COPY, /* Internal only; copies to internal buffer */
EVENT_NONE /* Internal only; should never see this event */
enum
{
EVENT_START = 0, /* Start tag */
EVENT_END, /* End tag */
EVENT_TEXT, /* Text */
EVENT_NAME, /* Attribute name */
EVENT_VAL, /* Attribute value */
EVENT_END_DOC, /* End of document */
EVENT_COPY, /* Internal only; copies to internal buffer */
EVENT_NONE /* Internal only; should never see this event */
};
/* xml structure typedef */
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 */
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 */
void rtgui_xml_destroy(rtgui_xml_t* rtgui_xml);
void rtgui_xml_destroy(rtgui_xml_t *rtgui_xml);
/* 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 */
const char* rtgui_xml_event_str(rt_uint8_t event);
const char *rtgui_xml_event_str(rt_uint8_t event);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -22,31 +22,31 @@
extern "C" {
#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))
/** 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))
/** 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))
struct rtgui_box
{
struct rtgui_object parent;
struct rtgui_box
{
struct rtgui_object parent;
rt_uint16_t orient;
rt_uint16_t border_size;
rt_uint16_t orient;
rt_uint16_t border_size;
struct rtgui_container* container;
};
typedef struct rtgui_box rtgui_box_t;
struct rtgui_container *container;
};
typedef struct rtgui_box rtgui_box_t;
struct rtgui_box* rtgui_box_create(int orientation, int border_size);
void rtgui_box_destroy(struct rtgui_box* box);
struct rtgui_box *rtgui_box_create(int orientation, int border_size);
void rtgui_box_destroy(struct rtgui_box *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(rtgui_box_t *box);
void rtgui_box_layout_rect(rtgui_box_t *box, struct rtgui_rect *rect);
#ifdef __cplusplus
}

View File

@ -22,57 +22,57 @@
extern "C" {
#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))
/** 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))
/** 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_BUTTON_FLAG_PRESS 0x01
#define RTGUI_BUTTON_FLAG_DEFAULT 0x02
#define RTGUI_BUTTON_FLAG_PRESS 0x01
#define RTGUI_BUTTON_FLAG_DEFAULT 0x02
#define RTGUI_BUTTON_TYPE_NORMAL 0x00
#define RTGUI_BUTTON_TYPE_PUSH 0x10
#define RTGUI_BUTTON_TYPE_NORMAL 0x00
#define RTGUI_BUTTON_TYPE_PUSH 0x10
/*
* the button widget
*/
struct rtgui_button
{
/* inherit from label */
struct rtgui_label parent;
/*
* the button widget
*/
struct rtgui_button
{
/* inherit from label */
struct rtgui_label parent;
/* button flag */
rt_base_t flag;
/* button flag */
rt_base_t flag;
/* pressed and unpressed image */
rtgui_image_t *pressed_image, *unpressed_image;
/* pressed and unpressed image */
rtgui_image_t *pressed_image, *unpressed_image;
/* click button event handler */
rtgui_onbutton_func_t on_button;
};
typedef struct rtgui_button rtgui_button_t;
/* click button event handler */
rtgui_onbutton_func_t on_button;
};
typedef struct rtgui_button rtgui_button_t;
rtgui_button_t* rtgui_button_create(const char* text);
rtgui_button_t* rtgui_pushbutton_create(const char* text);
void rtgui_button_destroy(rtgui_button_t* btn);
rtgui_button_t *rtgui_button_create(const char *text);
rtgui_button_t *rtgui_pushbutton_create(const char *text);
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_unpressed_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_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
}

View File

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

View File

@ -14,36 +14,36 @@ DECLARE_CLASS_TYPE(combobox);
/** Checks if the object is a rtgui_combobox */
#define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
#define RTGUI_COMBOBOX_WIDTH 75
#define RTGUI_COMBOBOX_HEIGHT 20
#define RTGUI_COMBOBOX_BUTTON_WIDTH 18
#define RTGUI_COMBOBOX_WIDTH 75
#define RTGUI_COMBOBOX_HEIGHT 20
#define RTGUI_COMBOBOX_BUTTON_WIDTH 18
struct rtgui_combobox
{
struct rtgui_widget parent;
struct rtgui_widget parent;
/* widget private data */
/* widget private data */
/* pull down window */
struct rtgui_win* pd_win;
rt_bool_t pd_pressed;
/* pull down window */
struct rtgui_win *pd_win;
rt_bool_t pd_pressed;
/* combobox items */
struct rtgui_listbox_item* items;
rt_uint16_t items_count;
rt_uint16_t current_item;
/* combobox items */
struct rtgui_listbox_item *items;
rt_uint16_t items_count;
rt_uint16_t current_item;
/* call back */
rtgui_event_handler_ptr on_selected;
/* call back */
rtgui_event_handler_ptr on_selected;
};
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);
void rtgui_combobox_destroy(rtgui_combobox_t* box);
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);
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);
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);
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

View File

@ -21,46 +21,46 @@
extern "C" {
#endif
DECLARE_CLASS_TYPE(container);
/** Gets the type of a container */
DECLARE_CLASS_TYPE(container);
/** Gets the type of a 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))
/** 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))
/*
* the container widget
*/
struct rtgui_container
{
struct rtgui_widget parent;
/*
* the container widget
*/
struct rtgui_container
{
struct rtgui_widget parent;
/* layout box */
struct rtgui_box* layout_box;
/* layout box */
struct rtgui_box *layout_box;
rtgui_list_t children;
};
typedef struct rtgui_container rtgui_container_t;
rtgui_list_t children;
};
typedef struct rtgui_container rtgui_container_t;
rtgui_container_t* rtgui_container_create(void);
void rtgui_container_destroy(rtgui_container_t* container);
rtgui_container_t *rtgui_container_create(void);
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 */
void rtgui_container_set_box(struct rtgui_container* container, struct rtgui_box* box);
void rtgui_container_layout(struct rtgui_container* container);
/* set layout 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_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_destroy_children(rtgui_container_t *container);
rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container);
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_destroy_children(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_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse* 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);
#ifdef __cplusplus
}

View File

@ -21,91 +21,91 @@
extern "C" {
#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))
/** 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))
/** 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_EDIT_NONE 0x00
#define RTGUI_EDIT_CARET 0x01
#define RTGUI_EDIT_VSCROLL 0x02
#define RTGUI_EDIT_HSCROLL 0x04
#define RTGUI_EDIT_SHIFT 0x10
#define RTGUI_EDIT_CTRL 0x20
#define RTGUI_EDIT_ALT 0x40
#define RTGUI_EDIT_CAPSLOCK 0x80
#define RTGUI_EDIT_NUMLOCK 0x100
#define RTGUI_EDIT_NONE 0x00
#define RTGUI_EDIT_CARET 0x01
#define RTGUI_EDIT_VSCROLL 0x02
#define RTGUI_EDIT_HSCROLL 0x04
#define RTGUI_EDIT_SHIFT 0x10
#define RTGUI_EDIT_CTRL 0x20
#define RTGUI_EDIT_ALT 0x40
#define RTGUI_EDIT_CAPSLOCK 0x80
#define RTGUI_EDIT_NUMLOCK 0x100
struct edit_update
{
/* rt_uint32_t type; */ /* update type */
rtgui_point_t start, end; /* update area */
};
struct edit_update
{
/* rt_uint32_t type; */ /* update type */
rtgui_point_t start, end; /* update area */
};
struct edit_line
{
rt_int16_t zsize; /* zone size */
rt_int16_t len;
struct edit_line *prev;
struct edit_line *next;
char *text;
};
struct edit_line
{
rt_int16_t zsize; /* zone size */
rt_int16_t len;
struct edit_line *prev;
struct edit_line *next;
char *text;
};
struct rtgui_edit
{
/* inherit from container */
rtgui_container_t parent;
struct rtgui_edit
{
/* inherit from container */
rtgui_container_t parent;
/* edit flag */
rt_uint32_t flag;
rt_int16_t max_rows, max_cols;
rt_int16_t row_per_page, col_per_page;
rtgui_point_t upleft;
rtgui_point_t visual;
rt_uint8_t tabsize;
rt_uint8_t item_height;
rt_uint8_t font_width,font_height;
rt_uint8_t margin;
rt_int16_t bzsize; /* base zone size */
struct rtgui_timer *caret_timer;
rtgui_color_t *caret;
rtgui_rect_t caret_rect;
struct edit_update update;
char *update_buf; /* speed up renewal process */
struct rtgui_dc *dbl_buf;
struct edit_line *head;
struct edit_line *tail;
struct edit_line *first_line;
/* edit flag */
rt_uint32_t flag;
rt_int16_t max_rows, max_cols;
rt_int16_t row_per_page, col_per_page;
rtgui_point_t upleft;
rtgui_point_t visual;
rt_uint8_t tabsize;
rt_uint8_t item_height;
rt_uint8_t font_width, font_height;
rt_uint8_t margin;
rt_int16_t bzsize; /* base zone size */
struct rtgui_timer *caret_timer;
rtgui_color_t *caret;
rtgui_rect_t caret_rect;
struct edit_update update;
char *update_buf; /* speed up renewal process */
struct rtgui_dc *dbl_buf;
struct edit_line *head;
struct edit_line *tail;
struct edit_line *first_line;
#ifdef RTGUI_EDIT_USING_SCROLL
struct rtgui_scrollbar *hscroll;
struct rtgui_scrollbar *vscroll;
struct rtgui_scrollbar *hscroll;
struct rtgui_scrollbar *vscroll;
#endif
};
};
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_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_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_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);
void _rtgui_edit_constructor(struct rtgui_edit *box);
void _rtgui_edit_deconstructor(struct rtgui_edit *textbox);
void _rtgui_edit_constructor(struct rtgui_edit *box);
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);
void rtgui_edit_destroy(struct rtgui_edit *edit);
void rtgui_edit_update(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);
void rtgui_edit_set_text(struct rtgui_edit *edit, const char* text);
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_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);
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_update(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);
void rtgui_edit_set_text(struct rtgui_edit *edit, const char *text);
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_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);
#ifdef __cplusplus
}

View File

@ -8,10 +8,10 @@
#define RTGUI_FITEM_DIR 0x1
struct rtgui_file_item
{
char* name;
char *name;
rt_uint32_t type;
rt_uint32_t size;
rt_uint32_t type;
rt_uint32_t size;
};
DECLARE_CLASS_TYPE(filelist);
@ -24,35 +24,35 @@ DECLARE_CLASS_TYPE(filelist);
struct rtgui_filelist_view
{
struct rtgui_container parent;
struct rtgui_container parent;
/* widget private data */
/* widget private data */
/* current directory */
char* current_directory;
char* pattern;
char *current_directory;
char *pattern;
/* the number of item in a page */
rt_uint16_t page_items;
rt_uint16_t items_count;
rt_uint16_t items_count;
/* the selected item */
rt_uint16_t current_item;
/* the selected item */
rt_uint16_t current_item;
/* items array */
struct rtgui_file_item *items;
/* items array */
struct rtgui_file_item *items;
};
typedef struct rtgui_filelist_view rtgui_filelist_view_t;
rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory,
const char* pattern,
const rtgui_rect_t* rect);
void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view);
rtgui_filelist_view_t *rtgui_filelist_view_create(const char *directory,
const char *pattern,
const rtgui_rect_t *rect);
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);
void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory);
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_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

View File

@ -28,45 +28,45 @@ DECLARE_CLASS_TYPE(groupbox);
/** Checks if the object is an rtgui_groupbox */
#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 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:
* - 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
* the status of widget, for example un-select this widget.
* - when a widget has been selected, group box invokes groupbox->select_func to change
* the status of widget, for example un-select this widget.
*/
struct rtgui_groupbox
{
struct rtgui_panel parent;
struct rtgui_panel parent;
char* label;
struct rtgui_box *box;
struct rtgui_widget *selected;
char *label;
struct rtgui_box *box;
struct rtgui_widget *selected;
widget_select_t select_func;
rtgui_event_handler_ptr on_selected;
widget_select_t select_func;
rtgui_event_handler_ptr on_selected;
};
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);
void rtgui_groupbox_destroy(rtgui_groupbox_t* groupbox);
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_layout(struct rtgui_groupbox *box);
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);
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);
box->on_selected = on_selected;
RT_ASSERT(box != RT_NULL);
box->on_selected = on_selected;
}
#endif

View File

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

View File

@ -31,19 +31,19 @@ DECLARE_CLASS_TYPE(label);
*/
struct rtgui_label
{
struct rtgui_widget parent;
struct rtgui_widget parent;
/* label */
char* text;
/* label */
char *text;
};
typedef struct rtgui_label rtgui_label_t;
rtgui_label_t* rtgui_label_create(const char* text);
void rtgui_label_destroy(rtgui_label_t* label);
rtgui_label_t *rtgui_label_create(const char *text);
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);
char* rtgui_label_get_text(rtgui_label_t* label);
void rtgui_label_set_text(rtgui_label_t *label, const char *text);
char *rtgui_label_get_text(rtgui_label_t *label);
#endif

View File

@ -21,11 +21,11 @@
#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
{
char* name;
rtgui_image_t *image;
char *name;
rtgui_image_t *image;
item_action action;
void *parameter;
@ -39,38 +39,38 @@ DECLARE_CLASS_TYPE(listview);
/** 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_LIST_VIEW_LIST 0x00
#define RTGUI_LIST_VIEW_ICON 0x01
#define RTGUI_LIST_VIEW_REPORT 0x02
#define RTGUI_LIST_VIEW_LIST 0x00
#define RTGUI_LIST_VIEW_ICON 0x01
#define RTGUI_LIST_VIEW_REPORT 0x02
struct rtgui_list_view
{
struct rtgui_container parent;
struct rtgui_container parent;
/* widget private data */
/* list item */
const struct rtgui_list_item* items;
/* widget private data */
/* list item */
const struct rtgui_list_item *items;
/* layout flag */
rt_uint16_t flag;
/* layout flag */
rt_uint16_t flag;
/* total number of items */
rt_uint16_t items_count;
/* total number of items */
rt_uint16_t items_count;
/* the number of item in a page */
rt_uint16_t page_items;
/* current item */
/* current item */
rt_int16_t current_item;
/* icon layout */
rt_uint8_t row_items, col_items;
/* icon layout */
rt_uint8_t row_items, col_items;
};
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_rect_t *rect, rt_uint16_t flag);
void rtgui_list_view_destroy(rtgui_list_view_t* view);
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);
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

View File

@ -22,31 +22,31 @@
struct rtgui_listbox_item
{
char* name;
rtgui_image_t *image;
char *name;
rtgui_image_t *image;
};
DECLARE_CLASS_TYPE(listbox);
/** 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 */
#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 */
#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_widget parent;
struct rtgui_widget parent;
/* widget private data */
/* listbox item */
const struct rtgui_listbox_item* items;
/* widget private data */
/* listbox item */
const struct rtgui_listbox_item *items;
/* item event handler */
rtgui_event_handler_ptr on_item;
/* item event handler */
rtgui_event_handler_ptr on_item;
/* total number of items */
rt_uint16_t items_count;
/* total number of items */
rt_uint16_t items_count;
/* the number of item in a page */
rt_uint16_t page_items;
/* current item */
@ -54,14 +54,14 @@ struct rtgui_listbox
};
typedef struct rtgui_listbox rtgui_listbox_t;
rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count,
rtgui_rect_t *rect);
void rtgui_listbox_destroy(rtgui_listbox_t* box);
rtgui_listbox_t *rtgui_listbox_create(const struct rtgui_listbox_item *items, rt_uint16_t count,
rtgui_rect_t *rect);
void rtgui_listbox_destroy(rtgui_listbox_t *box);
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_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);
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_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);
#endif

View File

@ -22,44 +22,45 @@
DECLARE_CLASS_TYPE(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 */
#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 */
#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_widget parent;
struct rtgui_widget parent;
/* widget private data */
/* listctrl items */
rt_uint32_t items;
/* widget private data */
/* listctrl items */
void *items;
/* total number of items */
rt_uint16_t items_count;
/* total number of items */
rt_uint16_t items_count;
/* the number of item in a page */
rt_uint16_t page_items;
/* current item */
rt_int16_t current_item;
rt_uint16_t item_height;
rt_uint16_t item_height;
/* item event handler */
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);
/* item event handler */
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);
};
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_rect_t *rect, rtgui_onitem_draw_t ondraw);
void rtgui_listctrl_destroy(rtgui_listctrl_t* ctrl);
rtgui_listctrl_t *rtgui_listctrl_create(void *items, rt_uint16_t count,
rtgui_rect_t *rect, rtgui_onitem_draw_t ondraw);
void rtgui_listctrl_destroy(rtgui_listctrl_t *ctrl);
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_items(rtgui_listctrl_t* ctrl, rt_uint32_t 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_itemheight(struct rtgui_listctrl* ctrl, int height);
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_items(rtgui_listctrl_t *ctrl, void *items, rt_uint16_t count);
void rtgui_listctrl_set_current_item(struct rtgui_listctrl *ctrl, rt_uint16_t index);
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

View File

@ -8,28 +8,28 @@
/* rtgui menu item */
enum rtgui_menu_item_type
{
RTGUI_ITEM_NORMAL,
RTGUI_ITEM_CHECK,
RTGUI_ITEM_SUBMENU,
RTGUI_ITEM_SEPARATOR
RTGUI_ITEM_NORMAL,
RTGUI_ITEM_CHECK,
RTGUI_ITEM_SUBMENU,
RTGUI_ITEM_SEPARATOR
};
typedef enum rtgui_menu_item_type rtgui_menu_item_type_t;
struct rtgui_menu_item
{
rtgui_menu_item_type_t type;
rtgui_menu_item_type_t type;
/* menu text label */
const char* label;
/* menu image */
rtgui_image_t *image;
/* menu text label */
const char *label;
/* menu image */
rtgui_image_t *image;
/* sub-menu item */
const struct rtgui_menu_item_t *submenu;
rt_uint16_t submenu_count;
/* sub-menu item */
const struct rtgui_menu_item_t *submenu;
rt_uint16_t submenu_count;
/* menu action */
rt_bool_t (*on_menuaction)(struct rtgui_object* object, struct rtgui_event* event);
/* menu action */
rt_bool_t (*on_menuaction)(struct rtgui_object *object, struct rtgui_event *event);
};
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 */
#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
{
/* inherited from window */
struct rtgui_win parent;
/* inherited from window */
struct rtgui_win parent;
/* menu items */
const struct rtgui_menu_item *items;
rt_uint16_t items_count;
/* menu items */
const struct rtgui_menu_item *items;
rt_uint16_t items_count;
/* parent menu */
struct rtgui_menu *parent_menu;
struct rtgui_menu *sub_menu;
/* parent menu */
struct rtgui_menu *parent_menu;
struct rtgui_menu *sub_menu;
/* menu item list control */
struct rtgui_listctrl *items_list;
/* menu item list control */
struct rtgui_listctrl *items_list;
/* pop event handle */
rtgui_event_handler_ptr on_menupop;
rtgui_event_handler_ptr on_menuhide;
/* pop event handle */
rtgui_event_handler_ptr on_menupop;
rtgui_event_handler_ptr on_menuhide;
};
typedef struct rtgui_menu rtgui_menu_t;
struct rtgui_menu* rtgui_menu_create(const char* title, struct rtgui_menu* parent_menu,
const struct rtgui_menu_item* items, rt_uint16_t count);
void rtgui_menu_destroy(struct rtgui_menu* 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);
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_onmenuhide(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_pop(struct rtgui_menu* menu, int x, int y);
void rtgui_menu_hiden(struct rtgui_menu* menu);
void rtgui_menu_pop(struct rtgui_menu *menu, int x, int y);
void rtgui_menu_hiden(struct rtgui_menu *menu);
#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 */
#define RTGUI_IS_NOTEBOOK(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_NOTEBOOK_TYPE))
#define RTGUI_NOTEBOOK_TOP 0x00
#define RTGUI_NOTEBOOK_BOTTOM 0x01
#define RTGUI_NOTEBOOK_NOTAB 0x02
#define RTGUI_NOTEBOOK_LEFT 0x03
#define RTGUI_NOTEBOOK_RIGHT 0x04
#define RTGUI_NOTEBOOK_TOP 0x00
#define RTGUI_NOTEBOOK_BOTTOM 0x01
#define RTGUI_NOTEBOOK_NOTAB 0x02
#define RTGUI_NOTEBOOK_LEFT 0x03
#define RTGUI_NOTEBOOK_RIGHT 0x04
struct rtgui_notebook_tab;
struct rtgui_notebook
{
struct rtgui_widget parent;
struct rtgui_widget parent;
rt_uint8_t flag;
rt_uint8_t flag;
/* widget private data */
struct rtgui_notebook_tab *childs;
rt_uint16_t count;
rt_int16_t current;
/* widget private data */
struct rtgui_notebook_tab *childs;
rt_uint16_t count;
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);
void rtgui_notebook_destroy(struct rtgui_notebook* notebook);
struct rtgui_notebook *rtgui_notebook_create(const rtgui_rect_t *rect, rt_uint8_t style);
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_ASSERT(notebook != RT_NULL);
notebook->tab_h = height;
RT_ASSERT(notebook != RT_NULL);
notebook->tab_h = height;
}
rt_inline void rtgui_notebook_set_tab_width(struct rtgui_notebook *notebook, rt_uint16_t width)
{
RT_ASSERT(notebook != RT_NULL);
notebook->tab_w = width;
RT_ASSERT(notebook != RT_NULL);
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
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);
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);
#endif
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index);
struct rtgui_widget* rtgui_notebook_get_current(struct rtgui_notebook* notebook);
rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook* notebook);
void rtgui_notebook_remove(struct rtgui_notebook *notebook, rt_uint16_t index);
struct rtgui_widget *rtgui_notebook_get_current(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);
void rtgui_notebook_get_client_rect(struct rtgui_notebook* notebook, struct rtgui_rect *rect);
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_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(struct rtgui_notebook *notebook, struct rtgui_widget *child);
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

View File

@ -31,21 +31,21 @@ DECLARE_CLASS_TYPE(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;
rtgui_panel_t* rtgui_panel_create(int border_style);
void rtgui_panel_destroy(rtgui_panel_t* panel);
rtgui_panel_t *rtgui_panel_create(int border_style);
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);
panel->border_style = border_style;
RT_ASSERT(panel != RT_NULL);
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

View File

@ -16,6 +16,7 @@
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/mv_view.h>
#include <rtgui/widgets/plot_curve.h>
DECLARE_CLASS_TYPE(plot);
@ -27,17 +28,10 @@ DECLARE_CLASS_TYPE(plot);
/** Checks if the object is an rtgui_plot */
#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;
struct rtgui_plot_curve_container *next;
};
enum rtgui_plot_flag
{
RTGUI_PLOT_INCREMENTAL,
RTGUI_PLOT_MOVING_WINDOW,
RTGUI_PLOT_SCAN,
RTGUI_PLOT_TYPE_SCAN,
RTGUI_PLOT_TYPE_INCREMENTAL,
};
/*
@ -45,20 +39,21 @@ enum rtgui_plot_flag
*/
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;
struct rtgui_plot_curve_container curve_container;
rtgui_plot_curve_dtype base_x;
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_set_base_point(struct rtgui_plot *plot, rt_uint16_t x, rt_uint16_t y);
void rtgui_plot_append_curve(struct rtgui_plot *plot, struct rtgui_plot_curve *curve);
void rtgui_plot_remove_curve(struct rtgui_plot *plot, struct rtgui_plot_curve *curve);
void rtgui_plot_set_base(struct rtgui_plot *plot,
rtgui_plot_curve_dtype x, rtgui_plot_curve_dtype y);
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__
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_mv_model.h>
DECLARE_CLASS_TYPE(plot_curve);
@ -31,15 +32,20 @@ DECLARE_CLASS_TYPE(plot_curve);
struct rtgui_plot_curve
{
struct rtgui_object parent;
struct rtgui_mv_model parent;
rtgui_color_t color;
rt_size_t length;
rtgui_plot_curve_dtype *x_data;
rtgui_plot_curve_dtype *y_data;
rtgui_plot_curve_dtype min_x, max_x;
rtgui_plot_curve_dtype min_y, max_y;
};
struct rtgui_plot_curve *rtgui_plot_curve_create(void);
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

View File

@ -17,20 +17,20 @@ DECLARE_CLASS_TYPE(progressbar);
struct rtgui_progressbar
{
struct rtgui_widget parent;
struct rtgui_widget parent;
int orient;
int orient;
int range;
int position;
};
typedef struct rtgui_progressbar rtgui_progressbar_t;
struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range, rtgui_rect_t* r);
void rtgui_progressbar_destroy(struct rtgui_progressbar* p_bar);
struct rtgui_progressbar *rtgui_progressbar_create(int orientation, int range, rtgui_rect_t *r);
void rtgui_progressbar_destroy(struct rtgui_progressbar *p_bar);
rt_bool_t rtgui_progressbar_event_handler(struct rtgui_object* object,
struct rtgui_event* event);
rt_bool_t rtgui_progressbar_event_handler(struct rtgui_object *object,
struct rtgui_event *event);
void rtgui_progressbar_set_value(struct rtgui_progressbar *p_bar, int value);
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_widget parent;
struct rtgui_widget parent;
/* widget private data */
char* text; /* radio box label */
/* widget private data */
char *text; /* radio box label */
/* box orient */
rt_uint8_t orient;
/* box orient */
rt_uint8_t orient;
/* item size */
rt_uint8_t item_size;
/* item size */
rt_uint8_t item_size;
char** items;
rt_uint16_t item_count;
rt_int16_t item_selection;
char **items;
rt_uint16_t item_count;
rt_int16_t item_selection;
};
typedef struct rtgui_radiobox rtgui_radiobox_t;
struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number);
void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox);
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_set_selection(struct rtgui_radiobox* radiobox, int selection);
int rtgui_radiobox_get_selection(struct rtgui_radiobox* radiobox);
void rtgui_radiobox_set_selection(struct rtgui_radiobox *radiobox, int selection);
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

View File

@ -14,14 +14,15 @@
#ifndef __RTGUI_SCROLLBAR_H__
#define __RTGUI_SCROLLBAR_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/container.h>
#ifdef __cplusplus
extern "C" {
#endif
DECLARE_CLASS_TYPE(scrollbar);
/** Gets the type of a scrollbar */
#define RTGUI_SCROLLBAR_TYPE (RTGUI_TYPE(scrollbar))
/** Casts the object to an rtgui_scrollbar */
@ -29,58 +30,60 @@ DECLARE_CLASS_TYPE(scrollbar);
/** Checks if the object is an rtgui_scrollbar */
#define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE))
#define RTGUI_DEFAULT_SB_WIDTH 100
#define RTGUI_DEFAULT_SB_HEIGHT 16
#define RTGUI_DEFAULT_SB_WIDTH 16
/* scrollbar status/positions*/
#define SBS_UNKNOWN 0x0000
#define SBS_LEFTARROW 0x0001
#define SBS_RIGHTARROW 0x0002
#define SBS_LEFTSPACE 0x0004
#define SBS_RIGHTSPACE 0x0008
#define SBS_HORZTHUMB 0x0010
#define SBS_LEFTSPACE 0x0004 /* Need mouse_motion event */
#define SBS_RIGHTSPACE 0x0008 /* Need mouse_motion event */
#define SBS_HORZTHUMB 0x0010 /* Need mouse_motion event */
#define SBS_UPARROW 0x0020
#define SBS_DOWNARROW 0x0040
#define SBS_UPSPACE 0x0080
#define SBS_DOWNSPACE 0x0100
#define SBS_VERTTHUMB 0x0200
#define SBS_UPSPACE 0x0080 /* Need mouse_motion event */
#define SBS_DOWNSPACE 0x0100 /* Need mouse_motion event */
#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
{
/* inherit from widget */
struct rtgui_widget parent;
rtgui_widget_t parent;
rt_uint8_t orient;
rt_uint8_t status;
rt_uint8_t orient;
rt_uint32_t status;
/* page_step = width of scrollbar */
/* thumb size = line_step * page_step / (page_step - (button width * 2)) */
/* page_step = display lines of scrollbar */
/* thumb_len = line_step * page_step / (page_step - (button width * 2)) */
rt_int16_t line_step, page_step;
rt_int16_t thumb_position, thumb_size;
rt_int16_t value, thumb_len,thumb_w;
/* 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;
struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r);
void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar);
rtgui_scrollbar_t* rtgui_scrollbar_create(rtgui_container_t *container,int left,int top,int w,int len,int orient);
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);
rt_int16_t rtgui_scrollbar_get_value(struct rtgui_scrollbar* bar);
void rtgui_scrollbar_set_value(struct rtgui_scrollbar* bar, rt_int16_t position);
void rtgui_scrollbar_set_onscroll(rtgui_scrollbar_t* bar, rtgui_event_handler_ptr handler);
void rtgui_scrollbar_set_orientation(rtgui_scrollbar_t* bar, int orient);
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);
void rtgui_scrollbar_set_orientation(struct rtgui_scrollbar* bar, int orientation);
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);
rt_bool_t rtgui_scrollbar_event_handler(rtgui_object_t *obj, rtgui_event_t* event);
void rtgui_scrollbar_hide(rtgui_scrollbar_t* bar);
#ifdef __cplusplus
}

View File

@ -27,27 +27,27 @@ DECLARE_CLASS_TYPE(slider);
struct rtgui_slider
{
struct rtgui_widget parent;
struct rtgui_widget parent;
/* widget private data */
rt_size_t min, max, value, ticks;
rt_size_t thumb_width;
/* widget private data */
rt_size_t min, max, value, ticks;
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;
struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient);
void rtgui_slider_destroy(struct rtgui_slider* slider);
struct rtgui_slider *rtgui_slider_create(rt_size_t min, rt_size_t max, int orient);
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_value(struct rtgui_slider* slider, rt_size_t value);
void rtgui_slider_set_orientation(struct rtgui_slider* slider, int orientation);
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_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

View File

@ -18,18 +18,18 @@ DECLARE_CLASS_TYPE(staticline);
struct rtgui_staticline
{
/* inherit from widget */
struct rtgui_widget parent;
/* inherit from widget */
struct rtgui_widget parent;
int orient;
int orient;
};
typedef struct rtgui_staticline rtgui_staticline_t;
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);
void rtgui_staticline_set_orientation(rtgui_staticline_t* staticline, int orientation);
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);
#endif

View File

@ -1,16 +1,16 @@
/*
* File : textbox.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, 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
* 2009-10-16 Bernard first version
*/
* File : textbox.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, 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
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_TEXTBOX_H__
#define __RTGUI_TEXTBOX_H__
@ -31,17 +31,17 @@ DECLARE_CLASS_TYPE(textbox);
/** Checks if the object is a rtgui_textbox_t */
#define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE))
#define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
#define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
#define RTGUI_TEXTBOX_SINGLE 0x00
#define RTGUI_TEXTBOX_MULTI 0x01 /* multiline */
#define RTGUI_TEXTBOX_MASK 0x02 /* ciphertext */
#define RTGUI_TEXTBOX_MULTI 0x01 /* multiline */
#define RTGUI_TEXTBOX_MASK 0x02 /* ciphertext */
#define RTGUI_TEXTBOX_DIGIT 0x04 /* digit */
#define RTGUI_TEXTBOX_CARET_SHOW 0x10
#define RTGUI_TEXTBOX_CARET_STAT 0x20 /* unused */
#define RTGUI_TEXTBOX_CARET_SHOW 0x10
#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
{
@ -53,8 +53,10 @@ struct rtgui_textbox
/* current line and position */
rt_uint16_t line, line_begin, position, line_length;
rt_uint16_t dis_length; /*may be display length.*/
char* text;
rt_uint16_t dis_length; /*may be display length.*/
rt_uint16_t first_pos;
char mask_char;
char *text;
rt_size_t font_width;
rtgui_timer_t *caret_timer;
@ -62,23 +64,24 @@ struct rtgui_textbox
rtgui_rect_t caret_rect;
/* 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;
struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint32_t flag);
void rtgui_textbox_destroy(struct rtgui_textbox* box);
rtgui_textbox_t *rtgui_textbox_create(const char *text, rt_uint32_t flag);
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);
const char* rtgui_textbox_get_value(struct rtgui_textbox* box);
void rtgui_textbox_set_value(struct rtgui_textbox *box, const char *text);
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
}
#endif

View File

@ -20,45 +20,45 @@
extern "C" {
#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))
/** 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))
/** 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))
/*
* the textview widget
*/
struct rtgui_textview
{
/* inherit from widget */
struct rtgui_widget parent;
/*
* the textview widget
*/
struct rtgui_textview
{
/* inherit from widget */
struct rtgui_widget parent;
rt_uint16_t line_width;
rt_uint16_t line_count;
rt_uint16_t line_width;
rt_uint16_t line_count;
char* lines;
char *lines;
rt_int16_t line_current;
rt_uint16_t line_page_count;
};
typedef struct rtgui_textview rtgui_textview_t;
rt_int16_t line_current;
rt_uint16_t line_page_count;
};
typedef struct rtgui_textview rtgui_textview_t;
rtgui_textview_t* rtgui_textview_create(const char* text, const rtgui_rect_t *rect);
void rtgui_textview_destroy(rtgui_textview_t* textview);
rtgui_textview_t *rtgui_textview_create(const char *text, const rtgui_rect_t *rect);
void rtgui_textview_destroy(rtgui_textview_t *textview);
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);
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);
/** @} */
/** @} */
#ifdef __cplusplus
}

View File

@ -26,19 +26,19 @@ DECLARE_CLASS_TYPE(wintitle);
struct rtgui_wintitle
{
struct rtgui_widget parent;
struct rtgui_widget parent;
/* title */
char* title;
/* title */
char *title;
};
typedef struct rtgui_wintitle rtgui_wintitle_t;
rtgui_wintitle_t* rtgui_wintitle_create(struct rtgui_win *window, const char* title);
void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle);
rtgui_wintitle_t *rtgui_wintitle_create(struct rtgui_win *window, const char *title);
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);
char *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle);
void rtgui_wintitle_set_title(rtgui_wintitle_t *wintitle, const char *title);
char *rtgui_wintitle_get_title(rtgui_wintitle_t *wintitle);
#endif

View File

@ -25,176 +25,176 @@
extern "C" {
#endif
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000
#define RTGUI_WIDGET_FLAG_SHOWN 0x0001
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000
#define RTGUI_WIDGET_FLAG_SHOWN 0x0001
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
/* rtgui widget attribute */
#define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w)->gc.foreground)
#define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w)->gc.background)
#define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w)->gc.textalign)
#define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w)->gc.font)
#define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w)->flag)
#define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w)->align)
#define RTGUI_WIDGET_BORDER(w) (RTGUI_WIDGET(w)->border)
#define RTGUI_WIDGET_BORDER_STYLE(w) (RTGUI_WIDGET(w)->border_style)
/* rtgui widget attribute */
#define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w)->gc.foreground)
#define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w)->gc.background)
#define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w)->gc.textalign)
#define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w)->gc.font)
#define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w)->flag)
#define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w)->align)
#define RTGUI_WIDGET_BORDER(w) (RTGUI_WIDGET(w)->border)
#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_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_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_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_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_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_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_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_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_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_DC_SET_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_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))
/** 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))
/** 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))
/*
* the base widget object
*/
struct rtgui_widget
{
/* inherit from rtgui_object */
struct rtgui_object object;
/*
* the base widget object
*/
struct rtgui_widget
{
/* inherit from rtgui_object */
struct rtgui_object object;
/* the widget that contains this widget */
struct rtgui_widget *parent;
/* the window that contains this widget */
struct rtgui_win *toplevel;
/* the widget children and sibling */
rtgui_list_t sibling;
/* the widget that contains this widget */
struct rtgui_widget *parent;
/* the window that contains this widget */
struct rtgui_win *toplevel;
/* the widget children and sibling */
rtgui_list_t sibling;
/* widget flag */
rt_int32_t flag;
/* widget flag */
rt_int32_t flag;
/* hardware device context */
rt_uint32_t dc_type;
const struct rtgui_dc_engine* dc_engine;
/* hardware device context */
rt_uint32_t dc_type;
const struct rtgui_dc_engine *dc_engine;
/* the graphic context of widget */
rtgui_gc_t gc;
/* the graphic context of widget */
rtgui_gc_t gc;
/* the widget extent */
rtgui_rect_t extent;
/* the widget extent */
rtgui_rect_t extent;
/* minimal width and height of widget */
rt_int16_t mini_width, mini_height;
/* widget align */
rt_int32_t align;
rt_uint16_t border;
rt_uint16_t border_style;
/* the rect clip */
rtgui_region_t clip;
/* minimal width and height of widget */
rt_int16_t mini_width, mini_height;
/* widget align */
rt_int32_t align;
rt_uint16_t border;
rt_uint16_t border_style;
/* the rect clip */
rtgui_region_t clip;
/* call back */
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);
/* call back */
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);
#ifndef RTGUI_USING_SMALL_SIZE
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_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_command) (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_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_command)(struct rtgui_object *widget, struct rtgui_event *event);
#endif
/* user private data */
rt_uint32_t user_data;
};
typedef struct rtgui_widget rtgui_widget_t;
/* user private data */
rt_uint32_t user_data;
};
typedef struct rtgui_widget rtgui_widget_t;
rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type);
void rtgui_widget_destroy(rtgui_widget_t* widget);
rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type);
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 */
void rtgui_widget_focus(rtgui_widget_t * widget);
void rtgui_widget_unfocus(rtgui_widget_t *widget);
/* focus and unfocus */
void rtgui_widget_focus(rtgui_widget_t *widget);
void rtgui_widget_unfocus(rtgui_widget_t *widget);
/* event handler for each command */
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);
/* event handler for each command */
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);
#ifndef RTGUI_USING_SMALL_SIZE
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_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_oncommand(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_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_oncommand(rtgui_widget_t *widget, rtgui_event_handler_ptr handler);
#endif
/* get and set rect of widget */
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_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_get_extent(rtgui_widget_t* widget, rtgui_rect_t *rect);
/* get and set rect of widget */
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_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_get_extent(rtgui_widget_t *widget, rtgui_rect_t *rect);
#ifndef RTGUI_USING_SMALL_SIZE
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_miniwidth(rtgui_widget_t *widget, int width);
void rtgui_widget_set_miniheight(rtgui_widget_t *widget, int height);
#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 */
void rtgui_widget_point_to_device(rtgui_widget_t * widget, rtgui_point_t * point);
/* get the physical position of a logic rect on widget */
void rtgui_widget_rect_to_device(rtgui_widget_t * widget, rtgui_rect_t * rect);
/* get the physical position of a logic point on widget */
void rtgui_widget_point_to_device(rtgui_widget_t *widget, rtgui_point_t *point);
/* get the physical position of a logic rect on widget */
void rtgui_widget_rect_to_device(rtgui_widget_t *widget, rtgui_rect_t *rect);
/* get the logic position of a physical point on widget */
void rtgui_widget_point_to_logic(rtgui_widget_t* widget, rtgui_point_t * point);
/* get the logic position of a physical rect on widget */
void rtgui_widget_rect_to_logic(rtgui_widget_t* widget, rtgui_rect_t* rect);
/* get the logic position of a physical point on widget */
void rtgui_widget_point_to_logic(rtgui_widget_t *widget, rtgui_point_t *point);
/* get the logic position of a physical rect on widget */
void rtgui_widget_rect_to_logic(rtgui_widget_t *widget, rtgui_rect_t *rect);
/* move widget and its children to a logic point */
void rtgui_widget_move_to_logic(rtgui_widget_t* widget, int dx, int dy);
/* move widget and its children to a logic point */
void rtgui_widget_move_to_logic(rtgui_widget_t *widget, int dx, int dy);
/* update the clip info of widget */
void rtgui_widget_update_clip(rtgui_widget_t* widget);
/* update the clip info of widget */
void rtgui_widget_update_clip(rtgui_widget_t *widget);
/* get the toplevel widget of 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);
/* get the toplevel widget of 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);
void rtgui_widget_show(rtgui_widget_t* widget);
rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_hide(rtgui_widget_t* widget);
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_show(rtgui_widget_t *widget);
rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_hide(rtgui_widget_t *widget);
rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_update(rtgui_widget_t *widget);
/* get parent color */
rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t* widget);
rtgui_color_t rtgui_widget_get_parent_background(rtgui_widget_t* widget);
/* get parent color */
rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t *widget);
rtgui_color_t rtgui_widget_get_parent_background(rtgui_widget_t *widget);
/* get the next sibling of widget */
rtgui_widget_t* rtgui_widget_get_next_sibling(rtgui_widget_t* widget);
/* get the prev sibling of widget */
rtgui_widget_t* rtgui_widget_get_prev_sibling(rtgui_widget_t* widget);
/* get the next sibling of widget */
rtgui_widget_t *rtgui_widget_get_next_sibling(rtgui_widget_t *widget);
/* get the prev sibling of widget */
rtgui_widget_t *rtgui_widget_get_prev_sibling(rtgui_widget_t *widget);
/* dump widget information */
void rtgui_widget_dump(rtgui_widget_t* widget);
/* dump widget information */
void rtgui_widget_dump(rtgui_widget_t *widget);
#ifdef __cplusplus
}

View File

@ -28,37 +28,37 @@ DECLARE_CLASS_TYPE(win);
/** Checks if the object is an rtgui_win */
#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_TITLE 0x0002 /* no title 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_MINIBOX 0x0010 /* window has the mini button */
#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_BORDER 0x0004 /* no border window */
#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_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_ONBTM 0x0080 /* window is in the bottom layer */
#define RTGUI_WIN_STYLE_MAINWIN 0x0106 /* window is a main window */
#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_ONBTM 0x0080 /* window is in the bottom layer */
#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
{
RTGUI_WIN_FLAG_INIT = 0x00, /* init state */
RTGUI_WIN_FLAG_MODAL = 0x01, /* modal mode window */
RTGUI_WIN_FLAG_CLOSED = 0x02, /* window is closed */
RTGUI_WIN_FLAG_ACTIVATE = 0x04, /* window is activated */
RTGUI_WIN_FLAG_UNDER_MODAL = 0x08, /* window is under modal
show(modaled by other) */
RTGUI_WIN_FLAG_CONNECTED = 0x10, /* connected to server */
/* 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
* such as ESC). Both of dispatching and handling are in the same
* function(rtgui_win_event_handler). So we have to distinguish between the
* two modes.
*
* If this flag is set, we are in key-handling mode.
*/
RTGUI_WIN_FLAG_HANDLE_KEY = 0x20
RTGUI_WIN_FLAG_INIT = 0x00, /* init state */
RTGUI_WIN_FLAG_MODAL = 0x01, /* modal mode window */
RTGUI_WIN_FLAG_CLOSED = 0x02, /* window is closed */
RTGUI_WIN_FLAG_ACTIVATE = 0x04, /* window is activated */
RTGUI_WIN_FLAG_UNDER_MODAL = 0x08, /* window is under modal
show(modaled by other) */
RTGUI_WIN_FLAG_CONNECTED = 0x10, /* connected to server */
/* 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
* such as ESC). Both of dispatching and handling are in the same
* function(rtgui_win_event_handler). So we have to distinguish between the
* two modes.
*
* If this flag is set, we are in key-handling mode.
*/
RTGUI_WIN_FLAG_HANDLE_KEY = 0x20
};
struct rtgui_win_title;
@ -66,54 +66,57 @@ struct rtgui_win_area;
struct rtgui_win
{
/* inherit from container */
rtgui_container_t parent;
/* inherit from container */
rtgui_container_t parent;
/* drawing count */
rt_base_t drawing;
/* drawing count */
rt_base_t drawing;
/* 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 */
struct rtgui_widget *focused_widget;
/* the widget that will grab the focus in current window */
struct rtgui_widget *focused_widget;
/* window style */
rt_uint16_t style;
/* which app I belong */
struct rtgui_app *app;
/* window state flag */
enum rtgui_win_flag flag;
/* window style */
rt_uint16_t style;
rtgui_modal_code_t modal_code;
/* window state flag */
enum rtgui_win_flag flag;
/* last mouse event handled widget */
rtgui_widget_t* last_mevent_widget;
rtgui_modal_code_t modal_code;
/* window title */
char* title;
/* last mouse event handled widget */
rtgui_widget_t *last_mevent_widget;
/* call back */
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);
/* window title */
char *title;
/* reserved user data */
rt_uint32_t user_data;
/* call back */
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_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_win_create(struct rtgui_win *parent_window, const char *title,
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);
void rtgui_win_destroy(rtgui_win_t* win);
void rtgui_win_destroy(rtgui_win_t *win);
/** Close window.
*
@ -124,30 +127,30 @@ void rtgui_win_destroy(rtgui_win_t* win);
*
* \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);
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_hiden(rtgui_win_t *win);
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_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 */
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_set_rect(rtgui_win_t *win, rtgui_rect_t *rect);
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_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_onkey(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_onclose(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);
char* rtgui_win_get_title(rtgui_win_t* win);
void rtgui_win_set_title(rtgui_win_t *win, const char *title);
char *rtgui_win_get_title(rtgui_win_t *win);
#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);
/* 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);
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect)
{
RT_ASSERT(rect != RT_NULL);
RT_ASSERT(driver != RT_NULL);
RT_ASSERT(rect != RT_NULL);
RT_ASSERT(driver != RT_NULL);
rect->x1 = rect->y1 = 0;
rect->x2 = driver->width;
rect->y2 = driver->height;
rect->x1 = rect->y1 = 0;
rect->x2 = driver->width;
rect->y2 = driver->height;
}
RTM_EXPORT(rtgui_graphic_driver_get_rect);
rt_err_t rtgui_graphic_set_device(rt_device_t device)
{
rt_err_t result;
struct rt_device_graphic_info info;
rt_err_t result;
struct rt_device_graphic_info info;
/* get framebuffer address */
result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
if (result != RT_EOK)
{
/* get device information failed */
return -RT_ERROR;
}
/* get framebuffer address */
result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
if (result != RT_EOK)
{
/* get device information failed */
return -RT_ERROR;
}
/* initialize framebuffer driver */
_driver.device = device;
_driver.pixel_format = info.pixel_format;
_driver.bits_per_pixel = info.bits_per_pixel;
_driver.width = info.width;
_driver.height = info.height;
_driver.pitch = _driver.width * _driver.bits_per_pixel/8;
_driver.framebuffer = info.framebuffer;
/* initialize framebuffer driver */
_driver.device = device;
_driver.pixel_format = info.pixel_format;
_driver.bits_per_pixel = info.bits_per_pixel;
_driver.width = info.width;
_driver.height = info.height;
_driver.pitch = _driver.width * _driver.bits_per_pixel / 8;
_driver.framebuffer = info.framebuffer;
if (info.framebuffer != RT_NULL)
{
/* is a frame buffer device */
_driver.ops = rtgui_framebuffer_get_ops(_driver.pixel_format);
}
else
{
/* is a pixel device */
_driver.ops = rtgui_pixel_device_get_ops(_driver.pixel_format);
}
return RT_EOK;
if (info.framebuffer != RT_NULL)
{
/* is a frame buffer device */
_driver.ops = rtgui_framebuffer_get_ops(_driver.pixel_format);
}
else
{
/* is a pixel device */
_driver.ops = rtgui_pixel_device_get_ops(_driver.pixel_format);
}
return RT_EOK;
}
RTM_EXPORT(rtgui_graphic_set_device);
/* 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.width = rect->x2 - rect->x1;
rect_info.height = rect->y2 - rect->y1;
rt_device_control(driver->device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info);
rect_info.x = rect->x1;
rect_info.y = rect->y1;
rect_info.width = rect->x2 - rect->x1;
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);
/* 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);
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);

File diff suppressed because it is too large Load Diff

View File

@ -20,11 +20,11 @@
struct rtgui_mouse_monitor
{
/* event rect */
rtgui_rect_t rect;
/* event rect */
rtgui_rect_t rect;
/* node list */
rtgui_list_t list;
/* node list */
rtgui_list_t list;
};
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_set_cursor_enable(rt_bool_t enable);
void rtgui_mouse_set_cursor(rtgui_image_t* cursor);
void rtgui_mouse_get_cursor_rect(rtgui_rect_t* rect);
void rtgui_mouse_set_cursor(rtgui_image_t *cursor);
void rtgui_mouse_get_cursor_rect(rtgui_rect_t *rect);
void rtgui_mouse_show_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
rt_bool_t rtgui_winrect_is_moved(void);
void rtgui_winrect_set(struct rtgui_topwin* topwin);
rt_bool_t rtgui_winrect_moved_done(rtgui_rect_t* winrect, 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);
#endif
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);
rt_bool_t rtgui_mouse_monitor_contains_point(rtgui_list_t* head, int x, int y);
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);
rt_bool_t rtgui_mouse_monitor_contains_point(rtgui_list_t *head, int x, int y);
#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_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();
if (driver != RT_NULL)
{
rtgui_graphic_driver_screen_update(driver, &(event->rect));
}
driver = rtgui_graphic_driver_get_default();
if (driver != RT_NULL)
{
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 */
rtgui_topwin_append_monitor_rect(event->wid, &(event->rect));
/* add monitor rect to top window list */
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 */
rtgui_topwin_remove_monitor_rect(event->wid, &(event->rect));
/* add monitor rect to top window list */
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 */
RTGUI_EVENT_MOUSE_BUTTON_INIT(event);
/* re-init to server thread */
RTGUI_EVENT_MOUSE_BUTTON_INIT(event);
#ifdef RTGUI_USING_WINMOVE
if (rtgui_winrect_is_moved() &&
event->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP))
{
struct rtgui_topwin* topwin;
rtgui_rect_t rect;
if (rtgui_winrect_is_moved() &&
event->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP))
{
struct rtgui_topwin *topwin;
rtgui_rect_t rect;
if (rtgui_winrect_moved_done(&rect, &topwin) == RT_TRUE)
{
struct rtgui_event_win_move ewin;
if (rtgui_winrect_moved_done(&rect, &topwin) == RT_TRUE)
{
struct rtgui_event_win_move ewin;
/* move window */
RTGUI_EVENT_WIN_MOVE_INIT(&ewin);
ewin.wid = topwin->wid;
if (topwin->title != RT_NULL)
{
if (topwin->flag & WINTITLE_BORDER)
{
ewin.x = rect.x1 + WINTITLE_BORDER_SIZE;
ewin.y = rect.y1 + WINTITLE_BORDER_SIZE;
}
if (!(topwin->flag & WINTITLE_NO)) ewin.y += WINTITLE_HEIGHT;
}
else
{
ewin.x = rect.x1;
ewin.y = rect.y1;
}
/* move window */
RTGUI_EVENT_WIN_MOVE_INIT(&ewin);
ewin.wid = topwin->wid;
if (topwin->title != RT_NULL)
{
if (topwin->flag & WINTITLE_BORDER)
{
ewin.x = rect.x1 + WINTITLE_BORDER_SIZE;
ewin.y = rect.y1 + WINTITLE_BORDER_SIZE;
}
if (!(topwin->flag & WINTITLE_NO)) ewin.y += WINTITLE_HEIGHT;
}
else
{
ewin.x = rect.x1;
ewin.y = rect.y1;
}
/* send to client thread */
rtgui_send(topwin->tid, &(ewin.parent), sizeof(ewin));
/* send to client thread */
rtgui_send(topwin->tid, &(ewin.parent), sizeof(ewin));
return;
}
}
return;
}
}
#endif
/* get the wnd which contains the mouse */
wnd = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
if (wnd != RT_NULL)
{
event->wid = wnd->wid;
/* get the wnd which contains the mouse */
wnd = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
if (wnd != RT_NULL)
{
event->wid = wnd->wid;
if (rtgui_topwin_get_focus() != wnd)
{
/* raise this window */
rtgui_topwin_activate_topwin(wnd);
}
if (rtgui_topwin_get_focus() != wnd)
{
/* raise this window */
rtgui_topwin_activate_topwin(wnd);
}
if (wnd->title != RT_NULL &&
rtgui_rect_contains_point(&(RTGUI_WIDGET(wnd->title)->extent), event->x, event->y) == RT_EOK)
{
rtgui_topwin_title_onmouse(wnd, event);
}
else
{
/* send mouse event to thread */
rtgui_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_mouse));
}
return ;
}
if (wnd->title != RT_NULL &&
rtgui_rect_contains_point(&(RTGUI_WIDGET(wnd->title)->extent), event->x, event->y) == RT_EOK)
{
rtgui_topwin_title_onmouse(wnd, event);
}
else
{
/* send mouse event to thread */
rtgui_send(wnd->tid, (struct rtgui_event *)event, sizeof(struct rtgui_event_mouse));
}
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 */
struct rtgui_topwin* win = RT_NULL;
/* the topwin contains current mouse */
struct rtgui_topwin *win = RT_NULL;
/* re-init mouse event */
RTGUI_EVENT_MOUSE_MOTION_INIT(event);
/* re-init mouse event */
RTGUI_EVENT_MOUSE_MOTION_INIT(event);
win = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
if (win != RT_NULL && win->monitor_list.next != RT_NULL)
{
// FIXME:
/* check whether the monitor exist */
if (rtgui_mouse_monitor_contains_point(&(win->monitor_list),
event->x, event->y) != RT_TRUE)
{
win = RT_NULL;
}
}
win = rtgui_topwin_get_wnd_no_modaled(event->x, event->y);
if (win != RT_NULL && win->monitor_list.next != RT_NULL)
{
// FIXME:
/* check whether the monitor exist */
if (rtgui_mouse_monitor_contains_point(&(win->monitor_list),
event->x, event->y) != RT_TRUE)
{
win = RT_NULL;
}
}
if (last_monitor_topwin != RT_NULL)
{
event->wid = last_monitor_topwin->wid;
/* send mouse motion event */
rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
}
if (last_monitor_topwin != RT_NULL)
{
event->wid = last_monitor_topwin->wid;
/* send mouse motion event */
rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
}
if (last_monitor_topwin != win)
{
last_monitor_topwin = win;
if (last_monitor_topwin != RT_NULL)
{
event->wid = last_monitor_topwin->wid;
if (last_monitor_topwin != win)
{
last_monitor_topwin = win;
if (last_monitor_topwin != RT_NULL)
{
event->wid = last_monitor_topwin->wid;
/* send mouse motion event */
rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
}
}
/* send mouse motion event */
rtgui_send(last_monitor_topwin->tid, &(event->parent), sizeof(struct rtgui_event_mouse));
}
}
/* move mouse to (x, y) */
rtgui_mouse_moveto(event->x, event->y);
/* move mouse to (x, 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 */
RTGUI_EVENT_KBD_INIT(event);
/* re-init to server thread */
RTGUI_EVENT_KBD_INIT(event);
/* todo: handle input method and global shortcut */
/* todo: handle input method and global shortcut */
wnd = rtgui_topwin_get_focus();
if (wnd != RT_NULL)
{
RT_ASSERT(wnd->flag & WINTITLE_ACTIVATE)
wnd = rtgui_topwin_get_focus();
if (wnd != RT_NULL)
{
RT_ASSERT(wnd->flag & WINTITLE_ACTIVATE)
/* send to focus window */
event->wid = wnd->wid;
/* send to focus window */
event->wid = wnd->wid;
/* send keyboard event to thread */
rtgui_send(wnd->tid, (struct rtgui_event*)event, sizeof(struct rtgui_event_kbd));
/* send keyboard event to thread */
rtgui_send(wnd->tid, (struct rtgui_event *)event, sizeof(struct rtgui_event_kbd));
return;
}
return;
}
}
#ifdef _WIN32
#ifdef _WIN32_NATIVE
#include <windows.h>
#endif
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(event != RT_NULL);
@ -203,107 +203,107 @@ static rt_bool_t rtgui_server_event_handler(struct rtgui_object *object,
switch (event->type)
{
case RTGUI_EVENT_APP_CREATE:
case RTGUI_EVENT_APP_DESTROY:
if (rtgui_wm_application != RT_NULL)
{
/* forward event to wm application */
rtgui_send(rtgui_wm_application->tid, event, sizeof(struct rtgui_event_application));
}
else
{
/* always ack with OK */
rtgui_ack(event, RTGUI_STATUS_OK);
}
break;
case RTGUI_EVENT_APP_DESTROY:
if (rtgui_wm_application != RT_NULL)
{
/* forward event to wm application */
rtgui_send(rtgui_wm_application->tid, event, sizeof(struct rtgui_event_application));
}
else
{
/* always ack with OK */
rtgui_ack(event, RTGUI_STATUS_OK);
}
break;
/* mouse and keyboard event */
/* mouse and keyboard event */
case RTGUI_EVENT_MOUSE_MOTION:
/* 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;
case RTGUI_EVENT_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;
case RTGUI_EVENT_KBD:
/* handle keyboard event */
rtgui_server_handle_kbd((struct rtgui_event_kbd*)event);
rtgui_server_handle_kbd((struct rtgui_event_kbd *)event);
break;
/* window event */
/* window event */
case RTGUI_EVENT_WIN_CREATE:
if (rtgui_topwin_add((struct rtgui_event_win_create*)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
if (rtgui_topwin_add((struct rtgui_event_win_create *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
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);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
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);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
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);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_MODAL_ENTER:
if (rtgui_topwin_modal_enter((struct rtgui_event_win_modal_enter*)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_MODAL_ENTER:
if (rtgui_topwin_modal_enter((struct rtgui_event_win_modal_enter *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_ACTIVATE:
if (rtgui_topwin_activate((struct rtgui_event_win_activate*)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_ACTIVATE:
if (rtgui_topwin_activate((struct rtgui_event_win_activate *)event) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_DESTROY:
if (last_monitor_topwin != RT_NULL &&
last_monitor_topwin->wid == ((struct rtgui_event_win*)event)->wid)
last_monitor_topwin = RT_NULL;
if (rtgui_topwin_remove(((struct rtgui_event_win*)event)->wid) == RT_EOK)
if (last_monitor_topwin != RT_NULL &&
last_monitor_topwin->wid == ((struct rtgui_event_win *)event)->wid)
last_monitor_topwin = RT_NULL;
if (rtgui_topwin_remove(((struct rtgui_event_win *)event)->wid) == RT_EOK)
rtgui_ack(event, RTGUI_STATUS_OK);
else
rtgui_ack(event, RTGUI_STATUS_ERROR);
break;
case RTGUI_EVENT_WIN_RESIZE:
rtgui_topwin_resize(((struct rtgui_event_win_resize*)event)->wid,
&(((struct rtgui_event_win_resize*)event)->rect));
rtgui_topwin_resize(((struct rtgui_event_win_resize *)event)->wid,
&(((struct rtgui_event_win_resize *)event)->rect));
break;
case RTGUI_EVENT_SET_WM:
if (rtgui_wm_application != RT_NULL)
{
rtgui_ack(event, RTGUI_STATUS_ERROR);
}
else
{
struct rtgui_event_set_wm *set_wm;
case RTGUI_EVENT_SET_WM:
if (rtgui_wm_application != RT_NULL)
{
rtgui_ack(event, RTGUI_STATUS_ERROR);
}
else
{
struct rtgui_event_set_wm *set_wm;
set_wm = (struct rtgui_event_set_wm*) event;
rtgui_wm_application = set_wm->app;
rtgui_ack(event, RTGUI_STATUS_OK);
}
break;
set_wm = (struct rtgui_event_set_wm *) event;
rtgui_wm_application = set_wm->app;
rtgui_ack(event, RTGUI_STATUS_OK);
}
break;
/* other event */
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:
/* 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
/* 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:
/* handle mouse monitor */
rtgui_server_handle_monitor_add((struct rtgui_event_monitor*)event);
rtgui_server_handle_monitor_add((struct rtgui_event_monitor *)event);
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
*/
static void rtgui_server_entry(void* parameter)
static void rtgui_server_entry(void *parameter)
{
#ifdef _WIN32
/* set the server thread to highest */
HANDLE hCurrentThread = GetCurrentThread();
SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST);
#ifdef _WIN32_NATIVE
/* set the server thread to highest */
HANDLE hCurrentThread = GetCurrentThread();
SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST);
#endif
/* create rtgui server application */
rtgui_server_application = rtgui_app_create(rtgui_server_tid,
"rtgui");
/* create rtgui server application */
rtgui_server_application = rtgui_app_create(rtgui_server_tid,
"rtgui");
if (rtgui_server_application == RT_NULL)
return;
rtgui_object_set_event_handler(RTGUI_OBJECT(rtgui_server_application),
rtgui_server_event_handler);
/* init mouse and show */
rtgui_mouse_init();
/* init mouse and show */
rtgui_mouse_init();
#ifdef RTGUI_USING_MOUSE_CURSOR
rtgui_mouse_show_cursor();
rtgui_mouse_show_cursor();
#endif
rtgui_app_run(rtgui_server_application);
@ -365,23 +368,23 @@ static void rtgui_server_entry(void* parameter)
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)
rtgui_send(rtgui_server_tid, event, size);
else
rt_kprintf("post when server is not running\n");
if (rtgui_server_tid != RT_NULL)
rtgui_send(rtgui_server_tid, event, size);
else
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)
return rtgui_send_sync(rtgui_server_tid, event, size);
else
{
rt_kprintf("post when server is not running\n");
return -RT_ENOSYS;
}
if (rtgui_server_tid != RT_NULL)
return rtgui_send_sync(rtgui_server_tid, event, size);
else
{
rt_kprintf("post when server is not running\n");
return -RT_ENOSYS;
}
}
void rtgui_server_init(void)
@ -389,13 +392,13 @@ void rtgui_server_init(void)
if (rtgui_server_tid != RT_NULL)
return;
rtgui_server_tid = rt_thread_create("rtgui",
rtgui_server_entry, RT_NULL,
RTGUI_SVR_THREAD_STACK_SIZE,
RTGUI_SVR_THREAD_PRIORITY,
RTGUI_SVR_THREAD_TIMESLICE);
rtgui_server_tid = rt_thread_create("rtgui",
rtgui_server_entry, RT_NULL,
RTGUI_SVR_THREAD_STACK_SIZE,
RTGUI_SVR_THREAD_PRIORITY,
RTGUI_SVR_THREAD_TIMESLICE);
/* start rtgui server thread */
if (rtgui_server_tid != RT_NULL)
rt_thread_startup(rtgui_server_tid);
/* start rtgui server thread */
if (rtgui_server_tid != RT_NULL)
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>
/* add or remove a top win */
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_activate(struct rtgui_event_win_activate* event);
rt_err_t rtgui_topwin_activate_topwin(struct rtgui_topwin* win);
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_activate(struct rtgui_event_win_activate *event);
rt_err_t rtgui_topwin_activate_topwin(struct rtgui_topwin *win);
/* 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 */
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 */
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 */
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 */
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) */
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(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);
/* window title */
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_ondraw(struct rtgui_topwin *win);
void rtgui_topwin_title_onmouse(struct rtgui_topwin *win, struct rtgui_event_mouse *event);
/* monitor 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_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);
/* get the topwin that is currently focused */
struct rtgui_topwin* rtgui_topwin_get_focus(void);
struct rtgui_topwin *rtgui_topwin_get_focus(void);
#endif

View File

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

View File

@ -16,276 +16,276 @@
#include <rtgui/widgets/button.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)
{
/* init widget and set event handler */
RTGUI_WIDGET(button)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(button), rtgui_button_event_handler);
rtgui_widget_set_onunfocus(RTGUI_WIDGET(button), rtgui_button_onunfocus);
/* un-press button */
button->flag = 0;
/* init widget and set event handler */
RTGUI_WIDGET(button)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(button), rtgui_button_event_handler);
rtgui_widget_set_onunfocus(RTGUI_WIDGET(button), rtgui_button_onunfocus);
/* un-press button */
button->flag = 0;
/* set flag and on_button event handler */
button->pressed_image = RT_NULL;
button->unpressed_image = RT_NULL;
button->on_button = RT_NULL;
/* set flag and on_button event handler */
button->pressed_image = RT_NULL;
button->unpressed_image = RT_NULL;
button->on_button = RT_NULL;
/* set gc */
RTGUI_WIDGET_FOREGROUND(button) = default_foreground;
RTGUI_WIDGET_BACKGROUND(button) = RTGUI_RGB(212, 208, 200);
RTGUI_WIDGET_TEXTALIGN(button) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
/* set gc */
RTGUI_WIDGET_FOREGROUND(button) = default_foreground;
RTGUI_WIDGET_BACKGROUND(button) = RTGUI_RGB(212, 208, 200);
RTGUI_WIDGET_TEXTALIGN(button) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
}
static void _rtgui_button_destructor(rtgui_button_t *button)
{
if (button->pressed_image != RT_NULL)
{
rtgui_image_destroy(button->pressed_image);
button->pressed_image = RT_NULL;
}
if (button->pressed_image != RT_NULL)
{
rtgui_image_destroy(button->pressed_image);
button->pressed_image = RT_NULL;
}
if (button->unpressed_image != RT_NULL)
{
rtgui_image_destroy(button->unpressed_image);
button->unpressed_image = RT_NULL;
}
if (button->unpressed_image != RT_NULL)
{
rtgui_image_destroy(button->unpressed_image);
button->unpressed_image = RT_NULL;
}
}
DEFINE_CLASS_TYPE(button, "button",
RTGUI_LABEL_TYPE,
_rtgui_button_constructor,
_rtgui_button_destructor,
sizeof(struct rtgui_button));
DEFINE_CLASS_TYPE(button, "button",
RTGUI_LABEL_TYPE,
_rtgui_button_constructor,
_rtgui_button_destructor,
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_button *btn;
struct rtgui_widget *widget;
struct rtgui_button *btn;
RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL);
RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL);
widget = RTGUI_WIDGET(object);
btn = RTGUI_BUTTON(widget);
switch (event->type)
{
case RTGUI_EVENT_PAINT:
rtgui_theme_draw_button(btn);
break;
widget = RTGUI_WIDGET(object);
btn = RTGUI_BUTTON(widget);
switch (event->type)
{
case RTGUI_EVENT_PAINT:
rtgui_theme_draw_button(btn);
break;
case RTGUI_EVENT_KBD:
{
struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*) event;
case RTGUI_EVENT_KBD:
{
struct rtgui_event_kbd *ekbd = (struct rtgui_event_kbd *) event;
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE))
{
if (RTGUI_KBD_IS_DOWN(ekbd))
{
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
}
else
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
}
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE))
{
if (RTGUI_KBD_IS_DOWN(ekbd))
{
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
}
else
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
}
/* draw button */
rtgui_theme_draw_button(btn);
/* draw button */
rtgui_theme_draw_button(btn);
if ((btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
{
/* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event);
}
}
}
break;
if ((btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
{
/* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event);
}
}
}
break;
case RTGUI_EVENT_MOUSE_BUTTON:
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
{
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event;
case RTGUI_EVENT_MOUSE_BUTTON:
if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
{
struct rtgui_event_mouse *emouse = (struct rtgui_event_mouse *)event;
/* it's not this widget event, clean status */
if (rtgui_rect_contains_point(&(RTGUI_WIDGET(btn)->extent),
emouse->x, emouse->y) != RT_EOK)
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
/* draw button */
rtgui_theme_draw_button(btn);
/* it's not this widget event, clean status */
if (rtgui_rect_contains_point(&(RTGUI_WIDGET(btn)->extent),
emouse->x, emouse->y) != RT_EOK)
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
/* draw button */
rtgui_theme_draw_button(btn);
break;
}
break;
}
if (btn->flag & RTGUI_BUTTON_TYPE_PUSH)
{
/* it's a push button */
if (emouse->button & RTGUI_MOUSE_BUTTON_UP)
{
if (btn->flag & RTGUI_BUTTON_FLAG_PRESS)
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
}
else
{
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
}
if (btn->flag & RTGUI_BUTTON_TYPE_PUSH)
{
/* it's a push button */
if (emouse->button & RTGUI_MOUSE_BUTTON_UP)
{
if (btn->flag & RTGUI_BUTTON_FLAG_PRESS)
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
}
else
{
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
}
/* draw button */
rtgui_theme_draw_button(btn);
/* draw button */
rtgui_theme_draw_button(btn);
if (btn->on_button != RT_NULL)
{
/* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event);
}
if (btn->on_button != RT_NULL)
{
/* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event);
}
#ifndef RTGUI_USING_SMALL_SIZE
/* invokes call back */
if (widget->on_mouseclick != RT_NULL &&
emouse->button & RTGUI_MOUSE_BUTTON_UP)
return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
/* invokes call back */
if (widget->on_mouseclick != RT_NULL &&
emouse->button & RTGUI_MOUSE_BUTTON_UP)
return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
#endif
}
}
else
{
if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT)
{
/* set the last mouse event handled widget */
struct rtgui_win* win;
}
}
else
{
if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT)
{
/* set the last mouse event handled widget */
struct rtgui_win *win;
win = RTGUI_WIN(RTGUI_WIDGET(btn)->toplevel);
win->last_mevent_widget = RTGUI_WIDGET(btn);
win = RTGUI_WIN(RTGUI_WIDGET(btn)->toplevel);
win->last_mevent_widget = RTGUI_WIDGET(btn);
/* it's a normal button */
if (emouse->button & RTGUI_MOUSE_BUTTON_DOWN)
{
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
}
else
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
}
/* it's a normal button */
if (emouse->button & RTGUI_MOUSE_BUTTON_DOWN)
{
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
}
else
{
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
}
/* draw button */
rtgui_theme_draw_button(btn);
/* draw button */
rtgui_theme_draw_button(btn);
#ifndef RTGUI_USING_SMALL_SIZE
/* invokes call back */
if (widget->on_mouseclick != RT_NULL &&
emouse->button & RTGUI_MOUSE_BUTTON_UP)
return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
/* invokes call back */
if (widget->on_mouseclick != RT_NULL &&
emouse->button & RTGUI_MOUSE_BUTTON_UP)
return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
#endif
if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
{
/* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event);
}
}
if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
{
/* call on button handler */
btn->on_button(RTGUI_OBJECT(widget), event);
}
}
}
}
return RT_TRUE;
}
default:
return rtgui_widget_event_handler(object, event);
}
return RT_TRUE;
}
default:
return rtgui_widget_event_handler(object, event);
}
return RT_FALSE;
return RT_FALSE;
}
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)
{
rtgui_rect_t rect;
rtgui_rect_t rect;
/* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rtgui_widget_set_rect(RTGUI_WIDGET(btn), &rect);
rtgui_label_set_text(RTGUI_LABEL(btn), text);
/* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rtgui_widget_set_rect(RTGUI_WIDGET(btn), &rect);
rtgui_label_set_text(RTGUI_LABEL(btn), text);
}
return btn;
}
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);
if (btn != RT_NULL) btn->flag |= RTGUI_BUTTON_TYPE_PUSH;
btn = rtgui_button_create(text);
if (btn != RT_NULL) btn->flag |= RTGUI_BUTTON_TYPE_PUSH;
return btn;
return btn;
}
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);
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);
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);
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);
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_widget_t *widget;
struct rtgui_dc *dc;
rtgui_rect_t rect;
rtgui_widget_t *widget;
struct rtgui_dc *dc;
RT_ASSERT(object);
widget = RTGUI_WIDGET(object);
RT_ASSERT(object);
widget = RTGUI_WIDGET(object);
dc = rtgui_dc_begin_drawing(widget);
if(dc == RT_NULL) return RT_FALSE;
rtgui_widget_get_rect(widget, &rect);
dc = rtgui_dc_begin_drawing(widget);
if (dc == RT_NULL) return RT_FALSE;
if(!RTGUI_WIDGET_IS_FOCUSED(widget))
{
/* 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_widget_get_rect(widget, &rect);
rtgui_dc_end_drawing(dc);
return RT_TRUE;
if (!RTGUI_WIDGET_IS_FOCUSED(widget))
{
/* 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)
{
/* init widget and set event handler */
RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_checkbox_event_handler);
/* init widget and set event handler */
RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_checkbox_event_handler);
/* set status */
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
box->on_button = RT_NULL;
/* set status */
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
box->on_button = RT_NULL;
/* set default gc */
RTGUI_WIDGET_TEXTALIGN(box) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
/* set default gc */
RTGUI_WIDGET_TEXTALIGN(box) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
}
DEFINE_CLASS_TYPE(checkbox, "checkbox",
RTGUI_LABEL_TYPE,
_rtgui_checkbox_constructor,
RT_NULL,
sizeof(struct rtgui_checkbox));
RTGUI_LABEL_TYPE,
_rtgui_checkbox_constructor,
RT_NULL,
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)
{
case RTGUI_EVENT_PAINT:
switch (event->type)
{
case RTGUI_EVENT_PAINT:
#ifndef RTGUI_USING_SMALL_SIZE
if (widget->on_draw != RT_NULL)
{
return widget->on_draw(RTGUI_OBJECT(widget), event);
}
else
if (widget->on_draw != RT_NULL)
{
return widget->on_draw(RTGUI_OBJECT(widget), event);
}
else
#endif
rtgui_theme_draw_checkbox(box);
break;
rtgui_theme_draw_checkbox(box);
break;
case RTGUI_EVENT_MOUSE_BUTTON:
{
if (RTGUI_WIDGET_IS_ENABLE(widget) && !RTGUI_WIDGET_IS_HIDE(widget))
{
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event;
if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT &&
emouse->button & RTGUI_MOUSE_BUTTON_UP)
{
/* set focus */
rtgui_widget_focus(widget);
case RTGUI_EVENT_MOUSE_BUTTON:
{
if (RTGUI_WIDGET_IS_ENABLE(widget) && !RTGUI_WIDGET_IS_HIDE(widget))
{
struct rtgui_event_mouse *emouse = (struct rtgui_event_mouse *)event;
if (emouse->button & RTGUI_MOUSE_BUTTON_LEFT &&
emouse->button & RTGUI_MOUSE_BUTTON_UP)
{
/* set focus */
rtgui_widget_focus(widget);
if (box->status_down & RTGUI_CHECKBOX_STATUS_UNCHECKED)
{
/* check it */
box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
}
else
{
/* un-check it */
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
}
}
if (box->status_down & RTGUI_CHECKBOX_STATUS_UNCHECKED)
{
/* check it */
box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
}
else
{
/* un-check it */
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
}
}
/* draw checkbox */
rtgui_theme_draw_checkbox(box);
/* draw checkbox */
rtgui_theme_draw_checkbox(box);
#ifndef RTGUI_USING_SMALL_SIZE
/* call user callback */
if (widget->on_mouseclick != RT_NULL)
{
return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
}
/* call user callback */
if (widget->on_mouseclick != RT_NULL)
{
return widget->on_mouseclick(RTGUI_OBJECT(widget), event);
}
#endif
if (box->on_button != RT_NULL)
{
box->on_button(RTGUI_OBJECT(widget), event);
return RT_TRUE;
}
}
if (box->on_button != RT_NULL)
{
box->on_button(RTGUI_OBJECT(widget), event);
return RT_TRUE;
}
}
return RT_TRUE;
}
default:
return rtgui_widget_event_handler(object, event);
}
return RT_TRUE;
}
default:
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)
{
rtgui_rect_t rect;
rtgui_rect_t rect;
/* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += RTGUI_BORDER_DEFAULT_WIDTH + 5 + (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
/* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += RTGUI_BORDER_DEFAULT_WIDTH + 5 + (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);
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;
}
rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);
rtgui_label_set_text(RTGUI_LABEL(box), text);
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);
if (checked == RT_TRUE)
checkbox->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
else
checkbox->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
RT_ASSERT(checkbox != RT_NULL);
if (checked == RT_TRUE)
checkbox->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
else
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)
return RT_TRUE;
if (checkbox->status_down == RTGUI_CHECKBOX_STATUS_CHECKED)
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