FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Calendar

    struct · ferroui-controls · v0.5.0

    struct Calendar
    

    Represents a control that enables a user to select a date by using a visual calendar display.

    A Calendar control can be used on its own, or as a drop-down part of a date picker control. A Calendar displays either the days of a month, the months of a year, or the years of a decade, depending on the value of the DisplayMode property. When displaying the days of a month, the user can select a date, a range of dates, or multiple ranges of dates. The kinds of selections that are allowed are controlled by the SelectionMode property.

    The range of dates displayed is governed by the DisplayDateStart and DisplayDateEnd properties. If DisplayMode is Year or Decade, only months or years that contain displayable dates will be displayed.

    The BlackoutDates property can be used to specify dates that cannot be selected. These dates will be displayed as dimmed and disabled.

    By default, Today is highlighted. This can be disabled by setting IsTodayHighlighted to false.

    The Calendar control provides basic navigation using either the mouse or keyboard. The following table summarizes keyboard navigation.

        Key Combination     DisplayMode     Action
        ARROW               Any             Change focused date, unselect
                                            all selected dates, and select
                                            new focused date.
    
        SHIFT+ARROW         Any             If SelectionMode is not set to
                                            SingleDate or None begin
                                            selecting a range of dates.
    
        CTRL+UP ARROW       Any             Switch to the next larger
                                            DisplayMode.  If DisplayMode is
                                            already Decade, no action.
    
        CTRL+DOWN ARROW     Any             Switch to the next smaller
                                            DisplayMode.  If DisplayMode is
                                            already Month, no action.
    
        SPACEBAR            Month           Select focused date.
    
        SPACEBAR            Year or Decade  Switch DisplayMode to the Month
                                            or Year represented by focused
                                            item.
    

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<Calendar>
    

    Returns a strong reference to this object.

    Source

    first_day_of_week_property

    fn first_day_of_week_property() -> &'static StyledProperty<DayOfWeek>
    

    Defines the FirstDayOfWeek property.

    Source

    is_today_highlighted_property

    fn is_today_highlighted_property() -> &'static StyledProperty<bool>
    

    Defines the IsTodayHighlighted property.

    Source

    header_background_property

    fn header_background_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Defines the HeaderBackground property.

    Source

    is_week_number_visible_property

    fn is_week_number_visible_property() -> &'static StyledProperty<bool>
    

    Defines the IsWeekNumberVisible property.

    Source

    week_number_rule_property

    fn week_number_rule_property() -> &'static StyledProperty<CalendarWeekRule>
    

    Defines the WeekNumberRule property.

    Source

    display_mode_property

    fn display_mode_property() -> &'static StyledProperty<CalendarMode>
    

    Defines the DisplayMode property.

    Source

    selection_mode_property

    fn selection_mode_property() -> &'static StyledProperty<CalendarSelectionMode>
    

    Defines the SelectionMode property.

    Source

    allow_tap_range_selection_property

    fn allow_tap_range_selection_property() -> &'static StyledProperty<bool>
    

    Defines the AllowTapRangeSelection property.

    Source

    selected_date_property

    fn selected_date_property() -> &'static StyledProperty<Option<DateTime>>
    

    Defines the SelectedDate property.

    Source

    display_date_property

    fn display_date_property() -> &'static StyledProperty<DateTime>
    

    Defines the DisplayDate property.

    Source

    display_date_start_property

    fn display_date_start_property() -> &'static StyledProperty<Option<DateTime>>
    

    Defines the DisplayDateStart property.

    Source

    display_date_end_property

    fn display_date_end_property() -> &'static StyledProperty<Option<DateTime>>
    

    Defines the DisplayDateEnd property.

    Source

    construct

    fn construct() -> Self
    

    Creates the class data; see ferroui_base::FerroObject::construct.

    Source

    new

    fn new() -> Ref<Self>
    

    Initializes a new instance of the Calendar class.

    Source

    first_day_of_week

    fn first_day_of_week(self: &Self) -> DayOfWeek
    

    Gets or sets the day that is considered the beginning of the week. The default is the first day of the week of the culture that was current when the class was initialised.

    Source

    set_first_day_of_week

    fn set_first_day_of_week(self: &Self, value: DayOfWeek)
    

    Source

    is_today_highlighted

    fn is_today_highlighted(self: &Self) -> bool
    

    Gets or sets a value indicating whether the current date is highlighted. The default is true.

    Source

    set_is_today_highlighted

    fn set_is_today_highlighted(self: &Self, value: bool)
    

    Source

    header_background

    fn header_background(self: &Self) -> Option<Rc<dyn IBrush>>
    

    The brush of the background of the header.

    Source

    set_header_background

    fn set_header_background(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    is_week_number_visible

    fn is_week_number_visible(self: &Self) -> bool
    

    Gets or sets a value indicating whether week numbers are shown in the month view.

    Source

    set_is_week_number_visible

    fn set_is_week_number_visible(self: &Self, value: bool)
    

    Source

    week_number_rule

    fn week_number_rule(self: &Self) -> CalendarWeekRule
    

    Gets or sets the rule used to determine the first week of the year for week number display. The default is taken from the culture that was current when the class was initialised.

    Use CalendarWeekRule::FirstFourDayWeek in combination with a first day of the week of DayOfWeek::Monday for ISO 8601 week numbering.

    Source

    set_week_number_rule

    fn set_week_number_rule(self: &Self, value: CalendarWeekRule)
    

    Source

    display_mode

    fn display_mode(self: &Self) -> CalendarMode
    

    Gets or sets a value indicating whether the calendar is displayed in months, years, or decades.

    Source

    set_display_mode

    fn set_display_mode(self: &Self, value: CalendarMode)
    

    Source

    selection_mode

    fn selection_mode(self: &Self) -> CalendarSelectionMode
    

    Gets or sets a value that indicates what kind of selections are allowed. The default is CalendarSelectionMode::SingleDate.

    This property determines whether the Calendar allows no selection, selection of a single date, or selection of multiple dates.

    When this property is changed, all selected dates will be cleared.

    Source

    set_selection_mode

    fn set_selection_mode(self: &Self, value: CalendarSelectionMode)
    

    Source

    allow_tap_range_selection

    fn allow_tap_range_selection(self: &Self) -> bool
    

    Gets or sets a value indicating whether tap-to-select range mode is enabled. When enabled, users can tap a start date and then tap an end date to select a range. The default is true.

    This feature only works when SelectionMode is set to a range mode. When enabled, the first tap selects the start date, and the second tap selects the end date to complete the range. Tapping a third date starts a new range.

    Source

    set_allow_tap_range_selection

    fn set_allow_tap_range_selection(self: &Self, value: bool)
    

    Source

    selected_date

    fn selected_date(self: &Self) -> Option<DateTime>
    

    Gets or sets the currently selected date. The default is None.

    Setting it panics when the given date is in the blackout dates, or when it is set to anything other than None while the selection mode is CalendarSelectionMode::None.

    Use this property when SelectionMode is set to SingleDate. In other modes, this property will always be the first date in SelectedDates.

    Source

    set_selected_date

    fn set_selected_date(self: &Self, value: Option<DateTime>)
    

    Source

    selected_dates

    fn selected_dates(self: &Self) -> SelectedDatesCollection
    

    Gets a collection of selected dates. The default is an empty collection.

    Dates can be added to the collection either individually or in a range using the AddRange method. Depending on the value of the SelectionMode property, adding a date or range to the collection may cause it to be cleared. The following table lists how the selection mode affects the SelectedDates property.

        CalendarSelectionMode   Description
        None                    No selections are allowed.  SelectedDate
                                cannot be set and no values can be added
                                to SelectedDates.
    
        SingleDate              Only a single date can be selected,
                                either by setting SelectedDate or the
                                first value in SelectedDates.  AddRange
                                cannot be used.
    
        SingleRange             A single range of dates can be selected.
                                Setting SelectedDate, adding a date
                                individually to SelectedDates, or using
                                AddRange will clear all previous values
                                from SelectedDates.
        MultipleRange           Multiple non-contiguous ranges of dates
                                can be selected. Adding a date
                                individually to SelectedDates or using
                                AddRange will not clear SelectedDates.
                                Setting SelectedDate will still clear
                                SelectedDates, but additional dates or
                                range can then be added.  Adding a range
                                that includes some dates that are
                                already selected or overlaps with
                                another range results in the union of
                                the ranges and does not cause an
                                exception.
    

    Source

    display_date

    fn display_date(self: &Self) -> DateTime
    

    Gets or sets the date to display. The default is today.

    A date that is not in the range specified by the DisplayDateStart and DisplayDateEnd properties is replaced by the nearest end of that range.

    Source

    set_display_date

    fn set_display_date(self: &Self, value: DateTime)
    

    Source

    display_date_start

    fn display_date_start(self: &Self) -> Option<DateTime>
    

    Gets or sets the first date to be displayed.

    Source

    set_display_date_start

    fn set_display_date_start(self: &Self, value: Option<DateTime>)
    

    Source

    blackout_dates

    fn blackout_dates(self: &Self) -> CalendarBlackoutDatesCollection
    

    Gets a collection of dates that are marked as not selectable. The default value is an empty collection.

    Adding a date to this collection when it is already selected panics.

    Dates in this collection will appear as disabled on the calendar.

    To make all past dates not selectable, you can use the add_dates_in_past method provided by the collection returned by this property.

    Source

    display_date_end

    fn display_date_end(self: &Self) -> Option<DateTime>
    

    Gets or sets the last date to be displayed.

    Source

    set_display_date_end

    fn set_display_date_end(self: &Self, value: Option<DateTime>)
    

    Source

    selected_dates_changed

    fn selected_dates_changed(self: &Self, handler: impl Fn(&SelectionChangedEventArgs) -> () + 'static) -> Subscription
    

    Occurs when the collection returned by the SelectedDates property is changed.

    Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the calendar.

    Source

    display_date_changed

    fn display_date_changed(self: &Self, handler: impl Fn(&CalendarDateChangedEventArgs) -> () + 'static) -> Subscription
    

    Occurs when the DisplayDate property is changed.

    This event occurs after DisplayDate is assigned its new value.

    Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the calendar.

    Source

    display_mode_changed

    fn display_mode_changed(self: &Self, handler: impl Fn(&CalendarModeChangedEventArgs) -> () + 'static) -> Subscription
    

    Occurs when the DisplayMode property is changed.

    Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the calendar.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.