view include/dndfile.h @ 22:92188f60323d default tip

Implement Masking function on Preview Dialog.
author pyon@macmini
date Sat, 04 Apr 2015 17:23:46 +0900
parents bc2e2b304095
children
line wrap: on
line source

// Filename   : dndfile.h
// Last Change: 2015-04-04 11:10:10.
//
#ifndef __DNDFILE_H__
#define __DNDFILE_H__

#include "db.h"
#include "wx/config.h"
#include "wx/fileconf.h"
#include "myframe.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] );

            wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") );
            wxArrayString hhs;
            for ( int n = 0; n < csv.GetLineCount(); n++ ) {
                wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL );
                if ( ! reHhs.Matches( hhsno ) ) 
                    continue;
                hhs.Add( hhsno );
            }
            csv.Close();

            //
            int d = hhs.GetCount() - m_grid->GetNumberRows();
            if ( d > 0 )
                m_grid->AppendRows( d, true );

            // グリッドに情報を読込み
            wxArrayString res = GetHhsInfoAndPathByHhsNoList( hhs );
            for ( int r = 0; r < res.GetCount(); r++ ) {
                wxArrayString data = wxSplit( res[r], '_', '\\' );
                m_grid->SetCellValue( r, 0, data[0] );
                m_grid->SetCellValue( r, 1, data[1] );
                m_grid->SetCellValue( r, 2, data[2] );    
            }

            return true;
        }

    private:
        wxGrid* m_grid;
};

class DnDFile2 : public wxFileDropTarget
{
    public:
        DnDFile2( MyFrame *frame )
        {
            m_frame = frame;
        }
        virtual bool OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filenames )
        {
            size_t nFiles = filenames.GetCount();
            if ( nFiles != 1 ) return false;

            m_frame->ShowBPrintFrame( filenames[0] );

            return true;
        }

    private:
        MyFrame* m_frame;
};

#endif  //__DNDFILE_H__