pub struct DateFieldState { /* private fields */ }Expand description
Controlled segmented editing state for one date field.
The application owns every visible declaration: separators, widths, colors, the placeholder look, and the focused-segment highlight. QuickGUI owns the calendar contract — leap years, month lengths, wrapping steps, typed-digit entry with automatic advance, bounded validation — plus which segment is being edited and the native spin-button semantics of each one.
The state retains one bounded placeholder string per segment and no task, timer, observer, or idle scheduler source.
Implementations§
Source§impl DateFieldState
impl DateFieldState
Sourcepub fn from_date(date: CivilDate) -> Self
pub fn from_date(date: CivilDate) -> Self
A field holding one complete date. An invalid date is clamped before it is retained.
Sourcepub fn order(self, order: DateFieldOrder) -> Self
pub fn order(self, order: DateFieldOrder) -> Self
Declare the segment order the application lays out.
Sourcepub fn minimum(self, minimum: CivilDate) -> Self
pub fn minimum(self, minimum: CivilDate) -> Self
Reject dates before this day. The bound is reported through validity, never by rewriting what the user typed.
Sourcepub fn placeholder(
self,
segment: DateSegment,
text: impl Into<Arc<str>>,
) -> Self
pub fn placeholder( self, segment: DateSegment, text: impl Into<Arc<str>>, ) -> Self
Replace one segment’s placeholder. Longer text than
MAX_DATE_FIELD_PLACEHOLDER_BYTES keeps the default.
pub const fn disabled(self, disabled: bool) -> Self
pub const fn segment_order(&self) -> DateFieldOrder
pub const fn minimum_date(&self) -> Option<CivilDate>
pub const fn maximum_date(&self) -> Option<CivilDate>
pub const fn is_disabled(&self) -> bool
Sourcepub fn value(&self) -> Option<CivilDate>
pub fn value(&self) -> Option<CivilDate>
The complete date, or None while any segment is empty or the combination is not real.
Sourcepub fn set_value(&mut self, value: Option<CivilDate>) -> bool
pub fn set_value(&mut self, value: Option<CivilDate>) -> bool
Replace the value. None clears every segment.
Sourcepub const fn segment_value(&self, segment: DateSegment) -> Option<i32>
pub const fn segment_value(&self, segment: DateSegment) -> Option<i32>
The raw numeric content of one segment.
pub const fn is_filled(&self, segment: DateSegment) -> bool
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Whether every segment holds a value.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether the field is empty or holds a real date inside its declared bounds.
A partly typed date is invalid: that is what a form needs to reject, and it matches the desktop and web behavior of a segmented date control.
pub fn placeholder_text(&self, segment: DateSegment) -> &Arc<str> ⓘ
Sourcepub fn segment_text(&self, segment: DateSegment) -> String
pub fn segment_text(&self, segment: DateSegment) -> String
The text one segment displays: zero-padded digits, or its placeholder while empty.
pub const fn focused_segment(&self) -> DateSegment
Sourcepub fn focus_segment(&mut self, segment: DateSegment) -> bool
pub fn focus_segment(&mut self, segment: DateSegment) -> bool
Move editing focus to one segment, discarding pending typed digits.
Sourcepub fn focus_next(&mut self) -> bool
pub fn focus_next(&mut self) -> bool
Move to the next segment in the declared order. The final segment reports false so Tab
can leave the field instead of trapping focus.
Sourcepub fn focus_previous(&mut self) -> bool
pub fn focus_previous(&mut self) -> bool
Move to the previous segment in the declared order.
Sourcepub fn segment_bounds(&self, segment: DateSegment) -> (i32, i32)
pub fn segment_bounds(&self, segment: DateSegment) -> (i32, i32)
The inclusive numeric range one segment accepts right now.
The day’s maximum honors the retained month and year, so February in a leap year offers 29.
Sourcepub fn step_segment(&mut self, segment: DateSegment, delta: i32) -> bool
pub fn step_segment(&mut self, segment: DateSegment, delta: i32) -> bool
Step one segment, wrapping at its bounds. An empty segment takes its minimum when stepped forward and its maximum when stepped backward.
Sourcepub fn to_segment_minimum(&mut self) -> bool
pub fn to_segment_minimum(&mut self) -> bool
Set the focused segment to its smallest legal value.
Sourcepub fn to_segment_maximum(&mut self) -> bool
pub fn to_segment_maximum(&mut self) -> bool
Set the focused segment to its largest legal value.
Sourcepub fn clear_segment(&mut self) -> bool
pub fn clear_segment(&mut self) -> bool
Clear the focused segment and any pending typed digits.
Sourcepub fn type_digit(&mut self, digit: u8) -> bool
pub fn type_digit(&mut self, digit: u8) -> bool
Type one ASCII digit into the focused segment.
The segment advances as soon as no further digit could fit: a month of 4, a day of 9,
or a complete four-digit year all move editing to the next segment immediately.
Sourcepub fn type_character(&mut self, character: char) -> bool
pub fn type_character(&mut self, character: char) -> bool
Type one printable character. Only ASCII digits change a date field.
Trait Implementations§
Source§impl Clone for DateFieldState
impl Clone for DateFieldState
Source§fn clone(&self) -> DateFieldState
fn clone(&self) -> DateFieldState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DateFieldState
impl Debug for DateFieldState
Source§impl Default for DateFieldState
impl Default for DateFieldState
Source§impl PartialEq for DateFieldState
impl PartialEq for DateFieldState
impl StructuralPartialEq for DateFieldState
Auto Trait Implementations§
impl Freeze for DateFieldState
impl RefUnwindSafe for DateFieldState
impl Send for DateFieldState
impl Sync for DateFieldState
impl Unpin for DateFieldState
impl UnsafeUnpin for DateFieldState
impl UnwindSafe for DateFieldState
Blanket Implementations§
impl<T> Action for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.