summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-04-24 14:59:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-04-24 16:45:40 +0100
commit7deac4656c53965125c9ec1ca6eb8fcc8d393afa (patch)
tree1ad5ce971cf3da22fcec786294d37e591c13029f /vcl
parentbeb2b25c97bbbe37309a6186269b30be7b0d7a6f (diff)
gtk3: get the right height for Edit boxes
smuggle the text height down to the native region calculation code instead of messing around with proxies Change-Id: I727ceddb5b431be82e6e5a725f9bca588e5b2046
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/edit.cxx5
-rw-r--r--vcl/source/outdev/nativecontrols.cxx13
-rw-r--r--vcl/source/window/brdwin.cxx22
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx21
4 files changed, 48 insertions, 13 deletions
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 6c737423d6a8..c9e19db49bfe 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2710,6 +2710,7 @@ void Edit::SetSubEdit( Edit* pEdit )
Size Edit::CalcMinimumSizeForText(const OUString &rString) const
{
int eCtrlType = ImplGetNativeControlType();
+ auto nTextHeight = GetTextHeight();
Size aSize;
if (mnWidthInChars != -1)
@@ -2726,7 +2727,7 @@ Size Edit::CalcMinimumSizeForText(const OUString &rString) const
else
aString = rString;
- aSize.Height() = GetTextHeight();
+ aSize.Height() = nTextHeight;
aSize.Width() = GetTextWidth(aString);
aSize.Width() += ImplGetExtraOffset() * 2;
@@ -2749,7 +2750,7 @@ Size Edit::CalcMinimumSizeForText(const OUString &rString) const
aSize = CalcWindowSize( aSize );
// ask NWF what if it has an opinion, too
- ImplControlValue aControlValue;
+ EditBoxValue aControlValue(nTextHeight);
Rectangle aRect( Point( 0, 0 ), aSize );
Rectangle aContent, aBound;
if( GetNativeControlRegion(
diff --git a/vcl/source/outdev/nativecontrols.cxx b/vcl/source/outdev/nativecontrols.cxx
index bfb0447a1953..7a8e70ffc1b3 100644
--- a/vcl/source/outdev/nativecontrols.cxx
+++ b/vcl/source/outdev/nativecontrols.cxx
@@ -247,9 +247,6 @@ static std::shared_ptr< ImplControlValue > TransformControlValue( const ImplCont
aResult.reset( pNew );
}
break;
- case CTRL_GENERIC:
- aResult.reset( new ImplControlValue( rVal ) );
- break;
case CTRL_MENU_POPUP:
{
const MenupopupValue* pMVal = static_cast<const MenupopupValue*>(&rVal);
@@ -258,6 +255,16 @@ static std::shared_ptr< ImplControlValue > TransformControlValue( const ImplCont
aResult.reset( pNew );
}
break;
+ case CTRL_EDITBOX:
+ {
+ auto nTextHeight = rDev.ImplLogicToDevicePixel(Rectangle(0, 0, 0, rVal.getNumericVal())).GetHeight();
+ EditBoxValue* pNew = new EditBoxValue(nTextHeight);
+ aResult.reset(pNew);
+ }
+ break;
+ case CTRL_GENERIC:
+ aResult.reset( new ImplControlValue( rVal ) );
+ break;
default:
OSL_FAIL( "unknown ImplControlValue type !" );
break;
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 5818d11b57ae..e4322e16d6b7 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -1040,6 +1040,7 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei
// for native widget drawing we must find out what
// control this border belongs to
ControlType aCtrlType = 0;
+ std::unique_ptr<ImplControlValue> xControlValue(new ImplControlValue());
if (pCtrl)
{
switch( pCtrl->GetType() )
@@ -1073,7 +1074,13 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei
case WINDOW_SPINFIELD:
case WINDOW_CALCINPUTLINE:
mbNWFBorder = true;
- aCtrlType = (pCtrl->GetStyle() & WB_SPIN) ? CTRL_SPINBOX : CTRL_EDITBOX;
+ if (pCtrl->GetStyle() & WB_SPIN)
+ aCtrlType = CTRL_SPINBOX;
+ else
+ {
+ aCtrlType = CTRL_EDITBOX;
+ xControlValue.reset(new EditBoxValue(pWin->GetTextHeight()));
+ }
break;
default:
break;
@@ -1081,12 +1088,11 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei
}
if( mbNWFBorder )
{
- ImplControlValue aControlValue;
Rectangle aCtrlRegion( (const Point&)Point(), Size( mnWidth < 10 ? 10 : mnWidth, mnHeight < 10 ? 10 : mnHeight ) );
Rectangle aBounds( aCtrlRegion );
Rectangle aContent( aCtrlRegion );
if( pWin->GetNativeControlRegion( aCtrlType, PART_ENTIRE_CONTROL, aCtrlRegion,
- ControlState::ENABLED, aControlValue, OUString(),
+ ControlState::ENABLED, *xControlValue, OUString(),
aBounds, aContent ) )
{
mnLeftBorder = aContent.Left() - aBounds.Left();
@@ -1192,7 +1198,7 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
ControlType aCtrlType = 0;
ControlPart aCtrlPart = PART_ENTIRE_CONTROL;
-
+ std::unique_ptr<ImplControlValue> xControlValue(new ImplControlValue());
if( pWin && (pCtrl = mpBorderWindow->GetWindow( WINDOW_CLIENT )) != NULL )
{
switch( pCtrl->GetType() )
@@ -1213,7 +1219,10 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
if( pCtrl->GetStyle() & WB_SPIN )
aCtrlType = CTRL_SPINBOX;
else
+ {
aCtrlType = CTRL_EDITBOX;
+ xControlValue.reset(new EditBoxValue(pCtrl->GetTextHeight()));
+ }
break;
case WINDOW_LISTBOX:
@@ -1258,7 +1267,6 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
if ( aCtrlType && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart) )
{
- ImplControlValue aControlValue;
ControlState nState = ControlState::ENABLED;
if ( !pWin->IsEnabled() )
@@ -1290,14 +1298,14 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
Rectangle aContentRgn( aCtrlRegion );
if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion,
- nState, aControlValue, OUString(),
+ nState, *xControlValue, OUString(),
aBoundingRgn, aContentRgn ))
{
aCtrlRegion=aContentRgn;
}
bNativeOK = pWin->DrawNativeControl( aCtrlType, aCtrlPart, aCtrlRegion, nState,
- aControlValue, OUString() );
+ *xControlValue, OUString() );
// if the native theme draws the spinbuttons in one call, make sure the proper settings
// are passed, this might force a redraw though.... (TODO: improve)
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index aba6dd955163..9c992baebcd0 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -980,7 +980,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
}
bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState,
- const ImplControlValue&, const OUString&,
+ const ImplControlValue& rValue, const OUString&,
Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion )
{
/* TODO: all this funcions needs improvements */
@@ -1069,6 +1069,25 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar
{
aEditRect = NWGetComboBoxButtonRect( nType, nPart, rControlRegion );
}
+ else if (nType == CTRL_EDITBOX)
+ {
+ gtk_style_context_save(mpEntryStyle);
+ gtk_style_context_add_class(mpEntryStyle, GTK_STYLE_CLASS_ENTRY);
+
+ GtkBorder border;
+ gtk_style_context_get_border(mpEntryStyle, GTK_STATE_FLAG_NORMAL, &border);
+
+ GtkBorder padding;
+ gtk_style_context_get_padding(mpEntryStyle, GTK_STATE_FLAG_NORMAL, &padding);
+
+ auto nTextHeight = rValue.getNumericVal();
+
+ gint nWidgetHeight = nTextHeight + padding.top + padding.bottom + border.top + border.bottom;
+
+ aEditRect = Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nWidgetHeight));
+
+ gtk_style_context_restore(mpEntryStyle);
+ }
else
{
return false;