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.core.controls.containercontrol; 10 11 public import dguihub.core.controls.reflectedcontrol; 12 13 abstract class ContainerControl : ReflectedControl { 14 protected Collection!(Control) _childControls; 15 16 @property public final bool rtlLayout() { 17 return cast(bool)(this.getExStyle() & WS_EX_LAYOUTRTL); 18 } 19 20 @property public final void rtlLayout(bool b) { 21 this.setExStyle(WS_EX_LAYOUTRTL, b); 22 } 23 24 @property public final Control[] controls() { 25 if (this._childControls) { 26 return this._childControls.get(); 27 } 28 29 return null; 30 } 31 32 private void addChildControl(Control c) { 33 if (!this._childControls) { 34 this._childControls = new Collection!(Control); 35 } 36 37 this._childControls.add(c); 38 39 if (this.created) { 40 c.show(); 41 } 42 } 43 44 protected void doChildControls() { 45 if (this._childControls) { 46 foreach (Control c; this._childControls) { 47 if (!c.created) //Extra Check: Avoid creating duplicate components (added at runtime) 48 { 49 c.show(); 50 } 51 } 52 } 53 } 54 55 protected override void createControlParams(ref CreateControlParams ccp) { 56 this.setStyle(WS_CLIPCHILDREN, true); 57 this.setExStyle(WS_EX_CONTROLPARENT, true); 58 59 super.createControlParams(ccp); 60 } 61 62 protected override void onDGuiMessage(ref Message m) { 63 switch (m.msg) { 64 case DGUI_ADDCHILDCONTROL: 65 this.addChildControl(winCast!(Control)(m.wParam)); 66 break; 67 68 default: 69 break; 70 } 71 72 super.onDGuiMessage(m); 73 } 74 75 protected override void onHandleCreated(EventArgs e) { 76 this.doChildControls(); 77 super.onHandleCreated(e); 78 } 79 }