file_browser.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: file_browser.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 20:45:10 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: file_browser.cpp,v 1000.1 2004/06/01 20:45:10 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software / database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software / database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Mike DiCuccio
- *
- * File Description:
- *
- */
- #include <ncbi_pch.hpp>
- #include <gui/dialogs/file_browser.hpp>
- #include <gui/widgets/FLU/Flu_File_Chooser.h>
- #ifdef NCBI_OS_MSWIN
- # include <windows.h>
- # include <commdlg.h>
- #endif
- BEGIN_NCBI_SCOPE
- string NcbiFileBrowser(const string& message,
- const string& pattern,
- const string& path,
- EFileBrowserType type)
- {
- string str;
- #ifdef NCBI_OS_MSWIN
-
- OPENFILENAME ofn;
- memset(&ofn, 0, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- string mswinPattern = pattern + ' ' + pattern + ' ';
- ofn.lpstrFilter = mswinPattern.c_str();
- ofn.lpstrInitialDir = path.c_str();
- char buf[1024];
- buf[0] = ' ';
- ofn.lpstrFile = buf;
- ofn.nMaxFile = sizeof(buf);
- if (type == eFileType_Open) {
- ofn.Flags |= OFN_FILEMUSTEXIST;
- if (GetOpenFileName(&ofn)) {
- str = buf;
- }
- } else {
- string ext;
- if (pattern.find('.') != string::npos) {
- ext = pattern.substr(pattern.find('.')+1);
- ofn.lpstrDefExt = ext.c_str();
- }
- if (GetSaveFileName(&ofn)) {
- str = buf;
- }
- }
- #else
- const char* text =
- flu_file_chooser(message.c_str(), pattern.c_str(), path.c_str());
- if ( text && *text ) {
- str = text;
- }
- #endif
- return str;
- }
- string NcbiDirBrowser(const string& message,
- const string& pattern)
- {
- const char* text =
- flu_dir_chooser(message.c_str(), pattern.c_str());
- string str;
- if ( text && *text ) {
- str = text;
- }
- return str;
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: file_browser.cpp,v $
- * Revision 1000.1 2004/06/01 20:45:10 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7
- *
- * Revision 1.7 2004/05/26 14:11:22 johnson
- * Win32: use correct member to return filename; add default extension when
- * saving if using pattern filter
- *
- * Revision 1.6 2004/05/25 17:09:30 dicuccio
- * Safe to include cmmdlg on all Windows platforms
- *
- * Revision 1.5 2004/05/24 19:37:26 gorelenk
- * Added include of commdlg.h for MSVC7
- *
- * Revision 1.4 2004/05/24 13:42:48 johnson
- * fix pattern-filter for Win32
- *
- * Revision 1.3 2004/05/21 22:27:41 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.2 2004/05/20 12:28:43 dicuccio
- * Added platform-specific wrapper for standard Win32 file browser
- *
- * Revision 1.1 2004/03/11 17:32:37 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */