org.eclipse.swt.custom
Class CTabFolder

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.CTabFolder
All Implemented Interfaces:
Drawable

public class CTabFolder
extends Composite

Safe:


Field Summary
private  ToolBar arrowBar
           
private  Image arrowLeftImage
           
private  Image arrowRightImage
           
(package private)  Color background
           
(package private)  Image backgroundImage
           
private  int borderBottom
           
private  Color borderColor1
           
private  Color borderColor2
           
private  Color borderColor3
           
static RGB borderInsideRGB
          Enabled: Color of innermost line of drop shadow border.
private  int borderLeft
           
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  int borderRight
           
private  int borderTop
           
(package private)  ToolBar closeBar
           
private  Image closeImage
           
private static int DEFAULT_HEIGHT
           
private static int DEFAULT_WIDTH
           
(package private)  boolean fixedTabHeight
           
(package private)  Color[] gradientColors
           
(package private)  int[] gradientPercents
           
private  ToolBar inactiveCloseBar
           
private  CTabItem inactiveItem
           
private  boolean inDispose
           
(package private)  int insertionIndex
           
private  CTabItem[] items
           
private  Label label
           
 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.
 int MIN_TAB_WIDTH
          Enabled:
private  Font oldFont
           
private  Point oldSize
           
(package private)  boolean onBottom
           
private  int selectedIndex
           
(package private)  Color selectionForeground
           
(package private)  boolean showBorders
           
(package private)  boolean showClose
           
private  boolean showToolTip
           
(package private)  int tabHeight
           
private  CTabFolderListener[] tabListeners
           
private  Shell tip
           
private  CTabItem toolTipItem
           
private  Control topRight
           
(package private)  int topTabIndex
           
(package private)  int xClient
           
(package private)  int yClient
           
 
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
CTabFolder(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
 void addCTabFolderListener(CTabFolderListener listener)
          Enabled: Adds the listener to the collection of listeners who will be notified when a tab item is closed.
 void addSelectionListener(SelectionListener listener)
          Enabled: Adds the listener to receive events.
private static int checkStyle(int style)
           
private  void closeNotify(CTabItem item, int time)
           
 Point computeSize(int wHint, int hHint, boolean changed)
          Enabled:
 Rectangle computeTrim(int x, int y, int width, int height)
          Enabled:
private  boolean correctLastItem()
           
private  void createArrowBar()
           
private  void createCloseBar()
           
(package private)  void createItem(CTabItem item, int index)
          Create the specified item at 'index'.
(package private)  void destroyItem(CTabItem item)
          Destroy the specified item.
private  void drawBorder(GC gc)
          Draw a border around the receiver.
 Rectangle getClientArea()
          Enabled:
 CTabItem getItem(int index)
          Enabled: Return the tab that is located at the specified index.
 CTabItem getItem(Point pt)
          Enabled: Gets the item at a point in the widget.
 int getItemCount()
          Enabled: Return the number of tabs in the folder.
 CTabItem[] getItems()
          Enabled: Return the tab items.
private  int getLastItem()
           
(package private)  char getMnemonic(String string)
           
 CTabItem getSelection()
          Enabled: Return the selected tab item, or an empty array if there is no selection.
 int getSelectionIndex()
          Enabled: Return the index of the selected tab item, or -1 if there is no selection.
 int getTabHeight()
          Enabled: Returns the height of the tab
private  Rectangle getToolSpace()
           
 Control getTopRight()
          Suppressed: Returns the control in the top right corner of the tab folder.
 int indexOf(CTabItem item)
          Enabled: Return the index of the specified tab or -1 if the tab is not in the receiver.
private  void initAccessible()
           
private  void onDispose()
          Dispose the items of the receiver
private  void onFocus(Event e)
           
private  void onKeyDown(Event e)
           
private  boolean onMnemonic(Event event)
           
private  void onMouseDoubleClick(Event event)
           
private  void onMouseDown(Event event)
          A mouse button was pressed down.
private  void onMouseExit(Event event)
           
private  void onMouseHover(Event event)
           
private  void onMouseMove(Event event)
           
private  boolean onPageTraversal(Event event)
           
private  void onPaint(Event event)
          Paint the receiver.
private  void onResize()
          The widget was resized.
private  void onTraverse(Event event)
           
private  void redrawTabArea(int index)
           
 void removeCTabFolderListener(CTabFolderListener listener)
          Enabled: Removes the listener.
 void removeSelectionListener(SelectionListener listener)
          Enabled: Removes the listener.
(package private)  void resetTabSize(boolean checkHeight)
           
private  Image scaleImage(Image image, int oldSize, int newSize)
           
private  boolean scroll_leftVisible()
          Answer true if not all tabs can be visible in the receive thus requiring the scroll buttons to be visible.
private  boolean scroll_rightVisible()
          Answer true if not all tabs can be visible in the receive thus requiring the scroll buttons to be visible.
private  void scroll_scrollLeft()
          Scroll the tab items to the left.
private  void scroll_scrollRight()
          Scroll the tab items to the right.
 void setBackground(Color color)
          Enabled:
 void setBorderVisible(boolean show)
          Enabled: Toggle the visibility of the border
private  void setButtonBounds()
           
 void setFont(Font font)
          Enabled:
 void setInsertMark(CTabItem item, boolean after)
          Enabled: Display an insert marker before or after the specified tab item.
 void setInsertMark(int index, boolean after)
          Enabled: Display an insert marker before or after the specified tab item.
(package private)  boolean setItemBounds()
          Layout the items and store the client area size.
private  boolean setItemLocation()
           
private  void setLastItem(int index)
           
 void setSelection(CTabItem item)
          Enabled: Set the selection to the tab at the specified item.
 void setSelection(int index)
          Enabled: Set the selection to the tab at the specified index.
private  void setSelection(int index, boolean notify)
          Set the selection to the tab at the specified index.
 void setSelectionBackground(Color[] colors, int[] percents)
          Enabled: Specify a gradient of colours to be draw in the background of the selected tab.
 void setSelectionBackground(Image image)
          Enabled: Set the image to be drawn in the background of the selected tab.
 void setSelectionForeground(Color color)
          Enabled: Set the foreground color of the selected tab.
 void setTabHeight(int height)
          Enabled: Specify a fixed height for the tab items.
 void setTopRight(Control control)
          Suppressed: Set the control that appears in the top right corner of the tab folder.
 void showItem(CTabItem item)
          Enabled: Shows the item.
 void showSelection()
          Enabled: Shows the selection.
private  void showToolTip(int x, int y)
           
private  void updateArrowBar()
           
private  void updateCloseBar()
           
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getChildren, getLayout, getTabList, layout, layout, moveAbove, moveBelow, setFocus, setLayout, 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, 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.


MIN_TAB_WIDTH

public int MIN_TAB_WIDTH
Enabled:


xClient

int xClient

yClient

int yClient

onBottom

boolean onBottom

fixedTabHeight

boolean fixedTabHeight

tabHeight

int tabHeight

items

private CTabItem[] items

selectedIndex

private int selectedIndex

topTabIndex

int topTabIndex

tabListeners

private CTabFolderListener[] tabListeners

backgroundImage

Image backgroundImage

gradientColors

Color[] gradientColors

gradientPercents

int[] gradientPercents

selectionForeground

Color selectionForeground

background

Color background

DEFAULT_WIDTH

private static final int DEFAULT_WIDTH

DEFAULT_HEIGHT

private static final int DEFAULT_HEIGHT

arrowBar

private ToolBar arrowBar

arrowLeftImage

private Image arrowLeftImage

arrowRightImage

private Image arrowRightImage

topRight

private Control topRight

showClose

boolean showClose

closeImage

private Image closeImage

closeBar

ToolBar closeBar

inactiveCloseBar

private ToolBar inactiveCloseBar

inactiveItem

private CTabItem inactiveItem

showBorders

boolean showBorders

borderBottom

private int borderBottom

borderLeft

private int borderLeft

borderRight

private int borderRight

borderTop

private int borderTop

borderColor1

private Color borderColor1

borderColor2

private Color borderColor2

borderColor3

private Color borderColor3

inDispose

private boolean inDispose

oldSize

private Point oldSize

oldFont

private Font oldFont

insertionIndex

int insertionIndex

tip

private Shell tip

label

private Label label

showToolTip

private boolean showToolTip

toolTipItem

private CTabItem toolTipItem
Constructor Detail

CTabFolder

public CTabFolder(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.TOP, SWT.BOTTOM, SWT.FLAT, Widget.getStyle()
Method Detail

checkStyle

private static int checkStyle(int style)

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Enabled: Adds the listener to receive events.

Parameters:
listener - the listener

addCTabFolderListener

public void addCTabFolderListener(CTabFolderListener listener)
Enabled: Adds the listener to the collection of listeners who will be notified when a tab item is closed.

Parameters:
listener - the listener which should be notified
See Also:
CTabFolderListener, removeCTabFolderListener(org.eclipse.swt.custom.CTabFolderListener)

closeNotify

private void closeNotify(CTabItem item,
                         int time)

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()

createItem

void createItem(CTabItem item,
                int index)
Create the specified item at 'index'.


createArrowBar

private void createArrowBar()

createCloseBar

private void createCloseBar()

destroyItem

void destroyItem(CTabItem item)
Destroy the specified item.


onKeyDown

private void onKeyDown(Event e)

onDispose

private void onDispose()
Dispose the items of the receiver


onFocus

private void onFocus(Event e)

drawBorder

private void drawBorder(GC gc)
Draw a border around the receiver.


getClientArea

public Rectangle getClientArea()
Enabled:

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

getTabHeight

public int getTabHeight()
Enabled: Returns the height of the tab

Returns:
the height of the tab

getItem

public CTabItem getItem(int index)
Enabled: Return the tab that is located at the specified index.

Returns:
the item at the specified index

getItem

public CTabItem getItem(Point pt)
Enabled: Gets the item at a point in the widget.

Returns:
the item at a point

getItemCount

public int getItemCount()
Enabled: Return the number of tabs in the folder.

Returns:
the number of tabs in the folder

getItems

public CTabItem[] getItems()
Enabled: Return the tab items.

Returns:
the tab items

getLastItem

private int getLastItem()

getSelection

public CTabItem getSelection()
Enabled: Return the selected tab item, or an empty array if there is no selection.

Returns:
the selected tab item

getSelectionIndex

public int getSelectionIndex()
Enabled: Return the index of the selected tab item, or -1 if there is no selection.

Returns:
the index of the selected tab item or -1

getToolSpace

private Rectangle getToolSpace()

getTopRight

public Control getTopRight()
Suppressed: Returns the control in the top right corner of the tab folder. 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 tab folder or null
Since:
2.1

indexOf

public int indexOf(CTabItem item)
Enabled: Return the index of the specified tab or -1 if the tab is not in the receiver.

Returns:
the index of the specified tab item or -1

initAccessible

private void initAccessible()

setButtonBounds

private void setButtonBounds()

setItemLocation

private boolean setItemLocation()

setLastItem

private void setLastItem(int index)

setItemBounds

boolean setItemBounds()
Layout the items and store the client area size.


onMnemonic

private boolean onMnemonic(Event event)

onPaint

private void onPaint(Event event)
Paint the receiver.


redrawTabArea

private void redrawTabArea(int index)

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Enabled: Removes the listener.

Parameters:
listener - the listener

removeCTabFolderListener

public void removeCTabFolderListener(CTabFolderListener listener)
Enabled: Removes the listener.

Parameters:
listener - the listener

onResize

private void onResize()
The widget was resized. Adjust the size of the currently selected page.


setBackground

public void setBackground(Color color)
Enabled:

Overrides:
setBackground in class Control
Parameters:
color - the new color (or null)

setSelectionBackground

public void setSelectionBackground(Color[] colors,
                                   int[] percents)
Enabled: Specify a gradient of colours to be draw in the background of the selected tab. For example to draw a gradient that varies from dark blue to blue and then to white, use the following call to setBackground:
	cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
		                           display.getSystemColor(SWT.COLOR_BLUE),
		                           display.getSystemColor(SWT.COLOR_WHITE), 
		                           display.getSystemColor(SWT.COLOR_WHITE)},
		               new int[] {25, 50, 100});
 

Parameters:
colors - an array of Color that specifies the colors to appear in the gradient in order of appearance left to right. The value null clears the background gradient. The value null can be used inside the array of Color to specify the background color.
percents - an array of integers between 0 and 100 specifying the percent of the width of the widget at which the color should change. The size of the percents array must be one less than the size of the colors array.

setSelectionBackground

public void setSelectionBackground(Image image)
Enabled: Set the image to be drawn in the background of the selected tab.

Parameters:
image - the image to be drawn in the background

setBorderVisible

public void setBorderVisible(boolean show)
Enabled: Toggle the visibility of the border

Parameters:
show - true if the border should be displayed

setFont

public void setFont(Font font)
Enabled:

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

setSelectionForeground

public void setSelectionForeground(Color color)
Enabled: Set the foreground color of the selected tab.

Parameters:
color - the color of the text displayed in the selected tab

setInsertMark

public void setInsertMark(CTabItem item,
                          boolean after)
Enabled: Display an insert marker before or after the specified tab item. A value of null will clear the mark.

Parameters:
item - the item with which the mark is associated or null
after - true if the mark should be displayed after the specified item

setInsertMark

public void setInsertMark(int index,
                          boolean after)
Enabled: Display an insert marker before or after the specified tab item. A value of -1 will clear the mark.

Parameters:
after - true if the mark should be displayed after the specified item

setSelection

public void setSelection(int index)
Enabled: Set the selection to the tab at the specified index.

Parameters:
index - the index of the tab item to be selected

setTopRight

public void setTopRight(Control control)
Suppressed: Set the control that appears in the top right corner of the tab folder. Typically this is a close button or a composite with a Menu and close button. The topRight control is optional. Setting the top right control to null will remove it from the tab folder.

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

showItem

public void showItem(CTabItem item)
Enabled: Shows the item. If the item is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the item is visible.

Parameters:
item - the item to be shown
Since:
2.0
See Also:
showSelection()

showSelection

public void showSelection()
Enabled: Shows the selection. If the selection is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the selection is visible.

Since:
2.0
See Also:
showItem(CTabItem)

getMnemonic

char getMnemonic(String string)

setSelection

public void setSelection(CTabItem item)
Enabled: Set the selection to the tab at the specified item.


setSelection

private void setSelection(int index,
                          boolean notify)
Set the selection to the tab at the specified index.


scaleImage

private Image scaleImage(Image image,
                         int oldSize,
                         int newSize)

updateCloseBar

private void updateCloseBar()

updateArrowBar

private void updateArrowBar()

onMouseDoubleClick

private void onMouseDoubleClick(Event event)

onMouseDown

private void onMouseDown(Event event)
A mouse button was pressed down. If a tab was hit select the tab.


onMouseExit

private void onMouseExit(Event event)

onMouseHover

private void onMouseHover(Event event)

showToolTip

private void showToolTip(int x,
                         int y)

onMouseMove

private void onMouseMove(Event event)

onTraverse

private void onTraverse(Event event)

onPageTraversal

private boolean onPageTraversal(Event event)

scroll_leftVisible

private boolean scroll_leftVisible()
Answer true if not all tabs can be visible in the receive thus requiring the scroll buttons to be visible.


scroll_rightVisible

private boolean scroll_rightVisible()
Answer true if not all tabs can be visible in the receive thus requiring the scroll buttons to be visible.


scroll_scrollLeft

private void scroll_scrollLeft()
Scroll the tab items to the left.


scroll_scrollRight

private void scroll_scrollRight()
Scroll the tab items to the right.


correctLastItem

private boolean correctLastItem()

setTabHeight

public void setTabHeight(int height)
Enabled: Specify a fixed height for the tab items. If no height is specified, the default height is the height of the text or the image, whichever is greater. Specifying a height of 0 will revert to the default height.

Parameters:
height - the pixel value of the height or 0

resetTabSize

void resetTabSize(boolean checkHeight)


comments?