/* 创建用于演示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; }
static void app_lcd(void *parameter) { /* create application */ struct rtgui_app *app; struct rtgui_rect rect1 = {0, 0, 240, 320}; struct rtgui_button* btn; struct rtgui_label *lb; app = rtgui_app_create("lcd_app"); if (!app) { rt_kprintf("Create application \"lcd_app\" failed!\n"); return; } /* create main window */ win_main = rtgui_win_create(RT_NULL, "main", &rect1, RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE); if (win_main == RT_NULL) { rt_kprintf("Create window \"main\" failed!\n"); rtgui_app_destroy(app); return; } RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win_main)) = green; rect1.x1 = rect1.y1 = 50; rect1.x2 -= 50; rect1.y2 -= 50; lb = rtgui_label_create("I am a transparent label!!!!!!!!!"); rtgui_widget_set_rect(RTGUI_WIDGET(lb), &rect1); RTGUI_WIDGET_FLAG(RTGUI_WIDGET(lb)) |= RTGUI_WIDGET_FLAG_TRANSPARENT; rect1.x1 += 20; rect1.y1 += 20; notebook = rtgui_notebook_create(&rect1, 0); /* create lable in main container */ btn = rtgui_button_create("Here I am."); rtgui_notebook_add(notebook, "btn A", RTGUI_WIDGET(btn)); rtgui_button_set_onbutton(btn, remove_myself); btn = rtgui_button_create("There I am."); rtgui_notebook_add(notebook, "btn B", RTGUI_WIDGET(btn)); rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(lb)); rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(notebook)); rtgui_win_show(win_main, RT_FALSE); rtgui_app_run(app); rtgui_app_destroy(app); }
static void app_lcd(void *parameter) { /* create application */ struct rtgui_app *app; struct rtgui_rect rect1 = {0, 0, 240, 320}; struct rtgui_win *win_main; struct rtgui_button* btn; app = rtgui_app_create(rt_thread_self(), "lcd_app"); if (!app) { rt_kprintf("Create application \"lcd_app\" failed!\n"); return; } /* create main window */ win_main = rtgui_win_create(RT_NULL, "main", &rect1, RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE); if (win_main == RT_NULL) { rt_kprintf("Create window \"main\" failed!\n"); rtgui_app_destroy(app); return; } notebook = rtgui_notebook_create(&rect1, 0); /* create lable in main container */ btn = rtgui_button_create("Here I am."); rtgui_notebook_add(notebook, "btn A", RTGUI_WIDGET(btn)); rtgui_button_set_onbutton(btn, remove_myself); btn = rtgui_button_create("There I am."); rtgui_notebook_add(notebook, "btn B", RTGUI_WIDGET(btn)); rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(notebook)); rtgui_win_show(win_main, RT_FALSE); rtgui_app_run(app); rtgui_app_destroy(app); }
/* * 构建应用视图 */ int app_view_structure(struct rtgui_workbench *workbench, struct rtgui_view *view) { int ret = SUCC; rtgui_rect_t rect, body_rect; rtgui_label_t* label; char str[48]; //rtgui_radiobox_t *radiobox; //rtgui_button_t* button; struct tm *ptime; #if 1==DISPLAY_OVERLOAD_INFO rtgui_label_t *rx_overload_label; #endif app_view_get_can_use_rect(view, &rect); zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, rect.x1, rect.y1, rect.x2, rect.y2)); body_rect.x1 = 0; body_rect.y1 = 0; body_rect.x2 = rect.x2; body_rect.y2 = TITLE_PANEL_HEIGHT; label = rtgui_label_create(DEVICE_NAME); if (NULL != label) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue; rtgui_widget_set_rect(RTGUI_WIDGET(label), &body_rect); /* view是一个container控件,调用add_child方法添加这个label控件 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); } else { printf_syn("creat title label fail\n"); } body_rect.x1 = 0; body_rect.y1 = TITLE_PANEL_HEIGHT; body_rect.x2 = rect.x2; body_rect.y2 = rect.y2; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); zvd_notebook = rtgui_notebook_create(&body_rect, RTGUI_NOTEBOOK_TOP); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(zvd_notebook)); re_form = rtgui_form_create(re_form_head, RE_FORM_ROWS, RE_FORM_COLS, &body_rect); rtgui_notebook_add(zvd_notebook, "接收端", RTGUI_WIDGET(re_form)); #if 1 set_form_px_col(re_form); i2str(str, avg_val[AVI_RE_PA]); rtgui_form_set_item(re_form, str, RE_PA_AVG_VALUE_ROW, RE_PA_AVG_VALUE_COL, 0); rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PA_OVER_RANGE_ROW, RE_PA_OVER_RANGE_COL, 0); i2str(str, avg_val[AVI_RE_PB]); rtgui_form_set_item(re_form, str, RE_PB_AVG_VALUE_ROW, RE_PB_AVG_VALUE_COL, 0); rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PB_OVER_RANGE_ROW, RE_PB_OVER_RANGE_COL, 0); i2str(str, avg_val[AVI_RE_PC]); rtgui_form_set_item(re_form, str, RE_PC_AVG_VALUE_ROW, RE_PC_AVG_VALUE_COL, 0); rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PC_OVER_RANGE_ROW, RE_PC_OVER_RANGE_COL, 0); #endif se_form = rtgui_form_create(se_form_head, SE_FORM_ROWS, SE_FORM_COLS, &body_rect); rtgui_notebook_add(zvd_notebook, "发射端", RTGUI_WIDGET(se_form)); #if 1 set_form_px_col(se_form); rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PA_OVER_RANGE_ROW, SE_PA_OVER_RANGE_COL, 0); rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PA_POWER_DOWN_ROW, SE_PA_POWER_DOWN_COL, 0); rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PB_OVER_RANGE_ROW, SE_PB_OVER_RANGE_COL, 0); rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PB_POWER_DOWN_ROW, SE_PB_POWER_DOWN_COL, 0); rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PC_OVER_RANGE_ROW, SE_PC_OVER_RANGE_COL, 0); rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PC_POWER_DOWN_ROW, SE_PC_POWER_DOWN_COL, 0); #endif sys_form = rtgui_form_create(sys_form_head, SYS_FORM_ROWS, SYS_FORM_COLS, &body_rect); rtgui_notebook_add(zvd_notebook, "系统", RTGUI_WIDGET(sys_form)); #if 1 rtgui_form_set_item(sys_form, "接收端", 1, 0, 0); i2str(str, sys_temper[STI_RE_CPU_T]); rtgui_form_set_item(sys_form, str, RE_RE_CPU_TEMP_ROW, RE_RE_CPU_TEMP_COL, 0); i2str(str, sys_temper[STI_RE_CTB_T]); rtgui_form_set_item(sys_form, str, RE_RE_BOX_TEMP_ROW, RE_RE_BOX_TEMP_COL, 0); convert_ver2str(re_version, str); rtgui_form_set_item(sys_form, str, RE_RE_SOFT_VER_ROW, RE_RE_SOFT_VER_COL, 0); rtgui_form_set_item(sys_form, "发射端", 2, 0, 0); i2str(str, sys_temper[STI_SE_CPU_T]); rtgui_form_set_item(sys_form, str, RE_SE_CPU_TEMP_ROW, RE_SE_CPU_TEMP_COL, 0); i2str(str, sys_temper[STI_SE_CTB_T]); rtgui_form_set_item(sys_form, str, RE_SE_BOX_TEMP_ROW, RE_SE_BOX_TEMP_COL, 0); convert_ver2str(se_version, str); rtgui_form_set_item(sys_form, str, RE_SE_SOFT_VER_ROW, RE_SE_SOFT_VER_COL, 0); creat_devsn(str, sizeof(str), 0); rtgui_form_set_row(sys_form, str, TE_SN_ROW); creat_devsn(str, sizeof(str), 1); rtgui_form_set_row(sys_form, str, RE_SN_ROW); #endif other_form = rtgui_form_create(other_form_head, OTHER_FORM_ROWS, OTHER_FORM_COLS, &body_rect); rtgui_notebook_add(zvd_notebook, "掉电", RTGUI_WIDGET(other_form)); #if 1 rtgui_form_set_item(other_form, "次数", 1, 0, 0); rtgui_form_set_item(other_form, "n", 2, 0, 0); rtgui_form_set_item(other_form, "n-1", 3, 0, 0); rtgui_form_set_item(other_form, "n-2", 4, 0, 0); update_tx_poweroff_info_of_otherform(); update_rx_poweroff_info_of_otherform(); #endif body_rect.x1 = FRAME_GAP; body_rect.y1 = body_rect.y2 + WIDGET_ROW_GAP; body_rect.x2 = FRAME_GAP + 8 * rt_strlen(RE_IF_SWITCH2CABLE_STR); body_rect.y2 = body_rect.y1 + 16; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); switch_cable_label = rtgui_label_create(RE_IF_SWITCH2CABLE_STR); if (NULL != switch_cable_label) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch_cable_label)) = RTGUI_ALIGN_CENTER_VERTICAL; //RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch_cable_label)) = blue; rtgui_widget_set_rect(RTGUI_WIDGET(switch_cable_label), &body_rect); /* view是一个container控件,调用add_child方法添加这个label控件 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch_cable_label)); } else { printf_syn("creat cable label fail\n"); } #if 1 body_rect.x1 = body_rect.x2 + 2; body_rect.x2 = body_rect.x1 + 16 + 8; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); switch_cable_yn_textview = rtgui_textview_create(print_info_str[PIS_ID_FOU], &body_rect); if (NULL != switch_cable_yn_textview) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch_cable_yn_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; //RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch_cable_yn_textview)) = red; rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch_cable_yn_textview)); } else { printf_syn("creat cable yn textview fail\n"); } #endif #if 1 body_rect.x1 = body_rect.x2 + 2 + 2*8; body_rect.x2 = body_rect.x1 + 8*rt_strlen(TE_HAD_POWEROFF_STR); zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); tx_poweroff_label = rtgui_label_create(TE_HAD_POWEROFF_STR); if (NULL != tx_poweroff_label) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(tx_poweroff_label)) = RTGUI_ALIGN_CENTER_VERTICAL; rtgui_widget_set_rect(RTGUI_WIDGET(tx_poweroff_label), &body_rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(tx_poweroff_label)); } else { printf_syn("tx poweroff label fail\n"); } body_rect.x1 = body_rect.x2 + 2; body_rect.x2 = body_rect.x1 + 16 + 8; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); tx_poweroff_yn_textview = rtgui_textview_create(print_info_str[PIS_ID_FOU], &body_rect); if (NULL != tx_poweroff_yn_textview) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(tx_poweroff_yn_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(tx_poweroff_yn_textview)); } else { printf_syn("creat cable yn textview fail\n"); } #endif #if 1 body_rect.x1 = FRAME_GAP; body_rect.y1 = body_rect.y2 + WIDGET_ROW_GAP; body_rect.x2 = FRAME_GAP + (8+1) * rt_strlen(RE_BUZZER_DISABLE_STR); body_rect.y2 = body_rect.y1 + 16 + 2*WIDGET_ROW_GAP; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); buzzer_button = rtgui_pushbutton_create(RE_BUZZER_DISABLE_STR); if (NULL != buzzer_button) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(buzzer_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; //RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(buzzer_button)) = blue; rtgui_widget_set_rect(RTGUI_WIDGET(buzzer_button), &body_rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(buzzer_button)); rtgui_button_set_onbutton(buzzer_button, buzzer_btn_onbutton); } else { printf_syn("creat buzzer pushbutton fail\n"); } body_rect.x1 = body_rect.x2 + FRAME_GAP; /* body_rect.y1 = body_rect.y1; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */ body_rect.x2 = body_rect.x1 + (8+1) * rt_strlen(SWITCH_TO_PT_STR);; /* body_rect.y2 = body_rect.y2; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */ switch2pt_button = rtgui_pushbutton_create(SWITCH_TO_PT_STR); if (NULL != switch2pt_button) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch2pt_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; //RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch2pt_button)) = blue; rtgui_widget_set_rect(RTGUI_WIDGET(switch2pt_button), &body_rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch2pt_button)); rtgui_button_set_onbutton(switch2pt_button, switch2pt_btn_onbutton); } else { printf_syn("creat switch button fail\n"); } #if USE_OPTICX_200S_VERSION body_rect.x1 = body_rect.x2 + FRAME_GAP; /* body_rect.y1 = body_rect.y1; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */ body_rect.x2 = body_rect.x1 + (8) * rt_strlen(RE_CUR_CHANNEL_NO_STR) + 2; /* body_rect.y2 = body_rect.y2; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */ zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); rxe_cur_channel_label = rtgui_label_create(RE_CUR_CHANNEL_NO_STR); if (NULL != rxe_cur_channel_label) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rxe_cur_channel_label)) = RTGUI_ALIGN_CENTER_VERTICAL; rtgui_widget_set_rect(RTGUI_WIDGET(rxe_cur_channel_label), &body_rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rxe_cur_channel_label)); } else { printf_syn("rxe cru channel label fail\n"); } body_rect.x1 = body_rect.x2 + 2; body_rect.x2 = body_rect.x1 + 8 + 8; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); str[0] = convert_cur_channel_to_char(); str[1] = '\0'; rxe_cur_channel_no_textview = rtgui_textview_create(str, &body_rect); if (NULL != rxe_cur_channel_no_textview) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rxe_cur_channel_no_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rxe_cur_channel_no_textview)); } else { printf_syn("creat cable yn textview fail\n"); } #endif #endif #if 1==DISPLAY_OVERLOAD_INFO body_rect.x1 = body_rect.x2 + 2 + 7*8; body_rect.x2 = body_rect.x1 + 8*rt_strlen(RE_OVERLOAD_CNT_STR); zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); rx_overload_label = rtgui_label_create(RE_OVERLOAD_CNT_STR); if (NULL != rx_overload_label) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rx_overload_label)) = RTGUI_ALIGN_CENTER_VERTICAL; rtgui_widget_set_rect(RTGUI_WIDGET(rx_overload_label), &body_rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rx_overload_label)); } else { printf_syn("tx poweroff label fail\n"); } body_rect.x1 = body_rect.x2 + 2; body_rect.x2 = body_rect.x1 + 16 + 8; zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__, body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2)); rx_overload_cnt_textview = rtgui_textview_create("0", &body_rect); if (NULL != rx_overload_cnt_textview) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rx_overload_cnt_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rx_overload_cnt_textview)); } else { printf_syn("creat cable yn textview fail\n"); } #endif #if 1 /* 创建时间标签, 2013-03-18 09:20 */ rtc_dev = rt_device_find("rtc"); if (NULL != rtc_dev) { time_t time; rt_device_control(rtc_dev, RT_DEVICE_CTRL_RTC_GET_TIME, &time); ptime = localtime(&time); rt_sprintf(sys_time_str, "%4d-%02d-%02d %02d:%02d:%02d", (ptime->tm_year+1900), (ptime->tm_mon+1), ptime->tm_mday, ptime->tm_hour, ptime->tm_min, ptime->tm_sec); body_rect.x2 = rtgui_graphic_driver_get_default()->width; body_rect.y2 = rtgui_graphic_driver_get_default()->height; body_rect.x1 = body_rect.x2 - (8+1) * 19; body_rect.y1 = body_rect.y2 - 20; #if SYS_TIME_USE_TEXTBOX sys_time_textbox = rtgui_textbox_create(sys_time_str, RTGUI_TEXTBOX_SINGLE | RTGUI_TEXTBOX_CARET_HIDE); if (NULL != sys_time_textbox) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sys_time_textbox)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; //RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue; RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue; //default_background; //RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)); rtgui_widget_set_rect(RTGUI_WIDGET(sys_time_textbox), &body_rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(sys_time_textbox)); } else { printf_syn("creat sys time textbox fail\n"); } #else sys_time_textview = rtgui_textview_create(sys_time_str, &body_rect); if (NULL != sys_time_textview) { RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sys_time_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; //RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue; rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(sys_time_textview)); } else { printf_syn("creat sys time textview fail\n"); } #endif } else { printf_syn("find rtc device fail\n"); } #endif rtgui_view_show(view, RT_FALSE); /* 显示视图 */ return ret; }
void win_thread_entry(void* parameter) { struct rtgui_app* app; struct rtgui_win *win; struct rtgui_panel *panel; struct rtgui_box *box; struct rtgui_label *label; struct rtgui_notebook *notebook; struct rtgui_rect rect = {50, 50, 350, 350}; app = rtgui_app_create(rt_thread_self(), "MyApp"); RT_ASSERT(app != RT_NULL); win = rtgui_mainwin_create(RT_NULL, "MyWindow", RTGUI_WIN_STYLE_DEFAULT); box = rtgui_box_create(RTGUI_VERTICAL, 10); rtgui_container_set_box(RTGUI_CONTAINER(win), box); /* create a panel */ panel = rtgui_panel_create(RTGUI_BORDER_BOX); RTGUI_WIDGET_ALIGN(panel) = RTGUI_ALIGN_EXPAND; rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(panel)); /* create sub-child for panel */ box = rtgui_box_create(RTGUI_VERTICAL, 10); rtgui_container_set_box(RTGUI_CONTAINER(panel), box); label = rtgui_label_create("hello panel!"); rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(label)); /* create a notebook */ notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_TOP); RTGUI_WIDGET_ALIGN(notebook) = RTGUI_ALIGN_EXPAND; rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(notebook)); _notebook = notebook; /* create tab-page for notebook */ panel = rtgui_panel_create(RTGUI_BORDER_STATIC); _panel = panel; box = rtgui_box_create(RTGUI_VERTICAL, 10); rtgui_container_set_box(RTGUI_CONTAINER(panel), box); label = rtgui_label_create("hello panel!"); rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(label)); rtgui_notebook_add(notebook, "Panel", RTGUI_WIDGET(panel)); /* create another page with label */ label = rtgui_label_create("hello notebook"); rtgui_notebook_add(notebook, "Text", RTGUI_WIDGET(label)); /* layout for window */ rtgui_container_layout(RTGUI_CONTAINER(win)); rtgui_win_show(win, RT_FALSE); rtgui_app_run(app); rtgui_win_destroy(win); rtgui_app_destroy(app); rt_kprintf("MyApp Quit.\n"); }
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 = rect.x1 + rt_strlen(title)*8; 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)); rtgui_widget_get_rect(RTGUI_WIDGET(container), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(container), &rect); rect.y1 += 20 + 5; rect.y2 = rect.y1 + 2; /* 创建一个水平的 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; }