diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-01-28 16:09:58 +0000 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-12 13:05:11 -0500 |
commit | a644b400d611bfa086e0cdb6b0a41228809ffd3d (patch) | |
tree | 1ee23e08991d149f1a38fb934022c40b9dd581cc | |
parent | dfffb3244a4fd8cd58fa7786cbec626604dc61e1 (diff) |
Related: fdo#73051 make font size drop down of optimal width
presumably keithcu felt the font size was too wide, so lets
try and implement the desired effect of an optimal width.
Change-Id: Idc1741de04b3559fa415ebcf2289f96ba240ca8f
Reviewed-on: https://gerrit.libreoffice.org/8520
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
-rw-r--r-- | svx/source/tbxctrls/tbunocontroller.cxx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx index c34384466b6e..ad99d66ffa67 100644 --- a/svx/source/tbxctrls/tbunocontroller.cxx +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -53,6 +53,7 @@ public: void statusChanged_Impl( long nHeight, bool bErase = false ); void UpdateFont( const ::com::sun::star::awt::FontDescriptor& rCurrentFont ); + void SetOptimalSize(); virtual long Notify( NotifyEvent& rNEvt ); @@ -85,12 +86,11 @@ SvxFontSizeBox_Impl::SvxFontSizeBox_Impl( FontSizeBox( _pParent, WinBits( WB_DROPDOWN ) ), m_pCtrl ( &_rCtrl ), - m_aLogicalSize ( 20,100 ), + m_aLogicalSize ( 0,100 ), m_bRelease ( true ), m_xDispatchProvider ( _rDispatchProvider ), m_xFrame ( _xFrame ) { - SetSizePixel( LogicToPixel( m_aLogicalSize, MAP_APPFONT )); SetValue( 0 ); SetText( "" ); } @@ -221,6 +221,16 @@ long SvxFontSizeBox_Impl::Notify( NotifyEvent& rNEvt ) return nHandled ? nHandled : FontSizeBox::Notify( rNEvt ); } +void SvxFontSizeBox_Impl::SetOptimalSize() +{ + Size aPrefSize(LogicToPixel(m_aLogicalSize, MAP_APPFONT)); + aPrefSize.Width() = get_preferred_size().Width(); + SetSizePixel(aPrefSize); + Size aDropSize(LogicToPixel(Size(0, LOGICAL_EDIT_HEIGHT), MAP_APPFONT)); + aDropSize.Width() = aPrefSize.Width(); + SetDropDownSizePixel(aDropSize); +} + // --------------------------------------------------------------------------- void SvxFontSizeBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) @@ -228,9 +238,7 @@ void SvxFontSizeBox_Impl::DataChanged( const DataChangedEvent& rDCEvt ) if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) { - SetSizePixel( LogicToPixel( m_aLogicalSize, MAP_APPFONT )); - Size aDropSize( m_aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT ); - SetDropDownSizePixel( LogicToPixel( aDropSize, MAP_APPFONT )); + SetOptimalSize(); } FontSizeBox::DataChanged( rDCEvt ); @@ -380,6 +388,10 @@ uno::Reference< awt::XWindow > SAL_CALL FontHeightToolBoxControl::createItemWind uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), m_xFrame, *this ); + //Get the box to fill itself with all its sizes + m_pBox->UpdateFont(m_aCurrentFont); + //Make it size itself to its optimal size re above sizes + m_pBox->SetOptimalSize(); xItemWindow = VCLUnoHelper::GetInterface( m_pBox ); } |