|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.groovemanager.gui.custom.CustomComposite
com.groovemanager.gui.custom.ScaleNum
This CustomComposite consists of a number displayed on a button. The value of the number can be changed by selecting and moving with the mouse, by double-clicking and entering it manually or by selecting the Composite and using the Up/Down-Arrows or the PageUp/PageDown-Keys. The idea was to create an alternative to Scale for integer user input
| Field Summary | |
|---|---|
private org.eclipse.swt.widgets.Button |
button
The button showing the current value |
private int |
dcTime
The double click time |
private int |
def
Minimum value |
private boolean |
editing
true if the Text field for user input is currently shown, false otherwise |
private int |
lastChange
Temporary variables |
private int |
lastClick
Temporary variables |
private int |
lastMove
Temporary variables |
private int |
lastX
Temporary variables |
private org.eclipse.swt.custom.StackLayout |
layout
The layout used to show either the button or the text field |
private int |
max
Minimum value |
private int |
min
Minimum value |
private static int |
MOUSE_OFFSET
Number of pixels the mouse has to be moved up or down to change the value |
private boolean |
mousedown
Indicates, if the mouse button is currently pressed or not |
private boolean |
readonly
Indicates whether this Composite has been created with READ_ONLY style or not |
private int |
selection
Minimum value |
private double |
speed
A value for the speed of the mouse movement |
private org.eclipse.swt.widgets.Text |
userInput
Text field for user-input of the value; shown when double-clicking |
| Constructor Summary | |
|---|---|
ScaleNum(org.eclipse.swt.widgets.Composite parent,
int style)
Construct a new ScaleNum |
|
| Method Summary | |
|---|---|
void |
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Add a SelectionListener that will be notified of value changes |
private void |
checkMinMax()
Internal methodd for keeping the values for minimum, maximum, default and the current value in a consistent state |
protected org.eclipse.swt.widgets.Composite |
createComposite(org.eclipse.swt.widgets.Composite parent,
int style)
This method is to be overwritten by concrete subclasses to create the real contents of this CustomComposite |
private void |
finishEditing()
Hide the text field |
int |
getDefault()
Get the default value |
protected int[] |
getListenerTypes()
For all types of listeners that should be possible to add to this Composite directly, the corresponding SWT.* constant should be contained in the returned Array. |
int |
getMaximum()
Get the maximum value |
int |
getMinimum()
Get the minimum value |
protected int |
getPossibleStyles()
Get a combination of all allowed SWT.* style constants |
int |
getSelection()
Get the current value |
protected void |
notifyListeners(int time)
Notify the registered SelectionListeners of a value change |
void |
setAll(int defaultSelected,
int minimum,
int maximum)
Set the minimum, maximum and default value. |
void |
setDefault(int d)
Set the default value |
void |
setDefaultAndSelection(int i)
Set the default value and the current value to the specified value |
void |
setMaximum(int m)
Set the maximum value |
void |
setMinimum(int m)
Set the minimum value |
void |
setSelection(int s)
Set the current value |
protected void |
setSelection(int s,
boolean updateText)
Internal method for value change |
private void |
startEditing()
Show the text field for user input |
private void |
startMouseDrag()
Indicates that a mouse dragging has been started for changing the value |
private void |
stopMouseDrag()
Indicates that mouse dragging has been stopped |
| Methods inherited from class com.groovemanager.gui.custom.CustomComposite |
|---|
addListener, checkStyle, getComposite, getData, getListeners, getParent, removeListener, setData, setLayoutData |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private org.eclipse.swt.widgets.Button button
private final int dcTime
private int def
private boolean editing
private int lastChange
private int lastClick
private int lastMove
private int lastX
private org.eclipse.swt.custom.StackLayout layout
private int max
private int min
private static final int MOUSE_OFFSET
private boolean mousedown
private boolean readonly
private int selection
private double speed
private org.eclipse.swt.widgets.Text userInput
| Constructor Detail |
|---|
public ScaleNum(org.eclipse.swt.widgets.Composite parent,
int style)
parent - The parent Compositestyle - Combination of SWT.* style constants.
Allowed values are:SWT.FLAT: For flat appearanceSWT.READ_ONLY: For the user not being able to change the
valueSWT.BORDER: For surrounding this Composite with a borderSWT.LEFT, SWT.CENTER or SWT.RIGHT:
For specification of this Composite´s alignment| Method Detail |
|---|
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
listener - The SelectionListener to addprivate void checkMinMax()
protected org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent,
int style)
CustomComposite
createComposite in class CustomCompositeparent - The parent Composite under which this Composite should
be createdstyle - Combination of valid SWT.* style constants
private void finishEditing()
public int getDefault()
protected int[] getListenerTypes()
CustomComposite
getListenerTypes in class CustomCompositepublic int getMaximum()
public int getMinimum()
protected int getPossibleStyles()
CustomComposite
getPossibleStyles in class CustomCompositeSWT.BORDER | SWT.LEFT | SWT.BORDERpublic int getSelection()
protected void notifyListeners(int time)
time - The time at which this event was generated
public void setAll(int defaultSelected,
int minimum,
int maximum)
defaultSelected - The default valueminimum - The minimum valuemaximum - The maximum valuepublic void setDefault(int d)
d - The default valuepublic void setDefaultAndSelection(int i)
i - The new valuepublic void setMaximum(int m)
m - The maximum valuepublic void setMinimum(int m)
m - The minimum valuepublic void setSelection(int s)
s - The current value
protected void setSelection(int s,
boolean updateText)
s - The new valueupdateText - true, if the content of the Text field should also be
updated, false otherwise. This parameter is for avoiding endless loops
of change notifications going on between this ScaleNum and its text
field.private void startEditing()
private void startMouseDrag()
private void stopMouseDrag()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||