annotate Porori/src/porori.cpp @ 1:bcbe8663e582 default tip

bug fix.
author pyon@macmini
date Fri, 14 Feb 2020 18:48:53 +0900
parents 2b4fc52a96d9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
1 /* Filename : porori.cpp
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
2 Last Change: 2020-02-12 水 15:53:15.
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
3 by Takayuki Mutoh
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
4 */
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
5 #include "porori.h"
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
6 #include "sample.xpm"
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
7
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
8 PororiFrame::PororiFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
9 : wxFrame(parent, id, title, pos, size, style)
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
10 {
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
11 this->SetIcon(wxIcon(m_icon));
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
12 this->SetSizeHints(wxDefaultSize, wxDefaultSize);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
13 this->SetBackgroundColour(wxColour(110, 200, 100));
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
14
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
15 wxBoxSizer* bSizerTop = new wxBoxSizer(wxHORIZONTAL);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
16
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
17 m_datePickerFrom = new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN|wxDP_SHOWCENTURY);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
18 bSizerTop->Add(m_datePickerFrom, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
19
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
20 m_staticText = new wxStaticText(this, wxID_ANY, wxT("~"), wxDefaultPosition, wxDefaultSize, 0);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
21 bSizerTop->Add(m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
22
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
23 m_datePickerTo = new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN|wxDP_SHOWCENTURY);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
24 bSizerTop->Add(m_datePickerTo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
25
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
26 m_button = new wxButton( this, ID_PROCESS, wxT("実行"), wxDefaultPosition, wxDefaultSize, 0);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
27 bSizerTop->Add(m_button, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
28
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
29 this->SetSizer(bSizerTop);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
30 this->Layout();
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
31
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
32 this->Centre(wxBOTH);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
33
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
34 // Initiaize
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
35 for (wxDateTime t = m_datePickerFrom->GetValue(); ; t -= wxTimeSpan::Day()) {
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
36 if (t.GetWeekDay() == 1){
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
37 m_datePickerFrom->SetValue(t);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
38 break;
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
39 }
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
40 }
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
41
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
42 // Connect Events
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
43 m_button->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PororiFrame::OnClick), NULL, this);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
44 }
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
45
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
46 PororiFrame::~PororiFrame()
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
47 {
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
48 // Disconnect Events
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
49 m_button->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PororiFrame::OnClick), NULL, this);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
50 }
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
51
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
52 void PororiFrame::OnClick(wxCommandEvent& WXUNUSED(event))
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
53 {
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
54 wxTextFile file(m_json);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
55 if (file.Create() || file.Open()) {
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
56 file.Clear();
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
57 wxDateTime from = m_datePickerFrom->GetValue();
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
58 wxDateTime to = m_datePickerTo->GetValue();
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
59 wxString json = wxString::Format(wxT("{\"From\":\"%s\",\"To\":\"%s\"}"), from.Format(wxT("%Y%m%d")), to.Format(wxT("%Y%m%d")));
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
60 file.AddLine(json);
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
61 file.Write();
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
62 }
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
63 this->Close();
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
64 }
2b4fc52a96d9 porori.
pyon@macmini
parents:
diff changeset
65