Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

dlgFilesSelector.hpp

Go to the documentation of this file.
00001 /* 00002 * wxChecksums 00003 * Copyright (C) 2003-2004 Julien Couot 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file dlgFilesSelector.hpp 00022 * Configuration dialog for selecting multiple files. 00023 */ 00024 00025 #ifndef INC_DLGFILESSELECTOR_HPP 00026 #define INC_DLGFILESSELECTOR_HPP 00027 00028 //--------------------------------------------------------------------------- 00029 // For compilers that support precompilation, includes "wx.h". 00030 #include <wx/wxprec.h> 00031 00032 #ifdef __BORLANDC__ 00033 #pragma hdrstop 00034 #endif 00035 00036 #ifndef WX_PRECOMP 00037 // Include your minimal set of headers here, or wx.h 00038 #include <wx/wx.h> 00039 #endif 00040 00041 #include <wx/spinctrl.h> 00042 00043 #include "fdftlmk.hpp" 00044 #include "slstview.hpp" 00045 //--------------------------------------------------------------------------- 00046 00047 00048 /** 00049 * Dialog for choosing multiple files to process. 00050 * 00051 * <B>Important:</B> you must call the <CODE>initialize()</CODE> method just 00052 * after the constructor the create the widgets of the window (this can't be 00053 * done in the constructor because <CODE>createControls()</CODE> calls pure 00054 * virtual methods. 00055 */ 00056 class dlgFilesSelector : public wxDialog 00057 { 00058 public: 00059 // Creates a new dialog. 00060 dlgFilesSelector(); 00061 00062 // Creates a new dialog. 00063 dlgFilesSelector(wxWindow* parent, const bool extendDialog = false); 00064 00065 // Initializes the dialog. 00066 virtual void initialize(); 00067 00068 // Destructor. 00069 virtual ~dlgFilesSelector(); 00070 00071 // Creates and initializes the controls of the dialog. 00072 void createControls(); 00073 00074 00075 protected: 00076 bool extend; ///< Is the dialog will be extended ? 00077 wxSortableListView* lvwFiles; ///< List of selected files. 00078 wxArrayString fileNames; ///< Names of the files given by the validator. 00079 wxButton* btnAdd; ///< Button for adding files. 00080 wxButton* btnRemove; ///< Button for removing files. 00081 wxRadioBox* rbxSortBy; ///< Sort by radio box buttons. 00082 wxRadioBox* rbxSortOrder; ///< Sort order radio box buttons. 00083 wxButton* btnSearchAndAdd; ///< Search and add files to the list of files. 00084 wxComboBox* cboNamed; ///< Name of the file to search. 00085 wxComboBox* cboLookIn; ///< Directory to begin the search. 00086 wxSpinCtrl* spnDepth; ///< Search depth. 00087 wxBoxSizer* extendSizer; ///< Sizer where controls should be added (it is positionned before the validation buttons). 00088 00089 // Gets a new unique identifier. 00090 static long getID(); 00091 00092 // Processes button Add. 00093 void btnAddClick(wxCommandEvent& event); 00094 // Processes button Remove. 00095 void btnRemoveClick(wxCommandEvent& event); 00096 // Processes button Add list. 00097 void btnAddListClick(wxCommandEvent& event); 00098 // Processes button Load list. 00099 void btnLoadListClick(wxCommandEvent& event); 00100 // Processes button Save list. 00101 void btnSaveListClick(wxCommandEvent& event); 00102 // Processes button Browse. 00103 void btnBrowseClick(wxCommandEvent& event); 00104 // Processes button Search and Add. 00105 void btnSearchAndAddClick(wxCommandEvent& event); 00106 00107 // Event handler for the selection of an item. 00108 void lvwFilesSelectItem(wxListEvent& event); 00109 // Event handler for the deselection of an item. 00110 void lvwFilesDeselectItem(wxListEvent& event); 00111 // Event handler for the key down event. 00112 void lvwFilesKeyDown(wxListEvent& event); 00113 // Processes a click on a header of a column of the list of files. 00114 void lvwFilesColumnClick(wxListEvent& event); 00115 00116 // Processes a selection of the column to sort. 00117 void rbxSortBySelect(wxCommandEvent& event); 00118 // Processes a selection of the sort order. 00119 void rbxSortOrderSelect(wxCommandEvent& event); 00120 00121 // Event handler for the enter key pressed on a search combo box. 00122 void cboSearchTextEnter(wxCommandEvent& event); 00123 00124 // Processes button OK. 00125 void btnOKClick(wxCommandEvent& event); 00126 00127 /// Controls IDs 00128 enum 00129 { 00130 LVW_FILES = wxID_HIGHEST + 1, 00131 BTN_ADD, 00132 BTN_REMOVE, 00133 BTN_ADDLIST, 00134 BTN_LOADLIST, 00135 BTN_SAVELIST, 00136 CBO_NAMED, 00137 CBO_LOOKIN, 00138 BTN_BROWSE, 00139 BTN_SEARCH_AND_ADD, 00140 SPN_DEPTH, 00141 RBX_SORT_BY, 00142 RBX_SORT_ORDER, 00143 BTN_OK, 00144 DLG_FILESSELECTOR_ID_HIGHEST 00145 }; 00146 00147 // Adds the given array of file names to the listview of file names. 00148 void addFileNamesToListView(const wxArrayString& fileNames); 00149 00150 // A validator for the files' list. 00151 class FilesListValidator; 00152 /// <CODE>FilesListValidator</CODE> can access to <CODE>getID()</CODE>. 00153 friend class FilesListValidator; 00154 00155 DECLARE_EVENT_TABLE() 00156 00157 private: 00158 DECLARE_DYNAMIC_CLASS(dlgFilesSelector) 00159 00160 public: 00161 // Gets the names of the files. 00162 void getFileNames(wxArrayString& names) const; 00163 00164 public: 00165 /** 00166 * Gets the root configuration key for parameters of this dialog. 00167 * 00168 * The returned string must be ended the a '<CODE>/</CODE>' character. 00169 * 00170 * @return The root configuration key for parameters of this dialog. 00171 */ 00172 virtual wxString getRootConfigKey() = 0; 00173 00174 // Gets the configuration key for the last files' names for searching files 00175 wxString getNamedConfigKey(const int n); 00176 00177 // Gets the configuration key for the last directories for searching files 00178 wxString getLookInConfigKey(const int n); 00179 00180 // Gets the maximum size of the history of the last files' names and directories for searching files 00181 int getHistoryMaxSize(); 00182 00183 protected: 00184 /// Preferences keys 00185 enum PreferencesKey 00186 { 00187 prGUI_SORT_BY = 0, 00188 prGUI_SORT_ORDER, 00189 prGUI_FILENAME_WIDTH, 00190 prGUI_DIRECTORY_WIDTH, 00191 prGUI_WINDOW_SIZE 00192 }; 00193 00194 // Gets the configuration key corresponding to the given preference key. 00195 wxString getConfigKey(const PreferencesKey pk); 00196 00197 protected: 00198 /// Custumised UI strings. 00199 enum UIStrings 00200 { 00201 uiDialogTitle = 0, 00202 uiBtnOK, 00203 uiFraFilesList, 00204 uiFraSearchFiles, 00205 uiOpenDlgAddFiles, 00206 uiOpenDlgAddList, 00207 uiOpenDlgLoadList, 00208 uiSaveDlgAddList 00209 }; 00210 00211 /** 00212 * Gets the string for the specified UI element. 00213 * 00214 * @param id Identifier of the wanted UI element. 00215 * @return The string for the specified UI element and an empty string if the 00216 * given UI element is invalid. 00217 */ 00218 virtual wxString getUIString(UIStrings id) = 0; 00219 00220 /** 00221 * Returns a set of filters for the "Add files" dialog. 00222 * 00223 * @return A set of filters for the "Add files" dialog. 00224 */ 00225 virtual wxFileDialogFilterMaker getFiltersForAddFilesDialog() = 0; 00226 00227 private: // Utility functions 00228 // Adds a file or a directory or a match pattern to a combo box. 00229 static void addLineToComboBox(wxComboBox* cboBox, const int maxLines); 00230 00231 // Gets the last directory used and the filter for the open or save dialog. 00232 void getLastDirectoryAndFilter(const wxString& configKey, wxString& lastDirKey, wxString& lastDir, wxFileDialogFilterMaker& fltMaker); 00233 }; 00234 //--------------------------------------------------------------------------- 00235 00236 #endif // INC_DLGFILESSELECTOR_HPP

Generated on Sun May 30 13:37:44 2004 for wxChecksums by doxygen 1.3.7