diff src/myframe.cpp @ 27:d21de4693652 v2.2dev v2.3

add hhsname
author pyon@macmini
date Sat, 05 Nov 2011 10:13:41 +0900
parents 5a934c8e1b95
children 24283d3a9592
line wrap: on
line diff
--- a/src/myframe.cpp	Thu Nov 03 15:48:26 2011 +0900
+++ b/src/myframe.cpp	Sat Nov 05 10:13:41 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.cpp
-// Last Change: 03-Nov-2011.
+// Last Change: 05-Nov-2011.
 //
 
 #include "main.h"
@@ -8,6 +8,13 @@
 #include "dndfile.h"
 #include "marksheet.h"
 
+#define LOGO_W  288
+#define LOGO_H   86
+#define HHSN_W  288
+#define HHSN_H   49
+#define THUMB_W 160
+#define THUMB_H 226
+
 // resources
 // the application icon (under Windows and OS/2 it is in resources and even
 // though we could still include the XPM here it would be unused)
@@ -106,34 +113,43 @@
 	
 	wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL );
 	
-	wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL );
+	wxBoxSizer* bSizerRecog = new wxBoxSizer( wxVERTICAL );
 	
 	m_staticTextName = new wxStaticText( this, wxID_ANY, wxT("氏名"), wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerGuess->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 );
+	bSizerRecog->Add( m_staticTextName, 0, wxTOP|wxLEFT, 5 );
     wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png");
     wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG );
 	m_bitmapName = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,95), 0 );
-	bSizerGuess->Add( m_bitmapName, 0, wxALL, 5 );
+	bSizerRecog->Add( m_bitmapName, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
 	
 	m_staticTextHhsno = new wxStaticText( this, wxID_ANY, wxT("被保険者番号"), wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerGuess->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 );
+	bSizerRecog->Add( m_staticTextHhsno, 0, wxTOP|wxLEFT, 5 );
     logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("0123456789.png");
     bmp.LoadFile( logo, wxBITMAP_TYPE_PNG );
 	m_bitmapHhsno = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize(320,54), 0 );
-	bSizerGuess->Add( m_bitmapHhsno, 0, wxALL, 5 );
+	bSizerRecog->Add( m_bitmapHhsno, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );
 	
 	m_staticTextGuess = new wxStaticText( this, wxID_ANY, wxT("推定値"), wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerGuess->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 );
+	bSizerRecog->Add( m_staticTextGuess, 0, wxTOP|wxLEFT, 5 );
+
+	wxBoxSizer* bSizerGuess = new wxBoxSizer( wxHORIZONTAL );
+
 	m_textCtrlGuess = new wxTextCtrl( this, ID_TEXTCTRLGUESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 	m_textCtrlGuess->SetMaxLength( 10 ); 
 	bSizerGuess->Add( m_textCtrlGuess, 0, wxALL, 5 );
+
+	m_textCtrlName = new wxTextCtrl( this, ID_TEXTCTRLNAME, wxEmptyString, wxDefaultPosition, wxSize(140,-1), 0 );
+    m_textCtrlName->SetBackgroundColour(wxT("LIGHT GREY"));
+	bSizerGuess->Add( m_textCtrlName, 0, wxALL, 5 );
 	
-	bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 );
+	bSizerRecog->Add( bSizerGuess, 0, wxEXPAND, 5 );
+
+	bSizerManip->Add( bSizerRecog, 0, wxEXPAND|wxLEFT, 5 );
 	
 	m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
     m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY"));
-	bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 );
-    m_imageList = new wxImageList( 160, 226 );
+	bSizerManip->Add( m_listCtrlView, 1, wxTOP|wxRIGHT|wxBOTTOM|wxEXPAND, 5 );
+    m_imageList = new wxImageList( THUMB_W, THUMB_H );
     m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
     //m_listCtrlView->SetDropTarget( new DnDFile(m_dirPickerWork) );
     this->SetDropTarget( new DnDFile(m_dirPickerWork) );
@@ -155,17 +171,20 @@
 
 	bSizerButton->Add( gSizer, 0, wxALL, 5 );
 
-	m_listCtrlHhsDir = new wxListCtrl( this, ID_LISTCTRLDIR, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
+	m_listCtrlHhsDir = new wxListCtrl( this, ID_LISTCTRLDIR, wxDefaultPosition, wxSize(280,-1), wxLC_REPORT|wxLC_SINGLE_SEL );
     wxListItem itemCol;
     itemCol.SetText( wxT("通番") );
     m_listCtrlHhsDir->InsertColumn( 0, itemCol );
-    m_listCtrlHhsDir->SetColumnWidth( 0, 50 );
+    m_listCtrlHhsDir->SetColumnWidth( 0, 40 );
     itemCol.SetText( wxT("被保険者番号") );
     m_listCtrlHhsDir->InsertColumn( 1, itemCol );
-    m_listCtrlHhsDir->SetColumnWidth( 1, 100 );
-    itemCol.SetText( wxT("ファイル数") );
+    m_listCtrlHhsDir->SetColumnWidth( 1, 90 );
+    itemCol.SetText( wxT("枚数") );
     m_listCtrlHhsDir->InsertColumn( 2, itemCol );
-    m_listCtrlHhsDir->SetColumnWidth( 2, 60 );
+    m_listCtrlHhsDir->SetColumnWidth( 2, 40 );
+    itemCol.SetText( wxT("氏名") );
+    m_listCtrlHhsDir->InsertColumn( 3, itemCol );
+    m_listCtrlHhsDir->SetColumnWidth( 3, 90 );
 
 	bSizerButton->Add( m_listCtrlHhsDir, 1, wxEXPAND|wxALL, 5 );
 	
@@ -379,14 +398,16 @@
         if ( i == 0 ) { // 1枚目はマークシートのはず
             wxImage marksheet( ci->fullpath, wxBITMAP_TYPE_JPEG );
 
+            // 氏名画像を表示
             wxImage name_image;
             name_image  = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) );
-            wxBitmap name_bmp  = ( name_image.Scale( 320, 95, wxIMAGE_QUALITY_HIGH ) );
+            wxBitmap name_bmp  = ( name_image.Scale( LOGO_W, LOGO_H, wxIMAGE_QUALITY_HIGH ) );
             m_bitmapName->SetBitmap( name_bmp );
 
+            // 被保険者番号画像を表示
             wxImage hhsno_image;
             hhsno_image = marksheet.GetSubImage( wxRect( wxPoint(1800,210), wxSize(594,100) ) );
-            wxBitmap hhsno_bmp = ( hhsno_image.Scale( 320, 54, wxIMAGE_QUALITY_HIGH ) );
+            wxBitmap hhsno_bmp = ( hhsno_image.Scale( HHSN_W, HHSN_H, wxIMAGE_QUALITY_HIGH ) );
             m_bitmapHhsno->SetBitmap( hhsno_bmp );
 
             wxString hhsno = GuessHhs( ci->fullpath );
@@ -394,7 +415,9 @@
             wxString name;
             int judge = IsHhsno( hhsno, name );
 	        if (      judge == 0 )  m_textCtrlGuess->SetBackgroundColour(*wxRED);       // not hhsno-style
-            //else if ( judge == 1 )  m_textCtrlGuess->SetBackgroundColour(wxT("YELLOW"));    // not in DB
+            else if ( judge == 1 )  m_textCtrlGuess->SetBackgroundColour(wxT("YELLOW"));    // not in DB
+            m_textCtrlName->SetValue( name );
+
             SetStatusText( wxString::Format(wxT("1st image : z = %f, l = %d"),ci->z,ci->l), 1 );
             m_listCtrlView->SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
         }
@@ -512,10 +535,10 @@
         //float z; long l; bool m = IsMarksheet( fullpath, &z, &l );
         float z; long l; bool m = IsMarksheet( fullpath, &z, &l, zmin, zmax, lmin, lmax );
         wxImage image( fullpath, wxBITMAP_TYPE_JPEG );
-        wxImage thumbnail = image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH );
+        wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, 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*160+x)*3+2] = 255;  // 文字色:黒(0,0,0)->青(0,0.255)
+        for ( int y=0; y<THUMB_H; y++ ) for ( int x=0; x<THUMB_W; x++ ) data[(y*THUMB_W+x)*3+2] = 255;  // 文字色:黒(0,0,0)->青(0,0.255)
         wxBitmap bmp_mask( thumbnail );
 
         ci->filename     = file;
@@ -580,14 +603,16 @@
     hhsdir.Append( m_textCtrlDist->GetValue() );
     hhsdir.Append( wxFILE_SEP_PATH );
 
-    wxListItem item = event.GetItem();
+    int i = event.GetIndex();
+    wxListItem item;
+    item.SetId(i);
+
     item.SetColumn(1);
     item.SetMask(wxLIST_MASK_TEXT);
     m_listCtrlHhsDir->GetItem( item );
     hhsdir.Append( item.GetText() );
     wxString execmd = wxT("explorer ") + hhsdir;
     wxExecute( execmd );
-    //wxMessageBox(hhsdir);
 }
 
 // 以下,定型もの