update dev300-m58
[ooovba.git] / applied_patches / 0018-cws-calctabcolor-svtools.diff
blob19fd0210df90f8fc8ce0eb0a93ff96f4269de07f
1 diff --git svtools/inc/tabbar.hxx svtools/inc/tabbar.hxx
2 index eed845a..6e0a51c 100644
3 --- svtools/inc/tabbar.hxx
4 +++ svtools/inc/tabbar.hxx
5 @@ -430,6 +430,11 @@ public:
6 USHORT nPos = TABBAR_APPEND );
7 void RemovePage( USHORT nPageId );
8 void MovePage( USHORT nPageId, USHORT nNewPos );
10 + Color GetTabBgColor( USHORT nPageId ) const;
11 + void SetTabBgColor( USHORT nPageId, const Color& aTabBgColor );
12 + BOOL IsDefaultTabBgColor( USHORT nPageId );
14 void Clear();
16 void EnablePage( USHORT nPageId, BOOL bEnable = TRUE );
17 diff --git svtools/source/control/tabbar.cxx svtools/source/control/tabbar.cxx
18 index ed1abbe..bfa6825 100644
19 --- svtools/source/control/tabbar.cxx
20 +++ svtools/source/control/tabbar.cxx
21 @@ -65,6 +65,10 @@ struct ImplTabBarItem
22 BOOL mbShort;
23 BOOL mbSelect;
24 BOOL mbEnable;
25 + Color maTabBgColor;
26 + bool IsDefaultTabBgColor() const { return maTabBgColor == Color(COL_AUTO) ? TRUE : FALSE; };
27 + Color maTabTextColor;
28 + bool IsDefaultTabTextColor() const { return maTabTextColor == Color(COL_AUTO) ? TRUE : FALSE; };
30 ImplTabBarItem( USHORT nItemId, const XubString& rText,
31 TabBarPageBits nPageBits ) :
32 @@ -77,6 +81,8 @@ struct ImplTabBarItem
33 mbShort = FALSE;
34 mbSelect = FALSE;
35 mbEnable = TRUE;
36 + maTabBgColor = Color( COL_AUTO );
37 + maTabTextColor = Color( COL_AUTO );
41 @@ -1049,7 +1055,8 @@ void TabBar::Paint( const Rectangle& )
42 // Font selektieren
43 Font aFont = GetFont();
44 Font aLightFont = aFont;
45 - aLightFont.SetWeight( WEIGHT_LIGHT );
46 + //aLightFont.SetWeight( WEIGHT_LIGHT ); //TODO Make font weight light on custom color only?
47 + aLightFont.SetWeight( WEIGHT_NORMAL );
49 // #i36013# exclude push buttons from painting area
50 Rectangle aClipRect( Point( mnOffX, 0 ), Point( mnLastOffX, GetOutputHeightPixel() - 1 ) );
51 @@ -1123,15 +1130,23 @@ void TabBar::Paint( const Rectangle& )
52 SetFont( aLightFont );
54 // Je nach Status die richtige FillInBrush setzen
55 + // Set the correct FillInBrush depending upon status
56 if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) )
58 + // Currently selected Tab
59 SetFillColor( aSelectColor );
60 SetTextColor( aSelectTextColor );
62 else
64 - SetFillColor( aFaceColor );
65 - SetTextColor( aFaceTextColor );
66 + if ( !pItem->IsDefaultTabBgColor() )
67 + {
68 + SetFillColor( pItem->maTabBgColor );
69 + SetTextColor( pItem->maTabTextColor );
70 + } else {
71 + SetFillColor( aFaceColor );
72 + SetTextColor( aFaceTextColor );
73 + }
76 // Muss Font Kursiv geschaltet werden
77 @@ -1163,21 +1178,38 @@ void TabBar::Paint( const Rectangle& )
78 long nTextHeight = GetTextHeight();
79 Point aTxtPos( aRect.Left()+(aRectSize.Width()-nTextWidth)/2,
80 (aRectSize.Height()-nTextHeight)/2 );
81 - if ( !pItem->mbEnable )
82 - DrawCtrlText( aTxtPos, aText, 0, STRING_LEN, (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC) );
83 - else
84 - DrawText( aTxtPos, aText );
86 + if ( pItem->IsDefaultTabBgColor() || (!pItem->mbSelect) )
87 + {
88 + if ( !pItem->mbEnable )
89 + DrawCtrlText( aTxtPos, aText, 0, STRING_LEN, (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC) );
90 + else
91 + DrawText( aTxtPos, aText );
92 + }
93 // Jetzt im Inhalt den 3D-Effekt ausgeben
94 aPos0.X()++;
95 aPos1.X()++;
96 aPos2.X()--;
97 aPos3.X()--;
98 - SetLineColor( rStyleSettings.GetLightColor() );
100 + // If this is the current tab, draw the left inner shadow the default color,
101 + // otherwise make it the same as the custom background color
102 + if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) {
103 + SetLineColor( rStyleSettings.GetLightColor() );
104 + } else {
105 + if ( !pItem->IsDefaultTabBgColor() )
107 + SetLineColor( pItem->maTabBgColor );
108 + } else {
109 + SetLineColor( rStyleSettings.GetLightColor() );
112 + // Draw the left side of the tab
113 DrawLine( aPos0, aPos1 );
115 if ( !pItem->mbSelect && (pItem->mnId != mnCurPageId) )
117 + // Draw the top inner shadow
118 + // ToDo: Change from this static color to tab custom bg color
119 DrawLine( Point( aPos0.X(), aPos0.Y()+1 ),
120 Point( aPos3.X(), aPos3.Y()+1 ) );
122 @@ -1187,8 +1219,27 @@ void TabBar::Paint( const Rectangle& )
123 aPos1.X()--;
124 aPos1.Y()--;
125 aPos2.Y()--;
126 + if ( !pItem->IsDefaultTabBgColor() && ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) )
128 + SetLineColor( pItem->maTabBgColor );
129 + DrawLine( Point(aPos1.X()-1, aPos1.Y()-1), Point(aPos2.X(), aPos2.Y()-1) );
131 DrawLine( aPos1, aPos2 );
133 + // draw a small 2px sliver of the original background color at the bottom of the selected tab
135 + if ( !pItem->IsDefaultTabBgColor() )
137 + if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) {
138 + SetLineColor( pItem->maTabBgColor );
139 + DrawLine( Point(aPos1.X()-1, aPos1.Y()-1), Point(aPos2.X(), aPos2.Y()-1) );
140 + if ( !pItem->mbEnable )
141 + DrawCtrlText( aTxtPos, aText, 0, STRING_LEN, (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC) );
142 + else
143 + DrawText( aTxtPos, aText );
147 // Da etwas uebermalt werden konnte, muessen wir die Polygon-
148 // umrandung nocheinmal ausgeben
149 SetLineColor( rStyleSettings.GetDarkShadowColor() );
150 @@ -1565,6 +1616,42 @@ void TabBar::InsertPage( USHORT nPageId, const XubString& rText,
152 // -----------------------------------------------------------------------
154 +Color TabBar::GetTabBgColor( USHORT nPageId ) const
156 + USHORT nPos = GetPagePos( nPageId );
158 + if ( nPos != TABBAR_PAGE_NOTFOUND )
159 + return mpItemList->GetObject( nPos )->maTabBgColor;
160 + else
161 + return Color( COL_AUTO );
164 +void TabBar::SetTabBgColor( USHORT nPageId, const Color& aTabBgColor )
166 + USHORT nPos = GetPagePos( nPageId );
167 + ImplTabBarItem* pItem;
168 + if ( nPos != TABBAR_PAGE_NOTFOUND )
170 + pItem = mpItemList->GetObject( nPos );
171 + // TODO: Need to take the text color specification out of this code!
172 + if ( aTabBgColor != Color( COL_AUTO ) )
174 + pItem->maTabBgColor = aTabBgColor;
175 + if ( aTabBgColor.GetLuminance() <= 128 ) //Do not use aTabBgColor.IsDark(), because that threshold is way too low...
176 + pItem->maTabTextColor = Color( COL_WHITE );
177 + else
178 + pItem->maTabTextColor = Color( COL_BLACK );
180 + else
182 + pItem->maTabBgColor = Color( COL_AUTO );
183 + pItem->maTabTextColor = Color( COL_AUTO );
188 +// -----------------------------------------------------------------------
190 void TabBar::RemovePage( USHORT nPageId )
192 USHORT nPos = GetPagePos( nPageId );
193 @@ -2486,9 +2573,12 @@ USHORT TabBar::ShowDropPos( const Point& rPos )
194 nX--;
195 else
196 nX++;
197 + if ( !pItem->IsDefaultTabBgColor() && !pItem->mbSelect)
198 + SetLineColor( pItem->maTabTextColor );
199 DrawLine( Point( nX, nY ), Point( nX, nY ) );
200 DrawLine( Point( nX+1, nY-1 ), Point( nX+1, nY+1 ) );
201 DrawLine( Point( nX+2, nY-2 ), Point( nX+2, nY+2 ) );
202 + SetLineColor( aBlackColor );
204 if ( (mnDropPos > 0) && (mnDropPos < nItemCount+1) )
206 @@ -2496,6 +2586,8 @@ USHORT TabBar::ShowDropPos( const Point& rPos )
207 nX = pItem->maRect.Right()-TABBAR_OFFSET_X;
208 if ( mnDropPos == nCurPos )
209 nX++;
210 + if ( !pItem->IsDefaultTabBgColor() && !pItem->mbSelect)
211 + SetLineColor( pItem->maTabTextColor );
212 DrawLine( Point( nX, nY ), Point( nX, nY ) );
213 DrawLine( Point( nX-1, nY-1 ), Point( nX-1, nY+1 ) );
214 DrawLine( Point( nX-2, nY-2 ), Point( nX-2, nY+2 ) );