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

dlgInvalidFiles.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 dlgInvalidFiles.cpp 00022 * Invalid files dialog. 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/busyinfo.h> 00040 #include <wx/filename.h> 00041 #include <wx/listctrl.h> 00042 00043 #include "dlgInvalidFiles.hpp" 00044 #include "comdefs.hpp" 00045 #include "utils.hpp" 00046 00047 #include "compat.hpp" 00048 //--------------------------------------------------------------------------- 00049 00050 00051 /// The C++ standard namespace. 00052 using namespace std; 00053 00054 00055 //########################################################################### 00056 // dlgInvalidFiles methods 00057 //########################################################################### 00058 00059 IMPLEMENT_DYNAMIC_CLASS(dlgInvalidFiles, wxDialog) 00060 00061 00062 /** 00063 * Creates a new dialog. 00064 */ 00065 dlgInvalidFiles::dlgInvalidFiles() : wxDialog() 00066 { 00067 createControls(wxEmptyString, InvalidFilesContainer()); 00068 } 00069 //--------------------------------------------------------------------------- 00070 00071 00072 /** 00073 * Creates a new dialog. 00074 * 00075 * @param parent Parent of the dialog. 00076 * @param title Title of the window. 00077 * @param msg Message to display. 00078 * @param files Invalid files and reason. 00079 */ 00080 dlgInvalidFiles::dlgInvalidFiles(wxWindow* parent, const wxString& title, 00081 const wxString& msg, 00082 const InvalidFilesContainer& files) : 00083 wxDialog(parent, -1, title, wxDefaultPosition, wxDefaultSize, 00084 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) 00085 { 00086 createControls(msg, files); 00087 00088 int w, h; 00089 ::wxDisplaySize(&w, &h); 00090 SetSize((w * 2) / 3, (h * 2) / 3); 00091 Centre(); 00092 } 00093 //--------------------------------------------------------------------------- 00094 00095 00096 /** 00097 * List compare function. 00098 * 00099 * <B>Warning &nbsp;:</B> this is a quick&dirty fonction, where a pointer 00100 * on a wxListView class is passed in a parameter with the long type. 00101 * 00102 * @param item1 data on the first item. 00103 * @param item2 data on the second item. 00104 * @param sortData Not used 00105 */ 00106 static int wxCALLBACK ListCompareFnct(long item1, long item2, long sortData) 00107 { 00108 int res; 00109 00110 // Gets the checksum data of the items 00111 wxFileName fn1 = *reinterpret_cast<const wxString*>(item1); 00112 wxFileName fn2 = *reinterpret_cast<const wxString*>(item2); 00113 00114 ::wxYield(); 00115 res = ::compareFileName(fn1.GetPath(wxPATH_GET_VOLUME), fn2.GetPath(wxPATH_GET_VOLUME)); 00116 if (res == 0) 00117 res = ::compareFileName(fn1.GetFullName(), fn2.GetFullName()); 00118 00119 return res; 00120 } 00121 //--------------------------------------------------------------------------- 00122 00123 00124 /** 00125 * Creates and initializes the controls of the dialog. 00126 */ 00127 void dlgInvalidFiles::createControls(const wxString& msg, 00128 const InvalidFilesContainer& files) 00129 { 00130 // Creates the control 00131 wxStaticText* lblMessage = new wxStaticText(this, -1, msg); 00132 wxListView* lwvFiles = new wxListView(this, -1, wxDefaultPosition, 00133 wxDefaultSize, 00134 wxLC_REPORT | wxLC_HRULES); 00135 wxButton* btnClose = new wxButton(this, BTN_CLOSE, _("&Close")); 00136 btnClose->SetDefault(); 00137 00138 // Add columns to the listview 00139 lwvFiles->InsertColumn(0, _("File name")); 00140 lwvFiles->InsertColumn(1, _("Reason")); 00141 00142 // Add items to the listview 00143 long p = 0; 00144 for (InvalidFilesContainer::const_iterator it = files.begin(); it != files.end(); it++, p++) 00145 { 00146 lwvFiles->InsertItem(p, it->first); 00147 lwvFiles->SetItem(p, 1, it->second); 00148 lwvFiles->SetItemData(p, reinterpret_cast<long>(&(it->first))); 00149 } 00150 00151 // Set the columns width 00152 lwvFiles->SetColumnWidth(0, wxLIST_AUTOSIZE); 00153 lwvFiles->SetColumnWidth(1, wxLIST_AUTOSIZE); 00154 00155 // Sort the list 00156 { 00157 wxWindowDisabler disableAll; 00158 wxBusyInfo wait(_("Please wait...")); 00159 lwvFiles->SortItems(ListCompareFnct, 0); 00160 } 00161 00162 00163 //------------------------------------------------------------------------- 00164 // Creates the dialog sizer 00165 00166 // Dialog sizer 00167 wxBoxSizer* dlgInvalidFilesSizer2 = new wxBoxSizer(wxVERTICAL); 00168 this->SetSizer(dlgInvalidFilesSizer2); 00169 wxBoxSizer* dlgInvalidFilesSizer = new wxBoxSizer(wxVERTICAL); 00170 dlgInvalidFilesSizer2->Add(dlgInvalidFilesSizer, 1, wxALL | wxGROW, CONTROL_SPACE); 00171 00172 dlgInvalidFilesSizer->Add(lblMessage, 0, wxALIGN_LEFT); 00173 dlgInvalidFilesSizer->Add(lwvFiles, 1, wxGROW | wxTOP, CONTROL_SPACE); 00174 dlgInvalidFilesSizer->Add(btnClose, 0, wxTOP | wxALIGN_RIGHT, CONTROL_SPACE); 00175 00176 // Set on the auto-layout feature 00177 this->SetAutoLayout(true); 00178 this->Layout(); 00179 00180 // Sets the background color 00181 //this->SetBackgroundColour(a_control->GetBackgroundColour()); */ 00182 } 00183 //--------------------------------------------------------------------------- 00184 00185 00186 /** 00187 * The class descructor. 00188 */ 00189 dlgInvalidFiles::~dlgInvalidFiles() 00190 { 00191 } 00192 //--------------------------------------------------------------------------- 00193 00194 00195 /** 00196 * Processes button Close. 00197 * 00198 * @param event The event's parameters 00199 */ 00200 void dlgInvalidFiles::btnCloseClick(wxCommandEvent& event) 00201 { 00202 if (this->IsModal()) 00203 this->EndModal(wxID_OK); 00204 else 00205 { 00206 this->SetReturnCode(wxID_OK); 00207 this->Show(false); 00208 } 00209 } 00210 //--------------------------------------------------------------------------- 00211 00212 00213 00214 BEGIN_EVENT_TABLE(dlgInvalidFiles, wxDialog) 00215 EVT_BUTTON(BTN_CLOSE, dlgInvalidFiles::btnCloseClick) 00216 END_EVENT_TABLE() 00217 //---------------------------------------------------------------------------

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