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