com.sibvisions.rad.ui.qt.impl.component
Class QtAbstractButton<B extends QAbstractButton>

java.lang.Object
  extended by com.sibvisions.rad.ui.qt.impl.QtResource<C>
      extended by com.sibvisions.rad.ui.qt.impl.QtComponentBase<C>
          extended by com.sibvisions.rad.ui.qt.impl.QtComponent<B>
              extended by com.sibvisions.rad.ui.qt.impl.component.QtAbstractButton<B>
Type Parameters:
B - an QAbstractButton
All Implemented Interfaces:
IActionComponent, IButton, IIcon, ILabel, IToggleActionComponent, IToggleButton, IAlignmentConstants, IComponent, IResource
Direct Known Subclasses:
QtButton, QtCheckBox, QtRadioButton, QtToggleButton

public abstract class QtAbstractButton<B extends QAbstractButton>
extends QtComponent<B>
implements IToggleButton

The QtAbstractButton class is the abstract base class of button widgets, providing functionality common to buttons. This class implements an abstract button.


Field Summary
protected  IImage image
          the IconImage.
protected  IImage imagePressed
          the selected state IconImage.
 
Fields inherited from class com.sibvisions.rad.ui.qt.impl.QtComponent
parent
 
Fields inherited from class com.sibvisions.rad.ui.qt.impl.QtComponentBase
factory
 
Fields inherited from class com.sibvisions.rad.ui.qt.impl.QtResource
resource
 
Fields inherited from interface javax.rad.ui.IAlignmentConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_STRETCH, ALIGN_TOP
 
Fields inherited from interface javax.rad.ui.IAlignmentConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_STRETCH, ALIGN_TOP
 
Fields inherited from interface javax.rad.ui.IAlignmentConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_STRETCH, ALIGN_TOP
 
Fields inherited from interface javax.rad.ui.IAlignmentConstants
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_STRETCH, ALIGN_TOP
 
Constructor Summary
QtAbstractButton(B pButton)
          Creates a new instance of QtButton.
 
Method Summary
 void clicked()
          Handles the click action of the button resource.
 ActionHandler eventAction()
          The EventHandler for the action event.
 Key getAccelerator()
          Returns the Key which serves as an accelerator for the button.
 String getActionCommand()
          Returns the command name of the action event fired by this action component.
 int getHorizontalTextPosition()
          Returns the horizontal position of the text relative to the icon.
 IImage getImage()
          Returns the default image.
 int getImageTextGap()
          Returns the amount of space between the text and the icon displayed in this button.
 IInsets getMargins()
          Returns the margin between the component's border and the text.
 IImage getMouseOverImage()
          Gets the image for the button when the mouse is over.
 IImage getPressedImage()
          Gets the image for the button when the button is pressed.
 String getText()
          Returns the text string that the label displays.
 int getVerticalTextPosition()
          Returns the vertical position of the text relative to the icon.
 boolean isBorderOnMouseEntered()
          Gets, if the border should only be shown on mouse entered.
 boolean isBorderPainted()
          Gets whether the border will be painted.
 boolean isDefaultButton()
          Gets the value of the defaultButton property, which if true means that this button is the current default button.
 boolean isSelected()
          Checks if the component is selected.
 void setAccelerator(Key pKey)
          Sets the key combination which invokes the component's action listeners without selecting.
 void setActionCommand(String pActionCommand)
          Sets the command name for the action event fired by this action component.
 void setBorderOnMouseEntered(boolean pBorderOnMouseEntered)
          Sets, if the border should only be shown on mouse entered.
 void setBorderPainted(boolean pBorderPainted)
          Sets whether the border will be painted.
 void setDefaultButton(boolean pDefault)
          Sets the defaultButton property.
 void setHorizontalAlignment(int pHorizontalAlignment)
          Sets the horizontal alignment. Possible values are defined in AlignmentConstants.
 void setHorizontalTextPosition(int pHorizontalPosition)
          Sets the horizontal position of the text relative to the icon.
 void setImage(IImage pImage)
          Sets the default image.
 void setImageTextGap(int pGap)
          If both the icon and text properties are set, this property defines the space between them.
 void setMargins(IInsets pInsets)
          Sets space for margin between the button's border and the text.
 void setMouseOverImage(IImage pImage)
          Sets the image for the button when the mouse is over.
 void setPressedImage(IImage pImage)
          Sets the image for the button when the button is pressed.
 void setSelected(boolean pSelected)
          Sets the selected state of the component.
 void setText(String pText)
          Defines the single line of text this component will display.
 void setVerticalAlignment(int pVerticalAlignment)
          Sets the vertical alignment. Possible values are defined in AlignmentConstants.
 void setVerticalTextPosition(int pVerticalPosition)
          Sets the vertical position of the text relative to the icon.
 void toggled(boolean pState)
          Handles the toggle action of the button resource.
 
Methods inherited from class com.sibvisions.rad.ui.qt.impl.QtComponent
addStyle, capture, getBackground, getBounds, getCursor, getFont, getForeground, getHorizontalAlignment, getLocation, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getStyleSheet, getToolTipText, getVerticalAlignment, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, requestFocus, setBackground, setBounds, setCursor, setEnabled, setFocusable, setFont, setForeground, setLocation, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setResourceVisible, setSize, setToolTipText
 
Methods inherited from class com.sibvisions.rad.ui.qt.impl.QtComponentBase
eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getFactory, isVisible, setFactory, setVisible
 
Methods inherited from class com.sibvisions.rad.ui.qt.impl.QtResource
equals, getResource, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.rad.ui.IComponent
capture, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getFactory, getFont, getForeground, getLocation, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getToolTipText, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, requestFocus, setBackground, setBounds, setCursor, setEnabled, setFocusable, setFont, setForeground, setLocation, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setToolTipText, setVisible
 
Methods inherited from interface javax.rad.ui.IResource
getResource
 
Methods inherited from interface javax.rad.ui.IAlignmentConstants
getHorizontalAlignment, getVerticalAlignment
 
Methods inherited from interface javax.rad.ui.IComponent
capture, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getFactory, getFont, getForeground, getLocation, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getToolTipText, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, requestFocus, setBackground, setBounds, setCursor, setEnabled, setFocusable, setFont, setForeground, setLocation, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setToolTipText, setVisible
 
Methods inherited from interface javax.rad.ui.IResource
getResource
 
Methods inherited from interface javax.rad.ui.IAlignmentConstants
getHorizontalAlignment, getVerticalAlignment
 
Methods inherited from interface javax.rad.ui.IComponent
capture, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getFactory, getFont, getForeground, getLocation, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getToolTipText, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, requestFocus, setBackground, setBounds, setCursor, setEnabled, setFocusable, setFont, setForeground, setLocation, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setToolTipText, setVisible
 
Methods inherited from interface javax.rad.ui.IResource
getResource
 
Methods inherited from interface javax.rad.ui.IAlignmentConstants
getHorizontalAlignment, getVerticalAlignment
 
Methods inherited from interface javax.rad.ui.IComponent
capture, eventKeyPressed, eventKeyReleased, eventKeyTyped, eventMouseClicked, eventMouseEntered, eventMouseExited, eventMousePressed, eventMouseReleased, getBackground, getBounds, getCursor, getFactory, getFont, getForeground, getLocation, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getToolTipText, isBackgroundSet, isCursorSet, isEnabled, isFocusable, isFontSet, isForegroundSet, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isVisible, requestFocus, setBackground, setBounds, setCursor, setEnabled, setFocusable, setFont, setForeground, setLocation, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setSize, setToolTipText, setVisible
 
Methods inherited from interface javax.rad.ui.IResource
getResource
 
Methods inherited from interface javax.rad.ui.IAlignmentConstants
getHorizontalAlignment, getVerticalAlignment
 

Field Detail

image

protected IImage image
the IconImage.


imagePressed

protected IImage imagePressed
the selected state IconImage.

Constructor Detail

QtAbstractButton

public QtAbstractButton(B pButton)
Creates a new instance of QtButton.

Parameters:
pButton - the button instance
Method Detail

setHorizontalAlignment

public void setHorizontalAlignment(int pHorizontalAlignment)
Sets the horizontal alignment. Possible values are defined in AlignmentConstants.

Specified by:
setHorizontalAlignment in interface IAlignmentConstants
Overrides:
setHorizontalAlignment in class QtComponent<B extends QAbstractButton>
Parameters:
pHorizontalAlignment - the new vertical alignment

setVerticalAlignment

public void setVerticalAlignment(int pVerticalAlignment)
Sets the vertical alignment. Possible values are defined in AlignmentConstants.

Specified by:
setVerticalAlignment in interface IAlignmentConstants
Overrides:
setVerticalAlignment in class QtComponent<B extends QAbstractButton>
Parameters:
pVerticalAlignment - the new vertical alignment

setAccelerator

public void setAccelerator(Key pKey)
Sets the key combination which invokes the component's action listeners without selecting. It is the UI's responsibility to install the correct action.

Specified by:
setAccelerator in interface IActionComponent
Parameters:
pKey - the Key which will serve as an accelerator

getAccelerator

public Key getAccelerator()
Returns the Key which serves as an accelerator for the button.

Specified by:
getAccelerator in interface IActionComponent
Returns:
a Key object identifying the accelerator key

eventAction

public ActionHandler eventAction()
The EventHandler for the action event.

Specified by:
eventAction in interface IActionComponent
Returns:
the EventHandler for the action event.

setActionCommand

public void setActionCommand(String pActionCommand)
Sets the command name for the action event fired by this action component. By default this action command is set to match the label of the button.

Specified by:
setActionCommand in interface IActionComponent
Parameters:
pActionCommand - a string used to set the action command. If the string is null then the action command is set to match the text of the action component.
See Also:
ActionEvent

getActionCommand

public String getActionCommand()
Returns the command name of the action event fired by this action component. If the command name is null (default) then this method returns the label of the button.

Specified by:
getActionCommand in interface IActionComponent
Returns:
the action command.

setHorizontalTextPosition

public void setHorizontalTextPosition(int pHorizontalPosition)
Sets the horizontal position of the text relative to the icon.

Specified by:
setHorizontalTextPosition in interface IButton
Parameters:
pHorizontalPosition - one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.LEFT
  • IAlignmentConstants.RIGHT

getHorizontalTextPosition

public int getHorizontalTextPosition()
Returns the horizontal position of the text relative to the icon.

Specified by:
getHorizontalTextPosition in interface IButton
Returns:
one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.LEFT
  • IAlignmentConstants.RIGHT

setVerticalTextPosition

public void setVerticalTextPosition(int pVerticalPosition)
Sets the vertical position of the text relative to the icon.

Specified by:
setVerticalTextPosition in interface IButton
Parameters:
pVerticalPosition - one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.TOP
  • IAlignmentConstants.BOTTOM

getVerticalTextPosition

public int getVerticalTextPosition()
Returns the vertical position of the text relative to the icon.

Specified by:
getVerticalTextPosition in interface IButton
Returns:
one of the following values:
  • IAlignmentConstants.CENTER
  • IAlignmentConstants.TOP
  • IAlignmentConstants.BOTTOM

setBorderOnMouseEntered

public void setBorderOnMouseEntered(boolean pBorderOnMouseEntered)
Sets, if the border should only be shown on mouse entered.

Specified by:
setBorderOnMouseEntered in interface IButton
Parameters:
pBorderOnMouseEntered - true, if the border should only be shown on mouse entered.

isBorderOnMouseEntered

public boolean isBorderOnMouseEntered()
Gets, if the border should only be shown on mouse entered.

Specified by:
isBorderOnMouseEntered in interface IButton
Returns:
true, if the border should only be shown on mouse entered.

setBorderPainted

public void setBorderPainted(boolean pBorderPainted)
Sets whether the border will be painted. If true, the border will be painted. The default value is that the border will be painted.

Specified by:
setBorderPainted in interface IButton
Parameters:
pBorderPainted - true to paint the border, otherwise false

isBorderPainted

public boolean isBorderPainted()
Gets whether the border will be painted.

Specified by:
isBorderPainted in interface IButton
Returns:
true when the border will be painted, otherwise false

setMouseOverImage

public void setMouseOverImage(IImage pImage)
Sets the image for the button when the mouse is over.

Specified by:
setMouseOverImage in interface IButton
Parameters:
pImage - the mouse over image

getMouseOverImage

public IImage getMouseOverImage()
Gets the image for the button when the mouse is over.

Specified by:
getMouseOverImage in interface IButton
Returns:
the mouse over image

setImage

public void setImage(IImage pImage)
Sets the default image.

Specified by:
setImage in interface IIcon
Parameters:
pImage - the image
See Also:
IIcon.getImage()

getImage

public IImage getImage()
Returns the default image.

Specified by:
getImage in interface IIcon
Returns:
the default image
See Also:
IIcon.setImage(IImage)

setText

public void setText(String pText)
Defines the single line of text this component will display. If the value of text is null or empty string, nothing is displayed.

Specified by:
setText in interface ILabel
Parameters:
pText - the text

getText

public String getText()
Returns the text string that the label displays.

Specified by:
getText in interface ILabel
Returns:
a String
See Also:
ILabel.setText(java.lang.String)

setImageTextGap

public void setImageTextGap(int pGap)
If both the icon and text properties are set, this property defines the space between them.

The default value of this property is 4 pixels.

This is a JavaBeans bound property.

Specified by:
setImageTextGap in interface IButton
Parameters:
pGap - the image gap
See Also:
IButton.getImageTextGap()

getImageTextGap

public int getImageTextGap()
Returns the amount of space between the text and the icon displayed in this button.

Specified by:
getImageTextGap in interface IButton
Returns:
an int equal to the number of pixels between the text and the icon.
See Also:
IButton.setImageTextGap(int)

setDefaultButton

public void setDefaultButton(boolean pDefault)
Sets the defaultButton property. The default button is the button which will be activated when a UI-defined activation event (typically the Enter key) occurs, regardless of whether or not the button has keyboard focus (unless there is another component within which consumes the activation event) For default activation to work, the button must be enabled.

Specified by:
setDefaultButton in interface IButton
Parameters:
pDefault - true to set this button as default button, otherwise false
See Also:
IButton.isDefaultButton()

isDefaultButton

public boolean isDefaultButton()
Gets the value of the defaultButton property, which if true means that this button is the current default button.

Specified by:
isDefaultButton in interface IButton
Returns:
true if this button is defined as default button, otherwise false
See Also:
IButton.setDefaultButton(boolean)

isSelected

public boolean isSelected()
Checks if the component is selected.

Specified by:
isSelected in interface IToggleActionComponent
Returns:
true if the component is selected, otherwise false

setSelected

public void setSelected(boolean pSelected)
Sets the selected state of the component.

Specified by:
setSelected in interface IToggleActionComponent
Parameters:
pSelected - true selects the toggle component, false deselects the toggle component.

setPressedImage

public void setPressedImage(IImage pImage)
Sets the image for the button when the button is pressed.

Specified by:
setPressedImage in interface IButton
Specified by:
setPressedImage in interface IToggleActionComponent
Parameters:
pImage - the mouse pressed image

getPressedImage

public IImage getPressedImage()
Gets the image for the button when the button is pressed.

Specified by:
getPressedImage in interface IButton
Specified by:
getPressedImage in interface IToggleActionComponent
Returns:
the mouse pressed image

setMargins

public void setMargins(IInsets pInsets)
Sets space for margin between the button's border and the text. Setting to null will cause the action component to use the default margin.

Specified by:
setMargins in interface IActionComponent
Parameters:
pInsets - the space between the border and the test

getMargins

public IInsets getMargins()
Returns the margin between the component's border and the text.

Specified by:
getMargins in interface IActionComponent
Returns:
an IInsets object specifying the margin between the component's border and the text
See Also:
IActionComponent.setMargins(IInsets)

clicked

public void clicked()
Handles the click action of the button resource.


toggled

public void toggled(boolean pState)
Handles the toggle action of the button resource.

Parameters:
pState - the current toggle state


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.