| 1 |
/* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
#include <gtkmm/widget.h> |
| 20 |
#include <glibmm/date.h> |
| 21 |
_DEFS(gtkmm,gtk) |
| 22 |
_PINCLUDE(gtkmm/private/widget_p.h) |
| 23 |
|
| 24 |
namespace Gtk |
| 25 |
{ |
| 26 |
|
| 27 |
_CC_INCLUDE(gtk/gtk.h) |
| 28 |
_WRAP_ENUM(CalendarDisplayOptions, GtkCalendarDisplayOptions, decl_prefix GTKMM_API) |
| 29 |
|
| 30 |
/** Display a calendar and/or allow the user to select a date. |
| 31 |
* |
| 32 |
* This is a widget that displays a calendar, one month at a time. |
| 33 |
* |
| 34 |
* The month and year currently displayed can be altered with |
| 35 |
* select_month(). The exact day can be selected from the displayed month |
| 36 |
* using select_day(). |
| 37 |
* |
| 38 |
* The way in which the calendar itself is displayed can be altered using |
| 39 |
* set_display_options(). |
| 40 |
* |
| 41 |
* The selected date can be retrieved from a GtkCalendar using get_date(). |
| 42 |
* |
| 43 |
* If performing many 'mark' operations, the calendar can be frozen to |
| 44 |
* prevent flicker, using freeze(), and 'thawed' again using thaw(). |
| 45 |
* |
| 46 |
* The Calendar widget looks like this: |
| 47 |
* @image html calendar1.png |
| 48 |
* |
| 49 |
* @ingroup Widgets |
| 50 |
*/ |
| 51 |
class GTKMM_API Calendar : public Widget |
| 52 |
{ |
| 53 |
_CLASS_GTKOBJECT(Calendar,GtkCalendar,GTK_CALENDAR,Gtk::Widget,GtkWidget,,,GTKMM_API) |
| 54 |
public: |
| 55 |
_CTOR_DEFAULT |
| 56 |
|
| 57 |
_WRAP_METHOD(void select_month(guint month, guint year), gtk_calendar_select_month) |
| 58 |
_WRAP_METHOD(void select_day(guint day), gtk_calendar_select_day) |
| 59 |
_WRAP_METHOD(void mark_day(guint day), gtk_calendar_mark_day) |
| 60 |
_WRAP_METHOD(void unmark_day(guint day), gtk_calendar_unmark_day) |
| 61 |
_WRAP_METHOD(void clear_marks(), gtk_calendar_clear_marks) |
| 62 |
|
| 63 |
_WRAP_METHOD(void set_display_options(CalendarDisplayOptions flags), gtk_calendar_set_display_options) |
| 64 |
_WRAP_METHOD(CalendarDisplayOptions get_display_options() const, gtk_calendar_get_display_options) |
| 65 |
|
| 66 |
_WRAP_METHOD(void get_date(guint& year, guint& month, guint& day) const, gtk_calendar_get_date) |
| 67 |
// Additional method not in GTK (#350584) |
| 68 |
/** Get the date as Glib::Date |
| 69 |
* |
| 70 |
* @param date Referenz to set the date |
| 71 |
*/ |
| 72 |
void get_date(Glib::Date& date) const; |
| 73 |
|
| 74 |
/** Detail markup handler. |
| 75 |
* For instance, |
| 76 |
* @code |
| 77 |
* Glib::ustring on_calendar_details(guint year, guint month, guint day); |
| 78 |
* @endcode |
| 79 |
* |
| 80 |
* @param year The year for which details are needed. |
| 81 |
* @param month The month for which details are needed. |
| 82 |
* @param day The day of @a month for which details are needed. |
| 83 |
* @result Pango markup with details for the specified day, or an empty string. |
| 84 |
* |
| 85 |
* This callback function provides Pango markup with detail information for the |
| 86 |
* specified day. Examples for such details are holidays or appointments. The |
| 87 |
* function should return an empty string when no information is available. |
| 88 |
* |
| 89 |
* @newin{2,14} |
| 90 |
*/ |
| 91 |
typedef sigc::slot<Glib::ustring, guint, guint, guint> SlotDetails; |
| 92 |
|
| 93 |
/** Installs a function which provides Pango markup with detail information |
| 94 |
* for each day. Examples for such details are holidays or appointments. That |
| 95 |
* information is shown below each day when show-details is set. |
| 96 |
* A tooltip containing full detail information is provided if the entire |
| 97 |
* text could not fit into the details area, or if the show-details property |
| 98 |
* is not set. |
| 99 |
* |
| 100 |
* The size of the details area can be restricted by setting the |
| 101 |
* detail-width-chars and detail-height-rows properties. |
| 102 |
* |
| 103 |
* @param slot A callback function providing details for each day. |
| 104 |
* |
| 105 |
* @newin{2,14} |
| 106 |
*/ |
| 107 |
void set_detail_func(const SlotDetails& slot); |
| 108 |
_IGNORE(gtk_calendar_set_detail_func) |
| 109 |
|
| 110 |
_WRAP_METHOD(void set_detail_width_chars(int chars), gtk_calendar_set_detail_width_chars) |
| 111 |
_WRAP_METHOD(void set_detail_height_rows(int rows), gtk_calendar_set_detail_height_rows) |
| 112 |
|
| 113 |
_WRAP_METHOD(int get_detail_width_chars() const, gtk_calendar_get_detail_width_chars) |
| 114 |
_WRAP_METHOD(int get_detail_height_rows() const, gtk_calendar_get_detail_height_rows) |
| 115 |
|
| 116 |
_WRAP_METHOD(bool get_day_is_marked(guint day) const, gtk_calendar_get_day_is_marked) |
| 117 |
|
| 118 |
_WRAP_SIGNAL(void month_changed(), "month_changed") |
| 119 |
_WRAP_SIGNAL(void day_selected(), "day_selected") |
| 120 |
_WRAP_SIGNAL(void day_selected_double_click(), "day_selected_double_click") |
| 121 |
_WRAP_SIGNAL(void prev_month(), "prev_month") |
| 122 |
_WRAP_SIGNAL(void next_month(), "next_month") |
| 123 |
_WRAP_SIGNAL(void prev_year(), "prev_year") |
| 124 |
_WRAP_SIGNAL(void next_year(), "next_year") |
| 125 |
|
| 126 |
_WRAP_PROPERTY("year", int) |
| 127 |
_WRAP_PROPERTY("month", int) |
| 128 |
_WRAP_PROPERTY("day", int) |
| 129 |
_WRAP_PROPERTY("show-heading", bool) |
| 130 |
_WRAP_PROPERTY("show-day-names", bool) |
| 131 |
_WRAP_PROPERTY("no-month-change", bool) |
| 132 |
_WRAP_PROPERTY("show-week-numbers", bool) |
| 133 |
_WRAP_PROPERTY("show-details", bool) |
| 134 |
_WRAP_PROPERTY("detail-width-chars", int) |
| 135 |
_WRAP_PROPERTY("detail-height-rows", int) |
| 136 |
}; |
| 137 |
|
| 138 |
} // namespace Gtk |