Mercurial > mercurial > hgweb_mover2.cgi
changeset 38:044cc2f5af81 v2.4 v2.7
small fix.
author | pyon@macmini |
---|---|
date | Thu, 24 Nov 2011 22:26:15 +0900 |
parents | 3b54f3deeed9 |
children | e0ebc6a4c4dc |
files | TODO include/common.h include/dirview.h include/main.h makefile src/dirview.cpp src/myframe.cpp |
diffstat | 7 files changed, 77 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Fri Nov 18 20:46:12 2011 +0900 +++ b/TODO Thu Nov 24 22:26:15 2011 +0900 @@ -1,11 +1,11 @@ ====================================================================== TODO ====================================================================== -v2.7 +v2.8 * d&d image * help -v2.8 +v2.9 * twain ----------------------------------------------------------------------
--- a/include/common.h Fri Nov 18 20:46:12 2011 +0900 +++ b/include/common.h Thu Nov 24 22:26:15 2011 +0900 @@ -1,5 +1,5 @@ // Filename : common.h -// Last Change: 17-Nov-2011. +// Last Change: 24-Nov-2011. // #ifndef __COMMON__ #define __COMMON__ @@ -64,7 +64,9 @@ ID_TIMER, - // param + // dirview + ID_BUTTONEXPLR, + ID_BUTTONCLOSE, }; #endif // __COMMON__
--- a/include/dirview.h Fri Nov 18 20:46:12 2011 +0900 +++ b/include/dirview.h Thu Nov 24 22:26:15 2011 +0900 @@ -1,5 +1,5 @@ // Filename : dirview.h -// Last Change: 24-Oct-2011. +// Last Change: 24-Nov-2011. // #ifndef __dirview__ @@ -9,20 +9,23 @@ class DirViewFrame : public wxFrame { + DECLARE_EVENT_TABLE() private: protected: - wxListCtrl* m_listCtrlAll; - wxListCtrl* m_listCtrlThumbnail; - wxStaticBitmap* m_bitmapPreview; + wxListCtrl* m_listCtrl; + wxButton* m_buttonExplorer; + wxButton* m_buttonClose; public: + wxString m_dir; - DirViewFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + DirViewFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); ~DirViewFrame(); - void DirViewFrame::OnThumbnail(wxListEvent& event); - void DirViewFrame::OnThumbnail(wxListEvent& event); + void OnExplorer(wxCommandEvent& event); + void OnClose(wxCommandEvent& event); + void LoadListImage( void ); }; #endif //__dirview__
--- a/include/main.h Fri Nov 18 20:46:12 2011 +0900 +++ b/include/main.h Thu Nov 24 22:26:15 2011 +0900 @@ -1,5 +1,5 @@ // Filename : main.h -// Last Change: 17-Nov-2011. +// Last Change: 24-Nov-2011. // #include "wx/wx.h" #include "wx/config.h" @@ -8,8 +8,8 @@ #define MYAPPNAME wxT("AMover2") #define VER 2 -#define REV 6 -#define BLD 20111121 +#define REV 7 +#define BLD 20111128 // private classes // Define a new application type, each program should derive a class from wxApp
--- a/makefile Fri Nov 18 20:46:12 2011 +0900 +++ b/makefile Thu Nov 24 22:26:15 2011 +0900 @@ -1,6 +1,6 @@ # # Makefile for wxWidgets Application -# Last Change: 07-Nov-2011. +# Last Change: 24-Nov-2011. # by Takayuki Mutoh # @@ -74,6 +74,7 @@ OBJ = $(OBJDIR)/main.o \ $(OBJDIR)/myframe.o \ + $(OBJDIR)/dirview.o \ $(OBJDIR)/param.o \ $(OBJDIR)/wxsqlite3.o ifdef COMSPEC @@ -109,6 +110,9 @@ $(OBJDIR)/param.o: param.cpp param.h common.h main.h $(CXX) -c $< -o $@ $(CPPFLAGS) +$(OBJDIR)/dirview.o: dirview.cpp dirview.h common.h main.h + $(CXX) -c $< -o $@ $(CPPFLAGS) + $(OBJDIR)/wxsqlite3.o: wxsqlite3.cpp $(CXX) -c $< -o $@ $(CPPFLAGS)
--- a/src/dirview.cpp Fri Nov 18 20:46:12 2011 +0900 +++ b/src/dirview.cpp Thu Nov 24 22:26:15 2011 +0900 @@ -1,41 +1,36 @@ - // Filename : dirview.cpp -// Last Change: 24-Oct-2011. +// Last Change: 24-Nov-2011. // #include "dirview.h" +#define THUMB_W 160 +#define THUMB_H 226 + // frame constructor DirViewFrame::DirViewFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); - wxBoxSizer* bSizer; - bSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); - m_listCtrlAll = new wxListCtrl( this, ID_LISTCTRLALL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); - itemCol.SetText( wxT("$BDLHV(B") ); - m_listCtrlAll->InsertColumn( 0, itemCol ); - m_listCtrlAll->SetColumnWidth( 0, 100 ); - itemCol.SetText( wxT("$BHoJ]81<THV9f(B") ); - m_listCtrlAll->InsertColumn( 1, itemCol ); - m_listCtrlAll->SetColumnWidth( 1, 180 ); - itemCol.SetText( wxT("$B%U%!%$%k?t(B") ); - m_listCtrlAll->InsertColumn( 2, itemCol ); - m_listCtrlAll->SetColumnWidth( 1, 100 ); - bSizer->Add( m_listCtrlAll, 0, wxALL|wxEXPAND, 5 ); + m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); + bSizerTop->Add( m_listCtrl, 1, wxEXPAND|wxALL, 5 ); + + wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); + + m_buttonExplorer = new wxButton( this, ID_BUTTONEXPLR, wxT("フォルダオープン"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonExplorer, 1, wxALL, 5 ); + m_buttonClose = new wxButton( this, ID_BUTTONCLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonClose, 1, wxALL, 5 ); - m_listCtrlThumbnail = new wxListCtrl( this, ID_LISTCTRLTHUMB, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); - bSizer->Add( m_listCtrlThumbnail, 0, wxALL|wxEXPAND, 5 ); - - m_bitmapPreview = new wxStaticBitmap( this, ID_BITMAPPREVIEW, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer->Add( m_bitmapPreview, 1, wxALL|wxEXPAND, 5 ); - - this->SetSizer( bSizer ); + bSizerTop->Add( bSizerButton, 0, wxALL, 5 ); + + this->SetSizer( bSizerTop ); this->Layout(); this->Centre( wxBOTH ); + this->LoadListImage(); } // destructor @@ -44,59 +39,40 @@ } // Event Table -BEGIN_EVENT_TABLE( MyFrame, wxFrame ) - EVT_LIST_ITEM_SELECTED( ID_LISTCTRLALL, DirViewFrame::OnThumbnail ) - EVT_LIST_ITEM_SELECTED( ID_LISTCTRLTHUMB, DirViewFrame::OnPreview ) +BEGIN_EVENT_TABLE( DirViewFrame, wxFrame ) + EVT_BUTTON( ID_BUTTONEXPLR, DirViewFrame::OnExplorer ) + EVT_BUTTON( ID_BUTTONCLOSE, DirViewFrame::OnClose ) END_EVENT_TABLE() // Event Handlers -void DirViewFrame::OnThumbnail(wxListEvent& event) +void DirViewFrame::OnExplorer(wxCommandEvent& WXUNUSED(event)) { - m_listCtrlThumbnail->DeleteAllItems(); - /* - m_imageList->RemoveAll(); - wxDir dir(m_dir); - wxString filename; - if ( !dir.IsOpened() ) return; - - bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); - - int i=0; - wxListItem item; - while ( cout ) { - wxString f = m_dir + wxFILE_SEP_PATH + filename; - wxFile file( f ); - long len = file.Length(); - if ( !m_checkBox->IsChecked() && len > 150000 ) { - cout = dir.GetNext( &filename ); - continue; - } - - item.SetId(i); - item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE); - item.SetStateMask(wxLIST_STATE_SELECTED); - item.SetState(wxLIST_STATE_SELECTED); - item.SetImage(i); - item.SetText(filename); - m_listCtrl->InsertItem( item ); - m_listCtrl->SetItem( item ); - - wxImage img( f, wxBITMAP_TYPE_JPEG ); - wxBitmap bmp( img.Scale( 63, 89, wxIMAGE_QUALITY_HIGH ) ); - m_imageList->Add( bmp ); - cout = dir.GetNext( &filename ); - i++; - } - */ - - return; + wxString execmd = wxT("explorer ") + m_dir; // hhsdir + //wxExecute( execmd ); + wxMessageBox( execmd ); + Close(true); } -void DirViewFrame::OnPreview(wxListEvent& event) +void DirViewFrame::OnClose(wxCommandEvent& WXUNUSED(event)) { + Close(true); } // Functions -void DirViewFrame::ListAll(void) +void DirViewFrame::LoadListImage() { + wxImageList* imageList = new wxImageList( THUMB_W, THUMB_H ); + m_listCtrl->AssignImageList( imageList, wxIMAGE_LIST_NORMAL ); + + wxArrayString filenames; + unsigned int n = wxDir::GetAllFiles( m_dir, &filenames, wxT("*.jpg"), wxDIR_FILES ); + for ( int i=0; i<n; i++ ) { + wxImage image( filenames[i], wxBITMAP_TYPE_JPEG ); + wxImage thumbnail = image.Scale( THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH ); + wxBitmap bmp( thumbnail ); + imageList->Add( bmp ); + m_listCtrl->InsertItem( i, filenames[i], i ); + m_listCtrl->SetItem( i, 0, filenames[i], i ); + } } +
--- a/src/myframe.cpp Fri Nov 18 20:46:12 2011 +0900 +++ b/src/myframe.cpp Thu Nov 24 22:26:15 2011 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 18-Nov-2011. +// Last Change: 24-Nov-2011. // #include "main.h" @@ -7,6 +7,7 @@ #include "param.h" #include "dndfile.h" #include "marksheet.h" +#include "dirview.h" #define LOGO_W 288 #define LOGO_H 86 @@ -47,7 +48,7 @@ wxMenuItem* m_menuItemAutoDetect; m_menuItemAutoDetect = new wxMenuItem( m_menuFile, ID_MENUITEMAUTOD, wxString( wxT("自動検知\tF2") ) , wxEmptyString, wxITEM_CHECK ); m_menuFile->Append( m_menuItemAutoDetect ); - m_menuItemAutoDetect->Check(true); + m_menuItemAutoDetect->Check(false); m_menuFile->AppendSeparator(); // ---- wxMenuItem* m_menuItemParam; @@ -458,7 +459,6 @@ // 本処理 m_listCtrlView->DeleteAllItems(); m_imageList->RemoveAll(); - wxListItem item; m_textCtrlGuess->SetBackgroundColour(*wxWHITE); if ( by_autodetect ) pd->Update( 0, wxT("処理開始") ); @@ -493,7 +493,7 @@ // 氏名画像を表示 wxImage name_image; - name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); + name_image = marksheet.GetSubImage( wxRect( wxPoint(300,550), wxSize(640,190) ) ); wxBitmap name_bmp = ( name_image.Scale( LOGO_W, LOGO_H, wxIMAGE_QUALITY_HIGH ) ); m_bitmapName->SetBitmap( name_bmp ); @@ -532,7 +532,7 @@ // 選択したものは青い画像を使う long i = -1; for ( ;; ) { - i = m_listCtrlView->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + i = m_listCtrlView->GetNextItem( i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); if ( i == -1 ) break; m_listCtrlView->SetItemImage( i, i+m_listCtrlView->GetItemCount() ); } @@ -545,7 +545,7 @@ void MyFrame::OnItemSelected(wxListEvent& event) { int i = event.GetIndex(); - int m = m_listCtrlView->GetSelectedItemCount(); + int m = m_listCtrlView->GetItemCount(); m_listCtrlView->SetItemImage( i, i+m ); // 青い画像 if ( m != 1 ) { @@ -719,8 +719,10 @@ item.SetMask(wxLIST_MASK_TEXT); m_listCtrlHhsDir->GetItem( item ); hhsdir.Append( item.GetText() ); - wxString execmd = wxT("explorer ") + hhsdir; - wxExecute( execmd ); + + DirViewFrame* dvf = new DirViewFrame( this, wxID_ANY, wxEmptyString ); + dvf->m_dir = hhsdir; + dvf->Show(true); } /* 以下,定型もの ***********************************************/