Mercurial > mercurial > hgweb_mover.cgi
diff src/myframe.cpp @ 2:1ea4f7981ff5
create window.
author | pyon@macmini |
---|---|
date | Sun, 02 Oct 2011 18:44:03 +0900 |
parents | |
children | a5bddd859104 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/myframe.cpp Sun Oct 02 18:44:03 2011 +0900 @@ -0,0 +1,229 @@ +// Filename : mainframe.cpp +// Last Change: 02-Oct-2011. +// +#include "symbol.h" +#include "common.h" +#include "myframe.h" +#include "delwhite.h" +#include "main.h" + +// resources +// the application icon (under Windows and OS/2 it is in resources and even +// though we could still include the XPM here it would be unused) +#if !defined(__WXMSW__) && !defined(__WXPM__) + #include "sample.xpm" +#endif + +////////////////////////////////////////////////////////////////////////// +// control constructor + +// 検索履歴をログに保存 +/* +void MyCmdBox::WriteLog( wxString& cmd, wxString& path ) +{ + wxString logfn = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("log.txt"); + wxTextFile logFile; + logFile.Open( logfn ); + wxDateTime now = wxDateTime::Now(); + wxString log = now.Format( wxT("%Y-%m-%d %H:%M:%S") ) + wxT(" ") + cmd + wxT(" ") + path; + logFile.AddLine( log ); + logFile.Write(); + logFile.Close(); + + return; +} +*/ + +////////////////////////////////////////////////////////////////////////// +// frame constructor +MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title ) + : wxFrame( parent, id, title ) +{ + //this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + // set the frame icon + SetIcon(wxICON(sample)); + + // メニューバー + m_menubar = new wxMenuBar(); + + m_menuFile = new wxMenu(); + m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") ); + //m_menuFile->AppendSeparator(); //---- + m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") ); + + m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); + + this->SetMenuBar( m_menubar ); + + // ステータスバー + int widths[] = { -1, 150, 120 }; + m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP ); + m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); + m_statusBar->SetStatusText( wxEmptyString, 0 ); + + // コントロール + wxBoxSizer* bSizerTop; + bSizerTop = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerWork; + bSizerWork = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業用フォルダ"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerWork->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_dirPickerWork = new wxDirPickerCtrl( this, ID_WORKDIR, wxGetApp().dir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); + bSizerWork->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonDetWhite = new wxButton( this, ID_DTWHITE, wxT("白紙検知"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerWork->Add( m_buttonDetWhite, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizerTop->Add( bSizerWork, 0, wxEXPAND, 5 ); + + wxBoxSizer* bSizerMoveTo; + bSizerMoveTo = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextMoveTo = new wxStaticText( this, wxID_ANY, wxT("移動先フォルダ"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerMoveTo->Add( m_staticTextMoveTo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_comboBoxMoveDrive = new wxComboBox( this, ID_DRIVE, wxT("C:"), wxDefaultPosition, wxSize( 50,-1 ), 0, NULL, 0 ); + bSizerMoveTo->Add( m_comboBoxMoveDrive, 0, wxALL, 5 ); + + m_datePickerCcn = new wxDatePickerCtrl( this, ID_DATE, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); + bSizerMoveTo->Add( m_datePickerCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_comboBoxCcn = new wxComboBox( this, ID_CCN, wxT("1\n2\n3\n"), wxDefaultPosition, wxSize( 100,-1 ), 0, NULL, 0 ); + bSizerMoveTo->Add( m_comboBoxCcn, 0, wxALL, 5 ); + + bSizerMoveTo->Add( 0, 0, 0, 0, 5 ); + + m_buttonMkDir = new wxButton( this, ID_MKDIR, wxT("ファルダ作成"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerMoveTo->Add( m_buttonMkDir, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + bSizerTop->Add( bSizerMoveTo, 0, 0, 5 ); + + wxBoxSizer* bSizerDoMove; + bSizerDoMove = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextDummy = new wxStaticText( this, wxID_ANY, wxT("移動先ふぉるだ"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDummy->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + + bSizerDoMove->Add( m_staticTextDummy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_textCtrlMoveDir = new wxTextCtrl( this, ID_DIR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlMoveDir->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) ); + + bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonDoMove->Enable( false ); + + bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 ); + + m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); + bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); + + this->SetSizer( bSizerTop ); + this->Layout(); + + this->Centre( wxBOTH ); + //this->SetDefaultItem(m_buttonDetWhite); + m_buttonDetWhite->SetFocus(); +} + +// destructor +MyFrame::~MyFrame() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MyFrame, wxFrame ) + EVT_SIZE( MyFrame::OnSize ) + EVT_MOVE( MyFrame::OnMove ) + EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) + EVT_MENU( wxID_ABOUT, MyFrame::OnAbout ) + EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite ) + EVT_CLOSE( MyFrame::SaveConfig ) +END_EVENT_TABLE() + +// Event Handlers +/* サイズ変更 */ +void MyFrame::OnSize(wxSizeEvent& event) +{ + this->Refresh( true, NULL ); + TellLocation(); + event.Skip(); +} +/* ウィンドウ移動 */ +void MyFrame::OnMove(wxMoveEvent& WXUNUSED(event)) +{ + TellLocation(); + return; +} +/* ウィンドウ位置とサイズを表示 */ +void MyFrame::TellLocation( void ) +{ + wxRect r = this->GetRect(); + int x = r.GetX(); + int y = r.GetY(); + int w = r.GetWidth(); + int h = r.GetHeight(); + SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 2 ); +} +/* 終了 */ +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +{ + Close(true); +} + +/* バージョン情報 */ +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) +{ + wxMessageBox( + wxString::Format( + wxT("Version %d.%d ( build %d ) by %s\n") + wxT("running under %s."), + VER, REV, BLD, wxVERSION_STRING, + wxGetOsDescription().c_str() + ), + wxT("About this program"), wxOK | wxICON_INFORMATION, this ); +} + +/* 白紙検知 */ +void MyFrame::OnDetectWhite(wxCommandEvent& WXUNUSED(event)) +{ + FrameDelWhite* dw = new FrameDelWhite( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); + dw->SetMinSize( wxSize( 580, 680 ) ); + + dw->m_dir = m_dirPickerWork->GetPath(); + dw->SetTitle( wxT("Delete White Sheet - ") + dw->m_dir ); + dw->LoadImages(); + + dw->Show(true); +} + +/* アプリケーションフォルダを開く */ +/* +void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) +{ + wxStandardPaths appdir; + wxString execmd = wxT("explorer ") + appdir.GetDataDir(); + wxExecute( execmd ); + return; +} +*/ + + +/* 設定を保存 */ +void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event)) +{ + if ( !IsIconized() && !IsMaximized() ) { + wxGetApp().rect = this->GetRect(); + } + wxGetApp().dir = m_dirPickerWork->GetPath(); + + Destroy(); +} +