Wed, 09 Dec 2020 11:33:00 +0100
add .hgignore
0
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | using System; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | using System.Collections.Generic; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | using System.Linq; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | using System.Text; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | using System.Threading.Tasks; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | namespace UI |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | public class TextArea : System.Windows.Controls.TextBox |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | public TextArea(Container container, String text, bool textarea) : base() |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | bool fill = false; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | if (textarea) |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | AcceptsReturn = true; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | IsUndoEnabled = false; // we need our own undo stack |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | VerticalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | fill = true; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | else |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | MinWidth = 15; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | if (text != null) |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | Text = text; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | container.Add(this, fill); |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | // ------------------ UiText methods ------------------ |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | public void SetText(String str) |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | Text = str; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | public String GetText() |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | return Text; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | public String GetSubString(int begin, int end) |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | return null; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | public void Insert(int pos, String str) |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | public int Position() |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | return CaretIndex; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | public int Selection() |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | return 0; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | public int Length() |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | return Text.Length; |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | public void Remove(int begin, int end) |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | { |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | } |
804d8803eade
add existing toolkit source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | } |