Mercurial > projects > dwt-mac
comparison dwt/widgets/Caret.d @ 36:db5a898b2119
Fixed a lot of compile errors
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 07 Oct 2008 12:56:18 +0200 |
parents | 5b53d338c709 |
children | d8635bb48c7c |
comparison
equal
deleted
inserted
replaced
35:7d135fe0caf2 | 36:db5a898b2119 |
---|---|
42 * </p> | 42 * </p> |
43 */ | 43 */ |
44 public class Caret : Widget { | 44 public class Caret : Widget { |
45 Canvas parent; | 45 Canvas parent; |
46 int x, y, width, height; | 46 int x, y, width, height; |
47 bool isVisible, isShowing; | 47 bool isVisible_, isShowing; |
48 int blinkRate; | 48 int blinkRate; |
49 Image image; | 49 Image image; |
50 Font font; | 50 Font font; |
51 | 51 |
52 static final int DEFAULT_WIDTH = 1; | 52 static final int DEFAULT_WIDTH = 1; |
84 this.parent = parent; | 84 this.parent = parent; |
85 createWidget (); | 85 createWidget (); |
86 } | 86 } |
87 | 87 |
88 bool blinkCaret () { | 88 bool blinkCaret () { |
89 if (!isVisible) return true; | 89 if (!isVisible_) return true; |
90 if (!isShowing) return showCaret (); | 90 if (!isShowing) return showCaret (); |
91 if (blinkRate is 0) return true; | 91 if (blinkRate is 0) return true; |
92 return hideCaret (); | 92 return hideCaret (); |
93 } | 93 } |
94 | 94 |
95 void createWidget () { | 95 void createWidget () { |
96 super.createWidget (); | 96 super.createWidget (); |
97 blinkRate = display.getCaretBlinkTime (); | 97 blinkRate = display.getCaretBlinkTime (); |
98 isVisible = true; | 98 isVisible_ = true; |
99 if (parent.getCaret () is null) { | 99 if (parent.getCaret () is null) { |
100 parent.setCaret (this); | 100 parent.setCaret (this); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
246 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 246 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
247 * </ul> | 247 * </ul> |
248 */ | 248 */ |
249 public bool getVisible () { | 249 public bool getVisible () { |
250 checkWidget(); | 250 checkWidget(); |
251 return isVisible; | 251 return isVisible_; |
252 } | 252 } |
253 | 253 |
254 bool hideCaret () { | 254 bool hideCaret () { |
255 if (!isShowing) return true; | 255 if (!isShowing) return true; |
256 isShowing = false; | 256 isShowing = false; |
271 * | 271 * |
272 * @see #getVisible | 272 * @see #getVisible |
273 */ | 273 */ |
274 public bool isVisible () { | 274 public bool isVisible () { |
275 checkWidget(); | 275 checkWidget(); |
276 return isVisible && parent.isVisible () && parent.hasFocus (); | 276 return isVisible_ && parent.isVisible () && parent.hasFocus (); |
277 } | 277 } |
278 | 278 |
279 bool isFocusCaret () { | 279 bool isFocusCaret () { |
280 return this is display.currentCaret; | 280 return this is display.currentCaret; |
281 } | 281 } |
282 | 282 |
283 void killFocus () { | 283 void killFocus () { |
284 if (display.currentCaret !is this) return; | 284 if (display.currentCaret !is this) return; |
285 display.setCurrentCaret (null); | 285 display.setCurrentCaret (null); |
286 if (isVisible) hideCaret (); | 286 if (isVisible_) hideCaret (); |
287 } | 287 } |
288 | 288 |
289 void releaseParent () { | 289 void releaseParent () { |
290 super.releaseParent (); | 290 super.releaseParent (); |
291 if (this is parent.getCaret ()) parent.setCaret (null); | 291 if (this is parent.getCaret ()) parent.setCaret (null); |
319 */ | 319 */ |
320 public void setBounds (int x, int y, int width, int height) { | 320 public void setBounds (int x, int y, int width, int height) { |
321 checkWidget(); | 321 checkWidget(); |
322 if (this.x is x && this.y is y && this.width is width && this.height is height) return; | 322 if (this.x is x && this.y is y && this.width is width && this.height is height) return; |
323 bool isFocus = isFocusCaret (); | 323 bool isFocus = isFocusCaret (); |
324 if (isFocus && isVisible) hideCaret (); | 324 if (isFocus && isVisible_) hideCaret (); |
325 this.x = x; | 325 this.x = x; |
326 this.y = y; | 326 this.y = y; |
327 this.width = width; | 327 this.width = width; |
328 this.height = height; | 328 this.height = height; |
329 if (isFocus && isVisible) showCaret (); | 329 if (isFocus && isVisible_) showCaret (); |
330 } | 330 } |
331 | 331 |
332 /** | 332 /** |
333 * Sets the receiver's size and location to the rectangular | 333 * Sets the receiver's size and location to the rectangular |
334 * area specified by the argument. The <code>x</code> and | 334 * area specified by the argument. The <code>x</code> and |
349 } | 349 } |
350 | 350 |
351 void setFocus () { | 351 void setFocus () { |
352 if (display.currentCaret is this) return; | 352 if (display.currentCaret is this) return; |
353 display.setCurrentCaret (this); | 353 display.setCurrentCaret (this); |
354 if (isVisible) showCaret (); | 354 if (isVisible_) showCaret (); |
355 } | 355 } |
356 | 356 |
357 /** | 357 /** |
358 * Sets the font that the receiver will use to paint textual information | 358 * Sets the font that the receiver will use to paint textual information |
359 * to the font specified by the argument, or to the default font for that | 359 * to the font specified by the argument, or to the default font for that |
396 checkWidget(); | 396 checkWidget(); |
397 if (image !is null && image.isDisposed ()) { | 397 if (image !is null && image.isDisposed ()) { |
398 error (DWT.ERROR_INVALID_ARGUMENT); | 398 error (DWT.ERROR_INVALID_ARGUMENT); |
399 } | 399 } |
400 bool isFocus = isFocusCaret (); | 400 bool isFocus = isFocusCaret (); |
401 if (isFocus && isVisible) hideCaret (); | 401 if (isFocus && isVisible_) hideCaret (); |
402 this.image = image; | 402 this.image = image; |
403 if (isFocus && isVisible) showCaret (); | 403 if (isFocus && isVisible_) showCaret (); |
404 } | 404 } |
405 | 405 |
406 /** | 406 /** |
407 * Sets the receiver's location to the point specified by | 407 * Sets the receiver's location to the point specified by |
408 * the arguments which are relative to the receiver's | 408 * the arguments which are relative to the receiver's |
490 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 490 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
491 * </ul> | 491 * </ul> |
492 */ | 492 */ |
493 public void setVisible (bool visible) { | 493 public void setVisible (bool visible) { |
494 checkWidget(); | 494 checkWidget(); |
495 if (visible is isVisible) return; | 495 if (visible is isVisible_) return; |
496 isVisible = visible; | 496 isVisible_ = visible; |
497 if (!isFocusCaret ()) return; | 497 if (!isFocusCaret ()) return; |
498 if (isVisible) { | 498 if (isVisible_) { |
499 showCaret (); | 499 showCaret (); |
500 } else { | 500 } else { |
501 hideCaret (); | 501 hideCaret (); |
502 } | 502 } |
503 } | 503 } |