2010-03-14 21:47:49 +08:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ʾ
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD>view<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>ťʱ<EFBFBD>ᰴ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ʾ
|
|
|
|
|
* <EFBFBD>µ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2010-01-18 07:41:59 +08:00
|
|
|
|
#include "demo_view.h"
|
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
|
#include <rtgui/widgets/button.h>
|
2010-01-27 08:05:32 +08:00
|
|
|
|
#include <rtgui/widgets/filelist_view.h>
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-10-16 07:40:44 +08:00
|
|
|
|
#ifdef RT_USING_DFS
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾѡ<CABE><D1A1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ǩ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
static rtgui_label_t* label;
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>İ<EFBFBD>ť<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-27 08:05:32 +08:00
|
|
|
|
static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
|
2010-01-18 07:41:59 +08:00
|
|
|
|
{
|
2010-01-27 08:05:32 +08:00
|
|
|
|
rtgui_filelist_view_t *view;
|
|
|
|
|
rtgui_workbench_t *workbench;
|
|
|
|
|
rtgui_rect_t rect;
|
2010-01-26 17:38:38 +08:00
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>workbench<63><68><EFBFBD><EFBFBD> */
|
2010-01-27 08:05:32 +08:00
|
|
|
|
workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
|
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>Win32ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ̨<C6BD><CCA8><EFBFBD>IJ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ʵĿ¼λ<C2BC><CEBB> */
|
2010-02-01 17:45:33 +08:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
|
|
|
|
|
#else
|
2010-01-27 08:05:32 +08:00
|
|
|
|
view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
|
2010-02-01 17:45:33 +08:00
|
|
|
|
#endif
|
2010-03-14 21:47:49 +08:00
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ʽ<EFBFBD><CABD>ʾ<EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ */
|
2010-01-27 08:05:32 +08:00
|
|
|
|
if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
|
|
|
|
|
{
|
|
|
|
|
char path[32];
|
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>гɹ<D0B3>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>·<EFBFBD><C2B7><EFBFBD><EFBFBD> */
|
2010-05-15 22:38:12 +08:00
|
|
|
|
rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
|
2010-01-27 08:05:32 +08:00
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ǩ */
|
2010-01-27 08:05:32 +08:00
|
|
|
|
rtgui_label_set_text(label, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ɾ<><C9BE> <20>ļ<EFBFBD><C4BC>б<EFBFBD> <20><>ͼ */
|
|
|
|
|
rtgui_view_destroy(RTGUI_VIEW(view));
|
2010-01-18 07:41:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ͼ */
|
2010-01-18 07:41:59 +08:00
|
|
|
|
rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
|
|
|
|
|
{
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
rtgui_view_t* view;
|
|
|
|
|
rtgui_button_t* open_btn;
|
|
|
|
|
rtgui_font_t* font;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>12<31><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
font = rtgui_font_refer("asc", 12);
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
view = demo_view(workbench, "FileList View");
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
demo_view_get_rect(view, &rect);
|
2010-01-18 07:41:59 +08:00
|
|
|
|
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y1 += 5;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD>õ<EFBFBD><C3B5>ı<EFBFBD><C4B1><EFBFBD>ǩ */
|
2010-03-14 14:36:46 +08:00
|
|
|
|
label = rtgui_label_create("fn: ");
|
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
2010-01-18 07:41:59 +08:00
|
|
|
|
RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
|
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
demo_view_get_rect(view, &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 = rect.x1 + 80;
|
|
|
|
|
rect.y1 += 30;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ */
|
2010-03-14 14:36:46 +08:00
|
|
|
|
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);
|
2010-01-18 07:41:59 +08:00
|
|
|
|
RTGUI_WIDGET_FONT(RTGUI_WIDGET(open_btn)) = font;
|
|
|
|
|
rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
|
|
|
|
|
|
2010-03-14 14:36:46 +08:00
|
|
|
|
return view;
|
2010-01-18 07:41:59 +08:00
|
|
|
|
}
|
2010-10-16 07:40:44 +08:00
|
|
|
|
#endif
|