annotate src/myframe.cpp @ 8:b59dfcc84d7a default tip

v0.4b
author pyon@macmini
date Thu, 13 Oct 2011 20:13:41 +0900
parents bfa0800f1176
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
1 // Filename : mainframe.cpp
8
pyon@macmini
parents: 7
diff changeset
2 // Last Change: 13-Oct-2011.
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
3 //
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
4 #include "symbol.h"
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
5 #include "common.h"
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
6 #include "myframe.h"
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
7 #include "delwhite.h"
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
8 #include "marksheet.h"
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
9 #include "main.h"
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
10
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
11 // resources
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
12 // the application icon (under Windows and OS/2 it is in resources and even
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
13 // though we could still include the XPM here it would be unused)
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
14 #if !defined(__WXMSW__) && !defined(__WXPM__)
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
15 #include "sample.xpm"
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
16 #endif
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
17
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
18 //////////////////////////////////////////////////////////////////////////
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
19 // control constructor
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
20
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
21 // 検索履歴をログに保存
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
22 /*
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
23 void MyCmdBox::WriteLog( wxString& cmd, wxString& path )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
24 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
25 wxString logfn = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("log.txt");
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
26 wxTextFile logFile;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
27 logFile.Open( logfn );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
28 wxDateTime now = wxDateTime::Now();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
29 wxString log = now.Format( wxT("%Y-%m-%d %H:%M:%S") ) + wxT(" ") + cmd + wxT(" ") + path;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
30 logFile.AddLine( log );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
31 logFile.Write();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
32 logFile.Close();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
33
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
34 return;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
35 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
36 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
37
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
38 //////////////////////////////////////////////////////////////////////////
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
39 // frame constructor
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
40 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
41 : wxFrame( parent, id, title )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
42 {
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
43 this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
44 // set the frame icon
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
45 SetIcon(wxICON(sample));
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
46
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
47 // メニューバー
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
48 m_menubar = new wxMenuBar();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
49
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
50 m_menuFile = new wxMenu();
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
51 m_menuFile->Append( ID_OPWORK, wxT("作業フォルダを開く"), wxT("Open work folder") );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
52 m_menuFile->AppendSeparator(); //----
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
53 m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") );
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
54 m_menuFile->AppendSeparator(); //----
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
55 m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
56
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
57 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
58
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
59 this->SetMenuBar( m_menubar );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
60
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
61 // ステータスバー
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
62 int widths[] = { -1, 150, 120 };
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
63 m_statusBar = this->CreateStatusBar( WXSIZEOF(widths), wxST_SIZEGRIP );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
64 m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
65 m_statusBar->SetStatusText( wxEmptyString, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
66
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
67 // コントロール
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
68 wxBoxSizer* bSizerTop;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
69 bSizerTop = new wxBoxSizer( wxVERTICAL );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
70
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
71 wxBoxSizer* bSizerWork;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
72 bSizerWork = new wxBoxSizer( wxHORIZONTAL );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
73
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
74 m_staticTextWork = new wxStaticText( this, wxID_ANY, wxT("作業用フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
75 bSizerWork->Add( m_staticTextWork, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
76
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
77 m_dirPickerWork = new wxDirPickerCtrl( this, ID_WORKDIR, wxGetApp().dir, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
78 bSizerWork->Add( m_dirPickerWork, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
79
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
80 m_buttonDetWhite = new wxButton( this, ID_DTWHITE, wxT("白紙検知"), wxDefaultPosition, wxDefaultSize, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
81 bSizerWork->Add( m_buttonDetWhite, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
82
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
83 bSizerTop->Add( bSizerWork, 0, wxEXPAND, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
84
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
85 wxBoxSizer* bSizerMoveTo;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
86 bSizerMoveTo = new wxBoxSizer( wxHORIZONTAL );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
87
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
88 m_staticTextMoveTo = new wxStaticText( this, wxID_ANY, wxT("移動先フォルダ"), wxDefaultPosition, wxDefaultSize, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
89 bSizerMoveTo->Add( m_staticTextMoveTo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
90
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
91 wxArrayString drives;
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
92 drives.Add(wxT("C:"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
93 drives.Add(wxT("Y:"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
94 drives.Add(wxT("Z:"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
95 m_comboBoxMoveDrive = new wxComboBox( this, ID_DRIVE, wxT("C:"), wxDefaultPosition, wxSize( 50,-1 ), drives, 0 );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
96 bSizerMoveTo->Add( m_comboBoxMoveDrive, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
97
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
98 m_datePickerCcn = new wxDatePickerCtrl( this, ID_DATE, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
99 bSizerMoveTo->Add( m_datePickerCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
100
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
101 wxArrayString ccns;
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
102 ccns.Add(wxT("角館1")); ccns.Add(wxT("角館2")); ccns.Add(wxT("角館3")); ccns.Add(wxT("角館4"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
103 ccns.Add(wxT("西仙1")); ccns.Add(wxT("西仙2")); ccns.Add(wxT("西仙3"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
104 ccns.Add(wxT("千畑1")); ccns.Add(wxT("千畑2")); ccns.Add(wxT("千畑3"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
105 ccns.Add(wxT("大曲1")); ccns.Add(wxT("大曲2")); ccns.Add(wxT("大曲3")); ccns.Add(wxT("大曲4")); ccns.Add(wxT("大曲5")); ccns.Add(wxT("大曲6"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
106 ccns.Add(wxT("六郷1")); ccns.Add(wxT("六郷2")); ccns.Add(wxT("六郷3"));
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
107 m_comboBoxCcn = new wxComboBox( this, ID_CCN, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), ccns, 0 );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
108 bSizerMoveTo->Add( m_comboBoxCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
109
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
110 m_buttonSetDir = new wxButton( this, ID_STDIR, wxT("フォルダ指定"), wxDefaultPosition, wxDefaultSize, 0 );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
111 bSizerMoveTo->Add( m_buttonSetDir, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
112
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
113 m_buttonMkDir = new wxButton( this, ID_MKDIR, wxT("フォルダ作成"), wxDefaultPosition, wxDefaultSize, 0 );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
114 bSizerMoveTo->Add( m_buttonMkDir, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
115
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
116 bSizerTop->Add( bSizerMoveTo, 0, 0, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
117
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
118 wxBoxSizer* bSizerDoMove;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
119 bSizerDoMove = new wxBoxSizer( wxHORIZONTAL );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
120
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
121 m_staticTextDummy = new wxStaticText( this, wxID_ANY, wxT("移動先ふぉるだ"), wxDefaultPosition, wxDefaultSize, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
122 m_staticTextDummy->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
123
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
124 bSizerDoMove->Add( m_staticTextDummy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
125
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
126 m_textCtrlMoveDir = new wxTextCtrl( this, ID_DIR, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
127 m_textCtrlMoveDir->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
128
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
129 bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
130
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
131 m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
132
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
133 bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
134
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
135 bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
136
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
137 m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
138 wxListItem itemCol;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
139 itemCol.SetText( wxT("通番") );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
140 m_listCtrl->InsertColumn( 0, itemCol );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
141 m_listCtrl->SetColumnWidth( 0, 100 );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
142 itemCol.SetText( wxT("被保険者番号") );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
143 m_listCtrl->InsertColumn( 1, itemCol );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
144 m_listCtrl->SetColumnWidth( 1, 180 );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
145 itemCol.SetText( wxT("ファイル数") );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
146 m_listCtrl->InsertColumn( 2, itemCol );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
147 m_listCtrl->SetColumnWidth( 1, 100 );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
148 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
149
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
150 this->SetSizer( bSizerTop );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
151 this->Layout();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
152
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
153 this->Centre( wxBOTH );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
154 m_buttonDetWhite->SetFocus();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
155 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
156
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
157 // destructor
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
158 MyFrame::~MyFrame()
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
159 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
160 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
161
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
162 // Event Table
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
163 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
164 EVT_SIZE( MyFrame::OnSize )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
165 EVT_MOVE( MyFrame::OnMove )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
166 EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
167 EVT_MENU( wxID_ABOUT, MyFrame::OnAbout )
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
168 EVT_MENU( ID_OPWORK, MyFrame::OnOpenWorkDir )
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
169 EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite )
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
170 EVT_BUTTON( ID_STDIR, MyFrame::SetDir )
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
171 EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir )
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
172 EVT_BUTTON( ID_DOMOVE, MyFrame::MoveImages )
5
pyon@macmini
parents: 4
diff changeset
173 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir )
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
174 EVT_CLOSE( MyFrame::SaveConfig )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
175 END_EVENT_TABLE()
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
176
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
177 // Event Handlers
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
178 /* サイズ変更 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
179 void MyFrame::OnSize(wxSizeEvent& event)
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
180 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
181 this->Refresh( true, NULL );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
182 TellLocation();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
183 event.Skip();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
184 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
185 /* ウィンドウ移動 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
186 void MyFrame::OnMove(wxMoveEvent& WXUNUSED(event))
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
187 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
188 TellLocation();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
189 return;
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
190 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
191 /* ウィンドウ位置とサイズを表示 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
192 void MyFrame::TellLocation( void )
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
193 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
194 wxRect r = this->GetRect();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
195 int x = r.GetX();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
196 int y = r.GetY();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
197 int w = r.GetWidth();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
198 int h = r.GetHeight();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
199 SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 2 );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
200 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
201 /* 終了 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
202 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
203 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
204 Close(true);
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
205 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
206
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
207 /* バージョン情報 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
208 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
209 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
210 wxMessageBox(
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
211 wxString::Format(
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
212 wxT("Version %d.%d ( build %d ) by %s\n")
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
213 wxT("running under %s."),
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
214 VER, REV, BLD, wxVERSION_STRING,
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
215 wxGetOsDescription().c_str()
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
216 ),
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
217 wxT("About this program"), wxOK | wxICON_INFORMATION, this );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
218 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
219
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
220 /* 白紙検知 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
221 void MyFrame::OnDetectWhite(wxCommandEvent& WXUNUSED(event))
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
222 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
223 FrameDelWhite* dw = new FrameDelWhite( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
8
pyon@macmini
parents: 7
diff changeset
224 dw->SetMinSize( wxSize( 580, 380 ) );
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
225
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
226 dw->m_dir = m_dirPickerWork->GetPath();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
227 dw->SetTitle( wxT("Delete White Sheet - ") + dw->m_dir );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
228 dw->LoadImages();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
229
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
230 dw->Show(true);
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
231 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
232
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
233 /* 移動先フォルダセット */
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
234 void MyFrame::SetDir(wxCommandEvent& WXUNUSED(event))
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
235 {
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
236 wxString dir;
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
237 dir.Append( m_comboBoxMoveDrive->GetValue() );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
238 dir.Append( wxFILE_SEP_PATH );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
239 wxDateTime dt = m_datePickerCcn->GetValue();
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
240 dir.Append( dt.Format(wxT("%Y%m%d")) );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
241 dir.Append( wxFILE_SEP_PATH );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
242 dir.Append( m_comboBoxCcn->GetValue() );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
243 m_textCtrlMoveDir->SetValue( dir );
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
244 }
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
245
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
246 /* 移動先フォルダ作成 */
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
247 void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event))
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
248 {
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
249 wxString dirname = m_textCtrlMoveDir->GetValue();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
250 wxString ccn = m_comboBoxCcn->GetValue();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
251 if ( dirname.Len() < 15 || ccn.IsEmpty() ) {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
252 wxMessageBox(wxT("フォルダを指定してください."));
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
253 return;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
254 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
255
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
256 wxStringTokenizer tkz( dirname, wxFILE_SEP_PATH );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
257 wxString d;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
258 while ( tkz.HasMoreTokens() ) {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
259 d.Append( tkz.GetNextToken() );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
260 d.Append( wxFILE_SEP_PATH );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
261 if ( !wxDirExists( d ) ) wxMkdir( d );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
262 }
3
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
263 }
a5bddd859104 implement delwhtie
pyon@macmini
parents: 2
diff changeset
264
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
265 /* 画像移動 */
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
266 void MyFrame::MoveImages(wxCommandEvent& WXUNUSED(event))
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
267 {
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
268 wxString dirname = m_textCtrlMoveDir->GetValue();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
269 wxString ccn = m_comboBoxCcn->GetValue();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
270 if ( dirname.IsEmpty() || ccn.IsEmpty() ) {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
271 wxMessageBox(wxT("フォルダを指定してください."));
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
272 return;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
273 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
274
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
275 dirname.Append( wxFILE_SEP_PATH );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
276 if ( !wxDirExists( dirname ) ) {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
277 wxMessageBox(wxT("フォルダが存在しません."));
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
278 return;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
279 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
280
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
281 wxString workdir = m_dirPickerWork->GetPath();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
282 wxDir dir( workdir );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
283 if ( !dir.IsOpened() ) return;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
284
8
pyon@macmini
parents: 7
diff changeset
285 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 200, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
pyon@macmini
parents: 7
diff changeset
286 pd.SetSize( wxSize(320,140) );
pyon@macmini
parents: 7
diff changeset
287 int p=0;
pyon@macmini
parents: 7
diff changeset
288
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
289 wxString filename;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
290 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
291
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
292 int cnt=0, r=0;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
293 wxString hhs;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
294 m_listCtrl->DeleteAllItems();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
295 while ( cout ) {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
296 wxString from = workdir + wxFILE_SEP_PATH + filename;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
297 if ( IsMarksheet( from ) ) {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
298 hhs = GuessHhs( from );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
299 wxString d = dirname + hhs;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
300 wxMkdir( d );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
301 m_listCtrl->InsertItem( r, wxString::Format(wxT("%d"),r+1) );
8
pyon@macmini
parents: 7
diff changeset
302 m_listCtrl->SetItem( r, 1, hhs, -1 ); // 被保険者番号
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
303 if ( r % 2 ) m_listCtrl->SetItemBackgroundColour( r, wxColour(wxT("WHEAT")) );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
304 r++;
7
bfa0800f1176 fix text-color
pyon@macmini
parents: 6
diff changeset
305 cnt=1;
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
306 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
307 if ( hhs.IsEmpty() ) {
7
bfa0800f1176 fix text-color
pyon@macmini
parents: 6
diff changeset
308 wxMessageBox(wxT("1枚目のマークシートの画像ファイルを確認してください."));
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
309 return;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
310 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
311 wxString to = dirname + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
312 wxRenameFile( from, to, false );
7
bfa0800f1176 fix text-color
pyon@macmini
parents: 6
diff changeset
313 m_listCtrl->SetItem( r-1, 2, wxString::Format(wxT("%d"),cnt), -1 ); // ファイル数
8
pyon@macmini
parents: 7
diff changeset
314 if ( cnt < 5 ) m_listCtrl->SetItemTextColour( r, wxColour(wxT("RED")) );
pyon@macmini
parents: 7
diff changeset
315 if ( cnt > 5 ) m_listCtrl->SetItemTextColour( r, wxColour(wxT("BLUE")) );
7
bfa0800f1176 fix text-color
pyon@macmini
parents: 6
diff changeset
316 cnt++;
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
317 // write log
8
pyon@macmini
parents: 7
diff changeset
318 pd.Update( p++, wxEmptyString );
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
319 cout = dir.GetNext( &filename );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
320 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
321
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
322 wxString cmd = wxT("explorer ") + dirname;
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
323 wxExecute( cmd );
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
324 }
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
325
5
pyon@macmini
parents: 4
diff changeset
326 /* 被保険者のフォルダを開く */
6
pyon@macmini
parents: 5
diff changeset
327 void MyFrame::OnOpenHhsDir(wxListEvent& event)
5
pyon@macmini
parents: 4
diff changeset
328 {
pyon@macmini
parents: 4
diff changeset
329 wxString hhsdir = m_textCtrlMoveDir->GetValue();
pyon@macmini
parents: 4
diff changeset
330 hhsdir.Append( wxFILE_SEP_PATH );
6
pyon@macmini
parents: 5
diff changeset
331
pyon@macmini
parents: 5
diff changeset
332 wxListItem item = event.GetItem();
pyon@macmini
parents: 5
diff changeset
333 item.SetColumn(1);
pyon@macmini
parents: 5
diff changeset
334 item.SetMask(wxLIST_MASK_TEXT);
pyon@macmini
parents: 5
diff changeset
335 m_listCtrl->GetItem( item );
5
pyon@macmini
parents: 4
diff changeset
336 hhsdir.Append( item.GetText() );
8
pyon@macmini
parents: 7
diff changeset
337 //wxMessageBox(hhsdir);
pyon@macmini
parents: 7
diff changeset
338 wxString execmd = wxT("explorer ") + hhsdir;
pyon@macmini
parents: 7
diff changeset
339 wxExecute( execmd );
5
pyon@macmini
parents: 4
diff changeset
340 }
pyon@macmini
parents: 4
diff changeset
341
4
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
342 /* 作業フォルダを開く */
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
343 void MyFrame::OnOpenWorkDir(wxCommandEvent& WXUNUSED(event))
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
344 {
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
345 wxString workdir = m_dirPickerWork->GetPath();
a505f7417742 v0.1 release
pyon@macmini
parents: 3
diff changeset
346 wxString execmd = wxT("explorer ") + workdir;
2
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
347 wxExecute( execmd );
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
348 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
349
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
350
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
351 /* 設定を保存 */
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
352 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event))
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
353 {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
354 if ( !IsIconized() && !IsMaximized() ) {
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
355 wxGetApp().rect = this->GetRect();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
356 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
357 wxGetApp().dir = m_dirPickerWork->GetPath();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
358
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
359 Destroy();
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
360 }
1ea4f7981ff5 create window.
pyon@macmini
parents:
diff changeset
361