static void info_entry(void* parameter) { rt_mq_t mq; struct rtgui_view* view; struct rtgui_workbench* workbench; mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); network_image = rtgui_image_create_from_mem("xpm", (rt_uint8_t*)network_xpm, sizeof(network_xpm), RT_TRUE); workbench = rtgui_workbench_create("info", "workbench"); if (workbench == RT_NULL) return; view = rtgui_view_create("view"); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white; rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); rtgui_workbench_add_view(workbench, view); rtgui_view_show(view, RT_FALSE); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
static void info_entry(void* parameter) { rt_mq_t mq; struct rtgui_view* view; struct rtgui_workbench* workbench; mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); workbench = rtgui_workbench_create("info", "workbench"); if(workbench == RT_NULL) return; view = rtgui_view_create("view"); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(view)) = black; rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); rtgui_workbench_add_view(workbench, view); /* this view can be focused */ RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* set widget focus */ rtgui_widget_focus(RTGUI_WIDGET(view)); rtgui_view_show(view, RT_FALSE); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
void window_entry(void* parameter) { rt_mq_t mq; char name[32]; rtgui_win_t *win; rtgui_rect_t rect = {10, 30, 110, 130}; mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO); /* 注册当前线程为GUI线程 */ rtgui_thread_register(rt_thread_self(), mq); snprintf(name, sizeof(name), "win %d", (rt_uint32_t)parameter); win = rtgui_win_create(RT_NULL, name, &rect, RTGUI_WIN_STYLE_DEFAULT); /* 显示窗口 */ rtgui_win_show(win, RT_FALSE); /* 执行窗口的事件循环 */ rtgui_win_event_loop(win); /* 去注册GUI线程 */ rtgui_thread_deregister(rt_thread_self()); /* delete message queue */ rt_mq_delete(mq); }
static void today_entry(void* parameter) { rt_mq_t mq; struct rtgui_view* view; struct rtgui_workbench* workbench; mq = rt_mq_create("qToday", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); /* create background image */ background = rtgui_image_create_from_file("png", "/bg.png", RT_FALSE); workbench = rtgui_workbench_create("main", "workbench"); if (workbench == RT_NULL) return; view = rtgui_view_create("Today"); rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); rtgui_workbench_add_view(workbench, view); rtgui_view_show(view); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
static void player_entry(void* parameter) { rt_mq_t mq; rtgui_rect_t rect; mq = rt_mq_create("ply_ui", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); /* create information timer */ info_timer = rtgui_timer_create(RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC, info_timer_timeout, RT_NULL); workbench = rtgui_workbench_create("main", "workbench"); if (workbench == RT_NULL) return; rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), player_workbench_event_handler); /* add home view */ home_view = rtgui_view_create("Home"); rtgui_widget_set_event_handler(RTGUI_WIDGET(home_view), home_view_event_handler); rtgui_workbench_add_view(workbench, home_view); /* this view can be focused */ RTGUI_WIDGET(home_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* set widget focus */ rtgui_widget_focus(RTGUI_WIDGET(home_view)); rtgui_widget_get_rect(RTGUI_WIDGET(home_view), &rect); rect.x1 += 6; rect.y1 += 150 + 25; rect.x2 = rect.x1 + 228; rect.y2 = rect.y1 + 145; music_listbox = rtgui_listbox_create(RT_NULL, 0, &rect); /* none focusable widget */ RTGUI_WIDGET(music_listbox)->flag &= ~RTGUI_WIDGET_FLAG_FOCUSABLE; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(music_listbox)) = black; RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(music_listbox)) = white; rtgui_container_add_child(RTGUI_CONTAINER(home_view), RTGUI_WIDGET(music_listbox)); rtgui_listbox_set_onitem(music_listbox, player_play_list_onitem); rtgui_view_show(home_view, RT_FALSE); /* add function view */ rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); function_view = rtgui_list_view_create(function_list, sizeof(function_list)/sizeof(struct rtgui_list_item), &rect, RTGUI_LIST_VIEW_LIST); rtgui_workbench_add_view(workbench, RTGUI_VIEW(function_view)); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
void workbench_panel1(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("hello 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); /* 创建图片视图 */ view = picture_view_create(workbench); /* 非模式方式显示视图 */ 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); }
static void gui_win_entry(void* parameter) { const struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default(); struct rt_messagequeue *mq; rtgui_win_t *win; rtgui_button_t *button; rtgui_point_t p; rtgui_rect_t rect = {0,0,200,180}; rtgui_label_t *label; rtgui_font_t *font; /* 创建GUI应用需要的消息队列 */ mq = rt_mq_create("demo_win", 256, 32, RT_IPC_FLAG_FIFO); /* 注册当前线程 */ rtgui_thread_register(rt_thread_self(), mq); /* 窗口居中 */ rtgui_rect_moveto(&rect, (gd->width - rtgui_rect_width(rect))/2, (gd->height - rtgui_rect_height(rect))/2); /* 创建窗口 */ win = rtgui_win_create(RT_NULL,"demo_win",&rect,RTGUI_WIN_DEFAULT); if(win == RT_NULL) return; /* 取得客户区坐标零点 */ p = rtgui_win_get_client_zero(win); label = rtgui_label_create(win, "hello world!", p.x+5, p.y+5, 100,25); font = rtgui_font_refer("asc", 12); RTGUI_WIDGET_FONT(label) = font; button = rtgui_button_create(win, "Exit", (rtgui_rect_width(rect)-50)/2, rtgui_rect_height(rect)-40,50,25); rtgui_button_set_onbutton(button,rtgui_win_close); rtgui_widget_set_event_handler(win, demo_gui_win_event_handler); rtgui_win_show(win,RT_FALSE); /* 执行工作台事件循环 */ rtgui_win_event_loop(win); demo_win_inited = RT_FALSE; /* 去注册GUI线程 */ rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
void calibration_entry(void* parameter) { rt_mq_t mq; rtgui_win_t* win; struct rtgui_rect rect; mq = rt_mq_create("cali", 40, 8, RT_IPC_FLAG_FIFO); if (mq == RT_NULL) return; rtgui_thread_register(rt_thread_self(), mq); rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect); /* set screen rect */ calibration_ptr->width = rect.x2; calibration_ptr->height = rect.y2; /* create calibration window */ win = rtgui_win_create(RT_NULL, "calibration", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER); rtgui_widget_set_event_handler(RTGUI_WIDGET(win), calibration_event_handler); if (win != RT_NULL) { rtgui_win_show(win, RT_FALSE); // rtgui_widget_update(RTGUI_WIDGET(win)); rtgui_win_event_loop(win); } rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); /* set calibration data */ rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION_DATA, &calibration_ptr->data); /* recover to normal */ rt_device_control(calibration_ptr->device, RT_TOUCH_NORMAL, RT_NULL); /* release memory */ rt_free(calibration_ptr); calibration_ptr = RT_NULL; /* tell other thread that we finished calibration */ rt_sem_release(touch_screen_calibrated); }
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 RT_VERSION == 4 demo_view_benchmark(workbench); #endif demo_view_dc(workbench); #if RT_VERSION == 4 #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); }