Kaydet (Commit) 27be8a26 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

KDE4 fix edit box borders

When recalculating the native window frame borders, calculate
using already existing window borders. Otherwise the KDE edit
box results in an unlimited recursion for increasing the
bounding rects, if the control doesn't fit.

Change-Id: I45e51e4796b06097ca537c656f004133dfacd033
üst 98e45efa
...@@ -530,9 +530,11 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei ...@@ -530,9 +530,11 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei
if( mbNWFBorder ) if( mbNWFBorder )
{ {
ImplControlValue aControlValue; ImplControlValue aControlValue;
Rectangle aCtrlRegion( (const Point&)Point(), Size( mnWidth < 10 ? 10 : mnWidth, mnHeight < 10 ? 10 : mnHeight ) ); Size aMinSize( mnWidth - mnLeftBorder - mnRightBorder, mnHeight - mnTopBorder - mnBottomBorder );
Rectangle aBounds( aCtrlRegion ); if( aMinSize.Width() < 10 ) aMinSize.setWidth( 10 );
Rectangle aContent( aCtrlRegion ); if( aMinSize.Height() < 10 ) aMinSize.setHeight( 10 );
Rectangle aCtrlRegion( Point(mnLeftBorder, mnTopBorder), aMinSize );
Rectangle aBounds, aContent;
if( pWin->GetNativeControlRegion( aCtrlType, ControlPart::Entire, aCtrlRegion, if( pWin->GetNativeControlRegion( aCtrlType, ControlPart::Entire, aCtrlRegion,
ControlState::ENABLED, aControlValue, OUString(), ControlState::ENABLED, aControlValue, OUString(),
aBounds, aContent ) ) aBounds, aContent ) )
......
...@@ -49,6 +49,8 @@ void KDEData::initNWF() ...@@ -49,6 +49,8 @@ void KDEData::initNWF()
// Qt theme engines may support a rollover menubar // Qt theme engines may support a rollover menubar
pSVData->maNWFData.mbRolloverMenubar = true; pSVData->maNWFData.mbRolloverMenubar = true;
pSVData->maNWFData.mbNoFocusRects = true;
// Styled menus need additional space // Styled menus need additional space
QStyle *style = QApplication::style(); QStyle *style = QApplication::style();
pSVData->maNWFData.mnMenuFormatBorderX = pSVData->maNWFData.mnMenuFormatBorderX =
......
...@@ -87,6 +87,7 @@ bool KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart par ...@@ -87,6 +87,7 @@ bool KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart par
case ControlType::Menubar: case ControlType::Menubar:
case ControlType::MenuPopup: case ControlType::MenuPopup:
case ControlType::Editbox: case ControlType::Editbox:
case ControlType::MultilineEditbox:
case ControlType::Combobox: case ControlType::Combobox:
case ControlType::Toolbar: case ControlType::Toolbar:
case ControlType::Frame: case ControlType::Frame:
...@@ -406,20 +407,15 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, ...@@ -406,20 +407,15 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
draw( QStyle::PE_IndicatorToolBarHandle, &option, m_image.get(), draw( QStyle::PE_IndicatorToolBarHandle, &option, m_image.get(),
vclStateValue2StateFlag(nControlState, value), rect ); vclStateValue2StateFlag(nControlState, value), rect );
} }
else if (type == ControlType::Editbox) else if (type == ControlType::Editbox || type == ControlType::MultilineEditbox)
{ {
QStyleOptionFrameV2 option; lcl_drawFrame( QStyle::PE_FrameLineEdit, m_image.get(),
draw( QStyle::PE_PanelLineEdit, &option, m_image.get(),
vclStateValue2StateFlag(nControlState, value), m_image->rect().adjusted( 2, 2, -2, -2 ));
draw( QStyle::PE_FrameLineEdit, &option, m_image.get(),
vclStateValue2StateFlag(nControlState, value)); vclStateValue2StateFlag(nControlState, value));
} }
else if (type == ControlType::Combobox) else if (type == ControlType::Combobox)
{ {
QStyleOptionComboBox option; QStyleOptionComboBox option;
option.editable = true; option.editable = true;
draw( QStyle::CC_ComboBox, &option, m_image.get(), draw( QStyle::CC_ComboBox, &option, m_image.get(),
vclStateValue2StateFlag(nControlState, value) ); vclStateValue2StateFlag(nControlState, value) );
} }
...@@ -678,32 +674,33 @@ bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, ...@@ -678,32 +674,33 @@ bool KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part,
{ {
int size = QApplication::style()->pixelMetric( int size = QApplication::style()->pixelMetric(
QStyle::PM_ButtonDefaultIndicator, &styleOption ); QStyle::PM_ButtonDefaultIndicator, &styleOption );
boundingRect.adjust( -size, -size, size, size ); boundingRect.adjust( -size, -size, size, size );
retVal = true; retVal = true;
} }
} }
break; break;
case ControlType::Editbox: case ControlType::Editbox:
case ControlType::MultilineEditbox:
{ {
int nFontHeight = QApplication::fontMetrics().height(); QStyleOptionFrameV3 fo;
//int nFrameSize = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth); fo.frameShape = QFrame::StyledPanel;
int nLayoutTop = QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); fo.state = QStyle::State_Sunken;
int nLayoutBottom = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin); fo.lineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int nLayoutLeft = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); QSize aMinSize = QApplication::style()->
int nLayoutRight = QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin); sizeFromContents( QStyle::CT_LineEdit, &fo, contentRect.size() );
if( aMinSize.height() > boundingRect.height() )
int nMinHeight = (nFontHeight + nLayoutTop + nLayoutBottom); {
if( boundingRect.height() < nMinHeight ) int nHeight = (aMinSize.height() - boundingRect.height()) / 2;
assert( 0 == (aMinSize.height() - boundingRect.height()) % 2 );
boundingRect.adjust( 0, -nHeight, 0, nHeight );
}
if( aMinSize.width() > boundingRect.width() )
{ {
int delta = nMinHeight - boundingRect.height(); int nWidth = (aMinSize.width() - boundingRect.width()) / 2;
boundingRect.adjust( 0, 0, 0, delta ); assert( 0 == (aMinSize.width() - boundingRect.width()) % 2 );
boundingRect.adjust( -nWidth, 0, nWidth, 0 );
} }
contentRect = boundingRect;
contentRect.adjust( -nLayoutLeft+1, -nLayoutTop+1, nLayoutRight-1, nLayoutBottom-1 );
retVal = true; retVal = true;
break; break;
} }
case ControlType::Checkbox: case ControlType::Checkbox:
......
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