HatchKeeper  0.90
The Free Open-Source Egg Incubation Software
DateDialog.cpp
Go to the documentation of this file.
1 /*******************************************************************/
10 #include <wx/wx.h>
11 #include <wx/datetime.h>
12 #include "../../headers/Date.h"
13 #include "../../headers/Declare.h"
14 
23 class DateDialog : public wxDialog
24 {
25  protected:
27  wxDatePickerCtrl* dateCalPicker;
29  public:
30  void OnDateSave(wxCommandEvent& );
31  HK_Date GetDate();
32  DateDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Date"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 200,110 ), long style = wxCAPTION|wxSYSTEM_MENU );
33 };
34 
36 DateDialog::DateDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
37 {
38  this->SetSizeHints( wxDefaultSize, wxDefaultSize );
39 
40  //Colors
41  vector<int> ColorRed = Settings.GetIntArray("ColorRed");
42  vector<int> ColorGreen = Settings.GetIntArray("ColorGreen");
43  vector<int> ColorBlue = Settings.GetIntArray("ColorBlue");
44  this->SetForegroundColour( wxColor(ColorRed[8],ColorGreen[8],ColorBlue[8]) );
45  this->SetBackgroundColour( wxColor(ColorRed[7],ColorGreen[7],ColorBlue[7]) );
46 
47  wxBoxSizer* bSizer1;
48  bSizer1 = new wxBoxSizer( wxVERTICAL );
49 
50  dateCalPicker = new wxDatePickerCtrl( this, wxID_ANY, wxDateTime::Today() , wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN );
51  bSizer1->Add( dateCalPicker, 0, wxALL|wxEXPAND, 5 );
52 
53  dateDialogSaveButton = new wxButton( this,wxID_ANY, l("Select"), wxDefaultPosition, wxDefaultSize, 0 );
54  bSizer1->Add( dateDialogSaveButton, 1, wxALL|wxEXPAND, 5 );
55 
56  this->SetSizer( bSizer1 );
57  this->Layout();
58 
59  this->Centre( wxBOTH );
60 
61  dateDialogSaveButton->Bind(wxEVT_BUTTON, &DateDialog::OnDateSave, this);
62 }
63 
65 void DateDialog::OnDateSave(wxCommandEvent&)
66 {
67  wxDateTime selDate = dateCalPicker->GetValue();
68 
69  DateDialogDate.SetDay(selDate.GetDay(wxDateTime::Local));
70  DateDialogDate.SetYear(selDate.GetYear(wxDateTime::Local));
71  DateDialogDate.SetMonth(selDate.GetMonth(wxDateTime::Local) + 1);
72  EndModal(0);
73 }
74 
HK_KeyValue Settings
Definition: Declare.h:36
HK_Date Today
Definition: Declare.h:33
std::string l(std::string Text)
A Helper Function For HK_Language.
Definition: Declare.h:52
This Dialog Allows The User To Select A Date.
Definition: DateDialog.cpp:24
HK_Date DateDialogDate
Definition: DateDialog.cpp:26
HK_Date GetDate()
Returns Selected Date.
Definition: DateDialog.cpp:76
wxButton * dateDialogSaveButton
Definition: DateDialog.cpp:28
DateDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT("Select Date"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(200, 110), long style=wxCAPTION|wxSYSTEM_MENU)
Constructor.
Definition: DateDialog.cpp:36
wxDatePickerCtrl * dateCalPicker
Definition: DateDialog.cpp:27
void OnDateSave(wxCommandEvent &)
Sets Date To ReturnDate And Closes Dialog.
Definition: DateDialog.cpp:65
A Class For Managing Dates.
Definition: Date.h:25
void SetMonth(int Month)
Sets Month Value, Doesn't Check If Its Valid.
Definition: HK_Date.cpp:51
void SetDay(int Days)
Sets Day Value, Doesn't Check If Its Valid.
Definition: HK_Date.cpp:48
void SetYear(int Year)
Sets Year Value, Doesn't Check If Its Valid.
Definition: HK_Date.cpp:54
vector< int > GetIntArray(int Selection)
Returns The Selected Value As An Array Of Integers.