[ 1936700 ] wxCAL_SHOW_WEEK_NUMBERS, slightly modified
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53247 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,7 +48,10 @@ enum
|
|||||||
wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010,
|
wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010,
|
||||||
|
|
||||||
// show the neighbouring weeks in the previous and next month
|
// show the neighbouring weeks in the previous and next month
|
||||||
wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020
|
wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020,
|
||||||
|
|
||||||
|
// show week numbers on the left side of the calendar.
|
||||||
|
wxCAL_SHOW_WEEK_NUMBERS = 0x0040
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -42,6 +42,10 @@ public:
|
|||||||
|
|
||||||
virtual void Mark(size_t day, bool mark);
|
virtual void Mark(size_t day, bool mark);
|
||||||
|
|
||||||
|
// implementation
|
||||||
|
// --------------
|
||||||
|
wxDateTime m_selectedDate;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGtkCalendarCtrl)
|
DECLARE_DYNAMIC_CLASS(wxGtkCalendarCtrl)
|
||||||
DECLARE_NO_COPY_CLASS(wxGtkCalendarCtrl)
|
DECLARE_NO_COPY_CLASS(wxGtkCalendarCtrl)
|
||||||
|
@@ -237,6 +237,8 @@ enum wxCalendarHitTestResult
|
|||||||
@style{wxCAL_SEQUENTIAL_MONTH_SELECTION}
|
@style{wxCAL_SEQUENTIAL_MONTH_SELECTION}
|
||||||
Use alternative, more compact, style for the month and year
|
Use alternative, more compact, style for the month and year
|
||||||
selection controls. (only generic)
|
selection controls. (only generic)
|
||||||
|
@style{wxCAL_SHOW_WEEK_NUMBERS}
|
||||||
|
Show week numbers on the left side of the calendar. (not in generic)
|
||||||
@endStyleTable
|
@endStyleTable
|
||||||
|
|
||||||
@beginEventTable{wxCalendarEvent}
|
@beginEventTable{wxCalendarEvent}
|
||||||
@@ -257,7 +259,7 @@ enum wxCalendarHitTestResult
|
|||||||
@category{ctrl}
|
@category{ctrl}
|
||||||
<!-- @appearance{calendarctrl.png} -->
|
<!-- @appearance{calendarctrl.png} -->
|
||||||
|
|
||||||
@nativeimpl{wxgtk}
|
@nativeimpl{wxgtk,wxmsw}
|
||||||
|
|
||||||
@see @ref page_samples_calendar, wxCalendarDateAttr, wxCalendarEvent,
|
@see @ref page_samples_calendar, wxCalendarDateAttr, wxCalendarEvent,
|
||||||
wxDatePickerCtrl
|
wxDatePickerCtrl
|
||||||
|
@@ -149,6 +149,7 @@ public:
|
|||||||
|
|
||||||
void OnCalSeqMonth(wxCommandEvent& event);
|
void OnCalSeqMonth(wxCommandEvent& event);
|
||||||
void OnCalShowSurroundingWeeks(wxCommandEvent& event);
|
void OnCalShowSurroundingWeeks(wxCommandEvent& event);
|
||||||
|
void OnCalShowWeekNumbers(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnSetDate(wxCommandEvent& event);
|
void OnSetDate(wxCommandEvent& event);
|
||||||
void OnToday(wxCommandEvent& event);
|
void OnToday(wxCommandEvent& event);
|
||||||
@@ -212,6 +213,7 @@ enum
|
|||||||
Calendar_Cal_Month,
|
Calendar_Cal_Month,
|
||||||
Calendar_Cal_SeqMonth,
|
Calendar_Cal_SeqMonth,
|
||||||
Calendar_Cal_SurroundWeeks,
|
Calendar_Cal_SurroundWeeks,
|
||||||
|
Calendar_Cal_WeekNumbers,
|
||||||
Calendar_Cal_SetDate,
|
Calendar_Cal_SetDate,
|
||||||
Calendar_Cal_Today,
|
Calendar_Cal_Today,
|
||||||
Calendar_Cal_BeginDST,
|
Calendar_Cal_BeginDST,
|
||||||
@@ -260,6 +262,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
|
|
||||||
EVT_MENU(Calendar_Cal_SeqMonth, MyFrame::OnCalSeqMonth)
|
EVT_MENU(Calendar_Cal_SeqMonth, MyFrame::OnCalSeqMonth)
|
||||||
EVT_MENU(Calendar_Cal_SurroundWeeks, MyFrame::OnCalShowSurroundingWeeks)
|
EVT_MENU(Calendar_Cal_SurroundWeeks, MyFrame::OnCalShowSurroundingWeeks)
|
||||||
|
EVT_MENU(Calendar_Cal_WeekNumbers, MyFrame::OnCalShowWeekNumbers)
|
||||||
|
|
||||||
EVT_MENU(Calendar_Cal_SetDate, MyFrame::OnSetDate)
|
EVT_MENU(Calendar_Cal_SetDate, MyFrame::OnSetDate)
|
||||||
EVT_MENU(Calendar_Cal_Today, MyFrame::OnToday)
|
EVT_MENU(Calendar_Cal_Today, MyFrame::OnToday)
|
||||||
@@ -367,6 +370,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
_T("Show s&urrounding weeks\tCtrl-W"),
|
_T("Show s&urrounding weeks\tCtrl-W"),
|
||||||
_T("Show the neighbouring weeks in the prev/next month"),
|
_T("Show the neighbouring weeks in the prev/next month"),
|
||||||
true);
|
true);
|
||||||
|
menuCal->Append(Calendar_Cal_WeekNumbers,
|
||||||
|
_T("Show &week numbers"),
|
||||||
|
_T("Toggle week numbers"),
|
||||||
|
true);
|
||||||
menuCal->AppendSeparator();
|
menuCal->AppendSeparator();
|
||||||
menuCal->Append(Calendar_Cal_SeqMonth,
|
menuCal->Append(Calendar_Cal_SeqMonth,
|
||||||
_T("Toggle month selector st&yle\tCtrl-Y"),
|
_T("Toggle month selector st&yle\tCtrl-Y"),
|
||||||
@@ -479,6 +486,11 @@ void MyFrame::OnCalShowSurroundingWeeks(wxCommandEvent& event)
|
|||||||
m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_SHOW_SURROUNDING_WEEKS);
|
m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_SHOW_SURROUNDING_WEEKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnCalShowWeekNumbers(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_SHOW_WEEK_NUMBERS);
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnSetDate(wxCommandEvent &WXUNUSED(event))
|
void MyFrame::OnSetDate(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
m_panel->SetDate(wxDateTime(24, wxDateTime::Dec, 2005, 22, 00, 00));
|
m_panel->SetDate(wxDateTime(24, wxDateTime::Dec, 2005, 22, 00, 00));
|
||||||
@@ -717,7 +729,8 @@ void MyPanel::ToggleCalStyle(bool on, int flag)
|
|||||||
else
|
else
|
||||||
style &= ~flag;
|
style &= ~flag;
|
||||||
|
|
||||||
if ( flag == wxCAL_SEQUENTIAL_MONTH_SELECTION )
|
if ( flag == wxCAL_SEQUENTIAL_MONTH_SELECTION
|
||||||
|
|| flag == wxCAL_SHOW_WEEK_NUMBERS)
|
||||||
{
|
{
|
||||||
// changing this style requires recreating the control
|
// changing this style requires recreating the control
|
||||||
RecreateCalendar(style);
|
RecreateCalendar(style);
|
||||||
|
@@ -28,7 +28,14 @@ extern "C" {
|
|||||||
static void gtk_day_selected_callback(GtkWidget *WXUNUSED(widget),
|
static void gtk_day_selected_callback(GtkWidget *WXUNUSED(widget),
|
||||||
wxGtkCalendarCtrl *cal)
|
wxGtkCalendarCtrl *cal)
|
||||||
{
|
{
|
||||||
|
wxDateTime date = cal->GetDate();
|
||||||
|
if (cal->m_selectedDate == date)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cal->m_selectedDate = date;
|
||||||
|
|
||||||
cal->GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED);
|
cal->GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED);
|
||||||
|
// send deprecated event
|
||||||
cal->GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED);
|
cal->GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +92,8 @@ bool wxGtkCalendarCtrl::Create(wxWindow *parent,
|
|||||||
|
|
||||||
if (style & wxCAL_NO_MONTH_CHANGE)
|
if (style & wxCAL_NO_MONTH_CHANGE)
|
||||||
g_object_set (G_OBJECT (m_widget), "no-month-change", true, NULL);
|
g_object_set (G_OBJECT (m_widget), "no-month-change", true, NULL);
|
||||||
|
if (style & wxCAL_SHOW_WEEK_NUMBERS)
|
||||||
|
g_object_set (G_OBJECT (m_widget), "show-week-numbers", true, NULL);
|
||||||
|
|
||||||
g_signal_connect_after(m_widget, "day-selected",
|
g_signal_connect_after(m_widget, "day-selected",
|
||||||
G_CALLBACK (gtk_day_selected_callback),
|
G_CALLBACK (gtk_day_selected_callback),
|
||||||
@@ -127,13 +136,22 @@ bool wxGtkCalendarCtrl::EnableMonthChange(bool enable)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxGtkCalendarCtrl::SetDate(const wxDateTime& date)
|
bool wxGtkCalendarCtrl::SetDate(const wxDateTime& date)
|
||||||
{
|
{
|
||||||
|
g_signal_handlers_block_by_func(m_widget,
|
||||||
|
(gpointer) gtk_day_selected_callback, this);
|
||||||
|
|
||||||
|
m_selectedDate = date;
|
||||||
int year = date.GetYear();
|
int year = date.GetYear();
|
||||||
int month = date.GetMonth();
|
int month = date.GetMonth();
|
||||||
int day = date.GetDay();
|
int day = date.GetDay();
|
||||||
gtk_calendar_select_month(GTK_CALENDAR(m_widget), month, year);
|
gtk_calendar_select_month(GTK_CALENDAR(m_widget), month, year);
|
||||||
gtk_calendar_select_day(GTK_CALENDAR(m_widget), day);
|
gtk_calendar_select_day(GTK_CALENDAR(m_widget), day);
|
||||||
|
|
||||||
|
g_signal_handlers_unblock_by_func( m_widget,
|
||||||
|
(gpointer) gtk_day_selected_callback, this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user