Wtx ~ Wt Extension Library
WtxLib
Widget.h
1 /**************************************************************************
2 ###########################################################################
3 ##
4 ## $SHOWOFFDB_BEGIN_LICENSE$
5 ## Copyright (C) 2011 Lorimark Solutions, LLC and/or its subsidiary(-ies).
6 ## All rights reserved.
7 ## Contact: Lorimark Solutions, LLC (info@showoff-db.org)
8 ##
9 ## This file is part of the Showoff Database Application Framework.
10 ##
11 ## Commercial Usage
12 ## Licensees holding valid ShowoffDB Commercial licenses may use this file in
13 ## accordance with the ShowoffDB Commercial License Agreement provided with the
14 ## Software or, alternatively, in accordance with the terms contained in
15 ## a written agreement between you and Lorimark Solutions, LLC.
16 ##
17 ## GNU Lesser General Public License Usage
18 ## Alternatively, this file may be used under the terms of the GNU Lesser
19 ## General Public License version 2.1 as published by the Free Software
20 ## Foundation and appearing in the file LICENSE.LGPL included in the
21 ## packaging of this file. Please review the following information to
22 ## ensure the GNU Lesser General Public License version 2.1 requirements
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ##
25 ## In addition, as a special exception, Lorimark Solutions, LLC gives
26 ## you certain additional rights. These rights are described in the
27 ## Lorimark Solutions, LLC ShowoffDB LGPL Exception version 1.0, included in
28 ## the file LGPL_EXCEPTION.txt in this package.
29 ##
30 ## GNU General Public License Usage
31 ## Alternatively, this file may be used under the terms of the GNU
32 ## General Public License version 3.0 as published by the Free Software
33 ## Foundation and appearing in the file LICENSE.GPL included in the
34 ## packaging of this file. Please review the following information to
35 ## ensure the GNU General Public License version 3.0 requirements will be
36 ## met: http://www.gnu.org/copyleft/gpl.html.
37 ##
38 ## If you have questions regarding the use of this file, please contact
39 ## Lorimark Solutions, LLC at info@showoff-db.org.
40 ## $SHOWOFFDB_END_LICENSE$
41 ##
42 #############################################################################
43 ****************************************************************************/
44 
45 #ifndef __WTX_CALENDARWIDGET_H___
46 #define __WTX_CALENDARWIDGET_H___
47 
48 namespace Wt {
49  class WStackedWidget;
50 }
51 
52 #include <Wtx/Addons/Web/Calendar/Database.h>
53 #include <Wtx/Addons/Web/Calendar/DayView.h>
54 #include <Wtx/Addons/Web/Calendar/WeekView.h>
55 #include <Wtx/Addons/Web/Calendar/MonthView.h>
56 #include <Wtx/Addons/Web/Calendar/YearView.h>
57 
58 namespace Wtx {
59  namespace Web {
60  namespace Calendar {
61 
66 class Widget
67 : public Wt::WContainerWidget
68 {
69  class ToolBar
70  : public Wt::WContainerWidget
71  {
72  public:
73  ToolBar();
74 
75  Wt::WPushButton * pbNew() const;
76  Wt::WPushButton * pbToday() const;
77  Wt::WPushButton * pbPrev() const;
78  Wt::WPushButton * pbNext() const;
79  Wt::WPushButton * pbFind() const;
80  Wt::WComboBox * cbView() const;
81  Wt::WPushButton * pbSett() const;
82 
83  public:
84 
85  Wt::WText * m_date = nullptr;
86  Wt::WPushButton * m_pbNew = nullptr;
87  Wt::WPushButton * m_pbToday = nullptr;
88  Wt::WPushButton * m_pbPrev = nullptr;
89  Wt::WPushButton * m_pbNext = nullptr;
90  Wt::WPushButton * m_pbFind = nullptr;
91  Wt::WComboBox * m_cbView = nullptr;
92  Wt::WPushButton * m_pbSett = nullptr;
93  };
94 
95  class SideBar
96  : public Wt::WContainerWidget
97  {
98  public:
99  SideBar( int firstDayOfWeek );
100 
101  Wt::WCalendar * calendar() const;
102 
103  private:
104 
105  Wt::WCalendar * m_calendar = nullptr;
106  };
107 
108  public:
109 
110  enum View {
111  DAY = 0,
112  WEEK = 1,
113  MONTH = 2,
114  YEAR = 3,
115  SCHEDULE = 4,
116  FOURDAYS = 5,
117  FIVEDAYS = 6,
118  TABLE = 7
119  };
120 
128  Widget( int firstDayOfWeek, Database & database );
129 
130  Wtx::Web::Calendar::YearView * yearView() const;
131  Wtx::Web::Calendar::MonthView * monthView() const;
132  Wtx::Web::Calendar::WeekView * weekView() const;
133  Wtx::Web::Calendar::DayView * dayView() const;
134 
135  const Wt::WDate & selectedDate() const;
136  void setSelectedDate( const Wt::WDate & date );
137 
138  void setView( int value );
139  int view() const;
140 
141  ToolBar * toolBar() const;
142  SideBar * sideBar() const;
143 
144  Wt::Signal<Wt::WDate> & itemNew();
145  Wt::Signal<Wt::WModelIndex> & itemClicked();
146  Wt::Signal<Wt::WModelIndex> & itemDoubleClicked();
147 
148  void updateView();
149 
150  std::shared_ptr<Wt::WAbstractItemModel> getModel( const Wt::WDate & date, const std::vector<std::string> & fieldList );
151 
152  protected:
153 
154  private:
155 
156  void selectPrevious();
157  void selectNext();
158 
159  Wt::WDate m_selectedDate;
160  Wt::WTemplate * m_templt = nullptr;
161  Wtx::Web::Calendar::YearView * m_yearView = nullptr;
162  Wtx::Web::Calendar::MonthView * m_monthView = nullptr;
163  Wtx::Web::Calendar::WeekView * m_weekView = nullptr;
164  Wtx::Web::Calendar::DayView * m_dayView = nullptr;
165  Wt::WStackedWidget * m_stack = nullptr;
166  ToolBar * m_toolBar = nullptr;
167  SideBar * m_sideBar = nullptr;
168 
169  Wt::Signal<Wt::WDate> m_itemNew;
170  Wt::Signal<Wt::WModelIndex> m_itemClicked;
171  Wt::Signal<Wt::WModelIndex> m_itemDoubleClicked;
172 
173  std::map< Wt::WDate, std::shared_ptr<Wt::WAbstractItemModel> > m_modelMaps;
174 
175  Database & m_database;
176 
177 }; // endclass Widget
178 
179  } // endnamespace Calendar
180  } // endnamespace Web
181 } // endnamespace Wtx
182 
183 
184 #endif // #ifndef __WTX_CALENDARWIDGET_H___
185 
186 
Calendar Widget.
Definition: Widget.h:66
Calendar Day Widget.
Definition: DayView.h:65
witty extension library
Definition: Activity.h:51