Wtx ~ Wt Extension Library
WtxLib
WeekView.cpp
1 
2 #include <Wt/WText.h>
3 
4 #include "Calendar.h"
5 #include "WeekView.h"
6 #include "Widget.h"
7 
8 Wtx::Web::Calendar::WeekView::WeekView( int firstDayOfWeek, Wtx::Web::Calendar::Widget * widget )
9 : Wtx::Web::Calendar::BaseView( firstDayOfWeek, widget )
10 {
11  addStyleClass( "divTable" );
12  addStyleClass( "blueTable" );
13 
14  {
15  auto cwHeader = addNew<Wt::WContainerWidget>();
16  cwHeader-> addStyleClass( "divTableHeading" );
17 
18  auto cwRow = cwHeader-> addNew<Wt::WContainerWidget>();
19  cwRow-> addStyleClass( "divTableRow" );
20 
21  auto cwTime = cwRow-> addNew<Wt::WContainerWidget>();
22 
23  for( int weekday = 0; weekday < 7; weekday++ )
24  {
25  auto cwDay = cwRow-> addNew<Wt::WContainerWidget>();
26  cwDay-> addStyleClass( "divTableHead" );
27 
28  cwDay-> addNew<Wt::WText>( daynames().at(weekday) );
29  }
30  }
31 
32  for( int hour = 0; hour < 24; hour++ )
33  {
34  auto cwRow = addNew<Wt::WContainerWidget>();
35  cwRow-> addStyleClass( "divTableRow" );
36 
37  std::string ap;
38  if( hour < 12 )
39  ap = "am";
40  else
41  ap = "pm";
42 
43  auto cwTime = cwRow-> addNew<Wt::WContainerWidget>();
44  cwTime-> addStyleClass( "divHour" );
45  if( hour > 0 )
46  {
47  if( hour == 12 )
48  {
49  cwTime-> addNew<Wt::WText>( Wt::WString("noon") );
50  }
51  else
52  {
53  cwTime-> addNew<Wt::WText>( Wt::WString("{1} {2}").arg( hour%12 ).arg( ap ) );
54  }
55  }
56  else
57  {
58  cwTime-> addNew<Wt::WText>( Wt::WString("12am") );
59  }
60 
61 
62  for( int day = 0; day < 7; day++ )
63  {
64  auto cwHour = cwRow-> addNew<Wt::WContainerWidget>();
65  cwHour-> addStyleClass( "divTableCell" );
66 
67 
68  }
69 
70  }
71 
72 }
73 
74 
Calendar Widget.
Definition: Widget.h:66
const std::vector< std::string > & daynames()
Long Day Names.
Definition: Calendar.cpp:11
witty extension library
Definition: Activity.h:51