PageWindow::PageWindow() { LoadResourceFile("Demo/demo01/ui_resources/test_scroller_snap.tb.txt"); // Listen to the pagers scroller if (TBWidget *pager = GetWidgetByID(TBIDC("page-scroller"))) pager->GetScroller()->SetSnapListener(this); }
virtual void OnProcessStates() { // Update the disabled state of undo/redo buttons, and caret info. if (TBEditField *edit = GetWidgetByIDAndType<TBEditField>(TBIDC("editfield"))) { if (TBWidget *undo = GetWidgetByID("undo")) undo->SetState(WIDGET_STATE_DISABLED, !edit->GetStyleEdit()->CanUndo()); if (TBWidget *redo = GetWidgetByID("redo")) redo->SetState(WIDGET_STATE_DISABLED, !edit->GetStyleEdit()->CanRedo()); if (TBTextField *info = GetWidgetByIDAndType<TBTextField>(TBIDC("info"))) { TBStr text; text.SetFormatted("Caret ofs: %d", edit->GetStyleEdit()->caret.GetGlobalOfs()); info->SetText(text); } } }
void LinuxGtkMenu::CheckMenuItem( uint32_t menuID, bool isChecked ) { auto newItemWidget = GetWidgetByID( menuID ); if( newItemWidget != nullptr ) { ExceptionSafeValueRestorer<bool> restore1( _inhibitMenuEvents ); _inhibitMenuEvents = true; gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(newItemWidget), isChecked ? TRUE : FALSE ); } }
void LinuxGtkMenu::EnableMenuItem( uint32_t menuID, bool isEnabled ) { auto newItemWidget = GetWidgetByID( menuID ); if( newItemWidget != nullptr ) { ExceptionSafeValueRestorer<bool> restore1( _inhibitMenuEvents ); _inhibitMenuEvents = true; gtk_widget_set_sensitive( newItemWidget, isEnabled ? TRUE : FALSE ); } }
void AddCheckbox(TBDebugInfo::SETTING setting, const char *str) { TBCheckBox *check = new TBCheckBox(); check->SetValue(g_tb_debug.settings[setting]); check->data.SetInt(setting); check->SetID(TBIDC("check")); TBClickLabel *label = new TBClickLabel(); label->SetText(str); label->GetContentRoot()->AddChild(check, WIDGET_Z_BOTTOM); GetWidgetByID(TBIDC("container"))->AddChild(label); }
void ScrollContainerWindow::OnMessageReceived(TBMessage *msg) { if (msg->message == TBIDC("new button") && msg->data) { if (TBWidget *target = GetWidgetByID(msg->data->id1)) { TBStr str; str.SetFormatted("Remove %d", msg->data->v1.GetInt()); TBButton *button = new TBButton; button->SetID(TBIDC("remove button")); button->SetText(str); target->AddChild(button); } } }