Struct cursive_calendar_view::CalendarView
[−]
[src]
pub struct CalendarView<T: TimeZone, L: Locale> { /* fields omitted */ }
View for selecting a date, supporting different modes for day, month or year based selection.
View modes can be navigated via Backspace
and Enter
.
Custom localization is possible by providing an implementation of the
Locale
trait.
Examples
// Allow selection a date within the year of 2017. let mut calendar = CalendarView::<UTC, EnglishLocale>::new(UTC::today()); calendar.set_highest_view_mode(ViewMode::Year); calendar.set_earliest_date(Some(UTC.ymd(2017, 1, 1))); calendar.set_latest_date(Some(UTC.ymd(2017, 12, 31))); calendar.set_show_iso_weeks(true);
Methods
impl<T: TimeZone, L: Locale> CalendarView<T, L>
[src]
fn new(today: Date<T>) -> Self
[src]
Creates new CalendarView
.
fn disable(&mut self)
[src]
Disables this view.
A disabled view cannot be selected.
fn enable(&mut self)
[src]
Re-enables this view.
fn set_enabled(&mut self, enabled: bool)
[src]
Enable or disable this view.
fn is_enabled(&self) -> bool
[src]
Returns true
if this view is enabled.
fn date(&self) -> Date<T>
[src]
Returns the currently selected date of this view.
fn set_selected_date(&mut self, date: Date<T>)
[src]
Sets the currently selected date of this view.
fn selected_date(self, date: Date<T>) -> Self
[src]
Sets the currently selected date of this view.
Chainable variant.
fn set_view_date(&mut self, date: Date<T>)
[src]
Sets the visually selected date of this view.
fn view_date(self, date: Date<T>) -> Self
[src]
Sets the visually selected date of this view.
Chainable variant.
fn set_view_mode(&mut self, mode: ViewMode)
[src]
Sets the currently active view mode of this view.
fn view_mode(self, mode: ViewMode) -> Self
[src]
Sets the currently active view mode of this view.
Chainable variant.
fn set_lowest_view_mode(&mut self, mode: ViewMode)
[src]
Sets the lowest view mode this calendar can be in.
Can be used conjunction with
CalendarView::set_highest_view_mode
to limit a CalendarView
to only allow selection of days, months or years.
fn lowest_view_mode(self, mode: ViewMode) -> Self
[src]
Sets the lowest view mode this calendar can be in.
Can be used conjunction with
CalendarView::set_highest_view_mode
to limit a CalendarView
to only allow selection of days, months or years.
Chainable variant.
fn set_highest_view_mode(&mut self, mode: ViewMode)
[src]
Sets the highest view mode this calendar can be in.
Can be used conjunction with
CalendarView::set_lowest_view_mode
to limit a CalendarView
to only allow selection of days, months or years.
fn highest_view_mode(self, mode: ViewMode) -> Self
[src]
Sets the highest view mode this calendar can be in.
Can be used conjunction with
CalendarView::set_lowest_view_mode
to limit a CalendarView
to only allow selection of days, months or years.
Chainable variant.
fn set_earliest_date(&mut self, date: Option<Date<T>>)
[src]
Sets and limits the earliest date selectable by this view.
fn earliest_date(self, date: Option<Date<T>>) -> Self
[src]
Sets and limits the earliest date selectable by this view.
Chainable variant.
fn set_latest_date(&mut self, date: Option<Date<T>>)
[src]
Sets and limits the latest date selectable by this view.
fn latest_date(self, date: Option<Date<T>>) -> Self
[src]
Sets and limits the latest date selectable by this view.
Chainable variant.
fn set_week_start(&mut self, day: WeekDay)
[src]
Allows to change the default week start day of WeekDay::Monday
to any other
WeekDay
.
fn week_start(self, day: WeekDay) -> Self
[src]
Allows to change the default week start day of WeekDay::Monday
to any other
WeekDay
.
Chainable variant.
fn set_show_iso_weeks(&mut self, show: bool)
[src]
Show or hide ISO week numbers in the ViewMode::Month
view mode.
ISO week numbers only make sense with a week start day of WeekDay::Monday
.
fn show_iso_weeks(self, show: bool) -> Self
[src]
Show or hide ISO week numbers in the ViewMode::Month
view mode.
ISO week numbers only make sense with a week start day of WeekDay::Monday
.
Chainable variant.
fn set_on_submit<F>(&mut self, cb: F) where
F: Fn(&mut Cursive, &Date<T>) + 'static,
[src]
F: Fn(&mut Cursive, &Date<T>) + 'static,
Sets a callback to be used when <Enter>
is pressed to select a date.
fn on_submit<F>(self, cb: F) -> Self where
F: Fn(&mut Cursive, &Date<T>) + 'static,
[src]
F: Fn(&mut Cursive, &Date<T>) + 'static,
Sets a callback to be used when <Enter>
is pressed to select a date.
Chainable variant.
fn set_on_select<F>(&mut self, cb: F) where
F: Fn(&mut Cursive, &Date<T>) + 'static,
[src]
F: Fn(&mut Cursive, &Date<T>) + 'static,
Sets a callback to be used when an a new date is visually selected.
fn on_select<F>(self, cb: F) -> Self where
F: Fn(&mut Cursive, &Date<T>) + 'static,
[src]
F: Fn(&mut Cursive, &Date<T>) + 'static,
Sets a callback to be used when an a new date is visually selected.
Chainable variant.
Trait Implementations
impl<T: TimeZone + 'static, L: Locale> View for CalendarView<T, L>
[src]
fn draw(&self, printer: &Printer)
[src]
Draws the view with the given printer (includes bounds) and focus.
fn required_size(&mut self, _: Vec2) -> Vec2
[src]
Returns the minimum size the view requires with the given restrictions. Read more
fn take_focus(&mut self, _: Direction) -> bool
[src]
This view is offered focus. Will it take it? Read more
fn on_event(&mut self, event: Event) -> EventResult
[src]
Called when a key was pressed. Read more
fn needs_relayout(&self) -> bool
[src]
Returns true
if the view content changed since last layout phase. Read more
fn layout(&mut self, XY<usize>)
[src]
Called once the size for this view has been decided, Read more
fn call_on_any(&mut self, &Selector, Box<FnMut(&mut (Any + 'static)) + 'a>)
[src]
Runs a closure on the view identified by the given selector. Read more
fn focus_view(&mut self, &Selector) -> Result<(), ()>
[src]
Moves the focus to the view identified by the given selector. Read more