Back to index

salome-gui  6.5.0
Public Member Functions
CloseButton Class Reference

List of all members.

Public Member Functions

 CloseButton (QWidget *)
 Constructor.
QSize sizeHint () const
 Get appropriate size for the button.
QSize minimumSizeHint () const
 Get minimum appropriate size for the button.
void enterEvent (QEvent *)
 Process mouse enter event.
void leaveEvent (QEvent *)
 Process mouse leave event.
void paintEvent (QPaintEvent *)
 Process paint event.

Detailed Description

Definition at line 271 of file QtxWorkstack.cxx.


Constructor & Destructor Documentation

CloseButton::CloseButton ( QWidget *  parent)

Constructor.

Parameters:
parentparent widget

Definition at line 289 of file QtxWorkstack.cxx.

: QAbstractButton( parent )
{
 setFocusPolicy( Qt::NoFocus );
}

Member Function Documentation

void CloseButton::enterEvent ( QEvent *  event)

Process mouse enter event.

Parameters:
eventmouse enter event

Definition at line 328 of file QtxWorkstack.cxx.

{
  if ( isEnabled() )
    update();
  QAbstractButton::enterEvent( event );
}
void CloseButton::leaveEvent ( QEvent *  event)

Process mouse leave event.

Parameters:
eventmouse leave event

Definition at line 340 of file QtxWorkstack.cxx.

{
  if( isEnabled() )
    update();
  QAbstractButton::leaveEvent( event );
}

Get minimum appropriate size for the button.

Returns:
minimum size value

Definition at line 318 of file QtxWorkstack.cxx.

{
  return sizeHint();
}

Here is the call graph for this function:

void CloseButton::paintEvent ( QPaintEvent *  )

Process paint event.

Parameters:
eventpaint event

Definition at line 352 of file QtxWorkstack.cxx.

{
  QPainter p( this );

  QRect r = rect();
  QStyleOption opt;
  opt.init( this );
  opt.state |= QStyle::State_AutoRaise;
  if ( isEnabled() && underMouse() && !isChecked() && !isDown() )
    opt.state |= QStyle::State_Raised;
  if ( isChecked() )
    opt.state |= QStyle::State_On;
  if ( isDown() )
    opt.state |= QStyle::State_Sunken;
  style()->drawPrimitive( QStyle::PE_PanelButtonTool, &opt, &p, this );

  int shiftHorizontal = opt.state & QStyle::State_Sunken ? style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &opt, this ) : 0;
  int shiftVertical = opt.state & QStyle::State_Sunken ? style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &opt, this ) : 0;

  r.adjust( 2, 2, -2, -2 );
  r.translate( shiftHorizontal, shiftVertical );

  QPixmap pm = icon().pixmap( style()->pixelMetric( QStyle::PM_SmallIconSize ), isEnabled() ?
                              underMouse() ? QIcon::Active : QIcon::Normal
                              : QIcon::Disabled,
                              isDown() ? QIcon::On : QIcon::Off );
  style()->drawItemPixmap( &p, r, Qt::AlignCenter, pm );
}
QSize CloseButton::sizeHint ( ) const

Get appropriate size for the button.

Returns:
size value

Definition at line 300 of file QtxWorkstack.cxx.

{
  ensurePolished();
  int dim = 0;
  if( !icon().isNull() )
  {
    const QPixmap pm = icon().pixmap( style()->pixelMetric( QStyle::PM_SmallIconSize ),
                                      QIcon::Normal );
    dim = qMax( pm.width(), pm.height() );
  }
  return QSize( dim + 4, dim + 4 );
}

Here is the caller graph for this function:


The documentation for this class was generated from the following file: