Mercurial > mercurial > hgweb_searcher03.cgi
annotate src/cache.cpp @ 18:a8e6e5769e3b
Small fixes.
author | pyon@macmini |
---|---|
date | Sat, 29 Nov 2014 11:02:35 +0900 |
parents | 52958cd4a073 |
children | a2ad87cad48b |
rev | line source |
---|---|
11 | 1 // Filename : cache.cpp |
18 | 2 // Last Change: 21-Nov-2014. |
11 | 3 // |
4 | |
5 #include "cache.h" | |
6 #include "db.h" | |
7 | |
8 CacheDialog::CacheDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
9 : wxDialog( parent, id, title, pos, size, style ) | |
10 { | |
11 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | |
12 | |
13 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | |
14 | |
15 m_datePickerBgn = new wxDatePickerCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); | |
16 bSizerTop->Add( m_datePickerBgn, 0, wxALL, 5 ); | |
17 | |
18 m_datePickerEnd = new wxDatePickerCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT ); | |
19 bSizerTop->Add( m_datePickerEnd, 0, wxALL, 5 ); | |
20 | |
21 m_buttonMake = new wxButton( this, ID_MKCACHE, wxT("作成"), wxDefaultPosition, wxDefaultSize, 0 ); | |
22 bSizerTop->Add( m_buttonMake, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); | |
23 | |
24 m_buttonClose = new wxButton( this, ID_CLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); | |
25 m_buttonClose->SetDefault(); | |
26 bSizerTop->Add( m_buttonClose, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); | |
27 | |
28 this->SetSizer( bSizerTop ); | |
29 this->Layout(); | |
30 bSizerTop->Fit( this ); | |
31 | |
32 this->Centre( wxBOTH ); | |
33 } | |
34 | |
35 CacheDialog::~CacheDialog() | |
36 { | |
37 } | |
38 | |
39 // Event Table | |
40 BEGIN_EVENT_TABLE( CacheDialog, wxDialog ) | |
41 EVT_BUTTON( ID_MKCACHE, CacheDialog::OnMakeCache ) | |
42 EVT_BUTTON( ID_CLOSE, CacheDialog::OnClose ) | |
43 END_EVENT_TABLE() | |
44 | |
45 // Event Handlers & Functions | |
46 void CacheDialog::Setting( wxString rootdir, int w, int h ) | |
47 { | |
48 m_rootdir = rootdir; | |
49 m_width = w; | |
50 m_height = h; | |
51 } | |
52 | |
53 void CacheDialog::OnMakeCache( wxCommandEvent& WXUNUSED(event) ) | |
54 { | |
55 wxDateTime b = m_datePickerBgn->GetValue(); | |
56 wxDateTime e = m_datePickerEnd->GetValue(); | |
57 | |
58 MakeCache( b.Format( wxT("%Y%m%d")), e.Format( wxT("%Y%m%d")) ); | |
59 } | |
60 | |
61 void CacheDialog::MakeCache( wxString from, wxString to ) | |
62 { | |
63 wxArrayString path = GetPathes( from, to ); | |
64 wxString cachedir = wxGetCwd() + wxFILE_SEP_PATH + wxT("cache"); | |
65 | |
66 for ( int i = 0; i < path.GetCount(); i++ ) { | |
67 | |
68 wxArrayString files; | |
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
69 wxDir::GetAllFiles( path[i], &files, wxT("*.jpg"), wxDIR_DEFAULT ); |
11 | 70 |
71 for ( int j = 0; j < files.GetCount(); j++ ) { | |
72 wxImage image( files[j], wxBITMAP_TYPE_JPEG ); | |
73 wxImage output = image.Scale( m_width, m_height, wxIMAGE_QUALITY_HIGH ); | |
74 | |
75 wxString buf = files[j]; | |
76 buf.Replace( m_rootdir, cachedir, false ); | |
77 buf = buf.BeforeLast( '.' ) + wxT(".png"); | |
78 | |
79 wxFileName tf( buf ); | |
80 if ( !tf.Exists() ) tf.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); | |
81 output.SaveFile( buf, wxBITMAP_TYPE_PNG ); | |
82 } | |
18 | 83 wxSleep( 30 ); |
11 | 84 } |
85 | |
86 wxMessageBox( wxT("cache updated.") ); | |
87 } | |
88 | |
89 void CacheDialog::OnClose( wxCommandEvent& WXUNUSED(event) ) | |
90 { | |
91 Close(); | |
92 } | |
93 |