Mercurial > mercurial > hgweb_mover2.cgi
view 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 |
line wrap: on
line source
// Filename : dirview.cpp // Last Change: 25-Nov-2011. // #include "dirview.h" #define THUMB_W 240 #define THUMB_H 340 // frame constructor DirViewFrame::DirViewFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { m_parent = parent; this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); m_listCtrl->SetBackgroundColour(wxT("LIGHT GREY")); bSizerTop->Add( m_listCtrl, 1, wxEXPAND|wxALL, 5 ); wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); m_buttonExplorer = new wxButton( this, ID_BUTTONEXPLR, wxT("フォルダオープン"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonExplorer, 1, wxALL, 5 ); m_buttonClose = new wxButton( this, ID_BUTTONCLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonClose, 1, wxALIGN_RIGHT|wxALL, 5 ); bSizerTop->Add( bSizerButton, 0, wxALIGN_BOTTOM|wxALL, 5 ); this->SetSizer( bSizerTop ); this->Layout(); this->Centre( wxBOTH ); } // destructor DirViewFrame::~DirViewFrame() { } // Event Table BEGIN_EVENT_TABLE( DirViewFrame, wxFrame ) EVT_BUTTON( ID_BUTTONEXPLR, DirViewFrame::OnExplorer ) EVT_BUTTON( ID_BUTTONCLOSE, DirViewFrame::OnClose ) END_EVENT_TABLE() // Event Handlers void DirViewFrame::OnExplorer(wxCommandEvent& WXUNUSED(event)) { wxString execmd = wxT("explorer ") + m_dir; // hhsdir wxExecute( execmd ); //wxMessageBox( execmd ); Close(true); } void DirViewFrame::OnClose(wxCommandEvent& WXUNUSED(event)) { Close(true); } // Functions void DirViewFrame::LoadListImage() { SetTitle( m_dir ); wxRect rect( m_parent->GetScreenPosition(), wxSize(1800,420) ); SetSize( rect ); return; wxImageList* imageList = new wxImageList( THUMB_W, THUMB_H ); m_listCtrl->AssignImageList( imageList, wxIMAGE_LIST_NORMAL ); wxArrayString filenames; unsigned int n = wxDir::GetAllFiles( m_dir, &filenames, wxT("*.jpg"), wxDIR_FILES ); for ( int i=0; i<n; i++ ) { wxImage image( filenames[i], wxBITMAP_TYPE_JPEG ); wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH ); wxBitmap bmp( thumbnail ); imageList->Add( bmp ); wxFileName f( filenames[i] ); m_listCtrl->InsertItem( i, f.GetFullName(), i ); m_listCtrl->SetItem( i, 0, f.GetFullName(), i ); } }