wxDataViewItem vvStampsModel::AddItem( const wxString& sName, unsigned int uCount, bool bChecked ) { // check if this item already exists stlDataItemMap::iterator it = this->mcDataItems.find(sName); if (it != this->mcDataItems.end()) { return wxDataViewItem(); } // add the item DataItem cItem; cItem.sName = sName; cItem.uCount = uCount; cItem.bChecked = bChecked; it = this->mcDataItems.insert(it, stlDataItemMap::value_type(sName, cItem)); // create a wxDataViewItem from it wxDataViewItem cViewItem = this->ConvertDataItem(it); // notify anyone that cares about the new item this->ItemAdded(wxDataViewItem(), cViewItem); // return the new item return cViewItem; }
unsigned int MyMusicTreeModel::GetChildren( const wxDataViewItem &parent, wxDataViewItemArray &array ) const { MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) parent.GetID(); if (!node) { array.Add( wxDataViewItem( (void*) m_root ) ); return 1; } if (node == m_classical) { MyMusicTreeModel *model = (MyMusicTreeModel*)(const MyMusicTreeModel*) this; model->m_classicalMusicIsKnownToControl = true; } if (node->GetChildCount() == 0) { return 0; } unsigned int count = node->GetChildren().GetCount(); for (unsigned int pos = 0; pos < count; pos++) { MyMusicTreeModelNode *child = node->GetChildren().Item( pos ); array.Add( wxDataViewItem( (void*) child ) ); } return count; }
wxDataViewItem FunctionsModel::GetParent(const wxDataViewItem& item) const { FunctionsModel_Item* node = reinterpret_cast<FunctionsModel_Item*>(item.m_pItem); if ( node ) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); }
wxDataViewItem CScoptViewResultsModel::GetParent(const wxDataViewItem& item) const { CScoptViewResultsModel_Item* node = reinterpret_cast<CScoptViewResultsModel_Item*>(item.m_pItem); if ( node ) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); }
wxDataViewItem StaleFilesModel::GetParent(const wxDataViewItem& item) const { StaleFilesModel_Item* node = reinterpret_cast<StaleFilesModel_Item*>(item.m_pItem); if ( node ) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); }
void MemCheckOutputView::ShowPageView(size_t page) { // CL_DEBUG1(PLUGIN_PREFIX("MemCheckOutputView::ShowPage()")); if(page < 1) m_currentPage = 1; else if(page > m_pageMax) m_currentPage = m_pageMax; else m_currentPage = page; if(m_currentPage == 0) m_textCtrlPageNumber->Clear(); else pageValidator.TransferToWindow(); // it sets m_textCtrlPageNumber m_currentPageIsEmptyView = true; m_currentItem = wxDataViewItem(0); m_onValueChangedLocked = false; m_markedErrorsCount = 0; m_dataViewCtrlErrorsModel->Clear(); if(m_totalErrorsView == 0) return; ErrorList& errorList = m_plugin->GetProcessor()->GetErrors(); long iStart = (long)(m_currentPage - 1) * m_plugin->GetSettings()->GetResultPageSize(); long iStop = (long)std::min(m_totalErrorsView - 1, m_currentPage * m_plugin->GetSettings()->GetResultPageSize() - 1); // CL_DEBUG1(PLUGIN_PREFIX("start - stop = %lu - %lu", iStart, iStop)); m_currentPageIsEmptyView = (iStop - iStart) < 0; // this should never happen if m_totalErrorsView > 0, but... if(m_currentPageIsEmptyView) return; wxWindowDisabler disableAll; wxBusyInfo wait(wxT(BUSY_MESSAGE)); m_mgr->GetTheApp()->Yield(); unsigned int flags = 0; if(m_plugin->GetSettings()->GetOmitNonWorkspace()) flags |= MC_IT_OMIT_NONWORKSPACE; if(m_plugin->GetSettings()->GetOmitDuplications()) flags |= MC_IT_OMIT_DUPLICATIONS; if(m_plugin->GetSettings()->GetOmitSuppressed()) flags |= MC_IT_OMIT_SUPPRESSED; size_t i = 0; MemCheckIterTools::ErrorListIterator it = MemCheckIterTools::Factory(errorList, m_workspacePath, flags); for(; i < iStart && it != errorList.end(); ++i, ++it) ; // skipping item before start // CL_DEBUG1(PLUGIN_PREFIX("items skiped")); m_mgr->GetTheApp()->Yield(); for(; i <= iStop; ++i, ++it) { if(it == errorList.end()) { CL_WARNING(PLUGIN_PREFIX("Some items skiped. Total errors count mismatches the iterator.")); break; } AddTree(wxDataViewItem(0), *it); // CL_DEBUG1(PLUGIN_PREFIX("adding %lu", i)); if(!(i % WAIT_UPDATE_PER_ITEMS)) m_mgr->GetTheApp()->Yield(); } }
wxDataViewItem GNC::GUI::AcquisitionTableModel::GetParent( const wxDataViewItem &item ) const { if (!item.IsOk()) { return wxDataViewItem(0); } //if it's a study... AcquisitionNode* pNode = (AcquisitionNode*)(item.GetID()); return wxDataViewItem( (void*) pNode->GetParent() ); }
wxDataViewItem TreeListModel::GetParent(const wxDataViewItem& item) const { if ( IsEmpty() ) { return wxDataViewItem(NULL); } TreeListModel_Item* node = reinterpret_cast<TreeListModel_Item*>(item.m_pItem); if ( node ) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); }
wxDataViewItem LLDBBreakpointModel::GetParent(const wxDataViewItem& item) const { if ( IsEmpty() ) { return wxDataViewItem(NULL); } LLDBBreakpointModel_Item* node = reinterpret_cast<LLDBBreakpointModel_Item*>(item.m_pItem); if ( node ) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); }
wxDataViewItem MemCheckDVCErrorsModel::GetParent(const wxDataViewItem& item) const { if ( IsEmpty() ) { return wxDataViewItem(NULL); } MemCheckDVCErrorsModel_Item* node = reinterpret_cast<MemCheckDVCErrorsModel_Item*>(item.m_pItem); if ( node ) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); }
virtual wxDataViewItem GetParent(const wxDataViewItem &item) const { // the invisible root node has no parent if (!item.IsOk()) return wxDataViewItem(0); ReplayProvider* provider = (ReplayProvider*)item.GetID(); if (provider == m_root) return wxDataViewItem(0); return wxDataViewItem((void*)provider->GetParent()); }
void GNC::GUI::AcquisitionTableModel::ClearResults() { CancelCommand(); wxDataViewItemArray toDeleteList; for (TMapIndex::iterator it = studyMap.begin(); it != studyMap.end(); ++it) { toDeleteList.push_back(wxDataViewItem((*it).second)); } //then delete studies Nodes... ItemsDeleted(wxDataViewItem(0), toDeleteList); //delete all and reload again... ClearStudyMap(); }
wxDataViewItem MyMusicTreeModel::GetParent( const wxDataViewItem &item ) const { // the invisible root node has no parent if (!item.IsOk()) return wxDataViewItem(0); MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID(); // "MyMusic" also has no parent if (node == m_root) return wxDataViewItem(0); return wxDataViewItem( (void*) node->GetParent() ); }
void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Refresh() { #ifdef REASSOCIATE_HACK m_Widget->AssociateModel( this ); #else std::queue<wxDataViewItem> todo; todo.push( wxDataViewItem() ); while( !todo.empty() ) { wxDataViewItem current = todo.front(); wxDataViewItemArray items; GetChildren( current, items ); ItemsAdded( current, items ); for( wxDataViewItemArray::const_iterator i = items.begin(); i != items.end(); ++i ) { if( IsContainer( *i ) ) todo.push( *i ); } todo.pop(); } #endif }
/* ActionSpecialTreeView::ActionSpecialTreeView * ActionSpecialTreeView class constructor *******************************************************************/ ActionSpecialTreeView::ActionSpecialTreeView(wxWindow* parent) : wxDataViewTreeCtrl(parent, -1) { parent_dialog = NULL; // Create root item root = wxDataViewItem(0); // Add 'None' item_none = AppendItem(root, "0: None"); // Populate tree vector<as_t> specials = theGameConfiguration->allActionSpecials(); std::sort(specials.begin(), specials.end()); for (unsigned a = 0; a < specials.size(); a++) { AppendItem(getGroup(specials[a].special->getGroup()), S_FMT("%d: %s", specials[a].number, specials[a].special->getName()), -1); } // Bind events Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, &ActionSpecialTreeView::onItemEdit, this); Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &ActionSpecialTreeView::onItemActivated, this); Expand(root); SetMinSize(wxSize(-1, 200)); }
wxDataViewItem vvStampsModel::GetParent( const wxDataViewItem& WXUNUSED(cItem) ) const { // every item's parent is the invisible root return wxDataViewItem(NULL); }
SpecialPresetTreeView(wxWindow* parent) : wxDataViewTreeCtrl{ parent, -1 }, root_{ wxDataViewItem(nullptr) }, parent_dialog_{ nullptr } { // Computing the minimum width of the tree is slightly complicated, since // wx doesn't expose it to us directly wxClientDC dc(this); dc.SetFont(GetFont()); wxSize textsize; // Populate tree addPresets(Game::customSpecialPresets(), textsize, dc); // User custom presets addPresets(Game::configuration().specialPresets(), textsize, dc); // From game configuration wxDataViewCtrl::Expand(root_); // Bind events Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, [&](wxDataViewEvent& e) { e.Veto(); }); Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [&](wxDataViewEvent& e) { if (GetChildCount(e.GetItem()) > 0) { // Expand if group node Expand(e.GetItem()); e.Skip(); } else if (parent_dialog_) parent_dialog_->EndModal(wxID_OK); }); // 64 is an arbitrary fudge factor -- should be at least the width of a // scrollbar plus the expand icons plus any extra padding int min_width = textsize.GetWidth() + GetIndent() + UI::scalePx(64); wxWindowBase::SetMinSize(wxSize(min_width, UI::scalePx(200))); }
AddFunctionsImpDlg::AddFunctionsImpDlg(wxWindow* parent, const TagEntryPtrVector_t &tags, const wxString &targetFile) : AddFunctionsImplBaseDlg(parent) { unsigned int colCount = m_dataviewModel->GetColCount(); m_dataviewModel = new MyAddFunctionsModel(); m_dataviewModel->SetColCount( colCount ); m_dataview->AssociateModel( m_dataviewModel.get() ); m_tags.insert(m_tags.end(), tags.begin(), tags.end()); for(size_t i=0; i<m_tags.size(); ++i) { wxVector<wxVariant> cols; cols.push_back(true); cols.push_back( m_tags.at(i)->GetDisplayName() ); // keep the implementation as the client data wxString body; TagEntryPtr tag = m_tags.at(i); tag->SetSignature( TagsManagerST::Get()->NormalizeFunctionSig( tag->GetSignature(), Normalize_Func_Name ) ); body << TagsManagerST::Get()->FormatFunction(tag, FunctionFormat_Impl); body << wxT("\n"); m_dataviewModel->AppendItem( wxDataViewItem(0), cols, new wxStringClientData(body) ); } m_filePicker->SetPath( targetFile ); WindowAttrManager::Load(this, "AddFunctionsImpDlg", NULL); }
unsigned int vvStampsControl::GetItemData( stlItemDataList* pItems, vvNullable<bool> nbChecked ) const { if (this->mpDataModel == NULL) { return 0u; } // run through all the items in the control unsigned int uCount = 0u; wxDataViewItemArray cChildren; this->mpDataModel->GetChildren(wxDataViewItem(), cChildren); for (wxDataViewItemArray::iterator it = cChildren.begin(); it != cChildren.end(); ++it) { // get the item's data ItemData cData; this->GetItemData(*it, cData); // check if the item matches our criteria if (nbChecked.IsNull() || nbChecked.GetValue() == cData.bChecked) { if (pItems != NULL) { pItems->push_back(cData); } ++uCount; } } return uCount; }
void MemCheckOutputView::OnMarkedErrorsToClip(wxCommandEvent& event) { wxDataViewEvent* menuEvent = dynamic_cast<wxDataViewEvent*>(event.GetEventUserData()); if(!menuEvent) return; wxString text; wxVariant variant; wxDataViewItemArray items; m_dataViewCtrlErrorsModel->GetChildren(wxDataViewItem(0), items); int supColumn = GetColumnByName(_("Suppress")); if(supColumn == wxNOT_FOUND) { return; } MemCheckErrorReferrer* errorRef; for(wxDataViewItemArray::iterator it = items.begin(); it != items.end(); ++it) { m_dataViewCtrlErrorsModel->GetValue(variant, *it, supColumn); if(variant.GetBool()) { errorRef = dynamic_cast<MemCheckErrorReferrer*>(m_dataViewCtrlErrorsModel->GetClientObject(*it)); text.Append(errorRef->Get().toString()); text.Append(wxT("\n\n")); } } text.Trim(); if(wxTheClipboard->Open()) { wxTheClipboard->SetData(new wxTextDataObject(text)); wxTheClipboard->Close(); } }
wxDataViewItem GraphTreeModel::findParentIter(const scene::INodePtr& node) const { // Find the parent's GraphTreeNode const GraphTreeNodePtr& nodePtr = findParentNode(node); // Return an empty iterator if not found return (nodePtr != NULL) ? nodePtr->getIter() : wxDataViewItem(); }
virtual unsigned int GetChildren( wxDataViewItemArray& aItems ) const { /// @todo C++11 for( std::list<Pin*>::const_iterator i = m_Members.begin(); i != m_Members.end(); ++i ) aItems.push_back( wxDataViewItem( *i ) ); return aItems.size(); }
wxDataViewItem ToDVI(Node* node) const { // Our root item must be represented as NULL at wxDVC level to map to // its own invisible root. if ( !node->GetParent() ) return wxDataViewItem(); return ToNonRootDVI(node); }
wxDataViewItem TreeListModel::InsertItem(const wxDataViewItem& insertBeforeMe, const wxVector<wxVariant>& data, wxClientData *clientData) { wxDataViewItem ch = DoInsertItem(insertBeforeMe, data, false, clientData); if ( ch.IsOk() ) { TreeListModel_Item* node = reinterpret_cast<TreeListModel_Item*>(ch.GetID()); ItemAdded(wxDataViewItem(node->GetParent()), ch); } return ch; }
void MemCheckOutputView::OnUnmarkAllErrors(wxCommandEvent& event) { wxDataViewItemArray items; m_dataViewCtrlErrorsModel->GetChildren(wxDataViewItem(0), items); for(wxDataViewItemArray::iterator it = items.begin(); it != items.end(); ++it) { MarkTree(*it, false); } }
unsigned int DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetChildren( const wxDataViewItem& aItem, wxDataViewItemArray& aItems ) const { if( !aItem.IsOk() ) { for( std::map<wxString, Group>::iterator i = m_Groups.begin(); i != m_Groups.end(); ++i ) if( i->second.GetCount() > 1 ) aItems.push_back( wxDataViewItem( &i->second ) ); for( std::list<Pin>::iterator i = m_Pins.begin(); i != m_Pins.end(); ++i ) if( !i->GetParent().IsOk() ) aItems.push_back( wxDataViewItem( &*i ) ); return aItems.size(); } else return reinterpret_cast<Item const*>( aItem.GetID() )->GetChildren( aItems ); }
void wxDataViewCtrl::FinishCustomItemEditing() { if (GetCustomRendererItem().IsOk()) { GetCustomRendererPtr()->FinishEditing(); SetCustomRendererItem(wxDataViewItem()); SetCustomRendererPtr (NULL); } }
void CScoptViewResultsModel::Clear() { wxVector<CScoptViewResultsModel_Item*> roots = m_data; wxVector<CScoptViewResultsModel_Item*>::iterator iter = roots.begin(); for(; iter != roots.end(); ++iter) { DeleteItem( wxDataViewItem(*iter) ); } Cleared(); }
void MemCheckOutputView::OnExpandAll(wxCommandEvent& event) { // CL_DEBUG1(PLUGIN_PREFIX("MemCheckOutputView::OnExpandAll()")); m_notebookOutputView->ChangeSelection(m_notebookOutputView->FindPage(m_panelErrors)); // not implemented in wxDVC :( // m_dataViewCtrlErrors->ExpandAll(); ExpandAll(wxDataViewItem(0)); }
void StaleFilesModel::Clear() { wxVector<StaleFilesModel_Item*> roots = m_data; wxVector<StaleFilesModel_Item*>::iterator iter = roots.begin(); for(; iter != roots.end(); ++iter) { DeleteItem( wxDataViewItem(*iter) ); } Cleared(); }