comparison src/dirview.cpp @ 40:ce5b61376fd0 v2.7 tip

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