diff options
Diffstat (limited to 'examples/gui')
42 files changed, 4015 insertions, 3966 deletions
diff --git a/examples/gui/SConscript b/examples/gui/SConscript index 55ad49d8a6..73d0f6731f 100644 --- a/examples/gui/SConscript +++ b/examples/gui/SConscript @@ -1,40 +1,46 @@ -from building import *
-
-src = Split("""
-demo_view_dc_buffer.c
-demo_view_instrument_panel.c
-demo_fnview.c
-demo_listview.c
-demo_listview_icon.c
-demo_panel_single.c
-demo_view.c
-demo_view_animation.c
-demo_view_buffer_animation.c
-demo_view_box.c
-demo_view_button.c
-demo_view_checkbox.c
-demo_view_dc.c
-demo_view_image.c
-demo_view_module.c
-demo_view_label.c
-demo_view_mywidget.c
-demo_view_progressbar.c
-demo_view_radiobox.c
-demo_view_listbox.c
-demo_view_slider.c
-demo_view_notebook.c
-demo_view_combobox.c
-demo_view_listctrl.c
-demo_view_menu.c
-demo_view_scrollbar.c
-demo_view_textbox.c
-demo_view_window.c
-demo_view_benchmark.c
-demo_workbench.c
-gui_init.c
-mywidget.c
-""")
-
-group = DefineGroup('gui_examples', src, depend = ['RT_USING_RTGUI'])
-
-Return('group')
+from building import * + +''' +demo_view_dc_buffer.c +demo_fnview.c +demo_listview.c +demo_listview_icon.c +demo_panel_single.c +demo_view_box.c +demo_view_image.c +demo_view_module.c +''' + +src = Split(""" +demo_application.c +demo_view.c +demo_view_benchmark.c +demo_view_dc.c +demo_view_ttf.c +demo_view_dc_buffer.c +demo_view_animation.c +demo_view_buffer_animation.c +demo_view_instrument_panel.c +demo_view_window.c +demo_view_label.c +demo_view_button.c +demo_view_checkbox.c +demo_view_progressbar.c +demo_view_scrollbar.c +demo_view_radiobox.c +demo_view_textbox.c +demo_view_listbox.c +demo_view_menu.c +demo_view_listctrl.c +demo_view_combobox.c +demo_view_slider.c +demo_view_notebook.c +demo_view_mywidget.c +mywidget.c +""") + + + +group = DefineGroup('gui_examples', src, depend = ['RT_USING_RTGUI']) + +Return('group') diff --git a/examples/gui/demo_application.c b/examples/gui/demo_application.c new file mode 100644 index 0000000000..00ffce982a --- /dev/null +++ b/examples/gui/demo_application.c @@ -0,0 +1,147 @@ +#include <rtgui/rtgui.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/rtgui_application.h> + +#include <rtgui/widgets/window.h> +#include <rtgui/widgets/notebook.h> + +struct rtgui_notebook *the_notebook; + +static rt_bool_t demo_handle_key(struct rtgui_object* object, struct rtgui_event* event) +{ + struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event; + + if (ekbd->type == RTGUI_KEYDOWN) + { + if (ekbd->key == RTGUIK_RIGHT) + { + demo_view_next(RT_NULL, RT_NULL); + return RT_TRUE; + } + else if (ekbd->key == RTGUIK_LEFT) + { + demo_view_prev(RT_NULL, RT_NULL); + return RT_TRUE; + } + } + return RT_TRUE; +} + +struct rtgui_win *main_win; +static void application_entry(void* parameter) +{ + struct rtgui_application *app; + struct rtgui_rect rect; + + app = rtgui_application_create(rt_thread_self(), "gui_demo"); + if (app == RT_NULL) + return; + + /* create a full screen window */ + rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect); + + main_win = rtgui_win_create(RT_NULL, "demo_win", &rect, + /*RTGUI_WIN_STYLE_DESKTOP_DEFAULT);*/ + RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE); + if (main_win == RT_NULL) + { + rtgui_application_destroy(app); + return; + } + + rtgui_win_set_onkey(main_win, demo_handle_key); + + /* create a no title notebook that we can switch demo on it easily. */ + the_notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_NOTAB); + if (the_notebook == RT_NULL) + { + rtgui_win_destroy(main_win); + rtgui_application_destroy(app); + return; + } + + rtgui_container_add_child(RTGUI_CONTAINER(main_win), RTGUI_WIDGET(the_notebook)); + + /* ��ʼ���������ӵ���ͼ */ + demo_view_benchmark(); + + demo_view_dc(); +#ifdef RTGUI_USING_TTF + demo_view_ttf(); +#endif + +#ifndef RTGUI_USING_SMALL_SIZE + demo_view_dc_buffer(); +#endif + demo_view_animation(); +#ifndef RTGUI_USING_SMALL_SIZE + demo_view_buffer_animation(); + demo_view_instrument_panel(); +#endif + demo_view_window(); + demo_view_label(); + demo_view_button(); + demo_view_checkbox(); + demo_view_progressbar(); + demo_view_scrollbar(); + demo_view_radiobox(); + demo_view_textbox(); + demo_view_listbox(); + demo_view_menu(); + demo_view_listctrl(); + demo_view_combobox(); + demo_view_slider(); + demo_view_notebook(); + demo_view_mywidget(); +#if 0 +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) + demo_view_image(); +#endif +#ifdef RT_USING_MODULE +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) + demo_view_module(); +#endif +#endif + demo_listview_view(); + demo_listview_icon_view(); +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) + demo_fn_view(); +#endif +#endif + + rtgui_win_show(main_win, RT_FALSE); + + /* ִ�й���̨�¼�ѭ�� */ + rtgui_application_run(app); + + rtgui_application_destroy(app); +} + +void application_init() +{ + static rt_bool_t inited = RT_FALSE; + + if (inited == RT_FALSE) /* �����ظ���ʼ�������ı��� */ + { + rt_thread_t tid; + + tid = rt_thread_create("wb", + application_entry, RT_NULL, + 2048 * 2, 25, 10); + + if (tid != RT_NULL) + rt_thread_startup(tid); + + inited = RT_TRUE; + } +} + +#ifdef RT_USING_FINSH +#include <finsh.h> +void application() +{ + application_init(); +} +/* finsh���������������ֱ��ִ��application()������ִ������ĺ��� */ +FINSH_FUNCTION_EXPORT(application, application demo) +#endif diff --git a/examples/gui/demo_fnview.c b/examples/gui/demo_fnview.c index d20fc99ee4..f7148659c0 100644 --- a/examples/gui/demo_fnview.c +++ b/examples/gui/demo_fnview.c @@ -1,90 +1,90 @@ -/*
- * �����嵥���ļ��б���ͼ��ʾ
- *
- * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ
- * �µ��ļ��б���ͼ��
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/button.h>
-#include <rtgui/widgets/filelist_view.h>
-
-#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
-/* ������ʾѡ���ļ������ı���ǩ */
-static rtgui_label_t* label;
-/* �����ļ��б���ͼ�İ�ť�ص����� */
-static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_filelist_view_t *view;
- rtgui_workbench_t *workbench;
- rtgui_rect_t rect;
-
- /* ��ö����workbench���� */
- workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
- rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
-
- /* ���Win32ƽ̨������ƽ̨���IJ�ͬ����ʵĿ¼λ�� */
-#ifdef _WIN32
- view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
-#else
- view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
-#endif
-
- /* ����ģʽ��ʽ��ʾ�ļ��б���ͼ */
- if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
- {
- char path[32];
-
- /* ���ļ��б���ͼ�гɹ�ѡ���ļ�����������Ӧ��·���� */
- rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
-
- /* �����ļ�·�����ı���ǩ */
- rtgui_label_set_text(label, path);
- }
-
- /* ɾ�� �ļ��б� ��ͼ */
- rtgui_view_destroy(RTGUI_VIEW(view));
-}
-
-/* ����������ʾ�ļ��б���ͼ����ͼ */
-rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_button_t* open_btn;
- rtgui_font_t* font;
-
- /* Ĭ�ϲ���12�������ʾ */
- font = rtgui_font_refer("asc", 12);
-
- /* ������ʾ�õ���ͼ */
- view = demo_view(workbench, "FileList View");
- /* �����ʾ��ͼ��λ����Ϣ */
- demo_view_get_rect(view, &rect);
-
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* ������ʾ�ļ�·���õ��ı���ǩ */
- label = rtgui_label_create("fn: ");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
-
- /* �����ʾ��ͼ��λ����Ϣ */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 80;
- rect.y1 += 30;
- rect.y2 = rect.y1 + 20;
- /* ������ť�Դ���һ���µ��ļ��б���ͼ */
- open_btn = rtgui_button_create("Open File");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
- rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(open_btn)) = font;
- rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
-
- return view;
-}
-#endif
+/* + * �����嵥���ļ��б���ͼ��ʾ + * + * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ + * �µ��ļ��б���ͼ�� + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/button.h> +#include <rtgui/widgets/filelist_view.h> + +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +/* ������ʾѡ���ļ������ı���ǩ */ +static rtgui_label_t* label; +/* �����ļ��б���ͼ�İ�ť�ص����� */ +static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_filelist_view_t *view; + rtgui_workbench_t *workbench; + rtgui_rect_t rect; + + /* ��ö����workbench���� */ + workbench = RTGUI_APPLICATION(rtgui_widget_get_toplevel(widget)); + rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); + + /* ���Win32ƽ̨������ƽ̨���IJ�ͬ����ʵĿ¼λ�� */ +#ifdef _WIN32 + view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect); +#else + view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect); +#endif + + /* ����ģʽ��ʽ��ʾ�ļ��б���ͼ */ + if (rtgui_container_show(RTGUI_CONTAINER(view), RT_TRUE) == RTGUI_MODAL_OK) + { + char path[32]; + + /* ���ļ��б���ͼ�гɹ�ѡ���ļ�����������Ӧ��·���� */ + rtgui_filelist_view_get_fullpath(view, path, sizeof(path)); + + /* �����ļ�·�����ı���ǩ */ + rtgui_label_set_text(label, path); + } + + /* ɾ�� �ļ��б� ��ͼ */ + rtgui_container_destroy(RTGUI_CONTAINER(view)); +} + +/* ����������ʾ�ļ��б���ͼ����ͼ */ +rtgui_container_t* demo_fn_view(rtgui_workbench_t* workbench) +{ + rtgui_rect_t rect; + rtgui_container_t* view; + rtgui_button_t* open_btn; + rtgui_font_t* font; + + /* Ĭ�ϲ���12�������ʾ */ + font = rtgui_font_refer("asc", 12); + + /* ������ʾ�õ���ͼ */ + view = demo_view(workbench, "FileList View"); + /* �����ʾ��ͼ��λ����Ϣ */ + demo_view_get_rect(view, &rect); + + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* ������ʾ�ļ�·���õ��ı���ǩ */ + label = rtgui_label_create("fn: "); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font; + + /* �����ʾ��ͼ��λ����Ϣ */ + demo_view_get_rect(view, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 80; + rect.y1 += 30; + rect.y2 = rect.y1 + 20; + /* ������ť�Դ���һ���µ��ļ��б���ͼ */ + open_btn = rtgui_button_create("Open File"); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn)); + rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(open_btn)) = font; + rtgui_button_set_onbutton(open_btn, open_btn_onbutton); + + return view; +} +#endif diff --git a/examples/gui/demo_listview.c b/examples/gui/demo_listview.c index 07f2814815..d1c00b1edb 100644 --- a/examples/gui/demo_listview.c +++ b/examples/gui/demo_listview.c @@ -1,115 +1,107 @@ -/*
- * �����嵥���б���ͼ��ʾ
- *
- * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ
- * �µ��б���ͼ
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/button.h>
-#include <rtgui/widgets/window.h>
-#include <rtgui/widgets/list_view.h>
-
-static rtgui_workbench_t* workbench = RT_NULL;
-static rtgui_list_view_t* _view = RT_NULL;
-// static rtgui_image_t* return_image = RT_NULL;
-
-/* �б���Ķ������� */
-#if RTTHREAD_VERSION >= 10000
-static void listitem_action(rtgui_widget_t *widget, void* parameter)
-#else
-static void listitem_action(void* parameter)
-#endif
-{
- char label_text[32];
- rtgui_win_t *win;
- rtgui_label_t *label;
- rtgui_rect_t rect = {0, 0, 150, 80};
- int no = (int)parameter;
-
- rtgui_rect_moveto(&rect, 20, 50);
-
- /* ��ʾ��Ϣ���� */
- win = rtgui_win_create(RTGUI_TOPLEVEL(workbench),
- "����", &rect, RTGUI_WIN_STYLE_DEFAULT);
-
- rect.x1 += 20;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
-
- /* ������Ӧ�ı�ǩ */
- rt_sprintf(label_text, "���� %d", no);
- label = rtgui_label_create(label_text);
-
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
-
- /* ��ģ̬��ʾ���� */
- rtgui_win_show(win, RT_FALSE);
-}
-
-/* ���ع��ܵĶ������� */
-#if RTTHREAD_VERSION >= 10000
-static void return_action(rtgui_widget_t* widget, void* parameter)
-#else
-static void return_action(void* parameter)
-#endif
-{
- rtgui_view_end_modal(RTGUI_VIEW(_view), RTGUI_MODAL_OK);
-}
-
-/* �������� */
-static struct rtgui_list_item items[] =
-{
- {"���1", RT_NULL, listitem_action, (void*)1},
- {"���2", RT_NULL, listitem_action, (void*)2},
- {"���3", RT_NULL, listitem_action, (void*)3},
- {"���4", RT_NULL, listitem_action, (void*)4},
- {"���5", RT_NULL, listitem_action, (void*)5},
- {"����", RT_NULL, return_action, RT_NULL},
-};
-
-/* ���б���ͼ�õİ�ť�������� */
-static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_rect_t rect;
-
- /* ��ö����workbench */
- workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
- rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
-
- /* ����һ���б���ͼ�� ��ָ��Ϊitems */
- _view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item),
- &rect, RTGUI_LIST_VIEW_LIST);
- /* ��workbench��������Ӧ����ͼ */
- rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view));
-
- /* ģʽ��ʾ��ͼ */
- rtgui_view_show(RTGUI_VIEW(_view), RT_TRUE);
- rtgui_view_destroy(RTGUI_VIEW(_view));
- _view = RT_NULL;
-}
-
-/* ����������ʾ�б���ͼ����ͼ */
-rtgui_view_t* demo_listview_view(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t *view;
- rtgui_button_t* open_btn;
-
- view = demo_view(workbench, "�б���ͼ��ʾ");
-
- /* ���Ӷ�����ť */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 80;
- rect.y1 += 30;
- rect.y2 = rect.y1 + 20;
- open_btn = rtgui_button_create("���б�");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
- rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
- rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
-
- return view;
-}
+/* + * �����嵥���б���ͼ��ʾ + * + * ������ӻ��ȴ�����һ����ʾ�õ�container�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ + * �µ��б���ͼ + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/button.h> +#include <rtgui/widgets/window.h> +#include <rtgui/widgets/list_view.h> + +static struct rtgui_application *application = RT_NULL; +static rtgui_list_view_t* _view = RT_NULL; +// static rtgui_image_t* return_image = RT_NULL; + +/* �б���Ķ������� */ +static void listitem_action(rtgui_widget_t *widget, void* parameter) +{ + char label_text[32]; + rtgui_win_t *win; + rtgui_label_t *label; + rtgui_rect_t rect = {0, 0, 150, 80}; + int no = (int)parameter; + + rtgui_rect_moveto(&rect, 20, 50); + + /* ��ʾ��Ϣ���� */ + win = rtgui_win_create(RTGUI_TOPLEVEL(application), + "����", &rect, RTGUI_WIN_STYLE_DEFAULT); + + rect.x1 += 20; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + + /* ������Ӧ�ı�ǩ */ + rt_sprintf(label_text, "���� %d", no); + label = rtgui_label_create(label_text); + + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rtgui_container_add_child(win, RTGUI_WIDGET(label)); + + /* ��ģ̬��ʾ���� */ + rtgui_win_show(win, RT_FALSE); +} + +/* ���ع��ܵĶ������� */ +static void return_action(rtgui_widget_t* widget, void* parameter) +{ + rtgui_container_end_modal(RTGUI_CONTAINER(_view), RTGUI_MODAL_OK); +} + +/* �����б���� */ +static struct rtgui_list_item items[] = +{ + {"�б���1", RT_NULL, listitem_action, (void*)1}, + {"�б���2", RT_NULL, listitem_action, (void*)2}, + {"�б���3", RT_NULL, listitem_action, (void*)3}, + {"�б���4", RT_NULL, listitem_action, (void*)4}, + {"�б���5", RT_NULL, listitem_action, (void*)5}, + {"����", RT_NULL, return_action, RT_NULL}, +}; + +/* ���б���ͼ�õİ�ť�������� */ +static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_rect_t rect; + + /* ��ö����application */ + application = RTGUI_APPLICATION(rtgui_widget_get_toplevel(widget)); + rtgui_widget_get_rect(RTGUI_WIDGET(application), &rect); + + /* ����һ���б���ͼ�� ��ָ��Ϊitems */ + _view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item), + &rect, RTGUI_LIST_VIEW_LIST); + + rtgui_application_add_container(application, RTGUI_CONTAINER(_view)); + + /* ģʽ��ʾ��ͼ */ + rtgui_container_show(RTGUI_CONTAINER(_view), RT_TRUE); + rtgui_container_destroy(RTGUI_CONTAINER(_view)); + _view = RT_NULL; +} + +/* ����������ʾ�б���ͼ����ͼ */ +rtgui_container_t* demo_listview_view(void) +{ + rtgui_rect_t rect; + rtgui_container_t *container; + rtgui_button_t* open_btn; + + container = demo_view("�б���ͼ��ʾ"); + + /* ���Ӷ�����ť */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 80; + rect.y1 += 30; + rect.y2 = rect.y1 + 20; + open_btn = rtgui_button_create("���б�"); + rtgui_container_add_child(container, RTGUI_WIDGET(open_btn)); + rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect); + rtgui_button_set_onbutton(open_btn, open_btn_onbutton); + + return container; +} diff --git a/examples/gui/demo_listview_icon.c b/examples/gui/demo_listview_icon.c index f95640401b..a5f6e20b4b 100644 --- a/examples/gui/demo_listview_icon.c +++ b/examples/gui/demo_listview_icon.c @@ -1,354 +1,350 @@ -/*
- * �����嵥���б���ͼ��ʾ
- *
- * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ
- * �µ��б���ͼ
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/button.h>
-#include <rtgui/widgets/window.h>
-#include <rtgui/widgets/list_view.h>
-
-static rtgui_workbench_t* workbench = RT_NULL;
-static rtgui_list_view_t* _view = RT_NULL;
-
-/* �б���Ķ������� */
-#if RTTHREAD_VERSION >= 10000
-static void listitem_action(rtgui_widget_t* widget, void* parameter)
-#else
-static void listitem_action(void* parameter)
-#endif
-{
- char label_text[32];
- rtgui_win_t *win;
- rtgui_label_t *label;
- rtgui_rect_t rect = {0, 0, 150, 80};
- int no = (int)parameter;
-
- rtgui_rect_moveto(&rect, 20, 50);
-
- /* ��ʾ��Ϣ���� */
- win = rtgui_win_create(RTGUI_TOPLEVEL(workbench),
- "����", &rect, RTGUI_WIN_STYLE_DEFAULT);
-
- rect.x1 += 20;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
-
- /* ������Ӧ�ı�ǩ */
- rt_sprintf(label_text, "���� %d", no);
- label = rtgui_label_create(label_text);
-
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
-
- /* ��ģ̬��ʾ���� */
- rtgui_win_show(win, RT_FALSE);
-}
-
-/* ���ع��ܵĶ������� */
-#if RTTHREAD_VERSION >= 10000
-static void return_action(rtgui_widget_t* widget, void* parameter)
-#else
-static void return_action(void* parameter)
-#endif
-{
- /* �˳�ģ̬��ʾ */
- rtgui_view_end_modal(RTGUI_VIEW(_view), RTGUI_MODAL_OK);
-}
-
-/* ��� */
-#define ITEM_MAX 50
-static struct rtgui_list_item *items = RT_NULL;
-static rtgui_image_t* item_icon = RT_NULL;
-static rtgui_image_t* exit_icon = RT_NULL;
-
-static const char * image_xpm[] = {
- "16 16 106 2",
- " c None",
- ". c #D0C83F",
- "+ c #D0C840",
- "@ c #D0C030",
- "# c #D0B820",
- "$ c #D0B020",
- "% c #D0B01F",
- "& c #5F571F",
- "* c #F0F0C0",
- "= c #FFF8D0",
- "- c #FFF8C0",
- "; c #FFF8B0",
- "> c #FFF8A0",
- ", c #F0E870",
- "' c #707030",
- ") c #4F87EF",
- "! c #4F78C0",
- "~ c #5088E0",
- "{ c #5078C0",
- "] c #C0D0F0",
- "^ c #FFF8E0",
- "/ c #FFF090",
- "( c #F0E070",
- "_ c #6F97D0",
- ": c #C0D8FE",
- "< c #80A8F0",
- "[ c #7088D0",
- "} c #B0D0FF",
- "| c #90B0F0",
- "1 c #1040A0",
- "2 c #F0F080",
- "3 c #707040",
- "4 c #7098F0",
- "5 c #3068E0",
- "6 c #A0B8F0",
- "7 c #4070C0",
- "8 c #002880",
- "9 c #404040",
- "0 c #505050",
- "a c #F0F090",
- "b c #F0E860",
- "c c #F0D860",
- "d c #807840",
- "e c #2F5FC0",
- "f c #1050D0",
- "g c #1048B0",
- "h c #002870",
- "i c #C0C080",
- "j c #C0C070",
- "k c #F0F070",
- "l c #F0E060",
- "m c #E0D050",
- "n c #00277F",
- "o c #00287F",
- "p c #1F3F6F",
- "q c #1048C0",
- "r c #0040B0",
- "s c #204080",
- "t c #FFF890",
- "u c #F0D850",
- "v c #E0C840",
- "w c #807040",
- "x c #A0B06F",
- "y c #204880",
- "z c #2048A0",
- "A c #90A8C0",
- "B c #FFF080",
- "C c #F0D050",
- "D c #C0A830",
- "E c #6F682F",
- "F c #F0F0A0",
- "G c #E0D060",
- "H c #B0A040",
- "I c #D0B840",
- "J c #E0C040",
- "K c #D0B030",
- "L c #706820",
- "M c #5F581F",
- "N c #CFBF3F",
- "O c #FFF0A0",
- "P c #A09830",
- "Q c #A08820",
- "R c #908030",
- "S c #807830",
- "T c #707020",
- "U c #605820",
- "V c #6F672F",
- "W c #D0C040",
- "X c #F0E880",
- "Y c #907820",
- "Z c #B09820",
- "` c #B09010",
- " . c #B08820",
- ".. c #806820",
- "+. c #5F5F1F",
- "@. c #F0E080",
- "#. c #B09020",
- "$. c #C0B040",
- "%. c #A09030",
- "&. c #908020",
- "*. c #606020",
- "=. c #6F5F1F",
- "-. c #9F982F",
- ";. c #A0872F",
- ">. c #6F681F",
- ",. c #706020",
- " ",
- " . + + + @ @ # # $ % & ",
- " + * = = = = - ; > , ' ",
- " ) ! ~ { ] ^ = - - > / ( ' ",
- "_ : < { [ } | 1 - ; > > / 2 ( 3 ",
- "{ 4 5 1 6 7 5 8 9 0 a / , b c d ",
- "e f g h 8 8 g h i j / k l c m d ",
- " n o p q r s t 2 , l c u v w ",
- " x y z A B , l u C v D E ",
- " @ F > t k G H I J K L M ",
- " N @ O / 2 l P Q R S T U V ",
- " W m 2 X l I Y Z ` ...+. ",
- " W @.l u I R #.Z Y U M ",
- " $.G I $.%.R &.Y *.& =. ",
- " -.;.>.,.L L ,.& M ",
- " "};
-
-static const char * exit_xpm[] = {
- "16 16 71 1",
- " c None",
- ". c #CF673F",
- "+ c #D0673F",
- "@ c #C05F3F",
- "# c #BF5F3F",
- "$ c #D0674F",
- "% c #E07050",
- "& c #F07850",
- "* c #FF7040",
- "= c #F06830",
- "- c #E05830",
- "; c #D05030",
- "> c #B04F2F",
- ", c #D06F4F",
- "' c #F08060",
- ") c #FF9070",
- "! c #FF8860",
- "~ c #FF8050",
- "{ c #FF5820",
- "] c #FF4810",
- "^ c #D04810",
- "/ c #B0482F",
- "( c #FF9880",
- "_ c #FF6030",
- ": c #F04000",
- "< c #C04010",
- "[ c #A03F2F",
- "} c #E06840",
- "| c #FF9870",
- "1 c #FF7850",
- "2 c #FF6840",
- "3 c #F04010",
- "4 c #E03800",
- "5 c #A03820",
- "6 c #8F372F",
- "7 c #F06840",
- "8 c #FF8060",
- "9 c #FFFFFF",
- "0 c #FFF8F0",
- "a c #FFF0F0",
- "b c #FFE8E0",
- "c c #FFD0C0",
- "d c #E04010",
- "e c #B03010",
- "f c #7F2F1F",
- "g c #FFD8D0",
- "h c #FFC8C0",
- "i c #C03000",
- "j c #6F281F",
- "k c #F04810",
- "l c #FF6830",
- "m c #FFE0D0",
- "n c #F0C0B0",
- "o c #D04010",
- "p c #5F1F1F",
- "q c #E04820",
- "r c #FF4000",
- "s c #FF5020",
- "t c #FF5010",
- "u c #D03800",
- "v c #D03000",
- "w c #B02800",
- "x c #5F170F",
- "y c #C05020",
- "z c #F03800",
- "A c #802010",
- "B c #4F0F0F",
- "C c #A02800",
- "D c #C03810",
- "E c #5F0F00",
- "F c #A03810",
- " ",
- " .+@@@# ",
- " $%&*=-;> ",
- " ,')!~*{]^/ ",
- " +&)()~*_]:<[ ",
- " .}~!||!12{3456 ",
- " +7899990abcdef ",
- " @{19990bgchdij ",
- " @kl0abmchcnoip ",
- " @qr]stt]3duvwx ",
- " #yz:::z44uvvAB ",
- " >o4444uvvvCB ",
- " /DvvvvvvCE ",
- " [FeiiwAB ",
- " 6fjpxB ",
- " "};
-
-/* ���б���ͼ�õİ�ť�������� */
-static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_rect_t rect;
- rt_uint32_t index;
-
- /* ��ö����workbench */
- workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
- rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
-
- /* ��ʼ��ͼ���б� */
- if (items == RT_NULL)
- {
- char item_name[32];
-
- items = (struct rtgui_list_item *) rtgui_malloc((ITEM_MAX + 1) * sizeof(struct rtgui_list_item));
- for (index = 0; index < ITEM_MAX; index ++)
- {
- rt_snprintf(item_name, sizeof(item_name), "ͼ��%d", index);
- items[index].action = listitem_action;
- items[index].image = item_icon;
- items[index].name = rt_strdup(item_name);
- items[index].parameter = (void*) index;
- }
-
- items[ITEM_MAX].action = return_action;
- items[ITEM_MAX].image = exit_icon;
- items[ITEM_MAX].name = "�˳�";
- items[ITEM_MAX].parameter = RT_NULL;
- }
-
- /* ����һ���б���ͼ�� ��ָ��Ϊitems */
- _view = rtgui_list_view_create(items, ITEM_MAX + 1, &rect, RTGUI_LIST_VIEW_ICON);
- /* ��workbench��������Ӧ����ͼ */
- rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view));
-
- /* ģʽ��ʾ��ͼ */
- rtgui_view_show(RTGUI_VIEW(_view), RT_TRUE);
- rtgui_view_destroy(RTGUI_VIEW(_view));
-
- _view = RT_NULL;
-}
-
-/* ����������ʾ�б���ͼ����ͼ */
-rtgui_view_t* demo_listview_icon_view(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t *view;
- rtgui_button_t* open_btn;
-
- view = demo_view(workbench, "ͼ����ͼ��ʾ");
-
- if (item_icon == RT_NULL)
- item_icon = rtgui_image_create_from_mem("xpm",
- (const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE);
- if (exit_icon == RT_NULL)
- exit_icon = rtgui_image_create_from_mem("xpm",
- (const rt_uint8_t*)exit_xpm, sizeof(exit_xpm), RT_TRUE);
-
- /* ���Ӷ�����ť */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 80;
- rect.y1 += 30;
- rect.y2 = rect.y1 + 20;
- open_btn = rtgui_button_create("��ͼ���б�");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
- rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
- rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
-
- return view;
-}
+/* + * �����嵥���б���ͼ��ʾ + * + * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ + * �µ��б���ͼ + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/button.h> +#include <rtgui/widgets/window.h> +#include <rtgui/widgets/list_view.h> + +static struct rtgui_application *application = RT_NULL; +static rtgui_list_view_t* _view = RT_NULL; + +/* �б���Ķ������� */ +static void listitem_action(rtgui_widget_t* widget, void* parameter) +{ + char label_text[32]; + rtgui_win_t *win; + rtgui_label_t *label; + rtgui_rect_t rect = {0, 0, 150, 80}; + int no = (int)parameter; + + rtgui_rect_moveto(&rect, 20, 50); + + /* ��ʾ��Ϣ���� */ + win = rtgui_win_create(RTGUI_TOPLEVEL(application), + "����", &rect, RTGUI_WIN_STYLE_DEFAULT); + + rect.x1 += 20; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + + /* ������Ӧ�ı�ǩ */ + rt_sprintf(label_text, "���� %d", no); + label = rtgui_label_create(label_text); + + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label)); + + /* ��ģ̬��ʾ���� */ + rtgui_win_show(win, RT_FALSE); +} + +/* ���ع��ܵĶ������� */ +#if RT_VERSION == 4 +static void return_action(rtgui_widget_t* widget, void* parameter) +#else +static void return_action(void* parameter) +#endif +{ + /* �˳�ģ̬��ʾ */ + rtgui_container_end_modal(RTGUI_CONTAINER(_view), RTGUI_MODAL_OK); +} + +/* �б��� */ +#define ITEM_MAX 50 +static struct rtgui_list_item *items = RT_NULL; +static rtgui_image_t* item_icon = RT_NULL; +static rtgui_image_t* exit_icon = RT_NULL; + +static const char * image_xpm[] = { + "16 16 106 2", + " c None", + ". c #D0C83F", + "+ c #D0C840", + "@ c #D0C030", + "# c #D0B820", + "$ c #D0B020", + "% c #D0B01F", + "& c #5F571F", + "* c #F0F0C0", + "= c #FFF8D0", + "- c #FFF8C0", + "; c #FFF8B0", + "> c #FFF8A0", + ", c #F0E870", + "' c #707030", + ") c #4F87EF", + "! c #4F78C0", + "~ c #5088E0", + "{ c #5078C0", + "] c #C0D0F0", + "^ c #FFF8E0", + "/ c #FFF090", + "( c #F0E070", + "_ c #6F97D0", + ": c #C0D8FE", + "< c #80A8F0", + "[ c #7088D0", + "} c #B0D0FF", + "| c #90B0F0", + "1 c #1040A0", + "2 c #F0F080", + "3 c #707040", + "4 c #7098F0", + "5 c #3068E0", + "6 c #A0B8F0", + "7 c #4070C0", + "8 c #002880", + "9 c #404040", + "0 c #505050", + "a c #F0F090", + "b c #F0E860", + "c c #F0D860", + "d c #807840", + "e c #2F5FC0", + "f c #1050D0", + "g c #1048B0", + "h c #002870", + "i c #C0C080", + "j c #C0C070", + "k c #F0F070", + "l c #F0E060", + "m c #E0D050", + "n c #00277F", + "o c #00287F", + "p c #1F3F6F", + "q c #1048C0", + "r c #0040B0", + "s c #204080", + "t c #FFF890", + "u c #F0D850", + "v c #E0C840", + "w c #807040", + "x c #A0B06F", + "y c #204880", + "z c #2048A0", + "A c #90A8C0", + "B c #FFF080", + "C c #F0D050", + "D c #C0A830", + "E c #6F682F", + "F c #F0F0A0", + "G c #E0D060", + "H c #B0A040", + "I c #D0B840", + "J c #E0C040", + "K c #D0B030", + "L c #706820", + "M c #5F581F", + "N c #CFBF3F", + "O c #FFF0A0", + "P c #A09830", + "Q c #A08820", + "R c #908030", + "S c #807830", + "T c #707020", + "U c #605820", + "V c #6F672F", + "W c #D0C040", + "X c #F0E880", + "Y c #907820", + "Z c #B09820", + "` c #B09010", + " . c #B08820", + ".. c #806820", + "+. c #5F5F1F", + "@. c #F0E080", + "#. c #B09020", + "$. c #C0B040", + "%. c #A09030", + "&. c #908020", + "*. c #606020", + "=. c #6F5F1F", + "-. c #9F982F", + ";. c #A0872F", + ">. c #6F681F", + ",. c #706020", + " ", + " . + + + @ @ # # $ % & ", + " + * = = = = - ; > , ' ", + " ) ! ~ { ] ^ = - - > / ( ' ", + "_ : < { [ } | 1 - ; > > / 2 ( 3 ", + "{ 4 5 1 6 7 5 8 9 0 a / , b c d ", + "e f g h 8 8 g h i j / k l c m d ", + " n o p q r s t 2 , l c u v w ", + " x y z A B , l u C v D E ", + " @ F > t k G H I J K L M ", + " N @ O / 2 l P Q R S T U V ", + " W m 2 X l I Y Z ` ...+. ", + " W @.l u I R #.Z Y U M ", + " $.G I $.%.R &.Y *.& =. ", + " -.;.>.,.L L ,.& M ", + " "}; + +static const char * exit_xpm[] = { + "16 16 71 1", + " c None", + ". c #CF673F", + "+ c #D0673F", + "@ c #C05F3F", + "# c #BF5F3F", + "$ c #D0674F", + "% c #E07050", + "& c #F07850", + "* c #FF7040", + "= c #F06830", + "- c #E05830", + "; c #D05030", + "> c #B04F2F", + ", c #D06F4F", + "' c #F08060", + ") c #FF9070", + "! c #FF8860", + "~ c #FF8050", + "{ c #FF5820", + "] c #FF4810", + "^ c #D04810", + "/ c #B0482F", + "( c #FF9880", + "_ c #FF6030", + ": c #F04000", + "< c #C04010", + "[ c #A03F2F", + "} c #E06840", + "| c #FF9870", + "1 c #FF7850", + "2 c #FF6840", + "3 c #F04010", + "4 c #E03800", + "5 c #A03820", + "6 c #8F372F", + "7 c #F06840", + "8 c #FF8060", + "9 c #FFFFFF", + "0 c #FFF8F0", + "a c #FFF0F0", + "b c #FFE8E0", + "c c #FFD0C0", + "d c #E04010", + "e c #B03010", + "f c #7F2F1F", + "g c #FFD8D0", + "h c #FFC8C0", + "i c #C03000", + "j c #6F281F", + "k c #F04810", + "l c #FF6830", + "m c #FFE0D0", + "n c #F0C0B0", + "o c #D04010", + "p c #5F1F1F", + "q c #E04820", + "r c #FF4000", + "s c #FF5020", + "t c #FF5010", + "u c #D03800", + "v c #D03000", + "w c #B02800", + "x c #5F170F", + "y c #C05020", + "z c #F03800", + "A c #802010", + "B c #4F0F0F", + "C c #A02800", + "D c #C03810", + "E c #5F0F00", + "F c #A03810", + " ", + " .+@@@# ", + " $%&*=-;> ", + " ,')!~*{]^/ ", + " +&)()~*_]:<[ ", + " .}~!||!12{3456 ", + " +7899990abcdef ", + " @{19990bgchdij ", + " @kl0abmchcnoip ", + " @qr]stt]3duvwx ", + " #yz:::z44uvvAB ", + " >o4444uvvvCB ", + " /DvvvvvvCE ", + " [FeiiwAB ", + " 6fjpxB ", + " "}; + +/* ���б���ͼ�õİ�ť�������� */ +static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_rect_t rect; + rt_uint32_t index; + + /* ��ö����application */ + application = RTGUI_APPLICATION(rtgui_widget_get_toplevel(widget)); + rtgui_widget_get_rect(RTGUI_WIDGET(application), &rect); + + /* ��ʼ��ͼ���б� */ + if (items == RT_NULL) + { + char item_name[32]; + + items = (struct rtgui_list_item *) rtgui_malloc((ITEM_MAX + 1) * sizeof(struct rtgui_list_item)); + for (index = 0; index < ITEM_MAX; index ++) + { + rt_snprintf(item_name, sizeof(item_name), "ͼ��%d", index); + items[index].action = listitem_action; + items[index].image = item_icon; + items[index].name = rt_strdup(item_name); + items[index].parameter = (void*) index; + } + + items[ITEM_MAX].action = return_action; + items[ITEM_MAX].image = exit_icon; + items[ITEM_MAX].name = "�˳�"; + items[ITEM_MAX].parameter = RT_NULL; + } + + /* ����һ���б���ͼ�� ��ָ��Ϊitems */ + _view = rtgui_list_view_create(items, ITEM_MAX + 1, &rect, RTGUI_LIST_VIEW_ICON); + /* ��application��������Ӧ����ͼ */ + rtgui_application_add_container(application, RTGUI_CONTAINER(_view)); + + /* ģʽ��ʾ��ͼ */ + rtgui_container_show(RTGUI_CONTAINER(_view), RT_TRUE); + rtgui_container_destroy(RTGUI_CONTAINER(_view)); + + _view = RT_NULL; +} + +/* ����������ʾ�б���ͼ����ͼ */ +rtgui_container_t* demo_listview_icon_view(struct rtgui_application *app) +{ + rtgui_rect_t rect; + rtgui_container_t *view; + rtgui_button_t* open_btn; + + view = demo_view(app, "ͼ����ͼ��ʾ"); + + if (item_icon == RT_NULL) + item_icon = rtgui_image_create_from_mem("xpm", + (const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE); + if (exit_icon == RT_NULL) + exit_icon = rtgui_image_create_from_mem("xpm", + (const rt_uint8_t*)exit_xpm, sizeof(exit_xpm), RT_TRUE); + + /* ���Ӷ�����ť */ + demo_view_get_rect(view, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 80; + rect.y1 += 30; + rect.y2 = rect.y1 + 20; + open_btn = rtgui_button_create("��ͼ���б�"); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn)); + rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect); + rtgui_button_set_onbutton(open_btn, open_btn_onbutton); + + return view; +} diff --git a/examples/gui/demo_panel.c b/examples/gui/demo_panel.c index 27536eff46..339b67cc7d 100644 --- a/examples/gui/demo_panel.c +++ b/examples/gui/demo_panel.c @@ -1,27 +1,27 @@ -#include <rtgui/rtgui.h>
-#include <rtgui/rtgui_server.h>
-
-/*
- * Panel demo for 240x320
- * info panel: (0, 0) - (240, 25)
- * main panel: (0, 25) - (240, 320)
- */
-void panel_init(void)
-{
- rtgui_rect_t rect;
-
- /* register dock panel */
- rect.x1 = 0;
- rect.y1 = 0;
- rect.x2 = 240;
- rect.y2 = 25;
- rtgui_panel_register("info", &rect);
-
- /* register main panel */
- rect.x1 = 0;
- rect.y1 = 25;
- rect.x2 = 240;
- rect.y2 = 320;
- rtgui_panel_register("main", &rect);
- rtgui_panel_set_default_focused("main");
-}
+#include <rtgui/rtgui.h> +#include <rtgui/rtgui_server.h> + +/* + * Panel demo for 240x320 + * info panel: (0, 0) - (240, 25) + * main panel: (0, 25) - (240, 320) + */ +void panel_init(void) +{ + rtgui_rect_t rect; + + /* register dock panel */ + rect.x1 = 0; + rect.y1 = 0; + rect.x2 = 240; + rect.y2 = 25; + rtgui_panel_register("info", &rect); + + /* register main panel */ + rect.x1 = 0; + rect.y1 = 25; + rect.x2 = 240; + rect.y2 = 320; + rtgui_panel_register("main", &rect); + rtgui_panel_set_default_focused("main"); +} diff --git a/examples/gui/demo_panel_single.c b/examples/gui/demo_panel_single.c index 2e56de4fd4..c31e878f4a 100644 --- a/examples/gui/demo_panel_single.c +++ b/examples/gui/demo_panel_single.c @@ -1,19 +1,19 @@ -#include <rtgui/rtgui.h>
-#include <rtgui/driver.h>
-#include <rtgui/rtgui_server.h>
-
-/*
- * a single panel
- */
-void panel_init(void)
-{
- rtgui_rect_t rect;
-
- /* register main panel */
- rect.x1 = 0;
- rect.y1 = 0;
- rect.x2 = rtgui_graphic_driver_get_default()->width;
- rect.y2 = rtgui_graphic_driver_get_default()->height;
- rtgui_panel_register("main", &rect);
- rtgui_panel_set_default_focused("main");
-}
+#include <rtgui/rtgui.h> +#include <rtgui/driver.h> +#include <rtgui/rtgui_server.h> + +/* + * a single panel + */ +void panel_init(void) +{ + rtgui_rect_t rect; + + /* register main panel */ + rect.x1 = 0; + rect.y1 = 0; + rect.x2 = rtgui_graphic_driver_get_default()->width; + rect.y2 = rtgui_graphic_driver_get_default()->height; + rtgui_panel_register("main", &rect); + rtgui_panel_set_default_focused("main"); +} diff --git a/examples/gui/demo_simple_workbench.c b/examples/gui/demo_simple_workbench.c index d0432428c7..1f24ac72e5 100644 --- a/examples/gui/demo_simple_workbench.c +++ b/examples/gui/demo_simple_workbench.c @@ -1,60 +1,60 @@ -/*
- * A simple workbench
- */
-#include <rtthread.h>
-#include <rtgui/rtgui_server.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/workbench.h>
-
-static void workbench_entry(void* parameter)
-{
- rt_mq_t mq;
- rtgui_view_t* view;
- rtgui_label_t* label;
- struct rtgui_workbench* workbench;
- rtgui_rect_t rect;
-
- mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO);
- /* ע�ᵱǰ�߳�ΪGUI�߳� */
- rtgui_thread_register(rt_thread_self(), mq);
- /* ����һ������̨ */
- workbench = rtgui_workbench_create("main", "workbench #1");
- if (workbench == RT_NULL) return;
-
- view = rtgui_view_create("view");
- if (view == RT_NULL) return;
- /* ָ����ͼ�ı���ɫ */
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
-
- /* ����һ��label */
- label = rtgui_label_create("��ã�RT-Thread��");
- rect.x1 = 10; rect.y1 = 10;
- rect.x2 = 210; rect.y2 = 30;
- /* ����label��� */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- /* ���ӵ���workbench�� */
- rtgui_workbench_add_view(workbench, view);
- /* ��ģʽ��ʽ��ʾ��ͼ */
- rtgui_view_show(view, RT_FALSE);
-
- /* ִ�й���̨�¼�ѭ�� */
- rtgui_workbench_event_loop(workbench);
-
- /* ȥע��GUI�߳� */
- rtgui_thread_deregister(rt_thread_self());
-
- /* delete message queue */
- rt_mq_delete(mq);
-}
-
-/* ��ʼ��workbench */
-void wb_init()
-{
- rt_thread_t tid;
-
- tid = rt_thread_create("wb1", workbench_entry, RT_NULL, 2048, 20, 5);
- if (tid != RT_NULL) rt_thread_startup(tid);
-}
+/* + * A simple workbench + */ +#include <rtthread.h> +#include <rtgui/rtgui_server.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/workbench.h> + +static void workbench_entry(void* parameter) +{ + rt_mq_t mq; + rtgui_container_t* view; + rtgui_label_t* label; + struct rtgui_workbench* workbench; + rtgui_rect_t rect; + + mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO); + /* ע�ᵱǰ�߳�ΪGUI�߳� */ + rtgui_thread_register(rt_thread_self(), mq); + /* ����һ������̨ */ + workbench = rtgui_workbench_create("main", "workbench #1"); + if (workbench == RT_NULL) return; + + view = rtgui_container_create("view"); + if (view == RT_NULL) return; + /* ָ����ͼ�ı���ɫ */ + RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white; + + /* ����һ��label */ + label = rtgui_label_create("��ã�RT-Thread��"); + rect.x1 = 10; rect.y1 = 10; + rect.x2 = 210; rect.y2 = 30; + /* ����label��λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); + + /* ���ӵ���workbench�� */ + rtgui_workbench_add_view(workbench, view); + /* ��ģʽ��ʽ��ʾ��ͼ */ + rtgui_container_show(view, RT_FALSE); + + /* ִ�й���̨�¼�ѭ�� */ + rtgui_workbench_event_loop(workbench); + + /* ȥע��GUI�߳� */ + rtgui_thread_deregister(rt_thread_self()); + + /* delete message queue */ + rt_mq_delete(mq); +} + +/* ��ʼ��workbench */ +void wb_init() +{ + rt_thread_t tid; + + tid = rt_thread_create("wb1", workbench_entry, RT_NULL, 2048, 20, 5); + if (tid != RT_NULL) rt_thread_startup(tid); +} diff --git a/examples/gui/demo_view.c b/examples/gui/demo_view.c index f7b5e1594a..d19ee9ac3d 100644 --- a/examples/gui/demo_view.c +++ b/examples/gui/demo_view.c @@ -1,172 +1,150 @@ -#include <rtgui/rtgui.h>
-#include <rtgui/widgets/view.h>
-#include <rtgui/widgets/button.h>
-#include <rtgui/widgets/workbench.h>
-#include <rtgui/widgets/staticline.h>
-
-/* ���ڴ����ʾ��ͼ�����飬���ɴ���32����ʾ��ͼ */
-static rtgui_view_t* demo_view_list[32];
-/* ��ǰ��ʾ��ͼ���� */
-static rt_uint16_t demo_view_current = 0;
-/* �ܹ���������ʾ��ͼ��Ŀ */
-static rt_uint16_t demo_view_number = 0;
-
-/* ��ʾ��һ����ʾ��ͼ */
-void demo_view_next(struct rtgui_widget* widget, rtgui_event_t *event)
-{
- if (demo_view_current + 1< demo_view_number)
- {
- demo_view_current ++;
- rtgui_view_show(demo_view_list[demo_view_current], RT_FALSE);
- }
-}
-
-/* ��ʾǰһ����ʾ��ͼ */
-void demo_view_prev(struct rtgui_widget* widget, rtgui_event_t *event)
-{
- if (demo_view_current != 0)
- {
- demo_view_current --;
- rtgui_view_show(demo_view_list[demo_view_current], RT_FALSE);
- }
-}
-
-/* ����һ����ʾ��ͼ�����ṩ��workbench����ʾ�õı��� */
-rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
-{
- struct rtgui_view* view;
-
- /* ������ͼ������ */
- view = rtgui_view_create(title);
- if (view == RT_NULL) return RT_NULL;
-
- /* �����ɹ������ӵ������� */
- demo_view_list[demo_view_number] = view;
- demo_view_number ++;
-
- /* ���ӵ���workbench�� */
- rtgui_workbench_add_view(workbench, view);
-
- /* ������һ����ͼ��ǰһ����ͼ��ť */
- {
- struct rtgui_rect rect;
- struct rtgui_button *next_btn, *prev_btn;
- struct rtgui_label *label;
- struct rtgui_staticline *line;
-
- /* �����ͼ��λ����Ϣ(�ڼ��뵽workbench��ʱ��workbench���Զ�������ͼ�Ĵ�С) */
- rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
- rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
- rect.x1 += 5;
- rect.y1 += 5;
- rect.x2 -= 5;
- rect.y2 = rect.y1 + 20;
-
- /* ���������õı�ǩ */
- label = rtgui_label_create(title);
- /* ���ñ�ǩλ����Ϣ */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* ���ӱ�ǩ����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- rect.y1 += 20;
- rect.y2 += 20;
- /* ����һ��ˮƽ��staticline�� */
- line = rtgui_staticline_create(RTGUI_HORIZONTAL);
- /* ���þ�̬�ߵ�λ����Ϣ */
- rtgui_widget_set_rect(RTGUI_WIDGET(line), &rect);
- /* ���Ӿ�̬�ߵ���ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(line));
-
- /* �����ͼ��λ����Ϣ */
- rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
- rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
- rect.x2 -= 5;
- rect.y2 -= 5;
- rect.x1 = rect.x2 - 100;
- rect.y1 = rect.y2 - 25;
-
- /* ����"��һ��"��ť */
- next_btn = rtgui_button_create("��һ��");
- /* ����onbutton������demo_view_next���� */
- rtgui_button_set_onbutton(next_btn, demo_view_next);
- /* ���ð�ť��λ����Ϣ */
- rtgui_widget_set_rect(RTGUI_WIDGET(next_btn), &rect);
- /* ���Ӱ�ť����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(next_btn));
-
- /* �����ͼ��λ����Ϣ */
- rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
- rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
- rect.x1 += 5;
- rect.y2 -= 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 = rect.y2 - 25;
-
- /* ����"��һ��"��ť */
- prev_btn = rtgui_button_create("��һ��");
- /* ����onbutton������demo_view_prev���� */
- rtgui_button_set_onbutton(prev_btn, demo_view_prev);
- /* ���ð�ť��λ����Ϣ */
- rtgui_widget_set_rect(RTGUI_WIDGET(prev_btn), &rect);
- /* ���Ӱ�ť����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(prev_btn));
- }
-
- /* ���ش�������ͼ */
- return view;
-}
-
-/* ����������ڷ�����ʾ��ͼ�Ķ���������� */
-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);
- rtgui_widget_rect_to_device(RTGUI_WIDGET(view), rect);
- /* ȥ����ʾ������·���ť������ */
- rect->y1 += 45;
- 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);
- /* ȥ����ʾ������·���ť������ */
- rect->y1 += 45;
- rect->y2 -= 35;
-}
-
-/* ���DZ��汾ʱ������������ڷ����Զ���������box�ؼ� */
-#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;
-
- /* �����ͼ��λ����Ϣ */
- rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
- rect.y1 += 45;
- rect.y2 -= 25;
-
- /* ����һ���Զ��������� */
- box = rtgui_box_create(orient, &rect);
- /* ����box�ؼ�����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(box));
-
- return box;
-}
-#endif
-
-/* �������������ʾ��ǰ����ͼ */
-void demo_view_show()
-{
- if (demo_view_number != 0)
- {
- rtgui_view_show(demo_view_list[demo_view_current], RT_FALSE);
- }
-}
+#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)); + + /* �����ͼ��λ����Ϣ(�ڼ��뵽 notebook ��ʱ��notebook ���Զ����� container + * �Ĵ�С) */ + 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; + + /* ���������õı�ǩ */ + label = rtgui_label_create(title); + /* ���ñ�ǩλ����Ϣ */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* ���ӱ�ǩ����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + rect.y1 += 20; + rect.y2 += 20; + /* ����һ��ˮƽ�� staticline �� */ + line = rtgui_staticline_create(RTGUI_HORIZONTAL); + /* ���þ�̬�ߵ�λ����Ϣ */ + rtgui_widget_set_rect(RTGUI_WIDGET(line), &rect); + /* ���Ӿ�̬�ߵ���ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(line)); + + /* �����ͼ��λ����Ϣ */ + 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; + + /* ����"��һ��"��ť */ + next_btn = rtgui_button_create("��һ��"); + /* ����onbutton������demo_view_next���� */ + rtgui_button_set_onbutton(next_btn, demo_view_next); + /* ���ð�ť��λ����Ϣ */ + rtgui_widget_set_rect(RTGUI_WIDGET(next_btn), &rect); + /* ���Ӱ�ť����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(next_btn)); + + /* �����ͼ��λ����Ϣ */ + 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; + + /* ����"��һ��"��ť */ + prev_btn = rtgui_button_create("��һ��"); + /* ����onbutton������demo_view_prev���� */ + rtgui_button_set_onbutton(prev_btn, demo_view_prev); + /* ���ð�ť��λ����Ϣ */ + rtgui_widget_set_rect(RTGUI_WIDGET(prev_btn), &rect); + /* ���Ӱ�ť����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(prev_btn)); + + /* ���ش�������ͼ */ + return container; +} + +/* ����������ڷ�����ʾ��ͼ�Ķ���������� */ +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); + /* ȥ����ʾ������·���ť������ */ + 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); + /* ȥ����ʾ������·���ť������ */ + rect->y1 += 45; + rect->y2 -= 35; +} + +/* ���DZ��汾ʱ������������ڷ����Զ���������box�ؼ� */ +#ifndef RTGUI_USING_SMALL_SIZE +struct rtgui_box* demo_view_create_box(struct rtgui_container *container, int orient) +{ + rtgui_rect_t rect; + struct rtgui_box* box; + + /* �����ͼ��λ����Ϣ */ + rtgui_widget_get_rect(RTGUI_WIDGET(container), &rect); + rect.y1 += 45; + rect.y2 -= 25; + + /* ����һ���Զ��������� */ + box = rtgui_box_create(orient, &rect); + /* ����box�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(box)); + + return box; +} +#endif diff --git a/examples/gui/demo_view.h b/examples/gui/demo_view.h index e1c7729275..e1c93a53b3 100644 --- a/examples/gui/demo_view.h +++ b/examples/gui/demo_view.h @@ -1,39 +1,39 @@ -/*
- * 程序清单:view演示
- *
- * 这是一个视图的演示,也是为了配合整个GUI演示而制作的视图,或者说,其他大多数控件的演示
- * 都是采用,先创建一个demo_view(演示视图),然后再在这个演示视图上添加相应的控件。
- *
- * 这个演示视图默认上方带一个演示标题,下方带两个按钮,点击它切换到前一个视图或后一个视图。
- * 针对控件演示而言,这个演示视图最重要的是提供了一个可显示的区域,只需要在这块区域上添加
- * 控件即可达到演示的目的。
- *
- * 获得这个显示区域的函数是:
- * demo_view_get_rect函数。
- */
-#ifndef __DEMO_VIEW_H__
-#define __DEMO_VIEW_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/view.h>
-#include <rtgui/widgets/workbench.h>
-
-/* 如果是标准版本,可以启用box自动布局引擎 */
-#ifndef RTGUI_USING_SMALL_SIZE
-#include <rtgui/widgets/box.h>
-#endif
-
-/* 创建一个演示视图,需要给出这个视图所在的workbench和演示标题 */
-rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title);
-/* 获得演示视图提供给演示控件用的区域信息 */
-void demo_view_get_rect(rtgui_view_t* view, rtgui_rect_t *rect);
-void demo_view_get_logic_rect(rtgui_view_t* view, rtgui_rect_t *rect);
-void demo_view_show(void);
-
-/* 如果是标准版,可以调用这个函数获得一个自动布局引擎 */
-#ifndef RTGUI_USING_SMALL_SIZE
-rtgui_box_t* demo_view_create_box(rtgui_view_t* view, int orient);
-#endif
-
-#endif
-
+/* + * 程序清单:view演示 + * + * 这是一个视图的演示,也是为了配合整个GUI演示而制作的视图,或者说,其他大多数控件的演示 + * 都是采用,先创建一个demo_view(演示视图),然后再在这个演示视图上添加相应的控件。 + * + * 这个演示视图默认上方带一个演示标题,下方带两个按钮,点击它切换到前一个视图或后一个视图。 + * 针对控件演示而言,这个演示视图最重要的是提供了一个可显示的区域,只需要在这块区域上添加 + * 控件即可达到演示的目的。 + * + * 获得这个显示区域的函数是: + * demo_view_get_rect函数。 + */ +#ifndef __DEMO_VIEW_H__ +#define __DEMO_VIEW_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/rtgui_application.h> +#include <rtgui/widgets/container.h> + +/* 如果是标准版本,可以启用box自动布局引擎 */ +#ifndef RTGUI_USING_SMALL_SIZE +#include <rtgui/widgets/box.h> +#endif + +/* 创建一个演示视图,需要给出这个视图的演示标题 */ +rtgui_container_t* demo_view(const char* title); +/* 获得演示视图提供给演示控件用的区域信息 */ +void demo_view_get_rect(rtgui_container_t* view, rtgui_rect_t *rect); +void demo_view_get_logic_rect(rtgui_container_t* view, rtgui_rect_t *rect); +void demo_view_show(void); + +/* 如果是标准版,可以调用这个函数获得一个自动布局引擎 */ +#ifndef RTGUI_USING_SMALL_SIZE +rtgui_box_t* demo_view_create_box(rtgui_container_t* view, int orient); +#endif + +#endif + diff --git a/examples/gui/demo_view_animation.c b/examples/gui/demo_view_animation.c index fccc7bbea1..cc3bfb902f 100644 --- a/examples/gui/demo_view_animation.c +++ b/examples/gui/demo_view_animation.c @@ -1,113 +1,132 @@ -#include <rtgui/dc.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/view.h>
-#include "demo_view.h"
-
-/*
- * ֱ����DC�ϻ�ͼ��ʵ�ֶ���Ч��
- *
- * �����������ڶ�ʱ�������ģ������·�����ʾ����
- * "�����ҷ�"
- */
-static rt_int8_t dx = 1, dy = 1;
-static rtgui_rect_t text_rect;
-static rtgui_timer_t *timer;
-
-void timeout(struct rtgui_timer* timer, void* parameter)
-{
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
- rtgui_widget_t *widget;
-
- /* �ؼ�(view)ͨ��parameter�������ݸ���ʱ�� */
- widget = (rtgui_widget_t*)parameter;
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- return ;
-
- /* ���demo view������ͼ��������Ҫ�����жϱ߽� */
- demo_view_get_rect(RTGUI_VIEW(widget), &rect);
- rect.y2 -= 5;
-
- /* �ж��Ƿ��ǵ�һ�λ�ͼ */
- if ((text_rect.x1 == 0) && (text_rect.y1 == 0))
- {
- rtgui_rect_moveto(&text_rect, rect.x1, rect.y1);
- }
- else
- {
- /* �����ϵ����� */
- rtgui_dc_fill_rect(dc, &text_rect);
- }
-
- /* ����dx��dy */
- if (text_rect.x2 >= rect.x2) dx = -1;
- if (text_rect.x1 < rect.x1) dx = 1;
- if (text_rect.y2 >= rect.y2) dy = -1;
- if (text_rect.y1 < rect.y1) dy = 1;
-
- /* �ƶ��ı����λ�� */
- text_rect.x1 += dx; text_rect.x2 += dx;
- text_rect.y1 += dy; text_rect.y2 += dy;
-
- /* ��ͼ */
- rtgui_dc_draw_text(dc, "�����ҷ�", &text_rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
-}
-
-rt_bool_t animation_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- if (event->type == RTGUI_EVENT_PAINT)
- {
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
-
- /* ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view�Ȼ�ͼ */
- rtgui_view_event_handler(widget, event);
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- return RT_FALSE;
-
- /* ���demo view������ͼ������ */
- demo_view_get_rect(RTGUI_VIEW(widget), &rect);
-
- /* �������� */
- rtgui_dc_fill_rect(dc, &rect);
-
- /* ��ͼ */
- rtgui_dc_draw_text(dc, "�����ҷ�", &text_rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
- }
- else
- {
- /* ����Ĭ�ϵ��¼��������� */
- return rtgui_view_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-rtgui_view_t *demo_view_animation(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
-
- view = demo_view(workbench, "DC ����");
- if (view != RT_NULL)
- rtgui_widget_set_event_handler(RTGUI_WIDGET(view), animation_event_handler);
-
- rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "�����ҷ�", &text_rect);
- rtgui_rect_moveto(&text_rect, 0, 45);
- /* ������ʱ���Դ������� */
- timer = rtgui_timer_create(2, RT_TIMER_FLAG_PERIODIC, timeout, (void*)view);
- rtgui_timer_start(timer);
-
- return view;
-}
+#include <rtgui/dc.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/container.h> +#include "demo_view.h" + +/* + * ֱ����DC�ϻ�ͼ��ʵ�ֶ���Ч�� + * + * �����������ڶ�ʱ�������ģ������·�����ʾ���� + * "�����ҷ�" + */ +static rt_int8_t dx = 1, dy = 1; +static rtgui_rect_t text_rect; +static rtgui_timer_t *timer; + +void timeout(struct rtgui_timer* timer, void* parameter) +{ + struct rtgui_dc* dc; + struct rtgui_rect rect; + struct rtgui_widget *widget; + + /* �ؼ�(container)ͨ��parameter�������ݸ���ʱ�� */ + widget = RTGUI_WIDGET(parameter); + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + return ; + + /* ���demo container������ͼ��������Ҫ�����жϱ߽� */ + demo_view_get_rect(RTGUI_CONTAINER(widget), &rect); + rect.y2 -= 5; + + /* �ж��Ƿ��ǵ�һ�λ�ͼ */ + if ((text_rect.x1 == 0) && (text_rect.y1 == 0)) + { + rtgui_rect_moveto(&text_rect, rect.x1, rect.y1); + } + else + { + /* �����ϵ����� */ + rtgui_dc_fill_rect(dc, &text_rect); + } + + /* ����dx��dy */ + if (text_rect.x2 >= rect.x2) dx = -1; + if (text_rect.x1 < rect.x1) dx = 1; + if (text_rect.y2 >= rect.y2) dy = -1; + if (text_rect.y1 < rect.y1) dy = 1; + + /* �ƶ��ı����λ�� */ + text_rect.x1 += dx; text_rect.x2 += dx; + text_rect.y1 += dy; text_rect.y2 += dy; + + /* ��ͼ */ + rtgui_dc_draw_text(dc, "�����ҷ�", &text_rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); +} + +rt_bool_t animation_event_handler(struct rtgui_object* object, rtgui_event_t *event) +{ + struct rtgui_widget *widget = RTGUI_WIDGET(object); + + if (event->type == RTGUI_EVENT_PAINT) + { + struct rtgui_dc* dc; + rtgui_rect_t rect; + + /* ��Ϊ�õ���demo container�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo container�Ȼ�ͼ */ + rtgui_container_event_handler(object, event); + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + return RT_FALSE; + + /* ���demo container������ͼ������ */ + demo_view_get_rect(RTGUI_CONTAINER(widget), &rect); + + /* �������� */ + rtgui_dc_fill_rect(dc, &rect); + + /* ��ͼ */ + rtgui_dc_draw_text(dc, "�����ҷ�", &text_rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); + } + else + { + /* ����Ĭ�ϵ��¼��������� */ + return rtgui_container_event_handler(object, event); + } + + return RT_FALSE; +} + +static rt_bool_t animation_on_show(struct rtgui_object *object, struct rtgui_event *event) +{ + rt_kprintf("animation on show\n"); + if (timer != RT_NULL) + rtgui_timer_start(timer); + return RT_TRUE; +} + +static rt_bool_t animation_on_hide(struct rtgui_object *object, struct rtgui_event *event) +{ + rt_kprintf("animation on hide\n"); + if (timer != RT_NULL) + rtgui_timer_stop(timer); + return RT_TRUE; +} + +rtgui_container_t *demo_view_animation() +{ + rtgui_container_t *container; + + container = demo_view("DC ����"); + if (container != RT_NULL) + rtgui_object_set_event_handler(RTGUI_OBJECT(container), animation_event_handler); + + rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(container)), "�����ҷ�", &text_rect); + rtgui_rect_moveto(&text_rect, 0, 45); + timer = rtgui_timer_create(2, RT_TIMER_FLAG_PERIODIC, timeout, (void*)container); + + rtgui_widget_set_onshow(RTGUI_WIDGET(container), animation_on_show); + rtgui_widget_set_onhide(RTGUI_WIDGET(container), animation_on_hide); + + return container; +} diff --git a/examples/gui/demo_view_benchmark.c b/examples/gui/demo_view_benchmark.c index 181e542d0e..cd24824c62 100644 --- a/examples/gui/demo_view_benchmark.c +++ b/examples/gui/demo_view_benchmark.c @@ -1,111 +1,111 @@ -#include <rtgui/dc.h>
-#include <rtgui/dc_hw.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/view.h>
-#include "demo_view.h"
-
-#if RTTHREAD_VERSION >= 10000
-#define RAND(x1, x2) ((rand() % (x2 - x1)) + x1)
-
-static rtgui_view_t* view = RT_NULL;
-static int running = 0;
-
-void _onidle(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- rtgui_color_t color;
- rtgui_rect_t rect, draw_rect;
- struct rtgui_dc *dc;
-
- /* ��ÿؼ�������DC */
- // dc = rtgui_dc_hw_create(RTGUI_WIDGET(view));
- dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
- if (dc == RT_NULL) return ;
-
- demo_view_get_logic_rect(RTGUI_VIEW(view), &rect);
- draw_rect.x1 = RAND(rect.x1, rect.x2);
- draw_rect.y1 = RAND(rect.y1, rect.y2);
- draw_rect.x2 = RAND(draw_rect.x1, rect.x2);
- draw_rect.y2 = RAND(draw_rect.y1, rect.y2);
-
- color = RTGUI_RGB(rand() % 255, rand() % 255, rand() % 255);
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = color;
-
- rtgui_dc_fill_rect(dc, &draw_rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
-}
-
-void _draw_default(rtgui_widget_t* widget, rtgui_event_t* event)
-{
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
-
- /* ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view�Ȼ�ͼ */
- rtgui_view_event_handler(widget, event);
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- return ;
-
- /* ���demo view������ͼ������ */
- demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
-
- /* �������� */
- RTGUI_WIDGET_BACKGROUND(widget) = default_background;
- rtgui_dc_fill_rect(dc, &rect);
-
- /* ��ʾ��ʾ */
- rtgui_dc_draw_text(dc, "���������ʼ/ֹͣ����...", &rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
-}
-
-rt_bool_t benchmark_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- if (event->type == RTGUI_EVENT_PAINT)
- {
- _draw_default(widget, event);
- }
- else if (event->type == RTGUI_EVENT_KBD)
- {
- struct rtgui_event_kbd *kbd = (struct rtgui_event_kbd*)event;
-
- if (RTGUI_KBD_IS_UP(kbd))
- {
- if (running)
- {
- /* stop */
- rtgui_thread_set_onidle(RT_NULL);
- _draw_default(widget, event);
- }
- else
- {
- /* run */
- rtgui_thread_set_onidle(_onidle);
- }
-
- running = !running;
- }
- return RT_TRUE;
- }
- else
- {
- /* ����Ĭ�ϵ��¼��������� */
- return rtgui_view_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-rtgui_view_t *demo_view_benchmark(rtgui_workbench_t* workbench)
-{
- srand(100);
- view = demo_view(workbench, "��ͼ����");
- rtgui_widget_set_event_handler(RTGUI_WIDGET(view), benchmark_event_handler);
-
- return view;
-}
-#endif
+#include <rtgui/dc.h> +#include <rtgui/dc_hw.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/container.h> +#include "demo_view.h" + +#define RAND(x1, x2) ((rand() % (x2 - x1)) + x1) + +static struct rtgui_container *container = RT_NULL; +static int running = 0; + +void _onidle(struct rtgui_object *object, rtgui_event_t *event) +{ + rtgui_color_t color; + rtgui_rect_t rect, draw_rect; + struct rtgui_dc *dc; + + /* ��ÿؼ�������DC */ + // dc = rtgui_dc_hw_create(RTGUI_WIDGET(container)); + dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(container)); + if (dc == RT_NULL) + return; + + demo_view_get_logic_rect(RTGUI_CONTAINER(container), &rect); + draw_rect.x1 = RAND(rect.x1, rect.x2); + draw_rect.y1 = RAND(rect.y1, rect.y2); + draw_rect.x2 = RAND(draw_rect.x1, rect.x2); + draw_rect.y2 = RAND(draw_rect.y1, rect.y2); + + color = RTGUI_RGB(rand() % 255, rand() % 255, rand() % 255); + RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(container)) = color; + + rtgui_dc_fill_rect(dc, &draw_rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); +} + +void _draw_default(struct rtgui_object *object, rtgui_event_t* event) +{ + struct rtgui_widget *widget = RTGUI_WIDGET(object); + struct rtgui_dc* dc; + rtgui_rect_t rect; + + /* ��Ϊ�õ���demo container�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo container�Ȼ�ͼ */ + rtgui_container_event_handler(object, event); + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + return; + + /* ���demo container������ͼ������ */ + demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect); + + /* �������� */ + RTGUI_WIDGET_BACKGROUND(widget) = default_background; + rtgui_dc_fill_rect(dc, &rect); + + /* ��ʾ��ʾ */ + rtgui_dc_draw_text(dc, "���������ʼ/ֹͣ����...", &rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); +} + +rt_bool_t benchmark_event_handler(struct rtgui_object *object, rtgui_event_t *event) +{ + if (event->type == RTGUI_EVENT_PAINT) + { + _draw_default(object, event); + } + else if (event->type == RTGUI_EVENT_KBD) + { + struct rtgui_event_kbd *kbd = (struct rtgui_event_kbd*)event; + + if (RTGUI_KBD_IS_UP(kbd)) + { + if (running) + { + /* stop */ + rtgui_application_set_onidle(RT_NULL); + _draw_default(object, event); + } + else + { + /* run */ + rtgui_application_set_onidle(_onidle); + } + + running = !running; + } + return RT_TRUE; + } + else + { + /* ����Ĭ�ϵ��¼��������� */ + return rtgui_container_event_handler(object, event); + } + + return RT_FALSE; +} + +rtgui_container_t *demo_view_benchmark(void) +{ + srand(100); + container = demo_view("��ͼ����"); + rtgui_object_set_event_handler(RTGUI_OBJECT(container), benchmark_event_handler); + + return container; +} diff --git a/examples/gui/demo_view_box.c b/examples/gui/demo_view_box.c index eb7043e52a..41f1338c44 100644 --- a/examples/gui/demo_view_box.c +++ b/examples/gui/demo_view_box.c @@ -1,15 +1,15 @@ -#include "demo_view.h"
-#ifndef RTGUI_USING_SMALL_SIZE
-#include <rtgui/widgets/box.h>
-
-rtgui_view_t* demo_view_box(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
-
- view = demo_view(workbench, "Box View");
- demo_view_get_rect(view, &rect);
-
- return view;
-}
-#endif
+#include "demo_view.h" +#ifndef RTGUI_USING_SMALL_SIZE +#include <rtgui/widgets/box.h> + +rtgui_container_t* demo_view_box(rtgui_workbench_t* workbench) +{ + rtgui_rect_t rect; + rtgui_container_t* view; + + view = demo_view(workbench, "Box View"); + demo_view_get_rect(view, &rect); + + return view; +} +#endif diff --git a/examples/gui/demo_view_buffer_animation.c b/examples/gui/demo_view_buffer_animation.c index cadc2430e7..d435c787b2 100644 --- a/examples/gui/demo_view_buffer_animation.c +++ b/examples/gui/demo_view_buffer_animation.c @@ -1,124 +1,144 @@ -#include <rtgui/dc.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/view.h>
-#include "demo_view.h"
-
-/*
- * ֱ����DC�ϻ�ͼ��ʵ�ֶ���Ч��
- *
- * �����������ڶ�ʱ�������ģ������·�����ʾ����
- * "�����ҷ�"
- */
-static rt_int8_t dx = 1, dy = 1;
-static rtgui_rect_t text_rect;
-static rtgui_timer_t *timer;
-static struct rtgui_dc *dc_buffer;
-static void timeout(struct rtgui_timer* timer, void* parameter)
-{
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
- rtgui_widget_t *widget;
-
- /* �ؼ�(view)ͨ��parameter�������ݸ���ʱ�� */
- widget = (rtgui_widget_t*)parameter;
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- return ;
-
- /* ���demo view������ͼ��������Ҫ�����жϱ߽� */
- demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
- rect.y2 -= 5;
-
- /* �ж��Ƿ��ǵ�һ�λ�ͼ */
- if ((text_rect.x1 == 0) && (text_rect.y1 == 0))
- {
- rtgui_rect_moveto(&text_rect, rect.x1, rect.y1);
- }
-
- /* ����dx��dy */
- if (text_rect.x2 >= rect.x2) dx = -1;
- if (text_rect.x1 < rect.x1) dx = 1;
- if (text_rect.y2 >= rect.y2) dy = -1;
- if (text_rect.y1 < rect.y1) dy = 1;
-
- /* �ƶ��ı����λ�� */
- text_rect.x1 += dx; text_rect.x2 += dx;
- text_rect.y1 += dy; text_rect.y2 += dy;
-
- /* ��ͼ */
- rect = text_rect;
- rect.x2 += 2; rect.y2 += 2;
- rtgui_dc_blit(dc_buffer, NULL, dc, &rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
-}
-
-static rt_bool_t animation_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- if (event->type == RTGUI_EVENT_PAINT)
- {
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
-
- /* ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view�Ȼ�ͼ */
- rtgui_view_event_handler(widget, event);
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- return RT_FALSE;
-
- /* ���demo view������ͼ������ */
- demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
-
- /* ��ͼ */
- rect = text_rect;
- rtgui_rect_inflate(&rect, +1);
- rtgui_dc_blit(dc_buffer, NULL, dc, &rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
- }
- else
- {
- /* ����Ĭ�ϵ��¼��������� */
- return rtgui_view_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-rtgui_view_t *demo_view_buffer_animation(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
-
- view = demo_view(workbench, "DC ����������");
- if (view != RT_NULL)
- rtgui_widget_set_event_handler(RTGUI_WIDGET(view), animation_event_handler);
-
- rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "���嶯��", &text_rect);
- if (dc_buffer == RT_NULL)
- {
- rtgui_rect_t rect;
-
- rect.x1 = 0; rect.x2 = rtgui_rect_width(text_rect) + 2;
- rect.y1 = 0; rect.y2 = rtgui_rect_height(text_rect) + 2;
-
- /* ���� DC Buffer���� 50���� 50 */
- dc_buffer = rtgui_dc_buffer_create(rtgui_rect_width(rect), rtgui_rect_height(rect));
- RTGUI_DC_FC(dc_buffer) = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view));
- rtgui_dc_fill_rect(dc_buffer, &rect);
- RTGUI_DC_FC(dc_buffer) = black;
- rect.x1 = 1; rect.y1 = 1;
- rtgui_dc_draw_text(dc_buffer, "���嶯��", &rect);
- }
-
- /* ������ʱ���Դ������� */
- timer = rtgui_timer_create(1, RT_TIMER_FLAG_PERIODIC, timeout, (void*)view);
- rtgui_timer_start(timer);
-
- return view;
-}
+#include <rtgui/dc.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/container.h> +#include "demo_view.h" + +/* + * ֱ����DC�ϻ�ͼ��ʵ�ֶ���Ч�� + * + * �����������ڶ�ʱ�������ģ������·�����ʾ���� + * "�����ҷ�" + */ +static rt_int8_t dx = 1, dy = 1; +static rtgui_rect_t text_rect; +static rtgui_timer_t *timer; +static struct rtgui_dc *dc_buffer; +static void timeout(struct rtgui_timer* timer, void* parameter) +{ + struct rtgui_dc* dc; + rtgui_rect_t rect; + rtgui_widget_t *widget; + + /* �ؼ�(view)ͨ��parameter�������ݸ���ʱ�� */ + widget = (rtgui_widget_t*)parameter; + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + return ; + + /* ���demo view������ͼ��������Ҫ�����жϱ߽� */ + demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect); + rect.y2 -= 5; + + /* �ж��Ƿ��ǵ�һ�λ�ͼ */ + if ((text_rect.x1 == 0) && (text_rect.y1 == 0)) + { + rtgui_rect_moveto(&text_rect, rect.x1, rect.y1); + } + + /* ����dx��dy */ + if (text_rect.x2 >= rect.x2) dx = -1; + if (text_rect.x1 < rect.x1) dx = 1; + if (text_rect.y2 >= rect.y2) dy = -1; + if (text_rect.y1 < rect.y1) dy = 1; + + /* �ƶ��ı����λ�� */ + text_rect.x1 += dx; text_rect.x2 += dx; + text_rect.y1 += dy; text_rect.y2 += dy; + + /* ��ͼ */ + rect = text_rect; + rect.x2 += 2; rect.y2 += 2; + rtgui_dc_blit(dc_buffer, NULL, dc, &rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); +} + +static rt_bool_t animation_event_handler(struct rtgui_object *object, rtgui_event_t *event) +{ + struct rtgui_widget *widget = RTGUI_WIDGET(object); + + if (event->type == RTGUI_EVENT_PAINT) + { + struct rtgui_dc* dc; + rtgui_rect_t rect; + + /* ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view�Ȼ�ͼ */ + rtgui_container_event_handler(object, event); + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + return RT_FALSE; + + /* ���demo view������ͼ������ */ + demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect); + + /* ��ͼ */ + rect = text_rect; + rtgui_rect_inflate(&rect, +1); + rtgui_dc_blit(dc_buffer, NULL, dc, &rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); + } + else + { + /* ����Ĭ�ϵ��¼��������� */ + return rtgui_container_event_handler(object, event); + } + + return RT_FALSE; +} + +static rt_bool_t animation_on_show(struct rtgui_object *object, struct rtgui_event *event) +{ + rt_kprintf("buffer animation on show\n"); + rtgui_timer_start(timer); + + return RT_TRUE; +} + +static rt_bool_t animation_on_hide(struct rtgui_object *object, struct rtgui_event *event) +{ + rt_kprintf("buffer animation on hide\n"); + rtgui_timer_stop(timer); + + return RT_TRUE; +} + +struct rtgui_container *demo_view_buffer_animation(void) +{ + struct rtgui_container *container; + + container= demo_view("DC ����������"); + if (container!= RT_NULL) + rtgui_object_set_event_handler(RTGUI_OBJECT(container), animation_event_handler); + + rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(container)), "���嶯��", &text_rect); + if (dc_buffer == RT_NULL) + { + rtgui_rect_t rect; + + rect.x1 = 0; rect.x2 = rtgui_rect_width(text_rect) + 2; + rect.y1 = 0; rect.y2 = rtgui_rect_height(text_rect) + 2; + + /* ���� DC Buffer���� 50���� 50 */ + dc_buffer = rtgui_dc_buffer_create(rtgui_rect_width(rect), rtgui_rect_height(rect)); + RTGUI_DC_FC(dc_buffer) = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(container)); + rtgui_dc_fill_rect(dc_buffer, &rect); + RTGUI_DC_FC(dc_buffer) = black; + rect.x1 = 1; rect.y1 = 1; + rtgui_dc_draw_text(dc_buffer, "���嶯��", &rect); + } + + /* ������ʱ���Դ������� */ + timer = rtgui_timer_create(1, RT_TIMER_FLAG_PERIODIC, timeout, (void*)container); + + rtgui_widget_set_onshow(RTGUI_WIDGET(container), animation_on_show); + rtgui_widget_set_onhide(RTGUI_WIDGET(container), animation_on_hide); + + return container; +} diff --git a/examples/gui/demo_view_button.c b/examples/gui/demo_view_button.c index d54a7bc065..70465384b0 100644 --- a/examples/gui/demo_view_button.c +++ b/examples/gui/demo_view_button.c @@ -1,84 +1,80 @@ -/*
- * 程序清单:button控件演示
- *
- * 这个例子会在创建出的view上添加几个不同类型的button控件
- */
-
-#include "demo_view.h"
-#include <rtgui/widgets/button.h>
-
-/* 创建用于演示button控件的视图 */
-rtgui_view_t* demo_view_button(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_button_t* button;
- rtgui_font_t* font;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "Button View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* 创建一个button控件 */
- button = rtgui_button_create("Red");
- /* 设置label控件的前景色为红色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = red;
- /* 设置button的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- /* view是一个container控件,调用add_child方法添加这个button控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个button控件 */
- button = rtgui_button_create("Blue");
- /* 设置label控件的前景色为蓝色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = blue;
- /* 设置button的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- /* view是一个container控件,调用add_child方法添加这个button控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个button控件 */
- button = rtgui_button_create("12 font");
- /* 设置字体为12点阵的asc字体 */
- font = rtgui_font_refer("asc", 12);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(button)) = font;
- /* 设置button的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- /* view是一个container控件,调用add_child方法添加这个button控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个button控件 */
- button = rtgui_button_create("16 font");
- /* 设置字体为16点阵的asc字体 */
- font = rtgui_font_refer("asc", 16);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(button)) = font;
- /* 设置button的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- /* view是一个container控件,调用add_child方法添加这个button控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
-
- return view;
-}
+/* + * 程序清单:button控件演示 + * + * 这个例子会在创建出的container上添加几个不同类型的button控件 + */ + +#include "demo_view.h" +#include <rtgui/widgets/button.h> + +/* 创建用于演示button控件的视图 */ +rtgui_container_t* demo_view_button(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_button_t* button; + rtgui_font_t* font; + + /* 先创建一个演示用的视图 */ + container = demo_view("Button View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* 创建一个button控件 */ + button = rtgui_button_create("Red"); + /* 设置label控件的前景色为红色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = red; + /* 设置button的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(button)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个button控件 */ + button = rtgui_button_create("Blue"); + /* 设置label控件的前景色为蓝色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = blue; + /* 设置button的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(button)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个button控件 */ + button = rtgui_button_create("12 font"); + /* 设置字体为12点阵的asc字体 */ + font = rtgui_font_refer("asc", 12); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(button)) = font; + /* 设置button的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(button)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个button控件 */ + button = rtgui_button_create("16 font"); + /* 设置字体为16点阵的asc字体 */ + font = rtgui_font_refer("asc", 16); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(button)) = font; + /* 设置button的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(button)); + + return container; +} diff --git a/examples/gui/demo_view_checkbox.c b/examples/gui/demo_view_checkbox.c index f5e4ddc85e..fa67cf6f4c 100644 --- a/examples/gui/demo_view_checkbox.c +++ b/examples/gui/demo_view_checkbox.c @@ -1,84 +1,80 @@ -/*
- * 程序清单:checkbox控件演示
- *
- * 这个例子会在创建出的view上添加几个checkbox控件
- */
-
-#include "demo_view.h"
-#include <rtgui/widgets/checkbox.h>
-
-/* 创建用于演示checkbox控件的视图 */
-rtgui_view_t* demo_view_checkbox(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_checkbox_t* checkbox;
- rtgui_font_t* font;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "CheckBox View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* 创建一个checkbox控件 */
- checkbox = rtgui_checkbox_create("Red",RT_TRUE);
- /* 设置前景色为红色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = red;
- /* 设置checkbox的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
- /* view是一个container控件,调用add_child方法添加这个checkbox控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个checkbox控件 */
- checkbox = rtgui_checkbox_create("Blue",RT_TRUE);
- /* 设置前景色为蓝色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = blue;
- /* 设置checkbox的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
- /* view是一个container控件,调用add_child方法添加这个checkbox控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个checkbox控件 */
- checkbox = rtgui_checkbox_create("12 font",RT_TRUE);
- /* 设置字体为12点阵 */
- font = rtgui_font_refer("asc", 12);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(checkbox)) = font;
- /* 设置checkbox的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
- /* view是一个container控件,调用add_child方法添加这个checkbox控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个checkbox控件 */
- checkbox = rtgui_checkbox_create("16 font",RT_TRUE);
- /* 设置字体为16点阵 */
- font = rtgui_font_refer("asc", 16);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(checkbox)) = font;
- /* 设置checkbox的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect);
- /* view是一个container控件,调用add_child方法添加这个checkbox控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(checkbox));
-
- return view;
-}
+/* + * 程序清单:checkbox控件演示 + * + * 这个例子会在创建出的container上添加几个checkbox控件 + */ + +#include "demo_view.h" +#include <rtgui/widgets/checkbox.h> + +/* 创建用于演示checkbox控件的视图 */ +rtgui_container_t* demo_view_checkbox(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_checkbox_t* checkbox; + rtgui_font_t* font; + + /* 先创建一个演示用的视图 */ + container = demo_view("CheckBox View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* 创建一个checkbox控件 */ + checkbox = rtgui_checkbox_create("Red",RT_TRUE); + /* 设置前景色为红色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = red; + /* 设置checkbox的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(checkbox)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个checkbox控件 */ + checkbox = rtgui_checkbox_create("Blue",RT_TRUE); + /* 设置前景色为蓝色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = blue; + /* 设置checkbox的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(checkbox)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个checkbox控件 */ + checkbox = rtgui_checkbox_create("12 font",RT_TRUE); + /* 设置字体为12点阵 */ + font = rtgui_font_refer("asc", 12); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(checkbox)) = font; + /* 设置checkbox的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(checkbox)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个checkbox控件 */ + checkbox = rtgui_checkbox_create("16 font",RT_TRUE); + /* 设置字体为16点阵 */ + font = rtgui_font_refer("asc", 16); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(checkbox)) = font; + /* 设置checkbox的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(checkbox), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(checkbox)); + + return container; +} diff --git a/examples/gui/demo_view_combobox.c b/examples/gui/demo_view_combobox.c index a71a95069c..36fb4d1375 100644 --- a/examples/gui/demo_view_combobox.c +++ b/examples/gui/demo_view_combobox.c @@ -1,40 +1,40 @@ -/*
- * 程序清单:label控件演示
- *
- * 这个例子会在创建出的view上添加几个不同类型的label控件
- */
-#include "demo_view.h"
-#include <rtgui/widgets/combobox.h>
-
-struct rtgui_listbox_item items[] =
-{
- {"item 1", RT_NULL},
- {"item 2", RT_NULL},
- {"item 3", RT_NULL},
- {"item 4", RT_NULL},
- {"item 5", RT_NULL},
-};
-
-/* 创建用于演示combobox控件的视图 */
-rtgui_view_t* demo_view_combobox(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_combobox_t* box;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "ComboBox View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- box = rtgui_combobox_create(items, sizeof(items)/sizeof(items[0]), &rect);
- /* view是一个container控件,调用add_child方法添加这个box控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(box));
-
- return view;
-}
+/* + * 程序清单:label控件演示 + * + * 这个例子会在创建出的container上添加几个不同类型的label控件 + */ +#include "demo_view.h" +#include <rtgui/widgets/combobox.h> + +struct rtgui_listbox_item items[] = +{ + {"item 1", RT_NULL}, + {"item 2", RT_NULL}, + {"item 3", RT_NULL}, + {"item 4", RT_NULL}, + {"item 5", RT_NULL}, +}; + +/* 创建用于演示combobox控件的视图 */ +rtgui_container_t* demo_view_combobox(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_combobox_t* box; + + /* 先创建一个演示用的视图 */ + container = demo_view("ComboBox View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + box = rtgui_combobox_create(items, sizeof(items)/sizeof(items[0]), &rect); + /* container是一个container控件,调用add_child方法添加这个box控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(box)); + + return container; +} diff --git a/examples/gui/demo_view_dc.c b/examples/gui/demo_view_dc.c index 2ddfe4cd5b..f37d426e7b 100644 --- a/examples/gui/demo_view_dc.c +++ b/examples/gui/demo_view_dc.c @@ -1,190 +1,192 @@ -/*
- * �����嵥��DC������ʾ
- *
- * ������ӻ��ڴ�������view�Ͻ���DC��������ʾ
- */
-
-#include "demo_view.h"
-#include <rtgui/dc.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/slider.h>
-#include <rtgui/image_hdc.h>
-
-#include "play.hdh"
-#include "stop.hdh"
-struct rtgui_image_hdcmm play_image = RTGUI_IMAGE_HDC_DEF(2, 0x1c, 0x16, play_hdh);
-struct rtgui_image_hdcmm stop_image = RTGUI_IMAGE_HDC_DEF(2, 0x1c, 0x16, stop_hdh);
-
-/*
- * view���¼���������
- */
-rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- /* ����PAINT�¼����д��� */
- if (event->type == RTGUI_EVENT_PAINT)
- {
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
- // const int vx[] = {20, 50, 60, 45, 60, 20};
- // const int vy[] = {150, 50, 90, 60, 45, 50};
-
- /*
- * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view
- * �Ȼ�ͼ
- */
- rtgui_view_event_handler(widget, event);
-
- /************************************************************************/
- /* �������DC�IJ��� */
- /************************************************************************/
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- if (dc == RT_NULL)
- return RT_FALSE;
-
- /* ���demo view������ͼ������ */
- demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
-
- RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL;
- /* ��ʾGUI�İ汾��Ϣ */
-#ifdef RTGUI_USING_SMALL_SIZE
- rtgui_dc_draw_text(dc, "RT-Thread/GUIС�Ͱ汾", &rect);
-#else
- rtgui_dc_draw_text(dc, "RT-Thread/GUI���汾", &rect);
-#endif
-
- {
- rtgui_rect_t rect = {0, 0, 0x1c, 0x16};
- rtgui_rect_moveto(&rect, 80, 80);
- rtgui_image_blit((rtgui_image_t*)&play_image, dc, &rect);
-
- rect.x1 = 0; rect.y1 = 0;
- rect.x2 = 0x1c; rect.y2 = 0x16;
- rtgui_rect_moveto(&rect, 130, 80);
- rtgui_image_blit((rtgui_image_t*)&stop_image, dc, &rect);
- }
- /* ����һ��Բ�� */
- RTGUI_DC_FC(dc) = red;
- rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10);
-
- /* ���һ��Բ�� */
- RTGUI_DC_FC(dc) = green;
- rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10);
-#if 0
- /* ��һ��Բ�Ǿ��� */
- rect.x1 = 150;
- rect.y1 = 180;
- rect.x2 = 210;
- rect.y2 = 260;
- RTGUI_DC_FC(dc) = RTGUI_RGB(25, 70, 150);
- rtgui_dc_draw_round_rect(dc, &rect, 10);
-
- rect.x1 = 160;
- rect.y1 = 190;
- rect.x2 = 200;
- rect.y2 = 250;
- RTGUI_DC_FC(dc) = RTGUI_RGB(170, 7, 80);
- rtgui_dc_fill_round_rect(dc, &rect, 7);
-
- /* ��һ��Բ�� */
- RTGUI_DC_FC(dc) = RTGUI_RGB(250, 120, 120);
- rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120);
-
- /* ��һ������Բ�� */
- RTGUI_DC_FC(dc) = RTGUI_RGB(150, 23, 100);
- rtgui_dc_draw_annulus(dc, 180, 170, 30, 50, 210, 330);
-
- /* ����� */
- RTGUI_DC_FC(dc) = blue;
- rtgui_dc_draw_polygon(dc, vx, vy, 6);
-
-#endif
- RTGUI_DC_FC(dc) = blue;
-
- /* ���Ʋ�ͬ�ı߿� */
- {
- rtgui_rect_t rect = {0, 0, 16, 16};
- rtgui_rect_moveto(&rect, 30, 120);
-
- rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE);
- rect.x1 += 20;
- rect.x2 += 20 + 50;
- rtgui_dc_draw_text(dc, "raise", &rect);
- rect.x1 -= 20;
- rect.x2 -= 20 + 50;
- rect.y1 += 20;
- rect.y2 += 20;
-
- rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SIMPLE);
- rect.x1 += 20;
- rect.x2 += 20 + 50;
- rtgui_dc_draw_text(dc, "simple", &rect);
- rect.x1 -= 20;
- rect.x2 -= 20 + 50;
- rect.y1 += 20;
- rect.y2 += 20;
-
- rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
- rect.x1 += 20;
- rect.x2 += 20 + 50;
- rtgui_dc_draw_text(dc, "sunken", &rect);
- rect.x1 -= 20;
- rect.x2 -= 20 + 50;
- rect.y1 += 20;
- rect.y2 += 20;
-
- rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX);
- rect.x1 += 20;
- rect.x2 += 20 + 50;
- rtgui_dc_draw_text(dc, "box", &rect);
- rect.x1 -= 20;
- rect.x2 -= 20 + 50;
- rect.y1 += 20;
- rect.y2 += 20;
-
- rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC);
- rect.x1 += 20;
- rect.x2 += 20 + 50;
- rtgui_dc_draw_text(dc, "static", &rect);
- rect.x1 -= 20;
- rect.x2 -= 20 + 50;
- rect.y1 += 20;
- rect.y2 += 20;
-
- rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_EXTRA);
- rect.x1 += 20;
- rect.x2 += 20 + 50;
- rtgui_dc_draw_text(dc, "extera", &rect);
- rect.x1 -= 20;
- rect.x2 -= 20 + 50;
- rect.y1 += 20;
- rect.y2 += 20;
- }
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
- }
- else
- {
- /* �����¼�������Ĭ�ϵ��¼��������� */
- return rtgui_view_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-/* ��������DC������ʾ�õ���ͼ */
-rtgui_view_t *demo_view_dc(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
-
- view = demo_view(workbench, "DC Demo");
- if (view != RT_NULL)
- /* ���ó��Լ����¼��������� */
- rtgui_widget_set_event_handler(RTGUI_WIDGET(view), dc_event_handler);
-
- return view;
-}
+/* + * �����嵥��DC������ʾ + * + * ������ӻ��ڴ�������view�Ͻ���DC��������ʾ + */ + +#include "demo_view.h" +#include <rtgui/dc.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/slider.h> +#include <rtgui/image_hdc.h> + +#include "play.hdh" +#include "stop.hdh" +struct rtgui_image_hdcmm play_image = RTGUI_IMAGE_HDC_DEF(2, 0x1c, 0x16, play_hdh); +struct rtgui_image_hdcmm stop_image = RTGUI_IMAGE_HDC_DEF(2, 0x1c, 0x16, stop_hdh); + +/* + * view���¼��������� + */ +rt_bool_t dc_event_handler(struct rtgui_object* object, rtgui_event_t *event) +{ + struct rtgui_widget *widget = RTGUI_WIDGET(object); + + /* ����PAINT�¼����д��� */ + if (event->type == RTGUI_EVENT_PAINT) + { + struct rtgui_dc* dc; + rtgui_rect_t rect; + const int vx[] = {20, 50, 60, 45, 60, 20}; + const int vy[] = {150, 50, 90, 60, 45, 50}; + + /* + * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view + * �Ȼ�ͼ + */ + rtgui_container_event_handler(RTGUI_OBJECT(widget), event); + + /************************************************************************/ + /* �������DC�IJ��� */ + /************************************************************************/ + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + if (dc == RT_NULL) + return RT_FALSE; + + /* ���demo view������ͼ������ */ + demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect); + + RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL; + /* ��ʾGUI�İ汾��Ϣ */ +#ifdef RTGUI_USING_SMALL_SIZE + rtgui_dc_draw_text(dc, "RT-Thread/GUIС�Ͱ汾", &rect); +#else + rtgui_dc_draw_text(dc, "RT-Thread/GUI���汾", &rect); +#endif + + { + rtgui_rect_t rect = {0, 0, 0x1c, 0x16}; + rtgui_rect_moveto(&rect, 80, 80); + rtgui_image_blit((rtgui_image_t*)&play_image, dc, &rect); + + rect.x1 = 0; rect.y1 = 0; + rect.x2 = 0x1c; rect.y2 = 0x16; + rtgui_rect_moveto(&rect, 130, 80); + rtgui_image_blit((rtgui_image_t*)&stop_image, dc, &rect); + } + /* ����һ��Բ�� */ + RTGUI_DC_FC(dc) = red; + rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10); + + /* ���һ��Բ�� */ + RTGUI_DC_FC(dc) = green; + rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10); +#if 0 + /* ��һ��Բ�Ǿ��� */ + rect.x1 = 150; + rect.y1 = 180; + rect.x2 = 210; + rect.y2 = 260; + RTGUI_DC_FC(dc) = RTGUI_RGB(25, 70, 150); + rtgui_dc_draw_round_rect(dc, &rect, 10); + + rect.x1 = 160; + rect.y1 = 190; + rect.x2 = 200; + rect.y2 = 250; + RTGUI_DC_FC(dc) = RTGUI_RGB(170, 7, 80); + rtgui_dc_fill_round_rect(dc, &rect, 7); + + /* ��һ��Բ�� */ + RTGUI_DC_FC(dc) = RTGUI_RGB(250, 120, 120); + rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120); + + /* ��һ������Բ�� */ + RTGUI_DC_FC(dc) = RTGUI_RGB(150, 23, 100); + rtgui_dc_draw_annulus(dc, 180, 170, 30, 50, 210, 330); + + /* ����� */ + RTGUI_DC_FC(dc) = blue; + rtgui_dc_draw_polygon(dc, vx, vy, 6); + +#endif + RTGUI_DC_FC(dc) = blue; + + /* ���Ʋ�ͬ�ı߿� */ + { + rtgui_rect_t rect = {0, 0, 16, 16}; + rtgui_rect_moveto(&rect, 30, 120); + + rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE); + rect.x1 += 20; + rect.x2 += 20 + 50; + rtgui_dc_draw_text(dc, "raise", &rect); + rect.x1 -= 20; + rect.x2 -= 20 + 50; + rect.y1 += 20; + rect.y2 += 20; + + rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SIMPLE); + rect.x1 += 20; + rect.x2 += 20 + 50; + rtgui_dc_draw_text(dc, "simple", &rect); + rect.x1 -= 20; + rect.x2 -= 20 + 50; + rect.y1 += 20; + rect.y2 += 20; + + rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN); + rect.x1 += 20; + rect.x2 += 20 + 50; + rtgui_dc_draw_text(dc, "sunken", &rect); + rect.x1 -= 20; + rect.x2 -= 20 + 50; + rect.y1 += 20; + rect.y2 += 20; + + rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX); + rect.x1 += 20; + rect.x2 += 20 + 50; + rtgui_dc_draw_text(dc, "box", &rect); + rect.x1 -= 20; + rect.x2 -= 20 + 50; + rect.y1 += 20; + rect.y2 += 20; + + rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC); + rect.x1 += 20; + rect.x2 += 20 + 50; + rtgui_dc_draw_text(dc, "static", &rect); + rect.x1 -= 20; + rect.x2 -= 20 + 50; + rect.y1 += 20; + rect.y2 += 20; + + rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_EXTRA); + rect.x1 += 20; + rect.x2 += 20 + 50; + rtgui_dc_draw_text(dc, "extera", &rect); + rect.x1 -= 20; + rect.x2 -= 20 + 50; + rect.y1 += 20; + rect.y2 += 20; + } + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); + } + else + { + /* �����¼�������Ĭ�ϵ��¼��������� */ + return rtgui_container_event_handler(object, event); + } + + return RT_FALSE; +} + +/* ��������DC������ʾ�õ���ͼ */ +rtgui_container_t *demo_view_dc(void) +{ + rtgui_container_t *view; + + view = demo_view("DC Demo"); + if (view != RT_NULL) + /* ���ó��Լ����¼��������� */ + rtgui_object_set_event_handler(RTGUI_OBJECT(view), dc_event_handler); + + return view; +} diff --git a/examples/gui/demo_view_dc_buffer.c b/examples/gui/demo_view_dc_buffer.c index 07ce99bcbc..11770dcedc 100644 --- a/examples/gui/demo_view_dc_buffer.c +++ b/examples/gui/demo_view_dc_buffer.c @@ -1,83 +1,84 @@ -/*
- * �����嵥��DC Buffer��ʾ
- *
- * ������ӻ��ڴ�������view�Ͻ���DC Buffer����ʾ
- */
-
-#include "demo_view.h"
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/slider.h>
-#include <rtgui/image.h>
-
-// static rtgui_image_t *background;
-static struct rtgui_dc *dc_buffer;
-
-/*
- * view���¼���������
- */
-static rt_bool_t dc_buffer_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
-
- /* ����PAINT�¼����д��� */
- if (event->type == RTGUI_EVENT_PAINT)
- {
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
-
- /*
- * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view
- * �Ȼ�ͼ
- */
- rtgui_view_event_handler(widget, event);
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- if (dc == RT_NULL)
- return RT_FALSE;
-
- /* ���demo view������ͼ������ */
- demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
-
- rect.x1 += 10;
- rect.y1 += 10;
- rtgui_dc_blit(dc_buffer, NULL, dc, &rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
- }
- else
- {
- /* �����¼�������Ĭ�ϵ��¼��������� */
- return rtgui_view_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-/* ��������DC Buffer������ʾ�õ���ͼ */
-rtgui_view_t *demo_view_dc_buffer(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
-
- if (dc_buffer == RT_NULL)
- {
- rtgui_rect_t rect = {0, 0, 50, 50};
-
- /* ���� DC Buffer���� 50���� 50 */
- dc_buffer = rtgui_dc_buffer_create(50, 50);
- RTGUI_DC_FC(dc_buffer) = blue;
- rtgui_dc_fill_rect(dc_buffer, &rect);
-
- RTGUI_DC_FC(dc_buffer) = red;
- rtgui_dc_draw_circle(dc_buffer, 25, 25, 10);
- }
-
- view = demo_view(workbench, "����DC��ʾ");
- if (view != RT_NULL)
- /* ���ó��Լ����¼��������� */
- rtgui_widget_set_event_handler(RTGUI_WIDGET(view), dc_buffer_event_handler);
-
- return view;
-}
+/* + * �����嵥��DC Buffer��ʾ + * + * ������ӻ��ڴ�������view�Ͻ���DC Buffer����ʾ + */ + +#include "demo_view.h" +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/slider.h> +#include <rtgui/image.h> + +static rtgui_image_t *background; +static struct rtgui_dc *dc_buffer; + +/* + * view���¼��������� + */ +static rt_bool_t dc_buffer_event_handler(struct rtgui_object* object, rtgui_event_t *event) +{ + struct rtgui_widget *widget = RTGUI_WIDGET(object); + + /* ����PAINT�¼����д��� */ + if (event->type == RTGUI_EVENT_PAINT) + { + struct rtgui_dc* dc; + rtgui_rect_t rect; + + /* + * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view + * �Ȼ�ͼ + */ + rtgui_container_event_handler(object, event); + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + if (dc == RT_NULL) + return RT_FALSE; + + /* ���demo view������ͼ������ */ + demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect); + + rect.x1 += 10; + rect.y1 += 10; + rtgui_dc_blit(dc_buffer, NULL, dc, &rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); + } + else + { + /* �����¼�������Ĭ�ϵ��¼��������� */ + return rtgui_container_event_handler(object, event); + } + + return RT_FALSE; +} + +/* ��������DC Buffer������ʾ�õ���ͼ */ +rtgui_container_t *demo_view_dc_buffer() +{ + rtgui_container_t *view; + + if (dc_buffer == RT_NULL) + { + rtgui_rect_t rect = {0, 0, 50, 50}; + + /* ���� DC Buffer���� 50���� 50 */ + dc_buffer = rtgui_dc_buffer_create(50, 50); + RTGUI_DC_FC(dc_buffer) = blue; + rtgui_dc_fill_rect(dc_buffer, &rect); + + RTGUI_DC_FC(dc_buffer) = red; + rtgui_dc_draw_circle(dc_buffer, 25, 25, 10); + } + + view = demo_view("����DC��ʾ"); + if (view != RT_NULL) + /* ���ó��Լ����¼��������� */ + rtgui_object_set_event_handler(RTGUI_OBJECT(view), dc_buffer_event_handler); + + return view; +} diff --git a/examples/gui/demo_view_image.c b/examples/gui/demo_view_image.c index 3e8b7e2f33..ba866424da 100644 --- a/examples/gui/demo_view_image.c +++ b/examples/gui/demo_view_image.c @@ -1,131 +1,126 @@ -/*
- * �����嵥��DC����ʾͼ����ʾ
- *
- * ������ӻ��ڴ�������view����ʾͼ��
- */
-
-#include "demo_view.h"
-#include <rtgui/widgets/button.h>
-#include <rtgui/widgets/filelist_view.h>
-#include <string.h>
-
-#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
-static rtgui_image_t* image = RT_NULL;
-static rtgui_view_t* _view = RT_NULL;
-
-/* ��ť�Ļص����� */
-static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_filelist_view_t *view;
- rtgui_workbench_t *workbench;
- rtgui_rect_t rect;
-
- /* ��ö����workbench */
- workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
- rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
-
- /* WIN32ƽ̨�Ϻ���ʵ�豸�ϵij�ʼ·������ */
-#ifdef _WIN32
- view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
-#else
- view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
-#endif
- /* ģ̬��ʾһ���ļ��б���ͼ�����ṩ���û�ѡ��ͼ���ļ� */
- if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
- {
- char path[32], image_type[8];
-
- /* �����ļ�·���ı�ǩ */
- rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
- if (image != RT_NULL)
- {
- rtgui_image_destroy(image);
- image = RT_NULL;
- }
-
- rt_memset(image_type, 0, sizeof(image_type));
-
- /* ���ͼ������� */
- if (rt_strstr(path, ".bmp") != RT_NULL ||
- rt_strstr(path, ".BMP") != RT_NULL)
- strcat(image_type, "bmp");
- if (rt_strstr(path, ".png") != RT_NULL ||
- rt_strstr(path, ".PNG") != RT_NULL)
- strcat(image_type, "png");
- if (rt_strstr(path, ".jpg") != RT_NULL ||
- rt_strstr(path, ".JPG") != RT_NULL)
- strcat(image_type, "jpeg");
- if (rt_strstr(path, ".hdc") != RT_NULL ||
- rt_strstr(path, ".HDC") != RT_NULL)
- strcat(image_type, "hdc");
-
- /* ���ͼ���ļ���Ч��������Ӧ��rtgui_image���� */
- if (image_type[0] != '\0')
- image = rtgui_image_create_from_file(image_type, path, RT_TRUE);
- }
-
- /* ɾ�� �ļ��б� ��ͼ */
- rtgui_view_destroy(RTGUI_VIEW(view));
- rtgui_view_show(_view, RT_FALSE);
-}
-
-/* ��ʾ��ͼ���¼��������� */
-static rt_bool_t demo_view_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- rt_bool_t result;
-
- /* �ȵ���Ĭ�ϵ��¼���������(����ֻ����PAINT�¼�������ʾ��ͼ���б�����һЩ�ؼ�) */
- result = rtgui_view_event_handler(widget, event);
-
- if (event->type == RTGUI_EVENT_PAINT)
- {
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL)
- /* ��������������DC������(����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ���) */
- return RT_FALSE;
-
- /* ���demo view������ͼ������ */
- demo_view_get_rect(RTGUI_VIEW(widget), &rect);
-
- /* ���ͼ����ʾ���� */
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 30;
-
- if (image != RT_NULL)
- rtgui_image_blit(image, dc, &rect);
-
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
- }
-
- return result;
-}
-
-/* ����������ʾͼ�����ʾ��ͼ */
-rtgui_view_t* demo_view_image(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_button_t* open_btn;
-
- /* �ȴ���һ����ʾ��ͼ */
- _view = demo_view(workbench, "ͼ����ʾ");
- if (_view != RT_NULL)
- /* ����Ĭ�ϵ��¼�����������demo_view_event_handler���� */
- rtgui_widget_set_event_handler(RTGUI_WIDGET(_view), demo_view_event_handler);
-
- /* ����һ����ť */
- demo_view_get_rect(_view, &rect);
- rect.x1 += 5; rect.x2 = rect.x1 + 120;
- rect.y2 = rect.y1 + 20;
- open_btn = rtgui_button_create("��ͼ���ļ�");
- rtgui_container_add_child(RTGUI_CONTAINER(_view), RTGUI_WIDGET(open_btn));
- rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
- rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
-
- return _view;
-}
-#endif
+/* + * �����嵥��DC����ʾͼ����ʾ + * + * ������ӻ��ڴ�������container����ʾͼ�� + */ + +#include "demo_view.h" +#include <rtgui/widgets/button.h> +#include <rtgui/widgets/filelist_view.h> +#include <string.h> + +static rtgui_image_t* image = RT_NULL; +static rtgui_container_t* _container = RT_NULL; + +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +/* ��ť�Ļص����� */ +static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_filelist_view_t *filelist; + struct rtgui_rect rect = {0, 100, 240, 280}; + + /* WIN32ƽ̨�Ϻ���ʵ�豸�ϵij�ʼ·������ */ +#ifdef _WIN32 + filelist = rtgui_filelist_view_create("e:\\", "*.*", &rect); +#else + filelist = rtgui_filelist_view_create("/", "*.*", &rect); +#endif + /* ģ̬��ʾһ���ļ��б���ͼ�����ṩ���û�ѡ��ͼ���ļ� */ + if (rtgui_container_show(RTGUI_CONTAINER(filelist), RT_TRUE) == RTGUI_MODAL_OK) + { + char path[32], image_type[8]; + + /* �����ļ�·���ı�ǩ */ + rtgui_filelist_view_get_fullpath(filelist, path, sizeof(path)); + if (image != RT_NULL) + { + rtgui_image_destroy(image); + image = RT_NULL; + } + + rt_memset(image_type, 0, sizeof(image_type)); + + /* ���ͼ������� */ + if (rt_strstr(path, ".bmp") != RT_NULL || + rt_strstr(path, ".BMP") != RT_NULL) + strcat(image_type, "bmp"); + if (rt_strstr(path, ".png") != RT_NULL || + rt_strstr(path, ".PNG") != RT_NULL) + strcat(image_type, "png"); + if (rt_strstr(path, ".jpg") != RT_NULL || + rt_strstr(path, ".JPG") != RT_NULL) + strcat(image_type, "jpeg"); + if (rt_strstr(path, ".hdc") != RT_NULL || + rt_strstr(path, ".HDC") != RT_NULL) + strcat(image_type, "hdc"); + + /* ���ͼ���ļ���Ч��������Ӧ��rtgui_image���� */ + if (image_type[0] != '\0') + image = rtgui_image_create_from_file(image_type, path, RT_TRUE); + } + + /* ɾ�� �ļ��б� ��ͼ */ + rtgui_container_destroy(RTGUI_CONTAINER(filelist)); + rtgui_container_show(_container, RT_FALSE); +} + +/* ��ʾ��ͼ���¼��������� */ +static rt_bool_t demo_view_event_handler(rtgui_widget_t* widget, rtgui_event_t *event) +{ + rt_bool_t result; + + /* �ȵ���Ĭ�ϵ��¼���������(����ֻ����PAINT�¼�������ʾ��ͼ���б�����һЩ�ؼ�) */ + result = rtgui_container_event_handler(widget, event); + + if (event->type == RTGUI_EVENT_PAINT) + { + struct rtgui_dc* dc; + rtgui_rect_t rect; + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + if (dc == RT_NULL) + /* ��������������DC������(����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ���) */ + return RT_FALSE; + + /* ���demo container������ͼ������ */ + demo_view_get_rect(RTGUI_CONTAINER(widget), &rect); + + /* ���ͼ����ʾ���� */ + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 30; + + if (image != RT_NULL) + rtgui_image_blit(image, dc, &rect); + + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); + } + + return result; +} + +/* ����������ʾͼ�����ʾ��ͼ */ +rtgui_container_t* demo_view_image(void) +{ + rtgui_rect_t rect; + rtgui_button_t* open_btn; + + /* �ȴ���һ����ʾ��ͼ */ + _container = demo_view("ͼ����ʾ"); + if (_container != RT_NULL) + /* ����Ĭ�ϵ��¼�����������demo_view_event_handler���� */ + rtgui_object_set_event_handler(RTGUI_WIDGET(_container), demo_view_event_handler); + + /* ����һ����ť */ + demo_view_get_rect(_container, &rect); + rect.x1 += 5; rect.x2 = rect.x1 + 120; + rect.y2 = rect.y1 + 20; + open_btn = rtgui_button_create("��ͼ���ļ�"); + rtgui_container_add_child(RTGUI_CONTAINER(_container), RTGUI_WIDGET(open_btn)); + rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect); + rtgui_button_set_onbutton(open_btn, open_btn_onbutton); + + return _container; +} +#endif diff --git a/examples/gui/demo_view_instrument_panel.c b/examples/gui/demo_view_instrument_panel.c index a863fec2b6..d82ca28433 100644 --- a/examples/gui/demo_view_instrument_panel.c +++ b/examples/gui/demo_view_instrument_panel.c @@ -1,7 +1,7 @@ /* * �����嵥��DC������ʾ * - * ������ӻ��ڴ�������view�Ͻ���DC��������ʾ + * ������ӻ��ڴ�������container�Ͻ���DC��������ʾ */ #include "demo_view.h" @@ -13,10 +13,11 @@ #include <math.h> /* - * view���¼��������� + * container���¼��������� */ -rt_bool_t instrument_panel_event_handler(rtgui_widget_t* widget, rtgui_event_t *event) +rt_bool_t instrument_panel_event_handler(struct rtgui_object *object, rtgui_event_t *event) { + struct rtgui_widget *widget = RTGUI_WIDGET(object); char ac[4]; int i; int x0 = 120; @@ -33,10 +34,10 @@ rt_bool_t instrument_panel_event_handler(rtgui_widget_t* widget, rtgui_event_t * const int arrowy[] = {170-5, 170+5, 170}; /* - * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view + * ��Ϊ�õ���demo container�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo container * �Ȼ�ͼ */ - rtgui_view_event_handler(widget, event); + rtgui_container_event_handler(RTGUI_OBJECT(widget), event); /************************************************************************/ /* �������DC�IJ��� */ @@ -48,8 +49,8 @@ rt_bool_t instrument_panel_event_handler(rtgui_widget_t* widget, rtgui_event_t * if (dc == RT_NULL) return RT_FALSE; - /* ���demo view������ͼ������ */ - demo_view_get_rect(RTGUI_VIEW(widget), &rect); + /* ���demo container������ͼ������ */ + demo_view_get_rect(RTGUI_CONTAINER(widget), &rect); RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL; /* ��ʾGUI�İ汾��Ϣ */ @@ -128,21 +129,21 @@ rt_bool_t instrument_panel_event_handler(rtgui_widget_t* widget, rtgui_event_t * else { /* �����¼�������Ĭ�ϵ��¼��������� */ - return rtgui_view_event_handler(widget, event); + return rtgui_container_event_handler(RTGUI_OBJECT(widget), event); } return RT_FALSE; } /* ��������DC������ʾ�õ���ͼ */ -rtgui_view_t *demo_view_instrument_panel(rtgui_workbench_t* workbench) +rtgui_container_t *demo_view_instrument_panel(void) { - rtgui_view_t *view; + rtgui_container_t *container; - view = demo_view(workbench, "instrument panel Demo"); - if (view != RT_NULL) + container = demo_view("instrument panel Demo"); + if (container != RT_NULL) /* ���ó��Լ����¼��������� */ - rtgui_widget_set_event_handler(RTGUI_WIDGET(view), instrument_panel_event_handler); + rtgui_object_set_event_handler(RTGUI_OBJECT(container), instrument_panel_event_handler); - return view; + return container; } diff --git a/examples/gui/demo_view_label.c b/examples/gui/demo_view_label.c index 1c6b560082..348437dec0 100644 --- a/examples/gui/demo_view_label.c +++ b/examples/gui/demo_view_label.c @@ -1,104 +1,104 @@ -/*
- * 程序清单:label控件演示
- *
- * 这个例子会在创建出的view上添加几个不同类型的label控件
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-
-/* 创建用于演示label控件的视图 */
-rtgui_view_t* demo_view_label(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_label_t* label;
- rtgui_font_t* font;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "Label View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- label = rtgui_label_create("Red Left");
- /* 设置label控件上的文本对齐方式为:左对齐 */
- RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
- /* 设置label控件的前景色为红色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = red;
- /* 设置label的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view是一个container控件,调用add_child方法添加这个label控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- label = rtgui_label_create("Blue Right");
- /* 设置label控件上的文本对齐方式为:右对齐 */
- RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_RIGHT;
- /* 设置label控件的前景色为蓝色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue;
- /* 设置label的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view是一个container控件,调用add_child方法添加这个label控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- label = rtgui_label_create("Green Center");
- /* 设置label控件的前景色为绿色 */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = green;
- /* 设置label控件上的文本对齐方式为:右对齐 */
- RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_CENTER_HORIZONTAL;
- /* 设置label的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view是一个container控件,调用add_child方法添加这个label控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5 + 25 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- label = rtgui_label_create("12 font");
- /* 设置字体为12点阵的asc字体 */
- font = rtgui_font_refer("asc", 12);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
- /* 设置label的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view是一个container控件,调用add_child方法添加这个label控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.y1 += 5 + 25 + 25 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- label = rtgui_label_create("16 font");
- /* 设置字体为16点阵的asc字体 */
- font = rtgui_font_refer("asc", 16);
- RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
- /* 设置label的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view是一个container控件,调用add_child方法添加这个label控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- return view;
-}
-
+/* + * 程序清单:label控件演示 + * + * 这个例子会在创建出的container上添加几个不同类型的label控件 + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> + +/* 创建用于演示label控件的视图 */ +rtgui_container_t* demo_view_label(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_label_t* label; + rtgui_font_t* font; + + /* 先创建一个演示用的视图 */ + container = demo_view("Label View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + label = rtgui_label_create("Red Left"); + /* 设置label控件上的文本对齐方式为:左对齐 */ + RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT; + /* 设置label控件的前景色为红色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = red; + /* 设置label的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container是一个container控件,调用add_child方法添加这个label控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + label = rtgui_label_create("Blue Right"); + /* 设置label控件上的文本对齐方式为:右对齐 */ + RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_RIGHT; + /* 设置label控件的前景色为蓝色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue; + /* 设置label的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container是一个container控件,调用add_child方法添加这个label控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + label = rtgui_label_create("Green Center"); + /* 设置label控件的前景色为绿色 */ + RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = green; + /* 设置label控件上的文本对齐方式为:右对齐 */ + RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_CENTER_HORIZONTAL; + /* 设置label的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container是一个container控件,调用add_child方法添加这个label控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5 + 25 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + label = rtgui_label_create("12 font"); + /* 设置字体为12点阵的asc字体 */ + font = rtgui_font_refer("asc", 12); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font; + /* 设置label的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container是一个container控件,调用add_child方法添加这个label控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.y1 += 5 + 25 + 25 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + label = rtgui_label_create("16 font"); + /* 设置字体为16点阵的asc字体 */ + font = rtgui_font_refer("asc", 16); + RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font; + /* 设置label的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container是一个container控件,调用add_child方法添加这个label控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + return container; +} + diff --git a/examples/gui/demo_view_listbox.c b/examples/gui/demo_view_listbox.c index b098d719ce..9236d58425 100644 --- a/examples/gui/demo_view_listbox.c +++ b/examples/gui/demo_view_listbox.c @@ -1,191 +1,191 @@ -/*
- * 程序清单:label控件演示
- *
- * 这个例子会在创建出的view上添加几个不同类型的label控件
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/listbox.h>
-
-static rtgui_image_t* item_icon = RT_NULL;
-static const char * image_xpm[] = {
- "16 16 106 2",
- " c None",
- ". c #D0C83F",
- "+ c #D0C840",
- "@ c #D0C030",
- "# c #D0B820",
- "$ c #D0B020",
- "% c #D0B01F",
- "& c #5F571F",
- "* c #F0F0C0",
- "= c #FFF8D0",
- "- c #FFF8C0",
- "; c #FFF8B0",
- "> c #FFF8A0",
- ", c #F0E870",
- "' c #707030",
- ") c #4F87EF",
- "! c #4F78C0",
- "~ c #5088E0",
- "{ c #5078C0",
- "] c #C0D0F0",
- "^ c #FFF8E0",
- "/ c #FFF090",
- "( c #F0E070",
- "_ c #6F97D0",
- ": c #C0D8FE",
- "< c #80A8F0",
- "[ c #7088D0",
- "} c #B0D0FF",
- "| c #90B0F0",
- "1 c #1040A0",
- "2 c #F0F080",
- "3 c #707040",
- "4 c #7098F0",
- "5 c #3068E0",
- "6 c #A0B8F0",
- "7 c #4070C0",
- "8 c #002880",
- "9 c #404040",
- "0 c #505050",
- "a c #F0F090",
- "b c #F0E860",
- "c c #F0D860",
- "d c #807840",
- "e c #2F5FC0",
- "f c #1050D0",
- "g c #1048B0",
- "h c #002870",
- "i c #C0C080",
- "j c #C0C070",
- "k c #F0F070",
- "l c #F0E060",
- "m c #E0D050",
- "n c #00277F",
- "o c #00287F",
- "p c #1F3F6F",
- "q c #1048C0",
- "r c #0040B0",
- "s c #204080",
- "t c #FFF890",
- "u c #F0D850",
- "v c #E0C840",
- "w c #807040",
- "x c #A0B06F",
- "y c #204880",
- "z c #2048A0",
- "A c #90A8C0",
- "B c #FFF080",
- "C c #F0D050",
- "D c #C0A830",
- "E c #6F682F",
- "F c #F0F0A0",
- "G c #E0D060",
- "H c #B0A040",
- "I c #D0B840",
- "J c #E0C040",
- "K c #D0B030",
- "L c #706820",
- "M c #5F581F",
- "N c #CFBF3F",
- "O c #FFF0A0",
- "P c #A09830",
- "Q c #A08820",
- "R c #908030",
- "S c #807830",
- "T c #707020",
- "U c #605820",
- "V c #6F672F",
- "W c #D0C040",
- "X c #F0E880",
- "Y c #907820",
- "Z c #B09820",
- "` c #B09010",
- " . c #B08820",
- ".. c #806820",
- "+. c #5F5F1F",
- "@. c #F0E080",
- "#. c #B09020",
- "$. c #C0B040",
- "%. c #A09030",
- "&. c #908020",
- "*. c #606020",
- "=. c #6F5F1F",
- "-. c #9F982F",
- ";. c #A0872F",
- ">. c #6F681F",
- ",. c #706020",
- " ",
- " . + + + @ @ # # $ % & ",
- " + * = = = = - ; > , ' ",
- " ) ! ~ { ] ^ = - - > / ( ' ",
- "_ : < { [ } | 1 - ; > > / 2 ( 3 ",
- "{ 4 5 1 6 7 5 8 9 0 a / , b c d ",
- "e f g h 8 8 g h i j / k l c m d ",
- " n o p q r s t 2 , l c u v w ",
- " x y z A B , l u C v D E ",
- " @ F > t k G H I J K L M ",
- " N @ O / 2 l P Q R S T U V ",
- " W m 2 X l I Y Z ` ...+. ",
- " W @.l u I R #.Z Y U M ",
- " $.G I $.%.R &.Y *.& =. ",
- " -.;.>.,.L L ,.& M ",
- " "};
-
-static struct rtgui_listbox_item items[] =
-{
- {"list #0", RT_NULL},
- {"list #1", RT_NULL},
- {"list #2", RT_NULL},
- {"list #3", RT_NULL},
-};
-
-static void on_items(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_listbox_t* box;
- /* get listbox */
- box = RTGUI_LISTBOX(widget);
-
- /* 打印当前的项 */
- rt_kprintf("current item: %d\n", box->current_item);
-}
-
-/* 创建用于演示label控件的视图 */
-rtgui_view_t* demo_view_listbox(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_label_t* label;
- rtgui_listbox_t* box;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "ListBox Demo");
-
- if (item_icon == RT_NULL)
- item_icon = rtgui_image_create_from_mem("xpm",
- (const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE);
- items[1].image = item_icon;
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* 创建一个label控件 */
- label = rtgui_label_create("listbox: ");
- /* 设置label的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view是一个container控件,调用add_child方法添加这个label控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- rect.y1 = rect.y2 + 3;
- rect.y2 = 250;
- box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect);
- rtgui_listbox_set_onitem(box, on_items);
- /* view是一个container控件,调用add_child方法添加这个listbox控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(box));
-
- return view;
-}
+/* + * 程序清单:label控件演示 + * + * 这个例子会在创建出的container上添加几个不同类型的label控件 + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/listbox.h> + +static rtgui_image_t* item_icon = RT_NULL; +static const char * image_xpm[] = { + "16 16 106 2", + " c None", + ". c #D0C83F", + "+ c #D0C840", + "@ c #D0C030", + "# c #D0B820", + "$ c #D0B020", + "% c #D0B01F", + "& c #5F571F", + "* c #F0F0C0", + "= c #FFF8D0", + "- c #FFF8C0", + "; c #FFF8B0", + "> c #FFF8A0", + ", c #F0E870", + "' c #707030", + ") c #4F87EF", + "! c #4F78C0", + "~ c #5088E0", + "{ c #5078C0", + "] c #C0D0F0", + "^ c #FFF8E0", + "/ c #FFF090", + "( c #F0E070", + "_ c #6F97D0", + ": c #C0D8FE", + "< c #80A8F0", + "[ c #7088D0", + "} c #B0D0FF", + "| c #90B0F0", + "1 c #1040A0", + "2 c #F0F080", + "3 c #707040", + "4 c #7098F0", + "5 c #3068E0", + "6 c #A0B8F0", + "7 c #4070C0", + "8 c #002880", + "9 c #404040", + "0 c #505050", + "a c #F0F090", + "b c #F0E860", + "c c #F0D860", + "d c #807840", + "e c #2F5FC0", + "f c #1050D0", + "g c #1048B0", + "h c #002870", + "i c #C0C080", + "j c #C0C070", + "k c #F0F070", + "l c #F0E060", + "m c #E0D050", + "n c #00277F", + "o c #00287F", + "p c #1F3F6F", + "q c #1048C0", + "r c #0040B0", + "s c #204080", + "t c #FFF890", + "u c #F0D850", + "v c #E0C840", + "w c #807040", + "x c #A0B06F", + "y c #204880", + "z c #2048A0", + "A c #90A8C0", + "B c #FFF080", + "C c #F0D050", + "D c #C0A830", + "E c #6F682F", + "F c #F0F0A0", + "G c #E0D060", + "H c #B0A040", + "I c #D0B840", + "J c #E0C040", + "K c #D0B030", + "L c #706820", + "M c #5F581F", + "N c #CFBF3F", + "O c #FFF0A0", + "P c #A09830", + "Q c #A08820", + "R c #908030", + "S c #807830", + "T c #707020", + "U c #605820", + "V c #6F672F", + "W c #D0C040", + "X c #F0E880", + "Y c #907820", + "Z c #B09820", + "` c #B09010", + " . c #B08820", + ".. c #806820", + "+. c #5F5F1F", + "@. c #F0E080", + "#. c #B09020", + "$. c #C0B040", + "%. c #A09030", + "&. c #908020", + "*. c #606020", + "=. c #6F5F1F", + "-. c #9F982F", + ";. c #A0872F", + ">. c #6F681F", + ",. c #706020", + " ", + " . + + + @ @ # # $ % & ", + " + * = = = = - ; > , ' ", + " ) ! ~ { ] ^ = - - > / ( ' ", + "_ : < { [ } | 1 - ; > > / 2 ( 3 ", + "{ 4 5 1 6 7 5 8 9 0 a / , b c d ", + "e f g h 8 8 g h i j / k l c m d ", + " n o p q r s t 2 , l c u v w ", + " x y z A B , l u C v D E ", + " @ F > t k G H I J K L M ", + " N @ O / 2 l P Q R S T U V ", + " W m 2 X l I Y Z ` ...+. ", + " W @.l u I R #.Z Y U M ", + " $.G I $.%.R &.Y *.& =. ", + " -.;.>.,.L L ,.& M ", + " "}; + +static struct rtgui_listbox_item items[] = +{ + {"list #0", RT_NULL}, + {"list #1", RT_NULL}, + {"list #2", RT_NULL}, + {"list #3", RT_NULL}, +}; + +static void on_items(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_listbox_t* box; + /* get listbox */ + box = RTGUI_LISTBOX(widget); + + /* 打印当前的项 */ + rt_kprintf("current item: %d\n", box->current_item); +} + +/* 创建用于演示label控件的视图 */ +rtgui_container_t* demo_view_listbox(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_label_t* label; + rtgui_listbox_t* box; + + /* 先创建一个演示用的视图 */ + container = demo_view("ListBox Demo"); + + if (item_icon == RT_NULL) + item_icon = rtgui_image_create_from_mem("xpm", + (const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE); + items[1].image = item_icon; + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* 创建一个label控件 */ + label = rtgui_label_create("listbox: "); + /* 设置label的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container是一个container控件,调用add_child方法添加这个label控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + rect.y1 = rect.y2 + 3; + rect.y2 = 250; + box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect); + rtgui_listbox_set_onitem(box, on_items); + /* container是一个container控件,调用add_child方法添加这个listbox控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(box)); + + return container; +} diff --git a/examples/gui/demo_view_listctrl.c b/examples/gui/demo_view_listctrl.c index 50846e2b9d..fb7128fd22 100644 --- a/examples/gui/demo_view_listctrl.c +++ b/examples/gui/demo_view_listctrl.c @@ -1,252 +1,255 @@ -/*
- * �����嵥��label�ؼ���ʾ
- *
- * ������ӻ��ڴ�������view�����Ӽ�����ͬ���͵�label�ؼ�
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/listctrl.h>
-
-static rtgui_image_t* item_icon = RT_NULL;
-static const char * image_xpm[] = {
- "16 16 106 2",
- " c None",
- ". c #D0C83F",
- "+ c #D0C840",
- "@ c #D0C030",
- "# c #D0B820",
- "$ c #D0B020",
- "% c #D0B01F",
- "& c #5F571F",
- "* c #F0F0C0",
- "= c #FFF8D0",
- "- c #FFF8C0",
- "; c #FFF8B0",
- "> c #FFF8A0",
- ", c #F0E870",
- "' c #707030",
- ") c #4F87EF",
- "! c #4F78C0",
- "~ c #5088E0",
- "{ c #5078C0",
- "] c #C0D0F0",
- "^ c #FFF8E0",
- "/ c #FFF090",
- "( c #F0E070",
- "_ c #6F97D0",
- ": c #C0D8FE",
- "< c #80A8F0",
- "[ c #7088D0",
- "} c #B0D0FF",
- "| c #90B0F0",
- "1 c #1040A0",
- "2 c #F0F080",
- "3 c #707040",
- "4 c #7098F0",
- "5 c #3068E0",
- "6 c #A0B8F0",
- "7 c #4070C0",
- "8 c #002880",
- "9 c #404040",
- "0 c #505050",
- "a c #F0F090",
- "b c #F0E860",
- "c c #F0D860",
- "d c #807840",
- "e c #2F5FC0",
- "f c #1050D0",
- "g c #1048B0",
- "h c #002870",
- "i c #C0C080",
- "j c #C0C070",
- "k c #F0F070",
- "l c #F0E060",
- "m c #E0D050",
- "n c #00277F",
- "o c #00287F",
- "p c #1F3F6F",
- "q c #1048C0",
- "r c #0040B0",
- "s c #204080",
- "t c #FFF890",
- "u c #F0D850",
- "v c #E0C840",
- "w c #807040",
- "x c #A0B06F",
- "y c #204880",
- "z c #2048A0",
- "A c #90A8C0",
- "B c #FFF080",
- "C c #F0D050",
- "D c #C0A830",
- "E c #6F682F",
- "F c #F0F0A0",
- "G c #E0D060",
- "H c #B0A040",
- "I c #D0B840",
- "J c #E0C040",
- "K c #D0B030",
- "L c #706820",
- "M c #5F581F",
- "N c #CFBF3F",
- "O c #FFF0A0",
- "P c #A09830",
- "Q c #A08820",
- "R c #908030",
- "S c #807830",
- "T c #707020",
- "U c #605820",
- "V c #6F672F",
- "W c #D0C040",
- "X c #F0E880",
- "Y c #907820",
- "Z c #B09820",
- "` c #B09010",
- " . c #B08820",
- ".. c #806820",
- "+. c #5F5F1F",
- "@. c #F0E080",
- "#. c #B09020",
- "$. c #C0B040",
- "%. c #A09030",
- "&. c #908020",
- "*. c #606020",
- "=. c #6F5F1F",
- "-. c #9F982F",
- ";. c #A0872F",
- ">. c #6F681F",
- ",. c #706020",
- " ",
- " . + + + @ @ # # $ % & ",
- " + * = = = = - ; > , ' ",
- " ) ! ~ { ] ^ = - - > / ( ' ",
- "_ : < { [ } | 1 - ; > > / 2 ( 3 ",
- "{ 4 5 1 6 7 5 8 9 0 a / , b c d ",
- "e f g h 8 8 g h i j / k l c m d ",
- " n o p q r s t 2 , l c u v w ",
- " x y z A B , l u C v D E ",
- " @ F > t k G H I J K L M ",
- " N @ O / 2 l P Q R S T U V ",
- " W m 2 X l I Y Z ` ...+. ",
- " W @.l u I R #.Z Y U M ",
- " $.G I $.%.R &.Y *.& =. ",
- " -.;.>.,.L L ,.& M ",
- " "};
-
-static struct list_item
-{
- const char* name;
- const char* gender;
- int age;
- rtgui_image_t* image;
-} items[] =
-{
- {"index0", "00", 30, RT_NULL},
- {"index1", "m1", 30, RT_NULL},
- {"index2", "m2", 30, RT_NULL},
- {"index3", "m3", 30, RT_NULL},
- {"index4", "m4", 30, RT_NULL},
- {"index5", "m5", 30, RT_NULL},
- {"index6", "m6", 30, RT_NULL},
- {"index7", "m7", 30, RT_NULL},
- {"index8", "m8", 30, RT_NULL},
- {"index9", "m9", 30, RT_NULL},
- {"index10", "m10", 30, RT_NULL},
- {"index11", "m11", 30, RT_NULL},
- {"index12", "m12", 30, RT_NULL},
- {"index13", "m13", 30, RT_NULL},
- {"index14", "m14", 30, RT_NULL},
- {"index15", "m15", 30, RT_NULL},
- {"index16", "m16", 30, RT_NULL},
- {"index17", "m17", 30, RT_NULL},
- {"index18", "m18", 30, RT_NULL},
- {"index19", "m19", 30, RT_NULL},
-};
-
-void _rtgui_listctrl_item_draw(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index)
-{
- char age_str[8];
- rtgui_rect_t item_rect;
- struct list_item *items, *item;
-
- item_rect = *rect;
- item_rect.x1 += 5;
- items = (struct list_item*)list->items;
- item = &items[index];
-
- /* draw text */
- rtgui_dc_draw_text(dc, item->name, &item_rect); item_rect.x1 += 60;
- rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2);
-
- item_rect.x1 += 5;
- rtgui_dc_draw_text(dc, item->gender, &item_rect); item_rect.x1 += 60;
- rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2);
-
- item_rect.x1 += 5;
- rt_snprintf(age_str, sizeof(age_str), "%d", item->age);
- rtgui_dc_draw_text(dc, age_str, &item_rect); item_rect.x1 += 40;
- rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2);
-
- item_rect.x1 += 5;
-
- /* draw image */
- if (item->image != RT_NULL)
- {
- rtgui_rect_t image_rect;
-
- image_rect.x1 = 0; image_rect.y1 = 0;
- image_rect.x2 = item->image->w; image_rect.y2 = item->image->h;
- rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL);
- rtgui_image_blit(item->image, dc, &image_rect);
- }
-}
-
-static void on_items(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_listctrl_t* ctrl;
- /* get listctrl */
- ctrl = RTGUI_LISTCTRL(widget);
-
- /* ��ӡ��ǰ���� */
- rt_kprintf("current item: %d\n", ctrl->current_item);
-}
-
-/* ����������ʾlabel�ؼ�����ͼ */
-rtgui_view_t* demo_view_listctrl(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_label_t* label;
- rtgui_listctrl_t* box;
-
- /* �ȴ���һ����ʾ�õ���ͼ */
- view = demo_view(workbench, "List Control Demo");
-
- if (item_icon == RT_NULL)
- item_icon = rtgui_image_create_from_mem("xpm",
- (const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE);
- items[1].image = item_icon;
-
- /* �����ͼ��λ����Ϣ */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* ����һ��label�ؼ� */
- label = rtgui_label_create("List Control: ");
- /* ����label��� */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view��һ��container�ؼ�������add_child�����������label�ؼ� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- rect.y1 = rect.y2 + 3;
- rect.y2 = 250;
- box = rtgui_listctrl_create((rt_uint32_t)items, sizeof(items)/sizeof(items[0]), &rect,
- _rtgui_listctrl_item_draw);
- rtgui_listctrl_set_onitem(box, on_items);
- /* view��һ��container�ؼ�������add_child�����������listctrl�ؼ� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(box));
-
- return view;
-}
+/* + * �����嵥��label�ؼ���ʾ + * + * ������ӻ��ڴ�������container�����Ӽ�����ͬ���͵�label�ؼ� + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/listctrl.h> + +static rtgui_image_t* item_icon = RT_NULL; +static const char * image_xpm[] = { + "16 16 106 2", + " c None", + ". c #D0C83F", + "+ c #D0C840", + "@ c #D0C030", + "# c #D0B820", + "$ c #D0B020", + "% c #D0B01F", + "& c #5F571F", + "* c #F0F0C0", + "= c #FFF8D0", + "- c #FFF8C0", + "; c #FFF8B0", + "> c #FFF8A0", + ", c #F0E870", + "' c #707030", + ") c #4F87EF", + "! c #4F78C0", + "~ c #5088E0", + "{ c #5078C0", + "] c #C0D0F0", + "^ c #FFF8E0", + "/ c #FFF090", + "( c #F0E070", + "_ c #6F97D0", + ": c #C0D8FE", + "< c #80A8F0", + "[ c #7088D0", + "} c #B0D0FF", + "| c #90B0F0", + "1 c #1040A0", + "2 c #F0F080", + "3 c #707040", + "4 c #7098F0", + "5 c #3068E0", + "6 c #A0B8F0", + "7 c #4070C0", + "8 c #002880", + "9 c #404040", + "0 c #505050", + "a c #F0F090", + "b c #F0E860", + "c c #F0D860", + "d c #807840", + "e c #2F5FC0", + "f c #1050D0", + "g c #1048B0", + "h c #002870", + "i c #C0C080", + "j c #C0C070", + "k c #F0F070", + "l c #F0E060", + "m c #E0D050", + "n c #00277F", + "o c #00287F", + "p c #1F3F6F", + "q c #1048C0", + "r c #0040B0", + "s c #204080", + "t c #FFF890", + "u c #F0D850", + "v c #E0C840", + "w c #807040", + "x c #A0B06F", + "y c #204880", + "z c #2048A0", + "A c #90A8C0", + "B c #FFF080", + "C c #F0D050", + "D c #C0A830", + "E c #6F682F", + "F c #F0F0A0", + "G c #E0D060", + "H c #B0A040", + "I c #D0B840", + "J c #E0C040", + "K c #D0B030", + "L c #706820", + "M c #5F581F", + "N c #CFBF3F", + "O c #FFF0A0", + "P c #A09830", + "Q c #A08820", + "R c #908030", + "S c #807830", + "T c #707020", + "U c #605820", + "V c #6F672F", + "W c #D0C040", + "X c #F0E880", + "Y c #907820", + "Z c #B09820", + "` c #B09010", + " . c #B08820", + ".. c #806820", + "+. c #5F5F1F", + "@. c #F0E080", + "#. c #B09020", + "$. c #C0B040", + "%. c #A09030", + "&. c #908020", + "*. c #606020", + "=. c #6F5F1F", + "-. c #9F982F", + ";. c #A0872F", + ">. c #6F681F", + ",. c #706020", + " ", + " . + + + @ @ # # $ % & ", + " + * = = = = - ; > , ' ", + " ) ! ~ { ] ^ = - - > / ( ' ", + "_ : < { [ } | 1 - ; > > / 2 ( 3 ", + "{ 4 5 1 6 7 5 8 9 0 a / , b c d ", + "e f g h 8 8 g h i j / k l c m d ", + " n o p q r s t 2 , l c u v w ", + " x y z A B , l u C v D E ", + " @ F > t k G H I J K L M ", + " N @ O / 2 l P Q R S T U V ", + " W m 2 X l I Y Z ` ...+. ", + " W @.l u I R #.Z Y U M ", + " $.G I $.%.R &.Y *.& =. ", + " -.;.>.,.L L ,.& M ", + " "}; + +static struct list_item +{ + const char* name; + const char* gender; + int age; + rtgui_image_t* image; +} items[] = +{ + {"index0", "00", 30, RT_NULL}, + {"index1", "m1", 30, RT_NULL}, + {"index2", "m2", 30, RT_NULL}, + {"index3", "m3", 30, RT_NULL}, + {"index4", "m4", 30, RT_NULL}, + {"index5", "m5", 30, RT_NULL}, + {"index6", "m6", 30, RT_NULL}, + {"index7", "m7", 30, RT_NULL}, + {"index8", "m8", 30, RT_NULL}, + {"index9", "m9", 30, RT_NULL}, + {"index10", "m10", 30, RT_NULL}, + {"index11", "m11", 30, RT_NULL}, + {"index12", "m12", 30, RT_NULL}, + {"index13", "m13", 30, RT_NULL}, + {"index14", "m14", 30, RT_NULL}, + {"index15", "m15", 30, RT_NULL}, + {"index16", "m16", 30, RT_NULL}, + {"index17", "m17", 30, RT_NULL}, + {"index18", "m18", 30, RT_NULL}, + {"index19", "m19", 30, RT_NULL}, +}; + +void _rtgui_listctrl_item_draw(struct rtgui_listctrl *list, + struct rtgui_dc* dc, + rtgui_rect_t* rect, + rt_uint16_t index) +{ + char age_str[8]; + rtgui_rect_t item_rect; + struct list_item *items, *item; + + item_rect = *rect; + item_rect.x1 += 5; + items = (struct list_item*)list->items; + item = &items[index]; + + /* draw text */ + rtgui_dc_draw_text(dc, item->name, &item_rect); item_rect.x1 += 60; + rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2); + + item_rect.x1 += 5; + rtgui_dc_draw_text(dc, item->gender, &item_rect); item_rect.x1 += 60; + rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2); + + item_rect.x1 += 5; + rt_snprintf(age_str, sizeof(age_str), "%d", item->age); + rtgui_dc_draw_text(dc, age_str, &item_rect); item_rect.x1 += 40; + rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2); + + item_rect.x1 += 5; + + /* draw image */ + if (item->image != RT_NULL) + { + rtgui_rect_t image_rect; + + image_rect.x1 = 0; image_rect.y1 = 0; + image_rect.x2 = item->image->w; image_rect.y2 = item->image->h; + rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL); + rtgui_image_blit(item->image, dc, &image_rect); + } +} + +static void on_items(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_listctrl_t* ctrl; + /* get listctrl */ + ctrl = RTGUI_LISTCTRL(widget); + + /* ��ӡ��ǰ���� */ + rt_kprintf("current item: %d\n", ctrl->current_item); +} + +/* ����������ʾlabel�ؼ�����ͼ */ +rtgui_container_t* demo_view_listctrl(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_label_t* label; + rtgui_listctrl_t* box; + + /* �ȴ���һ����ʾ�õ���ͼ */ + container = demo_view("List Control Demo"); + + if (item_icon == RT_NULL) + item_icon = rtgui_image_create_from_mem("xpm", + (const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE); + items[1].image = item_icon; + + /* �����ͼ��λ����Ϣ */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* ����һ��label�ؼ� */ + label = rtgui_label_create("List Control: "); + /* ����label��λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* container��һ��container�ؼ�������add_child�����������label�ؼ� */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + rect.y1 = rect.y2 + 3; + rect.y2 = 250; + box = rtgui_listctrl_create((rt_uint32_t)items, sizeof(items)/sizeof(items[0]), &rect, + _rtgui_listctrl_item_draw); + rtgui_listctrl_set_onitem(box, on_items); + /* container��һ��container�ؼ�������add_child�����������listctrl�ؼ� */ + rtgui_container_add_child(container, RTGUI_WIDGET(box)); + + return container; +} diff --git a/examples/gui/demo_view_menu.c b/examples/gui/demo_view_menu.c index e92c446795..da323f67a3 100644 --- a/examples/gui/demo_view_menu.c +++ b/examples/gui/demo_view_menu.c @@ -1,70 +1,72 @@ -/*
- * 程序清单:menu控件演示
- *
- * 这个例子会在创建出的view上添加几个不同类型的label控件
- */
-#include "demo_view.h"
-#include <rtgui/widgets/menu.h>
-#include <rtgui/widgets/button.h>
-
-static rt_bool_t _onmenuitem(struct rtgui_widget *widget, struct rtgui_event* event)
-{
- rt_kprintf("menu action!!\n");
- return RT_TRUE;
-}
-
-static const rtgui_menu_item_t sub_items[] =
-{
- {RTGUI_ITEM_NORMAL, "item #1", RT_NULL, RT_NULL, 0, _onmenuitem},
- {RTGUI_ITEM_NORMAL, "item #2", RT_NULL, RT_NULL, 0, RT_NULL},
- {RTGUI_ITEM_SEPARATOR, RT_NULL, RT_NULL, RT_NULL, 0, RT_NULL},
- {RTGUI_ITEM_NORMAL, "item #3", RT_NULL, RT_NULL, 0, RT_NULL},
-};
-static const rtgui_menu_item_t items[] =
-{
- {RTGUI_ITEM_NORMAL, "item #1", RT_NULL, RT_NULL, 0, RT_NULL},
- {RTGUI_ITEM_NORMAL, "item #2", RT_NULL, RT_NULL, 0, RT_NULL},
- {RTGUI_ITEM_SEPARATOR, RT_NULL, RT_NULL, RT_NULL, 0, RT_NULL},
- {RTGUI_ITEM_SUBMENU, "item #3", RT_NULL, (struct rtgui_menu_item_t *)sub_items, sizeof(sub_items)/sizeof(sub_items[0]), RT_NULL},
-};
-static rtgui_menu_t* menu;
-
-static void _onmenu(struct rtgui_widget* widget, struct rtgui_event* event)
-{
- rtgui_rect_t rect;
-
- rtgui_widget_get_rect(widget, &rect);
- rtgui_widget_rect_to_device(widget, &rect);
-
- if (menu != RT_NULL)
- rtgui_menu_pop(menu, rect.x1, rect.y2 + 5);
-}
-
-/* 创建用于演示menu控件的视图 */
-rtgui_view_t* demo_view_menu(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_button_t* button;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "MENU View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* 创建一个button控件 */
- button = rtgui_button_create("Pop Menu");
- /* 设置button的位置 */
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- /* view是一个container控件,调用add_child方法添加这个button控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
- rtgui_button_set_onbutton(button, _onmenu);
-
- menu = rtgui_menu_create("Menu Test", RT_NULL, items, sizeof(items)/sizeof(items[0]));
-
- return view;
-}
+/* + * 程序清单:menu控件演示 + * + * 这个例子会在创建出的container上添加几个不同类型的label控件 + */ +#include "demo_view.h" +#include <rtgui/widgets/menu.h> +#include <rtgui/widgets/button.h> + +static rt_bool_t _onmenuitem(struct rtgui_widget *widget, struct rtgui_event* event) +{ + rt_kprintf("menu action!!\n"); + return RT_TRUE; +} + +static const rtgui_menu_item_t sub_items[] = +{ + {RTGUI_ITEM_NORMAL, "item #1", RT_NULL, RT_NULL, 0, _onmenuitem}, + {RTGUI_ITEM_NORMAL, "item #2", RT_NULL, RT_NULL, 0, RT_NULL}, + {RTGUI_ITEM_SEPARATOR, RT_NULL, RT_NULL, RT_NULL, 0, RT_NULL}, + {RTGUI_ITEM_NORMAL, "item #3", RT_NULL, RT_NULL, 0, RT_NULL}, +}; +static const rtgui_menu_item_t items[] = +{ + {RTGUI_ITEM_NORMAL, "item #1", RT_NULL, RT_NULL, 0, RT_NULL}, + {RTGUI_ITEM_NORMAL, "item #2", RT_NULL, RT_NULL, 0, RT_NULL}, + {RTGUI_ITEM_SEPARATOR, RT_NULL, RT_NULL, RT_NULL, 0, RT_NULL}, + {RTGUI_ITEM_SUBMENU, "item #3", RT_NULL, + (struct rtgui_menu_item_t *)sub_items, + sizeof(sub_items)/sizeof(sub_items[0]), RT_NULL}, +}; +static rtgui_menu_t* menu; + +static _onmenu(struct rtgui_widget* widget, struct rtgui_event* event) +{ + rtgui_rect_t rect; + + rtgui_widget_get_rect(widget, &rect); + rtgui_widget_rect_to_device(widget, &rect); + + if (menu != RT_NULL) + rtgui_menu_pop(menu, rect.x1, rect.y2 + 5); +} + +/* 创建用于演示menu控件的视图 */ +rtgui_container_t* demo_view_menu(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_button_t* button; + + /* 先创建一个演示用的视图 */ + container = demo_view("MENU View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* 创建一个button控件 */ + button = rtgui_button_create("Pop Menu"); + /* 设置button的位置 */ + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + /* container是一个container控件,调用add_child方法添加这个button控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(button)); + rtgui_button_set_onbutton(button, _onmenu); + + menu = rtgui_menu_create("Menu Test", RT_NULL, items, sizeof(items)/sizeof(items[0])); + + return container; +} diff --git a/examples/gui/demo_view_module.c b/examples/gui/demo_view_module.c index c1ce83b6f3..e98beff5d3 100644 --- a/examples/gui/demo_view_module.c +++ b/examples/gui/demo_view_module.c @@ -1,77 +1,77 @@ -/*
- * �����嵥��DC����ʾͼ����ʾ
- *
- * ������ӻ��ڴ�������view����ʾͼ��
- */
-
-#include "demo_view.h"
-#include <rtgui/widgets/button.h>
-#include <rtgui/widgets/filelist_view.h>
-#include <string.h>
-
-#ifdef RT_USING_MODULE
-#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
-static rtgui_view_t* _view = RT_NULL;
-
-/* ��ť�Ļص����� */
-static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
-{
- rtgui_filelist_view_t *view;
- rtgui_workbench_t *workbench;
- rtgui_rect_t rect;
-
- /* ��ö����workbench */
- workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
- rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
-
- /* WIN32ƽ̨�Ϻ���ʵ�豸�ϵij�ʼ·������ */
-#ifdef _WIN32
- view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
-#else
- view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
-#endif
- /* ģ̬��ʾһ���ļ��б���ͼ�����ṩ���û�ѡ��ͼ���ļ� */
- if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
- {
- char path[32], name[8];
-
- /* �����ļ�·���ı�ǩ */
- rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
-
- rt_memset(name, 0, sizeof(name));
-
- /* ���Ӧ��ģ������� */
- if (rt_strstr(path, ".mo") != RT_NULL || rt_strstr(path, ".so") != RT_NULL)
- {
- rt_module_open(path);
- }
- }
-
- /* ɾ�� �ļ��б� ��ͼ */
- rtgui_view_destroy(RTGUI_VIEW(view));
- rtgui_view_show(_view, RT_FALSE);
-}
-
-/* ����������ʾӦ��ģ�����ʾ��ͼ */
-rtgui_view_t* demo_view_module(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_button_t* open_btn;
-
- /* �ȴ���һ����ʾ��ͼ */
- _view = demo_view(workbench, "Ӧ��ģ����ʾ");
-
- /* ����һ����ť */
- demo_view_get_rect(_view, &rect);
- rect.x1 += 5; rect.x2 = rect.x1 + 120;
- rect.y2 = rect.y1 + 20;
- open_btn = rtgui_button_create("��Ӧ��ģ��");
- rtgui_container_add_child(RTGUI_CONTAINER(_view), RTGUI_WIDGET(open_btn));
- rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
- rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
-
- return _view;
-}
-#endif
-#endif
-
+/* + * �����嵥��DC����ʾͼ����ʾ + * + * ������ӻ��ڴ�������view����ʾͼ�� + */ + +#include "demo_view.h" +#include <rtgui/widgets/button.h> +#include <rtgui/widgets/filelist_view.h> +#include <string.h> + +#ifdef RT_USING_MODULE +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +static rtgui_container_t* _view = RT_NULL; + +/* ��ť�Ļص����� */ +static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) +{ + rtgui_filelist_view_t *view; + rtgui_workbench_t *workbench; + rtgui_rect_t rect; + + /* ��ö����workbench */ + workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget)); + rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); + + /* WIN32ƽ̨�Ϻ���ʵ�豸�ϵij�ʼ·������ */ +#ifdef _WIN32 + view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect); +#else + view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect); +#endif + /* ģ̬��ʾһ���ļ��б���ͼ�����ṩ���û�ѡ��ͼ���ļ� */ + if (rtgui_container_show(RTGUI_CONTAINER(view), RT_TRUE) == RTGUI_MODAL_OK) + { + char path[32], name[8]; + + /* �����ļ�·���ı�ǩ */ + rtgui_filelist_view_get_fullpath(view, path, sizeof(path)); + + rt_memset(name, 0, sizeof(name)); + + /* ���Ӧ��ģ������� */ + if (rt_strstr(path, ".mo") != RT_NULL || rt_strstr(path, ".so") != RT_NULL) + { + rt_module_open(path); + } + } + + /* ɾ�� �ļ��б� ��ͼ */ + rtgui_container_destroy(RTGUI_CONTAINER(view)); + rtgui_container_show(_view, RT_FALSE); +} + +/* ����������ʾӦ��ģ�����ʾ��ͼ */ +rtgui_container_t* demo_view_module(rtgui_workbench_t* workbench) +{ + rtgui_rect_t rect; + rtgui_button_t* open_btn; + + /* �ȴ���һ����ʾ��ͼ */ + _view = demo_view(workbench, "Ӧ��ģ����ʾ"); + + /* ����һ����ť */ + demo_view_get_rect(_view, &rect); + rect.x1 += 5; rect.x2 = rect.x1 + 120; + rect.y2 = rect.y1 + 20; + open_btn = rtgui_button_create("��Ӧ��ģ��"); + rtgui_container_add_child(RTGUI_CONTAINER(_view), RTGUI_WIDGET(open_btn)); + rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect); + rtgui_button_set_onbutton(open_btn, open_btn_onbutton); + + return _view; +} +#endif +#endif + diff --git a/examples/gui/demo_view_mywidget.c b/examples/gui/demo_view_mywidget.c index 1c0e6de693..d9f917980f 100644 --- a/examples/gui/demo_view_mywidget.c +++ b/examples/gui/demo_view_mywidget.c @@ -1,42 +1,42 @@ -/*
- * 程序清单:自定义控件演示
- *
- * 这个例子会在创建出的view上添加两个自定义控件
- */
-#include "demo_view.h"
-#include "mywidget.h"
-
-/* 创建用于演示自定义控件的视图 */
-rtgui_view_t *demo_view_mywidget(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
- rtgui_rect_t rect;
- rtgui_mywidget_t *mywidget;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "MyWidget View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.y1 + 80;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 80;
- /* 创建一个自定义控件 */
- mywidget = rtgui_mywidget_create(&rect);
- /* view是一个container控件,调用add_child方法添加这个自控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(mywidget));
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 25;
- rect.x2 = rect.y1 + 40;
- rect.y1 += 5 + 100;
- rect.y2 = rect.y1 + 40;
- /* 创建一个自定义控件 */
- mywidget = rtgui_mywidget_create(&rect);
- /* view是一个container控件,调用add_child方法添加这个自控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(mywidget));
-
- return view;
-}
+/* + * 程序清单:自定义控件演示 + * + * 这个例子会在创建出的container上添加两个自定义控件 + */ +#include "demo_view.h" +#include "mywidget.h" + +/* 创建用于演示自定义控件的视图 */ +rtgui_container_t *demo_view_mywidget(void) +{ + rtgui_container_t *container; + rtgui_rect_t rect; + rtgui_mywidget_t *mywidget; + + /* 先创建一个演示用的视图 */ + container = demo_view("MyWidget View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.y1 + 80; + rect.y1 += 5; + rect.y2 = rect.y1 + 80; + /* 创建一个自定义控件 */ + mywidget = rtgui_mywidget_create(&rect); + /* container是一个container控件,调用add_child方法添加这个自控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(mywidget)); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 25; + rect.x2 = rect.y1 + 40; + rect.y1 += 5 + 100; + rect.y2 = rect.y1 + 40; + /* 创建一个自定义控件 */ + mywidget = rtgui_mywidget_create(&rect); + /* container是一个container控件,调用add_child方法添加这个自控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(mywidget)); + + return container; +} diff --git a/examples/gui/demo_view_notebook.c b/examples/gui/demo_view_notebook.c index 4ec6c7c442..97ad06321e 100644 --- a/examples/gui/demo_view_notebook.c +++ b/examples/gui/demo_view_notebook.c @@ -1,53 +1,53 @@ -/*
- * 程序清单:notebook控件演示
- *
- * 这个例子会在创建出的view上演示notebook控件
- */
-
-#include "demo_view.h"
-#include <rtgui/widgets/notebook.h>
-#include <rtgui/widgets/listbox.h>
-
-const static struct rtgui_listbox_item items[] =
-{
- {"list #0", RT_NULL},
- {"list #1", RT_NULL},
- {"list #2", RT_NULL},
- {"list #3", RT_NULL},
-};
-
-const static struct rtgui_listbox_item items2[] =
-{
- {"list #0", RT_NULL},
- {"list #1", RT_NULL},
- {"list #2", RT_NULL},
- {"new list #1", RT_NULL},
- {"new list #2", RT_NULL},
-};
-
-/* 创建用于演示notebook控件的视图 */
-rtgui_view_t* demo_view_notebook(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_notebook_t* notebook;
- rtgui_listbox_t* box;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "Notebook View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
-
- notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_BOTTOM);
- /* view是一个container控件,调用add_child方法添加这个notebook控件 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(notebook));
-
- box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect);
- rtgui_notebook_add(notebook, "Tab 1", RTGUI_WIDGET(box));
-
- box = rtgui_listbox_create(items2, sizeof(items2)/sizeof(struct rtgui_listbox_item), &rect);
- rtgui_notebook_add(notebook, "Tab 2", RTGUI_WIDGET(box));
-
- return view;
-}
+/* + * 程序清单:notebook控件演示 + * + * 这个例子会在创建出的container上演示notebook控件 + */ + +#include "demo_view.h" +#include <rtgui/widgets/notebook.h> +#include <rtgui/widgets/listbox.h> + +const static struct rtgui_listbox_item items[] = +{ + {"list #0", RT_NULL}, + {"list #1", RT_NULL}, + {"list #2", RT_NULL}, + {"list #3", RT_NULL}, +}; + +const static struct rtgui_listbox_item items2[] = +{ + {"list #0", RT_NULL}, + {"list #1", RT_NULL}, + {"list #2", RT_NULL}, + {"new list #1", RT_NULL}, + {"new list #2", RT_NULL}, +}; + +/* 创建用于演示notebook控件的视图 */ +rtgui_container_t* demo_view_notebook(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + struct rtgui_notebook *notebook; + rtgui_listbox_t* box; + + /* 先创建一个演示用的视图 */ + container = demo_view("Notebook View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + + notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_BOTTOM); + /* container是一个container控件,调用add_child方法添加这个notebook控件 */ + rtgui_container_add_child(container, RTGUI_WIDGET(notebook)); + + box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect); + rtgui_notebook_add(notebook, "Tab 1", RTGUI_WIDGET(box)); + + box = rtgui_listbox_create(items2, sizeof(items2)/sizeof(struct rtgui_listbox_item), &rect); + rtgui_notebook_add(notebook, "Tab 2", RTGUI_WIDGET(box)); + + return container; +} diff --git a/examples/gui/demo_view_progressbar.c b/examples/gui/demo_view_progressbar.c index 620668d7d3..40eede7a89 100644 --- a/examples/gui/demo_view_progressbar.c +++ b/examples/gui/demo_view_progressbar.c @@ -1,59 +1,76 @@ -#include "demo_view.h"
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/progressbar.h>
-
-static rtgui_progressbar_t* hbar;
-static rtgui_progressbar_t* vbar;
-static rtgui_timer_t *bar_timer = RT_NULL;
-
-void progressbar_timeout(struct rtgui_timer* timer, void* parameter)
-{
- static rt_uint32_t value = 0;
-
- value ++;
- if (value == 100) value = 0;
-
- rtgui_progressbar_set_value(hbar, value);
- rtgui_progressbar_set_value(vbar, value);
-}
-
-rtgui_view_t *demo_view_progressbar(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
- rtgui_rect_t rect;
- rtgui_label_t *label;
-
- /* create a demo view */
- view = demo_view(workbench, "ProgressBar View");
-
- /* get demo view rect */
- demo_view_get_rect(view, &rect);
- label = rtgui_label_create("ˮƽ������:");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 5; rect.y2 = rect.y1 + 18;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rect.y1 += 20; rect.y2 = rect.y1 + 18;
- hbar = rtgui_progressbar_create(RTGUI_HORIZONTAL, 100, &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(hbar));
-
- /* get demo view rect */
- demo_view_get_rect(view, &rect);
- label = rtgui_label_create("��ֱ������:");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 45; rect.y2 = rect.y1 + 18;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rect.x1 += 110; rect.x2 = rect.x1 + 20;
- rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150;
- vbar = rtgui_progressbar_create(RTGUI_VERTICAL, 100, &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(vbar));
-
- bar_timer = rtgui_timer_create(50, RT_TIMER_FLAG_PERIODIC,
- progressbar_timeout, RT_NULL);
- rtgui_timer_start(bar_timer);
-
- return view;
-}
-
+#include "demo_view.h" +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/progressbar.h> + +static rtgui_progressbar_t* hbar; +static rtgui_progressbar_t* vbar; +static rtgui_timer_t *bar_timer = RT_NULL; + +void progressbar_timeout(struct rtgui_timer* timer, void* parameter) +{ + static rt_uint32_t value = 0; + + value++; + if (value == 100) + value = 0; + + rtgui_progressbar_set_value(hbar, value); + rtgui_progressbar_set_value(vbar, value); +} + +static rt_bool_t start_timer(struct rtgui_object *object, struct rtgui_event *event) +{ + if (bar_timer != RT_NULL) + rtgui_timer_start(bar_timer); + return RT_TRUE; +} + +static rt_bool_t stop_timer(struct rtgui_object *object, struct rtgui_event *event) +{ + if (bar_timer != RT_NULL) + rtgui_timer_stop(bar_timer); + return RT_TRUE; +} + +rtgui_container_t *demo_view_progressbar(void) +{ + rtgui_container_t *container; + rtgui_rect_t rect; + rtgui_label_t *label; + + /* create a demo container */ + container = demo_view("ProgressBar View"); + + /* get demo container rect */ + demo_view_get_rect(container, &rect); + label = rtgui_label_create("ˮƽ������:"); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 5; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.y1 += 20; rect.y2 = rect.y1 + 18; + hbar = rtgui_progressbar_create(RTGUI_HORIZONTAL, 100, &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(hbar)); + + /* get demo container rect */ + demo_view_get_rect(container, &rect); + label = rtgui_label_create("��ֱ������:"); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 45; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.x1 += 110; rect.x2 = rect.x1 + 20; + rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150; + vbar = rtgui_progressbar_create(RTGUI_VERTICAL, 100, &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(vbar)); + + bar_timer = rtgui_timer_create(50, RT_TIMER_FLAG_PERIODIC, + progressbar_timeout, RT_NULL); + + rtgui_widget_set_onshow(RTGUI_WIDGET(container), start_timer); + rtgui_widget_set_onhide(RTGUI_WIDGET(container), stop_timer); + + return container; +} + diff --git a/examples/gui/demo_view_radiobox.c b/examples/gui/demo_view_radiobox.c index ba204c8d7f..1fa8b36f15 100644 --- a/examples/gui/demo_view_radiobox.c +++ b/examples/gui/demo_view_radiobox.c @@ -1,69 +1,69 @@ -/*
- * 程序清单:radiobox控件演示
- *
- * 这个例子会在创建出的view上添加两个不同方向的radiobox控件
- */
-
-#include "demo_view.h"
-#include <rtgui/widgets/radiobox.h>
-
-/* 用于显示垂直方向的radio文本项数组 */
-static char* radio_item_v[5] =
- {
- "one",
- "two",
- "three",
- "item 1",
- "item 2"
- };
-
-/* 用于显示水平方向的radio文本项数组 */
-static char* radio_item_h[3] =
- {
- "one", "two", "three"
- };
-
-/* 创建用于演示radiobox控件的视图 */
-rtgui_view_t* demo_view_radiobox(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_radiobox_t* radiobox;
-
- /* 先创建一个演示用的视图 */
- view = demo_view(workbench, "RadioBox View");
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 5 * 25;
-
- /* 创建一个垂直方向显示的radiobox控件,文本项是radio_item_v数组,共5个项 */
- radiobox = rtgui_radiobox_create("Radio Box", RTGUI_VERTICAL, radio_item_v, 5);
- /* 设置当前选择的数组是第0项 */
- rtgui_radiobox_set_selection(radiobox, 0);
- /* 添加radiobox控件到视图中 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(radiobox));
- /* 设置radiobox控件的位置信息 */
- rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
-
- /* 获得视图的位置信息 */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5 + 5 * 25;
- rect.y2 = rect.y1 + 60;
-
- /* 创建一个水平方向显示的radiobox控件,文本项是radio_item_h数组,共3个项 */
- radiobox = rtgui_radiobox_create("Radio Box", RTGUI_HORIZONTAL, radio_item_h, 3);
- /* 设置当前选择的数组是第0项 */
- rtgui_radiobox_set_selection(radiobox, 0);
- /* 添加radiobox控件到视图中 */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(radiobox));
- /* 设置radiobox控件的位置信息 */
- rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
-
- return view;
-}
+/* + * 程序清单:radiobox控件演示 + * + * 这个例子会在创建出的container上添加两个不同方向的radiobox控件 + */ + +#include "demo_view.h" +#include <rtgui/widgets/radiobox.h> + +/* 用于显示垂直方向的radio文本项数组 */ +static char* radio_item_v[5] = + { + "one", + "two", + "three", + "item 1", + "item 2" + }; + +/* 用于显示水平方向的radio文本项数组 */ +static char* radio_item_h[3] = + { + "one", "two", "three" + }; + +/* 创建用于演示radiobox控件的视图 */ +rtgui_container_t* demo_view_radiobox(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_radiobox_t* radiobox; + + /* 先创建一个演示用的视图 */ + container = demo_view("RadioBox View"); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 5 * 25; + + /* 创建一个垂直方向显示的radiobox控件,文本项是radio_item_v数组,共5个项 */ + radiobox = rtgui_radiobox_create("Radio Box", RTGUI_VERTICAL, radio_item_v, 5); + /* 设置当前选择的数组是第0项 */ + rtgui_radiobox_set_selection(radiobox, 0); + /* 添加radiobox控件到视图中 */ + rtgui_container_add_child(container, RTGUI_WIDGET(radiobox)); + /* 设置radiobox控件的位置信息 */ + rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect); + + /* 获得视图的位置信息 */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5 + 5 * 25; + rect.y2 = rect.y1 + 60; + + /* 创建一个水平方向显示的radiobox控件,文本项是radio_item_h数组,共3个项 */ + radiobox = rtgui_radiobox_create("Radio Box", RTGUI_HORIZONTAL, radio_item_h, 3); + /* 设置当前选择的数组是第0项 */ + rtgui_radiobox_set_selection(radiobox, 0); + /* 添加radiobox控件到视图中 */ + rtgui_container_add_child(container, RTGUI_WIDGET(radiobox)); + /* 设置radiobox控件的位置信息 */ + rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect); + + return container; +} diff --git a/examples/gui/demo_view_scrollbar.c b/examples/gui/demo_view_scrollbar.c index 0c712c2552..db9b1a7e75 100644 --- a/examples/gui/demo_view_scrollbar.c +++ b/examples/gui/demo_view_scrollbar.c @@ -1,43 +1,43 @@ -#include "demo_view.h"
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/scrollbar.h>
-
-rtgui_view_t *demo_view_scrollbar(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
- rtgui_rect_t rect;
- rtgui_label_t *label;
- rtgui_scrollbar_t* hbar;
- rtgui_scrollbar_t* vbar;
-
- /* create a demo view */
- view = demo_view(workbench, "ScrollBar View");
-
- /* get demo view rect */
- demo_view_get_rect(view, &rect);
- label = rtgui_label_create("horizontal bar:");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 5; rect.y2 = rect.y1 + 18;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rect.y1 += 20; rect.y2 = rect.y1 + 18;
- hbar = rtgui_scrollbar_create(RTGUI_HORIZONTAL, &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(hbar));
-
- /* get demo view rect */
- demo_view_get_rect(view, &rect);
- label = rtgui_label_create("vertical bar:");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 45; rect.y2 = rect.y1 + 18;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rect.x1 += 110; rect.x2 = rect.x1 + 20;
- rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150;
- vbar = rtgui_scrollbar_create(RTGUI_VERTICAL, &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(vbar));
- rtgui_scrollbar_set_line_step(vbar, 1);
- // RTGUI_WIDGET_DISABLE(RTGUI_WIDGET(vbar));
-
- return view;
-}
+#include "demo_view.h" +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/scrollbar.h> + +rtgui_container_t *demo_view_scrollbar(void) +{ + rtgui_container_t *container; + rtgui_rect_t rect; + rtgui_label_t *label; + rtgui_scrollbar_t* hbar; + rtgui_scrollbar_t* vbar; + + /* create a demo container */ + container = demo_view("ScrollBar View"); + + /* get demo container rect */ + demo_view_get_rect(container, &rect); + label = rtgui_label_create("horizontal bar:"); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 5; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.y1 += 20; rect.y2 = rect.y1 + 18; + hbar = rtgui_scrollbar_create(RTGUI_HORIZONTAL, &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(hbar)); + + /* get demo container rect */ + demo_view_get_rect(container, &rect); + label = rtgui_label_create("vertical bar:"); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 45; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.x1 += 110; rect.x2 = rect.x1 + 20; + rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150; + vbar = rtgui_scrollbar_create(RTGUI_VERTICAL, &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(vbar)); + rtgui_scrollbar_set_line_step(vbar, 1); + // RTGUI_WIDGET_DISABLE(RTGUI_WIDGET(vbar)); + + return container; +} diff --git a/examples/gui/demo_view_slider.c b/examples/gui/demo_view_slider.c index e8efdd729c..62601989fc 100644 --- a/examples/gui/demo_view_slider.c +++ b/examples/gui/demo_view_slider.c @@ -1,42 +1,42 @@ -#include "demo_view.h"
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/slider.h>
-
-rtgui_view_t *demo_view_slider(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
- rtgui_rect_t rect;
- rtgui_label_t *label;
- rtgui_slider_t *slider;
-
- /* create a demo view */
- view = demo_view(workbench, "Slider View");
-
- /* get demo view rect */
- demo_view_get_rect(view, &rect);
- label = rtgui_label_create("horizontal slider:");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 5; rect.y2 = rect.y1 + 18;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rect.y1 += 20; rect.y2 = rect.y1 + 18;
- slider = rtgui_slider_create(0, 100, RTGUI_HORIZONTAL);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(slider));
- rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect);
-
- /* get demo view rect */
- demo_view_get_rect(view, &rect);
- label = rtgui_label_create("vertical slider:");
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
- rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 50; rect.y2 = rect.y1 + 18;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rect.x1 += 110; rect.x2 = rect.x1 + 20;
- rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150;
- slider = rtgui_slider_create(0, 100, RTGUI_VERTICAL);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(slider));
- rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect);
-
- return view;
-}
+#include "demo_view.h" +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/slider.h> + +rtgui_container_t *demo_view_slider(void) +{ + rtgui_container_t *container; + rtgui_rect_t rect; + rtgui_label_t *label; + rtgui_slider_t *slider; + + /* create a demo container */ + container = demo_view("Slider View"); + + /* get demo container rect */ + demo_view_get_rect(container, &rect); + label = rtgui_label_create("horizontal slider:"); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 5; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.y1 += 20; rect.y2 = rect.y1 + 18; + slider = rtgui_slider_create(0, 100, RTGUI_HORIZONTAL); + rtgui_container_add_child(container, RTGUI_WIDGET(slider)); + rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect); + + /* get demo container rect */ + demo_view_get_rect(container, &rect); + label = rtgui_label_create("vertical slider:"); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + rect.x1 += 5; rect.x2 -= 5; + rect.y1 += 50; rect.y2 = rect.y1 + 18; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rect.x1 += 110; rect.x2 = rect.x1 + 20; + rect.y1 += 18 + 5; rect.y2 = rect.y1 + 150; + slider = rtgui_slider_create(0, 100, RTGUI_VERTICAL); + rtgui_container_add_child(container, RTGUI_WIDGET(slider)); + rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect); + + return container; +} diff --git a/examples/gui/demo_view_textbox.c b/examples/gui/demo_view_textbox.c index e4b8646754..574915c1af 100644 --- a/examples/gui/demo_view_textbox.c +++ b/examples/gui/demo_view_textbox.c @@ -1,103 +1,102 @@ -/*
- * �����嵥��texbox�ؼ���ʾ
- *
- * ������ӻ��ڴ�������view�����Ӽ�����ͬ���͵�textbox�ؼ�
- */
-#include "demo_view.h"
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/textbox.h>
-
-/* ����������ʾtextbox�ؼ�����ͼ */
-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;
-
- /* �ȴ���һ����ʾ�õ���ͼ */
- view = demo_view(workbench, "TextBox View");
-
- /* �����ͼ��λ����Ϣ */
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 30;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* ����һ��label�ؼ� */
- label = rtgui_label_create("����: ");
- /* ����label��� */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* view��һ��container�ؼ�������add_child�����������label�ؼ� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
-
- /* ��textbox_rect��ֵ��rect���Լ���textbox�ؼ���λ�� */
- textbox_rect = rect;
- textbox_rect.x1 = textbox_rect.x2 + 5;
- textbox_rect.x2 = textbox_rect.x1 + 160;
- /* ����һ��textbox�ؼ� */
- text = rtgui_textbox_create("bernard",RTGUI_TEXTBOX_SINGLE);
- /* ����textbox�ؼ���λ�� */
- rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
- /* ����textbox�ؼ�����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
-
- /* ������һ��label�ؼ���λ�� */
- rect.y1 += 23;
- rect.y2 = rect.y1 + 20;
- /* ����һ��label�ؼ� */
- label = rtgui_label_create("�ʼ�: ");
- /* ����label��� */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* ����label�ؼ�����ͼ�� */
- 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;
- /* ����һ��textbox�ؼ� */
- text = rtgui_textbox_create("[email protected]",RTGUI_TEXTBOX_SINGLE);
- /* ����textbox�ؼ���λ�� */
- rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
- /* ����textbox�ؼ�����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
-
- rect.y1 += 23;
- rect.y2 = rect.y1 + 20;
- /* ����һ��label�ؼ� */
- label = rtgui_label_create("����: ");
- /* ����label��� */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* ����label�ؼ�����ͼ�� */
- 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;
- /* ����һ��textbox�ؼ� */
- text = rtgui_textbox_create("rt-thread",RTGUI_TEXTBOX_SINGLE);
- /* ����textbox��ʾ�ı�Ϊ������ʽ(����ʾΪ*�ţ��ʺ�����ʾ��������) */
- text->flag |= RTGUI_TEXTBOX_MASK;
- /* ����textbox�ؼ���λ�� */
- rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
- /* ����textbox�ؼ�����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
-
- rect.y1 += 23;
- rect.y2 = rect.y1 + 20;
- /* ����һ��label�ؼ� */
- label = rtgui_label_create("��ҳ: ");
- /* ����label��� */
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- /* ����label�ؼ�����ͼ�� */
- 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;
- /* ����һ��textbox�ؼ� */
- text = rtgui_textbox_create("http://www.rt-thread.org",RTGUI_TEXTBOX_SINGLE);
- /* ����textbox�ؼ���λ�� */
- rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect);
- /* ����textbox�ؼ�����ͼ�� */
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
-
- return view;
-}
+/* + * �����嵥��texbox�ؼ���ʾ + * + * ������ӻ��ڴ�������container�����Ӽ�����ͬ���͵�textbox�ؼ� + */ +#include "demo_view.h" +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/textbox.h> + +/* ����������ʾtextbox�ؼ�����ͼ */ +rtgui_container_t* demo_view_textbox(void) +{ + rtgui_rect_t rect, textbox_rect; + rtgui_container_t* container; + rtgui_label_t* label; + rtgui_textbox_t* text; + + /* �ȴ���һ����ʾ�õ���ͼ */ + container = demo_view("TextBox View"); + + /* �����ͼ��λ����Ϣ */ + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 30; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* ����һ��label�ؼ� */ + label = rtgui_label_create("����: "); + /* ����label��λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + + /* ��textbox_rect��ֵ��rect���Լ���textbox�ؼ���λ�� */ + textbox_rect = rect; + textbox_rect.x1 = textbox_rect.x2 + 5; + textbox_rect.x2 = textbox_rect.x1 + 160; + /* ����һ��textbox�ؼ� */ + text = rtgui_textbox_create("bernard",RTGUI_TEXTBOX_SINGLE); + /* ����textbox�ؼ���λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect); + /* ����textbox�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(text)); + + /* ������һ��label�ؼ���λ�� */ + rect.y1 += 23; + rect.y2 = rect.y1 + 20; + /* ����һ��label�ؼ� */ + label = rtgui_label_create("�ʼ�: "); + /* ����label��λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* ����label�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + textbox_rect = rect; + textbox_rect.x1 = textbox_rect.x2 + 5; + textbox_rect.x2 = textbox_rect.x1 + 160; + /* ����һ��textbox�ؼ� */ + text = rtgui_textbox_create("[email protected]",RTGUI_TEXTBOX_SINGLE); + /* ����textbox�ؼ���λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect); + /* ����textbox�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(text)); + + rect.y1 += 23; + rect.y2 = rect.y1 + 20; + /* ����һ��label�ؼ� */ + label = rtgui_label_create("����: "); + /* ����label��λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* ����label�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + textbox_rect = rect; + textbox_rect.x1 = textbox_rect.x2 + 5; + textbox_rect.x2 = textbox_rect.x1 + 160; + /* ����һ��textbox�ؼ� */ + text = rtgui_textbox_create("rt-thread",RTGUI_TEXTBOX_SINGLE); + /* ����textbox��ʾ�ı�Ϊ������ʽ(����ʾΪ*�ţ��ʺ�����ʾ��������) */ + text->flag |= RTGUI_TEXTBOX_MASK; + /* ����textbox�ؼ���λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect); + /* ����textbox�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(text)); + + rect.y1 += 23; + rect.y2 = rect.y1 + 20; + /* ����һ��label�ؼ� */ + label = rtgui_label_create("��ҳ: "); + /* ����label��λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + /* ����label�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(label)); + textbox_rect = rect; + textbox_rect.x1 = textbox_rect.x2 + 5; + textbox_rect.x2 = textbox_rect.x1 + 160; + /* ����һ��textbox�ؼ� */ + text = rtgui_textbox_create("http://www.rt-thread.org",RTGUI_TEXTBOX_SINGLE); + /* ����textbox�ؼ���λ�� */ + rtgui_widget_set_rect(RTGUI_WIDGET(text), &textbox_rect); + /* ����textbox�ؼ�����ͼ�� */ + rtgui_container_add_child(container, RTGUI_WIDGET(text)); + + return container; +} diff --git a/examples/gui/demo_view_ttf.c b/examples/gui/demo_view_ttf.c index 988f382985..87cc3095bd 100644 --- a/examples/gui/demo_view_ttf.c +++ b/examples/gui/demo_view_ttf.c @@ -1,96 +1,98 @@ -/*
- * �����嵥��TTF������ʾ��ʾ
- *
- * ������ӻ��ڴ�������view�Ͻ���TTF������ʾ����ʾ
- */
-
-#include "demo_view.h"
-#include <rtgui/dc.h>
-#include <rtgui/font.h>
-#include <rtgui/rtgui_system.h>
-
-#ifdef RTGUI_USING_TTF
-static rtgui_font_t *font_16, *font_24, *font_36, *font_48;
-
-/*
- * view���¼���������
- */
-rt_bool_t ttf_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
-{
- /* ����PAINT�¼����д��� */
- if (event->type == RTGUI_EVENT_PAINT)
- {
- struct rtgui_dc* dc;
- rtgui_rect_t rect;
- rtgui_font_t* saved;
-
- /*
- * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view
- * �Ȼ�ͼ
- */
- rtgui_view_event_handler(widget, event);
-
- /************************************************************************/
- /* �������DC�IJ��� */
- /************************************************************************/
-
- /* ��ÿؼ�������DC */
- dc = rtgui_dc_begin_drawing(widget);
- /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
- if (dc == RT_NULL)
- return RT_FALSE;
-
- /* ���demo view������ͼ������ */
- demo_view_get_rect(RTGUI_VIEW(widget), &rect);
-
- saved = RTGUI_WIDGET_FONT(widget);
-
- RTGUI_WIDGET_FONT(widget) = font_16;
- rtgui_dc_draw_text(dc, "ABCD����", &rect);
- rect.y1 += 18;
-
- RTGUI_WIDGET_FONT(widget) = font_24;
- rtgui_dc_draw_text(dc, "ABCD����", &rect);
- rect.y1 += 26;
-
- RTGUI_WIDGET_FONT(widget) = font_36;
- rtgui_dc_draw_text(dc, "ABCD����", &rect);
- rect.y1 += 38;
-
- RTGUI_WIDGET_FONT(widget) = font_48;
- rtgui_dc_draw_text(dc, "ABCD����", &rect);
-
- RTGUI_WIDGET_FONT(widget) = saved;
- /* ��ͼ��� */
- rtgui_dc_end_drawing(dc);
- }
- else
- {
- /* �����¼�������Ĭ�ϵ��¼��������� */
- return rtgui_view_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-/* ��������TTF������ʾ��ʾ�õ���ͼ */
-rtgui_view_t *demo_view_ttf(rtgui_workbench_t* workbench)
-{
- rtgui_view_t *view;
-
- font_16 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 16);
- font_24 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 24);
- font_36 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 36);
- font_48 = rtgui_freetype_font_create("d:/simsun.TTF", 0, 0, 72);
-
- view = demo_view(workbench, "TTF ��ʾ");
- if (view != RT_NULL)
- {
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
- /* ���ó��Լ����¼��������� */
- rtgui_widget_set_event_handler(RTGUI_WIDGET(view), ttf_event_handler);
- }
-
- return view;
-}
-#endif
+/* + * �����嵥��TTF������ʾ��ʾ + * + * ������ӻ��ڴ�������container�Ͻ���TTF������ʾ����ʾ + */ + +#include "demo_view.h" +#include <rtgui/dc.h> +#include <rtgui/font.h> +#include <rtgui/rtgui_system.h> + +#ifdef RTGUI_USING_TTF +static rtgui_font_t *font_16, *font_24, *font_36, *font_48; + +/* + * container���¼��������� + */ +rt_bool_t ttf_event_handler(struct rtgui_object* object, rtgui_event_t *event) +{ + struct rtgui_widget *widget = RTGUI_WIDGET(object); + + /* ����PAINT�¼����д��� */ + if (event->type == RTGUI_EVENT_PAINT) + { + struct rtgui_dc* dc; + rtgui_rect_t rect; + rtgui_font_t* saved; + + /* + * ��Ϊ�õ���demo container�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo container + * �Ȼ�ͼ + */ + rtgui_container_event_handler(widget, event); + + /************************************************************************/ + /* �������DC�IJ��� */ + /************************************************************************/ + + /* ��ÿؼ�������DC */ + dc = rtgui_dc_begin_drawing(widget); + /* ��������������DC�����أ�����ؼ��ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */ + if (dc == RT_NULL) + return RT_FALSE; + + /* ���demo container������ͼ������ */ + demo_view_get_rect(RTGUI_CONTAINER(widget), &rect); + + saved = RTGUI_WIDGET_FONT(widget); + + RTGUI_WIDGET_FONT(widget) = font_16; + rtgui_dc_draw_text(dc, "ABCD����", &rect); + rect.y1 += 18; + + RTGUI_WIDGET_FONT(widget) = font_24; + rtgui_dc_draw_text(dc, "ABCD����", &rect); + rect.y1 += 26; + + RTGUI_WIDGET_FONT(widget) = font_36; + rtgui_dc_draw_text(dc, "ABCD����", &rect); + rect.y1 += 38; + + RTGUI_WIDGET_FONT(widget) = font_48; + rtgui_dc_draw_text(dc, "ABCD����", &rect); + + RTGUI_WIDGET_FONT(widget) = saved; + /* ��ͼ��� */ + rtgui_dc_end_drawing(dc); + } + else + { + /* �����¼�������Ĭ�ϵ��¼��������� */ + return rtgui_container_event_handler(widget, event); + } + + return RT_FALSE; +} + +/* ��������TTF������ʾ��ʾ�õ���ͼ */ +rtgui_container_t *demo_view_ttf() +{ + rtgui_container_t *container; + + font_16 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 16); + font_24 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 24); + font_36 = rtgui_freetype_font_create("d:/simsun.ttf", 0, 0, 36); + font_48 = rtgui_freetype_font_create("d:/simsun.TTF", 0, 0, 72); + + container = demo_view("TTF ��ʾ"); + if (container != RT_NULL) + { + RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(container)) = white; + /* ���ó��Լ����¼��������� */ + rtgui_object_set_event_handler(RTGUI_OBJECT(container), ttf_event_handler); + } + + return container; +} +#endif diff --git a/examples/gui/demo_view_window.c b/examples/gui/demo_view_window.c index 2cbb9b9a57..d6d278681c 100644 --- a/examples/gui/demo_view_window.c +++ b/examples/gui/demo_view_window.c @@ -1,280 +1,296 @@ -/*
- * �����嵥��������ʾ
- *
- * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ͬ��ģʽ��������
- */
-
-#include <rtgui/rtgui.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/window.h>
-#include <rtgui/widgets/label.h>
-#include <rtgui/widgets/button.h>
-#include "demo_view.h"
-#include <string.h>
-
-static struct rtgui_timer *timer;
-static struct rtgui_label* label;
-static struct rtgui_win* msgbox = RT_NULL;
-static char label_text[80];
-static rt_uint8_t cnt = 5;
-
-/* ��ȡһ�������Ĵ��ڱ��� */
-static char* get_win_title()
-{
- static rt_uint8_t win_no = 0;
- static char win_title[16];
-
- rt_sprintf(win_title, "���� %d", ++win_no);
- return win_title;
-}
-
-/* ���ڹر�ʱ���¼����� */
-void window_demo_close(struct rtgui_widget* widget, rtgui_event_t *even)
-{
- rtgui_win_t* win;
-
- /* ������ؼ� */
- win = RTGUI_WIN(rtgui_widget_get_toplevel(widget));
-
- /* ���ٴ��� */
- rtgui_win_destroy(win);
-}
-
-/* �رնԻ���ʱ�Ļص����� */
-void diag_close(struct rtgui_timer* timer, void* parameter)
-{
- cnt --;
- rt_sprintf(label_text, "closed then %d second!", cnt);
-
- /* ���ñ�ǩ�ı������¿ؼ� */
- rtgui_label_set_text(label, label_text);
- rtgui_widget_update(RTGUI_WIDGET(label));
-
- if (cnt == 0)
- {
- /* ��ʱ���رնԻ��� */
- rtgui_win_destroy(msgbox);
-
- /* ֹͣ��ɾ����ʱ�� */
- rtgui_timer_stop(timer);
- rtgui_timer_destory(timer);
- }
-}
-
-/* AUTO���ڹر�ʱ���¼����� */
-rt_bool_t auto_window_close(struct rtgui_widget* widget, struct rtgui_event* event)
-{
- if (timer != RT_NULL)
- {
- /* ֹͣ��ɾ����ʱ�� */
- rtgui_timer_stop(timer);
- rtgui_timer_destory(timer);
-
- timer = RT_NULL;
- }
-
- return RT_TRUE;
-}
-
-static rt_uint16_t delta_x = 20;
-static rt_uint16_t delta_y = 40;
-
-/* ��������������ʾ */
-static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
-{
- rtgui_win_t *win;
- rtgui_label_t *label;
- rtgui_toplevel_t *parent;
- rtgui_rect_t rect = {0, 0, 150, 80};
-
- parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
- rtgui_rect_moveto(&rect, delta_x, delta_y);
- delta_x += 20;
- delta_y += 20;
-
- /* ����һ������ */
- win = rtgui_win_create(parent,
- get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
-
- rect.x1 += 20;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
-
- /* ����һ���ı���ǩ */
- label = rtgui_label_create("����һ����ͨ����");
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
-
- /* ��ģ̬��ʾ���� */
- rtgui_win_show(win, RT_FALSE);
-}
-
-/* �����Զ�������ʾ */
-static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
-{
- rtgui_toplevel_t *parent;
- struct rtgui_rect rect ={50, 50, 200, 200};
-
- parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
- msgbox = rtgui_win_create(parent, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
- if (msgbox != RT_NULL)
- {
- cnt = 5;
- rt_sprintf(label_text, "closed then %d second!", cnt);
- label = rtgui_label_create(label_text);
- rect.x1 += 5;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(msgbox), RTGUI_WIDGET(label));
-
- /* ���ùرմ���ʱ�Ķ��� */
- rtgui_win_set_onclose(msgbox, auto_window_close);
-
- rtgui_win_show(msgbox, RT_FALSE);
- }
-
- /* ����һ����ʱ�� */
- timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
- rtgui_timer_start(timer);
-}
-
-/* ����ģ̬������ʾ */
-static void demo_modalwin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
-{
- rtgui_win_t *win;
- rtgui_label_t *label;
- rtgui_toplevel_t *parent;
- rtgui_rect_t rect = {0, 0, 150, 80};
-
- parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
- rtgui_rect_moveto(&rect, delta_x, delta_y);
- delta_x += 20;
- delta_y += 20;
-
- /* ����һ������ */
- win = rtgui_win_create(parent,
- get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
-
- rect.x1 += 20;
- rect.x2 -= 5;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
-
- label = rtgui_label_create("����һ��ģʽ����");
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
-
- /* ģ̬��ʾ���� */
- rtgui_win_show(win, RT_TRUE);
- /* ����ģ̬��ʾ���ڣ��ر�ʱ��������ɾ�����ڣ���Ҫ����ɾ������ */
- rtgui_win_destroy(win);
-}
-
-/* �����ޱ��ⴰ����ʾ */
-static void demo_ntitlewin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
-{
- rtgui_win_t *win;
- rtgui_label_t *label;
- rtgui_button_t *button;
- rtgui_toplevel_t *parent;
- rtgui_rect_t widget_rect, rect = {0, 0, 150, 80};
-
- parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
- rtgui_rect_moveto(&rect, delta_x, delta_y);
- delta_x += 20;
- delta_y += 20;
-
- /* ����һ�����ڣ����Ϊ�ޱ��⼰�ޱ߿� */
- win = rtgui_win_create(parent,
- "no title", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win)) = white;
-
- /* ����һ���ı���ǩ */
- label = rtgui_label_create("�ޱ߿�");
- rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)), "�ޱ߿�", &widget_rect);
- rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
- widget_rect.y1 += 20;
- widget_rect.y2 += 20;
- rtgui_widget_set_rect(RTGUI_WIDGET(label), &widget_rect);
- rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
-
- /* ����һ���رհ�ť */
- widget_rect.x1 = 0;
- widget_rect.y1 = 0;
- widget_rect.x2 = 40;
- widget_rect.y2 = 20;
- rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
- widget_rect.y1 += 40;
- widget_rect.y2 += 40;
- button = rtgui_button_create("�ر�");
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &widget_rect);
- rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));
- rtgui_button_set_onbutton(button, window_demo_close);
-
- /* ��ģ̬��ʾ���� */
- rtgui_win_show(win, RT_FALSE);
-}
-
-rtgui_view_t* demo_view_window(rtgui_workbench_t* workbench)
-{
- rtgui_rect_t rect;
- rtgui_view_t* view;
- rtgui_button_t *button;
-
- /* ����һ����ʾ�õ���ͼ */
- view = demo_view(workbench, "Window Demo");
-
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5;
- rect.y2 = rect.y1 + 20;
- /* ������ť������ʾ�������� */
- button = rtgui_button_create("Normal Win");
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
- /* ����onbuttonΪdemo_win_onbutton���� */
- rtgui_button_set_onbutton(button, demo_win_onbutton);
-
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25;
- rect.y2 = rect.y1 + 20;
- /* ������ť������ʾһ���Զ��رյĴ��� */
- button = rtgui_button_create("Auto Win");
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
- /* ����onbuttonΪdemo_autowin_onbutton���� */
- rtgui_button_set_onbutton(button, demo_autowin_onbutton);
-
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* ������ť���ڴ���һ��ģʽ���� */
- button = rtgui_button_create("Modal Win");
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
- /* ����onbuttonΪdemo_modalwin_onbutton���� */
- rtgui_button_set_onbutton(button, demo_modalwin_onbutton);
-
- demo_view_get_rect(view, &rect);
- rect.x1 += 5;
- rect.x2 = rect.x1 + 100;
- rect.y1 += 5 + 25 + 25 + 25;
- rect.y2 = rect.y1 + 20;
- /* ������ť���ڴ���һ������������Ĵ��� */
- button = rtgui_button_create("NoTitle Win");
- rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
- rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
- /* ����onbuttonΪdemo_ntitlewin_onbutton���� */
- rtgui_button_set_onbutton(button, demo_ntitlewin_onbutton);
-
- return view;
-}
+/* + * �����嵥��������ʾ + * + * ������ӻ��ȴ�����һ����ʾ�õ�container�����������İ�ťʱ�ͬ��ģʽ�������� + */ + +#include <rtgui/rtgui.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/window.h> +#include <rtgui/widgets/label.h> +#include <rtgui/widgets/button.h> +#include "demo_view.h" +#include <string.h> + +static struct rtgui_timer *timer; +static struct rtgui_label* label; +static struct rtgui_win* msgbox = RT_NULL; +static char label_text[80]; +static rt_uint8_t cnt = 5; + +rtgui_win_t *normal_window; +rtgui_label_t *normal_window_label; +static char normal_window_label_text[16]; +static unsigned char normal_window_show_count = 1; +extern struct rtgui_win *main_win; + +static rt_bool_t normal_window_onclose(struct rtgui_object *win, + struct rtgui_event *event) +{ + normal_window_show_count++; + + return RT_TRUE; +} + +static void create_normal_win(void) +{ + rtgui_rect_t rect = {30, 40, 150, 80}; + + normal_window = rtgui_win_create(RT_NULL, "��ͨ����", + &rect, RTGUI_WIN_STYLE_DEFAULT); + + rect.x1 += 20; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + + /* ����һ���ı���ǩ */ + rt_sprintf(normal_window_label_text, + "�� %d ����ʾ", normal_window_show_count); + normal_window_label = rtgui_label_create(normal_window_label_text); + rtgui_widget_set_rect(RTGUI_WIDGET(normal_window_label), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(normal_window), + RTGUI_WIDGET(normal_window_label)); + + rtgui_win_set_onclose(normal_window, + normal_window_onclose); +} + +/* ��������������ʾ */ +static void demo_normal_window_onbutton(struct rtgui_widget* widget, rtgui_event_t* event) +{ + rt_sprintf(normal_window_label_text, + "�� %d ����ʾ", normal_window_show_count); + rtgui_label_set_text(normal_window_label, + normal_window_label_text); + /* ��ģ̬��ʾ���� */ + rtgui_win_show(normal_window, RT_FALSE); +} + +/* ��ȡһ�������Ĵ��ڱ��� */ +static char* get_win_title() +{ + static rt_uint8_t win_no = 0; + static char win_title[16]; + + rt_sprintf(win_title, "���� %d", ++win_no); + return win_title; +} + +/* �رնԻ���ʱ�Ļص����� */ +void diag_close(struct rtgui_timer* timer, void* parameter) +{ + cnt --; + rt_sprintf(label_text, "closed then %d second!", cnt); + + /* ���ñ�ǩ�ı������¿ؼ� */ + rtgui_label_set_text(label, label_text); + rtgui_widget_update(RTGUI_WIDGET(label)); + + if (cnt == 0) + { + /* ��ʱ���رնԻ��� */ + rtgui_win_destroy(msgbox); + + /* ֹͣ��ɾ����ʱ�� */ + rtgui_timer_stop(timer); + rtgui_timer_destory(timer); + } +} + +/* AUTO���ڹر�ʱ���¼����� */ +rt_bool_t auto_window_close(struct rtgui_object* object, struct rtgui_event* event) +{ + if (timer != RT_NULL) + { + /* ֹͣ��ɾ����ʱ�� */ + rtgui_timer_stop(timer); + rtgui_timer_destory(timer); + + timer = RT_NULL; + } + + return RT_TRUE; +} + +static rt_uint16_t delta_x = 20; +static rt_uint16_t delta_y = 40; + +/* �����Զ�������ʾ */ +static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event) +{ + struct rtgui_rect rect ={50, 50, 200, 200}; + + msgbox = rtgui_win_create(main_win, "Information", + &rect, RTGUI_WIN_STYLE_DEFAULT | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE); + if (msgbox == RT_NULL) + return; + + cnt = 5; + rt_sprintf(label_text, "closed then %d second!", cnt); + label = rtgui_label_create(label_text); + rect.x1 += 5; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(msgbox), + RTGUI_WIDGET(label)); + + /* ���ùرմ���ʱ�Ķ��� */ + rtgui_win_set_onclose(msgbox, auto_window_close); + + rtgui_win_show(msgbox, RT_FALSE); + /* ����һ����ʱ�� */ + timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL); + rtgui_timer_start(timer); +} + +/* ����ģ̬������ʾ */ +static void demo_modalwin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event) +{ + rtgui_win_t *win; + rtgui_label_t *label; + rtgui_rect_t rect = {0, 0, 150, 80}; + + rtgui_rect_moveto(&rect, delta_x, delta_y); + delta_x += 20; + delta_y += 20; + + /* ����һ������ */ + win = rtgui_win_create(main_win, + get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT); + + rect.x1 += 20; + rect.x2 -= 5; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + + label = rtgui_label_create("����һ��ģʽ����"); + rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label)); + + /* ģ̬��ʾ���� */ + rtgui_win_show(win, RT_TRUE); + + /* ɾ�����Զ�ɾ������ */ + rtgui_win_destroy(win); +} + +static void demo_close_ntitle_window(struct rtgui_widget* widget, rtgui_event_t* event) +{ + rtgui_win_t* win; + + /* ������ؼ� */ + win = RTGUI_WIN(rtgui_widget_get_toplevel(widget)); + + /* ���ٴ��� */ + rtgui_win_destroy(win); +} + +/* �����ޱ��ⴰ����ʾ */ +static void demo_ntitlewin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event) +{ + rtgui_win_t *win; + rtgui_label_t *label; + rtgui_button_t *button; + rtgui_rect_t widget_rect, rect = {0, 0, 150, 80}; + + rtgui_rect_moveto(&rect, delta_x, delta_y); + delta_x += 20; + delta_y += 20; + + /* ����һ�����ڣ����Ϊ�ޱ��⼰�ޱ߿� */ + win = rtgui_win_create(main_win, + "no title", &rect, RTGUI_WIN_STYLE_NO_TITLE | + RTGUI_WIN_STYLE_NO_BORDER | + RTGUI_WIN_STYLE_DESTROY_ON_CLOSE); + RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win)) = white; + + /* ����һ���ı���ǩ */ + label = rtgui_label_create("�ޱ߿�"); + rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)), "�ޱ߿�", &widget_rect); + rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL); + widget_rect.y1 += 20; + widget_rect.y2 += 20; + rtgui_widget_set_rect(RTGUI_WIDGET(label), &widget_rect); + rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label)); + RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white; + + /* ����һ���رհ�ť */ + widget_rect.x1 = 0; + widget_rect.y1 = 0; + widget_rect.x2 = 40; + widget_rect.y2 = 20; + rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL); + widget_rect.y1 += 40; + widget_rect.y2 += 40; + button = rtgui_button_create("�ر�"); + rtgui_widget_set_rect(RTGUI_WIDGET(button), &widget_rect); + rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button)); + rtgui_button_set_onbutton(button, demo_close_ntitle_window); + + rtgui_win_show(win, RT_FALSE); +} + +rtgui_container_t* demo_view_window(void) +{ + rtgui_rect_t rect; + rtgui_container_t* container; + rtgui_button_t *button; + + /* ����һ����ʾ�õ���ͼ */ + container = demo_view("Window Demo"); + + create_normal_win(); + + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5; + rect.y2 = rect.y1 + 20; + /* ������ť������ʾ�������� */ + button = rtgui_button_create("Normal Win"); + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(container), RTGUI_WIDGET(button)); + /* ����onbuttonΪdemo_win_onbutton���� */ + rtgui_button_set_onbutton(button, demo_normal_window_onbutton); + + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25; + rect.y2 = rect.y1 + 20; + /* ������ť������ʾһ���Զ��رյĴ��� */ + button = rtgui_button_create("Auto Win"); + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(container), RTGUI_WIDGET(button)); + /* ����onbuttonΪdemo_autowin_onbutton���� */ + rtgui_button_set_onbutton(button, demo_autowin_onbutton); + + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* ������ť���ڴ���һ��ģʽ���� */ + button = rtgui_button_create("Modal Win"); + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(container), RTGUI_WIDGET(button)); + /* ����onbuttonΪdemo_modalwin_onbutton���� */ + rtgui_button_set_onbutton(button, demo_modalwin_onbutton); + + demo_view_get_rect(container, &rect); + rect.x1 += 5; + rect.x2 = rect.x1 + 100; + rect.y1 += 5 + 25 + 25 + 25; + rect.y2 = rect.y1 + 20; + /* ������ť���ڴ���һ������������Ĵ��� */ + button = rtgui_button_create("NoTitle Win"); + rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect); + rtgui_container_add_child(RTGUI_CONTAINER(container), RTGUI_WIDGET(button)); + /* ����onbuttonΪdemo_ntitlewin_onbutton���� */ + rtgui_button_set_onbutton(button, demo_ntitlewin_onbutton); + + return container; +} diff --git a/examples/gui/demo_workbench.c b/examples/gui/demo_workbench.c deleted file mode 100644 index 99669bc298..0000000000 --- a/examples/gui/demo_workbench.c +++ /dev/null @@ -1,139 +0,0 @@ -#include <rtgui/rtgui.h> -#include <rtgui/rtgui_system.h> - -#include <rtgui/widgets/view.h> -#include <rtgui/widgets/workbench.h> - -static rt_bool_t demo_workbench_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) -{ - /* ����Ŀǰֻ�����¼�����Ȥ�������ǰworkbench����ģʽ��ʾ״̬�������� */ - if ((event->type == RTGUI_EVENT_KBD) && !RTGUI_WORKBENCH_IS_MODAL_MODE(RTGUI_WORKBENCH(widget))) - { - struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event; - - if (ekbd->type == RTGUI_KEYDOWN) - { - if (ekbd->key == RTGUIK_RIGHT) - { - demo_view_next(RT_NULL, RT_NULL); - return RT_TRUE; - } - else if (ekbd->key == RTGUIK_LEFT) - { - demo_view_prev(RT_NULL, RT_NULL); - return RT_TRUE; - } - } - } - - /* ������ǻ����¼���ʹ��viewԭ�����¼������������� */ - return rtgui_workbench_event_handler(widget, event); -} - -static void workbench_entry(void* parameter) -{ - rt_mq_t mq; - struct rtgui_workbench* workbench; - - /* ����GUIӦ����Ҫ����Ϣ���� */ -#ifdef RTGUI_USING_SMALL_SIZE - mq = rt_mq_create("workbench", 32, 32, RT_IPC_FLAG_FIFO); -#else - mq = rt_mq_create("workbench", 256, 32, RT_IPC_FLAG_FIFO); -#endif - /* ע�ᵱǰ�߳�ΪGUI�߳� */ - rtgui_thread_register(rt_thread_self(), mq); - - /* ����һ������̨ */ - workbench = rtgui_workbench_create("main", "workbench"); - if (workbench == RT_NULL) return; - - rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), demo_workbench_event_handler); - - /* ��ʼ���������ӵ���ͼ */ -#if RTTHREAD_VERSION >= 10000 - demo_view_benchmark(workbench); -#endif - - demo_view_dc(workbench); -#if RTTHREAD_VERSION >= 10000 -#ifdef RTGUI_USING_TTF - demo_view_ttf(workbench); -#endif -#endif - -#ifndef RTGUI_USING_SMALL_SIZE - demo_view_dc_buffer(workbench); -#endif - demo_view_animation(workbench); -#ifndef RTGUI_USING_SMALL_SIZE - demo_view_buffer_animation(workbench); - demo_view_instrument_panel(workbench); -#endif - demo_view_window(workbench); - demo_view_label(workbench); - demo_view_button(workbench); - demo_view_checkbox(workbench); - demo_view_progressbar(workbench); - demo_view_scrollbar(workbench); - demo_view_radiobox(workbench); - demo_view_textbox(workbench); - demo_view_listbox(workbench); - demo_view_menu(workbench); - demo_view_listctrl(workbench); - demo_view_combobox(workbench); - demo_view_slider(workbench); - // demo_view_notebook(workbench); - demo_view_mywidget(workbench); -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) - demo_view_image(workbench); -#endif -#ifdef RT_USING_MODULE -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) - demo_view_module(workbench); -#endif -#endif - demo_listview_view(workbench); - demo_listview_icon_view(workbench); -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) - demo_fn_view(workbench); -#endif - - /* ��ʾ��ͼ */ - demo_view_show(); - - /* ִ�й���̨�¼�ѭ�� */ - rtgui_workbench_event_loop(workbench); - - /* ȥע��GUI�߳� */ - rtgui_thread_deregister(rt_thread_self()); - rt_mq_delete(mq); -} - -void workbench_init() -{ - static rt_bool_t inited = RT_FALSE; - - if (inited == RT_FALSE) /* �����ظ���ʼ�������ı��� */ - { - rt_thread_t tid; - - tid = rt_thread_create("wb", - workbench_entry, RT_NULL, - 2048 * 2, 25, 10); - - if (tid != RT_NULL) rt_thread_startup(tid); - - inited = RT_TRUE; - } -} - -#ifdef RT_USING_FINSH -#include <finsh.h> -void workbench() -{ - workbench_init(); -} -/* finsh���������������ֱ��ִ��workbench()������ִ������ĺ��� */ -FINSH_FUNCTION_EXPORT(workbench, workbench demo) -#endif diff --git a/examples/gui/demo_xml.c b/examples/gui/demo_xml.c index 11a448103b..398161039d 100644 --- a/examples/gui/demo_xml.c +++ b/examples/gui/demo_xml.c @@ -1,26 +1,26 @@ -#include <rtthread.h>
-
-#include <rtgui/rtgui_xml.h>
-
-static int xml_event_handler(rt_uint8_t event, const char* text, rt_size_t len, void* user)
-{
- rt_kprintf("%s: %s\n", rtgui_xml_event_str(event), text);
- return 1;
-}
-
-const char xml_str[] = "<?xml version=\"1.0\"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>";
-void demo_xml()
-{
- rtgui_xml_t *xml;
-
- xml = rtgui_xml_create(512, xml_event_handler, RT_NULL);
- if (xml != RT_NULL)
- {
- rtgui_xml_parse(xml, xml_str, sizeof(xml_str));
- rtgui_xml_destroy(xml);
- }
-}
-#ifdef RT_USING_FINSH
-#include <finsh.h>
-FINSH_FUNCTION_EXPORT(demo_xml, show the demo of xml parser);
-#endif
+#include <rtthread.h> + +#include <rtgui/rtgui_xml.h> + +static int xml_event_handler(rt_uint8_t event, const char* text, rt_size_t len, void* user) +{ + rt_kprintf("%s: %s\n", rtgui_xml_event_str(event), text); + return 1; +} + +const char xml_str[] = "<?xml version=\"1.0\"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>"; +void demo_xml() +{ + rtgui_xml_t *xml; + + xml = rtgui_xml_create(512, xml_event_handler, RT_NULL); + if (xml != RT_NULL) + { + rtgui_xml_parse(xml, xml_str, sizeof(xml_str)); + rtgui_xml_destroy(xml); + } +} +#ifdef RT_USING_FINSH +#include <finsh.h> +FINSH_FUNCTION_EXPORT(demo_xml, show the demo of xml parser); +#endif diff --git a/examples/gui/gui_init.c b/examples/gui/gui_init.c index e0145a7716..6522046179 100644 --- a/examples/gui/gui_init.c +++ b/examples/gui/gui_init.c @@ -1,19 +1,19 @@ -#include <rtgui/rtgui.h>
-#include <rtgui/rtgui_server.h>
-#include <rtgui/rtgui_system.h>
-
-extern void workbench_init(void);
-extern void panel_init(void);
-
-/* GUI�����ʾ��ڣ�������߳��н��г�ʼ�� */
-void rtgui_startup()
-{
- /* GUIϵͳ��ʼ�� */
- rtgui_system_server_init();
-
- /* ��������ʼ�� */
- panel_init();
-
- /* ����workbench */
- workbench_init();
-}
+#include <rtgui/rtgui.h> +#include <rtgui/rtgui_server.h> +#include <rtgui/rtgui_system.h> + +extern void workbench_init(void); +extern void panel_init(void); + +/* GUI�����ʾ��ڣ�������߳��н��г�ʼ�� */ +void rtgui_startup() +{ + /* GUIϵͳ��ʼ�� */ + rtgui_system_server_init(); + + /* ��������ʼ�� */ + panel_init(); + + /* ����workbench */ + workbench_init(); +} diff --git a/examples/gui/mywidget.c b/examples/gui/mywidget.c index 095e8a5695..24ff207627 100644 --- a/examples/gui/mywidget.c +++ b/examples/gui/mywidget.c @@ -1,136 +1,136 @@ -#include <rtgui/dc.h>
-#include "mywidget.h"
-
-/* 控件绘图函数 */
-static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me)
-{
- struct rtgui_dc* dc;
- struct rtgui_rect rect;
- rt_uint16_t x, y;
-
- /* 获得目标DC,开始绘�?*/
- dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(me));
- if (dc == RT_NULL) return;
-
- /* 获得窗口的尺�?*/
- rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect);
- /* 绘制背景�?*/
- RTGUI_DC_BC(dc) = white;
- rtgui_dc_fill_rect(dc, &rect);
-
- /* 计算中心原点 */
- x = (rect.x2 + rect.x1)/2;
- y = (rect.y2 + rect.y1)/2;
-
- /* 绘制十字�?*/
- RTGUI_DC_FC(dc) = black;
- rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y);
- rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2);
-
- /* 根据状态绘制圆�?*/
- if (me->status == MYWIDGET_STATUS_ON)
- RTGUI_DC_FC(dc) = green;
- else
- RTGUI_DC_FC(dc) = red;
- rtgui_dc_fill_circle(dc, x, y, 5);
-
- /* 结束绘图 */
- rtgui_dc_end_drawing(dc);
- return;
-}
-
-/* 鼠标事件处理函数 */
-static void rtgui_mywidget_onmouse(struct rtgui_mywidget* me, struct rtgui_event_mouse* mouse)
-{
- struct rtgui_rect rect;
- rt_uint16_t x, y;
-
- /* 仅对鼠标抬起动作进行处理 */
- if (!(mouse->button & RTGUI_MOUSE_BUTTON_UP)) return;
-
- /* 获得控件的位�?*/
- rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect);
- /* get_rect函数获得是控件的相对位置,而鼠标事件给出的坐标是绝对坐标,需要做一个转�?*/
- rtgui_widget_rect_to_device(RTGUI_WIDGET(me), &rect);
-
- /* 计算中心原点 */
- x = (rect.x2 + rect.x1)/2;
- y = (rect.y2 + rect.y1)/2;
-
- /* 比较鼠标坐标是否在圈�?*/
- if ((mouse->x < x + 5 && mouse->x > x - 5) &&
- (mouse->y < y + 5 && mouse->y > y - 5))
- {
- /* 更改控件状�?*/
- if (me->status & MYWIDGET_STATUS_ON) me->status = MYWIDGET_STATUS_OFF;
- else me->status = MYWIDGET_STATUS_ON;
-
- /* 刷新(重新绘制)控件 */
- rtgui_mywidget_ondraw(me);
- }
-}
-
-/* mywidget控件的事件处理函�?*/
-rt_bool_t rtgui_mywidget_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
-{
- /* 调用事件处理函数时,widget指针指向控件本身,所以先获得相应控件对象的指�?*/
- struct rtgui_mywidget* me = RTGUI_MYWIDGET(widget);
-
- switch (event->type)
- {
- case RTGUI_EVENT_PAINT:
- /* 绘制事件,调用绘图函数绘�?*/
- rtgui_mywidget_ondraw(me);
- break;
-
- case RTGUI_EVENT_MOUSE_BUTTON:
- /* 鼠标事件 */
- rtgui_mywidget_onmouse(RTGUI_MYWIDGET(me), (struct rtgui_event_mouse*) event);
- break;
-
- /* 其他事件调用父类的事件处理函�?*/
- default:
- return rtgui_widget_event_handler(widget, event);
- }
-
- return RT_FALSE;
-}
-
-/* 自定义控件的构造函�?*/
-static void _rtgui_mywidget_constructor(rtgui_mywidget_t *mywidget)
-{
- /* 默认这个控件接收聚焦 */
- RTGUI_WIDGET(mywidget)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
- /* 初始化控件并设置事件处理函数 */
- rtgui_widget_set_event_handler(RTGUI_WIDGET(mywidget), rtgui_mywidget_event_handler);
-
- /* 初始状态时OFF */
- mywidget->status = MYWIDGET_STATUS_OFF;
-}
-
-DEFINE_CLASS_TYPE(mywidget, "mywidget",
- RTGUI_WIDGET_TYPE,
- _rtgui_mywidget_constructor,
- RT_NULL,
- sizeof(struct rtgui_mywidget));
-
-/* 创建一个自定义控件 */
-struct rtgui_mywidget* rtgui_mywidget_create(rtgui_rect_t* r)
-{
- struct rtgui_mywidget* me;
-
- /* 让rtgui_widget创建出一个指定类型:RTGUI_MYWIDGET_TYPE类型的控�?*/
- me = (struct rtgui_mywidget*) rtgui_widget_create (RTGUI_MYWIDGET_TYPE);
- if (me != RT_NULL)
- {
- rtgui_widget_set_rect(RTGUI_WIDGET(me), r);
- }
-
- return me;
-}
-
-/* 删除一个自定义控件 */
-void rtgui_mywidget_destroy(struct rtgui_mywidget* me)
-{
- rtgui_widget_destroy(RTGUI_WIDGET(me));
-}
+#include <rtgui/dc.h> +#include "mywidget.h" + +/* 控件绘图函数 */ +static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me) +{ + struct rtgui_dc* dc; + struct rtgui_rect rect; + rt_uint16_t x, y; + + /* 获得目标DC,开始绘�?*/ + dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(me)); + if (dc == RT_NULL) return; + + /* 获得窗口的尺�?*/ + rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect); + /* 绘制背景�?*/ + RTGUI_DC_BC(dc) = white; + rtgui_dc_fill_rect(dc, &rect); + + /* 计算中心原点 */ + x = (rect.x2 + rect.x1)/2; + y = (rect.y2 + rect.y1)/2; + + /* 绘制十字�?*/ + RTGUI_DC_FC(dc) = black; + rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y); + rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2); + + /* 根据状态绘制圆�?*/ + if (me->status == MYWIDGET_STATUS_ON) + RTGUI_DC_FC(dc) = green; + else + RTGUI_DC_FC(dc) = red; + rtgui_dc_fill_circle(dc, x, y, 5); + + /* 结束绘图 */ + rtgui_dc_end_drawing(dc); + return; +} + +/* 鼠标事件处理函数 */ +static void rtgui_mywidget_onmouse(struct rtgui_mywidget* me, struct rtgui_event_mouse* mouse) +{ + struct rtgui_rect rect; + rt_uint16_t x, y; + + /* 仅对鼠标抬起动作进行处理 */ + if (!(mouse->button & RTGUI_MOUSE_BUTTON_UP)) return; + + /* 获得控件的位�?*/ + rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect); + /* get_rect函数获得是控件的相对位置,而鼠标事件给出的坐标是绝对坐标,需要做一个转�?*/ + rtgui_widget_rect_to_device(RTGUI_WIDGET(me), &rect); + + /* 计算中心原点 */ + x = (rect.x2 + rect.x1)/2; + y = (rect.y2 + rect.y1)/2; + + /* 比较鼠标坐标是否在圈�?*/ + if ((mouse->x < x + 5 && mouse->x > x - 5) && + (mouse->y < y + 5 && mouse->y > y - 5)) + { + /* 更改控件状�?*/ + if (me->status & MYWIDGET_STATUS_ON) me->status = MYWIDGET_STATUS_OFF; + else me->status = MYWIDGET_STATUS_ON; + + /* 刷新(重新绘制)控件 */ + rtgui_mywidget_ondraw(me); + } +} + +/* mywidget控件的事件处理函�?*/ +rt_bool_t rtgui_mywidget_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) +{ + /* 调用事件处理函数时,widget指针指向控件本身,所以先获得相应控件对象的指�?*/ + struct rtgui_mywidget* me = RTGUI_MYWIDGET(widget); + + switch (event->type) + { + case RTGUI_EVENT_PAINT: + /* 绘制事件,调用绘图函数绘�?*/ + rtgui_mywidget_ondraw(me); + break; + + case RTGUI_EVENT_MOUSE_BUTTON: + /* 鼠标事件 */ + rtgui_mywidget_onmouse(RTGUI_MYWIDGET(me), (struct rtgui_event_mouse*) event); + break; + + /* 其他事件调用父类的事件处理函�?*/ + default: + return rtgui_widget_event_handler(RTGUI_OBJECT(widget), event); + } + + return RT_FALSE; +} + +/* 自定义控件的构造函�?*/ +static void _rtgui_mywidget_constructor(rtgui_mywidget_t *mywidget) +{ + /* 默认这个控件接收聚焦 */ + RTGUI_WIDGET(mywidget)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; + /* 初始化控件并设置事件处理函数 */ + rtgui_object_set_event_handler(RTGUI_OBJECT(mywidget), rtgui_mywidget_event_handler); + + /* 初始状态时OFF */ + mywidget->status = MYWIDGET_STATUS_OFF; +} + +DEFINE_CLASS_TYPE(mywidget, "mywidget", + RTGUI_WIDGET_TYPE, + _rtgui_mywidget_constructor, + RT_NULL, + sizeof(struct rtgui_mywidget)); + +/* 创建一个自定义控件 */ +struct rtgui_mywidget* rtgui_mywidget_create(rtgui_rect_t* r) +{ + struct rtgui_mywidget* me; + + /* 让rtgui_widget创建出一个指定类型:RTGUI_MYWIDGET_TYPE类型的控�?*/ + me = (struct rtgui_mywidget*) rtgui_widget_create (RTGUI_MYWIDGET_TYPE); + if (me != RT_NULL) + { + rtgui_widget_set_rect(RTGUI_WIDGET(me), r); + } + + return me; +} + +/* 删除一个自定义控件 */ +void rtgui_mywidget_destroy(struct rtgui_mywidget* me) +{ + rtgui_widget_destroy(RTGUI_WIDGET(me)); +} diff --git a/examples/gui/mywidget.h b/examples/gui/mywidget.h index 8de95ba1c6..65a68a01bd 100644 --- a/examples/gui/mywidget.h +++ b/examples/gui/mywidget.h @@ -1,50 +1,50 @@ -/*
- * 程序清单:自定义控件
- *
- * 这个例子是要实现一个自定义控件,外观大致如
- * |
- * --o--
- * |
+/* + * 程序清单:自定义控件 + * + * 这个例子是要实现一个自定义控件,外观大致如 + * | + * --o-- + * | * 的形状,中间的o色彩表示了当前的状态,ON状态时是绿色,OFF状态时是红色�? * 并且,这个o位置接受鼠标点击,点击下切换下相应的状态�? - */
-#ifndef __MY_WIDGET_H__
-#define __MY_WIDGET_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-
-/* 自定义控件的状态值定�?*/
-#define MYWIDGET_STATUS_ON 1
-#define MYWIDGET_STATUS_OFF 0
-
-DECLARE_CLASS_TYPE(mywidget);
-/** 每个控件会有一个类型,通过如下的宏获得控件相应的类型信�?*/
-#define RTGUI_MYWIDGET_TYPE (RTGUI_TYPE(mywidget))
-/** 对一个对象实例,可以通过下面的宏实现类型转换 */
-#define RTGUI_MYWIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MYWIDGET_TYPE, rtgui_mywidget_t))
-/** 可以通过下面的宏以决定一个具体实例是否是自定义控件类�?*/
-#define RTGUI_IS_MYWIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MYWIDGET_TYPE))
-
-/* 个性化控件类定�?*/
-struct rtgui_mywidget
-{
- /* 这个控件是继承自rtgui_widget控件 */
- struct rtgui_widget parent;
-
- /* 状态:ON、OFF */
- rt_uint8_t status;
-};
-typedef struct rtgui_mywidget rtgui_mywidget_t;
-
-/* 控件的创建和删除 */
-struct rtgui_mywidget* rtgui_mywidget_create(rtgui_rect_t* r);
-void rtgui_mywidget_destroy(struct rtgui_mywidget* me);
-
+ */ +#ifndef __MY_WIDGET_H__ +#define __MY_WIDGET_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +/* 自定义控件的状态值定�?*/ +#define MYWIDGET_STATUS_ON 1 +#define MYWIDGET_STATUS_OFF 0 + +DECLARE_CLASS_TYPE(mywidget); +/** 每个控件会有一个类型,通过如下的宏获得控件相应的类型信�?*/ +#define RTGUI_MYWIDGET_TYPE (RTGUI_TYPE(mywidget)) +/** 对一个对象实例,可以通过下面的宏实现类型转换 */ +#define RTGUI_MYWIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MYWIDGET_TYPE, rtgui_mywidget_t)) +/** 可以通过下面的宏以决定一个具体实例是否是自定义控件类�?*/ +#define RTGUI_IS_MYWIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MYWIDGET_TYPE)) + +/* 个性化控件类定�?*/ +struct rtgui_mywidget +{ + /* 这个控件是继承自rtgui_widget控件 */ + struct rtgui_widget parent; + + /* 状态:ON、OFF */ + rt_uint8_t status; +}; +typedef struct rtgui_mywidget rtgui_mywidget_t; + +/* 控件的创建和删除 */ +struct rtgui_mywidget* rtgui_mywidget_create(rtgui_rect_t* r); +void rtgui_mywidget_destroy(struct rtgui_mywidget* me); + /* 控件的默认事件处理函数�? - * 对一个控件而言,如果派生自它的子控件很可能会调用父控件的事件处理函数,
+ * 对一个控件而言,如果派生自它的子控件很可能会调用父控件的事件处理函数, * 所以这里采用公开声明的方式�? - */
-rt_bool_t rtgui_mywidget_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-#endif
+ */ +rt_bool_t rtgui_mywidget_event_handler(struct rtgui_widget* widget, struct rtgui_event* event); + +#endif diff --git a/examples/gui/play.hdh b/examples/gui/play.hdh index 276852cabc..0230cf09cc 100644 --- a/examples/gui/play.hdh +++ b/examples/gui/play.hdh @@ -1,107 +1,107 @@ -static const unsigned char play_hdh[] = {
- 0x48, 0x44, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0x9d, 0xae, 0xdf, 0xef, 0xbf, 0xe7, 0xbf, 0xe7,
- 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7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x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, + 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, + 0xdb, 0x8d, 0xdb, 0x8d, +}; diff --git a/examples/gui/stop.hdh b/examples/gui/stop.hdh index 9271b7ec9a..83f9e60b78 100644 --- a/examples/gui/stop.hdh +++ b/examples/gui/stop.hdh @@ -1,107 +1,107 @@ -static const unsigned char stop_hdh[] = {
- 0x48, 0x44, 0x43, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d, 0xdb, 0x8d,
- 0xdb, 0x8d, 0xdb, 0x8d, 0x9d, 0xae, 0xdf, 0xef, 0xbf, 0xe7, 0xbf, 0xe7,
- 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7,
- 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7,
- 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7,
- 0xbf, 0xe7, 0xbf, 0xe7, 0xbf, 0xe7, 0xbf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