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