1 /** DGui project file.
2
3 Copyright: Trogu Antonio Davide 2011-2013
4
5 License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
6
7 Authors: Trogu Antonio Davide
8 */
9 module dgui.textbox;
10
11 import dgui.core.controls.textcontrol;
12
13 enum CharacterCasing
14 {
15 normal = 0,
16 uppercase = ES_UPPERCASE,
17 lowercase = ES_LOWERCASE,
18 }
19
20 class TextBox: TextControl
21 {
22 private CharacterCasing _chChasing = CharacterCasing.normal;
23 private uint _maxLength = 0;
24
25 @property public final bool multiline()
26 {
27 return cast(bool)(this.getStyle() & ES_MULTILINE);
28 }
29
30 @property public final void multiline(bool b)
31 {
32 this.setStyle(ES_MULTILINE, b);
33 }
34
35 @property public final uint maxLength()
36 {
37 if(!this._maxLength)
38 {
39 if(this.getStyle() & ES_MULTILINE)
40 {
41 return 0xFFFFFFFF;
42 }
43 else
44 {
45 return 0xFFFFFFFE;
46 }
47 }
48
49 return this._maxLength;
50 }
51
52 @property public final void maxLength(uint len)
53 {
54 this._maxLength = len;
55
56 if(!len)
57 {
58 if(this.getStyle() & ES_MULTILINE)
59 {
60 len = 0xFFFFFFFF;
61 }
62 else
63 {
64 len = 0xFFFFFFFE;
65 }
66 }
67
68 if(this.created)
69 {
70 this.sendMessage(EM_SETLIMITTEXT, len, 0);
71 }
72 }
73
74 @property public final CharacterCasing characterCasing()
75 {
76 return this._chChasing;
77 }
78
79 @property public final void characterCasing(CharacterCasing ch)
80 {
81 this._chChasing = ch;
82
83 if(this.created)
84 {
85 this.setStyle(this._chChasing, false); //Remove Old Style
86 this.setStyle(ch, true); //Add New Style
87 }
88 }
89
90 @property public final void numbersOnly(bool b)
91 {
92 this.setStyle(ES_NUMBER, b);
93 }
94
95 @property public final void passwordText(bool b)
96 {
97 this.setStyle(ES_PASSWORD, b);
98 }
99
100 protected override void createControlParams(ref CreateControlParams ccp)
101 {
102 this.setExStyle(WS_EX_CLIENTEDGE, true);
103 this.setStyle(ES_AUTOHSCROLL | this._chChasing, true);
104 ccp.superclassName = WC_EDIT;
105 ccp.className = WC_DEDIT;
106
107 this.height = 20; //E questo cos'รจ?
108 super.createControlParams(ccp);
109 }
110
111 protected override void onHandleCreated(EventArgs e)
112 {
113 if(this._maxLength)
114 {
115 this.sendMessage(EM_SETLIMITTEXT, this._maxLength, 0);
116 }
117
118 super.onHandleCreated(e);
119 }
120 }