diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index 90f4eacf..73543dd9 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -202,6 +202,9 @@ class TQStyleControlElementGenericWidgetData { TQPixmap icon; TQPalette palette; TQFont font; + TQColor paletteBgColor; + TQString name; + TQString caption; }; class TQStyleControlElementTabBarData { @@ -276,6 +279,13 @@ class Q_EXPORT TQStyleControlElementData { TQRect sliderRect; TQPainter* activePainter; TQStyleControlElementToolBarWidgetData toolBarData; + TQ_UINT32 comboBoxListBoxFlags; + TQColor paletteBgColor; + TQ_UINT32 parentWidgetFlags; + TQString name; + TQString caption; + TQStyleControlElementGenericWidgetData topLevelWidgetData; + TQ_UINT32 topLevelWidgetFlags; public: TQStyleControlElementData(); @@ -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/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index ef31c25c..f32d73b9 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -2606,6 +2606,12 @@ TQPixmap TQStyle::stylePixmap(StylePixmap sp, const TQWidget *w, const TQStyleOp TQStyleControlElementData::TQStyleControlElementData() { activePainter = 0; + tickMarkSetting = 0; + comboBoxLineEditFlags = 0; + frameStyle = 0; + comboBoxListBoxFlags = 0; + parentWidgetFlags = 0; + topLevelWidgetFlags = 0; } #endif // QT_NO_STYLE diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 402354c6..a303a805 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -66,6 +66,7 @@ #include "ntqradiobutton.h" #include "ntqbitmap.h" #include "ntqprogressbar.h" +#include "ntqlistbox.h" #include "private/qdialogbuttons_p.h" #include #include @@ -158,7 +159,7 @@ TQStringList getObjectTypeListForObject(const TQObject* object) { } TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, TQStringList objectTypeList, const TQStyleOption& opt, bool populateReliantFields) { - TQStyle::ControlElementFlags cef = (TQStyle::ControlElementFlags)0; + TQStyle::ControlElementFlags cef = TQStyle::CEF_None; if (object) { if (objectTypeList.contains("TQPushButton")) { @@ -195,6 +196,12 @@ TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* obj if (t->identifier() == tb->currentTab()) cef = cef | TQStyle::CEF_IsActive; } } + if (objectTypeList.contains("TQTitleBar")) { + const TQTitleBar *tb = dynamic_cast(object); + if (tb) { + if (tb->isActive()) cef = cef | TQStyle::CEF_IsActive; + } + } if (objectTypeList.contains("TQToolBox")) { const TQToolBox *tb = dynamic_cast(object); if (tb) { @@ -232,6 +239,7 @@ TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* obj if (widget->isActiveWindow()) cef = cef | TQStyle::CEF_IsActiveWindow; if (widget->isTopLevel()) cef = cef | TQStyle::CEF_IsTopLevel; if (widget->isVisible()) cef = cef | TQStyle::CEF_IsVisible; + if (widget->isShown()) cef = cef | TQStyle::CEF_IsShown; } } } @@ -265,6 +273,7 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w 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 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w } ceData.palette = widget->palette(); ceData.font = widget->font(); + ceData.name = widget->name(); + ceData.caption = widget->caption(); if (ceData.widgetObjectTypes.contains("TQPushButton")) { const TQPushButton *button = dynamic_cast(widget); if (button) { @@ -394,6 +405,7 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.totalSteps = pb->totalSteps(); ceData.progressText = pb->progressString(); ceData.percentageVisible = pb->percentageVisible(); + ceData.orientation = pb->orientation(); } } if (ceData.widgetObjectTypes.contains("TQHeader")) { @@ -504,6 +516,7 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w 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 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w } ceData.viewportData.palette = viewport->palette(); ceData.viewportData.font = viewport->font(); + ceData.viewportData.name = viewport->name(); + ceData.viewportData.caption = viewport->caption(); } } } @@ -524,6 +539,10 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w if (lineEdit) { ceData.comboBoxLineEditFlags = getControlElementFlagsForObject(lineEdit, ceData.widgetObjectTypes, TQStyleOption::Default); } + const TQListBox* listBox = cb->listBox(); + if (listBox) { + ceData.comboBoxListBoxFlags = getControlElementFlagsForObject(listBox, ceData.widgetObjectTypes, TQStyleOption::Default); + } } } if (ceData.widgetObjectTypes.contains("TQFrame")) { @@ -554,6 +573,7 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w 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 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w } ceData.parentWidgetData.palette = parentWidget->palette(); ceData.parentWidgetData.font = parentWidget->font(); + ceData.parentWidgetData.name = parentWidget->name(); + ceData.parentWidgetData.caption = parentWidget->caption(); const TQDockWindow * dw = dynamic_cast(parentWidget); if (dw) { @@ -580,6 +602,59 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w if (toolbar) { ceData.toolBarData.orientation = toolbar->orientation(); } + ceData.parentWidgetFlags = getControlElementFlagsForObject(parentWidget, ceData.parentWidgetData.widgetObjectTypes, TQStyleOption::Default, populateReliantFields); + } + const TQWidget* topLevelWidget = widget->topLevelWidget(); + if (topLevelWidget) { + ceData.topLevelWidgetData.widgetObjectTypes = getObjectTypeListForObject(topLevelWidget); + ceData.topLevelWidgetData.allDataPopulated = populateReliantFields; + const TQPixmap* 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 = (TQt::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 TQPixmap* 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 TQDockWindow * dw = dynamic_cast(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 TQToolBar * toolbar = dynamic_cast(topLevelWidget); + if (toolbar) { + ceData.toolBarData.orientation = toolbar->orientation(); + } + ceData.topLevelWidgetFlags = getControlElementFlagsForObject(topLevelWidget, ceData.topLevelWidgetData.widgetObjectTypes, TQStyleOption::Default, populateReliantFields); } TQCheckListItem *item = opt.checkListItem(); diff --git a/src/widgets/ntqprogressbar.h b/src/widgets/ntqprogressbar.h index e4c66e99..ca73cd8a 100644 --- a/src/widgets/ntqprogressbar.h +++ b/src/widgets/ntqprogressbar.h @@ -60,6 +60,7 @@ class Q_EXPORT TQProgressBar : public TQFrame TQ_PROPERTY( bool centerIndicator READ centerIndicator WRITE setCenterIndicator ) TQ_PROPERTY( bool indicatorFollowsStyle READ indicatorFollowsStyle WRITE setIndicatorFollowsStyle ) TQ_PROPERTY( bool percentageVisible READ percentageVisible WRITE setPercentageVisible ) + TQ_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) public: TQProgressBar( TQWidget* parent=0, const char* name=0, WFlags f=0 ); @@ -111,6 +112,13 @@ private: // Disabled copy constructor and operator= TQProgressBar( const TQProgressBar & ); TQProgressBar &operator=( const TQProgressBar & ); #endif + +public: + virtual void setOrientation ( Orientation ); + Orientation orientation () const; + +private: + Orientation m_orientation; }; diff --git a/src/widgets/qprogressbar.cpp b/src/widgets/qprogressbar.cpp index 7a4ec383..bf40d9e4 100644 --- a/src/widgets/qprogressbar.cpp +++ b/src/widgets/qprogressbar.cpp @@ -44,6 +44,7 @@ #include "ntqdrawutil.h" #include "ntqpixmap.h" #include "ntqstyle.h" +#include "ntqwmatrix.h" #include "../kernel/qinternal_p.h" #if defined(QT_ACCESSIBILITY_SUPPORT) #include "ntqaccessible.h" @@ -102,7 +103,8 @@ TQProgressBar::TQProgressBar( TQWidget *parent, const char *name, WFlags f ) center_indicator( TRUE ), auto_indicator( TRUE ), percentage_visible( TRUE ), - d( 0 ) + d( 0 ), + m_orientation( Horizontal ) { setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) ); initFrame(); @@ -133,7 +135,8 @@ TQProgressBar::TQProgressBar( int totalSteps, center_indicator( TRUE ), auto_indicator( TRUE ), percentage_visible( TRUE ), - d( 0 ) + d( 0 ), + m_orientation( Horizontal ) { setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) ); initFrame(); @@ -234,9 +237,15 @@ TQSize TQProgressBar::sizeHint() const constPolish(); TQFontMetrics fm = fontMetrics(); int cw = style().pixelMetric(TQStyle::PM_ProgressBarChunkWidth, this); - return style().sizeFromContents(TQStyle::CT_ProgressBar, this, + TQSize sh = style().sizeFromContents(TQStyle::CT_ProgressBar, this, TQSize( cw * 7 + fm.width( '0' ) * 4, fm.height() + 8)); + if (m_orientation == TQt::Horizontal) { + return sh; + } + else { + return TQSize(sh.height(), sh.width()); + } } @@ -321,6 +330,22 @@ void TQProgressBar::styleChange( TQStyle& old ) TQFrame::styleChange( old ); } +TQt::Orientation TQProgressBar::orientation() const +{ + return m_orientation; +} + +void TQProgressBar::setOrientation(Orientation orient) +{ + m_orientation = orient; + if (m_orientation == TQt::Horizontal) { + setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ) ); + } + else { + setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Expanding ) ); + } +} + /*! This method is called to generate the text displayed in the center @@ -371,40 +396,71 @@ bool TQProgressBar::setIndicator( TQString & indicator, int progress, */ void TQProgressBar::drawContents( TQPainter *p ) { - const TQRect bar = contentsRect(); + const TQRect bar = contentsRect(); + + TQSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() ); + + TQPoint pn = backgroundOffset(); + buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() ); + + const TQPixmap *bpm = paletteBackgroundPixmap(); + if ( bpm ) { + buffer.painter()->fillRect( bar, TQBrush( paletteBackgroundColor(), *bpm ) ); + } + else { + buffer.painter()->fillRect( bar, paletteBackgroundColor() ); + } + buffer.painter()->setFont( p->font() ); - TQSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() ); + TQStyle::SFlags flags = TQStyle::Style_Default; + if (isEnabled()) { + flags |= TQStyle::Style_Enabled; + } + if (hasFocus()) { + flags |= TQStyle::Style_HasFocus; + } + if (hasMouse()) { + flags |= TQStyle::Style_MouseOver; + } - TQPoint pn = backgroundOffset(); - buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() ); + style().drawControl(TQStyle::CE_ProgressBarGroove, buffer.painter(), this, + TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarGroove, this), this ), + colorGroup(), flags); - const TQPixmap *bpm = paletteBackgroundPixmap(); - if ( bpm ) - buffer.painter()->fillRect( bar, TQBrush( paletteBackgroundColor(), *bpm ) ); - else - buffer.painter()->fillRect( bar, paletteBackgroundColor() ); - buffer.painter()->setFont( p->font() ); + TQWMatrix oldMatrix = buffer.painter()->worldMatrix(); - TQStyle::SFlags flags = TQStyle::Style_Default; - if (isEnabled()) - flags |= TQStyle::Style_Enabled; - if (hasFocus()) - flags |= TQStyle::Style_HasFocus; - if (hasMouse()) - flags |= TQStyle::Style_MouseOver; + TQStyleControlElementData ceData = populateControlElementDataFromWidget(this, TQStyleOption()); + TQStyle::ControlElementFlags elementFlags = getControlElementFlagsForObject(this, ceData.widgetObjectTypes, TQStyleOption()); - style().drawControl(TQStyle::CE_ProgressBarGroove, buffer.painter(), this, - TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarGroove, this), this ), - colorGroup(), flags); + // Draw contents + if (m_orientation == TQt::Vertical) { + // If oriented vertically, apply a 90 degree rotation matrix to the painter + TQWMatrix m; - style().drawControl(TQStyle::CE_ProgressBarContents, buffer.painter(), this, - TQStyle::visualRect(style().subRect(TQStyle::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(TQStyle::CE_ProgressBarLabel, buffer.painter(), this, - TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarLabel, this), this ), - colorGroup(), flags); + buffer.painter()->setWorldMatrix(m, TRUE); + + ceData.rect = TQRect(ceData.rect.y(), ceData.rect.x(), ceData.rect.height(), ceData.rect.width()); + } + + style().drawControl(TQStyle::CE_ProgressBarContents, buffer.painter(), ceData, elementFlags, + TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, this), ceData, elementFlags), + colorGroup(), flags, TQStyleOption(), this); + + buffer.painter()->setWorldMatrix(oldMatrix, TRUE); + + if (percentageVisible()) { + style().drawControl(TQStyle::CE_ProgressBarLabel, buffer.painter(), this, + TQStyle::visualRect(style().subRect(TQStyle::SR_ProgressBarLabel, this), this ), + colorGroup(), flags); + } } #endif