Mercurial > mercurial > hgweb_mover.cgi
comparison src/myframe.cpp @ 2:1ea4f7981ff5
create window.
| author | pyon@macmini |
|---|---|
| date | Sun, 02 Oct 2011 18:44:03 +0900 |
| parents | |
| children | a5bddd859104 |
comparison
equal
deleted
inserted
replaced
| 1:214f2908b8e4 | 2:1ea4f7981ff5 |
|---|---|
| 1 // Filename : mainframe.cpp | |
| 2 // Last Change: 02-Oct-2011. | |
| 3 // | |
| 4 #include "symbol.h" | |
| 5 #include "common.h" | |
| 6 #include "myframe.h" | |
| 7 #include "delwhite.h" | |
| 8 #include "main.h" | |
| 9 | |
| 10 // resources | |
| 11 // the application icon (under Windows and OS/2 it is in resources and even | |
| 12 // though we could still include the XPM here it would be unused) | |
| 13 #if !defined(__WXMSW__) && !defined(__WXPM__) | |
| 14 #include "sample.xpm" | |
| 15 #endif | |
| 16 | |
| 17 ////////////////////////////////////////////////////////////////////////// | |
| 18 // control constructor | |
| 19 | |
| 20 // 検索履歴をログに保存 | |
| 21 /* | |
| 22 void MyCmdBox::WriteLog( wxString& cmd, wxString& path ) | |
| 23 { | |
| 24 wxString logfn = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("log.txt"); | |
| 25 wxTextFile logFile; | |
| 26 logFile.Open( logfn ); | |
| 27 wxDateTime now = wxDateTime::Now(); | |
| 28 wxString log = now.Format( wxT("%Y-%m-%d %H:%M:%S") ) + wxT(" ") + cmd + wxT(" ") + path; | |
| 29 logFile.AddLine( log ); | |
| 30 logFile.Write(); | |
| 31 logFile.Close(); | |
| 32 | |
| 33 return; | |
| 34 } | |
| 35 */ | |
| 36 | |
| 37 ////////////////////////////////////////////////////////////////////////// | |
| 38 // frame constructor | |
| 39 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title ) | |
| 40 : wxFrame( parent, id, title ) | |
| 41 { | |
| 42 //this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | |
| 43 this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); | |
| 44 // set the frame icon | |
| 45 SetIcon(wxICON(sample)); | |
| 46 | |
| 47 // メニューバー | |
| 48 m_menubar = new wxMenuBar(); | |
| 49 | |
| 50 m_menuFile = new wxMenu(); | |
| 51 m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") ); | |
| 52 //m_menuFile->AppendSeparator(); //---- | |
| 53 m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") ); | |
| 54 | |
| 55 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); | |
| 56 | |
| 57 this->SetMenuBar( m_menubar ); | |
| 58 | |
| 59 // ステータスバー | |
| 60 int widths[] = { -1, 150, 120 }; | |
| 61 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP ); | |
| 62 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); | |
| 63 m_statusBar->SetStatusText( wxEmptyString, 0 ); | |
| 64 | |
| 65 // コントロール | |
| 66 wxBoxSizer* bSizerTop; | |
| 67 bSizerTop = new wxBoxSizer( wxVERTICAL ); | |
| 68 | |
| 69 wxBoxSizer* bSizerWork; | |
| 70 bSizerWork = new wxBoxSizer( wxHORIZONTAL ); | |
| 71 | |
| 72 m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業用フォルダ"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 73 bSizerWork->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 74 | |
| 75 m_dirPickerWork = new wxDirPickerCtrl( this, ID_WORKDIR, wxGetApp().dir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); | |
| 76 bSizerWork->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 77 | |
| 78 m_buttonDetWhite = new wxButton( this, ID_DTWHITE, wxT("白紙検知"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 79 bSizerWork->Add( m_buttonDetWhite, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 80 | |
| 81 bSizerTop->Add( bSizerWork, 0, wxEXPAND, 5 ); | |
| 82 | |
| 83 wxBoxSizer* bSizerMoveTo; | |
| 84 bSizerMoveTo = new wxBoxSizer( wxHORIZONTAL ); | |
| 85 | |
| 86 m_staticTextMoveTo = new wxStaticText( this, wxID_ANY, wxT("移動先フォルダ"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 87 bSizerMoveTo->Add( m_staticTextMoveTo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 88 | |
| 89 m_comboBoxMoveDrive = new wxComboBox( this, ID_DRIVE, wxT("C:"), wxDefaultPosition, wxSize( 50,-1 ), 0, NULL, 0 ); | |
| 90 bSizerMoveTo->Add( m_comboBoxMoveDrive, 0, wxALL, 5 ); | |
| 91 | |
| 92 m_datePickerCcn = new wxDatePickerCtrl( this, ID_DATE, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); | |
| 93 bSizerMoveTo->Add( m_datePickerCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 94 | |
| 95 m_comboBoxCcn = new wxComboBox( this, ID_CCN, wxT("1\n2\n3\n"), wxDefaultPosition, wxSize( 100,-1 ), 0, NULL, 0 ); | |
| 96 bSizerMoveTo->Add( m_comboBoxCcn, 0, wxALL, 5 ); | |
| 97 | |
| 98 bSizerMoveTo->Add( 0, 0, 0, 0, 5 ); | |
| 99 | |
| 100 m_buttonMkDir = new wxButton( this, ID_MKDIR, wxT("ファルダ作成"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 101 bSizerMoveTo->Add( m_buttonMkDir, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
| 102 | |
| 103 bSizerTop->Add( bSizerMoveTo, 0, 0, 5 ); | |
| 104 | |
| 105 wxBoxSizer* bSizerDoMove; | |
| 106 bSizerDoMove = new wxBoxSizer( wxHORIZONTAL ); | |
| 107 | |
| 108 m_staticTextDummy = new wxStaticText( this, wxID_ANY, wxT("移動先ふぉるだ"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 109 m_staticTextDummy->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); | |
| 110 | |
| 111 bSizerDoMove->Add( m_staticTextDummy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 112 | |
| 113 m_textCtrlMoveDir = new wxTextCtrl( this, ID_DIR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | |
| 114 m_textCtrlMoveDir->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) ); | |
| 115 | |
| 116 bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 117 | |
| 118 m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 119 m_buttonDoMove->Enable( false ); | |
| 120 | |
| 121 bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 122 | |
| 123 bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 ); | |
| 124 | |
| 125 m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); | |
| 126 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); | |
| 127 | |
| 128 this->SetSizer( bSizerTop ); | |
| 129 this->Layout(); | |
| 130 | |
| 131 this->Centre( wxBOTH ); | |
| 132 //this->SetDefaultItem(m_buttonDetWhite); | |
| 133 m_buttonDetWhite->SetFocus(); | |
| 134 } | |
| 135 | |
| 136 // destructor | |
| 137 MyFrame::~MyFrame() | |
| 138 { | |
| 139 } | |
| 140 | |
| 141 // Event Table | |
| 142 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
| 143 EVT_SIZE( MyFrame::OnSize ) | |
| 144 EVT_MOVE( MyFrame::OnMove ) | |
| 145 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | |
| 146 EVT_MENU( wxID_ABOUT, MyFrame::OnAbout ) | |
| 147 EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite ) | |
| 148 EVT_CLOSE( MyFrame::SaveConfig ) | |
| 149 END_EVENT_TABLE() | |
| 150 | |
| 151 // Event Handlers | |
| 152 /* サイズ変更 */ | |
| 153 void MyFrame::OnSize(wxSizeEvent& event) | |
| 154 { | |
| 155 this->Refresh( true, NULL ); | |
| 156 TellLocation(); | |
| 157 event.Skip(); | |
| 158 } | |
| 159 /* ウィンドウ移動 */ | |
| 160 void MyFrame::OnMove(wxMoveEvent& WXUNUSED(event)) | |
| 161 { | |
| 162 TellLocation(); | |
| 163 return; | |
| 164 } | |
| 165 /* ウィンドウ位置とサイズを表示 */ | |
| 166 void MyFrame::TellLocation( void ) | |
| 167 { | |
| 168 wxRect r = this->GetRect(); | |
| 169 int x = r.GetX(); | |
| 170 int y = r.GetY(); | |
| 171 int w = r.GetWidth(); | |
| 172 int h = r.GetHeight(); | |
| 173 SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 2 ); | |
| 174 } | |
| 175 /* 終了 */ | |
| 176 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) | |
| 177 { | |
| 178 Close(true); | |
| 179 } | |
| 180 | |
| 181 /* バージョン情報 */ | |
| 182 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) | |
| 183 { | |
| 184 wxMessageBox( | |
| 185 wxString::Format( | |
| 186 wxT("Version %d.%d ( build %d ) by %s\n") | |
| 187 wxT("running under %s."), | |
| 188 VER, REV, BLD, wxVERSION_STRING, | |
| 189 wxGetOsDescription().c_str() | |
| 190 ), | |
| 191 wxT("About this program"), wxOK | wxICON_INFORMATION, this ); | |
| 192 } | |
| 193 | |
| 194 /* 白紙検知 */ | |
| 195 void MyFrame::OnDetectWhite(wxCommandEvent& WXUNUSED(event)) | |
| 196 { | |
| 197 FrameDelWhite* dw = new FrameDelWhite( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); | |
| 198 dw->SetMinSize( wxSize( 580, 680 ) ); | |
| 199 | |
| 200 dw->m_dir = m_dirPickerWork->GetPath(); | |
| 201 dw->SetTitle( wxT("Delete White Sheet - ") + dw->m_dir ); | |
| 202 dw->LoadImages(); | |
| 203 | |
| 204 dw->Show(true); | |
| 205 } | |
| 206 | |
| 207 /* アプリケーションフォルダを開く */ | |
| 208 /* | |
| 209 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) | |
| 210 { | |
| 211 wxStandardPaths appdir; | |
| 212 wxString execmd = wxT("explorer ") + appdir.GetDataDir(); | |
| 213 wxExecute( execmd ); | |
| 214 return; | |
| 215 } | |
| 216 */ | |
| 217 | |
| 218 | |
| 219 /* 設定を保存 */ | |
| 220 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event)) | |
| 221 { | |
| 222 if ( !IsIconized() && !IsMaximized() ) { | |
| 223 wxGetApp().rect = this->GetRect(); | |
| 224 } | |
| 225 wxGetApp().dir = m_dirPickerWork->GetPath(); | |
| 226 | |
| 227 Destroy(); | |
| 228 } | |
| 229 |
