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

dlgFilesSelector.cpp

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.cpp 00022 * Configuration dialog for selecting multiple files. 00023 */ 00024 00025 00026 //--------------------------------------------------------------------------- 00027 // For compilers that support precompilation, includes "wx.h". 00028 #include <wx/wxprec.h> 00029 00030 #ifdef __BORLANDC__ 00031 #pragma hdrstop 00032 #endif 00033 00034 #ifndef WX_PRECOMP 00035 // Include your minimal set of headers here, or wx.h 00036 #include <wx/wx.h> 00037 #endif 00038 00039 #include <wx/config.h> 00040 #include <wx/filename.h> 00041 #include <wx/spinctrl.h> 00042 #include <wx/txtstrm.h> 00043 #include <wx/wfstream.h> 00044 00045 #include <climits> 00046 00047 #include "dlgFilesSelector.hpp" 00048 #include "appprefs.hpp" 00049 #include "bytedisp.hpp" 00050 #include "comdefs.hpp" 00051 #include "fdftlmk.hpp" 00052 #include "fileutil.hpp" 00053 #include "slstview.hpp" 00054 #include "utils.hpp" 00055 00056 #include "compat.hpp" 00057 //--------------------------------------------------------------------------- 00058 00059 00060 /// The C++ standard namespace. 00061 using namespace std; 00062 00063 00064 //########################################################################### 00065 // The list of files compare function 00066 //########################################################################### 00067 00068 /** 00069 * Function that compare two elements of the list of files of the files 00070 * selector dialog. 00071 * 00072 * @param item1 Data of the first item. This should be an unique identifier. 00073 * @param item2 Data of the second item. This should be an unique identifier. 00074 * @param sortData Adress of the instance of the 00075 * <CODE>wxSortableListView</CODE> that contains the data to 00076 * short. 00077 */ 00078 static int wxCALLBACK filesListCmpFnct(long item1, long item2, long sortData) 00079 { 00080 // Get the ListView 00081 wxSortableListView* lv = wxDynamicCast(sortData, wxSortableListView); 00082 00083 // Can't get the listview -> no sort. 00084 if (lv == NULL) 00085 return item1 - item2; 00086 00087 // No sort. 00088 if (lv->GetSortOrder() == wxSortableListView::none) 00089 return item1 - item2; 00090 00091 // Get the strings for comparison 00092 wxListItem li1, li2; 00093 li1.SetMask(wxLIST_MASK_TEXT); 00094 li1.SetColumn(lv->GetColumnToSort()); 00095 li1.SetId(lv->FindItem(-1, item1)); 00096 lv->GetItem(li1); 00097 li2.SetMask(wxLIST_MASK_TEXT); 00098 li2.SetColumn(lv->GetColumnToSort()); 00099 li2.SetId(lv->FindItem(-1, item2)); 00100 lv->GetItem(li2); 00101 wxString s1 = li1.GetText(); 00102 wxString s2 = li2.GetText(); 00103 00104 // Compute the result to return 00105 int res; 00106 if (lv->GetSortOrder() == wxSortableListView::ascending) 00107 res = ::compareFileName(s1, s2); 00108 else 00109 res = ::compareFileName(s2, s1); 00110 00111 return res; 00112 } 00113 //--------------------------------------------------------------------------- 00114 00115 00116 00117 //########################################################################### 00118 // A validator for the files' list 00119 //########################################################################### 00120 00121 static long idGen = LONG_MIN + 1; ///< Value for unique identifiers generation. 00122 00123 /** 00124 * Gets a new unique identifier. 00125 * 00126 * @return A new unique identifier. 00127 */ 00128 static long getUniqueId() 00129 { 00130 return idGen++; 00131 } 00132 //--------------------------------------------------------------------------- 00133 00134 00135 /** 00136 * A validator for the files' list. 00137 * 00138 * Checks that the given list of file's names has one or more elements. 00139 * 00140 * If the list is empty, it displays a message. 00141 */ 00142 class dlgFilesSelector::FilesListValidator : public wxValidator 00143 { 00144 protected: 00145 wxArrayString* value; ///< Adress of the array of strings where the value will be transfered. 00146 00147 // Clones the source instance in this instance. 00148 void clone(const FilesListValidator& source); 00149 00150 // Returns the wxListView associated with the validator. 00151 wxSortableListView* GetSortableListView() const; 00152 00153 public: 00154 // Constructor. 00155 FilesListValidator(wxArrayString* pValue); 00156 00157 // Copy constructor. 00158 FilesListValidator(const FilesListValidator& source); 00159 00160 // Assignment operator. 00161 FilesListValidator& operator=(const FilesListValidator& source); 00162 00163 // Returns a copy of the instance of the validator. 00164 virtual wxObject* Clone() const; 00165 00166 // Validates the value in the associated window. 00167 virtual bool Validate(wxWindow* parent); 00168 00169 // Transfers the value in the window to the validator. 00170 virtual bool TransferFromWindow(); 00171 00172 // Transfers the value associated with the validator to the window. 00173 virtual bool TransferToWindow(); 00174 }; 00175 //--------------------------------------------------------------------------- 00176 00177 00178 /** 00179 * Constructor. 00180 * 00181 * @param pValue Pointer on the array of strings where to value will be 00182 * transfered. 00183 */ 00184 dlgFilesSelector::FilesListValidator::FilesListValidator(wxArrayString* pValue) 00185 { 00186 value = pValue; 00187 } 00188 //--------------------------------------------------------------------------- 00189 00190 00191 /** 00192 * Clones the source instance in this instance. 00193 * 00194 * @param source Source instance. 00195 */ 00196 void dlgFilesSelector::FilesListValidator::clone(const FilesListValidator& source) 00197 { 00198 if (this != &source) 00199 { 00200 this->value = source.value; 00201 } 00202 } 00203 //--------------------------------------------------------------------------- 00204 00205 00206 /** 00207 * Copy constructor. 00208 * 00209 * @param source Source instance. 00210 */ 00211 dlgFilesSelector::FilesListValidator::FilesListValidator(const FilesListValidator& source) 00212 { 00213 clone(source); 00214 } 00215 //--------------------------------------------------------------------------- 00216 00217 00218 /** 00219 * Assignment operator. 00220 * 00221 * @param source Source instance. 00222 * @return A reference on the instance. 00223 */ 00224 dlgFilesSelector::FilesListValidator& dlgFilesSelector::FilesListValidator::operator=(const FilesListValidator& source) 00225 { 00226 clone(source); 00227 return *this; 00228 } 00229 //--------------------------------------------------------------------------- 00230 00231 00232 /** 00233 * Returns a copy of the instance of the validator. 00234 * 00235 * @return A copy of the instance of the validator. 00236 */ 00237 wxObject* dlgFilesSelector::FilesListValidator::Clone() const 00238 { 00239 return new FilesListValidator(*this); 00240 } 00241 //--------------------------------------------------------------------------- 00242 00243 00244 /** 00245 * Returns the <CODE>wxSortableListView</CODE> associated with the validator. 00246 * 00247 * @return The <CODE>wxSortableListView</CODE> associated with the validator or 00248 * <CODE>NULL</CODE> if the <CODE>wxSortableListView</CODE> associated with 00249 * the validator isn't a <CODE>wxSortableListView</CODE>. 00250 */ 00251 wxSortableListView* dlgFilesSelector::FilesListValidator::GetSortableListView() const 00252 { 00253 wxWindow* win = GetWindow(); 00254 if (win == NULL) 00255 return NULL; 00256 if (!win->IsKindOf(CLASSINFO(wxSortableListView))) 00257 return NULL; 00258 00259 return wxDynamicCast(win, wxSortableListView); 00260 } 00261 //--------------------------------------------------------------------------- 00262 00263 00264 /** 00265 * Validates the value in the associated window. 00266 * 00267 * @param parent Parent window. 00268 */ 00269 bool dlgFilesSelector::FilesListValidator::Validate(wxWindow* parent) 00270 { 00271 wxSortableListView* control = GetSortableListView(); 00272 if (control == NULL) 00273 return false; 00274 00275 if (control->GetItemCount() == 0) 00276 { 00277 ::wxMessageBox(_("Select at least a file."), _("Warning"), wxOK | wxICON_EXCLAMATION); 00278 return false; 00279 } 00280 else 00281 return true; 00282 } 00283 //--------------------------------------------------------------------------- 00284 00285 00286 /** 00287 * Transfers the value in the window to the validator. 00288 * 00289 * @return <CODE>true</CODE> on success, <CODE>false</CODE> otherwise. 00290 */ 00291 bool dlgFilesSelector::FilesListValidator::TransferFromWindow() 00292 { 00293 wxSortableListView* control = GetSortableListView(); 00294 if (control == NULL || value == NULL) 00295 return false; 00296 else 00297 { 00298 wxString fileName, directory; 00299 wxListItem listItem; 00300 listItem.SetMask(wxLIST_MASK_TEXT); 00301 long item = control->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 00302 while (item != -1) 00303 { 00304 // Read items info 00305 listItem.SetId(item); 00306 listItem.SetColumn(0); 00307 control->GetItem(listItem); 00308 fileName = listItem.GetText(); 00309 listItem.SetColumn(1); 00310 control->GetItem(listItem); 00311 directory = listItem.GetText(); 00312 00313 wxFileName fn(directory, fileName); 00314 value->Add(fn.GetFullPath()); 00315 00316 item = control->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 00317 } 00318 00319 return true; 00320 } 00321 } 00322 //--------------------------------------------------------------------------- 00323 00324 00325 /** 00326 * Transfers the value associated with the validator to the window. 00327 * 00328 * return <CODE>true</CODE> on success, <CODE>false</CODE> otherwise. 00329 */ 00330 bool dlgFilesSelector::FilesListValidator::TransferToWindow() 00331 { 00332 wxSortableListView* control = GetSortableListView(); 00333 if (control == NULL || value == NULL) 00334 return false; 00335 else 00336 { 00337 size_t s = value->GetCount(); 00338 size_t i; 00339 wxString fileName, lstFileName; 00340 wxString directory, lstDirectory; 00341 wxListItem listItem; 00342 listItem.SetMask(wxLIST_MASK_TEXT); 00343 00344 for (i = 0; i < s; i++) 00345 { 00346 wxFileName fn((*value)[i]); 00347 00348 // Don't add a directory or a file with a non-absolute path. 00349 if (!fn.DirExists() && fn.IsAbsolute()) 00350 { 00351 fileName = fn.GetFullName(); 00352 directory = fn.GetPath(wxPATH_GET_VOLUME); 00353 00354 // Checks if the file isn't already is the list. 00355 long item = control->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 00356 bool found = false; 00357 while (!found && item != -1) 00358 { 00359 listItem.SetId(item); 00360 listItem.SetColumn(0); 00361 control->GetItem(listItem); 00362 lstFileName = listItem.GetText(); 00363 listItem.SetColumn(1); 00364 control->GetItem(listItem); 00365 lstDirectory = listItem.GetText(); 00366 00367 if (compareFileName(fileName, lstFileName) == 0 && 00368 compareFileName(directory, lstDirectory) == 0) 00369 found = true; 00370 else 00371 item = control->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 00372 } 00373 if (!found) 00374 { 00375 long newItem = control->InsertItem(control->GetItemCount(), fileName); 00376 control->SetItem(newItem, 1, directory); 00377 control->SetItemData(newItem, dlgFilesSelector::getID()); 00378 } 00379 } 00380 } 00381 control->SortItems(filesListCmpFnct, reinterpret_cast<long>(control)); 00382 00383 return true; 00384 } 00385 } 00386 //--------------------------------------------------------------------------- 00387 00388 00389 00390 //########################################################################### 00391 // dlgFilesSelector methods 00392 //########################################################################### 00393 00394 IMPLEMENT_ABSTRACT_CLASS(dlgFilesSelector, wxDialog) 00395 00396 00397 /** 00398 * Creates a new dialog. 00399 */ 00400 dlgFilesSelector::dlgFilesSelector() : wxDialog() 00401 { 00402 extend = false; 00403 } 00404 //--------------------------------------------------------------------------- 00405 00406 00407 /** 00408 * Creates a new dialog. 00409 * 00410 * @param parent Parent of the dialog. 00411 * @param extendDialog <CODE>true</CODE> if the dialog will be extended with 00412 * other controls that the ones created by 00413 * <CODE>dlgFilesSelector</CODE>. If this parameter is 00414 * <CODE>true</CODE> then the <CODE>extendSizer</CODE> 00415 * attribute is initialised otherwise it equals to 00416 * <CODE>NULL</CODE>. 00417 */ 00418 dlgFilesSelector::dlgFilesSelector(wxWindow* parent, const bool extendDialog) : 00419 wxDialog(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 00420 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) 00421 { 00422 extend = extendDialog; 00423 } 00424 //--------------------------------------------------------------------------- 00425 00426 00427 /** 00428 * Initializes the dialog. 00429 * 00430 * If you derivate this method, please call the one of the parent class before 00431 * doing anything. 00432 */ 00433 void dlgFilesSelector::initialize() 00434 { 00435 createControls(); 00436 00437 Fit(); 00438 00439 // Get the size of the window 00440 wxSize s; 00441 if (PreferenceValue::read(getConfigKey(prGUI_WINDOW_SIZE), &s)) 00442 SetSize(s); 00443 00444 Centre(); 00445 } 00446 //--------------------------------------------------------------------------- 00447 00448 00449 00450 /** 00451 * Creates and initializes the controls of the dialog. 00452 */ 00453 void dlgFilesSelector::createControls() 00454 { 00455 // Creates the controls 00456 SetTitle(getUIString(uiDialogTitle)); 00457 wxStaticBox* fraFilesList = new wxStaticBox(this, -1, getUIString(uiFraFilesList)); 00458 lvwFiles = new wxSortableListView(this, LVW_FILES, wxDefaultPosition, 00459 wxSize((this->GetParent()->GetSize().GetWidth() * 2) / 3, 00460 (this->GetParent()->GetSize().GetHeight() / 2)), 00461 wxLC_REPORT, FilesListValidator(&(this->fileNames))); 00462 lvwFiles->InsertColumn(0, _("File name")); 00463 lvwFiles->InsertColumn(1, _("Directory")); 00464 00465 btnAdd = new wxButton(this, BTN_ADD, _("&Add...")); 00466 btnRemove = new wxButton(this, BTN_REMOVE, _("&Remove")); 00467 btnRemove->Disable(); 00468 wxButton* btnAddList = new wxButton(this, BTN_ADDLIST, _("Add li&st...")); 00469 wxButton* btnLoadList = new wxButton(this, BTN_LOADLIST, _("L&oad list...")); 00470 wxButton* btnSaveList = new wxButton(this, BTN_SAVELIST, _("Sa&ve list...")); 00471 const wxString rbxSortByChoices[] = { _("File name"), _("Directory") }; 00472 rbxSortBy = new wxRadioBox(this, RBX_SORT_BY, _("Sort b&y:"), wxDefaultPosition, wxDefaultSize, 2, rbxSortByChoices, 1, wxRA_SPECIFY_COLS); 00473 const wxString rbxSortOrderChoices[] = { _("Ascending"), _("Descending"), _("Don't sort") }; 00474 rbxSortOrder = new wxRadioBox(this, RBX_SORT_ORDER, _("Sor&t order:"), wxDefaultPosition, wxDefaultSize, 3, rbxSortOrderChoices, 1, wxRA_SPECIFY_COLS); 00475 00476 wxStaticBox* fraSearchFiles = new wxStaticBox(this, -1, getUIString(uiFraSearchFiles)); 00477 wxStaticText* lblNamed = new wxStaticText(this, -1, _("&Named:")); 00478 cboNamed = new wxComboBox(this, CBO_NAMED); 00479 wxStaticText* lblLookIn = new wxStaticText(this, -1, _("Look &in:")); 00480 cboLookIn = new wxComboBox(this, CBO_LOOKIN); 00481 wxButton* btnBrowse = new wxButton(this, BTN_BROWSE, _("&Browse...")); 00482 wxStaticText* lblDepth = new wxStaticText(this, -1, _("&Depth:")); 00483 spnDepth = new wxSpinCtrl(this, SPN_DEPTH, wxT("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP, 0, SHRT_MAX, 0); 00484 btnSearchAndAdd = new wxButton(this, BTN_SEARCH_AND_ADD, _("S&earch and add")); 00485 00486 wxButton* btnOK = new wxButton(this, BTN_OK, getUIString(uiBtnOK)); 00487 btnOK->SetDefault(); 00488 wxButton* btnCancel = new wxButton(this, wxID_CANCEL, _("Ca&ncel")); 00489 00490 00491 //------------------------------------------------------------------------- 00492 // Creates the dialog sizers 00493 00494 // Dialog sizer 00495 wxBoxSizer* dlgFilesSelectorSizer2 = new wxBoxSizer(wxVERTICAL); 00496 this->SetSizer(dlgFilesSelectorSizer2); 00497 wxBoxSizer* dlgFilesSelectorSizer = new wxBoxSizer(wxVERTICAL); 00498 dlgFilesSelectorSizer2->Add(dlgFilesSelectorSizer, 1, wxALL | wxGROW, CONTROL_SPACE); 00499 00500 // List of files 00501 wxStaticBoxSizer* fraFilesListSizer2 = new wxStaticBoxSizer(fraFilesList, wxVERTICAL); 00502 dlgFilesSelectorSizer->Add(fraFilesListSizer2, 1, wxGROW); 00503 wxBoxSizer* fraFilesListSizer = new wxBoxSizer(wxHORIZONTAL); 00504 fraFilesListSizer2->Add(fraFilesListSizer, 1, wxALL | wxGROW, CONTROL_SPACE / 2); 00505 00506 fraFilesListSizer->Add(lvwFiles, 1, wxGROW); 00507 00508 wxBoxSizer* filesListButtonsSizer = new wxBoxSizer(wxVERTICAL); 00509 filesListButtonsSizer->Add(btnAdd, 0, wxGROW | wxTOP, CONTROL_SPACE); 00510 filesListButtonsSizer->Add(btnRemove, 0, wxGROW | wxTOP, CONTROL_SPACE / 2); 00511 filesListButtonsSizer->Add(btnAddList, 0, wxGROW | wxTOP, CONTROL_SPACE); 00512 filesListButtonsSizer->Add(btnLoadList, 0, wxGROW | wxTOP, CONTROL_SPACE / 2); 00513 filesListButtonsSizer->Add(btnSaveList, 0, wxGROW | wxTOP, CONTROL_SPACE / 2); 00514 filesListButtonsSizer->Add(rbxSortBy, 0, wxGROW | wxTOP, CONTROL_SPACE); 00515 filesListButtonsSizer->Add(rbxSortOrder, 0, wxGROW | wxTOP, CONTROL_SPACE / 2); 00516 fraFilesListSizer->Add(filesListButtonsSizer, 0, wxLEFT | wxALIGN_TOP, CONTROL_SPACE); 00517 00518 // Search files section 00519 wxStaticBoxSizer* fraSearchFilesSizer2 = new wxStaticBoxSizer(fraSearchFiles, wxVERTICAL); 00520 dlgFilesSelectorSizer->Add(fraSearchFilesSizer2, 0, wxGROW | wxTOP, CONTROL_SPACE); 00521 wxBoxSizer* fraSearchFilesSizer = new wxBoxSizer(wxVERTICAL); 00522 fraSearchFilesSizer2->Add(fraSearchFilesSizer, 0, wxALL | wxGROW, CONTROL_SPACE / 2); 00523 00524 wxFlexGridSizer* searchSizer = new wxFlexGridSizer(2, CONTROL_SPACE / 2, CONTROL_SPACE); 00525 fraSearchFilesSizer->Add(searchSizer, 0, wxTOP | wxGROW, CONTROL_SPACE / 2); 00526 searchSizer->AddGrowableCol(1); 00527 searchSizer->Add(lblNamed, 0, wxALIGN_CENTER_VERTICAL); 00528 searchSizer->Add(cboNamed, 1, wxALIGN_CENTER_VERTICAL | wxGROW); 00529 searchSizer->Add(lblLookIn, 0, wxALIGN_CENTER_VERTICAL); 00530 wxBoxSizer* searchDirSizer = new wxBoxSizer(wxHORIZONTAL); 00531 searchSizer->Add(searchDirSizer, 1, wxALIGN_CENTER_VERTICAL | wxGROW); 00532 searchDirSizer->Add(cboLookIn, 1, wxALIGN_CENTER_VERTICAL | wxGROW); 00533 searchDirSizer->Add(btnBrowse, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, CONTROL_SPACE); 00534 searchSizer->Add(lblDepth, 0, wxALIGN_CENTER_VERTICAL); 00535 wxFlexGridSizer* searchDepthSizer = new wxFlexGridSizer(2, 0, CONTROL_SPACE); 00536 searchDepthSizer->AddGrowableCol(0); 00537 searchSizer->Add(searchDepthSizer, 1, wxALIGN_CENTER_VERTICAL | wxGROW); 00538 searchDepthSizer->Add(spnDepth, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); 00539 searchDepthSizer->Add(btnSearchAndAdd, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); 00540 00541 // Extend sizer 00542 if (extend) 00543 { 00544 extendSizer = new wxBoxSizer(wxVERTICAL); 00545 dlgFilesSelectorSizer->Add(extendSizer, 0, wxGROW); 00546 } 00547 else 00548 extendSizer = NULL; 00549 00550 // Validation buttons sizer 00551 wxGridSizer* buttonsSizer = new wxGridSizer(2, 0, 2 * CONTROL_SPACE); 00552 buttonsSizer->Add(btnOK); 00553 buttonsSizer->Add(btnCancel); 00554 dlgFilesSelectorSizer->Add(buttonsSizer, 0, wxTOP | wxALIGN_RIGHT, (3 * CONTROL_SPACE) / 2); 00555 00556 // Set on the auto-layout feature 00557 this->SetAutoLayout(true); 00558 this->Layout(); 00559 00560 00561 //------------------------------------------------------------------------- 00562 // Initializes the controls 00563 for (int i = 1; i <= getHistoryMaxSize(); i++) 00564 { 00565 wxString named, lookIn; 00566 wxConfig::Get()->Read(getNamedConfigKey(i), &named, wxEmptyString); 00567 wxConfig::Get()->Read(getLookInConfigKey(i), &lookIn, wxEmptyString); 00568 if (!named.IsEmpty()) 00569 cboNamed->Append(named.Strip(wxString::both)); 00570 if (!lookIn.IsEmpty()) 00571 cboLookIn->Append(lookIn.Strip(wxString::both)); 00572 } 00573 cboNamed->SetValue(wxEmptyString); 00574 cboLookIn->SetValue(wxEmptyString); 00575 00576 lvwFiles->SetColumnWidth(0, wxConfig::Get()->Read(getConfigKey(prGUI_FILENAME_WIDTH), wxLIST_AUTOSIZE_USEHEADER)); 00577 lvwFiles->SetColumnWidth(1, wxConfig::Get()->Read(getConfigKey(prGUI_DIRECTORY_WIDTH), wxLIST_AUTOSIZE_USEHEADER)); 00578 lvwFiles->SetColumnToSort(wxConfig::Get()->Read(getConfigKey(prGUI_SORT_BY), 0L)); 00579 lvwFiles->SetSortOrder(static_cast<wxSortableListView::SortOrder>(wxConfig::Get()->Read(getConfigKey(prGUI_SORT_ORDER), static_cast<long>(wxSortableListView::none)))); 00580 rbxSortBy->SetSelection(lvwFiles->GetColumnToSort()); 00581 switch (lvwFiles->GetSortOrder()) 00582 { 00583 case wxSortableListView::ascending : 00584 rbxSortOrder->SetSelection(0); 00585 break; 00586 case wxSortableListView::descending : 00587 rbxSortOrder->SetSelection(1); 00588 break; 00589 default : 00590 rbxSortOrder->SetSelection(2); 00591 } 00592 } 00593 //--------------------------------------------------------------------------- 00594 00595 00596 /** 00597 * The class descructor. 00598 */ 00599 dlgFilesSelector::~dlgFilesSelector() 00600 { 00601 } 00602 //--------------------------------------------------------------------------- 00603 00604 00605 /** 00606 * Processes button Add. 00607 * 00608 * @param event The event's parameters 00609 */ 00610 void dlgFilesSelector::btnAddClick(wxCommandEvent& event) 00611 { 00612 wxString lastDirKey = getRootConfigKey() + wxT("LastAddDirectory"); 00613 wxString lastDir; 00614 00615 // Get the last directory used 00616 wxConfig::Get()->Read(lastDirKey, &lastDir, wxEmptyString); 00617 if (!::wxDirExists(lastDir)) 00618 { 00619 lastDir = AppPrefs::getUserDocumentsDirName(); 00620 if (lastDir.IsEmpty()) 00621 lastDir = ::wxGetCwd(); 00622 } 00623 00624 // Gets the filter for knows types of checksums' files 00625 wxFileDialogFilterMaker fltMaker = getFiltersForAddFilesDialog(); 00626 00627 wxFileDialog dlgSelect(this, getUIString(uiOpenDlgAddFiles), 00628 lastDir, wxEmptyString, fltMaker.GetFilters(), 00629 wxOPEN | wxHIDE_READONLY | wxMULTIPLE | wxFILE_MUST_EXIST, wxDefaultPosition); 00630 00631 if (dlgSelect.ShowModal() == wxID_OK) 00632 { 00633 wxArrayString files; 00634 dlgSelect.GetPaths(files); 00635 addFileNamesToListView(files); 00636 00637 // Save the last directory used 00638 wxConfig::Get()->Write(lastDirKey, dlgSelect.GetDirectory()); 00639 } 00640 } 00641 //--------------------------------------------------------------------------- 00642 00643 00644 /** 00645 * Processes button Remove. 00646 * 00647 * @param event The event's parameters 00648 */ 00649 void dlgFilesSelector::btnRemoveClick(wxCommandEvent& event) 00650 { 00651 long item; 00652 00653 item = lvwFiles->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); 00654 while (item != -1) 00655 { 00656 lvwFiles->DeleteItem(item); 00657 item = lvwFiles->GetNextItem(item - 1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); 00658 } 00659 } 00660 //--------------------------------------------------------------------------- 00661 00662 00663 /** 00664 * Gets the last directory used and the filter for the open or save dialog. 00665 * 00666 * @param configKey Configuration key for the last directory. 00667 * @param lastDirKey String that will contains the full configuration key for the last directory. 00668 * @param lastDir String that will contains the last directory. 00669 * @param fltMaker Filter that will contains the filters for the open or save dialog. 00670 */ 00671 void dlgFilesSelector::getLastDirectoryAndFilter(const wxString& configKey, wxString& lastDirKey, wxString& lastDir, wxFileDialogFilterMaker& fltMaker) 00672 { 00673 lastDirKey = getRootConfigKey() + configKey; 00674 00675 // Get the last directory used 00676 wxConfig::Get()->Read(lastDirKey, &lastDir, wxEmptyString); 00677 if (!::wxDirExists(lastDir)) 00678 { 00679 lastDir = AppPrefs::getUserDocumentsDirName(); 00680 if (lastDir.IsEmpty()) 00681 lastDir = ::wxGetCwd(); 00682 } 00683 00684 fltMaker.AddFilter(_("Known files"), wxT("lst|txt")); 00685 fltMaker.AddFilter(_("Text files"), wxT("txt")); 00686 fltMaker.AddFilter(_("List of files"), wxT("lst")); 00687 fltMaker.AddFilter(_("All the files"), wxT("*")); 00688 } 00689 //--------------------------------------------------------------------------- 00690 00691 00692 /** 00693 * Processes button Add List. 00694 * 00695 * @param event The event's parameters 00696 */ 00697 void dlgFilesSelector::btnAddListClick(wxCommandEvent& event) 00698 { 00699 wxString lastDir, lastDirKey; 00700 wxFileDialogFilterMaker fltMaker; 00701 getLastDirectoryAndFilter(wxT("LastAddListDirectory"), lastDirKey, lastDir, fltMaker); 00702 00703 // Show the open dialog 00704 wxFileDialog dlgOpen(this, getUIString(uiOpenDlgAddList), 00705 lastDir, wxEmptyString, fltMaker.GetFilters(), 00706 wxOPEN | wxFILE_MUST_EXIST, wxDefaultPosition); 00707 00708 if (dlgOpen.ShowModal() == wxID_OK) 00709 { 00710 // Opens the file 00711 wxFileInputStream input(dlgOpen.GetPath()); 00712 if (!input.Ok()) 00713 return; 00714 wxTextInputStream text(input); 00715 00716 // Reads the lines 00717 wxArrayString files; 00718 wxString line; 00719 line = text.ReadLine(); 00720 while (!input.Eof()) 00721 { 00722 line.Trim(false).Trim(true); 00723 if (!line.IsEmpty()) 00724 files.Add(line); 00725 line = text.ReadLine(); 00726 } 00727 00728 // Add the files to the list 00729 addFileNamesToListView(files); 00730 00731 // Save the last directory used 00732 wxConfig::Get()->Write(lastDirKey, dlgOpen.GetDirectory()); 00733 } 00734 } 00735 //--------------------------------------------------------------------------- 00736 00737 00738 /** 00739 * Processes button Load List. 00740 * 00741 * @param event The event's parameters 00742 */ 00743 void dlgFilesSelector::btnLoadListClick(wxCommandEvent& event) 00744 { 00745 wxString lastDir, lastDirKey; 00746 wxFileDialogFilterMaker fltMaker; 00747 getLastDirectoryAndFilter(wxT("LastLoadListDirectory"), lastDirKey, lastDir, fltMaker); 00748 00749 // Show the open dialog 00750 wxFileDialog dlgOpen(this, getUIString(uiOpenDlgLoadList), 00751 lastDir, wxEmptyString, fltMaker.GetFilters(), 00752 wxOPEN | wxFILE_MUST_EXIST, wxDefaultPosition); 00753 00754 if (dlgOpen.ShowModal() == wxID_OK) 00755 { 00756 // Opens the file 00757 wxFileInputStream input(dlgOpen.GetPath()); 00758 if (!input.Ok()) 00759 return; 00760 wxTextInputStream text(input); 00761 00762 // Reads the lines 00763 wxArrayString files; 00764 wxString line; 00765 line = text.ReadLine(); 00766 while (!input.Eof()) 00767 { 00768 line.Trim(false).Trim(true); 00769 if (!line.IsEmpty()) 00770 files.Add(line); 00771 line = text.ReadLine(); 00772 } 00773 00774 // Remove all the previous files 00775 lvwFiles->DeleteAllItems(); 00776 00777 // Add the files to the list 00778 addFileNamesToListView(files); 00779 00780 // Save the last directory used 00781 wxConfig::Get()->Write(lastDirKey, dlgOpen.GetDirectory()); 00782 } 00783 } 00784 //--------------------------------------------------------------------------- 00785 00786 00787 /** 00788 * Processes button Save List. 00789 * 00790 * @param event The event's parameters 00791 */ 00792 void dlgFilesSelector::btnSaveListClick(wxCommandEvent& event) 00793 { 00794 wxString lastDir, lastDirKey; 00795 wxFileDialogFilterMaker fltMaker; 00796 getLastDirectoryAndFilter(wxT("LastSaveListDirectory"), lastDirKey, lastDir, fltMaker); 00797 00798 // Show the open dialog 00799 wxFileDialog dlgSave(this, getUIString(uiSaveDlgAddList), 00800 lastDir, wxEmptyString, fltMaker.GetFilters(), 00801 wxSAVE | wxOVERWRITE_PROMPT, wxDefaultPosition); 00802 00803 if (dlgSave.ShowModal() == wxID_OK) 00804 { 00805 wxFileOutputStream output(dlgSave.GetPath()); 00806 if (!output.Ok()) 00807 return; 00808 wxTextOutputStream text(output); 00809 00810 wxString fileName, directory; 00811 wxListItem listItem; 00812 listItem.SetMask(wxLIST_MASK_TEXT); 00813 long item = lvwFiles->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 00814 while (item != -1) 00815 { 00816 // Read items info 00817 listItem.SetId(item); 00818 listItem.SetColumn(0); 00819 lvwFiles->GetItem(listItem); 00820 fileName = listItem.GetText(); 00821 listItem.SetColumn(1); 00822 lvwFiles->GetItem(listItem); 00823 directory = listItem.GetText(); 00824 00825 wxFileName fn(directory, fileName); 00826 text.WriteString(fn.GetFullPath() + wxT('\n')); 00827 00828 item = lvwFiles->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 00829 } 00830 00831 // Save the last directory used 00832 wxConfig::Get()->Write(lastDirKey, dlgSave.GetDirectory()); 00833 } 00834 00835 } 00836 //--------------------------------------------------------------------------- 00837 00838 00839 /** 00840 * Processes button Browse. 00841 * 00842 * @param event The event's parameters 00843 */ 00844 void dlgFilesSelector::btnBrowseClick(wxCommandEvent& event) 00845 { 00846 const wxString lastDirKey = getRootConfigKey() + wxT("LookInBrowseLastDir"); 00847 wxString lastDir; 00848 00849 // Get the last directory used 00850 wxConfig::Get()->Read(lastDirKey, &lastDir, wxEmptyString); 00851 if (!::wxDirExists(lastDir)) 00852 { 00853 lastDir = AppPrefs::getUserDocumentsDirName(); 00854 if (lastDir.IsEmpty()) 00855 lastDir = ::wxGetCwd(); 00856 } 00857 00858 // Show the open dialog 00859 wxDirDialog dlgDir(this, _("Select the directory")); 00860 dlgDir.SetPath(lastDir); 00861 00862 if (dlgDir.ShowModal() == wxID_OK) 00863 { 00864 cboLookIn->SetValue(dlgDir.GetPath()); 00865 cboLookIn->SetFocus(); 00866 wxConfig::Get()->Write(lastDirKey, dlgDir.GetPath()); 00867 } 00868 } 00869 //--------------------------------------------------------------------------- 00870 00871 00872 /** 00873 * Adds a file or a directory or a match pattern to a combo box. 00874 * 00875 * @param cboBox The combobox. 00876 * @param maxLines The number of maximum lines in the combobox. 00877 */ 00878 void dlgFilesSelector::addLineToComboBox(wxComboBox* cboBox, const int maxLines) 00879 { 00880 wxString line = cboBox->GetValue().Strip(wxString::both); 00881 if (!line.IsEmpty()) 00882 { 00883 bool alreadyPresent = false; 00884 wxArrayString lines; 00885 int i = 0; 00886 while (!alreadyPresent && i < cboBox->GetCount()) 00887 { 00888 if (compareFileName(cboBox->GetString(i), line) == 0) 00889 alreadyPresent = true; 00890 else 00891 { 00892 lines.Add(cboBox->GetString(i)); 00893 i++; 00894 } 00895 } 00896 00897 if (!alreadyPresent) 00898 { 00899 cboBox->Freeze(); 00900 lines.Insert(line, 0); 00901 while (cboBox->GetCount() > 0) 00902 cboBox->Delete(0); 00903 int s = (lines.GetCount() < maxLines) ? lines.GetCount() : maxLines; 00904 for (i = 0; i < s; i++) 00905 cboBox->Append(lines[i]); 00906 cboBox->Thaw(); 00907 } 00908 } 00909 } 00910 //--------------------------------------------------------------------------- 00911 00912 00913 /** 00914 * Processes button Search and Add. 00915 * 00916 * @param event The event's parameters 00917 */ 00918 void dlgFilesSelector::btnSearchAndAddClick(wxCommandEvent& event) 00919 { 00920 // Checks the validity of the parameters 00921 if (cboLookIn->GetValue().IsEmpty()) 00922 { 00923 ::wxMessageBox(_("Please choose a directory."), _("Warning"), wxOK | wxICON_EXCLAMATION); 00924 cboLookIn->SetFocus(); 00925 return; 00926 } 00927 if (!::wxDirExists(cboLookIn->GetValue())) 00928 { 00929 ::wxMessageBox(wxString::Format(_("'%s' is invalid."), cboLookIn->GetValue().c_str()), _("Warning"), wxOK | wxICON_EXCLAMATION); 00930 cboLookIn->SetFocus(); 00931 return; 00932 } 00933 unsigned int depth = (spnDepth->GetValue() > 0) ? static_cast<unsigned int>(spnDepth->GetValue()) : 0U; 00934 00935 // No log 00936 wxLogNull logNo; 00937 00938 // Find the files 00939 wxArrayString res; 00940 wxArrayString files; 00941 BytesDisplayer size; 00942 files.Add(cboLookIn->GetValue()); 00943 if (::getFilesInSubdirectories(files, res, size, cboNamed->GetValue().Strip(wxString::both), depth)) 00944 { 00945 addFileNamesToListView(res); 00946 addLineToComboBox(cboNamed, getHistoryMaxSize()); 00947 addLineToComboBox(cboLookIn, getHistoryMaxSize()); 00948 00949 for (int i = 1; i <= getHistoryMaxSize(); i++) 00950 { 00951 wxString named = (cboNamed->GetCount() >= i) ? cboNamed->GetString(i - 1) : wxString(); 00952 wxString lookIn = (cboLookIn->GetCount() >= i) ? cboLookIn->GetString(i - 1) : wxString(); 00953 wxConfig::Get()->Write(getNamedConfigKey(i), named); 00954 wxConfig::Get()->Write(getLookInConfigKey(i), lookIn); 00955 } 00956 } 00957 } 00958 //--------------------------------------------------------------------------- 00959 00960 00961 /** 00962 * Event handler for the selection of an item. 00963 * 00964 * @param event Event parameters. 00965 */ 00966 void dlgFilesSelector::lvwFilesSelectItem(wxListEvent& event) 00967 { 00968 btnRemove->Enable(); 00969 } 00970 //--------------------------------------------------------------------------- 00971 00972 00973 /** 00974 * Event handler for the deselection of an item. 00975 * 00976 * @param event Event parameters. 00977 */ 00978 void dlgFilesSelector::lvwFilesDeselectItem(wxListEvent& event) 00979 { 00980 if (lvwFiles->GetSelectedItemCount() == 0) 00981 btnRemove->Disable(); 00982 } 00983 //--------------------------------------------------------------------------- 00984 00985 00986 /** 00987 * Processes a selection of the column to sort. 00988 * 00989 * @param event Event parameters. 00990 */ 00991 void dlgFilesSelector::rbxSortBySelect(wxCommandEvent& event) 00992 { 00993 lvwFiles->SetColumnToSort(event.GetInt()); 00994 lvwFiles->SortItems(filesListCmpFnct, reinterpret_cast<long>(lvwFiles)); 00995 } 00996 //--------------------------------------------------------------------------- 00997 00998 00999 /** 01000 * Processes a selection of the sort order. 01001 * 01002 * @param event Event parameters. 01003 */ 01004 void dlgFilesSelector::rbxSortOrderSelect(wxCommandEvent& event) 01005 { 01006 switch (event.GetInt()) 01007 { 01008 case 0 : // ascending 01009 lvwFiles->SetSortOrder(wxSortableListView::ascending); 01010 break; 01011 case 1 : // descending 01012 lvwFiles->SetSortOrder(wxSortableListView::descending); 01013 break; 01014 case 2 : // none 01015 lvwFiles->SetSortOrder(wxSortableListView::none); 01016 break; 01017 } 01018 lvwFiles->SortItems(filesListCmpFnct, reinterpret_cast<long>(lvwFiles)); 01019 } 01020 //--------------------------------------------------------------------------- 01021 01022 01023 /** 01024 * Event handler for the enter key pressed on a search combo box. 01025 * 01026 * @param event Event parameters. 01027 */ 01028 void dlgFilesSelector::cboSearchTextEnter(wxCommandEvent& event) 01029 { 01030 wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, BTN_SEARCH_AND_ADD); 01031 btnSearchAndAdd->ProcessEvent(e); 01032 } 01033 //--------------------------------------------------------------------------- 01034 01035 01036 /** 01037 * Event handler for the key down event. 01038 * 01039 * @param event Event parameters. 01040 */ 01041 void dlgFilesSelector::lvwFilesKeyDown(wxListEvent& event) 01042 { 01043 switch (event.GetKeyCode()) 01044 { 01045 case WXK_INSERT : { 01046 wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, BTN_ADD); 01047 btnAdd->ProcessEvent(e); 01048 break; } 01049 case WXK_DELETE : { 01050 wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, BTN_REMOVE); 01051 btnRemove->ProcessEvent(e); 01052 break; } 01053 default: 01054 event.Skip(); 01055 } 01056 } 01057 //--------------------------------------------------------------------------- 01058 01059 01060 /** 01061 * Processes a click on a header of a column of the list of files. 01062 * 01063 * @param event Event parameters. 01064 */ 01065 void dlgFilesSelector::lvwFilesColumnClick(wxListEvent& event) 01066 { 01067 if (event.GetColumn() == lvwFiles->GetColumnToSort()) 01068 lvwFiles->SetSortOrder((lvwFiles->GetSortOrder() == wxSortableListView::ascending) ? wxSortableListView::descending : wxSortableListView::ascending); 01069 else 01070 { 01071 lvwFiles->SetSortOrder(wxSortableListView::ascending); 01072 lvwFiles->SetColumnToSort(event.GetColumn()); 01073 } 01074 01075 rbxSortBy->SetSelection(event.GetColumn()); 01076 switch (lvwFiles->GetSortOrder()) 01077 { 01078 case wxSortableListView::ascending : 01079 rbxSortOrder->SetSelection(0); 01080 break; 01081 case wxSortableListView::descending : 01082 rbxSortOrder->SetSelection(1); 01083 break; 01084 default : 01085 rbxSortOrder->SetSelection(2); 01086 } 01087 01088 lvwFiles->SortItems(filesListCmpFnct, reinterpret_cast<long>(lvwFiles)); 01089 } 01090 //--------------------------------------------------------------------------- 01091 01092 01093 /** 01094 * Processes button OK. 01095 * 01096 * @param event The event's parameters 01097 */ 01098 void dlgFilesSelector::btnOKClick(wxCommandEvent& event) 01099 { 01100 if (Validate() && TransferDataFromWindow()) 01101 { 01102 // Save the preferences 01103 wxConfig::Get()->Write(getConfigKey(prGUI_SORT_BY), lvwFiles->GetColumnToSort()); 01104 wxConfig::Get()->Write(getConfigKey(prGUI_SORT_ORDER), lvwFiles->GetSortOrder()); 01105 wxConfig::Get()->Write(getConfigKey(prGUI_FILENAME_WIDTH), lvwFiles->GetColumnWidth(0)); 01106 wxConfig::Get()->Write(getConfigKey(prGUI_DIRECTORY_WIDTH), lvwFiles->GetColumnWidth(1)); 01107 wxSize s = GetSize(); 01108 wxConfig::Get()->Write(getConfigKey(prGUI_WINDOW_SIZE), wxString::Format(wxT("%d,%d"), s.GetWidth(), s.GetHeight())); 01109 01110 // Close the dialog 01111 if (IsModal()) 01112 EndModal(wxID_OK); 01113 else 01114 { 01115 SetReturnCode(wxID_OK); 01116 this->Show(FALSE); 01117 } 01118 } 01119 } 01120 //--------------------------------------------------------------------------- 01121 01122 01123 /** 01124 * Adds the given array of file names to the listview of file names. 01125 * 01126 * The names that already are in the list are not added. 01127 * 01128 * @param fileNames Names of the files to be added to the listview. 01129 */ 01130 void dlgFilesSelector::addFileNamesToListView(const wxArrayString& fileNames) 01131 { 01132 size_t s = fileNames.GetCount(); 01133 size_t i; 01134 wxString fileName, lstFileName; 01135 wxString directory, lstDirectory; 01136 wxListItem listItem; 01137 listItem.SetMask(wxLIST_MASK_TEXT); 01138 01139 for (i = 0; i < s; i++) 01140 { 01141 wxFileName fn(fileNames[i]); 01142 01143 // Don't add a directory or a file with a non-absolute path. 01144 if (!fn.DirExists() && fn.IsAbsolute()) 01145 { 01146 fileName = fn.GetFullName(); 01147 directory = fn.GetPath(wxPATH_GET_VOLUME); 01148 01149 // Checks if the file isn't already is the list. 01150 long item = lvwFiles->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 01151 bool found = false; 01152 while (!found && item != -1) 01153 { 01154 listItem.SetId(item); 01155 listItem.SetColumn(0); 01156 lvwFiles->GetItem(listItem); 01157 lstFileName = listItem.GetText(); 01158 listItem.SetColumn(1); 01159 lvwFiles->GetItem(listItem); 01160 lstDirectory = listItem.GetText(); 01161 01162 if (compareFileName(fileName, lstFileName) == 0 && 01163 compareFileName(directory, lstDirectory) == 0) 01164 found = true; 01165 else 01166 item = lvwFiles->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE); 01167 } 01168 if (!found) 01169 { 01170 long newItem = lvwFiles->InsertItem(lvwFiles->GetItemCount(), fileName); 01171 lvwFiles->SetItem(newItem, 1, directory); 01172 lvwFiles->SetItemData(newItem, getID()); 01173 } 01174 } 01175 } 01176 lvwFiles->SortItems(filesListCmpFnct, reinterpret_cast<long>(lvwFiles)); 01177 } 01178 //--------------------------------------------------------------------------- 01179 01180 01181 /** 01182 * Gets the names of the files. 01183 * 01184 * @param names The array which will contain the names of the files. 01185 */ 01186 void dlgFilesSelector::getFileNames(wxArrayString& names) const 01187 { 01188 names = fileNames; 01189 } 01190 //--------------------------------------------------------------------------- 01191 01192 01193 /** 01194 * Gets the configuration key for the last files' names for searching files. 01195 * 01196 * @param n The nth history configuration key to get. 01197 * @return The configuration key for the last files' names for searching files. 01198 */ 01199 wxString dlgFilesSelector::getNamedConfigKey(const int n) 01200 { 01201 if (n >= 1 && n <= getHistoryMaxSize()) 01202 return getRootConfigKey() + wxString::Format(wxT("History/Named%02d"), n); 01203 else 01204 return wxEmptyString; 01205 } 01206 //--------------------------------------------------------------------------- 01207 01208 01209 /** 01210 * Gets the configuration key for the last directories for searching files. 01211 * 01212 * @param n The nth history configuration key to get. 01213 * @return The configuration key for the last directories for searching files. 01214 */ 01215 wxString dlgFilesSelector::getLookInConfigKey(const int n) 01216 { 01217 if (n >= 1 && n <= getHistoryMaxSize()) 01218 return getRootConfigKey() + wxString::Format(wxT("History/LookIn%02d"), n); 01219 else 01220 return wxEmptyString; 01221 } 01222 //--------------------------------------------------------------------------- 01223 01224 01225 /** 01226 * Get the maximum size of the history of the last files' names and directories 01227 * for searching files. 01228 * 01229 * @return The maximum size of the history of the last files' names and 01230 * directories for searching files. 01231 */ 01232 inline int dlgFilesSelector::getHistoryMaxSize() 01233 { 01234 return 16; 01235 } 01236 //--------------------------------------------------------------------------- 01237 01238 01239 /** 01240 * Gets the configuration key corresponding to the given preference key. 01241 * 01242 * @param pk The preference key to get. 01243 * @return The configuration key corresponding to the given preference key or 01244 * an empty string if the preference key is invalid. 01245 */ 01246 wxString dlgFilesSelector::getConfigKey(const PreferencesKey pk) 01247 { 01248 wxString res = getRootConfigKey(); 01249 01250 switch (pk) 01251 { 01252 case prGUI_SORT_BY : 01253 res += wxT("FilesList/SortBy"); 01254 break; 01255 case prGUI_SORT_ORDER : 01256 res += wxT("FilesList/SortOrder"); 01257 break; 01258 case prGUI_FILENAME_WIDTH : 01259 res += wxT("FilesList/ColumnWidthFileName"); 01260 break; 01261 case prGUI_DIRECTORY_WIDTH : 01262 res += wxT("FilesList/ColumnWidthDirectory"); 01263 break; 01264 case prGUI_WINDOW_SIZE : 01265 res += wxT("WindowSize"); 01266 break; 01267 default : 01268 res = wxEmptyString; 01269 } 01270 01271 return res; 01272 } 01273 //--------------------------------------------------------------------------- 01274 01275 01276 /** 01277 * Gets a new unique identifier. 01278 * 01279 * @return A new unique identifier. 01280 */ 01281 long dlgFilesSelector::getID() 01282 { 01283 return ::getUniqueId(); 01284 } 01285 //--------------------------------------------------------------------------- 01286 01287 01288 01289 BEGIN_EVENT_TABLE(dlgFilesSelector, wxDialog) 01290 EVT_BUTTON(BTN_ADD, dlgFilesSelector::btnAddClick) 01291 EVT_BUTTON(BTN_REMOVE, dlgFilesSelector::btnRemoveClick) 01292 EVT_BUTTON(BTN_ADDLIST, dlgFilesSelector::btnAddListClick) 01293 EVT_BUTTON(BTN_LOADLIST, dlgFilesSelector::btnLoadListClick) 01294 EVT_BUTTON(BTN_SAVELIST, dlgFilesSelector::btnSaveListClick) 01295 EVT_BUTTON(BTN_BROWSE, dlgFilesSelector::btnBrowseClick) 01296 EVT_BUTTON(BTN_SEARCH_AND_ADD, dlgFilesSelector::btnSearchAndAddClick) 01297 EVT_LIST_ITEM_SELECTED(LVW_FILES, dlgFilesSelector::lvwFilesSelectItem) 01298 EVT_LIST_ITEM_DESELECTED(LVW_FILES, dlgFilesSelector::lvwFilesDeselectItem) 01299 EVT_LIST_DELETE_ITEM(LVW_FILES, dlgFilesSelector::lvwFilesDeselectItem) 01300 EVT_LIST_KEY_DOWN(LVW_FILES, dlgFilesSelector::lvwFilesKeyDown) 01301 EVT_LIST_COL_CLICK(LVW_FILES, dlgFilesSelector::lvwFilesColumnClick) 01302 EVT_RADIOBOX(RBX_SORT_BY, dlgFilesSelector::rbxSortBySelect) 01303 EVT_RADIOBOX(RBX_SORT_ORDER, dlgFilesSelector::rbxSortOrderSelect) 01304 EVT_TEXT_ENTER(CBO_NAMED, dlgFilesSelector::cboSearchTextEnter) 01305 EVT_TEXT_ENTER(CBO_LOOKIN, dlgFilesSelector::cboSearchTextEnter) 01306 EVT_BUTTON(BTN_OK, dlgFilesSelector::btnOKClick) 01307 END_EVENT_TABLE() 01308 //---------------------------------------------------------------------------

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