CalendarState

Struct CalendarState 

Source
pub struct CalendarState<const N: usize, Selection> {
    pub area: Rect,
    pub inner: Rect,
    pub widget_area: Rect,
    pub months: [MonthState<Selection>; N],
    pub selection: Rc<RefCell<Selection>>,
    pub focus: FocusFlag,
    pub non_exhaustive: NonExhaustive,
    /* private fields */
}
Expand description

A struct that contains an array of MonthState to get a true calendar behaviour. There is no Widget for this, the exact layout is left to the user. This takes care of all the rest.

Fields§

§area: Rect

Complete area read only. renewed for each render.

§inner: Rect

Area inside the block. read only. renewed for each render.

§widget_area: Rect
👎Deprecated since 2.3.0: use inner instead

Area inside the block. read only. renewed for each render.

§months: [MonthState<Selection>; N]

Months.

§selection: Rc<RefCell<Selection>>

Selection model.

§focus: FocusFlag

Calendar focus

§non_exhaustive: NonExhaustive

Implementations§

Source§

impl<const N: usize, Selection> CalendarState<N, Selection>

Source

pub fn new() -> Self
where Selection: Default,

Source

pub fn named(name: &str) -> Self
where Selection: Default,

Source

pub fn set_step(&mut self, step: usize)

Step-size when navigating outside the displayed calendar.

You can do a rolling calendar which goes back 1 month or a yearly calendar which goes back 12 months. Or any other value you like.

If you set step to 0 this kind of navigation is deactivated.

Default is 1.

Source

pub fn step(&self) -> usize

Step-size when navigating outside the displayed calendar.

You can do a rolling calendar which goes back 1 month or a yearly calendar which goes back 12 months. Or any other value you like.

If you set step to 0 this kind of navigation is deactivated.

Default is 1.

Source

pub fn set_today_policy(&mut self, home: TodayPolicy)

How should move_to_today() work.

Source

pub fn today_policy(&mut self) -> TodayPolicy

How should move_to_today() work.

Source

pub fn set_primary_idx(&mut self, primary: usize)

Set the primary month for the calendar.

The primary month will be focused with Tab navigation. That means you can jump over all calendar months with just one Tab.

Movement within the calendar is possible with the arrow-keys. This will change the primary month for future Tab navigation.

Source

pub fn primary_idx(&self) -> usize

The primary month for the calendar.

The primary month will be focused with Tab navigation. That means you can jump over all calendar months with just one Tab.

Movement within the calendar is possible with the arrow-keys. This will change the primary month for future Tab navigation.

Source

pub fn set_start_date(&mut self, date: NaiveDate)

Set the start-date for the calendar. This will set the start-date for each month.

Source

pub fn start_date(&self) -> NaiveDate

Start-date of the calendar.

Source

pub fn end_date(&self) -> NaiveDate

End-date of the calendar.

Source

pub fn scroll_forward(&mut self, n: usize) -> CalOutcome

Changes the start-date for each month. Doesn’t change any selection.

Source

pub fn scroll_back(&mut self, n: usize) -> CalOutcome

Changes the start-date for each month. Doesn’t change any selection.

Source

pub fn scroll_to(&mut self, date: NaiveDate) -> CalOutcome

Changes the start-date for each month. Doesn’t change any selection.

Source

pub fn screen_cursor(&self) -> Option<(u16, u16)>

Returns None

Source§

impl<const N: usize, Selection> CalendarState<N, Selection>
where Selection: CalendarSelection,

Source

pub fn is_selected(&self, date: NaiveDate) -> bool

Is the date selected?

Source

pub fn lead_selection(&self) -> Option<NaiveDate>

Lead selection.

Source§

impl<const N: usize> CalendarState<N, NoSelection>

Source

pub fn prev_month(&mut self, n: usize) -> CalOutcome

Move to the previous month. Scrolls the calendar if necessary.

Source

pub fn next_month(&mut self, n: usize) -> CalOutcome

Move to the next month. Scrolls the calendar if necessary.

Source

pub fn move_to_today(&mut self) -> CalOutcome

Move the calendar to show the current date.

Resets the start-dates according to TodayPolicy. Focuses the primary index and selects the current day.

Source

pub fn move_to(&mut self, date: NaiveDate) -> CalOutcome

Source§

impl<const N: usize> CalendarState<N, SingleSelection>

Source

pub fn clear_selection(&mut self)

Clear the selection.

Source

pub fn select(&mut self, date: NaiveDate) -> bool

Select the given date. Doesn’t scroll the calendar.

Source

pub fn selected(&self) -> Option<NaiveDate>

Selected date.

Source

pub fn move_to_today(&mut self) -> CalOutcome

Move the calendar to show the current date.

Resets the start-dates according to TodayPolicy. Focuses the primary index and selects the current day.

Source

pub fn move_to(&mut self, date: NaiveDate) -> CalOutcome

Move the calendar to show the given date.

Resets the start-dates according to TodayPolicy. Focuses the primary index and selects the current day.

Source

pub fn prev_day(&mut self, n: usize) -> CalOutcome

Select previous day. Scrolls the calendar if necessary.

Source

pub fn next_day(&mut self, n: usize) -> CalOutcome

Select previous week. Scrolls the calendar if necessary.

Source

pub fn prev_month(&mut self, n: usize) -> CalOutcome

Select the same day in the previous month.

This may shift the date a bit if it’s out of range of the new month.

Source

pub fn next_month(&mut self, n: usize) -> CalOutcome

Select the same day in the next month.

This may shift the date a bit if it’s out of range of the new month.

Source§

impl<const N: usize> CalendarState<N, RangeSelection>

Source

pub fn clear_selection(&mut self)

Clear the selection.

Source

pub fn select_month(&mut self, date: NaiveDate, extend: bool) -> bool

Select the full month of the date. Any date of the month will do. Can extend the selection to encompass the month. Any existing selection is buffed up to fill one month.

Source

pub fn select_week(&mut self, date: NaiveDate, extend: bool) -> bool

Select the week of the given date. Any date of the week will do. Can extend the selection to encompass the week. Any existing selection is buffed up to fill one week.

Source

pub fn select_day(&mut self, date: NaiveDate, extend: bool) -> bool

Select the given date. Can extend the selection to the given date.

Source

pub fn select(&mut self, selection: (NaiveDate, NaiveDate)) -> bool

Set the selection as (anchor, lead) pair.

Source

pub fn selected(&self) -> Option<(NaiveDate, NaiveDate)>

Selection as (anchor, lead) pair.

Source

pub fn selected_range(&self) -> Option<RangeInclusive<NaiveDate>>

Selection as NaiveDate range.

Source

pub fn move_to_today(&mut self) -> CalOutcome

Move the calendar to today.

Uses TodayPolicy to build the new calendar and focuses and selects the given date.

Source

pub fn move_to(&mut self, date: NaiveDate) -> CalOutcome

Move the calendar the given day.

Uses TodayPolicy to build the new calendar and focuses and selects the given date.

Source

pub fn move_to_prev(&mut self, months: Months, days: Days) -> CalOutcome

Move the lead selection back by months/days. Clears the current selection and scrolls if necessary.

Source

pub fn move_to_next(&mut self, months: Months, days: Days) -> CalOutcome

Move the lead selection forward by months/days. Clears the current selection and scrolls if necessary.

Source

pub fn prev_day(&mut self, n: usize, extend: bool) -> CalOutcome

Select previous day.

Can extend the selection to include the new date.

Source

pub fn next_day(&mut self, n: usize, extend: bool) -> CalOutcome

Select next day.

Can extend the selection to include the new date.

Source

pub fn prev_week(&mut self, n: usize, extend: bool) -> CalOutcome

Select the previous week.

When extending a selection, the current selection buffs up to fill one week.

Source

pub fn next_week(&mut self, n: usize, extend: bool) -> CalOutcome

Select the next week.

When extending a selection, the current selection buffs up to fill one week.

Source

pub fn prev_month(&mut self, n: usize, extend: bool) -> CalOutcome

Select the previous month.

When extending a selection, the current selection buffs up to fill one month.

Source

pub fn next_month(&mut self, n: usize, extend: bool) -> CalOutcome

Select the previous month.

When extending a selection, the current selection buffs up to fill one month.

Trait Implementations§

Source§

impl<const N: usize, Selection: Clone> Clone for CalendarState<N, Selection>

Source§

fn clone(&self) -> CalendarState<N, Selection>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, Selection: Debug> Debug for CalendarState<N, Selection>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize, Selection> Default for CalendarState<N, Selection>
where Selection: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, NoSelection>

Source§

fn handle(&mut self, event: &Event, _qualifier: MouseOnly) -> CalOutcome

Handle an event. Read more
Source§

impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, RangeSelection>

Source§

fn handle(&mut self, event: &Event, _qualifier: MouseOnly) -> CalOutcome

Handle an event. Read more
Source§

impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, SingleSelection>

Source§

fn handle(&mut self, event: &Event, _qualifier: MouseOnly) -> CalOutcome

Handle an event. Read more
Source§

impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, NoSelection>

Source§

fn handle(&mut self, event: &Event, _qualifier: Regular) -> CalOutcome

Handle an event. Read more
Source§

impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, RangeSelection>

Source§

fn handle(&mut self, event: &Event, _qualifier: Regular) -> CalOutcome

Handle an event. Read more
Source§

impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, SingleSelection>

Source§

fn handle(&mut self, event: &Event, _qualifier: Regular) -> CalOutcome

Handle an event. Read more
Source§

impl<const N: usize, Selection> HasFocus for CalendarState<N, Selection>

Source§

fn build(&self, builder: &mut FocusBuilder)

Build the focus-structure for the container/widget.
Source§

fn focus(&self) -> FocusFlag

Access to the flag for the rest.
Source§

fn area(&self) -> Rect

Area for mouse focus. Read more
Source§

fn build_nav(&self, navigable: Navigation, builder: &mut FocusBuilder)

Build the focus-structure for the container/widget. This is called when the default navigation will be overridden by the builder. Read more
Source§

fn id(&self) -> usize

Provide a unique id for the widget.
Source§

fn area_z(&self) -> u16

Z value for the area. Read more
Source§

fn navigable(&self) -> Navigation

Declares how the widget interacts with focus. Read more
Source§

fn is_focused(&self) -> bool

Focused?
Source§

fn lost_focus(&self) -> bool

Just lost focus.
Source§

fn gained_focus(&self) -> bool

Just gained focus.
Source§

impl<const N: usize, Selection> HasScreenCursor for CalendarState<N, Selection>

Source§

fn screen_cursor(&self) -> Option<(u16, u16)>

This returns the cursor position if Read more
Source§

impl<const N: usize, Selection> RelocatableState for CalendarState<N, Selection>

Source§

fn relocate(&mut self, shift: (i16, i16), clip: Rect)

Relocate the areas in this widgets state. Read more
Source§

fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)

Relocate only popup areas. As rendering the popups is a separate render, this has to be separate too.
Source§

fn relocate_popup_hidden(&mut self)

Relocate all popup areas to a clip-rect (0,0+0x0).
Source§

fn relocate_hidden(&mut self)

Relocate all areas to a clip-rect (0,0+0x0).

Auto Trait Implementations§

§

impl<const N: usize, Selection> !Freeze for CalendarState<N, Selection>

§

impl<const N: usize, Selection> !RefUnwindSafe for CalendarState<N, Selection>

§

impl<const N: usize, Selection> !Send for CalendarState<N, Selection>

§

impl<const N: usize, Selection> !Sync for CalendarState<N, Selection>

§

impl<const N: usize, Selection> Unpin for CalendarState<N, Selection>

§

impl<const N: usize, Selection> !UnwindSafe for CalendarState<N, Selection>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.