/src/wrappers/gtk/library/gtk_calendar.e

http://github.com/tybor/Liberty · Specman e · 373 lines · 132 code · 108 blank · 133 comment · 2 complexity · f7d5b19e7aa604dd3f5bfe57c3d3e189 MD5 · raw file

  1. indexing
  2. description: "GtkCalendar -- Displays a calendar and allows the user to select a date."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_CALENDAR
  21. -- GtkCalendar is a widget that displays a calendar, one month at a
  22. -- time. It can be created with `make'.
  23. -- The month and year currently displayed can be altered with
  24. -- `select_month'. The exact day can be selected from the displayed
  25. -- month using `select_day'.
  26. -- To place a visual marker on a particular day, use `mark_day' and
  27. -- to remove the marker, `unmark_day'. Alternative, all marks can
  28. -- be cleared with `clear_marks'.
  29. -- The way in which the calendar itself is displayed can be altered
  30. -- using `set_display_options'.
  31. -- The selected date can be retrieved from a GtkCalendar using
  32. -- `date'.
  33. inherit
  34. GTK_WIDGET
  35. -- GtkCalendar implements AtkImplementorIface interface.
  36. insert
  37. GTK_CALENDAR_EXTERNALS
  38. creation make, from_external_pointer
  39. feature -- size
  40. struct_size: INTEGER is
  41. external "C inline use <gtk/gtk.h>"
  42. alias "sizeof(GtkCalendar)"
  43. end
  44. feature {} -- Creation
  45. make is
  46. -- Creates a new calendar, with the current date being
  47. -- selected.
  48. do
  49. from_external_pointer (gtk_calendar_new)
  50. end
  51. feature
  52. marked_dates_count: INTEGER is
  53. -- the number of days that have a mark over them.
  54. do
  55. Result:=get_num_marked_dates(handle)
  56. end
  57. marked_date (an_n: INTEGER): INTEGER is
  58. -- the `an_n'-th marked date
  59. require valid_n: an_n.in_range(0,marked_dates_count-1)
  60. local array: NATIVE_ARRAY[INTEGER]
  61. do
  62. array:=array.from_pointer(get_marked_date(handle))
  63. Result:=array.item(an_n)
  64. end
  65. selected_day,day: INTEGER is
  66. -- the currently visible selected day.
  67. -- Note: GTK allows to access this feature either as
  68. -- selected_day, a field of a structure and throught the
  69. -- "day" property. Choose the fittest name. Paolo 2007-05-31
  70. do
  71. Result:=get_selected_day(handle)
  72. ensure valid: Result.in_range(1,31)
  73. end
  74. month: INTEGER is
  75. -- the currently visible month.
  76. do
  77. Result:=get_month(handle)
  78. ensure valid: Result.in_range(0,11)
  79. end
  80. year: INTEGER is
  81. -- the currently visible year.
  82. do
  83. Result:=get_year(handle)
  84. end
  85. date: G_DATE is
  86. -- Obtains the selected date from a GTK_CALENDAR
  87. local
  88. a_day, a_month, a_year: INTEGER
  89. do
  90. gtk_calendar_get_date (handle, $a_year, $a_month, $a_day)
  91. -- year : location to store the year number, or NULL
  92. -- month : location to store the month number (between 0 and 11), or NULL
  93. -- day : location to store the day number (between 1 and 31), or NULL
  94. create Result.make_dmy (a_day.to_integer_8, a_month + 1, a_year.to_integer_16)
  95. ensure
  96. Result /= Void
  97. Result.is_valid
  98. end
  99. select_month (a_month, an_year: INTEGER) is
  100. -- Shifts the calendar to a different month.
  101. -- month : a month number between 0 and 11.
  102. -- year : the year the month is in.
  103. require
  104. month.in_range (0, 11)
  105. year >= 0
  106. do
  107. gtk_calendar_select_month (handle, a_month, an_year)
  108. end
  109. select_day (a_day: INTEGER) is
  110. -- Selects a day from the current month.
  111. require valid_date: a_day.in_range(1,31)
  112. do
  113. gtk_calendar_select_day(handle, a_day)
  114. end
  115. unselect_day is
  116. -- unselect the currently selected day.
  117. do
  118. gtk_calendar_select_day(handle, 0)
  119. end
  120. mark_day (a_day: INTEGER) is
  121. -- Places a visual marker on a particular day.
  122. require valid_date: a_day.in_range(1,31)
  123. local always_true: INTEGER
  124. do
  125. always_true:=gtk_calendar_mark_day(handle,a_day)
  126. end
  127. unmark_day (a_day: INTEGER) is
  128. require valid_date: a_day.in_range(1,31)
  129. local always_true: INTEGER
  130. do
  131. always_true:=gtk_calendar_unmark_day(handle,a_day)
  132. end
  133. clear_marks is
  134. -- Remove all visual markers.
  135. do
  136. gtk_calendar_clear_marks(handle)
  137. end
  138. display_options: INTEGER is
  139. -- the current display options of calendar.
  140. do
  141. Result:=gtk_calendar_get_display_options(handle)
  142. ensure valid: are_valid_gtk_calendar_display_options(Result)
  143. end
  144. set_display_options (some_flags: INTEGER) is
  145. -- Sets display options (whether to display the heading and
  146. -- the month headings).
  147. require valid: are_valid_gtk_calendar_display_options(some_flags)
  148. do
  149. gtk_calendar_set_display_options(handle,some_flags)
  150. ensure set: display_options = some_flags
  151. end
  152. feature -- Properties: TODO
  153. -- "day" gint : Read / Write
  154. -- "month" gint : Read / Write
  155. -- "no-month-change" gboolean : Read / Write
  156. -- "show-day-names" gboolean : Read / Write
  157. -- "show-heading" gboolean : Read / Write
  158. -- "show-week-numbers" gboolean : Read / Write
  159. -- "year" gint : Read / Write
  160. -- Property Details
  161. -- The "day" property
  162. -- "day" gint : Read / Write
  163. -- The selected day (as a number between 1 and 31, or 0 to unselect the currently selected day).
  164. -- Allowed values: [0,31]
  165. -- Default value: 0
  166. -- ----------------------------------------------------------------------------------------------
  167. -- The "month" property
  168. -- "month" gint : Read / Write
  169. -- The selected month (as a number between 0 and 11).
  170. -- Allowed values: [0,11]
  171. -- Default value: 0
  172. -- ----------------------------------------------------------------------------------------------
  173. -- The "no-month-change" property
  174. -- "no-month-change" gboolean : Read / Write
  175. -- Determines whether the selected month can be changed.
  176. -- Default value: FALSE
  177. -- Since 2.4
  178. -- ----------------------------------------------------------------------------------------------
  179. -- The "show-day-names" property
  180. -- "show-day-names" gboolean : Read / Write
  181. -- Determines whether day names are displayed.
  182. -- Default value: TRUE
  183. -- Since 2.4
  184. -- ----------------------------------------------------------------------------------------------
  185. -- The "show-heading" property
  186. -- "show-heading" gboolean : Read / Write
  187. -- Determines whether a heading is displayed.
  188. -- Default value: TRUE
  189. -- Since 2.4
  190. -- ----------------------------------------------------------------------------------------------
  191. -- The "show-week-numbers" property
  192. -- "show-week-numbers" gboolean : Read / Write
  193. -- Determines whether week numbers are displayed.
  194. -- Default value: FALSE
  195. -- Since 2.4
  196. -- ----------------------------------------------------------------------------------------------
  197. -- The "year" property
  198. -- "year" gint : Read / Write
  199. -- The selected year.
  200. -- Allowed values: >= 0
  201. -- Default value: 0
  202. -- Signal Details
  203. -- The "day-selected" signal
  204. -- void user_function (GtkCalendar *calendar,
  205. -- gpointer user_data) : Run first
  206. -- Emitted when the user selects a day.
  207. -- calendar : the object which received the signal.
  208. -- user_data : user data set when the signal handler was connected.
  209. -- ----------------------------------------------------------------------------------------------
  210. -- The "day-selected-double-click" signal
  211. -- void user_function (GtkCalendar *calendar,
  212. -- gpointer user_data) : Run first
  213. -- calendar : the object which received the signal.
  214. -- user_data : user data set when the signal handler was connected.
  215. -- ----------------------------------------------------------------------------------------------
  216. -- The "month-changed" signal
  217. -- void user_function (GtkCalendar *calendar,
  218. -- gpointer user_data) : Run first
  219. -- Emitted when the user clicks a button to change the selected month on a calendar.
  220. -- calendar : the object which received the signal.
  221. -- user_data : user data set when the signal handler was connected.
  222. -- ----------------------------------------------------------------------------------------------
  223. -- The "next-month" signal
  224. -- void user_function (GtkCalendar *calendar,
  225. -- gpointer user_data) : Run first
  226. -- calendar : the object which received the signal.
  227. -- user_data : user data set when the signal handler was connected.
  228. -- ----------------------------------------------------------------------------------------------
  229. -- The "next-year" signal
  230. -- void user_function (GtkCalendar *calendar,
  231. -- gpointer user_data) : Run first
  232. -- calendar : the object which received the signal.
  233. -- user_data : user data set when the signal handler was connected.
  234. -- ----------------------------------------------------------------------------------------------
  235. -- The "prev-month" signal
  236. -- void user_function (GtkCalendar *calendar,
  237. -- gpointer user_data) : Run first
  238. -- calendar : the object which received the signal.
  239. -- user_data : user data set when the signal handler was connected.
  240. -- ----------------------------------------------------------------------------------------------
  241. -- The "prev-year" signal
  242. -- void user_function (GtkCalendar *calendar,
  243. -- gpointer user_data) : Run first
  244. -- calendar : the object which received the signal.
  245. -- user_data : user data set when the signal handler was connected.
  246. feature {} -- typedef struct _GtkCalendar GtkCalendar;
  247. -- Note: All of these fields should be considered read only, and
  248. -- everything in this struct should only be modified using the
  249. -- functions provided below.
  250. get_num_marked_dates (a_struct: POINTER): INTEGER is
  251. external "C struct GtkCalendar get num_marked_dates use <gtk/gtk.h>"
  252. end
  253. get_marked_date (a_struct: POINTER): POINTER is
  254. external "C struct GtkCalendar get marked_date use <gtk/gtk.h>"
  255. end
  256. get_selected_day (a_struct: POINTER): INTEGER is
  257. external "C struct GtkCalendar get selected_day use <gtk/gtk.h>"
  258. end
  259. get_month (a_struct: POINTER): INTEGER is
  260. external "C struct GtkCalendar get month use <gtk/gtk.h>"
  261. end
  262. get_year (a_struct: POINTER): INTEGER is
  263. external "C struct GtkCalendar get year use <gtk/gtk.h>"
  264. end
  265. end