// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(Calendar_Cal_SeqMonth, MyFrame::OnCalSeqMonth)
EVT_MENU(Calendar_Cal_SurroundWeeks, MyFrame::OnCalShowSurroundingWeeks)
EVT_MENU(Calendar_Cal_SeqMonth, MyFrame::OnCalSeqMonth)
EVT_MENU(Calendar_Cal_SurroundWeeks, MyFrame::OnCalShowSurroundingWeeks)
// the application object during program execution (it's better than using a
// static object for many reasons) and also declares the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// the application object during program execution (it's better than using a
// static object for many reasons) and also declares the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
wxPoint(50, 50), wxSize(450, 340));
wxPoint(50, 50), wxSize(450, 340));
- : wxFrame((wxFrame *)NULL, -1, title, pos, size)
+ : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
menuCal->Append(Calendar_Cal_Monday,
_T("Monday &first weekday\tCtrl-F"),
_T("Toggle between Mon and Sun as the first week day"),
menuCal->Append(Calendar_Cal_Monday,
_T("Monday &first weekday\tCtrl-F"),
_T("Toggle between Mon and Sun as the first week day"),
menuCal->Append(Calendar_Cal_Holidays, _T("Show &holidays\tCtrl-H"),
_T("Toggle highlighting the holidays"),
menuCal->Append(Calendar_Cal_Holidays, _T("Show &holidays\tCtrl-H"),
_T("Toggle highlighting the holidays"),
menuCal->Append(Calendar_Cal_Special, _T("Highlight &special dates\tCtrl-S"),
_T("Test custom highlighting"),
menuCal->Append(Calendar_Cal_Special, _T("Highlight &special dates\tCtrl-S"),
_T("Test custom highlighting"),
menuCal->Append(Calendar_Cal_SurroundWeeks,
_T("Show s&urrounding weeks\tCtrl-W"),
_T("Show the neighbouring weeks in the prev/next month"),
menuCal->Append(Calendar_Cal_SurroundWeeks,
_T("Show s&urrounding weeks\tCtrl-W"),
_T("Show the neighbouring weeks in the prev/next month"),
menuCal->AppendSeparator();
menuCal->Append(Calendar_Cal_SeqMonth,
_T("To&ggle month selector style\tCtrl-G"),
_T("Use another style for the calendar controls"),
menuCal->AppendSeparator();
menuCal->Append(Calendar_Cal_SeqMonth,
_T("To&ggle month selector style\tCtrl-G"),
_T("Use another style for the calendar controls"),
menuCal->Append(Calendar_Cal_Month, _T("&Month can be changed\tCtrl-M"),
_T("Allow changing the month in the calendar"),
menuCal->Append(Calendar_Cal_Month, _T("&Month can be changed\tCtrl-M"),
_T("Allow changing the month in the calendar"),
menuCal->Append(Calendar_Cal_Year, _T("&Year can be changed\tCtrl-Y"),
_T("Allow changing the year in the calendar"),
menuCal->Append(Calendar_Cal_Year, _T("&Year can be changed\tCtrl-Y"),
_T("Allow changing the year in the calendar"),
+ true);
+ menuCal->AppendSeparator();
+ menuCal->Append(Calendar_Cal_SetDate, _T("SetDate()"), _T("Set date to 2005-12-24."));
+ menuCal->Append(Calendar_Cal_Today, _T("Today()"), _T("Set the current date."));
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, _T("&File"));
menuBar->Append(menuCal, _T("&Calendar"));
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, _T("&File"));
menuBar->Append(menuCal, _T("&Calendar"));
- menuBar->Check(Calendar_Cal_Monday, TRUE);
- menuBar->Check(Calendar_Cal_Holidays, TRUE);
- menuBar->Check(Calendar_Cal_Month, TRUE);
- menuBar->Check(Calendar_Cal_Year, TRUE);
+ menuBar->Check(Calendar_Cal_Monday, true);
+ menuBar->Check(Calendar_Cal_Holidays, true);
+ menuBar->Check(Calendar_Cal_Month, true);
+ menuBar->Check(Calendar_Cal_Year, true);
// ----------------------------------------------------------------------------
// MyPanel
// ----------------------------------------------------------------------------
MyPanel::MyPanel(wxFrame *frame)
// ----------------------------------------------------------------------------
// MyPanel
// ----------------------------------------------------------------------------
MyPanel::MyPanel(wxFrame *frame)
wxString date;
date.Printf(wxT("Selected date: %s"),
wxDateTime::Today().FormatISODate().c_str());
wxString date;
date.Printf(wxT("Selected date: %s"),
wxDateTime::Today().FormatISODate().c_str());
- wxLayoutConstraints *c = new wxLayoutConstraints;
- c->left.SameAs(this, wxLeft, 10);
- c->centreY.SameAs(this, wxCentreY);
- c->height.AsIs();
- c->width.AsIs();
-
- m_date->SetConstraints(c);
+ wxBoxSizer *m_sizer = new wxBoxSizer( wxHORIZONTAL );
- c = new wxLayoutConstraints;
- c->left.SameAs(m_date, wxRight, 20);
- c->centreY.SameAs(this, wxCentreY);
- c->height.AsIs();
- c->width.AsIs();
+ m_sizer->Add(m_date, 0, wxALIGN_CENTER | wxALL, 10 );
+ m_sizer->Add(m_calendar, 0, wxALIGN_CENTER | wxALIGN_LEFT);
+
+void MyPanel::SetDate()
+{
+ wxDateTime date(24, wxDateTime::Dec, 2005, 23, 59, 59);
+ m_calendar->SetDate(date);
+}
+
+void MyPanel::Today()
+{
+ m_calendar->SetDate(wxDateTime::Today());
+}