comparison src/myframe.cpp @ 0:0c0701a935f8

Start Development.
author pyon@macmini
date Sun, 21 Jul 2013 16:07:19 +0900
parents
children 7b6dab24f4b8
comparison
equal deleted inserted replaced
-1:000000000000 0:0c0701a935f8
1 // Filename : myframe.cpp
2 // Last Change: 21-Jul-2013.
3 //
4 #include "main.h"
5 #include "myframe.h"
6 #include "about.h"
7 #include "kana.h"
8 #include "hist.h"
9 #include "index.h"
10 #include "mask.h"
11
12 #define WINL_W 400
13 #define LOGO_W 200
14 #define LOGO_H 92
15
16 // resources
17 #if !defined(__WXMSW__) && !defined(__WXPM__)
18 #include "sample.xpm"
19 #endif
20
21
22 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
23 : wxFrame( parent, id, title, pos, size, style )
24 {
25 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize );
26 this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
27 //this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
28
29 // set the frame icon
30 SetIcon(wxICON(sample));
31
32 // メニューバー Menu
33 m_menubar = new wxMenuBar( 0 );
34 m_menuFile = new wxMenu();
35
36 wxMenuItem* m_menuItemViewMode = new wxMenuItem( m_menuFile, ID_MNVIEW, wxString( wxT("ビューモード") ) , wxT("Toggle ViewMode"), wxITEM_CHECK );
37 m_menuFile->Append( m_menuItemViewMode );
38
39 m_menuFile->AppendSeparator(); // ----
40
41 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス") ) , wxT("Update index"), wxITEM_NORMAL );
42 m_menuFile->Append( m_menuItemIndex );
43
44 wxMenuItem* m_menuItemMask = new wxMenuItem( m_menuFile, ID_MNMASKPARAM, wxString( wxT("マスクパラメータ") ) , wxT("Setup mask parameters"), wxITEM_NORMAL );
45 m_menuFile->Append( m_menuItemMask );
46
47 wxMenuItem* m_menuItemAppDir = new wxMenuItem( m_menuFile, ID_MNAPPDIR, wxString( wxT("アプリケーションフォルダを開く") ) , wxT("Open application directory"), wxITEM_NORMAL );
48 m_menuFile->Append( m_menuItemAppDir );
49
50 m_menuFile->AppendSeparator(); // ----
51
52 wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL );
53 m_menuFile->Append( m_menuItemAbout );
54
55 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") );
56
57 this->SetMenuBar( m_menubar );
58
59 //
60 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
61
62 m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
63 //m_splitter->Connect( wxEVT_IDLE, wxIdleEventHandler( MyFrame::m_splitterOnIdle ), NULL, this );
64
65 m_panelL = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
66 wxBoxSizer* bSizerL = new wxBoxSizer( wxVERTICAL );
67
68 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png");
69 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG );
70 m_bitmap = new wxStaticBitmap( m_panelL, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 );
71 bSizerL->Add( m_bitmap, 0, wxALL, 5 );
72
73 m_textCtrlName = new wxTextCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 );
74 bSizerL->Add( m_textCtrlName, 0, wxALL, 5 );
75
76 m_textCtrlAddr = new wxTextCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 );
77 bSizerL->Add( m_textCtrlAddr, 0, wxALL, 5 );
78
79 m_listCtrl = new wxListCtrl( m_panelL, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
80 wxListItem itemCol;
81 itemCol.SetText( wxT("通番") );
82 m_listCtrl->InsertColumn( 0, itemCol );
83 m_listCtrl->SetColumnWidth( 0, 50 );
84 itemCol.SetText( wxT("年月日") );
85 m_listCtrl->InsertColumn( 1, itemCol );
86 m_listCtrl->SetColumnWidth( 1, 80 );
87 itemCol.SetText( wxT("場所") );
88 m_listCtrl->InsertColumn( 2, itemCol );
89 m_listCtrl->SetColumnWidth( 2, 300 );
90 bSizerL->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
91
92 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL );
93
94 //m_staticText = new wxStaticText( m_panelL, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 );
95 //bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
96
97 m_searchCtrl = new wxSearchCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
98 #ifndef __WXMAC__
99 m_searchCtrl->ShowSearchButton( true );
100 #endif
101 m_searchCtrl->ShowCancelButton( false );
102 bSizerCmd->Add( m_searchCtrl, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
103
104 m_buttonKana = new wxButton( m_panelL, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxDefaultSize, 0 );
105 bSizerCmd->Add( m_buttonKana, 0, wxALL, 5 );
106
107 m_buttonHist = new wxButton( m_panelL, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxDefaultSize, 0 );
108 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 );
109
110 bSizerL->Add( bSizerCmd, 0, wxEXPAND, 5 );
111
112 m_panelL->SetSizer( bSizerL );
113 m_panelL->Layout();
114 bSizerL->Fit( m_panelL );
115
116 m_panelR = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
117 wxBoxSizer* bSizerR = new wxBoxSizer( wxHORIZONTAL );
118
119 m_bitmapView = new wxStaticBitmap( m_panelR, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
120 bSizerR->Add( m_bitmapView, 1, wxALL|wxEXPAND, 5 );
121
122 m_listCtrlThumb = new wxListCtrl( m_panelR, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
123 bSizerR->Add( m_listCtrlThumb, 0, wxALL|wxEXPAND, 5 );
124
125 m_panelR->SetSizer( bSizerR );
126 m_panelR->Layout();
127 bSizerR->Fit( m_panelR );
128
129 m_panelR->Show( false );
130 bSizerTop->Add( m_splitter, 1, wxEXPAND, 5 );
131
132 this->SetSizer( bSizerTop );
133 this->Layout();
134
135 // ステータスバー Statusbar
136 m_statusBar = this->CreateStatusBar( 4, wxST_SIZEGRIP, wxID_ANY );
137 int widths[] = { 200, 100, -1, 90 };
138 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths );
139
140 this->Centre( wxBOTH );
141 }
142
143 MyFrame::~MyFrame()
144 {
145 }
146
147 // Event Table
148 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
149 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout )
150 EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
151 EVT_MENU( ID_MNVIEW, MyFrame::OnViewMode )
152 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex )
153 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam )
154 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir )
155 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir )
156 EVT_BUTTON( ID_KANA, MyFrame::OnKana )
157 EVT_BUTTON( ID_HIST, MyFrame::OnHistory )
158 EVT_SIZE( MyFrame::OnWinSize )
159 EVT_MOVE( MyFrame::OnWinMove )
160 EVT_CLOSE( MyFrame::SaveConfig )
161 END_EVENT_TABLE()
162
163 // Event Handlers & Functions
164 /* インデックス作成ダイアログ */
165 void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) )
166 {
167 IndexDialog* index = new IndexDialog( this, wxID_ANY, wxT("インデックス作成"), wxDefaultPosition, wxSize( 500, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
168 index->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
169 index->ShowModal();
170 }
171 /* マスクパラメータ設定ダイアログ */
172 void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) )
173 {
174 MaskDialog* mask = new MaskDialog( this, wxID_ANY, wxT("マスク位置とサイズの指定"), wxDefaultPosition, wxSize( 400, 210 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
175 mask->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
176 mask->ShowModal();
177 }
178 /* アプリフォルダを開く */
179 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) )
180 {
181 wxString appdir = wxGetCwd();
182 wxString execmd = wxT("explorer ") + appdir;
183 wxExecute( execmd );
184 }
185 /* ビューモードの切替え */
186 void MyFrame::OnViewMode( wxCommandEvent& event )
187 {
188 if ( event.IsChecked() ) {
189 int x, y;
190 GetSize( &x, &y );
191 SetSize( WINL_W + 500, y );
192 m_splitter->SplitVertically( m_panelL, m_panelR, 0 );
193 }
194 else {
195 m_splitter->Unsplit();
196 SetSize( WINL_W, -1 );
197 }
198 }
199 /* 被保険者フォルダを開く */
200 void MyFrame::OnOpenHhsDir( wxListEvent& event )
201 {
202 wxString hhsdir;
203 /*
204 hhsdir = m_textCtrlDist->GetValue() + wxFILE_SEP_PATH;
205
206 int i = event.GetIndex();
207 wxListItem item;
208 item.SetId(i);
209
210 item.SetColumn(1);
211 item.SetMask(wxLIST_MASK_TEXT);
212 m_listCtrlHhsDir->GetItem( item );
213 hhsdir.Append( item.GetText() );
214
215 DirViewFrame* dvf = new DirViewFrame( (wxWindow*)this, wxID_ANY, wxEmptyString );
216 dvf->m_dir = hhsdir;
217 dvf->LoadListImage();
218 dvf->Show(true);
219 */
220 }
221 /* カナ検索ダイアログ */
222 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) )
223 {
224 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 500, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
225 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
226 kana->ShowModal();
227 }
228 /* 検索履歴検索ダイアログ */
229 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) )
230 {
231 HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 550, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
232 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
233 hist->ShowModal();
234 }
235
236 /* サイズ変更 */
237 void MyFrame::OnWinSize( wxSizeEvent& event )
238 {
239 this->Refresh( true, NULL );
240 TellLocation();
241 event.Skip();
242 }
243 /* ウィンドウ移動 */
244 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) )
245 {
246 TellLocation();
247 return;
248 }
249 /* ウィンドウ位置とサイズを表示 */
250 void MyFrame::TellLocation( void )
251 {
252 wxRect r = this->GetRect();
253 int x = r.GetX();
254 int y = r.GetY();
255 int w = r.GetWidth();
256 int h = r.GetHeight();
257 //SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 );
258 }
259 /* 終了 */
260 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
261 {
262 Close( true );
263 }
264 /* 設定を保存 */
265 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) )
266 {
267 if ( !IsIconized() && !IsMaximized() ) {
268 wxGetApp().rect = this->GetRect();
269 }
270 Destroy();
271 }
272 /* アバウトダイアログ */
273 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
274 {
275 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP );
276 aboutDlg->ShowModal();
277 }
278