Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/myframe.cpp @ 9:b455f2d8aac9
Implement Preview.
author | pyon@macmini |
---|---|
date | Thu, 24 Apr 2014 18:31:39 +0900 |
parents | 4967d1e2b30c |
children | 29021e6e1ebe |
comparison
equal
deleted
inserted
replaced
8:4967d1e2b30c | 9:b455f2d8aac9 |
---|---|
1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
2 // Last Change: 01-Nov-2013. | 2 // Last Change: 24-Apr-2014. |
3 // | 3 // |
4 #include "main.h" | 4 #include "main.h" |
5 #include "db.h" | 5 #include "db.h" |
6 #include "about.h" | 6 #include "about.h" |
7 #include "kana.h" | 7 #include "kana.h" |
8 #include "hist.h" | 8 #include "hist.h" |
9 #include "preview.h" | |
9 #include "index.h" | 10 #include "index.h" |
10 #include "param.h" | 11 #include "param.h" |
11 #include "marksheet.h" | 12 #include "marksheet.h" |
12 #include "myframe.h" | 13 #include "myframe.h" |
13 #include "bprint.h" | 14 #include "bprint.h" |
14 | 15 |
16 | |
15 /////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////// |
16 // カスタム検索ボックス | 18 // カスタム検索ボックス |
17 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) | 19 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) |
18 : wxSearchCtrl( parent, id, value, pos, size, style ) | 20 : wxSearchCtrl( parent, id, value, pos, size, style ) |
19 { | 21 { |
21 | 23 |
22 MySearchBox::~MySearchBox() | 24 MySearchBox::~MySearchBox() |
23 { | 25 { |
24 } | 26 } |
25 | 27 |
28 void MySearchBox::SetMessage( wxString msg ) | |
29 { | |
30 wxFrame* p = (wxFrame*)FindWindowById( ID_MAIN ); | |
31 p->SetStatusText( msg, 0 ); | |
32 } | |
33 | |
26 // Event Table | 34 // Event Table |
27 BEGIN_EVENT_TABLE( MySearchBox, wxSearchCtrl ) | 35 BEGIN_EVENT_TABLE( MySearchBox, wxSearchCtrl ) |
28 EVT_CHAR( MySearchBox::OnKey ) | 36 EVT_CHAR( MySearchBox::OnKey ) |
29 END_EVENT_TABLE() | 37 END_EVENT_TABLE() |
30 | 38 |
31 // Event Handlers & Functions | 39 // Event Handlers & Functions |
32 void MySearchBox::OnKey( wxKeyEvent& event ) | 40 void MySearchBox::OnKey( wxKeyEvent& event ) |
33 { | 41 { |
42 int kc = event.GetKeyCode(); | |
34 wxString s = GetValue(); | 43 wxString s = GetValue(); |
35 // statustext( s.Len() ); | 44 |
36 | 45 if ( kc == 13 ) { |
37 if ( event.GetKeyCode() == 45 ) { // テンキーの '-' キーで1文字削除 | 46 event.Skip(); |
47 return; | |
48 } | |
49 | |
50 if ( kc == 45 ) { // テンキーの '-' キーで1文字削除 | |
38 wxString t = GetStringSelection(); | 51 wxString t = GetStringSelection(); |
39 if ( t.IsEmpty() ) { | 52 if ( t.IsEmpty() ) { |
40 long p = GetInsertionPoint(); | 53 long p = GetInsertionPoint(); |
41 if ( p > 0 ) Remove( p - 1, p ); | 54 if ( p > 0 ) Remove( p - 1, p ); |
42 } | 55 } |
44 Cut(); | 57 Cut(); |
45 } | 58 } |
46 return; | 59 return; |
47 } | 60 } |
48 | 61 |
49 if ( event.GetKeyCode() == WXK_ESCAPE ) { // clear by ESC | 62 if ( kc == WXK_ESCAPE ) { // clear by ESC |
50 this->Clear(); | 63 this->Clear(); |
51 return; | 64 return; |
52 } | 65 } |
53 | 66 |
67 // auto-complete | |
68 Cut(); | |
69 if ( kc >=48 && kc<=57 ) { // [0-9] | |
70 kc -= 48; | |
71 wxString input = GetValue() + wxString::Format( wxT("%d"), kc ); | |
72 if ( input.Len() < 5 ) { | |
73 event.Skip(); | |
74 return; | |
75 } | |
76 for ( unsigned int i = 0; i < m_jhhsno.GetCount(); i++ ) { | |
77 if ( m_jhhsno[i].StartsWith( input ) ) { | |
78 ChangeValue( m_jhhsno[i] ); | |
79 SetSelection( input.Len(), 10 ); | |
80 | |
81 wxArrayString s = wxSplit( GetHhsInfoByHhsNo( m_jhhsno[i] ), '_', '\\' ); | |
82 wxString msg = wxT("もしかして... ") + s[0] + wxT(" ?!"); | |
83 SetMessage( msg ); | |
84 return; | |
85 } | |
86 SetMessage( wxEmptyString ); | |
87 } | |
88 event.Skip(); | |
89 return; | |
90 } | |
54 event.Skip(); | 91 event.Skip(); |
55 } | 92 } |
56 | 93 |
94 /////////////////////////////////////////////////////////////// | |
95 // サムネイルパネル | |
96 #define THUMB_W 60 | |
97 #define THUMB_H 75 | |
98 ThumbnailPanel::ThumbnailPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
99 : wxPanel( parent, id, pos, size, style ) | |
100 { | |
101 wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); | |
102 this->SetBackgroundColour( wxColour( 192, 192, 192 ) ); | |
103 | |
104 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | |
105 wxBitmap bmp = wxBitmap( thumb, wxBITMAP_TYPE_PNG ); | |
106 | |
107 m_bitmap0 = new wxStaticBitmap( this, ID_THBMP0, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | |
108 bSizer->Add( m_bitmap0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
109 m_bitmap0->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this ); | |
110 | |
111 m_bitmap1 = new wxStaticBitmap( this, ID_THBMP1, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | |
112 bSizer->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
113 m_bitmap1->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this ); | |
114 | |
115 m_bitmap2 = new wxStaticBitmap( this, ID_THBMP2, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | |
116 bSizer->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
117 m_bitmap2->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this ); | |
118 | |
119 m_bitmap3 = new wxStaticBitmap( this, ID_THBMP3, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | |
120 bSizer->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
121 m_bitmap3->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this ); | |
122 | |
123 m_bitmap4 = new wxStaticBitmap( this, ID_THBMP4, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | |
124 bSizer->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
125 m_bitmap4->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); | |
126 | |
127 m_bitmap5 = new wxStaticBitmap( this, ID_THBMP5, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | |
128 bSizer->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
129 m_bitmap5->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | |
130 | |
131 this->SetSizer( bSizer ); | |
132 this->Layout(); | |
133 } | |
134 | |
135 ThumbnailPanel::~ThumbnailPanel() | |
136 { | |
137 m_bitmap0->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this ); | |
138 m_bitmap1->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this ); | |
139 m_bitmap2->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this ); | |
140 m_bitmap3->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this ); | |
141 m_bitmap4->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); | |
142 m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | |
143 } | |
144 | |
145 // Functions | |
146 /* サムネイル表示 */ | |
147 void ThumbnailPanel::SetImages( wxString dirpath ) | |
148 { | |
149 wxDir dir( dirpath ); | |
150 if ( !dir.IsOpened() ) return; | |
151 m_imagefiles.Clear(); | |
152 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); | |
153 | |
154 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); | |
155 wxDir cdir( cachedir ); | |
156 if ( !cdir.IsOpened() ) return; | |
157 | |
158 wxArrayString cachefiles; | |
159 wxDir::GetAllFiles( cachedir, &cachefiles, wxT("*.png"), wxDIR_FILES ); | |
160 | |
161 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | |
162 int n = cachefiles.GetCount(); | |
163 if ( n < 6 ) { | |
164 while ( n < 6 ) { | |
165 cachefiles.Add( thumb ); | |
166 n++; | |
167 } | |
168 } | |
169 | |
170 wxBitmap bmp; | |
171 bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); | |
172 bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); | |
173 bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); | |
174 bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); | |
175 bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); | |
176 bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); | |
177 } | |
178 /* 画像クリックで拡大表示 */ | |
179 void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { Preview( 0 ); } | |
180 void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { Preview( 1 ); } | |
181 void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { Preview( 2 ); } | |
182 void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { Preview( 3 ); } | |
183 void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { Preview( 4 ); } | |
184 void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { Preview( 5 ); } | |
185 void ThumbnailPanel::Preview( int n ) | |
186 { | |
187 if ( m_imagefiles.GetCount() < n ) return; | |
188 | |
189 PreviewDialog* pd = new PreviewDialog( this, wxID_ANY, wxT("プレビュー"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); | |
190 pd->Show(); | |
191 pd->Maximize( true ); | |
192 pd->SetImage( m_imagefiles[n] ); | |
193 } | |
57 | 194 |
58 /////////////////////////////////////////////////////////////// | 195 /////////////////////////////////////////////////////////////// |
59 // メインフレーム | 196 // メインフレーム |
60 #define WINL_W 480 | 197 #define WINL_W 480 |
61 #define LOGO_W 200 | 198 #define LOGO_W 200 |
68 | 205 |
69 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 206 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
70 : wxFrame( parent, id, title, pos, size, style ) | 207 : wxFrame( parent, id, title, pos, size, style ) |
71 { | 208 { |
72 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize ); | 209 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize ); |
73 this->SetMinSize( wxSize( WINL_W, 500 ) ); | 210 //this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); |
74 this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); | 211 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); |
75 //this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); | |
76 | 212 |
77 // set the frame icon | 213 // set the frame icon |
78 SetIcon(wxICON(sample)); | 214 SetIcon(wxICON(sample)); |
79 | 215 |
80 // メニューバー Menu | 216 // メニューバー Menu |
84 wxMenuItem* m_menuItemBPrintMode = new wxMenuItem( m_menuFile, ID_MNBPNT, wxString( wxT("バッチ印刷モード\tF12") ) , wxT("Batch Print Mode"), wxITEM_NORMAL ); | 220 wxMenuItem* m_menuItemBPrintMode = new wxMenuItem( m_menuFile, ID_MNBPNT, wxString( wxT("バッチ印刷モード\tF12") ) , wxT("Batch Print Mode"), wxITEM_NORMAL ); |
85 m_menuFile->Append( m_menuItemBPrintMode ); | 221 m_menuFile->Append( m_menuItemBPrintMode ); |
86 | 222 |
87 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL ); | 223 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL ); |
88 m_menuFile->Append( m_menuItemIndex ); | 224 m_menuFile->Append( m_menuItemIndex ); |
89 | |
90 m_menuFile->AppendSeparator(); // ---- | |
91 | |
92 wxMenuItem* m_menuItemViewStyle = new wxMenuItem( m_menuFile, ID_MNVIEW, wxString( wxT("ビュースタイル\tF10") ) , wxT("Toggle ViewStyle"), wxITEM_CHECK ); | |
93 m_menuFile->Append( m_menuItemViewStyle ); | |
94 | 225 |
95 m_menuFile->AppendSeparator(); // ---- | 226 m_menuFile->AppendSeparator(); // ---- |
96 | 227 |
97 wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL ); | 228 wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL ); |
98 m_menuFile->Append( m_menuItemBkup ); | 229 m_menuFile->Append( m_menuItemBkup ); |
121 this->SetMenuBar( m_menubar ); | 252 this->SetMenuBar( m_menubar ); |
122 | 253 |
123 // | 254 // |
124 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | 255 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); |
125 | 256 |
126 m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D ); | 257 m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); |
258 | |
127 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL ); | 259 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL ); |
128 | |
129 // left-pane | |
130 m_panelMain = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | |
131 | 260 |
132 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); | 261 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); |
133 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); | 262 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); |
134 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 ); | 263 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 ); |
135 bSizerMain->Add( m_bitmap, 0, wxALL, 5 ); | 264 bSizerMain->Add( m_bitmap, 0, wxALL, 5 ); |
149 m_listCtrl->InsertColumn( 1, itemCol ); | 278 m_listCtrl->InsertColumn( 1, itemCol ); |
150 m_listCtrl->SetColumnWidth( 1, 80 ); | 279 m_listCtrl->SetColumnWidth( 1, 80 ); |
151 itemCol.SetText( wxT("場所") ); | 280 itemCol.SetText( wxT("場所") ); |
152 m_listCtrl->InsertColumn( 2, itemCol ); | 281 m_listCtrl->InsertColumn( 2, itemCol ); |
153 m_listCtrl->SetColumnWidth( 2, 300 ); | 282 m_listCtrl->SetColumnWidth( 2, 300 ); |
154 bSizerMain->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); | 283 bSizerMain->Add( m_listCtrl, 1, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 ); |
155 | 284 |
285 m_thumbPanel = new ThumbnailPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxSize( -1, 100 ), wxSUNKEN_BORDER ); | |
286 bSizerMain->Add( m_thumbPanel, 0, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 ); | |
287 | |
288 // | |
156 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); | 289 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); |
157 | 290 |
158 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); | 291 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); |
159 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 292 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
160 | 293 |
161 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); | 294 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); |
295 m_searchBox->SetJudgedHhs( GetJudgedHhsNo() ); | |
162 #ifndef __WXMAC__ | 296 #ifndef __WXMAC__ |
163 m_searchBox->ShowSearchButton( true ); | 297 m_searchBox->ShowSearchButton( true ); |
164 #endif | 298 #endif |
165 m_searchBox->ShowCancelButton( false ); | 299 m_searchBox->ShowCancelButton( false ); |
166 m_searchBox->SetFocus(); | 300 m_searchBox->SetFocus(); |
170 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 ); | 304 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 ); |
171 | 305 |
172 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); | 306 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
173 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); | 307 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); |
174 | 308 |
309 // | |
175 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 ); | 310 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 ); |
176 | 311 |
177 m_panelMain->SetSizer( bSizerMain ); | 312 m_panelMain->SetSizer( bSizerMain ); |
178 m_panelMain->Layout(); | 313 m_panelMain->Layout(); |
179 bSizerMain->Fit( m_panelMain ); | 314 bSizerMain->Fit( m_panelMain ); |
180 | 315 bSizerTop->Add( m_panelMain, 1, wxEXPAND|wxALL, 5 ); |
181 // right-pane | 316 |
182 m_panelView = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | |
183 wxBoxSizer* bSizerView = new wxBoxSizer( wxHORIZONTAL ); | |
184 | |
185 m_bitmapView = new wxStaticBitmap( m_panelView, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); | |
186 bSizerView->Add( m_bitmapView, 1, wxALL|wxEXPAND, 5 ); | |
187 | |
188 m_listCtrlThumb = new wxListCtrl( m_panelView, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); | |
189 bSizerView->Add( m_listCtrlThumb, 0, wxALL|wxEXPAND, 5 ); | |
190 | |
191 m_panelView->SetSizer( bSizerView ); | |
192 m_panelView->Layout(); | |
193 bSizerView->Fit( m_panelView ); | |
194 | |
195 m_panelView->Show( false ); | |
196 // | 317 // |
197 m_splitter->Initialize( m_panelMain ); | |
198 bSizerTop->Add( m_splitter, 1, wxEXPAND, 5 ); | |
199 | |
200 this->SetSizer( bSizerTop ); | 318 this->SetSizer( bSizerTop ); |
201 this->Layout(); | 319 this->Layout(); |
202 | 320 |
203 // ステータスバー Statusbar | 321 // ステータスバー Statusbar |
204 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); | 322 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); |
215 { | 333 { |
216 } | 334 } |
217 | 335 |
218 // Event Table | 336 // Event Table |
219 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | 337 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) |
220 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) | 338 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) |
221 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 339 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
222 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) | 340 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) |
223 EVT_MENU( ID_MNVIEW, MyFrame::OnViewStyle ) | 341 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) |
224 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) | 342 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) |
225 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) | |
226 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) | 343 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) |
227 EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam ) | 344 EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam ) |
228 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) | 345 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) |
229 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnSelectHhsDir ) | 346 EVT_LIST_ITEM_SELECTED( ID_LIST, MyFrame::OnSelectItem ) |
347 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem ) | |
230 EVT_BUTTON( ID_KANA, MyFrame::OnKana ) | 348 EVT_BUTTON( ID_KANA, MyFrame::OnKana ) |
231 EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) | 349 EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) |
350 EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand ) | |
232 EVT_SIZE( MyFrame::OnWinSize ) | 351 EVT_SIZE( MyFrame::OnWinSize ) |
233 EVT_MOVE( MyFrame::OnWinMove ) | 352 EVT_MOVE( MyFrame::OnWinMove ) |
234 EVT_CLOSE( MyFrame::SaveConfig ) | 353 EVT_CLOSE( MyFrame::SaveConfig ) |
235 EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand ) | |
236 END_EVENT_TABLE() | 354 END_EVENT_TABLE() |
237 | 355 |
238 // Event Handlers & Functions | 356 // Event Handlers & Functions |
239 /* エンターキーフック */ | 357 /* エンターキーフック */ |
240 void MyFrame::OnCommand( wxCommandEvent& event ) | 358 void MyFrame::OnCommand( wxCommandEvent& event ) |
241 { | 359 { |
242 wxString s = m_searchBox->GetValue(); | 360 wxString s = m_searchBox->GetLineText(0); |
361 | |
362 if ( s.IsSameAs( wxT(".") ) ) { | |
363 OpenAppDir(); | |
364 return; | |
365 } | |
243 | 366 |
244 if ( s.IsSameAs( wxT("99") ) ) { | 367 if ( s.IsSameAs( wxT("99") ) ) { |
245 Close(); | 368 Close(); |
246 return; | 369 return; |
247 } | 370 } |
253 | 376 |
254 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | 377 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); |
255 if ( reHhs.Matches( s ) ) { | 378 if ( reHhs.Matches( s ) ) { |
256 m_hhsno = s; | 379 m_hhsno = s; |
257 UpdateList( m_hhsno ); | 380 UpdateList( m_hhsno ); |
381 UpdateThumbmail( 0 ); | |
258 return; | 382 return; |
259 } | 383 } |
260 | 384 |
261 wxRegEx reNo( wxT("^[0-9]{1,2}$") ); | 385 wxRegEx reNo( wxT("^[0-9]{1,2}$") ); |
262 if ( reNo.Matches( s ) ) { | 386 if ( reNo.Matches( s ) ) { |
329 | 453 |
330 config->Read( wxT("lmin"), &lmin ); | 454 config->Read( wxT("lmin"), &lmin ); |
331 config->Read( wxT("lmax"), &lmax ); | 455 config->Read( wxT("lmax"), &lmax ); |
332 config->Read( wxT("zmin"), &zmin ); | 456 config->Read( wxT("zmin"), &zmin ); |
333 config->Read( wxT("zmax"), &zmax ); | 457 config->Read( wxT("zmax"), &zmax ); |
458 | |
334 } | 459 } |
335 /* 印刷 */ | 460 /* 印刷 */ |
336 void MyFrame::PrintImages( wxString hhsno ) | 461 void MyFrame::PrintImages( wxString hhsno ) |
337 { | 462 { |
338 bool mask_flag = false; | 463 bool mask_flag = false; |
339 wxMessageDialog md( this, wxT("マクスしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition ); | 464 wxMessageDialog md( this, wxT("マスクしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition ); |
340 if ( md.ShowModal() == wxID_YES ) { | 465 if ( md.ShowModal() == wxID_YES ) { |
341 mask_flag = true; | 466 mask_flag = true; |
342 } | 467 } |
343 | 468 |
344 // 印刷用の html を作成 | 469 // 印刷用の html を作成 |
524 return; | 649 return; |
525 } | 650 } |
526 /* アプリフォルダを開く */ | 651 /* アプリフォルダを開く */ |
527 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) | 652 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) |
528 { | 653 { |
654 OpenAppDir(); | |
655 } | |
656 void MyFrame::OpenAppDir( ) | |
657 { | |
529 wxString appdir = wxGetCwd(); | 658 wxString appdir = wxGetCwd(); |
530 wxString execmd = wxT("explorer ") + appdir; | 659 wxString execmd = wxT("explorer ") + appdir; |
531 wxExecute( execmd ); | 660 wxExecute( execmd ); |
532 } | 661 } |
533 /* ビューの切替え */ | |
534 void MyFrame::OnViewStyle( wxCommandEvent& event ) | |
535 { | |
536 if ( event.IsChecked() ) { | |
537 int x, y; | |
538 GetSize( &x, &y ); | |
539 SetSize( WINL_W + 500, y ); | |
540 m_splitter->SplitVertically( m_panelMain, m_panelView, 0 ); | |
541 } | |
542 else { | |
543 m_splitter->Unsplit(); | |
544 SetSize( WINL_W, -1 ); | |
545 } | |
546 } | |
547 /* 被保険者フォルダを開く */ | 662 /* 被保険者フォルダを開く */ |
548 void MyFrame::OnSelectHhsDir( wxListEvent& event ) | 663 void MyFrame::OnDClickItem( wxListEvent& event ) |
549 { | 664 { |
550 int i = event.GetIndex(); | 665 int i = event.GetIndex(); |
551 OpenHhsDir( i ); | 666 OpenHhsDir( i ); |
667 UpdateThumbmail( i ); | |
552 } | 668 } |
553 /* 番号で指定したフォルダを開く */ | 669 /* 番号で指定したフォルダを開く */ |
554 void MyFrame::OpenHhsDir( int n ) | 670 void MyFrame::OpenHhsDir( int n ) |
555 { | 671 { |
556 wxListItem item; | 672 wxListItem item; |
570 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); | 686 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
571 | 687 |
572 if ( kana->ShowModal() == wxID_OK ) { | 688 if ( kana->ShowModal() == wxID_OK ) { |
573 m_hhsno = kana->GetHhsNo(); | 689 m_hhsno = kana->GetHhsNo(); |
574 UpdateList( m_hhsno ); | 690 UpdateList( m_hhsno ); |
691 UpdateThumbmail( 0 ); | |
575 } | 692 } |
576 } | 693 } |
577 /* 検索履歴検索ダイアログ */ | 694 /* 検索履歴検索ダイアログ */ |
578 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) | 695 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) |
579 { | 696 { |
581 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); | 698 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
582 | 699 |
583 if ( hist->ShowModal() == wxID_OK ) { | 700 if ( hist->ShowModal() == wxID_OK ) { |
584 m_hhsno = hist->GetHhsNo(); | 701 m_hhsno = hist->GetHhsNo(); |
585 UpdateList( m_hhsno ); | 702 UpdateList( m_hhsno ); |
703 UpdateThumbmail( 0 ); | |
586 } | 704 } |
587 } | 705 } |
588 | 706 |
589 /* 検索結果をリストアップ */ | 707 /* 検索結果をリストアップ */ |
590 void MyFrame::UpdateList( wxString hhsno ) | 708 void MyFrame::UpdateList( wxString hhsno ) |
641 hist.RemoveLine( 20 ); | 759 hist.RemoveLine( 20 ); |
642 hist.InsertLine( history, 0 ); | 760 hist.InsertLine( history, 0 ); |
643 hist.Write(); | 761 hist.Write(); |
644 hist.Close(); | 762 hist.Close(); |
645 } | 763 } |
764 /* フォルダを選択したとき */ | |
765 void MyFrame::OnSelectItem( wxListEvent& event ) | |
766 { | |
767 UpdateThumbmail( event.GetIndex() ); | |
768 } | |
769 /* サムネイルを更新 */ | |
770 void MyFrame::UpdateThumbmail( int n ) | |
771 { | |
772 wxListItem item; | |
773 item.SetId( n ); | |
774 | |
775 item.SetColumn( 2 ); | |
776 item.SetMask( wxLIST_MASK_TEXT ); | |
777 m_listCtrl->GetItem( item ); | |
778 | |
779 m_thumbPanel->SetImages( item.GetText() ); | |
780 } | |
646 /* ステータスバーにメッセージを出力 */ | 781 /* ステータスバーにメッセージを出力 */ |
647 void MyFrame::SetStatusMessage( wxString msg, long n ) | 782 void MyFrame::SetStatusMessage( wxString msg, long n ) |
648 { | 783 { |
649 if ( GetStatusBar() ) | 784 if ( GetStatusBar() ) |
650 SetStatusText( msg, n ); | 785 SetStatusText( msg, n ); |
684 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) | 819 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) |
685 { | 820 { |
686 if ( !IsIconized() && !IsMaximized() ) { | 821 if ( !IsIconized() && !IsMaximized() ) { |
687 wxGetApp().rect = this->GetRect(); | 822 wxGetApp().rect = this->GetRect(); |
688 } | 823 } |
824 delete config; | |
689 Destroy(); | 825 Destroy(); |
690 } | 826 } |
691 /* アバウトダイアログ */ | 827 /* アバウトダイアログ */ |
692 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | 828 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) |
693 { | 829 { |