update radiobox handling; add more optimization on small size.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@311 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
8d99235dea
commit
a1d1aea772
|
@ -767,6 +767,10 @@ void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16
|
||||||
int startoct, endoct, oct, stopval_start, stopval_end;
|
int startoct, endoct, oct, stopval_start, stopval_end;
|
||||||
double temp;
|
double temp;
|
||||||
|
|
||||||
|
stopval_start = 0;
|
||||||
|
stopval_end = 0;
|
||||||
|
temp = 0;
|
||||||
|
|
||||||
/* Sanity check radius */
|
/* Sanity check radius */
|
||||||
if (r < 0) return ;
|
if (r < 0) return ;
|
||||||
/* Special case for r=0 - draw a point */
|
/* Special case for r=0 - draw a point */
|
||||||
|
|
|
@ -47,7 +47,8 @@ void rtgui_font_system_init()
|
||||||
|
|
||||||
#ifdef RTGUI_USING_FONT12
|
#ifdef RTGUI_USING_FONT12
|
||||||
rtgui_font_set_defaut(&rtgui_font_asc12);
|
rtgui_font_set_defaut(&rtgui_font_asc12);
|
||||||
#elif defined(RTGUI_USING_FONT16)
|
#endif
|
||||||
|
#ifdef RTGUI_USING_FONT16
|
||||||
rtgui_font_set_defaut(&rtgui_font_asc16);
|
rtgui_font_set_defaut(&rtgui_font_asc16);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,15 +270,19 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
|
||||||
/* draw button */
|
/* draw button */
|
||||||
struct rtgui_dc* dc;
|
struct rtgui_dc* dc;
|
||||||
struct rtgui_rect rect;
|
struct rtgui_rect rect;
|
||||||
|
rtgui_color_t fc;
|
||||||
|
|
||||||
/* begin drawing */
|
/* begin drawing */
|
||||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(btn));
|
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(btn));
|
||||||
if (dc == RT_NULL) return;
|
if (dc == RT_NULL) return;
|
||||||
|
|
||||||
|
/* get widget rect */
|
||||||
rtgui_widget_get_rect(RTGUI_WIDGET(btn), &rect);
|
rtgui_widget_get_rect(RTGUI_WIDGET(btn), &rect);
|
||||||
|
|
||||||
|
/* get forecolor */
|
||||||
|
fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn));
|
||||||
|
|
||||||
/* fill button rect with background color */
|
/* fill button rect with background color */
|
||||||
// RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(btn)) = RTGUI_RGB(212, 208, 200);
|
|
||||||
rtgui_dc_fill_rect(dc, &rect);
|
rtgui_dc_fill_rect(dc, &rect);
|
||||||
|
|
||||||
if (btn->flag & RTGUI_BUTTON_TYPE_PUSH && btn->flag & RTGUI_BUTTON_FLAG_PRESS)
|
if (btn->flag & RTGUI_BUTTON_TYPE_PUSH && btn->flag & RTGUI_BUTTON_FLAG_PRESS)
|
||||||
|
@ -359,10 +363,12 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set forecolor */
|
||||||
|
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn)) = fc;
|
||||||
|
|
||||||
if (btn->pressed_image == RT_NULL)
|
if (btn->pressed_image == RT_NULL)
|
||||||
{
|
{
|
||||||
/* re-set foreground and get default rect */
|
/* re-set foreground and get default rect */
|
||||||
RTGUI_WIDGET(btn)->gc.foreground = RTGUI_RGB(0, 0, 0);
|
|
||||||
rtgui_widget_get_rect(RTGUI_WIDGET(btn), &rect);
|
rtgui_widget_get_rect(RTGUI_WIDGET(btn), &rect);
|
||||||
|
|
||||||
/* remove border */
|
/* remove border */
|
||||||
|
@ -511,7 +517,7 @@ void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox)
|
||||||
/* swap fore/back color */
|
/* swap fore/back color */
|
||||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox));
|
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox));
|
||||||
|
|
||||||
rtgui_rect_inflate(&box_rect, -2);
|
rtgui_rect_inflate(&box_rect, -4);
|
||||||
rtgui_dc_fill_rect(dc, &box_rect);
|
rtgui_dc_fill_rect(dc, &box_rect);
|
||||||
|
|
||||||
/* restore saved color */
|
/* restore saved color */
|
||||||
|
@ -562,7 +568,7 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox)
|
||||||
|
|
||||||
/* draw group text */
|
/* draw group text */
|
||||||
rtgui_font_get_metrics(rtgui_dc_get_font(dc), radiobox->text, &text_rect);
|
rtgui_font_get_metrics(rtgui_dc_get_font(dc), radiobox->text, &text_rect);
|
||||||
rtgui_rect_moveto(&text_rect, rect.x1 + 5, rect.y1);
|
rtgui_rect_moveto(&text_rect, rect.x1 + bord_size + 5, rect.y1);
|
||||||
rtgui_dc_fill_rect(dc, &text_rect);
|
rtgui_dc_fill_rect(dc, &text_rect);
|
||||||
rtgui_dc_draw_text(dc, radiobox->text, &text_rect);
|
rtgui_dc_draw_text(dc, radiobox->text, &text_rect);
|
||||||
}
|
}
|
||||||
|
@ -584,8 +590,10 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox)
|
||||||
/* draw radio */
|
/* draw radio */
|
||||||
if (radiobox->item_selection == index)
|
if (radiobox->item_selection == index)
|
||||||
{
|
{
|
||||||
|
if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(radiobox)))
|
||||||
rtgui_dc_draw_focus_rect(dc, &item_rect);
|
rtgui_dc_draw_focus_rect(dc, &item_rect);
|
||||||
rtgui_dc_fill_circle(dc, item_rect.x1 + item_size/2 + 2, item_rect.y1 + item_size/2 + 2, item_size/2 - 2);
|
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);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -615,17 +623,18 @@ void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox)
|
||||||
if (radiobox->item_selection == index)
|
if (radiobox->item_selection == index)
|
||||||
{
|
{
|
||||||
rtgui_dc_draw_focus_rect(dc, &item_rect);
|
rtgui_dc_draw_focus_rect(dc, &item_rect);
|
||||||
rtgui_dc_fill_circle(dc, item_rect.x1 + item_size/2 + 2, item_rect.y1 + item_size/2 + 2, item_size/2 - 2);
|
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);
|
||||||
}
|
}
|
||||||
else
|
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_circle(dc, item_rect.x1 + bord_size/2 + 2, item_rect.y1 + bord_size/2 + 2, bord_size/2 - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw text */
|
/* draw text */
|
||||||
item_rect.x1 += item_size + 3;
|
item_rect.x1 += bord_size + 3;
|
||||||
rtgui_dc_draw_text(dc, radiobox->items[index], &item_rect);
|
rtgui_dc_draw_text(dc, radiobox->items[index], &item_rect);
|
||||||
item_rect.x1 -= item_size + 3;
|
item_rect.x1 -= bord_size + 3;
|
||||||
|
|
||||||
item_rect.x1 += item_size;
|
item_rect.x1 += item_size;
|
||||||
item_rect.x2 += item_size;
|
item_rect.x2 += item_size;
|
||||||
|
|
|
@ -344,7 +344,7 @@ struct rtgui_event_kbd
|
||||||
#define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT))
|
#define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT))
|
||||||
#define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
|
#define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
|
||||||
#define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
|
#define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
|
||||||
#define RTGUI_KBD_IS_DOWN(e) ((e)->flag == RTGUI_KEYDOWN)
|
#define RTGUI_KBD_IS_DOWN(e) ((e)->type == RTGUI_KEYDOWN)
|
||||||
|
|
||||||
#define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION)
|
#define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION)
|
||||||
#define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON)
|
#define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
/* #define RTGUI_USING_MOUSE_CURSOR */
|
/* #define RTGUI_USING_MOUSE_CURSOR */
|
||||||
|
|
||||||
/* #define RTGUI_USING_FONT12 */
|
#define RTGUI_USING_FONT12
|
||||||
|
|
||||||
#define RTGUI_USING_FONT16
|
#define RTGUI_USING_FONT16
|
||||||
#define RTGUI_USING_FONTHZ
|
#define RTGUI_USING_FONTHZ
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct rtgui_button
|
||||||
void (*on_button)(struct rtgui_widget* widget, rtgui_event_t *event);
|
void (*on_button)(struct rtgui_widget* widget, rtgui_event_t *event);
|
||||||
};
|
};
|
||||||
typedef struct rtgui_button rtgui_button_t;
|
typedef struct rtgui_button rtgui_button_t;
|
||||||
|
typedef void (*rtgui_onbutton_func_t)(struct rtgui_widget* widget, rtgui_event_t *event);
|
||||||
|
|
||||||
rtgui_type_t *rtgui_button_type_get(void);
|
rtgui_type_t *rtgui_button_type_get(void);
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ void rtgui_button_destroy(rtgui_button_t* btn);
|
||||||
void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image);
|
void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image);
|
||||||
void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image);
|
void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image);
|
||||||
|
|
||||||
void rtgui_button_ondraw(rtgui_button_t* btn);
|
void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func);
|
||||||
|
|
||||||
rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef struct rtgui_radiobox rtgui_radiobox_t;
|
||||||
|
|
||||||
rtgui_type_t *rtgui_radiobox_type_get(void);
|
rtgui_type_t *rtgui_radiobox_type_get(void);
|
||||||
|
|
||||||
struct rtgui_radiobox* rtgui_radiobox_create(int orient, char** radio_items, int number);
|
struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number);
|
||||||
void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox);
|
void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox);
|
||||||
|
|
||||||
void rtgui_radiobox_set_selection(struct rtgui_radiobox* radiobox, int selection);
|
void rtgui_radiobox_set_selection(struct rtgui_radiobox* radiobox, int selection);
|
||||||
|
|
|
@ -975,7 +975,6 @@ void rtgui_topwin_append_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect)
|
||||||
rtgui_mouse_monitor_append(&(win->monitor_list), rect);
|
rtgui_mouse_monitor_append(&(win->monitor_list), rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RTGUI_USING_SMALL_SIZE
|
|
||||||
void rtgui_topwin_remove_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect)
|
void rtgui_topwin_remove_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect)
|
||||||
{
|
{
|
||||||
struct rtgui_topwin* win;
|
struct rtgui_topwin* win;
|
||||||
|
@ -993,8 +992,8 @@ void rtgui_topwin_remove_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect)
|
||||||
/* remove rect from top window monitor rect list */
|
/* remove rect from top window monitor rect list */
|
||||||
rtgui_mouse_monitor_remove(&(win->monitor_list), rect);
|
rtgui_mouse_monitor_remove(&(win->monitor_list), rect);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifdef RTGUI_USING_SMALL_SIZE
|
||||||
/**
|
/**
|
||||||
* get clip information for topwin
|
* get clip information for topwin
|
||||||
* wid, the self window id. If wid = NULL, get whole topwin clip information.
|
* wid, the self window id. If wid = NULL, get whole topwin clip information.
|
||||||
|
@ -1025,6 +1024,7 @@ void rtgui_topwin_get_clipinfo(struct rtgui_rect* rect_list, rt_int32_t count)
|
||||||
}
|
}
|
||||||
rt_sem_release(&_rtgui_topwin_lock);
|
rt_sem_release(&_rtgui_topwin_lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RT_USING_FINSH
|
#ifdef RT_USING_FINSH
|
||||||
#include <finsh.h>
|
#include <finsh.h>
|
||||||
|
|
|
@ -82,6 +82,33 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
||||||
rtgui_theme_draw_button(btn);
|
rtgui_theme_draw_button(btn);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RTGUI_EVENT_KBD:
|
||||||
|
{
|
||||||
|
struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*) event;
|
||||||
|
|
||||||
|
if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE))
|
||||||
|
{
|
||||||
|
if (RTGUI_KBD_IS_DOWN(ekbd))
|
||||||
|
{
|
||||||
|
btn->flag |= RTGUI_BUTTON_FLAG_PRESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btn->flag &= ~RTGUI_BUTTON_FLAG_PRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* draw button */
|
||||||
|
rtgui_theme_draw_button(btn);
|
||||||
|
|
||||||
|
if ((btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
|
||||||
|
{
|
||||||
|
/* call on button handler */
|
||||||
|
btn->on_button(widget, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||||
{
|
{
|
||||||
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event;
|
struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event;
|
||||||
|
@ -103,6 +130,12 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
||||||
#endif
|
#endif
|
||||||
rtgui_theme_draw_button(btn);
|
rtgui_theme_draw_button(btn);
|
||||||
|
|
||||||
|
if (btn->on_button != RT_NULL)
|
||||||
|
{
|
||||||
|
/* call on button handler */
|
||||||
|
btn->on_button(widget, event);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
/* invokes call back */
|
/* invokes call back */
|
||||||
if (widget->on_mouseclick != RT_NULL &&
|
if (widget->on_mouseclick != RT_NULL &&
|
||||||
|
@ -132,6 +165,12 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
|
||||||
#endif
|
#endif
|
||||||
rtgui_theme_draw_button(btn);
|
rtgui_theme_draw_button(btn);
|
||||||
|
|
||||||
|
if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
|
||||||
|
{
|
||||||
|
/* call on button handler */
|
||||||
|
btn->on_button(widget, event);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
#ifndef RTGUI_USING_SMALL_SIZE
|
||||||
/* invokes call back */
|
/* invokes call back */
|
||||||
if (widget->on_mouseclick != RT_NULL &&
|
if (widget->on_mouseclick != RT_NULL &&
|
||||||
|
@ -198,3 +237,10 @@ void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image)
|
||||||
btn->unpressed_image = image;
|
btn->unpressed_image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func)
|
||||||
|
{
|
||||||
|
RT_ASSERT(btn != RT_NULL);
|
||||||
|
|
||||||
|
btn->on_button = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui
|
||||||
int bord_size;
|
int bord_size;
|
||||||
struct rtgui_rect rect;
|
struct rtgui_rect rect;
|
||||||
|
|
||||||
|
/* focus widgets */
|
||||||
|
rtgui_widget_focus(RTGUI_WIDGET(radiobox));
|
||||||
|
|
||||||
/* get widget rect */
|
/* get widget rect */
|
||||||
rtgui_widget_get_rect(RTGUI_WIDGET(radiobox), &rect);
|
rtgui_widget_get_rect(RTGUI_WIDGET(radiobox), &rect);
|
||||||
|
|
||||||
|
@ -59,15 +62,18 @@ static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui
|
||||||
bord_size = rtgui_rect_height(bord_rect);
|
bord_size = rtgui_rect_height(bord_rect);
|
||||||
}
|
}
|
||||||
rtgui_rect_inflate(&rect, - bord_size);
|
rtgui_rect_inflate(&rect, - bord_size);
|
||||||
|
if (rtgui_rect_contains_point(&rect, event->x, event->y) != RT_EOK) return;
|
||||||
|
|
||||||
if (radiobox->orient == RTGUI_VERTICAL)
|
if (radiobox->orient == RTGUI_VERTICAL)
|
||||||
{
|
{
|
||||||
|
int delta_y = event->y - rect.y1;
|
||||||
|
rtgui_radiobox_set_selection(radiobox, delta_y / radiobox->item_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int delta_x = event->x - rect.x1;
|
||||||
|
rtgui_radiobox_set_selection(radiobox, delta_x / radiobox->item_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtgui_widget_focus(RTGUI_WIDGET(radiobox));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +106,8 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_widget* widget, struct rtgui
|
||||||
rtgui_widget_focus(RTGUI_WIDGET(radiobox));
|
rtgui_widget_focus(RTGUI_WIDGET(radiobox));
|
||||||
if (!(RTGUI_KBD_IS_UP(e))) return RT_FALSE;
|
if (!(RTGUI_KBD_IS_UP(e))) return RT_FALSE;
|
||||||
|
|
||||||
|
if (radiobox->orient == RTGUI_VERTICAL)
|
||||||
|
{
|
||||||
if (e->key == RTGUIK_UP)
|
if (e->key == RTGUIK_UP)
|
||||||
{
|
{
|
||||||
if (radiobox->item_selection > 0)
|
if (radiobox->item_selection > 0)
|
||||||
|
@ -110,6 +118,20 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_widget* widget, struct rtgui
|
||||||
if (radiobox->item_selection < radiobox->item_count - 1)
|
if (radiobox->item_selection < radiobox->item_count - 1)
|
||||||
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection + 1);
|
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (e->key == RTGUIK_LEFT)
|
||||||
|
{
|
||||||
|
if (radiobox->item_selection > 0)
|
||||||
|
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection - 1);
|
||||||
|
}
|
||||||
|
else if (e->key == RTGUIK_RIGHT)
|
||||||
|
{
|
||||||
|
if (radiobox->item_selection < radiobox->item_count - 1)
|
||||||
|
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -127,25 +149,29 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_widget* widget, struct rtgui
|
||||||
return RT_FALSE;
|
return RT_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct rtgui_radiobox* rtgui_radiobox_create(int orient, char** radio_items, int number)
|
struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number)
|
||||||
{
|
{
|
||||||
struct rtgui_radiobox* radiobox;
|
struct rtgui_radiobox* radiobox;
|
||||||
|
|
||||||
radiobox = (struct rtgui_radiobox*) rtgui_widget_create (RTGUI_RADIOBOX_TYPE);
|
radiobox = (struct rtgui_radiobox*) rtgui_widget_create (RTGUI_RADIOBOX_TYPE);
|
||||||
if (radiobox != RT_NULL)
|
if (radiobox != RT_NULL)
|
||||||
{
|
{
|
||||||
|
rt_uint8_t board_size;
|
||||||
|
struct rtgui_rect rect;
|
||||||
|
|
||||||
radiobox->items = radio_items;
|
radiobox->items = radio_items;
|
||||||
radiobox->item_count = number;
|
radiobox->item_count = number;
|
||||||
radiobox->item_selection = -1;
|
radiobox->item_selection = -1;
|
||||||
|
radiobox->text = rt_strdup(label);
|
||||||
|
|
||||||
/* set proper of control */
|
/* set proper of control */
|
||||||
rtgui_radiobox_set_orientation(radiobox, orient);
|
rtgui_radiobox_set_orientation(radiobox, orient);
|
||||||
|
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(radiobox)), "H", &rect);
|
||||||
|
board_size = rtgui_rect_height(rect);
|
||||||
|
|
||||||
if (orient == RTGUI_VERTICAL)
|
if (orient == RTGUI_VERTICAL)
|
||||||
{
|
{
|
||||||
struct rtgui_rect rect;
|
radiobox->item_size = board_size;
|
||||||
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(radiobox)), "H", &rect);
|
|
||||||
|
|
||||||
radiobox->item_size = rtgui_rect_height(rect);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -161,7 +187,7 @@ struct rtgui_radiobox* rtgui_radiobox_create(int orient, char** radio_items, int
|
||||||
{
|
{
|
||||||
rtgui_font_get_metrics(font, radio_items[index], &rect);
|
rtgui_font_get_metrics(font, radio_items[index], &rect);
|
||||||
if (rtgui_rect_width(rect) > radiobox->item_size)
|
if (rtgui_rect_width(rect) > radiobox->item_size)
|
||||||
radiobox->item_size = rtgui_rect_width(rect);
|
radiobox->item_size = board_size + 3 + rtgui_rect_width(rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,8 +137,12 @@ void rtgui_toplevel_handle_clip(struct rtgui_toplevel* top,
|
||||||
top->external_clip_size = info->num_rect;
|
top->external_clip_size = info->num_rect;
|
||||||
|
|
||||||
#ifdef RTGUI_USING_SMALL_SIZE
|
#ifdef RTGUI_USING_SMALL_SIZE
|
||||||
|
{
|
||||||
|
extern void rtgui_topwin_get_clipinfo(struct rtgui_rect* list, rt_int32_t count);
|
||||||
|
|
||||||
/* get rect list from topwin list */
|
/* get rect list from topwin list */
|
||||||
rtgui_topwin_get_clipinfo(top->external_clip_rect, top->external_clip_size);
|
rtgui_topwin_get_clipinfo(top->external_clip_rect, top->external_clip_size);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* copy rect array */
|
/* copy rect array */
|
||||||
rt_memcpy(top->external_clip_rect, (void*)(info + 1), sizeof(rtgui_rect_t) * info->num_rect);
|
rt_memcpy(top->external_clip_rect, (void*)(info + 1), sizeof(rtgui_rect_t) * info->num_rect);
|
||||||
|
|
Loading…
Reference in New Issue