1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.widgets.calendarwidget; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.calendar; 19 import qt.core.coreevent; 20 import qt.core.datetime; 21 import qt.core.map; 22 import qt.core.namespace; 23 import qt.core.object; 24 import qt.core.rect; 25 import qt.core.size; 26 import qt.gui.event; 27 import qt.gui.painter; 28 import qt.gui.textformat; 29 import qt.helpers; 30 import qt.widgets.widget; 31 32 /+ QT_REQUIRE_CONFIG(calendarwidget); 33 34 35 class QDate; 36 class QTextCharFormat; +/ 37 extern(C++, class) struct QCalendarWidgetPrivate; 38 39 class /+ Q_WIDGETS_EXPORT +/ QCalendarWidget : QWidget 40 { 41 mixin(Q_OBJECT); 42 /+ Q_ENUMS(Qt::DayOfWeek) 43 Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate) 44 Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate) 45 Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate) 46 Q_PROPERTY(Qt::DayOfWeek firstDayOfWeek READ firstDayOfWeek WRITE setFirstDayOfWeek) 47 Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible) 48 Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode) 49 Q_PROPERTY(HorizontalHeaderFormat horizontalHeaderFormat READ horizontalHeaderFormat WRITE setHorizontalHeaderFormat) 50 Q_PROPERTY(VerticalHeaderFormat verticalHeaderFormat READ verticalHeaderFormat WRITE setVerticalHeaderFormat) 51 Q_PROPERTY(bool navigationBarVisible READ isNavigationBarVisible WRITE setNavigationBarVisible) 52 Q_PROPERTY(bool dateEditEnabled READ isDateEditEnabled WRITE setDateEditEnabled) 53 Q_PROPERTY(int dateEditAcceptDelay READ dateEditAcceptDelay WRITE setDateEditAcceptDelay) +/ 54 55 public: 56 enum HorizontalHeaderFormat { 57 NoHorizontalHeader, 58 SingleLetterDayNames, 59 ShortDayNames, 60 LongDayNames 61 } 62 /+ Q_ENUM(HorizontalHeaderFormat) +/ 63 64 enum VerticalHeaderFormat { 65 NoVerticalHeader, 66 ISOWeekNumbers 67 } 68 /+ Q_ENUM(VerticalHeaderFormat) +/ 69 70 enum SelectionMode { 71 NoSelection, 72 SingleSelection 73 } 74 /+ Q_ENUM(SelectionMode) +/ 75 76 /+ explicit +/this(QWidget parent = null); 77 ~this(); 78 79 /+ virtual +/ override QSize sizeHint() const; 80 /+ virtual +/ override QSize minimumSizeHint() const; 81 82 final QDate selectedDate() const; 83 84 final int yearShown() const; 85 final int monthShown() const; 86 87 final QDate minimumDate() const; 88 final void setMinimumDate(ref const(QDate) date); 89 90 final QDate maximumDate() const; 91 final void setMaximumDate(ref const(QDate) date); 92 93 final /+ Qt:: +/qt.core.namespace.DayOfWeek firstDayOfWeek() const; 94 final void setFirstDayOfWeek(/+ Qt:: +/qt.core.namespace.DayOfWeek dayOfWeek); 95 96 final bool isNavigationBarVisible() const; 97 final bool isGridVisible() const; 98 99 final QCalendar calendar() const; 100 final void setCalendar(QCalendar calendar); 101 102 final SelectionMode selectionMode() const; 103 final void setSelectionMode(SelectionMode mode); 104 105 final HorizontalHeaderFormat horizontalHeaderFormat() const; 106 final void setHorizontalHeaderFormat(HorizontalHeaderFormat format); 107 108 final VerticalHeaderFormat verticalHeaderFormat() const; 109 final void setVerticalHeaderFormat(VerticalHeaderFormat format); 110 111 final QTextCharFormat headerTextFormat() const; 112 final void setHeaderTextFormat(ref const(QTextCharFormat) format); 113 114 final QTextCharFormat weekdayTextFormat(/+ Qt:: +/qt.core.namespace.DayOfWeek dayOfWeek) const; 115 final void setWeekdayTextFormat(/+ Qt:: +/qt.core.namespace.DayOfWeek dayOfWeek, ref const(QTextCharFormat) format); 116 117 // final QMap!(QDate, QTextCharFormat) dateTextFormat() const; 118 final QTextCharFormat dateTextFormat(ref const(QDate) date) const; 119 final void setDateTextFormat(ref const(QDate) date, ref const(QTextCharFormat) format); 120 121 final bool isDateEditEnabled() const; 122 final void setDateEditEnabled(bool enable); 123 124 final int dateEditAcceptDelay() const; 125 final void setDateEditAcceptDelay(int delay); 126 127 protected: 128 override bool event(QEvent event); 129 override bool eventFilter(QObject watched, QEvent event); 130 override void mousePressEvent(QMouseEvent event); 131 override void resizeEvent(QResizeEvent event); 132 override void keyPressEvent(QKeyEvent event); 133 134 /+ virtual +/ void paintCell(QPainter* painter, ref const(QRect) rect, ref const(QDate) date) const; 135 final void updateCell(ref const(QDate) date); 136 final void updateCells(); 137 138 public /+ Q_SLOTS +/: 139 @QSlot final void setSelectedDate(ref const(QDate) date); 140 @QSlot final void setDateRange(ref const(QDate) min, ref const(QDate) max); 141 @QSlot final void setCurrentPage(int year, int month); 142 @QSlot final void setGridVisible(bool show); 143 @QSlot final void setNavigationBarVisible(bool visible); 144 @QSlot final void showNextMonth(); 145 @QSlot final void showPreviousMonth(); 146 @QSlot final void showNextYear(); 147 @QSlot final void showPreviousYear(); 148 @QSlot final void showSelectedDate(); 149 @QSlot final void showToday(); 150 151 /+ Q_SIGNALS +/public: 152 @QSignal final void selectionChanged(); 153 @QSignal final void clicked(ref const(QDate) date); 154 @QSignal final void activated(ref const(QDate) date); 155 @QSignal final void currentPageChanged(int year, int month); 156 157 private: 158 /+ Q_DECLARE_PRIVATE(QCalendarWidget) +/ 159 /+ Q_DISABLE_COPY(QCalendarWidget) +/ 160 161 /+ Q_PRIVATE_SLOT(d_func(), void _q_slotShowDate(const QDate &date)) 162 Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date)) 163 Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date, bool changeMonth)) 164 Q_PRIVATE_SLOT(d_func(), void _q_editingFinished()) 165 Q_PRIVATE_SLOT(d_func(), void _q_prevMonthClicked()) 166 Q_PRIVATE_SLOT(d_func(), void _q_nextMonthClicked()) 167 Q_PRIVATE_SLOT(d_func(), void _q_yearEditingFinished()) 168 Q_PRIVATE_SLOT(d_func(), void _q_yearClicked()) 169 Q_PRIVATE_SLOT(d_func(), void _q_monthChanged(QAction *act)) +/ 170 171 } 172