PageRenderTime 43ms CodeModel.GetById 34ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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