1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/********************************************************************************
* *
* B a s e C a l e n d a r W i d g e t *
* *
*********************************************************************************
* Copyright (C) 2006,2022 by Sander Jansen. All Rights Reserved. *
*********************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/> *
********************************************************************************/
#ifndef FXCALENDARVIEW_H
#define FXCALENDARVIEW_H
#ifndef FXWINDOW_H
#include "FXWindow.h"
#endif
namespace FX {
/// Calendar styles
enum {
CALENDAR_BROWSESELECT = 0x00000000, /// Browse selection mode enforces one single item to be selected at all times
CALENDAR_SINGLESELECT = 0x00100000, /// Single selection mode allows up to one item to be selected
CALENDAR_WEEKNUMBERS = 0x00200000, /// Show ISO8601 Week numbers
CALENDAR_STATIC = 0x00400000, /// Disable navigation to prev/next month in display.
CALENDAR_HIDEOTHER = 0x00800000, /// Do not show days of other months.
};
class FXFont;
/**
* The Basic Calendar Widget. Renders the base calendar and keeps track of selection.
* Most usefull to widget developers. Use it if you need a calendar rendered in some component.
*/
class FXAPI FXCalendarView : public FXWindow {
FXDECLARE(FXCalendarView)
protected:
FXFont *font; // Font
FXDate current; // Current Date
FXDate selected; // Selected Date
FXDate ds; // First Day in Calendar
FXint month; // Which month is being viewed.
FXint firstday; // Which day of the week we display in the first column
FXint ws; // First week number in Calendar
FXColor todayColor; // Today Color
FXColor titleColor; // Title Color
FXColor titleBackColor; // Title Back Color
FXColor dayColor; // Normal Day Color
FXColor otherDayColor; // Normal Day Color Disabled
FXColor weekendColor; // Weekend Color
FXColor otherWeekendColor; // Weekend Color Disabled
FXbool has_selection; // If any date is selected
FXbool state; // State
protected:
FXCalendarView();
void moveFocus(FXDate);
void markdirty(FXDate);
void updateview(FXbool notify=true);
private:
FXCalendarView(const FXCalendarView&);
FXCalendarView &operator=(const FXCalendarView&);
public:
long onPaint(FXObject*,FXSelector,void*);
long onLeftBtnPress(FXObject*,FXSelector,void*);
long onLeftBtnRelease(FXObject*,FXSelector,void*);
long onKeyPress(FXObject*,FXSelector,void*);
long onKeyRelease(FXObject*,FXSelector,void*);
long onFocusIn(FXObject*,FXSelector,void*);
long onFocusOut(FXObject*,FXSelector,void*);
long onClicked(FXObject*,FXSelector,void*);
long onDoubleClicked(FXObject*,FXSelector,void*);
long onTripleClicked(FXObject*,FXSelector,void*);
long onCommand(FXObject*,FXSelector,void*);
long onCmdSetValue(FXObject*,FXSelector,void*);
long onCmdSetIntValue(FXObject*,FXSelector,void*);
long onCmdGetIntValue(FXObject*,FXSelector,void*);
public:
/// Construct a Calendar View
FXCalendarView(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=CALENDAR_BROWSESELECT,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
/// Create server-side resources
virtual void create();
/// Detach server-side resources
virtual void detach();
/// Yes we can
virtual FXbool canFocus() const;
/// Set focus
virtual void setFocus();
/// Kill focus
virtual void killFocus();
/// Enable the window
virtual void enable();
/// Disable the window
virtual void disable();
/// Return the default width of this window
virtual FXint getDefaultWidth();
/// Return the default height of this window
virtual FXint getDefaultHeight();
/// Get date at x,y if any
FXbool getDateAt(FXint x,FXint y,FXDate& date) const;
/// Set date
void setCurrentDate(FXDate date,FXbool notify=false);
/// Get the current date
FXDate getCurrentDate() const { return current; }
/// Set the current month; current day will be properly updated for the choosen month
void setCurrentMonth(FXint month,FXbool notify=false);
/**
* Return the current month shown. The month may be different than the current
* date if a day in a sibling month is current.
*/
FXint getCurrentMonth() const { return month; }
/// Select Date
void selectDate(FXDate date,FXbool notify=false);
/// Deselect Date
void killSelection(FXbool notify=false);
/// Get the selected date, if any
FXbool getSelectedDate(FXDate& date) const;
/// Set the first day of the week [0...6]
void setFirstDay(FXint d);
/// Get the first day of the week [0...6]
FXint getFirstDay() const { return firstday; }
/// Set the calendar style
void setCalendarStyle(FXuint);
/// Get the calendar style
FXuint getCalendarStyle() const;
/// Set the display color of titles
void setTitleColor(FXColor c);
/// Get the display color of titles
FXColor getTitleColor() const { return titleColor; }
/// Set the display background color of titles
void setTitleBackColor(FXColor c);
/// Get the display background color of titles
FXColor getTitleBackColor() const { return titleBackColor; }
/// Set the display color of non-weekend days
void setDayColor(FXColor c);
/// Get the display color of non-weekend days
FXColor getDayColor() const { return dayColor; }
/// Set the display color of non-weekend days not in the current month
void setOtherDayColor(FXColor c);
/// Get the display color of non-weekend days not in the current month
FXColor getOtherDayColor() const { return otherDayColor; }
/// Set the display color of today
void setTodayColor(FXColor c);
/// Get the display color of today
FXColor getTodayColor() const { return todayColor; }
/// Set the display color of days in the weekend
void setWeekendColor(FXColor c);
/// Get the display color of days in the weekend
FXColor getWeekendColor() const { return weekendColor; }
/// Set the display color of days in the weekend not in the current month
void setOtherWeekendColor(FXColor c);
/// Get the display color of days in the weekend not in the current month
FXColor getOtherWeekendColor() const { return otherWeekendColor; }
/// Set the text font
void setFont(FXFont *fnt);
/// Get the text font
FXFont* getFont() const { return font; }
/// Destructor
virtual ~FXCalendarView();
};
}
#endif
|