2
|
1 // Filename : mainframe.cpp
|
3
|
2 // Last Change: 03-Oct-2011.
|
2
|
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 {
|
3
|
42 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
2
|
43 // set the frame icon
|
|
44 SetIcon(wxICON(sample));
|
|
45
|
|
46 // メニューバー
|
|
47 m_menubar = new wxMenuBar();
|
|
48
|
|
49 m_menuFile = new wxMenu();
|
|
50 m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") );
|
|
51 //m_menuFile->AppendSeparator(); //----
|
|
52 m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") );
|
|
53
|
|
54 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") );
|
|
55
|
|
56 this->SetMenuBar( m_menubar );
|
|
57
|
|
58 // ステータスバー
|
|
59 int widths[] = { -1, 150, 120 };
|
|
60 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP );
|
|
61 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths );
|
|
62 m_statusBar->SetStatusText( wxEmptyString, 0 );
|
|
63
|
|
64 // コントロール
|
|
65 wxBoxSizer* bSizerTop;
|
|
66 bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
67
|
|
68 wxBoxSizer* bSizerWork;
|
|
69 bSizerWork = new wxBoxSizer( wxHORIZONTAL );
|
|
70
|
|
71 m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業用フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
72 bSizerWork->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
73
|
|
74 m_dirPickerWork = new wxDirPickerCtrl( this, ID_WORKDIR, wxGetApp().dir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
|
|
75 bSizerWork->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
76
|
|
77 m_buttonDetWhite = new wxButton( this, ID_DTWHITE, wxT("白紙検知"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
78 bSizerWork->Add( m_buttonDetWhite, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
79
|
|
80 bSizerTop->Add( bSizerWork, 0, wxEXPAND, 5 );
|
|
81
|
|
82 wxBoxSizer* bSizerMoveTo;
|
|
83 bSizerMoveTo = new wxBoxSizer( wxHORIZONTAL );
|
|
84
|
|
85 m_staticTextMoveTo = new wxStaticText( this, wxID_ANY, wxT("移動先フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
86 bSizerMoveTo->Add( m_staticTextMoveTo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
87
|
3
|
88 wxArrayString drives;
|
|
89 drives.Add(wxT("C:"));
|
|
90 drives.Add(wxT("Y:"));
|
|
91 drives.Add(wxT("Z:"));
|
|
92 m_comboBoxMoveDrive = new wxComboBox( this, ID_DRIVE, wxT("C:"), wxDefaultPosition, wxSize( 50,-1 ), drives, 0 );
|
|
93 bSizerMoveTo->Add( m_comboBoxMoveDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
2
|
94
|
3
|
95 m_datePickerCcn = new wxDatePickerCtrl( this, ID_DATE, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN );
|
2
|
96 bSizerMoveTo->Add( m_datePickerCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
97
|
3
|
98 wxArrayString ccns;
|
|
99 ccns.Add(wxT("角館1")); ccns.Add(wxT("角館2")); ccns.Add(wxT("角館3")); ccns.Add(wxT("角館4"));
|
|
100 ccns.Add(wxT("西仙1")); ccns.Add(wxT("西仙2")); ccns.Add(wxT("西仙3"));
|
|
101 ccns.Add(wxT("千畑1")); ccns.Add(wxT("千畑2")); ccns.Add(wxT("千畑3"));
|
|
102 ccns.Add(wxT("大曲1")); ccns.Add(wxT("大曲2")); ccns.Add(wxT("大曲3")); ccns.Add(wxT("大曲4")); ccns.Add(wxT("大曲5")); ccns.Add(wxT("大曲6"));
|
|
103 ccns.Add(wxT("六郷1")); ccns.Add(wxT("六郷2")); ccns.Add(wxT("六郷3"));
|
|
104 m_comboBoxCcn = new wxComboBox( this, ID_CCN, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), ccns, 0 );
|
|
105 bSizerMoveTo->Add( m_comboBoxCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
2
|
106
|
3
|
107 m_buttonSetDir = new wxButton( this, ID_STDIR, wxT("フォルダ指定"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
108 bSizerMoveTo->Add( m_buttonSetDir, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
|
109
|
|
110 m_buttonMkDir = new wxButton( this, ID_MKDIR, wxT("フォルダ作成"), wxDefaultPosition, wxDefaultSize, 0 );
|
2
|
111 bSizerMoveTo->Add( m_buttonMkDir, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
|
112
|
|
113 bSizerTop->Add( bSizerMoveTo, 0, 0, 5 );
|
|
114
|
|
115 wxBoxSizer* bSizerDoMove;
|
|
116 bSizerDoMove = new wxBoxSizer( wxHORIZONTAL );
|
|
117
|
|
118 m_staticTextDummy = new wxStaticText( this, wxID_ANY, wxT("移動先ふぉるだ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
119 m_staticTextDummy->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
|
|
120
|
|
121 bSizerDoMove->Add( m_staticTextDummy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
122
|
|
123 m_textCtrlMoveDir = new wxTextCtrl( this, ID_DIR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
124 m_textCtrlMoveDir->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) );
|
|
125
|
|
126 bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
127
|
|
128 m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
129 m_buttonDoMove->Enable( false );
|
|
130
|
|
131 bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
|
|
132
|
|
133 bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 );
|
|
134
|
|
135 m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
|
|
136 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
137
|
|
138 this->SetSizer( bSizerTop );
|
|
139 this->Layout();
|
|
140
|
|
141 this->Centre( wxBOTH );
|
|
142 //this->SetDefaultItem(m_buttonDetWhite);
|
|
143 m_buttonDetWhite->SetFocus();
|
|
144 }
|
|
145
|
|
146 // destructor
|
|
147 MyFrame::~MyFrame()
|
|
148 {
|
|
149 }
|
|
150
|
|
151 // Event Table
|
|
152 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
|
|
153 EVT_SIZE( MyFrame::OnSize )
|
|
154 EVT_MOVE( MyFrame::OnMove )
|
|
155 EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
|
|
156 EVT_MENU( wxID_ABOUT, MyFrame::OnAbout )
|
|
157 EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite )
|
3
|
158 EVT_BUTTON( ID_STDIR, MyFrame::SetDir )
|
|
159 EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir )
|
2
|
160 EVT_CLOSE( MyFrame::SaveConfig )
|
|
161 END_EVENT_TABLE()
|
|
162
|
|
163 // Event Handlers
|
|
164 /* サイズ変更 */
|
|
165 void MyFrame::OnSize(wxSizeEvent& event)
|
|
166 {
|
|
167 this->Refresh( true, NULL );
|
|
168 TellLocation();
|
|
169 event.Skip();
|
|
170 }
|
|
171 /* ウィンドウ移動 */
|
|
172 void MyFrame::OnMove(wxMoveEvent& WXUNUSED(event))
|
|
173 {
|
|
174 TellLocation();
|
|
175 return;
|
|
176 }
|
|
177 /* ウィンドウ位置とサイズを表示 */
|
|
178 void MyFrame::TellLocation( void )
|
|
179 {
|
|
180 wxRect r = this->GetRect();
|
|
181 int x = r.GetX();
|
|
182 int y = r.GetY();
|
|
183 int w = r.GetWidth();
|
|
184 int h = r.GetHeight();
|
|
185 SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 2 );
|
|
186 }
|
|
187 /* 終了 */
|
|
188 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
189 {
|
|
190 Close(true);
|
|
191 }
|
|
192
|
|
193 /* バージョン情報 */
|
|
194 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
195 {
|
|
196 wxMessageBox(
|
|
197 wxString::Format(
|
|
198 wxT("Version %d.%d ( build %d ) by %s\n")
|
|
199 wxT("running under %s."),
|
|
200 VER, REV, BLD, wxVERSION_STRING,
|
|
201 wxGetOsDescription().c_str()
|
|
202 ),
|
|
203 wxT("About this program"), wxOK | wxICON_INFORMATION, this );
|
|
204 }
|
|
205
|
|
206 /* 白紙検知 */
|
|
207 void MyFrame::OnDetectWhite(wxCommandEvent& WXUNUSED(event))
|
|
208 {
|
|
209 FrameDelWhite* dw = new FrameDelWhite( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
|
|
210 dw->SetMinSize( wxSize( 580, 680 ) );
|
|
211
|
|
212 dw->m_dir = m_dirPickerWork->GetPath();
|
|
213 dw->SetTitle( wxT("Delete White Sheet - ") + dw->m_dir );
|
|
214 dw->LoadImages();
|
|
215
|
|
216 dw->Show(true);
|
|
217 }
|
|
218
|
3
|
219 /* 移動先フォルダセット */
|
|
220 void MyFrame::SetDir(wxCommandEvent& WXUNUSED(event))
|
|
221 {
|
|
222 wxString dir;
|
|
223 dir.Append( m_comboBoxMoveDrive->GetValue() );
|
|
224 dir.Append( wxFILE_SEP_PATH );
|
|
225 wxDateTime dt = m_datePickerCcn->GetValue();
|
|
226 dir.Append( dt.Format(wxT("%Y%m%d")) );
|
|
227 dir.Append( wxFILE_SEP_PATH );
|
|
228 dir.Append( m_comboBoxCcn->GetValue() );
|
|
229 m_textCtrlMoveDir->SetValue( dir );
|
|
230 }
|
|
231
|
|
232 void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event))
|
|
233 {
|
|
234 }
|
|
235
|
2
|
236 /* アプリケーションフォルダを開く */
|
|
237 /*
|
|
238 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event))
|
|
239 {
|
|
240 wxStandardPaths appdir;
|
|
241 wxString execmd = wxT("explorer ") + appdir.GetDataDir();
|
|
242 wxExecute( execmd );
|
|
243 return;
|
|
244 }
|
|
245 */
|
|
246
|
|
247
|
|
248 /* 設定を保存 */
|
|
249 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event))
|
|
250 {
|
|
251 if ( !IsIconized() && !IsMaximized() ) {
|
|
252 wxGetApp().rect = this->GetRect();
|
|
253 }
|
|
254 wxGetApp().dir = m_dirPickerWork->GetPath();
|
|
255
|
|
256 Destroy();
|
|
257 }
|
|
258
|