changeset 23:a2dd16b70c08 v2.2dev

apply vivid-coloured image for selected item.
author pyon@macmini
date Tue, 01 Nov 2011 22:26:41 +0900
parents 4432aba77d6b
children 5c99c6fa50df
files TODO include/cache.h include/myframe.h src/myframe.cpp
diffstat 4 files changed, 61 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Mon Oct 31 21:05:22 2011 +0900
+++ b/TODO	Tue Nov 01 22:26:41 2011 +0900
@@ -5,13 +5,18 @@
 * ccn folder make
 * error check hhsno
 * hhs explore & file count
+* hhs name from db
 * auto cache rebuild off
 * color red if guess hhsno failed
 * help
+* building cache time
+* F5 detect
+* F7 move
 
 ----------------------------------------------------------------------
  Memo
 ----------------------------------------------------------------------
+shinseisho
 00000000XY
 X: omagari 0, nisisen 2, kakudate 3, senhata 4
 Y: 1..6
--- a/include/cache.h	Mon Oct 31 21:05:22 2011 +0900
+++ b/include/cache.h	Tue Nov 01 22:26:41 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : cache.h
-// Last Change: 23-Oct-2011.
+// Last Change: 01-Nov-2011.
 //
 #ifndef __cache__
 #define __cache__
@@ -14,6 +14,7 @@
     long     l;
     bool     marksheet;
     wxBitmap thumbnail;
+    wxBitmap selthumbnail;
     bool     exists;
 };
 
--- a/include/myframe.h	Mon Oct 31 21:05:22 2011 +0900
+++ b/include/myframe.h	Tue Nov 01 22:26:41 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.h
-// Last Change: 26-Oct-2011.
+// Last Change: 01-Nov-2011.
 //
 
 #ifndef __myframe__
@@ -58,7 +58,8 @@
         void OnParam(wxCommandEvent& event);
         void OnNextThursday(wxCommandEvent& event);
         void OnMakeDir(wxCommandEvent& event);
-        void GetImageInfo(wxListEvent& event);
+        void OnItemSelected(wxListEvent& event);
+        void OnItemDeselected(wxListEvent& event);
         void ViewLarge(wxListEvent& event);
         void OnDetect(wxCommandEvent& event);
         void OnMove(wxCommandEvent& event);
--- a/src/myframe.cpp	Mon Oct 31 21:05:22 2011 +0900
+++ b/src/myframe.cpp	Tue Nov 01 22:26:41 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.cpp
-// Last Change: 26-Oct-2011.
+// Last Change: 01-Nov-2011.
 //
 
 #include "main.h"
@@ -200,8 +200,9 @@
     EVT_MENU( ID_MENUITEMPARAM,   MyFrame::OnParam )
     EVT_MENU( ID_MENUITEMAPPDIR,  MyFrame::OnOpenAppDir )
     EVT_MENU( wxID_EXIT,          MyFrame::OnQuit )
-    EVT_LIST_ITEM_SELECTED(  ID_LISTCTRLVIEW, MyFrame::GetImageInfo )
-    EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge )
+    EVT_LIST_ITEM_SELECTED(   ID_LISTCTRLVIEW, MyFrame::OnItemSelected )
+    EVT_LIST_ITEM_DESELECTED( ID_LISTCTRLVIEW, MyFrame::OnItemDeselected )
+    EVT_LIST_ITEM_ACTIVATED(  ID_LISTCTRLVIEW, MyFrame::ViewLarge )
     EVT_BUTTON( ID_BUTTONNEXTTHU, MyFrame::OnNextThursday )
     EVT_BUTTON( ID_BUTTONMKDIR,   MyFrame::OnMakeDir )
     EVT_BUTTON( ID_BUTTONDETECT,  MyFrame::OnDetect )
@@ -339,6 +340,7 @@
     m_listCtrlView->DeleteAllItems();
     m_imageList->RemoveAll();
     wxListItem item;
+
     wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 7, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
     pd.SetSize( wxSize(320,140) );
 
@@ -346,14 +348,25 @@
     for ( CacheHash::iterator it=CH.begin(); it != CH.end(); ++it ) {
         keys.Add(it->first);
     }
-    bool select = true;
     keys.Sort();
+    // イメージリストを作成
+    for ( int i=0; i<keys.GetCount(); i++ ) { // item image
+        CacheItem* ci = new CacheItem;
+        ci = CH[keys[i]];
+        m_imageList->Add( ci->thumbnail );
+    }
+    for ( int i=0; i<keys.GetCount(); i++ ) { // item selected image
+        CacheItem* ci = new CacheItem;
+        ci = CH[keys[i]];
+        m_imageList->Add( ci->selthumbnail );
+    }
+    // アイテム作成
+    bool select = true;  // flag
     for ( int i=0; i<keys.GetCount(); i++ ) {
         CacheItem* ci = new CacheItem;
         ci = CH[keys[i]];
-        m_listCtrlView->InsertItem( i, ci->filename  );
+        m_listCtrlView->InsertItem( i, ci->filename, i );
         m_listCtrlView->SetItem( i, 0, ci->filename, i );
-        m_imageList->Add( ci->thumbnail );
 
         if ( i == 0 ) { // 1枚目はマークシートのはず
             wxImage marksheet( ci->fullpath, wxBITMAP_TYPE_JPEG );
@@ -381,16 +394,25 @@
         pd.Update( i+1, wxT("画像認識中") );
     }
 
+    // 選択したものは青い画像を使う
+    long i = -1;
+    for ( ;; ) {
+        i = m_listCtrlView->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+        if ( i == -1 ) break;
+        m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() );
+    }
+
     SetStatusText( wxEmptyString, 2 );
 }
 
-/* 画像を選択 */
-void MyFrame::GetImageInfo(wxListEvent& event)
+/* 画像を選択したとき画像の情報をステータスバーに表示 */
+void MyFrame::OnItemSelected(wxListEvent& event)
 {
+    int i = event.GetIndex();
+    m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() );    // 青い画像
+
     if ( m_listCtrlView->GetSelectedItemCount() != 1 ) return;
-
     SetStatusText( wxEmptyString, 2 );
-    int i = event.GetIndex();
 
     wxString filename = event.GetText();
     CacheItem* ci = new CacheItem;
@@ -399,6 +421,11 @@
     if ( ci->marksheet ) msg = wxT("perhaps marksheet !");
     SetStatusText( wxString::Format(wxT("selected image : z = %f, l = %d ...")+msg, ci->z, ci->l ), 2 );
 }
+void MyFrame::OnItemDeselected(wxListEvent& event)
+{
+    int i = event.GetIndex();
+    m_listCtrlView->SetItemImage( i, i );
+}
 
 /* 画像のスクリーン表示*/
 void MyFrame::ViewLarge(wxListEvent& event)
@@ -468,16 +495,21 @@
         /* 新しいファイルはキャッシュ */
         float z; long l; bool m = IsMarksheet( fullpath, &z, &l );
         wxImage image( fullpath, wxBITMAP_TYPE_JPEG );
-        wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) );
+        wxImage thumbnail = image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH );
+        wxBitmap bmp( thumbnail );
+        unsigned char *data = thumbnail.GetData();
+        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)
+        wxBitmap bmp_mask( thumbnail );
 
-        ci->filename  = file;
-        ci->fullpath  = fullpath;
-        ci->marksheet = m;
-        ci->z         = z;
-        ci->l         = l;
-        ci->exists    = true;
-        ci->thumbnail = bmp;
-        ci->modtime   = wxEmptyString; // TODO.
+        ci->filename     = file;
+        ci->fullpath     = fullpath;
+        ci->marksheet    = m;
+        ci->z            = z;
+        ci->l            = l;
+        ci->exists       = true;
+        ci->thumbnail    = bmp;
+        ci->selthumbnail = bmp_mask;
+        ci->modtime      = wxEmptyString; // TODO.
 
         CH[ci->filename] = ci;  // add hash
         wxGetApp().WriteLog( file + wxT(" appended.") + wxString::Format(wxT(" ( m=%d z=%f l=%d )"), m ? 1 : 0, z, l ) );