org.eclipse.swt.custom
Class ViewForm

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.Composite
                          |
                          +--org.eclipse.swt.custom.ViewForm
All Implemented Interfaces:
Drawable

public class ViewForm
extends Composite

Safe: Instances of this class implement a Composite that lays out three children horizontally and allows programmatic control of layout and border parameters. ViewForm is used in the workbench to implement a view's label/menu/toolbar local bar.

Note that although this class is a subclass of Composite, it does not make sense to set a layout on it.

Styles:
BORDER, FLAT
Events:
(None)

IMPORTANT: This class is not intended to be subclassed.


Field Summary
private  int BORDER_BOTTOM
           
private  int BORDER_LEFT
           
private  int BORDER_RIGHT
           
private  int BORDER_TOP
           
private  Color borderColor1
           
private  Color borderColor2
           
private  Color borderColor3
           
static RGB borderInsideRGB
          Enabled: Color of innermost line of drop shadow border.
static RGB borderMiddleRGB
          Enabled: Color of middle line of drop shadow border.
static RGB borderOutsideRGB
          Enabled: Color of outermost line of drop shadow border.
private  Control content
           
private  int drawLine1
           
private  int drawLine2
           
 int marginHeight
          Enabled: marginHeight specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the form.
 int marginWidth
          Enabled: marginWidth specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the form.
private static int OFFSCREEN
           
private  Rectangle oldArea
           
private  boolean separateTopCenter
           
private  boolean showBorder
           
private  Control topCenter
           
private  Control topLeft
           
private  Control topRight
           
 
Fields inherited from class org.eclipse.swt.widgets.Composite
 
Fields inherited from class org.eclipse.swt.widgets.Scrollable
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
 
Constructor Summary
ViewForm(Composite parent, int style)
          Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
private static int checkStyle(int style)
          Check the style bits to ensure that no invalid styles are applied.
 Point computeSize(int wHint, int hHint, boolean changed)
          Enabled:
 Rectangle computeTrim(int x, int y, int width, int height)
          Enabled:
 Rectangle getClientArea()
          Enabled:
 Control getContent()
          Enabled: Returns the content area.
 Control getTopCenter()
          Enabled: Returns Control that appears in the top center of the pane.
 Control getTopLeft()
          Enabled: Returns the Control that appears in the top left corner of the pane.
 Control getTopRight()
          Enabled: Returns the control in the top right corner of the pane.
 void layout(boolean changed)
          Enabled:
private  void onDispose()
           
private  void onPaint(GC gc)
          Draws the focus border.
private  void onResize()
           
 void setBorderVisible(boolean show)
          Enabled: Specify whether the border should be displayed or not.
 void setContent(Control content)
          Enabled: Sets the content.
 void setFont(Font f)
          Enabled: Set the widget font.
 void setLayout(Layout layout)
          Enabled: Sets the layout which is associated with the receiver to be the argument which may be null.
 void setTopCenter(Control topCenter)
          Enabled: Set the control that appears in the top center of the pane.
 void setTopCenterSeparate(boolean show)
          Enabled: 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.
 void setTopLeft(Control c)
          Enabled: Set the control that appears in the top left corner of the pane.
 void setTopRight(Control c)
          Enabled: Set the control that appears in the top right corner of the pane.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getChildren, getLayout, getTabList, layout, moveAbove, moveBelow, setFocus, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getDisplay, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isDisposed, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, transferActive, transferFocus, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getStyle, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

marginWidth

public int marginWidth
Enabled: marginWidth specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the form. The default value is 0.


marginHeight

public int marginHeight
Enabled: marginHeight specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the form. The default value is 0.


borderInsideRGB

public static RGB borderInsideRGB
Enabled: Color of innermost line of drop shadow border.


borderMiddleRGB

public static RGB borderMiddleRGB
Enabled: Color of middle line of drop shadow border.


borderOutsideRGB

public static RGB borderOutsideRGB
Enabled: Color of outermost line of drop shadow border.


topLeft

private Control topLeft

topCenter

private Control topCenter

topRight

private Control topRight

content

private Control content

separateTopCenter

private boolean separateTopCenter

drawLine1

private int drawLine1

drawLine2

private int drawLine2

showBorder

private boolean showBorder

BORDER_TOP

private int BORDER_TOP

BORDER_BOTTOM

private int BORDER_BOTTOM

BORDER_LEFT

private int BORDER_LEFT

BORDER_RIGHT

private int BORDER_RIGHT

borderColor1

private Color borderColor1

borderColor2

private Color borderColor2

borderColor3

private Color borderColor3

oldArea

private Rectangle oldArea

OFFSCREEN

private static final int OFFSCREEN
Constructor Detail

ViewForm

public ViewForm(Composite parent,
                int style)
Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
See Also:
SWT.BORDER, SWT.FLAT, Widget.getStyle()
Method Detail

checkStyle

private static int checkStyle(int style)
Check the style bits to ensure that no invalid styles are applied.


computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Enabled:

Overrides:
computeSize in class Composite
Parameters:
wHint - the width hint (can be SWT.DEFAULT)
hHint - the height hint (can be SWT.DEFAULT)
changed - true if the control's contents have changed, and false otherwise
Returns:
the preferred size of the control.
See Also:
Layout, Control.getBorderWidth(), Control.getBounds(), Control.getSize(), Control.pack(), "computeTrim, getClientArea for controls that implement them"

computeTrim

public Rectangle computeTrim(int x,
                             int y,
                             int width,
                             int height)
Enabled:

Overrides:
computeTrim in class Scrollable
Returns:
the required bounds to produce the given client area
See Also:
Scrollable.getClientArea()

getClientArea

public Rectangle getClientArea()
Enabled:

Overrides:
getClientArea in class Scrollable
Returns:
the client area
See Also:
Scrollable.computeTrim(int, int, int, int)

getContent

public Control getContent()
Enabled: Returns the content area.

Returns:
the control in the content area of the pane or null

getTopCenter

public Control getTopCenter()
Enabled: Returns Control that appears in the top center of the pane. Typically this is a toolbar.

Returns:
the control in the top center of the pane or null

getTopLeft

public Control getTopLeft()
Enabled: Returns the Control that appears in the top left corner of the pane. Typically this is a label such as CLabel.

Returns:
the control in the top left corner of the pane or null

getTopRight

public Control getTopRight()
Enabled: 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.

Returns:
the control in the top right corner of the pane or null

layout

public void layout(boolean changed)
Enabled:

Overrides:
layout in class Composite
Parameters:
changed - true if the layout must flush its caches, and false otherwise

onDispose

private void onDispose()

onPaint

private void onPaint(GC gc)
Draws the focus border.


onResize

private void onResize()

setContent

public void setContent(Control content)
Enabled: Sets the content. Setting the content to null will remove it from the pane - however, the creator of the content must dispose of the content.


setFont

public void setFont(Font f)
Enabled: Set the widget font. This will apply the font to the topLeft, topRight and topCenter widgets.

Overrides:
setFont in class Control
Parameters:
f - the new font (or null)

setLayout

public void setLayout(Layout layout)
Enabled: Sets the layout which is associated with the receiver to be the argument which may be null.

Note : ViewForm does not use a layout class to size and position its children.

Overrides:
setLayout in class Composite
Parameters:
layout - the receiver's new layout or null

setTopCenter

public void setTopCenter(Control topCenter)
Enabled: 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 pane - however, the creator of the topCenter must dispose of the topCenter.


setTopLeft

public void setTopLeft(Control c)
Enabled: 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 pane - however, the creator of the control must dispose of the control.

Parameters:
c - the control to be displayed in the top left corner or null

setTopRight

public void setTopRight(Control c)
Enabled: 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 pane - however, the creator of the control must dispose of the control.

Parameters:
c - the control to be displayed in the top right corner or null

setBorderVisible

public void setBorderVisible(boolean show)
Enabled: Specify whether the border should be displayed or not.

Parameters:
show - true if the border should be displayed

setTopCenterSeparate

public void setTopCenterSeparate(boolean show)
Enabled: 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.

Parameters:
show - true if the topCenter will always appear on a separate line by itself


comments?