Class DefaultGalleryGroupRenderer
java.lang.Object
org.eclipse.nebula.widgets.gallery.AbstractGalleryGroupRenderer
org.eclipse.nebula.widgets.gallery.AbstractGridGroupRenderer
org.eclipse.nebula.widgets.gallery.DefaultGalleryGroupRenderer
public class DefaultGalleryGroupRenderer extends AbstractGridGroupRenderer
Default group renderer used by the Gallery widget. Supports multi-line text, images, animation and several other features.
NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.
-
Field Summary
Fields Modifier and Type Field Description protected booleananimationprotected IMovementanimationCloseMovementprotected intanimationLengthprotected IMovementanimationOpenMovementprotected static java.lang.StringDATA_ANIMATION(package private) booleanmarginCalculatedTrue if margins have already been calculated.Fields inherited from class org.eclipse.nebula.widgets.gallery.AbstractGridGroupRenderer
autoMargin, DEFAULT_SIZE, EMPTY_STRING, H_COUNT, itemHeight, itemWidth, margin, minMargin, V_COUNTFields inherited from class org.eclipse.nebula.widgets.gallery.AbstractGalleryGroupRenderer
expanded, gallery -
Constructor Summary
Constructors Constructor Description DefaultGalleryGroupRenderer()This group renderer draws a title line, then items in a grid layout. -
Method Summary
Modifier and Type Method Description voiddraw(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight)Group size informations can be retrieved from group.protected voiddrawGroup(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight)protected voiddrawGroupBackground(org.eclipse.swt.graphics.GC gc, GalleryItem item, int x, int y, int width, int height)Draw group background using system default gradient or the user-defined color.protected intdrawGroupToggleButton(org.eclipse.swt.graphics.GC gc, int x, int y, GalleryItem group)Draw the toggle button.protected voiddrawItem(org.eclipse.swt.graphics.GC gc, int index, boolean selected, GalleryItem parent, int offsetY)Draw a child item.IMovementgetAnimationCloseMovement()intgetAnimationLength()IMovementgetAnimationOpenMovement()Get the current movement used for animationorg.eclipse.swt.graphics.FontgetFont()Returns the font used for drawing the group title or null if system font is used.protected intgetGroupHeight(GalleryItem group)protected intgetGroupOffset(GalleryItem item)Returns a group offset (size of title + margin)protected java.lang.StringgetGroupTitle(GalleryItem group)GalleryItemgetItem(GalleryItem group, org.eclipse.swt.graphics.Point coords)Returns the item at coords relative to the parent group.intgetMaxImageHeight()intgetMaxImageWidth()intgetScrollBarIncrement()Returns the preferred Scrollbar increment for the current gallery layout.org.eclipse.swt.graphics.RectanglegetSize(GalleryItem item)Returns the size of a group.org.eclipse.swt.graphics.ColorgetTitleBackground()org.eclipse.swt.graphics.ColorgetTitleBackground2()org.eclipse.swt.graphics.ColorgetTitleForeground()Get group title text color.protected org.eclipse.swt.graphics.RectanglegetToggleButtonBounds()booleanisAnimation()booleanisFillIfSingleColumn()protected booleanisGroupExpanded(GalleryItem item)Return item expand state (item.isExpanded()) Returns always true is alwaysExpanded is set to true.booleanisTitleBackgroundGradient()voidlayout(org.eclipse.swt.graphics.GC gc, GalleryItem group)This method is called on each root item when the Gallery changes (resize, item addition or removal) in order to update the gallery size.booleanmouseDown(GalleryItem group, org.eclipse.swt.widgets.Event e, org.eclipse.swt.graphics.Point coords)This method can be implemented to handle mouse down events at the group level.voidpreDraw(org.eclipse.swt.graphics.GC gc)This method is called before drawing the first item.voidpreLayout(org.eclipse.swt.graphics.GC gc)This method is called before the layout of the first item.voidsetAnimation(boolean animation)Enable animation for group expand/collapse.voidsetAnimationCloseMovement(IMovement animationMovement)Set the movement used for close animation.voidsetAnimationLength(int animationLength)Set the length of the animationvoidsetAnimationOpenMovement(IMovement animationMovement)Set the movement used for open animation.voidsetFillIfSingleColumn(boolean fillIfSingle)Experimental feature.voidsetFont(org.eclipse.swt.graphics.Font font)Set the font for drawing the group title or null to use system font.voidsetGallery(Gallery gallery)voidsetMaxImageHeight(int imageHeight)Set the maximum height for a group image in the title bar.voidsetMaxImageWidth(int imageWidth)Set the maximum width for a group image in the title bar.voidsetTitleBackground(org.eclipse.swt.graphics.Color titleBackground)voidsetTitleBackgroundGradient(org.eclipse.swt.graphics.Color gradientBackground, org.eclipse.swt.graphics.Color gradientForeground)voidsetTitleForeground(org.eclipse.swt.graphics.Color titleColor)Change group title text color.protected voidstartGroupAnimation(GalleryItem group, boolean doOpen)Methods inherited from class org.eclipse.nebula.widgets.gallery.AbstractGridGroupRenderer
calculateMargins, dispose, getItem, getItemHeight, getItemWidth, getLayoutData, getMinMargin, getNextItem, getSize, getSize, getVisibleItems, gridLayout, isAlwaysExpanded, isAutoMargin, mouseDown, setAlwaysExpanded, setAutoMargin, setItemHeight, setItemSize, setItemWidth, setMinMarginMethods inherited from class org.eclipse.nebula.widgets.gallery.AbstractGalleryGroupRenderer
getBackground, getFont, getForeground, getGallery, getGroupPosition, getGroupSize, isDebugMode, isExpanded, notifyTreeListeners, postDraw, postLayout, setExpanded, setGroupSize, updateScrollBarsProperties, updateStructuralValues
-
Field Details
-
marginCalculated
boolean marginCalculatedTrue if margins have already been calculated. Prevents margins calculation for each group -
animation
protected boolean animation -
animationLength
protected int animationLength -
animationOpenMovement
-
animationCloseMovement
-
DATA_ANIMATION
protected static final java.lang.String DATA_ANIMATION- See Also:
- Constant Field Values
-
-
Constructor Details
-
DefaultGalleryGroupRenderer
public DefaultGalleryGroupRenderer()This group renderer draws a title line, then items in a grid layout.
-
-
Method Details
-
setGallery
- Overrides:
setGalleryin classAbstractGalleryGroupRenderer
-
drawGroupBackground
protected void drawGroupBackground(org.eclipse.swt.graphics.GC gc, GalleryItem item, int x, int y, int width, int height)Draw group background using system default gradient or the user-defined color.- Parameters:
gc-item- TODOx-y-width-height-
-
drawGroupToggleButton
protected int drawGroupToggleButton(org.eclipse.swt.graphics.GC gc, int x, int y, GalleryItem group)Draw the toggle button.- Parameters:
gc-x-y-group-
-
getToggleButtonBounds
protected org.eclipse.swt.graphics.Rectangle getToggleButtonBounds() -
getGroupHeight
-
drawGroup
protected void drawGroup(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight) -
getGroupTitle
-
getGroupOffset
Returns a group offset (size of title + margin)- Parameters:
item-- Returns:
- group offset or 0 if the item is not a group
-
draw
public void draw(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight)Description copied from class:AbstractGalleryGroupRendererGroup size informations can be retrieved from group. Clipping informations -
layout
Description copied from class:AbstractGalleryGroupRendererThis method is called on each root item when the Gallery changes (resize, item addition or removal) in order to update the gallery size. The implementation must update the item internal size (px) using setGroupSize(item, size); before returning.- Overrides:
layoutin classAbstractGridGroupRenderer
-
preDraw
public void preDraw(org.eclipse.swt.graphics.GC gc)Description copied from class:AbstractGalleryGroupRendererThis method is called before drawing the first item. It can be used to calculate some values (like font metrics) that will be used for each item.- Overrides:
preDrawin classAbstractGalleryGroupRenderer
-
preLayout
public void preLayout(org.eclipse.swt.graphics.GC gc)Description copied from class:AbstractGalleryGroupRendererThis method is called before the layout of the first item. It can be used to calculate some values (like font metrics) that will be used for each item.- Overrides:
preLayoutin classAbstractGridGroupRenderer- See Also:
(org.eclipse.swt.graphics.GC)
-
getItem
Description copied from class:AbstractGalleryGroupRendererReturns the item at coords relative to the parent group.- Overrides:
getItemin classAbstractGridGroupRenderer- Returns:
- See Also:
AbstractGridGroupRenderer.getItem( org.eclipse.nebula.widgets.gallery.GalleryItem, org.eclipse.swt.graphics.Point)
-
startGroupAnimation
-
mouseDown
public boolean mouseDown(GalleryItem group, org.eclipse.swt.widgets.Event e, org.eclipse.swt.graphics.Point coords)Description copied from class:AbstractGalleryGroupRendererThis method can be implemented to handle mouse down events at the group level. Usually to interact with custom group UI.- Specified by:
mouseDownin classAbstractGalleryGroupRenderer- Parameters:
group- The group on which the mouse click occurede- The original mouse eventcoords- The pointer coordinates relative to the group- Returns:
- false if event was handled by the group renderer and Gallery should not try to handle this event as a click on a GalleryItem.
- See Also:
AbstractGalleryGroupRenderer.mouseDown(org.eclipse.nebula.widgets.gallery.GalleryItem, org.eclipse.swt.widgets.Event, org.eclipse.swt.graphics.Point)
-
getSize
Description copied from class:AbstractGalleryGroupRendererReturns the size of a group.- Overrides:
getSizein classAbstractGridGroupRenderer- Returns:
- See Also:
AbstractGridGroupRenderer.getSize( org.eclipse.nebula.widgets.gallery.GalleryItem)
-
getTitleForeground
public org.eclipse.swt.graphics.Color getTitleForeground()Get group title text color.- Returns:
- current color.
-
setTitleForeground
public void setTitleForeground(org.eclipse.swt.graphics.Color titleColor)Change group title text color.- Parameters:
titleColor- Color or null to revert to default.
-
getTitleBackground
public org.eclipse.swt.graphics.Color getTitleBackground() -
setTitleBackground
public void setTitleBackground(org.eclipse.swt.graphics.Color titleBackground) -
setTitleBackgroundGradient
public void setTitleBackgroundGradient(org.eclipse.swt.graphics.Color gradientBackground, org.eclipse.swt.graphics.Color gradientForeground) -
getFont
public org.eclipse.swt.graphics.Font getFont()Returns the font used for drawing the group title or null if system font is used.- Returns:
- the font
-
setFont
public void setFont(org.eclipse.swt.graphics.Font font)Set the font for drawing the group title or null to use system font.- Parameters:
font- the font to set
-
drawItem
protected void drawItem(org.eclipse.swt.graphics.GC gc, int index, boolean selected, GalleryItem parent, int offsetY)Description copied from class:AbstractGridGroupRendererDraw a child item. Only used when useGroup is true. -
getScrollBarIncrement
public int getScrollBarIncrement()Description copied from class:AbstractGalleryGroupRendererReturns the preferred Scrollbar increment for the current gallery layout.- Overrides:
getScrollBarIncrementin classAbstractGalleryGroupRenderer- Returns:
-
isFillIfSingleColumn
public boolean isFillIfSingleColumn()- Returns:
- See Also:
setFillIfSingleColumn(boolean)
-
setFillIfSingleColumn
public void setFillIfSingleColumn(boolean fillIfSingle)Experimental feature.
If set to true, this will enable a special behavior when the items are so large that only one can fit in the client area. In this case, items are always resized and centered to fit best in the client area.
See bug 266613 : https://bugs.eclipse.org/266613
- Parameters:
fillIfSingle-
-
getMaxImageWidth
public int getMaxImageWidth()- Returns:
- See Also:
setMaxImageWidth(int)
-
setMaxImageWidth
public void setMaxImageWidth(int imageWidth)Set the maximum width for a group image in the title bar.- Parameters:
imageWidth-- See Also:
GalleryItem.setImage(Image)
-
getMaxImageHeight
public int getMaxImageHeight()- Returns:
- See Also:
setMaxImageHeight(int)
-
setMaxImageHeight
public void setMaxImageHeight(int imageHeight)Set the maximum height for a group image in the title bar.- Parameters:
imageHeight-- See Also:
GalleryItem.setImage(Image)
-
isAnimation
public boolean isAnimation()- Returns:
- See Also:
setAnimation(boolean)
-
setAnimation
public void setAnimation(boolean animation)Enable animation for group expand/collapse.- Parameters:
animation-- See Also:
setAnimationLength(int),setAnimationOpenMovement(IMovement)
-
getAnimationLength
public int getAnimationLength()- Returns:
- See Also:
setAnimationLength(int)
-
setAnimationLength
public void setAnimationLength(int animationLength)Set the length of the animation- Parameters:
animationLength-- See Also:
setAnimation(boolean),setAnimationOpenMovement(IMovement)
-
getAnimationOpenMovement
Get the current movement used for animation- Returns:
- See Also:
setAnimationOpenMovement(IMovement)
-
getAnimationCloseMovement
- Returns:
- See Also:
setAnimationCloseMovement(IMovement)
-
setAnimationOpenMovement
Set the movement used for open animation.- Parameters:
animationMovement-- See Also:
setAnimation(boolean),setAnimationLength(int)
-
setAnimationCloseMovement
Set the movement used for close animation.- Parameters:
animationMovement-- See Also:
setAnimation(boolean),setAnimationLength(int)
-
isGroupExpanded
Description copied from class:AbstractGridGroupRendererReturn item expand state (item.isExpanded()) Returns always true is alwaysExpanded is set to true.- Overrides:
isGroupExpandedin classAbstractGridGroupRenderer- Returns:
-
isTitleBackgroundGradient
public boolean isTitleBackgroundGradient() -
getTitleBackground2
public org.eclipse.swt.graphics.Color getTitleBackground2()
-