/* 创建用于演示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); }
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_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); }
/* * 构建应用视图 */ 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"); }
void app_mgr_win_init(void) { struct rtgui_win* win; rtgui_rect_t rect; struct rtgui_notebook *notebook; rtgui_listbox_t* box; struct rtgui_image* pressed_image; struct rtgui_image* unpressed_image; int font_size; struct block_panel* block; int angle_y; /* create main window of Application Manager */ win = rtgui_mainwin_create(RT_NULL, "AppMgr", RTGUI_WIN_STYLE_MAINWIN); RTGUI_WIDGET_BACKGROUND(win) = RTGUI_RGB(241, 241, 241); /* create icon image */ pressed_image = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)home_xpm, sizeof(home_xpm), RT_FALSE); unpressed_image = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)home_gray_xpm, sizeof(home_gray_xpm), RT_FALSE); rtgui_font_get_metrics(RTGUI_WIDGET_FONT(win), "AppMgr", &rect); font_size = rtgui_rect_height(rect); /* create notebook */ rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect); notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_LEFT); RTGUI_WIDGET_BACKGROUND(notebook) = RTGUI_RGB(241, 241, 241); rtgui_notebook_set_tab_height(notebook, pressed_image->h + font_size + 3 * RTGUI_WIDGET_DEFAULT_MARGIN); rtgui_notebook_set_tab_width(notebook, 65); angle_y = rect.x1; /* create navigation */ rtgui_notebook_get_client_rect(notebook, &rect); block = block_panel_create(angle_y + notebook->tab_h/2, &rect); RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241); rtgui_notebook_add_image(notebook, "AppTask", RTGUI_WIDGET(block), pressed_image, unpressed_image); apps_list_create(RTGUI_PANEL(block)); angle_y += notebook->tab_h; block = block_panel_create(angle_y + notebook->tab_h/2, &rect); RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241); rtgui_notebook_add_image(notebook, "Tab 1", RTGUI_WIDGET(block), pressed_image, unpressed_image); { struct rtgui_rect box_rect; block_panel_get_client_extent(block, &box_rect); // rtgui_widget_get_extent(RTGUI_WIDGET(block), &box_rect); // rtgui_rect_inflate(&box_rect, -15); box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &box_rect); rtgui_container_add_child(RTGUI_CONTAINER(block), RTGUI_WIDGET(box)); } angle_y += notebook->tab_h; block = block_panel_create(angle_y + notebook->tab_h/2, &rect); RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241); rtgui_notebook_add_image(notebook, "Tab 2", RTGUI_WIDGET(block), pressed_image, unpressed_image); angle_y += notebook->tab_h; rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(notebook)); rtgui_win_show(win, RT_FALSE); /* set as main window */ rtgui_app_set_main_win(win); }