找回密码
 立即注册
查看: 2168|回复: 0

自定义日历小部件相关代码

[复制链接]
发表于 2015-8-13 13:30:36 | 显示全部楼层 |阅读模式
这段代码演示如何自定义日历:-设置自定义的名称为平日-set 的方法来设置格式的字符串,用来显示月份和年份-设置周第一天
  1. char *_format_month_year(struct tm *selected_time) {
  2.         char buf[32];
  3.         
  4.         //e.g. output: "August 2015"
  5.         if (!strftime(buf, sizeof(buf), "%B %Y", selected_time))
  6.                 return NULL;
  7.         
  8.         // //e.g. output: "Aug 15"
  9.         //if (!strftime(buf, sizeof(buf), "%b %u", selected_time))
  10.         //return NULL;
  11.         
  12.         return strdup(buf);
  13. }

  14. void show_calendar(appdata_s *ad) {

  15.         Evas_Object *calendar = elm_calendar_add(ad->win);
  16.         evas_object_size_hint_weight_set(calendar, EVAS_HINT_EXPAND,
  17.         EVAS_HINT_EXPAND);
  18.         elm_win_resize_object_add(ad->win, calendar);
  19.         evas_object_show(calendar);
  20.         
  21.         //set method to format the string used to display month and year
  22.         elm_calendar_format_function_set(calendar, _format_month_year);
  23.         
  24.         //set custom names for weekdays
  25.         const char *days[] = { ";(", ":(", ":(", ":|", ":)", ":D", ":)" };
  26.         elm_calendar_weekdays_names_set(calendar, days);
  27.         
  28.         //set first day of week, here Sunday (=0)
  29.         elm_calendar_first_day_of_week_set(calendar, 0);

  30. }
复制代码
欢迎来到泰泽网:http://www.tizennet.com/ 泰泽论坛:http://bbs.tizennet.com/ 好没有内涵哦,快到设置中更改这个无聊的签名吧!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|泰泽应用|泰泽论坛|泰泽网|小黑屋|Archiver|手机版|泰泽邮箱|泰泽网 ( 蜀ICP备13024062号-1 )

GMT+8, 2024-4-20 16:52 , Processed in 0.069698 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表