bool CLocalListView::OnAcceptRename(const wxListEvent& event) { const int index = event.GetIndex(); if (!index && m_hasParent) return false; if (event.GetLabel() == _T("")) return false; if (!m_pState->GetLocalDir().IsWriteable()) return false; CLocalFileData *const data = GetData(event.GetIndex()); if (!data || data->flags == fill) return false; wxString newname = event.GetLabel(); #ifdef __WXMSW__ newname = newname.Left(255); #endif if (newname == data->name) return false; if (!RenameFile(this, m_dir, data->name, newname)) return false; data->name = newname; #ifdef __WXMSW__ data->label = data->name; #endif m_pState->RefreshLocal(); return true; }
void GamessQFrame::OnJoblistctrlEndLabelEdit( wxListEvent& event ) { Job *job = mJobList.Item(event.GetIndex())->GetData(); if (mQueueManager.SetName(job->GetId(), event.GetLabel())) { job->SetName(event.GetLabel()); } RefreshButtons(); }
void ResourceLibraryDialog::OnlistCtrlItemActivated(wxListEvent& event) { if ( event.GetLabel() == _("Parent folder") && event.GetIndex() == 0 ) { wxFileName dir = wxFileName::DirName(currentDir+"/.."); currentDir = dir.GetPath(); ConstructList(); } else if (wxDirExists(currentDir+"/"+event.GetLabel())) { wxFileName filename = wxFileName::FileName(currentDir+"/"+event.GetLabel()); filename.Normalize(); currentDir = filename.GetFullPath(); ConstructList(); } }
void WFileList::OnEndLabelEdit(wxListEvent& event) { wmain->container.SetSubFileProperty(event.GetIndex(), "Name", strWX2STL(event.GetLabel())); wmain->UpdateSubFileCaption(event.GetIndex()); wmain->SetModified(); }
void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event ) { wxFileData *fd = (wxFileData*)event.m_item.m_data; wxASSERT( fd ); if ((event.GetLabel().empty()) || (event.GetLabel() == _(".")) || (event.GetLabel() == _("..")) || (event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND)) { wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR ); dialog.ShowModal(); event.Veto(); return; } wxString new_name( wxPathOnly( fd->GetFilePath() ) ); new_name += wxFILE_SEP_PATH; new_name += event.GetLabel(); wxLogNull log; if (wxFileExists(new_name)) { wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR ); dialog.ShowModal(); event.Veto(); } if (wxRenameFile(fd->GetFilePath(),new_name)) { fd->SetNewName( new_name, event.GetLabel() ); ignoreChanges = true; SetItemState( event.GetItem(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); ignoreChanges = false; UpdateItem( event.GetItem() ); EnsureVisible( event.GetItem() ); } else { wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR ); dialog.ShowModal(); event.Veto(); } }
/** * Event handler for when the user finished editing a name * Copies the namestring given by the user back to the settings * * @param event */ void EditLocationsDialog::OnEditFinished(wxListEvent &event) { if(event.GetIndex() < 0 || event.GetIndex() >= (int)settings.locations.size()) return; strncpy((char*) &settings.locations[event.GetIndex()].name, event.GetLabel().char_str(), LOCATION_LENGTH+1); editing = false; UpdateButtons(); }
void wxGxContentView::OnEndLabelEdit(wxListEvent& event) { //event.Skip(); if ( event.GetLabel().IsEmpty() ) { event.Veto(); return; } LPITEMDATA pItemData = (LPITEMDATA)event.GetData(); if(pItemData == NULL) { event.Veto(); return; } wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pItemData->nObjectID); IGxObjectEdit* pObjEdit = dynamic_cast<IGxObjectEdit*>(pGxObject); if(pObjEdit == NULL) { event.Veto(); return; } if(pObjEdit->Rename(event.GetLabel())) { m_pCatalog->ObjectChanged(pGxObject->GetId()); } else { event.Veto(); wxMessageBox(_("Rename failed!"), _("Error"), wxICON_ERROR | wxOK ); SORTDATA sortdata = { m_bSortAsc, m_currentSortCol }; SortItems(GxObjectCVCompareFunction, (long)&sortdata); SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1); return; } }
void EditChainsDialog::OnChainsEndEdit(wxListEvent &event) { if (event.IsEditCancelled()) { return; } wxString newname = event.GetLabel(); mBatchCommands.RenameChain(mActiveChain, newname); mActiveChain = newname; PopulateChains(); }
void PakFileDialog::OnListItemSelected( wxListEvent& ev ) { m_selected = ev.GetLabel(); pakbrowser_files_type::iterator fit = m_files.find(m_selected); if( fit != m_files.end() ) { // it's a file update_preview(fit->second + wxT("#zip:") + m_curpath + m_selected); pakbrowser_files_type::iterator fit = m_files.find(m_selected); #ifdef NDEBUG if( fit != m_files.end() ) #endif m_infolabel->SetLabel( _("Archive: ") + fit->second); } else { // it's a dir m_preview->SetBitmap(wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(64, 64))); update_nolabel(); } }
void DataModelListCtrl::OnEndLabelEdit(wxListEvent& event) { if (!event.IsEditCancelled()) { wxDataModelBase* db = GetModel(); const wxString str = event.GetLabel(); const int pos = GetFirstSelected(); bool ok = (pos != wxNOT_FOUND); wxString errorMsg = _("Failed"); if (ok) { wxDataModelColumnInfo info; ok = GetModel()->GetColumn(m_column_clicked, &info); if (ok && (info.VariantType == wxT("string")) ) { ok = (str.length() <= info.Length); if (!ok) errorMsg = _("Text too long"); } if (ok) { wxVariant var = str; if (ok) ok = db->SetValueByRow(var, pos, m_column_clicked); } } if (!ok) { wxMessageBox(errorMsg); event.Veto(); } } m_column_clicked = wxNOT_FOUND; }
void CLocalListView::OnEndLabelEdit(wxListEvent& event) { if (event.IsEditCancelled()) return; int index = event.GetIndex(); if (!index && m_hasParent) { event.Veto(); return; } if (event.GetLabel() == _T("")) { event.Veto(); return; } wxString newname = event.GetLabel(); #ifdef __WXMSW__ newname = newname.Left(255); if ((newname.Find('/') != -1) || (newname.Find('\\') != -1) || (newname.Find(':') != -1) || (newname.Find('*') != -1) || (newname.Find('?') != -1) || (newname.Find('"') != -1) || (newname.Find('<') != -1) || (newname.Find('>') != -1) || (newname.Find('|') != -1)) { wxMessageBox(_("Filenames may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION); event.Veto(); return; } SHFILEOPSTRUCT op; memset(&op, 0, sizeof(op)); wxString dir = m_dir; if (dir.Right(1) != _T("\\") && dir.Right(1) != _T("/")) dir += _T("\\"); wxString from = dir + m_fileData[m_indexMapping[index]].name + _T(" "); from.SetChar(from.Length() - 1, '\0'); op.pFrom = from; wxString to = dir + newname + _T(" "); to.SetChar(to.Length()-1, '\0'); op.pTo = to; op.hwnd = (HWND)GetHandle(); op.wFunc = FO_RENAME; op.fFlags = FOF_ALLOWUNDO; if (SHFileOperation(&op)) event.Veto(); else { m_fileData[m_indexMapping[index]].name = newname; return; } #else if ((newname.Find('/') != -1) || (newname.Find('*') != -1) || (newname.Find('?') != -1) || (newname.Find('<') != -1) || (newname.Find('>') != -1) || (newname.Find('|') != -1)) { wxMessageBox(_("Filenames may not contain any of the following characters: / * ? < > |"), _("Invalid filename"), wxICON_EXCLAMATION); event.Veto(); return; } wxString dir = m_dir; if (dir.Right(1) != _T("\\") && dir.Right(1) != _T("/")) dir += _T("\\"); if (wxRename(dir + m_fileData[m_indexMapping[index]].name, dir + newname)) m_fileData[m_indexMapping[index]].name = newname; else event.Veto(); #endif }
void PakFileDialog::OnListItemDblClick( wxListEvent& ev ) { wxString name = ev.GetLabel(); open_dir(name); }
void MainFrame::OnListEndLabel(wxListEvent& evt) { if (evt.IsEditCancelled()) return; wxTreeItemId tree_id = m_pTree->GetSelection(); if (!tree_id) { evt.Veto(); return; } TreeItemData* pItem = (TreeItemData*)m_pTree->GetItemData(tree_id); if (!pItem) { evt.Veto(); return; } wxString strOld = m_pList->GetItemText(evt.GetIndex()); try { if (!pItem->RenameValue(Omega::string_t(strOld.wc_str(),Omega::string_t::npos),Omega::string_t(evt.GetLabel().wc_str(),Omega::string_t::npos))) { wxMessageBox(wxString::Format(_("Cannot rename %s: The specified value name already exists. Type another name and try again."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this); evt.Veto(); } } catch (Omega::IAlreadyExistsException* pE) { pE->Release(); wxMessageBox(wxString::Format(_("Cannot rename %s: The specified value name already exists. Type another name and try again."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this); evt.Veto(); } catch (Omega::Registry::IBadNameException* pE) { pE->Release(); wxMessageBox(wxString::Format(_("Cannot rename %s: The specified value name is invalid. Type another name and try again."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this); evt.Veto(); } catch (Omega::Registry::IAccessDeniedException* pE) { pE->Release(); wxMessageBox(wxString::Format(_("Cannot rename %s: You do not have permission to edit this part of the registry."),strOld.c_str()),_("Error Renaming Value"),wxOK|wxICON_ERROR,this); evt.Veto(); } catch (Omega::IException* pE) { wxMessageBox(pE->GetDescription().c_wstr(),_("System Error"),wxOK|wxICON_ERROR,this); pE->Release(); evt.Veto(); } catch (...) { evt.Veto(); throw; } }