Mercurial > mercurial > hgweb_imcv.cgi
comparison myframe.cpp @ 3:cc1f1fa544a4
for wxWidgets 3.1
author | pyon@macmini |
---|---|
date | Sun, 27 Nov 2016 20:15:37 +0900 |
parents | 25a76c128804 |
children | 3fadcf124bb4 |
comparison
equal
deleted
inserted
replaced
2:25a76c128804 | 3:cc1f1fa544a4 |
---|---|
1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
2 // Last Change: 03-Feb-2014. | 2 // Last Change: 2016-11-27 Sun 20:08:02. |
3 // | 3 // |
4 | 4 |
5 #include "myframe.h" | 5 #include "myframe.h" |
6 #include "dndfile.h" | 6 #include "dndfile.h" |
7 #include "sample.xpm" | 7 #include "sample.xpm" |
8 | 8 |
9 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 9 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
10 : wxFrame( parent, id, title, pos, size, style ) | 10 : wxFrame( parent, id, title, pos, size, style ) |
11 { | 11 { |
12 this->SetIcon( wxIcon( wxT("sample") ) ); | 12 this->SetIcon( wxIcon( wxT("sample") ) ); |
13 this->SetSizeHints( wxSize( 450, 200 ), wxSize( 450, 200 ) ); | 13 //this->SetSizeHints( wxSize( 450, 200 ), wxSize( 450, 200 ) ); |
14 this->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); | 14 this->SetSizeHints( wxSize( 550, 200 ), wxSize( 550, 200 ) ); |
15 this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) ); | 15 this->SetBackgroundColour( *wxBLACK ); |
16 | 16 |
17 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | 17 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); |
18 | 18 |
19 // Source | 19 // Source |
20 wxBoxSizer* bSizerSource = new wxBoxSizer( wxHORIZONTAL ); | 20 wxBoxSizer* bSizerSource = new wxBoxSizer( wxHORIZONTAL ); |
21 | 21 |
22 m_staticTextSource = new wxStaticText( this, wxID_ANY, wxT("Source"), wxDefaultPosition, wxSize( 90,-1 ), wxALIGN_RIGHT ); | 22 m_staticTextSource = new wxStaticText( this, wxID_ANY, wxT("Source"), wxDefaultPosition, wxSize( 90, -1 ), wxALIGN_RIGHT ); |
23 m_staticTextSource->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 23 m_staticTextSource->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
24 m_staticTextSource->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 24 m_staticTextSource->SetBackgroundColour( *wxBLACK ); |
25 | 25 |
26 bSizerSource->Add( m_staticTextSource, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 26 bSizerSource->Add( m_staticTextSource, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
27 | 27 |
28 m_textCtrlSource = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), wxTAB_TRAVERSAL ); | 28 m_textCtrlSource = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), wxTAB_TRAVERSAL ); |
29 bSizerSource->Add( m_textCtrlSource, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 29 bSizerSource->Add( m_textCtrlSource, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
30 | 30 |
31 bSizerTop->Add( bSizerSource, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); | 31 bSizerTop->Add( bSizerSource, 1, wxEXPAND, 5 ); |
32 | 32 |
33 // Config | 33 // Config |
34 // Type | 34 // Type |
35 wxBoxSizer* bSizerConfig = new wxBoxSizer( wxHORIZONTAL ); | 35 wxBoxSizer* bSizerConfig = new wxBoxSizer( wxHORIZONTAL ); |
36 | 36 |
37 m_staticTextConfig = new wxStaticText( this, wxID_ANY, wxT("Config"), wxDefaultPosition, wxSize( 90,-1 ), wxALIGN_RIGHT ); | 37 m_staticTextConfig = new wxStaticText( this, wxID_ANY, wxT("Config"), wxDefaultPosition, wxSize( 90, -1 ), wxALIGN_RIGHT ); |
38 m_staticTextConfig->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 38 m_staticTextConfig->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
39 m_staticTextConfig->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 39 m_staticTextConfig->SetBackgroundColour( *wxBLACK ); |
40 bSizerConfig->Add( m_staticTextConfig, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 40 bSizerConfig->Add( m_staticTextConfig, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
41 | 41 |
42 m_staticTextType = new wxStaticText( this, wxID_ANY, wxT("Type"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); | 42 m_staticTextType = new wxStaticText( this, wxID_ANY, wxT("Type"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); |
43 m_staticTextType->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 43 m_staticTextType->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
44 m_staticTextType->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 44 m_staticTextType->SetBackgroundColour( *wxBLACK ); |
45 bSizerConfig->Add( m_staticTextType, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 45 bSizerConfig->Add( m_staticTextType, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
46 | 46 |
47 m_comboBoxType = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY|wxTAB_TRAVERSAL ); | 47 m_comboBoxType = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY|wxTAB_TRAVERSAL ); |
48 m_comboBoxType->Append( wxT("Not change") ); | 48 m_comboBoxType->Append( wxT("Not change") ); |
49 m_comboBoxType->Append( wxT("PNG") ); | 49 m_comboBoxType->Append( wxT("PNG") ); |
51 m_comboBoxType->Append( wxT("GIF") ); | 51 m_comboBoxType->Append( wxT("GIF") ); |
52 m_comboBoxType->Append( wxT("ICON") ); | 52 m_comboBoxType->Append( wxT("ICON") ); |
53 m_comboBoxType->Append( wxT("BMP") ); | 53 m_comboBoxType->Append( wxT("BMP") ); |
54 m_comboBoxType->Append( wxT("TIFF") ); | 54 m_comboBoxType->Append( wxT("TIFF") ); |
55 m_comboBoxType->Append( wxT("JPEG") ); | 55 m_comboBoxType->Append( wxT("JPEG") ); |
56 m_comboBoxType->Append( wxT("SVG") ); | |
56 m_comboBoxType->SetSelection( 0 ); | 57 m_comboBoxType->SetSelection( 0 ); |
57 bSizerConfig->Add( m_comboBoxType, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 58 bSizerConfig->Add( m_comboBoxType, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
58 | 59 |
59 // Size | 60 // Size |
60 m_staticTextSize = new wxStaticText( this, wxID_ANY, wxT("Size"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); | 61 m_staticTextSize = new wxStaticText( this, wxID_ANY, wxT("Size"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); |
61 m_staticTextSize->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 62 m_staticTextSize->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
62 m_staticTextSize->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 63 m_staticTextSize->SetBackgroundColour( *wxBLACK ); |
63 bSizerConfig->Add( m_staticTextSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 64 bSizerConfig->Add( m_staticTextSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
64 | 65 |
65 m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | 66 m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); |
66 m_staticTextWidth->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 67 m_staticTextWidth->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
67 m_staticTextWidth->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 68 m_staticTextWidth->SetBackgroundColour( *wxBLACK ); |
68 bSizerConfig->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); | 69 bSizerConfig->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
69 | 70 |
70 m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_CENTRE ); | 71 m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_CENTRE ); |
72 m_staticTextWidth->SetBackgroundColour( *wxBLACK ); | |
71 bSizerConfig->Add( m_textCtrlWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 73 bSizerConfig->Add( m_textCtrlWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
72 | 74 |
73 m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | 75 m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); |
74 m_staticTextHeight->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 76 m_staticTextHeight->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
75 m_staticTextHeight->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 77 m_staticTextHeight->SetBackgroundColour( *wxBLACK ); |
76 bSizerConfig->Add( m_staticTextHeight, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); | 78 bSizerConfig->Add( m_staticTextHeight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
77 | 79 |
78 m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_CENTRE ); | 80 m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_CENTRE ); |
79 bSizerConfig->Add( m_textCtrlHeight, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 81 bSizerConfig->Add( m_textCtrlHeight, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
80 | 82 |
81 bSizerTop->Add( bSizerConfig, 1, wxEXPAND, 5 ); | 83 bSizerTop->Add( bSizerConfig, 1, wxEXPAND, 5 ); |
82 | 84 |
83 // Output | 85 // Output |
84 wxBoxSizer* bSizerOutput = new wxBoxSizer( wxHORIZONTAL ); | 86 wxBoxSizer* bSizerOutput = new wxBoxSizer( wxHORIZONTAL ); |
85 | 87 |
86 m_staticTextOutput = new wxStaticText( this, wxID_ANY, wxT("Output folder"), wxDefaultPosition, wxSize( 90,-1 ), wxALIGN_RIGHT ); | 88 m_staticTextOutput = new wxStaticText( this, wxID_ANY, wxT("Output folder"), wxDefaultPosition, wxSize( 90, -1 ), wxALIGN_RIGHT ); |
87 m_staticTextOutput->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); | 89 m_staticTextOutput->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
88 m_staticTextOutput->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 90 m_staticTextOutput->SetBackgroundColour( *wxBLACK ); |
89 bSizerOutput->Add( m_staticTextOutput, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 91 bSizerOutput->Add( m_staticTextOutput, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
90 | 92 |
91 m_dirPicker = new wxDirPickerCtrl( this, wxID_ANY, wxGetCwd(), wxT("Select a folder"), wxDefaultPosition, wxSize( 200,-1 ), wxDIRP_DEFAULT_STYLE ); | 93 m_dirPicker = new wxDirPickerCtrl( this, wxID_ANY, wxGetCwd(), wxT("Select a folder"), wxDefaultPosition, wxSize( 200, -1 ), wxDIRP_DEFAULT_STYLE ); |
92 m_dirPicker->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); | 94 m_dirPicker->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); |
95 m_dirPicker->SetBackgroundColour( *wxBLACK ); | |
93 bSizerOutput->Add( m_dirPicker, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 96 bSizerOutput->Add( m_dirPicker, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
94 | 97 |
95 bSizerTop->Add( bSizerOutput, 1, wxEXPAND, 5 ); | 98 bSizerTop->Add( bSizerOutput, 1, wxEXPAND, 5 ); |
96 | 99 |
97 // Button | 100 // Button |
185 bool MyFrame::ConvertAFile( wxString file ) | 188 bool MyFrame::ConvertAFile( wxString file ) |
186 { | 189 { |
187 wxFileName f( file ); | 190 wxFileName f( file ); |
188 wxString ext = f.GetExt(); | 191 wxString ext = f.GetExt(); |
189 wxString name = f.GetName(); | 192 wxString name = f.GetName(); |
190 int in_type; | 193 wxBitmapType in_type; |
191 | 194 |
192 if ( ext.IsSameAs( wxT("jpg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; | 195 if ( ext.IsSameAs( wxT("jpg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; |
193 else if ( ext.IsSameAs( wxT("jpeg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; | 196 else if ( ext.IsSameAs( wxT("jpeg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; |
194 else if ( ext.IsSameAs( wxT("png"), false ) ) in_type = wxBITMAP_TYPE_PNG; | 197 else if ( ext.IsSameAs( wxT("png"), false ) ) in_type = wxBITMAP_TYPE_PNG; |
195 else if ( ext.IsSameAs( wxT("xpm"), false ) ) in_type = wxBITMAP_TYPE_XPM; | 198 else if ( ext.IsSameAs( wxT("xpm"), false ) ) in_type = wxBITMAP_TYPE_XPM; |
201 else { | 204 else { |
202 WarnMessage( wxT("Input file type is not supported !") ); | 205 WarnMessage( wxT("Input file type is not supported !") ); |
203 return false; | 206 return false; |
204 } | 207 } |
205 | 208 |
206 int out_type = in_type; | 209 wxBitmapType out_type = in_type; |
207 if ( choice_type == 1 ) { | 210 if ( choice_type == 1 ) { |
208 out_type = wxBITMAP_TYPE_PNG; | 211 out_type = wxBITMAP_TYPE_PNG; |
209 ext = wxT("png"); | 212 ext = wxT("png"); |
210 } | 213 } |
211 else if ( choice_type == 2 ) { | 214 else if ( choice_type == 2 ) { |
229 ext = wxT("tiff"); | 232 ext = wxT("tiff"); |
230 } | 233 } |
231 else if ( choice_type == 7 ) { | 234 else if ( choice_type == 7 ) { |
232 out_type = wxBITMAP_TYPE_JPEG; | 235 out_type = wxBITMAP_TYPE_JPEG; |
233 ext = wxT("jpg"); | 236 ext = wxT("jpg"); |
237 } | |
238 else if ( choice_type == 8 ) { | |
239 // SVG | |
234 } | 240 } |
235 | 241 |
236 wxImage image( file, in_type ); | 242 wxImage image( file, in_type ); |
237 if ( w == 0 || h == 0 ) { | 243 if ( w == 0 || h == 0 ) { |
238 w = (long)(image.GetWidth()); | 244 w = (long)(image.GetWidth()); |
257 if ( out_dir.IsSameAs( dn.GetPath() ) ) { | 263 if ( out_dir.IsSameAs( dn.GetPath() ) ) { |
258 WarnMessage( wxT("Output directory is same as input directory !") ); | 264 WarnMessage( wxT("Output directory is same as input directory !") ); |
259 return false; | 265 return false; |
260 } | 266 } |
261 | 267 |
262 int out_type = wxBITMAP_TYPE_INVALID; | 268 wxBitmapType out_type = wxBITMAP_TYPE_INVALID; |
263 wxString out_ext; | 269 wxString out_ext; |
264 if ( choice_type == 1 ) { | 270 if ( choice_type == 1 ) { |
265 out_type = wxBITMAP_TYPE_PNG; | 271 out_type = wxBITMAP_TYPE_PNG; |
266 out_ext = wxT("png"); | 272 out_ext = wxT("png"); |
267 } | 273 } |
287 } | 293 } |
288 else if ( choice_type == 7 ) { | 294 else if ( choice_type == 7 ) { |
289 out_type = wxBITMAP_TYPE_JPEG; | 295 out_type = wxBITMAP_TYPE_JPEG; |
290 out_ext = wxT("jpg"); | 296 out_ext = wxT("jpg"); |
291 } | 297 } |
298 else if ( choice_type == 8 ) { | |
299 // SVG | |
300 } | |
292 | 301 |
293 wxArrayString files; | 302 wxArrayString files; |
294 wxDir::GetAllFiles( dir, &files, wxT("*.*"), wxDIR_DEFAULT ); | 303 wxDir::GetAllFiles( dir, &files, wxT("*.*"), wxDIR_DEFAULT ); |
295 | 304 |
296 for ( long i = 0; i < files.GetCount(); i++ ) { | 305 for ( long i = 0; i < files.GetCount(); i++ ) { |
297 | 306 |
298 wxFileName fn( files[i] ); | 307 wxFileName fn( files[i] ); |
299 wxString in_ext = fn.GetExt(); | 308 wxString in_ext = fn.GetExt(); |
300 int in_type; | 309 wxBitmapType in_type; |
301 | 310 |
302 if ( in_ext.IsSameAs( wxT("jpg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; | 311 if ( in_ext.IsSameAs( wxT("jpg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; |
303 else if ( in_ext.IsSameAs( wxT("jpeg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; | 312 else if ( in_ext.IsSameAs( wxT("jpeg"), false ) ) in_type = wxBITMAP_TYPE_JPEG; |
304 else if ( in_ext.IsSameAs( wxT("png"), false ) ) in_type = wxBITMAP_TYPE_PNG; | 313 else if ( in_ext.IsSameAs( wxT("png"), false ) ) in_type = wxBITMAP_TYPE_PNG; |
305 else if ( in_ext.IsSameAs( wxT("xpm"), false ) ) in_type = wxBITMAP_TYPE_XPM; | 314 else if ( in_ext.IsSameAs( wxT("xpm"), false ) ) in_type = wxBITMAP_TYPE_XPM; |