summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/gui/demo_fnview.c23
-rw-r--r--examples/gui/demo_listview.c18
-rw-r--r--examples/gui/demo_view_dc.c26
-rw-r--r--examples/gui/demo_view_image.c32
-rw-r--r--examples/gui/demo_view_window.c12
5 files changed, 92 insertions, 19 deletions
diff --git a/examples/gui/demo_fnview.c b/examples/gui/demo_fnview.c
index c1451d4ba3..034e7d743e 100644
--- a/examples/gui/demo_fnview.c
+++ b/examples/gui/demo_fnview.c
@@ -1,31 +1,43 @@
+/*
+ * �����嵥���ļ��б���ͼ��ʾ
+ *
+ * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ
+ * �µ��ļ��б���ͼ��
+ */
#include "demo_view.h"
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/filelist_view.h>
+/* ������ʾѡ���ļ������ı���ǩ */
static rtgui_label_t* label;
+/* �����ļ��б���ͼ�İ�ť�ص����� */
static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
{
- /* create a file list view */
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];
- /* set label */
+ /* ���ļ��б���ͼ�гɹ�ѡ���ļ�����������Ӧ��·���� */
rtgui_filelist_get_fullpath(view, path, sizeof(path));
+ /* �����ļ�·�����ı���ǩ */
rtgui_label_set_text(label, path);
}
@@ -33,6 +45,7 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
rtgui_view_destroy(RTGUI_VIEW(view));
}
+/* ����������ʾ�ļ��б���ͼ����ͼ */
rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect;
@@ -40,25 +53,31 @@ rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
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);
diff --git a/examples/gui/demo_listview.c b/examples/gui/demo_listview.c
index fb573b7daf..a4adaaafda 100644
--- a/examples/gui/demo_listview.c
+++ b/examples/gui/demo_listview.c
@@ -1,3 +1,9 @@
+/*
+ * �����嵥���б���ͼ��ʾ
+ *
+ * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�ᰴ��ģʽ��ʾ����ʽ��ʾ
+ * �µ��б���ͼ
+ */
#include "demo_view.h"
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
@@ -8,6 +14,7 @@ static rtgui_workbench_t* workbench = RT_NULL;
static rtgui_list_view_t* _view = RT_NULL;
static rtgui_image_t* return_image = RT_NULL;
+/* �б���Ķ������� */
static void listitem_action(void* parameter)
{
char label_text[32];
@@ -27,6 +34,7 @@ static void listitem_action(void* parameter)
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
+ /* ������Ӧ�ı�ǩ */
rt_sprintf(label_text, "���� %d", no);
label = rtgui_label_create(label_text);
@@ -37,15 +45,18 @@ static void listitem_action(void* parameter)
rtgui_win_show(win, RT_FALSE);
}
+/* ���ع��ܵĶ������� */
static void return_action(void* parameter)
{
if (_view != RT_NULL)
{
+ /* ɾ���б���ͼ */
rtgui_view_destroy(RTGUI_VIEW(_view));
_view = RT_NULL;
}
}
+/* �����б���� */
static struct rtgui_list_item items[] =
{
{"���1", RT_NULL, listitem_action, (void*)1},
@@ -56,22 +67,26 @@ static struct rtgui_list_item items[] =
{"����", RT_NULL, return_action, RT_NULL},
};
+/* ���б���ͼ�õİ�ť�������� */
static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
{
- /* create a file list view */
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);
+ /* ��workbench��������Ӧ����ͼ */
rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view));
/* ģʽ��ʾ��ͼ */
rtgui_view_show(RTGUI_VIEW(_view), RT_FALSE);
}
+/* ����������ʾ�б���ͼ����ͼ */
rtgui_view_t* demo_listview_view(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect;
@@ -80,6 +95,7 @@ rtgui_view_t* demo_listview_view(rtgui_workbench_t* workbench)
view = demo_view(workbench, "�б���ͼ��ʾ");
+ /* ���Ӷ�����ť */
demo_view_get_rect(view, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 80;
diff --git a/examples/gui/demo_view_dc.c b/examples/gui/demo_view_dc.c
index bb12fb7fdc..501286aa99 100644
--- a/examples/gui/demo_view_dc.c
+++ b/examples/gui/demo_view_dc.c
@@ -1,10 +1,20 @@
+/*
+ * �����嵥��DC������ʾ
+ *
+ * ������ӻ��ڴ�������view�Ͻ���DC��������ʾ
+ */
+
#include "demo_view.h"
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/slider.h>
+/*
+ * 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;
@@ -12,22 +22,27 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
rt_uint32_t vx[] = {20, 50, 60, 45, 60, 20};
rt_uint32_t vy[] = {150, 50, 90, 60, 45, 50};
- /* ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view�Ȼ�ͼ */
+ /*
+ * ��Ϊ�õ���demo view�����汾����һ���ֿؼ��������ڻ�ͼʱ��Ҫ��demo view
+ * �Ȼ�ͼ
+ */
rtgui_view_event_handler(widget, event);
/************************************************************************/
- /* �������DC�Ĵ��� */
+ /* �������DC�IJ��� */
/************************************************************************/
/* ��ÿؼ�������DC */
dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��򸸿ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
+ /* ��������������DC�����أ�����ؼ��򸸿ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
+ if (dc == RT_NULL)
return RT_FALSE;
/* ���demo view������ͼ������ */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
rtgui_dc_set_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
@@ -109,24 +124,27 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
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;
diff --git a/examples/gui/demo_view_image.c b/examples/gui/demo_view_image.c
index 5053b8cd41..c68b56f347 100644
--- a/examples/gui/demo_view_image.c
+++ b/examples/gui/demo_view_image.c
@@ -1,3 +1,9 @@
+/*
+ * �����嵥��DC����ʾͼ����ʾ
+ *
+ * ������ӻ��ڴ�������view����ʾͼ��
+ */
+
#include "demo_view.h"
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/filelist_view.h>
@@ -5,26 +11,29 @@
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)
{
- /* create a file list view */
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];
- /* set label */
+ /* �����ļ�·���ı�ǩ */
rtgui_filelist_get_fullpath(view, path, sizeof(path));
if (image != RT_NULL) rtgui_image_destroy(image);
@@ -32,15 +41,16 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
/* ���ͼ������� */
if (rt_strstr(path, ".png") != RT_NULL ||
- 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)
+ rt_strstr(path, ".JPG") != RT_NULL)
strcat(image_type, "jpeg");
if (rt_strstr(path, ".hdc") != RT_NULL ||
- 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);
}
@@ -50,11 +60,12 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
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)
@@ -64,7 +75,8 @@ static rt_bool_t demo_view_event_handler(rtgui_widget_t* widget, rtgui_event_t *
/* ��ÿؼ�������DC */
dc = rtgui_dc_begin_drawing(widget);
- if (dc == RT_NULL) /* ��������������DC�����أ�����ؼ��򸸿ؼ�������״̬��DC�ǻ�ȡ���ɹ��ģ� */
+ if (dc == RT_NULL)
+ /* ��������������DC������(����ؼ��򸸿ؼ�������״̬��DC�ǻ�ȡ���ɹ���) */
return RT_FALSE;
/* ���demo view������ͼ������ */
@@ -72,7 +84,7 @@ static rt_bool_t demo_view_event_handler(rtgui_widget_t* widget, rtgui_event_t *
/* ���ͼ����ʾ���� */
rect.x1 += 5; rect.x2 -= 5;
- rect.y1 += 30;
+ rect.y1 += 30;
if (image != RT_NULL)
rtgui_image_blit(image, dc, &rect);
@@ -84,15 +96,19 @@ static rt_bool_t demo_view_event_handler(rtgui_widget_t* widget, rtgui_event_t *
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;
diff --git a/examples/gui/demo_view_window.c b/examples/gui/demo_view_window.c
index c3eedf843d..8445d1b8ec 100644
--- a/examples/gui/demo_view_window.c
+++ b/examples/gui/demo_view_window.c
@@ -1,3 +1,9 @@
+/*
+ * �����嵥��������ʾ
+ *
+ * ������ӻ��ȴ�����һ����ʾ�õ�view�����������İ�ťʱ�᲻ͬ��ģʽ��������
+ */
+
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/window.h>
@@ -79,6 +85,7 @@ static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
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));
@@ -91,10 +98,7 @@ static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
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
- };
+ 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);