annotate src/miniframe.cpp @ 21:a2ad87cad48b

Enhanced the convenience of Cache dialog.
author pyon@macmini
date Wed, 17 Dec 2014 00:52:43 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
1 // Filename : mini.cpp
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
2 // Last Change: 12-Dec-2014.
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
3 //
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
4 #include "main.h"
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
5 #include "db.h"
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
6 #include "hhsdb.h"
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
7 #include "miniframe.h"
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
8 #include "update.h"
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
9
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
10 ///////////////////////////////////////////////////////////////
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
11 // カスタム検索ボックス
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
12 MiniSearchBox::MiniSearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
13 : wxSearchCtrl( parent, id, value, pos, size, style )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
14 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
15 SetMaxLength( 11 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
16 #ifndef __WXMAC__
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
17 ShowSearchButton( true );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
18 #endif
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
19 ShowCancelButton( false );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
20 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
21
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
22 MiniSearchBox::~MiniSearchBox()
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
23 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
24 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
25
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
26 // Event Table
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
27 BEGIN_EVENT_TABLE( MiniSearchBox, wxSearchCtrl )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
28 EVT_CHAR( MiniSearchBox::OnKey )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
29 END_EVENT_TABLE()
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
30
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
31 // Event Handlers & Functions
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
32 void MiniSearchBox::OnKey( wxKeyEvent& event )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
33 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
34 int kc = event.GetKeyCode();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
35 wxString s = GetValue();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
36
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
37 if ( kc == 13 ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
38 event.Skip();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
39 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
40 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
41
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
42 if ( kc == 45 ) { // テンキーの '-' キーで1文字削除
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
43 wxString t = GetStringSelection();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
44 if ( t.IsEmpty() ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
45 long p = GetInsertionPoint();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
46 if ( p > 0 ) Remove( p - 1, p );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
47 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
48 else {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
49 Cut();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
50 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
51 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
52 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
53
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
54 if ( kc == WXK_ESCAPE ) { // clear by ESC
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
55 this->Clear();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
56 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
57 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
58
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
59 Cut();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
60 event.Skip();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
61 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
62
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
63
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
64 ///////////////////////////////////////////////////////////////
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
65 // メインフレーム
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
66
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
67 // resources
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
68 #if !defined(__WXMSW__) && !defined(__WXPM__)
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
69 #include "sample.xpm"
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
70 #endif
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
71
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
72 MiniFrame::MiniFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
73 : wxFrame( parent, id, title, pos, size, style )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
74 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
75 this->SetSizeHints( wxSize( 100, 45 ), wxSize( 100, 45 ) );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
76 this->SetBackgroundColour( wxColour(wxT("WHITE")) );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
77
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
78 // set the frame icon
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
79 SetIcon(wxICON(sample));
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
80
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
81 //
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
82 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
83
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
84 m_staticText = new wxStaticText( this, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, 0 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
85 bSizerTop->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 0 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
86
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
87 m_searchBox = new MiniSearchBox( this, ID_MSEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
88 m_searchBox->SetFocus();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
89 bSizerTop->Add( m_searchBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 0 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
90
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
91 //
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
92 this->SetSizer( bSizerTop );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
93 this->Layout();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
94
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
95 this->Centre( wxBOTH );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
96 LoadParam();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
97 if ( CheckNewFiles( m_shared ) != 0 )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
98 Close();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
99 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
100
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
101 MiniFrame::~MiniFrame()
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
102 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
103 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
104
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
105 // Event Table
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
106 BEGIN_EVENT_TABLE( MiniFrame, wxFrame )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
107 EVT_TEXT_ENTER( ID_MSEARCH, MiniFrame::OnCommand )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
108 END_EVENT_TABLE()
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
109
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
110 // Event Handlers & Functions
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
111 /* エンターキーフック */
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
112 void MiniFrame::OnCommand( wxCommandEvent& event )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
113 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
114 wxString s = m_searchBox->GetLineText(0);
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
115
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
116 if ( s.IsSameAs( wxT(".") ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
117 OpenAppDir();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
118 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
119 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
120
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
121 if ( s.IsSameAs( wxT("z") ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
122 Transform( wxT("full mode") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
123 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
124 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
125
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
126 if ( s.StartsWith( wxT("9") ) || s.IsSameAs( wxT("q") ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
127 Close();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
128 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
129 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
130
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
131 wxRegEx reHhs( wxT("^0[1238][0-9]{8}.?$") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
132 if ( reHhs.Matches( s ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
133
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
134 if ( s.Len() == 10 ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
135 m_hhsno = s;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
136 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
137 else {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
138 m_hhsno = s.Left( 10 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
139 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
140
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
141 wxArrayString pathes = GetPathByHhsNo( m_hhsno );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
142 if ( pathes.IsEmpty() ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
143 m_searchBox->SetValue( wxT("No data.") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
144 m_searchBox->SelectAll();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
145 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
146 else {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
147 if ( s.Right( 1 ).IsSameAs( wxT("+") ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
148 PrintImages( pathes[0] );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
149 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
150 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
151 OpenHhsDir( pathes[0] );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
152 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
153 return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
154 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
155 m_searchBox->SelectAll();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
156 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
157 /* パラメータを設定ファイルから読み込む */
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
158 void MiniFrame::LoadParam( void )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
159 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
160 conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf");
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
161 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
162
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
163 int x, y;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
164
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
165 // Shaerd
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
166 config->SetPath( wxT("/Index") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
167 config->Read( wxT("shared"), &m_shared );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
168
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
169 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
170 /* アプリフォルダを開く */
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
171 void MiniFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
172 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
173 OpenAppDir();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
174 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
175 void MiniFrame::OpenAppDir( )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
176 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
177 wxString appdir = wxGetCwd();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
178 wxString execmd = wxT("explorer ") + appdir;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
179 wxExecute( execmd );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
180 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
181 /* 被保険者フォルダを開く */
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
182 void MiniFrame::OpenHhsDir( wxString path )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
183 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
184 wxString execmd = wxT("explorer ") + path;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
185 wxExecute( execmd );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
186 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
187 /* 印刷 */
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
188 void MiniFrame::PrintImages( wxString path )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
189 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
190 wxDir dir( path );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
191 if ( !dir.IsOpened() ) return;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
192
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
193 wxString html;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
194 html = html + wxT("<html><body>\n");
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
195
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
196 wxString file;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
197 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
198 int n = 0;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
199 wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
200 while ( cout ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
201 file = path + wxFILE_SEP_PATH + file;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
202 file.Replace( wxFILE_SEP_PATH, wxT("/") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
203 wxString tmpjpg = wxString::Format( wxT("%stmp%d.jpg"), tmpdir, n );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
204 wxCopyFile( file, tmpjpg, true );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
205 html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>");
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
206 html = html + wxT("<div align=right><font size=-2><u>") + path.Right( 10 ) + wxT("</u></font></div>");
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
207 cout = dir.GetNext( &file );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
208 n++;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
209 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
210 html = html + wxT("</body></html>");
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
211
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
212 // start printing
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
213 wxHtmlPrintout hpout( wxT("Searcher03") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
214 hpout.SetMargins( 0, 0, 0, 0, 0 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
215 wxPrintDialogData pd;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
216 wxPrinter p( &pd );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
217
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
218 hpout.SetHtmlText( html, wxEmptyString, false );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
219 p.Print( NULL, &hpout, true );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
220 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
221 /* フルモードに変形 */
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
222 void MiniFrame::Transform( wxString mode )
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
223 {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
224 wxTextFile textfile;
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
225 textfile.Open( wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
226 for ( int i=0; i<textfile.GetLineCount(); i++ ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
227 if ( textfile[i].StartsWith( wxT("mode=") ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
228 textfile.RemoveLine( i );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
229 textfile.InsertLine( wxT("mode=0"), i );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
230 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
231 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
232 textfile.Write();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
233 textfile.Close();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
234
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
235 Show( false );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
236 wxExecute( wxT("searcher03.exe") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
237 wxSleep( 1 );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
238
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
239 textfile.Open( wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf") );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
240 for ( int i=0; i<textfile.GetLineCount(); i++ ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
241 if ( textfile[i].StartsWith( wxT("mode=") ) ) {
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
242 textfile.RemoveLine( i );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
243 textfile.InsertLine( wxT("mode=1"), i );
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
244 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
245 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
246 textfile.Write();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
247 textfile.Close();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
248
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
249 Close();
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
250 }
a2ad87cad48b Enhanced the convenience of Cache dialog.
pyon@macmini
parents:
diff changeset
251