1
0

demo_view_textbox.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "demo_view.h"
  2. #include <rtgui/widgets/label.h>
  3. #include <rtgui/widgets/textbox.h>
  4. rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
  5. {
  6. rtgui_rect_t rect, textbox_rect;
  7. rtgui_view_t* view;
  8. rtgui_label_t* label;
  9. rtgui_textbox_t* text;
  10. /* create a demo view */
  11. view = demo_view(workbench, "TextBox View");
  12. /* add label */
  13. demo_view_get_rect(view, &rect);
  14. rect.x1 += 5; rect.x2 = rect.x1 + 30;
  15. rect.y1 += 5; rect.y2 = rect.y1 + 20;
  16. label = rtgui_label_create("Ăű×Ö: ");
  17. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  18. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  19. textbox_rect = rect;
  20. textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
  21. text = rtgui_textbox_create("bernard");
  22. rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
  23. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
  24. rect.y1 += 23; rect.y2 = rect.y1 + 20;
  25. label = rtgui_label_create("ÓĘźţ: ");
  26. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  27. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  28. textbox_rect = rect;
  29. textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
  30. text = rtgui_textbox_create("bernard.xiong@gmail.com");
  31. rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
  32. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
  33. rect.y1 += 23; rect.y2 = rect.y1 + 20;
  34. label = rtgui_label_create("ĂÜÂë: ");
  35. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  36. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  37. textbox_rect = rect;
  38. textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
  39. text = rtgui_textbox_create("rt-thread");
  40. text->flag |= RTGUI_TEXTBOX_MASK;
  41. rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
  42. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
  43. rect.y1 += 23; rect.y2 = rect.y1 + 20;
  44. label = rtgui_label_create("Ö÷Ňł: ");
  45. rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
  46. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
  47. textbox_rect = rect;
  48. textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
  49. text = rtgui_textbox_create("http://www.rt-thread.org");
  50. rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
  51. rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
  52. return view;
  53. }