Class Gallery
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class Gallery
extends org.eclipse.swt.widgets.Canvas
SWT Widget that displays an image gallery
see https://www.eclipse.org/nebula/widgets/gallery/gallery.php
This widget requires jdk-1.8+
Style VIRTUAL is used to create a Gallery whose
GalleryItems are to be populated by the client on an on-demand
basis instead of up-front. This can provide significant performance
improvements for galleries that are very large or for which
GalleryItem population is expensive (for example, retrieving
values from an external source).
Here is an example of using a Gallery with style
VIRTUAL:
final Gallery gallery = new Gallery(parent, SWT.VIRTUAL | V_SCROLL | SWT.BORDER);
gallery.setGroupRenderer(new DefaultGalleryGroupRenderer());
gallery.setItemRenderer(new DefaultGalleryItemRenderer());
gallery.setItemCount(1000000);
gallery.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
GalleryItem item = (GalleryItem) event.item;
int index = gallery.indexOf(item);
item.setText("Item " + index);
System.out.println(item.getText());
}
});
- Styles:
- SINGLE, MULTI, VIRTUAL, V_SCROLL, H_SCROLL
Note: Only one of the styles SINGLE and MULTI may be specified.
Note: Only one of the styles V_SCROLL and H_SCROLL may be specified.
- Events:
- Selection, DefaultSelection, SetData, PaintItem
NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.
-
Field Summary
Fields Modifier and Type Field Description (package private) intantialiasImage quality : antialiasprotected static booleanDEBUGUsed to enable debug logging in the Gallery widget.(package private) AbstractGalleryGroupRenderergroupRendererprotected inthigherQualityDelay(package private) intinterpolationImage quality : interpolation(package private) AbstractGalleryItemRendereritemRenderer(package private) GalleryItem[]itemsprotected intlastContentHeightprotected intlastContentWidthprotected intlastControlHeightprotected intlastControlWidth(package private) intlastIndexOfprotected GalleryItemlastSingleClickKeeps track of the last selected item.protected intlastTranslateValue(package private) booleanlowQualityOnUserActionLow quality on user action : decrease drawing quality on scrolling or resize.(package private) booleanmultiMulti-selection flag(package private) java.lang.RunnableredrawTimerprotected int[]selectionFlagsSelection bit flags.protected inttranslateCurrent translation (scroll bar position).(package private) booleanverticalScrolling direction flag.(package private) booleanvirtualVirtual mode flag.(package private) intvirtualGroupDefaultItemCount(package private) booleanvirtualGroupsUltra virtual : non visible groups are not initialized.(package private) booleanvirtualGroupsCompatibilityMode -
Constructor Summary
Constructors Constructor Description Gallery(org.eclipse.swt.widgets.Composite parent, int style)Create a Gallery -
Method Summary
Modifier and Type Method Description protected void_addSelection(GalleryItem item)protected java.lang.Object[]_arrayAddItem(java.lang.Object[] array, java.lang.Object object, int index)Adds an item to an array.protected int_arrayIndexOf(int[] array, int value)protected int_arrayIndexOf(java.lang.Object[] array, java.lang.Object value)protected int[]_arrayRemoveItem(int[] array, int index)protected java.lang.Object[]_arrayRemoveItem(java.lang.Object[] array, int index)protected void_deselectAll(boolean notifyListeners)Deselects all items and send selection event depending on parameter.protected GalleryItem_getItem(int index)Get the item at index.
If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData is fired.
This is the internal implementation of this method : checkWidget() is not used.protected GalleryItem_getItem(int index, boolean create)Get the item at 'index'.
If SWT.VIRTUAL is used, 'create' is true and the item has not been used yet, the item is created and a SWT.SetData is fired.protected GalleryItem_getItem(GalleryItem parent, int index)This method is used by items to implement getItem( index )protected int_indexOf(GalleryItem item)Returns the index of a GalleryItem when it is a root Itemprotected int_indexOf(GalleryItem parentItem, GalleryItem item)Returns the index of a GalleryItem when it is not a root Itemprotected boolean_mouseDown(org.eclipse.swt.widgets.Event event)Forward the mouseDown event to the corresponding group according to the mouse position.protected void_remove(int index)protected void_remove(GalleryItem parent, int index)protected void_removeSelection(GalleryItem parent, GalleryItem item)protected void_selectAll()void_setGalleryItems(GalleryItem[] items)(package private) void_showItem(GalleryItem item)protected voidaddItem(GalleryItem item, int position)voidaddSelectionListener(org.eclipse.swt.events.SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in theSelectionListenerinterface.voidaddTreeListener(org.eclipse.swt.events.TreeListener listener)Adds the listener to the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface.voidclear(int index)Clear one item.voidclear(int index, boolean all)Clear one item and all its children if 'all' is truevoidclearAll()Clear all GalleryGroupsvoidclearAll(boolean all)Clear all Gallery items.
If the Gallery is virtual, the item count is not reseted and all items will be created again at their first use.voiddeselectAll()Deselects all items.intgetAntialias()org.eclipse.swt.graphics.ColorgetBackground()org.eclipse.swt.graphics.ColorgetBackground(boolean galleryOnly)Returns the receiver's background color.org.eclipse.swt.graphics.ColorgetForeground()org.eclipse.swt.graphics.ColorgetForeground(boolean galleryOnly)Returns the receiver's foreground color.GalleryItemgetGroup(org.eclipse.swt.graphics.Point coords)Get group at pixel position (relative to client area).AbstractGalleryGroupRenderergetGroupRenderer()intgetHigherQualityDelay()intgetInterpolation()GalleryItemgetItem(int index)Get the item at index.
If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData event is fired.GalleryItemgetItem(org.eclipse.swt.graphics.Point coords)Get item at pixel positionintgetItemCount()Return the number of root-level items in the receiver.AbstractGalleryItemRenderergetItemRenderer()Get current item rendererGalleryItem[]getItems()GalleryItem[]getSelection()intgetSelectionCount()intgetVirtualGroupDefaultItemCount()intindexOf(GalleryItem item)Returns the index of a GalleryItem.booleanisLowQualityOnUserAction()protected booleanisSelected(GalleryItem item)booleanisUseControlColors()booleanisVertical()Checks if the Gallery was created with SWT.V_SCROLL (ie has a vertical scroll bar).booleanisVirtualGroups()booleanisVirtualGroupsCompatibilityMode()protected voidnotifySelectionListeners(GalleryItem item, int index, boolean isDefault)Send a selection event for a gallery itemprotected voidnotifyTreeListeners(GalleryItem item, boolean state)Send an Expand event for a GalleryItem(package private) voidonDispose()Clean up the Gallery and renderers on dispose.(package private) voidonMouseDoubleClick(org.eclipse.swt.widgets.Event e)(package private) voidonMouseDown(org.eclipse.swt.widgets.Event e)(package private) voidonMouseHandleLeft(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)(package private) voidonMouseHandleRight(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)Handle right click.(package private) voidonMouseUp(org.eclipse.swt.widgets.Event e)(package private) voidonPaint(org.eclipse.swt.graphics.GC gc)voidredraw(GalleryItem item)Redraw the item given as parameter.voidrefresh(int index)Refresh item by firering SWT.SetData.voidremove(int index)voidremove(GalleryItem item)voidremoveAll()voidremoveSelectionListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.voidremoveTreeListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed.protected voidscrollHorizontal()protected voidscrollVertical()voidselectAll()Selects all of the items in the receiver.protected voidsendPaintItemEvent(org.eclipse.swt.widgets.Item item, int index, org.eclipse.swt.graphics.GC gc, int x, int y, int width, int height)Send SWT.PaintItem for one item.voidsetAntialias(int antialias)Sets the gallery's anti-aliasing value to the parameter, which must be one ofSWT.DEFAULT,SWT.OFForSWT.ON.voidsetBackground(org.eclipse.swt.graphics.Color color)protected voidsetData(GalleryItem galleryItem, int index)Sends SWT.SetData event.voidsetForeground(org.eclipse.swt.graphics.Color color)voidsetGroupRenderer(AbstractGalleryGroupRenderer groupRenderer)voidsetHigherQualityDelay(int higherQualityDelay)Set the delay after the last user action before the redraw at higher quality is triggeredvoidsetInterpolation(int interpolation)Sets the gallery's interpolation setting to the parameter, which must be one ofSWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH.voidsetItemCount(int count)Sets the number of root-level items contained in the receiver.voidsetItemRenderer(AbstractGalleryItemRenderer itemRenderer)Set item receiver.voidsetLowQualityOnUserAction(boolean lowQualityOnUserAction)If set to true, the gallery will disable antialiasing and interpolation while the user is resizing or scrolling the gallery.protected voidsetSelected(GalleryItem item, boolean selected, boolean notifyListeners)Toggle item selection statusvoidsetSelection(GalleryItem[] items)voidsetUseControlColors(boolean useControlColors)Set useControlColors to true in order to get colors from parent Control (SWT default).voidsetVertical(boolean vertical)Deprecated.voidsetVirtualGroupDefaultItemCount(int defaultItemCount)Set the item count used when a group is not yet initialized (with virtual groups).voidsetVirtualGroups(boolean virtualGroups)Enable virtual groupsvoidsetVirtualGroupsCompatibilityMode(boolean compatibilityMode)Enable the compatibility workaround for problems with the ultra virtual mode.voidshowItem(GalleryItem item)Scroll the Gallery in order to make 'item' visible.protected voidupdateScrollBarsProperties()Move the scrollbar to reflect the current visible items position.protected voidupdateStructuralValues(boolean keepLocation)Deprecated.UseupdateStructuralValues(GalleryItem,boolean)insteadprotected voidupdateStructuralValues(GalleryItem changedGroup, boolean keepLocation)Recalculate structural values using the group renderer
Gallery and item size will be updated.Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIMEMethods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateMethods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
DEBUG
protected static boolean DEBUGUsed to enable debug logging in the Gallery widget. -
items
GalleryItem[] items -
selectionFlags
protected int[] selectionFlagsSelection bit flags. Each 'int' contains flags for 32 items. -
virtual
boolean virtualVirtual mode flag. -
virtualGroups
boolean virtualGroupsUltra virtual : non visible groups are not initialized. -
virtualGroupsCompatibilityMode
boolean virtualGroupsCompatibilityMode -
virtualGroupDefaultItemCount
int virtualGroupDefaultItemCount -
vertical
boolean verticalScrolling direction flag. True : V_SCROLL, false : H_SCROLL. -
multi
boolean multiMulti-selection flag -
interpolation
int interpolationImage quality : interpolation -
antialias
int antialiasImage quality : antialias -
lastIndexOf
int lastIndexOf -
lastSingleClick
Keeps track of the last selected item. This is necessary to support "Shift+Mouse button" where we have to select all items between the previous and the current item and keyboard navigation. -
translate
protected int translateCurrent translation (scroll bar position). Can be used by renderer during paint. -
lowQualityOnUserAction
boolean lowQualityOnUserActionLow quality on user action : decrease drawing quality on scrolling or resize. (faster) -
lastTranslateValue
protected int lastTranslateValue -
lastControlWidth
protected int lastControlWidth -
lastControlHeight
protected int lastControlHeight -
lastContentHeight
protected int lastContentHeight -
lastContentWidth
protected int lastContentWidth -
higherQualityDelay
protected int higherQualityDelay -
itemRenderer
AbstractGalleryItemRenderer itemRenderer -
groupRenderer
AbstractGalleryGroupRenderer groupRenderer -
redrawTimer
java.lang.Runnable redrawTimer
-
-
Constructor Details
-
Gallery
public Gallery(org.eclipse.swt.widgets.Composite parent, int style)Create a Gallery- Parameters:
parent-style- - SWT.VIRTUAL switches in virtual mode.
SWT.V_SCROLL add vertical slider and switches to vertical mode.
SWT.H_SCROLL add horizontal slider and switches to horizontal mode.
if both V_SCROLL and H_SCROLL are specified, the gallery is in vertical mode by default. Mode can be changed afterward using setVertical
SWT.MULTI allows only several items to be selected at the same time.
-
-
Method Details
-
getItemCount
public int getItemCount()Return the number of root-level items in the receiver. Does not include children.- Returns:
-
setItemCount
public void setItemCount(int count)Sets the number of root-level items contained in the receiver. Only work in VIRTUAL mode. -
getItemRenderer
Get current item renderer- Returns:
-
setItemRenderer
Set item receiver. Usually, this does not trigger gallery update. redraw must be called right after setGroupRenderer to reflect this change.- Parameters:
itemRenderer-
-
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in theSelectionListenerinterface.When
widgetSelectedis called, the item field of the event object is valid.- Parameters:
listener- the listener which should be notified- Throws:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener,removeSelectionListener(org.eclipse.swt.events.SelectionListener),SelectionEvent
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.- Parameters:
listener- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener,addSelectionListener(SelectionListener)
-
removeTreeListener
public void removeTreeListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed.- Parameters:
listener-
-
addTreeListener
public void addTreeListener(org.eclipse.swt.events.TreeListener listener)Adds the listener to the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface.- Parameters:
listener-
-
sendPaintItemEvent
protected void sendPaintItemEvent(org.eclipse.swt.widgets.Item item, int index, org.eclipse.swt.graphics.GC gc, int x, int y, int width, int height)Send SWT.PaintItem for one item.- Parameters:
item-index-gc-x-y-
-
isLowQualityOnUserAction
public boolean isLowQualityOnUserAction()- Returns:
-
setLowQualityOnUserAction
public void setLowQualityOnUserAction(boolean lowQualityOnUserAction)If set to true, the gallery will disable antialiasing and interpolation while the user is resizing or scrolling the gallery. This enables faster redraws at the cost of lower image quality. When every redraw is finished a last one will be issued using the default (higher) quality.- Parameters:
lowQualityOnUserAction-- See Also:
setHigherQualityDelay(int)
-
getHigherQualityDelay
public int getHigherQualityDelay()- Returns:
- See Also:
setHigherQualityDelay(int)
-
setHigherQualityDelay
public void setHigherQualityDelay(int higherQualityDelay)Set the delay after the last user action before the redraw at higher quality is triggered- Parameters:
higherQualityDelay-- See Also:
setLowQualityOnUserAction(boolean)
-
getInterpolation
public int getInterpolation()- Returns:
- See Also:
setInterpolation(int)
-
setInterpolation
public void setInterpolation(int interpolation)Sets the gallery's interpolation setting to the parameter, which must be one ofSWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH.- Parameters:
interpolation-
-
getAntialias
public int getAntialias()- Returns:
- See Also:
setAntialias(int)
-
setAntialias
public void setAntialias(int antialias)Sets the gallery's anti-aliasing value to the parameter, which must be one ofSWT.DEFAULT,SWT.OFForSWT.ON.- Parameters:
antialias-
-
notifySelectionListeners
Send a selection event for a gallery item- Parameters:
item-
-
notifyTreeListeners
Send an Expand event for a GalleryItem- Parameters:
item-index-
-
showItem
Scroll the Gallery in order to make 'item' visible.- Parameters:
item- Item to show
-
_showItem
-
setSelected
Toggle item selection status- Parameters:
item- Item which state is to be changed.selected- true is the item is now selected, false if it is now unselected.notifyListeners- If true, a selection event will be sent to all the current selection listeners.
-
_addSelection
-
_removeSelection
-
isSelected
-
deselectAll
public void deselectAll()Deselects all items. -
_deselectAll
protected void _deselectAll(boolean notifyListeners)Deselects all items and send selection event depending on parameter.- Parameters:
notifyListeners- If true, a selection event will be sent to all the current selection listeners.
-
onMouseDoubleClick
void onMouseDoubleClick(org.eclipse.swt.widgets.Event e) -
onMouseUp
void onMouseUp(org.eclipse.swt.widgets.Event e) -
onDispose
void onDispose()Clean up the Gallery and renderers on dispose. -
onMouseDown
void onMouseDown(org.eclipse.swt.widgets.Event e) -
onMouseHandleLeft
void onMouseHandleLeft(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up) -
onMouseHandleRight
void onMouseHandleRight(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)Handle right click.- Parameters:
e-item- : The item which is under the cursor or nulldown-up-
-
onPaint
void onPaint(org.eclipse.swt.graphics.GC gc) -
refresh
public void refresh(int index)Refresh item by firering SWT.SetData.Currently not implemented.
- Parameters:
index-
-
redraw
Redraw the item given as parameter.- Parameters:
item-
-
setData
Sends SWT.SetData event. Used if SWT.VIRTUAL- Parameters:
galleryItem-index-
-
updateStructuralValues
protected void updateStructuralValues(boolean keepLocation)Deprecated.UseupdateStructuralValues(GalleryItem,boolean)insteadRecalculate structural values using the group renderer
Gallery and item size will be updated.- Parameters:
keepLocation- if true, the current scrollbars position ratio is saved and restored even if the gallery size has changed. (Visible items stay visible)
-
updateStructuralValues
Recalculate structural values using the group renderer
Gallery and item size will be updated.- Parameters:
changedGroup- the group that was modified since the last layout. If the group renderer or more that one group have changed, use null as parameter (full update)keepLocation- if true, the current scrollbars position ratio is saved and restored even if the gallery size has changed. (Visible items stay visible)
-
updateScrollBarsProperties
protected void updateScrollBarsProperties()Move the scrollbar to reflect the current visible items position.
The bar which is moved depends of the current gallery scrolling : vertical or horizontal. -
scrollVertical
protected void scrollVertical() -
scrollHorizontal
protected void scrollHorizontal() -
addItem
-
getItem
Get the item at index.
If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData event is fired.- Parameters:
index- index of the item.- Returns:
- the GalleryItem or null if index is out of bounds
-
_getItem
This method is used by items to implement getItem( index )- Parameters:
parent-index-- Returns:
-
_getItem
Get the item at index.
If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData is fired.
This is the internal implementation of this method : checkWidget() is not used.- Parameters:
index-- Returns:
- The item at 'index' (not null)
-
_getItem
Get the item at 'index'.
If SWT.VIRTUAL is used, 'create' is true and the item has not been used yet, the item is created and a SWT.SetData is fired.- Parameters:
index-create-- Returns:
- The item at 'index' or null if there was no item and 'create' was false.
-
_mouseDown
protected boolean _mouseDown(org.eclipse.swt.widgets.Event event)Forward the mouseDown event to the corresponding group according to the mouse position.- Parameters:
event- The original MouseEvent- Returns:
- true if Gallery should continue standard mouse click handling
-
getItem
Get item at pixel position- Parameters:
coords-- Returns:
- GalleryItem or null
-
getGroup
Get group at pixel position (relative to client area).
This is an experimental API which is exposing an internal method, it may become deprecated at some point.
- Parameters:
coords-- Returns:
-
clearAll
public void clearAll(boolean all)Clear all Gallery items.
If the Gallery is virtual, the item count is not reseted and all items will be created again at their first use.- Parameters:
all- If true, all children will be cleared. Only groups are cleared otherwise.
-
clearAll
public void clearAll()Clear all GalleryGroups -
clear
public void clear(int index)Clear one item.- Parameters:
index-
-
clear
public void clear(int index, boolean all)Clear one item and all its children if 'all' is true- Parameters:
index-all-
-
indexOf
Returns the index of a GalleryItem.- Parameters:
parentItem-item-- Returns:
-
_indexOf
Returns the index of a GalleryItem when it is a root Item- Parameters:
parentItem-item-- Returns:
-
_indexOf
Returns the index of a GalleryItem when it is not a root Item- Parameters:
parentItem-item-- Returns:
-
getItems
-
isUseControlColors
public boolean isUseControlColors()- Returns:
- true if Gallery uses parent colors.
- See Also:
setUseControlColors(boolean)
-
setUseControlColors
public void setUseControlColors(boolean useControlColors)Set useControlColors to true in order to get colors from parent Control (SWT default). This may generate more objects on painting and slightly slow down the application. See Bug 279822 : https://bugs.eclipse.org/bugs/show_bug.cgi?id=279822 If enabled, you'll get new Color objects each time you call getXXXColor() on Gallery or GalleryItem. Default is false : colors are stored locally in Gallery, and you'll get the same object each time you call getXXXColor() on Gallery orGalleryItem. The Gallery may not catch color changes on parent control.- Parameters:
useControlColors-
-
getBackground
public org.eclipse.swt.graphics.Color getBackground()- Overrides:
getBackgroundin classorg.eclipse.swt.widgets.Control- See Also:
Control.getBackground()
-
getBackground
public org.eclipse.swt.graphics.Color getBackground(boolean galleryOnly)Returns the receiver's background color.- Parameters:
galleryOnly- If TRUE, does not try to parent widget or Display defaults to guess the real background color. Note : FALSE is the default behavior.- Returns:
- The background color or null if galleryOnly was used and the gallery has not foreground color set.
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getForeground
public org.eclipse.swt.graphics.Color getForeground()- Overrides:
getForegroundin classorg.eclipse.swt.widgets.Control- See Also:
Control.getForeground()
-
getForeground
public org.eclipse.swt.graphics.Color getForeground(boolean galleryOnly)Returns the receiver's foreground color.- Parameters:
galleryOnly- If TRUE, does not try to parent widget or Display defaults to guess the real foreground color. Note : FALSE is the default behavior.- Returns:
- The foreground color or null if galleryOnly was used and the gallery has not foreground color set.
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color)- Overrides:
setBackgroundin classorg.eclipse.swt.widgets.Control- See Also:
Control.setBackground(org.eclipse.swt.graphics .Color)
-
setForeground
public void setForeground(org.eclipse.swt.graphics.Color color)- Overrides:
setForegroundin classorg.eclipse.swt.widgets.Control- See Also:
Control.setForeground(org.eclipse.swt.graphics .Color)
-
isVertical
public boolean isVertical()Checks if the Gallery was created with SWT.V_SCROLL (ie has a vertical scroll bar).- Returns:
- true if the gallery has the SWT.V_SCROLL style.
-
setVertical
public void setVertical(boolean vertical)Deprecated.- Parameters:
vertical-
-
getGroupRenderer
-
setGroupRenderer
-
getSelection
-
getSelectionCount
public int getSelectionCount() -
selectAll
public void selectAll()Selects all of the items in the receiver. -
_selectAll
protected void _selectAll() -
setSelection
-
removeAll
public void removeAll() -
remove
public void remove(int index) -
remove
-
_remove
protected void _remove(int index) -
_remove
-
_arrayRemoveItem
protected java.lang.Object[] _arrayRemoveItem(java.lang.Object[] array, int index) -
_arrayAddItem
protected java.lang.Object[] _arrayAddItem(java.lang.Object[] array, java.lang.Object object, int index)Adds an item to an array.- Parameters:
array-object-index- : if index == -1, item is added at the end of the array.- Returns:
-
_arrayIndexOf
protected int _arrayIndexOf(int[] array, int value) -
_arrayIndexOf
protected int _arrayIndexOf(java.lang.Object[] array, java.lang.Object value) -
_arrayRemoveItem
protected int[] _arrayRemoveItem(int[] array, int index) -
_setGalleryItems
-
isVirtualGroups
public boolean isVirtualGroups()- Returns:
- See Also:
setVirtualGroups(boolean)
-
setVirtualGroups
public void setVirtualGroups(boolean virtualGroups)Enable virtual groupsWhen a gallery has the SWT.VIRTUAL flag, only items are initialized on display. All groups need to be initialized from the beginning to calculate the total size of the content.
Virtual groups enable creating groups AND items lazily at the cost of a poor approximation of the total size of the content.
While a group isn't initialized, the item count defined as default item count is used.
When a group comes into view, it is initialized using the setData event, and the size of the gallery content is updated to match the real value.
From the developer point of view, virtual groups uses exactly the same code as the standard virtual mode of SWT.
This mode can create visual glitches with code that automatically scrolls the widget such as SAT Smooth Scrolling. In that case, you can enable the compatibility mode which is little less lazy that the default virtual groups, but still better than the standard virtual mode
- Parameters:
virtualGroups-- See Also:
setVirtualGroupDefaultItemCount(int),setVirtualGroupsCompatibilityMode(boolean)
-
getVirtualGroupDefaultItemCount
public int getVirtualGroupDefaultItemCount()- Returns:
- See Also:
setVirtualGroupDefaultItemCount(int)
-
isVirtualGroupsCompatibilityMode
public boolean isVirtualGroupsCompatibilityMode()- Returns:
- See Also:
setVirtualGroupsCompatibilityMode(boolean)
-
setVirtualGroupsCompatibilityMode
public void setVirtualGroupsCompatibilityMode(boolean compatibilityMode)Enable the compatibility workaround for problems with the ultra virtual mode.- Parameters:
compatibilityMode-- See Also:
setVirtualGroups(boolean)
-
setVirtualGroupDefaultItemCount
public void setVirtualGroupDefaultItemCount(int defaultItemCount)Set the item count used when a group is not yet initialized (with virtual groups). Since the virtual groups make the size of the gallery change while scrolling, a fine tuned item count can improve the accuracy of the slider.- Parameters:
defaultItemCount-- See Also:
setVirtualGroups(boolean)
-