Mercurial > mercurial > hgweb_searcher2.cgi
view src/preview.cpp @ 3:75fefb53d983
update preview.
author | pyon@macmini |
---|---|
date | Sat, 09 Apr 2011 12:48:20 +0900 |
parents | e0cf49906039 |
children | d924b09ea2f3 |
line wrap: on
line source
// Filename : preview.cpp // Last Change: 09-Apr-2011. // #include "preview.h" // for all others, include the necessary headers (this file is usually all you // need because it includes almost all "standard" wxWidgets headers) #ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/dir.h" #endif // constructor FramePreview::FramePreview( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSize( 1600, 900 ); wxBoxSizer* bSizer; bSizer = new wxBoxSizer( wxHORIZONTAL ); // LeftPain ( thumbnail ) wxBoxSizer* bSizerL; bSizerL = new wxBoxSizer( wxVERTICAL ); m_staticText1 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_staticText1, 0, wxTOP|wxALIGN_CENTRE, 5 ); m_bitmap1 = new wxStaticBitmap( this, ID_IMG1, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTRE, 5 ); m_staticText2 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_staticText2, 0, wxTOP|wxALIGN_CENTRE, 5 ); m_bitmap2 = new wxStaticBitmap( this, ID_IMG2, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTRE, 5 ); m_staticText3 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_staticText3, 0, wxTOP|wxALIGN_CENTRE, 5 ); m_bitmap3 = new wxStaticBitmap( this, ID_IMG3, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTRE, 5 ); m_staticText4 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_staticText4, 0, wxTOP|wxALIGN_CENTRE, 5 ); m_bitmap4 = new wxStaticBitmap( this, ID_IMG4, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTRE, 5 ); m_staticText5 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_staticText5, 0, wxTOP|wxALIGN_CENTRE, 5 ); m_bitmap5 = new wxStaticBitmap( this, ID_IMG5, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerL->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTRE, 5 ); bSizer->Add( bSizerL, 0, wxEXPAND, 5 ); // MainPain ( preview ) m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); m_scrolledWindow->SetScrollRate( 5, 5 ); bSizer->Add( m_scrolledWindow, 1, wxEXPAND | wxALL, 5 ); m_bitmap = new wxStaticBitmap( this, ID_IMG, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizer->Add( m_bitmap, 0, wxALL, 5 ); // RightPain ( manip ) wxBoxSizer* bSizerR; bSizerR = new wxBoxSizer( wxVERTICAL ); m_staticText = new wxStaticText( this, wxID_ANY, wxT("倍率"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerR->Add( m_staticText, 0, wxALL, 5 ); m_textCtrl = new wxTextCtrl( this, ID_MGNFY, wxT("100%"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); m_textCtrl->SetMaxLength( 4 ); bSizerR->Add( m_textCtrl, 0, wxALL, 5 ); m_staticTextLarge = new wxStaticText( this, wxID_ANY, wxT("[+]"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerR->Add( m_staticTextLarge, 0, wxALL, 5 ); m_slider = new wxSlider( this, ID_SLDR, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LEFT|wxSL_VERTICAL ); bSizerR->Add( m_slider, 0, wxALL, 5 ); m_staticTextSmall = new wxStaticText( this, wxID_ANY, wxT("[-]"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerR->Add( m_staticTextSmall, 0, wxALL, 5 ); bSizerR->Add( 0, 0, 1, wxEXPAND, 5 ); m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerR->Add( m_buttonPrint, 0, wxALL, 5 ); m_buttonPrintAll = new wxButton( this, ID_PRTALL, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerR->Add( m_buttonPrintAll, 0, wxALL, 5 ); m_buttonClose = new wxButton( this, ID_CLSFRM, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerR->Add( m_buttonClose, 0, wxALL, 5 ); bSizer->Add( bSizerR, 0, wxEXPAND, 5 ); this->SetSizer( bSizer ); this->Layout(); this->Centre( wxBOTH ); LoadImages( wxEmptyString ); } // destructor FramePreview::~FramePreview() { } // Event Table BEGIN_EVENT_TABLE( FramePreview, wxFrame ) //EVT_BUTTON( ID_PRINT, FramePreview::PrintImage ) //EVT_BUTTON( ID_PRTALL, FramePreview::PrintAllImages ) EVT_BUTTON( ID_CLSFRM, FramePreview::CloseFrame ) END_EVENT_TABLE() // Event Handlers void FramePreview::CloseFrame(wxCommandEvent& WXUNUSED(event)) { this->Close(); return; } // Functions void FramePreview::LoadImages(wxString path) { path = wxGetCwd() + wxT("/testdrive"); // now test! wxDir dir(path); wxString file; if ( !dir.IsOpened() ) return; bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); SetThumbnail( this->m_staticText1, this->m_bitmap1, path, file ); dir.GetNext( &file ); SetThumbnail( this->m_staticText2, this->m_bitmap2, path, file ); dir.GetNext( &file ); SetThumbnail( this->m_staticText3, this->m_bitmap3, path, file ); dir.GetNext( &file ); SetThumbnail( this->m_staticText4, this->m_bitmap4, path, file ); dir.GetNext( &file ); SetThumbnail( this->m_staticText5, this->m_bitmap5, path, file ); return; } void FramePreview::SetThumbnail( wxStaticText* st, wxStaticBitmap* sb, wxString path, wxString file ) { st->SetLabel(file); file = path + wxFILE_SEP_PATH + file; wxImage img( file, wxBITMAP_TYPE_JPEG ); wxBitmap bmp( img.Scale( 105, 148, wxIMAGE_QUALITY_HIGH ) ); sb->SetBitmap( bmp ); return; }