Mercurial > projects > dwt-win
comparison dwt/layout/FormAttachment.d @ 184:4d06074bb1af
sync with dwt-linux
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 10 Mar 2008 16:49:04 +0100 |
parents | 69c0e2fa46b9 |
children | bcdc37794717 |
comparison
equal
deleted
inserted
replaced
183:c4643827733c | 184:4d06074bb1af |
---|---|
183 * @param numerator the numerator of the position | 183 * @param numerator the numerator of the position |
184 * @param denominator the denominator of the position | 184 * @param denominator the denominator of the position |
185 * @param offset the offset of the side from the position | 185 * @param offset the offset of the side from the position |
186 */ | 186 */ |
187 public this (int numerator, int denominator, int offset) { | 187 public this (int numerator, int denominator, int offset) { |
188 if (denominator is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); | 188 if (denominator == 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); |
189 this.numerator = numerator; | 189 this.numerator = numerator; |
190 this.denominator = denominator; | 190 this.denominator = denominator; |
191 this.offset = offset; | 191 this.offset = offset; |
192 } | 192 } |
193 | 193 |
242 if (m < n) { | 242 if (m < n) { |
243 temp = m; | 243 temp = m; |
244 m = n; | 244 m = n; |
245 n = temp; | 245 n = temp; |
246 } | 246 } |
247 while (n !is 0){ | 247 while (n != 0){ |
248 temp = m; | 248 temp = m; |
249 m = n; | 249 m = n; |
250 n = temp % n; | 250 n = temp % n; |
251 } | 251 } |
252 return m; | 252 return m; |
281 FormAttachment plus (int value) { | 281 FormAttachment plus (int value) { |
282 return new FormAttachment (numerator, denominator, offset + value); | 282 return new FormAttachment (numerator, denominator, offset + value); |
283 } | 283 } |
284 | 284 |
285 int solveX (int value) { | 285 int solveX (int value) { |
286 if (denominator is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); | 286 if (denominator == 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); |
287 return ((numerator * value) / denominator) + offset; | 287 return ((numerator * value) / denominator) + offset; |
288 } | 288 } |
289 | 289 |
290 int solveY (int value) { | 290 int solveY (int value) { |
291 if (numerator is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); | 291 if (numerator == 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO); |
292 return (value - offset) * denominator / numerator; | 292 return (value - offset) * denominator / numerator; |
293 } | 293 } |
294 | 294 |
295 /** | 295 /** |
296 * Returns a string containing a concise, human-readable | 296 * Returns a string containing a concise, human-readable |
297 * description of the receiver. | 297 * description of the receiver. |
298 * | 298 * |
299 * @return a string representation of the FormAttachment | 299 * @return a string representation of the FormAttachment |
300 */ | 300 */ |
301 public override char[] toString () { | 301 override public char[] toString () { |
302 char[] string = control !is null ? control.toString () : Format( "{}/{}", numerator, denominator ); | 302 char[] string = control != null ? control.toString () : Format( "{}/{}", numerator, denominator ); |
303 return Format("{{y = ({})x + {}}", string, ( offset >= 0 ? Format(")x + {}", offset ) : Format( ")x - {}", -offset))); | 303 return Format("{{y = ({})x + {}}", string, ( offset >= 0 ? Format(")x + {}", offset ) : Format( ")x - {}", -offset))); |
304 } | 304 } |
305 | 305 |
306 } | 306 } |