2012-04-18 23:06:12 +08:00
|
|
|
#include <rtgui/dc.h>
|
|
|
|
#include <rtgui/rtgui_theme.h>
|
|
|
|
#include <rtgui/widgets/staticline.h>
|
|
|
|
|
|
|
|
static void _rtgui_staticline_constructor(rtgui_staticline_t *staticline)
|
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
/* init widget and set event handler */
|
|
|
|
rtgui_rect_t rect = {0, 0, 100, 2};
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(staticline), &rect);
|
|
|
|
staticline->orient = RTGUI_HORIZONTAL;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_object_set_event_handler(RTGUI_OBJECT(staticline), rtgui_staticline_event_handler);
|
2012-04-18 23:06:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
DEFINE_CLASS_TYPE(staticline, "staticline",
|
|
|
|
RTGUI_WIDGET_TYPE,
|
|
|
|
_rtgui_staticline_constructor,
|
|
|
|
RT_NULL,
|
|
|
|
sizeof(struct rtgui_staticline));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
rt_bool_t rtgui_staticline_event_handler(struct rtgui_object *object, struct rtgui_event *event)
|
2012-04-18 23:06:12 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
struct rtgui_staticline *staticline;
|
|
|
|
RTGUI_WIDGET_EVENT_HANDLER_PREPARE
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
staticline = RTGUI_STATICLINE(object);
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case RTGUI_EVENT_PAINT:
|
2012-04-18 23:06:12 +08:00
|
|
|
#ifndef RTGUI_USING_SMALL_SIZE
|
2012-11-26 10:42:52 +08:00
|
|
|
if (widget->on_draw != RT_NULL)
|
|
|
|
widget->on_draw(RTGUI_OBJECT(widget), event);
|
|
|
|
else
|
2012-04-18 23:06:12 +08:00
|
|
|
#endif
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_theme_draw_staticline(staticline);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return rtgui_widget_event_handler(object, event);
|
|
|
|
}
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
return RT_FALSE;
|
2012-04-18 23:06:12 +08:00
|
|
|
}
|
2012-08-27 15:57:19 +08:00
|
|
|
RTM_EXPORT(rtgui_staticline_event_handler);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_staticline_t *rtgui_staticline_create(int orientation)
|
2012-04-18 23:06:12 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_staticline_t *staticline;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
staticline = (struct rtgui_staticline *) rtgui_widget_create(RTGUI_STATICLINE_TYPE);
|
|
|
|
if (staticline != RT_NULL)
|
|
|
|
{
|
|
|
|
rtgui_staticline_set_orientation(staticline, orientation);
|
|
|
|
}
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
return staticline;
|
2012-04-18 23:06:12 +08:00
|
|
|
}
|
2012-08-27 15:57:19 +08:00
|
|
|
RTM_EXPORT(rtgui_staticline_create);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
void rtgui_staticline_destroy(rtgui_staticline_t *staticline)
|
2012-04-18 23:06:12 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_widget_destroy(RTGUI_WIDGET(staticline));
|
2012-04-18 23:06:12 +08:00
|
|
|
}
|
2012-08-27 15:57:19 +08:00
|
|
|
RTM_EXPORT(rtgui_staticline_destroy);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
void rtgui_staticline_set_orientation(rtgui_staticline_t *staticline, int orientation)
|
2012-04-18 23:06:12 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
RT_ASSERT(staticline != RT_NULL);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
staticline->orient = orientation;
|
2012-04-18 23:06:12 +08:00
|
|
|
#ifndef RTGUI_USING_SMALL_SIZE
|
2012-11-26 10:42:52 +08:00
|
|
|
if (orientation == RTGUI_HORIZONTAL)
|
|
|
|
{
|
|
|
|
/* HORIZONTAL */
|
|
|
|
rtgui_widget_set_miniheight(RTGUI_WIDGET(staticline), 2);
|
|
|
|
rtgui_widget_set_miniwidth(RTGUI_WIDGET(staticline), 100);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* VERTICAL */
|
|
|
|
rtgui_widget_set_miniwidth(RTGUI_WIDGET(staticline), 2);
|
|
|
|
rtgui_widget_set_miniheight(RTGUI_WIDGET(staticline), 100);
|
|
|
|
}
|
2012-04-18 23:06:12 +08:00
|
|
|
#endif
|
|
|
|
}
|
2012-08-27 15:57:19 +08:00
|
|
|
RTM_EXPORT(rtgui_staticline_set_orientation);
|
|
|
|
|