Lines Matching +full:data +full:- +full:width
4 * calendar.c -- implements the calendar box
6 * Copyright 2001-2019,2020 Thomas E. Dickey
37 #define MON_WIDE 4 /* width of a month-name */
38 #define DAY_HIGH 6 /* maximum lines in day-grid */
39 #define DAY_WIDE (8 * MON_WIDE) /* width of the day-grid */
41 #define BTN_HIGH 1 /* height of button-row excluding margin */
43 /* two more lines: titles for day-of-week and month/year boxes */
48 sMONTH = -3
49 ,sYEAR = -2
50 ,sDAY = -1
62 int width; member
104 size_t limit = MON_WIDE - 1; in nameOfDayOfWeek()
111 * double-width cell. For now (2016/01/26), handle too-long names only in nameOfDayOfWeek()
186 *year -= 1; in adjust_year_month()
189 *month -= MAX_MONTHS; in adjust_year_month()
212 days_in_month(struct tm *current, int offset /* -1, 0, 1 */ ) in days_in_month()
214 int year = current->tm_year + 1900; in days_in_month()
215 int month = current->tm_mon + offset; in days_in_month()
228 days_in_year(struct tm *current, int offset /* -1, 0, 1 */ ) in days_in_year()
230 return days_per_year(current->tm_year + 1900 + offset); in days_in_year()
249 y -= (m < 3); in day_of_week()
250 return (6 + (y + (y / 4) - (y / 100) + (y / 400) + t[m - 1] + d)) % MAX_DAYS; in day_of_week()
257 while (--month >= 1) in day_in_year()
274 week += (diy - 1) / MAX_DAYS; in iso_week()
285 --week; in iso_week()
288 if (dow - new_year_dow < 0) in iso_week()
293 week = iso_week(--year, 12, 31); in iso_week()
301 if (365 + isleap(year) - diy < MAX_DAYS in iso_week()
322 * so that we have to show the week-number for the beginning of the in getisoweeks()
333 cell = current->tm_mday - ((6 + current->tm_mday - current->tm_wday) % MAX_DAYS); in day_cell_number()
334 if ((current->tm_mday - 1) % MAX_DAYS != current->tm_wday) in day_cell_number()
337 cell--; in day_cell_number()
348 result = two_d ? -MAX_DAYS : -1; in next_or_previous()
351 result = -1; in next_or_previous()
367 * Draw the day-of-month selection box
370 draw_day(BOX * data, struct tm *current) in draw_day() argument
375 int day = current->tm_mday; in draw_day()
381 int prev = days_in_month(current, -1); in draw_day()
383 werase(data->window); in draw_day()
384 dlg_draw_box2(data->parent, in draw_day()
385 data->y - MARGIN, data->x - MARGIN, in draw_day()
386 data->height + (2 * MARGIN), data->width + (2 * MARGIN), in draw_day()
391 dlg_attrset(data->window, menubox_attr); /* daynames headline */ in draw_day()
393 mvwprintw(data->window, in draw_day()
395 cell_wide - 1, in draw_day()
396 cell_wide - 1, in draw_day()
397 nameOfDayOfWeek(x + data->week_start)); in draw_day()
400 mday = ((6 + current->tm_mday - in draw_day()
401 current->tm_wday + in draw_day()
402 data->week_start) % MAX_DAYS) - MAX_DAYS; in draw_day()
403 if (mday <= -MAX_DAYS) in draw_day()
407 weeks = getisoweeks(current->tm_year + 1900, current->tm_mon + 1); in draw_day()
409 /* mday is now in the range -6 to 0. */ in draw_day()
410 week = (current->tm_yday + 6 + mday - current->tm_mday) / MAX_DAYS; in draw_day()
414 dlg_attrset(data->window, menubox_attr); /* weeknumbers headline */ in draw_day()
415 mvwprintw(data->window, in draw_day()
418 cell_wide - 1, in draw_day()
423 if (wmove(data->window, y, this_x) == ERR) in draw_day()
425 dlg_attrset(data->window, item_attr); /* not selected days */ in draw_day()
427 dlg_attrset(data->window, item_selected_attr); /* selected day */ in draw_day()
433 wprintw(data->window, "%*d", cell_wide - 2, mday); in draw_day()
435 wprintw(data->window, "%*d", cell_wide - 2, mday - last); in draw_day()
438 wprintw(data->window, "%*d", cell_wide - 2, mday + prev); in draw_day()
441 wmove(data->window, save_y, save_x); in draw_day()
443 /* just draw arrows - scrollbar is unsuitable here */ in draw_day()
444 dlg_draw_arrows(data->parent, TRUE, TRUE, in draw_day()
445 data->x + ARROWS_COL, in draw_day()
446 data->y - 1, in draw_day()
447 data->y + data->height); in draw_day()
453 * Draw the month-of-year selection box
456 draw_month(BOX * data, struct tm *current) in draw_month() argument
460 month = current->tm_mon + 1; in draw_month()
462 dlg_attrset(data->parent, dialog_attr); /* Headline "Month" */ in draw_month()
463 (void) mvwprintw(data->parent, data->y - 2, data->x - 1, _("Month")); in draw_month()
464 dlg_draw_box2(data->parent, in draw_month()
465 data->y - 1, data->x - 1, in draw_month()
466 data->height + 2, data->width + 2, in draw_month()
470 dlg_attrset(data->window, item_attr); /* color the month selection */ in draw_month()
471 mvwprintw(data->window, 0, 0, "%s", nameOfMonth(month - 1)); in draw_month()
472 wmove(data->window, 0, 0); in draw_month()
480 draw_year(BOX * data, struct tm *current) in draw_year() argument
482 int year = current->tm_year + 1900; in draw_year()
484 dlg_attrset(data->parent, dialog_attr); /* Headline "Year" */ in draw_year()
485 (void) mvwprintw(data->parent, data->y - 2, data->x - 1, _("Year")); in draw_year()
486 dlg_draw_box2(data->parent, in draw_year()
487 data->y - 1, data->x - 1, in draw_year()
488 data->height + 2, data->width + 2, in draw_year()
492 dlg_attrset(data->window, item_attr); /* color the year selection */ in draw_year()
493 mvwprintw(data->window, 0, 0, "%4d", year); in draw_year()
494 wmove(data->window, 0, 0); in draw_year()
499 init_object(BOX * data, in init_object() argument
502 int width, int height, in init_object() argument
507 data->parent = parent; in init_object()
508 data->x = x; in init_object()
509 data->y = y; in init_object()
510 data->width = width; in init_object()
511 data->height = height; in init_object()
512 data->box_draw = box_draw; in init_object()
513 data->week_start = key_offset; in init_object()
515 data->window = dlg_der_window(data->parent, in init_object()
516 data->height, data->width, in init_object()
517 data->y, data->x); in init_object()
518 if (data->window == 0) in init_object()
519 return -1; in init_object()
523 dlg_mouse_mkbigregion(y + 1, x + MON_WIDE, height - 1, width - MON_WIDE, in init_object()
526 dlg_mouse_mkregion(y, x, height, width, code); in init_object()
539 int result = -1; in read_locale_setting()
546 while (fgets(buf, (int) sizeof(buf) - 1, fp) != 0) { in read_locale_setting()
579 * glibc-specific. in WeekStart()
586 * probably Linux-specific, but harmless otherwise. When in WeekStart()
591 int basis_day = read_locale_setting("week-1stday", 0); in WeekStart()
594 int week_1stday = -1; in WeekStart()
600 result = first_day - week_1stday - 1; in WeekStart()
616 result = -1; in WeekStart()
653 current->tm_mday != old->tm_mday || in trace_date()
654 current->tm_mon != old->tm_mon || in trace_date()
655 current->tm_year != old->tm_year); in trace_date()
658 current->tm_year + 1900, in trace_date()
659 current->tm_mon + 1, in trace_date()
660 current->tm_mday)); in trace_date()
666 #define DrawObject(data) (data)->box_draw(data, ¤t) argument
675 int width, in dialog_calendar() argument
680 /* *INDENT-OFF* */ in dialog_calendar()
691 DLG_KEYS_DATA( DLGK_GRID_LEFT, '-' ), in dialog_calendar()
708 /* *INDENT-ON* */ in dialog_calendar()
712 int old_width = width; in dialog_calendar()
735 DLG_TRACE2N("width", width); in dialog_calendar()
752 current.tm_isdst = -1; in dialog_calendar()
754 current.tm_year = year - 1900; in dialog_calendar()
757 current.tm_mon = month - 1; in dialog_calendar()
773 if (((year -= 1900) > 0) && (year < 200)) { in dialog_calendar()
774 /* ugly, but I'd like to run this on older machines w/o mktime -TD */ in dialog_calendar()
779 now_time -= ONE_DAY * days_in_year(¤t, -1); in dialog_calendar()
783 now_time -= ONE_DAY * days_in_month(¤t, -1); in dialog_calendar()
787 now_time -= ONE_DAY; in dialog_calendar()
803 dlg_auto_size(title, prompt, &height, &width, 0, mincols); in dialog_calendar()
805 height += MIN_HIGH - 1; in dialog_calendar()
806 dlg_print_size(height, width); in dialog_calendar()
807 dlg_ctl_size(height, width); in dialog_calendar()
809 dialog = dlg_new_window(height, width, in dialog_calendar()
811 dlg_box_x_ordinate(width)); in dialog_calendar()
816 dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr); in dialog_calendar()
821 dlg_print_autowrap(dialog, prompt, height, width); in dialog_calendar()
831 (width - DAY_WIDE) / 2, in dialog_calendar()
832 1 + (height - (DAY_HIGH + BTN_HIGH + (5 * MARGIN))), in dialog_calendar()
846 dy_box.y - (HDR_HIGH + 2 * MARGIN), in dialog_calendar()
847 (DAY_WIDE / 2) - MARGIN, in dialog_calendar()
858 dy_box.x + mn_box.width + 2, in dialog_calendar()
860 mn_box.width, in dialog_calendar()
877 dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); in dialog_calendar()
879 dlg_set_focus(dialog, obj->window); in dialog_calendar()
886 #define Mouse2Key(key) (key - M_EVENT) in dialog_calendar()
894 /* handle function-keys */ in dialog_calendar()
921 /* reset data */ in dialog_calendar()
923 width = old_width; in dialog_calendar()
931 key2 = -1; in dialog_calendar()
941 - DLGK_MOUSE(KEY_MAX) in dialog_calendar()
942 - day_cell_number(¤t)); in dialog_calendar()
953 /* see comment regarding mktime -TD */ in dialog_calendar()
961 now_time -= ONE_DAY * in dialog_calendar()
962 days_in_month(¤t, -1); in dialog_calendar()
968 now_time -= (ONE_DAY in dialog_calendar()
969 * days_in_year(¤t, -1)); in dialog_calendar()
1003 sizeof(buffer) - 1, in dialog_calendar()