Mercurial > mercurial > hgweb_porori.cgi
view 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 |
line wrap: on
line source
/* Filename : porori.cpp Last Change: 2020-02-12 水 15:53:15. by Takayuki Mutoh */ #include "porori.h" #include "sample.xpm" PororiFrame::PororiFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style) { this->SetIcon(wxIcon(m_icon)); this->SetSizeHints(wxDefaultSize, wxDefaultSize); this->SetBackgroundColour(wxColour(110, 200, 100)); wxBoxSizer* bSizerTop = new wxBoxSizer(wxHORIZONTAL); m_datePickerFrom = new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN|wxDP_SHOWCENTURY); bSizerTop->Add(m_datePickerFrom, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); m_staticText = new wxStaticText(this, wxID_ANY, wxT("~"), wxDefaultPosition, wxDefaultSize, 0); bSizerTop->Add(m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5); m_datePickerTo = new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN|wxDP_SHOWCENTURY); bSizerTop->Add(m_datePickerTo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); m_button = new wxButton( this, ID_PROCESS, wxT("実行"), wxDefaultPosition, wxDefaultSize, 0); bSizerTop->Add(m_button, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); this->SetSizer(bSizerTop); this->Layout(); this->Centre(wxBOTH); // Initiaize for (wxDateTime t = m_datePickerFrom->GetValue(); ; t -= wxTimeSpan::Day()) { if (t.GetWeekDay() == 1){ m_datePickerFrom->SetValue(t); break; } } // Connect Events m_button->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PororiFrame::OnClick), NULL, this); } PororiFrame::~PororiFrame() { // Disconnect Events m_button->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PororiFrame::OnClick), NULL, this); } void PororiFrame::OnClick(wxCommandEvent& WXUNUSED(event)) { wxTextFile file(m_json); if (file.Create() || file.Open()) { file.Clear(); wxDateTime from = m_datePickerFrom->GetValue(); wxDateTime to = m_datePickerTo->GetValue(); wxString json = wxString::Format(wxT("{\"From\":\"%s\",\"To\":\"%s\"}"), from.Format(wxT("%Y%m%d")), to.Format(wxT("%Y%m%d"))); file.AddLine(json); file.Write(); } this->Close(); }