2012-04-18 23:06:12 +08:00
|
|
|
|
#include <rtgui/rtgui.h>
|
|
|
|
|
#include <rtgui/rtgui_application.h>
|
|
|
|
|
|
|
|
|
|
#include <rtgui/widgets/container.h>
|
|
|
|
|
#include <rtgui/widgets/notebook.h>
|
|
|
|
|
#include <rtgui/widgets/button.h>
|
|
|
|
|
#include <rtgui/widgets/staticline.h>
|
|
|
|
|
|
|
|
|
|
extern struct rtgui_notebook *the_notebook;
|
|
|
|
|
|
|
|
|
|
void demo_view_next(struct rtgui_object *object, struct rtgui_event *event)
|
|
|
|
|
{
|
|
|
|
|
rtgui_notebook_set_current_by_index(the_notebook,
|
|
|
|
|
(rtgui_notebook_get_current_index(the_notebook) + 1) %
|
|
|
|
|
rtgui_notebook_get_count(the_notebook));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void demo_view_prev(struct rtgui_object *object, struct rtgui_event *event)
|
|
|
|
|
{
|
|
|
|
|
rt_int16_t cur_idx = rtgui_notebook_get_current_index(the_notebook);
|
|
|
|
|
|
|
|
|
|
if (cur_idx == 0)
|
|
|
|
|
rtgui_notebook_set_current_by_index(the_notebook,
|
|
|
|
|
rtgui_notebook_get_count(the_notebook) - 1);
|
|
|
|
|
else
|
|
|
|
|
rtgui_notebook_set_current_by_index(the_notebook,
|
|
|
|
|
--cur_idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtgui_container_t* demo_view(const char *title)
|
|
|
|
|
{
|
|
|
|
|
struct rtgui_container *container;
|
|
|
|
|
struct rtgui_label *label;
|
|
|
|
|
struct rtgui_staticline *line;
|
|
|
|
|
struct rtgui_button *next_btn, *prev_btn;
|
|
|
|
|
struct rtgui_rect rect;
|
|
|
|
|
|
|
|
|
|
container = rtgui_container_create();
|
|
|
|
|
if (container == RT_NULL)
|
|
|
|
|
return RT_NULL;
|
|
|
|
|
|
|
|
|
|
rtgui_notebook_add(the_notebook, title, RTGUI_WIDGET(container));
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ(<28>ڼ<EFBFBD><DABC>뵽 notebook <20><>ʱ<EFBFBD><CAB1>notebook <20><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> container
|
|
|
|
|
* <EFBFBD>Ĵ<EFBFBD>С) */
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.y1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õı<C3B5>ǩ */
|
|
|
|
|
label = rtgui_label_create(title);
|
|
|
|
|
/* <20><><EFBFBD>ñ<EFBFBD>ǩλ<C7A9><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
|
|
|
|
/* <20><><EFBFBD>ӱ<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(label));
|
|
|
|
|
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ˮƽ<CBAE><C6BD> staticline <20><> */
|
|
|
|
|
line = rtgui_staticline_create(RTGUI_HORIZONTAL);
|
|
|
|
|
/* <20><><EFBFBD>þ<EFBFBD>̬<EFBFBD>ߵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(line), &rect);
|
|
|
|
|
/* <20><><EFBFBD>Ӿ<EFBFBD>̬<EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>ͼ<EFBFBD><CDBC> */
|
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(line));
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y2 -= 5;
|
|
|
|
|
rect.x1 = rect.x2 - 100;
|
|
|
|
|
rect.y1 = rect.y2 - 25;
|
|
|
|
|
|
|
|
|
|
/* <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> */
|
|
|
|
|
rtgui_button_set_onbutton(next_btn, demo_view_next);
|
|
|
|
|
/* <20><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(next_btn), &rect);
|
|
|
|
|
/* <20><><EFBFBD>Ӱ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(next_btn));
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.y2 -= 5;
|
|
|
|
|
rect.x2 = rect.x1 + 100;
|
|
|
|
|
rect.y1 = rect.y2 - 25;
|
|
|
|
|
|
|
|
|
|
/* <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> */
|
|
|
|
|
rtgui_button_set_onbutton(prev_btn, demo_view_prev);
|
|
|
|
|
/* <20><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(prev_btn), &rect);
|
|
|
|
|
/* <20><><EFBFBD>Ӱ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(prev_btn));
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ */
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <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> */
|
|
|
|
|
void demo_view_get_rect(rtgui_container_t* container, rtgui_rect_t *rect)
|
|
|
|
|
{
|
|
|
|
|
RT_ASSERT(container != RT_NULL);
|
|
|
|
|
RT_ASSERT(rect != RT_NULL);
|
|
|
|
|
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(container), rect);
|
|
|
|
|
rtgui_widget_rect_to_device(RTGUI_WIDGET(container), rect);
|
|
|
|
|
/* ȥ<><C8A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
rect->y1 += 45;
|
|
|
|
|
rect->y2 -= 35;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void demo_view_get_logic_rect(rtgui_container_t* container, rtgui_rect_t *rect)
|
|
|
|
|
{
|
|
|
|
|
RT_ASSERT(container != RT_NULL);
|
|
|
|
|
RT_ASSERT(rect != RT_NULL);
|
|
|
|
|
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(container), rect);
|
|
|
|
|
/* ȥ<><C8A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
rect->y1 += 45;
|
|
|
|
|
rect->y2 -= 35;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <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> */
|
|
|
|
|
#ifndef RTGUI_USING_SMALL_SIZE
|
2012-04-20 14:47:38 +08:00
|
|
|
|
#include <rtgui/widgets/box.h>
|
2012-04-18 23:06:12 +08:00
|
|
|
|
struct rtgui_box* demo_view_create_box(struct rtgui_container *container, int orient)
|
|
|
|
|
{
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
struct rtgui_box* box;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(container), &rect);
|
|
|
|
|
rect.y1 += 45;
|
|
|
|
|
rect.y2 -= 25;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
box = rtgui_box_create(orient, &rect);
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>box<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
|
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(box));
|
|
|
|
|
|
|
|
|
|
return box;
|
|
|
|
|
}
|
|
|
|
|
#endif
|