Mercurial > mercurial > hgweb_mover.cgi
view src/delwhite.cpp @ 6:99d612849255
v0.3
author | pyon@macmini |
---|---|
date | Sat, 08 Oct 2011 17:00:33 +0900 |
parents | a505f7417742 |
children |
line wrap: on
line source
// Filename : delwhite.cpp // Last Change: 05-Oct-2011. // #include "delwhite.h" // constructor FrameDelWhite::FrameDelWhite( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSize( 1200, 1000 ); this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); wxBoxSizer* bSizer; bSizer = new wxBoxSizer( wxVERTICAL ); m_listCtrl = new wxListCtrl( this, ID_LSWHITE, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); bSizer->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); m_imageList = new wxImageList( 63, 89 ); m_listCtrl->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); wxBoxSizer* bSizerBtn; bSizerBtn = new wxBoxSizer( wxHORIZONTAL ); m_checkBox = new wxCheckBox( this, ID_CHECK, wxT("全ての画像を表示"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer->Add( m_checkBox, 0, wxALL, 5 ); m_staticText = new wxStaticText( this, wxID_ANY, wxT("白紙ファイルを選択し,「削除」ボタンを押してください.") ); bSizerBtn->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_buttonDelWhite = new wxButton( this, ID_DELETE, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBtn->Add( m_buttonDelWhite, 0, wxALL, 5 ); m_buttonCancel = new wxButton( this, ID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBtn->Add( m_buttonCancel, 0, wxALL, 5 ); bSizer->Add( bSizerBtn, 0, wxEXPAND, 5 ); this->SetSizer( bSizer ); this->Layout(); this->Centre( wxBOTH ); } // destructor FrameDelWhite::~FrameDelWhite() { } // Event Table BEGIN_EVENT_TABLE( FrameDelWhite, wxFrame ) //EVT_LIST_ITEM_SELECTED( ID_LSTCTRL, FramePreview::ChageImage ) EVT_CHECKBOX( ID_CHECK, FrameDelWhite::UpdateList ) EVT_BUTTON( ID_DELETE, FrameDelWhite::DeleteImage ) EVT_BUTTON( ID_CANCEL, FrameDelWhite::CloseFrame ) END_EVENT_TABLE() // Event Handlers void FrameDelWhite::UpdateList(wxCommandEvent& WXUNUSED(event)) { LoadImages(); } void FrameDelWhite::DeleteImage(wxCommandEvent& WXUNUSED(event)) { wxDateTime now = wxDateTime::Now(); wxString trash = wxGetCwd() + wxFILE_SEP_PATH + wxT("trash") + wxFILE_SEP_PATH + now.Format(wxT("%Y%m%d%H%M%S")); wxMkdir( trash ); long item = -1; for ( ; ; ) { item = m_listCtrl->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); if ( item == -1 ) break; wxString file = m_listCtrl->GetItemText( item ); wxString from = m_dir + wxFILE_SEP_PATH + file; wxString to = trash + wxFILE_SEP_PATH + file; wxRenameFile( from, to, false ); } LoadImages(); return; } void FrameDelWhite::CloseFrame(wxCommandEvent& WXUNUSED(event)) { this->Close(); return; } // Functions void FrameDelWhite::LoadImages( void ) { m_listCtrl->DeleteAllItems(); m_imageList->RemoveAll(); wxDir dir(m_dir); wxString filename; if ( !dir.IsOpened() ) return; bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); int i=0; wxListItem item; while ( cout ) { wxString f = m_dir + wxFILE_SEP_PATH + filename; wxFile file( f ); long len = file.Length(); if ( !m_checkBox->IsChecked() && len > 150000 ) { cout = dir.GetNext( &filename ); continue; } item.SetId(i); item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE); item.SetStateMask(wxLIST_STATE_SELECTED); item.SetState(wxLIST_STATE_SELECTED); item.SetImage(i); item.SetText(filename); m_listCtrl->InsertItem( item ); m_listCtrl->SetItem( item ); wxImage img( f, wxBITMAP_TYPE_JPEG ); wxBitmap bmp( img.Scale( 63, 89, wxIMAGE_QUALITY_HIGH ) ); m_imageList->Add( bmp ); cout = dir.GetNext( &filename ); i++; } return; }