

On this example marks management will be explained. Functions \hyperlink{group__Calendar_gabc3a0f3b584eaf01f82576c8b2cad6c1}{elm\-\_\-calendar\-\_\-mark\-\_\-add()}, \hyperlink{group__Calendar_gaacf325f949268d816c3b2a601969ecda}{elm\-\_\-calendar\-\_\-mark\-\_\-del()} and \hyperlink{group__Calendar_ga7717966735134f0740f77b2524adbcc7}{elm\-\_\-calendar\-\_\-marks\-\_\-clear()} will be covered.

To add a mark, will be required to choose three things\-: \begin{DoxyItemize}
\item mark style \item mark date, or start date if it will be repeated \item mark periodicity\end{DoxyItemize}
Style defines the kind of mark will be displayed over marked day, on calendar. Default theme supports {\bfseries holiday} and {\bfseries checked}. If more is required, is possible to set a new theme to calendar widget using \hyperlink{group__Styles_ga7fc2d1f9ba723470da7a05799c49f7fe}{elm\-\_\-object\-\_\-style\-\_\-set()}, and use the signal that will be used by such marks.

Date is a {\ttfamily  struct tm }, as defined by {\ttfamily time.\-h}. More can be read on {\ttfamily ctime} manpage. If a date relative from current is required, this struct can be set as\-: 
\begin{DoxyCodeInclude}
   current\_time = time(NULL);
   localtime\_r(&current\_time, &selected\_time);

\end{DoxyCodeInclude}


Or if it's an absolute date, you can just declare the struct like\-:  
\begin{DoxyCodeInclude}
   \textcolor{keyword}{struct }tm sunday = \{ 0, 0, 12, 7, 0, 0, 0, 0, -1, 0, NULL \};
   \textcolor{comment}{/* tm \{sec, min, hour, mday, mon, year, wday, yday, isdst \} */}
   \textcolor{comment}{/* weekdays since Sunday, range 0 to 6 */}
   \textcolor{keyword}{struct }tm christmas;
   christmas.tm\_mday = 25;
   \textcolor{comment}{/* months since Jan, in the range 0 to 11 */}
   christmas.tm\_mon = 11;

\end{DoxyCodeInclude}


Periodicity is how frequently the mark will be displayed over the calendar. Can be a unique mark (that don't repeat), or it can repeat daily, weekly, monthly or annually. It's enumerated by {\ttfamily Elm\-\_\-\-Calendar\-\_\-\-Mark\-\_\-\-Repeat\-\_\-\-Type}.

So let's add some marks to our calendar. We will add christmas holiday, set Sundays as holidays, and check current day and day after that.  
\begin{DoxyCodeInclude}
   \textcolor{keyword}{struct }tm sunday = \{ 0, 0, 12, 7, 0, 0, 0, 0, -1, 0, NULL \};
   \textcolor{comment}{/* tm \{sec, min, hour, mday, mon, year, wday, yday, isdst \} */}
   \textcolor{comment}{/* weekdays since Sunday, range 0 to 6 */}
   \textcolor{keyword}{struct }tm christmas;
   christmas.tm\_mday = 25;
   \textcolor{comment}{/* months since Jan, in the range 0 to 11 */}
   christmas.tm\_mon = 11;
   current\_time = time(NULL);
   localtime\_r(&current\_time, &selected\_time);
   mark = elm_calendar_mark_add(cal, \textcolor{stringliteral}{"checked"}, &selected\_time,
                                ELM\_CALENDAR\_UNIQUE);

   \textcolor{comment}{/* check tomorrow */}
   current\_time = time(NULL) + 1 * SECS\_DAY;
   localtime\_r(&current\_time, &selected\_time);
   elm_calendar_mark_add(cal, \textcolor{stringliteral}{"checked"}, &selected\_time, ELM\_CALENDAR\_UNIQUE);

   \textcolor{comment}{/* mark christmas as holiday */}
   elm_calendar_mark_add(cal, \textcolor{stringliteral}{"holiday"}, &christmas, ELM\_CALENDAR\_ANNUALLY);

   \textcolor{comment}{/* mark Sundays as holidays */}
   elm_calendar_mark_add(cal, \textcolor{stringliteral}{"holiday"}, &sunday, ELM\_CALENDAR\_WEEKLY);

\end{DoxyCodeInclude}


We kept the return of first mark add, because we don't really won't it to be checked, so let's remove it\-: 
\begin{DoxyCodeInclude}
   elm_calendar_mark_del(mark);

\end{DoxyCodeInclude}


After all marks are added and removed, is required to draw them\-: 
\begin{DoxyCodeInclude}
   elm_calendar_marks_draw(cal);

\end{DoxyCodeInclude}


Finally, to clear all marks, let's set a callback for our button\-: 
\begin{DoxyCodeInclude}
   bt = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(bt, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(bt, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Clear marks"});
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_btn\_clear\_cb, cal);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

\end{DoxyCodeInclude}


This callback will receive our calendar object, and should clear it\-:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_clear\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *btn, \textcolor{keywordtype}{void} *ev)
\{
   Evas\_Object *cal = data;
   elm_calendar_marks_clear(cal);
   elm_calendar_marks_draw(cal);
\}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
Remember to draw marks after clear the calendar.
\end{DoxyNote}
Our example will look like this\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/calendar_example_06}
\caption{width=}
\end{DoxyImage}


See the full source code \hyperlink{calendar_example_06_8c-example}{calendar\-\_\-example\-\_\-06.\-c} here. 