rtt-f030/examples/gui/demo_view_textbox.c

104 lines
3.5 KiB
C
Raw Normal View History

/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>texbox<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD>ʾ
*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>textbox<EFBFBD>ؼ<EFBFBD>
*/
#include "demo_view.h"
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/textbox.h>
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾtextbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ */
rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect, textbox_rect;
rtgui_view_t* view;
rtgui_label_t* label;
rtgui_textbox_t* text;
/* <20>ȴ<EFBFBD><C8B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
view = demo_view(workbench, "TextBox View");
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(view, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 30;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
label = rtgui_label_create("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ");
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
/* view<65><77>һ<EFBFBD><D2BB>container<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>add_child<6C><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
/* <20><>textbox_rect<63><74>ֵ<EFBFBD><D6B5>rect<63><74><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB> */
textbox_rect = rect;
textbox_rect.x1 = textbox_rect.x2 + 5;
textbox_rect.x2 = textbox_rect.x1 + 160;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>textbox<6F>ؼ<EFBFBD> */
text = rtgui_textbox_create("bernard",RTGUI_TEXTBOX_SINGLE);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB> */
rect.y1 += 23;
rect.y2 = rect.y1 + 20;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
label = rtgui_label_create("<EFBFBD>ʼ<EFBFBD>: ");
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
textbox_rect = rect;
textbox_rect.x1 = textbox_rect.x2 + 5;
textbox_rect.x2 = textbox_rect.x1 + 160;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>textbox<6F>ؼ<EFBFBD> */
text = rtgui_textbox_create("bernard.xiong@gmail.com",RTGUI_TEXTBOX_SINGLE);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
rect.y1 += 23;
rect.y2 = rect.y1 + 20;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
label = rtgui_label_create("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ");
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
textbox_rect = rect;
textbox_rect.x1 = textbox_rect.x2 + 5;
textbox_rect.x2 = textbox_rect.x1 + 160;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>textbox<6F>ؼ<EFBFBD> */
text = rtgui_textbox_create("rt-thread",RTGUI_TEXTBOX_SINGLE);
/* <20><><EFBFBD><EFBFBD>textbox<6F><78>ʾ<EFBFBD>ı<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ(<28><><EFBFBD><EFBFBD>ʾΪ*<2A>ţ<EFBFBD><C5A3>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) */
text->flag |= RTGUI_TEXTBOX_MASK;
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
rect.y1 += 23;
rect.y2 = rect.y1 + 20;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label<65>ؼ<EFBFBD> */
label = rtgui_label_create("<EFBFBD><EFBFBD>ҳ: ");
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
/* <20><><EFBFBD><EFBFBD>label<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
textbox_rect = rect;
textbox_rect.x1 = textbox_rect.x2 + 5;
textbox_rect.x2 = textbox_rect.x1 + 160;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>textbox<6F>ؼ<EFBFBD> */
text = rtgui_textbox_create("http://www.rt-thread.org",RTGUI_TEXTBOX_SINGLE);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD>λ<EFBFBD><CEBB> */
rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
/* <20><><EFBFBD><EFBFBD>textbox<6F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
return view;
}