bool DemoApplication::Init() { if (!Application::Init()) return false; // Block new animations during Init. TBAnimationBlocker anim_blocker; // Run unit tests int num_failed_tests = TBRunTests(); // TBSelectList and TBSelectDropdown widgets have a default item source that are fed with any items // specified in the resource files. But it is also possible to set any source which can save memory // and improve performance. Then you don't have to populate each instance with its own set of items, // for widgets that occur many times in a UI, always with the same items. // Here we prepare the name source, that is used in a few places. for (int i = 0; boy_names[i]; i++) advanced_source.AddItem(new AdvancedItem(boy_names[i++], TBIDC("boy_item"), true)); for (int i = 0; girl_names[i]; i++) advanced_source.AddItem(new AdvancedItem(girl_names[i++], TBIDC("girl_item"), false)); for (int i = 0; girl_names[i]; i++) name_source.AddItem(new TBGenericStringItem(girl_names[i++], TBIDC("girl_item"))); for (int i = 0; boy_names[i]; i++) name_source.AddItem(new TBGenericStringItem(boy_names[i++], TBIDC("boy_item"))); advanced_source.SetSort(TB_SORT_ASCENDING); name_source.SetSort(TB_SORT_ASCENDING); // Prepare a source with submenus (with eternal recursion) so we can test sub menu support. popup_menu_source.AddItem(new TBGenericStringItem("Option 1", TBIDC("opt 1"))); popup_menu_source.AddItem(new TBGenericStringItem("Option 2", TBIDC("opt 2"))); popup_menu_source.AddItem(new TBGenericStringItem("-")); popup_menu_source.AddItem(new TBGenericStringItem("Same submenu", &popup_menu_source)); popup_menu_source.AddItem(new TBGenericStringItem("Long submenu", &name_source)); // Give the first item a skin image popup_menu_source.GetItem(0)->SetSkinImage(TBIDC("Icon16")); new MainWindow(); new EditWindow; new ListWindow(&name_source); new AdvancedListWindow(&advanced_source); new TabContainerWindow(); if (num_failed_tests) { TBStr text; text.SetFormatted("There is %d failed tests!\nCheck the output for details.", num_failed_tests); TBMessageWindow *msg_win = new TBMessageWindow(GetRoot(), TBIDC("")); msg_win->Show("Testing results", text); } return true; }