diff dwt/custom/ViewForm.d @ 41:6337764516f1

Sync dwt/custom with dwt-linux (took copy of complete folder)
author Frank Benoit <benoit@tionex.de>
date Tue, 07 Oct 2008 16:29:55 +0200
parents e831403a80a9
children
line wrap: on
line diff
--- a/dwt/custom/ViewForm.d	Tue Oct 07 14:41:31 2008 +0200
+++ b/dwt/custom/ViewForm.d	Tue Oct 07 16:29:55 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,17 +7,32 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
-module dwt.custom;
+module dwt.custom.ViewForm;
+
+import dwt.dwthelper.utils;
+
 
 
-import dwt.graphics.*;
-import dwt.widgets.*;
-import dwt.*;
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Color;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Event;
+import dwt.widgets.Layout;
+import dwt.widgets.Listener;
+import dwt.custom.ViewFormLayout;
 
 /**
  * Instances of this class implement a Composite that positions and sizes
- * children and allows programmatic control of layout and border parameters. 
+ * children and allows programmatic control of layout and border parameters.
  * ViewForm is used in the workbench to lay out a view's label/menu/toolbar
  * local bar.
  * <p>
@@ -28,11 +43,13 @@
  * <dt><b>Styles:</b></dt>
  * <dd>BORDER, FLAT</dd>
  * <dt><b>Events:</b></dt>
- * <dd>cast(None)</dd>
+ * <dd>(None)</dd>
  * </dl>
  * <p>
  * IMPORTANT: This class is <em>not</em> intended to be subclassed.
  * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
  */
 
 public class ViewForm : Composite {
@@ -66,45 +83,45 @@
      * The default value is 1.
      */
     public int verticalSpacing = 1;
-    
+
     /**
      * Color of innermost line of drop shadow border.
-     * 
+     *
      * NOTE This field is badly named and can not be fixed for backwards compatibility.
      * It should be capitalized.
-     * 
+     *
      * @deprecated
      */
-    public static RGB borderInsideRGB  = new RGB (132, 130, 132);
+    public static RGB borderInsideRGB;
     /**
      * Color of middle line of drop shadow border.
-     * 
+     *
      * NOTE This field is badly named and can not be fixed for backwards compatibility.
      * It should be capitalized.
-     * 
+     *
      * @deprecated
      */
-    public static RGB borderMiddleRGB  = new RGB (143, 141, 138);
+    public static RGB borderMiddleRGB;
     /**
      * Color of outermost line of drop shadow border.
-     * 
+     *
      * NOTE This field is badly named and can not be fixed for backwards compatibility.
      * It should be capitalized.
-     * 
+     *
      * @deprecated
      */
-    public static RGB borderOutsideRGB = new RGB (171, 168, 165);
-    
+    public static RGB borderOutsideRGB;
+
     // DWT widgets
     Control topLeft;
     Control topCenter;
     Control topRight;
     Control content;
-    
+
     // Configuration and state info
     bool separateTopCenter = false;
     bool showBorder = false;
-    
+
     int separator = -1;
     int borderTop = 0;
     int borderBottom = 0;
@@ -112,19 +129,26 @@
     int borderRight = 0;
     int highlight = 0;
     Point oldSize;
-    
+
     Color selectionBackground;
-    
+
     static final int OFFSCREEN = -200;
     static final int BORDER1_COLOR = DWT.COLOR_WIDGET_NORMAL_SHADOW;
     static final int SELECTION_BACKGROUND = DWT.COLOR_LIST_BACKGROUND;
+
+
+    static this(){
+        borderInsideRGB  = new RGB (132, 130, 132);
+        borderMiddleRGB  = new RGB (143, 141, 138);
+        borderOutsideRGB = new RGB (171, 168, 165);
+    }
 /**
  * Constructs a new instance of this class given its parent
  * and a style value describing its behavior and appearance.
  * <p>
  * The style value is either one of the style constants defined in
  * class <code>DWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together 
+ * class, or must be built by <em>bitwise OR</em>'ing together
  * (that is, using the <code>int</code> "|" operator) two or more
  * of those <code>DWT</code> style constants. The class description
  * lists the style constants that are applicable to the class.
@@ -144,25 +168,26 @@
  * @see DWT#BORDER
  * @see DWT#FLAT
  * @see #getStyle()
- */     
+ */
 public this(Composite parent, int style) {
     super(parent, checkStyle(style));
     super.setLayout(new ViewFormLayout());
-    
+
     setBorderVisible((style & DWT.BORDER) !is 0);
-    
-    Listener listener = new Listener() {
+
+    Listener listener = new class() Listener {
         public void handleEvent(Event e) {
             switch (e.type) {
                 case DWT.Dispose: onDispose(); break;
                 case DWT.Paint: onPaint(e.gc); break;
                 case DWT.Resize: onResize(); break;
+                default:
             }
         }
     };
-    
-    int[] events = new int[] {DWT.Dispose, DWT.Paint, DWT.Resize};
-    
+
+    int[] events = [DWT.Dispose, DWT.Paint, DWT.Resize];
+
     for (int i = 0; i < events.length; i++) {
         addListener(events[i], listener);
     }
@@ -176,12 +201,12 @@
 //protected void checkSubclass () {
 //  String name = getClass().getName ();
 //  String validName = ViewForm.class.getName();
-//  if (!validName.opEquals(name)) {
+//  if (!validName.equals(name)) {
 //      DWT.error (DWT.ERROR_INVALID_SUBCLASS);
 //  }
 //}
 
-public Rectangle computeTrim (int x, int y, int width, int height) {
+public override Rectangle computeTrim (int x, int y, int width, int height) {
     checkWidget ();
     int trimX = x - borderLeft - highlight;
     int trimY = y - borderTop - highlight;
@@ -189,7 +214,7 @@
     int trimHeight = height + borderTop + borderBottom + 2*highlight;
     return new Rectangle(trimX, trimY, trimWidth, trimHeight);
 }
-public Rectangle getClientArea() {
+public override Rectangle getClientArea() {
     checkWidget();
     Rectangle clientArea = super.getClientArea();
     clientArea.x += borderLeft;
@@ -200,7 +225,7 @@
 }
 /**
 * Returns the content area.
-* 
+*
 * @return the control in the content area of the pane or null
 */
 public Control getContent() {
@@ -210,7 +235,7 @@
 /**
 * Returns Control that appears in the top center of the pane.
 * Typically this is a toolbar.
-* 
+*
 * @return the control in the top center of the pane or null
 */
 public Control getTopCenter() {
@@ -220,7 +245,7 @@
 /**
 * Returns the Control that appears in the top left corner of the pane.
 * Typically this is a label such as CLabel.
-* 
+*
 * @return the control in the top left corner of the pane or null
 */
 public Control getTopLeft() {
@@ -230,7 +255,7 @@
 /**
 * Returns the control in the top right corner of the pane.
 * Typically this is a Close button or a composite with a Menu and Close button.
-* 
+*
 * @return the control in the top right corner of the pane or null
 */
 public Control getTopRight() {
@@ -257,9 +282,9 @@
             int y1 = 1;
             int x2 = size.x - 1;
             int y2 = size.y - 1;
-            int[] shape = new int[] {x1,y1, x2,y1, x2,y2, x1,y2, x1,y1+highlight,
-                               x1+highlight,y1+highlight, x1+highlight,y2-highlight, 
-                               x2-highlight,y2-highlight, x2-highlight,y1+highlight, x1,y1+highlight};
+            int[] shape = [x1,y1, x2,y1, x2,y2, x1,y2, x1,y1+highlight,
+                               x1+highlight,y1+highlight, x1+highlight,y2-highlight,
+                               x2-highlight,y2-highlight, x2-highlight,y1+highlight, x1,y1+highlight];
             Color highlightColor = getDisplay().getSystemColor(DWT.COLOR_LIST_SELECTION);
             gc.setBackground(highlightColor);
             gc.fillPolygon(shape);
@@ -280,16 +305,16 @@
         if (oldSize.x < size.x) {
             width = size.x - oldSize.x + borderRight + highlight;
         } else if (oldSize.x > size.x) {
-            width = borderRight + highlight;            
+            width = borderRight + highlight;
         }
         redraw(size.x - width, 0, width, size.y, false);
-        
+
         int height = 0;
         if (oldSize.y < size.y) {
-            height = size.y - oldSize.y + borderBottom + highlight;     
+            height = size.y - oldSize.y + borderBottom + highlight;
         }
         if (oldSize.y > size.y) {
-            height = borderBottom + highlight;      
+            height = borderBottom + highlight;
         }
         redraw(0, size.y - height, size.x, height, false);
     }
@@ -297,11 +322,11 @@
 }
 /**
 * Sets the content.
-* Setting the content to null will remove it from 
+* Setting the content to null will remove it from
 * the pane - however, the creator of the content must dispose of the content.
-* 
+*
 * @param content the control to be displayed in the content area or null
-* 
+*
 * @exception DWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -334,7 +359,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public void setLayout (Layout layout) {
+public override void setLayout (Layout layout) {
     checkWidget();
     return;
 }
@@ -348,11 +373,11 @@
 /**
 * Set the control that appears in the top center of the pane.
 * Typically this is a toolbar.
-* The topCenter is optional.  Setting the topCenter to null will remove it from 
+* The topCenter is optional.  Setting the topCenter to null will remove it from
 * the pane - however, the creator of the topCenter must dispose of the topCenter.
-* 
+*
 * @param topCenter the control to be displayed in the top center or null
-* 
+*
 * @exception DWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -374,11 +399,11 @@
 /**
 * Set the control that appears in the top left corner of the pane.
 * Typically this is a label such as CLabel.
-* The topLeft is optional.  Setting the top left control to null will remove it from 
+* The topLeft is optional.  Setting the top left control to null will remove it from
 * the pane - however, the creator of the control must dispose of the control.
-* 
+*
 * @param c the control to be displayed in the top left corner or null
-* 
+*
 * @exception DWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -400,11 +425,11 @@
 /**
 * Set the control that appears in the top right corner of the pane.
 * Typically this is a Close button or a composite with a Menu and Close button.
-* The topRight is optional.  Setting the top right control to null will remove it from 
+* The topRight is optional.  Setting the top right control to null will remove it from
 * the pane - however, the creator of the control must dispose of the control.
-* 
+*
 * @param c the control to be displayed in the top right corner or null
-* 
+*
 * @exception DWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -425,9 +450,9 @@
 }
 /**
 * Specify whether the border should be displayed or not.
-* 
+*
 * @param show true if the border should be displayed
-* 
+*
 * @exception DWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -436,11 +461,11 @@
 public void setBorderVisible(bool show) {
     checkWidget();
     if (showBorder is show) return;
-    
+
     showBorder = show;
     if (showBorder) {
         borderLeft = borderTop = borderRight = borderBottom = 1;
-        if ((getStyle() & DWT.FLAT)== 0) highlight = 2;
+        if ((getStyle() & DWT.FLAT)is 0) highlight = 2;
     } else {
         borderBottom = borderTop = borderLeft = borderRight = 0;
         highlight = 0;
@@ -449,12 +474,12 @@
     redraw();
 }
 /**
-* If true, the topCenter will always appear on a separate line by itself, otherwise the 
+* If true, the topCenter will always appear on a separate line by itself, otherwise the
 * topCenter will appear in the top row if there is room and will be moved to the second row if
 * required.
-* 
+*
 * @param show true if the topCenter will always appear on a separate line by itself
-* 
+*
 * @exception DWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>