changeset 3:1a64119ab257

Equipment Regist print-target by Drag & Drop.
author pyon@macmini
date Tue, 27 Aug 2013 18:50:00 +0900
parents c066fde99517
children fdba695b99f1
files Changes Makefile TODO image/logo.png image/sample.ico image/sample.xpm image/samplea.xpm image/takashi.png include/about.h include/bprint.h include/common.h include/db.h include/dndfile.h include/hist.h include/index.h include/kana.h include/main.h include/marksheet.h include/mask.h include/myframe.h include/sqlite3.h info.plist.in sample.rc src/about.cpp src/bprint.cpp src/db.cpp src/hist.cpp src/index.cpp src/kana.cpp src/main.cpp src/marksheet.cpp src/mask.cpp src/myframe.cpp src/wxsqlite3.cpp wxmac.icns
diffstat 5 files changed, 66 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Fri Aug 23 18:32:09 2013 +0900
+++ b/Changes	Tue Aug 27 18:50:00 2013 +0900
@@ -1,3 +1,8 @@
+version 03.04
+2013-08-27
+ Regist print targets by Drag & Drop.
+
+----
 version 03.03
 2013-08-23
  Added Batch Print Mode.
--- a/Makefile	Fri Aug 23 18:32:09 2013 +0900
+++ b/Makefile	Tue Aug 27 18:50:00 2013 +0900
@@ -1,5 +1,5 @@
 # Makefile for wxWidgets Application
-# Last Change: 23-Aug-2013.
+# Last Change: 27-Aug-2013.
 # by Takayuki Mutoh
 #
 
@@ -83,7 +83,7 @@
 $(OBJDIR)/mask.o: mask.cpp mask.h common.h
 	$(CXX) -c $< -o $@ $(CXXFLAGS)
 
-$(OBJDIR)/bprint.o: bprint.cpp bprint.h marksheet.h common.h
+$(OBJDIR)/bprint.o: bprint.cpp bprint.h marksheet.h common.h dndfile.h
 	$(CXX) -c $< -o $@ $(CXXFLAGS)
 
 $(OBJDIR)/db.o: db.cpp db.h common.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/dndfile.h	Tue Aug 27 18:50:00 2013 +0900
@@ -0,0 +1,53 @@
+// Filename   : dndfile.h
+// Last Change: 27-Aug-2013.
+//
+
+#include "db.h"
+
+class DnDFile : public wxFileDropTarget
+{
+    public:
+        DnDFile( wxGrid *grid )
+        {
+            m_grid = grid;
+        }
+        virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames )
+        {
+            size_t nFiles = filenames.GetCount();
+            if ( nFiles != 1 ) return false;
+
+            m_grid->ClearGrid();
+            wxTextFile csv;
+            csv.Open( filenames[0] );
+
+            int d = csv.GetLineCount() - m_grid->GetNumberRows();
+            if ( d > 0 )
+                m_grid->AppendRows( d, true );
+
+            wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") );
+            for ( int n = 0, j = 0; n < csv.GetLineCount(); n++ ) {
+                wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL );
+                if ( ! reHhs.Matches( hhsno ) ) {
+                    j++;
+                    continue;
+                }
+                int r = n - j;
+
+                wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' );
+                wxArrayString path = GetPathByHhsNo( hhsno );
+
+                if ( info.IsEmpty() ) info.Add( wxEmptyString );
+                if ( path.IsEmpty() ) path.Add( wxEmptyString );
+
+                m_grid->SetCellValue( r, 0, hhsno );
+                m_grid->SetCellValue( r, 1, info[0] );
+                m_grid->SetCellValue( r, 2, path[0] );    
+            }
+            csv.Close();
+            return true;
+        }
+
+    private:
+        wxGrid* m_grid;
+};
+        
--- a/src/bprint.cpp	Fri Aug 23 18:32:09 2013 +0900
+++ b/src/bprint.cpp	Tue Aug 27 18:50:00 2013 +0900
@@ -1,9 +1,10 @@
 // Filename   : bprint.cpp
-// Last Change: 23-Aug-2013.
+// Last Change: 27-Aug-2013.
 //
 
 #include "bprint.h"
 #include "marksheet.h"
+#include "dndfile.h"
 #include "db.h"
 
 FrameBatchPrint::FrameBatchPrint( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
@@ -36,6 +37,7 @@
     m_grid->SetColSize( 1, 100 );
     m_grid->SetColSize( 2, 220 );
     m_grid->SetColSize( 3,  70 );
+    m_grid->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_ALWAYS );
 	
 	// Rows
 	m_grid->EnableDragRowSize( true );
@@ -69,6 +71,7 @@
 	
 	this->Centre( wxBOTH );
 
+    this->SetDropTarget( new DnDFile( m_grid ) );
     SetGridReadOnly();
 }
 
--- a/src/myframe.cpp	Fri Aug 23 18:32:09 2013 +0900
+++ b/src/myframe.cpp	Tue Aug 27 18:50:00 2013 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.cpp
-// Last Change: 23-Aug-2013.
+// Last Change: 27-Aug-2013.
 //
 #include "main.h"
 #include "db.h"
@@ -376,7 +376,7 @@
 /* 一括印刷モード */
 void MyFrame::OnBPrintMode( wxCommandEvent& WXUNUSED(event) )
 {
-    FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 640, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR );
+    FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 680, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR );
     bp->SetMask1( m_mask1 );
     bp->SetMask2( m_mask2 );
     bp->SetMask3( m_mask3 );