1
|
1 // Filename : preview.cpp
|
3
|
2 // Last Change: 09-Apr-2011.
|
1
|
3 //
|
|
4
|
|
5 #include "preview.h"
|
|
6
|
|
7 // for all others, include the necessary headers (this file is usually all you
|
|
8 // need because it includes almost all "standard" wxWidgets headers)
|
|
9 #ifndef WX_PRECOMP
|
|
10 #include "wx/utils.h"
|
3
|
11 #include "wx/dir.h"
|
1
|
12 #endif
|
|
13
|
|
14
|
3
|
15 // constructor
|
|
16 FramePreview::FramePreview( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
1
|
17 {
|
4
|
18 this->SetSize( 1600, 950 );
|
1
|
19
|
|
20 wxBoxSizer* bSizer;
|
|
21 bSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
22
|
3
|
23 // LeftPain ( thumbnail )
|
1
|
24 wxBoxSizer* bSizerL;
|
|
25 bSizerL = new wxBoxSizer( wxVERTICAL );
|
|
26
|
4
|
27 m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( 140, 900 ), wxLC_ICON|wxLC_SINGLE_SEL );
|
|
28 bSizerL->Add( m_listCtrl, 1, wxEXPAND|wxALL|wxALIGN_CENTRE, 5 );
|
|
29 m_imageList = new wxImageList( 105, 148 );
|
|
30 m_listCtrl->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
|
1
|
31
|
|
32 bSizer->Add( bSizerL, 0, wxEXPAND, 5 );
|
|
33
|
3
|
34 // MainPain ( preview )
|
1
|
35 m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
4
|
36 m_scrolledWindow->SetScrollbars( 10, 10, 83, 117 );
|
|
37 //m_scrolledWindow->SetScrollRate( 5, 5 );
|
|
38 m_bitmap = new wxStaticBitmap( m_scrolledWindow, ID_IMG, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
39 bSizer->Add( m_scrolledWindow, 1, wxEXPAND | wxALL, 5 );
|
4
|
40 //bSizer->Add( m_bitmap, 0, wxALL, 5 );
|
1
|
41
|
3
|
42 // RightPain ( manip )
|
1
|
43 wxBoxSizer* bSizerR;
|
|
44 bSizerR = new wxBoxSizer( wxVERTICAL );
|
|
45
|
|
46 m_staticText = new wxStaticText( this, wxID_ANY, wxT("倍率"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
47 bSizerR->Add( m_staticText, 0, wxALL, 5 );
|
|
48 m_textCtrl = new wxTextCtrl( this, ID_MGNFY, wxT("100%"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
|
49 m_textCtrl->SetMaxLength( 4 );
|
|
50 bSizerR->Add( m_textCtrl, 0, wxALL, 5 );
|
|
51 m_staticTextLarge = new wxStaticText( this, wxID_ANY, wxT("[+]"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
52 bSizerR->Add( m_staticTextLarge, 0, wxALL, 5 );
|
|
53 m_slider = new wxSlider( this, ID_SLDR, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LEFT|wxSL_VERTICAL );
|
|
54 bSizerR->Add( m_slider, 0, wxALL, 5 );
|
|
55 m_staticTextSmall = new wxStaticText( this, wxID_ANY, wxT("[-]"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
56 bSizerR->Add( m_staticTextSmall, 0, wxALL, 5 );
|
|
57
|
|
58 bSizerR->Add( 0, 0, 1, wxEXPAND, 5 );
|
|
59
|
|
60 m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
61 bSizerR->Add( m_buttonPrint, 0, wxALL, 5 );
|
|
62 m_buttonPrintAll = new wxButton( this, ID_PRTALL, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
63 bSizerR->Add( m_buttonPrintAll, 0, wxALL, 5 );
|
|
64 m_buttonClose = new wxButton( this, ID_CLSFRM, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
65 bSizerR->Add( m_buttonClose, 0, wxALL, 5 );
|
|
66
|
|
67 bSizer->Add( bSizerR, 0, wxEXPAND, 5 );
|
|
68
|
|
69 this->SetSizer( bSizer );
|
|
70 this->Layout();
|
|
71
|
|
72 this->Centre( wxBOTH );
|
3
|
73
|
|
74 LoadImages( wxEmptyString );
|
1
|
75 }
|
|
76
|
3
|
77 // destructor
|
|
78 FramePreview::~FramePreview()
|
1
|
79 {
|
|
80 }
|
|
81
|
3
|
82 // Event Table
|
|
83 BEGIN_EVENT_TABLE( FramePreview, wxFrame )
|
|
84 //EVT_BUTTON( ID_PRINT, FramePreview::PrintImage )
|
|
85 //EVT_BUTTON( ID_PRTALL, FramePreview::PrintAllImages )
|
|
86 EVT_BUTTON( ID_CLSFRM, FramePreview::CloseFrame )
|
|
87 END_EVENT_TABLE()
|
|
88
|
|
89 // Event Handlers
|
|
90 void FramePreview::CloseFrame(wxCommandEvent& WXUNUSED(event))
|
|
91 {
|
|
92 this->Close();
|
|
93 return;
|
|
94 }
|
|
95
|
|
96 // Functions
|
|
97 void FramePreview::LoadImages(wxString path)
|
|
98 {
|
|
99 path = wxGetCwd() + wxT("/testdrive"); // now test!
|
|
100 wxDir dir(path);
|
|
101 wxString file;
|
|
102 if ( !dir.IsOpened() ) return;
|
|
103
|
|
104 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES );
|
4
|
105 if ( cout ) {
|
|
106 wxString mfile = path + wxFILE_SEP_PATH + file;
|
|
107 wxImage img( mfile, wxBITMAP_TYPE_JPEG );
|
|
108 wxBitmap bmp( img.Scale( 640, 877, wxIMAGE_QUALITY_HIGH ) );
|
|
109 m_bitmap->SetBitmap( bmp);
|
|
110 }
|
|
111 int i=0;
|
|
112 while ( cout ) {
|
|
113 m_listCtrl->InsertItem( i, file, i );
|
|
114 file = path + wxFILE_SEP_PATH + file;
|
|
115 wxImage img( file, wxBITMAP_TYPE_JPEG );
|
|
116 wxBitmap bmp( img.Scale( 105, 148, wxIMAGE_QUALITY_HIGH ) );
|
|
117 m_imageList->Add( bmp );
|
|
118 i++;
|
|
119 cout = dir.GetNext( &file );
|
|
120 }
|
3
|
121
|
|
122 return;
|
|
123 }
|
|
124
|
|
125
|