1
|
1 // Filename : preview.cpp
|
7
|
2 // Last Change: 16-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 {
|
7
|
18 this->SetSize( 1200, 1000 );
|
5
|
19 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
1
|
20
|
|
21 wxBoxSizer* bSizer;
|
|
22 bSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
23
|
3
|
24 // LeftPain ( thumbnail )
|
1
|
25 wxBoxSizer* bSizerL;
|
|
26 bSizerL = new wxBoxSizer( wxVERTICAL );
|
|
27
|
5
|
28 m_listCtrl = new wxListCtrl( this, ID_LSTCTRL, wxDefaultPosition, wxSize( 160, 900 ), wxLC_ICON|wxLC_SINGLE_SEL );
|
|
29 bSizerL->Add( m_listCtrl, 1, wxEXPAND|wxALL|wxALIGN_CENTRE, 0 );
|
4
|
30 m_imageList = new wxImageList( 105, 148 );
|
|
31 m_listCtrl->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
|
1
|
32
|
|
33 bSizer->Add( bSizerL, 0, wxEXPAND, 5 );
|
|
34
|
3
|
35 // MainPain ( preview )
|
1
|
36 m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
4
|
37 m_scrolledWindow->SetScrollbars( 10, 10, 83, 117 );
|
|
38 //m_scrolledWindow->SetScrollRate( 5, 5 );
|
|
39 m_bitmap = new wxStaticBitmap( m_scrolledWindow, ID_IMG, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
5
|
40 bSizer->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 0 );
|
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
|
5
|
60 m_buttonEdit = new wxButton( this, ID_PRINT, wxT("編集"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
61 bSizerR->Add( m_buttonEdit, 0, wxALL|wxALIGN_CENTRE, 5 );
|
|
62 m_buttonMask = new wxButton( this, ID_PRINT, wxT("マスク"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
63 bSizerR->Add( m_buttonMask, 0, wxALL|wxALIGN_CENTRE, 5 );
|
1
|
64 m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 );
|
5
|
65 bSizerR->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTRE, 5 );
|
1
|
66 m_buttonPrintAll = new wxButton( this, ID_PRTALL, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 );
|
5
|
67 bSizerR->Add( m_buttonPrintAll, 0, wxALL|wxALIGN_CENTRE, 5 );
|
1
|
68 m_buttonClose = new wxButton( this, ID_CLSFRM, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
|
5
|
69 bSizerR->Add( m_buttonClose, 0, wxALL|wxALIGN_CENTRE, 5 );
|
1
|
70
|
|
71 bSizer->Add( bSizerR, 0, wxEXPAND, 5 );
|
|
72
|
|
73 this->SetSizer( bSizer );
|
|
74 this->Layout();
|
|
75
|
|
76 this->Centre( wxBOTH );
|
3
|
77
|
|
78 LoadImages( wxEmptyString );
|
1
|
79 }
|
|
80
|
3
|
81 // destructor
|
|
82 FramePreview::~FramePreview()
|
1
|
83 {
|
|
84 }
|
|
85
|
3
|
86 // Event Table
|
|
87 BEGIN_EVENT_TABLE( FramePreview, wxFrame )
|
5
|
88 //EVT_LIST_ITEM_SELECTED( ID_LSTCTRL, FramePreview::ChageImage )
|
3
|
89 //EVT_BUTTON( ID_PRINT, FramePreview::PrintImage )
|
|
90 //EVT_BUTTON( ID_PRTALL, FramePreview::PrintAllImages )
|
|
91 EVT_BUTTON( ID_CLSFRM, FramePreview::CloseFrame )
|
|
92 END_EVENT_TABLE()
|
|
93
|
|
94 // Event Handlers
|
|
95 void FramePreview::CloseFrame(wxCommandEvent& WXUNUSED(event))
|
|
96 {
|
|
97 this->Close();
|
|
98 return;
|
|
99 }
|
|
100
|
5
|
101 void FramePreview::ChageImage(wxCommandEvent& WXUNUSED(event))
|
|
102 {
|
|
103 return;
|
|
104 }
|
|
105
|
3
|
106 // Functions
|
|
107 void FramePreview::LoadImages(wxString path)
|
|
108 {
|
|
109 path = wxGetCwd() + wxT("/testdrive"); // now test!
|
|
110 wxDir dir(path);
|
|
111 wxString file;
|
|
112 if ( !dir.IsOpened() ) return;
|
|
113
|
|
114 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES );
|
5
|
115 // preview
|
4
|
116 if ( cout ) {
|
|
117 wxString mfile = path + wxFILE_SEP_PATH + file;
|
|
118 wxImage img( mfile, wxBITMAP_TYPE_JPEG );
|
|
119 wxBitmap bmp( img.Scale( 640, 877, wxIMAGE_QUALITY_HIGH ) );
|
|
120 m_bitmap->SetBitmap( bmp);
|
|
121 }
|
5
|
122 // thumbnail
|
4
|
123 int i=0;
|
|
124 while ( cout ) {
|
|
125 m_listCtrl->InsertItem( i, file, i );
|
|
126 file = path + wxFILE_SEP_PATH + file;
|
|
127 wxImage img( file, wxBITMAP_TYPE_JPEG );
|
|
128 wxBitmap bmp( img.Scale( 105, 148, wxIMAGE_QUALITY_HIGH ) );
|
|
129 m_imageList->Add( bmp );
|
|
130 i++;
|
|
131 cout = dir.GetNext( &file );
|
|
132 }
|
3
|
133
|
|
134 return;
|
|
135 }
|
|
136
|