2
|
1 // Filename : delwhite.cpp
|
3
|
2 // Last Change: 03-Oct-2011.
|
2
|
3 //
|
|
4
|
|
5 #include "delwhite.h"
|
|
6
|
|
7 // for all others, include the necessary headers (this file is usually all you
|
|
8 // need because it includes almost all "standard" wxWidgets headers)
|
|
9 #ifndef WX_PRECOMP
|
|
10 #include "wx/utils.h"
|
|
11 #include "wx/dir.h"
|
|
12 #include "wx/file.h"
|
|
13 #endif
|
|
14
|
|
15
|
|
16 // constructor
|
|
17 FrameDelWhite::FrameDelWhite( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
|
18 {
|
|
19 this->SetSize( 1200, 1000 );
|
3
|
20 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
2
|
21
|
|
22 wxBoxSizer* bSizer;
|
|
23 bSizer = new wxBoxSizer( wxVERTICAL );
|
|
24
|
|
25 m_listCtrl = new wxListCtrl( this, ID_LSWHITE, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
|
|
26 bSizer->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
|
3
|
27 m_imageList = new wxImageList( 63, 89 );
|
2
|
28 m_listCtrl->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
|
|
29
|
|
30 wxBoxSizer* bSizerBtn;
|
|
31 bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
|
|
32
|
|
33 m_checkBox = new wxCheckBox( this, ID_CHECK, wxT("全ての画像を表示"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
34 bSizer->Add( m_checkBox, 0, wxALL, 5 );
|
|
35
|
|
36 m_staticText = new wxStaticText( this, wxID_ANY, wxT("白紙ファイルを選択し,「削除」ボタンを押してください.") );
|
|
37 bSizerBtn->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
38
|
|
39 m_buttonDelWhite = new wxButton( this, ID_DELETE, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
40 bSizerBtn->Add( m_buttonDelWhite, 0, wxALL, 5 );
|
|
41
|
|
42 m_buttonCancel = new wxButton( this, ID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
43 bSizerBtn->Add( m_buttonCancel, 0, wxALL, 5 );
|
|
44
|
|
45 bSizer->Add( bSizerBtn, 0, wxEXPAND, 5 );
|
|
46
|
|
47 this->SetSizer( bSizer );
|
|
48 this->Layout();
|
|
49
|
|
50 this->Centre( wxBOTH );
|
|
51 }
|
|
52
|
|
53 // destructor
|
|
54 FrameDelWhite::~FrameDelWhite()
|
|
55 {
|
|
56 }
|
|
57
|
|
58 // Event Table
|
|
59 BEGIN_EVENT_TABLE( FrameDelWhite, wxFrame )
|
|
60 //EVT_LIST_ITEM_SELECTED( ID_LSTCTRL, FramePreview::ChageImage )
|
3
|
61 EVT_CHECKBOX( ID_CHECK, FrameDelWhite::UpdateList )
|
2
|
62 EVT_BUTTON( ID_DELETE, FrameDelWhite::DeleteImage )
|
3
|
63 EVT_BUTTON( ID_CANCEL, FrameDelWhite::CloseFrame )
|
2
|
64 END_EVENT_TABLE()
|
|
65
|
|
66 // Event Handlers
|
3
|
67 void FrameDelWhite::UpdateList(wxCommandEvent& WXUNUSED(event))
|
|
68 {
|
|
69 LoadImages();
|
|
70 }
|
|
71
|
2
|
72 void FrameDelWhite::DeleteImage(wxCommandEvent& WXUNUSED(event))
|
|
73 {
|
|
74 return;
|
|
75 }
|
|
76
|
|
77 void FrameDelWhite::CloseFrame(wxCommandEvent& WXUNUSED(event))
|
|
78 {
|
|
79 this->Close();
|
|
80 return;
|
|
81 }
|
|
82
|
|
83 // Functions
|
|
84 void FrameDelWhite::LoadImages( void )
|
|
85 {
|
3
|
86 m_listCtrl->DeleteAllItems();
|
|
87 m_imageList->RemoveAll();
|
2
|
88 wxDir dir(m_dir);
|
|
89 wxString filename;
|
|
90 if ( !dir.IsOpened() ) return;
|
|
91
|
|
92 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES );
|
|
93
|
|
94 int i=0;
|
|
95 wxListItem item;
|
|
96 while ( cout ) {
|
|
97 wxString f = m_dir + wxFILE_SEP_PATH + filename;
|
|
98 wxFile file( f );
|
|
99 long len = file.Length();
|
3
|
100 if ( !m_checkBox->IsChecked() && len > 150000 ) {
|
2
|
101 cout = dir.GetNext( &filename );
|
|
102 continue;
|
|
103 }
|
|
104
|
|
105 item.SetId(i);
|
|
106 item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE);
|
|
107 item.SetStateMask(wxLIST_STATE_SELECTED);
|
|
108 item.SetState(wxLIST_STATE_SELECTED);
|
|
109 item.SetImage(i);
|
|
110 item.SetText(filename);
|
|
111 m_listCtrl->InsertItem( item );
|
|
112 m_listCtrl->SetItem( item );
|
|
113
|
|
114 wxImage img( f, wxBITMAP_TYPE_JPEG );
|
3
|
115 wxBitmap bmp( img.Scale( 63, 89, wxIMAGE_QUALITY_HIGH ) );
|
2
|
116 m_imageList->Add( bmp );
|
|
117 cout = dir.GetNext( &filename );
|
|
118 i++;
|
|
119 }
|
|
120
|
|
121 return;
|
|
122 }
|
|
123
|