comparison dwt/widgets/Caret.d @ 15:2952d5604c0a

Ported some widgets, added some stuff to the runtime bindings
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 29 Aug 2008 21:46:05 +0200
parents 380af2bdd8e5
children 5b53d338c709
comparison
equal deleted inserted replaced
14:762fbe6f17d3 15:2952d5604c0a
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
10 *******************************************************************************/ 13 *******************************************************************************/
11 module dwt.widgets.Caret; 14 module dwt.widgets.Caret;
12
13 import dwt.dwthelper.utils;
14 15
15 16
16 import dwt.DWT; 17 import dwt.DWT;
17 import dwt.DWTException; 18 import dwt.DWTException;
18 import dwt.graphics.Font; 19 import dwt.graphics.Font;
19 import dwt.graphics.Image; 20 import dwt.graphics.Image;
20 import dwt.graphics.Point; 21 import dwt.graphics.Point;
21 import dwt.graphics.Rectangle; 22 import dwt.graphics.Rectangle;
22 import dwt.internal.cocoa.NSRect; 23 import dwt.internal.cocoa.NSRect;
23 import dwt.internal.cocoa.NSSize; 24 import dwt.internal.cocoa.NSSize;
25
26 import dwt.dwthelper.utils;
27 import dwt.widgets.Canvas;
28 import dwt.widgets.Widget;
24 29
25 /** 30 /**
26 * Instances of this class provide an i-beam that is typically used 31 * Instances of this class provide an i-beam that is typically used
27 * as the insertion point for text. 32 * as the insertion point for text.
28 * <dl> 33 * <dl>
34 * <p> 39 * <p>
35 * IMPORTANT: This class is intended to be subclassed <em>only</em> 40 * IMPORTANT: This class is intended to be subclassed <em>only</em>
36 * within the DWT implementation. 41 * within the DWT implementation.
37 * </p> 42 * </p>
38 */ 43 */
39 public class Caret extends Widget { 44 public class Caret : Widget {
40 Canvas parent; 45 Canvas parent;
41 int x, y, width, height; 46 int x, y, width, height;
42 bool isVisible, isShowing; 47 bool isVisible, isShowing;
43 int blinkRate; 48 int blinkRate;
44 Image image; 49 Image image;
72 * 77 *
73 * @see DWT 78 * @see DWT
74 * @see Widget#checkSubclass 79 * @see Widget#checkSubclass
75 * @see Widget#getStyle 80 * @see Widget#getStyle
76 */ 81 */
77 public Caret (Canvas parent, int style) { 82 public this (Canvas parent, int style) {
78 super (parent, style); 83 super (parent, style);
79 this.parent = parent; 84 this.parent = parent;
80 createWidget (); 85 createWidget ();
81 } 86 }
82 87
101 if (parent.isDisposed ()) return false; 106 if (parent.isDisposed ()) return false;
102 int nWidth = width, nHeight = height; 107 int nWidth = width, nHeight = height;
103 if (nWidth <= 0) nWidth = DEFAULT_WIDTH; 108 if (nWidth <= 0) nWidth = DEFAULT_WIDTH;
104 if (image !is null) { 109 if (image !is null) {
105 NSSize size = image.handle.size(); 110 NSSize size = image.handle.size();
106 nWidth = (int)size.width; 111 nWidth = cast(int)size.width;
107 nHeight = (int)size.height; 112 nHeight = cast(int)size.height;
108 } 113 }
109 NSRect rect = new NSRect(); 114 NSRect rect = NSRect();
110 rect.x = x; 115 rect.x = x;
111 rect.y = y; 116 rect.y = y;
112 rect.width = nWidth; 117 rect.width = nWidth;
113 rect.height = nHeight; 118 rect.height = nHeight;
114 parent.view.setNeedsDisplayInRect(rect); 119 parent.view.setNeedsDisplayInRect(rect);