Kaydet (Commit) 0ede2509 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

KDE4 add frame to Spinbox and enable buttons...

... and don't claim to support all parts per default.

Change-Id: I7a8e0774b4573bf755737bc1adebe19a774736c9
üst 27be8a26
...@@ -504,6 +504,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, ...@@ -504,6 +504,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
else if (type == ControlType::Spinbox) else if (type == ControlType::Spinbox)
{ {
QStyleOptionSpinBox option; QStyleOptionSpinBox option;
option.frame = true;
// determine active control // determine active control
if( value.getType() == ControlType::SpinButtons ) if( value.getType() == ControlType::SpinButtons )
...@@ -513,6 +514,14 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, ...@@ -513,6 +514,14 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
option.activeSubControls |= QStyle::SC_SpinBoxUp; option.activeSubControls |= QStyle::SC_SpinBoxUp;
if( (pSpinVal->mnLowerState & ControlState::PRESSED) ) if( (pSpinVal->mnLowerState & ControlState::PRESSED) )
option.activeSubControls |= QStyle::SC_SpinBoxDown; option.activeSubControls |= QStyle::SC_SpinBoxDown;
if( (pSpinVal->mnUpperState & ControlState::ENABLED) )
option.stepEnabled |= QAbstractSpinBox::StepUpEnabled;
if( (pSpinVal->mnLowerState & ControlState::ENABLED) )
option.stepEnabled |= QAbstractSpinBox::StepDownEnabled;
if( (pSpinVal->mnUpperState & ControlState::ROLLOVER) )
option.state = QStyle::State_MouseOver;
if( (pSpinVal->mnLowerState & ControlState::ROLLOVER) )
option.state = QStyle::State_MouseOver;
} }
draw( QStyle::CC_SpinBox, &option, m_image.get(), draw( QStyle::CC_SpinBox, &option, m_image.get(),
...@@ -801,12 +810,25 @@ bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, ...@@ -801,12 +810,25 @@ bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
case ControlType::Spinbox: case ControlType::Spinbox:
{ {
QStyleOptionSpinBox sbo; QStyleOptionSpinBox sbo;
sbo.frame = true;
sbo.rect = QRect(0, 0, contentRect.width(), contentRect.height()); sbo.rect = QRect(0, 0, contentRect.width(), contentRect.height());
sbo.state = vclStateValue2StateFlag(controlState, val); sbo.state = vclStateValue2StateFlag(controlState, val);
switch ( part ) switch ( part )
{ {
case ControlPart::Entire:
{
int nHeight = QApplication::fontMetrics().height();
QSize aContentSize( contentRect.width(), nHeight );
QSize aMinSize = QApplication::style()->
sizeFromContents( QStyle::CT_SpinBox, &sbo, aContentSize );
if( aMinSize.height() > contentRect.height() )
contentRect.adjust( 0, 0, 0, aMinSize.height() - contentRect.height() );
boundingRect = contentRect;
retVal = true;
break;
}
case ControlPart::ButtonUp: case ControlPart::ButtonUp:
contentRect = QApplication::style()->subControlRect( contentRect = QApplication::style()->subControlRect(
QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxUp ); QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxUp );
...@@ -830,7 +852,7 @@ bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, ...@@ -830,7 +852,7 @@ bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
contentRect.translate( boundingRect.left(), boundingRect.top() ); contentRect.translate( boundingRect.left(), boundingRect.top() );
break; break;
default: default:
retVal = true; break;
} }
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment