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 dguihub.textbox; 10 11 import dguihub.core.controls.textcontrol; 12 13 enum CharacterCasing { 14 normal = 0, 15 uppercase = ES_UPPERCASE, 16 lowercase = ES_LOWERCASE, 17 } 18 19 class TextBox : TextControl { 20 private CharacterCasing _chChasing = CharacterCasing.normal; 21 private uint _maxLength = 0; 22 23 @property public final bool multiline() { 24 return cast(bool)(this.getStyle() & ES_MULTILINE); 25 } 26 27 @property public final void multiline(bool b) { 28 this.setStyle(ES_MULTILINE, b); 29 } 30 31 @property public final uint maxLength() { 32 if (!this._maxLength) { 33 if (this.getStyle() & ES_MULTILINE) { 34 return 0xFFFFFFFF; 35 } else { 36 return 0xFFFFFFFE; 37 } 38 } 39 40 return this._maxLength; 41 } 42 43 @property public final void maxLength(uint len) { 44 this._maxLength = len; 45 46 if (!len) { 47 if (this.getStyle() & ES_MULTILINE) { 48 len = 0xFFFFFFFF; 49 } else { 50 len = 0xFFFFFFFE; 51 } 52 } 53 54 if (this.created) { 55 this.sendMessage(EM_SETLIMITTEXT, len, 0); 56 } 57 } 58 59 @property public final CharacterCasing characterCasing() { 60 return this._chChasing; 61 } 62 63 @property public final void characterCasing(CharacterCasing ch) { 64 this._chChasing = ch; 65 66 if (this.created) { 67 this.setStyle(this._chChasing, false); //Remove Old Style 68 this.setStyle(ch, true); //Add New Style 69 } 70 } 71 72 @property public final void numbersOnly(bool b) { 73 this.setStyle(ES_NUMBER, b); 74 } 75 76 @property public final void passwordText(bool b) { 77 this.setStyle(ES_PASSWORD, b); 78 } 79 80 protected override void createControlParams(ref CreateControlParams ccp) { 81 this.setExStyle(WS_EX_CLIENTEDGE, true); 82 this.setStyle(ES_AUTOHSCROLL | this._chChasing, true); 83 ccp.superclassName = WC_EDIT; 84 ccp.className = WC_DEDIT; 85 86 this.height = 20; //E questo cos'è? 87 super.createControlParams(ccp); 88 } 89 90 protected override void onHandleCreated(EventArgs e) { 91 if (this._maxLength) { 92 this.sendMessage(EM_SETLIMITTEXT, this._maxLength, 0); 93 } 94 95 super.onHandleCreated(e); 96 } 97 }