19
|
1 // Filename : dirview.cpp
|
38
|
2 // Last Change: 24-Nov-2011.
|
19
|
3 //
|
|
4
|
|
5 #include "dirview.h"
|
|
6
|
38
|
7 #define THUMB_W 160
|
|
8 #define THUMB_H 226
|
|
9
|
19
|
10 // frame constructor
|
|
11 DirViewFrame::DirViewFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
|
12 {
|
|
13 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
|
14
|
38
|
15 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
19
|
16
|
38
|
17 m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
|
|
18 bSizerTop->Add( m_listCtrl, 1, wxEXPAND|wxALL, 5 );
|
|
19
|
|
20 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL );
|
|
21
|
|
22 m_buttonExplorer = new wxButton( this, ID_BUTTONEXPLR, wxT("フォルダオープン"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
23 bSizerButton->Add( m_buttonExplorer, 1, wxALL, 5 );
|
|
24 m_buttonClose = new wxButton( this, ID_BUTTONCLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
25 bSizerButton->Add( m_buttonClose, 1, wxALL, 5 );
|
19
|
26
|
38
|
27 bSizerTop->Add( bSizerButton, 0, wxALL, 5 );
|
|
28
|
|
29 this->SetSizer( bSizerTop );
|
19
|
30 this->Layout();
|
|
31
|
|
32 this->Centre( wxBOTH );
|
38
|
33 this->LoadListImage();
|
19
|
34 }
|
|
35
|
|
36 // destructor
|
|
37 DirViewFrame::~DirViewFrame()
|
|
38 {
|
|
39 }
|
|
40
|
|
41 // Event Table
|
38
|
42 BEGIN_EVENT_TABLE( DirViewFrame, wxFrame )
|
|
43 EVT_BUTTON( ID_BUTTONEXPLR, DirViewFrame::OnExplorer )
|
|
44 EVT_BUTTON( ID_BUTTONCLOSE, DirViewFrame::OnClose )
|
19
|
45 END_EVENT_TABLE()
|
|
46
|
|
47 // Event Handlers
|
38
|
48 void DirViewFrame::OnExplorer(wxCommandEvent& WXUNUSED(event))
|
19
|
49 {
|
38
|
50 wxString execmd = wxT("explorer ") + m_dir; // hhsdir
|
|
51 //wxExecute( execmd );
|
|
52 wxMessageBox( execmd );
|
|
53 Close(true);
|
19
|
54 }
|
|
55
|
38
|
56 void DirViewFrame::OnClose(wxCommandEvent& WXUNUSED(event))
|
19
|
57 {
|
38
|
58 Close(true);
|
19
|
59 }
|
|
60
|
|
61 // Functions
|
38
|
62 void DirViewFrame::LoadListImage()
|
19
|
63 {
|
38
|
64 wxImageList* imageList = new wxImageList( THUMB_W, THUMB_H );
|
|
65 m_listCtrl->AssignImageList( imageList, wxIMAGE_LIST_NORMAL );
|
|
66
|
|
67 wxArrayString filenames;
|
|
68 unsigned int n = wxDir::GetAllFiles( m_dir, &filenames, wxT("*.jpg"), wxDIR_FILES );
|
|
69 for ( int i=0; i<n; i++ ) {
|
|
70 wxImage image( filenames[i], wxBITMAP_TYPE_JPEG );
|
|
71 wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH );
|
|
72 wxBitmap bmp( thumbnail );
|
|
73 imageList->Add( bmp );
|
|
74 m_listCtrl->InsertItem( i, filenames[i], i );
|
|
75 m_listCtrl->SetItem( i, 0, filenames[i], i );
|
|
76 }
|
19
|
77 }
|
38
|
78
|