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