2 #include <Wt/WPushButton.h> 5 #include <Wt/WCalendar.h> 11 Wtx::Web::Calendar::YearView::MiniMonth::MiniMonth(
int firstDayOfWeek,
const Wt::WDate & date )
31 m_date = Wt::WDate(date.year(),date.month(),1);
39 Wt::WString(
"<center>{1} {2}</center>")
40 .arg( Wt::WDate::longMonthName( date.month() ) )
49 auto table = addNew<Wt::WTable>();
50 table-> addStyleClass(
"Wtx_MiniMonth" );
61 for(
int weekday = 0; weekday < 7; weekday++ )
63 auto w = std::make_unique<Wt::WText>(
daynames().at((weekday+firstDayOfWeek)%7).substr(0,3) );
65 w-> addStyleClass(
"Wtx_MiniMonth_dayname" );
67 table-> elementAt( 0, weekday )-> addWidget( std::move(w) );
73 auto dow = (date.dayOfWeek()-firstDayOfWeek)%7;
88 for(
int week = 0; week < 6; week++ )
95 for(
int day = 0; day < 7; day++ )
97 auto d = date.addDays( (dow*-1) + ((week*7)+day) );
98 auto w = std::make_unique<DayWidget>(d);
99 m_dayWidgets.push_back( w.get() );
101 table-> elementAt( week*7, day )-> addWidget( std::move(w) );
108 void Wtx::Web::Calendar::YearView::MiniMonth::setSelectedDate(
const Wt::WDate & date )
110 for(
auto dayWidget : m_dayWidgets )
112 if( dayWidget-> date() == date )
114 dayWidget-> setSelected(
true );
118 dayWidget-> setSelected(
false );
124 Wtx::Web::Calendar::YearView::DayWidget::DayWidget(
const Wt::WDate & date )
125 :
Wt::WText(
Wt::WString(
"{1}").arg( date.day() ) ),
128 addStyleClass(
"Wtx_MiniMonth_day" );
130 if( date == Wt::WDate::currentDate() )
132 addStyleClass(
"Wtx_MiniMonth_today" );
137 const Wt::WDate & Wtx::Web::Calendar::YearView::DayWidget::date()
const 142 void Wtx::Web::Calendar::YearView::DayWidget::setSelected(
bool value )
146 addStyleClass(
"Wtx_MiniMonth_selected" );
150 removeStyleClass(
"Wtx_MiniMonth_selected" );
155 :
Wtx::Web::
Calendar::BaseView( firstDayOfWeek, widget )
157 addStyleClass(
"divTable" );
158 addStyleClass(
"blueTable" );
160 auto currentYear = Wt::WDate( Wt::WDate::currentDate().year(), 1, 1 );
162 for(
int row = 0; row < 3; row++ )
164 auto cwRow = addNew<Wt::WContainerWidget>();
165 cwRow-> addStyleClass(
"divTableRow" );
167 for(
int col = 0; col < 4; col++ )
169 auto cwCol = cwRow-> addNew<Wt::WContainerWidget>();
170 cwCol-> addStyleClass(
"divTableCell" );
176 cwCol-> addNew<MiniMonth>( firstDayOfWeek, currentYear.addMonths( (row*4) + col ) )
186 const std::vector< Wtx::Web::Calendar::YearView::MiniMonth * > & Wtx::Web::Calendar::YearView::months()
const 191 const std::vector< Wtx::Web::Calendar::YearView::DayWidget * > & Wtx::Web::Calendar::YearView::days()
const 197 void Wtx::Web::Calendar::YearView::setSelectedDate(
const Wt::WDate & value )
199 Wtx::Web::Calendar::BaseView::setSelectedDate( value );
201 for(
auto month : m_months )
203 month-> setSelectedDate( value );
207 Wt::Signal< Wt::WDate > & Wtx::Web::Calendar::YearView::clicked()
const std::vector< std::string > & daynames()
Long Day Names.