1 Index: svx/source/tbxctrls/tbcontrl.cxx
2 ===================================================================
3 RCS file: /cvs/graphics/svx/source/tbxctrls/tbcontrl.cxx,v
4 retrieving revision 1.42
5 diff -u -p -u -r1.42 tbcontrl.cxx
6 --- svx/source/tbxctrls/tbcontrl.cxx 6 Jun 2003 10:44:32 -0000 1.42
7 +++ svx/source/tbxctrls/tbcontrl.cxx 1 Oct 2003 23:06:27 -0000
9 #ifndef _SV_SYSTEM_HXX //autogen wg. System
10 #include <vcl/system.hxx>
12 +#ifndef _SV_BMPACC_HXX
13 +#include <vcl/bmpacc.hxx>
16 #include <svtools/valueset.hxx>
18 @@ -426,10 +429,9 @@ private:
23 + BitmapEx aOrigBitmap;
27 BOOL bWasHiContrastMode;
30 @@ -1788,7 +1794,6 @@ SvxTbxButtonColorUpdater_Impl::SvxTbxBut
35 aCurColor ( COL_TRANSPARENT )
37 if (nTbxBtnId == SID_BACKGROUND_COLOR)
38 @@ -1803,106 +1808,82 @@ SvxTbxButtonColorUpdater_Impl::SvxTbxBut
40 SvxTbxButtonColorUpdater_Impl::~SvxTbxButtonColorUpdater_Impl()
45 // -----------------------------------------------------------------------
47 -void SvxTbxButtonColorUpdater_Impl::Update( const Color& rColor )
48 +// This sucks - but so does VirtualDevice for rendering on AlphaMasks
50 +BitmapDrawRect( Bitmap &rBitmap, const Rectangle &rRect, const Color& rColor )
52 - Image aImage( pTbx->GetItemImage( nBtnId ) );
53 - BOOL bSizeChanged = ( theBmpSize != aImage.GetSizePixel() );
54 - BOOL bDisplayModeChanged = ( bWasHiContrastMode != pTbx->GetBackground().GetColor().IsDark() );
56 - Color aColor( rColor );
58 - // #109290# Workaround for SetFillColor with COL_AUTO
59 - if ( aColor.GetColor() == COL_AUTO )
60 - aColor = Color( IMAGE_COL_TRANSPARENT );
61 + BitmapWriteAccess *pUpd = rBitmap.AcquireWriteAccess();
63 - if ( aCurColor == aColor && !bSizeChanged && !bDisplayModeChanged )
65 + for( long nY = rRect.Top(); nY < rRect.Bottom(); nY++ )
66 + for( long nX = rRect.Left(); nX < rRect.Right(); nX ++ )
67 + pUpd->SetPixel( nY, nX, rColor );
69 - VirtualDevice aVirDev( *pTbx );
71 + rBitmap.ReleaseAccess( pUpd );
74 - if ( bSizeChanged || bDisplayModeChanged )
76 - bWasHiContrastMode = pTbx->GetBackground().GetColor().IsDark();
77 - theBmpSize = aImage.GetSizePixel();
78 +void SvxTbxButtonColorUpdater_Impl::Update( const Color& rColor )
80 + Image aImage( pTbx->GetItemImage( nBtnId ) );
82 - if ( theBmpSize.Width() <= 16 )
83 - theUpdRect = Rectangle( Point(7,7), Size(8,8) );
85 - theUpdRect = Rectangle( Point(14,14), Size(11,11) );
86 + BOOL bIconChanged = ( aOrigBitmap.IsEmpty() && !aImage.GetBitmap().IsEmpty() ) ||
87 + ( aOrigBitmap.GetSizePixel() != aImage.GetSizePixel() ) ||
88 + ( bWasHiContrastMode != pTbx->GetBackground().GetColor().IsDark() );
90 + if ( aCurColor == rColor && !bIconChanged )
94 - aVirDev.SetPen( Pen( PEN_NULL ) );
95 - aVirDev.SetOutputSizePixel( theBmpSize );
96 - aVirDev.SetFillColor( Color( IMAGE_COL_TRANSPARENT ) );
97 - aVirDev.DrawRect( Rectangle( aNullPnt, theBmpSize ) );
98 - aVirDev.DrawImage( aNullPnt, aImage );
100 - pBtnBmp = new Bitmap( aVirDev.GetBitmap( aNullPnt, theBmpSize ) );
101 - if ( nDrawMode != TBX_UPDATER_MODE_CHAR_COLOR_NEW )
102 - aVirDev.DrawRect( theUpdRect );
104 - else if ( !pBtnBmp )
105 - pBtnBmp = new Bitmap( aVirDev.GetBitmap( aNullPnt, theBmpSize ) );
107 - aVirDev.SetOutputSizePixel( theBmpSize );
108 - aVirDev.DrawBitmap( aNullPnt, *pBtnBmp );
110 - // Choose line color according to background color
111 - if ( pTbx->GetBackground().GetColor().IsDark() )
112 - aVirDev.SetLineColor( COL_WHITE );
113 + Rectangle aUpdRect;
114 + if ( aImage.GetSizePixel().Width() <= 16 )
115 + aUpdRect = Rectangle( Point( 0,12 ), Size( aImage.GetSizePixel().Width(), 4 ) );
117 - aVirDev.SetLineColor( COL_BLACK );
118 + aUpdRect = Rectangle( Point( 1,19 ), Size( 24,6 ) );
120 - if ( nDrawMode == TBX_UPDATER_MODE_CHAR_COLOR_NEW &&
121 - ( aColor.GetColor() != COL_AUTO &&
122 - aColor.GetColor() != IMAGE_COL_TRANSPARENT ))
123 + if ( bIconChanged )
125 - // Draw border only if COLOR_AUTO is the new color!
126 - aVirDev.SetLineColor( aColor );
127 + aOrigBitmap = BitmapEx( aImage.GetBitmap(), aImage.GetMaskBitmap() );
128 + bWasHiContrastMode = pTbx->GetBackground().GetColor().IsDark();
130 - aVirDev.SetFillColor( aColor );
132 - if ( nDrawMode == TBX_UPDATER_MODE_CHAR_COLOR_NEW )
133 + Bitmap aNewBitmap( aOrigBitmap.GetBitmap() );
134 + Bitmap aNewMask( aOrigBitmap.GetMask() );
136 + BitmapDrawRect( aNewMask, aUpdRect, COL_BLACK );
137 + if( rColor.GetColor() == COL_AUTO )
139 - // New mode for our new high contrast enabled bitmaps
140 - if ( theBmpSize.Width() <= 16 )
141 - theUpdRect = Rectangle( Point( 0,12 ), Size(theBmpSize.Width(), 4 ) );
142 + Rectangle aInnerRect( aUpdRect.Left() + 1,
143 + aUpdRect.Top() + 1,
144 + aUpdRect.Right() - 1,
145 + aUpdRect.Bottom() - 1 );
146 + BitmapDrawRect( aNewMask, aInnerRect, COL_WHITE );
149 + if ( pTbx->GetBackground().GetColor().IsDark() )
150 + aLineColor = COL_WHITE;
152 - theUpdRect = Rectangle( Point( 1,19 ), Size( 24,6 ) );
153 - aVirDev.DrawRect( theUpdRect );
155 - else if ( nDrawMode != TBX_UPDATER_MODE_NONE )
157 - DrawChar( aVirDev, aColor );
160 - aVirDev.DrawRect( theUpdRect );
161 + aLineColor = COL_BLACK;
163 - aCurColor = aColor;
165 - // The following code asumes that we cannot change the display color depth
166 - // during Office runtime. Which is at least NOT true for newer Windows versions!
167 - const Bitmap aBmp( aVirDev.GetBitmap( aNullPnt, theBmpSize ) );
168 - static Color aTransparentColor;
169 - static sal_Bool bTransparentColorInitialized = sal_False;
171 - if( !bTransparentColorInitialized )
173 - aVirDev.DrawPixel( aNullPnt, IMAGE_COL_TRANSPARENT );
174 - aTransparentColor = aVirDev.GetPixel( aNullPnt );
175 - bTransparentColorInitialized = sal_True;
176 + Rectangle aHoriz( aUpdRect.Left(), aUpdRect.Top(),
177 + aUpdRect.Right(), aUpdRect.Top() + 1 );
178 + Rectangle aVert ( aUpdRect.Left(), aUpdRect.Top(),
179 + aUpdRect.Left() + 1, aUpdRect.Bottom() );
180 + BitmapDrawRect( aNewBitmap, aHoriz, aLineColor );
181 + aHoriz.Move( 0, aUpdRect.Bottom() - aUpdRect.Top() - 1 );
182 + BitmapDrawRect( aNewBitmap, aHoriz, aLineColor );
183 + BitmapDrawRect( aNewBitmap, aVert, aLineColor );
184 + aVert.Move( aUpdRect.Right() - aUpdRect.Left() - 1, 0 );
185 + BitmapDrawRect( aNewBitmap, aVert, aLineColor );
188 + BitmapDrawRect( aNewBitmap, aUpdRect, rColor );
190 - Bitmap aMaskBitmap = aBmp.CreateMask( aTransparentColor );
191 - Image aNewImage( aBmp, aMaskBitmap );
192 - pTbx->SetItemImage( nBtnId, aNewImage );
193 + pTbx->SetItemImage( nBtnId, Image( aNewBitmap, aNewMask ) );
197 // -----------------------------------------------------------------------
199 void SvxTbxButtonColorUpdater_Impl::DrawChar( VirtualDevice& rVirDev, const Color& rCol )
200 @@ -1935,6 +1916,7 @@ void SvxTbxButtonColorUpdater_Impl::Draw
201 rVirDev.DrawText( aPos, 'A' );
202 rVirDev.SetFont( aOldFont );
205 //========================================================================
206 // class SfxStyleControllerItem_Impl ------------------------------------------
207 //========================================================================