comparison dynamin/gui/container.d @ 5:4029d5af7542

Add blank lines and rewrap some comments.
author Jordan Miner <jminer7@gmail.com>
date Sat, 20 Jun 2009 12:26:40 -0500
parents aa4efef0f0b1
children b621b528823d
comparison
equal deleted inserted replaced
4:fc2420d39e3c 5:4029d5af7542
112 e.location = e.location + c.location; 112 e.location = e.location + c.location;
113 } else { 113 } else {
114 super.dispatchMouseDragged(e); 114 super.dispatchMouseDragged(e);
115 } 115 }
116 } 116 }
117
117 /** 118 /**
118 * Gets the child control at the specified point. If there are 119 * Gets the child control at the specified point. If there are
119 * multiple child controls at the point, the topmost control is returned. 120 * multiple child controls at the point, the topmost control is returned.
120 * If there is no child control at the point, null is returned. The returned 121 * If there is no child control at the point, null is returned. The returned
121 * control, if any, is a direct child of this container. 122 * control, if any, is a direct child of this container.
136 if(_children[i].contains(pt)) 137 if(_children[i].contains(pt))
137 return _children[i]; 138 return _children[i];
138 } 139 }
139 return null; 140 return null;
140 } 141 }
142
141 /** 143 /**
142 * Never returns null. If there is no descendant at the specified point, 144 * Never returns null. If there is no descendant at the specified point,
143 * this container will be returned. 145 * this container will be returned.
144 */ 146 */
145 Control getDescendantAtPoint(real[] pt) { 147 Control getDescendantAtPoint(real[] pt) {
165 } else { 167 } else {
166 return child; 168 return child;
167 } 169 }
168 } 170 }
169 } 171 }
172
170 /** 173 /**
171 * Gets or sets the minimum size of this window. A minimum width or 174 * Gets or sets the minimum size of this window. A minimum width or
172 * height of 0 means that there is no minimum width or height. 175 * height of 0 means that there is no minimum width or height.
173 * The default is Size(0, 0). 176 * The default is Size(0, 0).
174 */ 177 */
185 } 188 }
186 /// 189 ///
187 real minWidth() { return _minSize.width; } 190 real minWidth() { return _minSize.width; }
188 /// 191 ///
189 real minHeight() { return _minSize.height; } 192 real minHeight() { return _minSize.height; }
193
190 /** 194 /**
191 * Gets or sets the maximum size of this window. A maximum width or 195 * Gets or sets the maximum size of this window. A maximum width or
192 * height of 0 means that there is no maximum width or height. 196 * height of 0 means that there is no maximum width or height.
193 * The default is Size(0, 0). 197 * The default is Size(0, 0).
194 */ 198 */
205 } 209 }
206 /// 210 ///
207 real maxWidth() { return _maxSize.width; } 211 real maxWidth() { return _maxSize.width; }
208 /// 212 ///
209 real maxHeight() { return _maxSize.height; } 213 real maxHeight() { return _maxSize.height; }
214
210 /** 215 /**
211 * Causes this container to position its child controls. Called on every 216 * Causes this container to position its child controls. Called on every
212 * resize. Usually, this function will get each child's best size, and 217 * resize. Usually, this function will get each child's best size, and
213 * then set each child's location and height. The definition in Container 218 * then set each child's location and height. The definition in Container
214 * is empty, as it is intended for subclasses to override. 219 * is empty, as it is intended for subclasses to override.
215 */ 220 */
216 void layout() { 221 void layout() {
217 } 222 }
223
218 protected void add(Control child) { 224 protected void add(Control child) {
219 if(child.parent) 225 if(child.parent)
220 child.parent.remove(child); 226 child.parent.remove(child);
221 _children.add(child); 227 _children.add(child);
222 child.parent = this; 228 child.parent = this;
223 repaint(); 229 repaint();
224 //ControlAdded(EventArgs e); // TODO: add event 230 //ControlAdded(EventArgs e); // TODO: add event
225 } 231 }
232
226 protected void remove(Control child) { 233 protected void remove(Control child) {
227 _children.remove(child); 234 _children.remove(child);
228 child.parent = null; 235 child.parent = null;
229 repaint(); 236 repaint();
230 //ControlRemoved(EventArgs e); // TODO: add event 237 //ControlRemoved(EventArgs e); // TODO: add event
231 } 238 }
239
232 protected int opApply(int delegate(inout Control item) dg) { 240 protected int opApply(int delegate(inout Control item) dg) {
233 for(uint i = 0; i < _children.count; ++i) { 241 for(uint i = 0; i < _children.count; ++i) {
234 auto tmp = _children[i]; 242 auto tmp = _children[i];
235 if(int result = dg(tmp)) 243 if(int result = dg(tmp))
236 return result; 244 return result;