diff options
author | Darrell Anderson <[email protected]> | 2012-11-10 11:43:40 -0600 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2012-11-10 11:43:40 -0600 |
commit | 6bcbe0a787127751122109caf4a3cd621e13004e (patch) | |
tree | 5a0f15dcfa9330f1e1dbabe346ba69c848e17bdf /src | |
parent | f7873ac3368532ee4ab09e77e5112d7b6b1a8069 (diff) | |
parent | d1c672237288068a5e3777d16277221912bc0088 (diff) | |
download | qt3-6bcbe0a787127751122109caf4a3cd621e13004e.tar.gz qt3-6bcbe0a787127751122109caf4a3cd621e13004e.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/qstyle.cpp | 6 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 19 | ||||
-rw-r--r-- | src/styles/qcommonstyle.cpp | 77 | ||||
-rw-r--r-- | src/widgets/qprogressbar.cpp | 116 | ||||
-rw-r--r-- | src/widgets/qprogressbar.h | 8 |
5 files changed, 195 insertions, 31 deletions
diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 843027d..4e689c2 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -2606,6 +2606,12 @@ QPixmap QStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption QStyleControlElementData::QStyleControlElementData() { activePainter = 0; + tickMarkSetting = 0; + comboBoxLineEditFlags = 0; + frameStyle = 0; + comboBoxListBoxFlags = 0; + parentWidgetFlags = 0; + topLevelWidgetFlags = 0; } #endif // QT_NO_STYLE diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 111a987..f76b970 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -202,6 +202,9 @@ class QStyleControlElementGenericWidgetData { QPixmap icon; QPalette palette; QFont font; + QColor paletteBgColor; + QString name; + QString caption; }; class QStyleControlElementTabBarData { @@ -276,6 +279,13 @@ class Q_EXPORT QStyleControlElementData { QRect sliderRect; QPainter* activePainter; QStyleControlElementToolBarWidgetData toolBarData; + Q_UINT32 comboBoxListBoxFlags; + QColor paletteBgColor; + Q_UINT32 parentWidgetFlags; + QString name; + QString caption; + QStyleControlElementGenericWidgetData topLevelWidgetData; + Q_UINT32 topLevelWidgetFlags; public: QStyleControlElementData(); @@ -339,6 +349,7 @@ public: CEF_IsActiveWindow = 0x00200000, CEF_IsTopLevel = 0x00400000, CEF_IsVisible = 0x00800000, + CEF_IsShown = 0x01000000, CEF_HasMouse = 0x01000000 }; @@ -469,6 +480,8 @@ public: PE_MenuItemIndicatorIconFrame, PE_MenuItemIndicatorCheck, + PE_ScrollBarTrough, + // do not add any values below/greater this PE_CustomBase = 0xf000000 }; @@ -1050,6 +1063,12 @@ public: // int - width of menu check column SH_MenuIndicatorColumnWidth, + // bool - whether or not the lower two button drawing areas should be combined into one + SH_ScrollBar_CombineAddLineRegionDrawingAreas, + + // bool - whether or not the upper two button drawing areas should be combined into one + SH_ScrollBar_CombineSubLineRegionDrawingAreas, + // do not add any values below/greater than this SH_CustomBase = 0xf0000000 }; diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 1cc2540..a0e64d0 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -66,6 +66,7 @@ #include "qradiobutton.h" #include "qbitmap.h" #include "qprogressbar.h" +#include "qlistbox.h" #include "private/qdialogbuttons_p.h" #include <limits.h> #include <qpixmap.h> @@ -158,7 +159,7 @@ QStringList getObjectTypeListForObject(const QObject* object) { } QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields) { - QStyle::ControlElementFlags cef = (QStyle::ControlElementFlags)0; + QStyle::ControlElementFlags cef = QStyle::CEF_None; if (object) { if (objectTypeList.contains("QPushButton")) { @@ -195,6 +196,12 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec if (t->identifier() == tb->currentTab()) cef = cef | QStyle::CEF_IsActive; } } + if (objectTypeList.contains("QTitleBar")) { + const QTitleBar *tb = dynamic_cast<const QTitleBar*>(object); + if (tb) { + if (tb->isActive()) cef = cef | QStyle::CEF_IsActive; + } + } if (objectTypeList.contains("QToolBox")) { const QToolBox *tb = dynamic_cast<const QToolBox*>(object); if (tb) { @@ -232,6 +239,7 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec if (widget->isActiveWindow()) cef = cef | QStyle::CEF_IsActiveWindow; if (widget->isTopLevel()) cef = cef | QStyle::CEF_IsTopLevel; if (widget->isVisible()) cef = cef | QStyle::CEF_IsVisible; + if (widget->isShown()) cef = cef | QStyle::CEF_IsShown; } } } @@ -265,6 +273,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid if (populateReliantFields) { ceData.fgColor = widget->foregroundColor(); ceData.colorGroup = widget->colorGroup(); + ceData.paletteBgColor = widget->paletteBackgroundColor(); } ceData.geometry = widget->geometry(); ceData.rect = widget->rect(); @@ -275,6 +284,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid } ceData.palette = widget->palette(); ceData.font = widget->font(); + ceData.name = widget->name(); + ceData.caption = widget->caption(); if (ceData.widgetObjectTypes.contains("QPushButton")) { const QPushButton *button = dynamic_cast<const QPushButton*>(widget); if (button) { @@ -394,6 +405,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.totalSteps = pb->totalSteps(); ceData.progressText = pb->progressString(); ceData.percentageVisible = pb->percentageVisible(); + ceData.orientation = pb->orientation(); } } if (ceData.widgetObjectTypes.contains("QHeader")) { @@ -504,6 +516,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid if (populateReliantFields) { ceData.viewportData.fgColor = viewport->foregroundColor(); ceData.viewportData.colorGroup = viewport->colorGroup(); + ceData.viewportData.paletteBgColor = viewport->paletteBackgroundColor(); } ceData.viewportData.geometry = viewport->geometry(); ceData.viewportData.rect = viewport->rect(); @@ -514,6 +527,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid } ceData.viewportData.palette = viewport->palette(); ceData.viewportData.font = viewport->font(); + ceData.viewportData.name = viewport->name(); + ceData.viewportData.caption = viewport->caption(); } } } @@ -524,6 +539,10 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid if (lineEdit) { ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, QStyleOption::Default); } + const QListBox* listBox = cb->listBox(); + if (listBox) { + ceData.comboBoxListBoxFlags = getControlElementFlagsForObject(listBox, ceData.widgetObjectTypes, QStyleOption::Default); + } } } if (ceData.widgetObjectTypes.contains("QFrame")) { @@ -554,6 +573,7 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid if (populateReliantFields) { ceData.parentWidgetData.fgColor = parentWidget->foregroundColor(); ceData.parentWidgetData.colorGroup = parentWidget->colorGroup(); + ceData.parentWidgetData.paletteBgColor = parentWidget->paletteBackgroundColor(); } ceData.parentWidgetData.geometry = parentWidget->geometry(); ceData.parentWidgetData.rect = parentWidget->rect(); @@ -564,6 +584,8 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid } ceData.parentWidgetData.palette = parentWidget->palette(); ceData.parentWidgetData.font = parentWidget->font(); + ceData.parentWidgetData.name = parentWidget->name(); + ceData.parentWidgetData.caption = parentWidget->caption(); const QDockWindow * dw = dynamic_cast<const QDockWindow*>(parentWidget); if (dw) { @@ -580,6 +602,59 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid if (toolbar) { ceData.toolBarData.orientation = toolbar->orientation(); } + ceData.parentWidgetFlags = getControlElementFlagsForObject(parentWidget, ceData.parentWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields); + } + const QWidget* topLevelWidget = widget->topLevelWidget(); + if (topLevelWidget) { + ceData.topLevelWidgetData.widgetObjectTypes = getObjectTypeListForObject(topLevelWidget); + ceData.topLevelWidgetData.allDataPopulated = populateReliantFields; + const QPixmap* erasePixmap = topLevelWidget->backgroundPixmap(); + if (erasePixmap) { + ceData.topLevelWidgetData.bgPixmap = *erasePixmap; + } + if (populateReliantFields) { + ceData.topLevelWidgetData.bgBrush = topLevelWidget->backgroundBrush(); + } + ceData.topLevelWidgetData.wflags = topLevelWidget->getWFlags(); + if (populateReliantFields) { + ceData.topLevelWidgetData.windowState = (Qt::WindowState)(widget->windowState()); + } + ceData.topLevelWidgetData.bgColor = topLevelWidget->eraseColor(); + ceData.topLevelWidgetData.bgOffset = topLevelWidget->backgroundOffset(); + ceData.topLevelWidgetData.backgroundMode = topLevelWidget->backgroundMode(); + if (populateReliantFields) { + ceData.topLevelWidgetData.fgColor = topLevelWidget->foregroundColor(); + ceData.topLevelWidgetData.colorGroup = topLevelWidget->colorGroup(); + ceData.topLevelWidgetData.paletteBgColor = topLevelWidget->paletteBackgroundColor(); + } + ceData.topLevelWidgetData.geometry = topLevelWidget->geometry(); + ceData.topLevelWidgetData.rect = topLevelWidget->rect(); + ceData.topLevelWidgetData.pos = topLevelWidget->pos(); + const QPixmap* icon = topLevelWidget->icon(); + if (icon) { + ceData.topLevelWidgetData.icon = *icon; + } + ceData.topLevelWidgetData.palette = topLevelWidget->palette(); + ceData.topLevelWidgetData.font = topLevelWidget->font(); + ceData.topLevelWidgetData.name = topLevelWidget->name(); + ceData.topLevelWidgetData.caption = topLevelWidget->caption(); + + const QDockWindow * dw = dynamic_cast<const QDockWindow*>(topLevelWidget); + if (dw) { + if (dw->area()) { + ceData.dwData.hasDockArea = true; + ceData.dwData.areaOrientation = dw->area()->orientation(); + } + else { + ceData.dwData.hasDockArea = false; + } + ceData.dwData.closeEnabled = dw->isCloseEnabled(); + } + const QToolBar * toolbar = dynamic_cast<const QToolBar*>(topLevelWidget); + if (toolbar) { + ceData.toolBarData.orientation = toolbar->orientation(); + } + ceData.topLevelWidgetFlags = getControlElementFlagsForObject(topLevelWidget, ceData.topLevelWidgetData.widgetObjectTypes, QStyleOption::Default, populateReliantFields); } QCheckListItem *item = opt.checkListItem(); diff --git a/src/widgets/qprogressbar.cpp b/src/widgets/qprogressbar.cpp index 3d0f403..d5011da 100644 --- a/src/widgets/qprogressbar.cpp +++ b/src/widgets/qprogressbar.cpp @@ -44,6 +44,7 @@ #include "qdrawutil.h" #include "qpixmap.h" #include "qstyle.h" +#include "qwmatrix.h" #include "../kernel/qinternal_p.h" #if defined(QT_ACCESSIBILITY_SUPPORT) #include "qaccessible.h" @@ -102,7 +103,8 @@ QProgressBar::QProgressBar( QWidget *parent, const char *name, WFlags f ) center_indicator( TRUE ), auto_indicator( TRUE ), percentage_visible( TRUE ), - d( 0 ) + d( 0 ), + m_orientation( Horizontal ) { setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); initFrame(); @@ -133,7 +135,8 @@ QProgressBar::QProgressBar( int totalSteps, center_indicator( TRUE ), auto_indicator( TRUE ), percentage_visible( TRUE ), - d( 0 ) + d( 0 ), + m_orientation( Horizontal ) { setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); initFrame(); @@ -234,9 +237,15 @@ QSize QProgressBar::sizeHint() const constPolish(); QFontMetrics fm = fontMetrics(); int cw = style().pixelMetric(QStyle::PM_ProgressBarChunkWidth, this); - return style().sizeFromContents(QStyle::CT_ProgressBar, this, + QSize sh = style().sizeFromContents(QStyle::CT_ProgressBar, this, QSize( cw * 7 + fm.width( '0' ) * 4, fm.height() + 8)); + if (m_orientation == Qt::Horizontal) { + return sh; + } + else { + return QSize(sh.height(), sh.width()); + } } @@ -321,6 +330,22 @@ void QProgressBar::styleChange( QStyle& old ) QFrame::styleChange( old ); } +Qt::Orientation QProgressBar::orientation() const +{ + return m_orientation; +} + +void QProgressBar::setOrientation(Orientation orient) +{ + m_orientation = orient; + if (m_orientation == Qt::Horizontal) { + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + } + else { + setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + } +} + /*! This method is called to generate the text displayed in the center @@ -371,40 +396,71 @@ bool QProgressBar::setIndicator( QString & indicator, int progress, */ void QProgressBar::drawContents( QPainter *p ) { - const QRect bar = contentsRect(); + const QRect bar = contentsRect(); + + QSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() ); + + QPoint pn = backgroundOffset(); + buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() ); + + const QPixmap *bpm = paletteBackgroundPixmap(); + if ( bpm ) { + buffer.painter()->fillRect( bar, QBrush( paletteBackgroundColor(), *bpm ) ); + } + else { + buffer.painter()->fillRect( bar, paletteBackgroundColor() ); + } + buffer.painter()->setFont( p->font() ); - QSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() ); + QStyle::SFlags flags = QStyle::Style_Default; + if (isEnabled()) { + flags |= QStyle::Style_Enabled; + } + if (hasFocus()) { + flags |= QStyle::Style_HasFocus; + } + if (hasMouse()) { + flags |= QStyle::Style_MouseOver; + } - QPoint pn = backgroundOffset(); - buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() ); + style().drawControl(QStyle::CE_ProgressBarGroove, buffer.painter(), this, + QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarGroove, this), this ), + colorGroup(), flags); - const QPixmap *bpm = paletteBackgroundPixmap(); - if ( bpm ) - buffer.painter()->fillRect( bar, QBrush( paletteBackgroundColor(), *bpm ) ); - else - buffer.painter()->fillRect( bar, paletteBackgroundColor() ); - buffer.painter()->setFont( p->font() ); + QWMatrix oldMatrix = buffer.painter()->worldMatrix(); - QStyle::SFlags flags = QStyle::Style_Default; - if (isEnabled()) - flags |= QStyle::Style_Enabled; - if (hasFocus()) - flags |= QStyle::Style_HasFocus; - if (hasMouse()) - flags |= QStyle::Style_MouseOver; + QStyleControlElementData ceData = populateControlElementDataFromWidget(this, QStyleOption()); + QStyle::ControlElementFlags elementFlags = getControlElementFlagsForObject(this, ceData.widgetObjectTypes, QStyleOption()); - style().drawControl(QStyle::CE_ProgressBarGroove, buffer.painter(), this, - QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarGroove, this), this ), - colorGroup(), flags); + // Draw contents + if (m_orientation == Qt::Vertical) { + // If oriented vertically, apply a 90 degree rotation matrix to the painter + QWMatrix m; - style().drawControl(QStyle::CE_ProgressBarContents, buffer.painter(), this, - QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarContents, this), this ), - colorGroup(), flags); +// // Upside down +// m.rotate(90.0); +// m.translate(0, (bar.width())*(-1.0)); + + // Right side up + m.rotate(-90.0); + m.translate((bar.height())*(-1.0), 0); - if (percentageVisible()) - style().drawControl(QStyle::CE_ProgressBarLabel, buffer.painter(), this, - QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarLabel, this), this ), - colorGroup(), flags); + buffer.painter()->setWorldMatrix(m, TRUE); + + ceData.rect = QRect(ceData.rect.y(), ceData.rect.x(), ceData.rect.height(), ceData.rect.width()); + } + + style().drawControl(QStyle::CE_ProgressBarContents, buffer.painter(), ceData, elementFlags, + QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarContents, ceData, elementFlags, this), ceData, elementFlags), + colorGroup(), flags, QStyleOption(), this); + + buffer.painter()->setWorldMatrix(oldMatrix, TRUE); + + if (percentageVisible()) { + style().drawControl(QStyle::CE_ProgressBarLabel, buffer.painter(), this, + QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarLabel, this), this ), + colorGroup(), flags); + } } #endif diff --git a/src/widgets/qprogressbar.h b/src/widgets/qprogressbar.h index 2c4f039..ac69914 100644 --- a/src/widgets/qprogressbar.h +++ b/src/widgets/qprogressbar.h @@ -60,6 +60,7 @@ class Q_EXPORT QProgressBar : public QFrame Q_PROPERTY( bool centerIndicator READ centerIndicator WRITE setCenterIndicator ) Q_PROPERTY( bool indicatorFollowsStyle READ indicatorFollowsStyle WRITE setIndicatorFollowsStyle ) Q_PROPERTY( bool percentageVisible READ percentageVisible WRITE setPercentageVisible ) + Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) public: QProgressBar( QWidget* parent=0, const char* name=0, WFlags f=0 ); @@ -111,6 +112,13 @@ private: // Disabled copy constructor and operator= QProgressBar( const QProgressBar & ); QProgressBar &operator=( const QProgressBar & ); #endif + +public: + virtual void setOrientation ( Orientation ); + Orientation orientation () const; + +private: + Orientation m_orientation; }; |