Exemplo n.º 1
0
static void
set_api_state(api_data *api)
{
   const Eina_List *items = elm_box_children_get(api->box);
   static Elm_Calendar_Mark *m = NULL;
   if (!eina_list_count(items))
     return;

   switch(api->state)
     { /* Put all api-changes under switch */
      case STATE_MARK_MONTHLY:
           {
              Evas_Object *cal = eina_list_nth(items, 0);
              time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
              m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY);
              elm_calendar_selected_time_set(cal, gmtime(&the_time));
           }
         break;
      case STATE_MARK_WEEKLY:
           {
              Evas_Object *cal = eina_list_nth(items, 0);
              time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 4); /* Set date to DEC 26, 2010 */
              elm_calendar_mark_del(m);
              m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
              elm_calendar_selected_time_set(cal, gmtime(&the_time));
           }
         break;
      case STATE_SUNDAY_HIGHLIGHT:
           {
              Evas_Object *cal = eina_list_nth(items, 0);
              time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 3); /* Set date to DEC 25, 2010 */
              /* elm_calendar_mark_del(m); */
              m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
              elm_calendar_selected_time_set(cal, gmtime(&the_time));
           }
         break;
      case STATE_SELECT_DATE_DISABLED_WITH_MARKS:
           {
              Evas_Object *cal = eina_list_nth(items, 0);
              time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 10); /* Set date to JAN 01, 2011 */
              elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
              elm_calendar_selected_time_set(cal, gmtime(&the_time));
           }
         break;
      case STATE_SELECT_DATE_DISABLED_NO_MARKS:
           {
              Evas_Object *cal = eina_list_nth(items, 0);
              time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 40); /* Set date to FEB 01, 2011 */
              elm_calendar_marks_clear(cal);
              elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
              elm_calendar_selected_time_set(cal, gmtime(&the_time));
           }
         break;
      case API_STATE_LAST:
         break;
      default:
         return;
     }
}
static void startup(void)
{
        tet_infoline("[[ TET_MSG ]]:: ============ Startup ============ ");

	Elm_Calendar_Mark *mark;
	struct tm selected_time;
	time_t current_time;

        elm_init(0, NULL);
        main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
        evas_object_show(main_win);

        test_eo = elm_calendar_add(main_win);

	current_time = time(NULL) + 1 * 84600;
	localtime_r(&current_time, &selected_time);
	mark = elm_calendar_mark_add(test_eo, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
}
EAPI_MAIN int
elm_main(int argc, char **argv)
{
   Evas_Object *win, *bt, *bx, *cal;
   Elm_Calendar_Mark *mark;
   struct tm selected_time;
   time_t current_time;
   struct tm sunday = { 0, 0, 12, 7, 0, 0, 0, 0, -1, 0, NULL };
   /* tm {sec, min, hour, mday, mon, year, wday, yday, isdst } */
   /* weekdays since Sunday, range 0 to 6 */
   struct tm christmas;
   christmas.tm_mday = 25;
   /* months since Jan, in the range 0 to 11 */
   christmas.tm_mon = 11;

   win = elm_win_util_standard_add("calendar", "Calendar Marks Example");
   elm_win_autodel_set(win, EINA_TRUE);
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   bx = elm_box_add(win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, bx);
   evas_object_show(bx);

   cal = elm_calendar_add(win);
   evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
   elm_box_pack_end(bx, cal);
   evas_object_show(cal);

   /* check today - we'll remove it later */
   current_time = time(NULL);
   localtime_r(&current_time, &selected_time);
   mark = elm_calendar_mark_add(cal, "checked", &selected_time,
                                ELM_CALENDAR_UNIQUE);

   /* check tomorrow */
   current_time = time(NULL) + 1 * SECS_DAY;
   localtime_r(&current_time, &selected_time);
   elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);

   /* mark christmas as holiday */
   elm_calendar_mark_add(cal, "holiday", &christmas, ELM_CALENDAR_ANNUALLY);

   /* mark Sundays as holidays */
   elm_calendar_mark_add(cal, "holiday", &sunday, ELM_CALENDAR_WEEKLY);

   /* ok, let's remove today's check */
   elm_calendar_mark_del(mark);

   elm_calendar_marks_draw(cal);

   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, "Clear marks");
   evas_object_smart_callback_add(bt, "clicked", _btn_clear_cb, cal);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);

   evas_object_show(win);

   elm_run();

   return 0;
}
Exemplo n.º 4
0
void ActivityScenariosView::buttonPressed(void *data, Evas_Object *_edje, std::string emission, std::string source)
{
    if (source == "button.calendar")
    {
        Evas_Object *table = createPaddingTable(evas, parent, 330, 300, 10, 10);

        calendar = elm_calendar_add(parent);
        elm_object_style_set(calendar, "calaos");

        elm_calendar_first_day_of_week_set(calendar, ELM_DAY_MONDAY);

        const char *weekdays[] = { "DIM", "LUN", "MAR", "MER", "JEU", "VEN", "SAM" };
        elm_calendar_weekdays_names_set(calendar, weekdays);

        evas_object_smart_callback_add(calendar, "changed", _calendar_cb, this);

        //Mark sundays
        struct tm sunday = { 0, 0, 12, 7, 0, 0, 6, 0, -1, 0, NULL };
        elm_calendar_mark_add(calendar, "checked", &sunday, ELM_CALENDAR_WEEKLY);
        elm_calendar_marks_draw(calendar);

        evas_object_size_hint_fill_set(calendar, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_size_hint_weight_set(calendar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_show(calendar);

        elm_table_pack(table, calendar, 1, 1, 1, 1);

        Evas_Object *popup = elm_ctxpopup_add(parent);
        elm_object_content_set(popup, table);
        elm_object_style_set(popup, "calaos");
        elm_ctxpopup_direction_priority_set(popup,
                                            ELM_CTXPOPUP_DIRECTION_DOWN,
                                            ELM_CTXPOPUP_DIRECTION_LEFT,
                                            ELM_CTXPOPUP_DIRECTION_RIGHT,
                                            ELM_CTXPOPUP_DIRECTION_UP);

        Evas_Coord x,y;
        evas_pointer_canvas_xy_get(evas, &x, &y);
        evas_object_move(popup, x, y);
        evas_object_show(popup);
    }
    else if (source == "button.calendar.today")
    {
        tzset(); //Force reload of timezone data
        time_t t = time(0);
        currDate = *localtime(&t);
        reloadCalendar();
    }
    else if (source == "button.create")
    {
        buttonCreatePressed.emit();
    }
    else if (source == "button.list.all")
    {
        view_mode = VIEW_MODE_ALL;
        loadScenarioList();
    }
    else if (source == "button.list.light")
    {
        view_mode = VIEW_MODE_LIGHT;
        loadScenarioList();
    }
    else if (source == "button.list.shutters")
    {
        view_mode = VIEW_MODE_SHUTTER;
        loadScenarioList();
    }
    else if (source == "button.list.schedule")
    {
        view_mode = VIEW_MODE_SCHEDULE;
        loadScenarioList();
    }
}