Mercurial > mercurial > hgweb_imcv.cgi
diff myframe.cpp @ 4:3fadcf124bb4
add Percent.
author | pyon@macmini |
---|---|
date | Tue, 05 Jun 2018 22:09:21 +0900 |
parents | cc1f1fa544a4 |
children | cb33c4b9ea23 |
line wrap: on
line diff
--- a/myframe.cpp Sun Nov 27 20:15:37 2016 +0900 +++ b/myframe.cpp Tue Jun 05 22:09:21 2018 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 2016-11-27 Sun 20:08:02. +// Last Change: 2018-06-05 Tue 22:08:14. // #include "myframe.h" @@ -10,8 +10,7 @@ : wxFrame( parent, id, title, pos, size, style ) { this->SetIcon( wxIcon( wxT("sample") ) ); - //this->SetSizeHints( wxSize( 450, 200 ), wxSize( 450, 200 ) ); - this->SetSizeHints( wxSize( 550, 200 ), wxSize( 550, 200 ) ); + this->SetSizeHints( wxSize( 700, 200 ), wxSize( 700, 200 ) ); this->SetBackgroundColour( *wxBLACK ); wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); @@ -63,23 +62,30 @@ m_staticTextSize->SetBackgroundColour( *wxBLACK ); bSizerConfig->Add( m_staticTextSize, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_staticTextWidth = new wxStaticText( this, wxID_ANY, wxT("Width"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextWidth->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); m_staticTextWidth->SetBackgroundColour( *wxBLACK ); bSizerConfig->Add( m_staticTextWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_CENTRE ); - m_staticTextWidth->SetBackgroundColour( *wxBLACK ); + m_textCtrlWidth = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); bSizerConfig->Add( m_textCtrlWidth, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_staticTextHeight = new wxStaticText( this, wxID_ANY, wxT("Height"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextHeight->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); m_staticTextHeight->SetBackgroundColour( *wxBLACK ); bSizerConfig->Add( m_staticTextHeight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_CENTRE ); + m_textCtrlHeight = new wxTextCtrl( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxSize( 50, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); bSizerConfig->Add( m_textCtrlHeight, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - + + m_staticTextPercent = new wxStaticText( this, wxID_ANY, wxT("Percent"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPercent->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); + m_staticTextPercent->SetBackgroundColour( *wxBLACK ); + bSizerConfig->Add( m_staticTextPercent, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_textCtrlPercent = new wxTextCtrl( this, wxID_ANY, wxT("100"), wxDefaultPosition, wxSize( 40, -1 ), wxTE_RIGHT|wxTAB_TRAVERSAL ); + bSizerConfig->Add( m_textCtrlPercent, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerTop->Add( bSizerConfig, 1, wxEXPAND, 5 ); // Output @@ -147,7 +153,10 @@ buf = m_textCtrlHeight->GetValue(); buf.ToLong( &h, 10 ); - if ( choice_type == 0 && w == 0 && h == 0 ) { + buf = m_textCtrlPercent->GetValue(); + buf.ToLong( &s, 10 ); + + if ( choice_type == 0 && w == 0 && h == 0 && s == 100 ) { WarnMessage( wxT("no change !") ); return; } @@ -240,9 +249,14 @@ } wxImage image( file, in_type ); - if ( w == 0 || h == 0 ) { - w = (long)(image.GetWidth()); - h = (long)(image.GetHeight()); + if ( s == 100 ) { + if ( w == 0 || h == 0 ) { + w = (long)(image.GetWidth()); + h = (long)(image.GetHeight()); + } + } else { + w = (long)(image.GetWidth() * s / 100 ); + h = (long)(image.GetHeight() * s / 100 ); } wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); wxString outfile = out_dir + wxFILE_SEP_PATH + name + wxT(".") + ext; @@ -330,9 +344,14 @@ if ( !tf.Exists() ) tf.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); wxImage image( files[i], in_type ); - if ( w == 0 || h == 0 ) { - w = (long)(image.GetWidth()); - h = (long)(image.GetHeight()); + if ( s == 100 ) { + if ( w == 0 || h == 0 ) { + w = (long)(image.GetWidth()); + h = (long)(image.GetHeight()); + } + } else { + w = (long)(image.GetWidth() * s / 100 ); + h = (long)(image.GetHeight() * s / 100 ); } wxImage output = image.Scale( (int)w, (int)h, wxIMAGE_QUALITY_HIGH ); output.SaveFile( fullpath, out_type );