]> git.pld-linux.org Git - packages/libreoffice.git/blame - openoffice-gui-tbx-ctrl-bg.patch
- up
[packages/libreoffice.git] / openoffice-gui-tbx-ctrl-bg.patch
CommitLineData
efef92ce 1Index: svx/source/tbxctrls/tbcontrl.cxx
2===================================================================
3RCS file: /cvs/graphics/svx/source/tbxctrls/tbcontrl.cxx,v
4retrieving revision 1.42
5diff -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
8@@ -78,6 +78,9 @@
9 #ifndef _SV_SYSTEM_HXX //autogen wg. System
10 #include <vcl/system.hxx>
11 #endif
12+#ifndef _SV_BMPACC_HXX
13+#include <vcl/bmpacc.hxx>
14+#endif
15 #ifndef _VALUESET_HXX
16 #include <svtools/valueset.hxx>
17 #endif
18@@ -426,10 +429,9 @@ private:
19 USHORT nDrawMode;
20 USHORT nBtnId;
21 ToolBox* pTbx;
22- Bitmap* pBtnBmp;
23+ BitmapEx aOrigBitmap;
24 Color aCurColor;
25 Rectangle theUpdRect;
26- Size theBmpSize;
27 BOOL bWasHiContrastMode;
28 };
29
30@@ -1788,7 +1794,6 @@ SvxTbxButtonColorUpdater_Impl::SvxTbxBut
31 nDrawMode ( nMode ),
32 nBtnId ( nTbxBtnId ),
33 pTbx ( ptrTbx ),
34- pBtnBmp ( NULL ),
35 aCurColor ( COL_TRANSPARENT )
36 {
37 if (nTbxBtnId == SID_BACKGROUND_COLOR)
38@@ -1803,106 +1808,82 @@ SvxTbxButtonColorUpdater_Impl::SvxTbxBut
39
40 SvxTbxButtonColorUpdater_Impl::~SvxTbxButtonColorUpdater_Impl()
41 {
42- delete pBtnBmp;
43 }
44
45 // -----------------------------------------------------------------------
46
47-void SvxTbxButtonColorUpdater_Impl::Update( const Color& rColor )
48+// This sucks - but so does VirtualDevice for rendering on AlphaMasks
49+static void
50+BitmapDrawRect( Bitmap &rBitmap, const Rectangle &rRect, const Color& rColor )
51 {
52- Image aImage( pTbx->GetItemImage( nBtnId ) );
53- BOOL bSizeChanged = ( theBmpSize != aImage.GetSizePixel() );
54- BOOL bDisplayModeChanged = ( bWasHiContrastMode != pTbx->GetBackground().GetColor().IsDark() );
55-
56- Color aColor( rColor );
57-
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();
62
63- if ( aCurColor == aColor && !bSizeChanged && !bDisplayModeChanged )
64- return;
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 );
68
69- VirtualDevice aVirDev( *pTbx );
70- Point aNullPnt;
71+ rBitmap.ReleaseAccess( pUpd );
72+}
73
74- if ( bSizeChanged || bDisplayModeChanged )
75- {
76- bWasHiContrastMode = pTbx->GetBackground().GetColor().IsDark();
77- theBmpSize = aImage.GetSizePixel();
78+void SvxTbxButtonColorUpdater_Impl::Update( const Color& rColor )
79+{
80+ Image aImage( pTbx->GetItemImage( nBtnId ) );
81
82- if ( theBmpSize.Width() <= 16 )
83- theUpdRect = Rectangle( Point(7,7), Size(8,8) );
84- else
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() );
89+
90+ if ( aCurColor == rColor && !bIconChanged )
91+ return;
92+ aCurColor = rColor;
93
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 );
99- delete pBtnBmp;
100- pBtnBmp = new Bitmap( aVirDev.GetBitmap( aNullPnt, theBmpSize ) );
101- if ( nDrawMode != TBX_UPDATER_MODE_CHAR_COLOR_NEW )
102- aVirDev.DrawRect( theUpdRect );
103- }
104- else if ( !pBtnBmp )
105- pBtnBmp = new Bitmap( aVirDev.GetBitmap( aNullPnt, theBmpSize ) );
106-
107- aVirDev.SetOutputSizePixel( theBmpSize );
108- aVirDev.DrawBitmap( aNullPnt, *pBtnBmp );
109-
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 ) );
116 else
117- aVirDev.SetLineColor( COL_BLACK );
118+ aUpdRect = Rectangle( Point( 1,19 ), Size( 24,6 ) );
119
120- if ( nDrawMode == TBX_UPDATER_MODE_CHAR_COLOR_NEW &&
121- ( aColor.GetColor() != COL_AUTO &&
122- aColor.GetColor() != IMAGE_COL_TRANSPARENT ))
123+ if ( bIconChanged )
124 {
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();
129 }
130- aVirDev.SetFillColor( aColor );
131
132- if ( nDrawMode == TBX_UPDATER_MODE_CHAR_COLOR_NEW )
133+ Bitmap aNewBitmap( aOrigBitmap.GetBitmap() );
134+ Bitmap aNewMask( aOrigBitmap.GetMask() );
135+
136+ BitmapDrawRect( aNewMask, aUpdRect, COL_BLACK );
137+ if( rColor.GetColor() == COL_AUTO )
138 {
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 );
147+
148+ Color aLineColor;
149+ if ( pTbx->GetBackground().GetColor().IsDark() )
150+ aLineColor = COL_WHITE;
151 else
152- theUpdRect = Rectangle( Point( 1,19 ), Size( 24,6 ) );
153- aVirDev.DrawRect( theUpdRect );
154- }
155- else if ( nDrawMode != TBX_UPDATER_MODE_NONE )
156- {
157- DrawChar( aVirDev, aColor );
158- }
159- else
160- aVirDev.DrawRect( theUpdRect );
161+ aLineColor = COL_BLACK;
162
163- aCurColor = aColor;
164-
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;
170-
171- if( !bTransparentColorInitialized )
172- {
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 );
186 }
187+ else
188+ BitmapDrawRect( aNewBitmap, aUpdRect, rColor );
189
190- Bitmap aMaskBitmap = aBmp.CreateMask( aTransparentColor );
191- Image aNewImage( aBmp, aMaskBitmap );
192- pTbx->SetItemImage( nBtnId, aNewImage );
193+ pTbx->SetItemImage( nBtnId, Image( aNewBitmap, aNewMask ) );
194 }
195-
196+#if 0
197 // -----------------------------------------------------------------------
198
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 );
203 }
204+#endif
205 //========================================================================
206 // class SfxStyleControllerItem_Impl ------------------------------------------
207 //========================================================================
This page took 0.060941 seconds and 4 git commands to generate.