pl.netanel.swt.matrix.reloaded
Class ButtonCellBehavior<X extends java.lang.Number,Y extends java.lang.Number>

java.lang.Object
  extended by pl.netanel.swt.matrix.Painter<X,Y>
      extended by pl.netanel.swt.matrix.reloaded.ButtonCellBehavior<X,Y>
Type Parameters:
Y - indexing type for vertical axis
X - indexing type for horizontal axis

public class ButtonCellBehavior<X extends java.lang.Number,Y extends java.lang.Number>
extends Painter<X,Y>

Adds (or replaces) a painter named "button cells" that emulates a raised button shape.

When the cell is clicked the look of the cell becomes flat.

Only 2 pixel wide edge of cells is painted so the majority of the output of the underlying Painter.NAME_CELLS painter remains visible. Colors used are SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW, SWT.COLOR_WIDGET_LIGHT_SHADOW and SWT.COLOR_WIDGET_NORMAL_SHADOW.

Cells in the zone become not selectable.

Usage example:

 new ButtonCellPainter(matrix.getColumnHeader());
 


Field Summary
 
Fields inherited from class pl.netanel.swt.matrix.Painter
availableTextArea, collapsedImage, expanded, expandedImage, extent, frozenX, frozenY, gc, hasChildren, image, imagesAfter, imagesBefore, isSelected, NAME_BACKGORUND, NAME_CELLS, NAME_DRAG_ITEM_X, NAME_DRAG_ITEM_Y, NAME_EMBEDDED_CONTROLS, NAME_EMULATED_CONTROLS, NAME_FOCUS_CELL, NAME_FREEZE_HEAD_LINE_X, NAME_FREEZE_HEAD_LINE_Y, NAME_FREEZE_TAIL_LINE_X, NAME_FREEZE_TAIL_LINE_Y, NAME_FROZEN_HEAD_HEAD, NAME_FROZEN_HEAD_NONE, NAME_FROZEN_HEAD_TAIL, NAME_FROZEN_NONE_HEAD, NAME_FROZEN_NONE_NONE, NAME_FROZEN_NONE_TAIL, NAME_FROZEN_TAIL_HEAD, NAME_FROZEN_TAIL_NONE, NAME_FROZEN_TAIL_TAIL, NAME_LINES_X, NAME_LINES_Y, nodeImageSize, SCOPE_CELLS, SCOPE_CELLS_ITEM_X, SCOPE_CELLS_ITEM_Y, SCOPE_CELLS_X, SCOPE_CELLS_Y, SCOPE_ENTIRE, SCOPE_LINES_X, SCOPE_LINES_Y, selectionHighlight, style, text, textLayout
 
Constructor Summary
ButtonCellBehavior(Zone<X,Y> zone)
           
 
Method Summary
 void clean()
          Restores the default GC settings modified by modified by in Painter.init() or Painter.paint(int, int, int, int).
 void handleEvent(Event e)
           
protected  boolean init()
          Allows graphic optimization by performing operation that can be taken out of the cell painting loop.
protected  boolean isPushed(X indexX, Y indexY)
          Returns true if the cell at the specified location is in pushed state, or false otherwise.
static void main(java.lang.String[] args)
           
 void paint(int x, int y, int width, int height)
          Draws on the canvas within the given boundaries according to the given indexes.
protected  void paintIdle(int x, int y, int width, int height)
          Paints the cell when it is in the idle (not pushed) state.
protected  void paintPushed(int x, int y, int width, int height)
          Paints the cell when it is in the pushed state.
 void setup(X indexX, Y indexY)
          Configures the painter properties according to the given indexes.
 
Methods inherited from class pl.netanel.swt.matrix.Painter
align, clipText, computeSize, computeTextSize, dispose, getData, getImageAt, getName, getScope, getZone, hasTreeLinesVisible, isEnabled, isTreeEnabled, setData, setEnabled, setNodeImages, setTreeLinesVisible, setTreeVisible, setupSpatial, trackPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButtonCellBehavior

public ButtonCellBehavior(Zone<X,Y> zone)
Method Detail

handleEvent

public void handleEvent(Event e)

init

protected boolean init()
Description copied from class: Painter
Allows graphic optimization by performing operation that can be taken out of the cell painting loop.

If this method returns false the Painter.paint(int, int, int, int) and Painter.clean() methods will not be executed.

Overrides:
init in class Painter<X extends java.lang.Number,Y extends java.lang.Number>
Returns:
true if the initialization succeeded or false otherwise.
See Also:
clean()

setup

public void setup(X indexX,
                  Y indexY)
Description copied from class: Painter
Configures the painter properties according to the given indexes.

Default implementation invokes Painter.setupSpatial(Number, Number) and determines if the cell is selected, therefore when overridden should call super.setup.

Overrides:
setup in class Painter<X extends java.lang.Number,Y extends java.lang.Number>
Parameters:
indexX - cell index on the horizontal axis
indexY - cell index on the vertical axis

paint

public void paint(int x,
                  int y,
                  int width,
                  int height)
Description copied from class: Painter
Draws on the canvas within the given boundaries according to the given indexes.

Overrides:
paint in class Painter<X extends java.lang.Number,Y extends java.lang.Number>
Parameters:
x - the x coordinate of the painting boundaries
y - the y coordinate of the painting boundaries
width - the width of the painting boundaries
height - the height of the painting boundaries

isPushed

protected boolean isPushed(X indexX,
                           Y indexY)
Returns true if the cell at the specified location is in pushed state, or false otherwise.

Parameters:
indexX - index of a section item in the horizontal axis
indexY - index of a section item in the vertical axis.
Returns:
true if the cell at the specified location is in pushed state

paintPushed

protected void paintPushed(int x,
                           int y,
                           int width,
                           int height)
Paints the cell when it is in the pushed state.

Parameters:
x - the x coordinate of the painting boundaries
y - the y coordinate of the painting boundaries
width - the width of the painting boundaries
height - the height of the painting boundaries

paintIdle

protected void paintIdle(int x,
                         int y,
                         int width,
                         int height)
Paints the cell when it is in the idle (not pushed) state.

Parameters:
x - the x coordinate of the painting boundaries
y - the y coordinate of the painting boundaries
width - the width of the painting boundaries
height - the height of the painting boundaries

clean

public void clean()
Description copied from class: Painter
Restores the default GC settings modified by modified by in Painter.init() or Painter.paint(int, int, int, int).

Overrides:
clean in class Painter<X extends java.lang.Number,Y extends java.lang.Number>
See Also:
init()

main

public static void main(java.lang.String[] args)


Copyright © 2011 netanel.pl. All Rights Reserved.