diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-01-14 10:40:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-01-14 16:04:17 +0000 |
commit | 830f44b1ca0e121d3e27a031054313e3f194ab1d (patch) | |
tree | 5e278495b667b8ca36d10770dc07d32134954e80 /vcl/source | |
parent | d652af7d071bb5e5c3f7592d6dc7e7c400e711d3 (diff) |
we only ever want the preferred window size from GetOptimalSize
so remove the MAX and MIN options and simplify the whole lot
Change-Id: Iaaf350c37e01f7fce434af760bcddb9b7d7135ea
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/control/button.cxx | 28 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 9 | ||||
-rw-r--r-- | vcl/source/control/ctrl.cxx | 16 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 9 | ||||
-rw-r--r-- | vcl/source/control/fixed.cxx | 56 | ||||
-rw-r--r-- | vcl/source/control/lstbox.cxx | 9 | ||||
-rw-r--r-- | vcl/source/control/scrbar.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 9 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/brdwin.cxx | 12 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/msgbox.cxx | 11 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/tabdlg.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/tabpage.cxx | 11 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/window3.cxx | 13 |
18 files changed, 62 insertions, 147 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 8ad4c6cb6324..16190b482913 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1707,15 +1707,9 @@ Size PushButton::CalcMinimumSize( long nMaxWidth ) const return CalcWindowSize( aSize ); } -Size PushButton::GetOptimalSize(WindowSizeType eType) const +Size PushButton::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: { - return CalcMinimumSize(); - } - default: - return Button::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } bool PushButton::set_property(const rtl::OString &rKey, const rtl::OString &rValue) @@ -3077,14 +3071,9 @@ Size RadioButton::CalcMinimumSize( long nMaxWidth ) const // ----------------------------------------------------------------------- -Size RadioButton::GetOptimalSize(WindowSizeType eType) const +Size RadioButton::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcMinimumSize(); - default: - return Button::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } // ======================================================================= @@ -3992,14 +3981,9 @@ Size CheckBox::CalcMinimumSize( long nMaxWidth ) const // ----------------------------------------------------------------------- -Size CheckBox::GetOptimalSize(WindowSizeType eType) const +Size CheckBox::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcMinimumSize(); - default: - return Button::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } // ======================================================================= diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 389929c34b53..75f4e307e5e4 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -1016,14 +1016,9 @@ long ComboBox::CalcWindowSizePixel( sal_uInt16 nLines ) const // ----------------------------------------------------------------------- -Size ComboBox::GetOptimalSize(WindowSizeType eType) const +Size ComboBox::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcMinimumSize(); - default: - return Edit::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 8ebd3ebf124c..debdc4fab382 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -455,18 +455,10 @@ ControlLayoutData::~ControlLayoutData() // ----------------------------------------------------------------- -Size Control::GetOptimalSize(WindowSizeType eType) const -{ - switch (eType) { - case WINDOWSIZE_MINIMUM: - return Size( GetTextWidth( GetText() ) + 2 * 12, - GetTextHeight() + 2 * 6 ); - case WINDOWSIZE_PREFERRED: - return GetOptimalSize( WINDOWSIZE_MINIMUM ); - case WINDOWSIZE_MAXIMUM: - default: - return Size( LONG_MAX, LONG_MAX ); - } +Size Control::GetOptimalSize() const +{ + return Size( GetTextWidth( GetText() ) + 2 * 12, + GetTextHeight() + 2 * 6 ); } // ----------------------------------------------------------------- diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 513fd51e2d11..3e177d09a184 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2954,14 +2954,9 @@ Size Edit::GetMinimumEditSize() // ----------------------------------------------------------------------- -Size Edit::GetOptimalSize(WindowSizeType eType) const +Size Edit::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcMinimumSize(); - default: - return Control::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 4646f3b42983..42b150ce885b 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -417,34 +417,26 @@ Size FixedText::CalcMinimumSize( long nMaxWidth ) const } // ----------------------------------------------------------------------- -Size FixedText::GetOptimalSize(WindowSizeType eType) const +Size FixedText::GetOptimalSize() const { - switch (eType) + sal_Int32 nMaxAvailWidth = 0x7fffffff; + const OUString &rTxt = GetText(); + if (m_nMaxWidthChars != -1 && m_nMaxWidthChars < rTxt.getLength()) { - case WINDOWSIZE_MINIMUM: - { - sal_Int32 nMaxAvailWidth = 0x7fffffff; - const OUString &rTxt = GetText(); - if (m_nMaxWidthChars != -1 && m_nMaxWidthChars < rTxt.getLength()) - { - nMaxAvailWidth = getTextDimensions(this, - rTxt.copy(0, m_nMaxWidthChars), 0x7fffffff).Width(); - } - Size aRet = CalcMinimumSize(nMaxAvailWidth); - if (m_nMinWidthChars != -1) - { - OUStringBuffer aBuf; - comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x'); - Size aMinAllowed = getTextDimensions(this, - aBuf.makeStringAndClear(), 0x7fffffff); - if (aMinAllowed.Width() > aRet.Width()) - aRet = aMinAllowed; - } - return aRet; - } - default: - return Control::GetOptimalSize( eType ); + nMaxAvailWidth = getTextDimensions(this, + rTxt.copy(0, m_nMaxWidthChars), 0x7fffffff).Width(); + } + Size aRet = CalcMinimumSize(nMaxAvailWidth); + if (m_nMinWidthChars != -1) + { + OUStringBuffer aBuf; + comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x'); + Size aMinAllowed = getTextDimensions(this, + aBuf.makeStringAndClear(), 0x7fffffff); + if (aMinAllowed.Width() > aRet.Width()) + aRet = aMinAllowed; } + return aRet; } // ----------------------------------------------------------------------- @@ -753,14 +745,9 @@ void FixedLine::DataChanged( const DataChangedEvent& rDCEvt ) // ----------------------------------------------------------------------- -Size FixedLine::GetOptimalSize(WindowSizeType eType) const +Size FixedLine::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcWindowSize( FixedText::CalcMinimumTextSize ( this, 0x7fffffff ) ); - default: - return Control::GetOptimalSize( eType ); - } + return CalcWindowSize( FixedText::CalcMinimumTextSize ( this, 0x7fffffff ) ); } // ======================================================================= @@ -1106,10 +1093,9 @@ void FixedImage::Paint( const Rectangle& ) // ----------------------------------------------------------------------- -Size FixedImage::GetOptimalSize( WindowSizeType ) const +Size FixedImage::GetOptimalSize() const { - const Image* pImage = &maImage; - return pImage->GetSizePixel(); + return maImage.GetSizePixel(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index f36204b1420a..beb216d12c07 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1354,14 +1354,9 @@ Size ListBox::CalcSubEditSize() const // ----------------------------------------------------------------------- -Size ListBox::GetOptimalSize(WindowSizeType eType) const +Size ListBox::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcMinimumSize(); - default: - return Control::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index b99ff260188c..b2ffb7f2c29f 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -1507,7 +1507,7 @@ void ScrollBar::SetVisibleSize( long nNewSize ) } } -Size ScrollBar::GetOptimalSize(WindowSizeType) const +Size ScrollBar::GetOptimalSize() const { if (mbCalcSize) const_cast<ScrollBar*>(this)->ImplCalc(sal_False); diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index cba366d1b682..604c386587ba 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -995,14 +995,9 @@ Size SpinField::CalcMinimumSize() const // ----------------------------------------------------------------------- -Size SpinField::GetOptimalSize(WindowSizeType eType) const +Size SpinField::GetOptimalSize() const { - switch (eType) { - case WINDOWSIZE_MINIMUM: - return CalcMinimumSize(); - default: - return Edit::GetOptimalSize( eType ); - } + return CalcMinimumSize(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index e2fecc29e0d1..02ac5337de03 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2219,7 +2219,7 @@ Size TabControl::calculateRequisition() const if (!pPage) continue; - Size aPageSize(pPage->GetOptimalSize(WINDOWSIZE_PREFERRED)); + Size aPageSize(pPage->GetOptimalSize()); if (aPageSize.Width() > aOptimalPageSize.Width()) aOptimalPageSize.Width() = aPageSize.Width(); @@ -2251,10 +2251,8 @@ Size TabControl::calculateRequisition() const return aOptimalSize; } -Size TabControl::GetOptimalSize(WindowSizeType eType) const +Size TabControl::GetOptimalSize() const { - if (eType == WINDOWSIZE_MINIMUM) - return Size(); return calculateRequisition(); } diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index 9fea710b10b2..60b20a6ab623 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -2360,16 +2360,12 @@ Rectangle ImplBorderWindow::GetMenuRect() const return mpBorderView->GetMenuRect(); } -Size ImplBorderWindow::GetOptimalSize(WindowSizeType eType) const +Size ImplBorderWindow::GetOptimalSize() const { - if (eType == WINDOWSIZE_MAXIMUM) - return Size(mnMaxWidth, mnMaxHeight); - if (eType == WINDOWSIZE_MINIMUM) - return Size(mnMinWidth, mnMinHeight); - Window* pClientWindow = ImplGetClientWindow(); + const Window* pClientWindow = ImplGetClientWindow(); if (pClientWindow) - return pClientWindow->GetOptimalSize(eType); - return Size(0, 0); + return pClientWindow->GetOptimalSize(); + return Size(mnMinWidth, mnMinHeight); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 53eafdf6f782..1aef3e6296cd 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1188,10 +1188,10 @@ bool Dialog::isLayoutEnabled() const return pChild && isContainerWindow(*pChild) && !pChild->GetWindow(WINDOW_NEXT); } -Size Dialog::GetOptimalSize(WindowSizeType eType) const +Size Dialog::GetOptimalSize() const { - if (eType == WINDOWSIZE_MAXIMUM || !isLayoutEnabled()) - return SystemWindow::GetOptimalSize(eType); + if (!isLayoutEnabled()) + return SystemWindow::GetOptimalSize(); Size aSize = VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD)); diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 7364b11ef6a9..a6d9d409b541 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -21,10 +21,8 @@ VclContainer::VclContainer(Window *pParent, WinBits nStyle) SetBackground(); } -Size VclContainer::GetOptimalSize(WindowSizeType eType) const +Size VclContainer::GetOptimalSize() const { - if (eType == WINDOWSIZE_MAXIMUM) - return Window::GetOptimalSize(eType); return calculateRequisition(); } diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx index 86dd2233a748..6aca66e50320 100644 --- a/vcl/source/window/msgbox.cxx +++ b/vcl/source/window/msgbox.cxx @@ -426,15 +426,10 @@ void MessBox::SetCheckBoxState( sal_Bool bCheck ) // ----------------------------------------------------------------------- -Size MessBox::GetOptimalSize(WindowSizeType eType) const +Size MessBox::GetOptimalSize() const { - switch( eType ) { - case WINDOWSIZE_MINIMUM: - // FIXME: base me on the font size ? - return Size( 250, 100 ); - default: - return Window::GetOptimalSize( eType ); - } + // FIXME: base me on the font size ? + return Size( 250, 100 ); } // ============================================================================ diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 97614b2f1704..2222eb8f876d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -301,7 +301,7 @@ void PrintDialog::ShowNupOrderWindow::ImplInitSettings() SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) ); } -Size PrintDialog::ShowNupOrderWindow::GetOptimalSize(WindowSizeType) const +Size PrintDialog::ShowNupOrderWindow::GetOptimalSize() const { return Size(70, 70); } diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx index d6dbcd38f7bc..7dfeb14c4a20 100644 --- a/vcl/source/window/tabdlg.cxx +++ b/vcl/source/window/tabdlg.cxx @@ -56,7 +56,7 @@ void TabDialog::ImplPosControls() pTabControl = pChild; else if ( pTabControl ) { - Size aOptimalSize( pChild->GetOptimalSize( WINDOWSIZE_PREFERRED ) ); + Size aOptimalSize(pChild->GetOptimalSize()); long nTxtWidth = aOptimalSize.Width(); if ( nTxtWidth > aCtrlSize.Width() ) aCtrlSize.Width() = nTxtWidth; @@ -86,7 +86,7 @@ void TabDialog::ImplPosControls() Point aTabOffset( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+nOffY ); if (isContainerWindow(*pTabControl)) - pTabControl->SetSizePixel(pTabControl->GetOptimalSize(WINDOWSIZE_PREFERRED)); + pTabControl->SetSizePixel(pTabControl->GetOptimalSize()); Size aTabSize = pTabControl->GetSizePixel(); diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx index 5f04373db18a..b15d9c1ea09a 100644 --- a/vcl/source/window/tabpage.cxx +++ b/vcl/source/window/tabpage.cxx @@ -207,16 +207,11 @@ bool TabPage::isLayoutEnabled() const return pChild && isContainerWindow(*pChild) && !pChild->GetWindow(WINDOW_NEXT); } -Size TabPage::GetOptimalSize(WindowSizeType eType) const +Size TabPage::GetOptimalSize() const { - if (eType == WINDOWSIZE_MAXIMUM) - return Window::GetOptimalSize(eType); - Size aSize; if (isLayoutEnabled()) - aSize = GetWindow(WINDOW_FIRSTCHILD)->GetOptimalSize(eType); - else - aSize = getLegacyBestSizeForChildren(*this); - return Window::CalcWindowSize(aSize); + return GetWindow(WINDOW_FIRSTCHILD)->GetOptimalSize(); + return getLegacyBestSizeForChildren(*this); } void TabPage::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation) diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 72d117df22d3..acf9aada3c5e 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -2014,7 +2014,7 @@ namespace Size aRet(rWindow.get_width_request(), rWindow.get_height_request()); if (aRet.Width() == -1 || aRet.Height() == -1) { - Size aOptimal = rWindow.GetOptimalSize(WINDOWSIZE_PREFERRED); + Size aOptimal = rWindow.GetOptimalSize(); if (aRet.Width() == -1) aRet.Width() = aOptimal.Width(); if (aRet.Height() == -1) diff --git a/vcl/source/window/window3.cxx b/vcl/source/window/window3.cxx index b901276655ff..00919acce11a 100644 --- a/vcl/source/window/window3.cxx +++ b/vcl/source/window/window3.cxx @@ -32,18 +32,9 @@ WaitObject::~WaitObject() // ----------------------------------------------------------------------- -Size Window::GetOptimalSize(WindowSizeType eType) const +Size Window::GetOptimalSize() const { - switch (eType) - { - case WINDOWSIZE_MINIMUM: - return Size(); - case WINDOWSIZE_PREFERRED: - return GetOptimalSize( WINDOWSIZE_MINIMUM ); - case WINDOWSIZE_MAXIMUM: - default: - return Size( LONG_MAX, LONG_MAX ); - } + return Size(); } // ----------------------------------------------------------------------- |