#include <QLayout>
#include <QSplitter>
#include <QRubberBand>
-#include <QPushButton>
#include <QApplication>
#include <QInputDialog>
#include <QStackedWidget>
+#include <QPainter>
+#include <QStyleOption>
#define DARK_COLOR_LIGHT 250
myAreaRect->hide();
}
+
+QtxWorkstackAreaTitleButton::QtxWorkstackAreaTitleButton(QWidget *widget)
+: QAbstractButton(widget)
+{
+ setFocusPolicy(Qt::NoFocus);
+}
+
+QSize QtxWorkstackAreaTitleButton::sizeHint() const
+{
+ 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 );
+}
+void QtxWorkstackAreaTitleButton::enterEvent( QEvent *event )
+{
+ if ( isEnabled() )
+ update();
+ QAbstractButton::enterEvent( event );
+}
+
+void QtxWorkstackAreaTitleButton::leaveEvent( QEvent *event )
+{
+ if( isEnabled() )
+ update();
+ QAbstractButton::leaveEvent( event );
+}
+
+void QtxWorkstackAreaTitleButton::paintEvent( QPaintEvent* )
+{
+ 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);
+}
+
/*!
\class QtxWorkstackArea
\internal
myBar = new QtxWorkstackTabBar( top );
tl->addWidget( myBar, 1 );
- QPushButton* close = new QPushButton( top );
+ QtxWorkstackAreaTitleButton* close = new QtxWorkstackAreaTitleButton( top );
close->setIcon( style()->standardIcon( QStyle::SP_TitleBarCloseButton ) );
- close->setAutoDefault( true );
- close->setFlat( true );
myClose = close;
tl->addWidget( myClose );
#include <QTabBar>
#include <QEvent>
#include <QMap>
+#include <QAbstractButton>
class QAction;
class QSplitter;
-class QPushButton;
class QStackedWidget;
class QRubberBand;
friend class QtxWorkstackDrag;
};
+/*
+ Tool window title
+*/
+class QtxWorkstackAreaTitleButton : public QAbstractButton
+{
+ Q_OBJECT
+
+public:
+ QtxWorkstackAreaTitleButton(QWidget *widget);
+
+ QSize sizeHint() const;
+ inline QSize minimumSizeHint() const
+ { return sizeHint(); }
+
+ void enterEvent(QEvent *event);
+ void leaveEvent(QEvent *event);
+ void paintEvent(QPaintEvent *event);
+};
+
class QtxWorkstackArea : public QFrame
{
Q_OBJECT
private:
QtxWorkstackTabBar* myBar; //!< workarea tab bar header
- QPushButton* myClose; //!< close button
+ QAbstractButton* myClose; //!< close button
QStackedWidget* myStack; //!< widget stack
QWidgetList myList; //!< child widgets list
void Style_Model::initFromResource( QtxResourceMgr* theResMgr )
{
ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end();
- for ( ; anIt != anEnd; anIt++ )
+ for ( ; anIt != anEnd; ++anIt )
setValueFrom( theResMgr, anIt.key() );
if ( getBoolValue( is_defined_style ) )
return retrieve;
ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end();
int anId = -1;
- for ( ; anIt != anEnd && anId == -1; anIt++ )
+ for ( ; anIt != anEnd && anId == -1; ++anIt )
if ( anIt.value().myName == thePropName )
anId = anIt.key();
if ( anId == -1 )
setPredefinedStyle( getIntValue( defined_style ) );
retrieve = true;
// update for resources all datas
- for ( anIt = myValues.begin(); anIt != anEnd; anIt++ ) {
+ for ( anIt = myValues.begin(); anIt != anEnd; ++anIt ) {
if ( anIt.key() != anId )
getValueTo( theResMgr, anIt.key(), false );
}
}
case PE_PanelButtonTool : {
if ( w && ( opt->state & State_Enabled ) &&
- ( qobject_cast<QToolBar*>( w->parentWidget() ) ) ||
- ( w->inherits("QDockWidgetTitleButton") ) ) {
+ ( ( qobject_cast<QToolBar*>( w->parentWidget() ) ) ||
+ ( w->inherits("QDockWidgetTitleButton") ) ||
+ ( w->inherits("QtxWorkstackAreaTitleButton") ) ) ) {
bool aStateOn = opt->state & (State_Sunken | State_On);
bool aHighWdg = hasHover() && !getBoolValue( Style_Model::auto_raising_wdg ) &&
getBoolValue( Style_Model::highlight_wdg );