libyui-ncurses  2.44.1
/usr/src/RPM/BUILD/libyui-ncurses-2.44.1/src/NCAskForFile.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019    File:       NCAskForFile.h
00020 
00021    Author:     Gabriele Strattner <gs@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef NCAskForFile_h
00026 #define NCAskForFile_h
00027 
00028 #include <iosfwd>
00029 
00030 #include <vector>
00031 #include <string>
00032 
00033 #include "NCPopup.h"
00034 #include "NCLabel.h"
00035 #include "NCFileSelection.h"
00036 #include "NCPushButton.h"
00037 #include "NCComboBox.h"
00038 #include "NCCheckBox.h"
00039 #include "NCInputField.h"
00040 
00041 
00042 
00043 class NCAskForFile : public NCPopup
00044 {
00045 private:
00046 
00047     NCAskForFile & operator=( const NCAskForFile & );
00048     NCAskForFile( const NCAskForFile & );
00049 
00050 
00051     NCPushButton * okButton;
00052     NCPushButton * cancelButton;
00053     NCComboBox * dirName;               // the selected directory
00054     NCDirectoryTable *dirList;          // the directory list
00055     NCCheckBox *detailed;               // the 'Details' checkbox
00056 
00057     bool getCheckBoxValue( NCCheckBox * detailed );
00058 
00059     std::string iniFileName;                    // initial file name
00060 
00061 protected:
00062 
00063     NCFileTable *fileList;              // the file list
00064     NCInputField *fileName;
00065 
00066     virtual bool postAgain();
00067 
00068     virtual NCursesEvent wHandleInput( wint_t ch );
00069 
00070     virtual std::string getFileName() = 0;
00071 
00072     std::string checkIniDir( std::string startDir );
00073 
00074 public:
00075 
00076     NCAskForFile( const wpos at,
00077                   const std::string & startDir,
00078                   const std::string & filter,
00079                   const std::string & headline );
00080 
00081     virtual ~NCAskForFile() = 0;
00082 
00083     /**
00084      * Set the default size
00085      */
00086     virtual int preferredWidth();
00087     virtual int preferredHeight();
00088 
00089     /**
00090      * Create layout of file selection popup
00091      * iniDir:   The initial start directory
00092      * filter:   pattern what files to show
00093      * headline: popup headline
00094      * editable: file name field editable?
00095      */
00096     void createLayout( const std::string & iniDir,
00097                        const std::string & filter,
00098                        const std::string & headline,
00099                        bool  editable );
00100 
00101     /**
00102      * Shows the popup with the std::list of directories.
00103      */
00104     NCursesEvent & showDirPopup( );
00105 
00106     /**
00107      * Show new file information
00108      */
00109     void updateFileList();
00110 
00111 };
00112 
00113 
00114 class NCAskForExistingFile : public NCAskForFile
00115 {
00116 
00117     NCAskForExistingFile & operator=( const NCAskForFile & );
00118     NCAskForExistingFile( const NCAskForFile & );
00119 
00120 public:
00121 
00122     NCAskForExistingFile( const wpos at,
00123                           const std::string & startDir,
00124                           const std::string & filter,
00125                           const std::string & headline );
00126 
00127     virtual ~NCAskForExistingFile() {}
00128 
00129 protected:
00130 
00131     virtual std::string getFileName();
00132 };
00133 
00134 
00135 class NCAskForSaveFileName : public NCAskForFile
00136 {
00137 
00138     NCAskForSaveFileName & operator=( const NCAskForFile & );
00139     NCAskForSaveFileName( const NCAskForFile & );
00140 
00141 public:
00142 
00143     NCAskForSaveFileName( const wpos at,
00144                           const std::string & startDir,
00145                           const std::string & filter,
00146                           const std::string & headline );
00147 
00148     virtual ~NCAskForSaveFileName() {}
00149 
00150 protected:
00151 
00152     virtual std::string getFileName();
00153 
00154 };
00155 
00156 
00157 
00158 #endif // NCAskForFile_h
 All Classes Functions Variables