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 
94 	public static GType getType()
95 	{
96 		return gtk_calendar_get_type();
97 	}
98 
99 	/**
100 	 * Creates a new calendar, with the current date being selected.
101 	 *
102 	 * Return: a newly #GtkCalendar widget
103 	 *
104 	 * Throws: ConstructionException GTK+ fails to create the object.
105 	 */
106 	public this()
107 	{
108 		auto p = gtk_calendar_new();
109 		
110 		if(p is null)
111 		{
112 			throw new ConstructionException("null returned by new");
113 		}
114 		
115 		this(cast(GtkCalendar*) p);
116 	}
117 
118 	/**
119 	 * Remove all visual markers.
120 	 */
121 	public void clearMarks()
122 	{
123 		gtk_calendar_clear_marks(gtkCalendar);
124 	}
125 
126 	/**
127 	 * Obtains the selected date from a #GtkCalendar.
128 	 *
129 	 * Params:
130 	 *     year = location to store the year as a decimal
131 	 *         number (e.g. 2011), or %NULL
132 	 *     month = location to store the month number
133 	 *         (between 0 and 11), or %NULL
134 	 *     day = location to store the day number (between
135 	 *         1 and 31), or %NULL
136 	 */
137 	public void getDate(out uint year, out uint month, out uint day)
138 	{
139 		gtk_calendar_get_date(gtkCalendar, &year, &month, &day);
140 	}
141 
142 	/**
143 	 * Returns if the @day of the @calendar is already marked.
144 	 *
145 	 * Params:
146 	 *     day = the day number between 1 and 31.
147 	 *
148 	 * Return: whether the day is marked.
149 	 *
150 	 * Since: 3.0
151 	 */
152 	public bool getDayIsMarked(uint day)
153 	{
154 		return gtk_calendar_get_day_is_marked(gtkCalendar, day) != 0;
155 	}
156 
157 	/**
158 	 * Queries the height of detail cells, in rows.
159 	 * See #GtkCalendar:detail-width-chars.
160 	 *
161 	 * Return: The height of detail cells, in rows.
162 	 *
163 	 * Since: 2.14
164 	 */
165 	public int getDetailHeightRows()
166 	{
167 		return gtk_calendar_get_detail_height_rows(gtkCalendar);
168 	}
169 
170 	/**
171 	 * Queries the width of detail cells, in characters.
172 	 * See #GtkCalendar:detail-width-chars.
173 	 *
174 	 * Return: The width of detail cells, in characters.
175 	 *
176 	 * Since: 2.14
177 	 */
178 	public int getDetailWidthChars()
179 	{
180 		return gtk_calendar_get_detail_width_chars(gtkCalendar);
181 	}
182 
183 	/**
184 	 * Returns the current display options of @calendar.
185 	 *
186 	 * Return: the display options.
187 	 *
188 	 * Since: 2.4
189 	 */
190 	public GtkCalendarDisplayOptions getDisplayOptions()
191 	{
192 		return gtk_calendar_get_display_options(gtkCalendar);
193 	}
194 
195 	/**
196 	 * Places a visual marker on a particular day.
197 	 *
198 	 * Params:
199 	 *     day = the day number to mark between 1 and 31.
200 	 */
201 	public void markDay(uint day)
202 	{
203 		gtk_calendar_mark_day(gtkCalendar, day);
204 	}
205 
206 	/**
207 	 * Selects a day from the current month.
208 	 *
209 	 * Params:
210 	 *     day = the day number between 1 and 31, or 0 to unselect
211 	 *         the currently selected day.
212 	 */
213 	public void selectDay(uint day)
214 	{
215 		gtk_calendar_select_day(gtkCalendar, day);
216 	}
217 
218 	/**
219 	 * Shifts the calendar to a different month.
220 	 *
221 	 * Params:
222 	 *     month = a month number between 0 and 11.
223 	 *     year = the year the month is in.
224 	 */
225 	public void selectMonth(uint month, uint year)
226 	{
227 		gtk_calendar_select_month(gtkCalendar, month, year);
228 	}
229 
230 	/**
231 	 * Installs a function which provides Pango markup with detail information
232 	 * for each day. Examples for such details are holidays or appointments. That
233 	 * information is shown below each day when #GtkCalendar:show-details is set.
234 	 * A tooltip containing with full detail information is provided, if the entire
235 	 * text should not fit into the details area, or if #GtkCalendar:show-details
236 	 * is not set.
237 	 *
238 	 * The size of the details area can be restricted by setting the
239 	 * #GtkCalendar:detail-width-chars and #GtkCalendar:detail-height-rows
240 	 * properties.
241 	 *
242 	 * Params:
243 	 *     func = a function providing details for each day.
244 	 *     data = data to pass to @func invokations.
245 	 *     destroy = a function for releasing @data.
246 	 *
247 	 * Since: 2.14
248 	 */
249 	public void setDetailFunc(GtkCalendarDetailFunc func, void* data, GDestroyNotify destroy)
250 	{
251 		gtk_calendar_set_detail_func(gtkCalendar, func, data, destroy);
252 	}
253 
254 	/**
255 	 * Updates the height of detail cells.
256 	 * See #GtkCalendar:detail-height-rows.
257 	 *
258 	 * Params:
259 	 *     rows = detail height in rows.
260 	 *
261 	 * Since: 2.14
262 	 */
263 	public void setDetailHeightRows(int rows)
264 	{
265 		gtk_calendar_set_detail_height_rows(gtkCalendar, rows);
266 	}
267 
268 	/**
269 	 * Updates the width of detail cells.
270 	 * See #GtkCalendar:detail-width-chars.
271 	 *
272 	 * Params:
273 	 *     chars = detail width in characters.
274 	 *
275 	 * Since: 2.14
276 	 */
277 	public void setDetailWidthChars(int chars)
278 	{
279 		gtk_calendar_set_detail_width_chars(gtkCalendar, chars);
280 	}
281 
282 	/**
283 	 * Sets display options (whether to display the heading and the month
284 	 * headings).
285 	 *
286 	 * Params:
287 	 *     flags = the display options to set
288 	 *
289 	 * Since: 2.4
290 	 */
291 	public void setDisplayOptions(GtkCalendarDisplayOptions flags)
292 	{
293 		gtk_calendar_set_display_options(gtkCalendar, flags);
294 	}
295 
296 	/**
297 	 * Removes the visual marker from a particular day.
298 	 *
299 	 * Params:
300 	 *     day = the day number to unmark between 1 and 31.
301 	 */
302 	public void unmarkDay(uint day)
303 	{
304 		gtk_calendar_unmark_day(gtkCalendar, day);
305 	}
306 
307 	int[string] connectedSignals;
308 
309 	void delegate(Calendar)[] onDaySelectedListeners;
310 	/**
311 	 * Emitted when the user selects a day.
312 	 */
313 	void addOnDaySelected(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
314 	{
315 		if ( "day-selected" !in connectedSignals )
316 		{
317 			Signals.connectData(
318 				this,
319 				"day-selected",
320 				cast(GCallback)&callBackDaySelected,
321 				cast(void*)this,
322 				null,
323 				connectFlags);
324 			connectedSignals["day-selected"] = 1;
325 		}
326 		onDaySelectedListeners ~= dlg;
327 	}
328 	extern(C) static void callBackDaySelected(GtkCalendar* calendarStruct, Calendar _calendar)
329 	{
330 		foreach ( void delegate(Calendar) dlg; _calendar.onDaySelectedListeners )
331 		{
332 			dlg(_calendar);
333 		}
334 	}
335 
336 	void delegate(Calendar)[] onDaySelectedDoubleClickListeners;
337 	/**
338 	 * Emitted when the user double-clicks a day.
339 	 */
340 	void addOnDaySelectedDoubleClick(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
341 	{
342 		if ( "day-selected-double-click" !in connectedSignals )
343 		{
344 			Signals.connectData(
345 				this,
346 				"day-selected-double-click",
347 				cast(GCallback)&callBackDaySelectedDoubleClick,
348 				cast(void*)this,
349 				null,
350 				connectFlags);
351 			connectedSignals["day-selected-double-click"] = 1;
352 		}
353 		onDaySelectedDoubleClickListeners ~= dlg;
354 	}
355 	extern(C) static void callBackDaySelectedDoubleClick(GtkCalendar* calendarStruct, Calendar _calendar)
356 	{
357 		foreach ( void delegate(Calendar) dlg; _calendar.onDaySelectedDoubleClickListeners )
358 		{
359 			dlg(_calendar);
360 		}
361 	}
362 
363 	void delegate(Calendar)[] onMonthChangedListeners;
364 	/**
365 	 * Emitted when the user clicks a button to change the selected month on a
366 	 * calendar.
367 	 */
368 	void addOnMonthChanged(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
369 	{
370 		if ( "month-changed" !in connectedSignals )
371 		{
372 			Signals.connectData(
373 				this,
374 				"month-changed",
375 				cast(GCallback)&callBackMonthChanged,
376 				cast(void*)this,
377 				null,
378 				connectFlags);
379 			connectedSignals["month-changed"] = 1;
380 		}
381 		onMonthChangedListeners ~= dlg;
382 	}
383 	extern(C) static void callBackMonthChanged(GtkCalendar* calendarStruct, Calendar _calendar)
384 	{
385 		foreach ( void delegate(Calendar) dlg; _calendar.onMonthChangedListeners )
386 		{
387 			dlg(_calendar);
388 		}
389 	}
390 
391 	void delegate(Calendar)[] onNextMonthListeners;
392 	/**
393 	 * Emitted when the user switched to the next month.
394 	 */
395 	void addOnNextMonth(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
396 	{
397 		if ( "next-month" !in connectedSignals )
398 		{
399 			Signals.connectData(
400 				this,
401 				"next-month",
402 				cast(GCallback)&callBackNextMonth,
403 				cast(void*)this,
404 				null,
405 				connectFlags);
406 			connectedSignals["next-month"] = 1;
407 		}
408 		onNextMonthListeners ~= dlg;
409 	}
410 	extern(C) static void callBackNextMonth(GtkCalendar* calendarStruct, Calendar _calendar)
411 	{
412 		foreach ( void delegate(Calendar) dlg; _calendar.onNextMonthListeners )
413 		{
414 			dlg(_calendar);
415 		}
416 	}
417 
418 	void delegate(Calendar)[] onNextYearListeners;
419 	/**
420 	 * Emitted when user switched to the next year.
421 	 */
422 	void addOnNextYear(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
423 	{
424 		if ( "next-year" !in connectedSignals )
425 		{
426 			Signals.connectData(
427 				this,
428 				"next-year",
429 				cast(GCallback)&callBackNextYear,
430 				cast(void*)this,
431 				null,
432 				connectFlags);
433 			connectedSignals["next-year"] = 1;
434 		}
435 		onNextYearListeners ~= dlg;
436 	}
437 	extern(C) static void callBackNextYear(GtkCalendar* calendarStruct, Calendar _calendar)
438 	{
439 		foreach ( void delegate(Calendar) dlg; _calendar.onNextYearListeners )
440 		{
441 			dlg(_calendar);
442 		}
443 	}
444 
445 	void delegate(Calendar)[] onPrevMonthListeners;
446 	/**
447 	 * Emitted when the user switched to the previous month.
448 	 */
449 	void addOnPrevMonth(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
450 	{
451 		if ( "prev-month" !in connectedSignals )
452 		{
453 			Signals.connectData(
454 				this,
455 				"prev-month",
456 				cast(GCallback)&callBackPrevMonth,
457 				cast(void*)this,
458 				null,
459 				connectFlags);
460 			connectedSignals["prev-month"] = 1;
461 		}
462 		onPrevMonthListeners ~= dlg;
463 	}
464 	extern(C) static void callBackPrevMonth(GtkCalendar* calendarStruct, Calendar _calendar)
465 	{
466 		foreach ( void delegate(Calendar) dlg; _calendar.onPrevMonthListeners )
467 		{
468 			dlg(_calendar);
469 		}
470 	}
471 
472 	void delegate(Calendar)[] onPrevYearListeners;
473 	/**
474 	 * Emitted when user switched to the previous year.
475 	 */
476 	void addOnPrevYear(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
477 	{
478 		if ( "prev-year" !in connectedSignals )
479 		{
480 			Signals.connectData(
481 				this,
482 				"prev-year",
483 				cast(GCallback)&callBackPrevYear,
484 				cast(void*)this,
485 				null,
486 				connectFlags);
487 			connectedSignals["prev-year"] = 1;
488 		}
489 		onPrevYearListeners ~= dlg;
490 	}
491 	extern(C) static void callBackPrevYear(GtkCalendar* calendarStruct, Calendar _calendar)
492 	{
493 		foreach ( void delegate(Calendar) dlg; _calendar.onPrevYearListeners )
494 		{
495 			dlg(_calendar);
496 		}
497 	}
498 }