diff options
| author | [email protected] <[email protected]> | 2010-08-08 23:18:02 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2010-08-08 23:18:02 +0000 |
| commit | afe4c3cc61bce02062837163ff21bfba0428f904 (patch) | |
| tree | 8c9eb05299f93e37019bb7a399c2f15dd9617dc7 /components/rtgui | |
| parent | 2df619d986ab0254409d3a34047c944a8ebe61bc (diff) | |
update scrollbar widget.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@834 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui')
| -rw-r--r-- | components/rtgui/common/rtgui_theme.c | 122 | ||||
| -rw-r--r-- | components/rtgui/include/rtgui/rtgui_theme.h | 2 | ||||
| -rw-r--r-- | components/rtgui/include/rtgui/widgets/scrollbar.h | 17 | ||||
| -rw-r--r-- | components/rtgui/include/rtgui/widgets/slider.h | 13 | ||||
| -rw-r--r-- | components/rtgui/widgets/scrollbar.c | 205 | ||||
| -rw-r--r-- | components/rtgui/widgets/slider.c | 13 |
6 files changed, 218 insertions, 154 deletions
diff --git a/components/rtgui/common/rtgui_theme.c b/components/rtgui/common/rtgui_theme.c index 2b797bfe55..266ceea9c9 100644 --- a/components/rtgui/common/rtgui_theme.c +++ b/components/rtgui/common/rtgui_theme.c @@ -29,6 +29,7 @@ const rtgui_color_t default_foreground = RTGUI_RGB(0x00, 0x00, 0x00); const rtgui_color_t default_background = RTGUI_RGB(212, 208, 200); const rtgui_color_t selected_color = RTGUI_RGB(0xc0, 0xc0, 0xc0); +const rtgui_color_t disable_foreground = RTGUI_RGB(0x80, 0x80, 0x80); extern struct rtgui_font rtgui_font_asc16; extern struct rtgui_font rtgui_font_arial16; @@ -788,6 +789,127 @@ void rtgui_theme_draw_slider(struct rtgui_slider* slider) return; } +
+const static rt_uint8_t _up_arrow[] = {0x10, 0x38, 0x7C, 0xFE};
+const static rt_uint8_t _down_arrow[] = {0xFE,0x7C, 0x38, 0x10};
+const static rt_uint8_t _left_arrow[] = {0x10, 0x30, 0x70, 0xF0, 0x70, 0x30, 0x10};
+const static rt_uint8_t _right_arrow[] = {0x80, 0xC0, 0xE0, 0xF0, 0xE0, 0xC0, 0x80};
+
+void rtgui_theme_draw_scrollbar(struct rtgui_scrollbar* bar)
+{
+ /* draw scroll bar */
+ struct rtgui_dc* dc;
+ rtgui_rect_t rect, btn_rect, thum_rect, arrow_rect;
+ rtgui_color_t bc, fc;
+
+ /* begin drawing */
+ dc = rtgui_dc_begin_drawing(&(bar->parent));
+ if (dc == RT_NULL) return;
+
+ rtgui_widget_get_rect(RTGUI_WIDGET(bar), &rect);
+
+ /* draw background */
+ fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar));
+ if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
+ RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(128, 128, 128);
+
+ bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar));
+ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = white;
+ rtgui_dc_fill_rect(dc, &rect);
+
+ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = bc;
+
+ if (bar->orient == RTGUI_VERTICAL)
+ {
+ btn_rect = rect;
+ btn_rect.y2 = btn_rect.y1 + (rect.x2 - rect.x1);
+
+ /* draw up button */
+ rtgui_dc_fill_rect(dc, &btn_rect);
+ if (bar->status & SBS_UPARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
+ else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
+
+ /* draw arrow */
+ arrow_rect.x1 = 0; arrow_rect.y1 = 0;
+ arrow_rect.x2 = 7; arrow_rect.y2 = 4;
+ rtgui_rect_moveto_align(&btn_rect, &arrow_rect,
+ RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
+ rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1,
+ rtgui_rect_height(arrow_rect), _up_arrow);
+
+ /* draw thumb */
+ if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
+ {
+ rtgui_scrollbar_get_thumb_rect(bar, &thum_rect);
+ rtgui_dc_fill_rect(dc, &thum_rect);
+ rtgui_dc_draw_border(dc, &thum_rect, RTGUI_BORDER_RAISE);
+ }
+
+ /* draw down button */
+ btn_rect.y1 = rect.y2 - (rect.x2 - rect.x1);
+ btn_rect.y2 = rect.y2;
+
+ rtgui_dc_fill_rect(dc, &btn_rect);
+ if (bar->status & SBS_DOWNARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
+ else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
+
+ arrow_rect.x1 = 0; arrow_rect.y1 = 0;
+ arrow_rect.x2 = 7; arrow_rect.y2 = 4;
+ rtgui_rect_moveto_align(&btn_rect, &arrow_rect,
+ RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
+ rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1,
+ rtgui_rect_height(arrow_rect), _down_arrow);
+ }
+ else
+ {
+ btn_rect.x1 = rect.x1;
+ btn_rect.y1 = rect.y1;
+ btn_rect.x2 = rect.y2;
+ btn_rect.y2 = rect.y2;
+
+ /* draw left button */
+ rtgui_dc_fill_rect(dc, &btn_rect);
+ if (bar->status & SBS_LEFTARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
+ else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
+
+ arrow_rect.x1 = 0; arrow_rect.y1 = 0;
+ arrow_rect.x2 = 4; arrow_rect.y2 = 7;
+ rtgui_rect_moveto_align(&btn_rect, &arrow_rect,
+ RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
+ rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1,
+ rtgui_rect_height(arrow_rect), _left_arrow);
+
+ /* draw thumb */
+ if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
+ {
+ rtgui_scrollbar_get_thumb_rect(bar, &thum_rect);
+ rtgui_dc_fill_rect(dc, &thum_rect);
+ rtgui_dc_draw_border(dc, &thum_rect, RTGUI_BORDER_RAISE);
+ }
+
+ btn_rect.x1 = rect.x2 - rect.y2;
+ btn_rect.x2 = rect.x2;
+
+ /* draw right button */
+ rtgui_dc_fill_rect(dc, &btn_rect);
+ if (bar->status & SBS_RIGHTARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
+ else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
+
+ arrow_rect.x1 = 0; arrow_rect.y1 = 0;
+ arrow_rect.x2 = 4; arrow_rect.y2 = 7;
+ rtgui_rect_moveto_align(&btn_rect, &arrow_rect,
+ RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
+ rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1,
+ rtgui_rect_height(arrow_rect), _right_arrow);
+ }
+
+ /* end drawing */
+ rtgui_dc_end_drawing(dc);
+ RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = fc;
+
+ return;
+}
+ void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar) { /* draw progress bar */ diff --git a/components/rtgui/include/rtgui/rtgui_theme.h b/components/rtgui/include/rtgui/rtgui_theme.h index 507d0f3059..1bbcfcdb04 100644 --- a/components/rtgui/include/rtgui/rtgui_theme.h +++ b/components/rtgui/include/rtgui/rtgui_theme.h @@ -30,6 +30,7 @@ #include <rtgui/widgets/checkbox.h>
#include <rtgui/widgets/radiobox.h>
#include <rtgui/widgets/slider.h>
+#include <rtgui/widgets/scrollbar.h>
#include <rtgui/widgets/progressbar.h>
#include <rtgui/widgets/staticline.h>
@@ -48,6 +49,7 @@ void rtgui_theme_draw_checkbox(rtgui_checkbox_t* checkbox); void rtgui_theme_draw_radiobutton(struct rtgui_radiobox* radiobox, rt_uint16_t item); void rtgui_theme_draw_radiobox(struct rtgui_radiobox* radiobox);
void rtgui_theme_draw_slider(struct rtgui_slider* slider);
+void rtgui_theme_draw_scrollbar(struct rtgui_scrollbar* bar);
void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar);
void rtgui_theme_draw_staticline(struct rtgui_staticline* staticline);
diff --git a/components/rtgui/include/rtgui/widgets/scrollbar.h b/components/rtgui/include/rtgui/widgets/scrollbar.h index 867c718b20..d360822b58 100644 --- a/components/rtgui/include/rtgui/widgets/scrollbar.h +++ b/components/rtgui/include/rtgui/widgets/scrollbar.h @@ -1,3 +1,16 @@ +/*
+ * File : scrollbar.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2010, 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-08-09 Bernard first version
+ */
#ifndef __RTGUI_SCROLLBAR_H__
#define __RTGUI_SCROLLBAR_H__
@@ -48,8 +61,6 @@ struct rtgui_scrollbar /* position 1:1 width of scrollbar */
rt_int16_t min_position, max_position;
- rt_int16_t bar_width;
-
rt_bool_t (*on_scroll) (struct rtgui_widget* widget, struct rtgui_event* event);
};
typedef struct rtgui_scrollbar rtgui_scrollbar_t;
@@ -59,6 +70,8 @@ rtgui_type_t *rtgui_scrollbar_type_get(void); struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r);
void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar);
+void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect);
+
void rtgui_scrollbar_set_range(struct rtgui_scrollbar* bar, int min, int max);
rt_int16_t rtgui_scrollbar_get_value(struct rtgui_scrollbar* bar);
void rtgui_scrollbar_set_value(struct rtgui_scrollbar* bar, rt_int16_t position);
diff --git a/components/rtgui/include/rtgui/widgets/slider.h b/components/rtgui/include/rtgui/widgets/slider.h index d657790899..23bceedc9e 100644 --- a/components/rtgui/include/rtgui/widgets/slider.h +++ b/components/rtgui/include/rtgui/widgets/slider.h @@ -1,3 +1,16 @@ +/*
+ * File : slider.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_SLIDER_H__
#define __RTGUI_SLIDER_H__
diff --git a/components/rtgui/widgets/scrollbar.c b/components/rtgui/widgets/scrollbar.c index 42b93a8dfb..c83c7bb717 100644 --- a/components/rtgui/widgets/scrollbar.c +++ b/components/rtgui/widgets/scrollbar.c @@ -1,3 +1,16 @@ +/*
+ * File : scrollbar.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-08-09 Bernard first version
+ */
#include <rtgui/dc.h>
#include <rtgui/widgets/scrollbar.h>
@@ -12,12 +25,12 @@ static void _rtgui_scrollbar_constructor(rtgui_scrollbar_t *bar) rtgui_scrollbar_set_page_step(bar, 20);
rtgui_scrollbar_set_line_step(bar, 10);
+ bar->status = 0;
bar->thumb_position = 0;
bar->thumb_size = 16;
bar->on_scroll = RT_NULL;
bar->orient = RTGUI_HORIZONTAL;
- bar->bar_width = RTGUI_DEFAULT_SB_HEIGHT;
rtgui_widget_set_rect(RTGUI_WIDGET(bar), &rect);
/* set gc */
@@ -47,7 +60,7 @@ rt_inline rt_uint32_t _rtgui_scrollbar_get_thumb_position(rtgui_scrollbar_t* bar return thumb_position;
}
-rt_inline void _rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect)
+void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect)
{
struct rtgui_rect scrollbar_rect;
@@ -88,54 +101,9 @@ rtgui_type_t *rtgui_scrollbar_type_get(void) return scrollbar_type;
}
-static void _rtgui_scrollbar_ondraw(struct rtgui_scrollbar* bar);
-static void _rtgui_scrollbar_on_mouseclick(struct rtgui_widget * widget, struct rtgui_event * event);
-
-rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_widget * widget,
- struct rtgui_event * event)
-{
- struct rtgui_scrollbar* bar = (struct rtgui_scrollbar*)widget;
-
- switch (event->type)
- {
- case RTGUI_EVENT_PAINT:
-#ifndef RTGUI_USING_SMALL_SIZE
- if (widget->on_draw != RT_NULL) widget->on_draw(widget, event);
- else
-#endif
- {
- _rtgui_scrollbar_ondraw(bar);
- }
-
- break;
-
- case RTGUI_EVENT_MOUSE_BUTTON:
- if (RTGUI_WIDGET_IS_ENABLE(widget))
- {
-#ifndef RTGUI_USING_SMALL_SIZE
- if (widget->on_mouseclick != RT_NULL)
- {
- widget->on_mouseclick(widget, event);
- }
- else
-#endif
- {
- _rtgui_scrollbar_on_mouseclick(widget, event);
- }
- }
-
- break;
-
- default:
- break;
- }
-
- return RT_FALSE;
-}
-
static void _rtgui_scrollbar_on_mouseclick(struct rtgui_widget * widget, struct rtgui_event * event)
{
- rtgui_rect_t btn_rect, bar_rect;
+ rtgui_rect_t rect, btn_rect, bar_rect;
rt_uint32_t thumb_size, thumb_position;
struct rtgui_scrollbar* bar = (struct rtgui_scrollbar*)widget;
struct rtgui_event_mouse* mouse = (struct rtgui_event_mouse*)event;
@@ -242,7 +210,7 @@ static void _rtgui_scrollbar_on_mouseclick(struct rtgui_widget * widget, struct /* get bar rect */
bar_rect.x1 = widget->extent.x1 + (widget->extent.y2 - widget->extent.y1);
- bar_rect.x2 = widget->extent.x2 - (widget->extent.x2 - widget->extent.x1);
+ bar_rect.x2 = widget->extent.x2 - (widget->extent.y2 - widget->extent.y1);
bar_rect.y1 = widget->extent.y1;
bar_rect.y2 = widget->extent.y2;
if (rtgui_rect_contains_point(&bar_rect, mouse->x, mouse->y) == RT_EOK)
@@ -291,7 +259,7 @@ static void _rtgui_scrollbar_on_mouseclick(struct rtgui_widget * widget, struct }
__exit:
- _rtgui_scrollbar_ondraw(bar);
+ rtgui_theme_draw_scrollbar(bar);
if ((mouse->button & (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN)) ==
(RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN))
{
@@ -299,118 +267,46 @@ __exit: }
}
-static void _rtgui_scrollbar_ondraw(struct rtgui_scrollbar* bar)
+rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_widget * widget,
+ struct rtgui_event * event)
{
- /* draw scroll bar */
- struct rtgui_dc* dc;
- struct rtgui_rect rect;
- int vx[4], vy[4];
-
- /* begin drawing */
- dc = rtgui_dc_begin_drawing(&(bar->parent));
- if (dc == RT_NULL) return;
-
- rtgui_widget_get_rect(RTGUI_WIDGET(bar), &rect);
-
- /* draw background */
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(236, 236, 229);
- rtgui_dc_fill_rect(dc, &rect);
-
- if (bar->orient == RTGUI_VERTICAL)
- {
- rtgui_rect_t btn_rect, thum_rect;
-
- btn_rect = rect;
- btn_rect.y2 = btn_rect.y1 + rect.x2 - rect.x1;
-
- /* draw up button */
- if (bar->status & SBS_UPARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
- else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
-
- /* draw arrow */
- if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(201, 201, 194);
- vx[0] = 0; vy[0] = 0;
- vx[1] = rtgui_rect_width(rect); vy[1] = 0;
- vx[2] = vx[1] / 2; vy[2] = 8;
- vx[3] = 0; vy[3] = 0;
- rtgui_dc_fill_polygon(dc, vx, vy, 4);
- // rtgui_dc_draw_arrow(dc, &btn_rect, RTGUI_ARRAW_UP);
+ struct rtgui_scrollbar* bar = (struct rtgui_scrollbar*)widget;
- /* draw thumb */
- if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
+ switch (event->type)
+ {
+ case RTGUI_EVENT_PAINT:
+#ifndef RTGUI_USING_SMALL_SIZE
+ if (widget->on_draw != RT_NULL) widget->on_draw(widget, event);
+ else
+#endif
{
- _rtgui_scrollbar_get_thumb_rect(bar, &thum_rect);
- rtgui_dc_draw_border(dc, &thum_rect, RTGUI_BORDER_RAISE);
+ rtgui_theme_draw_scrollbar(bar);
}
- /* draw down button */
- btn_rect.y1 = rect.y2 - (rect.x2 - rect.x1);
- btn_rect.y2 = rect.y2;
-
- if (bar->status & SBS_DOWNARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
- else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
-
- if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(201, 201, 194);
-
- vx[0] = 0; vy[0] = rtgui_rect_height(rect);
- vx[1] = rtgui_rect_width(rect); vy[1] = rtgui_rect_height(rect);
- vx[2] = vx[1] / 2; vy[2] = rtgui_rect_height(rect) - 8;
- vx[0] = 0; vy[0] = rtgui_rect_height(rect);
- rtgui_dc_fill_polygon(dc, vx, vy, 4);
- // rtgui_dc_draw_arrow(dc, &btn_rect, RTGUI_ARRAW_DOWN);
- }
- else
- {
- rtgui_rect_t btn_rect, thum_rect;
+ break;
- btn_rect.x1 = rect.x1;
- btn_rect.x2 = rect.y2;
- btn_rect.y1 = rect.y1;
- btn_rect.y2 = rect.y2;
-
- /* draw left button */
- if (bar->status & SBS_LEFTARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
- else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
-
- if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(201, 201, 194);
-
- vx[0] = 0; vy[0] = 0;
- vx[1] = 0; vy[1] = rtgui_rect_height(rect);
- vx[2] = 8; vy[2] = rtgui_rect_height(rect)/2;
- vx[3] = 0; vy[3] = 0;
- rtgui_dc_fill_polygon(dc, vx, vy, 4);
- // rtgui_dc_draw_arrow(dc, &btn_rect, RTGUI_ARRAW_LEFT);
-
- /* draw thumb */
- if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
+ case RTGUI_EVENT_MOUSE_BUTTON:
+ if (RTGUI_WIDGET_IS_ENABLE(widget))
{
- _rtgui_scrollbar_get_thumb_rect(bar, &thum_rect);
- rtgui_dc_draw_border(dc, &thum_rect, RTGUI_BORDER_RAISE);
+#ifndef RTGUI_USING_SMALL_SIZE
+ if (widget->on_mouseclick != RT_NULL)
+ {
+ widget->on_mouseclick(widget, event);
+ }
+ else
+#endif
+ {
+ _rtgui_scrollbar_on_mouseclick(widget, event);
+ }
}
- btn_rect.x1 = rect.x2 - rect.y2;
- btn_rect.x2 = rect.x2;
+ break;
- /* draw right button */
- if (bar->status & SBS_RIGHTARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN);
- else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE);
-
- if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar)))
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(201, 201, 194);
- vx[0] = rtgui_rect_width(rect); vy[0] = 0;
- vx[1] = rtgui_rect_width(rect) - 8; vy[1] = rtgui_rect_height(rect)/2;
- vx[2] = rtgui_rect_width(rect); vy[2] = rtgui_rect_height(rect);
- vx[0] = rtgui_rect_width(rect); vy[0] = 0;
- rtgui_dc_fill_polygon(dc, vx, vy, 4);
- // rtgui_dc_draw_arrow(dc, &btn_rect, RTGUI_ARRAW_RIGHT);
- }
+ default:
+ break;
+ }
- /* end drawing */
- rtgui_dc_end_drawing(dc);
- return;
+ return RT_FALSE;
}
struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r)
@@ -421,7 +317,13 @@ struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r) if (bar != RT_NULL)
{
if (r != RT_NULL)
+ {
rtgui_widget_set_rect(RTGUI_WIDGET(bar), r);
+ if (orient == RTGUI_VERTICAL)
+ bar->thumb_size = (r->x2 - r->x1);
+ else
+ bar->thumb_size = (r->y2 - r->y1);
+ }
bar->orient = orient;
}
@@ -439,7 +341,6 @@ void rtgui_scrollbar_set_orientation(rtgui_scrollbar_t* bar, int orientation) RT_ASSERT(bar != RT_NULL);
bar->orient = orientation;
- bar->bar_width = RTGUI_DEFAULT_SB_HEIGHT;
#ifndef RTGUI_USING_SMALL_SIZE
if (bar->orient == RTGUI_HORIZONTAL)
{
diff --git a/components/rtgui/widgets/slider.c b/components/rtgui/widgets/slider.c index f9be26b72a..4779892c8b 100644 --- a/components/rtgui/widgets/slider.c +++ b/components/rtgui/widgets/slider.c @@ -1,3 +1,16 @@ +/*
+ * File : slider.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2010, 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/rtgui_theme.h>
#include <rtgui/widgets/slider.h>
|
