1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Calendar;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Widget;
31 public  import gtkc.gdktypes;
32 private import gtkc.gtk;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * #GtkCalendar is a widget that displays a Gregorian calendar, one month
38  * at a time. It can be created with gtk_calendar_new().
39  * 
40  * The month and year currently displayed can be altered with
41  * gtk_calendar_select_month(). The exact day can be selected from the
42  * displayed month using gtk_calendar_select_day().
43  * 
44  * To place a visual marker on a particular day, use gtk_calendar_mark_day()
45  * and to remove the marker, gtk_calendar_unmark_day(). Alternative, all
46  * marks can be cleared with gtk_calendar_clear_marks().
47  * 
48  * The way in which the calendar itself is displayed can be altered using
49  * gtk_calendar_set_display_options().
50  * 
51  * The selected date can be retrieved from a #GtkCalendar using
52  * gtk_calendar_get_date().
53  * 
54  * Users should be aware that, although the Gregorian calendar is the
55  * legal calendar in most countries, it was adopted progressively
56  * between 1582 and 1929. Display before these dates is likely to be
57  * historically incorrect.
58  */
59 public class Calendar : Widget
60 {
61 	/** the main Gtk struct */
62 	protected GtkCalendar* gtkCalendar;
63 
64 	/** Get the main Gtk struct */
65 	public GtkCalendar* getCalendarStruct()
66 	{
67 		return gtkCalendar;
68 	}
69 
70 	/** the main Gtk struct as a void* */
71 	protected override void* getStruct()
72 	{
73 		return cast(void*)gtkCalendar;
74 	}
75 
76 	protected override void setStruct(GObject* obj)
77 	{
78 		gtkCalendar = cast(GtkCalendar*)obj;
79 		super.setStruct(obj);
80 	}
81 
82 	/**
83 	 * Sets our main struct and passes it to the parent class.
84 	 */
85 	public this (GtkCalendar* gtkCalendar, bool ownedRef = false)
86 	{
87 		this.gtkCalendar = gtkCalendar;
88 		super(cast(GtkWidget*)gtkCalendar, ownedRef);
89 	}
90 
91 
92 	/** */
93 	public static GType getType()
94 	{
95 		return gtk_calendar_get_type();
96 	}
97 
98 	/**
99 	 * Creates a new calendar, with the current date being selected.
100 	 *
101 	 * Return: a newly #GtkCalendar widget
102 	 *
103 	 * Throws: ConstructionException GTK+ fails to create the object.
104 	 */
105 	public this()
106 	{
107 		auto p = gtk_calendar_new();
108 		
109 		if(p is null)
110 		{
111 			throw new ConstructionException("null returned by new");
112 		}
113 		
114 		this(cast(GtkCalendar*) p);
115 	}
116 
117 	/**
118 	 * Remove all visual markers.
119 	 */
120 	public void clearMarks()
121 	{
122 		gtk_calendar_clear_marks(gtkCalendar);
123 	}
124 
125 	/**
126 	 * Obtains the selected date from a #GtkCalendar.
127 	 *
128 	 * Params:
129 	 *     year = location to store the year as a decimal
130 	 *         number (e.g. 2011), or %NULL
131 	 *     month = location to store the month number
132 	 *         (between 0 and 11), or %NULL
133 	 *     day = location to store the day number (between
134 	 *         1 and 31), or %NULL
135 	 */
136 	public void getDate(out uint year, out uint month, out uint day)
137 	{
138 		gtk_calendar_get_date(gtkCalendar, &year, &month, &day);
139 	}
140 
141 	/**
142 	 * Returns if the @day of the @calendar is already marked.
143 	 *
144 	 * Params:
145 	 *     day = the day number between 1 and 31.
146 	 *
147 	 * Return: whether the day is marked.
148 	 *
149 	 * Since: 3.0
150 	 */
151 	public bool getDayIsMarked(uint day)
152 	{
153 		return gtk_calendar_get_day_is_marked(gtkCalendar, day) != 0;
154 	}
155 
156 	/**
157 	 * Queries the height of detail cells, in rows.
158 	 * See #GtkCalendar:detail-width-chars.
159 	 *
160 	 * Return: The height of detail cells, in rows.
161 	 *
162 	 * Since: 2.14
163 	 */
164 	public int getDetailHeightRows()
165 	{
166 		return gtk_calendar_get_detail_height_rows(gtkCalendar);
167 	}
168 
169 	/**
170 	 * Queries the width of detail cells, in characters.
171 	 * See #GtkCalendar:detail-width-chars.
172 	 *
173 	 * Return: The width of detail cells, in characters.
174 	 *
175 	 * Since: 2.14
176 	 */
177 	public int getDetailWidthChars()
178 	{
179 		return gtk_calendar_get_detail_width_chars(gtkCalendar);
180 	}
181 
182 	/**
183 	 * Returns the current display options of @calendar.
184 	 *
185 	 * Return: the display options.
186 	 *
187 	 * Since: 2.4
188 	 */
189 	public GtkCalendarDisplayOptions getDisplayOptions()
190 	{
191 		return gtk_calendar_get_display_options(gtkCalendar);
192 	}
193 
194 	/**
195 	 * Places a visual marker on a particular day.
196 	 *
197 	 * Params:
198 	 *     day = the day number to mark between 1 and 31.
199 	 */
200 	public void markDay(uint day)
201 	{
202 		gtk_calendar_mark_day(gtkCalendar, day);
203 	}
204 
205 	/**
206 	 * Selects a day from the current month.
207 	 *
208 	 * Params:
209 	 *     day = the day number between 1 and 31, or 0 to unselect
210 	 *         the currently selected day.
211 	 */
212 	public void selectDay(uint day)
213 	{
214 		gtk_calendar_select_day(gtkCalendar, day);
215 	}
216 
217 	/**
218 	 * Shifts the calendar to a different month.
219 	 *
220 	 * Params:
221 	 *     month = a month number between 0 and 11.
222 	 *     year = the year the month is in.
223 	 */
224 	public void selectMonth(uint month, uint year)
225 	{
226 		gtk_calendar_select_month(gtkCalendar, month, year);
227 	}
228 
229 	/**
230 	 * Installs a function which provides Pango markup with detail information
231 	 * for each day. Examples for such details are holidays or appointments. That
232 	 * information is shown below each day when #GtkCalendar:show-details is set.
233 	 * A tooltip containing with full detail information is provided, if the entire
234 	 * text should not fit into the details area, or if #GtkCalendar:show-details
235 	 * is not set.
236 	 *
237 	 * The size of the details area can be restricted by setting the
238 	 * #GtkCalendar:detail-width-chars and #GtkCalendar:detail-height-rows
239 	 * properties.
240 	 *
241 	 * Params:
242 	 *     func = a function providing details for each day.
243 	 *     data = data to pass to @func invokations.
244 	 *     destroy = a function for releasing @data.
245 	 *
246 	 * Since: 2.14
247 	 */
248 	public void setDetailFunc(GtkCalendarDetailFunc func, void* data, GDestroyNotify destroy)
249 	{
250 		gtk_calendar_set_detail_func(gtkCalendar, func, data, destroy);
251 	}
252 
253 	/**
254 	 * Updates the height of detail cells.
255 	 * See #GtkCalendar:detail-height-rows.
256 	 *
257 	 * Params:
258 	 *     rows = detail height in rows.
259 	 *
260 	 * Since: 2.14
261 	 */
262 	public void setDetailHeightRows(int rows)
263 	{
264 		gtk_calendar_set_detail_height_rows(gtkCalendar, rows);
265 	}
266 
267 	/**
268 	 * Updates the width of detail cells.
269 	 * See #GtkCalendar:detail-width-chars.
270 	 *
271 	 * Params:
272 	 *     chars = detail width in characters.
273 	 *
274 	 * Since: 2.14
275 	 */
276 	public void setDetailWidthChars(int chars)
277 	{
278 		gtk_calendar_set_detail_width_chars(gtkCalendar, chars);
279 	}
280 
281 	/**
282 	 * Sets display options (whether to display the heading and the month
283 	 * headings).
284 	 *
285 	 * Params:
286 	 *     flags = the display options to set
287 	 *
288 	 * Since: 2.4
289 	 */
290 	public void setDisplayOptions(GtkCalendarDisplayOptions flags)
291 	{
292 		gtk_calendar_set_display_options(gtkCalendar, flags);
293 	}
294 
295 	/**
296 	 * Removes the visual marker from a particular day.
297 	 *
298 	 * Params:
299 	 *     day = the day number to unmark between 1 and 31.
300 	 */
301 	public void unmarkDay(uint day)
302 	{
303 		gtk_calendar_unmark_day(gtkCalendar, day);
304 	}
305 
306 	int[string] connectedSignals;
307 
308 	void delegate(Calendar)[] onDaySelectedListeners;
309 	/**
310 	 * Emitted when the user selects a day.
311 	 */
312 	void addOnDaySelected(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
313 	{
314 		if ( "day-selected" !in connectedSignals )
315 		{
316 			Signals.connectData(
317 				this,
318 				"day-selected",
319 				cast(GCallback)&callBackDaySelected,
320 				cast(void*)this,
321 				null,
322 				connectFlags);
323 			connectedSignals["day-selected"] = 1;
324 		}
325 		onDaySelectedListeners ~= dlg;
326 	}
327 	extern(C) static void callBackDaySelected(GtkCalendar* calendarStruct, Calendar _calendar)
328 	{
329 		foreach ( void delegate(Calendar) dlg; _calendar.onDaySelectedListeners )
330 		{
331 			dlg(_calendar);
332 		}
333 	}
334 
335 	void delegate(Calendar)[] onDaySelectedDoubleClickListeners;
336 	/**
337 	 * Emitted when the user double-clicks a day.
338 	 */
339 	void addOnDaySelectedDoubleClick(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
340 	{
341 		if ( "day-selected-double-click" !in connectedSignals )
342 		{
343 			Signals.connectData(
344 				this,
345 				"day-selected-double-click",
346 				cast(GCallback)&callBackDaySelectedDoubleClick,
347 				cast(void*)this,
348 				null,
349 				connectFlags);
350 			connectedSignals["day-selected-double-click"] = 1;
351 		}
352 		onDaySelectedDoubleClickListeners ~= dlg;
353 	}
354 	extern(C) static void callBackDaySelectedDoubleClick(GtkCalendar* calendarStruct, Calendar _calendar)
355 	{
356 		foreach ( void delegate(Calendar) dlg; _calendar.onDaySelectedDoubleClickListeners )
357 		{
358 			dlg(_calendar);
359 		}
360 	}
361 
362 	void delegate(Calendar)[] onMonthChangedListeners;
363 	/**
364 	 * Emitted when the user clicks a button to change the selected month on a
365 	 * calendar.
366 	 */
367 	void addOnMonthChanged(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
368 	{
369 		if ( "month-changed" !in connectedSignals )
370 		{
371 			Signals.connectData(
372 				this,
373 				"month-changed",
374 				cast(GCallback)&callBackMonthChanged,
375 				cast(void*)this,
376 				null,
377 				connectFlags);
378 			connectedSignals["month-changed"] = 1;
379 		}
380 		onMonthChangedListeners ~= dlg;
381 	}
382 	extern(C) static void callBackMonthChanged(GtkCalendar* calendarStruct, Calendar _calendar)
383 	{
384 		foreach ( void delegate(Calendar) dlg; _calendar.onMonthChangedListeners )
385 		{
386 			dlg(_calendar);
387 		}
388 	}
389 
390 	void delegate(Calendar)[] onNextMonthListeners;
391 	/**
392 	 * Emitted when the user switched to the next month.
393 	 */
394 	void addOnNextMonth(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
395 	{
396 		if ( "next-month" !in connectedSignals )
397 		{
398 			Signals.connectData(
399 				this,
400 				"next-month",
401 				cast(GCallback)&callBackNextMonth,
402 				cast(void*)this,
403 				null,
404 				connectFlags);
405 			connectedSignals["next-month"] = 1;
406 		}
407 		onNextMonthListeners ~= dlg;
408 	}
409 	extern(C) static void callBackNextMonth(GtkCalendar* calendarStruct, Calendar _calendar)
410 	{
411 		foreach ( void delegate(Calendar) dlg; _calendar.onNextMonthListeners )
412 		{
413 			dlg(_calendar);
414 		}
415 	}
416 
417 	void delegate(Calendar)[] onNextYearListeners;
418 	/**
419 	 * Emitted when user switched to the next year.
420 	 */
421 	void addOnNextYear(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
422 	{
423 		if ( "next-year" !in connectedSignals )
424 		{
425 			Signals.connectData(
426 				this,
427 				"next-year",
428 				cast(GCallback)&callBackNextYear,
429 				cast(void*)this,
430 				null,
431 				connectFlags);
432 			connectedSignals["next-year"] = 1;
433 		}
434 		onNextYearListeners ~= dlg;
435 	}
436 	extern(C) static void callBackNextYear(GtkCalendar* calendarStruct, Calendar _calendar)
437 	{
438 		foreach ( void delegate(Calendar) dlg; _calendar.onNextYearListeners )
439 		{
440 			dlg(_calendar);
441 		}
442 	}
443 
444 	void delegate(Calendar)[] onPrevMonthListeners;
445 	/**
446 	 * Emitted when the user switched to the previous month.
447 	 */
448 	void addOnPrevMonth(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
449 	{
450 		if ( "prev-month" !in connectedSignals )
451 		{
452 			Signals.connectData(
453 				this,
454 				"prev-month",
455 				cast(GCallback)&callBackPrevMonth,
456 				cast(void*)this,
457 				null,
458 				connectFlags);
459 			connectedSignals["prev-month"] = 1;
460 		}
461 		onPrevMonthListeners ~= dlg;
462 	}
463 	extern(C) static void callBackPrevMonth(GtkCalendar* calendarStruct, Calendar _calendar)
464 	{
465 		foreach ( void delegate(Calendar) dlg; _calendar.onPrevMonthListeners )
466 		{
467 			dlg(_calendar);
468 		}
469 	}
470 
471 	void delegate(Calendar)[] onPrevYearListeners;
472 	/**
473 	 * Emitted when user switched to the previous year.
474 	 */
475 	void addOnPrevYear(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
476 	{
477 		if ( "prev-year" !in connectedSignals )
478 		{
479 			Signals.connectData(
480 				this,
481 				"prev-year",
482 				cast(GCallback)&callBackPrevYear,
483 				cast(void*)this,
484 				null,
485 				connectFlags);
486 			connectedSignals["prev-year"] = 1;
487 		}
488 		onPrevYearListeners ~= dlg;
489 	}
490 	extern(C) static void callBackPrevYear(GtkCalendar* calendarStruct, Calendar _calendar)
491 	{
492 		foreach ( void delegate(Calendar) dlg; _calendar.onPrevYearListeners )
493 		{
494 			dlg(_calendar);
495 		}
496 	}
497 }