xref: /haiku/src/kits/interface/ControlLook.cpp (revision a884b43bb1c7bbd60789f35934466a970fe59d9f)
12f86ba45SStephan Aßmus /*
22f86ba45SStephan Aßmus  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3*a884b43bSJohn Scipione  * Copyright 2012, Haiku Inc. All rights reserved.
42f86ba45SStephan Aßmus  * Distributed under the terms of the MIT License.
5*a884b43bSJohn Scipione  *
6*a884b43bSJohn Scipione  * Authors:
7*a884b43bSJohn Scipione  *		John Scipione <jscipione@gmail.com>
82f86ba45SStephan Aßmus  */
9d452ff66SAxel Dörfler 
10d452ff66SAxel Dörfler 
112f86ba45SStephan Aßmus #include <ControlLook.h>
122f86ba45SStephan Aßmus 
132f86ba45SStephan Aßmus #include <Control.h>
142f86ba45SStephan Aßmus #include <GradientLinear.h>
152f86ba45SStephan Aßmus #include <Region.h>
162f86ba45SStephan Aßmus #include <Shape.h>
172f86ba45SStephan Aßmus #include <String.h>
182f86ba45SStephan Aßmus #include <View.h>
19d63b75faSPhilippe Saint-Pierre #include <Window.h>
202f86ba45SStephan Aßmus 
21*a884b43bSJohn Scipione #include "ContainerWindow.h"
22*a884b43bSJohn Scipione 
23*a884b43bSJohn Scipione 
242f86ba45SStephan Aßmus namespace BPrivate {
252f86ba45SStephan Aßmus 
26*a884b43bSJohn Scipione 
272f86ba45SStephan Aßmus static const float kEdgeBevelLightTint = 0.59;
282f86ba45SStephan Aßmus static const float kEdgeBevelShadowTint = 1.0735;
292f86ba45SStephan Aßmus 
302f86ba45SStephan Aßmus 
31d63b75faSPhilippe Saint-Pierre BControlLook::BControlLook():
32d63b75faSPhilippe Saint-Pierre 	fCachedOutline(false),
33d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace(-1)
342f86ba45SStephan Aßmus {
352f86ba45SStephan Aßmus }
362f86ba45SStephan Aßmus 
372f86ba45SStephan Aßmus 
382f86ba45SStephan Aßmus BControlLook::~BControlLook()
392f86ba45SStephan Aßmus {
402f86ba45SStephan Aßmus }
412f86ba45SStephan Aßmus 
422f86ba45SStephan Aßmus 
432f86ba45SStephan Aßmus BAlignment
442f86ba45SStephan Aßmus BControlLook::DefaultLabelAlignment() const
452f86ba45SStephan Aßmus {
462f86ba45SStephan Aßmus 	return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
472f86ba45SStephan Aßmus }
482f86ba45SStephan Aßmus 
492f86ba45SStephan Aßmus 
502f86ba45SStephan Aßmus float
512f86ba45SStephan Aßmus BControlLook::DefaultLabelSpacing() const
522f86ba45SStephan Aßmus {
5320a11271SAxel Dörfler 	return ceilf(be_plain_font->Size() / 2.0);
5420a11271SAxel Dörfler }
5520a11271SAxel Dörfler 
5620a11271SAxel Dörfler 
5720a11271SAxel Dörfler float
5820a11271SAxel Dörfler BControlLook::DefaultItemSpacing() const
5920a11271SAxel Dörfler {
6020a11271SAxel Dörfler 	return ceilf(be_plain_font->Size() * 0.85);
612f86ba45SStephan Aßmus }
622f86ba45SStephan Aßmus 
632f86ba45SStephan Aßmus 
6482ab3167SAlex Wilson float
656648dd3cSAlex Wilson BControlLook::ComposeSpacing(float spacing)
6682ab3167SAlex Wilson {
67d90a465eSAlex Wilson 	if (spacing == B_USE_DEFAULT_SPACING || spacing == B_USE_ITEM_SPACING) {
6882ab3167SAlex Wilson 		return be_control_look->DefaultItemSpacing();
696648dd3cSAlex Wilson 	} else if (spacing == B_USE_HALF_ITEM_SPACING) {
706648dd3cSAlex Wilson 		return be_control_look->DefaultItemSpacing() * 0.5f;
716648dd3cSAlex Wilson 	} else if (spacing == B_USE_WINDOW_INSETS) {
726648dd3cSAlex Wilson 		return be_control_look->DefaultItemSpacing();
736648dd3cSAlex Wilson 	} else if (spacing == B_USE_SMALL_SPACING) {
746648dd3cSAlex Wilson 		return be_control_look->DefaultItemSpacing() * 0.7f;
756648dd3cSAlex Wilson 	} else if (spacing == B_USE_BIG_SPACING) {
766648dd3cSAlex Wilson 		return be_control_look->DefaultItemSpacing() * 1.3f;
776648dd3cSAlex Wilson 	}
786648dd3cSAlex Wilson 	return spacing;
7982ab3167SAlex Wilson }
8082ab3167SAlex Wilson 
8182ab3167SAlex Wilson 
822f86ba45SStephan Aßmus uint32
832f86ba45SStephan Aßmus BControlLook::Flags(BControl* control) const
842f86ba45SStephan Aßmus {
852f86ba45SStephan Aßmus 	uint32 flags = 0;
862f86ba45SStephan Aßmus 
872f86ba45SStephan Aßmus 	if (!control->IsEnabled())
882f86ba45SStephan Aßmus 		flags |= B_DISABLED;
892f86ba45SStephan Aßmus 
902f86ba45SStephan Aßmus 	if (control->IsFocus())
912f86ba45SStephan Aßmus 		flags |= B_FOCUSED;
922f86ba45SStephan Aßmus 
932f86ba45SStephan Aßmus 	if (control->Value() == B_CONTROL_ON)
942f86ba45SStephan Aßmus 		flags |= B_ACTIVATED;
952f86ba45SStephan Aßmus 
9661ac1a85SStephan Aßmus 	if (control->Parent() != NULL
9761ac1a85SStephan Aßmus 		&& (control->Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
9861ac1a85SStephan Aßmus 		// In this constellation, assume we want to render the control
9961ac1a85SStephan Aßmus 		// against the already existing view contents of the parent view.
10061ac1a85SStephan Aßmus 		flags |= B_BLEND_FRAME;
10161ac1a85SStephan Aßmus 	}
10261ac1a85SStephan Aßmus 
1032f86ba45SStephan Aßmus 	return flags;
1042f86ba45SStephan Aßmus }
1052f86ba45SStephan Aßmus 
1062f86ba45SStephan Aßmus 
1072f86ba45SStephan Aßmus // #pragma mark -
1082f86ba45SStephan Aßmus 
1092f86ba45SStephan Aßmus 
1102f86ba45SStephan Aßmus void
1112f86ba45SStephan Aßmus BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
112681c2e44SStephan Aßmus 	const rgb_color& base, const rgb_color& background, uint32 flags,
113681c2e44SStephan Aßmus 	uint32 borders)
1142f86ba45SStephan Aßmus {
115*a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
116*a884b43bSJohn Scipione 		background, 1.0, 1.0, flags, borders);
117*a884b43bSJohn Scipione }
118*a884b43bSJohn Scipione 
119*a884b43bSJohn Scipione 
120*a884b43bSJohn Scipione void
121*a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
122*a884b43bSJohn Scipione 	float radius, const rgb_color& base, const rgb_color& background, uint32 flags,
123*a884b43bSJohn Scipione 	uint32 borders)
124*a884b43bSJohn Scipione {
125*a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
126*a884b43bSJohn Scipione 		base, background, 1.0, 1.0, flags, borders);
127*a884b43bSJohn Scipione }
128*a884b43bSJohn Scipione 
129*a884b43bSJohn Scipione 
130*a884b43bSJohn Scipione void
131*a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect,
132*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
133*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
134*a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags,
135*a884b43bSJohn Scipione 	uint32 borders)
136*a884b43bSJohn Scipione {
137*a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
138*a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background,
139*a884b43bSJohn Scipione 		1.0, 1.0, flags, borders);
1402f86ba45SStephan Aßmus }
1412f86ba45SStephan Aßmus 
1422f86ba45SStephan Aßmus 
1432f86ba45SStephan Aßmus void
1442f86ba45SStephan Aßmus BControlLook::DrawButtonBackground(BView* view, BRect& rect,
1452f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
1462f86ba45SStephan Aßmus 	uint32 borders, enum orientation orientation)
1472f86ba45SStephan Aßmus {
148*a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f,
149*a884b43bSJohn Scipione 		base, flags, borders, orientation);
1502f86ba45SStephan Aßmus }
1512f86ba45SStephan Aßmus 
1522f86ba45SStephan Aßmus 
153*a884b43bSJohn Scipione void
154*a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
155*a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base, uint32 flags,
156*a884b43bSJohn Scipione 	uint32 borders, enum orientation orientation)
157*a884b43bSJohn Scipione {
158*a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, radius, radius, radius,
159*a884b43bSJohn Scipione 		radius, base, flags, borders, orientation);
1602f86ba45SStephan Aßmus }
1612f86ba45SStephan Aßmus 
1622f86ba45SStephan Aßmus 
163*a884b43bSJohn Scipione void
164*a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
165*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
166*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
167*a884b43bSJohn Scipione 	uint32 flags, uint32 borders, enum orientation orientation)
168*a884b43bSJohn Scipione {
169*a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, leftTopRadius,
170*a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags,
171*a884b43bSJohn Scipione 		borders, orientation);
1722f86ba45SStephan Aßmus }
1732f86ba45SStephan Aßmus 
1742f86ba45SStephan Aßmus 
1752f86ba45SStephan Aßmus void
1762f86ba45SStephan Aßmus BControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
1771a72cb41SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
1781a72cb41SStephan Aßmus 	uint32 borders)
1792f86ba45SStephan Aßmus {
180*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1812f86ba45SStephan Aßmus 		return;
1822f86ba45SStephan Aßmus 
1832f86ba45SStephan Aßmus 	// the surface edges
1842f86ba45SStephan Aßmus 
1852f86ba45SStephan Aßmus 	// colors
1861a72cb41SStephan Aßmus 	float topTint;
1871a72cb41SStephan Aßmus 	float bottomTint;
1881a72cb41SStephan Aßmus 
189*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
1901a72cb41SStephan Aßmus 		rgb_color bevelColor1 = tint_color(base, 1.40);
1911a72cb41SStephan Aßmus 		rgb_color bevelColor2 = tint_color(base, 1.25);
1921a72cb41SStephan Aßmus 
1931a72cb41SStephan Aßmus 		topTint = 1.25;
1941a72cb41SStephan Aßmus 		bottomTint = 1.20;
1952f86ba45SStephan Aßmus 
1962f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
1971a72cb41SStephan Aßmus 			bevelColor1, bevelColor1,
1981a72cb41SStephan Aßmus 			bevelColor2, bevelColor2,
1991a72cb41SStephan Aßmus 			borders & B_TOP_BORDER);
2001a72cb41SStephan Aßmus 	} else {
2011a72cb41SStephan Aßmus 		rgb_color cornerColor = tint_color(base, 0.9);
2021a72cb41SStephan Aßmus 		rgb_color bevelColorTop = tint_color(base, 0.5);
2031a72cb41SStephan Aßmus 		rgb_color bevelColorLeft = tint_color(base, 0.7);
2041a72cb41SStephan Aßmus 		rgb_color bevelColorRightBottom = tint_color(base, 1.08);
2051a72cb41SStephan Aßmus 
2061a72cb41SStephan Aßmus 		topTint = 0.69;
2071a72cb41SStephan Aßmus 		bottomTint = 1.03;
2081a72cb41SStephan Aßmus 
2091a72cb41SStephan Aßmus 		_DrawFrame(view, rect,
2101a72cb41SStephan Aßmus 			bevelColorLeft, bevelColorTop,
2111a72cb41SStephan Aßmus 			bevelColorRightBottom, bevelColorRightBottom,
2122f86ba45SStephan Aßmus 			cornerColor, cornerColor,
2132f86ba45SStephan Aßmus 			borders);
2141a72cb41SStephan Aßmus 	}
2152f86ba45SStephan Aßmus 
216*a884b43bSJohn Scipione 	// draw surface top
2172f86ba45SStephan Aßmus 	_FillGradient(view, rect, base, topTint, bottomTint);
2182f86ba45SStephan Aßmus }
2192f86ba45SStephan Aßmus 
2202f86ba45SStephan Aßmus 
2212f86ba45SStephan Aßmus void
222681c2e44SStephan Aßmus BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
223681c2e44SStephan Aßmus 	const BRect& updateRect, const rgb_color& base,
224681c2e44SStephan Aßmus 	const rgb_color& background, uint32 flags, uint32 borders)
22513cd46dfSStephan Aßmus {
226*a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
227*a884b43bSJohn Scipione 		background, 0.6, 1.0, flags, borders);
228*a884b43bSJohn Scipione }
229*a884b43bSJohn Scipione 
230*a884b43bSJohn Scipione 
231*a884b43bSJohn Scipione void
232*a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
233*a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
234*a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
235*a884b43bSJohn Scipione {
236*a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
237*a884b43bSJohn Scipione 		base, background, 0.6, 1.0, flags, borders);
238*a884b43bSJohn Scipione }
239*a884b43bSJohn Scipione 
240*a884b43bSJohn Scipione 
241*a884b43bSJohn Scipione void
242*a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
243*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius,
244*a884b43bSJohn Scipione 	float rightTopRadius, float leftBottomRadius,
245*a884b43bSJohn Scipione 	float rightBottomRadius, const rgb_color& base,
246*a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
247*a884b43bSJohn Scipione {
248*a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
249*a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background, 0.6, 1.0,
250*a884b43bSJohn Scipione 		flags, borders);
25113cd46dfSStephan Aßmus }
25213cd46dfSStephan Aßmus 
25313cd46dfSStephan Aßmus 
25413cd46dfSStephan Aßmus void
2552f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
2562f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, bool popupIndicator,
2572f86ba45SStephan Aßmus 	uint32 flags)
2582f86ba45SStephan Aßmus {
259*a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect,
260*a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, popupIndicator, flags);
2612f86ba45SStephan Aßmus }
2622f86ba45SStephan Aßmus 
2632f86ba45SStephan Aßmus 
2642f86ba45SStephan Aßmus void
2652f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
2662f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
2672f86ba45SStephan Aßmus 	uint32 borders)
2682f86ba45SStephan Aßmus {
269*a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundInside(view, rect, updateRect,
270*a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, flags, borders);
2712f86ba45SStephan Aßmus }
2722f86ba45SStephan Aßmus 
2732f86ba45SStephan Aßmus 
274*a884b43bSJohn Scipione void
275*a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
276*a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
277*a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
278*a884b43bSJohn Scipione {
279*a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, radius, radius,
280*a884b43bSJohn Scipione 		radius, radius, base, popupIndicator, flags);
2812f86ba45SStephan Aßmus }
2822f86ba45SStephan Aßmus 
283*a884b43bSJohn Scipione 
284*a884b43bSJohn Scipione void
285*a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
286*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
287*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
288*a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
289*a884b43bSJohn Scipione {
290*a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, leftTopRadius,
291*a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base,
292*a884b43bSJohn Scipione 		popupIndicator, flags);
2932f86ba45SStephan Aßmus }
2942f86ba45SStephan Aßmus 
295*a884b43bSJohn Scipione 
2962f86ba45SStephan Aßmus void
2972f86ba45SStephan Aßmus BControlLook::DrawMenuBackground(BView* view, BRect& rect,
2982f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
2992f86ba45SStephan Aßmus 	uint32 borders)
3002f86ba45SStephan Aßmus {
301*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3022f86ba45SStephan Aßmus 		return;
3032f86ba45SStephan Aßmus 
304*a884b43bSJohn Scipione 	// surface top color
3052f86ba45SStephan Aßmus 	rgb_color background = tint_color(base, 0.75);
3062f86ba45SStephan Aßmus 
307*a884b43bSJohn Scipione 	// inner bevel colors
308*a884b43bSJohn Scipione 	rgb_color bevelLightColor;
309*a884b43bSJohn Scipione 	rgb_color bevelShadowColor;
310*a884b43bSJohn Scipione 
311*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3122f86ba45SStephan Aßmus 		bevelLightColor = tint_color(background, 0.80);
3132f86ba45SStephan Aßmus 		bevelShadowColor = tint_color(background, 1.07);
3142f86ba45SStephan Aßmus 	} else {
3152f86ba45SStephan Aßmus 		bevelLightColor = tint_color(background, 0.6);
3162f86ba45SStephan Aßmus 		bevelShadowColor = tint_color(background, 1.12);
3172f86ba45SStephan Aßmus 	}
3182f86ba45SStephan Aßmus 
319*a884b43bSJohn Scipione 	// draw inner bevel
3202f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3212f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3222f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3232f86ba45SStephan Aßmus 		borders);
3242f86ba45SStephan Aßmus 
325*a884b43bSJohn Scipione 	// draw surface top
3262f86ba45SStephan Aßmus 	view->SetHighColor(background);
3272f86ba45SStephan Aßmus 	view->FillRect(rect);
3282f86ba45SStephan Aßmus }
3292f86ba45SStephan Aßmus 
3302f86ba45SStephan Aßmus 
3312f86ba45SStephan Aßmus void
3322f86ba45SStephan Aßmus BControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
3332f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
3342f86ba45SStephan Aßmus 	uint32 borders)
3352f86ba45SStephan Aßmus {
336*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3372f86ba45SStephan Aßmus 		return;
3382f86ba45SStephan Aßmus 
339*a884b43bSJohn Scipione 	// surface edges
3402f86ba45SStephan Aßmus 	float topTint;
3412f86ba45SStephan Aßmus 	float bottomTint;
3422f86ba45SStephan Aßmus 	rgb_color selectedColor = base;
3432f86ba45SStephan Aßmus 
344*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3452f86ba45SStephan Aßmus 		topTint = 0.9;
3462f86ba45SStephan Aßmus 		bottomTint = 1.05;
3472f86ba45SStephan Aßmus 		selectedColor = tint_color(base, 1.26);
348*a884b43bSJohn Scipione 	} else if ((flags & B_DISABLED) != 0) {
3492f86ba45SStephan Aßmus 		topTint = 0.80;
3502f86ba45SStephan Aßmus 		bottomTint = 1.07;
3512f86ba45SStephan Aßmus 	} else {
3522f86ba45SStephan Aßmus 		topTint = 0.6;
3532f86ba45SStephan Aßmus 		bottomTint = 1.12;
3542f86ba45SStephan Aßmus 	}
3552f86ba45SStephan Aßmus 
3562f86ba45SStephan Aßmus 	rgb_color bevelLightColor = tint_color(selectedColor, topTint);
3572f86ba45SStephan Aßmus 	rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint);
3582f86ba45SStephan Aßmus 
359*a884b43bSJohn Scipione 	// draw surface edges
3602f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3612f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3622f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3632f86ba45SStephan Aßmus 		borders);
3642f86ba45SStephan Aßmus 
365*a884b43bSJohn Scipione 	// draw surface top
3662f86ba45SStephan Aßmus 	view->SetLowColor(selectedColor);
3672f86ba45SStephan Aßmus //	_FillGradient(view, rect, selectedColor, topTint, bottomTint);
3682f86ba45SStephan Aßmus 	_FillGradient(view, rect, selectedColor, bottomTint, topTint);
3692f86ba45SStephan Aßmus }
3702f86ba45SStephan Aßmus 
3712f86ba45SStephan Aßmus 
3722f86ba45SStephan Aßmus void
3732f86ba45SStephan Aßmus BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect,
3742f86ba45SStephan Aßmus 	const rgb_color& base, const rgb_color& barColor, float progressPosition)
3752f86ba45SStephan Aßmus {
3762f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
3772f86ba45SStephan Aßmus 		return;
3782f86ba45SStephan Aßmus 
3792f86ba45SStephan Aßmus 	_DrawOuterResessedFrame(view, rect, base, 0.6);
3802f86ba45SStephan Aßmus 
3812f86ba45SStephan Aßmus 	// colors
3822f86ba45SStephan Aßmus 	rgb_color dark1BorderColor = tint_color(base, 1.3);
3832f86ba45SStephan Aßmus 	rgb_color dark2BorderColor = tint_color(base, 1.2);
3842f86ba45SStephan Aßmus 	rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
3852f86ba45SStephan Aßmus 	rgb_color dark2FilledBorderColor = tint_color(barColor, 1.45);
3862f86ba45SStephan Aßmus 
3872f86ba45SStephan Aßmus 	BRect filledRect(rect);
3882f86ba45SStephan Aßmus 	filledRect.right = progressPosition - 1;
3892f86ba45SStephan Aßmus 
3902f86ba45SStephan Aßmus 	BRect nonfilledRect(rect);
3912f86ba45SStephan Aßmus 	nonfilledRect.left = progressPosition;
3922f86ba45SStephan Aßmus 
3932f86ba45SStephan Aßmus 	bool filledSurface = filledRect.Width() > 0;
3942f86ba45SStephan Aßmus 	bool nonfilledSurface = nonfilledRect.Width() > 0;
3952f86ba45SStephan Aßmus 
3962f86ba45SStephan Aßmus 	if (filledSurface) {
3972f86ba45SStephan Aßmus 		_DrawFrame(view, filledRect,
3982f86ba45SStephan Aßmus 			dark1FilledBorderColor, dark1FilledBorderColor,
3992f86ba45SStephan Aßmus 			dark2FilledBorderColor, dark2FilledBorderColor);
4002f86ba45SStephan Aßmus 
4012f86ba45SStephan Aßmus 		_FillGlossyGradient(view, filledRect, barColor, 0.55, 0.68, 0.76, 0.90);
4022f86ba45SStephan Aßmus 	}
4032f86ba45SStephan Aßmus 
4042f86ba45SStephan Aßmus 	if (nonfilledSurface) {
4052f86ba45SStephan Aßmus 		_DrawFrame(view, nonfilledRect, dark1BorderColor, dark1BorderColor,
4062f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor,
4072f86ba45SStephan Aßmus 			B_TOP_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
4082f86ba45SStephan Aßmus 
4092f86ba45SStephan Aßmus 		if (nonfilledRect.left < nonfilledRect.right) {
4102f86ba45SStephan Aßmus 			// shadow from fill bar, or left border
4112f86ba45SStephan Aßmus 			rgb_color leftBorder = dark1BorderColor;
4122f86ba45SStephan Aßmus 			if (filledSurface)
4132f86ba45SStephan Aßmus 				leftBorder = tint_color(base, 0.50);
4142f86ba45SStephan Aßmus 			view->SetHighColor(leftBorder);
4152f86ba45SStephan Aßmus 			view->StrokeLine(nonfilledRect.LeftTop(),
4162f86ba45SStephan Aßmus 				nonfilledRect.LeftBottom());
4172f86ba45SStephan Aßmus 			nonfilledRect.left++;
4182f86ba45SStephan Aßmus 		}
4192f86ba45SStephan Aßmus 
4202f86ba45SStephan Aßmus 		_FillGradient(view, nonfilledRect, base, 0.25, 0.06);
4212f86ba45SStephan Aßmus 	}
4222f86ba45SStephan Aßmus }
4232f86ba45SStephan Aßmus 
4242f86ba45SStephan Aßmus 
4252f86ba45SStephan Aßmus void
4262f86ba45SStephan Aßmus BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect,
4272f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4282f86ba45SStephan Aßmus {
4292f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4302f86ba45SStephan Aßmus 		return;
4312f86ba45SStephan Aßmus 
4322f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
4332f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
4342f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
4352f86ba45SStephan Aßmus 
436*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4374f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags);
4382f86ba45SStephan Aßmus 
4392f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.15);
4402f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.15);
441*a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
4422f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
4432f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.48);
4442f86ba45SStephan Aßmus 
4452f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
4462f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
4472f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
4482f86ba45SStephan Aßmus 
4492f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
4502f86ba45SStephan Aßmus 	} else {
4514f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags);
4522f86ba45SStephan Aßmus 
4532f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.40);
4542f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.38);
4552f86ba45SStephan Aßmus 	}
4562f86ba45SStephan Aßmus 
457*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
4582f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
4592f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
4602f86ba45SStephan Aßmus 	}
4612f86ba45SStephan Aßmus 
4622f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
4632f86ba45SStephan Aßmus 		dark1BorderColor, dark1BorderColor,
4642f86ba45SStephan Aßmus 		dark2BorderColor, dark2BorderColor);
4652f86ba45SStephan Aßmus 
466*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4672f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.4, 0.2);
4682f86ba45SStephan Aßmus 	} else {
4692f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.15, 0.0);
4702f86ba45SStephan Aßmus 	}
4712f86ba45SStephan Aßmus 
4722f86ba45SStephan Aßmus 	rgb_color markColor;
4732f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
4742f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
4752f86ba45SStephan Aßmus 
4762f86ba45SStephan Aßmus 		rect.InsetBy(2, 2);
4772f86ba45SStephan Aßmus 		view->SetPenSize(max_c(1.0, ceilf(rect.Width() / 3.5)));
4782f86ba45SStephan Aßmus 		view->SetDrawingMode(B_OP_OVER);
4792f86ba45SStephan Aßmus 
4802f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightBottom());
4812f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightTop());
4822f86ba45SStephan Aßmus 	}
4832f86ba45SStephan Aßmus }
4842f86ba45SStephan Aßmus 
4852f86ba45SStephan Aßmus 
4862f86ba45SStephan Aßmus void
4872f86ba45SStephan Aßmus BControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect,
4882f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4892f86ba45SStephan Aßmus {
4902f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4912f86ba45SStephan Aßmus 		return;
4922f86ba45SStephan Aßmus 
4932f86ba45SStephan Aßmus 	rgb_color borderColor;
4942f86ba45SStephan Aßmus 	rgb_color bevelLight;
4952f86ba45SStephan Aßmus 	rgb_color bevelShadow;
4962f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
4972f86ba45SStephan Aßmus 
498*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4992f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.15);
5002f86ba45SStephan Aßmus 		bevelLight = base;
5012f86ba45SStephan Aßmus 		bevelShadow = base;
502*a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
5032f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.50);
5042f86ba45SStephan Aßmus 		bevelLight = borderColor;
5052f86ba45SStephan Aßmus 		bevelShadow = borderColor;
5062f86ba45SStephan Aßmus 	} else {
5072f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.45);
5082f86ba45SStephan Aßmus 		bevelLight = tint_color(base, 0.55);
5092f86ba45SStephan Aßmus 		bevelShadow = tint_color(base, 1.11);
5102f86ba45SStephan Aßmus 	}
5112f86ba45SStephan Aßmus 
512*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
5132f86ba45SStephan Aßmus 		borderColor = navigationColor;
5142f86ba45SStephan Aßmus 	}
5152f86ba45SStephan Aßmus 
5162f86ba45SStephan Aßmus 	BGradientLinear bevelGradient;
5172f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelShadow, 0);
5182f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelLight, 255);
5192f86ba45SStephan Aßmus 	bevelGradient.SetStart(rect.LeftTop());
5202f86ba45SStephan Aßmus 	bevelGradient.SetEnd(rect.RightBottom());
5212f86ba45SStephan Aßmus 
5222f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5232f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5242f86ba45SStephan Aßmus 
5252f86ba45SStephan Aßmus 	bevelGradient.MakeEmpty();
5262f86ba45SStephan Aßmus 	bevelGradient.AddColor(borderColor, 0);
5272f86ba45SStephan Aßmus 	bevelGradient.AddColor(tint_color(borderColor, 0.8), 255);
5282f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5292f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5302f86ba45SStephan Aßmus 
5312f86ba45SStephan Aßmus 	float topTint;
5322f86ba45SStephan Aßmus 	float bottomTint;
533*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5342f86ba45SStephan Aßmus 		topTint = 0.4;
5352f86ba45SStephan Aßmus 		bottomTint = 0.2;
5362f86ba45SStephan Aßmus 	} else {
5372f86ba45SStephan Aßmus 		topTint = 0.15;
5382f86ba45SStephan Aßmus 		bottomTint = 0.0;
5392f86ba45SStephan Aßmus 	}
5402f86ba45SStephan Aßmus 
5412f86ba45SStephan Aßmus 	BGradientLinear gradient;
5422f86ba45SStephan Aßmus 	_MakeGradient(gradient, rect, base, topTint, bottomTint);
5432f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
5442f86ba45SStephan Aßmus 
5452f86ba45SStephan Aßmus 	rgb_color markColor;
5462f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
5472f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
5482f86ba45SStephan Aßmus 		rect.InsetBy(3, 3);
5492f86ba45SStephan Aßmus 		view->FillEllipse(rect);
5502f86ba45SStephan Aßmus 	}
5512f86ba45SStephan Aßmus }
5522f86ba45SStephan Aßmus 
5532f86ba45SStephan Aßmus 
5542f86ba45SStephan Aßmus void
5552f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2,
5562f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
5572f86ba45SStephan Aßmus 	enum orientation orientation)
5582f86ba45SStephan Aßmus {
5592f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect1, updateRect, base, flags, orientation);
5602f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation);
5612f86ba45SStephan Aßmus }
5622f86ba45SStephan Aßmus 
5632f86ba45SStephan Aßmus void
5642f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect,
5652f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
5662f86ba45SStephan Aßmus 	enum orientation orientation)
5672f86ba45SStephan Aßmus {
5682f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
5692f86ba45SStephan Aßmus 		return;
5702f86ba45SStephan Aßmus 
5712f86ba45SStephan Aßmus 	float gradient1Tint;
5722f86ba45SStephan Aßmus 	float gradient2Tint;
5732f86ba45SStephan Aßmus 	float darkEdge1Tint;
5742f86ba45SStephan Aßmus 	float darkEdge2Tint;
5752f86ba45SStephan Aßmus 	float shadowTint;
5762f86ba45SStephan Aßmus 
577*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5782f86ba45SStephan Aßmus 		gradient1Tint = 0.9;
5792f86ba45SStephan Aßmus 		gradient2Tint = 0.8;
5802f86ba45SStephan Aßmus 		darkEdge1Tint = B_DARKEN_2_TINT;
5812f86ba45SStephan Aßmus 		darkEdge2Tint = B_DARKEN_2_TINT;
5822f86ba45SStephan Aßmus 		shadowTint = gradient1Tint;
5832f86ba45SStephan Aßmus 	} else {
5842f86ba45SStephan Aßmus 		gradient1Tint = 1.10;
5852f86ba45SStephan Aßmus 		gradient2Tint = 1.05;
5862f86ba45SStephan Aßmus 		darkEdge1Tint = B_DARKEN_3_TINT;
5872f86ba45SStephan Aßmus 		darkEdge2Tint = B_DARKEN_2_TINT;
5882f86ba45SStephan Aßmus 		shadowTint = gradient1Tint;
5892f86ba45SStephan Aßmus 	}
5902f86ba45SStephan Aßmus 
5912f86ba45SStephan Aßmus 	rgb_color darkEdge1 = tint_color(base, darkEdge1Tint);
5922f86ba45SStephan Aßmus 	rgb_color darkEdge2 = tint_color(base, darkEdge2Tint);
5932f86ba45SStephan Aßmus 	rgb_color shadow = tint_color(base, shadowTint);
5942f86ba45SStephan Aßmus 
5952f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
5962f86ba45SStephan Aßmus 		// dark vertical line on left edge
5972f86ba45SStephan Aßmus 		if (rect.Width() > 0) {
5982f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge1);
5992f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
6002f86ba45SStephan Aßmus 			rect.left++;
6012f86ba45SStephan Aßmus 		}
6022f86ba45SStephan Aßmus 		// dark vertical line on right edge
6032f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6042f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge2);
6052f86ba45SStephan Aßmus 			view->StrokeLine(rect.RightTop(), rect.RightBottom());
6062f86ba45SStephan Aßmus 			rect.right--;
6072f86ba45SStephan Aßmus 		}
6082f86ba45SStephan Aßmus 		// vertical shadow line after left edge
6092f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6102f86ba45SStephan Aßmus 			view->SetHighColor(shadow);
6112f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
6122f86ba45SStephan Aßmus 			rect.left++;
6132f86ba45SStephan Aßmus 		}
6142f86ba45SStephan Aßmus 		// fill
6152f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6162f86ba45SStephan Aßmus 			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
6172f86ba45SStephan Aßmus 				orientation);
6182f86ba45SStephan Aßmus 		}
6192f86ba45SStephan Aßmus 	} else {
6202f86ba45SStephan Aßmus 		// dark vertical line on top edge
6212f86ba45SStephan Aßmus 		if (rect.Height() > 0) {
6222f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge1);
6232f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.RightTop());
6242f86ba45SStephan Aßmus 			rect.top++;
6252f86ba45SStephan Aßmus 		}
6262f86ba45SStephan Aßmus 		// dark vertical line on bottom edge
6272f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6282f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge2);
6292f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
6302f86ba45SStephan Aßmus 			rect.bottom--;
6312f86ba45SStephan Aßmus 		}
6322f86ba45SStephan Aßmus 		// horizontal shadow line after top edge
6332f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6342f86ba45SStephan Aßmus 			view->SetHighColor(shadow);
6352f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.RightTop());
6362f86ba45SStephan Aßmus 			rect.top++;
6372f86ba45SStephan Aßmus 		}
6382f86ba45SStephan Aßmus 		// fill
6392f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6402f86ba45SStephan Aßmus 			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
6412f86ba45SStephan Aßmus 				orientation);
6422f86ba45SStephan Aßmus 		}
6432f86ba45SStephan Aßmus 	}
6442f86ba45SStephan Aßmus }
6452f86ba45SStephan Aßmus 
6462f86ba45SStephan Aßmus 
64740a10e1cSStephan Aßmus void
64874bb70aeSStephan Aßmus BControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
64974bb70aeSStephan Aßmus 	const BRect& updateRect, BRect verticalScrollBarFrame,
65074bb70aeSStephan Aßmus 	BRect horizontalScrollBarFrame, const rgb_color& base,
65174bb70aeSStephan Aßmus 	border_style border, uint32 flags, uint32 _borders)
65274bb70aeSStephan Aßmus {
653ce955579SStephan Aßmus 	// calculate scroll corner rect before messing with the "rect"
654ce955579SStephan Aßmus 	BRect scrollCornerFillRect(rect.right, rect.bottom,
655ce955579SStephan Aßmus 		rect.right, rect.bottom);
656ce955579SStephan Aßmus 	if (horizontalScrollBarFrame.IsValid())
657ce955579SStephan Aßmus 		scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1;
658ce955579SStephan Aßmus 	if (verticalScrollBarFrame.IsValid())
659ce955579SStephan Aßmus 		scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1;
660ce955579SStephan Aßmus 
661c44aa833SStephan Aßmus 	if (border == B_NO_BORDER) {
662c44aa833SStephan Aßmus 		if (scrollCornerFillRect.IsValid()) {
663c44aa833SStephan Aßmus 			view->SetHighColor(base);
664c44aa833SStephan Aßmus 			view->FillRect(scrollCornerFillRect);
665c44aa833SStephan Aßmus 		}
666c44aa833SStephan Aßmus 		return;
667c44aa833SStephan Aßmus 	}
668c44aa833SStephan Aßmus 
669c44aa833SStephan Aßmus 	bool excludeScrollCorner = border == B_FANCY_BORDER
670c44aa833SStephan Aßmus 		&& horizontalScrollBarFrame.IsValid()
671c44aa833SStephan Aßmus 		&& verticalScrollBarFrame.IsValid();
672c44aa833SStephan Aßmus 
67374bb70aeSStephan Aßmus 	uint32 borders = _borders;
67474bb70aeSStephan Aßmus 	if (excludeScrollCorner) {
67574bb70aeSStephan Aßmus 		rect.bottom = horizontalScrollBarFrame.top;
67674bb70aeSStephan Aßmus 		rect.right = verticalScrollBarFrame.left;
67774bb70aeSStephan Aßmus 		borders &= ~(B_RIGHT_BORDER | B_BOTTOM_BORDER);
67874bb70aeSStephan Aßmus 	}
67974bb70aeSStephan Aßmus 
68074bb70aeSStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
68174bb70aeSStephan Aßmus 
68274bb70aeSStephan Aßmus 	if (border == B_FANCY_BORDER)
6834f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
68474bb70aeSStephan Aßmus 
685*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
68674bb70aeSStephan Aßmus 		rgb_color focusColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
68774bb70aeSStephan Aßmus 		_DrawFrame(view, rect, focusColor, focusColor, focusColor, focusColor,
68874bb70aeSStephan Aßmus 			borders);
68974bb70aeSStephan Aßmus 	} else {
69074bb70aeSStephan Aßmus 		_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
69174bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, borders);
69274bb70aeSStephan Aßmus 	}
69374bb70aeSStephan Aßmus 
69474bb70aeSStephan Aßmus 	if (excludeScrollCorner) {
69574bb70aeSStephan Aßmus 		horizontalScrollBarFrame.InsetBy(-1, -1);
69674bb70aeSStephan Aßmus 		// do not overdraw the top edge
69774bb70aeSStephan Aßmus 		horizontalScrollBarFrame.top += 2;
69874bb70aeSStephan Aßmus 		borders = _borders;
69974bb70aeSStephan Aßmus 		borders &= ~B_TOP_BORDER;
70074bb70aeSStephan Aßmus 		_DrawOuterResessedFrame(view, horizontalScrollBarFrame, base,
7014f579098SStephan Aßmus 			1.0, 1.0, flags, borders);
70274bb70aeSStephan Aßmus 		_DrawFrame(view, horizontalScrollBarFrame, scrollbarFrameColor,
70374bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
70474bb70aeSStephan Aßmus 			borders);
70574bb70aeSStephan Aßmus 
70674bb70aeSStephan Aßmus 
70774bb70aeSStephan Aßmus 		verticalScrollBarFrame.InsetBy(-1, -1);
70874bb70aeSStephan Aßmus 		// do not overdraw the left edge
70974bb70aeSStephan Aßmus 		verticalScrollBarFrame.left += 2;
71074bb70aeSStephan Aßmus 		borders = _borders;
71174bb70aeSStephan Aßmus 		borders &= ~B_LEFT_BORDER;
71274bb70aeSStephan Aßmus 		_DrawOuterResessedFrame(view, verticalScrollBarFrame, base,
7134f579098SStephan Aßmus 			1.0, 1.0, flags, borders);
71474bb70aeSStephan Aßmus 		_DrawFrame(view, verticalScrollBarFrame, scrollbarFrameColor,
71574bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
71674bb70aeSStephan Aßmus 			borders);
717ce955579SStephan Aßmus 
718ce955579SStephan Aßmus 		// exclude recessed frame
719ce955579SStephan Aßmus 		scrollCornerFillRect.top++;
720ce955579SStephan Aßmus 		scrollCornerFillRect.left++;
721ce955579SStephan Aßmus 	}
722ce955579SStephan Aßmus 
723ce955579SStephan Aßmus 	if (scrollCornerFillRect.IsValid()) {
724ce955579SStephan Aßmus 		view->SetHighColor(base);
725ce955579SStephan Aßmus 		view->FillRect(scrollCornerFillRect);
72674bb70aeSStephan Aßmus 	}
72774bb70aeSStephan Aßmus }
72874bb70aeSStephan Aßmus 
72974bb70aeSStephan Aßmus 
73074bb70aeSStephan Aßmus void
73140a10e1cSStephan Aßmus BControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect,
73240a10e1cSStephan Aßmus 	const rgb_color& base, uint32 direction, uint32 flags, float tint)
73340a10e1cSStephan Aßmus {
73440a10e1cSStephan Aßmus 	BPoint tri1, tri2, tri3;
73540a10e1cSStephan Aßmus 	float hInset = rect.Width() / 3;
73640a10e1cSStephan Aßmus 	float vInset = rect.Height() / 3;
73740a10e1cSStephan Aßmus 	rect.InsetBy(hInset, vInset);
73840a10e1cSStephan Aßmus 
73940a10e1cSStephan Aßmus 	switch (direction) {
74040a10e1cSStephan Aßmus 		case B_LEFT_ARROW:
74140a10e1cSStephan Aßmus 			tri1.Set(rect.right, rect.top);
74240a10e1cSStephan Aßmus 			tri2.Set(rect.right - rect.Width() / 1.33,
74340a10e1cSStephan Aßmus 				(rect.top + rect.bottom + 1) /2 );
74440a10e1cSStephan Aßmus 			tri3.Set(rect.right, rect.bottom + 1);
74540a10e1cSStephan Aßmus 			break;
74640a10e1cSStephan Aßmus 		case B_RIGHT_ARROW:
74740a10e1cSStephan Aßmus 			tri1.Set(rect.left, rect.bottom + 1);
74840a10e1cSStephan Aßmus 			tri2.Set(rect.left + rect.Width() / 1.33,
74940a10e1cSStephan Aßmus 				(rect.top + rect.bottom + 1) / 2);
75040a10e1cSStephan Aßmus 			tri3.Set(rect.left, rect.top);
75140a10e1cSStephan Aßmus 			break;
75240a10e1cSStephan Aßmus 		case B_UP_ARROW:
75340a10e1cSStephan Aßmus 			tri1.Set(rect.left, rect.bottom);
75440a10e1cSStephan Aßmus 			tri2.Set((rect.left + rect.right + 1) / 2,
75540a10e1cSStephan Aßmus 				rect.bottom - rect.Height() / 1.33);
75640a10e1cSStephan Aßmus 			tri3.Set(rect.right + 1, rect.bottom);
75740a10e1cSStephan Aßmus 			break;
75840a10e1cSStephan Aßmus 		case B_DOWN_ARROW:
75940a10e1cSStephan Aßmus 		default:
76040a10e1cSStephan Aßmus 			tri1.Set(rect.left, rect.top);
76140a10e1cSStephan Aßmus 			tri2.Set((rect.left + rect.right + 1) / 2,
76240a10e1cSStephan Aßmus 				rect.top + rect.Height() / 1.33);
76340a10e1cSStephan Aßmus 			tri3.Set(rect.right + 1, rect.top);
76440a10e1cSStephan Aßmus 			break;
76540a10e1cSStephan Aßmus 	}
76640a10e1cSStephan Aßmus 	// offset triangle if down
767*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
76840a10e1cSStephan Aßmus 		view->MovePenTo(BPoint(1, 1));
76940a10e1cSStephan Aßmus 	else
77040a10e1cSStephan Aßmus 		view->MovePenTo(BPoint(0, 0));
77140a10e1cSStephan Aßmus 
77240a10e1cSStephan Aßmus 	BShape arrowShape;
77340a10e1cSStephan Aßmus 	arrowShape.MoveTo(tri1);
77440a10e1cSStephan Aßmus 	arrowShape.LineTo(tri2);
77540a10e1cSStephan Aßmus 	arrowShape.LineTo(tri3);
77640a10e1cSStephan Aßmus 
777*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
77840a10e1cSStephan Aßmus 		tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
77940a10e1cSStephan Aßmus 
78040a10e1cSStephan Aßmus 	view->SetHighColor(tint_color(base, tint));
78140a10e1cSStephan Aßmus 
78240a10e1cSStephan Aßmus 	float penSize = view->PenSize();
78340a10e1cSStephan Aßmus 	drawing_mode mode = view->DrawingMode();
78440a10e1cSStephan Aßmus 
78540a10e1cSStephan Aßmus 	view->SetPenSize(ceilf(hInset / 2.0));
78640a10e1cSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
78740a10e1cSStephan Aßmus 	view->StrokeShape(&arrowShape);
78840a10e1cSStephan Aßmus 
78940a10e1cSStephan Aßmus 	view->SetPenSize(penSize);
79040a10e1cSStephan Aßmus 	view->SetDrawingMode(mode);
79140a10e1cSStephan Aßmus }
79240a10e1cSStephan Aßmus 
79340a10e1cSStephan Aßmus 
7942f86ba45SStephan Aßmus rgb_color
7952f86ba45SStephan Aßmus BControlLook::SliderBarColor(const rgb_color& base)
7962f86ba45SStephan Aßmus {
7972f86ba45SStephan Aßmus 	return tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT);
7982f86ba45SStephan Aßmus }
7992f86ba45SStephan Aßmus 
8002f86ba45SStephan Aßmus 
8012f86ba45SStephan Aßmus void
8022f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
8032f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor,
8042f86ba45SStephan Aßmus 	float sliderScale, uint32 flags, enum orientation orientation)
8052f86ba45SStephan Aßmus {
8062f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
8072f86ba45SStephan Aßmus 		return;
8082f86ba45SStephan Aßmus 
8092f86ba45SStephan Aßmus 	// separate the bar in two sides
8102f86ba45SStephan Aßmus 	float sliderPosition;
8112f86ba45SStephan Aßmus 	BRect leftBarSide = rect;
8122f86ba45SStephan Aßmus 	BRect rightBarSide = rect;
8132f86ba45SStephan Aßmus 
8142f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8152f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.left + 2 + (rect.Width() - 2)
8162f86ba45SStephan Aßmus 			* sliderScale);
8172f86ba45SStephan Aßmus 		leftBarSide.right = sliderPosition - 1;
8182f86ba45SStephan Aßmus 		rightBarSide.left = sliderPosition;
8192f86ba45SStephan Aßmus 	} else {
820f3997b74SStephan Aßmus 		// NOTE: position is reverse of coords
8212f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
822f3997b74SStephan Aßmus 			* (1.0 - sliderScale));
823f3997b74SStephan Aßmus 		leftBarSide.top = sliderPosition;
824f3997b74SStephan Aßmus 		rightBarSide.bottom = sliderPosition - 1;
8252f86ba45SStephan Aßmus 	}
8262f86ba45SStephan Aßmus 
8272f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
8282f86ba45SStephan Aßmus 	BRegion region(rect);
8292f86ba45SStephan Aßmus 	region.Exclude(rightBarSide);
8302f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8312f86ba45SStephan Aßmus 
8322f86ba45SStephan Aßmus 	view->PushState();
8332f86ba45SStephan Aßmus 
8342f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
8352f86ba45SStephan Aßmus 		orientation);
8362f86ba45SStephan Aßmus 
8372f86ba45SStephan Aßmus 	view->PopState();
8382f86ba45SStephan Aßmus 
8392f86ba45SStephan Aßmus 	region.Set(rect);
8402f86ba45SStephan Aßmus 	region.Exclude(leftBarSide);
8412f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8422f86ba45SStephan Aßmus 
8432f86ba45SStephan Aßmus 	view->PushState();
8442f86ba45SStephan Aßmus 
8452f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
8462f86ba45SStephan Aßmus 		orientation);
8472f86ba45SStephan Aßmus 
8482f86ba45SStephan Aßmus 	view->PopState();
8492f86ba45SStephan Aßmus }
8502f86ba45SStephan Aßmus 
8512f86ba45SStephan Aßmus 
8522f86ba45SStephan Aßmus void
8532f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
8542f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color fillColor, uint32 flags,
8552f86ba45SStephan Aßmus 	enum orientation orientation)
8562f86ba45SStephan Aßmus {
8572f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
8582f86ba45SStephan Aßmus 		return;
8592f86ba45SStephan Aßmus 
8602f86ba45SStephan Aßmus 	// separate the rect into corners
8612f86ba45SStephan Aßmus 	BRect leftCorner(rect);
8622f86ba45SStephan Aßmus 	BRect rightCorner(rect);
8632f86ba45SStephan Aßmus 	BRect barRect(rect);
8642f86ba45SStephan Aßmus 
8652f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8662f86ba45SStephan Aßmus 		leftCorner.right = leftCorner.left + leftCorner.Height();
8672f86ba45SStephan Aßmus 		rightCorner.left = rightCorner.right - rightCorner.Height();
8682f86ba45SStephan Aßmus 		barRect.left += ceilf(barRect.Height() / 2);
8692f86ba45SStephan Aßmus 		barRect.right -= ceilf(barRect.Height() / 2);
8702f86ba45SStephan Aßmus 	} else {
8712f86ba45SStephan Aßmus 		leftCorner.bottom = leftCorner.top + leftCorner.Width();
8722f86ba45SStephan Aßmus 		rightCorner.top = rightCorner.bottom - rightCorner.Width();
8732f86ba45SStephan Aßmus 		barRect.top += ceilf(barRect.Width() / 2);
8742f86ba45SStephan Aßmus 		barRect.bottom -= ceilf(barRect.Width() / 2);
8752f86ba45SStephan Aßmus 	}
8762f86ba45SStephan Aßmus 
8772f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
8782f86ba45SStephan Aßmus 	BRegion region(rect);
8792f86ba45SStephan Aßmus 	region.Exclude(barRect);
8802f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8812f86ba45SStephan Aßmus 
88261ac1a85SStephan Aßmus 	if ((flags & B_BLEND_FRAME) == 0) {
8832f86ba45SStephan Aßmus 		view->SetHighColor(base);
8842f86ba45SStephan Aßmus 		view->FillRect(rect);
88561ac1a85SStephan Aßmus 	}
8862f86ba45SStephan Aßmus 
8872f86ba45SStephan Aßmus 	// figure out the tints to be used
8882f86ba45SStephan Aßmus 	float edgeLightTint;
8892f86ba45SStephan Aßmus 	float edgeShadowTint;
8902f86ba45SStephan Aßmus 	float frameLightTint;
8912f86ba45SStephan Aßmus 	float frameShadowTint;
8922f86ba45SStephan Aßmus 	float fillLightTint;
8932f86ba45SStephan Aßmus 	float fillShadowTint;
89461ac1a85SStephan Aßmus 	uint8 edgeLightAlpha;
89561ac1a85SStephan Aßmus 	uint8 edgeShadowAlpha;
89661ac1a85SStephan Aßmus 	uint8 frameLightAlpha;
89761ac1a85SStephan Aßmus 	uint8 frameShadowAlpha;
8982f86ba45SStephan Aßmus 
899*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
9002f86ba45SStephan Aßmus 		edgeLightTint = 1.0;
9012f86ba45SStephan Aßmus 		edgeShadowTint = 1.0;
9022f86ba45SStephan Aßmus 		frameLightTint = 1.20;
9032f86ba45SStephan Aßmus 		frameShadowTint = 1.25;
9042f86ba45SStephan Aßmus 		fillLightTint = 0.9;
9052f86ba45SStephan Aßmus 		fillShadowTint = 1.05;
90610ddee8dSStephan Aßmus 		edgeLightAlpha = 12;
90710ddee8dSStephan Aßmus 		edgeShadowAlpha = 12;
90861ac1a85SStephan Aßmus 		frameLightAlpha = 40;
90961ac1a85SStephan Aßmus 		frameShadowAlpha = 45;
9102f86ba45SStephan Aßmus 
9112f86ba45SStephan Aßmus 		fillColor.red = uint8(fillColor.red * 0.4 + base.red * 0.6);
9122f86ba45SStephan Aßmus 		fillColor.green = uint8(fillColor.green * 0.4 + base.green * 0.6);
9132f86ba45SStephan Aßmus 		fillColor.blue = uint8(fillColor.blue * 0.4 + base.blue * 0.6);
9142f86ba45SStephan Aßmus 	} else {
9152f86ba45SStephan Aßmus 		edgeLightTint = 0.65;
9162f86ba45SStephan Aßmus 		edgeShadowTint = 1.07;
9172f86ba45SStephan Aßmus 		frameLightTint = 1.40;
9182f86ba45SStephan Aßmus 		frameShadowTint = 1.50;
9192f86ba45SStephan Aßmus 		fillLightTint = 0.8;
9202f86ba45SStephan Aßmus 		fillShadowTint = 1.1;
92110ddee8dSStephan Aßmus 		edgeLightAlpha = 15;
92210ddee8dSStephan Aßmus 		edgeShadowAlpha = 15;
92361ac1a85SStephan Aßmus 		frameLightAlpha = 92;
92461ac1a85SStephan Aßmus 		frameShadowAlpha = 107;
9252f86ba45SStephan Aßmus 	}
9262f86ba45SStephan Aßmus 
92761ac1a85SStephan Aßmus 	rgb_color edgeLightColor;
92861ac1a85SStephan Aßmus 	rgb_color edgeShadowColor;
92961ac1a85SStephan Aßmus 	rgb_color frameLightColor;
93061ac1a85SStephan Aßmus 	rgb_color frameShadowColor;
9312f86ba45SStephan Aßmus 	rgb_color fillLightColor = tint_color(fillColor, fillLightTint);
9322f86ba45SStephan Aßmus 	rgb_color fillShadowColor = tint_color(fillColor, fillShadowTint);
9332f86ba45SStephan Aßmus 
93461ac1a85SStephan Aßmus 	drawing_mode oldMode = view->DrawingMode();
93561ac1a85SStephan Aßmus 
936*a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
93761ac1a85SStephan Aßmus 		edgeLightColor = (rgb_color){ 255, 255, 255, edgeLightAlpha };
93861ac1a85SStephan Aßmus 		edgeShadowColor = (rgb_color){ 0, 0, 0, edgeShadowAlpha };
93961ac1a85SStephan Aßmus 		frameLightColor = (rgb_color){ 0, 0, 0, frameLightAlpha };
94061ac1a85SStephan Aßmus 		frameShadowColor = (rgb_color){ 0, 0, 0, frameShadowAlpha };
94161ac1a85SStephan Aßmus 
94261ac1a85SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
94361ac1a85SStephan Aßmus 	} else {
94461ac1a85SStephan Aßmus 		edgeLightColor = tint_color(base, edgeLightTint);
94561ac1a85SStephan Aßmus 		edgeShadowColor = tint_color(base, edgeShadowTint);
94661ac1a85SStephan Aßmus 		frameLightColor = tint_color(fillColor, frameLightTint);
94761ac1a85SStephan Aßmus 		frameShadowColor = tint_color(fillColor, frameShadowTint);
94861ac1a85SStephan Aßmus 	}
94961ac1a85SStephan Aßmus 
9502f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
9512f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
9522f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9532f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
9542f86ba45SStephan Aßmus 
9552f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
9562f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9572f86ba45SStephan Aßmus 			fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
9582f86ba45SStephan Aßmus 	} else {
9592f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
9602f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9612f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
9622f86ba45SStephan Aßmus 
9632f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
9642f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9652f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
9662f86ba45SStephan Aßmus 	}
9672f86ba45SStephan Aßmus 
9682f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(NULL);
9692f86ba45SStephan Aßmus 
9702f86ba45SStephan Aßmus 	view->BeginLineArray(4);
9712f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
9722f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), edgeShadowColor);
9732f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
9742f86ba45SStephan Aßmus 			edgeLightColor);
9752f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
9762f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), frameShadowColor);
9772f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
9782f86ba45SStephan Aßmus 			frameLightColor);
9792f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
9802f86ba45SStephan Aßmus 	} else {
9812f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), edgeShadowColor);
9822f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
9832f86ba45SStephan Aßmus 			edgeLightColor);
9842f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
9852f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), frameShadowColor);
9862f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
9872f86ba45SStephan Aßmus 			frameLightColor);
9882f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
9892f86ba45SStephan Aßmus 	}
9902f86ba45SStephan Aßmus 	view->EndLineArray();
9912f86ba45SStephan Aßmus 
99261ac1a85SStephan Aßmus 	view->SetDrawingMode(oldMode);
99361ac1a85SStephan Aßmus 
9942f86ba45SStephan Aßmus 	_FillGradient(view, barRect, fillColor, fillShadowTint, fillLightTint,
9952f86ba45SStephan Aßmus 		orientation);
9962f86ba45SStephan Aßmus }
9972f86ba45SStephan Aßmus 
9982f86ba45SStephan Aßmus 
9992f86ba45SStephan Aßmus void
10002f86ba45SStephan Aßmus BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
10012f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, enum orientation orientation)
10022f86ba45SStephan Aßmus {
10032f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
10042f86ba45SStephan Aßmus 		return;
10052f86ba45SStephan Aßmus 
10062f86ba45SStephan Aßmus 	// figure out frame color
10072f86ba45SStephan Aßmus 	rgb_color frameLightColor;
10082f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
10092f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
10102f86ba45SStephan Aßmus 
1011*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
10122f86ba45SStephan Aßmus 		// focused
10132f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
10142f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
10152f86ba45SStephan Aßmus 	} else {
10162f86ba45SStephan Aßmus 		// figure out the tints to be used
10172f86ba45SStephan Aßmus 		float frameLightTint;
10182f86ba45SStephan Aßmus 		float frameShadowTint;
10192f86ba45SStephan Aßmus 
1020*a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
10212f86ba45SStephan Aßmus 			frameLightTint = 1.30;
10222f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
10232f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
10242f86ba45SStephan Aßmus 		} else {
10252f86ba45SStephan Aßmus 			frameLightTint = 1.6;
10262f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
10272f86ba45SStephan Aßmus 		}
10282f86ba45SStephan Aßmus 
10292f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
10302f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
10312f86ba45SStephan Aßmus 	}
10322f86ba45SStephan Aßmus 
10332f86ba45SStephan Aßmus 	BRect originalRect(rect);
10342f86ba45SStephan Aßmus 	rect.right--;
10352f86ba45SStephan Aßmus 	rect.bottom--;
10362f86ba45SStephan Aßmus 
10372f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor,
10382f86ba45SStephan Aßmus 		frameShadowColor, frameShadowColor);
10392f86ba45SStephan Aßmus 
10402f86ba45SStephan Aßmus 	flags &= ~B_ACTIVATED;
10412f86ba45SStephan Aßmus 	DrawButtonBackground(view, rect, updateRect, base, flags);
10422f86ba45SStephan Aßmus 
10432f86ba45SStephan Aßmus 	// thumb shadow
10442f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
10452f86ba45SStephan Aßmus 	view->SetHighColor(shadowColor);
10462f86ba45SStephan Aßmus 	originalRect.left++;
10472f86ba45SStephan Aßmus 	originalRect.top++;
10482f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.LeftBottom(), originalRect.RightBottom());
10492f86ba45SStephan Aßmus 	originalRect.bottom--;
10502f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.RightTop(), originalRect.RightBottom());
10512f86ba45SStephan Aßmus 
10522f86ba45SStephan Aßmus 	// thumb edge
10532f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
10542f86ba45SStephan Aßmus 		rect.InsetBy(0, floorf(rect.Height() / 4));
10552f86ba45SStephan Aßmus 		rect.left = floorf((rect.left + rect.right) / 2);
10562f86ba45SStephan Aßmus 		rect.right = rect.left + 1;
10572f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
10582f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
10592f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
10602f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
10612f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
10622f86ba45SStephan Aßmus 		lightColor.alpha = 128;
10632f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
10642f86ba45SStephan Aßmus 		view->StrokeLine(rect.RightTop(), rect.RightBottom());
10652f86ba45SStephan Aßmus 	} else {
10662f86ba45SStephan Aßmus 		rect.InsetBy(floorf(rect.Width() / 4), 0);
10672f86ba45SStephan Aßmus 		rect.top = floorf((rect.top + rect.bottom) / 2);
10682f86ba45SStephan Aßmus 		rect.bottom = rect.top + 1;
10692f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
10702f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
10712f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
10722f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightTop());
10732f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
10742f86ba45SStephan Aßmus 		lightColor.alpha = 128;
10752f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
10762f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
10772f86ba45SStephan Aßmus 	}
10782f86ba45SStephan Aßmus 
10792f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
10802f86ba45SStephan Aßmus }
10812f86ba45SStephan Aßmus 
10822f86ba45SStephan Aßmus 
10832f86ba45SStephan Aßmus void
10842f86ba45SStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
10852f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
10862f86ba45SStephan Aßmus 	enum orientation orientation)
10872f86ba45SStephan Aßmus {
10888ee9217eSStephan Aßmus 	DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation);
10898ee9217eSStephan Aßmus }
10908ee9217eSStephan Aßmus 
10918ee9217eSStephan Aßmus 
10928ee9217eSStephan Aßmus void
10938ee9217eSStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
10948ee9217eSStephan Aßmus 	const BRect& updateRect, const rgb_color& base, const rgb_color& fill,
10958ee9217eSStephan Aßmus 	uint32 flags, enum orientation orientation)
10968ee9217eSStephan Aßmus {
10972f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
10982f86ba45SStephan Aßmus 		return;
10992f86ba45SStephan Aßmus 
11002f86ba45SStephan Aßmus 	// figure out frame color
11012f86ba45SStephan Aßmus 	rgb_color frameLightColor;
11022f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
11032f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
11042f86ba45SStephan Aßmus 
11052f86ba45SStephan Aßmus 	float topTint = 0.49;
11062f86ba45SStephan Aßmus 	float middleTint1 = 0.62;
11072f86ba45SStephan Aßmus 	float middleTint2 = 0.76;
11082f86ba45SStephan Aßmus 	float bottomTint = 0.90;
11092f86ba45SStephan Aßmus 
1110*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
11112f86ba45SStephan Aßmus 		topTint = (topTint + B_NO_TINT) / 2;
11122f86ba45SStephan Aßmus 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
11132f86ba45SStephan Aßmus 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
11142f86ba45SStephan Aßmus 		bottomTint = (bottomTint + B_NO_TINT) / 2;
1115*a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
11162f86ba45SStephan Aßmus 		static const float kHoverTintFactor = 0.85;
11172f86ba45SStephan Aßmus 		topTint *= kHoverTintFactor;
11182f86ba45SStephan Aßmus 		middleTint1 *= kHoverTintFactor;
11192f86ba45SStephan Aßmus 		middleTint2 *= kHoverTintFactor;
11202f86ba45SStephan Aßmus 		bottomTint *= kHoverTintFactor;
11212f86ba45SStephan Aßmus 	}
11222f86ba45SStephan Aßmus 
1123*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
11242f86ba45SStephan Aßmus 		// focused
11252f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
11262f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
11272f86ba45SStephan Aßmus 	} else {
11282f86ba45SStephan Aßmus 		// figure out the tints to be used
11292f86ba45SStephan Aßmus 		float frameLightTint;
11302f86ba45SStephan Aßmus 		float frameShadowTint;
11312f86ba45SStephan Aßmus 
1132*a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
11332f86ba45SStephan Aßmus 			frameLightTint = 1.30;
11342f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
11352f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
11362f86ba45SStephan Aßmus 		} else {
11372f86ba45SStephan Aßmus 			frameLightTint = 1.6;
11382f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
11392f86ba45SStephan Aßmus 		}
11402f86ba45SStephan Aßmus 
11412f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
11422f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
11432f86ba45SStephan Aßmus 	}
11442f86ba45SStephan Aßmus 
11458ee9217eSStephan Aßmus 	// make room for the shadow
11468ee9217eSStephan Aßmus 	rect.right--;
11478ee9217eSStephan Aßmus 	rect.bottom--;
11482f86ba45SStephan Aßmus 
11492f86ba45SStephan Aßmus 	uint32 viewFlags = view->Flags();
11502f86ba45SStephan Aßmus 	view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
11512f86ba45SStephan Aßmus 	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
11522f86ba45SStephan Aßmus 
1153f3997b74SStephan Aßmus 	float centerh = (rect.left + rect.right) / 2;
1154f3997b74SStephan Aßmus 	float centerv = (rect.top + rect.bottom) / 2;
11552f86ba45SStephan Aßmus 
11568ee9217eSStephan Aßmus 	BShape shape;
1157f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
11588ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
11598ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
11608ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
1161f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5));
11628ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
1163f3997b74SStephan Aßmus 	} else {
1164f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5));
1165f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
1166f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5));
1167f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, centerv + 0.5));
1168f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5));
1169f3997b74SStephan Aßmus 	}
11708ee9217eSStephan Aßmus 	shape.Close();
11718ee9217eSStephan Aßmus 
11728ee9217eSStephan Aßmus 	view->MovePenTo(BPoint(1, 1));
11738ee9217eSStephan Aßmus 
11748ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
11758ee9217eSStephan Aßmus 	view->SetHighColor(shadowColor);
11768ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
11778ee9217eSStephan Aßmus 
11788ee9217eSStephan Aßmus 	view->MovePenTo(B_ORIGIN);
11798ee9217eSStephan Aßmus 
11808ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
11812f86ba45SStephan Aßmus 	view->SetHighColor(frameLightColor);
11828ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
11832f86ba45SStephan Aßmus 
11842f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
11858ee9217eSStephan Aßmus 	shape.Clear();
1186f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
11878ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
11888ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1189f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top));
1190f3997b74SStephan Aßmus 	} else {
1191f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 1, rect.top));
1192f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1193f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left, centerv + 0.5));
1194f3997b74SStephan Aßmus 	}
11958ee9217eSStephan Aßmus 	shape.Close();
11962f86ba45SStephan Aßmus 
11972f86ba45SStephan Aßmus 	BGradientLinear gradient;
1198*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
11998ee9217eSStephan Aßmus 		_MakeGradient(gradient, rect, fill, topTint, bottomTint);
12002f86ba45SStephan Aßmus 	} else {
12018ee9217eSStephan Aßmus 		_MakeGlossyGradient(gradient, rect, fill, topTint, middleTint1,
12022f86ba45SStephan Aßmus 			middleTint2, bottomTint);
12032f86ba45SStephan Aßmus 	}
12042f86ba45SStephan Aßmus 
12058ee9217eSStephan Aßmus 	view->FillShape(&shape, gradient);
12062f86ba45SStephan Aßmus 
12072f86ba45SStephan Aßmus 	view->SetFlags(viewFlags);
12082f86ba45SStephan Aßmus }
12092f86ba45SStephan Aßmus 
12102f86ba45SStephan Aßmus 
12112f86ba45SStephan Aßmus void
12122f86ba45SStephan Aßmus BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
12132f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, int32 count,
12142f86ba45SStephan Aßmus 	hash_mark_location location, uint32 flags, enum orientation orientation)
12152f86ba45SStephan Aßmus {
12162f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
12172f86ba45SStephan Aßmus 		return;
12182f86ba45SStephan Aßmus 
12192f86ba45SStephan Aßmus 	rgb_color lightColor;
12202f86ba45SStephan Aßmus 	rgb_color darkColor;
12212f86ba45SStephan Aßmus 
1222*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12232f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.9);
12242f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.07);
12252f86ba45SStephan Aßmus 	} else {
12262f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.8);
12272f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.14);
12282f86ba45SStephan Aßmus 	}
12292f86ba45SStephan Aßmus 
12302f86ba45SStephan Aßmus 	int32 hashMarkCount = max_c(count, 2);
12312f86ba45SStephan Aßmus 		// draw at least two hashmarks at min/max if
12322f86ba45SStephan Aßmus 		// fHashMarks != B_HASH_MARKS_NONE
12332f86ba45SStephan Aßmus 	float factor;
12342f86ba45SStephan Aßmus 	float startPos;
12352f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12362f86ba45SStephan Aßmus 		factor = (rect.Width() - 2) / (hashMarkCount - 1);
12372f86ba45SStephan Aßmus 		startPos = rect.left + 1;
12382f86ba45SStephan Aßmus 	} else {
12392f86ba45SStephan Aßmus 		factor = (rect.Height() - 2) / (hashMarkCount - 1);
12402f86ba45SStephan Aßmus 		startPos = rect.top + 1;
12412f86ba45SStephan Aßmus 	}
12422f86ba45SStephan Aßmus 
12432f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_TOP) {
12442f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
12452f86ba45SStephan Aßmus 
12462f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
12472f86ba45SStephan Aßmus 			float pos = startPos;
12482f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12492f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.top),
12502f86ba45SStephan Aßmus 							  BPoint(pos, rect.top + 4), darkColor);
12512f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.top),
12522f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.top + 4), lightColor);
12532f86ba45SStephan Aßmus 
12542f86ba45SStephan Aßmus 				pos += factor;
12552f86ba45SStephan Aßmus 			}
12562f86ba45SStephan Aßmus 		} else {
12572f86ba45SStephan Aßmus 			float pos = startPos;
12582f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12592f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos),
12602f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos), darkColor);
12612f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos + 1),
12622f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos + 1), lightColor);
12632f86ba45SStephan Aßmus 
12642f86ba45SStephan Aßmus 				pos += factor;
12652f86ba45SStephan Aßmus 			}
12662f86ba45SStephan Aßmus 		}
12672f86ba45SStephan Aßmus 
12682f86ba45SStephan Aßmus 		view->EndLineArray();
12692f86ba45SStephan Aßmus 	}
12702f86ba45SStephan Aßmus 
12712f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_BOTTOM) {
12722f86ba45SStephan Aßmus 
12732f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
12742f86ba45SStephan Aßmus 
12752f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
12762f86ba45SStephan Aßmus 			float pos = startPos;
12772f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12782f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.bottom - 4),
12792f86ba45SStephan Aßmus 							  BPoint(pos, rect.bottom), darkColor);
12802f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.bottom - 4),
12812f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.bottom), lightColor);
12822f86ba45SStephan Aßmus 
12832f86ba45SStephan Aßmus 				pos += factor;
12842f86ba45SStephan Aßmus 			}
12852f86ba45SStephan Aßmus 		} else {
12862f86ba45SStephan Aßmus 			float pos = startPos;
12872f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12882f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos),
12892f86ba45SStephan Aßmus 							  BPoint(rect.right, pos), darkColor);
12902f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos + 1),
12912f86ba45SStephan Aßmus 							  BPoint(rect.right, pos + 1), lightColor);
12922f86ba45SStephan Aßmus 
12932f86ba45SStephan Aßmus 				pos += factor;
12942f86ba45SStephan Aßmus 			}
12952f86ba45SStephan Aßmus 		}
12962f86ba45SStephan Aßmus 
12972f86ba45SStephan Aßmus 		view->EndLineArray();
12982f86ba45SStephan Aßmus 	}
12992f86ba45SStephan Aßmus }
13002f86ba45SStephan Aßmus 
13012f86ba45SStephan Aßmus 
13022f86ba45SStephan Aßmus void
13032f86ba45SStephan Aßmus BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
13042f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
13052f86ba45SStephan Aßmus {
13062f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
13072f86ba45SStephan Aßmus 		return;
13082f86ba45SStephan Aßmus 
1309*a884b43bSJohn Scipione 	// clipping constraints for the view
1310*a884b43bSJohn Scipione 	BRegion clipping;
1311*a884b43bSJohn Scipione 	view->GetClippingRegion(&clipping);
1312*a884b43bSJohn Scipione 
1313*a884b43bSJohn Scipione 	// intersect constraints with updateRect
1314*a884b43bSJohn Scipione 	BRegion updateClipping(updateRect);
1315*a884b43bSJohn Scipione 	clipping.IntersectWith(&updateClipping);
1316*a884b43bSJohn Scipione 
1317*a884b43bSJohn Scipione 	// clip to the intersection
1318*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
1319*a884b43bSJohn Scipione 
13202f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
13212f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
13222f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
13232f86ba45SStephan Aßmus 	rgb_color frameLightColor;
13242f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
13252f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
13262f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
13272f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
13282f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
13292f86ba45SStephan Aßmus 
1330*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
13312f86ba45SStephan Aßmus 		edgeLightColor = base;
1332*a884b43bSJohn Scipione 		edgeShadowColor = base;
13332f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1334*a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13352f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1336*a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13372f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
13382f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
13392f86ba45SStephan Aßmus 	} else {
13402f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1341*a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
13422f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1343*a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13442f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.6);
1345*a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13462f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.75), 0);
13472f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.03), 255);
13482f86ba45SStephan Aßmus 	}
134912ea5a2cSStephan Aßmus 
1350*a884b43bSJohn Scipione 	static const float kRoundCornerRadius = 4.0f;
13512f86ba45SStephan Aßmus 
1352*a884b43bSJohn Scipione 	// left top corner dimensions
1353*a884b43bSJohn Scipione 	BRect leftTopCorner(rect);
1354*a884b43bSJohn Scipione 	leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
1355*a884b43bSJohn Scipione 	leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1356*a884b43bSJohn Scipione 	clipping.Exclude(leftTopCorner);
13572f86ba45SStephan Aßmus 
1358*a884b43bSJohn Scipione 	// draw the left top corner
1359*a884b43bSJohn Scipione 	_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
1360*a884b43bSJohn Scipione 		edgeShadowColor, frameLightColor, bevelLightColor,
1361*a884b43bSJohn Scipione 		fillGradient);
13622f86ba45SStephan Aßmus 
1363*a884b43bSJohn Scipione 	// right top corner dimensions
1364*a884b43bSJohn Scipione 	BRect rightTopCorner(rect);
1365*a884b43bSJohn Scipione 	rightTopCorner.right = floorf(rect.right);
1366*a884b43bSJohn Scipione 	rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
1367*a884b43bSJohn Scipione 	rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1368*a884b43bSJohn Scipione 	clipping.Exclude(rightTopCorner);
13692f86ba45SStephan Aßmus 
1370*a884b43bSJohn Scipione 	// draw the right top corner
1371*a884b43bSJohn Scipione 	_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
1372*a884b43bSJohn Scipione 		edgeShadowColor, edgeLightColor, frameLightColor,
1373*a884b43bSJohn Scipione 		frameShadowColor, bevelLightColor, bevelShadowColor,
1374*a884b43bSJohn Scipione 		fillGradient);
13752f86ba45SStephan Aßmus 
1376*a884b43bSJohn Scipione 	// clip out the corners
13772f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&clipping);
13782f86ba45SStephan Aßmus 
1379*a884b43bSJohn Scipione 	// draw the rest of frame and fill
13802f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
13812f86ba45SStephan Aßmus 		edgeLightColor,
13822f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
13832f86ba45SStephan Aßmus 	if ((borders & B_LEFT_BORDER) == 0)
13842f86ba45SStephan Aßmus 		rect.left++;
13852f86ba45SStephan Aßmus 	if ((borders & B_RIGHT_BORDER) == 0)
13862f86ba45SStephan Aßmus 		rect.right--;
13872f86ba45SStephan Aßmus 
13882f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
13892f86ba45SStephan Aßmus 		frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
13902f86ba45SStephan Aßmus 
13912f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
13922f86ba45SStephan Aßmus 		bevelShadowColor);
13932f86ba45SStephan Aßmus 
13942f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
13952f86ba45SStephan Aßmus 
1396*a884b43bSJohn Scipione 	// reset clipping constraints
13972f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(NULL);
13982f86ba45SStephan Aßmus }
13992f86ba45SStephan Aßmus 
14002f86ba45SStephan Aßmus 
14012f86ba45SStephan Aßmus void
140283aff015SPhilippe Houdoin BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
14032f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
14042f86ba45SStephan Aßmus {
14052f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
14062f86ba45SStephan Aßmus 		return;
14072f86ba45SStephan Aßmus 
14082f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
14092f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
14102f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
14112f86ba45SStephan Aßmus 	rgb_color frameLightColor;
14122f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
14132f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
14142f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
14152f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
14162f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
14172f86ba45SStephan Aßmus 
1418*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
14192f86ba45SStephan Aßmus 		edgeLightColor = base;
1420*a884b43bSJohn Scipione 		edgeShadowColor = base;
14212f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1422*a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14232f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1424*a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
14252f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
14262f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
14272f86ba45SStephan Aßmus 	} else {
14282f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1429*a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
14302f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1431*a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14322f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 1.10);
1433*a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.17);
14342f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.12), 0);
14352f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.08), 255);
14362f86ba45SStephan Aßmus 	}
14372f86ba45SStephan Aßmus 
14382f86ba45SStephan Aßmus 	// active tabs stand out at the top, but this is an inactive tab
14392f86ba45SStephan Aßmus 	view->SetHighColor(base);
14402f86ba45SStephan Aßmus 	view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
14412f86ba45SStephan Aßmus 	rect.top += 4;
14422f86ba45SStephan Aßmus 
14432f86ba45SStephan Aßmus 	// frame and fill
14442f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
14452f86ba45SStephan Aßmus 		edgeLightColor,
14462f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14472f86ba45SStephan Aßmus 
14482f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
14492f86ba45SStephan Aßmus 		frameShadowColor,
14502f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14512f86ba45SStephan Aßmus 
1452b3601d82SStephan Aßmus 	if (rect.IsValid()) {
1453b3601d82SStephan Aßmus 		_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
1454b3601d82SStephan Aßmus 			bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
1455b3601d82SStephan Aßmus 	} else {
1456b3601d82SStephan Aßmus 		if ((B_LEFT_BORDER & ~borders) != 0)
1457b3601d82SStephan Aßmus 			rect.left++;
1458b3601d82SStephan Aßmus 	}
14592f86ba45SStephan Aßmus 
14602f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
14612f86ba45SStephan Aßmus }
14622f86ba45SStephan Aßmus 
14632f86ba45SStephan Aßmus 
14641f9fd6d8SStephan Aßmus void
14651f9fd6d8SStephan Aßmus BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
14661f9fd6d8SStephan Aßmus 	const rgb_color& base, enum orientation orientation, uint32 flags,
14671f9fd6d8SStephan Aßmus 	uint32 borders)
14681f9fd6d8SStephan Aßmus {
1469*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1470*a884b43bSJohn Scipione 		return;
1471*a884b43bSJohn Scipione 
14721f9fd6d8SStephan Aßmus 	rgb_color background;
14731f9fd6d8SStephan Aßmus 	if ((flags & (B_CLICKED | B_ACTIVATED)) != 0)
14741f9fd6d8SStephan Aßmus 		background = tint_color(base, B_DARKEN_1_TINT);
14751f9fd6d8SStephan Aßmus 	else
14761f9fd6d8SStephan Aßmus 		background = base;
14771f9fd6d8SStephan Aßmus 
14781f9fd6d8SStephan Aßmus 	rgb_color light = tint_color(background, 0.6);
14791f9fd6d8SStephan Aßmus 	rgb_color shadow = tint_color(background, 1.21);
14801f9fd6d8SStephan Aßmus 
14811f9fd6d8SStephan Aßmus 	// frame
14821f9fd6d8SStephan Aßmus 	if (borders != 0 && rect.Width() > 3 && rect.Height() > 3)
14831f9fd6d8SStephan Aßmus 		DrawRaisedBorder(view, rect, updateRect, background, flags, borders);
14841f9fd6d8SStephan Aßmus 
14851f9fd6d8SStephan Aßmus 	// dots and rest of background
14861f9fd6d8SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
14871f9fd6d8SStephan Aßmus 		if (rect.Width() > 2) {
14881f9fd6d8SStephan Aßmus 			// background on left/right
14891f9fd6d8SStephan Aßmus 			BRegion region(rect);
14901f9fd6d8SStephan Aßmus 			rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5);
14911f9fd6d8SStephan Aßmus 			rect.right = rect.left + 1;
14921f9fd6d8SStephan Aßmus 			region.Exclude(rect);
14931f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
14941f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
14951f9fd6d8SStephan Aßmus 		}
14961f9fd6d8SStephan Aßmus 
14971f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
14981f9fd6d8SStephan Aßmus 		BPoint stop = rect.LeftBottom();
14991f9fd6d8SStephan Aßmus 		int32 num = 1;
15001f9fd6d8SStephan Aßmus 		while (dot.y <= stop.y) {
15011f9fd6d8SStephan Aßmus 			rgb_color col1;
15021f9fd6d8SStephan Aßmus 			rgb_color col2;
15031f9fd6d8SStephan Aßmus 			switch (num) {
15041f9fd6d8SStephan Aßmus 				case 1:
15051f9fd6d8SStephan Aßmus 					col1 = background;
15061f9fd6d8SStephan Aßmus 					col2 = background;
15071f9fd6d8SStephan Aßmus 					break;
15081f9fd6d8SStephan Aßmus 				case 2:
15091f9fd6d8SStephan Aßmus 					col1 = shadow;
15101f9fd6d8SStephan Aßmus 					col2 = background;
15111f9fd6d8SStephan Aßmus 					break;
15121f9fd6d8SStephan Aßmus 				case 3:
1513a5339f65SStephan Aßmus 				default:
15141f9fd6d8SStephan Aßmus 					col1 = background;
15151f9fd6d8SStephan Aßmus 					col2 = light;
15161f9fd6d8SStephan Aßmus 					num = 0;
15171f9fd6d8SStephan Aßmus 					break;
15181f9fd6d8SStephan Aßmus 			}
15191f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15201f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15211f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15221f9fd6d8SStephan Aßmus 			dot.x++;
15231f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15241f9fd6d8SStephan Aßmus 			dot.x -= 1.0;
15251f9fd6d8SStephan Aßmus 			// next pixel
15261f9fd6d8SStephan Aßmus 			num++;
15271f9fd6d8SStephan Aßmus 			dot.y++;
15281f9fd6d8SStephan Aßmus 		}
15291f9fd6d8SStephan Aßmus 	} else {
15301f9fd6d8SStephan Aßmus 		if (rect.Height() > 2) {
15311f9fd6d8SStephan Aßmus 			// background on left/right
15321f9fd6d8SStephan Aßmus 			BRegion region(rect);
15331f9fd6d8SStephan Aßmus 			rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5);
15341f9fd6d8SStephan Aßmus 			rect.bottom = rect.top + 1;
15351f9fd6d8SStephan Aßmus 			region.Exclude(rect);
15361f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
15371f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
15381f9fd6d8SStephan Aßmus 		}
15391f9fd6d8SStephan Aßmus 
15401f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15411f9fd6d8SStephan Aßmus 		BPoint stop = rect.RightTop();
15421f9fd6d8SStephan Aßmus 		int32 num = 1;
15431f9fd6d8SStephan Aßmus 		while (dot.x <= stop.x) {
15441f9fd6d8SStephan Aßmus 			rgb_color col1;
15451f9fd6d8SStephan Aßmus 			rgb_color col2;
15461f9fd6d8SStephan Aßmus 			switch (num) {
15471f9fd6d8SStephan Aßmus 				case 1:
15481f9fd6d8SStephan Aßmus 					col1 = background;
15491f9fd6d8SStephan Aßmus 					col2 = background;
15501f9fd6d8SStephan Aßmus 					break;
15511f9fd6d8SStephan Aßmus 				case 2:
15521f9fd6d8SStephan Aßmus 					col1 = shadow;
15531f9fd6d8SStephan Aßmus 					col2 = background;
15541f9fd6d8SStephan Aßmus 					break;
15551f9fd6d8SStephan Aßmus 				case 3:
15569f981a88SFrançois Revol 				default:
15571f9fd6d8SStephan Aßmus 					col1 = background;
15581f9fd6d8SStephan Aßmus 					col2 = light;
15591f9fd6d8SStephan Aßmus 					num = 0;
15601f9fd6d8SStephan Aßmus 					break;
15611f9fd6d8SStephan Aßmus 			}
15621f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15631f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15641f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15651f9fd6d8SStephan Aßmus 			dot.y++;
15661f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15671f9fd6d8SStephan Aßmus 			dot.y -= 1.0;
15681f9fd6d8SStephan Aßmus 			// next pixel
15691f9fd6d8SStephan Aßmus 			num++;
15701f9fd6d8SStephan Aßmus 			dot.x++;
15711f9fd6d8SStephan Aßmus 		}
15721f9fd6d8SStephan Aßmus 	}
15731f9fd6d8SStephan Aßmus }
15741f9fd6d8SStephan Aßmus 
15751f9fd6d8SStephan Aßmus 
15762f86ba45SStephan Aßmus // #pragma mark -
15772f86ba45SStephan Aßmus 
15782f86ba45SStephan Aßmus 
15792f86ba45SStephan Aßmus void
15802f86ba45SStephan Aßmus BControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
15812f86ba45SStephan Aßmus 	const rgb_color& base, border_style border, uint32 flags, uint32 borders)
15822f86ba45SStephan Aßmus {
15832f86ba45SStephan Aßmus 	if (border == B_NO_BORDER)
15842f86ba45SStephan Aßmus 		return;
15852f86ba45SStephan Aßmus 
15862f86ba45SStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
1587*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
15882f86ba45SStephan Aßmus 		scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
15892f86ba45SStephan Aßmus 
15902f86ba45SStephan Aßmus 	if (border == B_FANCY_BORDER)
15914f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
15922f86ba45SStephan Aßmus 
15932f86ba45SStephan Aßmus 	_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
15942f86ba45SStephan Aßmus 		scrollbarFrameColor, scrollbarFrameColor, borders);
15952f86ba45SStephan Aßmus }
15962f86ba45SStephan Aßmus 
15972f86ba45SStephan Aßmus 
15982f86ba45SStephan Aßmus void
15992f86ba45SStephan Aßmus BControlLook::DrawRaisedBorder(BView* view, BRect& rect,
16002f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16012f86ba45SStephan Aßmus 	uint32 borders)
16022f86ba45SStephan Aßmus {
16032f86ba45SStephan Aßmus 	rgb_color lightColor;
16042f86ba45SStephan Aßmus 	rgb_color shadowColor;
16052f86ba45SStephan Aßmus 
1606*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16072f86ba45SStephan Aßmus 		lightColor = base;
16082f86ba45SStephan Aßmus 		shadowColor = base;
16092f86ba45SStephan Aßmus 	} else {
16102f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.85);
16112f86ba45SStephan Aßmus 		shadowColor = tint_color(base, 1.07);
16122f86ba45SStephan Aßmus 	}
16132f86ba45SStephan Aßmus 
16142f86ba45SStephan Aßmus 	_DrawFrame(view, rect, lightColor, lightColor, shadowColor, shadowColor,
16152f86ba45SStephan Aßmus 		borders);
16162f86ba45SStephan Aßmus }
16172f86ba45SStephan Aßmus 
16182f86ba45SStephan Aßmus 
16192f86ba45SStephan Aßmus void
16202f86ba45SStephan Aßmus BControlLook::DrawTextControlBorder(BView* view, BRect& rect,
16212f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16222f86ba45SStephan Aßmus 	uint32 borders)
16232f86ba45SStephan Aßmus {
16242f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
16252f86ba45SStephan Aßmus 		return;
16262f86ba45SStephan Aßmus 
16272f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
16282f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
16292f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
16302f86ba45SStephan Aßmus 
1631*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16324f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags, borders);
16332f86ba45SStephan Aßmus 
1634*a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
16354f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 40 };
16364f579098SStephan Aßmus 		else
16372f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.15);
16384f579098SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
1639*a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
16402f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
16412f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.49);
16422f86ba45SStephan Aßmus 
16434f579098SStephan Aßmus 		// BCheckBox uses this to indicate the clicked state...
16442f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
16452f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16462f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
16472f86ba45SStephan Aßmus 
16482f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
16492f86ba45SStephan Aßmus 	} else {
16504f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags, borders);
16512f86ba45SStephan Aßmus 
1652*a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
16534f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 102 };
16544f579098SStephan Aßmus 			dark2BorderColor = (rgb_color){ 0, 0, 0, 97 };
16554f579098SStephan Aßmus 		} else {
16562f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.40);
16572f86ba45SStephan Aßmus 			dark2BorderColor = tint_color(base, 1.38);
16582f86ba45SStephan Aßmus 		}
16594f579098SStephan Aßmus 	}
16602f86ba45SStephan Aßmus 
1661*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) == 0 && (flags & B_FOCUSED) != 0) {
16622f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
16632f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
16642f86ba45SStephan Aßmus 	}
16652f86ba45SStephan Aßmus 
1666*a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
16674f579098SStephan Aßmus 		drawing_mode oldMode = view->DrawingMode();
16684f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
16694f579098SStephan Aßmus 
16702f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
16712f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16722f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
16734f579098SStephan Aßmus 
16744f579098SStephan Aßmus 		view->SetDrawingMode(oldMode);
16754f579098SStephan Aßmus 	} else {
16764f579098SStephan Aßmus 		_DrawFrame(view, rect,
16774f579098SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16784f579098SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
16794f579098SStephan Aßmus 	}
16802f86ba45SStephan Aßmus }
16812f86ba45SStephan Aßmus 
16822f86ba45SStephan Aßmus 
16832f86ba45SStephan Aßmus void
16842f86ba45SStephan Aßmus BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect,
16852f86ba45SStephan Aßmus 	const rgb_color& base, uint32 borders)
16862f86ba45SStephan Aßmus {
16872f86ba45SStephan Aßmus 	rgb_color frameColor = tint_color(base, 1.30);
16882f86ba45SStephan Aßmus 	rgb_color bevelLight = tint_color(base, 0.8);
16892f86ba45SStephan Aßmus 	rgb_color bevelShadow = tint_color(base, 1.03);
16902f86ba45SStephan Aßmus 
16912f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelShadow, bevelShadow, bevelLight, bevelLight,
16922f86ba45SStephan Aßmus 		borders);
16932f86ba45SStephan Aßmus 
16942f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameColor, frameColor, frameColor, frameColor,
16952f86ba45SStephan Aßmus 		borders);
16962f86ba45SStephan Aßmus 
16972f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLight, bevelLight, bevelShadow, bevelShadow,
16982f86ba45SStephan Aßmus 		borders);
16992f86ba45SStephan Aßmus }
17002f86ba45SStephan Aßmus 
17012f86ba45SStephan Aßmus 
17022f86ba45SStephan Aßmus void
17032f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17042f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags)
17052f86ba45SStephan Aßmus {
17062f86ba45SStephan Aßmus 	DrawLabel(view, label, rect, updateRect, base, flags,
17072f86ba45SStephan Aßmus 		DefaultLabelAlignment());
17082f86ba45SStephan Aßmus }
17092f86ba45SStephan Aßmus 
17102f86ba45SStephan Aßmus 
17112f86ba45SStephan Aßmus void
17122f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17132f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
17142f86ba45SStephan Aßmus 	const BAlignment& alignment)
17152f86ba45SStephan Aßmus {
17162f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
17172f86ba45SStephan Aßmus 		return;
17182f86ba45SStephan Aßmus 
17192f86ba45SStephan Aßmus 	// truncate the label if necessary and get the width and height
17202f86ba45SStephan Aßmus 	BString truncatedLabel(label);
17212f86ba45SStephan Aßmus 
17222f86ba45SStephan Aßmus 	BFont font;
17232f86ba45SStephan Aßmus 	view->GetFont(&font);
17242f86ba45SStephan Aßmus 
17252f86ba45SStephan Aßmus 	float width = rect.Width();
17262f86ba45SStephan Aßmus 	font.TruncateString(&truncatedLabel, B_TRUNCATE_END, width);
17272f86ba45SStephan Aßmus 	width = font.StringWidth(truncatedLabel.String());
17282f86ba45SStephan Aßmus 
17292f86ba45SStephan Aßmus 	font_height fontHeight;
17302f86ba45SStephan Aßmus 	font.GetHeight(&fontHeight);
17312f86ba45SStephan Aßmus 	float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
17322f86ba45SStephan Aßmus 
17332f86ba45SStephan Aßmus 	// handle alignment
17342f86ba45SStephan Aßmus 	BPoint location;
17352f86ba45SStephan Aßmus 
17362f86ba45SStephan Aßmus 	switch (alignment.horizontal) {
17372f86ba45SStephan Aßmus 	default:
17382f86ba45SStephan Aßmus 		case B_ALIGN_LEFT:
17392f86ba45SStephan Aßmus 			location.x = rect.left;
17402f86ba45SStephan Aßmus 			break;
17412f86ba45SStephan Aßmus 		case B_ALIGN_RIGHT:
17422f86ba45SStephan Aßmus 			location.x = rect.right - width;
17432f86ba45SStephan Aßmus 			break;
17442f86ba45SStephan Aßmus 		case B_ALIGN_CENTER:
17452f86ba45SStephan Aßmus 			location.x = (rect.left + rect.right - width) / 2.0f;
17462f86ba45SStephan Aßmus 			break;
17472f86ba45SStephan Aßmus 	}
17482f86ba45SStephan Aßmus 
17492f86ba45SStephan Aßmus 	switch (alignment.vertical) {
17502f86ba45SStephan Aßmus 		case B_ALIGN_TOP:
17512f86ba45SStephan Aßmus 			location.y = rect.top + ceilf(fontHeight.ascent);
17522f86ba45SStephan Aßmus 			break;
17532f86ba45SStephan Aßmus 		default:
17542f86ba45SStephan Aßmus 		case B_ALIGN_MIDDLE:
17552f86ba45SStephan Aßmus 			location.y = floorf((rect.top + rect.bottom - height) / 2.0f + 0.5f)
17562f86ba45SStephan Aßmus 				+ ceilf(fontHeight.ascent);
17572f86ba45SStephan Aßmus 			break;
17582f86ba45SStephan Aßmus 		case B_ALIGN_BOTTOM:
17592f86ba45SStephan Aßmus 			location.y = rect.bottom - ceilf(fontHeight.descent);
17602f86ba45SStephan Aßmus 			break;
17612f86ba45SStephan Aßmus 	}
17622f86ba45SStephan Aßmus 
1763c4e211feSStephan Aßmus 	DrawLabel(view, truncatedLabel.String(), base, flags, location);
1764c4e211feSStephan Aßmus }
1765c4e211feSStephan Aßmus 
1766c4e211feSStephan Aßmus 
1767c4e211feSStephan Aßmus void
1768c4e211feSStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
1769c4e211feSStephan Aßmus 	uint32 flags, const BPoint& where)
1770c4e211feSStephan Aßmus {
1771c4e211feSStephan Aßmus 	// setup the text color
1772c4e211feSStephan Aßmus 	// TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here,
1773c4e211feSStephan Aßmus 	// or elliminate that constant alltogether (stippi: +1).
1774d63b75faSPhilippe Saint-Pierre 
1775d63b75faSPhilippe Saint-Pierre 	BWindow* window = view->Window();
1776d63b75faSPhilippe Saint-Pierre 	bool isDesktop = window
1777d63b75faSPhilippe Saint-Pierre 		&& window->Feel() == kPrivateDesktopWindowFeel
1778d63b75faSPhilippe Saint-Pierre 		&& window->Look() == kPrivateDesktopWindowLook
1779d63b75faSPhilippe Saint-Pierre 		&& view->Parent()
1780d63b75faSPhilippe Saint-Pierre 		&& view->Parent()->Parent() == NULL
1781d63b75faSPhilippe Saint-Pierre 		&& (flags & B_IGNORE_OUTLINE) == 0;
1782d63b75faSPhilippe Saint-Pierre 
1783d63b75faSPhilippe Saint-Pierre 	rgb_color	low;
1784c4e211feSStephan Aßmus 	rgb_color	color;
1785d63b75faSPhilippe Saint-Pierre 	rgb_color	glowColor;
1786d63b75faSPhilippe Saint-Pierre 
1787d63b75faSPhilippe Saint-Pierre 	if (isDesktop)
1788d63b75faSPhilippe Saint-Pierre 		low = view->Parent()->ViewColor();
1789c4e211feSStephan Aßmus 	else
1790d63b75faSPhilippe Saint-Pierre 		low = base;
1791d63b75faSPhilippe Saint-Pierre 
1792d63b75faSPhilippe Saint-Pierre 	if (low.red + low.green + low.blue > 128 * 3) {
1793d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_DARKEN_MAX_TINT);
1794d63b75faSPhilippe Saint-Pierre 		glowColor = kWhite;
1795d63b75faSPhilippe Saint-Pierre 	} else {
1796d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_LIGHTEN_MAX_TINT);
1797d63b75faSPhilippe Saint-Pierre 		glowColor = kBlack;
1798d63b75faSPhilippe Saint-Pierre 	}
1799c4e211feSStephan Aßmus 
1800*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
1801d63b75faSPhilippe Saint-Pierre 		color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
1802d63b75faSPhilippe Saint-Pierre 		color.green = (uint8)(((int32)low.green + color.green + 1) / 2);
1803d63b75faSPhilippe Saint-Pierre 		color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2);
1804d63b75faSPhilippe Saint-Pierre 	}
1805d63b75faSPhilippe Saint-Pierre 
1806d63b75faSPhilippe Saint-Pierre 	drawing_mode oldMode = view->DrawingMode();
1807d63b75faSPhilippe Saint-Pierre 
1808d63b75faSPhilippe Saint-Pierre 	if (isDesktop) {
1809*a884b43bSJohn Scipione 		// drawing occurs on the desktop
1810d63b75faSPhilippe Saint-Pierre 		if (fCachedWorkspace != current_workspace()) {
1811d63b75faSPhilippe Saint-Pierre 			int8 indice = 0;
1812d63b75faSPhilippe Saint-Pierre 			int32 mask;
1813d63b75faSPhilippe Saint-Pierre 			bool tmpOutline;
1814d63b75faSPhilippe Saint-Pierre 			while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
1815d63b75faSPhilippe Saint-Pierre 					indice, &mask) == B_OK
1816d63b75faSPhilippe Saint-Pierre 				&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
1817d63b75faSPhilippe Saint-Pierre 					indice, &tmpOutline) == B_OK) {
1818d63b75faSPhilippe Saint-Pierre 
1819d63b75faSPhilippe Saint-Pierre 				if (((1 << current_workspace()) & mask) != 0) {
1820d63b75faSPhilippe Saint-Pierre 					fCachedOutline = tmpOutline;
1821d63b75faSPhilippe Saint-Pierre 					fCachedWorkspace = current_workspace();
1822d63b75faSPhilippe Saint-Pierre 					break;
1823d63b75faSPhilippe Saint-Pierre 				}
1824d63b75faSPhilippe Saint-Pierre 				indice++;
1825d63b75faSPhilippe Saint-Pierre 			}
1826d63b75faSPhilippe Saint-Pierre 		}
1827d63b75faSPhilippe Saint-Pierre 
1828d63b75faSPhilippe Saint-Pierre 		if (fCachedOutline) {
1829d63b75faSPhilippe Saint-Pierre 			BFont font;
1830d63b75faSPhilippe Saint-Pierre 			view->GetFont(&font);
1831d63b75faSPhilippe Saint-Pierre 
1832d63b75faSPhilippe Saint-Pierre 			view->SetDrawingMode(B_OP_ALPHA);
1833d63b75faSPhilippe Saint-Pierre 			view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
1834d63b75faSPhilippe Saint-Pierre 			// Draw glow or outline
1835d63b75faSPhilippe Saint-Pierre 			if (glowColor == kWhite) {
1836d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(2.0);
1837d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1838d63b75faSPhilippe Saint-Pierre 
1839d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1840d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1841d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1842d63b75faSPhilippe Saint-Pierre 
1843d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1844d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1845d63b75faSPhilippe Saint-Pierre 
1846d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 65;
1847d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1848d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1849d63b75faSPhilippe Saint-Pierre 
1850d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1851d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1852d63b75faSPhilippe Saint-Pierre 			} else if (glowColor == kBlack) {
1853d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1854d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1855d63b75faSPhilippe Saint-Pierre 
1856d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1857d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1858d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1859d63b75faSPhilippe Saint-Pierre 
1860d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1861d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1862d63b75faSPhilippe Saint-Pierre 
1863d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 200;
1864d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1865d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, BPoint(where.x + 1, where.y + 1));
1866d63b75faSPhilippe Saint-Pierre 			}
1867d63b75faSPhilippe Saint-Pierre 		}
1868c4e211feSStephan Aßmus 	}
1869c4e211feSStephan Aßmus 
1870c4e211feSStephan Aßmus 	view->SetHighColor(color);
1871c4e211feSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
1872c4e211feSStephan Aßmus 	view->DrawString(label, where);
1873c4e211feSStephan Aßmus 	view->SetDrawingMode(oldMode);
18742f86ba45SStephan Aßmus }
18752f86ba45SStephan Aßmus 
18762f86ba45SStephan Aßmus 
1877d63b75faSPhilippe Saint-Pierre void
1878d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo)
1879d63b75faSPhilippe Saint-Pierre {
1880d452ff66SAxel Dörfler 	fBackgroundInfo = backgroundInfo;
1881d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace = -1;
1882d63b75faSPhilippe Saint-Pierre }
1883d63b75faSPhilippe Saint-Pierre 
1884d63b75faSPhilippe Saint-Pierre 
18852f86ba45SStephan Aßmus // #pragma mark -
18862f86ba45SStephan Aßmus 
18872f86ba45SStephan Aßmus 
18882f86ba45SStephan Aßmus void
188913cd46dfSStephan Aßmus BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
1890*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
1891*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
1892*a884b43bSJohn Scipione 	const rgb_color& background, float contrast, float brightness,
1893*a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
189413cd46dfSStephan Aßmus {
1895*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1896*a884b43bSJohn Scipione 		return;
189713cd46dfSStephan Aßmus 
1898*a884b43bSJohn Scipione 	// clipping constraints for the view
1899*a884b43bSJohn Scipione 	BRegion clipping;
1900*a884b43bSJohn Scipione 	view->GetClippingRegion(&clipping);
190113cd46dfSStephan Aßmus 
1902*a884b43bSJohn Scipione 	// intersect constraints with updateRect
1903*a884b43bSJohn Scipione 	BRegion updateClipping(updateRect);
1904*a884b43bSJohn Scipione 	clipping.IntersectWith(&updateClipping);
1905*a884b43bSJohn Scipione 
1906*a884b43bSJohn Scipione 	// clip to the intersection
1907*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
1908*a884b43bSJohn Scipione 
1909*a884b43bSJohn Scipione 	// outer edge colors
1910*a884b43bSJohn Scipione 	rgb_color edgeLightColor;
1911*a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
1912*a884b43bSJohn Scipione 
1913*a884b43bSJohn Scipione 	// default button frame color
19144f579098SStephan Aßmus 	// TODO: B_BLEND_FRAME
1915*a884b43bSJohn Scipione 	float defaultIndicatorTint = 1.2;
1916*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
1917*a884b43bSJohn Scipione 		defaultIndicatorTint = (B_NO_TINT + defaultIndicatorTint) / 2;
191813cd46dfSStephan Aßmus 
1919*a884b43bSJohn Scipione 	rgb_color defaultIndicatorColor = tint_color(base, defaultIndicatorTint);
1920*a884b43bSJohn Scipione 	rgb_color cornerBgColor = background;
192113cd46dfSStephan Aßmus 
1922*a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
1923*a884b43bSJohn Scipione 		// draw default button indicator
1924*a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(defaultIndicatorColor,
1925*a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
1926*a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
1927*a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(defaultIndicatorColor,
1928*a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
1929*a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
193013cd46dfSStephan Aßmus 
1931*a884b43bSJohn Scipione 		cornerBgColor = defaultIndicatorColor;
193213cd46dfSStephan Aßmus 
1933*a884b43bSJohn Scipione 		view->SetHighColor(background);
1934*a884b43bSJohn Scipione 		view->FillRect(rect);
193513cd46dfSStephan Aßmus 		view->SetHighColor(base);
1936*a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
1937*a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
193813cd46dfSStephan Aßmus 
1939*a884b43bSJohn Scipione 		view->SetHighColor(defaultIndicatorColor);
1940*a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
1941*a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
194213cd46dfSStephan Aßmus 
1943*a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
1944*a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
194513cd46dfSStephan Aßmus 	} else {
1946*a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(background,
1947*a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
1948*a884b43bSJohn Scipione 			brightness * 1.0, flags);
1949*a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(background,
1950*a884b43bSJohn Scipione 			contrast * (flags & B_DISABLED) != 0 ? 0.0 : 1.0,
1951*a884b43bSJohn Scipione 			brightness * 1.0, flags);
195213cd46dfSStephan Aßmus 	}
195313cd46dfSStephan Aßmus 
1954*a884b43bSJohn Scipione 	// frame colors
1955*a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
1956*a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
1957*a884b43bSJohn Scipione 
1958*a884b43bSJohn Scipione 	// rounded corners
1959*a884b43bSJohn Scipione 
1960*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
1961*a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
1962*a884b43bSJohn Scipione 		// draw left top rounded corner
1963*a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
1964*a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius),
1965*a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius));
1966*a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
1967*a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect,
1968*a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, frameLightColor);
1969*a884b43bSJohn Scipione 	}
1970*a884b43bSJohn Scipione 
1971*a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
1972*a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
1973*a884b43bSJohn Scipione 		// draw right top rounded corner
1974*a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius),
1975*a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
1976*a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius));
1977*a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
1978*a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect,
1979*a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
1980*a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
1981*a884b43bSJohn Scipione 	}
1982*a884b43bSJohn Scipione 
1983*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
1984*a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
1985*a884b43bSJohn Scipione 		// draw left bottom rounded corner
1986*a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
1987*a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius),
1988*a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius), floorf(rect.bottom));
1989*a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
1990*a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect,
1991*a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
1992*a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
1993*a884b43bSJohn Scipione 	}
1994*a884b43bSJohn Scipione 
1995*a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
1996*a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
1997*a884b43bSJohn Scipione 		// draw right bottom rounded corner
1998*a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius),
1999*a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius), floorf(rect.right),
2000*a884b43bSJohn Scipione 			floorf(rect.bottom));
2001*a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2002*a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightBottom(view, rightBottomCorner,
2003*a884b43bSJohn Scipione 			updateRect, cornerBgColor, edgeLightColor, frameShadowColor);
2004*a884b43bSJohn Scipione 	}
2005*a884b43bSJohn Scipione 
2006*a884b43bSJohn Scipione 	// clip out the corners
2007*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2008*a884b43bSJohn Scipione 
2009*a884b43bSJohn Scipione 	// draw outer edge
2010*a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
2011*a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, defaultIndicatorColor,
2012*a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2013*a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9),
2014*a884b43bSJohn Scipione 			flags, borders);
2015*a884b43bSJohn Scipione 	} else {
2016*a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, background,
2017*a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
2018*a884b43bSJohn Scipione 			brightness * 1.0, flags, borders);
2019*a884b43bSJohn Scipione 	}
2020*a884b43bSJohn Scipione 
2021*a884b43bSJohn Scipione 	// draw frame
2022*a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
20234f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
20244f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
20254f579098SStephan Aßmus 
2026*a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2027*a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
20284f579098SStephan Aßmus 
20294f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
20304f579098SStephan Aßmus 	} else {
2031*a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2032*a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
20334f579098SStephan Aßmus 	}
2034*a884b43bSJohn Scipione 
2035*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(NULL);
203613cd46dfSStephan Aßmus }
203713cd46dfSStephan Aßmus 
203813cd46dfSStephan Aßmus 
203913cd46dfSStephan Aßmus void
20402f86ba45SStephan Aßmus BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
20414f579098SStephan Aßmus 	const rgb_color& base, float contrast, float brightness, uint32 flags,
20424f579098SStephan Aßmus 	uint32 borders)
20432f86ba45SStephan Aßmus {
2044*a884b43bSJohn Scipione 	rgb_color edgeLightColor = _EdgeLightColor(base, contrast,
2045*a884b43bSJohn Scipione 		brightness, flags);
2046*a884b43bSJohn Scipione 	rgb_color edgeShadowColor = _EdgeShadowColor(base, contrast,
2047*a884b43bSJohn Scipione 		brightness, flags);
2048*a884b43bSJohn Scipione 
2049*a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
20504f579098SStephan Aßmus 		// assumes the background has already been painted
20514f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
20524f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
20534f579098SStephan Aßmus 
2054*a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2055*a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
20564f579098SStephan Aßmus 
20574f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
20584f579098SStephan Aßmus 	} else {
2059*a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2060*a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
20612f86ba45SStephan Aßmus 	}
20624f579098SStephan Aßmus }
20632f86ba45SStephan Aßmus 
20642f86ba45SStephan Aßmus 
20652f86ba45SStephan Aßmus void
20662f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
20672f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
20682f86ba45SStephan Aßmus 	uint32 borders)
20692f86ba45SStephan Aßmus {
20702f86ba45SStephan Aßmus 	view->BeginLineArray(4);
20712f86ba45SStephan Aßmus 
20722f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
20732f86ba45SStephan Aßmus 		view->AddLine(
20742f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
20752f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top), left);
20762f86ba45SStephan Aßmus 		rect.left++;
20772f86ba45SStephan Aßmus 	}
20782f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
20792f86ba45SStephan Aßmus 		view->AddLine(
20802f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
20812f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), top);
20822f86ba45SStephan Aßmus 		rect.top++;
20832f86ba45SStephan Aßmus 	}
20842f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
20852f86ba45SStephan Aßmus 		view->AddLine(
20862f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top),
20872f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), right);
20882f86ba45SStephan Aßmus 		rect.right--;
20892f86ba45SStephan Aßmus 	}
20902f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
20912f86ba45SStephan Aßmus 		view->AddLine(
20922f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
20932f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
20942f86ba45SStephan Aßmus 		rect.bottom--;
20952f86ba45SStephan Aßmus 	}
20962f86ba45SStephan Aßmus 
20972f86ba45SStephan Aßmus 	view->EndLineArray();
20982f86ba45SStephan Aßmus }
20992f86ba45SStephan Aßmus 
21002f86ba45SStephan Aßmus 
21012f86ba45SStephan Aßmus void
21022f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
21032f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
21042f86ba45SStephan Aßmus 	const rgb_color& rightTop, const rgb_color& leftBottom, uint32 borders)
21052f86ba45SStephan Aßmus {
21062f86ba45SStephan Aßmus 	view->BeginLineArray(6);
21072f86ba45SStephan Aßmus 
21082f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
21092f86ba45SStephan Aßmus 		if (borders & B_RIGHT_BORDER) {
21102f86ba45SStephan Aßmus 			view->AddLine(
21112f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
21122f86ba45SStephan Aßmus 				BPoint(rect.right - 1, rect.top), top);
21132f86ba45SStephan Aßmus 			view->AddLine(
21142f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top),
21152f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), rightTop);
21162f86ba45SStephan Aßmus 		} else {
21172f86ba45SStephan Aßmus 			view->AddLine(
21182f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
21192f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), top);
21202f86ba45SStephan Aßmus 		}
21212f86ba45SStephan Aßmus 		rect.top++;
21222f86ba45SStephan Aßmus 	}
21232f86ba45SStephan Aßmus 
21242f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
21252f86ba45SStephan Aßmus 		view->AddLine(
21262f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
21272f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom - 1), left);
21282f86ba45SStephan Aßmus 		view->AddLine(
21292f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
21302f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom), leftBottom);
21312f86ba45SStephan Aßmus 		rect.left++;
21322f86ba45SStephan Aßmus 	}
21332f86ba45SStephan Aßmus 
21342f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
21352f86ba45SStephan Aßmus 		view->AddLine(
21362f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
21372f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
21382f86ba45SStephan Aßmus 		rect.bottom--;
21392f86ba45SStephan Aßmus 	}
21402f86ba45SStephan Aßmus 
21412f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
21422f86ba45SStephan Aßmus 		view->AddLine(
21432f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom),
21442f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), right);
21452f86ba45SStephan Aßmus 		rect.right--;
21462f86ba45SStephan Aßmus 	}
21472f86ba45SStephan Aßmus 
21482f86ba45SStephan Aßmus 	view->EndLineArray();
21492f86ba45SStephan Aßmus }
21502f86ba45SStephan Aßmus 
21512f86ba45SStephan Aßmus 
21522f86ba45SStephan Aßmus void
2153*a884b43bSJohn Scipione BControlLook::_DrawButtonBackground(BView* view, BRect& rect,
2154*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2155*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2156*a884b43bSJohn Scipione 	uint32 flags, uint32 borders, enum orientation orientation)
21572f86ba45SStephan Aßmus {
2158*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2159*a884b43bSJohn Scipione 		return;
21602f86ba45SStephan Aßmus 
2161*a884b43bSJohn Scipione 	// clipping constraints for the view
2162*a884b43bSJohn Scipione 	BRegion clipping;
2163*a884b43bSJohn Scipione 	view->GetClippingRegion(&clipping);
21642f86ba45SStephan Aßmus 
2165*a884b43bSJohn Scipione 	// intersect constraints with updateRect
2166*a884b43bSJohn Scipione 	BRegion updateClipping(updateRect);
2167*a884b43bSJohn Scipione 	clipping.IntersectWith(&updateClipping);
21682f86ba45SStephan Aßmus 
2169*a884b43bSJohn Scipione 	// clip to the intersection
2170*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
21712f86ba45SStephan Aßmus 
2172*a884b43bSJohn Scipione 	// inner bevel colors
2173*a884b43bSJohn Scipione 	rgb_color bevelLightColor  = _BevelLightColor(base, flags);
2174*a884b43bSJohn Scipione 	rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2175*a884b43bSJohn Scipione 
2176*a884b43bSJohn Scipione 	// button background color
2177*a884b43bSJohn Scipione 	rgb_color buttonBgColor;
2178*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
2179*a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, 0.7);
21802f86ba45SStephan Aßmus 	else
2181*a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, B_LIGHTEN_1_TINT);
2182*a884b43bSJohn Scipione 
2183*a884b43bSJohn Scipione 	// surface top gradient
2184*a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2185*a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, base, flags, orientation);
2186*a884b43bSJohn Scipione 
2187*a884b43bSJohn Scipione 	// rounded corners
2188*a884b43bSJohn Scipione 
2189*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2190*a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2191*a884b43bSJohn Scipione 		// draw left top rounded corner
2192*a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2193*a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2194*a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2195*a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2196*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2197*a884b43bSJohn Scipione 			bevelLightColor, fillGradient);
2198*a884b43bSJohn Scipione 	}
2199*a884b43bSJohn Scipione 
2200*a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2201*a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2202*a884b43bSJohn Scipione 		// draw right top rounded corner
2203*a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2204*a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2205*a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2206*a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2207*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner,
2208*a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2209*a884b43bSJohn Scipione 	}
2210*a884b43bSJohn Scipione 
2211*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2212*a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2213*a884b43bSJohn Scipione 		// draw left bottom rounded corner
2214*a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2215*a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2216*a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2217*a884b43bSJohn Scipione 			floorf(rect.bottom));
2218*a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2219*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2220*a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2221*a884b43bSJohn Scipione 	}
2222*a884b43bSJohn Scipione 
2223*a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2224*a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2225*a884b43bSJohn Scipione 		// draw right bottom rounded corner
2226*a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2227*a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2228*a884b43bSJohn Scipione 			floorf(rect.bottom));
2229*a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2230*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2231*a884b43bSJohn Scipione 			updateRect, bevelShadowColor, fillGradient);
2232*a884b43bSJohn Scipione 	}
2233*a884b43bSJohn Scipione 
2234*a884b43bSJohn Scipione 	// clip out the corners
2235*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2236*a884b43bSJohn Scipione 
2237*a884b43bSJohn Scipione 	// draw inner bevel
2238*a884b43bSJohn Scipione 
2239*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
2240*a884b43bSJohn Scipione 		view->BeginLineArray(4);
2241*a884b43bSJohn Scipione 
2242*a884b43bSJohn Scipione 		// shadow along left/top borders
2243*a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2244*a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2245*a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelLightColor);
2246*a884b43bSJohn Scipione 			rect.left++;
2247*a884b43bSJohn Scipione 		}
2248*a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2249*a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2250*a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelLightColor);
2251*a884b43bSJohn Scipione 			rect.top++;
2252*a884b43bSJohn Scipione 		}
2253*a884b43bSJohn Scipione 
2254*a884b43bSJohn Scipione 		// softer shadow along left/top borders
2255*a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2256*a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2257*a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelShadowColor);
2258*a884b43bSJohn Scipione 			rect.left++;
2259*a884b43bSJohn Scipione 		}
2260*a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2261*a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2262*a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelShadowColor);
2263*a884b43bSJohn Scipione 			rect.top++;
2264*a884b43bSJohn Scipione 		}
2265*a884b43bSJohn Scipione 
2266*a884b43bSJohn Scipione 		view->EndLineArray();
2267*a884b43bSJohn Scipione 	} else {
2268*a884b43bSJohn Scipione 		_DrawFrame(view, rect,
2269*a884b43bSJohn Scipione 			bevelLightColor, bevelLightColor,
2270*a884b43bSJohn Scipione 			bevelShadowColor, bevelShadowColor,
2271*a884b43bSJohn Scipione 			buttonBgColor, buttonBgColor, borders);
2272*a884b43bSJohn Scipione 	}
2273*a884b43bSJohn Scipione 
2274*a884b43bSJohn Scipione 	// fill in the background
2275*a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2276*a884b43bSJohn Scipione 
2277*a884b43bSJohn Scipione 	// reset clipping constraints
2278*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(NULL);
22792f86ba45SStephan Aßmus }
22802f86ba45SStephan Aßmus 
22812f86ba45SStephan Aßmus 
22822f86ba45SStephan Aßmus void
2283*a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundOutside(BView* view, BRect& rect,
2284*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2285*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2286*a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
22872f86ba45SStephan Aßmus {
2288*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2289*a884b43bSJohn Scipione 		return;
2290*a884b43bSJohn Scipione 
2291*a884b43bSJohn Scipione 	if (popupIndicator) {
2292*a884b43bSJohn Scipione 		BRect leftRect(rect);
2293*a884b43bSJohn Scipione 		leftRect.right -= 10;
2294*a884b43bSJohn Scipione 
2295*a884b43bSJohn Scipione 		BRect rightRect(rect);
2296*a884b43bSJohn Scipione 		rightRect.left = rightRect.right - 9;
2297*a884b43bSJohn Scipione 
2298*a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, leftRect, updateRect,
2299*a884b43bSJohn Scipione 			leftTopRadius, 0.0f, leftBottomRadius, 0.0f, base, flags,
2300*a884b43bSJohn Scipione 			B_LEFT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER);
2301*a884b43bSJohn Scipione 
2302*a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rightRect, updateRect,
2303*a884b43bSJohn Scipione 			0.0f, rightTopRadius, 0.0f, rightBottomRadius, base, flags,
2304*a884b43bSJohn Scipione 			B_TOP_BORDER | B_RIGHT_BORDER | B_BOTTOM_BORDER);
2305*a884b43bSJohn Scipione 
2306*a884b43bSJohn Scipione 		// popup marker
2307*a884b43bSJohn Scipione 		BPoint center(roundf((rightRect.left + rightRect.right) / 2.0),
2308*a884b43bSJohn Scipione 					  roundf((rightRect.top + rightRect.bottom) / 2.0));
2309*a884b43bSJohn Scipione 		BPoint triangle[3];
2310*a884b43bSJohn Scipione 		triangle[0] = center + BPoint(-2.5, -0.5);
2311*a884b43bSJohn Scipione 		triangle[1] = center + BPoint(2.5, -0.5);
2312*a884b43bSJohn Scipione 		triangle[2] = center + BPoint(0.0, 2.0);
2313*a884b43bSJohn Scipione 
2314*a884b43bSJohn Scipione 		uint32 viewFlags = view->Flags();
2315*a884b43bSJohn Scipione 		view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
2316*a884b43bSJohn Scipione 
2317*a884b43bSJohn Scipione 		rgb_color markColor;
2318*a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2319*a884b43bSJohn Scipione 			markColor = tint_color(base, 1.35);
23202f86ba45SStephan Aßmus 		else
2321*a884b43bSJohn Scipione 			markColor = tint_color(base, 1.65);
2322*a884b43bSJohn Scipione 
2323*a884b43bSJohn Scipione 		view->SetHighColor(markColor);
2324*a884b43bSJohn Scipione 		view->FillTriangle(triangle[0], triangle[1], triangle[2]);
2325*a884b43bSJohn Scipione 
2326*a884b43bSJohn Scipione 		// draw a line on the left of the popup frame
2327*a884b43bSJohn Scipione 		rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2328*a884b43bSJohn Scipione 		view->SetHighColor(bevelShadowColor);
2329*a884b43bSJohn Scipione 		BPoint leftTopCorner(floorf(rightRect.left - 1.0),
2330*a884b43bSJohn Scipione 			floorf(rightRect.top - 1.0));
2331*a884b43bSJohn Scipione 		BPoint leftBottomCorner(floorf(rightRect.left - 1.0),
2332*a884b43bSJohn Scipione 			floorf(rightRect.bottom + 1.0));
2333*a884b43bSJohn Scipione 		view->StrokeLine(leftTopCorner, leftBottomCorner);
2334*a884b43bSJohn Scipione 
2335*a884b43bSJohn Scipione 		view->SetFlags(viewFlags);
2336*a884b43bSJohn Scipione 
2337*a884b43bSJohn Scipione 		rect = leftRect;
2338*a884b43bSJohn Scipione 	} else {
2339*a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rect, updateRect, leftTopRadius,
2340*a884b43bSJohn Scipione 			rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags);
2341*a884b43bSJohn Scipione 	}
23422f86ba45SStephan Aßmus }
23432f86ba45SStephan Aßmus 
23442f86ba45SStephan Aßmus 
2345*a884b43bSJohn Scipione void
2346*a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
2347*a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2348*a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2349*a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
23502f86ba45SStephan Aßmus {
2351*a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2352*a884b43bSJohn Scipione 		return;
2353*a884b43bSJohn Scipione 
2354*a884b43bSJohn Scipione 	// clipping constraints for the view
2355*a884b43bSJohn Scipione 	BRegion clipping;
2356*a884b43bSJohn Scipione 	view->GetClippingRegion(&clipping);
2357*a884b43bSJohn Scipione 
2358*a884b43bSJohn Scipione 	// intersect constraints with updateRect
2359*a884b43bSJohn Scipione 	BRegion updateClipping(updateRect);
2360*a884b43bSJohn Scipione 	clipping.IntersectWith(&updateClipping);
2361*a884b43bSJohn Scipione 
2362*a884b43bSJohn Scipione 	// clip to the intersection
2363*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2364*a884b43bSJohn Scipione 
2365*a884b43bSJohn Scipione 	// frame colors
2366*a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
2367*a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
2368*a884b43bSJohn Scipione 
2369*a884b43bSJohn Scipione 	// indicator background color
2370*a884b43bSJohn Scipione 	rgb_color indicatorBase;
2371*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0)
2372*a884b43bSJohn Scipione 		indicatorBase = base;
2373*a884b43bSJohn Scipione 	else {
2374*a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2375*a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.05);
2376*a884b43bSJohn Scipione 		else
2377*a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.12);
23782f86ba45SStephan Aßmus 	}
23792f86ba45SStephan Aßmus 
2380*a884b43bSJohn Scipione 	// bevel colors
2381*a884b43bSJohn Scipione 	rgb_color cornerColor = tint_color(indicatorBase, 0.85);
2382*a884b43bSJohn Scipione 	rgb_color bevelColor1 = tint_color(indicatorBase, 0.3);
2383*a884b43bSJohn Scipione 	rgb_color bevelColor2 = tint_color(indicatorBase, 0.5);
2384*a884b43bSJohn Scipione 	rgb_color bevelColor3 = tint_color(indicatorBase, 1.03);
23852f86ba45SStephan Aßmus 
2386*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
2387*a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.8);
2388*a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.7);
2389*a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.8);
2390*a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.01);
23912f86ba45SStephan Aßmus 	} else {
2392*a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.85);
2393*a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.3);
2394*a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.5);
2395*a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.03);
23962f86ba45SStephan Aßmus 	}
2397*a884b43bSJohn Scipione 
2398*a884b43bSJohn Scipione 	// surface top gradient
2399*a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2400*a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, indicatorBase, flags);
2401*a884b43bSJohn Scipione 
2402*a884b43bSJohn Scipione 	// rounded corners
2403*a884b43bSJohn Scipione 
2404*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2405*a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2406*a884b43bSJohn Scipione 		// draw left top rounded corner
2407*a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2408*a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2409*a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2410*a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2411*a884b43bSJohn Scipione 
2412*a884b43bSJohn Scipione 		BRegion cornerClipping(leftTopCorner);
2413*a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2414*a884b43bSJohn Scipione 
2415*a884b43bSJohn Scipione 		BRect ellipseRect(leftTopCorner);
2416*a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2417*a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2418*a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2419*a884b43bSJohn Scipione 
2420*a884b43bSJohn Scipione 		// draw the frame (again)
2421*a884b43bSJohn Scipione 		view->SetHighColor(frameLightColor);
2422*a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2423*a884b43bSJohn Scipione 
2424*a884b43bSJohn Scipione 		// draw the bevel and background
2425*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2426*a884b43bSJohn Scipione 			bevelColor1, fillGradient);
2427*a884b43bSJohn Scipione 	}
2428*a884b43bSJohn Scipione 
2429*a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2430*a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2431*a884b43bSJohn Scipione 		// draw right top rounded corner
2432*a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2433*a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2434*a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2435*a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2436*a884b43bSJohn Scipione 
2437*a884b43bSJohn Scipione 		BRegion cornerClipping(rightTopCorner);
2438*a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2439*a884b43bSJohn Scipione 
2440*a884b43bSJohn Scipione 		BRect ellipseRect(rightTopCorner);
2441*a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2442*a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2443*a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2444*a884b43bSJohn Scipione 
2445*a884b43bSJohn Scipione 		// draw the frame (again)
2446*a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2447*a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2448*a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
24492f86ba45SStephan Aßmus 		} else {
2450*a884b43bSJohn Scipione 			BGradientLinear gradient;
2451*a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2452*a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2453*a884b43bSJohn Scipione 			gradient.SetStart(rightTopCorner.LeftTop());
2454*a884b43bSJohn Scipione 			gradient.SetEnd(rightTopCorner.RightBottom());
2455*a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
24562f86ba45SStephan Aßmus 		}
24572f86ba45SStephan Aßmus 
2458*a884b43bSJohn Scipione 		// draw the bevel and background
2459*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect,
2460*a884b43bSJohn Scipione 			bevelColor1, bevelColor3, fillGradient);
2461*a884b43bSJohn Scipione 	}
24622f86ba45SStephan Aßmus 
2463*a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2464*a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2465*a884b43bSJohn Scipione 		// draw left bottom rounded corner
2466*a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2467*a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2468*a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2469*a884b43bSJohn Scipione 			floorf(rect.bottom));
2470*a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2471*a884b43bSJohn Scipione 
2472*a884b43bSJohn Scipione 		BRegion cornerClipping(leftBottomCorner);
2473*a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2474*a884b43bSJohn Scipione 
2475*a884b43bSJohn Scipione 		BRect ellipseRect(leftBottomCorner);
2476*a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2477*a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2478*a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2479*a884b43bSJohn Scipione 
2480*a884b43bSJohn Scipione 		// draw the frame (again)
2481*a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2482*a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2483*a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
2484*a884b43bSJohn Scipione 		} else {
2485*a884b43bSJohn Scipione 			BGradientLinear gradient;
2486*a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2487*a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2488*a884b43bSJohn Scipione 			gradient.SetStart(leftBottomCorner.LeftTop());
2489*a884b43bSJohn Scipione 			gradient.SetEnd(leftBottomCorner.RightBottom());
2490*a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
2491*a884b43bSJohn Scipione 		}
2492*a884b43bSJohn Scipione 
2493*a884b43bSJohn Scipione 		// draw the bevel and background
2494*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2495*a884b43bSJohn Scipione 			updateRect, bevelColor2, bevelColor3, fillGradient);
2496*a884b43bSJohn Scipione 	}
2497*a884b43bSJohn Scipione 
2498*a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2499*a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2500*a884b43bSJohn Scipione 		// draw right bottom rounded corner
2501*a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2502*a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2503*a884b43bSJohn Scipione 			floorf(rect.bottom));
2504*a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2505*a884b43bSJohn Scipione 
2506*a884b43bSJohn Scipione 		BRegion cornerClipping(rightBottomCorner);
2507*a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2508*a884b43bSJohn Scipione 
2509*a884b43bSJohn Scipione 		BRect ellipseRect(rightBottomCorner);
2510*a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2511*a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2512*a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2513*a884b43bSJohn Scipione 
2514*a884b43bSJohn Scipione 		// draw the frame (again)
2515*a884b43bSJohn Scipione 		view->SetHighColor(frameShadowColor);
2516*a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2517*a884b43bSJohn Scipione 
2518*a884b43bSJohn Scipione 		// draw the bevel and background
2519*a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2520*a884b43bSJohn Scipione 			updateRect, bevelColor3, fillGradient);
2521*a884b43bSJohn Scipione 	}
2522*a884b43bSJohn Scipione 
2523*a884b43bSJohn Scipione 	// clip out the corners
2524*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2525*a884b43bSJohn Scipione 
2526*a884b43bSJohn Scipione 	// draw the bevel
2527*a884b43bSJohn Scipione 	_DrawFrame(view, rect,
2528*a884b43bSJohn Scipione 		bevelColor2, bevelColor1,
2529*a884b43bSJohn Scipione 		bevelColor3, bevelColor3,
2530*a884b43bSJohn Scipione 		cornerColor, cornerColor,
2531*a884b43bSJohn Scipione 		borders);
2532*a884b43bSJohn Scipione 
2533*a884b43bSJohn Scipione 	// fill in the background
2534*a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2535*a884b43bSJohn Scipione 
2536*a884b43bSJohn Scipione 	// reset clipping constraints
2537*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(NULL);
2538*a884b43bSJohn Scipione }
2539*a884b43bSJohn Scipione 
2540*a884b43bSJohn Scipione 
2541*a884b43bSJohn Scipione void
2542*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftTop(BView* view, BRect& cornerRect,
2543*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2544*a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2545*a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2546*a884b43bSJohn Scipione {
2547*a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftTop(view, cornerRect, updateRect,
2548*a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2549*a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftTop(view, cornerRect, updateRect,
2550*a884b43bSJohn Scipione 		bevelColor, fillGradient);
2551*a884b43bSJohn Scipione }
2552*a884b43bSJohn Scipione 
2553*a884b43bSJohn Scipione 
2554*a884b43bSJohn Scipione void
2555*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftTop(BView* view, BRect& cornerRect,
2556*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2557*a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2558*a884b43bSJohn Scipione {
2559*a884b43bSJohn Scipione 	// constrain clipping region to corner
2560*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2561*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2562*a884b43bSJohn Scipione 
2563*a884b43bSJohn Scipione 	// background
2564*a884b43bSJohn Scipione 	view->SetHighColor(background);
2565*a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2566*a884b43bSJohn Scipione 
2567*a884b43bSJohn Scipione 	// outer edge
2568*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2569*a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2570*a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2571*a884b43bSJohn Scipione 
2572*a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2573*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2574*a884b43bSJohn Scipione 
2575*a884b43bSJohn Scipione 	// frame
2576*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2577*a884b43bSJohn Scipione 	cornerRect.left++;
2578*a884b43bSJohn Scipione 	cornerRect.top++;
2579*a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2580*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2581*a884b43bSJohn Scipione 
2582*a884b43bSJohn Scipione 	// prepare for bevel
2583*a884b43bSJohn Scipione 	cornerRect.left++;
2584*a884b43bSJohn Scipione 	cornerRect.top++;
2585*a884b43bSJohn Scipione }
2586*a884b43bSJohn Scipione 
2587*a884b43bSJohn Scipione 
2588*a884b43bSJohn Scipione void
2589*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftTop(BView* view, BRect& cornerRect,
2590*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelColor,
2591*a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2592*a884b43bSJohn Scipione {
2593*a884b43bSJohn Scipione 	// constrain clipping region to corner
2594*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2595*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2596*a884b43bSJohn Scipione 
2597*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2598*a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2599*a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2600*a884b43bSJohn Scipione 
2601*a884b43bSJohn Scipione 	// bevel
2602*a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2603*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2604*a884b43bSJohn Scipione 
2605*a884b43bSJohn Scipione 	// gradient
2606*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2607*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2608*a884b43bSJohn Scipione }
2609*a884b43bSJohn Scipione 
2610*a884b43bSJohn Scipione 
2611*a884b43bSJohn Scipione void
2612*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightTop(BView* view, BRect& cornerRect,
2613*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2614*a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2615*a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor,
2616*a884b43bSJohn Scipione 	const rgb_color& bevelTopColor, const rgb_color& bevelRightColor,
2617*a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2618*a884b43bSJohn Scipione {
2619*a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightTop(view, cornerRect, updateRect,
2620*a884b43bSJohn Scipione 		background, edgeTopColor, edgeRightColor, frameTopColor,
2621*a884b43bSJohn Scipione 		frameRightColor);
2622*a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightTop(view, cornerRect, updateRect,
2623*a884b43bSJohn Scipione 		bevelTopColor, bevelRightColor, fillGradient);
2624*a884b43bSJohn Scipione }
2625*a884b43bSJohn Scipione 
2626*a884b43bSJohn Scipione 
2627*a884b43bSJohn Scipione void
2628*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightTop(BView* view, BRect& cornerRect,
2629*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2630*a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2631*a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor)
2632*a884b43bSJohn Scipione {
2633*a884b43bSJohn Scipione 	// constrain clipping region to corner
2634*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2635*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2636*a884b43bSJohn Scipione 
2637*a884b43bSJohn Scipione 	// background
2638*a884b43bSJohn Scipione 	view->SetHighColor(background);
2639*a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2640*a884b43bSJohn Scipione 
2641*a884b43bSJohn Scipione 	// outer edge
2642*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2643*a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2644*a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2645*a884b43bSJohn Scipione 
2646*a884b43bSJohn Scipione 	BGradientLinear gradient;
2647*a884b43bSJohn Scipione 	gradient.AddColor(edgeTopColor, 0);
2648*a884b43bSJohn Scipione 	gradient.AddColor(edgeRightColor, 255);
2649*a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2650*a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2651*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2652*a884b43bSJohn Scipione 
2653*a884b43bSJohn Scipione 	// frame
2654*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2655*a884b43bSJohn Scipione 	cornerRect.right--;
2656*a884b43bSJohn Scipione 	cornerRect.top++;
2657*a884b43bSJohn Scipione 	if (frameTopColor == frameRightColor) {
2658*a884b43bSJohn Scipione 		view->SetHighColor(frameTopColor);
2659*a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2660*a884b43bSJohn Scipione 	} else {
2661*a884b43bSJohn Scipione 		gradient.SetColor(0, frameTopColor);
2662*a884b43bSJohn Scipione 		gradient.SetColor(1, frameRightColor);
2663*a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2664*a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2665*a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2666*a884b43bSJohn Scipione 	}
2667*a884b43bSJohn Scipione 
2668*a884b43bSJohn Scipione 	// prepare for bevel
2669*a884b43bSJohn Scipione 	cornerRect.right--;
2670*a884b43bSJohn Scipione 	cornerRect.top++;
2671*a884b43bSJohn Scipione }
2672*a884b43bSJohn Scipione 
2673*a884b43bSJohn Scipione 
2674*a884b43bSJohn Scipione void
2675*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightTop(BView* view, BRect& cornerRect,
2676*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelTopColor,
2677*a884b43bSJohn Scipione 	const rgb_color& bevelRightColor, const BGradientLinear& fillGradient)
2678*a884b43bSJohn Scipione {
2679*a884b43bSJohn Scipione 	// constrain clipping region to corner
2680*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2681*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2682*a884b43bSJohn Scipione 
2683*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2684*a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2685*a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2686*a884b43bSJohn Scipione 
2687*a884b43bSJohn Scipione 	// bevel
2688*a884b43bSJohn Scipione 	BGradientLinear gradient;
2689*a884b43bSJohn Scipione 	gradient.AddColor(bevelTopColor, 0);
2690*a884b43bSJohn Scipione 	gradient.AddColor(bevelRightColor, 255);
2691*a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2692*a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2693*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2694*a884b43bSJohn Scipione 
2695*a884b43bSJohn Scipione 	// gradient
2696*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2697*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2698*a884b43bSJohn Scipione }
2699*a884b43bSJohn Scipione 
2700*a884b43bSJohn Scipione 
2701*a884b43bSJohn Scipione void
2702*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftBottom(BView* view, BRect& cornerRect,
2703*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2704*a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
2705*a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor,
2706*a884b43bSJohn Scipione 	const rgb_color& bevelLeftColor, const rgb_color& bevelBottomColor,
2707*a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2708*a884b43bSJohn Scipione {
2709*a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftBottom(view, cornerRect, updateRect,
2710*a884b43bSJohn Scipione 		background, edgeLeftColor, edgeBottomColor, frameLeftColor,
2711*a884b43bSJohn Scipione 		frameBottomColor);
2712*a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftBottom(view, cornerRect, updateRect,
2713*a884b43bSJohn Scipione 		bevelLeftColor, bevelBottomColor, fillGradient);
2714*a884b43bSJohn Scipione }
2715*a884b43bSJohn Scipione 
2716*a884b43bSJohn Scipione 
2717*a884b43bSJohn Scipione void
2718*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftBottom(BView* view, BRect& cornerRect,
2719*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2720*a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
2721*a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor)
2722*a884b43bSJohn Scipione {
2723*a884b43bSJohn Scipione 	// constrain clipping region to corner
2724*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2725*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2726*a884b43bSJohn Scipione 
2727*a884b43bSJohn Scipione 	// background
2728*a884b43bSJohn Scipione 	view->SetHighColor(background);
2729*a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2730*a884b43bSJohn Scipione 
2731*a884b43bSJohn Scipione 	// outer edge
2732*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2733*a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2734*a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2735*a884b43bSJohn Scipione 
2736*a884b43bSJohn Scipione 	BGradientLinear gradient;
2737*a884b43bSJohn Scipione 	gradient.AddColor(edgeLeftColor, 0);
2738*a884b43bSJohn Scipione 	gradient.AddColor(edgeBottomColor, 255);
2739*a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2740*a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2741*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2742*a884b43bSJohn Scipione 
2743*a884b43bSJohn Scipione 	// frame
2744*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2745*a884b43bSJohn Scipione 	cornerRect.left++;
2746*a884b43bSJohn Scipione 	cornerRect.bottom--;
2747*a884b43bSJohn Scipione 	if (frameLeftColor == frameBottomColor) {
2748*a884b43bSJohn Scipione 		view->SetHighColor(frameLeftColor);
2749*a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2750*a884b43bSJohn Scipione 	} else {
2751*a884b43bSJohn Scipione 		gradient.SetColor(0, frameLeftColor);
2752*a884b43bSJohn Scipione 		gradient.SetColor(1, frameBottomColor);
2753*a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2754*a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2755*a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2756*a884b43bSJohn Scipione 	}
2757*a884b43bSJohn Scipione 
2758*a884b43bSJohn Scipione 	// prepare for bevel
2759*a884b43bSJohn Scipione 	cornerRect.left++;
2760*a884b43bSJohn Scipione 	cornerRect.bottom--;
2761*a884b43bSJohn Scipione }
2762*a884b43bSJohn Scipione 
2763*a884b43bSJohn Scipione 
2764*a884b43bSJohn Scipione void
2765*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftBottom(BView* view, BRect& cornerRect,
2766*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelLeftColor,
2767*a884b43bSJohn Scipione 	const rgb_color& bevelBottomColor, const BGradientLinear& fillGradient)
2768*a884b43bSJohn Scipione {
2769*a884b43bSJohn Scipione 	// constrain clipping region to corner
2770*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2771*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2772*a884b43bSJohn Scipione 
2773*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2774*a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2775*a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2776*a884b43bSJohn Scipione 
2777*a884b43bSJohn Scipione 	// bevel
2778*a884b43bSJohn Scipione 	BGradientLinear gradient;
2779*a884b43bSJohn Scipione 	gradient.AddColor(bevelLeftColor, 0);
2780*a884b43bSJohn Scipione 	gradient.AddColor(bevelBottomColor, 255);
2781*a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2782*a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2783*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2784*a884b43bSJohn Scipione 
2785*a884b43bSJohn Scipione 	// gradient
2786*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2787*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2788*a884b43bSJohn Scipione 
2789*a884b43bSJohn Scipione 	view->PopState();
2790*a884b43bSJohn Scipione }
2791*a884b43bSJohn Scipione 
2792*a884b43bSJohn Scipione 
2793*a884b43bSJohn Scipione void
2794*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightBottom(BView* view, BRect& cornerRect,
2795*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2796*a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2797*a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2798*a884b43bSJohn Scipione {
2799*a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightBottom(view, cornerRect, updateRect,
2800*a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2801*a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightBottom(view, cornerRect, updateRect,
2802*a884b43bSJohn Scipione 		bevelColor, fillGradient);
2803*a884b43bSJohn Scipione }
2804*a884b43bSJohn Scipione 
2805*a884b43bSJohn Scipione 
2806*a884b43bSJohn Scipione void
2807*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect,
2808*a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2809*a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2810*a884b43bSJohn Scipione {
2811*a884b43bSJohn Scipione 	// constrain clipping region to corner
2812*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2813*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2814*a884b43bSJohn Scipione 
2815*a884b43bSJohn Scipione 	// background
2816*a884b43bSJohn Scipione 	view->SetHighColor(background);
2817*a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2818*a884b43bSJohn Scipione 
2819*a884b43bSJohn Scipione 	// outer edge
2820*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2821*a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2822*a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2823*a884b43bSJohn Scipione 
2824*a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2825*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2826*a884b43bSJohn Scipione 
2827*a884b43bSJohn Scipione 	// frame
2828*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2829*a884b43bSJohn Scipione 	cornerRect.right--;
2830*a884b43bSJohn Scipione 	cornerRect.bottom++;
2831*a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2832*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2833*a884b43bSJohn Scipione 
2834*a884b43bSJohn Scipione 	// prepare for bevel
2835*a884b43bSJohn Scipione 	cornerRect.left++;
2836*a884b43bSJohn Scipione 	cornerRect.bottom--;
2837*a884b43bSJohn Scipione }
2838*a884b43bSJohn Scipione 
2839*a884b43bSJohn Scipione 
2840*a884b43bSJohn Scipione void
2841*a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightBottom(BView* view,
2842*a884b43bSJohn Scipione 	BRect& cornerRect, const BRect& updateRect, const rgb_color& bevelColor,
2843*a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2844*a884b43bSJohn Scipione {
2845*a884b43bSJohn Scipione 	// constrain clipping region to corner
2846*a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2847*a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2848*a884b43bSJohn Scipione 
2849*a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2850*a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2851*a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2852*a884b43bSJohn Scipione 
2853*a884b43bSJohn Scipione 	// bevel
2854*a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2855*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2856*a884b43bSJohn Scipione 
2857*a884b43bSJohn Scipione 	// gradient
2858*a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2859*a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
28602f86ba45SStephan Aßmus }
28612f86ba45SStephan Aßmus 
28622f86ba45SStephan Aßmus 
28632f86ba45SStephan Aßmus void
28642f86ba45SStephan Aßmus BControlLook::_DrawRoundBarCorner(BView* view, BRect& rect,
28652f86ba45SStephan Aßmus 	const BRect& updateRect,
28662f86ba45SStephan Aßmus 	const rgb_color& edgeLightColor, const rgb_color& edgeShadowColor,
28672f86ba45SStephan Aßmus 	const rgb_color& frameLightColor, const rgb_color& frameShadowColor,
28682f86ba45SStephan Aßmus 	const rgb_color& fillLightColor, const rgb_color& fillShadowColor,
28692f86ba45SStephan Aßmus 	float leftInset, float topInset, float rightInset, float bottomInset,
28702f86ba45SStephan Aßmus 	enum orientation orientation)
28712f86ba45SStephan Aßmus {
28722f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
28732f86ba45SStephan Aßmus 		return;
28742f86ba45SStephan Aßmus 
28752f86ba45SStephan Aßmus 	BGradientLinear gradient;
28762f86ba45SStephan Aßmus 	gradient.AddColor(edgeShadowColor, 0);
28772f86ba45SStephan Aßmus 	gradient.AddColor(edgeLightColor, 255);
28782f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
28792f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
28802f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
28812f86ba45SStephan Aßmus 	else
28822f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
28832f86ba45SStephan Aßmus 
28842f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
28852f86ba45SStephan Aßmus 
28862f86ba45SStephan Aßmus 	rect.left += leftInset;
28872f86ba45SStephan Aßmus 	rect.top += topInset;
28882f86ba45SStephan Aßmus 	rect.right += rightInset;
28892f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
28902f86ba45SStephan Aßmus 
28912f86ba45SStephan Aßmus 	gradient.MakeEmpty();
28922f86ba45SStephan Aßmus 	gradient.AddColor(frameShadowColor, 0);
28932f86ba45SStephan Aßmus 	gradient.AddColor(frameLightColor, 255);
28942f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
28952f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
28962f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
28972f86ba45SStephan Aßmus 	else
28982f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
28992f86ba45SStephan Aßmus 
29002f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
29012f86ba45SStephan Aßmus 
29022f86ba45SStephan Aßmus 	rect.left += leftInset;
29032f86ba45SStephan Aßmus 	rect.top += topInset;
29042f86ba45SStephan Aßmus 	rect.right += rightInset;
29052f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
29062f86ba45SStephan Aßmus 
29072f86ba45SStephan Aßmus 	gradient.MakeEmpty();
29082f86ba45SStephan Aßmus 	gradient.AddColor(fillShadowColor, 0);
29092f86ba45SStephan Aßmus 	gradient.AddColor(fillLightColor, 255);
29102f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
29112f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
29122f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
29132f86ba45SStephan Aßmus 	else
29142f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
29152f86ba45SStephan Aßmus 
29162f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
29172f86ba45SStephan Aßmus }
29182f86ba45SStephan Aßmus 
29192f86ba45SStephan Aßmus 
2920*a884b43bSJohn Scipione rgb_color
2921*a884b43bSJohn Scipione BControlLook::_EdgeLightColor(const rgb_color& base, float contrast,
2922*a884b43bSJohn Scipione 	float brightness, uint32 flags)
29232f86ba45SStephan Aßmus {
2924*a884b43bSJohn Scipione 	rgb_color edgeLightColor;
29252f86ba45SStephan Aßmus 
2926*a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
2927*a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
2928*a884b43bSJohn Scipione 		uint32 white = uint8(255 * brightness);
29292f86ba45SStephan Aßmus 
2930*a884b43bSJohn Scipione 		edgeLightColor = (rgb_color){ white, white, white, alpha };
29312f86ba45SStephan Aßmus 	} else {
2932*a884b43bSJohn Scipione 		// colors
2933*a884b43bSJohn Scipione 		float tintLight = kEdgeBevelLightTint;
2934*a884b43bSJohn Scipione 
2935*a884b43bSJohn Scipione 		if (contrast == 0.0)
2936*a884b43bSJohn Scipione 			tintLight = B_NO_TINT;
2937*a884b43bSJohn Scipione 		else if (contrast != 1.0)
2938*a884b43bSJohn Scipione 			tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast;
2939*a884b43bSJohn Scipione 
2940*a884b43bSJohn Scipione 		edgeLightColor = tint_color(base, tintLight);
2941*a884b43bSJohn Scipione 
2942*a884b43bSJohn Scipione 		if (brightness < 1.0) {
2943*a884b43bSJohn Scipione 			edgeLightColor.red = uint8(edgeLightColor.red * brightness);
2944*a884b43bSJohn Scipione 			edgeLightColor.green = uint8(edgeLightColor.green * brightness);
2945*a884b43bSJohn Scipione 			edgeLightColor.blue = uint8(edgeLightColor.blue * brightness);
2946*a884b43bSJohn Scipione 		}
29472f86ba45SStephan Aßmus 	}
29482f86ba45SStephan Aßmus 
2949*a884b43bSJohn Scipione 	return edgeLightColor;
2950*a884b43bSJohn Scipione }
2951*a884b43bSJohn Scipione 
2952*a884b43bSJohn Scipione 
2953*a884b43bSJohn Scipione rgb_color
2954*a884b43bSJohn Scipione BControlLook::_EdgeShadowColor(const rgb_color& base, float contrast,
2955*a884b43bSJohn Scipione 	float brightness, uint32 flags)
2956*a884b43bSJohn Scipione {
2957*a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
2958*a884b43bSJohn Scipione 
2959*a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
2960*a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
2961*a884b43bSJohn Scipione 		edgeShadowColor = (rgb_color){ 0, 0, 0, alpha };
2962*a884b43bSJohn Scipione 	} else {
2963*a884b43bSJohn Scipione 		float tintShadow = kEdgeBevelShadowTint;
2964*a884b43bSJohn Scipione 
2965*a884b43bSJohn Scipione 		if (contrast == 0.0)
2966*a884b43bSJohn Scipione 			tintShadow = B_NO_TINT;
2967*a884b43bSJohn Scipione 		else if (contrast != 1.0)
2968*a884b43bSJohn Scipione 			tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast;
2969*a884b43bSJohn Scipione 
2970*a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, tintShadow);
2971*a884b43bSJohn Scipione 
2972*a884b43bSJohn Scipione 		if (brightness < 1.0) {
2973*a884b43bSJohn Scipione 			edgeShadowColor.red = uint8(edgeShadowColor.red * brightness);
2974*a884b43bSJohn Scipione 			edgeShadowColor.green = uint8(edgeShadowColor.green * brightness);
2975*a884b43bSJohn Scipione 			edgeShadowColor.blue = uint8(edgeShadowColor.blue * brightness);
2976*a884b43bSJohn Scipione 		}
2977*a884b43bSJohn Scipione 	}
2978*a884b43bSJohn Scipione 
2979*a884b43bSJohn Scipione 	return edgeShadowColor;
2980*a884b43bSJohn Scipione }
2981*a884b43bSJohn Scipione 
2982*a884b43bSJohn Scipione 
2983*a884b43bSJohn Scipione rgb_color
2984*a884b43bSJohn Scipione BControlLook::_FrameLightColor(const rgb_color& base, uint32 flags)
2985*a884b43bSJohn Scipione {
2986*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
2987*a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
2988*a884b43bSJohn Scipione 
2989*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
2990*a884b43bSJohn Scipione 		return _FrameShadowColor(base, flags & ~B_ACTIVATED);
2991*a884b43bSJohn Scipione 
2992*a884b43bSJohn Scipione 	rgb_color frameLightColor;
2993*a884b43bSJohn Scipione 
2994*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
2995*a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
2996*a884b43bSJohn Scipione 		frameLightColor = tint_color(base, 1.145);
2997*a884b43bSJohn Scipione 
2998*a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
2999*a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.14);
3000*a884b43bSJohn Scipione 	} else {
3001*a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
3002*a884b43bSJohn Scipione 			frameLightColor = (rgb_color){ 0, 0, 0, 75 };
3003*a884b43bSJohn Scipione 		else
3004*a884b43bSJohn Scipione 			frameLightColor = tint_color(base, 1.33);
3005*a884b43bSJohn Scipione 
3006*a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3007*a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.35);
3008*a884b43bSJohn Scipione 	}
3009*a884b43bSJohn Scipione 
3010*a884b43bSJohn Scipione 	return frameLightColor;
3011*a884b43bSJohn Scipione }
3012*a884b43bSJohn Scipione 
3013*a884b43bSJohn Scipione 
3014*a884b43bSJohn Scipione rgb_color
3015*a884b43bSJohn Scipione BControlLook::_FrameShadowColor(const rgb_color& base, uint32 flags)
3016*a884b43bSJohn Scipione {
3017*a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
3018*a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
3019*a884b43bSJohn Scipione 
3020*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3021*a884b43bSJohn Scipione 		return _FrameLightColor(base, flags & ~B_ACTIVATED);
3022*a884b43bSJohn Scipione 
3023*a884b43bSJohn Scipione 	rgb_color frameShadowColor;
3024*a884b43bSJohn Scipione 
3025*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3026*a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
3027*a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.24);
3028*a884b43bSJohn Scipione 
3029*a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3030*a884b43bSJohn Scipione 			frameShadowColor = tint_color(base, 1.145);
3031*a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.12);
3032*a884b43bSJohn Scipione 		}
3033*a884b43bSJohn Scipione 	} else {
3034*a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3035*a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3036*a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 75 };
3037*a884b43bSJohn Scipione 			else
3038*a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.33);
3039*a884b43bSJohn Scipione 
3040*a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.5);
3041*a884b43bSJohn Scipione 		} else {
3042*a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3043*a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 95 };
3044*a884b43bSJohn Scipione 			else
3045*a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.47);
3046*a884b43bSJohn Scipione 		}
3047*a884b43bSJohn Scipione 	}
3048*a884b43bSJohn Scipione 
3049*a884b43bSJohn Scipione 	return frameShadowColor;
3050*a884b43bSJohn Scipione }
3051*a884b43bSJohn Scipione 
3052*a884b43bSJohn Scipione 
3053*a884b43bSJohn Scipione rgb_color
3054*a884b43bSJohn Scipione BControlLook::_BevelLightColor(const rgb_color& base, uint32 flags)
3055*a884b43bSJohn Scipione {
3056*a884b43bSJohn Scipione 	rgb_color bevelLightColor = tint_color(base, 0.2);
3057*a884b43bSJohn Scipione 
3058*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3059*a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_LIGHTEN_1_TINT);
3060*a884b43bSJohn Scipione 
3061*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3062*a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_DARKEN_1_TINT);
3063*a884b43bSJohn Scipione 
3064*a884b43bSJohn Scipione 	return bevelLightColor;
3065*a884b43bSJohn Scipione }
3066*a884b43bSJohn Scipione 
3067*a884b43bSJohn Scipione 
3068*a884b43bSJohn Scipione rgb_color
3069*a884b43bSJohn Scipione BControlLook::_BevelShadowColor(const rgb_color& base, uint32 flags)
3070*a884b43bSJohn Scipione {
3071*a884b43bSJohn Scipione 	rgb_color bevelShadowColor = tint_color(base, 1.08);
3072*a884b43bSJohn Scipione 
3073*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3074*a884b43bSJohn Scipione 		bevelShadowColor = base;
3075*a884b43bSJohn Scipione 
3076*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3077*a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, B_DARKEN_1_TINT);
3078*a884b43bSJohn Scipione 
3079*a884b43bSJohn Scipione 	return bevelShadowColor;
3080*a884b43bSJohn Scipione }
3081*a884b43bSJohn Scipione 
3082*a884b43bSJohn Scipione 
3083*a884b43bSJohn Scipione void
3084*a884b43bSJohn Scipione BControlLook::_FillGradient(BView* view, const BRect& rect,
3085*a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3086*a884b43bSJohn Scipione 	enum orientation orientation)
3087*a884b43bSJohn Scipione {
3088*a884b43bSJohn Scipione 	BGradientLinear gradient;
3089*a884b43bSJohn Scipione 	_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3090*a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3091*a884b43bSJohn Scipione }
3092*a884b43bSJohn Scipione 
3093*a884b43bSJohn Scipione 
3094*a884b43bSJohn Scipione void
3095*a884b43bSJohn Scipione BControlLook::_FillGlossyGradient(BView* view, const BRect& rect,
3096*a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3097*a884b43bSJohn Scipione 	float middle2Tint, float bottomTint, enum orientation orientation)
3098*a884b43bSJohn Scipione {
3099*a884b43bSJohn Scipione 	BGradientLinear gradient;
3100*a884b43bSJohn Scipione 	_MakeGlossyGradient(gradient, rect, base, topTint, middle1Tint,
3101*a884b43bSJohn Scipione 		middle2Tint, bottomTint, orientation);
3102*a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3103*a884b43bSJohn Scipione }
3104*a884b43bSJohn Scipione 
3105*a884b43bSJohn Scipione 
3106*a884b43bSJohn Scipione void
3107*a884b43bSJohn Scipione BControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect,
3108*a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3109*a884b43bSJohn Scipione 	enum orientation orientation) const
3110*a884b43bSJohn Scipione {
3111*a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3112*a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
31132f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
3114*a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3115*a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3116*a884b43bSJohn Scipione 	else
3117*a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3118*a884b43bSJohn Scipione }
31192f86ba45SStephan Aßmus 
31202f86ba45SStephan Aßmus 
3121*a884b43bSJohn Scipione void
3122*a884b43bSJohn Scipione BControlLook::_MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect,
3123*a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3124*a884b43bSJohn Scipione 	float middle2Tint, float bottomTint,
3125*a884b43bSJohn Scipione 	enum orientation orientation) const
3126*a884b43bSJohn Scipione {
3127*a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3128*a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle1Tint), 132);
3129*a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle2Tint), 136);
3130*a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
3131*a884b43bSJohn Scipione 	gradient.SetStart(rect.LeftTop());
3132*a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3133*a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3134*a884b43bSJohn Scipione 	else
3135*a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3136*a884b43bSJohn Scipione }
3137*a884b43bSJohn Scipione 
3138*a884b43bSJohn Scipione 
3139*a884b43bSJohn Scipione void
3140*a884b43bSJohn Scipione BControlLook::_MakeButtonGradient(BGradientLinear& gradient, BRect& rect,
3141*a884b43bSJohn Scipione 	const rgb_color& base, uint32 flags, enum orientation orientation) const
3142*a884b43bSJohn Scipione {
3143*a884b43bSJohn Scipione 	float topTint = 0.49;
3144*a884b43bSJohn Scipione 	float middleTint1 = 0.62;
3145*a884b43bSJohn Scipione 	float middleTint2 = 0.76;
3146*a884b43bSJohn Scipione 	float bottomTint = 0.90;
3147*a884b43bSJohn Scipione 
3148*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3149*a884b43bSJohn Scipione 		topTint = 1.11;
3150*a884b43bSJohn Scipione 		bottomTint = 1.08;
3151*a884b43bSJohn Scipione 	}
3152*a884b43bSJohn Scipione 
3153*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3154*a884b43bSJohn Scipione 		topTint = (topTint + B_NO_TINT) / 2;
3155*a884b43bSJohn Scipione 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
3156*a884b43bSJohn Scipione 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
3157*a884b43bSJohn Scipione 		bottomTint = (bottomTint + B_NO_TINT) / 2;
3158*a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
3159*a884b43bSJohn Scipione 		static const float kHoverTintFactor = 0.85;
3160*a884b43bSJohn Scipione 		topTint *= kHoverTintFactor;
3161*a884b43bSJohn Scipione 		middleTint1 *= kHoverTintFactor;
3162*a884b43bSJohn Scipione 		middleTint2 *= kHoverTintFactor;
3163*a884b43bSJohn Scipione 		bottomTint *= kHoverTintFactor;
3164*a884b43bSJohn Scipione 	}
3165*a884b43bSJohn Scipione 
3166*a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3167*a884b43bSJohn Scipione 		_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3168*a884b43bSJohn Scipione 	} else {
3169*a884b43bSJohn Scipione 		_MakeGlossyGradient(gradient, rect, base, topTint, middleTint1,
3170*a884b43bSJohn Scipione 			middleTint2, bottomTint, orientation);
3171*a884b43bSJohn Scipione 	}
3172*a884b43bSJohn Scipione }
3173*a884b43bSJohn Scipione 
3174*a884b43bSJohn Scipione 
3175*a884b43bSJohn Scipione 
3176*a884b43bSJohn Scipione bool
3177*a884b43bSJohn Scipione BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,
3178*a884b43bSJohn Scipione 	rgb_color& color, uint32 flags) const
3179*a884b43bSJohn Scipione {
3180*a884b43bSJohn Scipione 	if ((flags & (B_ACTIVATED | B_CLICKED)) == 0) {
3181*a884b43bSJohn Scipione 		// no mark to be drawn at all
3182*a884b43bSJohn Scipione 		return false;
3183*a884b43bSJohn Scipione 	}
3184*a884b43bSJohn Scipione 
3185*a884b43bSJohn Scipione 	// TODO: Get from UI settings
3186*a884b43bSJohn Scipione 	color.red = 27;
3187*a884b43bSJohn Scipione 	color.green = 82;
3188*a884b43bSJohn Scipione 	color.blue = 140;
3189*a884b43bSJohn Scipione 
3190*a884b43bSJohn Scipione 	float mix = 1.0;
3191*a884b43bSJohn Scipione 
3192*a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3193*a884b43bSJohn Scipione 		// activated, but disabled
3194*a884b43bSJohn Scipione 		mix = 0.4;
3195*a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
3196*a884b43bSJohn Scipione 		if ((flags & B_ACTIVATED) != 0) {
3197*a884b43bSJohn Scipione 			// loosing activation
3198*a884b43bSJohn Scipione 			mix = 0.7;
3199*a884b43bSJohn Scipione 		} else {
3200*a884b43bSJohn Scipione 			// becoming activated
3201*a884b43bSJohn Scipione 			mix = 0.3;
3202*a884b43bSJohn Scipione 		}
3203*a884b43bSJohn Scipione 	} else {
3204*a884b43bSJohn Scipione 		// simply activated
3205*a884b43bSJohn Scipione 	}
3206*a884b43bSJohn Scipione 
3207*a884b43bSJohn Scipione 	color.red = uint8(color.red * mix + base.red * (1.0 - mix));
3208*a884b43bSJohn Scipione 	color.green = uint8(color.green * mix + base.green * (1.0 - mix));
3209*a884b43bSJohn Scipione 	color.blue = uint8(color.blue * mix + base.blue * (1.0 - mix));
3210*a884b43bSJohn Scipione 
3211*a884b43bSJohn Scipione 	return true;
32122f86ba45SStephan Aßmus }
32132f86ba45SStephan Aßmus 
32142f86ba45SStephan Aßmus 
32152f86ba45SStephan Aßmus // NOTE: May come from a add-on in the future. Initialized in
32162f86ba45SStephan Aßmus // InterfaceDefs.cpp
32172f86ba45SStephan Aßmus BControlLook* be_control_look = NULL;
32182f86ba45SStephan Aßmus 
3219*a884b43bSJohn Scipione 
32202f86ba45SStephan Aßmus } // namespace BPrivate
3221