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