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 IMovementanimationOpenMovementprivate AnimationRunneranimationRunnerprotected static java.lang.StringDATA_ANIMATIONprivate org.eclipse.swt.graphics.ColordescriptionColorprivate booleanfillThis flag is set during layout, if fillIfSigle is true, and if there is only one column or rowprivate booleanfillIfSingleColumnIf true, this flag will enable a special behavior when the items are so large that only one can fit in the client area.private org.eclipse.swt.graphics.Fontfontprivate intfontHeightprivate org.eclipse.swt.graphics.PointimageSize(package private) booleanmarginCalculatedTrue if margins have already been calculated.private intmaxImageHeightprivate intmaxImageWidthprivate static java.lang.StringPARENTHESIS_CLOSEprivate static java.lang.StringPARENTHESIS_OPENprivate org.eclipse.swt.graphics.ColortitleBackgroundprivate org.eclipse.swt.graphics.ColortitleBackground2private booleantitleBackgroundGradientprivate org.eclipse.swt.graphics.ColortitleForegroundprivate inttitleHeight-
Fields inherited from class org.eclipse.nebula.widgets.gallery.AbstractGridGroupRenderer
autoMargin, DEFAULT_SIZE, EMPTY_STRING, H_COUNT, itemHeight, itemWidth, margin, minMargin, V_COUNT
-
Fields 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
All Methods Instance Methods Concrete Methods 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.private intdrawGroupImage(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, org.eclipse.swt.graphics.Point imageSize2)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.private voidpre(org.eclipse.swt.graphics.GC myGc)Prepare font metrics and title height for both preLayout and preDraw.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, setMinMargin
-
Methods 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 Detail
-
animationRunner
private AnimationRunner animationRunner
-
PARENTHESIS_OPEN
private static final java.lang.String PARENTHESIS_OPEN
- See Also:
- Constant Field Values
-
PARENTHESIS_CLOSE
private static final java.lang.String PARENTHESIS_CLOSE
- See Also:
- Constant Field Values
-
fontHeight
private int fontHeight
-
titleHeight
private int titleHeight
-
titleForeground
private org.eclipse.swt.graphics.Color titleForeground
-
descriptionColor
private org.eclipse.swt.graphics.Color descriptionColor
-
titleBackground
private org.eclipse.swt.graphics.Color titleBackground
-
titleBackgroundGradient
private boolean titleBackgroundGradient
-
titleBackground2
private org.eclipse.swt.graphics.Color titleBackground2
-
maxImageWidth
private int maxImageWidth
-
maxImageHeight
private int maxImageHeight
-
imageSize
private org.eclipse.swt.graphics.Point imageSize
-
fillIfSingleColumn
private boolean fillIfSingleColumn
If true, this flag 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.
-
fill
private boolean fill
This flag is set during layout, if fillIfSigle is true, and if there is only one column or row
-
marginCalculated
boolean marginCalculated
True if margins have already been calculated. Prevents margins calculation for each group
-
font
private org.eclipse.swt.graphics.Font font
-
animation
protected boolean animation
-
animationLength
protected int animationLength
-
animationOpenMovement
protected IMovement animationOpenMovement
-
animationCloseMovement
protected IMovement animationCloseMovement
-
DATA_ANIMATION
protected static final java.lang.String DATA_ANIMATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
setGallery
public void setGallery(Gallery gallery)
- 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
protected int getGroupHeight(GalleryItem group)
-
drawGroup
protected void drawGroup(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight)
-
drawGroupImage
private int drawGroupImage(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, org.eclipse.swt.graphics.Point imageSize2)
-
getGroupTitle
protected java.lang.String getGroupTitle(GalleryItem group)
-
getGroupOffset
protected int getGroupOffset(GalleryItem item)
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
public void layout(org.eclipse.swt.graphics.GC gc, GalleryItem group)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)
-
pre
private void pre(org.eclipse.swt.graphics.GC myGc)
Prepare font metrics and title height for both preLayout and preDraw.- Parameters:
myGc-
-
getItem
public GalleryItem getItem(GalleryItem group, org.eclipse.swt.graphics.Point coords)
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
protected void startGroupAnimation(GalleryItem group, boolean doOpen)
-
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
public org.eclipse.swt.graphics.Rectangle getSize(GalleryItem item)
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
public IMovement getAnimationOpenMovement()
Get the current movement used for animation- Returns:
- See Also:
setAnimationOpenMovement(IMovement)
-
getAnimationCloseMovement
public IMovement getAnimationCloseMovement()
- Returns:
- See Also:
setAnimationCloseMovement(IMovement)
-
setAnimationOpenMovement
public void setAnimationOpenMovement(IMovement animationMovement)
Set the movement used for open animation.- Parameters:
animationMovement-- See Also:
setAnimation(boolean),setAnimationLength(int)
-
setAnimationCloseMovement
public void setAnimationCloseMovement(IMovement animationMovement)
Set the movement used for close animation.- Parameters:
animationMovement-- See Also:
setAnimation(boolean),setAnimationLength(int)
-
isGroupExpanded
protected boolean isGroupExpanded(GalleryItem item)
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()
-
-