Coverage Report - net.miginfocom.swt.SwtContainerWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
SwtContainerWrapper
N/A
N/A
1.25
 
 1  
 package net.miginfocom.swt;
 2  
 /*
 3  
  * License (BSD):
 4  
  * ==============
 5  
  *
 6  
  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
 7  
  * All rights reserved.
 8  
  *
 9  
  * Redistribution and use in source and binary forms, with or without modification,
 10  
  * are permitted provided that the following conditions are met:
 11  
  * Redistributions of source code must retain the above copyright notice, this list
 12  
  * of conditions and the following disclaimer.
 13  
  * Redistributions in binary form must reproduce the above copyright notice, this
 14  
  * list of conditions and the following disclaimer in the documentation and/or other
 15  
  * materials provided with the distribution.
 16  
  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
 17  
  * used to endorse or promote products derived from this software without specific
 18  
  * prior written permission.
 19  
  *
 20  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 21  
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 22  
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 23  
  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 24  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 25  
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 26  
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 27  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 28  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 29  
  * OF SUCH DAMAGE.
 30  
  *
 31  
  * @version 1.0
 32  
  * @author Mikael Grev, MiG InfoCom AB
 33  
  *         Date: 2006-sep-08
 34  
  */
 35  
 
 36  
 import net.miginfocom.layout.ComponentWrapper;
 37  
 import net.miginfocom.layout.ContainerWrapper;
 38  
 import org.eclipse.swt.SWT;
 39  
 import org.eclipse.swt.widgets.Composite;
 40  
 import org.eclipse.swt.widgets.Control;
 41  
 
 42  
 import java.util.Random;
 43  
 
 44  
 /**
 45  
  */
 46  
 public final class SwtContainerWrapper extends SwtComponentWrapper implements ContainerWrapper
 47  
 {
 48  
         public SwtContainerWrapper(Composite c)
 49  
         {
 50  
                 super(c);
 51  
         }
 52  
 
 53  
         public ComponentWrapper[] getComponents()
 54  
         {
 55  
                 Composite c = (Composite) getComponent();
 56  
                 Control[] cons = c.getChildren();
 57  
                 ComponentWrapper[] cws = new ComponentWrapper[cons.length];
 58  
                 for (int i = 0; i < cws.length; i++)
 59  
                         cws[i] = new SwtComponentWrapper(cons[i]);
 60  
                 return cws;
 61  
         }
 62  
 
 63  
         public int getComponentCount()
 64  
         {
 65  
                 return ((Composite) getComponent()).getChildren().length;
 66  
         }
 67  
 
 68  
         public Object getLayout()
 69  
         {
 70  
                 return ((Composite) getComponent()).getLayout();
 71  
         }
 72  
 
 73  
         public final boolean isLeftToRight()
 74  
         {
 75  
                 return (((Composite) getComponent()).getStyle() & SWT.LEFT_TO_RIGHT) > 0;
 76  
         }
 77  
 
 78  
         public final void paintDebugCell(int x, int y, int width, int height)
 79  
         {
 80  
                 // A Composite can not draw above its children, so the cells can not be painted.
 81  
 
 82  
 //                if (c.isDisposed())
 83  
 //                        return;
 84  
 //                GC gc = new GC(c);
 85  
 //
 86  
 //                gc.setLineStyle(SWT.LINE_DASHDOTDOT);
 87  
 //                gc.setLineJoin(SWT.JOIN_MITER);
 88  
 //                gc.setLineCap(SWT.CAP_SQUARE);
 89  
 //
 90  
 //                gc.setBackground(DB_CELL_BG);
 91  
 //                gc.fillRectangle(x, y, width, height);
 92  
 //
 93  
 //                gc.setForeground(DB_CELL_OUTLINE);
 94  
 //                gc.drawRectangle(x, y, width - 1, height - 1);
 95  
 //
 96  
 //                gc.dispose();
 97  
         }
 98  
 
 99  
         public int getComponetType(boolean disregardScrollPane)
 100  
         {
 101  
                 return TYPE_CONTAINER;
 102  
         }
 103  
 
 104  
 
 105  
         public int getLayoutHashCode()
 106  
         {
 107  
                 int h = super.getLayoutHashCode();
 108  
 
 109  
                 if (isLeftToRight())
 110  
                         h |= (1 << 26);
 111  
 
 112  
                 return h;
 113  
         }
 114  
 }