void CheckList::ToggleSelection(int index) { if (IsSelected(index)) DeselectItem(index); else SetSelectedIndex(index); }
NS_IMETHODIMP HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex) { ErrorResult rv; SetSelectedIndex(aSelectedIndex, rv); return rv.ErrorCode(); }
void ComboBox::OnCellSelected(UIList *forList, UIListCell *selectedCell) { SetSelectedIndex(selectedCell->GetIndex(), true); comboButton->SetSelected(false); if(list->GetParent()) { list->GetParent()->RemoveControl(list); } }
bool List::SetSelectedOption(const std::string &option) { std::vector<std::string>::const_iterator it = std::find(m_options.begin(), m_options.end(), option); if (it != m_options.end()) { SetSelectedIndex(it - m_options.begin()); return true; } else { return false; } }
BOOL FontDropDown::SetTopFontName(StringBase* StrValue, FontClass Type, BOOL Deselect) { TheTopItem.FontName = *StrValue; TheTopItem.Type = Type; // Deselect any selected items if(Deselect) SetSelectedIndex(-1); return TRUE; }
void NickListCtrl::OnActivateItem(wxListEvent& event) { int index = event.GetIndex(); if (index == -1) return; const User* user = m_data[index]; if (user) { ui().mw().OpenPrivateChat(*user, true); //true --> setfoucs } SetSelectedIndex(index); }
bool ButtonPanel::SelectPrevious() { for (int i = selected_index - 1; i >= 0; --i) { const auto &button = *buttons[i]; if (button.IsVisible() && button.IsEnabled()) { SetSelectedIndex(i); return true; } } return false; }
bool ButtonPanel::SelectNext() { for (unsigned i = selected_index + 1, n = buttons.size(); i < n; ++i) { const auto &button = *buttons[i]; if (button.IsVisible() && button.IsEnabled()) { SetSelectedIndex(i); return true; } } return false; }
bool PaletteView::KeyInput(std::string keyName) { if(keyName == "Left") { int c = GetSelectedOrDefaultIndex(); if(c == 0) c = (int)colors.size() - 1; else c--; SetSelectedIndex(c); return true; }else if(keyName == "Right") { int c = GetSelectedOrDefaultIndex(); if(c == (int)colors.size() - 1) c = 0; else c++; SetSelectedIndex(c); return true; }else if(keyName == "Up") { int c = GetSelectedOrDefaultIndex(); if(c < 8) c += (int)colors.size() - 8; else c -= 8; SetSelectedIndex(c); return true; }else if(keyName == "Down") { int c = GetSelectedOrDefaultIndex(); if(c >= (int)colors.size() - 8) c -= (int)colors.size() - 8; else c += 8; SetSelectedIndex(c); return true; }else{ return false; } }
LPCPlayList MyLib::NewPlaylist(BOOL bNotify,std::tstring playlistname,bool bAutoPL) { LPCPlayList l=new CPlayList(playlistname); m_playLists.push_back(l); if(bAutoPL) l->SetAuto(bAutoPL); int nIndex=GetItemCount()-1; SetSelectedIndex(nIndex); if(bNotify) NotifyMsg(WM_SOME_PL_CHANGED,FALSE,0,0); return l; }
void ChoiceForm::UpdateChoicePanel(String shaderName) { glFinish(); if (shaderName.Length()) SetText(L"Choice Control - " + shaderName); currentShaderName = shaderName; scrollPanel->ClearChildren(); existingChoices.Clear(); additionalAttribs.Clear(); auto choices = choiceControl->GetChoices(shaderName, existingChoices); int line = 0; comboBoxChoiceNames.Clear(); choiceComboBoxes.Clear(); choiceCheckBoxes.Clear(); existingChoices.Clear(); scrollPanel->SetLayout(GraphicsUI::ContainerLayoutType::Stack); for (auto & choice : choices) { if (choice.Options.Count() == 1) continue; auto wrapper = new GraphicsUI::Container(scrollPanel); wrapper->AutoHeight = true; wrapper->Padding = EM(0.1f); auto lbl = new GraphicsUI::CheckBox(wrapper); lbl->SetText(choice.ChoiceName); lbl->Top = EM(0.2f); choiceCheckBoxes.Add(choice.ChoiceName, lbl); auto cmb = new GraphicsUI::ComboBox(wrapper); cmb->AddTextItem(L"(auto) " + choice.DefaultValue); for (auto & opt : choice.Options) { cmb->AddTextItem(opt.ToString()); } comboBoxChoiceNames[cmb] = choice.ChoiceName; choiceComboBoxes[choice.ChoiceName] = cmb; cmb->SetSelectedIndex(0); cmb->OnChanged.Bind(this, &ChoiceForm::ChoiceComboBox_Changed); cmb->Posit(0, 0, EM(7.0f), EM(1.5f)); cmb->DockStyle = GraphicsUI::Control::dsRight; line++; } SizeChanged(); }
void ChoiceForm::Autotune(float timeBudget) { bool countOnly = false; ResetButton_Clicked(nullptr); referenceFrame = ReadFrameData(choiceControl->RenderFrame()); EnumerableDictionary<String, Spire::Compiler::ShaderChoiceValue> currentChoices; currentBestValue = 1e30f; currentBestChoices = currentChoices; HashSet<String> selectedChoices; for (auto & chk : choiceCheckBoxes) if (chk.Value->Checked) selectedChoices.Add(chk.Key); autotuningLog.Clear(); auto startTimePoint = PerformanceCounter::Start(); int count = AutotuneHelper(selectedChoices, currentChoices, timeBudget, countOnly); float time = PerformanceCounter::EndSeconds(startTimePoint); autotuningLog << L"time: " << time << EndLine; printf("variant count: %d\ntime: %f\n", count, time); File::WriteAllText(L"autotuneLog.txt", autotuningLog.ToString()); if (!countOnly) { existingChoices = currentBestChoices; disableChoiceChangeCapture = true; for (auto & choice : existingChoices) { auto cmb = choiceComboBoxes[choice.Key].GetValue(); int idxToSelect = 0; for (int i = 0; i < cmb->Items.Count(); i++) if (cmb->GetTextItem(i)->GetText() == choice.Value.ToString()) { idxToSelect = i; break; } cmb->SetSelectedIndex(idxToSelect); } disableChoiceChangeCapture = false; Recompile(); ShaderChanged(currentShaderName); } }
bool ListBox::OnMouseButtonRelease( const int2& screenPos, uint32_t button ) { bool eventConsumed = false; if (button == MS_LeftButton) { if (mPressed) { if (mSelectionRegion.Contains((float)screenPos.X(), (float)screenPos.Y())) { int32_t selIndex = mVertScrollBar->GetScrollValue() + (int32_t)floorf((screenPos.Y() - mSelectionRegion.Top()) / mTextRowHeight); SetSelectedIndex(selIndex, true); } mPressed = false; eventConsumed = true; } } return eventConsumed; }
void ComboBox::SetNewItemsSet(const Vector<String> &listItems) { indecesMap.clear(); items = listItems; Font *font = ControlsFactory::GetFontLight(); listWidth = size.x; for (int i = 0; i < (int32)items.size(); i++) { float itemWidth = (float32)font->GetStringSize(StringToWString(items[i])).dx; listWidth = Max(listWidth, itemWidth); indecesMap[items[i]] = i; } if(listWidth != size.x) { listWidth += (ControlsFactory::OFFSET * 2); } // int32 sz = Min(8, (int32)items.size()); int32 sz = (int32)items.size(); if(maxVisibleItemsCount > 0 && sz > maxVisibleItemsCount) { sz = maxVisibleItemsCount; } SafeRelease(list); list = new UIList(Rect(size.x - listWidth, size.y, listWidth, size.y * sz), UIList::ORIENTATION_VERTICAL); list->SetDelegate(this); ControlsFactory::SetScrollbar(list); ControlsFactory::CusomizeListControl(list); selectionIndex = 0; ControlsFactory::CustomizeButton(comboButton, StringToWString(items[selectionIndex])); SetSelectedIndex(0, false); }
void StaticScrollArea::itemClicked() { QPushButton* button = (QPushButton*)sender(); int index = std::find(buttons.begin(), buttons.end(), button) - buttons.begin(); SetSelectedIndex(index + currentOffset); }
BOOL DocumentFontDropDown::FillInFontList(Document * WorkDoc) { ERROR2IF(ParentDlg == NULL, FALSE, "FontDropDown not properly initialised"); BeginSlowJob(); SetListRedraw(FALSE); // Disable redraw while updating KillList(); // Delete combobox contents and empty the fonts list //ClearList(); // Delete combobox contents // Setup the static class pointer variable so we can add things to this dropdown... CurrentFontDropDown = (void *)this; //if(Fonts.GetCount() == 0) //{ if (WorkDoc == NULL) { // Fill in one item in the list which is no document fonts being used String_8 DashString(_R(IDS_K_FINFODLG_DASH)); TheTopItem.FontName = DashString; TheTopItem.Type = FC_UNDEFINED; //AddFontToList((TCHAR*)&TheTopItem.FontName, TheTopItem.Type); } else { // Build the font list for the specified document // This will NOT be alphabetical FontList DocFonts; DocFonts.Build(WorkDoc); FontListItem* FontItem = DocFonts.GetFirstItem(); if (FontItem == NULL) { // Fill in one item in the list which is no document fonts being used TheTopItem.FontName = _R(IDS_NO_FONTSINDOC); TheTopItem.Type = FC_UNDEFINED; //AddFontToList((TCHAR*)&TheTopItem.FontName, TheTopItem.Type); } else { //BOOL FirstInList = TRUE; // fill up the list while (FontItem != NULL) { // get the name String_64 Name = FontItem->GetFontName(); WORD Handle = FONTMANAGER->GetFontHandle(&Name); // check the style INT32 Style = FontItem->GetFontStyle(); if(Style & 1) Name += _T(" -Bold"); if(Style & 2) Name += _T(" -Italic"); if(Handle > 0) { if (FONTMANAGER->IsFontReplaced(Handle)) Name += _T(" *"); } FontClass Type = FontItem->GetFontClass(); AddFontToList(Name, Type); FontItem = DocFonts.GetNextItem(FontItem); ContinueSlowJob(); } } } //} // Work out the top item, if any, on the alphabetically sorted list // ready for putting in the top combo box item FontDropItem *pTopItem = (FontDropItem *)Fonts.GetHead(); if (pTopItem != NULL) { // Fill in the top item in the list TheTopItem.FontName = pTopItem->FontName; TheTopItem.Type = pTopItem->Type; } ListItem *Item = Fonts.GetHead(); while (Item != NULL) { // Add the font in the list to the combo box AddItem((void *) Item); // Try the next item Item = Fonts.GetNext(Item); } // Re-enable redraw SetListRedraw(TRUE); // We have no concept of a selected font SetSelectedIndex(-1); EndSlowJob(); return(TRUE); }
BOOL FontDropDown::SetSelection(FontDropItem *TheFont) { ERROR2IF(ParentDlg == NULL, FALSE, "FontDropDown not properly initialised"); INT32 SelectedIndex = -1; TRACEUSER("wuerthne", _T("SetSelection to %s"), (TCHAR*)TheFont->FontName); INT32 Index = 0; INT32 MaxIndex = GetNumberOfItems(); while (Index < MaxIndex) { if ( (TheFont->FontName == ((FontDropItem *) GetItemData(Index))->FontName) && (TheFont->Type == ((FontDropItem *) GetItemData(Index))->Type) ) { SelectedIndex = Index; break; } Index++; } if (Index == MaxIndex) { TRACEUSER("wuerthne", _T("font not in list, Index = %d"), Index); // font was not in the list, so make sure there is a special item at the // end to accomodate it String_64 NewName(TheFont->FontName); NewName += String_64(_R(IDS_FONTMISSING)); if (m_MissingItemAdded) { TRACEUSER("wuerthne", _T("update missing item")); FontDropItem *Item = (FontDropItem*)Fonts.GetTail(); Item->SetInfo(NewName, FC_UNDEFINED); SelectedIndex = Index - 1; } else { TRACEUSER("wuerthne", _T("add missing item")); FontDropItem *Item = new FontDropItem(NewName, FC_UNDEFINED); Fonts.AddTail(Item); AddItem((void*) Item); m_MissingItemAdded = TRUE; SelectedIndex = Index; } } else { // the font was in the list, so if there is a "missing" item at the end remove it // (unless of course, the selected item *is* the "missing" item, but this cannot // normally happen because our item has the added text " (missing)") if (m_MissingItemAdded && SelectedIndex != MaxIndex - 1) { TRACEUSER("wuerthne", _T("remove missing item")); delete( (FontDropItem*)((Fonts.RemoveItem(Fonts.GetTail()))) ); m_MissingItemAdded = FALSE; // delete the item from the combo box DeleteItem(MaxIndex - 1); } } TRACEUSER("wuerthne", _T("setting index to %d"), SelectedIndex); SetSelectedIndex(SelectedIndex); // And set the appropriate selected item TRACEUSER("wuerthne", _T("SetSelection done")); return(TRUE); }
void ComboBox::SetSelectedKey(const String &newSelecetedKey) { SetSelectedIndex(IndexByKey(newSelecetedKey), true); }