diff options
author | Bjoern Michaelsen <b_michaelsen@openoffice.org> | 2010-01-22 14:49:55 +0100 |
---|---|---|
committer | Bjoern Michaelsen <b_michaelsen@openoffice.org> | 2010-01-22 14:49:55 +0100 |
commit | a1d57594cffc6d93bb637247a74c86f138b8ffc5 (patch) | |
tree | 3c6473872ecaeac1ce5138a4f06a800372219e83 /vcl/source/control | |
parent | d919fae167e345762843da3e50054963dcc5cf45 (diff) | |
parent | 8765a3bf9f2926a50d0f644e4263782269abe023 (diff) |
cbosdo02: merging changesets up to DEV300_m69
Diffstat (limited to 'vcl/source/control')
-rw-r--r-- | vcl/source/control/button.cxx | 175 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 6 | ||||
-rw-r--r-- | vcl/source/control/ctrl.cxx | 189 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 20 | ||||
-rw-r--r-- | vcl/source/control/field2.cxx | 11 | ||||
-rw-r--r-- | vcl/source/control/fixed.cxx | 108 | ||||
-rw-r--r-- | vcl/source/control/group.cxx | 44 | ||||
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 40 | ||||
-rw-r--r-- | vcl/source/control/lstbox.cxx | 6 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 74 |
11 files changed, 378 insertions, 299 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index e7a4aadb8694..53a060af6bd6 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -50,7 +50,7 @@ #include <tools/poly.hxx> #include <vcl/button.hxx> #include <vcl/window.h> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #ifndef _SV_NATIVEWIDGET_HXX #include <vcl/salnativewidgets.hxx> #endif @@ -383,8 +383,8 @@ void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, WinBits nWinStyle = GetStyle(); Rectangle aOutRect( rPos, rSize ); - MetricVector *pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; - String *pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; + MetricVector *pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; + String *pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; ImageAlign eImageAlign = mpButtonData->meImageAlign; Size aImageSize = mpButtonData->maImage.GetSizePixel(); @@ -406,13 +406,12 @@ void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, } else if ( bDrawText && !bDrawImage && !bHasSymbol ) { - aOutRect = pDev->GetTextRect( aOutRect, aText, nTextStyle ); - rSize = aOutRect.GetSize(); - rPos = aOutRect.TopLeft(); + DrawControlText( *pDev, aOutRect, aText, nTextStyle, pVector, pDisplayText ); ImplSetFocusRect( aOutRect ); + rSize = aOutRect.GetSize(); + rPos = aOutRect.TopLeft(); - pDev->DrawText( aOutRect, aText, nTextStyle, pVector, pDisplayText ); return; } @@ -853,31 +852,25 @@ WinBits PushButton::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ) return nStyle; } +// ----------------------------------------------------------------- + +const Font& PushButton::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetPushButtonFont(); +} + +// ----------------------------------------------------------------- +const Color& PushButton::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetButtonTextColor(); +} + // ----------------------------------------------------------------------- void PushButton::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetPushButtonFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetButtonTextColor(); - SetTextColor( aColor ); - SetTextFillColor(); - } + Button::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -1659,7 +1652,7 @@ void PushButton::KeyUp( const KeyEvent& rKEvt ) void PushButton::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<PushButton*>(this)->ImplDrawPushButton( true ); } @@ -2225,31 +2218,25 @@ WinBits RadioButton::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ) return nStyle; } +// ----------------------------------------------------------------- + +const Font& RadioButton::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetRadioCheckFont(); +} + +// ----------------------------------------------------------------- +const Color& RadioButton::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetRadioCheckTextColor(); +} + // ----------------------------------------------------------------------- void RadioButton::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetRadioCheckFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetRadioCheckTextColor(); - SetTextColor( aColor ); - SetTextFillColor(); - } + Button::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -2424,16 +2411,14 @@ if ( bNativeOK == FALSE ) void RadioButton::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, const Point& rPos, const Size& rSize, - const Size& rImageSize, long nImageSep, - Rectangle& rStateRect, - Rectangle& rMouseRect, - bool bLayout ) + const Size& rImageSize, Rectangle& rStateRect, + Rectangle& rMouseRect, bool bLayout ) { WinBits nWinStyle = GetStyle(); XubString aText( GetText() ); Rectangle aRect( rPos, rSize ); - MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; - String* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; + MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; + String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; pDev->Push( PUSH_CLIPREGION ); pDev->IntersectClipRegion( Rectangle( rPos, rSize ) ); @@ -2446,9 +2431,9 @@ void RadioButton::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, { USHORT nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags ); + const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() ); Size aSize( rSize ); Point aPos( rPos ); - aPos.X() += rImageSize.Width() + nImageSep; aSize.Width() -= rImageSize.Width() + nImageSep; @@ -2578,7 +2563,7 @@ void RadioButton::ImplDrawRadioButton( bool bLayout ) // Draw control text ImplDraw( this, 0, Point(), GetOutputSizePixel(), - aImageSize, IMPL_SEP_BUTTON_IMAGE, maStateRect, maMouseRect, bLayout ); + aImageSize, maStateRect, maMouseRect, bLayout ); if( !bLayout || (IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)==TRUE) ) { @@ -2854,7 +2839,7 @@ void RadioButton::KeyUp( const KeyEvent& rKEvt ) void RadioButton::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<RadioButton*>(this)->ImplDrawRadioButton( true ); } @@ -2909,8 +2894,7 @@ void RadioButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize pDev->SetTextFillColor(); ImplDraw( pDev, nFlags, aPos, aSize, - aImageSize, GetDrawPixel( pDev, IMPL_SEP_BUTTON_IMAGE ), - aStateRect, aMouseRect ); + aImageSize, aStateRect, aMouseRect ); Point aCenterPos = aStateRect.Center(); long nRadX = aImageSize.Width()/2; @@ -3158,6 +3142,15 @@ void RadioButton::Check( BOOL bCheck ) // ----------------------------------------------------------------------- +long RadioButton::ImplGetImageToTextDistance() const +{ + // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements, + // which might have been aligned with the text of the check box + return CalcZoom( 4 ); +} + +// ----------------------------------------------------------------------- + Size RadioButton::ImplGetRadioImageSize() const { Size aSize; @@ -3331,12 +3324,12 @@ Size RadioButton::CalcMinimumSize( long nMaxWidth ) const { // subtract what will be added later nMaxWidth-=2; - nMaxWidth -= IMPL_SEP_BUTTON_IMAGE; + nMaxWidth -= ImplGetImageToTextDistance(); Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ), aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize(); aSize.Width()+=2; // for focus rect - aSize.Width() += IMPL_SEP_BUTTON_IMAGE; + aSize.Width() += ImplGetImageToTextDistance(); aSize.Width() += aTextSize.Width(); if ( aSize.Height() < aTextSize.Height() ) aSize.Height() = aTextSize.Height(); @@ -3395,31 +3388,25 @@ WinBits CheckBox::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ) return nStyle; } +// ----------------------------------------------------------------- + +const Font& CheckBox::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetRadioCheckFont(); +} + +// ----------------------------------------------------------------- +const Color& CheckBox::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetRadioCheckTextColor(); +} + // ----------------------------------------------------------------------- void CheckBox::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetRadioCheckFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetRadioCheckTextColor(); - SetTextColor( aColor ); - SetTextFillColor(); - } + Button::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -3527,9 +3514,8 @@ void CheckBox::ImplDrawCheckBoxState() void CheckBox::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, const Point& rPos, const Size& rSize, - const Size& rImageSize, long nImageSep, - Rectangle& rStateRect, Rectangle& rMouseRect, - bool bLayout ) + const Size& rImageSize, Rectangle& rStateRect, + Rectangle& rMouseRect, bool bLayout ) { WinBits nWinStyle = GetStyle(); XubString aText( GetText() ); @@ -3543,6 +3529,7 @@ void CheckBox::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, { USHORT nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags ); + const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() ); Size aSize( rSize ); Point aPos( rPos ); aPos.X() += rImageSize.Width() + nImageSep; @@ -3640,7 +3627,7 @@ void CheckBox::ImplDrawCheckBox( bool bLayout ) HideFocus(); ImplDraw( this, 0, Point(), GetOutputSizePixel(), aImageSize, - IMPL_SEP_BUTTON_IMAGE, maStateRect, maMouseRect, bLayout ); + maStateRect, maMouseRect, bLayout ); if( !bLayout ) { @@ -3797,7 +3784,7 @@ void CheckBox::KeyUp( const KeyEvent& rKEvt ) void CheckBox::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<CheckBox*>(this)->ImplDrawCheckBox( true ); } @@ -3852,8 +3839,7 @@ void CheckBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, pDev->SetTextFillColor(); ImplDraw( pDev, nFlags, aPos, aSize, - aImageSize, GetDrawPixel( pDev, IMPL_SEP_BUTTON_IMAGE ), - aStateRect, aMouseRect, false ); + aImageSize, aStateRect, aMouseRect, false ); pDev->SetLineColor(); pDev->SetFillColor( Color( COL_BLACK ) ); @@ -4099,6 +4085,15 @@ void CheckBox::EnableTriState( BOOL bTriState ) // ----------------------------------------------------------------------- +long CheckBox::ImplGetImageToTextDistance() const +{ + // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements, + // which might have been aligned with the text of the check box + return CalcZoom( 4 ); +} + +// ----------------------------------------------------------------------- + Size CheckBox::ImplGetCheckImageSize() const { Size aSize; @@ -4232,12 +4227,12 @@ Size CheckBox::CalcMinimumSize( long nMaxWidth ) const { // subtract what will be added later nMaxWidth-=2; - nMaxWidth -= IMPL_SEP_BUTTON_IMAGE; + nMaxWidth -= ImplGetImageToTextDistance(); Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ), aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize(); aSize.Width()+=2; // for focus rect - aSize.Width() += IMPL_SEP_BUTTON_IMAGE; + aSize.Width() += ImplGetImageToTextDistance(); aSize.Width() += aTextSize.Width(); if ( aSize.Height() < aTextSize.Height() ) aSize.Height() = aTextSize.Height(); diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index f83e46e38302..21707d0182f5 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -44,7 +44,7 @@ #include <vcl/subedit.hxx> #include <vcl/event.hxx> #include <vcl/combobox.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> @@ -689,7 +689,7 @@ void ComboBox::Resize() void ComboBox::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); AppendLayoutData( *mpSubEdit ); mpSubEdit->SetLayoutDataParent( this ); Control* pMainWindow = mpImplLB->GetMainWindow(); @@ -1534,7 +1534,7 @@ void ComboBox::SetBorderStyle( USHORT nBorderStyle ) long ComboBox::GetIndexForPoint( const Point& rPoint, USHORT& rPos ) const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); // check whether rPoint fits at all diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 55c979fbd69f..1800327df33c 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -39,10 +39,12 @@ #include <vcl/event.hxx> #include <vcl/ctrl.hxx> #include <vcl/decoview.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #include <vcl/salnativewidgets.hxx> +#include <vcl/textlayout.hxx> - +#include <comphelper/processfactory.hxx> +#include <tools/diagnose_ex.h> using namespace vcl; @@ -51,7 +53,7 @@ using namespace vcl; void Control::ImplInitControlData() { mbHasFocus = FALSE; - mpLayoutData = NULL; + mpControlData = new ImplControlData; } // ----------------------------------------------------------------------- @@ -90,7 +92,7 @@ Control::Control( Window* pParent, const ResId& rResId ) : Control::~Control() { - delete mpLayoutData, mpLayoutData = NULL; + delete mpControlData, mpControlData = NULL; } // ----------------------------------------------------------------------- @@ -111,7 +113,7 @@ void Control::LoseFocus() void Control::Resize() { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); Window::Resize(); } @@ -123,10 +125,31 @@ void Control::FillLayoutData() const // ----------------------------------------------------------------------- +void Control::CreateLayoutData() const +{ + DBG_ASSERT( !mpControlData->mpLayoutData, "Control::CreateLayoutData: should be called with non-existent layout data only!" ); + mpControlData->mpLayoutData = new ::vcl::ControlLayoutData(); +} + +// ----------------------------------------------------------------------- + +bool Control::HasLayoutData() const +{ + return mpControlData->mpLayoutData != NULL; +} + +// ----------------------------------------------------------------------- + +::vcl::ControlLayoutData* Control::GetLayoutData() const +{ + return mpControlData->mpLayoutData; +} + +// ----------------------------------------------------------------------- + void Control::SetText( const String& rStr ) { - delete mpLayoutData; - mpLayoutData = NULL; + ImplClearLayoutData(); Window::SetText( rStr ); } @@ -142,9 +165,9 @@ Rectangle ControlLayoutData::GetCharacterBounds( long nIndex ) const Rectangle Control::GetCharacterBounds( long nIndex ) const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetCharacterBounds( nIndex ) : Rectangle(); + return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetCharacterBounds( nIndex ) : Rectangle(); } // ----------------------------------------------------------------------- @@ -167,9 +190,9 @@ long ControlLayoutData::GetIndexForPoint( const Point& rPoint ) const long Control::GetIndexForPoint( const Point& rPoint ) const { - if( ! mpLayoutData ) + if( ! HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetIndexForPoint( rPoint ) : -1; + return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetIndexForPoint( rPoint ) : -1; } // ----------------------------------------------------------------------- @@ -186,9 +209,9 @@ long ControlLayoutData::GetLineCount() const long Control::GetLineCount() const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetLineCount() : 0; + return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetLineCount() : 0; } // ----------------------------------------------------------------------- @@ -220,9 +243,9 @@ Pair ControlLayoutData::GetLineStartEnd( long nLine ) const Pair Control::GetLineStartEnd( long nLine ) const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->GetLineStartEnd( nLine ) : Pair( -1, -1 ); + return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->GetLineStartEnd( nLine ) : Pair( -1, -1 ); } // ----------------------------------------------------------------------- @@ -263,18 +286,18 @@ long ControlLayoutData::ToRelativeLineIndex( long nIndex ) const long Control::ToRelativeLineIndex( long nIndex ) const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->ToRelativeLineIndex( nIndex ) : -1; + return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->ToRelativeLineIndex( nIndex ) : -1; } // ----------------------------------------------------------------------- String Control::GetDisplayText() const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); - return mpLayoutData ? mpLayoutData->m_aDisplayText : GetText(); + return mpControlData->mpLayoutData ? mpControlData->mpLayoutData->m_aDisplayText : GetText(); } // ----------------------------------------------------------------------- @@ -321,8 +344,7 @@ void Control::StateChanged( StateChangedType nStateChange ) nStateChange == STATE_CHANGE_CONTROLFONT ) { - delete mpLayoutData; - mpLayoutData = NULL; + ImplClearLayoutData(); } Window::StateChanged( nStateChange ); } @@ -331,25 +353,25 @@ void Control::StateChanged( StateChangedType nStateChange ) void Control::AppendLayoutData( const Control& rSubControl ) const { - if( ! rSubControl.mpLayoutData ) + if( !rSubControl.HasLayoutData() ) rSubControl.FillLayoutData(); - if( ! rSubControl.mpLayoutData || ! rSubControl.mpLayoutData->m_aDisplayText.Len() ) + if( !rSubControl.HasLayoutData() || !rSubControl.mpControlData->mpLayoutData->m_aDisplayText.Len() ) return; - long nCurrentIndex = mpLayoutData->m_aDisplayText.Len(); - mpLayoutData->m_aDisplayText.Append( rSubControl.mpLayoutData->m_aDisplayText ); - int nLines = rSubControl.mpLayoutData->m_aLineIndices.size(); + long nCurrentIndex = mpControlData->mpLayoutData->m_aDisplayText.Len(); + mpControlData->mpLayoutData->m_aDisplayText.Append( rSubControl.mpControlData->mpLayoutData->m_aDisplayText ); + int nLines = rSubControl.mpControlData->mpLayoutData->m_aLineIndices.size(); int n; - mpLayoutData->m_aLineIndices.push_back( nCurrentIndex ); + mpControlData->mpLayoutData->m_aLineIndices.push_back( nCurrentIndex ); for( n = 1; n < nLines; n++ ) - mpLayoutData->m_aLineIndices.push_back( rSubControl.mpLayoutData->m_aLineIndices[n] + nCurrentIndex ); - int nRectangles = rSubControl.mpLayoutData->m_aUnicodeBoundRects.size(); + mpControlData->mpLayoutData->m_aLineIndices.push_back( rSubControl.mpControlData->mpLayoutData->m_aLineIndices[n] + nCurrentIndex ); + int nRectangles = rSubControl.mpControlData->mpLayoutData->m_aUnicodeBoundRects.size(); Rectangle aRel = const_cast<Control&>(rSubControl).GetWindowExtentsRelative( const_cast<Control*>(this) ); for( n = 0; n < nRectangles; n++ ) { - Rectangle aRect = rSubControl.mpLayoutData->m_aUnicodeBoundRects[n]; + Rectangle aRect = rSubControl.mpControlData->mpLayoutData->m_aUnicodeBoundRects[n]; aRect.Move( aRel.Left(), aRel.Top() ); - mpLayoutData->m_aUnicodeBoundRects.push_back( aRect ); + mpControlData->mpLayoutData->m_aUnicodeBoundRects.push_back( aRect ); } } @@ -378,15 +400,15 @@ BOOL Control::ImplCallEventListenersAndHandler( ULONG nEvent, const Link& rHand void Control::SetLayoutDataParent( const Control* pParent ) const { - if( mpLayoutData ) - mpLayoutData->m_pParent = pParent; + if( HasLayoutData() ) + mpControlData->mpLayoutData->m_pParent = pParent; } // ----------------------------------------------------------------- void Control::ImplClearLayoutData() const { - delete mpLayoutData, mpLayoutData = NULL; + delete mpControlData->mpLayoutData, mpControlData->mpLayoutData = NULL; } // ----------------------------------------------------------------------- @@ -467,3 +489,102 @@ Size Control::GetOptimalSize(WindowSizeType eType) const return Size( LONG_MAX, LONG_MAX ); } } + +// ----------------------------------------------------------------- + +void Control::SetReferenceDevice( OutputDevice* _referenceDevice ) +{ + if ( mpControlData->mpReferenceDevice == _referenceDevice ) + return; + + mpControlData->mpReferenceDevice = _referenceDevice; + Invalidate(); +} + +// ----------------------------------------------------------------- + +OutputDevice* Control::GetReferenceDevice() const +{ + return mpControlData->mpReferenceDevice; +} + +// ----------------------------------------------------------------- + +const Font& Control::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetLabelFont(); +} + +// ----------------------------------------------------------------- +const Color& Control::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetLabelTextColor(); +} + +// ----------------------------------------------------------------- +void Control::ImplInitSettings( const BOOL _bFont, const BOOL _bForeground ) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + if ( _bFont ) + { + Font aFont( GetCanonicalFont( rStyleSettings ) ); + if ( IsControlFont() ) + aFont.Merge( GetControlFont() ); + SetZoomedPointFont( aFont ); + } + + if ( _bForeground || _bFont ) + { + Color aColor; + if ( IsControlForeground() ) + aColor = GetControlForeground(); + else + aColor = GetCanonicalTextColor( rStyleSettings ); + SetTextColor( aColor ); + SetTextFillColor(); + } +} + +// ----------------------------------------------------------------- + +void Control::DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRect, const XubString& _rStr, + USHORT _nStyle, MetricVector* _pVector, String* _pDisplayText ) const +{ +#ifdef FS_DEBUG + if ( !_pVector ) + { + static MetricVector aCharRects; + static String sDisplayText; + aCharRects.clear(); + sDisplayText = String(); + _pVector = &aCharRects; + _pDisplayText = &sDisplayText; + } +#endif + + if ( !mpControlData->mpReferenceDevice || ( mpControlData->mpReferenceDevice == &_rTargetDevice ) ) + { + _io_rRect = _rTargetDevice.GetTextRect( _io_rRect, _rStr, _nStyle ); + _rTargetDevice.DrawText( _io_rRect, _rStr, _nStyle, _pVector, _pDisplayText ); + } + else + { + ControlTextRenderer aRenderer( *this, _rTargetDevice, *mpControlData->mpReferenceDevice ); + _io_rRect = aRenderer.DrawText( _io_rRect, _rStr, _nStyle, _pVector, _pDisplayText ); + } + +#ifdef FS_DEBUG + _rTargetDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); + _rTargetDevice.SetLineColor( COL_LIGHTRED ); + _rTargetDevice.SetFillColor(); + for ( MetricVector::const_iterator cr = _pVector->begin(); + cr != _pVector->end(); + ++cr + ) + { + _rTargetDevice.DrawRect( *cr ); + } + _rTargetDevice.Pop(); +#endif +} diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 5f41a441c6a1..b654e034470f 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -47,7 +47,7 @@ #include <vcl/subedit.hxx> #include <vcl/edit.hxx> #include <vcl/svapp.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #include <vcl/msgbox.hxx> #include <vcl/window.h> @@ -409,7 +409,7 @@ void Edit::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) if ( IsControlFont() ) aFont.Merge( GetControlFont() ); SetZoomedPointFont( aFont ); - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); } if ( bFont || bForeground ) @@ -526,8 +526,8 @@ void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout ) long nPos = nStart ? pDX[2*nStart] : 0; aPos.X() = nPos + mnXOffset + ImplGetExtraOffset(); - MetricVector* pVector = &mpLayoutData->m_aUnicodeBoundRects; - String* pDisplayText = &mpLayoutData->m_aDisplayText; + MetricVector* pVector = &mpControlData->mpLayoutData->m_aUnicodeBoundRects; + String* pDisplayText = &mpControlData->mpLayoutData->m_aDisplayText; DrawText( aPos, aText, nStart, nEnd - nStart, pVector, pDisplayText ); @@ -722,7 +722,7 @@ void Edit::ImplDelete( const Selection& rSelection, BYTE nDirection, BYTE nMode ((rSelection.Max() == aText.Len()) && (nDirection == EDIT_DEL_RIGHT))) ) return; - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); Selection aSelection( rSelection ); aSelection.Justify(); @@ -864,7 +864,7 @@ void Edit::ImplInsertText( const XubString& rStr, const Selection* pNewSel, sal_ rtl::OUString aNewText( ImplGetValidString( rStr ) ); ImplTruncateToMaxLen( aNewText, aSelection.Len() ); - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); if ( aSelection.Len() ) maText.Erase( (xub_StrLen)aSelection.Min(), (xub_StrLen)aSelection.Len() ); @@ -1006,7 +1006,7 @@ void Edit::ImplSetText( const XubString& rText, const Selection* pNewSelection ) // wird, dann InsertText, damit flackerfrei. if ( ( rText.Len() <= mnMaxTextLen ) && ( (rText != maText) || (pNewSelection && (*pNewSelection != maSelection)) ) ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); maSelection.Min() = 0; maSelection.Max() = maText.Len(); if ( mnXOffset || HasPaintEvent() ) @@ -1637,7 +1637,7 @@ BOOL Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) { if ( !rKEvt.GetKeyCode().IsMod2() ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator(); Selection aSel( maSelection ); @@ -1858,7 +1858,7 @@ void Edit::KeyInput( const KeyEvent& rKEvt ) void Edit::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<Edit*>(this)->ImplRepaint( 0, STRING_LEN, true ); } @@ -2648,7 +2648,7 @@ void Edit::ImplSetSelection( const Selection& rSelection, BOOL bPaint ) if ( aNew != maSelection ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); maSelection = aNew; if ( bPaint && ( aOld.Len() || aNew.Len() || IsPaintTransparent() ) ) diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index b417774142d3..a7729f4ace24 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -55,6 +55,7 @@ #include <unotools/localedatawrapper.hxx> #include <unotools/calendarwrapper.hxx> #include <unotools/charclass.hxx> +#include <unotools/misccfg.hxx> using namespace ::com::sun::star; @@ -1214,7 +1215,7 @@ static BOOL ImplDateProcessKeyInput( Edit*, const KeyEvent& rKEvt, ExtDateFieldF static BOOL ImplDateGetValue( const XubString& rStr, Date& rDate, ExtDateFieldFormat eDateFormat, const LocaleDataWrapper& rLocaleDataWrapper, const CalendarWrapper& rCalendarWrapper, - const AllSettings& rSettings ) + const AllSettings& ) { USHORT nDay = 0; USHORT nMonth = 0; @@ -1312,7 +1313,7 @@ static BOOL ImplDateGetValue( const XubString& rStr, Date& rDate, ExtDateFieldFo return FALSE; Date aNewDate( nDay, nMonth, nYear ); - DateFormatter::ExpandCentury( aNewDate, rSettings.GetMiscSettings().GetTwoDigitYearStart() ); + DateFormatter::ExpandCentury( aNewDate, utl::MiscCfg().GetYear2000() ); if ( aNewDate.IsValid() ) { rDate = aNewDate; @@ -1355,7 +1356,7 @@ BOOL DateFormatter::ImplDateReformat( const XubString& rStr, XubString& rOutStr, // ----------------------------------------------------------------------- XubString DateFormatter::ImplGetDateAsText( const Date& rDate, - const AllSettings& rSettings ) const + const AllSettings& ) const { BOOL bShowCentury = FALSE; switch ( GetExtDateFormat() ) @@ -1379,7 +1380,7 @@ XubString DateFormatter::ImplGetDateAsText( const Date& rDate, if ( !bShowCentury ) { // Check if I have to use force showing the century - USHORT nTwoDigitYearStart = rSettings.GetMiscSettings().GetTwoDigitYearStart(); + USHORT nTwoDigitYearStart = utl::MiscCfg().GetYear2000(); USHORT nYear = rDate.GetYear(); // Wenn Jahr nicht im 2stelligen Grenzbereich liegt, @@ -2033,7 +2034,7 @@ void DateFormatter::Reformat() void DateFormatter::ExpandCentury( Date& rDate ) { - ExpandCentury( rDate, Application::GetSettings().GetMiscSettings().GetTwoDigitYearStart() ); + ExpandCentury( rDate, utl::MiscCfg().GetYear2000() ); } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index ecb066d107ce..3d19e288a1ce 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -33,7 +33,7 @@ #include <vcl/decoview.hxx> #include <vcl/event.hxx> #include <vcl/fixed.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #include <vcl/window.h> #include <tools/rc.h> @@ -109,40 +109,25 @@ WinBits FixedText::ImplInitStyle( WinBits nStyle ) return nStyle; } +// ----------------------------------------------------------------- + +const Font& FixedText::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoFont() : _rStyle.GetLabelFont(); +} + +// ----------------------------------------------------------------- +const Color& FixedText::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoTextColor() : _rStyle.GetLabelTextColor(); +} + // ----------------------------------------------------------------------- void FixedText::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont; - if ( GetStyle() & WB_INFO ) - aFont = rStyleSettings.GetInfoFont(); - else - aFont = rStyleSettings.GetLabelFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - { - if ( GetStyle() & WB_INFO ) - aColor = rStyleSettings.GetInfoTextColor(); - else - aColor = rStyleSettings.GetLabelTextColor(); - } - SetTextColor( aColor ); - SetTextFillColor(); - } + Control::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -278,17 +263,13 @@ void FixedText::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, nTextStyle |= TEXT_DRAW_MONO; if( bFillLayout ) - { - mpLayoutData->m_aDisplayText = String(); - pDev->DrawText( Rectangle( aPos, rSize ), - aText, - nTextStyle, - &mpLayoutData->m_aUnicodeBoundRects, - &mpLayoutData->m_aDisplayText - ); - } - else - pDev->DrawText( Rectangle( aPos, rSize ), aText, nTextStyle ); + mpControlData->mpLayoutData->m_aDisplayText = String(); + + Rectangle aRect( Rectangle( aPos, rSize ) ); + DrawControlText( *pDev, aRect, aText, nTextStyle, + bFillLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL, + bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL + ); } // ----------------------------------------------------------------------- @@ -446,7 +427,7 @@ Size FixedText::GetOptimalSize(WindowSizeType eType) const void FixedText::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); ImplDraw( const_cast<FixedText*>(this), 0, Point(), GetOutputSizePixel(), true ); } @@ -468,31 +449,25 @@ WinBits FixedLine::ImplInitStyle( WinBits nStyle ) return nStyle; } +// ----------------------------------------------------------------- + +const Font& FixedLine::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetGroupFont(); +} + +// ----------------------------------------------------------------- +const Color& FixedLine::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetGroupTextColor(); +} + // ----------------------------------------------------------------------- void FixedLine::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetGroupFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetGroupTextColor(); - SetTextColor( aColor ); - SetTextFillColor(); - } + Control::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -526,8 +501,8 @@ void FixedLine::ImplDraw( bool bLayout ) String aText = GetText(); const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); WinBits nWinStyle = GetStyle(); - MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; - String* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; + MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; + String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) SetLineColor( Color( COL_BLACK ) ); @@ -574,8 +549,7 @@ void FixedLine::ImplDraw( bool bLayout ) if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) nStyle |= TEXT_DRAW_MONO; - aRect = GetTextRect( aRect, aText, nStyle ); - DrawText( aRect, aText, nStyle, pVector, pDisplayText ); + DrawControlText( *this, aRect, aText, nStyle, pVector, pDisplayText ); if( !pVector ) { @@ -617,7 +591,7 @@ FixedLine::FixedLine( Window* pParent, const ResId& rResId ) : void FixedLine::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<FixedLine*>(this)->ImplDraw( true ); } diff --git a/vcl/source/control/group.cxx b/vcl/source/control/group.cxx index a844c2f2eb93..4adc91f88d84 100644 --- a/vcl/source/control/group.cxx +++ b/vcl/source/control/group.cxx @@ -32,7 +32,7 @@ #include "precompiled_vcl.hxx" #include <vcl/event.hxx> #include <vcl/group.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #ifndef _SV_RC_H #include <tools/rc.h> @@ -66,31 +66,25 @@ WinBits GroupBox::ImplInitStyle( WinBits nStyle ) return nStyle; } +// ----------------------------------------------------------------- + +const Font& GroupBox::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetGroupFont(); +} + +// ----------------------------------------------------------------- +const Color& GroupBox::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetGroupTextColor(); +} + // ----------------------------------------------------------------------- void GroupBox::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetGroupFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetGroupTextColor(); - SetTextColor( aColor ); - SetTextFillColor(); - } + Control::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -227,16 +221,16 @@ void GroupBox::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, } } - MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; - String* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; - pDev->DrawText( aRect, aText, nTextStyle, pVector, pDisplayText ); + MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; + String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; + DrawControlText( *pDev, aRect, aText, nTextStyle, pVector, pDisplayText ); } // ----------------------------------------------------------------------- void GroupBox::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<GroupBox*>(this)-> ImplDraw( const_cast<GroupBox*>(this), 0, Point(), GetOutputSizePixel(), true ); } diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index c0a28c8b03fd..a915d8e6b9e8 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -40,7 +40,7 @@ #include <vcl/lstbox.h> #include <vcl/ilstbox.hxx> #include <vcl/i18nhelp.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #include <vcl/unohelp.hxx> #ifndef _COM_SUN_STAR_UTIL_XCOLLATOR_HPP_ #include <com/sun/star/i18n/XCollator.hpp> @@ -647,7 +647,7 @@ void ImplListBoxWindow::Clear() mnTop = 0; mnLeft = 0; mbImgsDiffSz = FALSE; - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; @@ -656,7 +656,7 @@ void ImplListBoxWindow::Clear() void ImplListBoxWindow::SetUserItemSize( const Size& rSz ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); maUserItemSize = rSz; ImplCalcMetrics(); } @@ -778,7 +778,7 @@ void ImplListBoxWindow::ImplCallSelect() nMRUCount--; } - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); ImplEntryType* pNewEntry = new ImplEntryType( aSelected ); pNewEntry->mbIsSelected = bSelectNewEntry; @@ -798,7 +798,7 @@ void ImplListBoxWindow::ImplCallSelect() USHORT ImplListBoxWindow::InsertEntry( USHORT nPos, ImplEntryType* pNewEntry ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); USHORT nNewPos = mpEntryList->InsertEntry( nPos, pNewEntry, mbSort ); if( (GetStyle() & WB_WORDBREAK) ) @@ -812,7 +812,7 @@ USHORT ImplListBoxWindow::InsertEntry( USHORT nPos, ImplEntryType* pNewEntry ) void ImplListBoxWindow::RemoveEntry( USHORT nPos ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); mpEntryList->RemoveEntry( nPos ); if( mnCurrentPos >= mpEntryList->GetEntryCount() ) mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; @@ -1062,7 +1062,7 @@ void ImplListBoxWindow::SelectEntry( USHORT nPos, BOOL bSelect ) ImplPaint( nPos ); if ( !IsVisible( nPos ) ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); USHORT nVisibleEntries = GetLastVisibleEntry()-mnTop; if ( !nVisibleEntries || !IsReallyVisible() || ( nPos < GetTopEntry() ) ) { @@ -1233,7 +1233,7 @@ BOOL ImplListBoxWindow::SelectEntries( USHORT nSelect, LB_EVENT_TYPE eLET, BOOL if( HasFocus() ) ImplShowFocusRect(); } - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); } return bSelectionChanged; } @@ -1838,8 +1838,8 @@ void ImplListBoxWindow::DrawEntry( USHORT nPos, BOOL bDrawImage, BOOL bDrawText, if( bDrawText ) { - MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; - String* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; + MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; + String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; XubString aStr( mpEntryList->GetEntryText( nPos ) ); if ( aStr.Len() ) { @@ -1859,7 +1859,7 @@ void ImplListBoxWindow::DrawEntry( USHORT nPos, BOOL bDrawImage, BOOL bDrawText, } if( bLayout ) - mpLayoutData->m_aLineIndices.push_back( mpLayoutData->m_aDisplayText.Len() ); + mpControlData->mpLayoutData->m_aLineIndices.push_back( mpControlData->mpLayoutData->m_aDisplayText.Len() ); // pb: #106948# explicit mirroring for calc if ( mbMirroring ) @@ -1900,7 +1900,7 @@ void ImplListBoxWindow::DrawEntry( USHORT nPos, BOOL bDrawImage, BOOL bDrawText, void ImplListBoxWindow::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<ImplListBoxWindow*>(this)-> ImplDoPaint( Rectangle( Point( 0, 0 ), GetOutputSize() ), true ); } @@ -1978,7 +1978,7 @@ void ImplListBoxWindow::Resize() if ( bShowFocusRect ) ImplShowFocusRect(); - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); } // ----------------------------------------------------------------------- @@ -2034,7 +2034,7 @@ void ImplListBoxWindow::SetTopEntry( USHORT nTop ) if ( nTop != mnTop ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); long nDiff = mpEntryList->GetAddedHeight( mnTop, nTop, 0 ); Update(); ImplHideFocusRect(); @@ -2078,7 +2078,7 @@ void ImplListBoxWindow::ScrollHorz( long n ) if ( nDiff ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); mnLeft = sal::static_int_cast<USHORT>(mnLeft + nDiff); Update(); ImplHideFocusRect(); @@ -2148,7 +2148,7 @@ void ImplListBoxWindow::StateChanged( StateChangedType nType ) ImplInitSettings( FALSE, FALSE, TRUE ); Invalidate(); } - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); } // ----------------------------------------------------------------------- @@ -2162,7 +2162,7 @@ void ImplListBoxWindow::DataChanged( const DataChangedEvent& rDCEvt ) ((rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE)) ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); ImplInitSettings( TRUE, TRUE, TRUE ); ImplCalcMetrics(); Invalidate(); @@ -2743,7 +2743,7 @@ void ImplWin::MouseButtonDown( const MouseEvent& ) void ImplWin::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const_cast<ImplWin*>(this)->ImplDraw( true ); } @@ -2936,8 +2936,8 @@ void ImplWin::DrawEntry( BOOL bDrawImage, BOOL bDrawText, BOOL bDrawTextAtImageP aTextRect.Left() += nMaxWidth + IMG_TXT_DISTANCE; } - MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; - String* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; + MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; + String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; DrawText( aTextRect, maString, nTextStyle, pVector, pDisplayText ); } diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index a4d3cbc22544..ceabbe4ab166 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -43,7 +43,7 @@ #include "vcl/ilstbox.hxx" #include "vcl/lstbox.hxx" #include "vcl/combobox.hxx" -#include "vcl/controllayout.hxx" +#include "vcl/controldata.hxx" #include "tools/debug.hxx" @@ -719,7 +719,7 @@ void ListBox::Resize() void ListBox::FillLayoutData() const { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); const Control* pMainWin = mpImplLB->GetMainWindow(); if( mpFloatWin ) { @@ -743,7 +743,7 @@ void ListBox::FillLayoutData() const long ListBox::GetIndexForPoint( const Point& rPoint, USHORT& rPos ) const { - if( ! mpLayoutData ) + if( !HasLayoutData() ) FillLayoutData(); // check whether rPoint fits at all diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 0d656da40ba7..1cdaa39298df 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -36,7 +36,7 @@ #include "vcl/decoview.hxx" #include "vcl/spin.h" #include "vcl/spinfld.hxx" -#include "vcl/controllayout.hxx" +#include "vcl/controldata.hxx" #include "vcl/svdata.hxx" // ======================================================================= @@ -637,7 +637,7 @@ void SpinField::FillLayoutData() const { if( mbSpin ) { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); AppendLayoutData( *GetSubEdit() ); GetSubEdit()->SetLayoutDataParent( this ); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 561d550b1168..9a34629ddf8e 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -45,7 +45,7 @@ #include <vcl/button.hxx> #include <vcl/tabpage.hxx> #include <vcl/tabctrl.hxx> -#include <vcl/controllayout.hxx> +#include <vcl/controldata.hxx> #include <vcl/sound.hxx> #include <vcl/window.h> @@ -169,31 +169,25 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle ) EnableChildTransparentMode( TRUE ); } +// ----------------------------------------------------------------- + +const Font& TabControl::GetCanonicalFont( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetAppFont(); +} + +// ----------------------------------------------------------------- +const Color& TabControl::GetCanonicalTextColor( const StyleSettings& _rStyle ) const +{ + return _rStyle.GetButtonTextColor(); +} + // ----------------------------------------------------------------------- void TabControl::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetAppFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } - - if ( bForeground || bFont ) - { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetButtonTextColor(); - SetTextColor( aColor ); - SetTextFillColor(); - } + Control::ImplInitSettings( bFont, bForeground ); if ( bBackground ) { @@ -232,9 +226,9 @@ void TabControl::ImplInitSettings( BOOL bFont, void TabControl::ImplFreeLayoutData() { - if( mpLayoutData ) + if( HasLayoutData() ) { - delete mpLayoutData, mpLayoutData = NULL; + ImplClearLayoutData(); mpTabCtrlData->maLayoutPageIdToLine.clear(); mpTabCtrlData->maLayoutLineToPageId.clear(); } @@ -864,9 +858,9 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo if( bLayout ) { - if( ! mpLayoutData ) + if( !HasLayoutData() ) { - mpLayoutData = new vcl::ControlLayoutData(); + mpControlData->mpLayoutData = new vcl::ControlLayoutData(); mpTabCtrlData->maLayoutLineToPageId.clear(); mpTabCtrlData->maLayoutPageIdToLine.clear(); mpTabCtrlData->maTabRectangles.clear(); @@ -1010,8 +1004,8 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo if( bLayout ) { - int nLine = mpLayoutData->m_aLineIndices.size(); - mpLayoutData->m_aLineIndices.push_back( mpLayoutData->m_aDisplayText.Len() ); + int nLine = mpControlData->mpLayoutData->m_aLineIndices.size(); + mpControlData->mpLayoutData->m_aLineIndices.push_back( mpControlData->mpLayoutData->m_aDisplayText.Len() ); mpTabCtrlData->maLayoutPageIdToLine[ (int)pItem->mnId ] = nLine; mpTabCtrlData->maLayoutLineToPageId[ nLine ] = (int)pItem->mnId; mpTabCtrlData->maTabRectangles.push_back( aRect ); @@ -1044,8 +1038,8 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo DrawCtrlText( Point( nXPos + aImageSize.Width(), nYPos ), pItem->maFormatText, 0, STRING_LEN, nStyle, - bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL, - bLayout ? &mpLayoutData->m_aDisplayText : NULL + bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL, + bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL ); } @@ -2108,17 +2102,17 @@ Rectangle TabControl::GetCharacterBounds( USHORT nPageId, long nIndex ) const { Rectangle aRet; - if( ! mpLayoutData || ! mpTabCtrlData->maLayoutPageIdToLine.size() ) + if( !HasLayoutData() || ! mpTabCtrlData->maLayoutPageIdToLine.size() ) FillLayoutData(); - if( mpLayoutData ) + if( HasLayoutData() ) { std::hash_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( (int)nPageId ); if( it != mpTabCtrlData->maLayoutPageIdToLine.end() ) { - Pair aPair = mpLayoutData->GetLineStartEnd( it->second ); + Pair aPair = mpControlData->mpLayoutData->GetLineStartEnd( it->second ); if( (aPair.B() - aPair.A()) >= nIndex ) - aRet = mpLayoutData->GetCharacterBounds( aPair.A() + nIndex ); + aRet = mpControlData->mpLayoutData->GetCharacterBounds( aPair.A() + nIndex ); } } @@ -2131,20 +2125,20 @@ long TabControl::GetIndexForPoint( const Point& rPoint, USHORT& rPageId ) const { long nRet = -1; - if( ! mpLayoutData || ! mpTabCtrlData->maLayoutPageIdToLine.size() ) + if( !HasLayoutData() || ! mpTabCtrlData->maLayoutPageIdToLine.size() ) FillLayoutData(); - if( mpLayoutData ) + if( HasLayoutData() ) { - int nIndex = mpLayoutData->GetIndexForPoint( rPoint ); + int nIndex = mpControlData->mpLayoutData->GetIndexForPoint( rPoint ); if( nIndex != -1 ) { // what line (->pageid) is this index in ? - int nLines = mpLayoutData->GetLineCount(); + int nLines = mpControlData->mpLayoutData->GetLineCount(); int nLine = -1; while( ++nLine < nLines ) { - Pair aPair = mpLayoutData->GetLineStartEnd( nLine ); + Pair aPair = mpControlData->mpLayoutData->GetLineStartEnd( nLine ); if( aPair.A() <= nIndex && aPair.B() >= nIndex ) { nRet = nIndex - aPair.A(); @@ -2173,10 +2167,10 @@ Rectangle TabControl::GetTabPageBounds( USHORT nPage ) const { Rectangle aRet; - if( ! mpLayoutData || ! mpTabCtrlData->maLayoutPageIdToLine.size() ) + if( !HasLayoutData() || ! mpTabCtrlData->maLayoutPageIdToLine.size() ) FillLayoutData(); - if( mpLayoutData ) + if( HasLayoutData() ) { std::hash_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( (int)nPage ); if( it != mpTabCtrlData->maLayoutPageIdToLine.end() ) |