sptk2 logo
SPTK Home Page
CCalendar.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/DateTime.h>
30#include <sptk5/gui/CControl.h>
31#include <sptk5/gui/CLayoutClient.h>
32#include <sptk5/gui/CPopupWindow.h>
33
34class Fl_Box;
35
36class Fl_Button;
37
38namespace sptk {
39
52class SP_EXPORT CCalendar
53 : public ::Fl_Group
54 , public CLayoutClient
55{
56 Fl_Group* m_headerBox;
57 Fl_Group* m_buttonBox;
58 Fl_Box* m_monthNameBox;
59 std::array<Fl_Box*, 7> m_dayNameBoxes;
60 std::array<Fl_Button*, 31> m_dayButtons;
61 std::array<Fl_Button*, 4> m_switchButtons;
62 DateTime m_date;
63 std::string m_headerLabel;
64 int m_activeButtonIndex;
65 std::array<char, 14> m_weekDayLabels;
66
70 static void cbDayButtonClicked(Fl_Widget*, void*);
71
75 static void cbSwitchButtonClicked(Fl_Widget*, void*);
76
80 void ctor_init();
81
82protected:
86 void dayButtonClicked(uint32_t day);
87
91 void switchButtonClicked(int32_t monthChange);
92
93public:
100 CCalendar(const char* label, int layoutSize = 20, CLayoutAlign layoutAlignment = CLayoutAlign::TOP);
101
110 CCalendar(int x, int y, int w, int h, const char* label = nullptr);
111
119 void resize(int x, int y, int w, int h) override;
120
124 int maxHeight() const;
125
129 void autoHeight(int minHeight);
130
134 void date(DateTime dt);
135
139 DateTime date() const;
140};
141
148class SP_EXPORT CPopupCalendar
149 : public CPopupWindow
150{
151 friend class CCalendar;
152
156 CCalendar* m_calendar;
157
161 Fl_Widget* m_dateControl;
162
163protected:
167 int handle(int) override;
168
169public:
174 explicit CPopupCalendar(Fl_Widget* dateControl);
175
179 void attachTo(Fl_Widget* dateControl)
180 {
181 m_dateControl = dateControl;
182 }
183
191 void resize(int x, int y, int w, int h) override;
192
196 void clicked()
197 {
198 m_clicked = 1;
199 }
200
205 void date(DateTime dt)
206 {
207 m_calendar->date(dt);
208 }
209
215 {
216 return m_calendar->date();
217 }
218
226 bool showModal() override;
227};
231} // namespace sptk
Calendar widget.
Definition: CCalendar.h:55
CCalendar(int x, int y, int w, int h, const char *label=nullptr)
FLTK-style constructor.
void dayButtonClicked(uint32_t day)
The reaction function for the clicking on one of the day buttons.
CCalendar(const char *label, int layoutSize=20, CLayoutAlign layoutAlignment=CLayoutAlign::TOP)
SPTK-style constructor.
int maxHeight() const
Reports the maximum height of the calendar widget.
DateTime date() const
Reports the calendar date.
void autoHeight(int minHeight)
Resizes widget to the optimal height, considering minHeight.
void switchButtonClicked(int32_t monthChange)
The reaction function for the clicking on one of the month change buttonss.
void date(DateTime dt)
Sets the calendar date.
void resize(int x, int y, int w, int h) override
Widget resize.
Definition: CLayoutClient.h:82
Popup Calendar.
Definition: CCalendar.h:150
int handle(int) override
bool showModal() override
Shows the calendar in modal mode.
DateTime date() const
Reports the calendar date.
Definition: CCalendar.h:214
void attachTo(Fl_Widget *dateControl)
Attaches the calendar to another widget.
Definition: CCalendar.h:179
CPopupCalendar(Fl_Widget *dateControl)
Constructor.
void date(DateTime dt)
Sets the calendar date.
Definition: CCalendar.h:205
void clicked()
Function that is used to report that calendar is clicked on and should be hidden.
Definition: CCalendar.h:196
void resize(int x, int y, int w, int h) override
Widget resize.
Base popup window.
Definition: CPopupWindow.h:48
Definition: DateTime.h:86
DateTime date() const
CLayoutAlign
Definition: CLayoutClient.h:44
@ TOP
Align to the right.

Fri Oct 14 2022 09:58:31: SPTK 5.4.1