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