Mercurial > mercurial > hgweb_mover2.cgi
comparison src/myframe.cpp @ 23:a2dd16b70c08 v2.2dev
apply vivid-coloured image for selected item.
| author | pyon@macmini |
|---|---|
| date | Tue, 01 Nov 2011 22:26:41 +0900 |
| parents | c540dc3eabe5 |
| children | 5c99c6fa50df |
comparison
equal
deleted
inserted
replaced
| 22:4432aba77d6b | 23:a2dd16b70c08 |
|---|---|
| 1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
| 2 // Last Change: 26-Oct-2011. | 2 // Last Change: 01-Nov-2011. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "main.h" | 5 #include "main.h" |
| 6 #include "myframe.h" | 6 #include "myframe.h" |
| 7 #include "param.h" | 7 #include "param.h" |
| 198 EVT_SIZE( MyFrame::OnWinSize ) | 198 EVT_SIZE( MyFrame::OnWinSize ) |
| 199 EVT_MOVE( MyFrame::OnWinMove ) | 199 EVT_MOVE( MyFrame::OnWinMove ) |
| 200 EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam ) | 200 EVT_MENU( ID_MENUITEMPARAM, MyFrame::OnParam ) |
| 201 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) | 201 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) |
| 202 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 202 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
| 203 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo ) | 203 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemSelected ) |
| 204 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) | 204 EVT_LIST_ITEM_DESELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemDeselected ) |
| 205 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) | |
| 205 EVT_BUTTON( ID_BUTTONNEXTTHU, MyFrame::OnNextThursday ) | 206 EVT_BUTTON( ID_BUTTONNEXTTHU, MyFrame::OnNextThursday ) |
| 206 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir ) | 207 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir ) |
| 207 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) | 208 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) |
| 208 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) | 209 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) |
| 209 EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete ) | 210 EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete ) |
| 337 | 338 |
| 338 // 本処理 | 339 // 本処理 |
| 339 m_listCtrlView->DeleteAllItems(); | 340 m_listCtrlView->DeleteAllItems(); |
| 340 m_imageList->RemoveAll(); | 341 m_imageList->RemoveAll(); |
| 341 wxListItem item; | 342 wxListItem item; |
| 343 | |
| 342 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | 344 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); |
| 343 pd.SetSize( wxSize(320,140) ); | 345 pd.SetSize( wxSize(320,140) ); |
| 344 | 346 |
| 345 wxArrayString keys; | 347 wxArrayString keys; |
| 346 for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) { | 348 for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) { |
| 347 keys.Add(it->first); | 349 keys.Add(it->first); |
| 348 } | 350 } |
| 349 bool select = true; | |
| 350 keys.Sort(); | 351 keys.Sort(); |
| 352 // イメージリストを作成 | |
| 353 for ( int i=0; i<keys.GetCount(); i++ ) { // item image | |
| 354 CacheItem* ci = new CacheItem; | |
| 355 ci = CH[keys[i]]; | |
| 356 m_imageList->Add( ci->thumbnail ); | |
| 357 } | |
| 358 for ( int i=0; i<keys.GetCount(); i++ ) { // item selected image | |
| 359 CacheItem* ci = new CacheItem; | |
| 360 ci = CH[keys[i]]; | |
| 361 m_imageList->Add( ci->selthumbnail ); | |
| 362 } | |
| 363 // アイテム作成 | |
| 364 bool select = true; // flag | |
| 351 for ( int i=0; i<keys.GetCount(); i++ ) { | 365 for ( int i=0; i<keys.GetCount(); i++ ) { |
| 352 CacheItem* ci = new CacheItem; | 366 CacheItem* ci = new CacheItem; |
| 353 ci = CH[keys[i]]; | 367 ci = CH[keys[i]]; |
| 354 m_listCtrlView->InsertItem( i, ci->filename ); | 368 m_listCtrlView->InsertItem( i, ci->filename, i ); |
| 355 m_listCtrlView->SetItem( i, 0, ci->filename, i ); | 369 m_listCtrlView->SetItem( i, 0, ci->filename, i ); |
| 356 m_imageList->Add( ci->thumbnail ); | |
| 357 | 370 |
| 358 if ( i == 0 ) { // 1枚目はマークシートのはず | 371 if ( i == 0 ) { // 1枚目はマークシートのはず |
| 359 wxImage marksheet( ci->fullpath, wxBITMAP_TYPE_JPEG ); | 372 wxImage marksheet( ci->fullpath, wxBITMAP_TYPE_JPEG ); |
| 360 | 373 |
| 361 wxImage name_image; | 374 wxImage name_image; |
| 379 } | 392 } |
| 380 | 393 |
| 381 pd.Update( i+1, wxT("画像認識中") ); | 394 pd.Update( i+1, wxT("画像認識中") ); |
| 382 } | 395 } |
| 383 | 396 |
| 397 // 選択したものは青い画像を使う | |
| 398 long i = -1; | |
| 399 for ( ;; ) { | |
| 400 i = m_listCtrlView->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); | |
| 401 if ( i == -1 ) break; | |
| 402 m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() ); | |
| 403 } | |
| 404 | |
| 384 SetStatusText( wxEmptyString, 2 ); | 405 SetStatusText( wxEmptyString, 2 ); |
| 385 } | 406 } |
| 386 | 407 |
| 387 /* 画像を選択 */ | 408 /* 画像を選択したとき画像の情報をステータスバーに表示 */ |
| 388 void MyFrame::GetImageInfo(wxListEvent& event) | 409 void MyFrame::OnItemSelected(wxListEvent& event) |
| 389 { | 410 { |
| 411 int i = event.GetIndex(); | |
| 412 m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() ); // 青い画像 | |
| 413 | |
| 390 if ( m_listCtrlView->GetSelectedItemCount() != 1 ) return; | 414 if ( m_listCtrlView->GetSelectedItemCount() != 1 ) return; |
| 391 | |
| 392 SetStatusText( wxEmptyString, 2 ); | 415 SetStatusText( wxEmptyString, 2 ); |
| 393 int i = event.GetIndex(); | |
| 394 | 416 |
| 395 wxString filename = event.GetText(); | 417 wxString filename = event.GetText(); |
| 396 CacheItem* ci = new CacheItem; | 418 CacheItem* ci = new CacheItem; |
| 397 ci = CH[filename]; | 419 ci = CH[filename]; |
| 398 wxString msg; | 420 wxString msg; |
| 399 if ( ci->marksheet ) msg = wxT("perhaps marksheet !"); | 421 if ( ci->marksheet ) msg = wxT("perhaps marksheet !"); |
| 400 SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, ci->z, ci->l ), 2 ); | 422 SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, ci->z, ci->l ), 2 ); |
| 423 } | |
| 424 void MyFrame::OnItemDeselected(wxListEvent& event) | |
| 425 { | |
| 426 int i = event.GetIndex(); | |
| 427 m_listCtrlView->SetItemImage( i, i ); | |
| 401 } | 428 } |
| 402 | 429 |
| 403 /* 画像のスクリーン表示*/ | 430 /* 画像のスクリーン表示*/ |
| 404 void MyFrame::ViewLarge(wxListEvent& event) | 431 void MyFrame::ViewLarge(wxListEvent& event) |
| 405 { | 432 { |
| 466 continue; | 493 continue; |
| 467 } | 494 } |
| 468 /* 新しいファイルはキャッシュ */ | 495 /* 新しいファイルはキャッシュ */ |
| 469 float z; long l; bool m = IsMarksheet( fullpath, &z, &l ); | 496 float z; long l; bool m = IsMarksheet( fullpath, &z, &l ); |
| 470 wxImage image( fullpath, wxBITMAP_TYPE_JPEG ); | 497 wxImage image( fullpath, wxBITMAP_TYPE_JPEG ); |
| 471 wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) ); | 498 wxImage thumbnail = image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ); |
| 472 | 499 wxBitmap bmp( thumbnail ); |
| 473 ci->filename = file; | 500 unsigned char *data = thumbnail.GetData(); |
| 474 ci->fullpath = fullpath; | 501 for ( int y=0; y<226; y++ ) for ( int x=0; x<160; x++ ) data[(y*226+x)*3+2] = 255; // 文字色:黒(0,0,0)->青(0,0.255) |
| 475 ci->marksheet = m; | 502 wxBitmap bmp_mask( thumbnail ); |
| 476 ci->z = z; | 503 |
| 477 ci->l = l; | 504 ci->filename = file; |
| 478 ci->exists = true; | 505 ci->fullpath = fullpath; |
| 479 ci->thumbnail = bmp; | 506 ci->marksheet = m; |
| 480 ci->modtime = wxEmptyString; // TODO. | 507 ci->z = z; |
| 508 ci->l = l; | |
| 509 ci->exists = true; | |
| 510 ci->thumbnail = bmp; | |
| 511 ci->selthumbnail = bmp_mask; | |
| 512 ci->modtime = wxEmptyString; // TODO. | |
| 481 | 513 |
| 482 CH[ci->filename] = ci; // add hash | 514 CH[ci->filename] = ci; // add hash |
| 483 wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) ); | 515 wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) ); |
| 484 } | 516 } |
| 485 | 517 |
