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 boolean
animation
protected IMovement
animationCloseMovement
protected int
animationLength
protected IMovement
animationOpenMovement
protected static java.lang.String
DATA_ANIMATION
(package private) boolean
marginCalculated
True 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_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
Modifier and Type Method Description void
draw(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 void
drawGroup(org.eclipse.swt.graphics.GC gc, GalleryItem group, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight)
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.protected int
drawGroupToggleButton(org.eclipse.swt.graphics.GC gc, int x, int y, GalleryItem group)
Draw the toggle button.protected void
drawItem(org.eclipse.swt.graphics.GC gc, int index, boolean selected, GalleryItem parent, int offsetY)
Draw a child item.IMovement
getAnimationCloseMovement()
int
getAnimationLength()
IMovement
getAnimationOpenMovement()
Get the current movement used for animationorg.eclipse.swt.graphics.Font
getFont()
Returns the font used for drawing the group title or null if system font is used.protected int
getGroupHeight(GalleryItem group)
protected int
getGroupOffset(GalleryItem item)
Returns a group offset (size of title + margin)protected java.lang.String
getGroupTitle(GalleryItem group)
GalleryItem
getItem(GalleryItem group, org.eclipse.swt.graphics.Point coords)
Returns the item at coords relative to the parent group.int
getMaxImageHeight()
int
getMaxImageWidth()
int
getScrollBarIncrement()
Returns the preferred Scrollbar increment for the current gallery layout.org.eclipse.swt.graphics.Rectangle
getSize(GalleryItem item)
Returns the size of a group.org.eclipse.swt.graphics.Color
getTitleBackground()
org.eclipse.swt.graphics.Color
getTitleBackground2()
org.eclipse.swt.graphics.Color
getTitleForeground()
Get group title text color.protected org.eclipse.swt.graphics.Rectangle
getToggleButtonBounds()
boolean
isAnimation()
boolean
isFillIfSingleColumn()
protected boolean
isGroupExpanded(GalleryItem item)
Return item expand state (item.isExpanded()) Returns always true is alwaysExpanded is set to true.boolean
isTitleBackgroundGradient()
void
layout(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.boolean
mouseDown(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.void
preDraw(org.eclipse.swt.graphics.GC gc)
This method is called before drawing the first item.void
preLayout(org.eclipse.swt.graphics.GC gc)
This method is called before the layout of the first item.void
setAnimation(boolean animation)
Enable animation for group expand/collapse.void
setAnimationCloseMovement(IMovement animationMovement)
Set the movement used for close animation.void
setAnimationLength(int animationLength)
Set the length of the animationvoid
setAnimationOpenMovement(IMovement animationMovement)
Set the movement used for open animation.void
setFillIfSingleColumn(boolean fillIfSingle)
Experimental feature.void
setFont(org.eclipse.swt.graphics.Font font)
Set the font for drawing the group title or null to use system font.void
setGallery(Gallery gallery)
void
setMaxImageHeight(int imageHeight)
Set the maximum height for a group image in the title bar.void
setMaxImageWidth(int imageWidth)
Set the maximum width for a group image in the title bar.void
setTitleBackground(org.eclipse.swt.graphics.Color titleBackground)
void
setTitleBackgroundGradient(org.eclipse.swt.graphics.Color gradientBackground, org.eclipse.swt.graphics.Color gradientForeground)
void
setTitleForeground(org.eclipse.swt.graphics.Color titleColor)
Change group title text color.protected void
startGroupAnimation(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 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:
setGallery
in 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:AbstractGalleryGroupRenderer
Group size informations can be retrieved from group. Clipping informations -
layout
Description copied from class:AbstractGalleryGroupRenderer
This 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:
layout
in classAbstractGridGroupRenderer
-
preDraw
public void preDraw(org.eclipse.swt.graphics.GC gc)Description copied from class:AbstractGalleryGroupRenderer
This 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:
preDraw
in classAbstractGalleryGroupRenderer
-
preLayout
public void preLayout(org.eclipse.swt.graphics.GC gc)Description copied from class:AbstractGalleryGroupRenderer
This 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:
preLayout
in classAbstractGridGroupRenderer
- See Also:
(org.eclipse.swt.graphics.GC)
-
getItem
Description copied from class:AbstractGalleryGroupRenderer
Returns the item at coords relative to the parent group.- Overrides:
getItem
in 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:AbstractGalleryGroupRenderer
This method can be implemented to handle mouse down events at the group level. Usually to interact with custom group UI.- Specified by:
mouseDown
in 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:AbstractGalleryGroupRenderer
Returns the size of a group.- Overrides:
getSize
in 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:AbstractGridGroupRenderer
Draw a child item. Only used when useGroup is true. -
getScrollBarIncrement
public int getScrollBarIncrement()Description copied from class:AbstractGalleryGroupRenderer
Returns the preferred Scrollbar increment for the current gallery layout.- Overrides:
getScrollBarIncrement
in 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:AbstractGridGroupRenderer
Return item expand state (item.isExpanded()) Returns always true is alwaysExpanded is set to true.- Overrides:
isGroupExpanded
in classAbstractGridGroupRenderer
- Returns:
-
isTitleBackgroundGradient
public boolean isTitleBackgroundGradient() -
getTitleBackground2
public org.eclipse.swt.graphics.Color getTitleBackground2()
-