changeset 43:ecf39b275c8d

Caret
author Frank Benoit <benoit@tionex.de>
date Fri, 11 Jan 2008 05:22:12 +0100
parents 787b5413b0ce
children dfcb4aee42d4
files dwt/widgets/Caret.d todo.txt
diffstat 2 files changed, 67 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/Caret.d	Fri Jan 11 05:07:22 2008 +0100
+++ b/dwt/widgets/Caret.d	Fri Jan 11 05:22:12 2008 +0100
@@ -9,7 +9,8 @@
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
 module dwt.widgets.Caret;
-import dwt.graphics.Font;
+
+/+
 class Caret{
     int blinkRate;
     bool blinkCaret();
@@ -22,11 +23,16 @@
     bool isDisposed();
     public void setFont (Font font) ;
 }
-/+++
++/
 
-import dwt.*;
-import dwt.internal.gtk.*;
-import dwt.graphics.*;
+import dwt.SWT;
+import dwt.internal.gtk.OS;
+import dwt.graphics.Image;
+import dwt.graphics.Font;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Widget;
+import dwt.widgets.Canvas;
 
 /**
  * Instances of this class provide an i-beam that is typically used
@@ -42,10 +48,10 @@
  * within the SWT implementation.
  * </p>
  */
-public class Caret extends Widget {
+public class Caret : Widget {
 	Canvas parent;
 	int x, y, width, height;
-	boolean isVisible, isShowing;
+	bool isVisible_, isShowing;
 	int blinkRate;
 	Image image;
 	Font font;
@@ -78,45 +84,45 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Caret (Canvas parent, int style) {
+public this (Canvas parent, int style) {
 	super (parent, style);
 	this.parent = parent;
 	createWidget (0);
 }
 
-boolean blinkCaret () {
-	if (!isVisible) return true;
+bool blinkCaret () {
+	if (!isVisible_) return true;
 	if (!isShowing) return showCaret ();
-	if (blinkRate == 0) return true;
+	if (blinkRate is 0) return true;
 	return hideCaret ();
 }
 
 void createWidget (int index) {
 	super.createWidget (index);
 	blinkRate = display.getCaretBlinkTime ();
-	isVisible = true;
-	if (parent.getCaret () == null) {
+	isVisible_ = true;
+	if (parent.getCaret () is null) {
 		parent.setCaret (this);
 	}
 }
 
-boolean drawCaret () {
-	if (parent == null) return false;
+bool drawCaret () {
+	if (parent is null) return false;
 	if (parent.isDisposed ()) return false;
-	int /*long*/ window = parent.paintWindow ();
-	int /*long*/ gc = OS.gdk_gc_new (window);
-	GdkColor color = new GdkColor ();
-	color.red = (short) 0xffff;
-	color.green = (short) 0xffff;
-	color.blue = (short) 0xffff;
-	int /*long*/ colormap = OS.gdk_colormap_get_system ();
+	auto window = parent.paintWindow ();
+	auto gc = OS.gdk_gc_new (window);
+	GdkColor* color = new GdkColor ();
+	color.red = 0xffff;
+	color.green = 0xffff;
+	color.blue = 0xffff;
+	auto colormap = OS.gdk_colormap_get_system ();
 	OS.gdk_colormap_alloc_color (colormap, color, true, true);
 	OS.gdk_gc_set_foreground (gc, color);
 	OS.gdk_gc_set_function (gc, OS.GDK_XOR);
-	if (image != null && !image.isDisposed() && image.mask == 0) {
-		int[] width = new int[1]; int[] height = new int[1];
-	 	OS.gdk_drawable_get_size(image.pixmap, width, height);
-		OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, x, y, width[0], height[0]);
+	if (image !is null && !image.isDisposed() && image.mask is null) {
+		int width; int height;
+	 	OS.gdk_drawable_get_size(image.pixmap, &width, &height);
+		OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, x, y, width, height);
 	} else {
 		int nWidth = width, nHeight = height;
 		if (nWidth <= 0) nWidth = 1;
@@ -140,7 +146,7 @@
  */
 public Rectangle getBounds () {
 	checkWidget();
-	if (image != null) {
+	if (image !is null) {
 		Rectangle rect = image.getBounds ();
 		return new Rectangle (x, y, rect.width, rect.height);
 	}
@@ -159,7 +165,7 @@
  */
 public Font getFont () {
 	checkWidget();
-	if (font != null) return font;
+	if (font !is null) return font;
 	return parent.getFont ();
 }
 
@@ -221,7 +227,7 @@
  */
 public Point getSize () {
 	checkWidget();
-	if (image != null) {
+	if (image !is null) {
 		Rectangle rect = image.getBounds ();
 		return new Point (rect.width, rect.height);
 	}
@@ -245,12 +251,12 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public boolean getVisible () {
+public bool getVisible () {
 	checkWidget();
-	return isVisible;
+	return isVisible_;
 }
 
-boolean hideCaret () {
+bool hideCaret () {
 	if (!isShowing) return true;
 	isShowing = false;
 	return drawCaret ();
@@ -270,29 +276,29 @@
  *
  * @see #getVisible
  */
-public boolean isVisible () {
+public bool isVisible () {
 	checkWidget();
-	return isVisible && parent.isVisible () && parent.hasFocus ();
+	return isVisible_ && parent.isVisible () && parent.hasFocus ();
 }
 
-boolean isFocusCaret () {
-	return this == display.currentCaret;
+bool isFocusCaret () {
+	return this is display.currentCaret;
 }
 
 void killFocus () {
-	if (display.currentCaret != this) return;
+	if (display.currentCaret !is this) return;
 	display.setCurrentCaret (null);
-	if (isVisible) hideCaret ();
+	if (isVisible_) hideCaret ();
 }
 
 void releaseParent () {
 	super.releaseParent ();
-	if (this == parent.getCaret ()) parent.setCaret (null);
+	if (this is parent.getCaret ()) parent.setCaret (null);
 }
 
 void releaseWidget () {
 	super.releaseWidget ();
-	if (display.currentCaret == this) {
+	if (display.currentCaret is this) {
 		hideCaret ();
 		display.setCurrentCaret (null);
 	}
@@ -318,13 +324,13 @@
  */
 public void setBounds (int x, int y, int width, int height) {
 	checkWidget();
-	if (this.x == x && this.y == y && this.width == width && this.height == height) return;
-	boolean isFocus = isFocusCaret ();
-	if (isFocus && isVisible) hideCaret ();
+	if (this.x is x && this.y is y && this.width is width && this.height is height) return;
+	bool isFocus = isFocusCaret ();
+	if (isFocus && isVisible_) hideCaret ();
 	this.x = x; this.y = y;
 	this.width = width; this.height = height;
 	parent.updateCaret ();
-	if (isFocus && isVisible) showCaret ();
+	if (isFocus && isVisible_) showCaret ();
 }
 
 /**
@@ -342,14 +348,14 @@
  */
 public void setBounds (Rectangle rect) {
 	checkWidget();
-	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (rect is null) error (SWT.ERROR_NULL_ARGUMENT);
 	setBounds (rect.x, rect.y, rect.width, rect.height);
 }
 
 void setFocus () {
-	if (display.currentCaret == this) return;
+	if (display.currentCaret is this) return;
 	display.setCurrentCaret (this);
-	if (isVisible) showCaret ();
+	if (isVisible_) showCaret ();
 }
 
 /**
@@ -369,7 +375,7 @@
  */
 public void setFont (Font font) {
 	checkWidget();
-	if (font != null && font.isDisposed ()) {
+	if (font !is null && font.isDisposed ()) {
 		error (SWT.ERROR_INVALID_ARGUMENT);
 	}
 	this.font = font;
@@ -392,13 +398,13 @@
  */
 public void setImage (Image image) {
 	checkWidget();
-	if (image != null && image.isDisposed ()) {
+	if (image !is null && image.isDisposed ()) {
 		error (SWT.ERROR_INVALID_ARGUMENT);
 	}
-	boolean isFocus = isFocusCaret ();
-	if (isFocus && isVisible) hideCaret ();
+	bool isFocus = isFocusCaret ();
+	if (isFocus && isVisible_) hideCaret ();
 	this.image = image;
-	if (isFocus && isVisible) showCaret ();
+	if (isFocus && isVisible_) showCaret ();
 }
 
 /**
@@ -433,7 +439,7 @@
  */
 public void setLocation (Point location) {
 	checkWidget();
-	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (location is null) error (SWT.ERROR_NULL_ARGUMENT);
 	setLocation (location.x, location.y);
 }
 
@@ -468,7 +474,7 @@
  */
 public void setSize (Point size) {
 	checkWidget();
-	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (size is null) error (SWT.ERROR_NULL_ARGUMENT);
 	setSize (size.x, size.y);
 }
 
@@ -488,23 +494,22 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public void setVisible (boolean visible) {
+public void setVisible (bool visible) {
 	checkWidget();
-	if (visible == isVisible) return;
-	isVisible = visible;
+	if (visible is isVisible_) return;
+	isVisible_ = visible;
 	if (!isFocusCaret ()) return;
-	if (isVisible) {
+	if (isVisible_) {
 		showCaret ();
 	} else {
 		hideCaret ();
 	}
 }
 
-boolean showCaret () {
+bool showCaret () {
 	if (isShowing) return true;
 	isShowing = true;
 	return drawCaret ();
 }
 
 }
-+++/
\ No newline at end of file
--- a/todo.txt	Fri Jan 11 05:07:22 2008 +0100
+++ b/todo.txt	Fri Jan 11 05:22:12 2008 +0100
@@ -11,7 +11,8 @@
     Replace with prompt
         s/\<String\>/char[]/g       // replace only types, not comments or parts for identifiers
         s/is 0/is null/g            // replace only that one, that are reference types
-
+    Search for "int /*long*/"
+        -> "auto" if variable that gets initialized with something typed, e.g. result of method call.
 
 Next Steps:
     * accessibility package (independant)