summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_calendar_eo.h
blob: 09a97eb8686b689552401f8b474d11654d24c3a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
#ifndef _ELM_CALENDAR_EO_H_
#define _ELM_CALENDAR_EO_H_

#ifndef _ELM_CALENDAR_EO_CLASS_TYPE
#define _ELM_CALENDAR_EO_CLASS_TYPE

typedef Eo Elm_Calendar;

#endif

#ifndef _ELM_CALENDAR_EO_TYPES
#define _ELM_CALENDAR_EO_TYPES

/**
 * @brief Event periodicity, used to define if a mark should be repeated beyond
 * event's day.
 *
 * It's set when a mark is added. So, for a mark added to 13th May with
 * periodicity set to WEEKLY, there will be marks every week after this date.
 * Marks will be displayed at 13th, 20th, 27th, 3rd June ...
 *
 * Values don't work as bitmask, only one can be chosen. See also
 * @ref elm_obj_calendar_mark_add.
 *
 * @ingroup Elm_Calendar_Mark_Repeat
 */
typedef enum
{
  ELM_CALENDAR_UNIQUE = 0, /**< Default value. Marks will be displayed only on
                            * event day. */
  ELM_CALENDAR_DAILY, /**< Marks will be displayed every day after event day
                       * (inclusive). */
  ELM_CALENDAR_WEEKLY, /**< Marks will be displayed every week after event day
                        * (inclusive) - i.e. each seven days. */
  ELM_CALENDAR_MONTHLY, /**< Marks will be displayed every month day that
                         * coincides to event day. E.g.: if an event is set to
                         * 30th Jan, no marks will be displayed on Feb, but
                         * will be displayed on 30th Mar. */
  ELM_CALENDAR_ANNUALLY, /**< Marks will be displayed every year that coincides
                          * to event day (and month). E.g. an event added to
                          * 30th Jan 2012 will be repeated on 30th Jan 2013. */
  ELM_CALENDAR_LAST_DAY_OF_MONTH, /**< Marks will be displayed every last day of
                                   * month after event day (inclusive).
                                   *
                                   * @since 1.7 */
  ELM_CALENDAR_REVERSE_DAILY /**< Marks will be displayed every day before event
                              * day.
                              *
                              * @since 1.19 */
} Elm_Calendar_Mark_Repeat_Type;

/**
 * @brief A weekday
 *
 * See also @ref elm_obj_calendar_first_day_of_week_set.
 *
 * @ingroup Elm_Calendar
 */
typedef enum
{
  ELM_DAY_SUNDAY = 0, /**< Sunday weekday */
  ELM_DAY_MONDAY, /**< Monday weekday */
  ELM_DAY_TUESDAY, /**< Tuesday weekday */
  ELM_DAY_WEDNESDAY, /**< Wednesday weekday */
  ELM_DAY_THURSDAY, /**< Thursday weekday */
  ELM_DAY_FRIDAY, /**< Friday weekday */
  ELM_DAY_SATURDAY, /**< Saturday weekday */
  ELM_DAY_LAST /**< Sentinel value to indicate last enum field during iteration
                */
} Elm_Calendar_Weekday;

/**
 * @brief The mode, who determine how user could select a day
 *
 * See also @ref elm_obj_calendar_select_mode_set()
 *
 * @ingroup Elm_Calendar_Select
 */
typedef enum
{
  ELM_CALENDAR_SELECT_MODE_DEFAULT = 0, /**< Default value. A day is always
                                         * selected. */
  ELM_CALENDAR_SELECT_MODE_ALWAYS, /**< A day is always selected. */
  ELM_CALENDAR_SELECT_MODE_NONE, /**< None of the days can be selected. */
  ELM_CALENDAR_SELECT_MODE_ONDEMAND /**< User may have selected a day or not. */
} Elm_Calendar_Select_Mode;

/**
 * @brief A bitmask used to define which fields of a @c tm struct will be taken
 * into account, when elm_calendar_selected_time_set() is invoked.
 *
 * See also @ref elm_obj_calendar_selectable_set,
 * @ref elm_obj_calendar_selected_time_set.
 *
 * @since 1.8
 *
 * @ingroup Elm_Calendar
 */
typedef enum
{
  ELM_CALENDAR_SELECTABLE_NONE = 0, /**< Take no field into account */
  ELM_CALENDAR_SELECTABLE_YEAR = 1 /* 1 >> 0 */, /**< Take year field into
                                                  * account */
  ELM_CALENDAR_SELECTABLE_MONTH = 2 /* 1 >> 1 */, /**< Take month field into
                                                   * account */
  ELM_CALENDAR_SELECTABLE_DAY = 4 /* 1 >> 2 */ /**< Take day field into account
                                                */
} Elm_Calendar_Selectable;

/** Item handle for a calendar mark. Created with
 * @ref elm_obj_calendar_mark_add and deleted with
 * @ref elm_obj_calendar_mark_del.
 *
 * @ingroup Elm_Calendar
 */
typedef struct _Elm_Calendar_Mark Elm_Calendar_Mark;


#endif
/**
 * @brief Calendar widget
 *
 * It helps applications to flexibly display a calendar with day of the week,
 * date, year and month. Applications are able to set specific dates to be
 * reported back, when selected, in the smart callbacks of the calendar widget.
 *
 * @ingroup Elm_Calendar
 */
#define ELM_CALENDAR_CLASS elm_calendar_class_get()

EWAPI const Efl_Class *elm_calendar_class_get(void);

/**
 * @brief The first day of week to use on calendar widgets'.
 *
 * @param[in] obj The object.
 * @param[in] day Weekday enum value, see @ref Elm_Calendar_Weekday
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_first_day_of_week_set(Eo *obj, Elm_Calendar_Weekday day);

/**
 * @brief The first day of week to use on calendar widgets'.
 *
 * @param[in] obj The object.
 *
 * @return Weekday enum value, see @ref Elm_Calendar_Weekday
 *
 * @ingroup Elm_Calendar
 */
EOAPI Elm_Calendar_Weekday elm_obj_calendar_first_day_of_week_get(const Eo *obj);

/**
 * @brief Define which fields of a tm struct will be taken into account, when
 * Elm.Calendar.selected_time.set is invoked.
 *
 * By Default the bitmask is set to use all fields of a tm struct (year, month
 * and day of the month).
 *
 * See also @ref elm_obj_calendar_selected_time_set.
 *
 * @param[in] obj The object.
 * @param[in] selectable A bitmask of Elm_Calendar_Selectable
 *
 * @since 1.8
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_selectable_set(Eo *obj, Elm_Calendar_Selectable selectable);

/**
 * @brief Define which fields of a tm struct will be taken into account, when
 * Elm.Calendar.selected_time.set is invoked.
 *
 * By Default the bitmask is set to use all fields of a tm struct (year, month
 * and day of the month).
 *
 * See also @ref elm_obj_calendar_selected_time_set.
 *
 * @param[in] obj The object.
 *
 * @return A bitmask of Elm_Calendar_Selectable
 *
 * @since 1.8
 *
 * @ingroup Elm_Calendar
 */
EOAPI Elm_Calendar_Selectable elm_obj_calendar_selectable_get(const Eo *obj);

/**
 * @brief The interval on time updates for an user mouse button hold on
 * calendar widgets' month/year selection.
 *
 * This interval value is decreased while the user holds the mouse pointer
 * either selecting next or previous month/year.
 *
 * This helps the user to get to a given month distant from the current one
 * easier/faster, as it will start to change quicker and quicker on mouse
 * button holds.
 *
 * The calculation for the next change interval value, starting from the one
 * set with this call, is the previous interval divided by 1.05, so it
 * decreases a little bit.
 *
 * The default starting interval value for automatic changes is 0.85 seconds.
 *
 * @param[in] obj The object.
 * @param[in] interval The (first) interval value in seconds
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_interval_set(Eo *obj, double interval);

/**
 * @brief The interval on time updates for an user mouse button hold on
 * calendar widgets' month/year selection.
 *
 * This interval value is decreased while the user holds the mouse pointer
 * either selecting next or previous month/year.
 *
 * This helps the user to get to a given month distant from the current one
 * easier/faster, as it will start to change quicker and quicker on mouse
 * button holds.
 *
 * The calculation for the next change interval value, starting from the one
 * set with this call, is the previous interval divided by 1.05, so it
 * decreases a little bit.
 *
 * The default starting interval value for automatic changes is 0.85 seconds.
 *
 * @param[in] obj The object.
 *
 * @return The (first) interval value in seconds
 *
 * @ingroup Elm_Calendar
 */
EOAPI double elm_obj_calendar_interval_get(const Eo *obj);

/**
 * @brief Weekdays names to be displayed by the calendar.
 *
 * By default, weekdays abbreviations get from system are displayed: E.g. for
 * an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
 *
 * The first string should be related to Sunday, the second to Monday...
 *
 * See also @ref elm_obj_calendar_weekdays_names_get.
 *
 * @ref calendar_example_02. @ref calendar_example_05.
 *
 * @param[in] obj The object.
 * @param[in] weekdays Array of seven strings to be used as weekday names.
 * Warning: It must have 7 elements, or it will access invalid memory. Warning:
 * The strings must be @c null terminated ('@\0').
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_weekdays_names_set(Eo *obj, const char **weekdays);

/**
 * @brief Weekdays names to be displayed by the calendar.
 *
 * By default, weekdays abbreviations get from system are displayed: E.g. for
 * an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
 *
 * The first string should be related to Sunday, the second to Monday...
 *
 * See also @ref elm_obj_calendar_weekdays_names_get.
 *
 * @ref calendar_example_02. @ref calendar_example_05.
 *
 * @param[in] obj The object.
 *
 * @return Array of seven strings to be used as weekday names. Warning: It must
 * have 7 elements, or it will access invalid memory. Warning: The strings must
 * be @c null terminated ('@\0').
 *
 * @ingroup Elm_Calendar
 */
EOAPI const char **elm_obj_calendar_weekdays_names_get(const Eo *obj);

/**
 * @brief Select day mode to use.
 *
 * The day selection mode used.
 *
 * @param[in] obj The object.
 * @param[in] mode The select mode to use.
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_select_mode_set(Eo *obj, Elm_Calendar_Select_Mode mode);

/**
 * @brief Select day mode to use.
 *
 * The day selection mode used.
 *
 * @param[in] obj The object.
 *
 * @return The select mode to use.
 *
 * @ingroup Elm_Calendar
 */
EOAPI Elm_Calendar_Select_Mode elm_obj_calendar_select_mode_get(const Eo *obj);

/**
 * @brief Set a function to format the string that will be used to display
 * month and year;
 *
 * By default it uses strftime with "%B %Y" format string. It should allocate
 * the memory that will be used by the string, that will be freed by the widget
 * after usage. A pointer to the string and a pointer to the time struct will
 * be provided.
 *
 * @ref calendar_example_02.
 *
 * @param[in] obj The object.
 * @param[in] format_function Function to set the month-year string given the
 * selected date.
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_format_function_set(Eo *obj, Elm_Calendar_Format_Cb format_function);

/**
 * @brief Get a list of all the calendar marks.
 *
 * See also @ref elm_obj_calendar_mark_add, @ref elm_obj_calendar_mark_del(),
 * @ref elm_obj_calendar_marks_clear.
 *
 * @param[in] obj The object.
 *
 * @return List with all calendar marks
 *
 * @ingroup Elm_Calendar
 */
EOAPI const Eina_List *elm_obj_calendar_marks_get(const Eo *obj);

/**
 * @brief Minimum date on calendar.
 *
 * See also @ref elm_obj_calendar_date_max_set,
 * @ref elm_obj_calendar_date_max_get
 *
 * Set minimum date on calendar.
 *
 * Set the minimum date, changing the displayed month or year if needed.
 * Displayed day also to be disabled if it is smaller than minimum date.
 *
 * @param[in] obj The object.
 * @param[in] min A tm struct to point to minimum date.
 *
 * @since 1.19
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_date_min_set(Eo *obj, const Efl_Time *min);

/**
 * @brief Minimum date on calendar.
 *
 * See also @ref elm_obj_calendar_date_max_set,
 * @ref elm_obj_calendar_date_max_get
 *
 * Get minimum date.
 *
 * Default value is 1 JAN,1902.
 *
 * @param[in] obj The object.
 *
 * @return A tm struct to point to minimum date.
 *
 * @since 1.19
 *
 * @ingroup Elm_Calendar
 */
EOAPI const Efl_Time *elm_obj_calendar_date_min_get(const Eo *obj);

/**
 * @brief Maximum date on calendar.
 *
 * See also @ref elm_obj_calendar_date_min_set,
 * @ref elm_obj_calendar_date_min_get
 *
 * Set maximum date on calendar.
 *
 * Set the maximum date, changing the displayed month or year if needed.
 * Displayed day also to be disabled if it is bigger than maximum date.
 *
 * @param[in] obj The object.
 * @param[in] max A tm struct to point to maximum date.
 *
 * @since 1.19
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_date_max_set(Eo *obj, const Efl_Time *max);

/**
 * @brief Maximum date on calendar.
 *
 * See also @ref elm_obj_calendar_date_min_set,
 * @ref elm_obj_calendar_date_min_get
 *
 * Get maximum date.
 *
 * Default maximum year is -1. Default maximum day and month are 31 and DEC.
 *
 * If the maximum year is a negative value, it will be limited depending on the
 * platform architecture (year 2037 for 32 bits);
 *
 * @param[in] obj The object.
 *
 * @return A tm struct to point to maximum date.
 *
 * @since 1.19
 *
 * @ingroup Elm_Calendar
 */
EOAPI const Efl_Time *elm_obj_calendar_date_max_get(const Eo *obj);

/**
 * @brief Set selected date to be highlighted on calendar.
 *
 * Set the selected date, changing the displayed month if needed. Selected date
 * changes when the user goes to next/previous month or select a day pressing
 * over it on calendar.
 *
 * See also @ref elm_obj_calendar_selected_time_get.
 *
 * @ref calendar_example_04
 *
 * @param[in] obj The object.
 * @param[in] selected_time A tm struct to represent the selected date.
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_selected_time_set(Eo *obj, Efl_Time *selected_time);

/**
 * @brief Get selected date.
 *
 * Get date selected by the user or set by function
 * @ref elm_obj_calendar_selected_time_set(). Selected date changes when the
 * user goes to next/previous month or select a day pressing over it on
 * calendar.
 *
 * See also @ref elm_obj_calendar_selected_time_get.
 *
 * @ref calendar_example_05.
 *
 * @param[in] obj The object.
 * @param[in,out] selected_time A tm struct to point to selected date.
 *
 * @return @c true if the method succeeded, @c false otherwise
 *
 * @ingroup Elm_Calendar
 */
EOAPI Eina_Bool elm_obj_calendar_selected_time_get(const Eo *obj, Efl_Time *selected_time);

/**
 * @brief Add a new mark to the calendar
 *
 * Add a mark that will be drawn in the calendar respecting the insertion time
 * and periodicity. It will emit the type as signal to the widget theme.
 * Default theme supports "holiday" and "checked", but it can be extended.
 *
 * It won't immediately update the calendar, drawing the marks. For this,
 * @ref elm_obj_calendar_marks_draw(). However, when user selects next or
 * previous month calendar forces marks drawn.
 *
 * Marks created with this method can be deleted with
 * @ref elm_obj_calendar_mark_del().
 *
 * See also @ref elm_obj_calendar_marks_draw, @ref elm_obj_calendar_mark_del().
 *
 * @ref calendar_example_06
 *
 * @param[in] obj The object.
 * @param[in] mark_type A string used to define the type of mark. It will be
 * emitted to the theme, that should display a related modification on these
 * days representation.
 * @param[in] mark_time A time struct to represent the date of inclusion of the
 * mark. For marks that repeats it will just be displayed after the inclusion
 * date in the calendar.
 * @param[in] repeat Repeat the event following this periodicity. Can be a
 * unique mark (that don't repeat), daily, weekly, monthly or annually.
 *
 * @return The newly added calendar mark
 *
 * @ingroup Elm_Calendar
 */
EOAPI Elm_Calendar_Mark *elm_obj_calendar_mark_add(Eo *obj, const char *mark_type, Efl_Time *mark_time, Elm_Calendar_Mark_Repeat_Type repeat);

/**
 * @brief Delete mark from the calendar.
 *
 * If deleting all calendar marks is required,
 * @ref elm_obj_calendar_marks_clear() should be used instead of getting marks
 * list and deleting each one.
 *
 * See also @ref elm_obj_calendar_mark_add(),
 * @ref elm_obj_calendar_marks_clear().
 *
 * @param[in] obj The object.
 * @param[in] mark The mark to be deleted.
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_mark_del(Eo *obj, Elm_Calendar_Mark *mark);

/**
 * @brief Remove all calendar's marks
 *
 * See also  @ref elm_obj_calendar_mark_add, @ref elm_obj_calendar_mark_del().
 * @param[in] obj The object.
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_marks_clear(Eo *obj);

/**
 * @brief Draw calendar marks.
 *
 * Should be used after adding, removing or clearing marks. It will go through
 * the entire marks list updating the calendar. If lots of marks will be added,
 * add all the marks and then call this function.
 *
 * When the month is changed, i.e. user selects next or previous month, marks
 * will be drawn.
 *
 * See also  @ref elm_obj_calendar_mark_add, @ref elm_obj_calendar_mark_del(),
 * @ref elm_obj_calendar_marks_clear.
 *
 * @ref calendar_example_06
 * @param[in] obj The object.
 *
 * @ingroup Elm_Calendar
 */
EOAPI void elm_obj_calendar_marks_draw(Eo *obj);

/**
 * @brief Get the current time displayed in the widget
 *
 * @param[in] obj The object.
 * @param[in,out] displayed_time A tm struct to point to displayed date.
 *
 * @return @c true if the method succeeded, @c false otherwise
 *
 * @since 1.8
 *
 * @ingroup Elm_Calendar
 */
EOAPI Eina_Bool elm_obj_calendar_displayed_time_get(const Eo *obj, Efl_Time *displayed_time);

EWAPI extern const Efl_Event_Description _ELM_CALENDAR_EVENT_CHANGED;

/** Emitted when the date in the calendar is changed
 *
 * @ingroup Elm_Calendar
 */
#define ELM_CALENDAR_EVENT_CHANGED (&(_ELM_CALENDAR_EVENT_CHANGED))

EWAPI extern const Efl_Event_Description _ELM_CALENDAR_EVENT_DISPLAY_CHANGED;

/** Emitted when the current month displayed in the calendar is changed
 *
 * @ingroup Elm_Calendar
 */
#define ELM_CALENDAR_EVENT_DISPLAY_CHANGED (&(_ELM_CALENDAR_EVENT_DISPLAY_CHANGED))

#endif