xref: /haiku/src/kits/interface/ControlLook.cpp (revision 5666b4f7a3c7cec818d229901b9664d106346591)
12f86ba45SStephan Aßmus /*
22f86ba45SStephan Aßmus  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3a884b43bSJohn Scipione  * Copyright 2012, Haiku Inc. All rights reserved.
42f86ba45SStephan Aßmus  * Distributed under the terms of the MIT License.
5a884b43bSJohn Scipione  *
6a884b43bSJohn Scipione  * Authors:
7a884b43bSJohn 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 
21a884b43bSJohn Scipione #include "ContainerWindow.h"
22a884b43bSJohn Scipione 
23a884b43bSJohn Scipione 
242f86ba45SStephan Aßmus namespace BPrivate {
252f86ba45SStephan Aßmus 
26a884b43bSJohn 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 {
115a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
116a884b43bSJohn Scipione 		background, 1.0, 1.0, flags, borders);
117a884b43bSJohn Scipione }
118a884b43bSJohn Scipione 
119a884b43bSJohn Scipione 
120a884b43bSJohn Scipione void
121a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
122a884b43bSJohn Scipione 	float radius, const rgb_color& base, const rgb_color& background, uint32 flags,
123a884b43bSJohn Scipione 	uint32 borders)
124a884b43bSJohn Scipione {
125a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
126a884b43bSJohn Scipione 		base, background, 1.0, 1.0, flags, borders);
127a884b43bSJohn Scipione }
128a884b43bSJohn Scipione 
129a884b43bSJohn Scipione 
130a884b43bSJohn Scipione void
131a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect,
132a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
133a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
134a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags,
135a884b43bSJohn Scipione 	uint32 borders)
136a884b43bSJohn Scipione {
137a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
138a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background,
139a884b43bSJohn 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 {
148a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f,
149a884b43bSJohn Scipione 		base, flags, borders, orientation);
1502f86ba45SStephan Aßmus }
1512f86ba45SStephan Aßmus 
1522f86ba45SStephan Aßmus 
153a884b43bSJohn Scipione void
154a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
155a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base, uint32 flags,
156a884b43bSJohn Scipione 	uint32 borders, enum orientation orientation)
157a884b43bSJohn Scipione {
158a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, radius, radius, radius,
159a884b43bSJohn Scipione 		radius, base, flags, borders, orientation);
1602f86ba45SStephan Aßmus }
1612f86ba45SStephan Aßmus 
1622f86ba45SStephan Aßmus 
163a884b43bSJohn Scipione void
164a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
165a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
166a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
167a884b43bSJohn Scipione 	uint32 flags, uint32 borders, enum orientation orientation)
168a884b43bSJohn Scipione {
169a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, leftTopRadius,
170a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags,
171a884b43bSJohn 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 {
180a884b43bSJohn 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 
189a884b43bSJohn 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 
216a884b43bSJohn 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 {
226a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
227a884b43bSJohn Scipione 		background, 0.6, 1.0, flags, borders);
228a884b43bSJohn Scipione }
229a884b43bSJohn Scipione 
230a884b43bSJohn Scipione 
231a884b43bSJohn Scipione void
232a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
233a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
234a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
235a884b43bSJohn Scipione {
236a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
237a884b43bSJohn Scipione 		base, background, 0.6, 1.0, flags, borders);
238a884b43bSJohn Scipione }
239a884b43bSJohn Scipione 
240a884b43bSJohn Scipione 
241a884b43bSJohn Scipione void
242a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
243a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius,
244a884b43bSJohn Scipione 	float rightTopRadius, float leftBottomRadius,
245a884b43bSJohn Scipione 	float rightBottomRadius, const rgb_color& base,
246a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
247a884b43bSJohn Scipione {
248a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
249a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background, 0.6, 1.0,
250a884b43bSJohn 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 {
259a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect,
260a884b43bSJohn 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 {
269a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundInside(view, rect, updateRect,
270a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, flags, borders);
2712f86ba45SStephan Aßmus }
2722f86ba45SStephan Aßmus 
2732f86ba45SStephan Aßmus 
274a884b43bSJohn Scipione void
275a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
276a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
277a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
278a884b43bSJohn Scipione {
279a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, radius, radius,
280a884b43bSJohn Scipione 		radius, radius, base, popupIndicator, flags);
2812f86ba45SStephan Aßmus }
2822f86ba45SStephan Aßmus 
283a884b43bSJohn Scipione 
284a884b43bSJohn Scipione void
285a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
286a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
287a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
288a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
289a884b43bSJohn Scipione {
290a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, leftTopRadius,
291a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base,
292a884b43bSJohn Scipione 		popupIndicator, flags);
2932f86ba45SStephan Aßmus }
2942f86ba45SStephan Aßmus 
295a884b43bSJohn 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 {
301a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3022f86ba45SStephan Aßmus 		return;
3032f86ba45SStephan Aßmus 
304a884b43bSJohn Scipione 	// surface top color
3052f86ba45SStephan Aßmus 	rgb_color background = tint_color(base, 0.75);
3062f86ba45SStephan Aßmus 
307a884b43bSJohn Scipione 	// inner bevel colors
308a884b43bSJohn Scipione 	rgb_color bevelLightColor;
309a884b43bSJohn Scipione 	rgb_color bevelShadowColor;
310a884b43bSJohn Scipione 
311a884b43bSJohn 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 
319a884b43bSJohn 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 
325a884b43bSJohn 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 {
336a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3372f86ba45SStephan Aßmus 		return;
3382f86ba45SStephan Aßmus 
339a884b43bSJohn Scipione 	// surface edges
3402f86ba45SStephan Aßmus 	float topTint;
3412f86ba45SStephan Aßmus 	float bottomTint;
3422f86ba45SStephan Aßmus 	rgb_color selectedColor = base;
3432f86ba45SStephan Aßmus 
344a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3452f86ba45SStephan Aßmus 		topTint = 0.9;
3462f86ba45SStephan Aßmus 		bottomTint = 1.05;
347a884b43bSJohn Scipione 	} else if ((flags & B_DISABLED) != 0) {
3482f86ba45SStephan Aßmus 		topTint = 0.80;
3492f86ba45SStephan Aßmus 		bottomTint = 1.07;
3502f86ba45SStephan Aßmus 	} else {
3512f86ba45SStephan Aßmus 		topTint = 0.6;
3522f86ba45SStephan Aßmus 		bottomTint = 1.12;
3532f86ba45SStephan Aßmus 	}
3542f86ba45SStephan Aßmus 
3552f86ba45SStephan Aßmus 	rgb_color bevelLightColor = tint_color(selectedColor, topTint);
3562f86ba45SStephan Aßmus 	rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint);
3572f86ba45SStephan Aßmus 
358a884b43bSJohn Scipione 	// draw surface edges
3592f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3602f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3612f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3622f86ba45SStephan Aßmus 		borders);
3632f86ba45SStephan Aßmus 
364a884b43bSJohn Scipione 	// draw surface top
3652f86ba45SStephan Aßmus 	view->SetLowColor(selectedColor);
3662f86ba45SStephan Aßmus //	_FillGradient(view, rect, selectedColor, topTint, bottomTint);
3672f86ba45SStephan Aßmus 	_FillGradient(view, rect, selectedColor, bottomTint, topTint);
3682f86ba45SStephan Aßmus }
3692f86ba45SStephan Aßmus 
3702f86ba45SStephan Aßmus 
3712f86ba45SStephan Aßmus void
3722f86ba45SStephan Aßmus BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect,
3732f86ba45SStephan Aßmus 	const rgb_color& base, const rgb_color& barColor, float progressPosition)
3742f86ba45SStephan Aßmus {
3752f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
3762f86ba45SStephan Aßmus 		return;
3772f86ba45SStephan Aßmus 
3782f86ba45SStephan Aßmus 	_DrawOuterResessedFrame(view, rect, base, 0.6);
3792f86ba45SStephan Aßmus 
3802f86ba45SStephan Aßmus 	// colors
3812f86ba45SStephan Aßmus 	rgb_color dark1BorderColor = tint_color(base, 1.3);
3822f86ba45SStephan Aßmus 	rgb_color dark2BorderColor = tint_color(base, 1.2);
3832f86ba45SStephan Aßmus 	rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
3842f86ba45SStephan Aßmus 	rgb_color dark2FilledBorderColor = tint_color(barColor, 1.45);
3852f86ba45SStephan Aßmus 
3862f86ba45SStephan Aßmus 	BRect filledRect(rect);
3872f86ba45SStephan Aßmus 	filledRect.right = progressPosition - 1;
3882f86ba45SStephan Aßmus 
3892f86ba45SStephan Aßmus 	BRect nonfilledRect(rect);
3902f86ba45SStephan Aßmus 	nonfilledRect.left = progressPosition;
3912f86ba45SStephan Aßmus 
3922f86ba45SStephan Aßmus 	bool filledSurface = filledRect.Width() > 0;
3932f86ba45SStephan Aßmus 	bool nonfilledSurface = nonfilledRect.Width() > 0;
3942f86ba45SStephan Aßmus 
3952f86ba45SStephan Aßmus 	if (filledSurface) {
3962f86ba45SStephan Aßmus 		_DrawFrame(view, filledRect,
3972f86ba45SStephan Aßmus 			dark1FilledBorderColor, dark1FilledBorderColor,
3982f86ba45SStephan Aßmus 			dark2FilledBorderColor, dark2FilledBorderColor);
3992f86ba45SStephan Aßmus 
4002f86ba45SStephan Aßmus 		_FillGlossyGradient(view, filledRect, barColor, 0.55, 0.68, 0.76, 0.90);
4012f86ba45SStephan Aßmus 	}
4022f86ba45SStephan Aßmus 
4032f86ba45SStephan Aßmus 	if (nonfilledSurface) {
4042f86ba45SStephan Aßmus 		_DrawFrame(view, nonfilledRect, dark1BorderColor, dark1BorderColor,
4052f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor,
4062f86ba45SStephan Aßmus 			B_TOP_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
4072f86ba45SStephan Aßmus 
4082f86ba45SStephan Aßmus 		if (nonfilledRect.left < nonfilledRect.right) {
4092f86ba45SStephan Aßmus 			// shadow from fill bar, or left border
4102f86ba45SStephan Aßmus 			rgb_color leftBorder = dark1BorderColor;
4112f86ba45SStephan Aßmus 			if (filledSurface)
4122f86ba45SStephan Aßmus 				leftBorder = tint_color(base, 0.50);
4132f86ba45SStephan Aßmus 			view->SetHighColor(leftBorder);
4142f86ba45SStephan Aßmus 			view->StrokeLine(nonfilledRect.LeftTop(),
4152f86ba45SStephan Aßmus 				nonfilledRect.LeftBottom());
4162f86ba45SStephan Aßmus 			nonfilledRect.left++;
4172f86ba45SStephan Aßmus 		}
4182f86ba45SStephan Aßmus 
4192f86ba45SStephan Aßmus 		_FillGradient(view, nonfilledRect, base, 0.25, 0.06);
4202f86ba45SStephan Aßmus 	}
4212f86ba45SStephan Aßmus }
4222f86ba45SStephan Aßmus 
4232f86ba45SStephan Aßmus 
4242f86ba45SStephan Aßmus void
4252f86ba45SStephan Aßmus BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect,
4262f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4272f86ba45SStephan Aßmus {
4282f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4292f86ba45SStephan Aßmus 		return;
4302f86ba45SStephan Aßmus 
4312f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
4322f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
4332f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
4342f86ba45SStephan Aßmus 
435a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4364f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags);
4372f86ba45SStephan Aßmus 
4382f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.15);
4392f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.15);
440a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
4412f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
4422f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.48);
4432f86ba45SStephan Aßmus 
4442f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
4452f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
4462f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
4472f86ba45SStephan Aßmus 
4482f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
4492f86ba45SStephan Aßmus 	} else {
4504f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags);
4512f86ba45SStephan Aßmus 
4522f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.40);
4532f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.38);
4542f86ba45SStephan Aßmus 	}
4552f86ba45SStephan Aßmus 
456a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
4572f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
4582f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
4592f86ba45SStephan Aßmus 	}
4602f86ba45SStephan Aßmus 
4612f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
4622f86ba45SStephan Aßmus 		dark1BorderColor, dark1BorderColor,
4632f86ba45SStephan Aßmus 		dark2BorderColor, dark2BorderColor);
4642f86ba45SStephan Aßmus 
465a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4662f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.4, 0.2);
4672f86ba45SStephan Aßmus 	} else {
4682f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.15, 0.0);
4692f86ba45SStephan Aßmus 	}
4702f86ba45SStephan Aßmus 
4712f86ba45SStephan Aßmus 	rgb_color markColor;
4722f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
4732f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
4742f86ba45SStephan Aßmus 
4752f86ba45SStephan Aßmus 		rect.InsetBy(2, 2);
4762f86ba45SStephan Aßmus 		view->SetPenSize(max_c(1.0, ceilf(rect.Width() / 3.5)));
4772f86ba45SStephan Aßmus 		view->SetDrawingMode(B_OP_OVER);
4782f86ba45SStephan Aßmus 
4792f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightBottom());
4802f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightTop());
4812f86ba45SStephan Aßmus 	}
4822f86ba45SStephan Aßmus }
4832f86ba45SStephan Aßmus 
4842f86ba45SStephan Aßmus 
4852f86ba45SStephan Aßmus void
4862f86ba45SStephan Aßmus BControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect,
4872f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4882f86ba45SStephan Aßmus {
4892f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4902f86ba45SStephan Aßmus 		return;
4912f86ba45SStephan Aßmus 
4922f86ba45SStephan Aßmus 	rgb_color borderColor;
4932f86ba45SStephan Aßmus 	rgb_color bevelLight;
4942f86ba45SStephan Aßmus 	rgb_color bevelShadow;
4952f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
4962f86ba45SStephan Aßmus 
497a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4982f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.15);
4992f86ba45SStephan Aßmus 		bevelLight = base;
5002f86ba45SStephan Aßmus 		bevelShadow = base;
501a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
5022f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.50);
5032f86ba45SStephan Aßmus 		bevelLight = borderColor;
5042f86ba45SStephan Aßmus 		bevelShadow = borderColor;
5052f86ba45SStephan Aßmus 	} else {
5062f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.45);
5072f86ba45SStephan Aßmus 		bevelLight = tint_color(base, 0.55);
5082f86ba45SStephan Aßmus 		bevelShadow = tint_color(base, 1.11);
5092f86ba45SStephan Aßmus 	}
5102f86ba45SStephan Aßmus 
511a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
5122f86ba45SStephan Aßmus 		borderColor = navigationColor;
5132f86ba45SStephan Aßmus 	}
5142f86ba45SStephan Aßmus 
5152f86ba45SStephan Aßmus 	BGradientLinear bevelGradient;
5162f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelShadow, 0);
5172f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelLight, 255);
5182f86ba45SStephan Aßmus 	bevelGradient.SetStart(rect.LeftTop());
5192f86ba45SStephan Aßmus 	bevelGradient.SetEnd(rect.RightBottom());
5202f86ba45SStephan Aßmus 
5212f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5222f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5232f86ba45SStephan Aßmus 
5242f86ba45SStephan Aßmus 	bevelGradient.MakeEmpty();
5252f86ba45SStephan Aßmus 	bevelGradient.AddColor(borderColor, 0);
5262f86ba45SStephan Aßmus 	bevelGradient.AddColor(tint_color(borderColor, 0.8), 255);
5272f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5282f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5292f86ba45SStephan Aßmus 
5302f86ba45SStephan Aßmus 	float topTint;
5312f86ba45SStephan Aßmus 	float bottomTint;
532a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5332f86ba45SStephan Aßmus 		topTint = 0.4;
5342f86ba45SStephan Aßmus 		bottomTint = 0.2;
5352f86ba45SStephan Aßmus 	} else {
5362f86ba45SStephan Aßmus 		topTint = 0.15;
5372f86ba45SStephan Aßmus 		bottomTint = 0.0;
5382f86ba45SStephan Aßmus 	}
5392f86ba45SStephan Aßmus 
5402f86ba45SStephan Aßmus 	BGradientLinear gradient;
5412f86ba45SStephan Aßmus 	_MakeGradient(gradient, rect, base, topTint, bottomTint);
5422f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
5432f86ba45SStephan Aßmus 
5442f86ba45SStephan Aßmus 	rgb_color markColor;
5452f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
5462f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
5472f86ba45SStephan Aßmus 		rect.InsetBy(3, 3);
5482f86ba45SStephan Aßmus 		view->FillEllipse(rect);
5492f86ba45SStephan Aßmus 	}
5502f86ba45SStephan Aßmus }
5512f86ba45SStephan Aßmus 
5522f86ba45SStephan Aßmus 
5532f86ba45SStephan Aßmus void
5542f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2,
5552f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
5562f86ba45SStephan Aßmus 	enum orientation orientation)
5572f86ba45SStephan Aßmus {
5582f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect1, updateRect, base, flags, orientation);
5592f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation);
5602f86ba45SStephan Aßmus }
5612f86ba45SStephan Aßmus 
56288969219SJohn Scipione 
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 
577a884b43bSJohn 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 
685a884b43bSJohn 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
767a884b43bSJohn 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 
777a884b43bSJohn 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 
809*5666b4f7SJohn Scipione 	// save the clipping constraints of the view
810*5666b4f7SJohn Scipione 	view->PushState();
811*5666b4f7SJohn Scipione 
8122f86ba45SStephan Aßmus 	// separate the bar in two sides
8132f86ba45SStephan Aßmus 	float sliderPosition;
8142f86ba45SStephan Aßmus 	BRect leftBarSide = rect;
8152f86ba45SStephan Aßmus 	BRect rightBarSide = rect;
8162f86ba45SStephan Aßmus 
8172f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8182f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.left + 2 + (rect.Width() - 2)
8192f86ba45SStephan Aßmus 			* sliderScale);
8202f86ba45SStephan Aßmus 		leftBarSide.right = sliderPosition - 1;
8212f86ba45SStephan Aßmus 		rightBarSide.left = sliderPosition;
8222f86ba45SStephan Aßmus 	} else {
823f3997b74SStephan Aßmus 		// NOTE: position is reverse of coords
8242f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
825f3997b74SStephan Aßmus 			* (1.0 - sliderScale));
826f3997b74SStephan Aßmus 		leftBarSide.top = sliderPosition;
827f3997b74SStephan Aßmus 		rightBarSide.bottom = sliderPosition - 1;
8282f86ba45SStephan Aßmus 	}
8292f86ba45SStephan Aßmus 
8302f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
8312f86ba45SStephan Aßmus 	BRegion region(rect);
8322f86ba45SStephan Aßmus 	region.Exclude(rightBarSide);
8332f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8342f86ba45SStephan Aßmus 
8352f86ba45SStephan Aßmus 	view->PushState();
8362f86ba45SStephan Aßmus 
8372f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
8382f86ba45SStephan Aßmus 		orientation);
8392f86ba45SStephan Aßmus 
8402f86ba45SStephan Aßmus 	view->PopState();
8412f86ba45SStephan Aßmus 
8422f86ba45SStephan Aßmus 	region.Set(rect);
8432f86ba45SStephan Aßmus 	region.Exclude(leftBarSide);
8442f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8452f86ba45SStephan Aßmus 
8462f86ba45SStephan Aßmus 	view->PushState();
8472f86ba45SStephan Aßmus 
8482f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
8492f86ba45SStephan Aßmus 		orientation);
8502f86ba45SStephan Aßmus 
8512f86ba45SStephan Aßmus 	view->PopState();
8523244c2bcSJohn Scipione 
853*5666b4f7SJohn Scipione 	// restore the clipping constraints of the view
854*5666b4f7SJohn Scipione 	view->PopState();
8552f86ba45SStephan Aßmus }
8562f86ba45SStephan Aßmus 
8572f86ba45SStephan Aßmus 
8582f86ba45SStephan Aßmus void
8592f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
8602f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color fillColor, uint32 flags,
8612f86ba45SStephan Aßmus 	enum orientation orientation)
8622f86ba45SStephan Aßmus {
8632f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
8642f86ba45SStephan Aßmus 		return;
8652f86ba45SStephan Aßmus 
8662f86ba45SStephan Aßmus 	// separate the rect into corners
8672f86ba45SStephan Aßmus 	BRect leftCorner(rect);
8682f86ba45SStephan Aßmus 	BRect rightCorner(rect);
8692f86ba45SStephan Aßmus 	BRect barRect(rect);
8702f86ba45SStephan Aßmus 
8712f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8722f86ba45SStephan Aßmus 		leftCorner.right = leftCorner.left + leftCorner.Height();
8732f86ba45SStephan Aßmus 		rightCorner.left = rightCorner.right - rightCorner.Height();
8742f86ba45SStephan Aßmus 		barRect.left += ceilf(barRect.Height() / 2);
8752f86ba45SStephan Aßmus 		barRect.right -= ceilf(barRect.Height() / 2);
8762f86ba45SStephan Aßmus 	} else {
8772f86ba45SStephan Aßmus 		leftCorner.bottom = leftCorner.top + leftCorner.Width();
8782f86ba45SStephan Aßmus 		rightCorner.top = rightCorner.bottom - rightCorner.Width();
8792f86ba45SStephan Aßmus 		barRect.top += ceilf(barRect.Width() / 2);
8802f86ba45SStephan Aßmus 		barRect.bottom -= ceilf(barRect.Width() / 2);
8812f86ba45SStephan Aßmus 	}
8822f86ba45SStephan Aßmus 
8832f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
8842f86ba45SStephan Aßmus 	BRegion region(rect);
8852f86ba45SStephan Aßmus 	region.Exclude(barRect);
8862f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8872f86ba45SStephan Aßmus 
88861ac1a85SStephan Aßmus 	if ((flags & B_BLEND_FRAME) == 0) {
8892f86ba45SStephan Aßmus 		view->SetHighColor(base);
8902f86ba45SStephan Aßmus 		view->FillRect(rect);
89161ac1a85SStephan Aßmus 	}
8922f86ba45SStephan Aßmus 
8932f86ba45SStephan Aßmus 	// figure out the tints to be used
8942f86ba45SStephan Aßmus 	float edgeLightTint;
8952f86ba45SStephan Aßmus 	float edgeShadowTint;
8962f86ba45SStephan Aßmus 	float frameLightTint;
8972f86ba45SStephan Aßmus 	float frameShadowTint;
8982f86ba45SStephan Aßmus 	float fillLightTint;
8992f86ba45SStephan Aßmus 	float fillShadowTint;
90061ac1a85SStephan Aßmus 	uint8 edgeLightAlpha;
90161ac1a85SStephan Aßmus 	uint8 edgeShadowAlpha;
90261ac1a85SStephan Aßmus 	uint8 frameLightAlpha;
90361ac1a85SStephan Aßmus 	uint8 frameShadowAlpha;
9042f86ba45SStephan Aßmus 
905a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
9062f86ba45SStephan Aßmus 		edgeLightTint = 1.0;
9072f86ba45SStephan Aßmus 		edgeShadowTint = 1.0;
9082f86ba45SStephan Aßmus 		frameLightTint = 1.20;
9092f86ba45SStephan Aßmus 		frameShadowTint = 1.25;
9102f86ba45SStephan Aßmus 		fillLightTint = 0.9;
9112f86ba45SStephan Aßmus 		fillShadowTint = 1.05;
91210ddee8dSStephan Aßmus 		edgeLightAlpha = 12;
91310ddee8dSStephan Aßmus 		edgeShadowAlpha = 12;
91461ac1a85SStephan Aßmus 		frameLightAlpha = 40;
91561ac1a85SStephan Aßmus 		frameShadowAlpha = 45;
9162f86ba45SStephan Aßmus 
9172f86ba45SStephan Aßmus 		fillColor.red = uint8(fillColor.red * 0.4 + base.red * 0.6);
9182f86ba45SStephan Aßmus 		fillColor.green = uint8(fillColor.green * 0.4 + base.green * 0.6);
9192f86ba45SStephan Aßmus 		fillColor.blue = uint8(fillColor.blue * 0.4 + base.blue * 0.6);
9202f86ba45SStephan Aßmus 	} else {
9212f86ba45SStephan Aßmus 		edgeLightTint = 0.65;
9222f86ba45SStephan Aßmus 		edgeShadowTint = 1.07;
9232f86ba45SStephan Aßmus 		frameLightTint = 1.40;
9242f86ba45SStephan Aßmus 		frameShadowTint = 1.50;
9252f86ba45SStephan Aßmus 		fillLightTint = 0.8;
9262f86ba45SStephan Aßmus 		fillShadowTint = 1.1;
92710ddee8dSStephan Aßmus 		edgeLightAlpha = 15;
92810ddee8dSStephan Aßmus 		edgeShadowAlpha = 15;
92961ac1a85SStephan Aßmus 		frameLightAlpha = 92;
93061ac1a85SStephan Aßmus 		frameShadowAlpha = 107;
9312f86ba45SStephan Aßmus 	}
9322f86ba45SStephan Aßmus 
93361ac1a85SStephan Aßmus 	rgb_color edgeLightColor;
93461ac1a85SStephan Aßmus 	rgb_color edgeShadowColor;
93561ac1a85SStephan Aßmus 	rgb_color frameLightColor;
93661ac1a85SStephan Aßmus 	rgb_color frameShadowColor;
9372f86ba45SStephan Aßmus 	rgb_color fillLightColor = tint_color(fillColor, fillLightTint);
9382f86ba45SStephan Aßmus 	rgb_color fillShadowColor = tint_color(fillColor, fillShadowTint);
9392f86ba45SStephan Aßmus 
94061ac1a85SStephan Aßmus 	drawing_mode oldMode = view->DrawingMode();
94161ac1a85SStephan Aßmus 
942a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
94361ac1a85SStephan Aßmus 		edgeLightColor = (rgb_color){ 255, 255, 255, edgeLightAlpha };
94461ac1a85SStephan Aßmus 		edgeShadowColor = (rgb_color){ 0, 0, 0, edgeShadowAlpha };
94561ac1a85SStephan Aßmus 		frameLightColor = (rgb_color){ 0, 0, 0, frameLightAlpha };
94661ac1a85SStephan Aßmus 		frameShadowColor = (rgb_color){ 0, 0, 0, frameShadowAlpha };
94761ac1a85SStephan Aßmus 
94861ac1a85SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
94961ac1a85SStephan Aßmus 	} else {
95061ac1a85SStephan Aßmus 		edgeLightColor = tint_color(base, edgeLightTint);
95161ac1a85SStephan Aßmus 		edgeShadowColor = tint_color(base, edgeShadowTint);
95261ac1a85SStephan Aßmus 		frameLightColor = tint_color(fillColor, frameLightTint);
95361ac1a85SStephan Aßmus 		frameShadowColor = tint_color(fillColor, frameShadowTint);
95461ac1a85SStephan Aßmus 	}
95561ac1a85SStephan Aßmus 
9562f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
9572f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
9582f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9592f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
9602f86ba45SStephan Aßmus 
9612f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
9622f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9632f86ba45SStephan Aßmus 			fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
9642f86ba45SStephan Aßmus 	} else {
9652f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
9662f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9672f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
9682f86ba45SStephan Aßmus 
9692f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
9702f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9712f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
9722f86ba45SStephan Aßmus 	}
9732f86ba45SStephan Aßmus 
9742f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(NULL);
9752f86ba45SStephan Aßmus 
9762f86ba45SStephan Aßmus 	view->BeginLineArray(4);
9772f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
9782f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), edgeShadowColor);
9792f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
9802f86ba45SStephan Aßmus 			edgeLightColor);
9812f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
9822f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), frameShadowColor);
9832f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
9842f86ba45SStephan Aßmus 			frameLightColor);
9852f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
9862f86ba45SStephan Aßmus 	} else {
9872f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), edgeShadowColor);
9882f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
9892f86ba45SStephan Aßmus 			edgeLightColor);
9902f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
9912f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), frameShadowColor);
9922f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
9932f86ba45SStephan Aßmus 			frameLightColor);
9942f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
9952f86ba45SStephan Aßmus 	}
9962f86ba45SStephan Aßmus 	view->EndLineArray();
9972f86ba45SStephan Aßmus 
99861ac1a85SStephan Aßmus 	view->SetDrawingMode(oldMode);
99961ac1a85SStephan Aßmus 
10002f86ba45SStephan Aßmus 	_FillGradient(view, barRect, fillColor, fillShadowTint, fillLightTint,
10012f86ba45SStephan Aßmus 		orientation);
10022f86ba45SStephan Aßmus }
10032f86ba45SStephan Aßmus 
10042f86ba45SStephan Aßmus 
10052f86ba45SStephan Aßmus void
10062f86ba45SStephan Aßmus BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
10072f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, enum orientation orientation)
10082f86ba45SStephan Aßmus {
10092f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
10102f86ba45SStephan Aßmus 		return;
10112f86ba45SStephan Aßmus 
10122f86ba45SStephan Aßmus 	// figure out frame color
10132f86ba45SStephan Aßmus 	rgb_color frameLightColor;
10142f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
10152f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
10162f86ba45SStephan Aßmus 
1017a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
10182f86ba45SStephan Aßmus 		// focused
10192f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
10202f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
10212f86ba45SStephan Aßmus 	} else {
10222f86ba45SStephan Aßmus 		// figure out the tints to be used
10232f86ba45SStephan Aßmus 		float frameLightTint;
10242f86ba45SStephan Aßmus 		float frameShadowTint;
10252f86ba45SStephan Aßmus 
1026a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
10272f86ba45SStephan Aßmus 			frameLightTint = 1.30;
10282f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
10292f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
10302f86ba45SStephan Aßmus 		} else {
10312f86ba45SStephan Aßmus 			frameLightTint = 1.6;
10322f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
10332f86ba45SStephan Aßmus 		}
10342f86ba45SStephan Aßmus 
10352f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
10362f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
10372f86ba45SStephan Aßmus 	}
10382f86ba45SStephan Aßmus 
10392f86ba45SStephan Aßmus 	BRect originalRect(rect);
10402f86ba45SStephan Aßmus 	rect.right--;
10412f86ba45SStephan Aßmus 	rect.bottom--;
10422f86ba45SStephan Aßmus 
10432f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor,
10442f86ba45SStephan Aßmus 		frameShadowColor, frameShadowColor);
10452f86ba45SStephan Aßmus 
10462f86ba45SStephan Aßmus 	flags &= ~B_ACTIVATED;
10472f86ba45SStephan Aßmus 	DrawButtonBackground(view, rect, updateRect, base, flags);
10482f86ba45SStephan Aßmus 
10492f86ba45SStephan Aßmus 	// thumb shadow
10502f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
10512f86ba45SStephan Aßmus 	view->SetHighColor(shadowColor);
10522f86ba45SStephan Aßmus 	originalRect.left++;
10532f86ba45SStephan Aßmus 	originalRect.top++;
10542f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.LeftBottom(), originalRect.RightBottom());
10552f86ba45SStephan Aßmus 	originalRect.bottom--;
10562f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.RightTop(), originalRect.RightBottom());
10572f86ba45SStephan Aßmus 
10582f86ba45SStephan Aßmus 	// thumb edge
10592f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
10602f86ba45SStephan Aßmus 		rect.InsetBy(0, floorf(rect.Height() / 4));
10612f86ba45SStephan Aßmus 		rect.left = floorf((rect.left + rect.right) / 2);
10622f86ba45SStephan Aßmus 		rect.right = rect.left + 1;
10632f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
10642f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
10652f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
10662f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
10672f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
10682f86ba45SStephan Aßmus 		lightColor.alpha = 128;
10692f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
10702f86ba45SStephan Aßmus 		view->StrokeLine(rect.RightTop(), rect.RightBottom());
10712f86ba45SStephan Aßmus 	} else {
10722f86ba45SStephan Aßmus 		rect.InsetBy(floorf(rect.Width() / 4), 0);
10732f86ba45SStephan Aßmus 		rect.top = floorf((rect.top + rect.bottom) / 2);
10742f86ba45SStephan Aßmus 		rect.bottom = rect.top + 1;
10752f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
10762f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
10772f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
10782f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightTop());
10792f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
10802f86ba45SStephan Aßmus 		lightColor.alpha = 128;
10812f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
10822f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
10832f86ba45SStephan Aßmus 	}
10842f86ba45SStephan Aßmus 
10852f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
10862f86ba45SStephan Aßmus }
10872f86ba45SStephan Aßmus 
10882f86ba45SStephan Aßmus 
10892f86ba45SStephan Aßmus void
10902f86ba45SStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
10912f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
10922f86ba45SStephan Aßmus 	enum orientation orientation)
10932f86ba45SStephan Aßmus {
10948ee9217eSStephan Aßmus 	DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation);
10958ee9217eSStephan Aßmus }
10968ee9217eSStephan Aßmus 
10978ee9217eSStephan Aßmus 
10988ee9217eSStephan Aßmus void
10998ee9217eSStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
11008ee9217eSStephan Aßmus 	const BRect& updateRect, const rgb_color& base, const rgb_color& fill,
11018ee9217eSStephan Aßmus 	uint32 flags, enum orientation orientation)
11028ee9217eSStephan Aßmus {
11032f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
11042f86ba45SStephan Aßmus 		return;
11052f86ba45SStephan Aßmus 
11062f86ba45SStephan Aßmus 	// figure out frame color
11072f86ba45SStephan Aßmus 	rgb_color frameLightColor;
11082f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
11092f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
11102f86ba45SStephan Aßmus 
11112f86ba45SStephan Aßmus 	float topTint = 0.49;
11122f86ba45SStephan Aßmus 	float middleTint1 = 0.62;
11132f86ba45SStephan Aßmus 	float middleTint2 = 0.76;
11142f86ba45SStephan Aßmus 	float bottomTint = 0.90;
11152f86ba45SStephan Aßmus 
1116a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
11172f86ba45SStephan Aßmus 		topTint = (topTint + B_NO_TINT) / 2;
11182f86ba45SStephan Aßmus 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
11192f86ba45SStephan Aßmus 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
11202f86ba45SStephan Aßmus 		bottomTint = (bottomTint + B_NO_TINT) / 2;
1121a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
11222f86ba45SStephan Aßmus 		static const float kHoverTintFactor = 0.85;
11232f86ba45SStephan Aßmus 		topTint *= kHoverTintFactor;
11242f86ba45SStephan Aßmus 		middleTint1 *= kHoverTintFactor;
11252f86ba45SStephan Aßmus 		middleTint2 *= kHoverTintFactor;
11262f86ba45SStephan Aßmus 		bottomTint *= kHoverTintFactor;
11272f86ba45SStephan Aßmus 	}
11282f86ba45SStephan Aßmus 
1129a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
11302f86ba45SStephan Aßmus 		// focused
11312f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
11322f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
11332f86ba45SStephan Aßmus 	} else {
11342f86ba45SStephan Aßmus 		// figure out the tints to be used
11352f86ba45SStephan Aßmus 		float frameLightTint;
11362f86ba45SStephan Aßmus 		float frameShadowTint;
11372f86ba45SStephan Aßmus 
1138a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
11392f86ba45SStephan Aßmus 			frameLightTint = 1.30;
11402f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
11412f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
11422f86ba45SStephan Aßmus 		} else {
11432f86ba45SStephan Aßmus 			frameLightTint = 1.6;
11442f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
11452f86ba45SStephan Aßmus 		}
11462f86ba45SStephan Aßmus 
11472f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
11482f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
11492f86ba45SStephan Aßmus 	}
11502f86ba45SStephan Aßmus 
11518ee9217eSStephan Aßmus 	// make room for the shadow
11528ee9217eSStephan Aßmus 	rect.right--;
11538ee9217eSStephan Aßmus 	rect.bottom--;
11542f86ba45SStephan Aßmus 
11552f86ba45SStephan Aßmus 	uint32 viewFlags = view->Flags();
11562f86ba45SStephan Aßmus 	view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
11572f86ba45SStephan Aßmus 	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
11582f86ba45SStephan Aßmus 
1159f3997b74SStephan Aßmus 	float centerh = (rect.left + rect.right) / 2;
1160f3997b74SStephan Aßmus 	float centerv = (rect.top + rect.bottom) / 2;
11612f86ba45SStephan Aßmus 
11628ee9217eSStephan Aßmus 	BShape shape;
1163f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
11648ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
11658ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
11668ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
1167f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5));
11688ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
1169f3997b74SStephan Aßmus 	} else {
1170f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5));
1171f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
1172f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5));
1173f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, centerv + 0.5));
1174f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5));
1175f3997b74SStephan Aßmus 	}
11768ee9217eSStephan Aßmus 	shape.Close();
11778ee9217eSStephan Aßmus 
11788ee9217eSStephan Aßmus 	view->MovePenTo(BPoint(1, 1));
11798ee9217eSStephan Aßmus 
11808ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
11818ee9217eSStephan Aßmus 	view->SetHighColor(shadowColor);
11828ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
11838ee9217eSStephan Aßmus 
11848ee9217eSStephan Aßmus 	view->MovePenTo(B_ORIGIN);
11858ee9217eSStephan Aßmus 
11868ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
11872f86ba45SStephan Aßmus 	view->SetHighColor(frameLightColor);
11888ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
11892f86ba45SStephan Aßmus 
11902f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
11918ee9217eSStephan Aßmus 	shape.Clear();
1192f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
11938ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
11948ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1195f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top));
1196f3997b74SStephan Aßmus 	} else {
1197f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 1, rect.top));
1198f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1199f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left, centerv + 0.5));
1200f3997b74SStephan Aßmus 	}
12018ee9217eSStephan Aßmus 	shape.Close();
12022f86ba45SStephan Aßmus 
12032f86ba45SStephan Aßmus 	BGradientLinear gradient;
1204a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12058ee9217eSStephan Aßmus 		_MakeGradient(gradient, rect, fill, topTint, bottomTint);
12062f86ba45SStephan Aßmus 	} else {
12078ee9217eSStephan Aßmus 		_MakeGlossyGradient(gradient, rect, fill, topTint, middleTint1,
12082f86ba45SStephan Aßmus 			middleTint2, bottomTint);
12092f86ba45SStephan Aßmus 	}
12102f86ba45SStephan Aßmus 
12118ee9217eSStephan Aßmus 	view->FillShape(&shape, gradient);
12122f86ba45SStephan Aßmus 
12132f86ba45SStephan Aßmus 	view->SetFlags(viewFlags);
12142f86ba45SStephan Aßmus }
12152f86ba45SStephan Aßmus 
12162f86ba45SStephan Aßmus 
12172f86ba45SStephan Aßmus void
12182f86ba45SStephan Aßmus BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
12192f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, int32 count,
12202f86ba45SStephan Aßmus 	hash_mark_location location, uint32 flags, enum orientation orientation)
12212f86ba45SStephan Aßmus {
12222f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
12232f86ba45SStephan Aßmus 		return;
12242f86ba45SStephan Aßmus 
12252f86ba45SStephan Aßmus 	rgb_color lightColor;
12262f86ba45SStephan Aßmus 	rgb_color darkColor;
12272f86ba45SStephan Aßmus 
1228a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12292f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.9);
12302f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.07);
12312f86ba45SStephan Aßmus 	} else {
12322f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.8);
12332f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.14);
12342f86ba45SStephan Aßmus 	}
12352f86ba45SStephan Aßmus 
12362f86ba45SStephan Aßmus 	int32 hashMarkCount = max_c(count, 2);
12372f86ba45SStephan Aßmus 		// draw at least two hashmarks at min/max if
12382f86ba45SStephan Aßmus 		// fHashMarks != B_HASH_MARKS_NONE
12392f86ba45SStephan Aßmus 	float factor;
12402f86ba45SStephan Aßmus 	float startPos;
12412f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12422f86ba45SStephan Aßmus 		factor = (rect.Width() - 2) / (hashMarkCount - 1);
12432f86ba45SStephan Aßmus 		startPos = rect.left + 1;
12442f86ba45SStephan Aßmus 	} else {
12452f86ba45SStephan Aßmus 		factor = (rect.Height() - 2) / (hashMarkCount - 1);
12462f86ba45SStephan Aßmus 		startPos = rect.top + 1;
12472f86ba45SStephan Aßmus 	}
12482f86ba45SStephan Aßmus 
12492f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_TOP) {
12502f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
12512f86ba45SStephan Aßmus 
12522f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
12532f86ba45SStephan Aßmus 			float pos = startPos;
12542f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12552f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.top),
12562f86ba45SStephan Aßmus 							  BPoint(pos, rect.top + 4), darkColor);
12572f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.top),
12582f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.top + 4), lightColor);
12592f86ba45SStephan Aßmus 
12602f86ba45SStephan Aßmus 				pos += factor;
12612f86ba45SStephan Aßmus 			}
12622f86ba45SStephan Aßmus 		} else {
12632f86ba45SStephan Aßmus 			float pos = startPos;
12642f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12652f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos),
12662f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos), darkColor);
12672f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos + 1),
12682f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos + 1), lightColor);
12692f86ba45SStephan Aßmus 
12702f86ba45SStephan Aßmus 				pos += factor;
12712f86ba45SStephan Aßmus 			}
12722f86ba45SStephan Aßmus 		}
12732f86ba45SStephan Aßmus 
12742f86ba45SStephan Aßmus 		view->EndLineArray();
12752f86ba45SStephan Aßmus 	}
12762f86ba45SStephan Aßmus 
12772f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_BOTTOM) {
12782f86ba45SStephan Aßmus 
12792f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
12802f86ba45SStephan Aßmus 
12812f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
12822f86ba45SStephan Aßmus 			float pos = startPos;
12832f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12842f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.bottom - 4),
12852f86ba45SStephan Aßmus 							  BPoint(pos, rect.bottom), darkColor);
12862f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.bottom - 4),
12872f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.bottom), lightColor);
12882f86ba45SStephan Aßmus 
12892f86ba45SStephan Aßmus 				pos += factor;
12902f86ba45SStephan Aßmus 			}
12912f86ba45SStephan Aßmus 		} else {
12922f86ba45SStephan Aßmus 			float pos = startPos;
12932f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12942f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos),
12952f86ba45SStephan Aßmus 							  BPoint(rect.right, pos), darkColor);
12962f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos + 1),
12972f86ba45SStephan Aßmus 							  BPoint(rect.right, pos + 1), lightColor);
12982f86ba45SStephan Aßmus 
12992f86ba45SStephan Aßmus 				pos += factor;
13002f86ba45SStephan Aßmus 			}
13012f86ba45SStephan Aßmus 		}
13022f86ba45SStephan Aßmus 
13032f86ba45SStephan Aßmus 		view->EndLineArray();
13042f86ba45SStephan Aßmus 	}
13052f86ba45SStephan Aßmus }
13062f86ba45SStephan Aßmus 
13072f86ba45SStephan Aßmus 
13082f86ba45SStephan Aßmus void
13092f86ba45SStephan Aßmus BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
13102f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
13112f86ba45SStephan Aßmus {
13122f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
13132f86ba45SStephan Aßmus 		return;
13142f86ba45SStephan Aßmus 
1315*5666b4f7SJohn Scipione 	// save the clipping constraints of the view
1316*5666b4f7SJohn Scipione 	view->PushState();
1317a884b43bSJohn Scipione 
1318*5666b4f7SJohn Scipione 	// set clipping constraints to updateRect
1319*5666b4f7SJohn Scipione 	BRegion clipping(updateRect);
1320a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
1321a884b43bSJohn Scipione 
13222f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
13232f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
13242f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
13252f86ba45SStephan Aßmus 	rgb_color frameLightColor;
13262f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
13272f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
13282f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
13292f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
13302f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
13312f86ba45SStephan Aßmus 
1332a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
13332f86ba45SStephan Aßmus 		edgeLightColor = base;
1334a884b43bSJohn Scipione 		edgeShadowColor = base;
13352f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1336a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13372f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1338a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13392f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
13402f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
13412f86ba45SStephan Aßmus 	} else {
13422f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1343a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
13442f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1345a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13462f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.6);
1347a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13482f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.75), 0);
13492f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.03), 255);
13502f86ba45SStephan Aßmus 	}
135112ea5a2cSStephan Aßmus 
1352a884b43bSJohn Scipione 	static const float kRoundCornerRadius = 4.0f;
13532f86ba45SStephan Aßmus 
1354a884b43bSJohn Scipione 	// left top corner dimensions
1355a884b43bSJohn Scipione 	BRect leftTopCorner(rect);
1356a884b43bSJohn Scipione 	leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
1357a884b43bSJohn Scipione 	leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1358a884b43bSJohn Scipione 	clipping.Exclude(leftTopCorner);
13592f86ba45SStephan Aßmus 
1360a884b43bSJohn Scipione 	// draw the left top corner
1361a884b43bSJohn Scipione 	_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
1362a884b43bSJohn Scipione 		edgeShadowColor, frameLightColor, bevelLightColor,
1363a884b43bSJohn Scipione 		fillGradient);
13642f86ba45SStephan Aßmus 
1365a884b43bSJohn Scipione 	// right top corner dimensions
1366a884b43bSJohn Scipione 	BRect rightTopCorner(rect);
1367a884b43bSJohn Scipione 	rightTopCorner.right = floorf(rect.right);
1368a884b43bSJohn Scipione 	rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
1369a884b43bSJohn Scipione 	rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1370a884b43bSJohn Scipione 	clipping.Exclude(rightTopCorner);
13712f86ba45SStephan Aßmus 
1372a884b43bSJohn Scipione 	// draw the right top corner
1373a884b43bSJohn Scipione 	_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
1374a884b43bSJohn Scipione 		edgeShadowColor, edgeLightColor, frameLightColor,
1375a884b43bSJohn Scipione 		frameShadowColor, bevelLightColor, bevelShadowColor,
1376a884b43bSJohn Scipione 		fillGradient);
13772f86ba45SStephan Aßmus 
1378a884b43bSJohn Scipione 	// clip out the corners
13792f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&clipping);
13802f86ba45SStephan Aßmus 
1381a884b43bSJohn Scipione 	// draw the rest of frame and fill
13822f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
13832f86ba45SStephan Aßmus 		edgeLightColor,
13842f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
13852f86ba45SStephan Aßmus 	if ((borders & B_LEFT_BORDER) == 0)
13862f86ba45SStephan Aßmus 		rect.left++;
13872f86ba45SStephan Aßmus 	if ((borders & B_RIGHT_BORDER) == 0)
13882f86ba45SStephan Aßmus 		rect.right--;
13892f86ba45SStephan Aßmus 
13902f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
13912f86ba45SStephan Aßmus 		frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
13922f86ba45SStephan Aßmus 
13932f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
13942f86ba45SStephan Aßmus 		bevelShadowColor);
13952f86ba45SStephan Aßmus 
13962f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
13972f86ba45SStephan Aßmus 
1398*5666b4f7SJohn Scipione 	// restore the clipping constraints of the view
1399*5666b4f7SJohn Scipione 	view->PopState();
14002f86ba45SStephan Aßmus }
14012f86ba45SStephan Aßmus 
14022f86ba45SStephan Aßmus 
14032f86ba45SStephan Aßmus void
140483aff015SPhilippe Houdoin BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
14052f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
14062f86ba45SStephan Aßmus {
14072f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
14082f86ba45SStephan Aßmus 		return;
14092f86ba45SStephan Aßmus 
14102f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
14112f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
14122f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
14132f86ba45SStephan Aßmus 	rgb_color frameLightColor;
14142f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
14152f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
14162f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
14172f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
14182f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
14192f86ba45SStephan Aßmus 
1420a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
14212f86ba45SStephan Aßmus 		edgeLightColor = base;
1422a884b43bSJohn Scipione 		edgeShadowColor = base;
14232f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1424a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14252f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1426a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
14272f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
14282f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
14292f86ba45SStephan Aßmus 	} else {
14302f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1431a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
14322f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1433a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14342f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 1.10);
1435a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.17);
14362f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.12), 0);
14372f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.08), 255);
14382f86ba45SStephan Aßmus 	}
14392f86ba45SStephan Aßmus 
14402f86ba45SStephan Aßmus 	// active tabs stand out at the top, but this is an inactive tab
14412f86ba45SStephan Aßmus 	view->SetHighColor(base);
14422f86ba45SStephan Aßmus 	view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
14432f86ba45SStephan Aßmus 	rect.top += 4;
14442f86ba45SStephan Aßmus 
14452f86ba45SStephan Aßmus 	// frame and fill
14462f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
14472f86ba45SStephan Aßmus 		edgeLightColor,
14482f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14492f86ba45SStephan Aßmus 
14502f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
14512f86ba45SStephan Aßmus 		frameShadowColor,
14522f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14532f86ba45SStephan Aßmus 
1454b3601d82SStephan Aßmus 	if (rect.IsValid()) {
1455b3601d82SStephan Aßmus 		_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
1456b3601d82SStephan Aßmus 			bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
1457b3601d82SStephan Aßmus 	} else {
1458b3601d82SStephan Aßmus 		if ((B_LEFT_BORDER & ~borders) != 0)
1459b3601d82SStephan Aßmus 			rect.left++;
1460b3601d82SStephan Aßmus 	}
14612f86ba45SStephan Aßmus 
14622f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
14632f86ba45SStephan Aßmus }
14642f86ba45SStephan Aßmus 
14652f86ba45SStephan Aßmus 
14661f9fd6d8SStephan Aßmus void
14671f9fd6d8SStephan Aßmus BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
14681f9fd6d8SStephan Aßmus 	const rgb_color& base, enum orientation orientation, uint32 flags,
14691f9fd6d8SStephan Aßmus 	uint32 borders)
14701f9fd6d8SStephan Aßmus {
1471a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1472a884b43bSJohn Scipione 		return;
1473a884b43bSJohn Scipione 
14741f9fd6d8SStephan Aßmus 	rgb_color background;
14751f9fd6d8SStephan Aßmus 	if ((flags & (B_CLICKED | B_ACTIVATED)) != 0)
14761f9fd6d8SStephan Aßmus 		background = tint_color(base, B_DARKEN_1_TINT);
14771f9fd6d8SStephan Aßmus 	else
14781f9fd6d8SStephan Aßmus 		background = base;
14791f9fd6d8SStephan Aßmus 
14801f9fd6d8SStephan Aßmus 	rgb_color light = tint_color(background, 0.6);
14811f9fd6d8SStephan Aßmus 	rgb_color shadow = tint_color(background, 1.21);
14821f9fd6d8SStephan Aßmus 
14831f9fd6d8SStephan Aßmus 	// frame
14841f9fd6d8SStephan Aßmus 	if (borders != 0 && rect.Width() > 3 && rect.Height() > 3)
14851f9fd6d8SStephan Aßmus 		DrawRaisedBorder(view, rect, updateRect, background, flags, borders);
14861f9fd6d8SStephan Aßmus 
14871f9fd6d8SStephan Aßmus 	// dots and rest of background
14881f9fd6d8SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
14891f9fd6d8SStephan Aßmus 		if (rect.Width() > 2) {
14901f9fd6d8SStephan Aßmus 			// background on left/right
14911f9fd6d8SStephan Aßmus 			BRegion region(rect);
14921f9fd6d8SStephan Aßmus 			rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5);
14931f9fd6d8SStephan Aßmus 			rect.right = rect.left + 1;
14941f9fd6d8SStephan Aßmus 			region.Exclude(rect);
14951f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
14961f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
14971f9fd6d8SStephan Aßmus 		}
14981f9fd6d8SStephan Aßmus 
14991f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15001f9fd6d8SStephan Aßmus 		BPoint stop = rect.LeftBottom();
15011f9fd6d8SStephan Aßmus 		int32 num = 1;
15021f9fd6d8SStephan Aßmus 		while (dot.y <= stop.y) {
15031f9fd6d8SStephan Aßmus 			rgb_color col1;
15041f9fd6d8SStephan Aßmus 			rgb_color col2;
15051f9fd6d8SStephan Aßmus 			switch (num) {
15061f9fd6d8SStephan Aßmus 				case 1:
15071f9fd6d8SStephan Aßmus 					col1 = background;
15081f9fd6d8SStephan Aßmus 					col2 = background;
15091f9fd6d8SStephan Aßmus 					break;
15101f9fd6d8SStephan Aßmus 				case 2:
15111f9fd6d8SStephan Aßmus 					col1 = shadow;
15121f9fd6d8SStephan Aßmus 					col2 = background;
15131f9fd6d8SStephan Aßmus 					break;
15141f9fd6d8SStephan Aßmus 				case 3:
1515a5339f65SStephan Aßmus 				default:
15161f9fd6d8SStephan Aßmus 					col1 = background;
15171f9fd6d8SStephan Aßmus 					col2 = light;
15181f9fd6d8SStephan Aßmus 					num = 0;
15191f9fd6d8SStephan Aßmus 					break;
15201f9fd6d8SStephan Aßmus 			}
15211f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15221f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15231f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15241f9fd6d8SStephan Aßmus 			dot.x++;
15251f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15261f9fd6d8SStephan Aßmus 			dot.x -= 1.0;
15271f9fd6d8SStephan Aßmus 			// next pixel
15281f9fd6d8SStephan Aßmus 			num++;
15291f9fd6d8SStephan Aßmus 			dot.y++;
15301f9fd6d8SStephan Aßmus 		}
15311f9fd6d8SStephan Aßmus 	} else {
15321f9fd6d8SStephan Aßmus 		if (rect.Height() > 2) {
15331f9fd6d8SStephan Aßmus 			// background on left/right
15341f9fd6d8SStephan Aßmus 			BRegion region(rect);
15351f9fd6d8SStephan Aßmus 			rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5);
15361f9fd6d8SStephan Aßmus 			rect.bottom = rect.top + 1;
15371f9fd6d8SStephan Aßmus 			region.Exclude(rect);
15381f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
15391f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
15401f9fd6d8SStephan Aßmus 		}
15411f9fd6d8SStephan Aßmus 
15421f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15431f9fd6d8SStephan Aßmus 		BPoint stop = rect.RightTop();
15441f9fd6d8SStephan Aßmus 		int32 num = 1;
15451f9fd6d8SStephan Aßmus 		while (dot.x <= stop.x) {
15461f9fd6d8SStephan Aßmus 			rgb_color col1;
15471f9fd6d8SStephan Aßmus 			rgb_color col2;
15481f9fd6d8SStephan Aßmus 			switch (num) {
15491f9fd6d8SStephan Aßmus 				case 1:
15501f9fd6d8SStephan Aßmus 					col1 = background;
15511f9fd6d8SStephan Aßmus 					col2 = background;
15521f9fd6d8SStephan Aßmus 					break;
15531f9fd6d8SStephan Aßmus 				case 2:
15541f9fd6d8SStephan Aßmus 					col1 = shadow;
15551f9fd6d8SStephan Aßmus 					col2 = background;
15561f9fd6d8SStephan Aßmus 					break;
15571f9fd6d8SStephan Aßmus 				case 3:
15589f981a88SFrançois Revol 				default:
15591f9fd6d8SStephan Aßmus 					col1 = background;
15601f9fd6d8SStephan Aßmus 					col2 = light;
15611f9fd6d8SStephan Aßmus 					num = 0;
15621f9fd6d8SStephan Aßmus 					break;
15631f9fd6d8SStephan Aßmus 			}
15641f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15651f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15661f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15671f9fd6d8SStephan Aßmus 			dot.y++;
15681f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15691f9fd6d8SStephan Aßmus 			dot.y -= 1.0;
15701f9fd6d8SStephan Aßmus 			// next pixel
15711f9fd6d8SStephan Aßmus 			num++;
15721f9fd6d8SStephan Aßmus 			dot.x++;
15731f9fd6d8SStephan Aßmus 		}
15741f9fd6d8SStephan Aßmus 	}
15751f9fd6d8SStephan Aßmus }
15761f9fd6d8SStephan Aßmus 
15771f9fd6d8SStephan Aßmus 
15782f86ba45SStephan Aßmus // #pragma mark -
15792f86ba45SStephan Aßmus 
15802f86ba45SStephan Aßmus 
15812f86ba45SStephan Aßmus void
15822f86ba45SStephan Aßmus BControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
15832f86ba45SStephan Aßmus 	const rgb_color& base, border_style border, uint32 flags, uint32 borders)
15842f86ba45SStephan Aßmus {
15852f86ba45SStephan Aßmus 	if (border == B_NO_BORDER)
15862f86ba45SStephan Aßmus 		return;
15872f86ba45SStephan Aßmus 
15882f86ba45SStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
1589a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
15902f86ba45SStephan Aßmus 		scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
15912f86ba45SStephan Aßmus 
15922f86ba45SStephan Aßmus 	if (border == B_FANCY_BORDER)
15934f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
15942f86ba45SStephan Aßmus 
15952f86ba45SStephan Aßmus 	_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
15962f86ba45SStephan Aßmus 		scrollbarFrameColor, scrollbarFrameColor, borders);
15972f86ba45SStephan Aßmus }
15982f86ba45SStephan Aßmus 
15992f86ba45SStephan Aßmus 
16002f86ba45SStephan Aßmus void
16012f86ba45SStephan Aßmus BControlLook::DrawRaisedBorder(BView* view, BRect& rect,
16022f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16032f86ba45SStephan Aßmus 	uint32 borders)
16042f86ba45SStephan Aßmus {
16052f86ba45SStephan Aßmus 	rgb_color lightColor;
16062f86ba45SStephan Aßmus 	rgb_color shadowColor;
16072f86ba45SStephan Aßmus 
1608a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16092f86ba45SStephan Aßmus 		lightColor = base;
16102f86ba45SStephan Aßmus 		shadowColor = base;
16112f86ba45SStephan Aßmus 	} else {
16122f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.85);
16132f86ba45SStephan Aßmus 		shadowColor = tint_color(base, 1.07);
16142f86ba45SStephan Aßmus 	}
16152f86ba45SStephan Aßmus 
16162f86ba45SStephan Aßmus 	_DrawFrame(view, rect, lightColor, lightColor, shadowColor, shadowColor,
16172f86ba45SStephan Aßmus 		borders);
16182f86ba45SStephan Aßmus }
16192f86ba45SStephan Aßmus 
16202f86ba45SStephan Aßmus 
16212f86ba45SStephan Aßmus void
16222f86ba45SStephan Aßmus BControlLook::DrawTextControlBorder(BView* view, BRect& rect,
16232f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16242f86ba45SStephan Aßmus 	uint32 borders)
16252f86ba45SStephan Aßmus {
16262f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
16272f86ba45SStephan Aßmus 		return;
16282f86ba45SStephan Aßmus 
16292f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
16302f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
16312f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
16322f86ba45SStephan Aßmus 
1633a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16344f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags, borders);
16352f86ba45SStephan Aßmus 
1636a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
16374f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 40 };
16384f579098SStephan Aßmus 		else
16392f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.15);
16404f579098SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
1641a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
16422f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
16432f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.49);
16442f86ba45SStephan Aßmus 
16454f579098SStephan Aßmus 		// BCheckBox uses this to indicate the clicked state...
16462f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
16472f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16482f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
16492f86ba45SStephan Aßmus 
16502f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
16512f86ba45SStephan Aßmus 	} else {
16524f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags, borders);
16532f86ba45SStephan Aßmus 
1654a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
16554f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 102 };
16564f579098SStephan Aßmus 			dark2BorderColor = (rgb_color){ 0, 0, 0, 97 };
16574f579098SStephan Aßmus 		} else {
16582f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.40);
16592f86ba45SStephan Aßmus 			dark2BorderColor = tint_color(base, 1.38);
16602f86ba45SStephan Aßmus 		}
16614f579098SStephan Aßmus 	}
16622f86ba45SStephan Aßmus 
1663a884b43bSJohn Scipione 	if ((flags & B_DISABLED) == 0 && (flags & B_FOCUSED) != 0) {
16642f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
16652f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
16662f86ba45SStephan Aßmus 	}
16672f86ba45SStephan Aßmus 
1668a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
16694f579098SStephan Aßmus 		drawing_mode oldMode = view->DrawingMode();
16704f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
16714f579098SStephan Aßmus 
16722f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
16732f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16742f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
16754f579098SStephan Aßmus 
16764f579098SStephan Aßmus 		view->SetDrawingMode(oldMode);
16774f579098SStephan Aßmus 	} else {
16784f579098SStephan Aßmus 		_DrawFrame(view, rect,
16794f579098SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16804f579098SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
16814f579098SStephan Aßmus 	}
16822f86ba45SStephan Aßmus }
16832f86ba45SStephan Aßmus 
16842f86ba45SStephan Aßmus 
16852f86ba45SStephan Aßmus void
16862f86ba45SStephan Aßmus BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect,
16872f86ba45SStephan Aßmus 	const rgb_color& base, uint32 borders)
16882f86ba45SStephan Aßmus {
16892f86ba45SStephan Aßmus 	rgb_color frameColor = tint_color(base, 1.30);
16902f86ba45SStephan Aßmus 	rgb_color bevelLight = tint_color(base, 0.8);
16912f86ba45SStephan Aßmus 	rgb_color bevelShadow = tint_color(base, 1.03);
16922f86ba45SStephan Aßmus 
16932f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelShadow, bevelShadow, bevelLight, bevelLight,
16942f86ba45SStephan Aßmus 		borders);
16952f86ba45SStephan Aßmus 
16962f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameColor, frameColor, frameColor, frameColor,
16972f86ba45SStephan Aßmus 		borders);
16982f86ba45SStephan Aßmus 
16992f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLight, bevelLight, bevelShadow, bevelShadow,
17002f86ba45SStephan Aßmus 		borders);
17012f86ba45SStephan Aßmus }
17022f86ba45SStephan Aßmus 
17032f86ba45SStephan Aßmus 
17042f86ba45SStephan Aßmus void
17052f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17062f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags)
17072f86ba45SStephan Aßmus {
17082f86ba45SStephan Aßmus 	DrawLabel(view, label, rect, updateRect, base, flags,
17092f86ba45SStephan Aßmus 		DefaultLabelAlignment());
17102f86ba45SStephan Aßmus }
17112f86ba45SStephan Aßmus 
17122f86ba45SStephan Aßmus 
17132f86ba45SStephan Aßmus void
17142f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17152f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
17162f86ba45SStephan Aßmus 	const BAlignment& alignment)
17172f86ba45SStephan Aßmus {
17182f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
17192f86ba45SStephan Aßmus 		return;
17202f86ba45SStephan Aßmus 
17212f86ba45SStephan Aßmus 	// truncate the label if necessary and get the width and height
17222f86ba45SStephan Aßmus 	BString truncatedLabel(label);
17232f86ba45SStephan Aßmus 
17242f86ba45SStephan Aßmus 	BFont font;
17252f86ba45SStephan Aßmus 	view->GetFont(&font);
17262f86ba45SStephan Aßmus 
17272f86ba45SStephan Aßmus 	float width = rect.Width();
17282f86ba45SStephan Aßmus 	font.TruncateString(&truncatedLabel, B_TRUNCATE_END, width);
17292f86ba45SStephan Aßmus 	width = font.StringWidth(truncatedLabel.String());
17302f86ba45SStephan Aßmus 
17312f86ba45SStephan Aßmus 	font_height fontHeight;
17322f86ba45SStephan Aßmus 	font.GetHeight(&fontHeight);
17332f86ba45SStephan Aßmus 	float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
17342f86ba45SStephan Aßmus 
17352f86ba45SStephan Aßmus 	// handle alignment
17362f86ba45SStephan Aßmus 	BPoint location;
17372f86ba45SStephan Aßmus 
17382f86ba45SStephan Aßmus 	switch (alignment.horizontal) {
17392f86ba45SStephan Aßmus 	default:
17402f86ba45SStephan Aßmus 		case B_ALIGN_LEFT:
17412f86ba45SStephan Aßmus 			location.x = rect.left;
17422f86ba45SStephan Aßmus 			break;
17432f86ba45SStephan Aßmus 		case B_ALIGN_RIGHT:
17442f86ba45SStephan Aßmus 			location.x = rect.right - width;
17452f86ba45SStephan Aßmus 			break;
17462f86ba45SStephan Aßmus 		case B_ALIGN_CENTER:
17472f86ba45SStephan Aßmus 			location.x = (rect.left + rect.right - width) / 2.0f;
17482f86ba45SStephan Aßmus 			break;
17492f86ba45SStephan Aßmus 	}
17502f86ba45SStephan Aßmus 
17512f86ba45SStephan Aßmus 	switch (alignment.vertical) {
17522f86ba45SStephan Aßmus 		case B_ALIGN_TOP:
17532f86ba45SStephan Aßmus 			location.y = rect.top + ceilf(fontHeight.ascent);
17542f86ba45SStephan Aßmus 			break;
17552f86ba45SStephan Aßmus 		default:
17562f86ba45SStephan Aßmus 		case B_ALIGN_MIDDLE:
17572f86ba45SStephan Aßmus 			location.y = floorf((rect.top + rect.bottom - height) / 2.0f + 0.5f)
17582f86ba45SStephan Aßmus 				+ ceilf(fontHeight.ascent);
17592f86ba45SStephan Aßmus 			break;
17602f86ba45SStephan Aßmus 		case B_ALIGN_BOTTOM:
17612f86ba45SStephan Aßmus 			location.y = rect.bottom - ceilf(fontHeight.descent);
17622f86ba45SStephan Aßmus 			break;
17632f86ba45SStephan Aßmus 	}
17642f86ba45SStephan Aßmus 
1765c4e211feSStephan Aßmus 	DrawLabel(view, truncatedLabel.String(), base, flags, location);
1766c4e211feSStephan Aßmus }
1767c4e211feSStephan Aßmus 
1768c4e211feSStephan Aßmus 
1769c4e211feSStephan Aßmus void
1770c4e211feSStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
1771c4e211feSStephan Aßmus 	uint32 flags, const BPoint& where)
1772c4e211feSStephan Aßmus {
1773c4e211feSStephan Aßmus 	// setup the text color
1774c4e211feSStephan Aßmus 	// TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here,
1775c4e211feSStephan Aßmus 	// or elliminate that constant alltogether (stippi: +1).
1776d63b75faSPhilippe Saint-Pierre 
1777d63b75faSPhilippe Saint-Pierre 	BWindow* window = view->Window();
1778d63b75faSPhilippe Saint-Pierre 	bool isDesktop = window
1779d63b75faSPhilippe Saint-Pierre 		&& window->Feel() == kPrivateDesktopWindowFeel
1780d63b75faSPhilippe Saint-Pierre 		&& window->Look() == kPrivateDesktopWindowLook
1781d63b75faSPhilippe Saint-Pierre 		&& view->Parent()
1782d63b75faSPhilippe Saint-Pierre 		&& view->Parent()->Parent() == NULL
1783d63b75faSPhilippe Saint-Pierre 		&& (flags & B_IGNORE_OUTLINE) == 0;
1784d63b75faSPhilippe Saint-Pierre 
1785d63b75faSPhilippe Saint-Pierre 	rgb_color	low;
1786c4e211feSStephan Aßmus 	rgb_color	color;
1787d63b75faSPhilippe Saint-Pierre 	rgb_color	glowColor;
1788d63b75faSPhilippe Saint-Pierre 
1789d63b75faSPhilippe Saint-Pierre 	if (isDesktop)
1790d63b75faSPhilippe Saint-Pierre 		low = view->Parent()->ViewColor();
1791c4e211feSStephan Aßmus 	else
1792d63b75faSPhilippe Saint-Pierre 		low = base;
1793d63b75faSPhilippe Saint-Pierre 
1794d63b75faSPhilippe Saint-Pierre 	if (low.red + low.green + low.blue > 128 * 3) {
1795d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_DARKEN_MAX_TINT);
1796d63b75faSPhilippe Saint-Pierre 		glowColor = kWhite;
1797d63b75faSPhilippe Saint-Pierre 	} else {
1798d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_LIGHTEN_MAX_TINT);
1799d63b75faSPhilippe Saint-Pierre 		glowColor = kBlack;
1800d63b75faSPhilippe Saint-Pierre 	}
1801c4e211feSStephan Aßmus 
1802a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
1803d63b75faSPhilippe Saint-Pierre 		color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
1804d63b75faSPhilippe Saint-Pierre 		color.green = (uint8)(((int32)low.green + color.green + 1) / 2);
1805d63b75faSPhilippe Saint-Pierre 		color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2);
1806d63b75faSPhilippe Saint-Pierre 	}
1807d63b75faSPhilippe Saint-Pierre 
1808d63b75faSPhilippe Saint-Pierre 	drawing_mode oldMode = view->DrawingMode();
1809d63b75faSPhilippe Saint-Pierre 
1810d63b75faSPhilippe Saint-Pierre 	if (isDesktop) {
1811a884b43bSJohn Scipione 		// drawing occurs on the desktop
1812d63b75faSPhilippe Saint-Pierre 		if (fCachedWorkspace != current_workspace()) {
1813d63b75faSPhilippe Saint-Pierre 			int8 indice = 0;
1814d63b75faSPhilippe Saint-Pierre 			int32 mask;
1815d63b75faSPhilippe Saint-Pierre 			bool tmpOutline;
1816d63b75faSPhilippe Saint-Pierre 			while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
1817d63b75faSPhilippe Saint-Pierre 					indice, &mask) == B_OK
1818d63b75faSPhilippe Saint-Pierre 				&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
1819d63b75faSPhilippe Saint-Pierre 					indice, &tmpOutline) == B_OK) {
1820d63b75faSPhilippe Saint-Pierre 
1821d63b75faSPhilippe Saint-Pierre 				if (((1 << current_workspace()) & mask) != 0) {
1822d63b75faSPhilippe Saint-Pierre 					fCachedOutline = tmpOutline;
1823d63b75faSPhilippe Saint-Pierre 					fCachedWorkspace = current_workspace();
1824d63b75faSPhilippe Saint-Pierre 					break;
1825d63b75faSPhilippe Saint-Pierre 				}
1826d63b75faSPhilippe Saint-Pierre 				indice++;
1827d63b75faSPhilippe Saint-Pierre 			}
1828d63b75faSPhilippe Saint-Pierre 		}
1829d63b75faSPhilippe Saint-Pierre 
1830d63b75faSPhilippe Saint-Pierre 		if (fCachedOutline) {
1831d63b75faSPhilippe Saint-Pierre 			BFont font;
1832d63b75faSPhilippe Saint-Pierre 			view->GetFont(&font);
1833d63b75faSPhilippe Saint-Pierre 
1834d63b75faSPhilippe Saint-Pierre 			view->SetDrawingMode(B_OP_ALPHA);
1835d63b75faSPhilippe Saint-Pierre 			view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
1836d63b75faSPhilippe Saint-Pierre 			// Draw glow or outline
1837d63b75faSPhilippe Saint-Pierre 			if (glowColor == kWhite) {
1838d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(2.0);
1839d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1840d63b75faSPhilippe Saint-Pierre 
1841d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1842d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1843d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1844d63b75faSPhilippe Saint-Pierre 
1845d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1846d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1847d63b75faSPhilippe Saint-Pierre 
1848d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 65;
1849d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1850d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1851d63b75faSPhilippe Saint-Pierre 
1852d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1853d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1854d63b75faSPhilippe Saint-Pierre 			} else if (glowColor == kBlack) {
1855d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1856d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1857d63b75faSPhilippe Saint-Pierre 
1858d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1859d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1860d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1861d63b75faSPhilippe Saint-Pierre 
1862d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1863d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1864d63b75faSPhilippe Saint-Pierre 
1865d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 200;
1866d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1867d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, BPoint(where.x + 1, where.y + 1));
1868d63b75faSPhilippe Saint-Pierre 			}
1869d63b75faSPhilippe Saint-Pierre 		}
1870c4e211feSStephan Aßmus 	}
1871c4e211feSStephan Aßmus 
1872c4e211feSStephan Aßmus 	view->SetHighColor(color);
1873c4e211feSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
1874c4e211feSStephan Aßmus 	view->DrawString(label, where);
1875c4e211feSStephan Aßmus 	view->SetDrawingMode(oldMode);
18762f86ba45SStephan Aßmus }
18772f86ba45SStephan Aßmus 
18782f86ba45SStephan Aßmus 
1879d63b75faSPhilippe Saint-Pierre void
1880d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo)
1881d63b75faSPhilippe Saint-Pierre {
1882d452ff66SAxel Dörfler 	fBackgroundInfo = backgroundInfo;
1883d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace = -1;
1884d63b75faSPhilippe Saint-Pierre }
1885d63b75faSPhilippe Saint-Pierre 
1886d63b75faSPhilippe Saint-Pierre 
18872f86ba45SStephan Aßmus // #pragma mark -
18882f86ba45SStephan Aßmus 
18892f86ba45SStephan Aßmus 
18902f86ba45SStephan Aßmus void
189113cd46dfSStephan Aßmus BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
1892a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
1893a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
1894a884b43bSJohn Scipione 	const rgb_color& background, float contrast, float brightness,
1895a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
189613cd46dfSStephan Aßmus {
1897a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1898a884b43bSJohn Scipione 		return;
189913cd46dfSStephan Aßmus 
19004fa76719SJohn Scipione 	// save the clipping constraints of the view
19014fa76719SJohn Scipione 	view->PushState();
190213cd46dfSStephan Aßmus 
1903*5666b4f7SJohn Scipione 	// set clipping constraints to updateRect
19044fa76719SJohn Scipione 	BRegion clipping(updateRect);
1905a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
1906a884b43bSJohn Scipione 
1907a884b43bSJohn Scipione 	// outer edge colors
1908a884b43bSJohn Scipione 	rgb_color edgeLightColor;
1909a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
1910a884b43bSJohn Scipione 
1911a884b43bSJohn Scipione 	// default button frame color
19124f579098SStephan Aßmus 	// TODO: B_BLEND_FRAME
1913a884b43bSJohn Scipione 	float defaultIndicatorTint = 1.2;
1914a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
1915a884b43bSJohn Scipione 		defaultIndicatorTint = (B_NO_TINT + defaultIndicatorTint) / 2;
191613cd46dfSStephan Aßmus 
1917a884b43bSJohn Scipione 	rgb_color defaultIndicatorColor = tint_color(base, defaultIndicatorTint);
191888969219SJohn Scipione 	rgb_color cornerBgColor;
191988969219SJohn Scipione 
192088969219SJohn Scipione 	drawing_mode oldMode = view->DrawingMode();
192113cd46dfSStephan Aßmus 
1922a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
192388969219SJohn Scipione 		cornerBgColor = defaultIndicatorColor;
1924a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(defaultIndicatorColor,
1925a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
1926a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
1927a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(defaultIndicatorColor,
1928a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
1929a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
193013cd46dfSStephan Aßmus 
193188969219SJohn Scipione 		// draw default button indicator
1932a884b43bSJohn Scipione 		view->SetHighColor(background);
1933a884b43bSJohn Scipione 		view->FillRect(rect);
193413cd46dfSStephan Aßmus 		view->SetHighColor(base);
1935a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
1936a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
193713cd46dfSStephan Aßmus 
1938a884b43bSJohn Scipione 		view->SetHighColor(defaultIndicatorColor);
1939a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
1940a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
194113cd46dfSStephan Aßmus 
1942a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
1943a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
194413cd46dfSStephan Aßmus 	} else {
194588969219SJohn Scipione 		cornerBgColor = background;
194641651bb3SJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
194741651bb3SJohn Scipione 			// set the background color to transparent for the case
194841651bb3SJohn Scipione 			// that we are on the desktop
194941651bb3SJohn Scipione 			cornerBgColor.alpha = 0;
195041651bb3SJohn Scipione 			view->SetDrawingMode(B_OP_ALPHA);
195141651bb3SJohn Scipione 		}
195288969219SJohn Scipione 
1953a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(background,
1954a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
1955a884b43bSJohn Scipione 			brightness * 1.0, flags);
1956a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(background,
1957a884b43bSJohn Scipione 			contrast * (flags & B_DISABLED) != 0 ? 0.0 : 1.0,
1958a884b43bSJohn Scipione 			brightness * 1.0, flags);
195913cd46dfSStephan Aßmus 	}
196013cd46dfSStephan Aßmus 
1961a884b43bSJohn Scipione 	// frame colors
1962a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
1963a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
1964a884b43bSJohn Scipione 
1965a884b43bSJohn Scipione 	// rounded corners
1966a884b43bSJohn Scipione 
1967a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
1968a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
1969a884b43bSJohn Scipione 		// draw left top rounded corner
1970a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
1971a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius),
1972a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius));
1973a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
1974a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect,
1975a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, frameLightColor);
1976a884b43bSJohn Scipione 	}
1977a884b43bSJohn Scipione 
1978a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
1979a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
1980a884b43bSJohn Scipione 		// draw right top rounded corner
1981a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius),
1982a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
1983a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius));
1984a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
1985a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect,
1986a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
1987a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
1988a884b43bSJohn Scipione 	}
1989a884b43bSJohn Scipione 
1990a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
1991a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
1992a884b43bSJohn Scipione 		// draw left bottom rounded corner
1993a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
1994a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius),
1995a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius), floorf(rect.bottom));
1996a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
1997a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect,
1998a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
1999a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
2000a884b43bSJohn Scipione 	}
2001a884b43bSJohn Scipione 
2002a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2003a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2004a884b43bSJohn Scipione 		// draw right bottom rounded corner
2005a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius),
2006a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius), floorf(rect.right),
2007a884b43bSJohn Scipione 			floorf(rect.bottom));
2008a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2009a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightBottom(view, rightBottomCorner,
2010a884b43bSJohn Scipione 			updateRect, cornerBgColor, edgeLightColor, frameShadowColor);
2011a884b43bSJohn Scipione 	}
2012a884b43bSJohn Scipione 
2013a884b43bSJohn Scipione 	// clip out the corners
2014a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2015a884b43bSJohn Scipione 
2016a884b43bSJohn Scipione 	// draw outer edge
2017a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
2018a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, defaultIndicatorColor,
2019a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2020a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9),
2021a884b43bSJohn Scipione 			flags, borders);
2022a884b43bSJohn Scipione 	} else {
2023a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, background,
2024a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
2025a884b43bSJohn Scipione 			brightness * 1.0, flags, borders);
2026a884b43bSJohn Scipione 	}
2027a884b43bSJohn Scipione 
202888969219SJohn Scipione 	view->SetDrawingMode(oldMode);
202988969219SJohn Scipione 
2030a884b43bSJohn Scipione 	// draw frame
2031a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
20324f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
20334f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
20344f579098SStephan Aßmus 
2035a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2036a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
20374f579098SStephan Aßmus 
20384f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
20394f579098SStephan Aßmus 	} else {
2040a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2041a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
20424f579098SStephan Aßmus 	}
2043a884b43bSJohn Scipione 
20444fa76719SJohn Scipione 	// restore the clipping constraints of the view
20454fa76719SJohn Scipione 	view->PopState();
204613cd46dfSStephan Aßmus }
204713cd46dfSStephan Aßmus 
204813cd46dfSStephan Aßmus 
204913cd46dfSStephan Aßmus void
20502f86ba45SStephan Aßmus BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
20514f579098SStephan Aßmus 	const rgb_color& base, float contrast, float brightness, uint32 flags,
20524f579098SStephan Aßmus 	uint32 borders)
20532f86ba45SStephan Aßmus {
2054a884b43bSJohn Scipione 	rgb_color edgeLightColor = _EdgeLightColor(base, contrast,
2055a884b43bSJohn Scipione 		brightness, flags);
2056a884b43bSJohn Scipione 	rgb_color edgeShadowColor = _EdgeShadowColor(base, contrast,
2057a884b43bSJohn Scipione 		brightness, flags);
2058a884b43bSJohn Scipione 
2059a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
20604f579098SStephan Aßmus 		// assumes the background has already been painted
20614f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
20624f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
20634f579098SStephan Aßmus 
2064a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2065a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
20664f579098SStephan Aßmus 
20674f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
20684f579098SStephan Aßmus 	} else {
2069a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2070a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
20712f86ba45SStephan Aßmus 	}
20724f579098SStephan Aßmus }
20732f86ba45SStephan Aßmus 
20742f86ba45SStephan Aßmus 
20752f86ba45SStephan Aßmus void
20762f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
20772f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
20782f86ba45SStephan Aßmus 	uint32 borders)
20792f86ba45SStephan Aßmus {
20802f86ba45SStephan Aßmus 	view->BeginLineArray(4);
20812f86ba45SStephan Aßmus 
20822f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
20832f86ba45SStephan Aßmus 		view->AddLine(
20842f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
20852f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top), left);
20862f86ba45SStephan Aßmus 		rect.left++;
20872f86ba45SStephan Aßmus 	}
20882f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
20892f86ba45SStephan Aßmus 		view->AddLine(
20902f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
20912f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), top);
20922f86ba45SStephan Aßmus 		rect.top++;
20932f86ba45SStephan Aßmus 	}
20942f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
20952f86ba45SStephan Aßmus 		view->AddLine(
20962f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top),
20972f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), right);
20982f86ba45SStephan Aßmus 		rect.right--;
20992f86ba45SStephan Aßmus 	}
21002f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
21012f86ba45SStephan Aßmus 		view->AddLine(
21022f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
21032f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
21042f86ba45SStephan Aßmus 		rect.bottom--;
21052f86ba45SStephan Aßmus 	}
21062f86ba45SStephan Aßmus 
21072f86ba45SStephan Aßmus 	view->EndLineArray();
21082f86ba45SStephan Aßmus }
21092f86ba45SStephan Aßmus 
21102f86ba45SStephan Aßmus 
21112f86ba45SStephan Aßmus void
21122f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
21132f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
21142f86ba45SStephan Aßmus 	const rgb_color& rightTop, const rgb_color& leftBottom, uint32 borders)
21152f86ba45SStephan Aßmus {
21162f86ba45SStephan Aßmus 	view->BeginLineArray(6);
21172f86ba45SStephan Aßmus 
21182f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
21192f86ba45SStephan Aßmus 		if (borders & B_RIGHT_BORDER) {
21202f86ba45SStephan Aßmus 			view->AddLine(
21212f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
21222f86ba45SStephan Aßmus 				BPoint(rect.right - 1, rect.top), top);
21232f86ba45SStephan Aßmus 			view->AddLine(
21242f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top),
21252f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), rightTop);
21262f86ba45SStephan Aßmus 		} else {
21272f86ba45SStephan Aßmus 			view->AddLine(
21282f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
21292f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), top);
21302f86ba45SStephan Aßmus 		}
21312f86ba45SStephan Aßmus 		rect.top++;
21322f86ba45SStephan Aßmus 	}
21332f86ba45SStephan Aßmus 
21342f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
21352f86ba45SStephan Aßmus 		view->AddLine(
21362f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
21372f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom - 1), left);
21382f86ba45SStephan Aßmus 		view->AddLine(
21392f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
21402f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom), leftBottom);
21412f86ba45SStephan Aßmus 		rect.left++;
21422f86ba45SStephan Aßmus 	}
21432f86ba45SStephan Aßmus 
21442f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
21452f86ba45SStephan Aßmus 		view->AddLine(
21462f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
21472f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
21482f86ba45SStephan Aßmus 		rect.bottom--;
21492f86ba45SStephan Aßmus 	}
21502f86ba45SStephan Aßmus 
21512f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
21522f86ba45SStephan Aßmus 		view->AddLine(
21532f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom),
21542f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), right);
21552f86ba45SStephan Aßmus 		rect.right--;
21562f86ba45SStephan Aßmus 	}
21572f86ba45SStephan Aßmus 
21582f86ba45SStephan Aßmus 	view->EndLineArray();
21592f86ba45SStephan Aßmus }
21602f86ba45SStephan Aßmus 
21612f86ba45SStephan Aßmus 
21622f86ba45SStephan Aßmus void
2163a884b43bSJohn Scipione BControlLook::_DrawButtonBackground(BView* view, BRect& rect,
2164a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2165a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2166a884b43bSJohn Scipione 	uint32 flags, uint32 borders, enum orientation orientation)
21672f86ba45SStephan Aßmus {
2168a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2169a884b43bSJohn Scipione 		return;
21702f86ba45SStephan Aßmus 
21714fa76719SJohn Scipione 	// save the clipping constraints of the view
21724fa76719SJohn Scipione 	view->PushState();
21732f86ba45SStephan Aßmus 
2174*5666b4f7SJohn Scipione 	// set clipping constraints to updateRect
21754fa76719SJohn Scipione 	BRegion clipping(updateRect);
2176a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
21772f86ba45SStephan Aßmus 
2178a884b43bSJohn Scipione 	// inner bevel colors
2179a884b43bSJohn Scipione 	rgb_color bevelLightColor  = _BevelLightColor(base, flags);
2180a884b43bSJohn Scipione 	rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2181a884b43bSJohn Scipione 
2182a884b43bSJohn Scipione 	// button background color
2183a884b43bSJohn Scipione 	rgb_color buttonBgColor;
2184a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
2185a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, 0.7);
21862f86ba45SStephan Aßmus 	else
2187a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, B_LIGHTEN_1_TINT);
2188a884b43bSJohn Scipione 
2189a884b43bSJohn Scipione 	// surface top gradient
2190a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2191a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, base, flags, orientation);
2192a884b43bSJohn Scipione 
2193a884b43bSJohn Scipione 	// rounded corners
2194a884b43bSJohn Scipione 
2195a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2196a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2197a884b43bSJohn Scipione 		// draw left top rounded corner
2198a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2199a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2200a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2201a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2202a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2203a884b43bSJohn Scipione 			bevelLightColor, fillGradient);
2204a884b43bSJohn Scipione 	}
2205a884b43bSJohn Scipione 
2206a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2207a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2208a884b43bSJohn Scipione 		// draw right top rounded corner
2209a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2210a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2211a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2212a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2213a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner,
2214a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2215a884b43bSJohn Scipione 	}
2216a884b43bSJohn Scipione 
2217a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2218a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2219a884b43bSJohn Scipione 		// draw left bottom rounded corner
2220a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2221a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2222a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2223a884b43bSJohn Scipione 			floorf(rect.bottom));
2224a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2225a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2226a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2227a884b43bSJohn Scipione 	}
2228a884b43bSJohn Scipione 
2229a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2230a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2231a884b43bSJohn Scipione 		// draw right bottom rounded corner
2232a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2233a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2234a884b43bSJohn Scipione 			floorf(rect.bottom));
2235a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2236a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2237a884b43bSJohn Scipione 			updateRect, bevelShadowColor, fillGradient);
2238a884b43bSJohn Scipione 	}
2239a884b43bSJohn Scipione 
2240a884b43bSJohn Scipione 	// clip out the corners
2241a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2242a884b43bSJohn Scipione 
2243a884b43bSJohn Scipione 	// draw inner bevel
2244a884b43bSJohn Scipione 
2245a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
2246a884b43bSJohn Scipione 		view->BeginLineArray(4);
2247a884b43bSJohn Scipione 
2248a884b43bSJohn Scipione 		// shadow along left/top borders
2249a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2250a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2251a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelLightColor);
2252a884b43bSJohn Scipione 			rect.left++;
2253a884b43bSJohn Scipione 		}
2254a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2255a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2256a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelLightColor);
2257a884b43bSJohn Scipione 			rect.top++;
2258a884b43bSJohn Scipione 		}
2259a884b43bSJohn Scipione 
2260a884b43bSJohn Scipione 		// softer shadow along left/top borders
2261a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2262a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2263a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelShadowColor);
2264a884b43bSJohn Scipione 			rect.left++;
2265a884b43bSJohn Scipione 		}
2266a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2267a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2268a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelShadowColor);
2269a884b43bSJohn Scipione 			rect.top++;
2270a884b43bSJohn Scipione 		}
2271a884b43bSJohn Scipione 
2272a884b43bSJohn Scipione 		view->EndLineArray();
2273a884b43bSJohn Scipione 	} else {
2274a884b43bSJohn Scipione 		_DrawFrame(view, rect,
2275a884b43bSJohn Scipione 			bevelLightColor, bevelLightColor,
2276a884b43bSJohn Scipione 			bevelShadowColor, bevelShadowColor,
2277a884b43bSJohn Scipione 			buttonBgColor, buttonBgColor, borders);
2278a884b43bSJohn Scipione 	}
2279a884b43bSJohn Scipione 
2280a884b43bSJohn Scipione 	// fill in the background
2281a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2282a884b43bSJohn Scipione 
22834fa76719SJohn Scipione 	// restore the clipping constraints of the view
22844fa76719SJohn Scipione 	view->PopState();
22852f86ba45SStephan Aßmus }
22862f86ba45SStephan Aßmus 
22872f86ba45SStephan Aßmus 
22882f86ba45SStephan Aßmus void
2289a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundOutside(BView* view, BRect& rect,
2290a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2291a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2292a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
22932f86ba45SStephan Aßmus {
2294a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2295a884b43bSJohn Scipione 		return;
2296a884b43bSJohn Scipione 
2297a884b43bSJohn Scipione 	if (popupIndicator) {
2298a884b43bSJohn Scipione 		BRect leftRect(rect);
2299a884b43bSJohn Scipione 		leftRect.right -= 10;
2300a884b43bSJohn Scipione 
2301a884b43bSJohn Scipione 		BRect rightRect(rect);
2302a884b43bSJohn Scipione 		rightRect.left = rightRect.right - 9;
2303a884b43bSJohn Scipione 
2304a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, leftRect, updateRect,
2305a884b43bSJohn Scipione 			leftTopRadius, 0.0f, leftBottomRadius, 0.0f, base, flags,
2306a884b43bSJohn Scipione 			B_LEFT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER);
2307a884b43bSJohn Scipione 
2308a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rightRect, updateRect,
2309a884b43bSJohn Scipione 			0.0f, rightTopRadius, 0.0f, rightBottomRadius, base, flags,
2310a884b43bSJohn Scipione 			B_TOP_BORDER | B_RIGHT_BORDER | B_BOTTOM_BORDER);
2311a884b43bSJohn Scipione 
2312a884b43bSJohn Scipione 		// popup marker
2313a884b43bSJohn Scipione 		BPoint center(roundf((rightRect.left + rightRect.right) / 2.0),
2314a884b43bSJohn Scipione 					  roundf((rightRect.top + rightRect.bottom) / 2.0));
2315a884b43bSJohn Scipione 		BPoint triangle[3];
2316a884b43bSJohn Scipione 		triangle[0] = center + BPoint(-2.5, -0.5);
2317a884b43bSJohn Scipione 		triangle[1] = center + BPoint(2.5, -0.5);
2318a884b43bSJohn Scipione 		triangle[2] = center + BPoint(0.0, 2.0);
2319a884b43bSJohn Scipione 
2320a884b43bSJohn Scipione 		uint32 viewFlags = view->Flags();
2321a884b43bSJohn Scipione 		view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
2322a884b43bSJohn Scipione 
2323a884b43bSJohn Scipione 		rgb_color markColor;
2324a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2325a884b43bSJohn Scipione 			markColor = tint_color(base, 1.35);
23262f86ba45SStephan Aßmus 		else
2327a884b43bSJohn Scipione 			markColor = tint_color(base, 1.65);
2328a884b43bSJohn Scipione 
2329a884b43bSJohn Scipione 		view->SetHighColor(markColor);
2330a884b43bSJohn Scipione 		view->FillTriangle(triangle[0], triangle[1], triangle[2]);
2331a884b43bSJohn Scipione 
2332a884b43bSJohn Scipione 		// draw a line on the left of the popup frame
2333a884b43bSJohn Scipione 		rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2334a884b43bSJohn Scipione 		view->SetHighColor(bevelShadowColor);
2335a884b43bSJohn Scipione 		BPoint leftTopCorner(floorf(rightRect.left - 1.0),
2336a884b43bSJohn Scipione 			floorf(rightRect.top - 1.0));
2337a884b43bSJohn Scipione 		BPoint leftBottomCorner(floorf(rightRect.left - 1.0),
2338a884b43bSJohn Scipione 			floorf(rightRect.bottom + 1.0));
2339a884b43bSJohn Scipione 		view->StrokeLine(leftTopCorner, leftBottomCorner);
2340a884b43bSJohn Scipione 
2341a884b43bSJohn Scipione 		view->SetFlags(viewFlags);
2342a884b43bSJohn Scipione 
2343a884b43bSJohn Scipione 		rect = leftRect;
2344a884b43bSJohn Scipione 	} else {
2345a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rect, updateRect, leftTopRadius,
2346a884b43bSJohn Scipione 			rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags);
2347a884b43bSJohn Scipione 	}
23482f86ba45SStephan Aßmus }
23492f86ba45SStephan Aßmus 
23502f86ba45SStephan Aßmus 
2351a884b43bSJohn Scipione void
2352a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
2353a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2354a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2355a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
23562f86ba45SStephan Aßmus {
2357a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2358a884b43bSJohn Scipione 		return;
2359a884b43bSJohn Scipione 
2360*5666b4f7SJohn Scipione 	// save the clipping constraints of the view
2361*5666b4f7SJohn Scipione 	view->PushState();
2362a884b43bSJohn Scipione 
2363*5666b4f7SJohn Scipione 	// set clipping constraints to updateRect
2364*5666b4f7SJohn Scipione 	BRegion clipping(updateRect);
2365a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2366a884b43bSJohn Scipione 
2367a884b43bSJohn Scipione 	// frame colors
2368a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
2369a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
2370a884b43bSJohn Scipione 
2371a884b43bSJohn Scipione 	// indicator background color
2372a884b43bSJohn Scipione 	rgb_color indicatorBase;
2373a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0)
2374a884b43bSJohn Scipione 		indicatorBase = base;
2375a884b43bSJohn Scipione 	else {
2376a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2377a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.05);
2378a884b43bSJohn Scipione 		else
2379a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.12);
23802f86ba45SStephan Aßmus 	}
23812f86ba45SStephan Aßmus 
2382a884b43bSJohn Scipione 	// bevel colors
2383a884b43bSJohn Scipione 	rgb_color cornerColor = tint_color(indicatorBase, 0.85);
2384a884b43bSJohn Scipione 	rgb_color bevelColor1 = tint_color(indicatorBase, 0.3);
2385a884b43bSJohn Scipione 	rgb_color bevelColor2 = tint_color(indicatorBase, 0.5);
2386a884b43bSJohn Scipione 	rgb_color bevelColor3 = tint_color(indicatorBase, 1.03);
23872f86ba45SStephan Aßmus 
2388a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
2389a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.8);
2390a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.7);
2391a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.8);
2392a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.01);
23932f86ba45SStephan Aßmus 	} else {
2394a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.85);
2395a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.3);
2396a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.5);
2397a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.03);
23982f86ba45SStephan Aßmus 	}
2399a884b43bSJohn Scipione 
2400a884b43bSJohn Scipione 	// surface top gradient
2401a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2402a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, indicatorBase, flags);
2403a884b43bSJohn Scipione 
2404a884b43bSJohn Scipione 	// rounded corners
2405a884b43bSJohn Scipione 
2406a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2407a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2408a884b43bSJohn Scipione 		// draw left top rounded corner
2409a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2410a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2411a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2412a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2413a884b43bSJohn Scipione 
2414a884b43bSJohn Scipione 		BRegion cornerClipping(leftTopCorner);
2415a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2416a884b43bSJohn Scipione 
2417a884b43bSJohn Scipione 		BRect ellipseRect(leftTopCorner);
2418a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2419a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2420a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2421a884b43bSJohn Scipione 
2422a884b43bSJohn Scipione 		// draw the frame (again)
2423a884b43bSJohn Scipione 		view->SetHighColor(frameLightColor);
2424a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2425a884b43bSJohn Scipione 
2426a884b43bSJohn Scipione 		// draw the bevel and background
2427a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2428a884b43bSJohn Scipione 			bevelColor1, fillGradient);
2429a884b43bSJohn Scipione 	}
2430a884b43bSJohn Scipione 
2431a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2432a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2433a884b43bSJohn Scipione 		// draw right top rounded corner
2434a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2435a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2436a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2437a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2438a884b43bSJohn Scipione 
2439a884b43bSJohn Scipione 		BRegion cornerClipping(rightTopCorner);
2440a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2441a884b43bSJohn Scipione 
2442a884b43bSJohn Scipione 		BRect ellipseRect(rightTopCorner);
2443a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2444a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2445a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2446a884b43bSJohn Scipione 
2447a884b43bSJohn Scipione 		// draw the frame (again)
2448a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2449a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2450a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
24512f86ba45SStephan Aßmus 		} else {
2452a884b43bSJohn Scipione 			BGradientLinear gradient;
2453a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2454a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2455a884b43bSJohn Scipione 			gradient.SetStart(rightTopCorner.LeftTop());
2456a884b43bSJohn Scipione 			gradient.SetEnd(rightTopCorner.RightBottom());
2457a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
24582f86ba45SStephan Aßmus 		}
24592f86ba45SStephan Aßmus 
2460a884b43bSJohn Scipione 		// draw the bevel and background
2461a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect,
2462a884b43bSJohn Scipione 			bevelColor1, bevelColor3, fillGradient);
2463a884b43bSJohn Scipione 	}
24642f86ba45SStephan Aßmus 
2465a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2466a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2467a884b43bSJohn Scipione 		// draw left bottom rounded corner
2468a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2469a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2470a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2471a884b43bSJohn Scipione 			floorf(rect.bottom));
2472a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2473a884b43bSJohn Scipione 
2474a884b43bSJohn Scipione 		BRegion cornerClipping(leftBottomCorner);
2475a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2476a884b43bSJohn Scipione 
2477a884b43bSJohn Scipione 		BRect ellipseRect(leftBottomCorner);
2478a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2479a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2480a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2481a884b43bSJohn Scipione 
2482a884b43bSJohn Scipione 		// draw the frame (again)
2483a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2484a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2485a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
2486a884b43bSJohn Scipione 		} else {
2487a884b43bSJohn Scipione 			BGradientLinear gradient;
2488a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2489a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2490a884b43bSJohn Scipione 			gradient.SetStart(leftBottomCorner.LeftTop());
2491a884b43bSJohn Scipione 			gradient.SetEnd(leftBottomCorner.RightBottom());
2492a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
2493a884b43bSJohn Scipione 		}
2494a884b43bSJohn Scipione 
2495a884b43bSJohn Scipione 		// draw the bevel and background
2496a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2497a884b43bSJohn Scipione 			updateRect, bevelColor2, bevelColor3, fillGradient);
2498a884b43bSJohn Scipione 	}
2499a884b43bSJohn Scipione 
2500a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2501a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2502a884b43bSJohn Scipione 		// draw right bottom rounded corner
2503a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2504a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2505a884b43bSJohn Scipione 			floorf(rect.bottom));
2506a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2507a884b43bSJohn Scipione 
2508a884b43bSJohn Scipione 		BRegion cornerClipping(rightBottomCorner);
2509a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2510a884b43bSJohn Scipione 
2511a884b43bSJohn Scipione 		BRect ellipseRect(rightBottomCorner);
2512a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2513a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2514a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2515a884b43bSJohn Scipione 
2516a884b43bSJohn Scipione 		// draw the frame (again)
2517a884b43bSJohn Scipione 		view->SetHighColor(frameShadowColor);
2518a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2519a884b43bSJohn Scipione 
2520a884b43bSJohn Scipione 		// draw the bevel and background
2521a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2522a884b43bSJohn Scipione 			updateRect, bevelColor3, fillGradient);
2523a884b43bSJohn Scipione 	}
2524a884b43bSJohn Scipione 
2525a884b43bSJohn Scipione 	// clip out the corners
2526a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2527a884b43bSJohn Scipione 
2528a884b43bSJohn Scipione 	// draw the bevel
2529a884b43bSJohn Scipione 	_DrawFrame(view, rect,
2530a884b43bSJohn Scipione 		bevelColor2, bevelColor1,
2531a884b43bSJohn Scipione 		bevelColor3, bevelColor3,
2532a884b43bSJohn Scipione 		cornerColor, cornerColor,
2533a884b43bSJohn Scipione 		borders);
2534a884b43bSJohn Scipione 
2535a884b43bSJohn Scipione 	// fill in the background
2536a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2537a884b43bSJohn Scipione 
2538*5666b4f7SJohn Scipione 	// restore the clipping constraints of the view
2539*5666b4f7SJohn Scipione 	view->PopState();
2540a884b43bSJohn Scipione }
2541a884b43bSJohn Scipione 
2542a884b43bSJohn Scipione 
2543a884b43bSJohn Scipione void
2544a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftTop(BView* view, BRect& cornerRect,
2545a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2546a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2547a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2548a884b43bSJohn Scipione {
2549a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftTop(view, cornerRect, updateRect,
2550a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2551a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftTop(view, cornerRect, updateRect,
2552a884b43bSJohn Scipione 		bevelColor, fillGradient);
2553a884b43bSJohn Scipione }
2554a884b43bSJohn Scipione 
2555a884b43bSJohn Scipione 
2556a884b43bSJohn Scipione void
2557a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftTop(BView* view, BRect& cornerRect,
2558a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2559a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2560a884b43bSJohn Scipione {
2561a884b43bSJohn Scipione 	// constrain clipping region to corner
2562a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2563a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2564a884b43bSJohn Scipione 
2565a884b43bSJohn Scipione 	// background
2566a884b43bSJohn Scipione 	view->SetHighColor(background);
2567a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2568a884b43bSJohn Scipione 
2569a884b43bSJohn Scipione 	// outer edge
2570a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2571a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2572a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2573a884b43bSJohn Scipione 
2574a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2575a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2576a884b43bSJohn Scipione 
2577a884b43bSJohn Scipione 	// frame
2578a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2579a884b43bSJohn Scipione 	cornerRect.left++;
2580a884b43bSJohn Scipione 	cornerRect.top++;
2581a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2582a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2583a884b43bSJohn Scipione 
2584a884b43bSJohn Scipione 	// prepare for bevel
2585a884b43bSJohn Scipione 	cornerRect.left++;
2586a884b43bSJohn Scipione 	cornerRect.top++;
2587a884b43bSJohn Scipione }
2588a884b43bSJohn Scipione 
2589a884b43bSJohn Scipione 
2590a884b43bSJohn Scipione void
2591a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftTop(BView* view, BRect& cornerRect,
2592a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelColor,
2593a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2594a884b43bSJohn Scipione {
2595a884b43bSJohn Scipione 	// constrain clipping region to corner
2596a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2597a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2598a884b43bSJohn Scipione 
2599a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2600a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2601a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2602a884b43bSJohn Scipione 
2603a884b43bSJohn Scipione 	// bevel
2604a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2605a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2606a884b43bSJohn Scipione 
2607a884b43bSJohn Scipione 	// gradient
2608a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2609a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2610a884b43bSJohn Scipione }
2611a884b43bSJohn Scipione 
2612a884b43bSJohn Scipione 
2613a884b43bSJohn Scipione void
2614a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightTop(BView* view, BRect& cornerRect,
2615a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2616a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2617a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor,
2618a884b43bSJohn Scipione 	const rgb_color& bevelTopColor, const rgb_color& bevelRightColor,
2619a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2620a884b43bSJohn Scipione {
2621a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightTop(view, cornerRect, updateRect,
2622a884b43bSJohn Scipione 		background, edgeTopColor, edgeRightColor, frameTopColor,
2623a884b43bSJohn Scipione 		frameRightColor);
2624a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightTop(view, cornerRect, updateRect,
2625a884b43bSJohn Scipione 		bevelTopColor, bevelRightColor, fillGradient);
2626a884b43bSJohn Scipione }
2627a884b43bSJohn Scipione 
2628a884b43bSJohn Scipione 
2629a884b43bSJohn Scipione void
2630a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightTop(BView* view, BRect& cornerRect,
2631a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2632a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2633a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor)
2634a884b43bSJohn Scipione {
2635a884b43bSJohn Scipione 	// constrain clipping region to corner
2636a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2637a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2638a884b43bSJohn Scipione 
2639a884b43bSJohn Scipione 	// background
2640a884b43bSJohn Scipione 	view->SetHighColor(background);
2641a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2642a884b43bSJohn Scipione 
2643a884b43bSJohn Scipione 	// outer edge
2644a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2645a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2646a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2647a884b43bSJohn Scipione 
2648a884b43bSJohn Scipione 	BGradientLinear gradient;
2649a884b43bSJohn Scipione 	gradient.AddColor(edgeTopColor, 0);
2650a884b43bSJohn Scipione 	gradient.AddColor(edgeRightColor, 255);
2651a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2652a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2653a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2654a884b43bSJohn Scipione 
2655a884b43bSJohn Scipione 	// frame
2656a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2657a884b43bSJohn Scipione 	cornerRect.right--;
2658a884b43bSJohn Scipione 	cornerRect.top++;
2659a884b43bSJohn Scipione 	if (frameTopColor == frameRightColor) {
2660a884b43bSJohn Scipione 		view->SetHighColor(frameTopColor);
2661a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2662a884b43bSJohn Scipione 	} else {
2663a884b43bSJohn Scipione 		gradient.SetColor(0, frameTopColor);
2664a884b43bSJohn Scipione 		gradient.SetColor(1, frameRightColor);
2665a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2666a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2667a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2668a884b43bSJohn Scipione 	}
2669a884b43bSJohn Scipione 
2670a884b43bSJohn Scipione 	// prepare for bevel
2671a884b43bSJohn Scipione 	cornerRect.right--;
2672a884b43bSJohn Scipione 	cornerRect.top++;
2673a884b43bSJohn Scipione }
2674a884b43bSJohn Scipione 
2675a884b43bSJohn Scipione 
2676a884b43bSJohn Scipione void
2677a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightTop(BView* view, BRect& cornerRect,
2678a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelTopColor,
2679a884b43bSJohn Scipione 	const rgb_color& bevelRightColor, const BGradientLinear& fillGradient)
2680a884b43bSJohn Scipione {
2681a884b43bSJohn Scipione 	// constrain clipping region to corner
2682a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2683a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2684a884b43bSJohn Scipione 
2685a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2686a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2687a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2688a884b43bSJohn Scipione 
2689a884b43bSJohn Scipione 	// bevel
2690a884b43bSJohn Scipione 	BGradientLinear gradient;
2691a884b43bSJohn Scipione 	gradient.AddColor(bevelTopColor, 0);
2692a884b43bSJohn Scipione 	gradient.AddColor(bevelRightColor, 255);
2693a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2694a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2695a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2696a884b43bSJohn Scipione 
2697a884b43bSJohn Scipione 	// gradient
2698a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2699a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2700a884b43bSJohn Scipione }
2701a884b43bSJohn Scipione 
2702a884b43bSJohn Scipione 
2703a884b43bSJohn Scipione void
2704a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftBottom(BView* view, BRect& cornerRect,
2705a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2706a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
2707a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor,
2708a884b43bSJohn Scipione 	const rgb_color& bevelLeftColor, const rgb_color& bevelBottomColor,
2709a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2710a884b43bSJohn Scipione {
2711a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftBottom(view, cornerRect, updateRect,
2712a884b43bSJohn Scipione 		background, edgeLeftColor, edgeBottomColor, frameLeftColor,
2713a884b43bSJohn Scipione 		frameBottomColor);
2714a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftBottom(view, cornerRect, updateRect,
2715a884b43bSJohn Scipione 		bevelLeftColor, bevelBottomColor, fillGradient);
2716a884b43bSJohn Scipione }
2717a884b43bSJohn Scipione 
2718a884b43bSJohn Scipione 
2719a884b43bSJohn Scipione void
2720a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftBottom(BView* view, BRect& cornerRect,
2721a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2722a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
2723a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor)
2724a884b43bSJohn Scipione {
2725a884b43bSJohn Scipione 	// constrain clipping region to corner
2726a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2727a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2728a884b43bSJohn Scipione 
2729a884b43bSJohn Scipione 	// background
2730a884b43bSJohn Scipione 	view->SetHighColor(background);
2731a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2732a884b43bSJohn Scipione 
2733a884b43bSJohn Scipione 	// outer edge
2734a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2735a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2736a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2737a884b43bSJohn Scipione 
2738a884b43bSJohn Scipione 	BGradientLinear gradient;
2739a884b43bSJohn Scipione 	gradient.AddColor(edgeLeftColor, 0);
2740a884b43bSJohn Scipione 	gradient.AddColor(edgeBottomColor, 255);
2741a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2742a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2743a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2744a884b43bSJohn Scipione 
2745a884b43bSJohn Scipione 	// frame
2746a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2747a884b43bSJohn Scipione 	cornerRect.left++;
2748a884b43bSJohn Scipione 	cornerRect.bottom--;
2749a884b43bSJohn Scipione 	if (frameLeftColor == frameBottomColor) {
2750a884b43bSJohn Scipione 		view->SetHighColor(frameLeftColor);
2751a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2752a884b43bSJohn Scipione 	} else {
2753a884b43bSJohn Scipione 		gradient.SetColor(0, frameLeftColor);
2754a884b43bSJohn Scipione 		gradient.SetColor(1, frameBottomColor);
2755a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2756a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2757a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2758a884b43bSJohn Scipione 	}
2759a884b43bSJohn Scipione 
2760a884b43bSJohn Scipione 	// prepare for bevel
2761a884b43bSJohn Scipione 	cornerRect.left++;
2762a884b43bSJohn Scipione 	cornerRect.bottom--;
2763a884b43bSJohn Scipione }
2764a884b43bSJohn Scipione 
2765a884b43bSJohn Scipione 
2766a884b43bSJohn Scipione void
2767a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftBottom(BView* view, BRect& cornerRect,
2768a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelLeftColor,
2769a884b43bSJohn Scipione 	const rgb_color& bevelBottomColor, const BGradientLinear& fillGradient)
2770a884b43bSJohn Scipione {
2771a884b43bSJohn Scipione 	// constrain clipping region to corner
2772a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2773a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2774a884b43bSJohn Scipione 
2775a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2776a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2777a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2778a884b43bSJohn Scipione 
2779a884b43bSJohn Scipione 	// bevel
2780a884b43bSJohn Scipione 	BGradientLinear gradient;
2781a884b43bSJohn Scipione 	gradient.AddColor(bevelLeftColor, 0);
2782a884b43bSJohn Scipione 	gradient.AddColor(bevelBottomColor, 255);
2783a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2784a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2785a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2786a884b43bSJohn Scipione 
2787a884b43bSJohn Scipione 	// gradient
2788a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2789a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2790a884b43bSJohn Scipione 
2791a884b43bSJohn Scipione 	view->PopState();
2792a884b43bSJohn Scipione }
2793a884b43bSJohn Scipione 
2794a884b43bSJohn Scipione 
2795a884b43bSJohn Scipione void
2796a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightBottom(BView* view, BRect& cornerRect,
2797a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2798a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2799a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2800a884b43bSJohn Scipione {
2801a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightBottom(view, cornerRect, updateRect,
2802a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2803a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightBottom(view, cornerRect, updateRect,
2804a884b43bSJohn Scipione 		bevelColor, fillGradient);
2805a884b43bSJohn Scipione }
2806a884b43bSJohn Scipione 
2807a884b43bSJohn Scipione 
2808a884b43bSJohn Scipione void
2809a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect,
2810a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2811a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2812a884b43bSJohn Scipione {
2813a884b43bSJohn Scipione 	// constrain clipping region to corner
2814a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2815a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2816a884b43bSJohn Scipione 
2817a884b43bSJohn Scipione 	// background
2818a884b43bSJohn Scipione 	view->SetHighColor(background);
2819a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2820a884b43bSJohn Scipione 
2821a884b43bSJohn Scipione 	// outer edge
2822a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2823a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2824a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2825a884b43bSJohn Scipione 
2826a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2827a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2828a884b43bSJohn Scipione 
2829a884b43bSJohn Scipione 	// frame
2830a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2831a884b43bSJohn Scipione 	cornerRect.right--;
2832a884b43bSJohn Scipione 	cornerRect.bottom++;
2833a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2834a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2835a884b43bSJohn Scipione 
2836a884b43bSJohn Scipione 	// prepare for bevel
2837a884b43bSJohn Scipione 	cornerRect.left++;
2838a884b43bSJohn Scipione 	cornerRect.bottom--;
2839a884b43bSJohn Scipione }
2840a884b43bSJohn Scipione 
2841a884b43bSJohn Scipione 
2842a884b43bSJohn Scipione void
2843a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightBottom(BView* view,
2844a884b43bSJohn Scipione 	BRect& cornerRect, const BRect& updateRect, const rgb_color& bevelColor,
2845a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2846a884b43bSJohn Scipione {
2847a884b43bSJohn Scipione 	// constrain clipping region to corner
2848a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2849a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2850a884b43bSJohn Scipione 
2851a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2852a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2853a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2854a884b43bSJohn Scipione 
2855a884b43bSJohn Scipione 	// bevel
2856a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2857a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2858a884b43bSJohn Scipione 
2859a884b43bSJohn Scipione 	// gradient
2860a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2861a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
28622f86ba45SStephan Aßmus }
28632f86ba45SStephan Aßmus 
28642f86ba45SStephan Aßmus 
28652f86ba45SStephan Aßmus void
28662f86ba45SStephan Aßmus BControlLook::_DrawRoundBarCorner(BView* view, BRect& rect,
28672f86ba45SStephan Aßmus 	const BRect& updateRect,
28682f86ba45SStephan Aßmus 	const rgb_color& edgeLightColor, const rgb_color& edgeShadowColor,
28692f86ba45SStephan Aßmus 	const rgb_color& frameLightColor, const rgb_color& frameShadowColor,
28702f86ba45SStephan Aßmus 	const rgb_color& fillLightColor, const rgb_color& fillShadowColor,
28712f86ba45SStephan Aßmus 	float leftInset, float topInset, float rightInset, float bottomInset,
28722f86ba45SStephan Aßmus 	enum orientation orientation)
28732f86ba45SStephan Aßmus {
28742f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
28752f86ba45SStephan Aßmus 		return;
28762f86ba45SStephan Aßmus 
28772f86ba45SStephan Aßmus 	BGradientLinear gradient;
28782f86ba45SStephan Aßmus 	gradient.AddColor(edgeShadowColor, 0);
28792f86ba45SStephan Aßmus 	gradient.AddColor(edgeLightColor, 255);
28802f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
28812f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
28822f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
28832f86ba45SStephan Aßmus 	else
28842f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
28852f86ba45SStephan Aßmus 
28862f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
28872f86ba45SStephan Aßmus 
28882f86ba45SStephan Aßmus 	rect.left += leftInset;
28892f86ba45SStephan Aßmus 	rect.top += topInset;
28902f86ba45SStephan Aßmus 	rect.right += rightInset;
28912f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
28922f86ba45SStephan Aßmus 
28932f86ba45SStephan Aßmus 	gradient.MakeEmpty();
28942f86ba45SStephan Aßmus 	gradient.AddColor(frameShadowColor, 0);
28952f86ba45SStephan Aßmus 	gradient.AddColor(frameLightColor, 255);
28962f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
28972f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
28982f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
28992f86ba45SStephan Aßmus 	else
29002f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
29012f86ba45SStephan Aßmus 
29022f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
29032f86ba45SStephan Aßmus 
29042f86ba45SStephan Aßmus 	rect.left += leftInset;
29052f86ba45SStephan Aßmus 	rect.top += topInset;
29062f86ba45SStephan Aßmus 	rect.right += rightInset;
29072f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
29082f86ba45SStephan Aßmus 
29092f86ba45SStephan Aßmus 	gradient.MakeEmpty();
29102f86ba45SStephan Aßmus 	gradient.AddColor(fillShadowColor, 0);
29112f86ba45SStephan Aßmus 	gradient.AddColor(fillLightColor, 255);
29122f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
29132f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
29142f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
29152f86ba45SStephan Aßmus 	else
29162f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
29172f86ba45SStephan Aßmus 
29182f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
29192f86ba45SStephan Aßmus }
29202f86ba45SStephan Aßmus 
29212f86ba45SStephan Aßmus 
2922a884b43bSJohn Scipione rgb_color
2923a884b43bSJohn Scipione BControlLook::_EdgeLightColor(const rgb_color& base, float contrast,
2924a884b43bSJohn Scipione 	float brightness, uint32 flags)
29252f86ba45SStephan Aßmus {
2926a884b43bSJohn Scipione 	rgb_color edgeLightColor;
29272f86ba45SStephan Aßmus 
2928a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
2929a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
2930a884b43bSJohn Scipione 		uint32 white = uint8(255 * brightness);
29312f86ba45SStephan Aßmus 
2932a884b43bSJohn Scipione 		edgeLightColor = (rgb_color){ white, white, white, alpha };
29332f86ba45SStephan Aßmus 	} else {
2934a884b43bSJohn Scipione 		// colors
2935a884b43bSJohn Scipione 		float tintLight = kEdgeBevelLightTint;
2936a884b43bSJohn Scipione 
2937a884b43bSJohn Scipione 		if (contrast == 0.0)
2938a884b43bSJohn Scipione 			tintLight = B_NO_TINT;
2939a884b43bSJohn Scipione 		else if (contrast != 1.0)
2940a884b43bSJohn Scipione 			tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast;
2941a884b43bSJohn Scipione 
2942a884b43bSJohn Scipione 		edgeLightColor = tint_color(base, tintLight);
2943a884b43bSJohn Scipione 
2944a884b43bSJohn Scipione 		if (brightness < 1.0) {
2945a884b43bSJohn Scipione 			edgeLightColor.red = uint8(edgeLightColor.red * brightness);
2946a884b43bSJohn Scipione 			edgeLightColor.green = uint8(edgeLightColor.green * brightness);
2947a884b43bSJohn Scipione 			edgeLightColor.blue = uint8(edgeLightColor.blue * brightness);
2948a884b43bSJohn Scipione 		}
29492f86ba45SStephan Aßmus 	}
29502f86ba45SStephan Aßmus 
2951a884b43bSJohn Scipione 	return edgeLightColor;
2952a884b43bSJohn Scipione }
2953a884b43bSJohn Scipione 
2954a884b43bSJohn Scipione 
2955a884b43bSJohn Scipione rgb_color
2956a884b43bSJohn Scipione BControlLook::_EdgeShadowColor(const rgb_color& base, float contrast,
2957a884b43bSJohn Scipione 	float brightness, uint32 flags)
2958a884b43bSJohn Scipione {
2959a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
2960a884b43bSJohn Scipione 
2961a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
2962a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
2963a884b43bSJohn Scipione 		edgeShadowColor = (rgb_color){ 0, 0, 0, alpha };
2964a884b43bSJohn Scipione 	} else {
2965a884b43bSJohn Scipione 		float tintShadow = kEdgeBevelShadowTint;
2966a884b43bSJohn Scipione 
2967a884b43bSJohn Scipione 		if (contrast == 0.0)
2968a884b43bSJohn Scipione 			tintShadow = B_NO_TINT;
2969a884b43bSJohn Scipione 		else if (contrast != 1.0)
2970a884b43bSJohn Scipione 			tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast;
2971a884b43bSJohn Scipione 
2972a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, tintShadow);
2973a884b43bSJohn Scipione 
2974a884b43bSJohn Scipione 		if (brightness < 1.0) {
2975a884b43bSJohn Scipione 			edgeShadowColor.red = uint8(edgeShadowColor.red * brightness);
2976a884b43bSJohn Scipione 			edgeShadowColor.green = uint8(edgeShadowColor.green * brightness);
2977a884b43bSJohn Scipione 			edgeShadowColor.blue = uint8(edgeShadowColor.blue * brightness);
2978a884b43bSJohn Scipione 		}
2979a884b43bSJohn Scipione 	}
2980a884b43bSJohn Scipione 
2981a884b43bSJohn Scipione 	return edgeShadowColor;
2982a884b43bSJohn Scipione }
2983a884b43bSJohn Scipione 
2984a884b43bSJohn Scipione 
2985a884b43bSJohn Scipione rgb_color
2986a884b43bSJohn Scipione BControlLook::_FrameLightColor(const rgb_color& base, uint32 flags)
2987a884b43bSJohn Scipione {
2988a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
2989a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
2990a884b43bSJohn Scipione 
2991a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
2992a884b43bSJohn Scipione 		return _FrameShadowColor(base, flags & ~B_ACTIVATED);
2993a884b43bSJohn Scipione 
2994a884b43bSJohn Scipione 	rgb_color frameLightColor;
2995a884b43bSJohn Scipione 
2996a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
2997a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
2998a884b43bSJohn Scipione 		frameLightColor = tint_color(base, 1.145);
2999a884b43bSJohn Scipione 
3000a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3001a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.14);
3002a884b43bSJohn Scipione 	} else {
3003a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
3004a884b43bSJohn Scipione 			frameLightColor = (rgb_color){ 0, 0, 0, 75 };
3005a884b43bSJohn Scipione 		else
3006a884b43bSJohn Scipione 			frameLightColor = tint_color(base, 1.33);
3007a884b43bSJohn Scipione 
3008a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3009a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.35);
3010a884b43bSJohn Scipione 	}
3011a884b43bSJohn Scipione 
3012a884b43bSJohn Scipione 	return frameLightColor;
3013a884b43bSJohn Scipione }
3014a884b43bSJohn Scipione 
3015a884b43bSJohn Scipione 
3016a884b43bSJohn Scipione rgb_color
3017a884b43bSJohn Scipione BControlLook::_FrameShadowColor(const rgb_color& base, uint32 flags)
3018a884b43bSJohn Scipione {
3019a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
3020a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
3021a884b43bSJohn Scipione 
3022a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3023a884b43bSJohn Scipione 		return _FrameLightColor(base, flags & ~B_ACTIVATED);
3024a884b43bSJohn Scipione 
3025a884b43bSJohn Scipione 	rgb_color frameShadowColor;
3026a884b43bSJohn Scipione 
3027a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3028a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
3029a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.24);
3030a884b43bSJohn Scipione 
3031a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3032a884b43bSJohn Scipione 			frameShadowColor = tint_color(base, 1.145);
3033a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.12);
3034a884b43bSJohn Scipione 		}
3035a884b43bSJohn Scipione 	} else {
3036a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3037a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3038a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 75 };
3039a884b43bSJohn Scipione 			else
3040a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.33);
3041a884b43bSJohn Scipione 
3042a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.5);
3043a884b43bSJohn Scipione 		} else {
3044a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3045a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 95 };
3046a884b43bSJohn Scipione 			else
3047a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.47);
3048a884b43bSJohn Scipione 		}
3049a884b43bSJohn Scipione 	}
3050a884b43bSJohn Scipione 
3051a884b43bSJohn Scipione 	return frameShadowColor;
3052a884b43bSJohn Scipione }
3053a884b43bSJohn Scipione 
3054a884b43bSJohn Scipione 
3055a884b43bSJohn Scipione rgb_color
3056a884b43bSJohn Scipione BControlLook::_BevelLightColor(const rgb_color& base, uint32 flags)
3057a884b43bSJohn Scipione {
3058a884b43bSJohn Scipione 	rgb_color bevelLightColor = tint_color(base, 0.2);
3059a884b43bSJohn Scipione 
3060a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3061a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_LIGHTEN_1_TINT);
3062a884b43bSJohn Scipione 
3063a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3064a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_DARKEN_1_TINT);
3065a884b43bSJohn Scipione 
3066a884b43bSJohn Scipione 	return bevelLightColor;
3067a884b43bSJohn Scipione }
3068a884b43bSJohn Scipione 
3069a884b43bSJohn Scipione 
3070a884b43bSJohn Scipione rgb_color
3071a884b43bSJohn Scipione BControlLook::_BevelShadowColor(const rgb_color& base, uint32 flags)
3072a884b43bSJohn Scipione {
3073a884b43bSJohn Scipione 	rgb_color bevelShadowColor = tint_color(base, 1.08);
3074a884b43bSJohn Scipione 
3075a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3076a884b43bSJohn Scipione 		bevelShadowColor = base;
3077a884b43bSJohn Scipione 
3078a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3079a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, B_DARKEN_1_TINT);
3080a884b43bSJohn Scipione 
3081a884b43bSJohn Scipione 	return bevelShadowColor;
3082a884b43bSJohn Scipione }
3083a884b43bSJohn Scipione 
3084a884b43bSJohn Scipione 
3085a884b43bSJohn Scipione void
3086a884b43bSJohn Scipione BControlLook::_FillGradient(BView* view, const BRect& rect,
3087a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3088a884b43bSJohn Scipione 	enum orientation orientation)
3089a884b43bSJohn Scipione {
3090a884b43bSJohn Scipione 	BGradientLinear gradient;
3091a884b43bSJohn Scipione 	_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3092a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3093a884b43bSJohn Scipione }
3094a884b43bSJohn Scipione 
3095a884b43bSJohn Scipione 
3096a884b43bSJohn Scipione void
3097a884b43bSJohn Scipione BControlLook::_FillGlossyGradient(BView* view, const BRect& rect,
3098a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3099a884b43bSJohn Scipione 	float middle2Tint, float bottomTint, enum orientation orientation)
3100a884b43bSJohn Scipione {
3101a884b43bSJohn Scipione 	BGradientLinear gradient;
3102a884b43bSJohn Scipione 	_MakeGlossyGradient(gradient, rect, base, topTint, middle1Tint,
3103a884b43bSJohn Scipione 		middle2Tint, bottomTint, orientation);
3104a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3105a884b43bSJohn Scipione }
3106a884b43bSJohn Scipione 
3107a884b43bSJohn Scipione 
3108a884b43bSJohn Scipione void
3109a884b43bSJohn Scipione BControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect,
3110a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3111a884b43bSJohn Scipione 	enum orientation orientation) const
3112a884b43bSJohn Scipione {
3113a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3114a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
31152f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
3116a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3117a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3118a884b43bSJohn Scipione 	else
3119a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3120a884b43bSJohn Scipione }
31212f86ba45SStephan Aßmus 
31222f86ba45SStephan Aßmus 
3123a884b43bSJohn Scipione void
3124a884b43bSJohn Scipione BControlLook::_MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect,
3125a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3126a884b43bSJohn Scipione 	float middle2Tint, float bottomTint,
3127a884b43bSJohn Scipione 	enum orientation orientation) const
3128a884b43bSJohn Scipione {
3129a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3130a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle1Tint), 132);
3131a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle2Tint), 136);
3132a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
3133a884b43bSJohn Scipione 	gradient.SetStart(rect.LeftTop());
3134a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3135a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3136a884b43bSJohn Scipione 	else
3137a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3138a884b43bSJohn Scipione }
3139a884b43bSJohn Scipione 
3140a884b43bSJohn Scipione 
3141a884b43bSJohn Scipione void
3142a884b43bSJohn Scipione BControlLook::_MakeButtonGradient(BGradientLinear& gradient, BRect& rect,
3143a884b43bSJohn Scipione 	const rgb_color& base, uint32 flags, enum orientation orientation) const
3144a884b43bSJohn Scipione {
3145a884b43bSJohn Scipione 	float topTint = 0.49;
3146a884b43bSJohn Scipione 	float middleTint1 = 0.62;
3147a884b43bSJohn Scipione 	float middleTint2 = 0.76;
3148a884b43bSJohn Scipione 	float bottomTint = 0.90;
3149a884b43bSJohn Scipione 
3150a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3151a884b43bSJohn Scipione 		topTint = 1.11;
3152a884b43bSJohn Scipione 		bottomTint = 1.08;
3153a884b43bSJohn Scipione 	}
3154a884b43bSJohn Scipione 
3155a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3156a884b43bSJohn Scipione 		topTint = (topTint + B_NO_TINT) / 2;
3157a884b43bSJohn Scipione 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
3158a884b43bSJohn Scipione 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
3159a884b43bSJohn Scipione 		bottomTint = (bottomTint + B_NO_TINT) / 2;
3160a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
3161a884b43bSJohn Scipione 		static const float kHoverTintFactor = 0.85;
3162a884b43bSJohn Scipione 		topTint *= kHoverTintFactor;
3163a884b43bSJohn Scipione 		middleTint1 *= kHoverTintFactor;
3164a884b43bSJohn Scipione 		middleTint2 *= kHoverTintFactor;
3165a884b43bSJohn Scipione 		bottomTint *= kHoverTintFactor;
3166a884b43bSJohn Scipione 	}
3167a884b43bSJohn Scipione 
3168a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3169a884b43bSJohn Scipione 		_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3170a884b43bSJohn Scipione 	} else {
3171a884b43bSJohn Scipione 		_MakeGlossyGradient(gradient, rect, base, topTint, middleTint1,
3172a884b43bSJohn Scipione 			middleTint2, bottomTint, orientation);
3173a884b43bSJohn Scipione 	}
3174a884b43bSJohn Scipione }
3175a884b43bSJohn Scipione 
3176a884b43bSJohn Scipione 
3177a884b43bSJohn Scipione 
3178a884b43bSJohn Scipione bool
3179a884b43bSJohn Scipione BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,
3180a884b43bSJohn Scipione 	rgb_color& color, uint32 flags) const
3181a884b43bSJohn Scipione {
3182a884b43bSJohn Scipione 	if ((flags & (B_ACTIVATED | B_CLICKED)) == 0) {
3183a884b43bSJohn Scipione 		// no mark to be drawn at all
3184a884b43bSJohn Scipione 		return false;
3185a884b43bSJohn Scipione 	}
3186a884b43bSJohn Scipione 
31874bb5af76SJohn Scipione 	color = ui_color(B_CONTROL_MARK_COLOR);
3188a884b43bSJohn Scipione 
3189a884b43bSJohn Scipione 	float mix = 1.0;
3190a884b43bSJohn Scipione 
3191a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3192a884b43bSJohn Scipione 		// activated, but disabled
3193a884b43bSJohn Scipione 		mix = 0.4;
3194a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
3195a884b43bSJohn Scipione 		if ((flags & B_ACTIVATED) != 0) {
3196a884b43bSJohn Scipione 			// loosing activation
3197a884b43bSJohn Scipione 			mix = 0.7;
3198a884b43bSJohn Scipione 		} else {
3199a884b43bSJohn Scipione 			// becoming activated
3200a884b43bSJohn Scipione 			mix = 0.3;
3201a884b43bSJohn Scipione 		}
3202a884b43bSJohn Scipione 	} else {
3203a884b43bSJohn Scipione 		// simply activated
3204a884b43bSJohn Scipione 	}
3205a884b43bSJohn Scipione 
3206a884b43bSJohn Scipione 	color.red = uint8(color.red * mix + base.red * (1.0 - mix));
3207a884b43bSJohn Scipione 	color.green = uint8(color.green * mix + base.green * (1.0 - mix));
3208a884b43bSJohn Scipione 	color.blue = uint8(color.blue * mix + base.blue * (1.0 - mix));
3209a884b43bSJohn Scipione 
3210a884b43bSJohn Scipione 	return true;
32112f86ba45SStephan Aßmus }
32122f86ba45SStephan Aßmus 
32132f86ba45SStephan Aßmus 
32142f86ba45SStephan Aßmus // NOTE: May come from a add-on in the future. Initialized in
32152f86ba45SStephan Aßmus // InterfaceDefs.cpp
32162f86ba45SStephan Aßmus BControlLook* be_control_look = NULL;
32172f86ba45SStephan Aßmus 
3218a884b43bSJohn Scipione 
32192f86ba45SStephan Aßmus } // namespace BPrivate
3220