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
use crate::{common::*, display::*, geom::*, text::*, util::inheritance::*};
class! {
/// Represents a text field of fixed size.
///
/// # HTML support
///
/// `TextField` supports assigning a limited dialect of HTML text
/// through its `set_html()` method.
/// It supports HTML entities and a subset of the HTML elements.
///
/// | Tag | Description |
/// | ------------------ | ----------------------------------------------- |
/// | `<b></b>` | Bold |
/// | `<i></i>` | Italic |
/// | `<s></s>` | Strikethrough |
/// | `<u></u>` | Underline text |
/// | `<img>` | Image, with support for `http:`, `https:`, `data:` and `file:` URLs |
/// | `<sup></sup>` | Superscript |
/// | `<sub></sub>` | Subscript |
/// | `<a></a>` | Anchor, supporting the `href` attribute |
/// | `<ul></ul>` | Unordered list |
/// | `<ol></ol>` | Ordered list |
/// | `<li></li>` | List item |
/// | `<p></p>` | Paragraph |
/// | `<center></center>` | Centered content |
/// | `<hN></hN>` | Heading title level *N*, where *N* is one based |
/// | `<hr>` | Horizontal ruler |
/// | `<br>` | Break |
///
pub struct TextField: DisplayObject < Node {
pub size: Vector2d = Vector2d(100.0, 50.0),
pub ref style_sheet: StyleSheetContainer = default(),
pub horizontal_alignment: TextHorizontalAlignment = TextHorizontalAlignment::Left,
pub vertical_alignment: TextVerticalAlignment = TextVerticalAlignment::Top,
/// Horizontal scroll, in pixels.
pub horizontal_scroll: f64 = 0.0,
/// Vertical scroll, in pixels.
pub vertical_scroll: f64 = 0.0,
}
pub fn constructor(text: String) {
super();
// this.set_text(text.clone());
}
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum TextHorizontalAlignment {
Left,
Center,
Right,
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum TextVerticalAlignment {
Top,
Center,
Bottom,
}