comparison dwt/custom/ViewFormLayout.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 380af2bdd8e5
children a9ab4c738ed8
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
20 * @see ViewForm 20 * @see ViewForm
21 */ 21 */
22 class ViewFormLayout : Layout { 22 class ViewFormLayout : Layout {
23 23
24 protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) { 24 protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) {
25 ViewForm form = (ViewForm)composite; 25 ViewForm form = cast(ViewForm)composite;
26 Control left = form.topLeft; 26 Control left = form.topLeft;
27 Control center = form.topCenter; 27 Control center = form.topCenter;
28 Control right = form.topRight; 28 Control right = form.topRight;
29 Control content = form.content; 29 Control content = form.content;
30 30
84 Object data = control.getLayoutData(); 84 Object data = control.getLayoutData();
85 if (data is null || !(data instanceof CLayoutData)) { 85 if (data is null || !(data instanceof CLayoutData)) {
86 data = new CLayoutData(); 86 data = new CLayoutData();
87 control.setLayoutData(data); 87 control.setLayoutData(data);
88 } 88 }
89 return ((CLayoutData)data).computeSize(control, wHint, hHint, flushCache); 89 return (cast(CLayoutData)data).computeSize(control, wHint, hHint, flushCache);
90 } 90 }
91 91
92 int computeTrim(Control c) { 92 int computeTrim(Control c) {
93 if (c instanceof Scrollable) { 93 if (c instanceof Scrollable) {
94 Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0); 94 Rectangle rect = (cast(Scrollable) c).computeTrim (0, 0, 0, 0);
95 return rect.width; 95 return rect.width;
96 } 96 }
97 return c.getBorderWidth () * 2; 97 return c.getBorderWidth () * 2;
98 } 98 }
99 99
100 protected bool flushCache(Control control) { 100 protected bool flushCache(Control control) {
101 Object data = control.getLayoutData(); 101 Object data = control.getLayoutData();
102 if (data !is null && data instanceof CLayoutData) ((CLayoutData)data).flushCache(); 102 if (data !is null && data instanceof CLayoutData) (cast(CLayoutData)data).flushCache();
103 return true; 103 return true;
104 } 104 }
105 105
106 protected void layout(Composite composite, bool flushCache) { 106 protected void layout(Composite composite, bool flushCache) {
107 ViewForm form = (ViewForm)composite; 107 ViewForm form = cast(ViewForm)composite;
108 Control left = form.topLeft; 108 Control left = form.topLeft;
109 Control center = form.topCenter; 109 Control center = form.topCenter;
110 Control right = form.topRight; 110 Control right = form.topRight;
111 Control content = form.content; 111 Control content = form.content;
112 112
174 center.setBounds(x, y, centerSize.x, topHeight); 174 center.setBounds(x, y, centerSize.x, topHeight);
175 x -= form.horizontalSpacing; 175 x -= form.horizontalSpacing;
176 } 176 }
177 if (left !is null && !left.isDisposed()) { 177 if (left !is null && !left.isDisposed()) {
178 top = true; 178 top = true;
179 Rectangle trim = left instanceof Composite ? ((Composite)left).computeTrim(0, 0, 0, 0) : new Rectangle(0, 0, 0, 0); 179 Rectangle trim = left instanceof Composite ? (cast(Composite)left).computeTrim(0, 0, 0, 0) : new Rectangle(0, 0, 0, 0);
180 int w = x - rect.x - form.marginWidth - form.highlight - trim.width; 180 int w = x - rect.x - form.marginWidth - form.highlight - trim.width;
181 int h = topHeight - trim.height; 181 int h = topHeight - trim.height;
182 leftSize = computeChildSize(left, w, h, false); 182 leftSize = computeChildSize(left, w, h, false);
183 left.setBounds(rect.x + form.marginWidth + form.highlight, y, leftSize.x, topHeight); 183 left.setBounds(rect.x + form.marginWidth + form.highlight, y, leftSize.x, topHeight);
184 } 184 }