wxCalendarCtrl(3erl)

πŸ’– NAME πŸ’–

okay so bestie, this is the manual page for wxCalendarCtrl β€” it's an Erlang module definition situation, page 3erl, and it's literally all about the calendar control class. πŸ—“οΈβœ¨


🌸 DESCRIPTION 🌸

The calendar control lets the user pick a date β€” main character energy fr. The user can move the current selection using the keyboard, and select the date (which generates an EVT_CALENDAR event) by pressing Return or double clicking it. πŸ’…

The generic calendar has advanced possibilities for customizing its display, described below. If you want to use these possibilities on every platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl. no cap, that's the whole vibe. πŸ¦‹

All global settings (such as colours and fonts used) can, of course, be changed. But also, the display style for each day in the month can be set independently using wxCalendarDateAttr class. ✨

An item without custom attributes is drawn with the default colours and font and without border, but setting custom attributes with setAttr/3 allows modifying its appearance. Just create a custom attribute object and set it for the day you want to be displayed specially β€” and note that the control will take ownership of the pointer, i.e. it will delete it itself. A day may be marked as being a holiday, even if it is not recognized as one by wx_datetime() using the wxCalendarDateAttr:setHoliday/2 method. πŸŽ€

As the attributes are specified for each day, they may change when the month is changed, so you will often want to update them in EVT_CALENDAR_PAGE_CHANGED event handler. lowkey important. πŸ‘‘

If neither the wxCAL_SUNDAY_FIRST or wxCAL_MONDAY_FIRST style is given, the first day of the week is determined from operating system's settings, if possible. The native wxGTK calendar chooses the first weekday based on locale, and these styles have no effect on it. 🌈

✨ Styles ✨

This class supports the following styles:

(the style list is coming in the next part, bestie β€” this part doesn't have the actual bullets yet, so stay tuned πŸ’–)

Note: Changing the selected date will trigger an EVT_CALENDAR_DAY, MONTH or YEAR event as well as an EVT_CALENDAR_SEL_CHANGED event. 😭

See: Examples, wxCalendarDateAttr, wxCalendarEvent, wxDatePickerCtrl

This class is derived (and can use functions) from: wxControl, wxWindow, wxEvtHandler. slay. πŸ”₯

wxWidgets docs: wxCalendarCtrl


🌟 EVENTS 🌟

Event types emitted from this class: calendar_sel_changed, calendar_weekday_clicked. πŸ¦‹πŸ’«


πŸŽ€ DATA TYPES πŸŽ€

wxCalendarCtrl() = wx:wx_object()

periodt. πŸ’…βœ¨

✨ EXPORTS ✨

okay so here’s the function buffet, bestie β€” every overload, every Option, every β€œonly in generic” footnote. no cap, all of it is staying. πŸ’…


πŸ¦‹ new() -> wxCalendarCtrl()

Default constructor. literally the baby-start version. ✨

🌸 new(Parent, Id) -> wxCalendarCtrl()

Types:

Parent = wxWindow:wxWindow()
Id = integer()

Two-arg constructor vibes, bestie. types are right there. 🫢

πŸŽ€ new(Parent, Id, Options :: [Option]) -> wxCalendarCtrl()

Types:

Parent = wxWindow:wxWindow()
Id = integer()
Option =
    {date, wx:wx_datetime()} |
    {pos, {X :: integer(), Y :: integer()}} |
    {size, {W :: integer(), H :: integer()}} |
    {style, integer()}

Does the same as create/4 method. fr fr, same energy. πŸ’–

🌈 create(This, Parent, Id) -> boolean()

Types:

This = wxCalendarCtrl()
Parent = wxWindow:wxWindow()
Id = integer()

Three-arg create form, bestie. πŸ¦‹

🌟 create(This, Parent, Id, Options :: [Option]) -> boolean()

Types:

This = wxCalendarCtrl()
Parent = wxWindow:wxWindow()
Id = integer()
Option =
    {date, wx:wx_datetime()} |
    {pos, {X :: integer(), Y :: integer()}} |
    {size, {W :: integer(), H :: integer()}} |
    {style, integer()}

Creates the control. See wxWindow:new/3 for the meaning of the parameters and the control overview for the possible styles. that’s the whole assignment, bestie. πŸ“š

πŸ’« destroy(This :: wxCalendarCtrl()) -> ok

Destroys the control. bye-bye, iconic little widget. πŸ’€

πŸ—“οΈ setDate(This, Date) -> boolean()

Types:

This = wxCalendarCtrl()
Date = wx:wx_datetime()

Sets the current date.

The Date parameter must be valid and in the currently valid range as set by SetDateRange() (not implemented in wx), otherwise the current date is not changed and the function returns false and, additionally, triggers an assertion failure if the date is invalid. so yes, bestie, invalid date = no change + false + assertion drama. 😭

πŸ—“οΈ getDate(This) -> wx:wx_datetime()

Types:

This = wxCalendarCtrl()

Gets the currently selected date. cute, simple, slay. ✨

πŸŒ™ enableYearChange(This) -> ok

Types:

This = wxCalendarCtrl()

No-Options form, bestie. the deets live under enableYearChange/2 right below. 🫢

πŸŒ™ enableYearChange(This, Options :: [Option]) -> ok

Types:

This = wxCalendarCtrl()
Option = {enable, boolean()}
🚨 Deprecated: This function should be used instead of changing wxCAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the user to change the year interactively. Only in generic wxCalendarCtrl.

so like, use this instead of poking the style bit yourself. periodt. πŸ’…

🌺 enableMonthChange(This) -> boolean()

Types:

This = wxCalendarCtrl()

No-Options form. shared behavior + return value are under enableMonthChange/2, bestie. 🌸

🌺 enableMonthChange(This, Options :: [Option]) -> boolean()

Types:

This = wxCalendarCtrl()
Option = {enable, boolean()}

This function should be used instead of changing wxCAL_NO_MONTH_CHANGE style bit.

It allows or disallows the user to change the month interactively. Note that if the month cannot be changed, the year cannot be changed neither.

Return: true if the value of this option really changed or false if it was already set to the requested value. vibe check passed only if it actually changed, no fake updates. πŸ’–

πŸŽ‰ enableHolidayDisplay(This) -> ok

Types:

This = wxCalendarCtrl()

No-Options form. holiday deets are under enableHolidayDisplay/2, bestie. πŸŽ€

πŸŽ‰ enableHolidayDisplay(This, Options :: [Option]) -> ok

Types:

This = wxCalendarCtrl()
Option = {display, boolean()}

This function should be used instead of changing wxCAL_SHOW_HOLIDAYS style bit directly.

It enables or disables the special highlighting of the holidays. holiday glow-up: on/off. ✨

🎨 setHeaderColours(This, ColFg, ColBg) -> ok

Types:

This = wxCalendarCtrl()
ColFg = ColBg = wx:wx_colour()

Set the colours used for painting the weekdays at the top of the control.

This method is currently only implemented in generic wxCalendarCtrl and does nothing in the native versions. native versions said β€œnot today” πŸ’…

🎨 getHeaderColourFg(This) -> wx:wx_colour4()

Types:

This = wxCalendarCtrl()

Gets the foreground colour of the header part of the calendar window.

This method is currently only implemented in generic wxCalendarCtrl and always returns wxNullColour in the native versions.

See: setHeaderColours/3

🎨 getHeaderColourBg(This) -> wx:wx_colour4()

Types:

This = wxCalendarCtrl()

Gets the background colour of the header part of the calendar window.

This method is currently only implemented in generic wxCalendarCtrl and always returns wxNullColour in the native versions.

See: setHeaderColours/3

πŸ’– setHighlightColours(This, ColFg, ColBg) -> ok

Types:

This = wxCalendarCtrl()
ColFg = ColBg = wx:wx_colour()

Set the colours to be used for highlighting the currently selected date.

This method is currently only implemented in generic wxCalendarCtrl and does nothing in the native versions. selected-date highlight fit check πŸ’…

πŸ’– getHighlightColourFg(This) -> wx:wx_colour4()

Types:

This = wxCalendarCtrl()

Gets the foreground highlight colour.

Only in generic wxCalendarCtrl.

This method is currently only implemented in generic wxCalendarCtrl and always returns wxNullColour in the native versions.

See: setHighlightColours/3

πŸ’– getHighlightColourBg(This) -> wx:wx_colour4()

Types:

This = wxCalendarCtrl()

Gets the background highlight colour.

Only in generic wxCalendarCtrl.

This method is currently only implemented in generic wxCalendarCtrl and always returns wxNullColour in the native versions.

See: setHighlightColours/3

πŸ“ setHolidayColours(This, ColFg, ColBg) -> ok

Types:

This = wxCalendarCtrl()
ColFg = ColBg = wx:wx_colour()

Sets the colours to be used for the holidays highlighting.

This method is only implemented in the generic version of the control and does nothing in the native ones. It should also only be called if the window style includes wxCAL_SHOW_HOLIDAYS flag or enableHolidayDisplay/2 had been called. so read the room, bestie β€” holiday colours need holiday mode. πŸ“

πŸ“ getHolidayColourFg(This) -> wx:wx_colour4()

Types:

This = wxCalendarCtrl()

Return the foreground colour currently used for holiday highlighting.

Only useful with generic wxCalendarCtrl as native versions currently don’t support holidays display at all and always return wxNullColour.

See: setHolidayColours/3

πŸ“ getHolidayColourBg(This) -> wx:wx_colour4()

Types:

This = wxCalendarCtrl()

Return the background colour currently used for holiday highlighting.

Only useful with generic wxCalendarCtrl as native versions currently don’t support holidays display at all and always return wxNullColour.

See: setHolidayColours/3

🧚 getAttr(This, Day) -> wxCalendarDateAttr:wxCalendarDateAttr()

Types:

This = wxCalendarCtrl()
Day = integer()

Returns the attribute for the given date (should be in the range 1...31).

The returned pointer may be NULL. Only in generic wxCalendarCtrl. pointer may be NULL, so handle that, bestie 🫢

🧚 setAttr(This, Day, Attr) -> ok

Types:

This = wxCalendarCtrl()
Day = integer()
Attr = wxCalendarDateAttr:wxCalendarDateAttr()

Associates the attribute with the specified date (in the range 1...31).

If the pointer is NULL, the items attribute is cleared. Only in generic wxCalendarCtrl. ✨

🌸 setHoliday(This, Day) -> ok

Types:

This = wxCalendarCtrl()
Day = integer()

Marks the specified day as being a holiday in the current month.

This method is only implemented in the generic version of the control and does nothing in the native ones. holiday marking said β€œgeneric only” πŸ’…

🌸 resetAttr(This, Day) -> ok

Types:

This = wxCalendarCtrl()
Day = integer()

Clears any attributes associated with the given day (in the range 1...31).

Only in generic wxCalendarCtrl. reset that vibe, bestie. 🧹

πŸ”₯ hitTest(This, Pos) -> Result

Types:

Result =
    {Res :: wx:wx_enum(),
     Date :: wx:wx_datetime(),
     Wd :: wx:wx_enum()}
This = wxCalendarCtrl()
Pos = {X :: integer(), Y :: integer()}

Returns one of wxCalendarHitTestResult constants and fills either date or wd pointer with the corresponding value depending on the hit test code.

Not implemented in wxGTK currently. wxGTK said β€œmiss me with this one” 😭


πŸ’– before you close the tab: the footer stamp has source wxWidgets team, version wx 2.2.2.1, and page wxCalendarCtrl(3erl) β€” and there’s no separate date printed in this footer, so I’m not gonna invent one, bestie. that would be messy. πŸŽ€

πŸ“¦ where this page comes from