From 49e090149a37d6a011cb25959530ef931289402a Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Fri, 12 Feb 2010 16:02:00 +0000 Subject: [PATCH] improve radio box drawing; fix focus issue; fix modal showing; add mouse support on list and file list view. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@409 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- rtgui/common/arial12font.c | 228 ------------------------ rtgui/common/arial16font.c | 228 ------------------------ rtgui/common/dc.c | 53 +++++- rtgui/common/font.c | 2 - rtgui/common/rtgui_system.c | 5 +- rtgui/common/rtgui_theme.c | 53 ++++-- rtgui/include/rtgui/rtgui_config.h | 13 ++ rtgui/include/rtgui/rtgui_theme.h | 6 + rtgui/include/rtgui/widgets/window.h | 5 +- rtgui/include/rtgui/widgets/workbench.h | 3 + rtgui/server/server.c | 2 +- rtgui/server/topwin.c | 7 +- rtgui/widgets/filelist_view.c | 36 ++++ rtgui/widgets/list_view.c | 32 ++++ rtgui/widgets/radiobox.c | 3 + rtgui/widgets/view.c | 11 +- rtgui/widgets/widget.c | 16 +- rtgui/widgets/window.c | 141 ++++++++++----- rtgui/widgets/workbench.c | 44 +++-- 19 files changed, 337 insertions(+), 551 deletions(-) delete mode 100644 rtgui/common/arial12font.c delete mode 100644 rtgui/common/arial16font.c diff --git a/rtgui/common/arial12font.c b/rtgui/common/arial12font.c deleted file mode 100644 index aa21ff08fe..0000000000 --- a/rtgui/common/arial12font.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * File : arial16font.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 - * 2010-01-21 Bernard first version - */ -#include - -#ifdef RTGUI_USING_FONT12 -const unsigned char arial12_font[]= -{ - /*---char: ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: ! ---*/ - 0x00,0x00,0x10,0x41,0x04,0x10,0x41,0x00,0x10, - /*---char: " ---*/ - 0x00,0x00,0x28,0xa2,0x80,0x00,0x00,0x00,0x00, - /*---char: # ---*/ - 0x00,0x00,0x05,0x17,0xf2,0x8a,0xfc,0xa5,0x14, - /*---char: $ ---*/ - 0x00,0x00,0x0e,0x55,0x45,0x0e,0x15,0x55,0x4e, - /*---char: % ---*/ - 0x00,0x00,0x0c,0x49,0x24,0xcd,0x04,0x20,0x84, - /*---char: & ---*/ - 0x00,0x00,0x06,0x24,0x92,0x8c,0x49,0x14,0x4e, - /*---char: ' ---*/ - 0x00,0x00,0x10,0x41,0x00,0x00,0x00,0x00,0x00, - /*---char: ( ---*/ - 0x00,0x00,0x04,0x20,0x84,0x10,0x41,0x04,0x08, - /*---char: ) ---*/ - 0x00,0x00,0x20,0x41,0x02,0x08,0x20,0x82,0x10, - /*---char: * ---*/ - 0x00,0x00,0x08,0xf8,0x85,0x00,0x00,0x00,0x00, - /*---char: + ---*/ - 0x00,0x00,0x00,0x00,0x41,0x1f,0x10,0x40,0x00, - /*---char: , ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, - /*---char: - ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0x00, - /*---char: . ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, - /*---char: / ---*/ - 0x00,0x00,0x08,0x21,0x04,0x10,0x41,0x08,0x20, - /*---char: 0 ---*/ - 0x00,0x00,0x0e,0x45,0x14,0x51,0x45,0x14,0x4e, - /*---char: 1 ---*/ - 0x00,0x00,0x04,0x31,0x41,0x04,0x10,0x41,0x04, - /*---char: 2 ---*/ - 0x00,0x00,0x0e,0x44,0x10,0x42,0x08,0x42,0x1f, - /*---char: 3 ---*/ - 0x00,0x00,0x0e,0x44,0x10,0x46,0x04,0x14,0x4e, - /*---char: 4 ---*/ - 0x00,0x00,0x02,0x18,0x62,0x8a,0x49,0xf0,0x82, - /*---char: 5 ---*/ - 0x00,0x00,0x0f,0x21,0x07,0x91,0x04,0x14,0x4e, - /*---char: 6 ---*/ - 0x00,0x00,0x0e,0x45,0x05,0x99,0x45,0x14,0x4e, - /*---char: 7 ---*/ - 0x00,0x00,0x1f,0x08,0x21,0x04,0x10,0x82,0x08, - /*---char: 8 ---*/ - 0x00,0x00,0x0e,0x45,0x14,0x4e,0x45,0x14,0x4e, - /*---char: 9 ---*/ - 0x00,0x00,0x0e,0x45,0x14,0x53,0x34,0x14,0x4e, - /*---char: : ---*/ - 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10, - /*---char: ; ---*/ - 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10, - /*---char: < ---*/ - 0x00,0x00,0x00,0x00,0x13,0x90,0x38,0x10,0x00, - /*---char: = ---*/ - 0x00,0x00,0x00,0x00,0x0f,0xc0,0x03,0xf0,0x00, - /*---char: > ---*/ - 0x00,0x00,0x00,0x01,0x03,0x81,0x39,0x00,0x00, - /*---char: ? ---*/ - 0x00,0x00,0x0e,0x45,0x10,0x42,0x10,0x40,0x04, - /*---char: @ ---*/ - 0x00,0x00,0x01,0x18,0x82,0x52,0x51,0x45,0x13, - /*---char: A ---*/ - 0x00,0x00,0x04,0x28,0xa2,0x91,0x7d,0x18,0x20, - /*---char: B ---*/ - 0x00,0x00,0x1f,0x41,0x04,0x1f,0x41,0x04,0x1f, - /*---char: C ---*/ - 0x00,0x00,0x07,0x21,0x04,0x10,0x41,0x02,0x07, - /*---char: D ---*/ - 0x00,0x00,0x1f,0x41,0x04,0x10,0x41,0x04,0x1f, - /*---char: E ---*/ - 0x00,0x00,0x1f,0x41,0x04,0x1f,0x41,0x04,0x1f, - /*---char: F ---*/ - 0x00,0x00,0x1f,0x41,0x04,0x1e,0x41,0x04,0x10, - /*---char: G ---*/ - 0x00,0x00,0x07,0x21,0x04,0x11,0x41,0x02,0x07, - /*---char: H ---*/ - 0x00,0x00,0x10,0x41,0x04,0x1f,0x41,0x04,0x10, - /*---char: I ---*/ - 0x00,0x00,0x10,0x41,0x04,0x10,0x41,0x04,0x10, - /*---char: J ---*/ - 0x00,0x00,0x02,0x08,0x20,0x82,0x0a,0x28,0x9c, - /*---char: K ---*/ - 0x00,0x00,0x10,0x41,0x14,0x94,0x69,0x14,0x10, - /*---char: L ---*/ - 0x00,0x00,0x10,0x41,0x04,0x10,0x41,0x04,0x1f, - /*---char: M ---*/ - 0x00,0x00,0x10,0x61,0x85,0x55,0x55,0x54,0x92, - /*---char: N ---*/ - 0x00,0x00,0x10,0x61,0x45,0x12,0x45,0x14,0x10, - /*---char: O ---*/ - 0x00,0x00,0x07,0x21,0x04,0x10,0x41,0x02,0x07, - /*---char: P ---*/ - 0x00,0x00,0x1f,0x41,0x04,0x1f,0x41,0x04,0x10, - /*---char: Q ---*/ - 0x00,0x00,0x07,0x21,0x04,0x10,0x41,0x32,0x07, - /*---char: R ---*/ - 0x00,0x00,0x1f,0x41,0x04,0x1f,0x45,0x04,0x10, - /*---char: S ---*/ - 0x00,0x00,0x0f,0x41,0x04,0x0f,0x01,0x04,0x0f, - /*---char: T ---*/ - 0x00,0x00,0x3f,0x10,0x41,0x04,0x10,0x41,0x04, - /*---char: U ---*/ - 0x00,0x00,0x10,0x41,0x04,0x10,0x41,0x02,0x07, - /*---char: V ---*/ - 0x00,0x00,0x20,0x81,0x14,0x51,0x28,0xa1,0x04, - /*---char: W ---*/ - 0x00,0x00,0x21,0x8a,0x24,0x94,0x51,0x42,0x08, - /*---char: X ---*/ - 0x00,0x00,0x20,0x45,0x12,0x84,0x29,0x14,0x60, - /*---char: Y ---*/ - 0x00,0x00,0x20,0x45,0x12,0x84,0x10,0x41,0x04, - /*---char: Z ---*/ - 0x00,0x00,0x1f,0x04,0x20,0x84,0x20,0x84,0x3f, - /*---char: [ ---*/ - 0x00,0x00,0x18,0x41,0x04,0x10,0x41,0x04,0x10, - /*---char: \ ---*/ - 0x00,0x00,0x20,0x81,0x04,0x10,0x41,0x02,0x08, - /*---char: ] ---*/ - 0x00,0x00,0x30,0x41,0x04,0x10,0x41,0x04,0x10, - /*---char: ^ ---*/ - 0x00,0x00,0x08,0x51,0x45,0x22,0x00,0x00,0x00, - /*---char: _ ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: ` ---*/ - 0x00,0x00,0x10,0x20,0x00,0x00,0x00,0x00,0x00, - /*---char: a ---*/ - 0x00,0x00,0x00,0x00,0xe4,0x41,0x3d,0x14,0xcd, - /*---char: b ---*/ - 0x00,0x00,0x10,0x41,0x66,0x51,0x45,0x16,0x56, - /*---char: c ---*/ - 0x00,0x00,0x00,0x00,0xc4,0x90,0x41,0x04,0x8c, - /*---char: d ---*/ - 0x00,0x00,0x01,0x04,0xd4,0xd1,0x45,0x14,0x4f, - /*---char: e ---*/ - 0x00,0x00,0x00,0x00,0xe4,0x51,0x7d,0x04,0x4e, - /*---char: f ---*/ - 0x00,0x00,0x0c,0x43,0x84,0x10,0x41,0x04,0x10, - /*---char: g ---*/ - 0x00,0x00,0x00,0x00,0xd4,0xd1,0x45,0x14,0xcd, - /*---char: h ---*/ - 0x00,0x00,0x10,0x41,0x66,0x51,0x45,0x14,0x51, - /*---char: i ---*/ - 0x00,0x00,0x10,0x01,0x04,0x10,0x41,0x04,0x10, - /*---char: j ---*/ - 0x00,0x00,0x10,0x01,0x04,0x10,0x41,0x04,0x10, - /*---char: k ---*/ - 0x00,0x00,0x10,0x41,0x14,0x94,0x71,0x24,0x91, - /*---char: l ---*/ - 0x00,0x00,0x10,0x41,0x04,0x10,0x41,0x04,0x10, - /*---char: m ---*/ - 0x00,0x00,0x00,0x01,0x66,0x51,0x45,0x14,0x51, - /*---char: n ---*/ - 0x00,0x00,0x00,0x01,0x66,0x51,0x45,0x14,0x51, - /*---char: o ---*/ - 0x00,0x00,0x00,0x00,0xe4,0x51,0x45,0x14,0x4e, - /*---char: p ---*/ - 0x00,0x00,0x00,0x01,0x66,0x51,0x45,0x16,0x56, - /*---char: q ---*/ - 0x00,0x00,0x00,0x00,0xd4,0xd1,0x45,0x14,0xcd, - /*---char: r ---*/ - 0x00,0x00,0x00,0x01,0x46,0x10,0x41,0x04,0x10, - /*---char: s ---*/ - 0x00,0x00,0x00,0x00,0xe4,0x50,0x38,0x14,0x4e, - /*---char: t ---*/ - 0x00,0x00,0x10,0x43,0x84,0x10,0x41,0x04,0x18, - /*---char: u ---*/ - 0x00,0x00,0x00,0x01,0x14,0x51,0x45,0x14,0x4f, - /*---char: v ---*/ - 0x00,0x00,0x00,0x02,0x28,0x94,0x51,0x42,0x08, - /*---char: w ---*/ - 0x00,0x00,0x00,0x02,0x28,0x95,0x55,0x52,0x08, - /*---char: x ---*/ - 0x00,0x00,0x00,0x02,0x25,0x14,0x21,0x45,0x22, - /*---char: y ---*/ - 0x00,0x00,0x00,0x02,0x28,0x94,0x51,0x42,0x08, - /*---char: z ---*/ - 0x00,0x00,0x00,0x03,0xe1,0x04,0x21,0x04,0x3e, - /*---char: { ---*/ - 0x00,0x00,0x08,0x41,0x04,0x10,0x81,0x04,0x10, - /*---char: | ---*/ - 0x00,0x00,0x10,0x41,0x04,0x10,0x41,0x04,0x10, - /*---char: } ---*/ - 0x00,0x00,0x10,0x20,0x82,0x08,0x10,0x82,0x08, - /*---char: ~ ---*/ - 0x00,0x00,0x00,0x00,0x00,0x0c,0x4c,0x00,0x00 -}; - -struct rtgui_font_bitmap arial12 = -{ - (const rt_uint8_t*)arial12_font, /* bmp */ - 6, /* width */ - 12, /* height */ - 32, /* first char */ - 127 /* last char */ -}; - -struct rtgui_font rtgui_font_arial12 = -{ - "arial", /* family */ - 12, /* height */ - 1, /* refer count */ - &bmp_font_engine, /* font engine */ - &arial12, /* font private data */ -}; -#endif diff --git a/rtgui/common/arial16font.c b/rtgui/common/arial16font.c deleted file mode 100644 index 07f61987f4..0000000000 --- a/rtgui/common/arial16font.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * File : arial16font.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 - * 2010-01-21 Bernard first version - */ -#include - -#ifdef RTGUI_USING_FONT16 -const unsigned char arial16_font[]= -{ - /*---char: ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: ! ---*/ - 0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, - /*---char: " ---*/ - 0x00,0x00,0x00,0x48,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: # ---*/ - 0x00,0x00,0x00,0x11,0x11,0x11,0x22,0xff,0x22,0x22,0x22,0xff,0x44,0x44,0x44,0x00, - /*---char: $ ---*/ - 0x00,0x00,0x08,0x1e,0x29,0x49,0x48,0x48,0x38,0x0e,0x09,0x09,0x49,0x2a,0x1c,0x08, - /*---char: % ---*/ - 0x00,0x00,0x00,0x38,0x44,0x44,0x45,0x45,0x39,0x02,0x02,0x04,0x04,0x08,0x08,0x00, - /*---char: & ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x22,0x22,0x14,0x18,0x28,0x44,0x42,0x41,0x22,0x1c,0x00, - /*---char: ' ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: ( ---*/ - 0x00,0x00,0x00,0x10,0x20,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x20, - /*---char: ) ---*/ - 0x00,0x00,0x00,0x40,0x20,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20, - /*---char: * ---*/ - 0x00,0x00,0x00,0x20,0xf8,0x20,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: + ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08,0x00,0x00,0x00, - /*---char: , ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20, - /*---char: - ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00, - /*---char: . ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00, - /*---char: / ---*/ - 0x00,0x00,0x00,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0x40,0x40,0x80,0x80,0x00, - /*---char: 0 ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1c,0x00, - /*---char: 1 ---*/ - 0x00,0x00,0x00,0x04,0x0c,0x14,0x24,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00, - /*---char: 2 ---*/ - 0x00,0x00,0x00,0x1e,0x22,0x41,0x01,0x01,0x02,0x02,0x04,0x08,0x10,0x20,0x7f,0x00, - /*---char: 3 ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x42,0x02,0x06,0x1c,0x02,0x01,0x01,0x41,0x62,0x1c,0x00, - /*---char: 4 ---*/ - 0x00,0x00,0x00,0x02,0x06,0x0a,0x12,0x12,0x22,0x42,0x82,0xff,0x02,0x02,0x02,0x00, - /*---char: 5 ---*/ - 0x00,0x00,0x00,0x3f,0x20,0x20,0x40,0x7c,0x42,0x01,0x01,0x01,0x41,0x22,0x1c,0x00, - /*---char: 6 ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x41,0x40,0x5c,0x62,0x41,0x41,0x41,0x41,0x22,0x1c,0x00, - /*---char: 7 ---*/ - 0x00,0x00,0x00,0x7f,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10,0x10,0x00, - /*---char: 8 ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x22,0x1c,0x22,0x41,0x41,0x41,0x22,0x1c,0x00, - /*---char: 9 ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x41,0x41,0x23,0x1d,0x01,0x41,0x22,0x1c,0x00, - /*---char: : ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, - /*---char: ; ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, - /*---char: < ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0e,0x30,0x40,0x30,0x0e,0x01,0x00,0x00,0x00, - /*---char: = ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00, - /*---char: > ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x38,0x06,0x01,0x06,0x38,0x40,0x00,0x00,0x00, - /*---char: ? ---*/ - 0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x01,0x02,0x04,0x08,0x08,0x08,0x00,0x08,0x00, - /*---char: @ ---*/ - 0x00,0x00,0x00,0x03,0x0c,0x10,0x21,0x22,0x44,0x48,0x48,0x48,0x48,0x44,0x23,0x10, - /*---char: A ---*/ - 0x00,0x00,0x00,0x04,0x0a,0x0a,0x0a,0x11,0x11,0x11,0x3f,0x20,0x20,0x40,0x40,0x00, - /*---char: B ---*/ - 0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x7f,0x40,0x40,0x40,0x40,0x40,0x7f,0x00, - /*---char: C ---*/ - 0x00,0x00,0x00,0x0f,0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x10,0x0f,0x00, - /*---char: D ---*/ - 0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7f,0x00, - /*---char: E ---*/ - 0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x7f,0x40,0x40,0x40,0x40,0x40,0x7f,0x00, - /*---char: F ---*/ - 0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x7f,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: G ---*/ - 0x00,0x00,0x00,0x0f,0x10,0x20,0x40,0x40,0x40,0x43,0x40,0x40,0x20,0x10,0x0f,0x00, - /*---char: H ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x7f,0x40,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: I ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: J ---*/ - 0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x42,0x42,0x3c,0x00, - /*---char: K ---*/ - 0x00,0x00,0x00,0x40,0x40,0x41,0x42,0x44,0x4c,0x54,0x62,0x41,0x41,0x40,0x40,0x00, - /*---char: L ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7f,0x00, - /*---char: M ---*/ - 0x00,0x00,0x00,0x40,0x60,0x60,0x50,0x50,0x48,0x48,0x45,0x45,0x45,0x42,0x42,0x00, - /*---char: N ---*/ - 0x00,0x00,0x00,0x40,0x60,0x50,0x50,0x48,0x44,0x44,0x42,0x41,0x41,0x40,0x40,0x00, - /*---char: O ---*/ - 0x00,0x00,0x00,0x0f,0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x10,0x0f,0x00, - /*---char: P ---*/ - 0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x7f,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: Q ---*/ - 0x00,0x00,0x00,0x0f,0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x23,0x10,0x0f,0x00, - /*---char: R ---*/ - 0x00,0x00,0x00,0x7f,0x40,0x40,0x40,0x40,0x40,0x7f,0x42,0x41,0x41,0x40,0x40,0x00, - /*---char: S ---*/ - 0x00,0x00,0x00,0x1f,0x20,0x40,0x40,0x20,0x1c,0x03,0x00,0x00,0x40,0x20,0x1f,0x00, - /*---char: T ---*/ - 0x00,0x00,0x00,0xff,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00, - /*---char: U ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x1f,0x00, - /*---char: V ---*/ - 0x00,0x00,0x00,0x40,0x40,0x20,0x20,0x20,0x11,0x11,0x11,0x0a,0x0a,0x04,0x04,0x00, - /*---char: W ---*/ - 0x00,0x00,0x00,0x81,0x82,0x42,0x42,0x44,0x44,0x24,0x28,0x28,0x28,0x10,0x10,0x00, - /*---char: X ---*/ - 0x00,0x00,0x00,0x40,0x20,0x11,0x11,0x0a,0x04,0x0a,0x11,0x11,0x20,0x40,0x80,0x00, - /*---char: Y ---*/ - 0x00,0x00,0x00,0x80,0x41,0x41,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x08,0x00, - /*---char: Z ---*/ - 0x00,0x00,0x00,0x7f,0x01,0x02,0x02,0x04,0x08,0x08,0x10,0x20,0x20,0x40,0xff,0x00, - /*---char: [ ---*/ - 0x00,0x00,0x00,0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, - /*---char: \ ---*/ - 0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x40,0x40,0x20,0x20,0x20,0x20,0x10,0x10,0x00, - /*---char: ] ---*/ - 0x00,0x00,0x00,0xe0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, - /*---char: ^ ---*/ - 0x00,0x00,0x00,0x10,0x28,0x28,0x44,0x44,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: _ ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: ` ---*/ - 0x00,0x00,0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - /*---char: a ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x21,0x41,0x07,0x39,0x41,0x41,0x43,0x3d,0x00, - /*---char: b ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x5c,0x62,0x41,0x41,0x41,0x41,0x41,0x62,0x5c,0x00, - /*---char: c ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x22,0x40,0x40,0x40,0x40,0x40,0x22,0x1c,0x00, - /*---char: d ---*/ - 0x00,0x00,0x00,0x01,0x01,0x01,0x1d,0x23,0x41,0x41,0x41,0x41,0x41,0x23,0x1d,0x00, - /*---char: e ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x7f,0x40,0x41,0x22,0x1c,0x00, - /*---char: f ---*/ - 0x00,0x00,0x00,0x30,0x40,0x40,0xf0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: g ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1d,0x23,0x41,0x41,0x41,0x41,0x41,0x23,0x1d,0x01, - /*---char: h ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x5c,0x62,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x00, - /*---char: i ---*/ - 0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: j ---*/ - 0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, - /*---char: k ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x41,0x42,0x44,0x48,0x58,0x64,0x44,0x42,0x41,0x00, - /*---char: l ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: m ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x63,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x00, - /*---char: n ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x62,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x00, - /*---char: o ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x41,0x41,0x41,0x22,0x1c,0x00, - /*---char: p ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x62,0x41,0x41,0x41,0x41,0x41,0x62,0x5c,0x40, - /*---char: q ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x1d,0x23,0x41,0x41,0x41,0x41,0x41,0x23,0x1d,0x01, - /*---char: r ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, - /*---char: s ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x40,0x40,0x3c,0x02,0x02,0x42,0x3c,0x00, - /*---char: t ---*/ - 0x00,0x00,0x00,0x00,0x40,0x40,0xf0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00, - /*---char: u ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x46,0x3a,0x00, - /*---char: v ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x82,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00, - /*---char: w ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x84,0x4a,0x4a,0x51,0x51,0x51,0x20,0x20,0x00, - /*---char: x ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x44,0x28,0x28,0x10,0x28,0x28,0x44,0x82,0x00, - /*---char: y ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x82,0x84,0x44,0x44,0x28,0x28,0x28,0x10,0x10, - /*---char: z ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x04,0x08,0x08,0x10,0x20,0x20,0x40,0xfe,0x00, - /*---char: { ---*/ - 0x00,0x00,0x00,0x18,0x20,0x20,0x20,0x20,0x20,0x20,0xc0,0x20,0x20,0x20,0x20,0x20, - /*---char: | ---*/ - 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, - /*---char: } ---*/ - 0x00,0x00,0x00,0xc0,0x20,0x20,0x20,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0x20,0x20, - /*---char: ~ ---*/ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x71,0x8e,0x00,0x00,0x00,0x00,0x00,0x00 -}; - -struct rtgui_font_bitmap arial16 = -{ - (const rt_uint8_t*)arial16_font, /* bmp */ - 8, /* width */ - 16, /* height */ - 32, /* first char */ - 127 /* last char */ -}; - -struct rtgui_font rtgui_font_arial16 = -{ - "arial", /* family */ - 16, /* height */ - 1, /* refer count */ - &bmp_font_engine, /* font engine */ - &arial16, /* font private data */ -}; -#endif diff --git a/rtgui/common/dc.c b/rtgui/common/dc.c index 6a0075f8e6..68a02e863b 100644 --- a/rtgui/common/dc.c +++ b/rtgui/common/dc.c @@ -226,8 +226,8 @@ void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtg #endif } -void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) -{ +void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) +{ int i, k; /* draw byte */ @@ -240,7 +240,7 @@ void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_ rtgui_dc_draw_point(dc, x + k, y + i); } } - } + } } void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) @@ -638,6 +638,44 @@ void rtgui_dc_fill_polygon(struct rtgui_dc* dc, const int* vx, const int* vy, in } } +#if 1 +void rtgui_dc_draw_circle(struct rtgui_dc *dc, + int xCenter, int yCenter, int radius) +{ + int x =0; + int y = radius; + int p = 1-radius; + + rtgui_dc_draw_point(dc,xCenter+x,yCenter+y); + rtgui_dc_draw_point(dc,xCenter-x,yCenter+y); + rtgui_dc_draw_point(dc,xCenter+x,yCenter-y); + rtgui_dc_draw_point(dc,xCenter-x,yCenter-y); + + rtgui_dc_draw_point(dc,xCenter+y,yCenter+x); + rtgui_dc_draw_point(dc,xCenter-y,yCenter+x); + rtgui_dc_draw_point(dc,xCenter+y,yCenter-x); + rtgui_dc_draw_point(dc,xCenter-y,yCenter-x); + + while(xmq, event, event_size); if (result != RT_EOK) - rt_kprintf("send event failed\n"); + { + if (event->type != RTGUI_EVENT_TIMER) + rt_kprintf("send event to %s failed\n", thread->tid->name); + } return result; } diff --git a/rtgui/common/rtgui_theme.c b/rtgui/common/rtgui_theme.c index 4f5ea3eb02..392ab67721 100644 --- a/rtgui/common/rtgui_theme.c +++ b/rtgui/common/rtgui_theme.c @@ -37,19 +37,19 @@ extern struct rtgui_font rtgui_font_arial12; /* init theme */ void rtgui_system_theme_init() -{ -#if RTGUI_DEFAULT_FONT_SIZE == 16 - rtgui_font_set_defaut(&rtgui_font_asc16); +{ +#if RTGUI_DEFAULT_FONT_SIZE == 16 + rtgui_font_set_defaut(&rtgui_font_asc16); #elif RTGUI_DEFAULT_FONT_SIZE == 12 - rtgui_font_set_defaut(&rtgui_font_asc12); -#else - rtgui_font_set_defaut(&rtgui_font_asc12); + rtgui_font_set_defaut(&rtgui_font_asc12); +#else + rtgui_font_set_defaut(&rtgui_font_asc12); #endif } -static const rt_uint8_t close_byte[14] = {0x06, 0x18, 0x03, 0x30, 0x01, 0xE0, 0x00, - 0xC0, 0x01, 0xE0, 0x03, 0x30, 0x06, 0x18 -}; +static const rt_uint8_t close_byte[14] = {0x06, 0x18, 0x03, 0x30, 0x01, 0xE0, 0x00, + 0xC0, 0x01, 0xE0, 0x03, 0x30, 0x06, 0x18 +}; /* window drawing */ void rtgui_theme_draw_win(struct rtgui_topwin* win) @@ -406,10 +406,7 @@ void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox) rtgui_dc_end_drawing(dc); } -#define CHECK_BOX_W 13 -#define CHECK_BOX_H 13 -static const rt_uint8_t checked_byte[7] = {0x02, 0x06, 0x8E, 0xDC, 0xF8, 0x70, 0x20}; - +static const rt_uint8_t checked_byte[7] = {0x02, 0x06, 0x8E, 0xDC, 0xF8, 0x70, 0x20}; void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox) { struct rtgui_dc* dc; @@ -472,6 +469,21 @@ void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox) return; } +static const rt_uint8_t radio_unchecked_byte[] = +{ + 0x0f, 0x00, 0x30, 0xc0, 0x40, 0x20, + 0x40, 0x20, 0x80, 0x10, 0x80, 0x10, + 0x80, 0x10, 0x80, 0x10, 0x40, 0x20, + 0x40, 0x20, 0x30, 0xc0, 0x0f, 0x00, +}; +static const rt_uint8_t radio_checked_byte[] = +{ + 0x0f, 0x00, 0x30, 0xc0, 0x40, 0x20, + 0x40, 0x20, 0x86, 0x10, 0x8f, 0x10, + 0x8f, 0x10, 0x86, 0x10, 0x40, 0x20, + 0x40, 0x20, 0x30, 0xc0, 0x0f, 0x00, +}; + void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox) { struct rtgui_dc* dc; @@ -531,9 +543,12 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox) if (radiobox->orient == RTGUI_VERTICAL) { + rt_uint16_t offset; + /* set the first text rect */ item_rect.y2 = item_rect.y1 + item_size; + offset = (item_size - RADIO_BOX_H) / 2; /* draw each radio button */ for (index = 0; index < radiobox->item_count; index ++) { @@ -544,12 +559,12 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox) { if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(radiobox))) rtgui_dc_draw_focus_rect(dc, &item_rect); - rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2 + 2, item_rect.y1 + item_size/2 + 2, item_size/2 - 2); - rtgui_dc_fill_circle(dc, item_rect.x1 + item_size/2 + 2, item_rect.y1 + item_size/2 + 2, item_size/2 - 4); + + rtgui_dc_draw_word(dc, item_rect.x1, item_rect.y1 + offset, RADIO_BOX_H, radio_checked_byte); } else { - rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2 + 2, item_rect.y1 + item_size/2 + 2, item_size/2 - 2); + rtgui_dc_draw_word(dc, item_rect.x1, item_rect.y1 + offset, RADIO_BOX_H, radio_unchecked_byte); } /* draw text */ @@ -576,12 +591,12 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox) if (radiobox->item_selection == index) { rtgui_dc_draw_focus_rect(dc, &item_rect); - rtgui_dc_draw_circle(dc, item_rect.x1 + bord_size/2 + 2, item_rect.y1 + bord_size/2 + 2, bord_size/2 - 2); - rtgui_dc_fill_circle(dc, item_rect.x1 + bord_size/2 + 2, item_rect.y1 + bord_size/2 + 2, bord_size/2 - 4); + + rtgui_dc_draw_word(dc, item_rect.x1, item_rect.y1, RADIO_BOX_H, radio_checked_byte); } else { - rtgui_dc_draw_circle(dc, item_rect.x1 + bord_size/2 + 2, item_rect.y1 + bord_size/2 + 2, bord_size/2 - 2); + rtgui_dc_draw_word(dc, item_rect.x1, item_rect.y1, RADIO_BOX_H, radio_unchecked_byte); } /* draw text */ diff --git a/rtgui/include/rtgui/rtgui_config.h b/rtgui/include/rtgui/rtgui_config.h index 311007d71e..a941ad6422 100644 --- a/rtgui/include/rtgui/rtgui_config.h +++ b/rtgui/include/rtgui/rtgui_config.h @@ -19,6 +19,19 @@ /* RTGUI options */ #ifdef _WIN32 +/* name length of RTGUI object */ +#define RTGUI_NAME_MAX 12 +/* support 16 weight font */ +#define RTGUI_USING_FONT16 +/* support Chinese font */ +#define RTGUI_USING_FONTHZ +/* use small size in RTGUI */ +#define RTGUI_USING_SMALL_SIZE +/* use mouse cursor */ +/* #define RTGUI_USING_MOUSE_CURSOR */ +/* default font size in RTGUI */ +#define RTGUI_DEFAULT_FONT_SIZE 12 + #define RTGUI_USING_STDIO_FILERW #define RTGUI_IMAGE_PNG #define RTGUI_IMAGE_JPEG diff --git a/rtgui/include/rtgui/rtgui_theme.h b/rtgui/include/rtgui/rtgui_theme.h index 979e1cb254..20912149bd 100644 --- a/rtgui/include/rtgui/rtgui_theme.h +++ b/rtgui/include/rtgui/rtgui_theme.h @@ -17,6 +17,12 @@ #include #include +#define CHECK_BOX_W 13 +#define CHECK_BOX_H 13 + +#define RADIO_BOX_W 12 +#define RADIO_BOX_H 12 + #include #include #include diff --git a/rtgui/include/rtgui/widgets/window.h b/rtgui/include/rtgui/widgets/window.h index ea730580ad..75c53eb69b 100644 --- a/rtgui/include/rtgui/widgets/window.h +++ b/rtgui/include/rtgui/widgets/window.h @@ -52,7 +52,10 @@ struct rtgui_win /* top window style */ rt_uint8_t style; + + rt_uint8_t flag; rtgui_modal_code_t modal_code; + rtgui_widget_t* modal_widget; /* window title */ char* title; @@ -69,7 +72,7 @@ struct rtgui_win rtgui_type_t *rtgui_win_type_get(void); rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, - rtgui_rect_t *rect, rt_uint32_t flag); + rtgui_rect_t *rect, rt_uint8_t flag); void rtgui_win_destroy(rtgui_win_t* win); rtgui_modal_code_t rtgui_win_show(rtgui_win_t* win, rt_bool_t is_modal); diff --git a/rtgui/include/rtgui/widgets/workbench.h b/rtgui/include/rtgui/widgets/workbench.h index 3d8668083a..ba863f080e 100644 --- a/rtgui/include/rtgui/widgets/workbench.h +++ b/rtgui/include/rtgui/widgets/workbench.h @@ -33,6 +33,8 @@ #define RTGUI_WORKBENCH_FLAG_DEFAULT RTGUI_WORKBENCH_FLAG_VISIBLE | RTGUI_WORKBENCH_FLAG_CLOSEBLE +#define RTGUI_WORKBENCH_IS_MODAL_MODE(w) ((w)->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE) + /** Gets the type of a workbench */ #define RTGUI_WORKBENCH_TYPE (rtgui_workbench_type_get()) /** Casts the object to an rtgui_workbench */ @@ -51,6 +53,7 @@ struct rtgui_workbench /* workbench flag */ rt_uint8_t flag; rtgui_modal_code_t modal_code; + rtgui_widget_t *modal_widget; /* workbench title */ unsigned char* title; diff --git a/rtgui/server/server.c b/rtgui/server/server.c index 4c72781f66..2d4b5c317b 100644 --- a/rtgui/server/server.c +++ b/rtgui/server/server.c @@ -483,7 +483,7 @@ static void rtgui_server_entry(void* parameter) #ifdef RTGUI_USING_SMALL_SIZE /* create rtgui server msgq */ rtgui_server_mq = rt_mq_create("rtgui", - 32, 8, RT_IPC_FLAG_FIFO); + 32, 16, RT_IPC_FLAG_FIFO); #else /* create rtgui server msgq */ rtgui_server_mq = rt_mq_create("rtgui", diff --git a/rtgui/server/topwin.c b/rtgui/server/topwin.c index 059b06d4a6..abd7266119 100644 --- a/rtgui/server/topwin.c +++ b/rtgui/server/topwin.c @@ -224,7 +224,7 @@ void rtgui_topwin_activate_win(struct rtgui_topwin* win) rtgui_theme_draw_win(win); } - if (rtgui_server_focus_topwin != RT_NULL) + if ((rtgui_server_focus_topwin != RT_NULL) && (rtgui_server_focus_topwin != win)) { /* deactivate the old focus win */ RTGUI_EVENT_WIN_DEACTIVATE_INIT(&event); @@ -465,6 +465,11 @@ void rtgui_topwin_show(struct rtgui_event_win* event) /* not the front window, raise it */ rtgui_topwin_raise(wid, sender); } + else + { + /* just raise it */ + rtgui_topwin_raise(wid, sender); + } } else { diff --git a/rtgui/widgets/filelist_view.c b/rtgui/widgets/filelist_view.c index 894ac965fe..3724b84d6d 100644 --- a/rtgui/widgets/filelist_view.c +++ b/rtgui/widgets/filelist_view.c @@ -415,6 +415,38 @@ rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct } break; + case RTGUI_EVENT_MOUSE_BUTTON: + { + rtgui_rect_t rect; + struct rtgui_event_mouse* emouse; + + emouse = (struct rtgui_event_mouse*)event; + + /* calculate selected item */ + + /* get physical extent information */ + rtgui_widget_get_rect(widget, &rect); + rtgui_widget_rect_to_device(widget, &rect); + + if (rtgui_rect_contains_point(&rect, emouse->x, emouse->y) == RT_EOK) + { + rt_uint16_t index; + index = (emouse->y - rect.y1) / (2 + rtgui_theme_get_selected_height()); + + if ((index < view->items_count) && (index < view->page_items)) + { + rt_uint16_t old_item; + + old_item = view->current_item; + + /* set selected item */ + view->current_item = (old_item/view->page_items) * view->page_items + index; + rtgui_filelist_view_update_current(view, old_item); + } + } + } + break; + case RTGUI_EVENT_KBD: { struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event; @@ -474,7 +506,11 @@ rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct } } else if (view->current_item == 0 && +#ifdef _WIN32 + (view->current_directory[1] == ':') && (view->current_directory[2] == '\\')) +#else (view->current_directory[0] == '/') && (view->current_directory[1] == '\0')) +#endif { if (RTGUI_VIEW(view)->modal_show == RT_TRUE) { diff --git a/rtgui/widgets/list_view.c b/rtgui/widgets/list_view.c index 91ff21970b..42f50b702c 100644 --- a/rtgui/widgets/list_view.c +++ b/rtgui/widgets/list_view.c @@ -182,6 +182,38 @@ rt_bool_t rtgui_list_view_event_handler(struct rtgui_widget* widget, struct rtgu } break; + case RTGUI_EVENT_MOUSE_BUTTON: + { + rtgui_rect_t rect; + struct rtgui_event_mouse* emouse; + + emouse = (struct rtgui_event_mouse*)event; + + /* calculate selected item */ + + /* get physical extent information */ + rtgui_widget_get_rect(widget, &rect); + rtgui_widget_rect_to_device(widget, &rect); + + if (rtgui_rect_contains_point(&rect, emouse->x, emouse->y) == RT_EOK) + { + rt_uint16_t index; + index = (emouse->y - rect.y1) / (2 + rtgui_theme_get_selected_height()); + + if ((index < view->items_count) && (index < view->page_items)) + { + rt_uint16_t old_item; + + old_item = view->current_item; + + /* set selected item */ + view->current_item = view->current_item/view->page_items + index; + rtgui_list_view_update_current(view, old_item); + } + } + } + break; + case RTGUI_EVENT_KBD: { struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event; diff --git a/rtgui/widgets/radiobox.c b/rtgui/widgets/radiobox.c index d5bd39f841..babf9f9ce1 100644 --- a/rtgui/widgets/radiobox.c +++ b/rtgui/widgets/radiobox.c @@ -192,6 +192,9 @@ struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char radiobox->item_size = board_size + 3 + rtgui_rect_width(rect); } } + + if (radiobox->item_size < RADIO_BOX_H + 2) + radiobox->item_size = RADIO_BOX_H + 2; } return radiobox; diff --git a/rtgui/widgets/view.c b/rtgui/widgets/view.c index ed436d5282..3c2c714eca 100644 --- a/rtgui/widgets/view.c +++ b/rtgui/widgets/view.c @@ -116,7 +116,10 @@ rtgui_view_t* rtgui_view_create(const char* title) void rtgui_view_destroy(rtgui_view_t* view) { - rtgui_widget_destroy(RTGUI_WIDGET(view)); + if (view->modal_show == RT_TRUE) + rtgui_view_end_modal(view, RTGUI_MODAL_CANCEL); + else + rtgui_widget_destroy(RTGUI_WIDGET(view)); } void rtgui_view_set_box(rtgui_view_t* view, rtgui_box_t* box) @@ -151,9 +154,12 @@ rtgui_modal_code_t rtgui_view_show(rtgui_view_t* view, rt_bool_t is_modal) { /* set modal mode */ workbench->flag |= RTGUI_WORKBENCH_FLAG_MODAL_MODE; + workbench->modal_widget = RTGUI_WIDGET(view); /* perform workbench event loop */ rtgui_workbench_event_loop(workbench); + + workbench->modal_widget = RT_NULL; return workbench->modal_code; } @@ -171,6 +177,9 @@ void rtgui_view_end_modal(rtgui_view_t* view, rtgui_modal_code_t modal_code) workbench = RTGUI_WORKBENCH(RTGUI_WIDGET(view)->parent); workbench->modal_code = modal_code; workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + + /* remove modal mode */ + view->modal_show = RT_FALSE; } void rtgui_view_hide(rtgui_view_t* view) diff --git a/rtgui/widgets/widget.c b/rtgui/widgets/widget.c index dbdf4f22c3..61043c81ec 100644 --- a/rtgui/widgets/widget.c +++ b/rtgui/widgets/widget.c @@ -37,10 +37,11 @@ static void _rtgui_widget_constructor(rtgui_widget_t *widget) widget->toplevel = RT_NULL; /* some common event handler */ -#ifndef RTGUI_USING_SMALL_SIZE - widget->on_draw = RT_NULL; widget->on_focus_in = RT_NULL; widget->on_focus_out = RT_NULL; + +#ifndef RTGUI_USING_SMALL_SIZE + widget->on_draw = RT_NULL; widget->on_mouseclick = RT_NULL; widget->on_key = RT_NULL; widget->on_size = RT_NULL; @@ -276,11 +277,9 @@ void rtgui_widget_focus(rtgui_widget_t *widget) if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(parent))) break; } -#ifndef RTGUI_USING_SMALL_SIZE /* invoke on focus in call back */ if (widget->on_focus_in != RT_NULL) widget->on_focus_in(widget, RT_NULL); -#endif } /** @@ -291,15 +290,16 @@ void rtgui_widget_unfocus(rtgui_widget_t *widget) { RT_ASSERT(widget != RT_NULL); - widget->flag &= ~RTGUI_WIDGET_FLAG_FOCUS; - if (!widget->toplevel || !RTGUI_WIDGET_IS_FOCUSED(widget)) return; -#ifndef RTGUI_USING_SMALL_SIZE + widget->flag &= ~RTGUI_WIDGET_FLAG_FOCUS; + if (widget->on_focus_out != RT_NULL) widget->on_focus_out(widget, RT_NULL); -#endif + + /* refresh widget */ + rtgui_widget_update(widget); } void rtgui_widget_point_to_device(rtgui_widget_t* widget, rtgui_point_t* point) diff --git a/rtgui/widgets/window.c b/rtgui/widgets/window.c index 1f6dfdcc34..03465f207e 100644 --- a/rtgui/widgets/window.c +++ b/rtgui/widgets/window.c @@ -113,7 +113,7 @@ rtgui_type_t *rtgui_win_type_get(void) return win_type; } -rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_rect_t *rect, rt_uint32_t style) +rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_rect_t *rect, rt_uint8_t style) { struct rtgui_win* win; @@ -143,28 +143,14 @@ rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* tit void rtgui_win_destroy(struct rtgui_win* win) { - if (win->parent_toplevel != RT_NULL) + if (win->style & RTGUI_WIN_STYLE_MODAL) { - if (win->style & RTGUI_WIN_STYLE_MODAL) - { - /* exit modal mode */ - win->style &= ~RTGUI_WIN_STYLE_MODAL; - /* set style to closed */ - win->style |= RTGUI_WIN_STYLE_CLOSED; - } - else rtgui_widget_destroy(RTGUI_WIDGET(win)); - - } - else if (win->style & RTGUI_WIN_STYLE_CLOSED) - { - rtgui_widget_destroy(RTGUI_WIDGET(win)); + /* end modal */ + rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL); } else { - /* exit modal mode */ - win->style &= ~RTGUI_WIN_STYLE_MODAL; - /* set style to closed */ - win->style |= RTGUI_WIN_STYLE_CLOSED; + rtgui_widget_destroy(RTGUI_WIDGET(win)); } } @@ -205,15 +191,37 @@ rtgui_modal_code_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal) { if (win->parent_toplevel != RT_NULL) { - rtgui_workbench_t* workbench; + rtgui_widget_t *parent_widget; + + /* set style */ + win->style |= RTGUI_WIN_STYLE_MODAL; /* get root toplevel */ - workbench = RTGUI_WORKBENCH(win->parent_toplevel); - workbench->flag |= RTGUI_WORKBENCH_FLAG_MODAL_MODE; + parent_widget = RTGUI_WIDGET(win->parent_toplevel); + if (RTGUI_IS_WORKBENCH(parent_widget)) + { + rtgui_workbench_t* workbench; + workbench = RTGUI_WORKBENCH(win->parent_toplevel); + workbench->flag |= RTGUI_WORKBENCH_FLAG_MODAL_MODE; + workbench->modal_widget = RTGUI_WIDGET(win); - rtgui_workbench_event_loop(workbench); - result = workbench->modal_code; - workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + rtgui_workbench_event_loop(workbench); + result = workbench->modal_code; + workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + workbench->modal_widget = RT_NULL; + } + else if (RTGUI_IS_WIN(parent_widget)) + { + rtgui_win_t* parent_win; + parent_win = RTGUI_WIN(win->parent_toplevel); + parent_win->flag |= RTGUI_WORKBENCH_FLAG_MODAL_MODE; + parent_win->modal_widget = RTGUI_WIDGET(win); + + rtgui_win_event_loop(parent_win); + result = parent_win->modal_code; + parent_win->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + parent_win->modal_widget = RT_NULL; + } } else { @@ -233,19 +241,33 @@ void rtgui_win_end_modal(struct rtgui_win* win, rtgui_modal_code_t modal_code) { if (win->parent_toplevel != RT_NULL) { - rtgui_workbench_t* workbench; + if (RTGUI_IS_WORKBENCH(win->parent_toplevel)) + { + rtgui_workbench_t* workbench; - /* which is shown under workbench */ - workbench = RTGUI_WORKBENCH(win->parent_toplevel); - workbench->modal_code = modal_code; - workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + /* which is shown under workbench */ + workbench = RTGUI_WORKBENCH(win->parent_toplevel); + workbench->modal_code = modal_code; + workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + } + else if (RTGUI_IS_WIN(win->parent_toplevel)) + { + rtgui_win_t* parent_win; + + /* which is shown under win */ + parent_win = RTGUI_WIN(win->parent_toplevel); + parent_win->modal_code = modal_code; + parent_win->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE; + } } else { /* which is a stand alone window */ win->modal_code = modal_code; - win->style &= ~RTGUI_WIN_STYLE_MODAL; } + + /* remove modal mode */ + win->style &= ~RTGUI_WIN_STYLE_MODAL; } void rtgui_win_hiden(struct rtgui_win* win) @@ -359,8 +381,15 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even if (win->on_close(widget, event) == RT_FALSE) return RT_TRUE; } - /* destroy window */ - rtgui_win_destroy(win); + if (win->style & RTGUI_WIN_STYLE_MODAL) + { + rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL); + } + else + { + /* destroy window */ + rtgui_win_destroy(win); + } /* exit event loop */ return RT_TRUE; @@ -394,16 +423,29 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even break; case RTGUI_EVENT_WIN_DEACTIVATE: - win->style &= ~RTGUI_WIN_STYLE_ACTIVATE; -#ifndef RTGUI_USING_SMALL_SIZE - if (widget->on_draw != RT_NULL) widget->on_draw(widget, event); - else -#endif - rtgui_win_ondraw(win); - - if (win->on_deactivate != RT_NULL) + if (win->style & RTGUI_WIN_STYLE_MODAL) { - win->on_deactivate(widget, event); + /* do not deactivate a modal win */ + struct rtgui_event_win_show eshow; + RTGUI_EVENT_WIN_SHOW_INIT(&eshow); + eshow.wid = win; + + rtgui_thread_send(RTGUI_TOPLEVEL(win)->server, RTGUI_EVENT(&eshow), + sizeof(struct rtgui_event_win_show)); + } + else + { + win->style &= ~RTGUI_WIN_STYLE_ACTIVATE; +#ifndef RTGUI_USING_SMALL_SIZE + if (widget->on_draw != RT_NULL) widget->on_draw(widget, event); + else +#endif + rtgui_win_ondraw(win); + + if (win->on_deactivate != RT_NULL) + { + win->on_deactivate(widget, event); + } } break; @@ -416,7 +458,13 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even break; case RTGUI_EVENT_MOUSE_BUTTON: - if (rtgui_container_dispatch_mouse_event(RTGUI_CONTAINER(win), (struct rtgui_event_mouse*)event) == RT_FALSE) + if (win->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE) + { + if (win->modal_widget != RT_NULL) + return win->modal_widget->event_handler(win->modal_widget, event); + } + else if (rtgui_container_dispatch_mouse_event(RTGUI_CONTAINER(win), + (struct rtgui_event_mouse*)event) == RT_FALSE) { #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_mouseclick != RT_NULL) @@ -445,7 +493,12 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_even break; case RTGUI_EVENT_KBD: - if (RTGUI_CONTAINER(win)->focused != widget) + if (win->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE) + { + if (win->modal_widget != RT_NULL) + return win->modal_widget->event_handler(win->modal_widget, event); + } + else if (RTGUI_CONTAINER(win)->focused != widget) { RTGUI_CONTAINER(win)->focused->event_handler(RTGUI_CONTAINER(win)->focused, event); } diff --git a/rtgui/widgets/workbench.c b/rtgui/widgets/workbench.c index 5ac2cd2452..cd0d5fedb3 100644 --- a/rtgui/widgets/workbench.c +++ b/rtgui/widgets/workbench.c @@ -294,12 +294,24 @@ rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* e } else { - /* let viewer to handle it */ - rtgui_view_t* view = workbench->current_view; - if (view != RT_NULL && - RTGUI_WIDGET(view)->event_handler != RT_NULL) + if (RTGUI_WORKBENCH_IS_MODAL_MODE(workbench)) { - RTGUI_WIDGET(view)->event_handler(RTGUI_WIDGET(view), event); + /* let modal widget to handle it */ + if (workbench->modal_widget != RT_NULL && + workbench->modal_widget->event_handler != RT_NULL) + { + workbench->modal_widget->event_handler(workbench->modal_widget, event); + } + } + else + { + /* let viewer to handle it */ + rtgui_view_t* view = workbench->current_view; + if (view != RT_NULL && + RTGUI_WIDGET(view)->event_handler != RT_NULL) + { + RTGUI_WIDGET(view)->event_handler(RTGUI_WIDGET(view), event); + } } } } @@ -317,14 +329,26 @@ rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* e } else { - if (RTGUI_CONTAINER(widget)->focused == widget) + if (RTGUI_WORKBENCH_IS_MODAL_MODE(workbench)) { - /* set focused widget to the current view */ - if (workbench->current_view != RT_NULL) - rtgui_widget_focus(RTGUI_WIDGET(RTGUI_CONTAINER(workbench->current_view)->focused)); + /* let modal widget to handle it */ + if (workbench->modal_widget != RT_NULL && + workbench->modal_widget->event_handler != RT_NULL) + { + workbench->modal_widget->event_handler(workbench->modal_widget, event); + } } + else + { + if (RTGUI_CONTAINER(widget)->focused == widget) + { + /* set focused widget to the current view */ + if (workbench->current_view != RT_NULL) + rtgui_widget_focus(RTGUI_WIDGET(RTGUI_CONTAINER(workbench->current_view)->focused)); + } - return rtgui_toplevel_event_handler(widget, event); + return rtgui_toplevel_event_handler(widget, event); + } } } break;