org.opensubsystems.patterns.thickclient.application.swt
Class NumericText

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.opensubsystems.patterns.thickclient.application.swt.NumericText
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class NumericText
extends org.eclipse.swt.widgets.Composite

Text field allowing to type only numbers.

Version:
$Id: NumericText.java,v 1.2 2007/01/07 06:14:15 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
protected  boolean m_bDecimalPoint
          If true then numbers with decimal point are allowed (there can be at most 1 decimal point character in the number).
protected  char m_cDecimalPoint
          Decimal point character to use.
protected  java.lang.String m_strDecimalPoint
          Decimal point string to use.
protected  org.eclipse.swt.widgets.Text m_textField
          Text field used by this composite.
static int MAX_DECIMAL_DIGITS
          Maximum number of digits allowed after the decimal point.
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
NumericText(org.eclipse.swt.widgets.Composite parent, int style, boolean bDecimalPoint)
          Create text field, which accepts only numbers.
 
Method Summary
 org.eclipse.swt.widgets.Layout createLayout()
          Create layout which will be used by this control.
 java.lang.String getDecimalPointText()
           
 org.eclipse.swt.widgets.Text getTextField()
          Get text field used by this composite.
 boolean setTextLimit(int iLimit)
          This function sets maximal number of characters typed.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_cDecimalPoint

protected char m_cDecimalPoint
Decimal point character to use.


m_strDecimalPoint

protected java.lang.String m_strDecimalPoint
Decimal point string to use.


MAX_DECIMAL_DIGITS

public static final int MAX_DECIMAL_DIGITS
Maximum number of digits allowed after the decimal point.

See Also:
Constant Field Values

m_textField

protected org.eclipse.swt.widgets.Text m_textField
Text field used by this composite.


m_bDecimalPoint

protected boolean m_bDecimalPoint
If true then numbers with decimal point are allowed (there can be at most 1 decimal point character in the number).

Constructor Detail

NumericText

public NumericText(org.eclipse.swt.widgets.Composite parent,
                   int style,
                   boolean bDecimalPoint)
Create text field, which accepts only numbers.

Parameters:
parent - - parent which owns this text field
style - - style to use for this text field
bDecimalPoint - - if true, number can contain decimal point
Method Detail

getTextField

public org.eclipse.swt.widgets.Text getTextField()
Get text field used by this composite.

Returns:
Text

createLayout

public org.eclipse.swt.widgets.Layout createLayout()
Create layout which will be used by this control.

Returns:
Layout - layout to use by this control.

setTextLimit

public boolean setTextLimit(int iLimit)
This function sets maximal number of characters typed. If decimal point is allowed then this count has to include the decimal point. This method has to be called BEFORE any text is present in the field.

Parameters:
iLimit - - maximal number of characters
Returns:
boolean - sucess flag

getDecimalPointText

public java.lang.String getDecimalPointText()
Returns:
String - string representing decimal point


Copyright © 2003 - 2006 OpenSubsystems s.r.o.