BOOL CBrowseDlg::OnInitDialog() { CCeDialog::OnInitDialog(); LocalizeDialog(GetSafeHwnd(), IDD); // make extension list int nStart = 0; int nSemiCol = m_strExts.Find(';'); while (nSemiCol != -1) { m_arExts.Add(m_strExts.Mid(nStart, nSemiCol - nStart)); nStart = nSemiCol + 1; nSemiCol = m_strExts.Find(';', nStart); } m_arExts.Add(m_strExts.Mid(nStart)); CDC *pDC = GetDC(); if (pDC->GetDeviceCaps(LOGPIXELSX) > 130) m_oImageList.Create(IDB_DIRS_HI, SCALEX(16), 10, RGB(255, 0, 255)); else m_oImageList.Create(IDB_DIRS, SCALEX(16), 10, RGB(255, 0, 255)); ReleaseDC(pDC); // menu bar BOOL fSuccess; SHMENUBARINFO mbi = { 0 }; mbi.cbSize = sizeof(mbi); mbi.dwFlags = SHCMBF_HMENU; mbi.nToolBarId = m_nMenuID; //m_bNewFolderBtn ? IDR_BROWSE : IDR_CANCEL; mbi.hInstRes = AfxGetInstanceHandle(); mbi.hwndParent = GetSafeHwnd(); fSuccess = SHCreateMenuBar(&mbi); m_hwndCmdBar = mbi.hwndMB; LocalizeMenubar(m_hwndCmdBar); SHFILEINFO sfi = { 0 }; // folder ZeroMemory(&sfi, sizeof(sfi)); SHGetFileInfo(_T("\\"), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SMALLICON); m_oImageList.Add(sfi.hIcon); m_ctlDirs.SetImageList(&m_oImageList, TVSIL_NORMAL); // m_ctlCaption.SetTitle(m_strCaption); // sanitize path if (m_strPath.Right(1).CompareNoCase(_T("\\")) != 0) m_strPath += _T("\\"); FillMe(); SelectPath(m_strPath); SetForegroundWindow(); // SESSION_RESTORE; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void wxGenericDirCtrl::SelectPaths(const wxArrayString& paths) { if ( HasFlag(wxDIRCTRL_MULTIPLE) ) { UnselectAll(); for ( unsigned n = 0; n < paths.size(); n++ ) { SelectPath(paths[n]); } } }
inline void ProfileListWidget::CopyClicked() { assert(GetList().GetCursorIndex() < list.size()); const auto &item = list[GetList().GetCursorIndex()]; const TCHAR *old_path = item.path; const TCHAR *old_filename = item.name; ProfileMap data; if (!Profile::LoadFile(data, old_path)) { ShowMessageBox(old_filename, _("Failed to load file."), MB_OK|MB_ICONEXCLAMATION); return; } if (!CheckProfilePasswordResult(CheckProfilePassword(data))) return; StaticString<64> new_name; new_name.clear(); if (!TextEntryDialog(new_name, _("Profile name"))) return; StaticString<80> new_filename; new_filename = new_name; new_filename += _T(".prf"); StaticString<MAX_PATH> new_path; LocalPath(new_path.buffer(), new_filename); if (File::ExistsAny(new_path)) { ShowMessageBox(new_name, _("File exists already."), MB_OK|MB_ICONEXCLAMATION); return; } if (!Profile::SaveFile(data, new_path)) { ShowMessageBox(new_name, _("Failed to save file."), MB_OK|MB_ICONEXCLAMATION); return; } UpdateList(); SelectPath(new_path); }
int PathAndFile::ValidatePath(void) { int Result; RepeatCheck: if (PROJ_chdir(Path)) { if ((Result = UserMessageYNCAN("Output Event Path", "An invalid output directory is specified for one of the Output Events. Select a new directory or cancel the rendering?")) == 0) return (0); if (Result == 2) { if (SelectPath()) goto RepeatCheck; return (0); } // if return (1); } // if return (1); } // PathAndFile::ValidatePath
inline void ProfileListWidget::NewClicked() { StaticString<64> name; name.clear(); if (!TextEntryDialog(name, _("Profile name"))) return; StaticString<80> filename; filename = name; filename += _T(".prf"); StaticString<MAX_PATH> path; LocalPath(path.buffer(), filename); if (!File::CreateExclusive(path)) { ShowMessageBox(name, _("File exists already."), MB_OK|MB_ICONEXCLAMATION); return; } UpdateList(); SelectPath(path); }
BOOL CBCGPBreadcrumb::PreTranslateMessage (MSG* pMsg) { if (m_pInplaceEdit == NULL && pMsg->message == WM_KEYDOWN) { if (IsCharAlphaNumeric((TCHAR)pMsg->wParam) || pMsg->wParam == VK_SPACE) { WindowProc (pMsg->message, pMsg->wParam, pMsg->lParam); return TRUE; } } if (m_pInplaceEdit != NULL && pMsg->hwnd == m_pInplaceEdit->GetSafeHwnd () && pMsg->message == WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: { CString strPath; m_pInplaceEdit->GetWindowText (strPath); if (!ValidateInplaceEdit (strPath)) { // Continue editing return TRUE; } CancelInplaceEditor (); SelectPath (strPath); return TRUE; } case VK_ESCAPE: CancelInplaceEditor (); return TRUE; } } return CEdit::PreTranslateMessage (pMsg); }
void wxExGenericDirCtrl::ExpandAndSelectPath(const wxString& path) { UnselectAll(); ExpandPath(path); SelectPath(path); }
void VirtualDirectorySelectorDlg::DoBuildTree() { wxWindowUpdateLocker locker(m_treeCtrl); m_treeCtrl->DeleteAllItems(); if ( m_images == NULL ) { m_images = new wxImageList(16, 16); BitmapLoader bmpLoader; m_images->Add( bmpLoader.LoadBitmap( wxT( "workspace/16/workspace" ) ) );//0 m_images->Add( bmpLoader.LoadBitmap( wxT( "workspace/16/virtual_folder" ) ) ); //1 m_images->Add( bmpLoader.LoadBitmap( wxT( "workspace/16/project" ) ) ); //2 m_treeCtrl->AssignImageList(m_images); } if (m_workspace) { wxArrayString projects; m_workspace->GetProjectList(projects); VisualWorkspaceNode nodeData; nodeData.name = m_workspace->GetName(); nodeData.type = ProjectItem::TypeWorkspace; TreeNode<wxString, VisualWorkspaceNode> *tree = new TreeNode<wxString, VisualWorkspaceNode>(m_workspace->GetName(), nodeData); for (size_t i=0; i<projects.GetCount(); i++) { if (!m_projectName.empty() && projects.Item(i) != m_projectName) { // If we were passed a specific project, display only that one continue; } wxString err; ProjectPtr p = m_workspace->FindProjectByName(projects.Item(i), err); if (p) { p->GetVirtualDirectories(tree); } } //create the tree wxTreeItemId root = m_treeCtrl->AddRoot(nodeData.name, 0, 0); tree->GetData().itemId = root; TreeWalker<wxString, VisualWorkspaceNode> walker(tree); for (; !walker.End(); walker++) { // Add the item to the tree TreeNode<wxString, VisualWorkspaceNode>* node = walker.GetNode(); // Skip root node if (node->IsRoot()) continue; wxTreeItemId parentHti = node->GetParent()->GetData().itemId; if (parentHti.IsOk() == false) { parentHti = root; } int imgId(2); // Virtual folder switch (node->GetData().type) { case ProjectItem::TypeWorkspace: imgId = 0; break; case ProjectItem::TypeProject: imgId = 2; break; case ProjectItem::TypeVirtualDirectory: default: imgId = 1; break; } //add the item to the tree node->GetData().itemId = m_treeCtrl->AppendItem( parentHti, // parent node->GetData().name, // display name imgId, // item image index imgId // selected item image ); m_treeCtrl->SortChildren(parentHti); } #if !defined(__WXMSW__) // For a single project, hide the workspace node. This doesn't work on wxMSW if (!m_projectName.empty()) { m_treeCtrl->SetWindowStyle(m_treeCtrl->GetWindowStyle() | wxTR_HIDE_ROOT); wxTreeItemIdValue cookie; wxTreeItemId projitem = m_treeCtrl->GetFirstChild(root, cookie); if (projitem.IsOk() && m_treeCtrl->HasChildren(projitem)) { m_treeCtrl->Expand(projitem); } } else #endif if (root.IsOk() && m_treeCtrl->HasChildren(root)) { m_treeCtrl->Expand(root); } delete tree; } // if a initialPath was provided, try to find and select it if (SelectPath(m_initialPath)) { m_treeCtrl->Expand(m_treeCtrl->GetSelection()); } }