diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-05-13 10:06:02 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-05-13 12:49:01 +0100 |
commit | b1a9498a1415ca42e4d13f3e56daff0ebffc0ccf (patch) | |
tree | 8f93312b3fdb31c78bed1fce61f38664362bb87b /vcl | |
parent | 47ac1b7445520c04f4c98bac925fe14257fd8098 (diff) |
Remove EditBoxValue again and just use the native widgets size request
Change-Id: Ib9d0f06bffc9e9d31149a622350145024a9b8a99
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/combobox.cxx | 6 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 5 | ||||
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/lstbox.cxx | 8 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/nativecontrols.cxx | 19 | ||||
-rw-r--r-- | vcl/source/window/brdwin.cxx | 13 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 48 |
9 files changed, 39 insertions, 70 deletions
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 502ab15d8221..688fff6af2bd 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -109,7 +109,7 @@ void ComboBox::ImplCalcEditHeight() Rectangle aCtrlRegion( Point( 0, 0 ), Size( 10, 10 ) ); Rectangle aBoundRegion, aContentRegion; - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; ControlType aType = IsDropDownBox() ? CTRL_COMBOBOX : CTRL_EDITBOX; if( GetNativeControlRegion( aType, PART_ENTIRE_CONTROL, aCtrlRegion, @@ -992,7 +992,7 @@ long ComboBox::getMaxWidthScrollBarAndDownButton() const long nButtonDownWidth = 0; vcl::Window *pBorder = GetWindow( WINDOW_BORDER ); - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; @@ -1425,7 +1425,7 @@ ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Siz long nBottom = rOutSz.Height(); vcl::Window *pBorder = GetWindow( WINDOW_BORDER ); - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 0d5859e3842a..c64228210d00 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2739,7 +2739,6 @@ void Edit::SetSubEdit( Edit* pEdit ) Size Edit::CalcMinimumSizeForText(const OUString &rString) const { int eCtrlType = ImplGetNativeControlType(); - auto nTextHeight = GetTextHeight(); Size aSize; if (mnWidthInChars != -1) @@ -2756,7 +2755,7 @@ Size Edit::CalcMinimumSizeForText(const OUString &rString) const else aString = rString; - aSize.Height() = nTextHeight; + aSize.Height() = GetTextHeight(); aSize.Width() = GetTextWidth(aString); aSize.Width() += ImplGetExtraXOffset() * 2; @@ -2775,7 +2774,7 @@ Size Edit::CalcMinimumSizeForText(const OUString &rString) const aSize = CalcWindowSize( aSize ); // ask NWF what if it has an opinion, too - EditBoxValue aControlValue(nTextHeight); + ImplControlValue aControlValue; Rectangle aRect( Point( 0, 0 ), aSize ); Rectangle aContent, aBound; if( GetNativeControlRegion( diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 0961df128e83..8e94b42ed4e9 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -2675,7 +2675,7 @@ void ImplWin::ImplDraw( bool bLayout ) // vcl/source/window/brdwin.cxx vcl::Window *pWin = GetParent(); - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; if ( !pWin->IsEnabled() ) nState &= ~ControlState::ENABLED; if ( pWin->HasFocus() ) diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index f45962bb3420..8db825e8880d 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -118,7 +118,7 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) if( IsNativeWidgetEnabled() && IsNativeControlSupported( CTRL_LISTBOX, PART_ENTIRE_CONTROL ) ) { - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Rectangle aCtrlRegion( Point( 0, 0 ), Size( 20, mnDDHeight ) ); Rectangle aBoundingRgn( aCtrlRegion ); Rectangle aContentRgn( aCtrlRegion ); @@ -634,7 +634,7 @@ void ListBox::Resize() // Note: in case of no border, pBorder will actually be this vcl::Window *pBorder = GetWindow( WINDOW_BORDER ); - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; @@ -1220,7 +1220,7 @@ Size ListBox::CalcMinimumSize() const { // Try native borders; scrollbar size may not be a good indicator // See how large the edit area inside is to estimate what is needed for the dropdown - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; Size aTestSize( 100, 20 ); @@ -1239,7 +1239,7 @@ Size ListBox::CalcMinimumSize() const if (IsDropDownBox()) // Check minimum height of dropdown box { - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Rectangle aRect( Point( 0, 0 ), aSz ); Rectangle aContent, aBound; if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aRect, ControlState::NONE, diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 00f9a0827c94..aeef55b244d4 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -670,7 +670,7 @@ void SpinField::ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rec vcl::Window *pBorder = pWin->GetWindow( WINDOW_BORDER ); // get the system's spin button size - EditBoxValue aControlValue(pWin->GetTextHeight()); + ImplControlValue aControlValue; Rectangle aBound; Point aPoint; @@ -724,7 +724,7 @@ void SpinField::Resize() { ImplCalcButtonAreas( this, aSize, maDropDownRect, maUpperRect, maLowerRect ); - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; @@ -923,7 +923,7 @@ Size SpinField::CalcMinimumSizeForText(const OUString &rString) const aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize(); if ( GetStyle() & WB_SPIN ) { - EditBoxValue aControlValue(GetTextHeight()); + ImplControlValue aControlValue; Rectangle aArea( Point(), Size(100, aSz.Height())); Rectangle aEntireBound, aEntireContent, aEditBound, aEditContent; if ( diff --git a/vcl/source/outdev/nativecontrols.cxx b/vcl/source/outdev/nativecontrols.cxx index 95fbfaa2c164..e46df3324262 100644 --- a/vcl/source/outdev/nativecontrols.cxx +++ b/vcl/source/outdev/nativecontrols.cxx @@ -150,12 +150,6 @@ PushButtonValue* PushButtonValue::clone() const return new PushButtonValue( *this ); } -EditBoxValue* EditBoxValue::clone() const -{ - assert( typeid( const EditBoxValue ) == typeid( *this )); - return new EditBoxValue( *this ); -} - // These functions are mainly passthrough functions that allow access to // the SalFrame behind a Window object for native widget rendering purposes. @@ -254,6 +248,9 @@ 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); @@ -262,16 +259,6 @@ 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 154875792365..06a28c0bccbc 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -1040,11 +1040,8 @@ 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) { - xControlValue.reset(new EditBoxValue(pCtrl->GetTextHeight())); - switch( pCtrl->GetType() ) { case WINDOW_LISTBOX: @@ -1087,11 +1084,12 @@ 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, *xControlValue, OUString(), + ControlState::ENABLED, aControlValue, OUString(), aBounds, aContent ) ) { mnLeftBorder = aContent.Left() - aBounds.Left(); @@ -1199,10 +1197,8 @@ 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) { - xControlValue.reset(new EditBoxValue(pCtrl->GetTextHeight())); switch (pCtrl->GetType()) { case WINDOW_MULTILINEEDIT: @@ -1266,6 +1262,7 @@ void ImplSmallBorderWindowView::DrawWindow(sal_uInt16 nDrawFlags, OutputDevice*, if (aCtrlType && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart)) { + ImplControlValue aControlValue; ControlState nState = ControlState::ENABLED; if (!pWin->IsEnabled()) @@ -1299,13 +1296,13 @@ void ImplSmallBorderWindowView::DrawWindow(sal_uInt16 nDrawFlags, OutputDevice*, Rectangle aContentRgn(aCtrlRegion); if (!ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize && pWin->GetNativeControlRegion(aCtrlType, aCtrlPart, aCtrlRegion, - nState, *xControlValue, OUString(), + nState, aControlValue, OUString(), aBoundingRgn, aContentRgn)) { aCtrlRegion=aContentRgn; } - bNativeOK = pWin->DrawNativeControl(aCtrlType, aCtrlPart, aCtrlRegion, nState, *xControlValue, OUString()); + bNativeOK = pWin->DrawNativeControl(aCtrlType, aCtrlPart, aCtrlRegion, nState, aControlValue, 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/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 34f3d0e50038..41d232f64423 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -1670,7 +1670,7 @@ bool ToolBox::ImplCalcItem() { Rectangle aRect( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) ); Rectangle aReg( aRect ); - EditBoxValue aVal(GetTextHeight()); + ImplControlValue aVal; Rectangle aNativeBounds, aNativeContent; if( IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) { diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 2aad70e5caf5..ce3e88fe91d8 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -1040,25 +1040,12 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co return true; } -Rectangle AdjustRectForTextBordersPadding(GtkStyleContext* pStyle, long nContentHeight, const Rectangle& rControlRegion) +Rectangle GetWidgetSize(const Rectangle& rControlRegion, GtkWidget* widget) { - gtk_style_context_save(pStyle); - - GtkBorder border; - gtk_style_context_get_border(pStyle, GTK_STATE_FLAG_NORMAL, &border); - - GtkBorder padding; - gtk_style_context_get_padding(pStyle, GTK_STATE_FLAG_NORMAL, &padding); - - gint nWidgetHeight = nContentHeight + padding.top + padding.bottom + border.top + border.bottom; - - nWidgetHeight = std::max<gint>(nWidgetHeight, rControlRegion.GetHeight()); - - Rectangle aEditRect(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nWidgetHeight)); - - gtk_style_context_restore(pStyle); - - return aEditRect; + GtkRequisition aReq; + gtk_widget_get_preferred_size(widget, NULL, &aReq); + long nHeight = (rControlRegion.GetHeight() > aReq.height) ? rControlRegion.GetHeight() : aReq.height; + return Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nHeight)); } Rectangle AdjustRectForTextBordersPadding(GtkStyleContext* pStyle, long nContentWidth, long nContentHeight, const Rectangle& rControlRegion) @@ -1086,6 +1073,8 @@ Rectangle AdjustRectForTextBordersPadding(GtkStyleContext* pStyle, long nContent static GtkWidget* gCacheWindow; static GtkWidget* gDumbContainer; +static GtkWidget* gSpinBox; +static GtkWidget* gEntryBox; static GtkWidget* gComboBox; static GtkWidget* gComboBoxButtonWidget; static GtkWidget* gComboBoxEntryWidget; @@ -1170,7 +1159,7 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar ((nPart==PART_BUTTON_UP) || (nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) ) { - Rectangle aControlRegion(AdjustRectForTextBordersPadding(mpSpinStyle, rValue.getNumericVal(), rControlRegion)); + Rectangle aControlRegion(GetWidgetSize(rControlRegion, gSpinBox)); aEditRect = NWGetSpinButtonRect(nPart, aControlRegion); } else if ( (nType==CTRL_COMBOBOX) && @@ -1185,25 +1174,19 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar } else if (nType == CTRL_EDITBOX && nPart == PART_ENTIRE_CONTROL) { - aEditRect = AdjustRectForTextBordersPadding(mpEntryStyle, rValue.getNumericVal(), rControlRegion); + aEditRect = GetWidgetSize(rControlRegion, gEntryBox); } else if (nType == CTRL_LISTBOX && nPart == PART_ENTIRE_CONTROL) { - GtkRequisition aReq; - gtk_widget_get_preferred_size(gComboBox, NULL, &aReq); - long nHeight = (rControlRegion.GetHeight() > aReq.height) ? rControlRegion.GetHeight() : aReq.height; - aEditRect = Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nHeight)); + aEditRect = GetWidgetSize(rControlRegion, gListBox); } else if (nType == CTRL_COMBOBOX && nPart == PART_ENTIRE_CONTROL) { - GtkRequisition aReq; - gtk_widget_get_preferred_size(gComboBox, NULL, &aReq); - long nHeight = (rControlRegion.GetHeight() > aReq.height) ? rControlRegion.GetHeight() : aReq.height; - aEditRect = Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nHeight)); + aEditRect = GetWidgetSize(rControlRegion, gComboBox); } else if (nType == CTRL_SPINBOX && nPart == PART_ENTIRE_CONTROL) { - aEditRect = AdjustRectForTextBordersPadding(mpSpinStyle, rValue.getNumericVal(), rControlRegion); + aEditRect = GetWidgetSize(rControlRegion, gSpinBox); } else if (nType == CTRL_TAB_ITEM && nPart == PART_ENTIRE_CONTROL) { @@ -1791,7 +1774,8 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gtk_widget_realize(gDumbContainer); gtk_widget_realize(gCacheWindow); - getStyleContext(&mpEntryStyle, gtk_entry_new()); + gEntryBox = gtk_entry_new(); + getStyleContext(&mpEntryStyle, gEntryBox); getStyleContext(&mpButtonStyle, gtk_button_new()); getStyleContext(&mpToolbarStyle, gtk_toolbar_new()); @@ -1840,7 +1824,8 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gtk_style_context_add_class(mpMenuBarStyle, GTK_STYLE_CLASS_MENU); /* Spinbutton */ - getStyleContext(&mpSpinStyle, gtk_spin_button_new(NULL, 0, 0)); + gSpinBox = gtk_spin_button_new(NULL, 0, 0); + getStyleContext(&mpSpinStyle, gSpinBox); /* NoteBook */ getStyleContext(&mpNoteBookStyle, gtk_notebook_new()); @@ -1857,6 +1842,7 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) /* Listbox */ gListBox = gtk_combo_box_text_new(); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gListBox), "sample"); getStyleContext(&mpListboxStyle, gListBox); /* Get ComboBox Button */ gtk_container_forall(GTK_CONTAINER(gListBox), |