Use automatically selected first weekday by default in calendar sample
Also create a wxLocale object with wxLANGUAGE_DEFAULT so that automatic selection has a better chance of doing the right thing across different platforms.
This commit is contained in:
@@ -70,7 +70,9 @@
|
|||||||
// Define a new application type, each program should derive a class from wxApp
|
// Define a new application type, each program should derive a class from wxApp
|
||||||
class MyApp : public wxApp
|
class MyApp : public wxApp
|
||||||
{
|
{
|
||||||
|
wxLocale m_locale;
|
||||||
public:
|
public:
|
||||||
|
MyApp();
|
||||||
// override base class virtuals
|
// override base class virtuals
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
|
|
||||||
@@ -153,6 +155,8 @@ public:
|
|||||||
}
|
}
|
||||||
#endif // wxHAS_NATIVE_CALENDARCTRL
|
#endif // wxHAS_NATIVE_CALENDARCTRL
|
||||||
|
|
||||||
|
void OnCalAutoWeekday(wxCommandEvent& event);
|
||||||
|
void OnCalSunday(wxCommandEvent& event);
|
||||||
void OnCalMonday(wxCommandEvent& event);
|
void OnCalMonday(wxCommandEvent& event);
|
||||||
void OnCalHolidays(wxCommandEvent& event);
|
void OnCalHolidays(wxCommandEvent& event);
|
||||||
void OnCalSpecial(wxCommandEvent& event);
|
void OnCalSpecial(wxCommandEvent& event);
|
||||||
@@ -240,6 +244,8 @@ enum
|
|||||||
Calendar_File_ClearLog = wxID_CLEAR,
|
Calendar_File_ClearLog = wxID_CLEAR,
|
||||||
Calendar_File_Quit = wxID_EXIT,
|
Calendar_File_Quit = wxID_EXIT,
|
||||||
Calendar_Cal_Generic = 200,
|
Calendar_Cal_Generic = 200,
|
||||||
|
Calendar_Cal_AutoWeekday,
|
||||||
|
Calendar_Cal_Sunday,
|
||||||
Calendar_Cal_Monday,
|
Calendar_Cal_Monday,
|
||||||
Calendar_Cal_Holidays,
|
Calendar_Cal_Holidays,
|
||||||
Calendar_Cal_Special,
|
Calendar_Cal_Special,
|
||||||
@@ -298,6 +304,8 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(Calendar_Cal_Generic, MyFrame::OnCalGeneric)
|
EVT_MENU(Calendar_Cal_Generic, MyFrame::OnCalGeneric)
|
||||||
#endif // wxHAS_NATIVE_CALENDARCTRL
|
#endif // wxHAS_NATIVE_CALENDARCTRL
|
||||||
|
|
||||||
|
EVT_MENU(Calendar_Cal_AutoWeekday, MyFrame::OnCalAutoWeekday)
|
||||||
|
EVT_MENU(Calendar_Cal_Sunday, MyFrame::OnCalSunday)
|
||||||
EVT_MENU(Calendar_Cal_Monday, MyFrame::OnCalMonday)
|
EVT_MENU(Calendar_Cal_Monday, MyFrame::OnCalMonday)
|
||||||
EVT_MENU(Calendar_Cal_Holidays, MyFrame::OnCalHolidays)
|
EVT_MENU(Calendar_Cal_Holidays, MyFrame::OnCalHolidays)
|
||||||
EVT_MENU(Calendar_Cal_Special, MyFrame::OnCalSpecial)
|
EVT_MENU(Calendar_Cal_Special, MyFrame::OnCalSpecial)
|
||||||
@@ -319,6 +327,8 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
|
|
||||||
EVT_UPDATE_UI(Calendar_Cal_SeqMonth, MyFrame::OnUpdateUIGenericOnly)
|
EVT_UPDATE_UI(Calendar_Cal_SeqMonth, MyFrame::OnUpdateUIGenericOnly)
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
|
EVT_UPDATE_UI(Calendar_Cal_AutoWeekday, MyFrame::OnUpdateUIGenericOnly)
|
||||||
|
EVT_UPDATE_UI(Calendar_Cal_Sunday, MyFrame::OnUpdateUIGenericOnly)
|
||||||
EVT_UPDATE_UI(Calendar_Cal_Monday, MyFrame::OnUpdateUIGenericOnly)
|
EVT_UPDATE_UI(Calendar_Cal_Monday, MyFrame::OnUpdateUIGenericOnly)
|
||||||
EVT_UPDATE_UI(Calendar_Cal_Holidays, MyFrame::OnUpdateUIGenericOnly)
|
EVT_UPDATE_UI(Calendar_Cal_Holidays, MyFrame::OnUpdateUIGenericOnly)
|
||||||
#endif
|
#endif
|
||||||
@@ -349,6 +359,13 @@ wxIMPLEMENT_APP(MyApp);
|
|||||||
// the application class
|
// the application class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
MyApp::MyApp() :
|
||||||
|
// Locale affects on the language used in the calendar, and may affect
|
||||||
|
// on the first day of the week.
|
||||||
|
m_locale(wxLANGUAGE_DEFAULT)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// `Main program' equivalent: the program execution "starts" here
|
// `Main program' equivalent: the program execution "starts" here
|
||||||
bool MyApp::OnInit()
|
bool MyApp::OnInit()
|
||||||
{
|
{
|
||||||
@@ -396,10 +413,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
"Toggle between native and generic control");
|
"Toggle between native and generic control");
|
||||||
menuCal->AppendSeparator();
|
menuCal->AppendSeparator();
|
||||||
#endif // wxHAS_NATIVE_CALENDARCTRL
|
#endif // wxHAS_NATIVE_CALENDARCTRL
|
||||||
menuCal->Append(Calendar_Cal_Monday,
|
menuCal->AppendRadioItem(Calendar_Cal_AutoWeekday,
|
||||||
wxT("Monday &first weekday\tCtrl-F"),
|
wxT("Automatic &first weekday\tCtrl-V"));
|
||||||
wxT("Toggle between Mon and Sun as the first week day"),
|
menuCal->AppendRadioItem(Calendar_Cal_Sunday,
|
||||||
true);
|
wxT("Sunday &first weekday\tCtrl-Z"));
|
||||||
|
menuCal->AppendRadioItem(Calendar_Cal_Monday,
|
||||||
|
wxT("Monday &first weekday\tCtrl-F"));
|
||||||
menuCal->Append(Calendar_Cal_Holidays, wxT("Show &holidays\tCtrl-H"),
|
menuCal->Append(Calendar_Cal_Holidays, wxT("Show &holidays\tCtrl-H"),
|
||||||
wxT("Toggle highlighting the holidays"),
|
wxT("Toggle highlighting the holidays"),
|
||||||
true);
|
true);
|
||||||
@@ -462,7 +481,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
menuBar->Append(menuTime, wxT("&Time picker"));
|
menuBar->Append(menuTime, wxT("&Time picker"));
|
||||||
#endif // wxUSE_TIMEPICKCTRL
|
#endif // wxUSE_TIMEPICKCTRL
|
||||||
|
|
||||||
menuBar->Check(Calendar_Cal_Monday, true);
|
menuBar->Check(Calendar_Cal_AutoWeekday, true);
|
||||||
|
menuBar->Check(Calendar_Cal_Sunday, false);
|
||||||
|
menuBar->Check(Calendar_Cal_Monday, false);
|
||||||
menuBar->Check(Calendar_Cal_Holidays, true);
|
menuBar->Check(Calendar_Cal_Holidays, true);
|
||||||
menuBar->Check(Calendar_Cal_Month, true);
|
menuBar->Check(Calendar_Cal_Month, true);
|
||||||
menuBar->Check(Calendar_Cal_LimitDates, false);
|
menuBar->Check(Calendar_Cal_LimitDates, false);
|
||||||
@@ -503,8 +524,21 @@ void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
|
|||||||
m_logWindow->Clear();
|
m_logWindow->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnCalAutoWeekday(wxCommandEvent&)
|
||||||
|
{
|
||||||
|
m_panel->ToggleCalStyle(false, wxCAL_SUNDAY_FIRST);
|
||||||
|
m_panel->ToggleCalStyle(false, wxCAL_MONDAY_FIRST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnCalSunday(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
m_panel->ToggleCalStyle(false, wxCAL_MONDAY_FIRST);
|
||||||
|
m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_SUNDAY_FIRST);
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnCalMonday(wxCommandEvent& event)
|
void MyFrame::OnCalMonday(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
m_panel->ToggleCalStyle(false, wxCAL_SUNDAY_FIRST);
|
||||||
m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_MONDAY_FIRST);
|
m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_MONDAY_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +736,7 @@ MyPanel::MyPanel(wxWindow *parent)
|
|||||||
wxDateTime::Today().FormatISODate().c_str());
|
wxDateTime::Today().FormatISODate().c_str());
|
||||||
m_date = new wxStaticText(this, wxID_ANY, date);
|
m_date = new wxStaticText(this, wxID_ANY, date);
|
||||||
m_calendar = DoCreateCalendar(wxDefaultDateTime,
|
m_calendar = DoCreateCalendar(wxDefaultDateTime,
|
||||||
wxCAL_MONDAY_FIRST | wxCAL_SHOW_HOLIDAYS);
|
wxCAL_SHOW_HOLIDAYS);
|
||||||
|
|
||||||
// adjust to vertical/horizontal display
|
// adjust to vertical/horizontal display
|
||||||
bool horizontal = ( wxSystemSettings::GetMetric(wxSYS_SCREEN_X) > wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) );
|
bool horizontal = ( wxSystemSettings::GetMetric(wxSYS_SCREEN_X) > wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) );
|
||||||
|
Reference in New Issue
Block a user