提交 a0e99e8a 编写于 作者: B bernard.xiong

add RTGUI source code

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@104 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 72adcb33
/*
* File : asc12font.c
* 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
*/
#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 struct rtgui_font_bitmap asc12 =
{
asc12_font, /* bmp */
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 */
};
此差异已折叠。
/*
* File : caret.c
* 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
*/
#include <rtgui/dc.h>
#include <rtgui/caret.h>
#include <rtgui/rtgui_system.h>
#define RTGUI_CARET_WIDTH 2
#ifdef __WIN32__
#define RTGUI_CARET_BLINK 300
#else
#define RTGUI_CARET_BLINK 30
#endif
static void rtgui_caret_blink(struct rtgui_timer* timer, void* parameter)
{
struct rtgui_caret* caret;
rtgui_widget_t* widget;
caret = (struct rtgui_caret*)parameter;
RT_ASSERT(caret != RT_NULL);
if (caret->owner == RT_NULL) return;
/* caret's owner is visible? */
widget = caret->owner;
do
{
if (RTGUI_WIDGET_IS_HIDE(widget) == RT_TRUE) return;
widget = widget->parent;
} while (widget != RT_NULL);
if (caret->is_show == RT_TRUE)
{
/* set to false */
caret->is_show = RT_FALSE;
/* update owner widget */
if (caret->owner != RT_NULL)
{
rtgui_widget_update(caret->owner);
}
}
else
{
/* set to true */
caret->is_show = RT_TRUE;
/* draw caret */
rtgui_caret_draw(caret);
}
}
struct rtgui_caret* rtgui_caret_create(struct rtgui_widget* owner)
{
struct rtgui_caret* caret;
RT_ASSERT(owner != RT_NULL);
caret = (struct rtgui_caret*)rtgui_malloc(sizeof(struct rtgui_caret));
if (caret != RT_NULL)
{
caret->is_show = RT_FALSE;
caret->extent.x1 = 0;
caret->extent.y1 = 0;
caret->extent.x2 = RTGUI_CARET_WIDTH;
caret->extent.y2 = owner->gc.font->height;
caret->owner = owner;
caret->dc = (struct rtgui_dc*)rtgui_dc_buffer_create(RTGUI_CARET_WIDTH, caret->extent.y2);
if (caret->dc == RT_NULL) goto __exit;
rtgui_dc_set_color(caret->dc, black);
rtgui_dc_fill_rect(caret->dc, &(caret->extent));
caret->timer_period = RTGUI_CARET_BLINK;
caret->timer = rtgui_timer_create(caret->timer_period,
RT_TIMER_FLAG_PERIODIC,
rtgui_caret_blink, caret);
if (caret->timer == RT_NULL) goto __exit_dc;
caret->show_point.x = 0;
caret->show_point.y = 0;
}
return caret;
__exit_dc:
rtgui_dc_destory(caret->dc);
__exit:
rtgui_free(caret);
return RT_NULL;
}
void rtgui_caret_destroy(struct rtgui_caret* caret)
{
RT_ASSERT(caret != RT_NULL);
if (caret->is_show == RT_TRUE)
{
/* stop timer */
rtgui_timer_stop(caret->timer);
}
caret->owner = RT_NULL;
rtgui_dc_destory(caret->dc);
rtgui_timer_destory(caret->timer);
rtgui_free(caret);
}
/* show caret on owner widget logic position */
void rtgui_caret_show(struct rtgui_caret* caret, rt_base_t x, rt_base_t y)
{
if (caret->is_show == RT_TRUE)
{
/* set show flag and stop blink timer */
caret->is_show = RT_FALSE;
rtgui_timer_stop(caret->timer);
}
/* set show x and y */
caret->show_point.x = x;
caret->show_point.y = y;
/* set show flag and start blink timer */
caret->is_show = RT_TRUE;
/* draw caret */
rtgui_caret_draw(caret);
/* start blink timer */
rtgui_timer_start(caret->timer);
}
void rtgui_caret_hide(struct rtgui_caret* caret)
{
RT_ASSERT(caret != RT_NULL);
/* set show flag and stop blink timer */
caret->is_show = RT_FALSE;
rtgui_timer_stop(caret->timer);
/* update owner widget */
if (caret->owner != RT_NULL)
{
rtgui_widget_update(caret->owner);
}
}
void rtgui_caret_set_point(struct rtgui_caret* caret, int x, int y)
{
RT_ASSERT(caret != RT_NULL);
if (caret->is_show == RT_TRUE)
{
/* stop the old caret */
rtgui_timer_stop(caret->timer);
/* update owner widget */
if (caret->owner != RT_NULL && caret->is_show)
{
rtgui_widget_update(caret->owner);
}
}
caret->show_point.x = x;
caret->show_point.y = y;
/* draw caret */
rtgui_caret_draw(caret);
/* start blink timer */
rtgui_timer_start(caret->timer);
}
void rtgui_caret_set_box(struct rtgui_caret* caret, int w, int h)
{
RT_ASSERT(caret != RT_NULL);
caret->extent.x2 = caret->extent.x1 + w;
caret->extent.y2 = caret->extent.y1 + h;
}
void rtgui_caret_draw(struct rtgui_caret* caret)
{
RT_ASSERT(caret != RT_NULL);
if (caret->is_show == RT_TRUE && caret->owner->toplevel != RT_NULL)
{
struct rtgui_rect rect = caret->extent;
struct rtgui_point point = {0, 0};
struct rtgui_dc* hw_dc;
rtgui_rect_moveto(&rect, caret->show_point.x, caret->show_point.y);
hw_dc = rtgui_dc_begin_drawing(caret->owner);
rtgui_dc_blit(caret->dc, &point, hw_dc, &rect);
rtgui_dc_end_drawing(hw_dc);
}
}
/*
* File : color.c
* 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
*/
#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 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 default_foreground = RTGUI_RGB(0x00, 0x00, 0x00);
const rtgui_color_t default_background = RTGUI_RGB(0xff, 0xff, 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 : dc_buffer.c
* 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
*/
#include <rtgui/rtgui.h>
#include <rtgui/dc.h>
#include <rtgui/color.h>
#include <rtgui/rtgui_system.h>
struct rtgui_dc_buffer
{
struct rtgui_dc parent;
/* color and font */
rtgui_color_t color;
struct rtgui_font* font;
/* text align */
rt_int32_t align;
/* width and height */
rt_uint16_t width, height;
rt_uint16_t pitch;
/* blit info */
rt_uint32_t clip_sync;
rtgui_region_t clip;
/* 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_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(struct rtgui_dc* self, struct rtgui_point* dc_point,
struct rtgui_dc* dest, rtgui_rect_t* rect);
static void rtgui_dc_buffer_set_color (struct rtgui_dc* dc, rtgui_color_t color);
static rtgui_color_t rtgui_dc_buffer_get_color(struct rtgui_dc* dc);
static void rtgui_dc_buffer_set_font(struct rtgui_dc* dc, rtgui_font_t* font);
static rtgui_font_t* rtgui_dc_buffer_get_font(struct rtgui_dc* dc);
static void rtgui_dc_buffer_set_textalign(struct rtgui_dc* dc, rt_int32_t textalign);
static rt_int32_t rtgui_dc_buffer_get_textalign(struct rtgui_dc* dc);
static rt_bool_t rtgui_dc_buffer_get_visible(struct rtgui_dc* dc);
static void rtgui_dc_buffer_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect);
static void rtgui_dc_buffer_init(struct rtgui_dc_buffer* dc)
{
if (dc == RT_NULL) return;
dc->parent.type = RTGUI_DC_BUFFER;
dc->parent.draw_point = rtgui_dc_buffer_draw_point;
dc->parent.draw_hline = rtgui_dc_buffer_draw_hline;
dc->parent.draw_vline = rtgui_dc_buffer_draw_vline;
dc->parent.fill_rect = rtgui_dc_buffer_fill_rect;
dc->parent.blit = rtgui_dc_buffer_blit;
dc->parent.set_color = rtgui_dc_buffer_set_color;
dc->parent.get_color = rtgui_dc_buffer_get_color;
dc->parent.set_font = rtgui_dc_buffer_set_font;
dc->parent.get_font = rtgui_dc_buffer_get_font;
dc->parent.set_textalign = rtgui_dc_buffer_set_textalign;
dc->parent.get_textalign = rtgui_dc_buffer_get_textalign;
dc->parent.get_visible= rtgui_dc_buffer_get_visible;
dc->parent.get_rect = rtgui_dc_buffer_get_rect;
dc->parent.fini = rtgui_dc_buffer_fini;
}
struct rtgui_dc* rtgui_dc_buffer_create(int w, int h)
{
struct rtgui_dc_buffer* dc;
dc = (struct rtgui_dc_buffer*)rtgui_malloc(sizeof(struct rtgui_dc_buffer));
rtgui_dc_buffer_init(dc);
dc->color = 0;
dc->font = RT_NULL;
dc->align = 0;
dc->width = w;
dc->height = h;
dc->pitch = w * sizeof(rtgui_color_t);
dc->clip_sync = 0;
rtgui_region_init(&(dc->clip));
dc->pixel = rtgui_malloc(h * dc->pitch);
rt_memset(dc->pixel, 0, h * dc->pitch);
return &(dc->parent);
}
rt_uint8_t* rtgui_dc_buffer_get_pixel(struct rtgui_dc* dc)
{
struct rtgui_dc_buffer* dc_buffer;
dc_buffer = (struct rtgui_dc_buffer*)dc;
return dc_buffer->pixel;
}
static rt_bool_t rtgui_dc_buffer_fini(struct rtgui_dc* dc)
{
struct rtgui_dc_buffer* buffer = (struct rtgui_dc_buffer*)dc;
if (dc->type != RTGUI_DC_BUFFER) return RT_FALSE;
rtgui_free(buffer->pixel);
buffer->pixel = RT_NULL;
return RT_TRUE;
}
static void rtgui_dc_buffer_draw_point(struct rtgui_dc* self, int x, int y)
{
rtgui_color_t* ptr;
struct rtgui_dc_buffer* dc;
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));
*ptr = dc->color;
}
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;
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;
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->color;
ptr += dc->width;
}
}
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;
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->color;
}
}
static void rtgui_dc_buffer_fill_rect (struct rtgui_dc* self, struct rtgui_rect* rect)
{
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;
/* fill first line */
rtgui_dc_buffer_draw_hline(&(dc->parent), r.x1, r.x2, r.y1);
/* 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));
}
}
}
/* rtgui_color to RGB323 */
rt_inline void rtgui_blit_line_1(rtgui_color_t* color, rt_uint8_t* dest, int line)
{
struct _color {rt_uint8_t r, g, b, a;} *c;
c = (struct _color*)color;
while (line-- > 0)
{
*dest = (c->r & 0xe0) | (c->g & 0xc0) >> 3 | (c->b & 0xe0) >> 5 ;
c ++;
dest ++;
}
}
/* rtgui_color to RGB565 */
rt_inline void rtgui_blit_line_2(rtgui_color_t* color, rt_uint8_t* dest, int line)
{
struct _color {rt_uint8_t r, g, b, a;} *c;
rt_uint16_t* ptr;
c = (struct _color*)color;
ptr = (rt_uint16_t*)dest;
while (line-- > 0)
{
*ptr = ((c->r & 0xf8) << 8) | ((c->g & 0xfc) << 3) | (c->b >> 3);
c ++;
ptr ++;
}
}
/* rtgui_color to RGB888 */
rt_inline void rtgui_blit_line_4(rtgui_color_t* color, rt_uint8_t* dest, int line)
{
rt_memcpy(dest, color, line * 4);
}
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_hw* hw = (struct rtgui_dc_hw*)dest;
if (dest->type == RTGUI_DC_HW)
{
register int index;
int fb_pitch;
rtgui_rect_t abs_rect;
void (*blit_line)(rtgui_color_t* color, rt_uint8_t* dest, int line);
abs_rect.x1 = hw->owner->extent.x1 + rect->x1;
abs_rect.y1 = hw->owner->extent.y1 + rect->y1;
abs_rect.x2 = abs_rect.x1 + rtgui_rect_width(*rect);
abs_rect.y2 = abs_rect.y1 + rtgui_rect_height(*rect);
/* hw fb pitch */
fb_pitch = hw->device->byte_per_pixel * hw->device->width;
/* hardware dc blit */
if (!rtgui_region_not_empty(&dc->clip) ||
dc->clip_sync != hw->owner->clip_sync)
{
/* should re-calculate clip */
rtgui_region_intersect_rect(&(dc->clip),
&(hw->owner->clip), &abs_rect);
}
switch (hw->device->byte_per_pixel)
{
case 1:
blit_line = rtgui_blit_line_1;
break;
case 2:
blit_line = rtgui_blit_line_2;
break;
case 3:
blit_line = rtgui_blit_line_4;
break;
default:
/* can not blit */
return;
}
/* blit each clip rect */
if (dc->clip.data == RT_NULL)
{
int y;
rtgui_color_t* pixel;
rt_uint8_t* fb;
pixel = (rtgui_color_t*)(dc->pixel + (dc_point->y + dc->clip.extents.y1 - abs_rect.y1) * dc->pitch +
(dc_point->x + dc->clip.extents.x1 - abs_rect.x1) * sizeof(rtgui_color_t));
fb = hw->device->get_framebuffer() + dc->clip.extents.y1 * fb_pitch +
dc->clip.extents.x1 * hw->device->byte_per_pixel;
for (y = dc->clip.extents.y1; y < dc->clip.extents.y2; y ++)
{
blit_line(pixel, fb, dc->clip.extents.x2 - dc->clip.extents.x1);
fb += fb_pitch;
pixel += dc->width;
}
}
else for (index = 0; index < rtgui_region_num_rects(&(dc->clip)); index ++)
{
int y;
rtgui_rect_t* prect;
rtgui_color_t* pixel;
rt_uint8_t* fb;
prect = ((rtgui_rect_t *)(dc->clip.data + index + 1));
pixel = (rtgui_color_t*)(dc->pixel + (dc_point->y + prect->y1 - abs_rect.y1) * dc->pitch +
(dc_point->x + prect->x1 - abs_rect.x1) * sizeof(rtgui_color_t));
fb = hw->device->get_framebuffer() + prect->y1 * fb_pitch +
prect->x1 * hw->device->byte_per_pixel;
for (y = prect->y1; y < prect->y2; y ++)
{
blit_line(pixel, fb, prect->x2 - prect->x1);
fb += fb_pitch;
pixel += dc->width;
}
}
}
}
static void rtgui_dc_buffer_set_color (struct rtgui_dc* self, rtgui_color_t color)
{
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
dc->color = color;
}
static rtgui_color_t rtgui_dc_buffer_get_color(struct rtgui_dc* self)
{
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
return dc->color;
}
static void rtgui_dc_buffer_set_font(struct rtgui_dc* self, rtgui_font_t* font)
{
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
dc->font = font;
}
static rtgui_font_t* rtgui_dc_buffer_get_font(struct rtgui_dc* self)
{
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
return dc->font;
}
static void rtgui_dc_buffer_set_textalign(struct rtgui_dc* self, rt_int32_t textalign)
{
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
dc->align = textalign;
}
static rt_int32_t rtgui_dc_buffer_get_textalign(struct rtgui_dc* self)
{
struct rtgui_dc_buffer* dc = (struct rtgui_dc_buffer*)self;
return dc->align;
}
static rt_bool_t rtgui_dc_buffer_get_visible(struct rtgui_dc* dc)
{
return RT_TRUE;
}
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;
rect->x1 = rect->y1 = 0;
rect->x2 = dc->width;
rect->y2 = dc->height;
}
/*
* File : dc_hw.c
* 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
*/
#include <rtgui/dc.h>
#include <rtgui/driver.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/view.h>
#include <rtgui/widgets/window.h>
#include <rtgui/widgets/workbench.h>
#include <rtgui/widgets/title.h>
static void rtgui_dc_hw_draw_point(struct rtgui_dc* dc, int x, int y);
static void rtgui_dc_hw_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y);
static void rtgui_dc_hw_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2);
static void rtgui_dc_hw_fill_rect (struct rtgui_dc* dc, rtgui_rect_t* rect);
static void rtgui_dc_hw_blit (struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
static void rtgui_dc_hw_set_color (struct rtgui_dc* dc, rtgui_color_t color);
static rtgui_color_t rtgui_dc_hw_get_color (struct rtgui_dc* dc);
static void rtgui_dc_hw_set_font(struct rtgui_dc* dc, rtgui_font_t* font);
static rtgui_font_t* rtgui_dc_hw_get_font(struct rtgui_dc* dc);
static void rtgui_dc_hw_set_textalign(struct rtgui_dc* dc, rt_int32_t textalign);
static rt_int32_t rtgui_dc_hw_get_textalign(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* rtgui_dc_begin_drawing(rtgui_widget_t* owner)
{
return rtgui_dc_hw_create(owner);
}
void rtgui_dc_end_drawing(struct rtgui_dc* dc)
{
if (rtgui_dc_hw_fini(dc) == RT_TRUE)
{
rtgui_free(dc);
}
}
void rtgui_dc_hw_init(struct rtgui_dc_hw* dc)
{
if (dc == RT_NULL) return;
dc->parent.type = RTGUI_DC_HW;
dc->parent.draw_point = rtgui_dc_hw_draw_point;
dc->parent.draw_hline = rtgui_dc_hw_draw_hline;
dc->parent.draw_vline = rtgui_dc_hw_draw_vline;
dc->parent.fill_rect = rtgui_dc_hw_fill_rect ;
dc->parent.blit = rtgui_dc_hw_blit;
dc->parent.set_color = rtgui_dc_hw_set_color;
dc->parent.get_color = rtgui_dc_hw_get_color;
dc->parent.set_font = rtgui_dc_hw_set_font;
dc->parent.get_font = rtgui_dc_hw_get_font;
dc->parent.set_textalign = rtgui_dc_hw_set_textalign;
dc->parent.get_textalign = rtgui_dc_hw_get_textalign;
dc->parent.get_visible= rtgui_dc_hw_get_visible;
dc->parent.get_rect = rtgui_dc_hw_get_rect;
dc->parent.fini = rtgui_dc_hw_fini;
}
extern struct rt_mutex cursor_mutex;
#define dc_set_foreground(c) dc->owner->gc.foreground = c
#define dc_set_background(c) dc->owner->gc.background = c
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_hw* dc;
rtgui_widget_t* widget;
/* adjudge owner */
if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
if (!RTGUI_IS_TOPLEVEL(owner->toplevel)) return RT_NULL;
/* malloc a dc object */
dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw));
rtgui_dc_hw_init(dc);
dc->owner = owner;
dc->visible = RT_TRUE;
dc->device = rtgui_graphic_driver_get_default();
/* set visible */
widget = owner;
while (widget != RT_NULL)
{
if (RTGUI_WIDGET_IS_HIDE(widget))
{
dc->visible = RT_FALSE;
break;
}
widget = widget->parent;
}
if (RTGUI_IS_WINTITLE(dc->owner->toplevel))
{
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(dc->owner->toplevel);
top->drawing ++;
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();
#else
/* hide cursor */
rtgui_mouse_hide_cursor();
#endif
#endif
}
}
else if (RTGUI_IS_WORKBENCH(dc->owner->toplevel) ||
RTGUI_IS_WIN(dc->owner->toplevel))
{
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(dc->owner->toplevel);
top->drawing ++;
if (top->drawing == 1)
{
#ifdef __WIN32__
#ifdef RTGUI_USING_MOUSE_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;
rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
}
}
return &(dc->parent);
}
static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
{
struct rtgui_dc_hw* hw = (struct rtgui_dc_hw*)dc;
if (dc == RT_NULL || hw->parent.type != RTGUI_DC_HW) return RT_FALSE;
if (RTGUI_IS_WINTITLE(hw->owner->toplevel))
{
/* update title extent */
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(hw->owner->toplevel);
top->drawing --;
if (top->drawing == 0)
{
#ifdef __WIN32__
#ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_release(&cursor_mutex);
/* show cursor */
rtgui_mouse_show_cursor();
rt_kprintf("show cursor\n");
#endif
/* update screen */
hw->device->screen_update(&(hw->owner->extent));
#else
#ifdef RTGUI_USING_MOUSE_CURSOR
/* show cursor */
rtgui_mouse_show_cursor();
#endif
/* update screen */
hw->device->screen_update(&(hw->owner->extent));
#endif
}
}
else if (RTGUI_IS_WORKBENCH(hw->owner->toplevel) ||
RTGUI_IS_WIN(hw->owner->toplevel))
{
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(hw->owner->toplevel);
top->drawing --;
if (top->drawing == 0)
{
#ifdef __WIN32__
#ifdef RTGUI_USING_MOUSE_CURSOR
rt_mutex_release(&cursor_mutex);
/* show cursor */
rtgui_mouse_show_cursor();
rt_kprintf("show cursor\n");
#endif
/* update screen */
hw->device->screen_update(&(hw->owner->extent));
#else
/* send to server to end drawing */
struct rtgui_event_update_end eupdate;
RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
eupdate.rect = RTGUI_WIDGET(top)->extent;
rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
}
}
return RT_TRUE;
}
/*
* draw a logic point on device
*/
static void rtgui_dc_hw_draw_point(struct rtgui_dc* self, int x, int y)
{
struct rtgui_dc_hw* dc;
rtgui_rect_t rect;
dc = (struct rtgui_dc_hw*)self;
if (dc == RT_NULL || dc->visible != RT_TRUE) return;
x = x + dc->owner->extent.x1;
y = y + dc->owner->extent.y1;
if (rtgui_region_contains_point(&(dc->owner->clip), x, y, &rect) == RT_EOK)
{
/* draw this point */
dc->device->set_pixel(&(dc->owner->gc.foreground), 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)
{
register rt_base_t index;
struct rtgui_dc_hw* dc;
dc = (struct rtgui_dc_hw*)self;
if (dc == RT_NULL || dc->visible != RT_TRUE) return;
x = x + dc->owner->extent.x1;
y1 = y1 + dc->owner->extent.y1;
y2 = y2 + dc->owner->extent.y1;
if (dc->owner->clip.data == RT_NULL)
{
rtgui_rect_t* prect;
prect = &(dc->owner->clip.extents);
/* calculate vline intersect */
if (prect->x1 > x || prect->x2 <= x) return;
if (prect->y2 <= y1 || prect->y1 > y2) return;
if (prect->y1 > y1) y1 = prect->y1;
if (prect->y2 < y2) y2 = prect->y2;
/* draw vline */
dc->device->draw_vline(&(dc->owner->gc.foreground), x, y1, y2);
}
else for (index = 0; index < rtgui_region_num_rects(&(dc->owner->clip)); index ++)
{
rtgui_rect_t* prect;
register rt_base_t draw_y1, draw_y2;
prect = ((rtgui_rect_t *)(dc->owner->clip.data + index + 1));
draw_y1 = y1;
draw_y2 = y2;
/* calculate vline clip */
if (prect->x1 > x || prect->x2 <= x) continue;
if (prect->y2 <= y1 || prect->y1 > y2) continue;
if (prect->y1 > y1) draw_y1 = prect->y1;
if (prect->y2 < y2) draw_y2 = prect->y2;
/* draw vline */
dc->device->draw_vline(&(dc->owner->gc.foreground), x, draw_y1, draw_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)
{
register rt_base_t index;
struct rtgui_dc_hw* dc;
dc = (struct rtgui_dc_hw*)self;
if (dc == RT_NULL || dc->visible != RT_TRUE) return;
/* convert logic to device */
x1 = x1 + dc->owner->extent.x1;
x2 = x2 + dc->owner->extent.x1;
y = y + dc->owner->extent.y1;
if (dc->owner->clip.data == RT_NULL)
{
rtgui_rect_t* prect;
prect = &(dc->owner->clip.extents);
/* 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;
/* draw hline */
dc->device->draw_hline(&(dc->owner->gc.foreground), x1, x2, y);
}
else for (index = 0; index < rtgui_region_num_rects(&(dc->owner->clip)); index ++)
{
rtgui_rect_t* prect;
register rt_base_t draw_x1, draw_x2;
prect = ((rtgui_rect_t *)(dc->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;
if (prect->x1 > x1) draw_x1 = prect->x1;
if (prect->x2 < x2) draw_x2 = prect->x2;
/* draw hline */
dc->device->draw_hline(&(dc->owner->gc.foreground), draw_x1, draw_x2, y);
}
}
static void rtgui_dc_hw_fill_rect (struct rtgui_dc* self, struct rtgui_rect* rect)
{
rtgui_color_t foreground;
register rt_base_t index;
struct rtgui_dc_hw* dc;
dc = (struct rtgui_dc_hw*)self;
if (dc == RT_NULL || dc->visible != RT_TRUE) return;
/* save foreground color */
foreground = dc->owner->gc.foreground;
/* set background color as foreground color */
dc->owner->gc.foreground = dc->owner->gc.background;
/* fill rect */
for (index = rect->y1; index < rect->y2; index ++)
{
rtgui_dc_hw_draw_hline(self, rect->x1, rect->x2, index);
}
/* restore foreground color */
dc->owner->gc.foreground = foreground;
}
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 ;
}
static void rtgui_dc_hw_set_color(struct rtgui_dc* self, rtgui_color_t color)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
if (self != RT_NULL)
{
dc->owner->gc.foreground = color;
}
}
static rtgui_color_t rtgui_dc_hw_get_color(struct rtgui_dc* self)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
return self != RT_NULL? dc->owner->gc.foreground : white;
}
static void rtgui_dc_hw_set_font(struct rtgui_dc* self, rtgui_font_t* font)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
if (self != RT_NULL)
{
dc->owner->gc.font = font;
}
}
static rtgui_font_t* rtgui_dc_hw_get_font(struct rtgui_dc* self)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
return self != RT_NULL? dc->owner->gc.font : RT_NULL;
}
static void rtgui_dc_hw_set_textalign(struct rtgui_dc* self, rt_int32_t textalign)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
dc->owner->gc.textalign = textalign;
}
static rt_int32_t rtgui_dc_hw_get_textalign(struct rtgui_dc* self)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
return dc->owner->gc.textalign;
}
static rt_bool_t rtgui_dc_hw_get_visible(struct rtgui_dc* dc)
{
return RT_TRUE;
}
static void rtgui_dc_hw_get_rect(struct rtgui_dc* self, rtgui_rect_t* rect)
{
struct rtgui_dc_hw* dc = (struct rtgui_dc_hw*)self;
rtgui_widget_get_rect(dc->owner, rect);
}
/*
* File : filerw.c
* 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
*/
#include <rtgui/filerw.h>
#include <rtgui/rtgui_system.h>
#ifdef RT_USING_STDIO_FILERW
#include <stdio.h>
/* standard file read/write */
struct rtgui_filerw_stdio
{
/* inherit from rtgui_filerw */
struct rtgui_filerw parent;
FILE* fp;
};
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};
if (whence < RTGUI_FILE_SEEK_SET || whence > RTGUI_FILE_SEEK_END)
{
return -1;
}
if (fseek(stdio_filerw->fp, offset, stdio_whence[whence]) == 0)
{
return ftell(stdio_filerw->fp);
}
return -1;
}
static int stdio_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_size_t maxnum)
{
size_t nread;
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
nread = fread(ptr, size, maxnum, stdio_filerw->fp);
if (nread == 0 && ferror(stdio_filerw->fp))
{
return -1;
}
return nread;
}
static int stdio_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num)
{
size_t nwrote;
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
nwrote = fwrite(ptr, size, num, stdio_filerw->fp);
if ( nwrote == 0 && ferror(stdio_filerw->fp) )
{
return -1;
}
return nwrote;
}
int stdio_tell(struct rtgui_filerw* context)
{
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
return ftell(stdio_filerw->fp);
}
int stdio_eof(struct rtgui_filerw* context)
{
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
return feof(stdio_filerw->fp);
}
static int stdio_close(struct rtgui_filerw *context)
{
struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context;
if (stdio_filerw)
{
fclose(stdio_filerw->fp);
rtgui_free(stdio_filerw);
return 0;
}
return -1;
}
#endif
/* memory file read/write */
struct rtgui_filerw_mem
{
/* inherit from rtgui_filerw */
struct rtgui_filerw parent;
rt_uint8_t *mem_base, *mem_position, *mem_end;
};
static int mem_seek(struct rtgui_filerw *context, rt_off_t offset, int whence)
{
rt_uint8_t* newpos;
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
RT_ASSERT(mem != RT_NULL);
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_END:
newpos = mem->mem_end + offset;
break;
default:
return -1;
}
if ( newpos < mem->mem_base )
newpos = mem->mem_base;
if ( newpos > mem->mem_end )
newpos = mem->mem_end;
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;
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;
rt_memcpy(ptr, mem->mem_position, total_bytes);
mem->mem_position += total_bytes;
return (total_bytes / size);
}
static int mem_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num)
{
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
if ((mem->mem_position + (num * size)) > mem->mem_end)
{
num = (mem->mem_end - mem->mem_position)/size;
}
rt_memcpy(mem->mem_position, ptr, num*size);
mem->mem_position += num*size;
return num;
}
static int mem_tell(struct rtgui_filerw* context)
{
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
return mem->mem_position - mem->mem_base;
}
static int mem_eof(struct rtgui_filerw* context)
{
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
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;
if (mem != RT_NULL)
{
rtgui_free(mem);
return 0;
}
return -1;
}
rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* 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;
return mem->mem_base;
}
/* file read/write public interface */
#ifdef RT_USING_STDIO_FILERW
struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* mode)
{
FILE *fp;
struct rtgui_filerw_stdio *rw;
RT_ASSERT(filename != RT_NULL);
rw = RT_NULL;
fp = fopen(filename, mode);
if ( fp != NULL )
{
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->fp = fp;
}
}
return &(rw->parent);
}
#endif
struct rtgui_filerw* rtgui_filerw_create_mem(rt_uint8_t* mem, rt_size_t size)
{
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->mem_base = mem;
rw->mem_position = mem;
rw->mem_end = mem + size;
}
return &(rw->parent);
}
int rtgui_filerw_seek(struct rtgui_filerw* context, rt_off_t offset, int whence)
{
RT_ASSERT(context != RT_NULL);
return context->seek(context, offset, whence);
}
int rtgui_filerw_read(struct rtgui_filerw* context, void* buffer, rt_size_t size, rt_size_t count)
{
RT_ASSERT(context != RT_NULL);
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)
{
RT_ASSERT(context != RT_NULL);
return context->write(context, buffer, size, count);
}
int rtgui_filerw_eof (struct rtgui_filerw* context)
{
RT_ASSERT(context != RT_NULL);
return context->eof(context);
}
int rtgui_filerw_tell(struct rtgui_filerw* context)
{
RT_ASSERT(context != RT_NULL);
return context->tell(context);
}
int rtgui_filerw_close(struct rtgui_filerw* context)
{
int result;
RT_ASSERT(context != RT_NULL);
/* close context */
result = context->close(context);
if (result != 0)
{
/* close file failed */
return -1;
}
return 0;
}
/*
* File : font.c
* 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
*/
#include <rtgui/font.h>
#include <rtgui/dc.h>
static rtgui_list_t _rtgui_font_list;
static struct rtgui_font* rtgui_default_font;
extern struct rtgui_font rtgui_font_asc16;
extern struct rtgui_font rtgui_font_asc12;
#ifdef RTGUI_USING_FONTHZ
extern struct rtgui_font rtgui_font_hz16;
extern struct rtgui_font rtgui_font_hz12;
#endif
void rtgui_font_system_init()
{
rtgui_list_init(&(_rtgui_font_list));
/* set default font to NULL */
rtgui_default_font = RT_NULL;
#ifdef RTGUI_USING_FONT16
rtgui_font_system_add_font(&rtgui_font_asc16);
#ifdef RTGUI_USING_FONTHZ
rtgui_font_system_add_font(&rtgui_font_hz16);
#endif
#endif
rtgui_font_system_add_font(&rtgui_font_asc12);
#ifdef RTGUI_USING_FONTHZ
rtgui_font_system_add_font(&rtgui_font_hz12);
#endif
rtgui_font_set_defaut(&rtgui_font_asc12);
}
void rtgui_font_system_add_font(struct rtgui_font* font)
{
rtgui_list_init(&(font->list));
rtgui_list_append(&_rtgui_font_list, &(font->list));
}
void rtgui_font_system_remove_font(struct rtgui_font* font)
{
rtgui_list_remove(&_rtgui_font_list, &(font->list));
}
struct rtgui_font* rtgui_font_default()
{
return rtgui_default_font;
}
void rtgui_font_set_defaut(struct rtgui_font* font)
{
rtgui_default_font = font;
}
struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height)
{
/* 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;
}
}
return RT_NULL;
}
void rtgui_font_derefer(struct rtgui_font* font)
{
RT_ASSERT(font != RT_NULL);
font->refer_count --;
/* 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 rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect)
{
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);
}
}
int rtgui_font_get_string_width(struct rtgui_font* font, const rt_uint8_t* text)
{
rtgui_rect_t rect;
/* get metrics */
rtgui_font_get_metrics(font, text, &rect);
return rect.x2 - rect.x1;
}
void rtgui_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect)
{
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));
}
}
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect);
struct rtgui_font_engine bmp_font_engine =
{
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)
{
const rt_uint8_t* font_ptr = font->bmp + ch * font->height;
rt_uint16_t x, y, w, h;
register rt_base_t i, j;
x = rect->x1;
y = rect->y1;
/* check first and last char */
if (ch < font->first_char || ch > font->last_char) return;
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 ++ )
{
for (j = 0; j < w; j ++)
{
if ( ((font_ptr[i] >> (7-j)) & 0x01) != 0)
{
/* draw a pixel */
rtgui_dc_draw_point(dc, j + x, i + y);
}
}
}
}
static void rtgui_bitmap_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect)
{
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
RT_ASSERT(bmp_font != RT_NULL);
while (len-- && rect->x1 < rect->x2)
{
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect);
/* move x to next character */
rect->x1 += bmp_font->width;
text ++;
}
}
static void rtgui_bitmap_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, rtgui_rect_t* rect)
{
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
RT_ASSERT(bmp_font != RT_NULL);
/* set metrics rect */
rect->x1 = rect->y1 = 0;
rect->x2 = bmp_font->width * (rt_int16_t)rt_strlen((const char*)text);
rect->y2 = bmp_font->height;
}
/*
* File : image.c
* 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
*/
#include <rtthread.h>
#include <rtgui/image.h>
#include <rtgui/image_xpm.h>
#include <rtgui/rtgui_system.h>
#include <string.h>
#ifdef RTGUI_IMAGE_BMP
#include <rtgui/image_bmp.h>
#endif
#ifdef RTGUI_IMAGE_JPEG
#include <rtgui/image_jpeg.h>
#endif
#ifdef RTGUI_IMAGE_PNG
#include <rtgui/image_png.h>
#endif
static rtgui_list_t _rtgui_system_image_list = {RT_NULL};
/* init rtgui image system */
void rtgui_system_image_init(void)
{
/* always support XPM image */
rtgui_image_xpm_init();
#ifdef RTGUI_IMAGE_BMP
rtgui_image_bmp_init();
#endif
#ifdef RTGUI_IMAGE_JPEG
rtgui_image_jpeg_init();
#endif
#ifdef RTGUI_IMAGE_PNG
rtgui_image_png_init();
#endif
}
static struct rtgui_image_engine* rtgui_image_get_engine(const char* type)
{
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);
if (strncasecmp(engine->name, type, strlen(engine->name)) ==0)
return engine;
}
return RT_NULL;
}
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;
/* 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;
}
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_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);
}
return image;
}
struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length)
{
struct rtgui_filerw* filerw;
struct rtgui_image_engine* engine;
struct rtgui_image* image = RT_NULL;
/* create filerw context */
filerw = rtgui_filerw_create_mem((rt_uint8_t*)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;
}
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_load(image, filerw, RT_TRUE) != RT_TRUE)
{
/* close filerw context */
rtgui_filerw_close(filerw);
return RT_NULL;
}
/* set image engine */
image->engine = engine;
}
else
{
rtgui_filerw_close(filerw);
}
return image;
}
void rtgui_image_destroy(struct rtgui_image* image)
{
RT_ASSERT(image != RT_NULL);
image->engine->image_unload(image);
rtgui_free(image);
}
/* register an image engine */
void rtgui_image_register_engine(struct rtgui_image_engine* engine)
{
RT_ASSERT(engine!= RT_NULL);
rtgui_list_append(&_rtgui_system_image_list, &(engine->list));
}
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);
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);
}
}
/*
* File : image_xpm.c
* 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
*/
#include <stdio.h>
#include <string.h>
#include <rtgui/filerw.h>
#include <rtgui/image_xpm.h>
#include <rtgui/rtgui_system.h>
#define XPM_MAGIC_LEN 9
static rt_bool_t rtgui_image_xpm_check(struct rtgui_filerw * file);
static rt_bool_t rtgui_image_xpm_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
static void rtgui_image_xpm_unload(struct rtgui_image* image);
static void rtgui_image_xpm_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
struct rtgui_image_engine rtgui_image_xpm_engine =
{
"xpm",
{RT_NULL},
rtgui_image_xpm_check,
rtgui_image_xpm_load,
rtgui_image_xpm_unload,
rtgui_image_xpm_blit
};
struct rgb_item
{
char *name;
int r;
int g;
int b;
};
const struct rgb_item rgbRecord[234] = {
{"AliceBlue", 240, 248, 255},
{"AntiqueWhite", 250, 235, 215},
{"Aquamarine", 50, 191, 193},
{"Azure", 240, 255, 255},
{"Beige", 245, 245, 220},
{"Bisque", 255, 228, 196},
{"Black", 0, 0, 0},
{"BlanchedAlmond", 255, 235, 205},
{"Blue", 0, 0, 255},
{"BlueViolet", 138, 43, 226},
{"Brown", 165, 42, 42},
{"burlywood", 222, 184, 135},
{"CadetBlue", 95, 146, 158},
{"chartreuse", 127, 255, 0},
{"chocolate", 210, 105, 30},
{"Coral", 255, 114, 86},
{"CornflowerBlue", 34, 34, 152},
{"cornsilk", 255, 248, 220},
{"Cyan", 0, 255, 255},
{"DarkGoldenrod", 184, 134, 11},
{"DarkGreen", 0, 86, 45},
{"DarkKhaki", 189, 183, 107},
{"DarkOliveGreen", 85, 86, 47},
{"DarkOrange", 255, 140, 0},
{"DarkOrchid", 139, 32, 139},
{"DarkSalmon", 233, 150, 122},
{"DarkSeaGreen", 143, 188, 143},
{"DarkSlateBlue", 56, 75, 102},
{"DarkSlateGray", 47, 79, 79},
{"DarkTurquoise", 0, 166, 166},
{"DarkViolet", 148, 0, 211},
{"DeepPink", 255, 20, 147},
{"DeepSkyBlue", 0, 191, 255},
{"DimGray", 84, 84, 84},
{"DodgerBlue", 30, 144, 255},
{"Firebrick", 142, 35, 35},
{"FloralWhite", 255, 250, 240},
{"ForestGreen", 80, 159, 105},
{"gainsboro", 220, 220, 220},
{"GhostWhite", 248, 248, 255},
{"Gold", 218, 170, 0},
{"Goldenrod", 239, 223, 132},
{"Gray", 126, 126, 126},
{"Gray0", 0, 0, 0},
{"Gray1", 3, 3, 3},
{"Gray10", 26, 26, 26},
{"Gray100", 255, 255, 255},
{"Gray11", 28, 28, 28},
{"Gray12", 31, 31, 31},
{"Gray13", 33, 33, 33},
{"Gray14", 36, 36, 36},
{"Gray15", 38, 38, 38},
{"Gray16", 41, 41, 41},
{"Gray17", 43, 43, 43},
{"Gray18", 46, 46, 46},
{"Gray19", 48, 48, 48},
{"Gray2", 5, 5, 5},
{"Gray20", 51, 51, 51},
{"Gray21", 54, 54, 54},
{"Gray22", 56, 56, 56},
{"Gray23", 59, 59, 59},
{"Gray24", 61, 61, 61},
{"Gray25", 64, 64, 64},
{"Gray26", 66, 66, 66},
{"Gray27", 69, 69, 69},
{"Gray28", 71, 71, 71},
{"Gray29", 74, 74, 74},
{"Gray3", 8, 8, 8},
{"Gray30", 77, 77, 77},
{"Gray31", 79, 79, 79},
{"Gray32", 82, 82, 82},
{"Gray33", 84, 84, 84},
{"Gray34", 87, 87, 87},
{"Gray35", 89, 89, 89},
{"Gray36", 92, 92, 92},
{"Gray37", 94, 94, 94},
{"Gray38", 97, 97, 97},
{"Gray39", 99, 99, 99},
{"Gray4", 10, 10, 10},
{"Gray40", 102, 102, 102},
{"Gray41", 105, 105, 105},
{"Gray42", 107, 107, 107},
{"Gray43", 110, 110, 110},
{"Gray44", 112, 112, 112},
{"Gray45", 115, 115, 115},
{"Gray46", 117, 117, 117},
{"Gray47", 120, 120, 120},
{"Gray48", 122, 122, 122},
{"Gray49", 125, 125, 125},
{"Gray5", 13, 13, 13},
{"Gray50", 127, 127, 127},
{"Gray51", 130, 130, 130},
{"Gray52", 133, 133, 133},
{"Gray53", 135, 135, 135},
{"Gray54", 138, 138, 138},
{"Gray55", 140, 140, 140},
{"Gray56", 143, 143, 143},
{"Gray57", 145, 145, 145},
{"Gray58", 148, 148, 148},
{"Gray59", 150, 150, 150},
{"Gray6", 15, 15, 15},
{"Gray60", 153, 153, 153},
{"Gray61", 156, 156, 156},
{"Gray62", 158, 158, 158},
{"Gray63", 161, 161, 161},
{"Gray64", 163, 163, 163},
{"Gray65", 166, 166, 166},
{"Gray66", 168, 168, 168},
{"Gray67", 171, 171, 171},
{"Gray68", 173, 173, 173},
{"Gray69", 176, 176, 176},
{"Gray7", 18, 18, 18},
{"Gray70", 179, 179, 179},
{"Gray71", 181, 181, 181},
{"Gray72", 184, 184, 184},
{"Gray73", 186, 186, 186},
{"Gray74", 189, 189, 189},
{"Gray75", 191, 191, 191},
{"Gray76", 194, 194, 194},
{"Gray77", 196, 196, 196},
{"Gray78", 199, 199, 199},
{"Gray79", 201, 201, 201},
{"Gray8", 20, 20, 20},
{"Gray80", 204, 204, 204},
{"Gray81", 207, 207, 207},
{"Gray82", 209, 209, 209},
{"Gray83", 212, 212, 212},
{"Gray84", 214, 214, 214},
{"Gray85", 217, 217, 217},
{"Gray86", 219, 219, 219},
{"Gray87", 222, 222, 222},
{"Gray88", 224, 224, 224},
{"Gray89", 227, 227, 227},
{"Gray9", 23, 23, 23},
{"Gray90", 229, 229, 229},
{"Gray91", 232, 232, 232},
{"Gray92", 235, 235, 235},
{"Gray93", 237, 237, 237},
{"Gray94", 240, 240, 240},
{"Gray95", 242, 242, 242},
{"Gray96", 245, 245, 245},
{"Gray97", 247, 247, 247},
{"Gray98", 250, 250, 250},
{"Gray99", 252, 252, 252},
{"Green", 0, 255, 0},
{"GreenYellow", 173, 255, 47},
{"honeydew", 240, 255, 240},
{"HotPink", 255, 105, 180},
{"IndianRed", 107, 57, 57},
{"ivory", 255, 255, 240},
{"Khaki", 179, 179, 126},
{"lavender", 230, 230, 250},
{"LavenderBlush", 255, 240, 245},
{"LawnGreen", 124, 252, 0},
{"LemonChiffon", 255, 250, 205},
{"LightBlue", 176, 226, 255},
{"LightCoral", 240, 128, 128},
{"LightCyan", 224, 255, 255},
{"LightGoldenrod", 238, 221, 130},
{"LightGoldenrodYellow", 250, 250, 210},
{"LightGray", 168, 168, 168},
{"LightPink", 255, 182, 193},
{"LightSalmon", 255, 160, 122},
{"LightSeaGreen", 32, 178, 170},
{"LightSkyBlue", 135, 206, 250},
{"LightSlateBlue", 132, 112, 255},
{"LightSlateGray", 119, 136, 153},
{"LightSteelBlue", 124, 152, 211},
{"LightYellow", 255, 255, 224},
{"LimeGreen", 0, 175, 20},
{"linen", 250, 240, 230},
{"Magenta", 255, 0, 255},
{"Maroon", 143, 0, 82},
{"MediumAquamarine", 0, 147, 143},
{"MediumBlue", 50, 50, 204},
{"MediumForestGreen", 50, 129, 75},
{"MediumGoldenrod", 209, 193, 102},
{"MediumOrchid", 189, 82, 189},
{"MediumPurple", 147, 112, 219},
{"MediumSeaGreen", 52, 119, 102},
{"MediumSlateBlue", 106, 106, 141},
{"MediumSpringGreen", 35, 142, 35},
{"MediumTurquoise", 0, 210, 210},
{"MediumVioletRed", 213, 32, 121},
{"MidnightBlue", 47, 47, 100},
{"MintCream", 245, 255, 250},
{"MistyRose", 255, 228, 225},
{"moccasin", 255, 228, 181},
{"NavajoWhite", 255, 222, 173},
{"Navy", 35, 35, 117},
{"NavyBlue", 35, 35, 117},
{"OldLace", 253, 245, 230},
{"OliveDrab", 107, 142, 35},
{"Orange", 255, 135, 0},
{"OrangeRed", 255, 69, 0},
{"Orchid", 239, 132, 239},
{"PaleGoldenrod", 238, 232, 170},
{"PaleGreen", 115, 222, 120},
{"PaleTurquoise", 175, 238, 238},
{"PaleVioletRed", 219, 112, 147},
{"PapayaWhip", 255, 239, 213},
{"PeachPuff", 255, 218, 185},
{"peru", 205, 133, 63},
{"Pink", 255, 181, 197},
{"Plum", 197, 72, 155},
{"PowderBlue", 176, 224, 230},
{"purple", 160, 32, 240},
{"Red", 255, 0, 0},
{"RosyBrown", 188, 143, 143},
{"RoyalBlue", 65, 105, 225},
{"SaddleBrown", 139, 69, 19},
{"Salmon", 233, 150, 122},
{"SandyBrown", 244, 164, 96},
{"SeaGreen", 82, 149, 132},
{"seashell", 255, 245, 238},
{"Sienna", 150, 82, 45},
{"SkyBlue", 114, 159, 255},
{"SlateBlue", 126, 136, 171},
{"SlateGray", 112, 128, 144},
{"snow", 255, 250, 250},
{"SpringGreen", 65, 172, 65},
{"SteelBlue", 84, 112, 170},
{"Tan", 222, 184, 135},
{"Thistle", 216, 191, 216},
{"tomato", 255, 99, 71},
{"Transparent", 0, 0, 1},
{"Turquoise", 25, 204, 223},
{"Violet", 156, 62, 206},
{"VioletRed", 243, 62, 150},
{"Wheat", 245, 222, 179},
{"White", 255, 255, 255},
{"WhiteSmoke", 245, 245, 245},
{"Yellow", 255, 255, 0},
{"YellowGreen", 50, 216, 56}
};
/* Hash table to look up colors from pixel strings */
#define STARTING_HASH_SIZE 256
struct hash_entry
{
char key[10];
rtgui_color_t color;
struct hash_entry *next;
};
struct color_hash
{
struct hash_entry **table;
struct hash_entry *entries; /* array of all entries */
struct hash_entry *next_free;
int size;
int maxnum;
};
static int hash_key(const char *key, int cpp, int size)
{
int hash;
hash = 0;
while ( cpp-- > 0 )
{
hash = hash * 33 + *key++;
}
return hash & (size - 1);
}
static struct color_hash *create_colorhash(int maxnum)
{
int bytes, s;
struct color_hash *hash;
/* we know how many entries we need, so we can allocate
everything here */
hash = rtgui_malloc(sizeof *hash);
if(!hash) return RT_NULL;
/* use power-of-2 sized hash table for decoding speed */
for(s = STARTING_HASH_SIZE; s < maxnum; s <<= 1) ;
hash->size = s;
hash->maxnum = maxnum;
bytes = hash->size * sizeof(struct hash_entry **);
hash->entries = RT_NULL; /* in case rt_malloc fails */
hash->table = rtgui_malloc(bytes);
if(!hash->table) return RT_NULL;
rt_memset(hash->table, 0, bytes);
hash->entries = rtgui_malloc(maxnum * sizeof(struct hash_entry));
if(!hash->entries) return RT_NULL;
hash->next_free = hash->entries;
return hash;
}
static int add_colorhash(struct color_hash *hash,
char *key, int cpp, rtgui_color_t *color)
{
int index = hash_key(key, cpp, hash->size);
struct hash_entry *e = hash->next_free++;
e->color = *color;
rt_memset(e->key, 0, sizeof(e->key));
rt_strncpy(e->key, key, cpp);
e->next = hash->table[index];
hash->table[index] = e;
return 1;
}
static void get_colorhash(struct color_hash *hash, const char *key, int cpp, rtgui_color_t* c)
{
struct hash_entry *entry = hash->table[hash_key(key, cpp, hash->size)];
while(entry)
{
if(rt_memcmp(key, entry->key, cpp) == 0)
{
*c = entry->color;
return;
}
entry = entry->next;
}
return ; /* garbage in - garbage out */
}
static void free_colorhash(struct color_hash *hash)
{
if(hash && hash->table)
{
rtgui_free(hash->table);
rtgui_free(hash->entries);
rtgui_free(hash);
}
}
#if defined(_MSC_VER) || defined(__CC_ARM)
int strcasecmp( const char* s1, const char* s2 )
{
register unsigned int x2;
register unsigned int x1;
while (1) {
x2 = *s2 - 'A'; if (x2 < 26u) x2 += 32;
x1 = *s1 - 'A'; if (x1 < 26u) x1 += 32;
s1++; s2++;
if (x2 != x1)
break;
if (x1 == (unsigned int)-'A')
break;
}
return x1 - x2;
}
#endif
static int hex2int (char *str)
{
int i = 0;
int r = 0;
for (i = 0; i < 2; i++)
{
if (str[i] >= '0' && str[i] <= '9') r += str[i] - '0';
else if (str[i] >= 'a' && str[i] <= 'f') r += str[i] - 'a' + 10;
else if (str[i] >= 'A' && str[i] <= 'F') r += str[i] - 'A' + 10;
if (!i) r *= 16;
}
return r;
}
void rtgui_image_xpm_init()
{
/* register xpm engine */
rtgui_image_register_engine(&rtgui_image_xpm_engine);
}
static rt_bool_t rtgui_image_xpm_check(struct rtgui_filerw* file)
{
#if 0
rt_uint8_t buffer[XPM_MAGIC_LEN];
rt_size_t start;
rt_bool_t result;
result = RT_FALSE;
start = rtgui_filerw_tell(file);
/* seek to the begining of file */
if (start != 0) rtgui_filerw_seek(file, 0, SEEK_SET);
rtgui_filerw_read(file, &buffer[0], XPM_MAGIC_LEN, 1);
if (rt_memcmp(buffer, "/* XPM */", (rt_ubase_t)XPM_MAGIC_LEN) == 0)
result = RT_TRUE;
rtgui_filerw_seek(file, start, SEEK_SET);
return result;
#else
/* we can not check image type for memory file */
return RT_TRUE;
#endif
}
static rt_bool_t rtgui_image_xpm_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load)
{
const char **xpm;
const char *buf;
const char *buf_tmp;
int w, h;
int colors = 0;
int colors_pp = 0;
int i, j;
/* color hash table */
struct color_hash *colors_table = RT_NULL;
if (image == RT_NULL) return RT_FALSE;
xpm = (const char **)rtgui_filerw_mem_getdata(file);
if (xpm == RT_NULL) return RT_FALSE;
/* set image engine */
image->engine = &rtgui_image_xpm_engine;
/* parse xpm image */
sscanf(xpm[0], "%d %d %d %d", &w, &h, &colors, &colors_pp);
image->w = w;
image->h = h;
/* build color table */
colors_table = create_colorhash(colors);
if (!colors_table)
{
return RT_FALSE;
}
for (i = 0; i < colors; i++)
{
char color_name[10];
rtgui_color_t c = 0;
buf = xpm[i + 1];
for (j = 0; j < colors_pp; j++)
{
color_name[j] = buf[j];
}
color_name[j] = '\0';
/* build rtgui_color */
if ((buf_tmp = strstr(buf, "c #")) != RT_NULL)
{
char color_hex[10];
/* hexadecimal color value */
sscanf(buf_tmp, "c #%s", color_hex);
c = RTGUI_ARGB(0, hex2int(color_hex),
hex2int(color_hex + 2),
hex2int(color_hex + 4));
}
else if ((buf_tmp = strstr(buf, "c ")) != RT_NULL)
{
int k;
/* color name */
char rgbname[30];
sscanf(buf_tmp, "c %s", rgbname);
if (strcasecmp(rgbname, "None") == 0)
{
goto color_none;
}
for (k = 0; k < 234; k++)
{
if (strcasecmp(rgbname, rgbRecord[k].name) == 0)
{
c = RTGUI_ARGB(0, rgbRecord[k].r,
rgbRecord[k].g,
rgbRecord[k].b);
break;
}
}
}
else
{
color_none:
c = RTGUI_RGB(0, 0, 0);
}
/* add to color hash table */
add_colorhash(colors_table, color_name, colors_pp, &c);
}
/* build rgb pixel data */
image->data = (rt_uint8_t*) rtgui_malloc(image->w * image->h * sizeof(rtgui_color_t));
memset(image->data, 0, image->w * image->h * sizeof(rtgui_color_t));
{
rtgui_color_t *ptr = (rtgui_color_t*) image->data;
for (h = 0; h < image->h; h++)
{
buf = xpm[colors + 1 + h];
for (w = 0; w < image->w; w++, buf += colors_pp)
{
get_colorhash(colors_table, buf, colors_pp, ptr);
ptr ++;
}
}
}
free_colorhash(colors_table);
return RT_TRUE;
}
static void rtgui_image_xpm_unload(struct rtgui_image* image)
{
if (image != RT_NULL)
{
/* release data */
rtgui_free(image->data);
image->data = RT_NULL;
}
}
static void rtgui_image_xpm_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect)
{
rt_uint16_t x, y;
rtgui_color_t* ptr;
rtgui_color_t foreground;
RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL);
RT_ASSERT(image->data != RT_NULL);
ptr = (rtgui_color_t*) image->data;
/* save foreground color */
foreground = rtgui_dc_get_color(dc);
/* draw each point within dc */
for (y = 0; y < image->h; y ++)
{
for (x = 0; x < image->w; x++)
{
/* not alpha */
if ((*ptr >> 24) != 255)
{
rtgui_dc_set_color(dc, *ptr);
rtgui_dc_draw_point(dc, x + rect->x1, y + rect->y1);
}
/* move to next color buffer */
ptr ++;
}
}
/* restore foreground */
rtgui_dc_set_color(dc, foreground);
}
此差异已折叠。
......@@ -40,18 +40,6 @@ void rtgui_system_server_init()
rtgui_server_init();
}
void rtgui_system_app_init()
{
/* init launcher thread */
rtgui_launcher_init();
/* init pyim */
// rtgui_pyim_init();
/* init term win */
// rtgui_term_init();
}
/************************************************************************/
/* RTGUI Thread Wrapper */
/************************************************************************/
......
......@@ -19,13 +19,14 @@
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/textbox.h>
#include <rtgui/widgets/iconbox.h>
#include <rtgui/widgets/title.h>
#include <rtgui/rtgui_theme.h>
#include <rtgui/rtgui_server.h>
#define WINTITLE_CB_WIDTH 14
#define WINTITLE_CB_HEIGHT 14
static const char * close_unpressed_xpm[] = {
static const rt_uint8_t *close_unpressed_xpm[] = {
"14 14 55 1",
" c None",
". c #DCDFEA",
......@@ -97,7 +98,7 @@ static const char * close_unpressed_xpm[] = {
"#mnnnnnnnnnnm#",
"op@@@@@@@@@@po"};
static const char * close_pressed_xpm[] = {
static const rt_uint8_t *close_pressed_xpm[] = {
"14 14 66 1",
" c None",
". c #CED4EE",
......@@ -191,9 +192,11 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win)
/* init close box image */
if (close_pressed == RT_NULL)
close_pressed = rtgui_image_create_from_mem("xpm", close_pressed_xpm, sizeof(close_pressed_xpm));
close_pressed = rtgui_image_create_from_mem("xpm",
(const rt_uint8_t*)close_pressed_xpm, sizeof(close_pressed_xpm));
if (close_unpressed == RT_NULL)
close_unpressed = rtgui_image_create_from_mem("xpm", close_unpressed_xpm, sizeof(close_unpressed_xpm));
close_unpressed = rtgui_image_create_from_mem("xpm",
(const rt_uint8_t*)close_unpressed_xpm, sizeof(close_unpressed_xpm));
/* begin drawing */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(win->title));
......@@ -437,3 +440,4 @@ void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox)
/* end drawing */
rtgui_dc_end_drawing(dc);
}
/*
* File : caret.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_CARET_H__
#define __RTGUI_CARET_H__
#include <rtgui/dc.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/widget.h>
struct rtgui_caret
{
/* show flag */
rt_bool_t is_show;
/* the show point of caret */
struct rtgui_point show_point;
/* widget owner */
struct rtgui_widget* owner;
/* caret buffer dc */
struct rtgui_dc *dc;
/* caret extent */
struct rtgui_rect extent;
/* the blink timer */
struct rtgui_timer* timer;
rt_int32_t timer_period;
};
typedef struct rtgui_caret rtgui_caret_t;
struct rtgui_caret* rtgui_caret_create(struct rtgui_widget* owner);
void rtgui_caret_destroy(struct rtgui_caret* caret);
void rtgui_caret_show(struct rtgui_caret* caret, rt_base_t x, rt_base_t y);
void rtgui_caret_hide(struct rtgui_caret* caret);
void rtgui_caret_draw(struct rtgui_caret* caret);
void rtgui_caret_set_point(struct rtgui_caret* caret, int x, int y);
void rtgui_caret_set_box(struct rtgui_caret* caret, int w, int h);
#endif
/*
* File : color.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_COLOR_H__
#define __RTGUI_COLOR_H__
#include <rtgui/rtgui.h>
typedef unsigned long rtgui_color_t;
#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)
extern const rtgui_color_t default_foreground;
extern const rtgui_color_t default_background;
extern const rtgui_color_t red;
extern const rtgui_color_t green;
extern const rtgui_color_t blue;
extern const rtgui_color_t black;
extern const rtgui_color_t white;
extern const rtgui_color_t high_light;
extern const rtgui_color_t dark_grey;
extern const rtgui_color_t light_grey;
/*
* RTGUI default color format
* BBBB BBBB GGGG GGGG RRRR RRRR
*/
/* convert rtgui color to BBBBBGGGGGGRRRRR */
rt_inline rt_uint16_t rtgui_color_to_565(rtgui_color_t c)
{
rt_uint16_t pixel;
pixel = ((RTGUI_RGB_B(c)>> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_R(c) >> 3);
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;
r = pixel & 0x1f;
g = (pixel >> 5) & 0x3f;
b = (pixel >> 11) & 0x1f;
color = r * 8225 / 1024 + ((g * 4047 / 1024) << 8) + ((b * 8225 / 1024) << 16);
return color;
}
/* convert rtgui color to RRRRRGGGGGGBBBBB */
rt_inline rt_uint16_t rtgui_color_to_565p(rtgui_color_t c)
{
rt_uint16_t pixel;
pixel = ((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;
r = (pixel >> 11) & 0x1f;
g = (pixel >> 5) & 0x3f;
b = pixel & 0x1f;
color = r * 8225 / 1024 + ((g * 4047 / 1024) << 8) + ((b * 8225 / 1024) << 16);
return color;
}
#endif
/*
* File : dc.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_DC_H__
#define __RTGUI_DC_H__
#include <rtgui/rtgui.h>
#include <rtgui/font.h>
#include <rtgui/driver.h>
#include <rtgui/widgets/widget.h>
enum rtgui_dc_type
{
RTGUI_DC_HW,
RTGUI_DC_BUFFER,
};
/* the abstract device context */
struct rtgui_dc
{
/* type of device context */
rt_uint32_t type;
/* interface */
void (*draw_point)(struct rtgui_dc* dc, int x, int y);
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 )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
/* set and get color */
void (*set_color )(struct rtgui_dc* dc, rtgui_color_t color);
rtgui_color_t (*get_color)(struct rtgui_dc* dc);
/* set and get font */
void (*set_font )(struct rtgui_dc* dc, rtgui_font_t* font);
rtgui_font_t* (*get_font)(struct rtgui_dc* dc);
void (*set_textalign)(struct rtgui_dc* dc, rt_int32_t align);
rt_int32_t (*get_textalign)(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);
rt_bool_t (*fini )(struct rtgui_dc* dc);
};
/* hardware device context */
struct rtgui_dc_hw
{
struct rtgui_dc parent;
/* widget owner */
rtgui_widget_t* owner;
/* visible */
rt_bool_t visible;
/* display driver */
struct rtgui_graphic_driver* device;
};
/* 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);
/* create a hardware dc */
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner);
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_draw_point(struct rtgui_dc* dc, int x, int y);
void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2);
void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y);
void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
void rtgui_dc_set_color(struct rtgui_dc* dc, rtgui_color_t color);
rtgui_color_t rtgui_dc_get_color(struct rtgui_dc* dc);
void rtgui_dc_set_font(struct rtgui_dc* dc, rtgui_font_t* font);
rtgui_font_t* rtgui_dc_get_font(struct rtgui_dc* dc);
void rtgui_dc_set_textalign(struct rtgui_dc* dc, rt_int32_t align);
rt_int32_t rtgui_dc_get_textalign(struct rtgui_dc* dc);
rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc);
void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect);
void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2);
void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtgui_rect* 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_arrow(struct rtgui_dc* dc, rtgui_rect_t* rect, int kind);
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_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_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
#endif
/*
* File : filerw.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_FILERW_H__
#define __RTGUI_FILERW_H__
#include <rtgui/rtgui.h>
#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);
};
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(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);
/* get memory data from filerw memory object */
rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context);
#endif
/*
* File : font.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_FONT_H__
#define __RTGUI_FONT_H__
#include <rtgui/rtgui.h>
#include <rtgui/list.h>
struct rtgui_font;
struct rtgui_dc;
struct rtgui_rect;
struct rtgui_font_engine
{
/* 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 rt_uint8_t* text,
rt_ubase_t len, struct rtgui_rect* rect);
void (*font_get_metrics)(struct rtgui_font* font, const rt_uint8_t* text, struct rtgui_rect* rect);
};
/*
* bitmap font engine
*/
/* bitmap font private data */
struct rtgui_font_bitmap
{
/* bitmap data */
const rt_uint8_t* bmp;
rt_uint16_t width;
rt_uint16_t height;
rt_uint8_t first_char;
rt_uint8_t last_char;
};
extern struct rtgui_font_engine bmp_font_engine;
struct rtgui_font
{
/* font name */
char* family;
/* font height */
rt_uint16_t height;
/* refer count */
rt_uint32_t refer_count;
/* font engine */
struct rtgui_font_engine* engine;
/* font private data */
void* data;
/* 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);
struct rtgui_font* rtgui_font_refer(const rt_uint8_t* 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 rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
int rtgui_font_get_string_width(struct rtgui_font* font, const rt_uint8_t* text);
void rtgui_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, struct rtgui_rect* rect);
#endif
/*
* File : image.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_IMAGE_H__
#define __RTGUI_IMAGE_H__
#include <rtgui/dc.h>
#include <rtgui/filerw.h>
#include <rtgui/region.h>
struct rtgui_image;
struct rtgui_image_engine
{
const char* name;
struct rtgui_list_node list;
/* 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);
void (*image_blit)(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
};
struct rtgui_image
{
/* image metrics */
rt_uint16_t w, h;
/* image engine */
struct rtgui_image_engine* engine;
/* image private data */
void* data;
};
typedef struct rtgui_image rtgui_image_t;
/* init rtgui image system */
void rtgui_system_image_init(void);
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_mem(const char* type, const rt_uint8_t* data, rt_size_t length);
void rtgui_image_destroy(struct rtgui_image* image);
/* register an image 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);
#endif
/*
* File : image_png.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_IMAGE_PNG_H__
#define __RTGUI_IMAGE_PNG_H__
#include <rtgui/image.h>
#endif
/*
* File : image_xpm.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_IMAGE_XPM_H__
#define __RTGUI_IMAGE_XPM_H__
#include <rtgui/image.h>
void rtgui_image_xpm_init(void);
#endif
此差异已折叠。
/*
* File : list.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_LIST_H__
#define __RTGUI_LIST_H__
#include <rtgui/rtgui.h>
struct rtgui_list_node
{
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;
}
rt_inline void rtgui_list_append(rtgui_list_t *l, rtgui_list_t *n)
{
struct rtgui_list_node* node;
node = l;
while (node->next) node = node->next;
/* 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;
}
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 node */
if (node->next != (rtgui_list_t *)0) node->next = node->next->next;
return l;
}
#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)
#endif
/*
* File : region.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_REGION_H__
#define __RTGUI_REGION_H__
#include <rtgui/rtgui.h>
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
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 */
};
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;
/* 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, rtgui_rect_t *extents);
void rtgui_region_fini (rtgui_region_t *region);
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_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);
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
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);
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);
/* 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(rtgui_rect_t *rect, int x, int y);
int rtgui_rect_is_intersect(rtgui_rect_t *rect1, rtgui_rect_t *rect2);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* _PIXMAN_H_ */
......@@ -16,10 +16,7 @@
#include <rtthread.h>
/* RTGUI options */
#define RTGUI_IMAGE_JPEG
#define RTGUI_NAME_MAX 32
#include <rtgui/rtgui_config.h>
#define RT_INT16_MAX 32767
#define RT_INT16_MIN (-RT_INT16_MAX-1)
......
/*
* File : rtgui_config.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_CONFIG_H__
#define __RTGUI_CONFIG_H__
/* RTGUI options */
/* name length of RTGUI object */
#define RTGUI_NAME_MAX 32
/* #define RTGUI_USING_MOUSE_CURSOR */
/* #define RTGUI_USING_FONT16 */
#define RT_USING_STDIO_FILERW
#define RTGUI_SVR_THREAD_PRIORITY 15
#define RTGUI_SVR_THREAD_TIMESLICE 5
#define RTGUI_APP_THREAD_PRIORITY 25
#define RTGUI_APP_THREAD_TIMESLICE 8
#endif
......@@ -67,4 +67,9 @@ void rtgui_server_init(void);
/* post an event to server */
void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size);
/* register or deregister panel in server */
void rtgui_panel_register(char* name, rtgui_rect_t* extent);
void rtgui_panel_deregister(char* name);
#endif
......@@ -15,6 +15,7 @@
#define __RTGUI_THEME_H__
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -49,10 +49,6 @@ struct rtgui_panel
rt_thread_t wm_thread;
};
/* register or deregister panel in server */
void rtgui_panel_register(char* name, rtgui_rect_t* extent);
void rtgui_panel_deregister(char* name);
/* find panel by name */
struct rtgui_panel* rtgui_panel_find(char* name);
......
......@@ -21,12 +21,6 @@
#include "panel.h"
#include "topwin.h"
#define RTGUI_SVR_THREAD_PRIORITY 96
#define RTGUI_SVR_THREAD_TIMESLICE 20
#define RTGUI_APP_THREAD_PRIORITY 220
#define RTGUI_APP_THREAD_TIMESLICE 20
static char rtgui_server_stack[2048];
static struct rt_thread rtgui_server_thread;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册