2010-01-14 17:59:07 +08:00
|
|
|
|
#include <rtgui/rtgui.h>
|
2010-01-18 07:41:59 +08:00
|
|
|
|
#include <rtgui/widgets/view.h>
|
|
|
|
|
#include <rtgui/widgets/button.h>
|
|
|
|
|
#include <rtgui/widgets/workbench.h>
|
2010-01-25 08:02:14 +08:00
|
|
|
|
#include <rtgui/widgets/staticline.h>
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD>32<33><32><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
static rtgui_view_t* demo_view_list[32];
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><>ǰ<EFBFBD><C7B0>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD> */
|
2010-03-08 07:30:15 +08:00
|
|
|
|
static rt_uint16_t demo_view_current = 0;
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC>Ŀ */
|
2010-03-08 07:30:15 +08:00
|
|
|
|
static rt_uint16_t demo_view_number = 0;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><>ʾ<EFBFBD><CABE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ */
|
2010-01-27 17:42:19 +08:00
|
|
|
|
void demo_view_next(struct rtgui_widget* widget, rtgui_event_t *event)
|
2010-01-18 07:41:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (demo_view_current + 1< demo_view_number)
|
|
|
|
|
{
|
|
|
|
|
demo_view_current ++;
|
|
|
|
|
rtgui_view_show(demo_view_list[demo_view_current], RT_FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><>ʾǰһ<C7B0><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ */
|
2010-01-27 17:42:19 +08:00
|
|
|
|
void demo_view_prev(struct rtgui_widget* widget, rtgui_event_t *event)
|
2010-01-18 07:41:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (demo_view_current != 0)
|
|
|
|
|
{
|
|
|
|
|
demo_view_current --;
|
|
|
|
|
rtgui_view_show(demo_view_list[demo_view_current], RT_FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD><E1B9A9>workbench<63><68><EFBFBD><EFBFBD>ʾ<EFBFBD>õı<C3B5><C4B1><EFBFBD> */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
|
2010-01-18 07:41:59 +08:00
|
|
|
|
{
|
2010-03-14 14:36:46 +08:00
|
|
|
|
struct rtgui_view* view;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-08-10 15:28:54 +08:00
|
|
|
|
view = rtgui_view_create(title);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
if (view == RT_NULL) return RT_NULL;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
demo_view_list[demo_view_number] = view;
|
|
|
|
|
demo_view_number ++;
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>workbench<63><68> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_workbench_add_view(workbench, view);
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ǰһ<C7B0><D2BB><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ť */
|
2010-03-14 14:36:46 +08:00
|
|
|
|
{
|
|
|
|
|
struct rtgui_rect rect;
|
|
|
|
|
struct rtgui_button *next_btn, *prev_btn;
|
2010-01-21 18:05:06 +08:00
|
|
|
|
struct rtgui_label *label;
|
|
|
|
|
struct rtgui_staticline *line;
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ(<28>ڼ<EFBFBD><DABC>뵽workbench<63><68>ʱ<EFBFBD><CAB1>workbench<63><68><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>Ĵ<EFBFBD>С) */
|
2010-01-21 18:05:06 +08:00
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.y1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2010-01-21 18:05:06 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õı<C3B5>ǩ */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
label = rtgui_label_create(title);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ñ<EFBFBD>ǩλ<C7A9><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-21 18:05:06 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ӱ<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
2010-01-21 18:05:06 +08:00
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
2010-01-25 08:02:14 +08:00
|
|
|
|
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ˮƽ<CBAE><C6BD>staticline<6E><65> */
|
2010-01-21 18:05:06 +08:00
|
|
|
|
line = rtgui_staticline_create(RTGUI_HORIZONTAL);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>þ<EFBFBD>̬<EFBFBD>ߵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-21 18:05:06 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(line), &rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>Ӿ<EFBFBD>̬<EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>ͼ<EFBFBD><CDBC> */
|
2010-01-21 18:05:06 +08:00
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(line));
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y2 -= 5;
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rect.x1 = rect.x2 - 100;
|
|
|
|
|
rect.y1 = rect.y2 - 25;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>"<22><>һ<EFBFBD><D2BB>"<22><>ť */
|
|
|
|
|
next_btn = rtgui_button_create("<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>");
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>onbutton<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>demo_view_next<78><74><EFBFBD><EFBFBD> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_button_set_onbutton(next_btn, demo_view_next);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(next_btn), &rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>Ӱ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(next_btn));
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.y2 -= 5;
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rect.x2 = rect.x1 + 100;
|
|
|
|
|
rect.y1 = rect.y2 - 25;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>"<22><>һ<EFBFBD><D2BB>"<22><>ť */
|
|
|
|
|
prev_btn = rtgui_button_create("<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>");
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>onbutton<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>demo_view_prev<65><76><EFBFBD><EFBFBD> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_button_set_onbutton(prev_btn, demo_view_prev);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(prev_btn), &rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>Ӱ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(prev_btn));
|
2010-03-14 14:36:46 +08:00
|
|
|
|
}
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
void demo_view_get_rect(rtgui_view_t* view, rtgui_rect_t *rect)
|
|
|
|
|
{
|
|
|
|
|
RT_ASSERT(view != RT_NULL);
|
|
|
|
|
RT_ASSERT(rect != RT_NULL);
|
|
|
|
|
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(view), rect);
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* ȥ<><C8A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rect->y1 += 45;
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rect->y2 -= 35;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void demo_view_get_logic_rect(rtgui_view_t* view, rtgui_rect_t *rect)
|
|
|
|
|
{
|
|
|
|
|
RT_ASSERT(view != RT_NULL);
|
|
|
|
|
RT_ASSERT(rect != RT_NULL);
|
|
|
|
|
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(view), rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* ȥ<><C8A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-11-15 08:26:11 +08:00
|
|
|
|
rect->y1 += 45;
|
|
|
|
|
rect->y2 -= 35;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD>DZ<EFBFBD><EFBFBD>汾ʱ<E6B1BE><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>box<6F>ؼ<EFBFBD> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
#ifndef RTGUI_USING_SMALL_SIZE
|
|
|
|
|
rtgui_box_t* demo_view_create_box(rtgui_view_t* view, int orient)
|
|
|
|
|
{
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
rtgui_box_t* box;
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
2010-01-21 18:05:06 +08:00
|
|
|
|
rect.y1 += 45;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rect.y2 -= 25;
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
box = rtgui_box_create(orient, &rect);
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>box<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(box));
|
|
|
|
|
|
|
|
|
|
return box;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-11-22 09:50:05 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ͼ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
void demo_view_show()
|
|
|
|
|
{
|
|
|
|
|
if (demo_view_number != 0)
|
|
|
|
|
{
|
2010-03-08 07:30:15 +08:00
|
|
|
|
rtgui_view_show(demo_view_list[demo_view_current], RT_FALSE);
|
2010-01-18 07:41:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|