1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! Class-specific widget traits
//!
//! These traits provide generic ways to interact with common widget properties,
//! e.g. to read the text of a `Label` or set the state of a `CheckBox`.
use crate AccelString;
use crate TkAction;
/// Read / write a boolean value
///
/// The value `true` means *checked*, *selected* or *toggled on*.
/// Read an unformatted `&str`
///
/// For write-support, see [`HasString`]. Alternatively, for e.g.
/// `Label<&'static str>`, the `set_text` method which may be used, but in
/// practice this is rarely sufficient.
/// Read / write an unformatted `String`
/*TODO: HasHtml with get and set?
/// Read / write a formatted `String`
pub trait HasFormatted {
/// Get text as a `String`
fn get_formatted(&self) -> FormattedString;
/// Set from a formatted string
fn set_formatted<S: Into<FormattedString>>(&mut self, text: S) -> TkAction
where
Self: Sized,
{
self.set_formatted_string(text.into())
}
/// Set from a formatted string
fn set_formatted_string(&mut self, text: FormattedString) -> TkAction;
}
*/
/// Set a control label
///
/// Control labels do not support rich-text formatting but do support
/// accelerator keys, identified via a `&` prefix (e.g. `&File`).