Mercurial > mercurial > hgweb_searcher03.cgi
changeset 15:de222bc84e48
Implement Mouse Gesture in Preview Dialog.
author | pyon@macmini |
---|---|
date | Sun, 15 Jun 2014 16:45:52 +0900 |
parents | ac17a73e39b3 |
children | 1ba97995f642 |
files | Changes include/common.h include/myframe.h include/preview.h src/myframe.cpp src/preview.cpp |
diffstat | 6 files changed, 124 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Thu Jun 05 04:19:03 2014 +0900 +++ b/Changes Sun Jun 15 16:45:52 2014 +0900 @@ -1,16 +1,24 @@ +version 03.17 +2014-06-17 + Implement Mouse-Gesture in PreviewDialog. + +---- +version 03.16 +2014-06-06 + Implement Paste Search. + +---- version 03.15 2014-06-05 Zoom in / out in PreviewDialog. ---- - version 03.14 2014-05-23 Implement Hhs DB update dialog. Colouring selected thumbnail in PreviewDialog. ---- - version 03.13 2014-05-21 Implement file infomation window in PreviewDialog.
--- a/include/common.h Thu Jun 05 04:19:03 2014 +0900 +++ b/include/common.h Sun Jun 15 16:45:52 2014 +0900 @@ -1,5 +1,5 @@ // Filename : common.h -// Last Change: 14-May-2014. +// Last Change: 05-Jun-2014. // #ifndef __COMMON_H__ #define __COMMON_H__ @@ -44,6 +44,7 @@ #include <wx/dir.h> #include <wx/print.h> #include <wx/filepicker.h> +#include <wx/clipbrd.h> #include <wx/html/htmprint.h> #include <wx/datectrl.h> #include <wx/xrc/xmlres.h>
--- a/include/myframe.h Thu Jun 05 04:19:03 2014 +0900 +++ b/include/myframe.h Sun Jun 15 16:45:52 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.h -// Last Change: 20-May-2014. +// Last Change: 05-Jun-2014. // #ifndef __MYFRAME_H__ #define __MYFRAME_H__ @@ -85,6 +85,7 @@ ThumbnailPanel* m_thumbPanel; wxStaticText* m_staticText; // コマンド? MySearchBox* m_searchBox; + wxButton* m_buttonPaste; wxButton* m_buttonKana; wxButton* m_buttonHist; wxStatusBar* m_statusBar; @@ -106,6 +107,7 @@ void OnDClickItem( wxListEvent& event ); void OnSelectItem( wxListEvent& event ); void OpenHhsDir( int n ); + void OnPaste( wxCommandEvent& WXUNUSED(event) ); void OnKana( wxCommandEvent& WXUNUSED(event) ); void OnHistory( wxCommandEvent& WXUNUSED(event) ); void OnCommand( wxCommandEvent& WXUNUSED(event) ); @@ -138,6 +140,7 @@ ID_THUMB, ID_SEARCH, + ID_PASTE, ID_KANA, ID_HIST, };
--- a/include/preview.h Thu Jun 05 04:19:03 2014 +0900 +++ b/include/preview.h Sun Jun 15 16:45:52 2014 +0900 @@ -1,5 +1,5 @@ // Filename : preview.h -// Last Change: 04-Jun-2014. +// Last Change: 09-Jun-2014. // #ifndef __PREVIEW_H__ @@ -45,10 +45,11 @@ { DECLARE_EVENT_TABLE() private: - wxString m_preview; + int m_preview; wxArrayString m_imagefiles; wxArrayString m_cachefiles; float m_zoom; + int cx, cy; protected: wxScrolledWindow* m_scrolledWindow; @@ -68,6 +69,8 @@ void SetPreviewImage( int n ); void OnWheel( wxMouseEvent& event ); void OnDClick( wxMouseEvent& WXUNUSED(event) ); + void OnStartRGesture( wxMouseEvent& event ); + void OnEndRGesture( wxMouseEvent& event ); void OnPrint( wxCommandEvent& WXUNUSED(event) ); };
--- a/src/myframe.cpp Thu Jun 05 04:19:03 2014 +0900 +++ b/src/myframe.cpp Sun Jun 15 16:45:52 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 23-May-2014. +// Last Change: 05-Jun-2014. // #include "main.h" #include "db.h" @@ -151,20 +151,31 @@ /* サムネイル表示 */ void ThumbnailPanel::SetCacheImages( wxString dirpath ) { + wxBitmap bmp; + wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); + wxDir dir( dirpath ); if ( !dir.IsOpened() ) return; m_imagefiles.Clear(); wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); + m_cachefiles.Clear(); wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); wxDir cdir( cachedir ); - if ( !cdir.IsOpened() ) return; + if ( !cdir.IsOpened() ) { + bmp.LoadFile( thumb, wxBITMAP_TYPE_PNG ); + m_bitmap0->SetBitmap( bmp ); + m_bitmap1->SetBitmap( bmp ); + m_bitmap2->SetBitmap( bmp ); + m_bitmap3->SetBitmap( bmp ); + m_bitmap4->SetBitmap( bmp ); + m_bitmap5->SetBitmap( bmp ); + return; + } - m_cachefiles.Clear(); wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); - wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); int n = m_cachefiles.GetCount(); if ( n < 6 ) { while ( n < 6 ) { @@ -173,7 +184,6 @@ } } - wxBitmap bmp; bmp.LoadFile( m_cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); bmp.LoadFile( m_cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); bmp.LoadFile( m_cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); @@ -313,8 +323,11 @@ m_searchBox->SetFocus(); bSizerCmd->Add( m_searchBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + m_buttonPaste = new wxButton( m_panelMain, ID_PASTE, wxT("貼付検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); + bSizerCmd->Add( m_buttonPaste, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 10 ); + m_buttonKana = new wxButton( m_panelMain, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); - bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 ); + bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); @@ -360,8 +373,9 @@ EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) EVT_LIST_ITEM_SELECTED( ID_LIST, MyFrame::OnSelectItem ) EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem ) - EVT_BUTTON( ID_KANA, MyFrame::OnKana ) - EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) + EVT_BUTTON( ID_PASTE, MyFrame::OnPaste ) + EVT_BUTTON( ID_KANA, MyFrame::OnKana ) + EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand ) EVT_SIZE( MyFrame::OnWinSize ) EVT_MOVE( MyFrame::OnWinMove ) @@ -711,6 +725,31 @@ wxExecute( execmd ); } +/* 貼付検索 */ +void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) ) +{ + wxString s; + if ( wxTheClipboard->Open() ) { + if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) { + wxTextDataObject data; + wxTheClipboard->GetData( data ); + s = data.GetText(); + } + wxTheClipboard->Close(); + } + + wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); + if ( reHhs.Matches( s ) ) { + m_hhsno = s; + UpdateList( m_hhsno ); + UpdateThumbmail( 0 ); + return; + } + else { + wxMessageBox( wxT("被保険者番号ではありません.") ); + } +} + /* カナ検索ダイアログ */ void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) {
--- a/src/preview.cpp Thu Jun 05 04:19:03 2014 +0900 +++ b/src/preview.cpp Sun Jun 15 16:45:52 2014 +0900 @@ -1,5 +1,5 @@ // Filename : preview.cpp -// Last Change: 04-Jun-2014. +// Last Change: 11-Jun-2014. // #include "marksheet.h" @@ -58,7 +58,7 @@ } // Functions -/* サムネイル表示 */ +/* サムネイル画像作成 */ void PThumbnailPanel::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ) { m_imagefiles = imagefiles; @@ -135,9 +135,11 @@ wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxALWAYS_SHOW_SB ); - m_scrolledWindow->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PreviewDialog::OnWheel ), NULL, this ); + m_scrolledWindow->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PreviewDialog::OnWheel ), NULL, this ); m_bitmap = new wxStaticBitmap( m_scrolledWindow, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); m_bitmap->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( PreviewDialog::OnDClick ), NULL, this ); + m_bitmap->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( PreviewDialog::OnStartRGesture ), NULL, this ); + m_bitmap->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( PreviewDialog::OnEndRGesture ), NULL, this ); bSizerTop->Add( m_scrolledWindow, 1, wxALL|wxEXPAND, 5 ); wxBoxSizer* bSizerMenu = new wxBoxSizer( wxVERTICAL ); @@ -166,8 +168,10 @@ PreviewDialog::~PreviewDialog() { - m_scrolledWindow->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PreviewDialog::OnWheel ), NULL, this ); + m_scrolledWindow->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PreviewDialog::OnWheel ), NULL, this ); m_bitmap->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( PreviewDialog::OnDClick ), NULL, this ); + m_bitmap->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( PreviewDialog::OnStartRGesture ), NULL, this ); + m_bitmap->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( PreviewDialog::OnEndRGesture ), NULL, this ); } // Event Table @@ -177,9 +181,10 @@ #define WIDTH 2480 #define HEIGHT 3509 +/* プレビューするファイルをセット */ void PreviewDialog::SetPreviewImage( int n ) { - m_preview = m_imagefiles[n]; + m_preview = n; m_zoom = 1.0; SetZoom( m_zoom ); @@ -193,6 +198,7 @@ m_textInfo->SetValue( info ); } +/* 倍率を指定しロード */ void PreviewDialog::SetZoom( float zoom ) { int w, h; @@ -202,7 +208,7 @@ m_bitmap->SetBitmap( wxNullBitmap ); wxImage img; - img.LoadFile( m_preview, wxBITMAP_TYPE_JPEG ); + img.LoadFile( m_imagefiles[m_preview], wxBITMAP_TYPE_JPEG ); wxBitmap bmp( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ); m_bitmap->SetBitmap( bmp ); m_bitmap->Centre( wxHORIZONTAL ); @@ -211,6 +217,7 @@ m_scrolledWindow->SetScrollbars( 10, 10, 0, h/10 ); } +/* ファイル名を保持 */ void PreviewDialog::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ) { m_imagefiles = imagefiles; @@ -221,6 +228,7 @@ this->SetTitle( title ); } +/* コントロールキー + マウスホイール で画像を拡大・縮小 */ void PreviewDialog::OnWheel( wxMouseEvent& event ) { if ( event.ControlDown() ) { @@ -238,6 +246,7 @@ event.Skip(); } +/* 画像のダブルクリックで倍率変更 */ void PreviewDialog::OnDClick( wxMouseEvent& WXUNUSED(event) ) { if ( m_zoom > 2.1 ) m_zoom = 1.0; @@ -246,6 +255,46 @@ SetZoom( m_zoom ); } +/* 右ジェスチャー検知開始 */ +void PreviewDialog::OnStartRGesture( wxMouseEvent& event ) +{ + event.GetPosition( &cx, &cy ); +} + +/* 右ジェスチャー判定 */ +void PreviewDialog::OnEndRGesture( wxMouseEvent& event ) +{ + int x, y; + event.GetPosition( &x, &y ); + + int dx = x - cx; + int dy = y - cy; + float rad = fabs( atan2( dy, dx ) ); + float pi = 3.14159; + + // 右へジェスチャー + if ( rad < pi/8 && dx > 0 ) { + if ( m_preview < m_imagefiles.GetCount() - 1 ) + m_preview++; + else + return; + m_thumbPanel->Preview( m_preview ); + } + // 左へジェスチャー + else if ( rad > pi/8*7 && rad < pi && dx < 0 ) { + if ( m_preview > 0 ) + m_preview--; + else + return; + m_thumbPanel->Preview( m_preview ); + } + // 右上ヘジェスチャー + else if ( rad > pi/8 && rad < pi/8*3 && dx > 0 ) { + Close(); + } +} + +/* 印刷 */ void PreviewDialog::OnPrint( wxCommandEvent& WXUNUSED(event) ) { wxString html; @@ -253,7 +302,7 @@ wxString tmpjpg = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("preview.jpg"); - wxCopyFile( m_preview, tmpjpg, true ); + wxCopyFile( m_imagefiles[m_preview], tmpjpg, true ); html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>"); html = html + wxT("</body></html>");