void hListBox::selectElement(std::string label) { hGuiData * foundData = findElement(label); if(foundData != NULL) selectElement(foundData->offset+1); }
unsigned LayoutListBox::size() const { unsigned specifiedSize = selectElement()->size(); if (specifiedSize >= 1) return specifiedSize; return defaultSize; }
// process the callback. This invokes the callback by calling the handle, // and using the processEventPointer to send back the scope uint8_t GuiElementList::callbackProcess(processEvent_t processEventHandle, void* processEventPointer, GuiElement *element, uint8_t event) { if (!visible() || !enabled()) return 0; if (event == GUI_EVENT_PRESS && selectedElement) { selectElement(selectedElement, true); // chain the callback selectedElement->callbackProcess(processEventHandle, processEventPointer, selectedElement, event); } if (processEventHandle != NULL) processEventHandle(NULL, selectedElement, event); // draw(); // this return is for the c++ version of the callbacks return 0; /* * Here is the caller side implementation. it needs a static class wrapper adding to the caller * which when called uses casting to cast back to the stored source class * * static uint8_t processEvent(void *p, GuiElement *element, uint8_t event) { * return ((CallBackSourceClass *)p)->callbackFunction(element, event); * } * * where the callback function is defined as * uint8_t callbackFunction(GuiElement *element, uint8_t event); * * don't forget to connect the callback * * button.connectCallback(processEvent, this); <-- note we pass the static function * */ }
void GUIResourceTreeView::setSelection(const Vector<Path>& paths) { unselectAll(); Stack<ResourceTreeElement*> todo; todo.push(&mRootElement); while (!todo.empty()) { ResourceTreeElement* currentElem = todo.top(); todo.pop(); auto iterFind = std::find(paths.begin(), paths.end(), currentElem->mFullPath); if (iterFind != paths.end()) { expandToElement(currentElem); selectElement(currentElem); } for (auto& child : currentElem->mChildren) { ResourceTreeElement* sceneChild = static_cast<ResourceTreeElement*>(child); todo.push(sceneChild); } } }
void CheckDocument::slotSelect(QTreeWidgetItem* ite) { if (itemMap.contains(ite)) { // #10537 Check item has not been destroyed before requesting its selection if (itemMap[ite].isNull()) return; ScCore->primaryMainWindow()->closeActiveWindowMasterPageEditor(); m_Doc->setActiveLayer(itemMap[ite]->LayerNr); ScCore->primaryMainWindow()->changeLayer(m_Doc->activeLayer()); emit selectElement(itemMap[ite]->OwnPage, itemMap[ite]->ItemNr); return; } if (pageMap.contains(ite)) { // #10537 Get page index from pointer in case user has deleted a page // after preflight has been run int pageIndex = m_Doc->DocPages.indexOf(pageMap[ite]); if (pageIndex < 0) return; ScCore->primaryMainWindow()->closeActiveWindowMasterPageEditor(); emit selectPage(pageIndex); return; } if (masterPageMap.contains(ite)) { // #10537 Get page index from pointer in case user has deleted a page // after preflight has been run int pageIndex = m_Doc->MasterPages.indexOf(masterPageMap[ite]); if (pageIndex < 0) return; emit selectMasterPage(masterPageMap[ite]->pageName()); return; } if (masterPageItemMap.contains(ite)) { // #10537 Check item has not been destroyed before requesting its selection if (masterPageItemMap[ite].isNull()) return; if (!m_Doc->masterPageMode()) emit selectMasterPage(masterPageItemMap[ite]->OnMasterPage); m_Doc->setActiveLayer(masterPageItemMap[ite]->LayerNr); ScCore->primaryMainWindow()->changeLayer(m_Doc->activeLayer()); emit selectElement(-1, masterPageItemMap[ite]->ItemNr); return; } }
/** * Helper method for getting the focused DOM Node from our parent(list) node. We * need to use the frame to get the focused option because for some reason we * weren't getting the proper notification when the focus changed using the DOM */ already_AddRefed<nsIContent> nsHTMLSelectOptionAccessible::GetFocusedOption(nsIContent *aListNode) { NS_ASSERTION(aListNode, "Called GetFocusedOptionNode without a valid list node"); nsIFrame *frame = aListNode->GetPrimaryFrame(); if (!frame) return nsnull; PRInt32 focusedOptionIndex = 0; // Get options nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(aListNode)); NS_ASSERTION(selectElement, "No select element where it should be"); nsCOMPtr<nsIDOMHTMLOptionsCollection> options; nsresult rv = selectElement->GetOptions(getter_AddRefs(options)); if (NS_SUCCEEDED(rv)) { nsIListControlFrame *listFrame = do_QueryFrame(frame); if (listFrame) { // Get what's focused in listbox by asking frame for "selected item". // Can't use dom interface for this, because it will always return the first selected item // when there is more than 1 item selected. We need the focused item, not // the first selected item. focusedOptionIndex = listFrame->GetSelectedIndex(); if (focusedOptionIndex == -1) { nsCOMPtr<nsIDOMNode> nextOption; while (PR_TRUE) { ++ focusedOptionIndex; options->Item(focusedOptionIndex, getter_AddRefs(nextOption)); nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = do_QueryInterface(nextOption); if (!optionElement) { break; } PRBool disabled; optionElement->GetDisabled(&disabled); if (!disabled) { break; } } } } else // Combo boxes can only have 1 selected option, so they can use the dom interface for this rv = selectElement->GetSelectedIndex(&focusedOptionIndex); } // Either use options and focused index, or default return null if (NS_SUCCEEDED(rv) && options && focusedOptionIndex >= 0) { // Something is focused nsCOMPtr<nsIDOMNode> focusedOptionNode; options->Item(focusedOptionIndex, getter_AddRefs(focusedOptionNode)); nsIContent *focusedOption = nsnull; if (focusedOptionNode) CallQueryInterface(focusedOptionNode, &focusedOption); return focusedOption; } return nsnull; }
MetaEditor::MetaEditor(QWidget *parent) : QDialog(parent), m_mainWindow(qobject_cast<MainWindow *>(parent)), m_Relator(MarcRelators::instance()), m_RemoveRow(new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Delete),this, 0, 0, Qt::WidgetWithChildrenShortcut)) { setupUi(this); m_book = m_mainWindow->GetCurrentBook(); m_version = m_book->GetConstOPF()->GetEpubVersion(); m_opfdata = m_book->GetOPF()->GetText(); QStringList headers; headers << tr("Name") << tr("Value"); QString data = GetOPFMetadata(); TreeModel *model = new TreeModel(headers, data); view->setModel(model); for (int column = 0; column < model->columnCount(); ++column) view->resizeColumnToContents(column); if (!isVisible()) { ReadSettings(); } if (m_version.startsWith('3')) { loadMetadataElements(); loadMetadataProperties(); } else { loadE2MetadataElements(); loadE2MetadataProperties(); } connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateActions())); connect(delButton, SIGNAL(clicked()), this, SLOT(removeRow())); connect(tbMoveUp, SIGNAL(clicked()), this, SLOT(moveRowUp())); connect(tbMoveDown, SIGNAL(clicked()), this, SLOT(moveRowDown())); connect(m_RemoveRow, SIGNAL(activated()), this, SLOT(removeRow())); if (m_version.startsWith('3')) { connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectElement())); connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectProperty())); } else { connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectE2Element())); connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectE2Property())); } connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveData())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); updateActions(); }
int SkinContext::selectInt(const QDomNode& node, const QString& nodeName, bool* pOk) const { bool ok = false; int conv = nodeToString(selectElement(node, nodeName)).toInt(&ok); if (pOk != NULL) { *pOk = ok; } return ok ? conv : 0; }
void LayoutMenuList::updateOptionsWidth() const { float maxOptionWidth = 0; for (const auto& option : selectElement()->optionList()) { String text = option->textIndentedToRespectGroupLabel(); const ComputedStyle* itemStyle = option->computedStyle() ? option->computedStyle() : style(); applyTextTransform(itemStyle, text, ' '); // We apply SELECT's style, not OPTION's style because m_optionsWidth is // used to determine intrinsic width of the menulist box. TextRun textRun = constructTextRun(style()->font(), text, *style()); maxOptionWidth = std::max(maxOptionWidth, style()->font().width(textRun)); } m_optionsWidth = static_cast<int>(ceilf(maxOptionWidth)); }
UIElement* UI::scroll(MouseCursor& cursor) { int scroll_amount = cursor.scrollWheel(); if(!scroll_amount) return 0; bool dir = (scroll_amount > 0); UIElement* el = scrollableElementAt(cursor.getPos()); if(!el) return 0; if(el->isSelectable()) selectElement(el); el->scroll(dir); return el; }
void OutlinePalette::slotSelect(QTreeWidgetItem* ite, int col) { if (!m_MainWindow || m_MainWindow->scriptIsRunning()) return; selectionTriggered = true; OutlineTreeItem *item = (OutlineTreeItem*)ite; uint pg = 0; PageItem *pgItem = NULL; switch (item->type) { case 0: emit selectMasterPage(item->PageObject->pageName()); break; case 1: if (!currDoc->masterPageMode()) emit selectMasterPage(item->PageItemObject->OnMasterPage); if (item->PageItemObject->Groups.count() == 0) emit selectElement(-1, item->PageItemObject->ItemNr, false); else { if (item->PageItemObject->isGroupControl) emit selectElement(-1, item->PageItemObject->ItemNr, false); else emit selectElement(-1, item->PageItemObject->ItemNr, true); } break; case 2: pg = item->PageObject->pageNr(); m_MainWindow->closeActiveWindowMasterPageEditor(); emit selectPage(pg); break; case 3: case 4: pgItem = item->PageItemObject; m_MainWindow->closeActiveWindowMasterPageEditor(); if (pgItem->Groups.count() == 0) emit selectElement(pgItem->OwnPage, pgItem->ItemNr, false); else { if (pgItem->isGroupControl) emit selectElement(pgItem->OwnPage, pgItem->ItemNr, false); else emit selectElement(pgItem->OwnPage, pgItem->ItemNr, true); } break; default: break; } selectionTriggered = false; }
void LayoutMenuList::updateFromElement() { HTMLSelectElement* select = selectElement(); HTMLOptionElement* option = select->optionToBeShown(); String text = emptyString(); m_optionStyle.clear(); if (select->isMultiple()) { unsigned selectedCount = 0; HTMLOptionElement* selectedOptionElement = nullptr; for (const auto& option : select->optionList()) { if (option->selected()) { if (++selectedCount == 1) selectedOptionElement = option; } } if (selectedCount == 1) { text = selectedOptionElement->textIndentedToRespectGroupLabel(); m_optionStyle = selectedOptionElement->mutableComputedStyle(); } else { Locale& locale = select->locale(); String localizedNumberString = locale.convertToLocalizedNumber(String::number(selectedCount)); text = locale.queryString(WebLocalizedString::SelectMenuListText, localizedNumberString); ASSERT(!m_optionStyle); } } else { if (option) { text = option->textIndentedToRespectGroupLabel(); m_optionStyle = option->mutableComputedStyle(); } } setText(text.stripWhiteSpace()); didUpdateActiveOption(option); }
LayoutUnit LayoutListBox::itemHeight() const { HTMLSelectElement* select = selectElement(); if (!select) return LayoutUnit(); const auto& items = select->listItems(); if (items.isEmpty()) return defaultItemHeight(); LayoutUnit maxHeight; for (Element* element : items) { if (isHTMLOptGroupElement(element)) element = &toHTMLOptGroupElement(element)->optGroupLabelElement(); LayoutObject* layoutObject = element->layoutObject(); LayoutUnit itemHeight; if (layoutObject && layoutObject->isBox()) itemHeight = toLayoutBox(layoutObject)->size().height(); else itemHeight = defaultItemHeight(); maxHeight = std::max(maxHeight, itemHeight); } return maxHeight; }
int main(){ exception e; FILE *f = NULL; int i = 0,count=0,par_count=0,v=0; char* filename = "./bioinfo.xml"; struct stat s; UByte *xml = NULL; // this is the buffer containing the XML content, UByte means unsigned byte VTDGen *vg = NULL; // This is the VTDGen that parses XML VTDNav *vn = NULL; // This is the VTDNav that navigates the VTD records AutoPilot *ap = NULL; // allocate a piece of buffer then reads in the document content // assume "c:\soap2.xml" is the name of the file f = fopen(filename,"r"); stat(filename,&s); i = (int) s.st_size; wprintf(L"size of the file is %d \n",i); xml = (UByte *)malloc(sizeof(UByte) *i); i = fread(xml,sizeof(UByte),i,f); Try{ vg = createVTDGen(); setDoc(vg,xml,i); parse(vg,TRUE); vn = getNav(vg); ap = createAutoPilot2(); bind(ap,vn); if (selectXPath(ap,L"/bix/package/command/parlist")){ while(evalXPath(ap)!= -1){ count++; } } if (selectXPath(ap,L"/bix/package/command/parlist/par")){ while(evalXPath(ap)!= -1){ par_count++; } } wprintf(L"count ==> %d \n",count); wprintf(L"par_count ==> %d \n",par_count); toElement(vn,ROOT); selectElement(ap,L"par"); while(iterateAP(ap)){ if (getCurrentDepth(vn) == 4){ v++; } } wprintf(L"verify ==> %d \n",v); fclose(f); // remember C has no automatic garbage collector // needs to deallocate manually. freeVTDNav(vn); freeVTDGen(vg); freeAutoPilot(ap); } Catch (e) { if (e.et == parse_exception) printf("parse exception e ==> %s \n %s\n", e.msg, e.sub_msg); // manual garbage collection here freeVTDGen(vg); } return 0; }
double SkinContext::selectDouble(const QDomNode& node, const QString& nodeName) const { bool ok = false; double conv = nodeToString(selectElement(node, nodeName)).toDouble(&ok); return ok ? conv : 0.0; }
float SkinContext::selectFloat(const QDomNode& node, const QString& nodeName) const { bool ok = false; float conv = nodeToString(selectElement(node, nodeName)).toFloat(&ok); return ok ? conv : 0.0f; }
QString SkinContext::selectString(const QDomNode& node, const QString& nodeName) const { QDomElement child = selectElement(node, nodeName); return nodeToString(child); }
int SkinContext::selectInt(const QDomNode& node, const QString& nodeName) const { bool ok = false; int conv = nodeToString(selectElement(node, nodeName)).toInt(&ok); return ok ? conv : 0; }
void hListBox::elementSetSelected(int element, bool flag) { if(flag == true) selectElement(element); else unselectElement(element); }
void UI::removeElement(UIElement* e) { if(e == getSelected()) selectElement(0); elements.erase(std::remove(elements.begin(), elements.end(), e), elements.end()); e->setUI(0); }
void LayoutListBox::stopAutoscroll() { HTMLSelectElement* select = selectElement(); if (select->isDisabledFormControl()) return; select->handleMouseRelease(); }
void hListBox::selectItem(int item) { selectElement(item); }