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