PageRenderTime 36ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/generated/gtkd/gtk/Calendar.d

http://github.com/gtkd-developers/GtkD
D | 359 lines | 125 code | 35 blank | 199 comment | 3 complexity | 891954874f587727b368743d25e4dc8c MD5 | raw file
Possible License(s): LGPL-3.0
  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. // generated automatically - do not change
  20. // find conversion definition on APILookup.txt
  21. // implement new conversion functionalities on the wrap.utils pakage
  22. module gtk.Calendar;
  23. private import glib.ConstructionException;
  24. private import gobject.ObjectG;
  25. private import gobject.Signals;
  26. private import gtk.Widget;
  27. private import gtk.c.functions;
  28. public import gtk.c.types;
  29. public import gtkc.gtktypes;
  30. private import std.algorithm;
  31. /**
  32. * #GtkCalendar is a widget that displays a Gregorian calendar, one month
  33. * at a time. It can be created with gtk_calendar_new().
  34. *
  35. * The month and year currently displayed can be altered with
  36. * gtk_calendar_select_month(). The exact day can be selected from the
  37. * displayed month using gtk_calendar_select_day().
  38. *
  39. * To place a visual marker on a particular day, use gtk_calendar_mark_day()
  40. * and to remove the marker, gtk_calendar_unmark_day(). Alternative, all
  41. * marks can be cleared with gtk_calendar_clear_marks().
  42. *
  43. * The way in which the calendar itself is displayed can be altered using
  44. * gtk_calendar_set_display_options().
  45. *
  46. * The selected date can be retrieved from a #GtkCalendar using
  47. * gtk_calendar_get_date().
  48. *
  49. * Users should be aware that, although the Gregorian calendar is the
  50. * legal calendar in most countries, it was adopted progressively
  51. * between 1582 and 1929. Display before these dates is likely to be
  52. * historically incorrect.
  53. */
  54. public class Calendar : Widget
  55. {
  56. /** the main Gtk struct */
  57. protected GtkCalendar* gtkCalendar;
  58. /** Get the main Gtk struct */
  59. public GtkCalendar* getCalendarStruct(bool transferOwnership = false)
  60. {
  61. if (transferOwnership)
  62. ownedRef = false;
  63. return gtkCalendar;
  64. }
  65. /** the main Gtk struct as a void* */
  66. protected override void* getStruct()
  67. {
  68. return cast(void*)gtkCalendar;
  69. }
  70. /**
  71. * Sets our main struct and passes it to the parent class.
  72. */
  73. public this (GtkCalendar* gtkCalendar, bool ownedRef = false)
  74. {
  75. this.gtkCalendar = gtkCalendar;
  76. super(cast(GtkWidget*)gtkCalendar, ownedRef);
  77. }
  78. /** */
  79. public static GType getType()
  80. {
  81. return gtk_calendar_get_type();
  82. }
  83. /**
  84. * Creates a new calendar, with the current date being selected.
  85. *
  86. * Returns: a newly #GtkCalendar widget
  87. *
  88. * Throws: ConstructionException GTK+ fails to create the object.
  89. */
  90. public this()
  91. {
  92. auto p = gtk_calendar_new();
  93. if(p is null)
  94. {
  95. throw new ConstructionException("null returned by new");
  96. }
  97. this(cast(GtkCalendar*) p);
  98. }
  99. /**
  100. * Remove all visual markers.
  101. */
  102. public void clearMarks()
  103. {
  104. gtk_calendar_clear_marks(gtkCalendar);
  105. }
  106. /**
  107. * Obtains the selected date from a #GtkCalendar.
  108. *
  109. * Params:
  110. * year = location to store the year as a decimal
  111. * number (e.g. 2011), or %NULL
  112. * month = location to store the month number
  113. * (between 0 and 11), or %NULL
  114. * day = location to store the day number (between
  115. * 1 and 31), or %NULL
  116. */
  117. public void getDate(out uint year, out uint month, out uint day)
  118. {
  119. gtk_calendar_get_date(gtkCalendar, &year, &month, &day);
  120. }
  121. /**
  122. * Returns if the @day of the @calendar is already marked.
  123. *
  124. * Params:
  125. * day = the day number between 1 and 31.
  126. *
  127. * Returns: whether the day is marked.
  128. *
  129. * Since: 3.0
  130. */
  131. public bool getDayIsMarked(uint day)
  132. {
  133. return gtk_calendar_get_day_is_marked(gtkCalendar, day) != 0;
  134. }
  135. /**
  136. * Queries the height of detail cells, in rows.
  137. * See #GtkCalendar:detail-width-chars.
  138. *
  139. * Returns: The height of detail cells, in rows.
  140. *
  141. * Since: 2.14
  142. */
  143. public int getDetailHeightRows()
  144. {
  145. return gtk_calendar_get_detail_height_rows(gtkCalendar);
  146. }
  147. /**
  148. * Queries the width of detail cells, in characters.
  149. * See #GtkCalendar:detail-width-chars.
  150. *
  151. * Returns: The width of detail cells, in characters.
  152. *
  153. * Since: 2.14
  154. */
  155. public int getDetailWidthChars()
  156. {
  157. return gtk_calendar_get_detail_width_chars(gtkCalendar);
  158. }
  159. /**
  160. * Returns the current display options of @calendar.
  161. *
  162. * Returns: the display options.
  163. *
  164. * Since: 2.4
  165. */
  166. public GtkCalendarDisplayOptions getDisplayOptions()
  167. {
  168. return gtk_calendar_get_display_options(gtkCalendar);
  169. }
  170. /**
  171. * Places a visual marker on a particular day.
  172. *
  173. * Params:
  174. * day = the day number to mark between 1 and 31.
  175. */
  176. public void markDay(uint day)
  177. {
  178. gtk_calendar_mark_day(gtkCalendar, day);
  179. }
  180. /**
  181. * Selects a day from the current month.
  182. *
  183. * Params:
  184. * day = the day number between 1 and 31, or 0 to unselect
  185. * the currently selected day.
  186. */
  187. public void selectDay(uint day)
  188. {
  189. gtk_calendar_select_day(gtkCalendar, day);
  190. }
  191. /**
  192. * Shifts the calendar to a different month.
  193. *
  194. * Params:
  195. * month = a month number between 0 and 11.
  196. * year = the year the month is in.
  197. */
  198. public void selectMonth(uint month, uint year)
  199. {
  200. gtk_calendar_select_month(gtkCalendar, month, year);
  201. }
  202. /**
  203. * Installs a function which provides Pango markup with detail information
  204. * for each day. Examples for such details are holidays or appointments. That
  205. * information is shown below each day when #GtkCalendar:show-details is set.
  206. * A tooltip containing with full detail information is provided, if the entire
  207. * text should not fit into the details area, or if #GtkCalendar:show-details
  208. * is not set.
  209. *
  210. * The size of the details area can be restricted by setting the
  211. * #GtkCalendar:detail-width-chars and #GtkCalendar:detail-height-rows
  212. * properties.
  213. *
  214. * Params:
  215. * func = a function providing details for each day.
  216. * data = data to pass to @func invokations.
  217. * destroy = a function for releasing @data.
  218. *
  219. * Since: 2.14
  220. */
  221. public void setDetailFunc(GtkCalendarDetailFunc func, void* data, GDestroyNotify destroy)
  222. {
  223. gtk_calendar_set_detail_func(gtkCalendar, func, data, destroy);
  224. }
  225. /**
  226. * Updates the height of detail cells.
  227. * See #GtkCalendar:detail-height-rows.
  228. *
  229. * Params:
  230. * rows = detail height in rows.
  231. *
  232. * Since: 2.14
  233. */
  234. public void setDetailHeightRows(int rows)
  235. {
  236. gtk_calendar_set_detail_height_rows(gtkCalendar, rows);
  237. }
  238. /**
  239. * Updates the width of detail cells.
  240. * See #GtkCalendar:detail-width-chars.
  241. *
  242. * Params:
  243. * chars = detail width in characters.
  244. *
  245. * Since: 2.14
  246. */
  247. public void setDetailWidthChars(int chars)
  248. {
  249. gtk_calendar_set_detail_width_chars(gtkCalendar, chars);
  250. }
  251. /**
  252. * Sets display options (whether to display the heading and the month
  253. * headings).
  254. *
  255. * Params:
  256. * flags = the display options to set
  257. *
  258. * Since: 2.4
  259. */
  260. public void setDisplayOptions(GtkCalendarDisplayOptions flags)
  261. {
  262. gtk_calendar_set_display_options(gtkCalendar, flags);
  263. }
  264. /**
  265. * Removes the visual marker from a particular day.
  266. *
  267. * Params:
  268. * day = the day number to unmark between 1 and 31.
  269. */
  270. public void unmarkDay(uint day)
  271. {
  272. gtk_calendar_unmark_day(gtkCalendar, day);
  273. }
  274. /**
  275. * Emitted when the user selects a day.
  276. */
  277. gulong addOnDaySelected(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  278. {
  279. return Signals.connect(this, "day-selected", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  280. }
  281. /**
  282. * Emitted when the user double-clicks a day.
  283. */
  284. gulong addOnDaySelectedDoubleClick(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  285. {
  286. return Signals.connect(this, "day-selected-double-click", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  287. }
  288. /**
  289. * Emitted when the user clicks a button to change the selected month on a
  290. * calendar.
  291. */
  292. gulong addOnMonthChanged(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  293. {
  294. return Signals.connect(this, "month-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  295. }
  296. /**
  297. * Emitted when the user switched to the next month.
  298. */
  299. gulong addOnNextMonth(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  300. {
  301. return Signals.connect(this, "next-month", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  302. }
  303. /**
  304. * Emitted when user switched to the next year.
  305. */
  306. gulong addOnNextYear(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  307. {
  308. return Signals.connect(this, "next-year", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  309. }
  310. /**
  311. * Emitted when the user switched to the previous month.
  312. */
  313. gulong addOnPrevMonth(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  314. {
  315. return Signals.connect(this, "prev-month", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  316. }
  317. /**
  318. * Emitted when user switched to the previous year.
  319. */
  320. gulong addOnPrevYear(void delegate(Calendar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
  321. {
  322. return Signals.connect(this, "prev-year", dlg, connectFlags ^ ConnectFlags.SWAPPED);
  323. }
  324. }