Mercurial > mercurial > hgweb_searcher03.cgi
diff src/myframe.cpp @ 0:0c0701a935f8
Start Development.
author | pyon@macmini |
---|---|
date | Sun, 21 Jul 2013 16:07:19 +0900 |
parents | |
children | 7b6dab24f4b8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/myframe.cpp Sun Jul 21 16:07:19 2013 +0900 @@ -0,0 +1,278 @@ +// Filename : myframe.cpp +// Last Change: 21-Jul-2013. +// +#include "main.h" +#include "myframe.h" +#include "about.h" +#include "kana.h" +#include "hist.h" +#include "index.h" +#include "mask.h" + +#define WINL_W 400 +#define LOGO_W 200 +#define LOGO_H 92 + +// resources +#if !defined(__WXMSW__) && !defined(__WXPM__) + #include "sample.xpm" +#endif + + +MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) + : wxFrame( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize ); + this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + //this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); + + // set the frame icon + SetIcon(wxICON(sample)); + + // メニューバー Menu + m_menubar = new wxMenuBar( 0 ); + m_menuFile = new wxMenu(); + + wxMenuItem* m_menuItemViewMode = new wxMenuItem( m_menuFile, ID_MNVIEW, wxString( wxT("ビューモード") ) , wxT("Toggle ViewMode"), wxITEM_CHECK ); + m_menuFile->Append( m_menuItemViewMode ); + + m_menuFile->AppendSeparator(); // ---- + + wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス") ) , wxT("Update index"), wxITEM_NORMAL ); + m_menuFile->Append( m_menuItemIndex ); + + wxMenuItem* m_menuItemMask = new wxMenuItem( m_menuFile, ID_MNMASKPARAM, wxString( wxT("マスクパラメータ") ) , wxT("Setup mask parameters"), wxITEM_NORMAL ); + m_menuFile->Append( m_menuItemMask ); + + wxMenuItem* m_menuItemAppDir = new wxMenuItem( m_menuFile, ID_MNAPPDIR, wxString( wxT("アプリケーションフォルダを開く") ) , wxT("Open application directory"), wxITEM_NORMAL ); + m_menuFile->Append( m_menuItemAppDir ); + + m_menuFile->AppendSeparator(); // ---- + + wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL ); + m_menuFile->Append( m_menuItemAbout ); + + m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); + + this->SetMenuBar( m_menubar ); + + // + wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); + + m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D ); + //m_splitter->Connect( wxEVT_IDLE, wxIdleEventHandler( MyFrame::m_splitterOnIdle ), NULL, this ); + + m_panelL = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerL = new wxBoxSizer( wxVERTICAL ); + + wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); + wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); + m_bitmap = new wxStaticBitmap( m_panelL, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 ); + bSizerL->Add( m_bitmap, 0, wxALL, 5 ); + + m_textCtrlName = new wxTextCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 ); + bSizerL->Add( m_textCtrlName, 0, wxALL, 5 ); + + m_textCtrlAddr = new wxTextCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 ); + bSizerL->Add( m_textCtrlAddr, 0, wxALL, 5 ); + + m_listCtrl = new wxListCtrl( m_panelL, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); + wxListItem itemCol; + itemCol.SetText( wxT("通番") ); + m_listCtrl->InsertColumn( 0, itemCol ); + m_listCtrl->SetColumnWidth( 0, 50 ); + itemCol.SetText( wxT("年月日") ); + m_listCtrl->InsertColumn( 1, itemCol ); + m_listCtrl->SetColumnWidth( 1, 80 ); + itemCol.SetText( wxT("場所") ); + m_listCtrl->InsertColumn( 2, itemCol ); + m_listCtrl->SetColumnWidth( 2, 300 ); + bSizerL->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); + + //m_staticText = new wxStaticText( m_panelL, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); + //bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_searchCtrl = new wxSearchCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + #ifndef __WXMAC__ + m_searchCtrl->ShowSearchButton( true ); + #endif + m_searchCtrl->ShowCancelButton( false ); + bSizerCmd->Add( m_searchCtrl, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonKana = new wxButton( m_panelL, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerCmd->Add( m_buttonKana, 0, wxALL, 5 ); + + m_buttonHist = new wxButton( m_panelL, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); + + bSizerL->Add( bSizerCmd, 0, wxEXPAND, 5 ); + + m_panelL->SetSizer( bSizerL ); + m_panelL->Layout(); + bSizerL->Fit( m_panelL ); + + m_panelR = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerR = new wxBoxSizer( wxHORIZONTAL ); + + m_bitmapView = new wxStaticBitmap( m_panelR, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerR->Add( m_bitmapView, 1, wxALL|wxEXPAND, 5 ); + + m_listCtrlThumb = new wxListCtrl( m_panelR, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); + bSizerR->Add( m_listCtrlThumb, 0, wxALL|wxEXPAND, 5 ); + + m_panelR->SetSizer( bSizerR ); + m_panelR->Layout(); + bSizerR->Fit( m_panelR ); + + m_panelR->Show( false ); + bSizerTop->Add( m_splitter, 1, wxEXPAND, 5 ); + + this->SetSizer( bSizerTop ); + this->Layout(); + + // ステータスバー Statusbar + m_statusBar = this->CreateStatusBar( 4, wxST_SIZEGRIP, wxID_ANY ); + int widths[] = { 200, 100, -1, 90 }; + m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); + + this->Centre( wxBOTH ); +} + +MyFrame::~MyFrame() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MyFrame, wxFrame ) + EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) + EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) + EVT_MENU( ID_MNVIEW, MyFrame::OnViewMode ) + EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) + EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) + EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) + EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) + EVT_BUTTON( ID_KANA, MyFrame::OnKana ) + EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) + EVT_SIZE( MyFrame::OnWinSize ) + EVT_MOVE( MyFrame::OnWinMove ) + EVT_CLOSE( MyFrame::SaveConfig ) +END_EVENT_TABLE() + +// Event Handlers & Functions +/* インデックス作成ダイアログ */ +void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) ) +{ + IndexDialog* index = new IndexDialog( this, wxID_ANY, wxT("インデックス作成"), wxDefaultPosition, wxSize( 500, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); + index->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); + index->ShowModal(); +} +/* マスクパラメータ設定ダイアログ */ +void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) ) +{ + MaskDialog* mask = new MaskDialog( this, wxID_ANY, wxT("マスク位置とサイズの指定"), wxDefaultPosition, wxSize( 400, 210 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); + mask->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); + mask->ShowModal(); +} +/* アプリフォルダを開く */ +void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) +{ + wxString appdir = wxGetCwd(); + wxString execmd = wxT("explorer ") + appdir; + wxExecute( execmd ); +} +/* ビューモードの切替え */ +void MyFrame::OnViewMode( wxCommandEvent& event ) +{ + if ( event.IsChecked() ) { + int x, y; + GetSize( &x, &y ); + SetSize( WINL_W + 500, y ); + m_splitter->SplitVertically( m_panelL, m_panelR, 0 ); + } + else { + m_splitter->Unsplit(); + SetSize( WINL_W, -1 ); + } +} +/* 被保険者フォルダを開く */ +void MyFrame::OnOpenHhsDir( wxListEvent& event ) +{ + wxString hhsdir; + /* + hhsdir = m_textCtrlDist->GetValue() + wxFILE_SEP_PATH; + + int i = event.GetIndex(); + wxListItem item; + item.SetId(i); + + item.SetColumn(1); + item.SetMask(wxLIST_MASK_TEXT); + m_listCtrlHhsDir->GetItem( item ); + hhsdir.Append( item.GetText() ); + + DirViewFrame* dvf = new DirViewFrame( (wxWindow*)this, wxID_ANY, wxEmptyString ); + dvf->m_dir = hhsdir; + dvf->LoadListImage(); + dvf->Show(true); + */ +} +/* カナ検索ダイアログ */ +void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) +{ + KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 500, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); + kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); + kana->ShowModal(); +} +/* 検索履歴検索ダイアログ */ +void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) +{ + HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 550, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); + hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); + hist->ShowModal(); +} + +/* サイズ変更 */ +void MyFrame::OnWinSize( wxSizeEvent& event ) +{ + this->Refresh( true, NULL ); + TellLocation(); + event.Skip(); +} +/* ウィンドウ移動 */ +void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) ) +{ + TellLocation(); + return; +} +/* ウィンドウ位置とサイズを表示 */ +void MyFrame::TellLocation( void ) +{ + wxRect r = this->GetRect(); + int x = r.GetX(); + int y = r.GetY(); + int w = r.GetWidth(); + int h = r.GetHeight(); + //SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 ); +} +/* 終了 */ +void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) +{ + Close( true ); +} +/* 設定を保存 */ +void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) +{ + if ( !IsIconized() && !IsMaximized() ) { + wxGetApp().rect = this->GetRect(); + } + Destroy(); +} +/* アバウトダイアログ */ +void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) +{ + AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); + aboutDlg->ShowModal(); +} +