changeset 46:798c6c92c4e2

fix indention
author Frank Benoit <benoit@tionex.de>
date Sun, 06 Apr 2008 15:31:24 +0200
parents 5a5be20dc120
children 596b23b3567f
files dwtsnippets/coolbar/Snippet140.d
diffstat 1 files changed, 68 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/dwtsnippets/coolbar/Snippet140.d	Sun Apr 06 15:26:23 2008 +0200
+++ b/dwtsnippets/coolbar/Snippet140.d	Sun Apr 06 15:31:24 2008 +0200
@@ -43,76 +43,78 @@
 
 
 void main () {
-        display = new Display ();
-        shell = new Shell (display);
-        shell.setLayout(new GridLayout());
-        coolBar = new CoolBar(shell, DWT.FLAT | DWT.BORDER);
-        coolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
-        ToolBar toolBar = new ToolBar(coolBar, DWT.FLAT | DWT.WRAP);
-        int minWidth = 0;
-        for (int j = 0; j < 5; j++) {
-                int width = 0;
-                ToolItem item = new ToolItem(toolBar, DWT.PUSH);
-                item.setText("B" ~ to!(char[])(j));
-                width = item.getWidth();
-                /* find the width of the widest tool */
-                if (width > minWidth) minWidth = width;
-        }
-        CoolItem coolItem = new CoolItem(coolBar, DWT.DROP_DOWN);
-        coolItem.setControl(toolBar);
-        Point size = toolBar.computeSize(DWT.DEFAULT, DWT.DEFAULT);
-        Point coolSize = coolItem.computeSize (size.x, size.y);
-        coolItem.setMinimumSize(minWidth, coolSize.y);
-        coolItem.setPreferredSize(coolSize);
-        coolItem.setSize(coolSize);
-        coolItem.addSelectionListener(new class() SelectionAdapter {
-                public void widgetSelected(SelectionEvent event) {
-                        if (event.detail == DWT.ARROW) {
-                                CoolItem item = cast(CoolItem) event.widget;
-                                Rectangle itemBounds = item.getBounds ();
-                                Point pt = coolBar.toDisplay(new Point(itemBounds.x, itemBounds.y));
-                                itemBounds.x = pt.x;
-                                itemBounds.y = pt.y;
-                                ToolBar bar = cast(ToolBar) item.getControl ();
-                                ToolItem[] tools = bar.getItems ();
+    display = new Display ();
+    shell = new Shell (display);
+    shell.setLayout(new GridLayout());
+    coolBar = new CoolBar(shell, DWT.FLAT | DWT.BORDER);
+    coolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
+    ToolBar toolBar = new ToolBar(coolBar, DWT.FLAT | DWT.WRAP);
+    int minWidth = 0;
+    for (int j = 0; j < 5; j++) {
+        int width = 0;
+        ToolItem item = new ToolItem(toolBar, DWT.PUSH);
+        item.setText("B" ~ to!(char[])(j));
+        width = item.getWidth();
+        /* find the width of the widest tool */
+        if (width > minWidth) minWidth = width;
+    }
+    CoolItem coolItem = new CoolItem(coolBar, DWT.DROP_DOWN);
+    coolItem.setControl(toolBar);
+    Point size = toolBar.computeSize(DWT.DEFAULT, DWT.DEFAULT);
+    Point coolSize = coolItem.computeSize (size.x, size.y);
+    coolItem.setMinimumSize(minWidth, coolSize.y);
+    coolItem.setPreferredSize(coolSize);
+    coolItem.setSize(coolSize);
+    coolItem.addSelectionListener(new class() SelectionAdapter {
+        public void widgetSelected(SelectionEvent event) {
+            if (event.detail == DWT.ARROW) {
+                CoolItem item = cast(CoolItem) event.widget;
+                Rectangle itemBounds = item.getBounds ();
+                Point pt = coolBar.toDisplay(new Point(itemBounds.x, itemBounds.y));
+                itemBounds.x = pt.x;
+                itemBounds.y = pt.y;
+                ToolBar bar = cast(ToolBar) item.getControl ();
+                ToolItem[] tools = bar.getItems ();
 
-                                int i = 0;
-                                while (i < tools.length) {
-                                        Rectangle toolBounds = tools[i].getBounds ();
-                                        pt = bar.toDisplay(new Point(toolBounds.x, toolBounds.y));
-                                        toolBounds.x = pt.x;
-                                        toolBounds.y = pt.y;
+                int i = 0;
+                while (i < tools.length) {
+                    Rectangle toolBounds = tools[i].getBounds ();
+                    pt = bar.toDisplay(new Point(toolBounds.x, toolBounds.y));
+                    toolBounds.x = pt.x;
+                    toolBounds.y = pt.y;
 
-                                        /* Figure out the visible portion of the tool by looking at the
-                                         * intersection of the tool bounds with the cool item bounds. */
-                                          Rectangle intersection = itemBounds.intersection (toolBounds);
+                    /* Figure out the visible portion of the tool by looking at the
+                     * intersection of the tool bounds with the cool item bounds.
+                     */
+                    Rectangle intersection = itemBounds.intersection (toolBounds);
 
-                                        /* If the tool is not completely within the cool item bounds, then it
-                                         * is partially hidden, and all remaining tools are completely hidden. */
-                                          if (intersection != toolBounds) break;
-                                          i++;
-                                }
+                    /* If the tool is not completely within the cool item bounds, then it
+                     * is partially hidden, and all remaining tools are completely hidden.
+                     */
+                    if (intersection != toolBounds) break;
+                    i++;
+                }
 
-                                /* Create a menu with items for each of the completely hidden buttons. */
-                                if (chevronMenu !is null) chevronMenu.dispose();
-                                chevronMenu = new Menu (coolBar);
-                                for (int j = i; j < tools.length; j++) {
-                                        MenuItem menuItem = new MenuItem (chevronMenu, DWT.PUSH);
-                                        menuItem.setText (tools[j].getText());
-                                }
+                /* Create a menu with items for each of the completely hidden buttons. */
+                if (chevronMenu !is null) chevronMenu.dispose();
+                chevronMenu = new Menu (coolBar);
+                for (int j = i; j < tools.length; j++) {
+                    MenuItem menuItem = new MenuItem (chevronMenu, DWT.PUSH);
+                    menuItem.setText (tools[j].getText());
+                }
 
-                                /* Drop down the menu below the chevron, with the left edges aligned. */
-                                pt = coolBar.toDisplay(new Point(event.x, event.y));
-                                chevronMenu.setLocation (pt.x, pt.y);
-                                chevronMenu.setVisible (true);
-                        }
-                }
-        });
+                /* Drop down the menu below the chevron, with the left edges aligned. */
+                pt = coolBar.toDisplay(new Point(event.x, event.y));
+                chevronMenu.setLocation (pt.x, pt.y);
+                chevronMenu.setVisible (true);
+            }
+        }
+    });
 
-        shell.pack();
-        shell.open ();
-        while (!shell.isDisposed ()) {
-                if (!display.readAndDispatch ()) display.sleep ();
-        }
-        display.dispose ();
+    shell.pack();
+    shell.open ();
+    while (!shell.isDisposed ()) {
+        if (!display.readAndDispatch ()) display.sleep ();
+    }
+    display.dispose ();
 }