# XmCalendar

`XmCalendar` is an additive, date-only calendar widget. Its value is an `XmCalendarDate` civil date (`year`, `month`, `day`); it is never converted to an instant and the widget never consults the host time zone or daylight-saving rules. Years are in the inclusive range 1 through 9999 and use the proleptic Gregorian calendar, including the 400-year leap-year rule.

The initial value is 1970-01-01. Applications can set a value with `XmCalendarSetDate` and an inclusive range with `XmCalendarSetRange`. Both operations validate before changing state. A range change is rejected if it would exclude the current date, so a failed update has no partial effect. The default range is 0001-01-01 through 9999-12-31.

`XmNcalendarWeekStart` is an unsigned weekday number using Sunday = 0 through Saturday = 6. `XmNcalendarRtl` mirrors the day columns and reverses horizontal keyboard movement; it does not change the civil date or the week-start rule. The heading and weekday labels use deterministic English fallback labels. A future locale provider may replace those labels without changing date semantics.

Arrow keys move by one day or one week, Page Up/Down move by one month while clamping the day to the target month, and Home/End select the first/last day of the current month. Return activates the current date. Pointer activation selects a day and a second activation invokes the activate callback. Dates outside the inclusive range remain visible but are not selectable. Keyboard and pointer input is inactive while the Calendar or an ancestor is insensitive; applications may still set its value programmatically.

`XmNcalendarDateChangedCallback` and `XmNcalendarActivateCallback` receive an `XmCalendarCallbackStruct`. Callback code may destroy the widget; the widget does not access its instance after invoking a callback.

This first implementation deliberately keeps the public contract bounded and date-only. DatePicker and TimePicker controls, locale providers, and timezone or daylight-saving interpretation are separate work packages.

## Component demo

Captured gallery example and its corresponding source excerpt.

**Demo**

![xmCalendarWidgetClass demo](<gallery-screenshots/xm-calendarwidgetclass.png>)

**Source**

Actual gallery excerpt: class = xmCalendarWidgetClass. The host supplies parent, name, callback and client\_data. Shared factory locals: Widget example; XmString label = NULL. The shared factory frees label, attaches callbacks and sizes the preview. Helpers and the complete factory are in gallery\_examples.c.

```c
XmCalendarDate date = {2026, 10, 25};
example = XtVaCreateManagedWidget((char *)name, class, parent,
                                  NULL);
XmCalendarSetDate(example, &date, False);
```

[Complete demo source](<demos/programs/ckmotif-gallery/gallery_examples.c>) · [Public header](<lib/Xm/Calendar.h>)
