

On this example marks management will be explained. Functions elm\+\_\+calendar\+\_\+mark\+\_\+add(), elm\+\_\+calendar\+\_\+mark\+\_\+del() and 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 \mbox{\hyperlink{group__Elm__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}{0}
\DoxyCodeLine{\ \ \ current\_time\ =\ time(NULL);}
\DoxyCodeLine{\ \ \ localtime\_r(\&current\_time,\ \&selected\_time);}

\end{DoxyCodeInclude}
 Or if it\textquotesingle{}s an absolute date, you can just declare the struct like\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }tm\ sunday;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }tm\ christmas;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ At\ least\ on\ Windows,\ tm\ has\ 9\ fields.}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ As\ a\ workaround,\ set\ sunday\ to\ 0\ and\ set}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ th\ needed\ fields\ to\ correct\ value}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ */}}
\DoxyCodeLine{\ \ \ memset(\&sunday,\ 0,\ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct}\ tm));}
\DoxyCodeLine{\ \ \ sunday.tm\_hour\ =\ 12;}
\DoxyCodeLine{\ \ \ sunday.tm\_mday\ =\ 7;}
\DoxyCodeLine{\ \ \ sunday.tm\_isdst\ =\ -\/1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ memset(\&christmas,\ 0,\ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct}\ tm));}
\DoxyCodeLine{\ \ \ christmas.tm\_mday\ =\ 25;}
\DoxyCodeLine{\ \ \ 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\textquotesingle{}t repeat), or it can repeat daily, weekly, monthly or annually. It\textquotesingle{}s enumerated by {\ttfamily Elm\+\_\+\+Calendar\+\_\+\+Mark\+\_\+\+Repeat\+\_\+\+Type}.

So let\textquotesingle{}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}{0}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }tm\ sunday;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }tm\ christmas;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ At\ least\ on\ Windows,\ tm\ has\ 9\ fields.}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ As\ a\ workaround,\ set\ sunday\ to\ 0\ and\ set}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ th\ needed\ fields\ to\ correct\ value}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ */}}
\DoxyCodeLine{\ \ \ memset(\&sunday,\ 0,\ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct}\ tm));}
\DoxyCodeLine{\ \ \ sunday.tm\_hour\ =\ 12;}
\DoxyCodeLine{\ \ \ sunday.tm\_mday\ =\ 7;}
\DoxyCodeLine{\ \ \ sunday.tm\_isdst\ =\ -\/1;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ memset(\&christmas,\ 0,\ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct}\ tm));}
\DoxyCodeLine{\ \ \ christmas.tm\_mday\ =\ 25;}
\DoxyCodeLine{\ \ \ christmas.tm\_mon\ =\ 11;}
\DoxyCodeLine{\ \ \ current\_time\ =\ time(NULL);}
\DoxyCodeLine{\ \ \ localtime\_r(\&current\_time,\ \&selected\_time);}
\DoxyCodeLine{\ \ \ mark\ =\ elm\_calendar\_mark\_add(cal,\ \textcolor{stringliteral}{"{}checked"{}},\ \&selected\_time,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ELM\_CALENDAR\_UNIQUE);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ check\ tomorrow\ */}}
\DoxyCodeLine{\ \ \ current\_time\ =\ time(NULL)\ +\ 1\ *\ SECS\_DAY;}
\DoxyCodeLine{\ \ \ localtime\_r(\&current\_time,\ \&selected\_time);}
\DoxyCodeLine{\ \ \ elm\_calendar\_mark\_add(cal,\ \textcolor{stringliteral}{"{}checked"{}},\ \&selected\_time,\ ELM\_CALENDAR\_UNIQUE);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ mark\ christmas\ as\ holiday\ */}}
\DoxyCodeLine{\ \ \ elm\_calendar\_mark\_add(cal,\ \textcolor{stringliteral}{"{}holiday"{}},\ \&christmas,\ ELM\_CALENDAR\_ANNUALLY);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ mark\ Sundays\ as\ holidays\ */}}
\DoxyCodeLine{\ \ \ 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\textquotesingle{}t really won\textquotesingle{}t it to be checked, so let\textquotesingle{}s remove it\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ elm\_calendar\_mark\_del(mark);}

\end{DoxyCodeInclude}
 After all marks are added and removed, is required to draw them\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ elm\_calendar\_marks\_draw(cal);}

\end{DoxyCodeInclude}
 Finally, to clear all marks, let\textquotesingle{}s set a callback for our button\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ bt\ =\ \mbox{\hyperlink{group__Elm__Button_gaf5caf46d74c4e122a18da323935d25e4}{elm\_button\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(bt,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gaaf1d3e26e36b316977336066b6f56632}{evas\_object\_size\_hint\_align\_set}}(bt,\ \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}},\ \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}});}
\DoxyCodeLine{\ \ \ elm\_object\_text\_set(bt,\ \textcolor{stringliteral}{"{}Clear\ marks"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(bt,\ \textcolor{stringliteral}{"{}clicked"{}},\ \_btn\_clear\_cb,\ cal);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(bx,\ bt);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bt);}

\end{DoxyCodeInclude}
 This callback will receive our calendar object, and should clear it\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_btn\_clear\_cb(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *btn\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *ev\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *cal\ =\ data;}
\DoxyCodeLine{\ \ \ elm\_calendar\_marks\_clear(cal);}
\DoxyCodeLine{\ \ \ elm\_calendar\_marks\_draw(cal);}
\DoxyCodeLine{\}}

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

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/calendar_example_06}}
\end{DoxyImageNoCaption}


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