0
|
1 // Filename : myframe.cpp
|
|
2 // Last Change: 15-Oct-2011.
|
|
3 //
|
|
4
|
|
5 #include "main.h"
|
|
6 #include "myframe.h"
|
1
|
7 #include "marksheet.h"
|
0
|
8
|
|
9 //////////////////////////////////////////////////////////////////////////
|
|
10 // frame constructor
|
|
11 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
|
12 {
|
|
13 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
|
14 // set the frame icon
|
|
15 //SetIcon(wxICON(sample));
|
|
16
|
|
17 // メニューバー
|
|
18 m_menubarFile = new wxMenuBar();
|
|
19 m_menuFile = new wxMenu();
|
|
20 wxMenuItem* m_menuItemParam;
|
|
21 m_menuItemParam = new wxMenuItem( m_menuFile, ID_MENUITEMPARAM, wxString( wxT("パラメータ(&P)") ) , wxEmptyString, wxITEM_NORMAL );
|
|
22 m_menuFile->Append( m_menuItemParam );
|
|
23
|
|
24 wxMenuItem* m_menuItemAppDIr;
|
|
25 m_menuItemAppDIr = new wxMenuItem( m_menuFile, ID_MENUITEMAPPDIR, wxString( wxT("アプリフォルダを開く(&O)") ) , wxEmptyString, wxITEM_NORMAL );
|
|
26 m_menuFile->Append( m_menuItemAppDIr );
|
|
27
|
|
28 wxMenuItem* m_separator;
|
|
29 m_separator = m_menuFile->AppendSeparator(); // ----
|
|
30
|
|
31 wxMenuItem* m_menuItemQuit;
|
|
32 m_menuItemQuit = new wxMenuItem( m_menuFile, ID_MENUITEMQUIT, wxString( wxT("終了(&X)") ) , wxEmptyString, wxITEM_NORMAL );
|
|
33 m_menuFile->Append( m_menuItemQuit );
|
|
34
|
|
35 m_menubarFile->Append( m_menuFile, wxT("ファイル(&F)") );
|
|
36
|
|
37 this->SetMenuBar( m_menubarFile );
|
|
38
|
|
39 // コントロール
|
|
40 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
41
|
|
42 wxBoxSizer* bSizerFrom = new wxBoxSizer( wxHORIZONTAL );
|
|
43
|
|
44 m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
45 bSizerFrom->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
46
|
|
47 m_dirPickerWork = new wxDirPickerCtrl( this, wxID_ANY, wxGetApp().workdir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
|
|
48 bSizerFrom->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
49
|
|
50 bSizerTop->Add( bSizerFrom, 0, wxEXPAND, 5 );
|
|
51
|
1
|
52 wxBoxSizer* bSizerDist = new wxBoxSizer( wxHORIZONTAL );
|
|
53
|
|
54 m_staticTextDist = new wxStaticText( this, wxID_ANY, wxT("保存フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
55 bSizerDist->Add( m_staticTextDist, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
56
|
|
57 m_textCtrlDist = new wxTextCtrl( this, ID_TEXTCTRLDIST, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
58 m_textCtrlDist->SetMaxLength( 15 );
|
|
59 bSizerDist->Add( m_textCtrlDist, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
60 bSizerDist->Add( 0, 0, 1, wxEXPAND, 5 );
|
0
|
61
|
|
62 m_staticTextDrive = new wxStaticText( this, wxID_ANY, wxT("ドライブ"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
63 bSizerDist->Add( m_staticTextDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
64
|
|
65 wxArrayString drives;
|
|
66 drives.Add(wxT("C:"));
|
|
67 drives.Add(wxT("Y:"));
|
|
68 drives.Add(wxT("Z:"));
|
|
69 m_comboBoxDrive = new wxComboBox( this, wxID_ANY, wxT("C:"), wxDefaultPosition, wxSize(50,-1), drives, 0 );
|
1
|
70 bSizerDist->Add( m_comboBoxDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
71
|
|
72 m_staticTextDate = new wxStaticText( this, wxID_ANY, wxT("開催日"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
73 bSizerDist->Add( m_staticTextDate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
74
|
|
75 m_datePicker = new wxDatePickerCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN );
|
1
|
76 bSizerDist->Add( m_datePicker, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
77
|
|
78 m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT("合議体"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
79 bSizerDist->Add( m_staticTextCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
80
|
|
81 wxArrayString ccns;
|
|
82 ccns.Add(wxT("角館1")); ccns.Add(wxT("角館2")); ccns.Add(wxT("角館3")); ccns.Add(wxT("角館4"));
|
|
83 ccns.Add(wxT("西仙1")); ccns.Add(wxT("西仙2")); ccns.Add(wxT("西仙3"));
|
|
84 ccns.Add(wxT("千畑1")); ccns.Add(wxT("千畑2")); ccns.Add(wxT("千畑3"));
|
|
85 ccns.Add(wxT("大曲1")); ccns.Add(wxT("大曲2")); ccns.Add(wxT("大曲3")); ccns.Add(wxT("大曲4")); ccns.Add(wxT("大曲5")); ccns.Add(wxT("大曲6"));
|
|
86 ccns.Add(wxT("六郷1")); ccns.Add(wxT("六郷2")); ccns.Add(wxT("六郷3"));
|
|
87 m_comboBoxCcn = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100,-1), ccns, 0 );
|
1
|
88 bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 );
|
0
|
89
|
|
90 m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
91 bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 );
|
0
|
92
|
|
93
|
|
94 bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 );
|
|
95
|
|
96 wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL );
|
|
97
|
|
98 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL );
|
|
99
|
|
100 m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
101 bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 );
|
|
102 m_bitmapName = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(320,95), 0 );
|
0
|
103 bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 );
|
|
104
|
|
105 m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
106 bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 );
|
|
107 m_bitmapHHsno = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(320,54), 0 );
|
0
|
108 bSizerGuess->Add( m_bitmapHHsno, 0, wxALL, 5 );
|
|
109
|
|
110 m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
111 bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 );
|
0
|
112 m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
113 m_textCtrlGuess->SetMaxLength( 10 );
|
|
114 bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 );
|
|
115
|
|
116 bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 );
|
|
117
|
|
118 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
|
1
|
119 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY"));
|
0
|
120 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 );
|
1
|
121 m_imageList = new wxImageList( 189, 267 );
|
0
|
122 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
|
|
123
|
|
124 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL );
|
|
125
|
1
|
126 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
127 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 );
|
0
|
128 m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
129 bSizerButton->Add( m_buttonMove, 0, wxALL, 5 );
|
1
|
130 m_buttonMD = new wxButton( this, ID_BUTTONMD, wxT("移動&検知"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
131 bSizerButton->Add( m_buttonMD, 0, wxALL, 5 );
|
0
|
132 m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
133 bSizerButton->Add( m_buttonDel, 0, wxALL, 5 );
|
|
134 m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
135 bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 );
|
|
136
|
|
137 bSizerManip->Add( bSizerButton, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
|
138
|
|
139 bSizerTop->Add( bSizerManip, 1, wxEXPAND, 5 );
|
|
140
|
|
141 this->SetSizer( bSizerTop );
|
|
142 this->Layout();
|
|
143
|
|
144 // ステータスバー
|
1
|
145 int widths[] = { -1, 150, 200, 120 };
|
0
|
146 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP );
|
|
147 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths );
|
|
148 m_statusBar->SetStatusText( wxEmptyString, 0 );
|
|
149
|
|
150 this->Centre( wxBOTH );
|
|
151 }
|
|
152
|
|
153 // destructor
|
|
154 MyFrame::~MyFrame()
|
|
155 {
|
|
156 }
|
|
157
|
|
158 // Event Table
|
|
159 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
|
1
|
160 EVT_SIZE( MyFrame::OnWinSize )
|
|
161 EVT_MOVE( MyFrame::OnWinMove )
|
|
162 EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam )
|
|
163 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir )
|
|
164 EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
|
|
165 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect )
|
|
166 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove )
|
|
167 EVT_BUTTON( ID_BUTTONMD, MyFrame::OnMoveAndDetect )
|
|
168 //EVT_BUTTON( ID_BUTTONDEL, MyFrame::Delete )
|
|
169 //EVT_BUTTON( ID_BUTTONUNDO, MyFrame::Undo )
|
|
170 //EVT_LIST_ITEM_MIDDLE_CLICK( ID_LISTCTRLVIEW, MyFrame::ToggleSelect )
|
|
171 EVT_LIST_ITEM_RIGHT_CLICK( ID_LISTCTRLVIEW, MyFrame::ToggleSelect )
|
|
172 //EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir )
|
0
|
173 EVT_CLOSE( MyFrame::SaveConfig )
|
|
174 END_EVENT_TABLE()
|
|
175
|
|
176 // Event Handlers
|
|
177 /* 移動先フォルダ作成 */
|
|
178 void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event))
|
|
179 {
|
1
|
180 wxString to;
|
|
181 to.Append( m_comboBoxDrive->GetValue() );
|
|
182 to.Append( wxFILE_SEP_PATH );
|
|
183 wxDateTime dt = m_datePicker->GetValue();
|
|
184 to.Append( dt.Format(wxT("%Y%m%d")) );
|
|
185 to.Append( wxFILE_SEP_PATH );
|
|
186 to.Append( m_comboBoxCcn->GetValue() );
|
|
187 m_textCtrlDist->SetValue( to );
|
|
188
|
0
|
189 wxString ccn = m_comboBoxCcn->GetValue();
|
1
|
190 if ( to.Len() < 15 || ccn.IsEmpty() ) {
|
0
|
191 wxMessageBox(wxT("フォルダを指定してください."));
|
|
192 return;
|
|
193 }
|
|
194
|
1
|
195 wxStringTokenizer tkz( to, wxFILE_SEP_PATH );
|
0
|
196 wxString d;
|
|
197 while ( tkz.HasMoreTokens() ) {
|
|
198 d.Append( tkz.GetNextToken() );
|
|
199 d.Append( wxFILE_SEP_PATH );
|
|
200 if ( !wxDirExists( d ) ) wxMkdir( d );
|
|
201 }
|
|
202
|
|
203 wxMessageBox(wxT("移動先フォルダ準備完了"));
|
1
|
204 wxString cmd = wxT("explorer ") + to;
|
0
|
205 wxExecute( cmd );
|
|
206 }
|
|
207
|
1
|
208 /* 移動 */
|
|
209 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event))
|
|
210 {
|
|
211 MoveImage();
|
|
212 }
|
|
213 /* 検知 */
|
|
214 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event))
|
|
215 {
|
|
216 ReadyImage();
|
|
217 }
|
|
218 /* 移動し検知 */
|
|
219 void MyFrame::OnMoveAndDetect(wxCommandEvent& WXUNUSED(event))
|
0
|
220 {
|
|
221 MoveImage();
|
|
222 ReadyImage();
|
|
223 }
|
|
224
|
|
225 /* 画像をリストコントロールに表示 */
|
|
226 void MyFrame::ReadyImage()
|
|
227 {
|
|
228 wxString workdir = m_dirPickerWork->GetPath();
|
|
229 wxDir dir( workdir );
|
|
230 if ( !dir.IsOpened() ) return;
|
|
231
|
|
232 wxString filename;
|
|
233 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES );
|
|
234
|
|
235 int i = 0;
|
|
236 m_listCtrlView->DeleteAllItems();
|
|
237 m_imageList->RemoveAll();
|
|
238 wxListItem item;
|
1
|
239 wxString first;
|
|
240 float b; long l;
|
0
|
241 while ( cout ) {
|
|
242 if ( i > 7 ) break;
|
|
243
|
|
244 wxString imagefile = workdir + wxFILE_SEP_PATH + filename;
|
1
|
245 if ( i == 0 ) {
|
|
246 IsMarksheet( imagefile, &b, &l );
|
|
247 first = imagefile;
|
|
248 SetStatusText( wxString::Format(wxT("z = %f, l = %d"),b,l), 2 );
|
|
249 }
|
|
250 if ( i > 1 && IsMarksheet( imagefile, &b, &l ) ) cout = false;
|
0
|
251
|
|
252 item.SetId(i);
|
|
253 item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE);
|
|
254 item.SetStateMask(wxLIST_STATE_SELECTED);
|
|
255 item.SetState(wxLIST_STATE_SELECTED);
|
|
256 item.SetImage(i);
|
|
257 item.SetText(filename);
|
|
258 m_listCtrlView->InsertItem( item );
|
|
259 m_listCtrlView->SetItem( item );
|
|
260
|
1
|
261 wxImage image( imagefile, wxBITMAP_TYPE_JPEG );
|
|
262 wxBitmap bmp( image.Scale( 189, 267, wxIMAGE_QUALITY_HIGH ) );
|
0
|
263 m_imageList->Add( bmp );
|
|
264 // write log
|
|
265 i++;
|
|
266 cout = dir.GetNext( &filename );
|
|
267 }
|
1
|
268
|
|
269 wxImage marksheet( first, wxBITMAP_TYPE_JPEG );
|
|
270 wxImage name_image;
|
|
271 name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) );
|
|
272 wxBitmap name_bmp = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) );
|
|
273 m_bitmapName->SetBitmap( name_bmp );
|
|
274
|
|
275 wxImage hhsno_image;
|
|
276 hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) );
|
|
277 wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) );
|
|
278 m_bitmapHHsno->SetBitmap( hhsno_bmp );
|
|
279
|
|
280 wxString hhsno = GuessHhs( first );
|
|
281 m_textCtrlGuess->SetValue( hhsno );
|
0
|
282 }
|
|
283
|
|
284 /* 画像移動 */
|
|
285 void MyFrame::MoveImage()
|
|
286 {
|
|
287 wxString distdir = m_textCtrlDist->GetValue();
|
|
288 wxString ccn = m_comboBoxCcn->GetValue();
|
|
289 if ( distdir.IsEmpty() || ccn.IsEmpty() ) {
|
|
290 wxMessageBox(wxT("フォルダを指定してください."));
|
|
291 return;
|
|
292 }
|
|
293
|
|
294 distdir.Append( wxFILE_SEP_PATH );
|
|
295 if ( !wxDirExists( distdir ) ) {
|
|
296 wxMessageBox(wxT("フォルダが存在しません."));
|
|
297 return;
|
|
298 }
|
|
299
|
|
300 /*
|
|
301 wxString to = distdir + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename;
|
|
302 wxRenameFile( from, to, false );
|
|
303 */
|
|
304 }
|
|
305
|
1
|
306 /* 画像を選択 */
|
|
307 void MyFrame::ToggleSelect(wxListEvent& event)
|
|
308 {
|
|
309 }
|
|
310
|
|
311 /* パラメータダイアログ */
|
|
312 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event))
|
|
313 {
|
|
314 }
|
|
315
|
0
|
316 // 以下,定型もの
|
|
317 /* アプリフォルダを開く */
|
|
318 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event))
|
|
319 {
|
|
320 wxString appdir = m_dirPickerWork->GetPath();
|
|
321 wxString execmd = wxT("explorer ") + appdir;
|
|
322 wxExecute( execmd );
|
|
323 }
|
|
324
|
|
325 /* サイズ変更 */
|
1
|
326 void MyFrame::OnWinSize(wxSizeEvent& event)
|
0
|
327 {
|
|
328 this->Refresh( true, NULL );
|
|
329 TellLocation();
|
|
330 event.Skip();
|
|
331 }
|
|
332 /* ウィンドウ移動 */
|
1
|
333 void MyFrame::OnWinMove(wxMoveEvent& WXUNUSED(event))
|
0
|
334 {
|
|
335 TellLocation();
|
|
336 return;
|
|
337 }
|
|
338 /* ウィンドウ位置とサイズを表示 */
|
|
339 void MyFrame::TellLocation( void )
|
|
340 {
|
|
341 wxRect r = this->GetRect();
|
|
342 int x = r.GetX();
|
|
343 int y = r.GetY();
|
|
344 int w = r.GetWidth();
|
|
345 int h = r.GetHeight();
|
1
|
346 SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 );
|
0
|
347 }
|
|
348 /* 終了 */
|
|
349 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
350 {
|
|
351 Close(true);
|
|
352 }
|
|
353 /* 設定を保存 */
|
|
354 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event))
|
|
355 {
|
|
356 if ( !IsIconized() && !IsMaximized() ) {
|
|
357 wxGetApp().rect = this->GetRect();
|
|
358 }
|
|
359 wxGetApp().workdir = m_dirPickerWork->GetPath();
|
|
360
|
|
361 Destroy();
|
|
362 }
|
|
363
|