fix some widgets drawing routine.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@333 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2010-01-25 00:01:18 +00:00
parent e1f2525416
commit 143d95a998
9 changed files with 65 additions and 13 deletions

View File

@ -259,12 +259,12 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win)
if (win->flag & WINTITLE_ACTIVATE)
{
r = 10; g = 36; b = 106;
delta = (float)(rect.x2 - rect.x1) / 160;
delta = 150 / (float)(rect.x2 - rect.x1);
}
else
{
r = 128; g = 128; b = 128;
delta = (float)(rect.x2 - rect.x1) / 64;
delta = 64 / (float)(rect.x2 - rect.x1);
}
for (index = rect.x1; index < rect.x2; index ++)
@ -450,6 +450,7 @@ void rtgui_theme_draw_textbox(rtgui_textbox_t* box)
/* draw button */
struct rtgui_dc* dc;
struct rtgui_rect rect;
rtgui_color_t fc;
/* begin drawing */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(box));
@ -457,19 +458,39 @@ void rtgui_theme_draw_textbox(rtgui_textbox_t* box)
/* get widget rect */
rtgui_widget_get_rect(RTGUI_WIDGET(box), &rect);
fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(box));
/* fill widget rect with background color */
/* fill widget rect with white color */
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(box)) = white;
rtgui_dc_fill_rect(dc, &rect);
/* draw border */
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC);
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(box)) = RTGUI_RGB(123, 158, 189);
rtgui_dc_draw_rect(dc, &rect);
/* draw text */
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(box)) = fc;
if (box->text != RT_NULL)
{
rect.x1 += RTGUI_TEXTBOX_MARGIN;
if (box->flag & RTGUI_TEXTBOX_MASK)
{
/* draw '*' */
rt_size_t len = rt_strlen(box->text);
if (len > 0)
{
char *text_mask = rtgui_malloc(len);
rt_memset(text_mask, '*', len);
text_mask[len] = 0;
rtgui_dc_draw_text(dc, text_mask, &rect);
rt_free(text_mask);
}
}
else
{
rtgui_dc_draw_text(dc, box->text, &rect);
}
/* draw caret */
if (box->flag & RTGUI_TEXTBOX_CARET_SHOW)
@ -477,8 +498,10 @@ void rtgui_theme_draw_textbox(rtgui_textbox_t* box)
rect.x1 += box->position * box->font_width;
rect.x2 = rect.x1 + box->font_width;
rect.y2 -= 2;
rect.y1 = rect.y2 - 3;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(box)) = black;
rtgui_dc_fill_rect(dc, &rect);
}
}
@ -669,6 +692,7 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox)
{
/* set the first text rect */
item_rect.x2 = item_rect.x1 + item_size;
item_rect.y2 = item_rect.y1 + bord_size;
/* draw each radio button */
for (index = 0; index < radiobox->item_count; index ++)
@ -866,7 +890,9 @@ void rtgui_theme_draw_staticline(struct rtgui_staticline* staticline)
/* begin drawing */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(staticline));
if (dc == RT_NULL) return ;
rtgui_widget_get_rect(RTGUI_WIDGET(staticline), &rect);
rtgui_dc_fill_rect(dc, &rect);
if (staticline->orientation == RTGUI_HORIZONTAL)
{

View File

@ -15,7 +15,6 @@
#define __RT_GUI_H__
#include <rtthread.h>
#include <rtgui/rtgui_config.h>
#define RT_INT16_MAX 32767

View File

@ -42,9 +42,18 @@
#define RTGUI_SVR_THREAD_PRIORITY 15
#define RTGUI_SVR_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_SVR_THREAD_STACK_SIZE 1024
#else
#define RTGUI_SVR_THREAD_STACK_SIZE 2048
#endif
#define RTGUI_APP_THREAD_PRIORITY 25
#define RTGUI_APP_THREAD_TIMESLICE 8
#define RTGUI_APP_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_APP_THREAD_STACK_SIZE 1024
#else
#define RTGUI_APP_THREAD_STACK_SIZE 2048
#endif
#endif

View File

@ -29,6 +29,7 @@
#define RTGUI_TEXTBOX_SINGLE 0x00
#define RTGUI_TEXTBOX_MULTI 0x01
#define RTGUI_TEXTBOX_MASK 0x02
#define RTGUI_TEXTBOX_CARET_SHOW 0x10
#define RTGUI_TEXTBOX_CARET_HIDE 0x00

View File

@ -480,9 +480,15 @@ static void rtgui_server_entry(void* parameter)
SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST);
#endif
#ifdef RTGUI_USING_SMALL_SIZE
/* create rtgui server msgq */
rtgui_server_mq = rt_mq_create("rtgui",
64, 8, RT_IPC_FLAG_FIFO);
#else
/* create rtgui server msgq */
rtgui_server_mq = rt_mq_create("rtgui",
256, 8, RT_IPC_FLAG_FIFO);
#endif
/* register rtgui server thread */
rtgui_thread_register(rtgui_server_tid, rtgui_server_mq);
@ -495,7 +501,11 @@ static void rtgui_server_entry(void* parameter)
while (1)
{
/* the buffer uses to receive event */
#ifdef RTGUI_USING_SMALL_SIZE
char event_buf[64];
#else
char event_buf[256];
#endif
struct rtgui_event* event = (struct rtgui_event*)&(event_buf[0]);
if (rtgui_thread_recv(event, sizeof(event_buf)) == RT_EOK)

View File

@ -49,8 +49,9 @@ static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui
/* focus widgets */
rtgui_widget_focus(RTGUI_WIDGET(radiobox));
/* get widget rect */
/* get widget physical rect */
rtgui_widget_get_rect(RTGUI_WIDGET(radiobox), &rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(radiobox), &rect);
/* get board size */
if (radiobox->orient == RTGUI_VERTICAL)
@ -187,7 +188,7 @@ struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char
for (index = 0; index < number; index ++)
{
rtgui_font_get_metrics(font, radio_items[index], &rect);
if (rtgui_rect_width(rect) > radiobox->item_size)
if ( (board_size + 3 + rtgui_rect_width(rect)) > radiobox->item_size)
radiobox->item_size = board_size + 3 + rtgui_rect_width(rect);
}
}

View File

@ -10,9 +10,6 @@ static void _rtgui_staticline_constructor(rtgui_staticline_t *staticline)
rtgui_widget_set_rect(RTGUI_WIDGET(staticline), &rect);
staticline->orientation= RTGUI_HORIZONTAL;
/* set background color */
RTGUI_WIDGET(staticline)->gc.background = RTGUI_RGB(64, 64, 64);
rtgui_widget_set_event_handler(RTGUI_WIDGET(staticline), rtgui_staticline_event_handler);
}

View File

@ -127,8 +127,13 @@ static void rtgui_textbox_onmouse(struct rtgui_textbox* box, struct rtgui_event_
box->position = x / box->font_width;
}
/* set caret to show */
box->flag |= RTGUI_TEXTBOX_CARET_SHOW;
/* set widget focus */
rtgui_widget_focus(RTGUI_WIDGET(box));
/* re-draw text box */
rtgui_theme_draw_textbox(box);
}
}
@ -236,6 +241,8 @@ static rt_bool_t rtgui_textbox_onfocus(struct rtgui_widget* widget, struct rtgui
{
struct rtgui_textbox* box = (struct rtgui_textbox*)widget;
/* set caret to show */
box->flag |= RTGUI_TEXTBOX_CARET_SHOW;
/* start caret timer */
rtgui_timer_start(box->caret_timer);
@ -248,7 +255,8 @@ static rt_bool_t rtgui_textbox_onunfocus(struct rtgui_widget* widget, struct rtg
/* stop caret timer */
rtgui_timer_stop(box->caret_timer);
/* hide caret */
/* set caret to hide */
box->flag &= ~RTGUI_TEXTBOX_CARET_SHOW;
return RT_TRUE;
}

View File

@ -19,6 +19,7 @@ static void _rtgui_wintitle_constructor(rtgui_wintitle_t* wintitle)
{
wintitle->title = RT_NULL;
RTGUI_WIDGET(wintitle)->flag = RTGUI_WIDGET_FLAG_DEFAULT;
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(wintitle)) = RTGUI_ALIGN_CENTER_VERTICAL;
}
static void _rtgui_wintitle_deconstructor(rtgui_wintitle_t* wintitle)