00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#include <wx/wxprec.h>
00029
00030
#ifdef __BORLANDC__
00031
#pragma hdrstop
00032
#endif
00033
00034
#ifndef WX_PRECOMP
00035
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
00052
using namespace std;
00053
00054
00055
00056
00057
00058
00059 IMPLEMENT_DYNAMIC_CLASS(
dlgInvalidFiles, wxDialog)
00060
00061
00062
00063
00064
00065 dlgInvalidFiles::
dlgInvalidFiles() : wxDialog()
00066 {
00067 createControls(wxEmptyString, InvalidFilesContainer());
00068 }
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
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
00098
00099
00100
00101
00102
00103
00104
00105
00106 static int wxCALLBACK
ListCompareFnct(
long item1,
long item2,
long sortData)
00107 {
00108
int res;
00109
00110
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
00126
00127 void dlgInvalidFiles::createControls(
const wxString& msg,
00128
const InvalidFilesContainer& files)
00129 {
00130
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
00139 lwvFiles->InsertColumn(0, _(
"File name"));
00140 lwvFiles->InsertColumn(1, _(
"Reason"));
00141
00142
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
00152 lwvFiles->SetColumnWidth(0, wxLIST_AUTOSIZE);
00153 lwvFiles->SetColumnWidth(1, wxLIST_AUTOSIZE);
00154
00155
00156 {
00157 wxWindowDisabler disableAll;
00158 wxBusyInfo wait(_(
"Please wait..."));
00159 lwvFiles->SortItems(
ListCompareFnct, 0);
00160 }
00161
00162
00163
00164
00165
00166
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
00177 this->SetAutoLayout(
true);
00178 this->Layout();
00179
00180
00181
00182 }
00183
00184
00185
00186
00187
00188
00189 dlgInvalidFiles::~dlgInvalidFiles()
00190 {
00191 }
00192
00193
00194
00195
00196
00197
00198
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