xref: /haiku/src/kits/interface/ControlLook.cpp (revision e047b40a2fd11728e4f7ac83d121299c89e9e658)
12f86ba45SStephan Aßmus /*
22f86ba45SStephan Aßmus  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3*e047b40aSAxel Dörfler  * Copyright 2012-2015 Haiku, Inc. All rights reserved.
42f86ba45SStephan Aßmus  * Distributed under the terms of the MIT License.
5a884b43bSJohn Scipione  *
6a884b43bSJohn Scipione  * Authors:
7e439b003SJohn Scipione  *		Stephan Aßmus, superstippi@gmx.de
8e439b003SJohn Scipione  *		John Scipione, jscipione@gmail.com
92f86ba45SStephan Aßmus  */
10d452ff66SAxel Dörfler 
11d452ff66SAxel Dörfler 
122f86ba45SStephan Aßmus #include <ControlLook.h>
132f86ba45SStephan Aßmus 
141b848ee7SIngo Weinhold #include <algorithm>
151b848ee7SIngo Weinhold 
162f86ba45SStephan Aßmus #include <Control.h>
172f86ba45SStephan Aßmus #include <GradientLinear.h>
181b848ee7SIngo Weinhold #include <LayoutUtils.h>
192f86ba45SStephan Aßmus #include <Region.h>
202f86ba45SStephan Aßmus #include <Shape.h>
212f86ba45SStephan Aßmus #include <String.h>
222f86ba45SStephan Aßmus #include <View.h>
23d63b75faSPhilippe Saint-Pierre #include <Window.h>
242f86ba45SStephan Aßmus 
25a884b43bSJohn Scipione #include "ContainerWindow.h"
26a884b43bSJohn Scipione 
27a884b43bSJohn Scipione 
282f86ba45SStephan Aßmus namespace BPrivate {
292f86ba45SStephan Aßmus 
30a884b43bSJohn Scipione 
312f86ba45SStephan Aßmus static const float kEdgeBevelLightTint = 0.59;
322f86ba45SStephan Aßmus static const float kEdgeBevelShadowTint = 1.0735;
33a0848a19SIngo Weinhold static const float kHoverTintFactor = 0.85;
34a0848a19SIngo Weinhold 
35a0848a19SIngo Weinhold static const float kButtonPopUpIndicatorWidth = 11;
362f86ba45SStephan Aßmus 
372f86ba45SStephan Aßmus 
38d63b75faSPhilippe Saint-Pierre BControlLook::BControlLook():
39d63b75faSPhilippe Saint-Pierre 	fCachedOutline(false),
40d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace(-1)
412f86ba45SStephan Aßmus {
422f86ba45SStephan Aßmus }
432f86ba45SStephan Aßmus 
442f86ba45SStephan Aßmus 
452f86ba45SStephan Aßmus BControlLook::~BControlLook()
462f86ba45SStephan Aßmus {
472f86ba45SStephan Aßmus }
482f86ba45SStephan Aßmus 
492f86ba45SStephan Aßmus 
502f86ba45SStephan Aßmus BAlignment
512f86ba45SStephan Aßmus BControlLook::DefaultLabelAlignment() const
522f86ba45SStephan Aßmus {
532f86ba45SStephan Aßmus 	return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
542f86ba45SStephan Aßmus }
552f86ba45SStephan Aßmus 
562f86ba45SStephan Aßmus 
572f86ba45SStephan Aßmus float
582f86ba45SStephan Aßmus BControlLook::DefaultLabelSpacing() const
592f86ba45SStephan Aßmus {
6020a11271SAxel Dörfler 	return ceilf(be_plain_font->Size() / 2.0);
6120a11271SAxel Dörfler }
6220a11271SAxel Dörfler 
6320a11271SAxel Dörfler 
6420a11271SAxel Dörfler float
6520a11271SAxel Dörfler BControlLook::DefaultItemSpacing() const
6620a11271SAxel Dörfler {
6720a11271SAxel Dörfler 	return ceilf(be_plain_font->Size() * 0.85);
682f86ba45SStephan Aßmus }
692f86ba45SStephan Aßmus 
702f86ba45SStephan Aßmus 
7182ab3167SAlex Wilson float
726648dd3cSAlex Wilson BControlLook::ComposeSpacing(float spacing)
7382ab3167SAlex Wilson {
74*e047b40aSAxel Dörfler 	switch ((int)spacing) {
75*e047b40aSAxel Dörfler 		case B_USE_DEFAULT_SPACING:
76*e047b40aSAxel Dörfler 		case B_USE_ITEM_SPACING:
7782ab3167SAlex Wilson 			return be_control_look->DefaultItemSpacing();
78*e047b40aSAxel Dörfler 		case B_USE_HALF_ITEM_SPACING:
79a8b89c6bSStephan Aßmus 			return ceilf(be_control_look->DefaultItemSpacing() * 0.5f);
80*e047b40aSAxel Dörfler 		case B_USE_WINDOW_SPACING:
816648dd3cSAlex Wilson 			return be_control_look->DefaultItemSpacing();
82*e047b40aSAxel Dörfler 		case B_USE_SMALL_SPACING:
83a8b89c6bSStephan Aßmus 			return ceilf(be_control_look->DefaultItemSpacing() * 0.7f);
84*e047b40aSAxel Dörfler 		case B_USE_BIG_SPACING:
85a8b89c6bSStephan Aßmus 			return ceilf(be_control_look->DefaultItemSpacing() * 1.3f);
866648dd3cSAlex Wilson 	}
87*e047b40aSAxel Dörfler 
886648dd3cSAlex Wilson 	return spacing;
8982ab3167SAlex Wilson }
9082ab3167SAlex Wilson 
9182ab3167SAlex Wilson 
922f86ba45SStephan Aßmus uint32
932f86ba45SStephan Aßmus BControlLook::Flags(BControl* control) const
942f86ba45SStephan Aßmus {
952f86ba45SStephan Aßmus 	uint32 flags = 0;
962f86ba45SStephan Aßmus 
972f86ba45SStephan Aßmus 	if (!control->IsEnabled())
982f86ba45SStephan Aßmus 		flags |= B_DISABLED;
992f86ba45SStephan Aßmus 
100d38ba8f7SJohn Scipione 	if (control->IsFocus() && control->Window() != NULL
101d38ba8f7SJohn Scipione 		&& control->Window()->IsActive()) {
1022f86ba45SStephan Aßmus 		flags |= B_FOCUSED;
10359655dcbSJohn Scipione 	}
1042f86ba45SStephan Aßmus 
105df37cd4eSIngo Weinhold 	switch (control->Value()) {
106df37cd4eSIngo Weinhold 		case B_CONTROL_ON:
1072f86ba45SStephan Aßmus 			flags |= B_ACTIVATED;
108df37cd4eSIngo Weinhold 			break;
109df37cd4eSIngo Weinhold 		case B_CONTROL_PARTIALLY_ON:
110df37cd4eSIngo Weinhold 			flags |= B_PARTIALLY_ACTIVATED;
111df37cd4eSIngo Weinhold 			break;
112df37cd4eSIngo Weinhold 	}
1132f86ba45SStephan Aßmus 
11461ac1a85SStephan Aßmus 	if (control->Parent() != NULL
11561ac1a85SStephan Aßmus 		&& (control->Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
11661ac1a85SStephan Aßmus 		// In this constellation, assume we want to render the control
11761ac1a85SStephan Aßmus 		// against the already existing view contents of the parent view.
11861ac1a85SStephan Aßmus 		flags |= B_BLEND_FRAME;
11961ac1a85SStephan Aßmus 	}
12061ac1a85SStephan Aßmus 
1212f86ba45SStephan Aßmus 	return flags;
1222f86ba45SStephan Aßmus }
1232f86ba45SStephan Aßmus 
1242f86ba45SStephan Aßmus 
1252f86ba45SStephan Aßmus // #pragma mark -
1262f86ba45SStephan Aßmus 
1272f86ba45SStephan Aßmus 
1282f86ba45SStephan Aßmus void
1292f86ba45SStephan Aßmus BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
130681c2e44SStephan Aßmus 	const rgb_color& base, const rgb_color& background, uint32 flags,
131681c2e44SStephan Aßmus 	uint32 borders)
1322f86ba45SStephan Aßmus {
133a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
134a884b43bSJohn Scipione 		background, 1.0, 1.0, flags, borders);
135a884b43bSJohn Scipione }
136a884b43bSJohn Scipione 
137a884b43bSJohn Scipione 
138a884b43bSJohn Scipione void
139a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
140a884b43bSJohn Scipione 	float radius, const rgb_color& base, const rgb_color& background, uint32 flags,
141a884b43bSJohn Scipione 	uint32 borders)
142a884b43bSJohn Scipione {
143a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
144a884b43bSJohn Scipione 		base, background, 1.0, 1.0, flags, borders);
145a884b43bSJohn Scipione }
146a884b43bSJohn Scipione 
147a884b43bSJohn Scipione 
148a884b43bSJohn Scipione void
149a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect,
150a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
151a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
152a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags,
153a884b43bSJohn Scipione 	uint32 borders)
154a884b43bSJohn Scipione {
155a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
156a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background,
157a884b43bSJohn Scipione 		1.0, 1.0, flags, borders);
1582f86ba45SStephan Aßmus }
1592f86ba45SStephan Aßmus 
1602f86ba45SStephan Aßmus 
1612f86ba45SStephan Aßmus void
1622f86ba45SStephan Aßmus BControlLook::DrawButtonBackground(BView* view, BRect& rect,
1632f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
164e724b26fSJohn Scipione 	uint32 borders, orientation orientation)
1652f86ba45SStephan Aßmus {
166a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f,
167a0848a19SIngo Weinhold 		base, false, flags, borders, orientation);
1682f86ba45SStephan Aßmus }
1692f86ba45SStephan Aßmus 
1702f86ba45SStephan Aßmus 
171a884b43bSJohn Scipione void
172a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
173a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base, uint32 flags,
174e724b26fSJohn Scipione 	uint32 borders, orientation orientation)
175a884b43bSJohn Scipione {
176a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, radius, radius, radius,
177a0848a19SIngo Weinhold 		radius, base, false, flags, borders, orientation);
1782f86ba45SStephan Aßmus }
1792f86ba45SStephan Aßmus 
1802f86ba45SStephan Aßmus 
181a884b43bSJohn Scipione void
182a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
183a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
184a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
185e724b26fSJohn Scipione 	uint32 flags, uint32 borders, orientation orientation)
186a884b43bSJohn Scipione {
187a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, leftTopRadius,
188a0848a19SIngo Weinhold 		rightTopRadius, leftBottomRadius, rightBottomRadius, base, false, flags,
189a884b43bSJohn Scipione 		borders, orientation);
1902f86ba45SStephan Aßmus }
1912f86ba45SStephan Aßmus 
1922f86ba45SStephan Aßmus 
1932f86ba45SStephan Aßmus void
1942f86ba45SStephan Aßmus BControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
1951a72cb41SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
1961a72cb41SStephan Aßmus 	uint32 borders)
1972f86ba45SStephan Aßmus {
198a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1992f86ba45SStephan Aßmus 		return;
2002f86ba45SStephan Aßmus 
2012f86ba45SStephan Aßmus 	// the surface edges
2022f86ba45SStephan Aßmus 
2032f86ba45SStephan Aßmus 	// colors
2041a72cb41SStephan Aßmus 	float topTint;
2051a72cb41SStephan Aßmus 	float bottomTint;
2061a72cb41SStephan Aßmus 
207a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
2081a72cb41SStephan Aßmus 		rgb_color bevelColor1 = tint_color(base, 1.40);
2091a72cb41SStephan Aßmus 		rgb_color bevelColor2 = tint_color(base, 1.25);
2101a72cb41SStephan Aßmus 
2111a72cb41SStephan Aßmus 		topTint = 1.25;
2121a72cb41SStephan Aßmus 		bottomTint = 1.20;
2132f86ba45SStephan Aßmus 
2142f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
2151a72cb41SStephan Aßmus 			bevelColor1, bevelColor1,
2161a72cb41SStephan Aßmus 			bevelColor2, bevelColor2,
2171a72cb41SStephan Aßmus 			borders & B_TOP_BORDER);
2181a72cb41SStephan Aßmus 	} else {
2191a72cb41SStephan Aßmus 		rgb_color cornerColor = tint_color(base, 0.9);
2201a72cb41SStephan Aßmus 		rgb_color bevelColorTop = tint_color(base, 0.5);
2211a72cb41SStephan Aßmus 		rgb_color bevelColorLeft = tint_color(base, 0.7);
2221a72cb41SStephan Aßmus 		rgb_color bevelColorRightBottom = tint_color(base, 1.08);
2231a72cb41SStephan Aßmus 
2241a72cb41SStephan Aßmus 		topTint = 0.69;
2251a72cb41SStephan Aßmus 		bottomTint = 1.03;
2261a72cb41SStephan Aßmus 
2271a72cb41SStephan Aßmus 		_DrawFrame(view, rect,
2281a72cb41SStephan Aßmus 			bevelColorLeft, bevelColorTop,
2291a72cb41SStephan Aßmus 			bevelColorRightBottom, bevelColorRightBottom,
2302f86ba45SStephan Aßmus 			cornerColor, cornerColor,
2312f86ba45SStephan Aßmus 			borders);
2321a72cb41SStephan Aßmus 	}
2332f86ba45SStephan Aßmus 
234a884b43bSJohn Scipione 	// draw surface top
2352f86ba45SStephan Aßmus 	_FillGradient(view, rect, base, topTint, bottomTint);
2362f86ba45SStephan Aßmus }
2372f86ba45SStephan Aßmus 
2382f86ba45SStephan Aßmus 
2392f86ba45SStephan Aßmus void
240681c2e44SStephan Aßmus BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
241681c2e44SStephan Aßmus 	const BRect& updateRect, const rgb_color& base,
242681c2e44SStephan Aßmus 	const rgb_color& background, uint32 flags, uint32 borders)
24313cd46dfSStephan Aßmus {
244a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
245a884b43bSJohn Scipione 		background, 0.6, 1.0, flags, borders);
246a884b43bSJohn Scipione }
247a884b43bSJohn Scipione 
248a884b43bSJohn Scipione 
249a884b43bSJohn Scipione void
250a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
251a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
252a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
253a884b43bSJohn Scipione {
254a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
255a884b43bSJohn Scipione 		base, background, 0.6, 1.0, flags, borders);
256a884b43bSJohn Scipione }
257a884b43bSJohn Scipione 
258a884b43bSJohn Scipione 
259a884b43bSJohn Scipione void
260a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
261a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius,
262a884b43bSJohn Scipione 	float rightTopRadius, float leftBottomRadius,
263a884b43bSJohn Scipione 	float rightBottomRadius, const rgb_color& base,
264a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
265a884b43bSJohn Scipione {
266a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
267a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background, 0.6, 1.0,
268a884b43bSJohn Scipione 		flags, borders);
26913cd46dfSStephan Aßmus }
27013cd46dfSStephan Aßmus 
27113cd46dfSStephan Aßmus 
27213cd46dfSStephan Aßmus void
2732f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
2742f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, bool popupIndicator,
2752f86ba45SStephan Aßmus 	uint32 flags)
2762f86ba45SStephan Aßmus {
277a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect,
278a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, popupIndicator, flags);
2792f86ba45SStephan Aßmus }
2802f86ba45SStephan Aßmus 
2812f86ba45SStephan Aßmus 
2822f86ba45SStephan Aßmus void
2832f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
2842f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
2852f86ba45SStephan Aßmus 	uint32 borders)
2862f86ba45SStephan Aßmus {
287a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundInside(view, rect, updateRect,
288a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, flags, borders);
2892f86ba45SStephan Aßmus }
2902f86ba45SStephan Aßmus 
2912f86ba45SStephan Aßmus 
292a884b43bSJohn Scipione void
293a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
294a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
295a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
296a884b43bSJohn Scipione {
297a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, radius, radius,
298a884b43bSJohn Scipione 		radius, radius, base, popupIndicator, flags);
2992f86ba45SStephan Aßmus }
3002f86ba45SStephan Aßmus 
301a884b43bSJohn Scipione 
302a884b43bSJohn Scipione void
303a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
304a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
305a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
306a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
307a884b43bSJohn Scipione {
308a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, leftTopRadius,
309a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base,
310a884b43bSJohn Scipione 		popupIndicator, flags);
3112f86ba45SStephan Aßmus }
3122f86ba45SStephan Aßmus 
313a884b43bSJohn Scipione 
3142f86ba45SStephan Aßmus void
3152f86ba45SStephan Aßmus BControlLook::DrawMenuBackground(BView* view, BRect& rect,
3162f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
3172f86ba45SStephan Aßmus 	uint32 borders)
3182f86ba45SStephan Aßmus {
319a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3202f86ba45SStephan Aßmus 		return;
3212f86ba45SStephan Aßmus 
322a884b43bSJohn Scipione 	// surface top color
3232f86ba45SStephan Aßmus 	rgb_color background = tint_color(base, 0.75);
3242f86ba45SStephan Aßmus 
325a884b43bSJohn Scipione 	// inner bevel colors
326a884b43bSJohn Scipione 	rgb_color bevelLightColor;
327a884b43bSJohn Scipione 	rgb_color bevelShadowColor;
328a884b43bSJohn Scipione 
329a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3302f86ba45SStephan Aßmus 		bevelLightColor = tint_color(background, 0.80);
3312f86ba45SStephan Aßmus 		bevelShadowColor = tint_color(background, 1.07);
3322f86ba45SStephan Aßmus 	} else {
3332f86ba45SStephan Aßmus 		bevelLightColor = tint_color(background, 0.6);
3342f86ba45SStephan Aßmus 		bevelShadowColor = tint_color(background, 1.12);
3352f86ba45SStephan Aßmus 	}
3362f86ba45SStephan Aßmus 
337a884b43bSJohn Scipione 	// draw inner bevel
3382f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3392f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3402f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3412f86ba45SStephan Aßmus 		borders);
3422f86ba45SStephan Aßmus 
343a884b43bSJohn Scipione 	// draw surface top
3442f86ba45SStephan Aßmus 	view->SetHighColor(background);
3452f86ba45SStephan Aßmus 	view->FillRect(rect);
3462f86ba45SStephan Aßmus }
3472f86ba45SStephan Aßmus 
3482f86ba45SStephan Aßmus 
3492f86ba45SStephan Aßmus void
3502f86ba45SStephan Aßmus BControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
3512f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
3522f86ba45SStephan Aßmus 	uint32 borders)
3532f86ba45SStephan Aßmus {
354a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3552f86ba45SStephan Aßmus 		return;
3562f86ba45SStephan Aßmus 
357a884b43bSJohn Scipione 	// surface edges
3582f86ba45SStephan Aßmus 	float topTint;
3592f86ba45SStephan Aßmus 	float bottomTint;
3602f86ba45SStephan Aßmus 	rgb_color selectedColor = base;
3612f86ba45SStephan Aßmus 
362a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3632f86ba45SStephan Aßmus 		topTint = 0.9;
3642f86ba45SStephan Aßmus 		bottomTint = 1.05;
365a884b43bSJohn Scipione 	} else if ((flags & B_DISABLED) != 0) {
3662f86ba45SStephan Aßmus 		topTint = 0.80;
3672f86ba45SStephan Aßmus 		bottomTint = 1.07;
3682f86ba45SStephan Aßmus 	} else {
3692f86ba45SStephan Aßmus 		topTint = 0.6;
3702f86ba45SStephan Aßmus 		bottomTint = 1.12;
3712f86ba45SStephan Aßmus 	}
3722f86ba45SStephan Aßmus 
3732f86ba45SStephan Aßmus 	rgb_color bevelLightColor = tint_color(selectedColor, topTint);
3742f86ba45SStephan Aßmus 	rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint);
3752f86ba45SStephan Aßmus 
376a884b43bSJohn Scipione 	// draw surface edges
3772f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3782f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3792f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3802f86ba45SStephan Aßmus 		borders);
3812f86ba45SStephan Aßmus 
382a884b43bSJohn Scipione 	// draw surface top
3832f86ba45SStephan Aßmus 	view->SetLowColor(selectedColor);
3842f86ba45SStephan Aßmus //	_FillGradient(view, rect, selectedColor, topTint, bottomTint);
3852f86ba45SStephan Aßmus 	_FillGradient(view, rect, selectedColor, bottomTint, topTint);
3862f86ba45SStephan Aßmus }
3872f86ba45SStephan Aßmus 
3882f86ba45SStephan Aßmus 
3892f86ba45SStephan Aßmus void
3902f86ba45SStephan Aßmus BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect,
3912f86ba45SStephan Aßmus 	const rgb_color& base, const rgb_color& barColor, float progressPosition)
3922f86ba45SStephan Aßmus {
3932f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
3942f86ba45SStephan Aßmus 		return;
3952f86ba45SStephan Aßmus 
3962f86ba45SStephan Aßmus 	_DrawOuterResessedFrame(view, rect, base, 0.6);
3972f86ba45SStephan Aßmus 
3982f86ba45SStephan Aßmus 	// colors
3992f86ba45SStephan Aßmus 	rgb_color dark1BorderColor = tint_color(base, 1.3);
4002f86ba45SStephan Aßmus 	rgb_color dark2BorderColor = tint_color(base, 1.2);
4012f86ba45SStephan Aßmus 	rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
4022f86ba45SStephan Aßmus 	rgb_color dark2FilledBorderColor = tint_color(barColor, 1.45);
4032f86ba45SStephan Aßmus 
4042f86ba45SStephan Aßmus 	BRect filledRect(rect);
4052f86ba45SStephan Aßmus 	filledRect.right = progressPosition - 1;
4062f86ba45SStephan Aßmus 
4072f86ba45SStephan Aßmus 	BRect nonfilledRect(rect);
4082f86ba45SStephan Aßmus 	nonfilledRect.left = progressPosition;
4092f86ba45SStephan Aßmus 
4102f86ba45SStephan Aßmus 	bool filledSurface = filledRect.Width() > 0;
4112f86ba45SStephan Aßmus 	bool nonfilledSurface = nonfilledRect.Width() > 0;
4122f86ba45SStephan Aßmus 
4132f86ba45SStephan Aßmus 	if (filledSurface) {
4142f86ba45SStephan Aßmus 		_DrawFrame(view, filledRect,
4152f86ba45SStephan Aßmus 			dark1FilledBorderColor, dark1FilledBorderColor,
4162f86ba45SStephan Aßmus 			dark2FilledBorderColor, dark2FilledBorderColor);
4172f86ba45SStephan Aßmus 
4182f86ba45SStephan Aßmus 		_FillGlossyGradient(view, filledRect, barColor, 0.55, 0.68, 0.76, 0.90);
4192f86ba45SStephan Aßmus 	}
4202f86ba45SStephan Aßmus 
4212f86ba45SStephan Aßmus 	if (nonfilledSurface) {
4222f86ba45SStephan Aßmus 		_DrawFrame(view, nonfilledRect, dark1BorderColor, dark1BorderColor,
4232f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor,
4242f86ba45SStephan Aßmus 			B_TOP_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
4252f86ba45SStephan Aßmus 
4262f86ba45SStephan Aßmus 		if (nonfilledRect.left < nonfilledRect.right) {
4272f86ba45SStephan Aßmus 			// shadow from fill bar, or left border
4282f86ba45SStephan Aßmus 			rgb_color leftBorder = dark1BorderColor;
4292f86ba45SStephan Aßmus 			if (filledSurface)
4302f86ba45SStephan Aßmus 				leftBorder = tint_color(base, 0.50);
4312f86ba45SStephan Aßmus 			view->SetHighColor(leftBorder);
4322f86ba45SStephan Aßmus 			view->StrokeLine(nonfilledRect.LeftTop(),
4332f86ba45SStephan Aßmus 				nonfilledRect.LeftBottom());
4342f86ba45SStephan Aßmus 			nonfilledRect.left++;
4352f86ba45SStephan Aßmus 		}
4362f86ba45SStephan Aßmus 
4372f86ba45SStephan Aßmus 		_FillGradient(view, nonfilledRect, base, 0.25, 0.06);
4382f86ba45SStephan Aßmus 	}
4392f86ba45SStephan Aßmus }
4402f86ba45SStephan Aßmus 
4412f86ba45SStephan Aßmus 
4422f86ba45SStephan Aßmus void
4432f86ba45SStephan Aßmus BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect,
4442f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4452f86ba45SStephan Aßmus {
4462f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4472f86ba45SStephan Aßmus 		return;
4482f86ba45SStephan Aßmus 
4492f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
4502f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
4512f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
4522f86ba45SStephan Aßmus 
453a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4544f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags);
4552f86ba45SStephan Aßmus 
4562f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.15);
4572f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.15);
458a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
4592f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
4602f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.48);
4612f86ba45SStephan Aßmus 
4622f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
4632f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
4642f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
4652f86ba45SStephan Aßmus 
4662f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
4672f86ba45SStephan Aßmus 	} else {
4684f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags);
4692f86ba45SStephan Aßmus 
4702f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.40);
4712f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.38);
4722f86ba45SStephan Aßmus 	}
4732f86ba45SStephan Aßmus 
474a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
4752f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
4762f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
4772f86ba45SStephan Aßmus 	}
4782f86ba45SStephan Aßmus 
4792f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
4802f86ba45SStephan Aßmus 		dark1BorderColor, dark1BorderColor,
4812f86ba45SStephan Aßmus 		dark2BorderColor, dark2BorderColor);
4822f86ba45SStephan Aßmus 
4836905b4faSJohn Scipione 	if ((flags & B_DISABLED) != 0)
4842f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.4, 0.2);
4856905b4faSJohn Scipione 	else
4862f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.15, 0.0);
4872f86ba45SStephan Aßmus 
4882f86ba45SStephan Aßmus 	rgb_color markColor;
4892f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
4902f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
4912f86ba45SStephan Aßmus 
4928359b407SJohn Scipione 		BFont font;
4938359b407SJohn Scipione 		view->GetFont(&font);
4948359b407SJohn Scipione 		float inset = std::max(2.0f, roundf(font.Size() / 6));
4958359b407SJohn Scipione 		rect.InsetBy(inset, inset);
4962f86ba45SStephan Aßmus 
4978359b407SJohn Scipione 		float penSize = std::max(1.0f, ceilf(rect.Width() / 3.5f));
4988359b407SJohn Scipione 		if (penSize > 1.0f && fmodf(penSize, 2.0f) == 0.0f) {
4998359b407SJohn Scipione 			// Tweak ends to "include" the pixel at the index,
5008359b407SJohn Scipione 			// we need to do this in order to produce results like R5,
5018359b407SJohn Scipione 			// where coordinates were inclusive
5028359b407SJohn Scipione 			rect.right++;
5038359b407SJohn Scipione 			rect.bottom++;
5048359b407SJohn Scipione 		}
5058359b407SJohn Scipione 
5068359b407SJohn Scipione 		view->SetPenSize(penSize);
5078359b407SJohn Scipione 		view->SetDrawingMode(B_OP_OVER);
5082f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightBottom());
5092f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightTop());
5102f86ba45SStephan Aßmus 	}
5112f86ba45SStephan Aßmus }
5122f86ba45SStephan Aßmus 
5132f86ba45SStephan Aßmus 
5142f86ba45SStephan Aßmus void
5152f86ba45SStephan Aßmus BControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect,
5162f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
5172f86ba45SStephan Aßmus {
5182f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
5192f86ba45SStephan Aßmus 		return;
5202f86ba45SStephan Aßmus 
5212f86ba45SStephan Aßmus 	rgb_color borderColor;
5222f86ba45SStephan Aßmus 	rgb_color bevelLight;
5232f86ba45SStephan Aßmus 	rgb_color bevelShadow;
5242f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
5252f86ba45SStephan Aßmus 
526a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5272f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.15);
5282f86ba45SStephan Aßmus 		bevelLight = base;
5292f86ba45SStephan Aßmus 		bevelShadow = base;
530a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
5312f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.50);
5322f86ba45SStephan Aßmus 		bevelLight = borderColor;
5332f86ba45SStephan Aßmus 		bevelShadow = borderColor;
5342f86ba45SStephan Aßmus 	} else {
5352f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.45);
5362f86ba45SStephan Aßmus 		bevelLight = tint_color(base, 0.55);
5372f86ba45SStephan Aßmus 		bevelShadow = tint_color(base, 1.11);
5382f86ba45SStephan Aßmus 	}
5392f86ba45SStephan Aßmus 
540a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
5412f86ba45SStephan Aßmus 		borderColor = navigationColor;
5422f86ba45SStephan Aßmus 	}
5432f86ba45SStephan Aßmus 
5442f86ba45SStephan Aßmus 	BGradientLinear bevelGradient;
5452f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelShadow, 0);
5462f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelLight, 255);
5472f86ba45SStephan Aßmus 	bevelGradient.SetStart(rect.LeftTop());
5482f86ba45SStephan Aßmus 	bevelGradient.SetEnd(rect.RightBottom());
5492f86ba45SStephan Aßmus 
5502f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5512f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5522f86ba45SStephan Aßmus 
5532f86ba45SStephan Aßmus 	bevelGradient.MakeEmpty();
5542f86ba45SStephan Aßmus 	bevelGradient.AddColor(borderColor, 0);
5552f86ba45SStephan Aßmus 	bevelGradient.AddColor(tint_color(borderColor, 0.8), 255);
5562f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5572f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5582f86ba45SStephan Aßmus 
5592f86ba45SStephan Aßmus 	float topTint;
5602f86ba45SStephan Aßmus 	float bottomTint;
561a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5622f86ba45SStephan Aßmus 		topTint = 0.4;
5632f86ba45SStephan Aßmus 		bottomTint = 0.2;
5642f86ba45SStephan Aßmus 	} else {
5652f86ba45SStephan Aßmus 		topTint = 0.15;
5662f86ba45SStephan Aßmus 		bottomTint = 0.0;
5672f86ba45SStephan Aßmus 	}
5682f86ba45SStephan Aßmus 
5692f86ba45SStephan Aßmus 	BGradientLinear gradient;
5702f86ba45SStephan Aßmus 	_MakeGradient(gradient, rect, base, topTint, bottomTint);
5712f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
5722f86ba45SStephan Aßmus 
5732f86ba45SStephan Aßmus 	rgb_color markColor;
5742f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
5752f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
57622af0f18SJohn Scipione 		BFont font;
57722af0f18SJohn Scipione 		view->GetFont(&font);
57822af0f18SJohn Scipione 		float inset = roundf(font.Size() / 4);
57922af0f18SJohn Scipione 		rect.InsetBy(inset, inset);
5802f86ba45SStephan Aßmus 		view->FillEllipse(rect);
5812f86ba45SStephan Aßmus 	}
5822f86ba45SStephan Aßmus }
5832f86ba45SStephan Aßmus 
5842f86ba45SStephan Aßmus 
5852f86ba45SStephan Aßmus void
5862f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2,
5872f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
588e724b26fSJohn Scipione 	orientation orientation)
5892f86ba45SStephan Aßmus {
5902f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect1, updateRect, base, flags, orientation);
5912f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation);
5922f86ba45SStephan Aßmus }
5932f86ba45SStephan Aßmus 
59488969219SJohn Scipione 
5952f86ba45SStephan Aßmus void
5962f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect,
5972f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
598e724b26fSJohn Scipione 	orientation orientation)
5992f86ba45SStephan Aßmus {
6002f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
6012f86ba45SStephan Aßmus 		return;
6022f86ba45SStephan Aßmus 
6032f86ba45SStephan Aßmus 	float gradient1Tint;
6042f86ba45SStephan Aßmus 	float gradient2Tint;
6052f86ba45SStephan Aßmus 	float darkEdge1Tint;
6062f86ba45SStephan Aßmus 	float darkEdge2Tint;
6072f86ba45SStephan Aßmus 	float shadowTint;
6082f86ba45SStephan Aßmus 
609a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
6102f86ba45SStephan Aßmus 		gradient1Tint = 0.9;
6112f86ba45SStephan Aßmus 		gradient2Tint = 0.8;
6122f86ba45SStephan Aßmus 		darkEdge1Tint = B_DARKEN_2_TINT;
6132f86ba45SStephan Aßmus 		darkEdge2Tint = B_DARKEN_2_TINT;
6142f86ba45SStephan Aßmus 		shadowTint = gradient1Tint;
6152f86ba45SStephan Aßmus 	} else {
6162f86ba45SStephan Aßmus 		gradient1Tint = 1.10;
6172f86ba45SStephan Aßmus 		gradient2Tint = 1.05;
6182f86ba45SStephan Aßmus 		darkEdge1Tint = B_DARKEN_3_TINT;
6192f86ba45SStephan Aßmus 		darkEdge2Tint = B_DARKEN_2_TINT;
6202f86ba45SStephan Aßmus 		shadowTint = gradient1Tint;
6212f86ba45SStephan Aßmus 	}
6222f86ba45SStephan Aßmus 
6232f86ba45SStephan Aßmus 	rgb_color darkEdge1 = tint_color(base, darkEdge1Tint);
6242f86ba45SStephan Aßmus 	rgb_color darkEdge2 = tint_color(base, darkEdge2Tint);
6252f86ba45SStephan Aßmus 	rgb_color shadow = tint_color(base, shadowTint);
6262f86ba45SStephan Aßmus 
6272f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
6282f86ba45SStephan Aßmus 		// dark vertical line on left edge
6292f86ba45SStephan Aßmus 		if (rect.Width() > 0) {
6302f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge1);
6312f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
6322f86ba45SStephan Aßmus 			rect.left++;
6332f86ba45SStephan Aßmus 		}
6342f86ba45SStephan Aßmus 		// dark vertical line on right edge
6352f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6362f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge2);
6372f86ba45SStephan Aßmus 			view->StrokeLine(rect.RightTop(), rect.RightBottom());
6382f86ba45SStephan Aßmus 			rect.right--;
6392f86ba45SStephan Aßmus 		}
6402f86ba45SStephan Aßmus 		// vertical shadow line after left edge
6412f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6422f86ba45SStephan Aßmus 			view->SetHighColor(shadow);
6432f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
6442f86ba45SStephan Aßmus 			rect.left++;
6452f86ba45SStephan Aßmus 		}
6462f86ba45SStephan Aßmus 		// fill
6472f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6482f86ba45SStephan Aßmus 			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
6492f86ba45SStephan Aßmus 				orientation);
6502f86ba45SStephan Aßmus 		}
6512f86ba45SStephan Aßmus 	} else {
6522f86ba45SStephan Aßmus 		// dark vertical line on top edge
6532f86ba45SStephan Aßmus 		if (rect.Height() > 0) {
6542f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge1);
6552f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.RightTop());
6562f86ba45SStephan Aßmus 			rect.top++;
6572f86ba45SStephan Aßmus 		}
6582f86ba45SStephan Aßmus 		// dark vertical line on bottom edge
6592f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6602f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge2);
6612f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
6622f86ba45SStephan Aßmus 			rect.bottom--;
6632f86ba45SStephan Aßmus 		}
6642f86ba45SStephan Aßmus 		// horizontal shadow line after top edge
6652f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6662f86ba45SStephan Aßmus 			view->SetHighColor(shadow);
6672f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.RightTop());
6682f86ba45SStephan Aßmus 			rect.top++;
6692f86ba45SStephan Aßmus 		}
6702f86ba45SStephan Aßmus 		// fill
6712f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6722f86ba45SStephan Aßmus 			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
6732f86ba45SStephan Aßmus 				orientation);
6742f86ba45SStephan Aßmus 		}
6752f86ba45SStephan Aßmus 	}
6762f86ba45SStephan Aßmus }
6772f86ba45SStephan Aßmus 
6782f86ba45SStephan Aßmus 
67940a10e1cSStephan Aßmus void
68074bb70aeSStephan Aßmus BControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
68174bb70aeSStephan Aßmus 	const BRect& updateRect, BRect verticalScrollBarFrame,
68274bb70aeSStephan Aßmus 	BRect horizontalScrollBarFrame, const rgb_color& base,
68374bb70aeSStephan Aßmus 	border_style border, uint32 flags, uint32 _borders)
68474bb70aeSStephan Aßmus {
685ce955579SStephan Aßmus 	// calculate scroll corner rect before messing with the "rect"
686ce955579SStephan Aßmus 	BRect scrollCornerFillRect(rect.right, rect.bottom,
687ce955579SStephan Aßmus 		rect.right, rect.bottom);
688539dc1bcSJohn Scipione 
689ce955579SStephan Aßmus 	if (horizontalScrollBarFrame.IsValid())
690ce955579SStephan Aßmus 		scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1;
691539dc1bcSJohn Scipione 
692ce955579SStephan Aßmus 	if (verticalScrollBarFrame.IsValid())
693ce955579SStephan Aßmus 		scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1;
694ce955579SStephan Aßmus 
695c44aa833SStephan Aßmus 	if (border == B_NO_BORDER) {
696c44aa833SStephan Aßmus 		if (scrollCornerFillRect.IsValid()) {
697c44aa833SStephan Aßmus 			view->SetHighColor(base);
698c44aa833SStephan Aßmus 			view->FillRect(scrollCornerFillRect);
699c44aa833SStephan Aßmus 		}
700c44aa833SStephan Aßmus 		return;
701c44aa833SStephan Aßmus 	}
702c44aa833SStephan Aßmus 
703c44aa833SStephan Aßmus 	bool excludeScrollCorner = border == B_FANCY_BORDER
704c44aa833SStephan Aßmus 		&& horizontalScrollBarFrame.IsValid()
705c44aa833SStephan Aßmus 		&& verticalScrollBarFrame.IsValid();
706c44aa833SStephan Aßmus 
70774bb70aeSStephan Aßmus 	uint32 borders = _borders;
70874bb70aeSStephan Aßmus 	if (excludeScrollCorner) {
70974bb70aeSStephan Aßmus 		rect.bottom = horizontalScrollBarFrame.top;
71074bb70aeSStephan Aßmus 		rect.right = verticalScrollBarFrame.left;
71174bb70aeSStephan Aßmus 		borders &= ~(B_RIGHT_BORDER | B_BOTTOM_BORDER);
71274bb70aeSStephan Aßmus 	}
71374bb70aeSStephan Aßmus 
71474bb70aeSStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
71574bb70aeSStephan Aßmus 
71674bb70aeSStephan Aßmus 	if (border == B_FANCY_BORDER)
7174f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
71874bb70aeSStephan Aßmus 
719a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
72074bb70aeSStephan Aßmus 		rgb_color focusColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
72174bb70aeSStephan Aßmus 		_DrawFrame(view, rect, focusColor, focusColor, focusColor, focusColor,
72274bb70aeSStephan Aßmus 			borders);
72374bb70aeSStephan Aßmus 	} else {
72474bb70aeSStephan Aßmus 		_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
72574bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, borders);
72674bb70aeSStephan Aßmus 	}
72774bb70aeSStephan Aßmus 
72874bb70aeSStephan Aßmus 	if (excludeScrollCorner) {
72974bb70aeSStephan Aßmus 		horizontalScrollBarFrame.InsetBy(-1, -1);
73074bb70aeSStephan Aßmus 		// do not overdraw the top edge
73174bb70aeSStephan Aßmus 		horizontalScrollBarFrame.top += 2;
73274bb70aeSStephan Aßmus 		borders = _borders;
73374bb70aeSStephan Aßmus 		borders &= ~B_TOP_BORDER;
73474bb70aeSStephan Aßmus 		_DrawOuterResessedFrame(view, horizontalScrollBarFrame, base,
7354f579098SStephan Aßmus 			1.0, 1.0, flags, borders);
73674bb70aeSStephan Aßmus 		_DrawFrame(view, horizontalScrollBarFrame, scrollbarFrameColor,
73774bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
73874bb70aeSStephan Aßmus 			borders);
73974bb70aeSStephan Aßmus 
74074bb70aeSStephan Aßmus 		verticalScrollBarFrame.InsetBy(-1, -1);
74174bb70aeSStephan Aßmus 		// do not overdraw the left edge
74274bb70aeSStephan Aßmus 		verticalScrollBarFrame.left += 2;
74374bb70aeSStephan Aßmus 		borders = _borders;
74474bb70aeSStephan Aßmus 		borders &= ~B_LEFT_BORDER;
74574bb70aeSStephan Aßmus 		_DrawOuterResessedFrame(view, verticalScrollBarFrame, base,
7464f579098SStephan Aßmus 			1.0, 1.0, flags, borders);
74774bb70aeSStephan Aßmus 		_DrawFrame(view, verticalScrollBarFrame, scrollbarFrameColor,
74874bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
74974bb70aeSStephan Aßmus 			borders);
750ce955579SStephan Aßmus 
751ce955579SStephan Aßmus 		// exclude recessed frame
752ce955579SStephan Aßmus 		scrollCornerFillRect.top++;
753ce955579SStephan Aßmus 		scrollCornerFillRect.left++;
754ce955579SStephan Aßmus 	}
755ce955579SStephan Aßmus 
756ce955579SStephan Aßmus 	if (scrollCornerFillRect.IsValid()) {
757ce955579SStephan Aßmus 		view->SetHighColor(base);
758ce955579SStephan Aßmus 		view->FillRect(scrollCornerFillRect);
75974bb70aeSStephan Aßmus 	}
76074bb70aeSStephan Aßmus }
76174bb70aeSStephan Aßmus 
76274bb70aeSStephan Aßmus 
76374bb70aeSStephan Aßmus void
76440a10e1cSStephan Aßmus BControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect,
76540a10e1cSStephan Aßmus 	const rgb_color& base, uint32 direction, uint32 flags, float tint)
76640a10e1cSStephan Aßmus {
76740a10e1cSStephan Aßmus 	BPoint tri1, tri2, tri3;
76840a10e1cSStephan Aßmus 	float hInset = rect.Width() / 3;
76940a10e1cSStephan Aßmus 	float vInset = rect.Height() / 3;
77040a10e1cSStephan Aßmus 	rect.InsetBy(hInset, vInset);
77140a10e1cSStephan Aßmus 
77240a10e1cSStephan Aßmus 	switch (direction) {
77340a10e1cSStephan Aßmus 		case B_LEFT_ARROW:
77440a10e1cSStephan Aßmus 			tri1.Set(rect.right, rect.top);
77540a10e1cSStephan Aßmus 			tri2.Set(rect.right - rect.Width() / 1.33,
77640a10e1cSStephan Aßmus 				(rect.top + rect.bottom + 1) / 2);
77740a10e1cSStephan Aßmus 			tri3.Set(rect.right, rect.bottom + 1);
77840a10e1cSStephan Aßmus 			break;
77940a10e1cSStephan Aßmus 		case B_RIGHT_ARROW:
780f9b1a47fSRyan Leavengood 			tri1.Set(rect.left + 1, rect.bottom + 1);
781f9b1a47fSRyan Leavengood 			tri2.Set(rect.left + 1 + rect.Width() / 1.33,
78240a10e1cSStephan Aßmus 				(rect.top + rect.bottom + 1) / 2);
783f9b1a47fSRyan Leavengood 			tri3.Set(rect.left + 1, rect.top);
78440a10e1cSStephan Aßmus 			break;
78540a10e1cSStephan Aßmus 		case B_UP_ARROW:
78640a10e1cSStephan Aßmus 			tri1.Set(rect.left, rect.bottom);
78740a10e1cSStephan Aßmus 			tri2.Set((rect.left + rect.right + 1) / 2,
78840a10e1cSStephan Aßmus 				rect.bottom - rect.Height() / 1.33);
78940a10e1cSStephan Aßmus 			tri3.Set(rect.right + 1, rect.bottom);
79040a10e1cSStephan Aßmus 			break;
79140a10e1cSStephan Aßmus 		case B_DOWN_ARROW:
79240a10e1cSStephan Aßmus 		default:
793f9b1a47fSRyan Leavengood 			tri1.Set(rect.left, rect.top + 1);
79440a10e1cSStephan Aßmus 			tri2.Set((rect.left + rect.right + 1) / 2,
795f9b1a47fSRyan Leavengood 				rect.top + 1 + rect.Height() / 1.33);
796f9b1a47fSRyan Leavengood 			tri3.Set(rect.right + 1, rect.top + 1);
79740a10e1cSStephan Aßmus 			break;
7981b41173cSJohn Scipione 		case B_LEFT_UP_ARROW:
79917c9912bSJohn Scipione 			tri1.Set(rect.left, rect.bottom);
80017c9912bSJohn Scipione 			tri2.Set(rect.left, rect.top);
80117c9912bSJohn Scipione 			tri3.Set(rect.right - 1, rect.top);
8021b41173cSJohn Scipione 			break;
8031b41173cSJohn Scipione 		case B_RIGHT_UP_ARROW:
804348cd0c5SJohn Scipione 			tri1.Set(rect.left + 1, rect.top);
8051b41173cSJohn Scipione 			tri2.Set(rect.right, rect.top);
8061b41173cSJohn Scipione 			tri3.Set(rect.right, rect.bottom);
8071b41173cSJohn Scipione 			break;
8081b41173cSJohn Scipione 		case B_RIGHT_DOWN_ARROW:
8091b41173cSJohn Scipione 			tri1.Set(rect.right, rect.top);
8101b41173cSJohn Scipione 			tri2.Set(rect.right, rect.bottom);
811348cd0c5SJohn Scipione 			tri3.Set(rect.left + 1, rect.bottom);
8121b41173cSJohn Scipione 			break;
8131b41173cSJohn Scipione 		case B_LEFT_DOWN_ARROW:
81417c9912bSJohn Scipione 			tri1.Set(rect.right - 1, rect.bottom);
81517c9912bSJohn Scipione 			tri2.Set(rect.left, rect.bottom);
81617c9912bSJohn Scipione 			tri3.Set(rect.left, rect.top);
8171b41173cSJohn Scipione 			break;
81840a10e1cSStephan Aßmus 	}
81940a10e1cSStephan Aßmus 
82040a10e1cSStephan Aßmus 	BShape arrowShape;
82140a10e1cSStephan Aßmus 	arrowShape.MoveTo(tri1);
82240a10e1cSStephan Aßmus 	arrowShape.LineTo(tri2);
82340a10e1cSStephan Aßmus 	arrowShape.LineTo(tri3);
82440a10e1cSStephan Aßmus 
825a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
82640a10e1cSStephan Aßmus 		tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
82740a10e1cSStephan Aßmus 
82840a10e1cSStephan Aßmus 	view->SetHighColor(tint_color(base, tint));
82940a10e1cSStephan Aßmus 
83040a10e1cSStephan Aßmus 	float penSize = view->PenSize();
83140a10e1cSStephan Aßmus 	drawing_mode mode = view->DrawingMode();
83240a10e1cSStephan Aßmus 
833f44a56caSRyan Leavengood 	view->MovePenTo(BPoint(0, 0));
834f44a56caSRyan Leavengood 
83540a10e1cSStephan Aßmus 	view->SetPenSize(ceilf(hInset / 2.0));
83640a10e1cSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
83740a10e1cSStephan Aßmus 	view->StrokeShape(&arrowShape);
83840a10e1cSStephan Aßmus 
83940a10e1cSStephan Aßmus 	view->SetPenSize(penSize);
84040a10e1cSStephan Aßmus 	view->SetDrawingMode(mode);
84140a10e1cSStephan Aßmus }
84240a10e1cSStephan Aßmus 
84340a10e1cSStephan Aßmus 
8442f86ba45SStephan Aßmus rgb_color
8452f86ba45SStephan Aßmus BControlLook::SliderBarColor(const rgb_color& base)
8462f86ba45SStephan Aßmus {
8472f86ba45SStephan Aßmus 	return tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT);
8482f86ba45SStephan Aßmus }
8492f86ba45SStephan Aßmus 
8502f86ba45SStephan Aßmus 
8512f86ba45SStephan Aßmus void
8522f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
8532f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor,
854e724b26fSJohn Scipione 	float sliderScale, uint32 flags, orientation orientation)
8552f86ba45SStephan Aßmus {
8562f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
8572f86ba45SStephan Aßmus 		return;
8582f86ba45SStephan Aßmus 
8595666b4f7SJohn Scipione 	// save the clipping constraints of the view
8605666b4f7SJohn Scipione 	view->PushState();
8615666b4f7SJohn Scipione 
8622f86ba45SStephan Aßmus 	// separate the bar in two sides
8632f86ba45SStephan Aßmus 	float sliderPosition;
8642f86ba45SStephan Aßmus 	BRect leftBarSide = rect;
8652f86ba45SStephan Aßmus 	BRect rightBarSide = rect;
8662f86ba45SStephan Aßmus 
8672f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8682f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.left + 2 + (rect.Width() - 2)
8692f86ba45SStephan Aßmus 			* sliderScale);
8702f86ba45SStephan Aßmus 		leftBarSide.right = sliderPosition - 1;
8712f86ba45SStephan Aßmus 		rightBarSide.left = sliderPosition;
8722f86ba45SStephan Aßmus 	} else {
873f3997b74SStephan Aßmus 		// NOTE: position is reverse of coords
8742f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
875f3997b74SStephan Aßmus 			* (1.0 - sliderScale));
876f3997b74SStephan Aßmus 		leftBarSide.top = sliderPosition;
877f3997b74SStephan Aßmus 		rightBarSide.bottom = sliderPosition - 1;
8782f86ba45SStephan Aßmus 	}
8792f86ba45SStephan Aßmus 
8802f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
8812f86ba45SStephan Aßmus 	BRegion region(rect);
8822f86ba45SStephan Aßmus 	region.Exclude(rightBarSide);
8832f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8842f86ba45SStephan Aßmus 
8852f86ba45SStephan Aßmus 	view->PushState();
8862f86ba45SStephan Aßmus 
8872f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
8882f86ba45SStephan Aßmus 		orientation);
8892f86ba45SStephan Aßmus 
8902f86ba45SStephan Aßmus 	view->PopState();
8912f86ba45SStephan Aßmus 
8922f86ba45SStephan Aßmus 	region.Set(rect);
8932f86ba45SStephan Aßmus 	region.Exclude(leftBarSide);
8942f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8952f86ba45SStephan Aßmus 
8962f86ba45SStephan Aßmus 	view->PushState();
8972f86ba45SStephan Aßmus 
8982f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
8992f86ba45SStephan Aßmus 		orientation);
9002f86ba45SStephan Aßmus 
9012f86ba45SStephan Aßmus 	view->PopState();
9023244c2bcSJohn Scipione 
9035666b4f7SJohn Scipione 	// restore the clipping constraints of the view
9045666b4f7SJohn Scipione 	view->PopState();
9052f86ba45SStephan Aßmus }
9062f86ba45SStephan Aßmus 
9072f86ba45SStephan Aßmus 
9082f86ba45SStephan Aßmus void
9092f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
9102f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color fillColor, uint32 flags,
911e724b26fSJohn Scipione 	orientation orientation)
9122f86ba45SStephan Aßmus {
9132f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
9142f86ba45SStephan Aßmus 		return;
9152f86ba45SStephan Aßmus 
9162f86ba45SStephan Aßmus 	// separate the rect into corners
9172f86ba45SStephan Aßmus 	BRect leftCorner(rect);
9182f86ba45SStephan Aßmus 	BRect rightCorner(rect);
9192f86ba45SStephan Aßmus 	BRect barRect(rect);
9202f86ba45SStephan Aßmus 
9212f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
9222f86ba45SStephan Aßmus 		leftCorner.right = leftCorner.left + leftCorner.Height();
9232f86ba45SStephan Aßmus 		rightCorner.left = rightCorner.right - rightCorner.Height();
9242f86ba45SStephan Aßmus 		barRect.left += ceilf(barRect.Height() / 2);
9252f86ba45SStephan Aßmus 		barRect.right -= ceilf(barRect.Height() / 2);
9262f86ba45SStephan Aßmus 	} else {
9272f86ba45SStephan Aßmus 		leftCorner.bottom = leftCorner.top + leftCorner.Width();
9282f86ba45SStephan Aßmus 		rightCorner.top = rightCorner.bottom - rightCorner.Width();
9292f86ba45SStephan Aßmus 		barRect.top += ceilf(barRect.Width() / 2);
9302f86ba45SStephan Aßmus 		barRect.bottom -= ceilf(barRect.Width() / 2);
9312f86ba45SStephan Aßmus 	}
9322f86ba45SStephan Aßmus 
9332f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
9342f86ba45SStephan Aßmus 	BRegion region(rect);
9352f86ba45SStephan Aßmus 	region.Exclude(barRect);
9362f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
9372f86ba45SStephan Aßmus 
93861ac1a85SStephan Aßmus 	if ((flags & B_BLEND_FRAME) == 0) {
9392f86ba45SStephan Aßmus 		view->SetHighColor(base);
9402f86ba45SStephan Aßmus 		view->FillRect(rect);
94161ac1a85SStephan Aßmus 	}
9422f86ba45SStephan Aßmus 
9432f86ba45SStephan Aßmus 	// figure out the tints to be used
9442f86ba45SStephan Aßmus 	float edgeLightTint;
9452f86ba45SStephan Aßmus 	float edgeShadowTint;
9462f86ba45SStephan Aßmus 	float frameLightTint;
9472f86ba45SStephan Aßmus 	float frameShadowTint;
9482f86ba45SStephan Aßmus 	float fillLightTint;
9492f86ba45SStephan Aßmus 	float fillShadowTint;
95061ac1a85SStephan Aßmus 	uint8 edgeLightAlpha;
95161ac1a85SStephan Aßmus 	uint8 edgeShadowAlpha;
95261ac1a85SStephan Aßmus 	uint8 frameLightAlpha;
95361ac1a85SStephan Aßmus 	uint8 frameShadowAlpha;
9542f86ba45SStephan Aßmus 
955a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
9562f86ba45SStephan Aßmus 		edgeLightTint = 1.0;
9572f86ba45SStephan Aßmus 		edgeShadowTint = 1.0;
9582f86ba45SStephan Aßmus 		frameLightTint = 1.20;
9592f86ba45SStephan Aßmus 		frameShadowTint = 1.25;
9602f86ba45SStephan Aßmus 		fillLightTint = 0.9;
9612f86ba45SStephan Aßmus 		fillShadowTint = 1.05;
96210ddee8dSStephan Aßmus 		edgeLightAlpha = 12;
96310ddee8dSStephan Aßmus 		edgeShadowAlpha = 12;
96461ac1a85SStephan Aßmus 		frameLightAlpha = 40;
96561ac1a85SStephan Aßmus 		frameShadowAlpha = 45;
9662f86ba45SStephan Aßmus 
9672f86ba45SStephan Aßmus 		fillColor.red = uint8(fillColor.red * 0.4 + base.red * 0.6);
9682f86ba45SStephan Aßmus 		fillColor.green = uint8(fillColor.green * 0.4 + base.green * 0.6);
9692f86ba45SStephan Aßmus 		fillColor.blue = uint8(fillColor.blue * 0.4 + base.blue * 0.6);
9702f86ba45SStephan Aßmus 	} else {
9712f86ba45SStephan Aßmus 		edgeLightTint = 0.65;
9722f86ba45SStephan Aßmus 		edgeShadowTint = 1.07;
9732f86ba45SStephan Aßmus 		frameLightTint = 1.40;
9742f86ba45SStephan Aßmus 		frameShadowTint = 1.50;
9752f86ba45SStephan Aßmus 		fillLightTint = 0.8;
9762f86ba45SStephan Aßmus 		fillShadowTint = 1.1;
97710ddee8dSStephan Aßmus 		edgeLightAlpha = 15;
97810ddee8dSStephan Aßmus 		edgeShadowAlpha = 15;
97961ac1a85SStephan Aßmus 		frameLightAlpha = 92;
98061ac1a85SStephan Aßmus 		frameShadowAlpha = 107;
9812f86ba45SStephan Aßmus 	}
9822f86ba45SStephan Aßmus 
98361ac1a85SStephan Aßmus 	rgb_color edgeLightColor;
98461ac1a85SStephan Aßmus 	rgb_color edgeShadowColor;
98561ac1a85SStephan Aßmus 	rgb_color frameLightColor;
98661ac1a85SStephan Aßmus 	rgb_color frameShadowColor;
9872f86ba45SStephan Aßmus 	rgb_color fillLightColor = tint_color(fillColor, fillLightTint);
9882f86ba45SStephan Aßmus 	rgb_color fillShadowColor = tint_color(fillColor, fillShadowTint);
9892f86ba45SStephan Aßmus 
99061ac1a85SStephan Aßmus 	drawing_mode oldMode = view->DrawingMode();
99161ac1a85SStephan Aßmus 
992a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
99361ac1a85SStephan Aßmus 		edgeLightColor = (rgb_color){ 255, 255, 255, edgeLightAlpha };
99461ac1a85SStephan Aßmus 		edgeShadowColor = (rgb_color){ 0, 0, 0, edgeShadowAlpha };
99561ac1a85SStephan Aßmus 		frameLightColor = (rgb_color){ 0, 0, 0, frameLightAlpha };
99661ac1a85SStephan Aßmus 		frameShadowColor = (rgb_color){ 0, 0, 0, frameShadowAlpha };
99761ac1a85SStephan Aßmus 
99861ac1a85SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
99961ac1a85SStephan Aßmus 	} else {
100061ac1a85SStephan Aßmus 		edgeLightColor = tint_color(base, edgeLightTint);
100161ac1a85SStephan Aßmus 		edgeShadowColor = tint_color(base, edgeShadowTint);
100261ac1a85SStephan Aßmus 		frameLightColor = tint_color(fillColor, frameLightTint);
100361ac1a85SStephan Aßmus 		frameShadowColor = tint_color(fillColor, frameShadowTint);
100461ac1a85SStephan Aßmus 	}
100561ac1a85SStephan Aßmus 
10062f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
10072f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
10082f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
10092f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
10102f86ba45SStephan Aßmus 
10112f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
10122f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
10132f86ba45SStephan Aßmus 			fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
10142f86ba45SStephan Aßmus 	} else {
10152f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
10162f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
10172f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
10182f86ba45SStephan Aßmus 
10192f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
10202f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
10212f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
10222f86ba45SStephan Aßmus 	}
10232f86ba45SStephan Aßmus 
10242f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(NULL);
10252f86ba45SStephan Aßmus 
10262f86ba45SStephan Aßmus 	view->BeginLineArray(4);
10272f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
10282f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), edgeShadowColor);
10292f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
10302f86ba45SStephan Aßmus 			edgeLightColor);
10312f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
10322f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), frameShadowColor);
10332f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
10342f86ba45SStephan Aßmus 			frameLightColor);
10352f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
10362f86ba45SStephan Aßmus 	} else {
10372f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), edgeShadowColor);
10382f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
10392f86ba45SStephan Aßmus 			edgeLightColor);
10402f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
10412f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), frameShadowColor);
10422f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
10432f86ba45SStephan Aßmus 			frameLightColor);
10442f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
10452f86ba45SStephan Aßmus 	}
10462f86ba45SStephan Aßmus 	view->EndLineArray();
10472f86ba45SStephan Aßmus 
104861ac1a85SStephan Aßmus 	view->SetDrawingMode(oldMode);
104961ac1a85SStephan Aßmus 
10502f86ba45SStephan Aßmus 	_FillGradient(view, barRect, fillColor, fillShadowTint, fillLightTint,
10512f86ba45SStephan Aßmus 		orientation);
10522f86ba45SStephan Aßmus }
10532f86ba45SStephan Aßmus 
10542f86ba45SStephan Aßmus 
10552f86ba45SStephan Aßmus void
10562f86ba45SStephan Aßmus BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
1057e724b26fSJohn Scipione 	const rgb_color& base, uint32 flags, orientation orientation)
10582f86ba45SStephan Aßmus {
10592f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
10602f86ba45SStephan Aßmus 		return;
10612f86ba45SStephan Aßmus 
10622f86ba45SStephan Aßmus 	// figure out frame color
10632f86ba45SStephan Aßmus 	rgb_color frameLightColor;
10642f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
10652f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
10662f86ba45SStephan Aßmus 
1067a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
10682f86ba45SStephan Aßmus 		// focused
10692f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
10702f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
10712f86ba45SStephan Aßmus 	} else {
10722f86ba45SStephan Aßmus 		// figure out the tints to be used
10732f86ba45SStephan Aßmus 		float frameLightTint;
10742f86ba45SStephan Aßmus 		float frameShadowTint;
10752f86ba45SStephan Aßmus 
1076a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
10772f86ba45SStephan Aßmus 			frameLightTint = 1.30;
10782f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
10792f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
10802f86ba45SStephan Aßmus 		} else {
10812f86ba45SStephan Aßmus 			frameLightTint = 1.6;
10822f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
10832f86ba45SStephan Aßmus 		}
10842f86ba45SStephan Aßmus 
10852f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
10862f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
10872f86ba45SStephan Aßmus 	}
10882f86ba45SStephan Aßmus 
10892f86ba45SStephan Aßmus 	BRect originalRect(rect);
10902f86ba45SStephan Aßmus 	rect.right--;
10912f86ba45SStephan Aßmus 	rect.bottom--;
10922f86ba45SStephan Aßmus 
10932f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor,
10942f86ba45SStephan Aßmus 		frameShadowColor, frameShadowColor);
10952f86ba45SStephan Aßmus 
10962f86ba45SStephan Aßmus 	flags &= ~B_ACTIVATED;
10972f86ba45SStephan Aßmus 	DrawButtonBackground(view, rect, updateRect, base, flags);
10982f86ba45SStephan Aßmus 
10992f86ba45SStephan Aßmus 	// thumb shadow
11002f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
11012f86ba45SStephan Aßmus 	view->SetHighColor(shadowColor);
11022f86ba45SStephan Aßmus 	originalRect.left++;
11032f86ba45SStephan Aßmus 	originalRect.top++;
11042f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.LeftBottom(), originalRect.RightBottom());
11052f86ba45SStephan Aßmus 	originalRect.bottom--;
11062f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.RightTop(), originalRect.RightBottom());
11072f86ba45SStephan Aßmus 
11082f86ba45SStephan Aßmus 	// thumb edge
11092f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
11102f86ba45SStephan Aßmus 		rect.InsetBy(0, floorf(rect.Height() / 4));
11112f86ba45SStephan Aßmus 		rect.left = floorf((rect.left + rect.right) / 2);
11122f86ba45SStephan Aßmus 		rect.right = rect.left + 1;
11132f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
11142f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
11152f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
11162f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
11172f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
11182f86ba45SStephan Aßmus 		lightColor.alpha = 128;
11192f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
11202f86ba45SStephan Aßmus 		view->StrokeLine(rect.RightTop(), rect.RightBottom());
11212f86ba45SStephan Aßmus 	} else {
11222f86ba45SStephan Aßmus 		rect.InsetBy(floorf(rect.Width() / 4), 0);
11232f86ba45SStephan Aßmus 		rect.top = floorf((rect.top + rect.bottom) / 2);
11242f86ba45SStephan Aßmus 		rect.bottom = rect.top + 1;
11252f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
11262f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
11272f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
11282f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightTop());
11292f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
11302f86ba45SStephan Aßmus 		lightColor.alpha = 128;
11312f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
11322f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
11332f86ba45SStephan Aßmus 	}
11342f86ba45SStephan Aßmus 
11352f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
11362f86ba45SStephan Aßmus }
11372f86ba45SStephan Aßmus 
11382f86ba45SStephan Aßmus 
11392f86ba45SStephan Aßmus void
11402f86ba45SStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
11412f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
1142e724b26fSJohn Scipione 	orientation orientation)
11432f86ba45SStephan Aßmus {
11448ee9217eSStephan Aßmus 	DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation);
11458ee9217eSStephan Aßmus }
11468ee9217eSStephan Aßmus 
11478ee9217eSStephan Aßmus 
11488ee9217eSStephan Aßmus void
11498ee9217eSStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
11508ee9217eSStephan Aßmus 	const BRect& updateRect, const rgb_color& base, const rgb_color& fill,
1151e724b26fSJohn Scipione 	uint32 flags, orientation orientation)
11528ee9217eSStephan Aßmus {
11532f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
11542f86ba45SStephan Aßmus 		return;
11552f86ba45SStephan Aßmus 
11562f86ba45SStephan Aßmus 	// figure out frame color
11572f86ba45SStephan Aßmus 	rgb_color frameLightColor;
11582f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
11592f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
11602f86ba45SStephan Aßmus 
11612f86ba45SStephan Aßmus 	float topTint = 0.49;
11622f86ba45SStephan Aßmus 	float middleTint1 = 0.62;
11632f86ba45SStephan Aßmus 	float middleTint2 = 0.76;
11642f86ba45SStephan Aßmus 	float bottomTint = 0.90;
11652f86ba45SStephan Aßmus 
1166a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
11672f86ba45SStephan Aßmus 		topTint = (topTint + B_NO_TINT) / 2;
11682f86ba45SStephan Aßmus 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
11692f86ba45SStephan Aßmus 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
11702f86ba45SStephan Aßmus 		bottomTint = (bottomTint + B_NO_TINT) / 2;
1171a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
11722f86ba45SStephan Aßmus 		topTint *= kHoverTintFactor;
11732f86ba45SStephan Aßmus 		middleTint1 *= kHoverTintFactor;
11742f86ba45SStephan Aßmus 		middleTint2 *= kHoverTintFactor;
11752f86ba45SStephan Aßmus 		bottomTint *= kHoverTintFactor;
11762f86ba45SStephan Aßmus 	}
11772f86ba45SStephan Aßmus 
1178a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
11792f86ba45SStephan Aßmus 		// focused
11802f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
11812f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
11822f86ba45SStephan Aßmus 	} else {
11832f86ba45SStephan Aßmus 		// figure out the tints to be used
11842f86ba45SStephan Aßmus 		float frameLightTint;
11852f86ba45SStephan Aßmus 		float frameShadowTint;
11862f86ba45SStephan Aßmus 
1187a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
11882f86ba45SStephan Aßmus 			frameLightTint = 1.30;
11892f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
11902f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
11912f86ba45SStephan Aßmus 		} else {
11922f86ba45SStephan Aßmus 			frameLightTint = 1.6;
11932f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
11942f86ba45SStephan Aßmus 		}
11952f86ba45SStephan Aßmus 
11962f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
11972f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
11982f86ba45SStephan Aßmus 	}
11992f86ba45SStephan Aßmus 
12008ee9217eSStephan Aßmus 	// make room for the shadow
12018ee9217eSStephan Aßmus 	rect.right--;
12028ee9217eSStephan Aßmus 	rect.bottom--;
12032f86ba45SStephan Aßmus 
12042f86ba45SStephan Aßmus 	uint32 viewFlags = view->Flags();
12052f86ba45SStephan Aßmus 	view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
12062f86ba45SStephan Aßmus 	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
12072f86ba45SStephan Aßmus 
1208f3997b74SStephan Aßmus 	float centerh = (rect.left + rect.right) / 2;
1209f3997b74SStephan Aßmus 	float centerv = (rect.top + rect.bottom) / 2;
12102f86ba45SStephan Aßmus 
12118ee9217eSStephan Aßmus 	BShape shape;
1212f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12138ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
12148ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
12158ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
1216f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5));
12178ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
1218f3997b74SStephan Aßmus 	} else {
1219f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5));
1220f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
1221f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5));
1222f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, centerv + 0.5));
1223f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5));
1224f3997b74SStephan Aßmus 	}
12258ee9217eSStephan Aßmus 	shape.Close();
12268ee9217eSStephan Aßmus 
12278ee9217eSStephan Aßmus 	view->MovePenTo(BPoint(1, 1));
12288ee9217eSStephan Aßmus 
12298ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
12308ee9217eSStephan Aßmus 	view->SetHighColor(shadowColor);
12318ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
12328ee9217eSStephan Aßmus 
12338ee9217eSStephan Aßmus 	view->MovePenTo(B_ORIGIN);
12348ee9217eSStephan Aßmus 
12358ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
12362f86ba45SStephan Aßmus 	view->SetHighColor(frameLightColor);
12378ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
12382f86ba45SStephan Aßmus 
12392f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
12408ee9217eSStephan Aßmus 	shape.Clear();
1241f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12428ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
12438ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1244f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top));
1245f3997b74SStephan Aßmus 	} else {
1246f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 1, rect.top));
1247f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1248f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left, centerv + 0.5));
1249f3997b74SStephan Aßmus 	}
12508ee9217eSStephan Aßmus 	shape.Close();
12512f86ba45SStephan Aßmus 
12522f86ba45SStephan Aßmus 	BGradientLinear gradient;
1253a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12548ee9217eSStephan Aßmus 		_MakeGradient(gradient, rect, fill, topTint, bottomTint);
12552f86ba45SStephan Aßmus 	} else {
12568ee9217eSStephan Aßmus 		_MakeGlossyGradient(gradient, rect, fill, topTint, middleTint1,
12572f86ba45SStephan Aßmus 			middleTint2, bottomTint);
12582f86ba45SStephan Aßmus 	}
12592f86ba45SStephan Aßmus 
12608ee9217eSStephan Aßmus 	view->FillShape(&shape, gradient);
12612f86ba45SStephan Aßmus 
12622f86ba45SStephan Aßmus 	view->SetFlags(viewFlags);
12632f86ba45SStephan Aßmus }
12642f86ba45SStephan Aßmus 
12652f86ba45SStephan Aßmus 
12662f86ba45SStephan Aßmus void
12672f86ba45SStephan Aßmus BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
12682f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, int32 count,
1269e724b26fSJohn Scipione 	hash_mark_location location, uint32 flags, orientation orientation)
12702f86ba45SStephan Aßmus {
12712f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
12722f86ba45SStephan Aßmus 		return;
12732f86ba45SStephan Aßmus 
12742f86ba45SStephan Aßmus 	rgb_color lightColor;
12752f86ba45SStephan Aßmus 	rgb_color darkColor;
12762f86ba45SStephan Aßmus 
1277a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12782f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.9);
12792f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.07);
12802f86ba45SStephan Aßmus 	} else {
12812f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.8);
12822f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.14);
12832f86ba45SStephan Aßmus 	}
12842f86ba45SStephan Aßmus 
1285c7756ee1SJohn Scipione 	int32 hashMarkCount = std::max(count, (int32)2);
12862f86ba45SStephan Aßmus 		// draw at least two hashmarks at min/max if
12872f86ba45SStephan Aßmus 		// fHashMarks != B_HASH_MARKS_NONE
12882f86ba45SStephan Aßmus 	float factor;
12892f86ba45SStephan Aßmus 	float startPos;
12902f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12912f86ba45SStephan Aßmus 		factor = (rect.Width() - 2) / (hashMarkCount - 1);
12922f86ba45SStephan Aßmus 		startPos = rect.left + 1;
12932f86ba45SStephan Aßmus 	} else {
12942f86ba45SStephan Aßmus 		factor = (rect.Height() - 2) / (hashMarkCount - 1);
12952f86ba45SStephan Aßmus 		startPos = rect.top + 1;
12962f86ba45SStephan Aßmus 	}
12972f86ba45SStephan Aßmus 
12982f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_TOP) {
12992f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
13002f86ba45SStephan Aßmus 
13012f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
13022f86ba45SStephan Aßmus 			float pos = startPos;
13032f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
13042f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.top),
13052f86ba45SStephan Aßmus 							  BPoint(pos, rect.top + 4), darkColor);
13062f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.top),
13072f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.top + 4), lightColor);
13082f86ba45SStephan Aßmus 
13092f86ba45SStephan Aßmus 				pos += factor;
13102f86ba45SStephan Aßmus 			}
13112f86ba45SStephan Aßmus 		} else {
13122f86ba45SStephan Aßmus 			float pos = startPos;
13132f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
13142f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos),
13152f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos), darkColor);
13162f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos + 1),
13172f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos + 1), lightColor);
13182f86ba45SStephan Aßmus 
13192f86ba45SStephan Aßmus 				pos += factor;
13202f86ba45SStephan Aßmus 			}
13212f86ba45SStephan Aßmus 		}
13222f86ba45SStephan Aßmus 
13232f86ba45SStephan Aßmus 		view->EndLineArray();
13242f86ba45SStephan Aßmus 	}
13252f86ba45SStephan Aßmus 
13266905b4faSJohn Scipione 	if ((location & B_HASH_MARKS_BOTTOM) != 0) {
13272f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
13282f86ba45SStephan Aßmus 
13292f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
13302f86ba45SStephan Aßmus 			float pos = startPos;
13312f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
13322f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.bottom - 4),
13332f86ba45SStephan Aßmus 							  BPoint(pos, rect.bottom), darkColor);
13342f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.bottom - 4),
13352f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.bottom), lightColor);
13362f86ba45SStephan Aßmus 
13372f86ba45SStephan Aßmus 				pos += factor;
13382f86ba45SStephan Aßmus 			}
13392f86ba45SStephan Aßmus 		} else {
13402f86ba45SStephan Aßmus 			float pos = startPos;
13412f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
13422f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos),
13432f86ba45SStephan Aßmus 							  BPoint(rect.right, pos), darkColor);
13442f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos + 1),
13452f86ba45SStephan Aßmus 							  BPoint(rect.right, pos + 1), lightColor);
13462f86ba45SStephan Aßmus 
13472f86ba45SStephan Aßmus 				pos += factor;
13482f86ba45SStephan Aßmus 			}
13492f86ba45SStephan Aßmus 		}
13502f86ba45SStephan Aßmus 
13512f86ba45SStephan Aßmus 		view->EndLineArray();
13522f86ba45SStephan Aßmus 	}
13532f86ba45SStephan Aßmus }
13542f86ba45SStephan Aßmus 
13552f86ba45SStephan Aßmus 
13562f86ba45SStephan Aßmus void
13572f86ba45SStephan Aßmus BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
13582f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
13592f86ba45SStephan Aßmus {
13602f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
13612f86ba45SStephan Aßmus 		return;
13622f86ba45SStephan Aßmus 
13636f207787SAdrien Destugues 	// Snap the rectangle to pixels to avoid rounding errors.
13646f207787SAdrien Destugues 	rect.left = floorf(rect.left);
13656f207787SAdrien Destugues 	rect.right = floorf(rect.right);
13666f207787SAdrien Destugues 	rect.top = floorf(rect.top);
13676f207787SAdrien Destugues 	rect.bottom = floorf(rect.bottom);
13686f207787SAdrien Destugues 
13695666b4f7SJohn Scipione 	// save the clipping constraints of the view
13705666b4f7SJohn Scipione 	view->PushState();
1371a884b43bSJohn Scipione 
13725666b4f7SJohn Scipione 	// set clipping constraints to updateRect
13735666b4f7SJohn Scipione 	BRegion clipping(updateRect);
1374a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
1375a884b43bSJohn Scipione 
13762f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
13772f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
13782f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
13792f86ba45SStephan Aßmus 	rgb_color frameLightColor;
13802f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
13812f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
13822f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
13832f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
13842f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
13852f86ba45SStephan Aßmus 
1386a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
13872f86ba45SStephan Aßmus 		edgeLightColor = base;
1388a884b43bSJohn Scipione 		edgeShadowColor = base;
13892f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1390a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13912f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1392a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13932f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
13942f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
13952f86ba45SStephan Aßmus 	} else {
13962f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1397a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
13982f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1399a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14002f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.6);
1401a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
14022f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.75), 0);
14032f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.03), 255);
14042f86ba45SStephan Aßmus 	}
140512ea5a2cSStephan Aßmus 
1406a884b43bSJohn Scipione 	static const float kRoundCornerRadius = 4.0f;
14072f86ba45SStephan Aßmus 
1408a884b43bSJohn Scipione 	// left top corner dimensions
1409a884b43bSJohn Scipione 	BRect leftTopCorner(rect);
1410a884b43bSJohn Scipione 	leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
1411a884b43bSJohn Scipione 	leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1412a884b43bSJohn Scipione 	clipping.Exclude(leftTopCorner);
14132f86ba45SStephan Aßmus 
1414a884b43bSJohn Scipione 	// draw the left top corner
1415a884b43bSJohn Scipione 	_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
1416a884b43bSJohn Scipione 		edgeShadowColor, frameLightColor, bevelLightColor,
1417a884b43bSJohn Scipione 		fillGradient);
14182f86ba45SStephan Aßmus 
1419a884b43bSJohn Scipione 	// right top corner dimensions
1420a884b43bSJohn Scipione 	BRect rightTopCorner(rect);
1421a884b43bSJohn Scipione 	rightTopCorner.right = floorf(rect.right);
1422a884b43bSJohn Scipione 	rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
1423a884b43bSJohn Scipione 	rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1424a884b43bSJohn Scipione 	clipping.Exclude(rightTopCorner);
14252f86ba45SStephan Aßmus 
1426a884b43bSJohn Scipione 	// draw the right top corner
1427a884b43bSJohn Scipione 	_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
1428a884b43bSJohn Scipione 		edgeShadowColor, edgeLightColor, frameLightColor,
1429a884b43bSJohn Scipione 		frameShadowColor, bevelLightColor, bevelShadowColor,
1430a884b43bSJohn Scipione 		fillGradient);
14312f86ba45SStephan Aßmus 
1432a884b43bSJohn Scipione 	// clip out the corners
14332f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&clipping);
14342f86ba45SStephan Aßmus 
1435a884b43bSJohn Scipione 	// draw the rest of frame and fill
14362f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
14372f86ba45SStephan Aßmus 		edgeLightColor,
14382f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14392f86ba45SStephan Aßmus 	if ((borders & B_LEFT_BORDER) == 0)
14402f86ba45SStephan Aßmus 		rect.left++;
14412f86ba45SStephan Aßmus 	if ((borders & B_RIGHT_BORDER) == 0)
14422f86ba45SStephan Aßmus 		rect.right--;
14432f86ba45SStephan Aßmus 
14442f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
14452f86ba45SStephan Aßmus 		frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
14462f86ba45SStephan Aßmus 
14472f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
14482f86ba45SStephan Aßmus 		bevelShadowColor);
14492f86ba45SStephan Aßmus 
14502f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
14512f86ba45SStephan Aßmus 
14525666b4f7SJohn Scipione 	// restore the clipping constraints of the view
14535666b4f7SJohn Scipione 	view->PopState();
14542f86ba45SStephan Aßmus }
14552f86ba45SStephan Aßmus 
14562f86ba45SStephan Aßmus 
14572f86ba45SStephan Aßmus void
145883aff015SPhilippe Houdoin BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
14592f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
14602f86ba45SStephan Aßmus {
14612f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
14622f86ba45SStephan Aßmus 		return;
14632f86ba45SStephan Aßmus 
14642f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
14652f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
14662f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
14672f86ba45SStephan Aßmus 	rgb_color frameLightColor;
14682f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
14692f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
14702f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
14712f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
14722f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
14732f86ba45SStephan Aßmus 
1474a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
14752f86ba45SStephan Aßmus 		edgeLightColor = base;
1476a884b43bSJohn Scipione 		edgeShadowColor = base;
14772f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1478a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14792f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1480a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
14812f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
14822f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
14832f86ba45SStephan Aßmus 	} else {
14842f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1485a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
14862f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1487a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14882f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 1.10);
1489a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.17);
14902f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.12), 0);
14912f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.08), 255);
14922f86ba45SStephan Aßmus 	}
14932f86ba45SStephan Aßmus 
14942f86ba45SStephan Aßmus 	// active tabs stand out at the top, but this is an inactive tab
14952f86ba45SStephan Aßmus 	view->SetHighColor(base);
14962f86ba45SStephan Aßmus 	view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
14972f86ba45SStephan Aßmus 	rect.top += 4;
14982f86ba45SStephan Aßmus 
14992f86ba45SStephan Aßmus 	// frame and fill
15002f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
15012f86ba45SStephan Aßmus 		edgeLightColor,
15022f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
15032f86ba45SStephan Aßmus 
15042f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
15052f86ba45SStephan Aßmus 		frameShadowColor,
15062f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
15072f86ba45SStephan Aßmus 
1508b3601d82SStephan Aßmus 	if (rect.IsValid()) {
1509b3601d82SStephan Aßmus 		_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
1510b3601d82SStephan Aßmus 			bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
1511b3601d82SStephan Aßmus 	} else {
1512b3601d82SStephan Aßmus 		if ((B_LEFT_BORDER & ~borders) != 0)
1513b3601d82SStephan Aßmus 			rect.left++;
1514b3601d82SStephan Aßmus 	}
15152f86ba45SStephan Aßmus 
15162f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
15172f86ba45SStephan Aßmus }
15182f86ba45SStephan Aßmus 
15192f86ba45SStephan Aßmus 
15201f9fd6d8SStephan Aßmus void
15211f9fd6d8SStephan Aßmus BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
1522e724b26fSJohn Scipione 	const rgb_color& base, orientation orientation, uint32 flags,
15231f9fd6d8SStephan Aßmus 	uint32 borders)
15241f9fd6d8SStephan Aßmus {
1525a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1526a884b43bSJohn Scipione 		return;
1527a884b43bSJohn Scipione 
15281f9fd6d8SStephan Aßmus 	rgb_color background;
15291f9fd6d8SStephan Aßmus 	if ((flags & (B_CLICKED | B_ACTIVATED)) != 0)
15301f9fd6d8SStephan Aßmus 		background = tint_color(base, B_DARKEN_1_TINT);
15311f9fd6d8SStephan Aßmus 	else
15321f9fd6d8SStephan Aßmus 		background = base;
15331f9fd6d8SStephan Aßmus 
15341f9fd6d8SStephan Aßmus 	rgb_color light = tint_color(background, 0.6);
15351f9fd6d8SStephan Aßmus 	rgb_color shadow = tint_color(background, 1.21);
15361f9fd6d8SStephan Aßmus 
15371f9fd6d8SStephan Aßmus 	// frame
15381f9fd6d8SStephan Aßmus 	if (borders != 0 && rect.Width() > 3 && rect.Height() > 3)
15391f9fd6d8SStephan Aßmus 		DrawRaisedBorder(view, rect, updateRect, background, flags, borders);
15401f9fd6d8SStephan Aßmus 
15411f9fd6d8SStephan Aßmus 	// dots and rest of background
15421f9fd6d8SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
15431f9fd6d8SStephan Aßmus 		if (rect.Width() > 2) {
15441f9fd6d8SStephan Aßmus 			// background on left/right
15451f9fd6d8SStephan Aßmus 			BRegion region(rect);
15461f9fd6d8SStephan Aßmus 			rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5);
15471f9fd6d8SStephan Aßmus 			rect.right = rect.left + 1;
15481f9fd6d8SStephan Aßmus 			region.Exclude(rect);
15491f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
15501f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
15511f9fd6d8SStephan Aßmus 		}
15521f9fd6d8SStephan Aßmus 
15531f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15541f9fd6d8SStephan Aßmus 		BPoint stop = rect.LeftBottom();
15551f9fd6d8SStephan Aßmus 		int32 num = 1;
15561f9fd6d8SStephan Aßmus 		while (dot.y <= stop.y) {
15571f9fd6d8SStephan Aßmus 			rgb_color col1;
15581f9fd6d8SStephan Aßmus 			rgb_color col2;
15591f9fd6d8SStephan Aßmus 			switch (num) {
15601f9fd6d8SStephan Aßmus 				case 1:
15611f9fd6d8SStephan Aßmus 					col1 = background;
15621f9fd6d8SStephan Aßmus 					col2 = background;
15631f9fd6d8SStephan Aßmus 					break;
15641f9fd6d8SStephan Aßmus 				case 2:
15651f9fd6d8SStephan Aßmus 					col1 = shadow;
15661f9fd6d8SStephan Aßmus 					col2 = background;
15671f9fd6d8SStephan Aßmus 					break;
15681f9fd6d8SStephan Aßmus 				case 3:
1569a5339f65SStephan Aßmus 				default:
15701f9fd6d8SStephan Aßmus 					col1 = background;
15711f9fd6d8SStephan Aßmus 					col2 = light;
15721f9fd6d8SStephan Aßmus 					num = 0;
15731f9fd6d8SStephan Aßmus 					break;
15741f9fd6d8SStephan Aßmus 			}
15751f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15761f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15771f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15781f9fd6d8SStephan Aßmus 			dot.x++;
15791f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15801f9fd6d8SStephan Aßmus 			dot.x -= 1.0;
15811f9fd6d8SStephan Aßmus 			// next pixel
15821f9fd6d8SStephan Aßmus 			num++;
15831f9fd6d8SStephan Aßmus 			dot.y++;
15841f9fd6d8SStephan Aßmus 		}
15851f9fd6d8SStephan Aßmus 	} else {
15861f9fd6d8SStephan Aßmus 		if (rect.Height() > 2) {
15871f9fd6d8SStephan Aßmus 			// background on left/right
15881f9fd6d8SStephan Aßmus 			BRegion region(rect);
15891f9fd6d8SStephan Aßmus 			rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5);
15901f9fd6d8SStephan Aßmus 			rect.bottom = rect.top + 1;
15911f9fd6d8SStephan Aßmus 			region.Exclude(rect);
15921f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
15931f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
15941f9fd6d8SStephan Aßmus 		}
15951f9fd6d8SStephan Aßmus 
15961f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15971f9fd6d8SStephan Aßmus 		BPoint stop = rect.RightTop();
15981f9fd6d8SStephan Aßmus 		int32 num = 1;
15991f9fd6d8SStephan Aßmus 		while (dot.x <= stop.x) {
16001f9fd6d8SStephan Aßmus 			rgb_color col1;
16011f9fd6d8SStephan Aßmus 			rgb_color col2;
16021f9fd6d8SStephan Aßmus 			switch (num) {
16031f9fd6d8SStephan Aßmus 				case 1:
16041f9fd6d8SStephan Aßmus 					col1 = background;
16051f9fd6d8SStephan Aßmus 					col2 = background;
16061f9fd6d8SStephan Aßmus 					break;
16071f9fd6d8SStephan Aßmus 				case 2:
16081f9fd6d8SStephan Aßmus 					col1 = shadow;
16091f9fd6d8SStephan Aßmus 					col2 = background;
16101f9fd6d8SStephan Aßmus 					break;
16111f9fd6d8SStephan Aßmus 				case 3:
16129f981a88SFrançois Revol 				default:
16131f9fd6d8SStephan Aßmus 					col1 = background;
16141f9fd6d8SStephan Aßmus 					col2 = light;
16151f9fd6d8SStephan Aßmus 					num = 0;
16161f9fd6d8SStephan Aßmus 					break;
16171f9fd6d8SStephan Aßmus 			}
16181f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
16191f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
16201f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
16211f9fd6d8SStephan Aßmus 			dot.y++;
16221f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
16231f9fd6d8SStephan Aßmus 			dot.y -= 1.0;
16241f9fd6d8SStephan Aßmus 			// next pixel
16251f9fd6d8SStephan Aßmus 			num++;
16261f9fd6d8SStephan Aßmus 			dot.x++;
16271f9fd6d8SStephan Aßmus 		}
16281f9fd6d8SStephan Aßmus 	}
16291f9fd6d8SStephan Aßmus }
16301f9fd6d8SStephan Aßmus 
16311f9fd6d8SStephan Aßmus 
16322f86ba45SStephan Aßmus // #pragma mark -
16332f86ba45SStephan Aßmus 
16342f86ba45SStephan Aßmus 
16352f86ba45SStephan Aßmus void
16362f86ba45SStephan Aßmus BControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
16372f86ba45SStephan Aßmus 	const rgb_color& base, border_style border, uint32 flags, uint32 borders)
16382f86ba45SStephan Aßmus {
16392f86ba45SStephan Aßmus 	if (border == B_NO_BORDER)
16402f86ba45SStephan Aßmus 		return;
16412f86ba45SStephan Aßmus 
16422f86ba45SStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
1643a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
16442f86ba45SStephan Aßmus 		scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
16452f86ba45SStephan Aßmus 
16462f86ba45SStephan Aßmus 	if (border == B_FANCY_BORDER)
16474f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
16482f86ba45SStephan Aßmus 
16492f86ba45SStephan Aßmus 	_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
16502f86ba45SStephan Aßmus 		scrollbarFrameColor, scrollbarFrameColor, borders);
16512f86ba45SStephan Aßmus }
16522f86ba45SStephan Aßmus 
16532f86ba45SStephan Aßmus 
16542f86ba45SStephan Aßmus void
16552f86ba45SStephan Aßmus BControlLook::DrawRaisedBorder(BView* view, BRect& rect,
16562f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16572f86ba45SStephan Aßmus 	uint32 borders)
16582f86ba45SStephan Aßmus {
16592f86ba45SStephan Aßmus 	rgb_color lightColor;
16602f86ba45SStephan Aßmus 	rgb_color shadowColor;
16612f86ba45SStephan Aßmus 
1662a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16632f86ba45SStephan Aßmus 		lightColor = base;
16642f86ba45SStephan Aßmus 		shadowColor = base;
16652f86ba45SStephan Aßmus 	} else {
16662f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.85);
16672f86ba45SStephan Aßmus 		shadowColor = tint_color(base, 1.07);
16682f86ba45SStephan Aßmus 	}
16692f86ba45SStephan Aßmus 
16702f86ba45SStephan Aßmus 	_DrawFrame(view, rect, lightColor, lightColor, shadowColor, shadowColor,
16712f86ba45SStephan Aßmus 		borders);
16722f86ba45SStephan Aßmus }
16732f86ba45SStephan Aßmus 
16742f86ba45SStephan Aßmus 
16752f86ba45SStephan Aßmus void
16762f86ba45SStephan Aßmus BControlLook::DrawTextControlBorder(BView* view, BRect& rect,
16772f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16782f86ba45SStephan Aßmus 	uint32 borders)
16792f86ba45SStephan Aßmus {
16802f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
16812f86ba45SStephan Aßmus 		return;
16822f86ba45SStephan Aßmus 
16832f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
16842f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
16852f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
168637456be7SAdrien Destugues 	rgb_color invalidColor = ui_color(B_FAILURE_COLOR);
16872f86ba45SStephan Aßmus 
1688a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16894f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags, borders);
16902f86ba45SStephan Aßmus 
1691a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
16924f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 40 };
16934f579098SStephan Aßmus 		else
16942f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.15);
16954f579098SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
1696a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
16972f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
16982f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.49);
16992f86ba45SStephan Aßmus 
17004f579098SStephan Aßmus 		// BCheckBox uses this to indicate the clicked state...
17012f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
17022f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
17032f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
17042f86ba45SStephan Aßmus 
17052f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
17062f86ba45SStephan Aßmus 	} else {
17074f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags, borders);
17082f86ba45SStephan Aßmus 
1709a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
17104f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 102 };
17114f579098SStephan Aßmus 			dark2BorderColor = (rgb_color){ 0, 0, 0, 97 };
17124f579098SStephan Aßmus 		} else {
17132f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.40);
17142f86ba45SStephan Aßmus 			dark2BorderColor = tint_color(base, 1.38);
17152f86ba45SStephan Aßmus 		}
17164f579098SStephan Aßmus 	}
17172f86ba45SStephan Aßmus 
1718a884b43bSJohn Scipione 	if ((flags & B_DISABLED) == 0 && (flags & B_FOCUSED) != 0) {
17192f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
17202f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
17212f86ba45SStephan Aßmus 	}
17222f86ba45SStephan Aßmus 
172337456be7SAdrien Destugues 	if ((flags & B_DISABLED) == 0 && (flags & B_INVALID) != 0) {
172437456be7SAdrien Destugues 		dark1BorderColor = invalidColor;
172537456be7SAdrien Destugues 		dark2BorderColor = invalidColor;
172637456be7SAdrien Destugues 	}
172737456be7SAdrien Destugues 
1728a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
17294f579098SStephan Aßmus 		drawing_mode oldMode = view->DrawingMode();
17304f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
17314f579098SStephan Aßmus 
17322f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
17332f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
17342f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
17354f579098SStephan Aßmus 
17364f579098SStephan Aßmus 		view->SetDrawingMode(oldMode);
17374f579098SStephan Aßmus 	} else {
17384f579098SStephan Aßmus 		_DrawFrame(view, rect,
17394f579098SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
17404f579098SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
17414f579098SStephan Aßmus 	}
17422f86ba45SStephan Aßmus }
17432f86ba45SStephan Aßmus 
17442f86ba45SStephan Aßmus 
17452f86ba45SStephan Aßmus void
17462f86ba45SStephan Aßmus BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect,
17472f86ba45SStephan Aßmus 	const rgb_color& base, uint32 borders)
17482f86ba45SStephan Aßmus {
17492f86ba45SStephan Aßmus 	rgb_color frameColor = tint_color(base, 1.30);
17502f86ba45SStephan Aßmus 	rgb_color bevelLight = tint_color(base, 0.8);
17512f86ba45SStephan Aßmus 	rgb_color bevelShadow = tint_color(base, 1.03);
17522f86ba45SStephan Aßmus 
17532f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelShadow, bevelShadow, bevelLight, bevelLight,
17542f86ba45SStephan Aßmus 		borders);
17552f86ba45SStephan Aßmus 
17562f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameColor, frameColor, frameColor, frameColor,
17572f86ba45SStephan Aßmus 		borders);
17582f86ba45SStephan Aßmus 
17592f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLight, bevelLight, bevelShadow, bevelShadow,
17602f86ba45SStephan Aßmus 		borders);
17612f86ba45SStephan Aßmus }
17622f86ba45SStephan Aßmus 
17632f86ba45SStephan Aßmus 
17642f86ba45SStephan Aßmus void
17652f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17662f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags)
17672f86ba45SStephan Aßmus {
17681b848ee7SIngo Weinhold 	DrawLabel(view, label, NULL, rect, updateRect, base, flags,
17692f86ba45SStephan Aßmus 		DefaultLabelAlignment());
17702f86ba45SStephan Aßmus }
17712f86ba45SStephan Aßmus 
17722f86ba45SStephan Aßmus 
17732f86ba45SStephan Aßmus void
17742f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17752f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
17762f86ba45SStephan Aßmus 	const BAlignment& alignment)
17772f86ba45SStephan Aßmus {
17781b848ee7SIngo Weinhold 	DrawLabel(view, label, NULL, rect, updateRect, base, flags, alignment);
1779c4e211feSStephan Aßmus }
1780c4e211feSStephan Aßmus 
1781c4e211feSStephan Aßmus 
1782c4e211feSStephan Aßmus void
1783c4e211feSStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
1784c4e211feSStephan Aßmus 	uint32 flags, const BPoint& where)
1785c4e211feSStephan Aßmus {
1786c4e211feSStephan Aßmus 	// setup the text color
1787c4e211feSStephan Aßmus 	// TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here,
1788c4e211feSStephan Aßmus 	// or elliminate that constant alltogether (stippi: +1).
1789d63b75faSPhilippe Saint-Pierre 
1790d63b75faSPhilippe Saint-Pierre 	BWindow* window = view->Window();
1791d63b75faSPhilippe Saint-Pierre 	bool isDesktop = window
1792d63b75faSPhilippe Saint-Pierre 		&& window->Feel() == kPrivateDesktopWindowFeel
1793d63b75faSPhilippe Saint-Pierre 		&& window->Look() == kPrivateDesktopWindowLook
1794d63b75faSPhilippe Saint-Pierre 		&& view->Parent()
1795d63b75faSPhilippe Saint-Pierre 		&& view->Parent()->Parent() == NULL
1796d63b75faSPhilippe Saint-Pierre 		&& (flags & B_IGNORE_OUTLINE) == 0;
1797d63b75faSPhilippe Saint-Pierre 
1798d63b75faSPhilippe Saint-Pierre 	rgb_color	low;
1799c4e211feSStephan Aßmus 	rgb_color	color;
1800d63b75faSPhilippe Saint-Pierre 	rgb_color	glowColor;
1801d63b75faSPhilippe Saint-Pierre 
1802d63b75faSPhilippe Saint-Pierre 	if (isDesktop)
1803d63b75faSPhilippe Saint-Pierre 		low = view->Parent()->ViewColor();
1804c4e211feSStephan Aßmus 	else
1805d63b75faSPhilippe Saint-Pierre 		low = base;
1806d63b75faSPhilippe Saint-Pierre 
1807d63b75faSPhilippe Saint-Pierre 	if (low.red + low.green + low.blue > 128 * 3) {
1808d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_DARKEN_MAX_TINT);
1809d63b75faSPhilippe Saint-Pierre 		glowColor = kWhite;
1810d63b75faSPhilippe Saint-Pierre 	} else {
1811d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_LIGHTEN_MAX_TINT);
1812d63b75faSPhilippe Saint-Pierre 		glowColor = kBlack;
1813d63b75faSPhilippe Saint-Pierre 	}
1814c4e211feSStephan Aßmus 
1815a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
1816d63b75faSPhilippe Saint-Pierre 		color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
1817d63b75faSPhilippe Saint-Pierre 		color.green = (uint8)(((int32)low.green + color.green + 1) / 2);
1818d63b75faSPhilippe Saint-Pierre 		color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2);
1819d63b75faSPhilippe Saint-Pierre 	}
1820d63b75faSPhilippe Saint-Pierre 
1821d63b75faSPhilippe Saint-Pierre 	drawing_mode oldMode = view->DrawingMode();
1822d63b75faSPhilippe Saint-Pierre 
1823d63b75faSPhilippe Saint-Pierre 	if (isDesktop) {
1824a884b43bSJohn Scipione 		// drawing occurs on the desktop
1825d63b75faSPhilippe Saint-Pierre 		if (fCachedWorkspace != current_workspace()) {
1826d63b75faSPhilippe Saint-Pierre 			int8 indice = 0;
1827d63b75faSPhilippe Saint-Pierre 			int32 mask;
1828d63b75faSPhilippe Saint-Pierre 			bool tmpOutline;
1829d63b75faSPhilippe Saint-Pierre 			while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
1830d63b75faSPhilippe Saint-Pierre 					indice, &mask) == B_OK
1831d63b75faSPhilippe Saint-Pierre 				&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
1832d63b75faSPhilippe Saint-Pierre 					indice, &tmpOutline) == B_OK) {
1833d63b75faSPhilippe Saint-Pierre 
1834d63b75faSPhilippe Saint-Pierre 				if (((1 << current_workspace()) & mask) != 0) {
1835d63b75faSPhilippe Saint-Pierre 					fCachedOutline = tmpOutline;
1836d63b75faSPhilippe Saint-Pierre 					fCachedWorkspace = current_workspace();
1837d63b75faSPhilippe Saint-Pierre 					break;
1838d63b75faSPhilippe Saint-Pierre 				}
1839d63b75faSPhilippe Saint-Pierre 				indice++;
1840d63b75faSPhilippe Saint-Pierre 			}
1841d63b75faSPhilippe Saint-Pierre 		}
1842d63b75faSPhilippe Saint-Pierre 
1843d63b75faSPhilippe Saint-Pierre 		if (fCachedOutline) {
1844d63b75faSPhilippe Saint-Pierre 			BFont font;
1845d63b75faSPhilippe Saint-Pierre 			view->GetFont(&font);
1846d63b75faSPhilippe Saint-Pierre 
1847d63b75faSPhilippe Saint-Pierre 			view->SetDrawingMode(B_OP_ALPHA);
1848d63b75faSPhilippe Saint-Pierre 			view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
1849d63b75faSPhilippe Saint-Pierre 			// Draw glow or outline
1850d63b75faSPhilippe Saint-Pierre 			if (glowColor == kWhite) {
1851d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(2.0);
1852d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1853d63b75faSPhilippe Saint-Pierre 
1854d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1855d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1856d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1857d63b75faSPhilippe Saint-Pierre 
1858d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1859d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1860d63b75faSPhilippe Saint-Pierre 
1861d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 65;
1862d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1863d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1864d63b75faSPhilippe Saint-Pierre 
1865d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1866d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1867d63b75faSPhilippe Saint-Pierre 			} else if (glowColor == kBlack) {
1868d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1869d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1870d63b75faSPhilippe Saint-Pierre 
1871d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1872d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1873d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1874d63b75faSPhilippe Saint-Pierre 
1875d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1876d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1877d63b75faSPhilippe Saint-Pierre 
1878d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 200;
1879d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1880d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, BPoint(where.x + 1, where.y + 1));
1881d63b75faSPhilippe Saint-Pierre 			}
1882d63b75faSPhilippe Saint-Pierre 		}
1883c4e211feSStephan Aßmus 	}
1884c4e211feSStephan Aßmus 
1885c4e211feSStephan Aßmus 	view->SetHighColor(color);
1886c4e211feSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
1887c4e211feSStephan Aßmus 	view->DrawString(label, where);
1888c4e211feSStephan Aßmus 	view->SetDrawingMode(oldMode);
18892f86ba45SStephan Aßmus }
18902f86ba45SStephan Aßmus 
18912f86ba45SStephan Aßmus 
1892d63b75faSPhilippe Saint-Pierre void
18931b848ee7SIngo Weinhold BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
18941b848ee7SIngo Weinhold 	BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags)
18951b848ee7SIngo Weinhold {
18961b848ee7SIngo Weinhold 	DrawLabel(view, label, icon, rect, updateRect, base, flags,
18971b848ee7SIngo Weinhold 		DefaultLabelAlignment());
18981b848ee7SIngo Weinhold }
18991b848ee7SIngo Weinhold 
19001b848ee7SIngo Weinhold 
19011b848ee7SIngo Weinhold void
19021b848ee7SIngo Weinhold BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
19031b848ee7SIngo Weinhold 	BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags,
19041b848ee7SIngo Weinhold 	const BAlignment& alignment)
19051b848ee7SIngo Weinhold {
19061b848ee7SIngo Weinhold 	if (!rect.Intersects(updateRect))
19071b848ee7SIngo Weinhold 		return;
19081b848ee7SIngo Weinhold 
19091b848ee7SIngo Weinhold 	if (label == NULL && icon == NULL)
19101b848ee7SIngo Weinhold 		return;
19111b848ee7SIngo Weinhold 
19121b848ee7SIngo Weinhold 	if (label == NULL) {
19131b848ee7SIngo Weinhold 		// icon only
19141b848ee7SIngo Weinhold 		BRect alignedRect = BLayoutUtils::AlignInFrame(rect,
19151b848ee7SIngo Weinhold 			icon->Bounds().Size(), alignment);
19161b848ee7SIngo Weinhold 		drawing_mode oldMode = view->DrawingMode();
19171b848ee7SIngo Weinhold 		view->SetDrawingMode(B_OP_OVER);
19181b848ee7SIngo Weinhold 		view->DrawBitmap(icon, alignedRect.LeftTop());
19191b848ee7SIngo Weinhold 		view->SetDrawingMode(oldMode);
19201b848ee7SIngo Weinhold 		return;
19211b848ee7SIngo Weinhold 	}
19221b848ee7SIngo Weinhold 
19231b848ee7SIngo Weinhold 	// label, possibly with icon
19246af520e2SIngo Weinhold 	float availableWidth = rect.Width() + 1;
19251b848ee7SIngo Weinhold 	float width = 0;
19261b848ee7SIngo Weinhold 	float textOffset = 0;
19271b848ee7SIngo Weinhold 	float height = 0;
19281b848ee7SIngo Weinhold 
19291b848ee7SIngo Weinhold 	if (icon != NULL) {
19301b848ee7SIngo Weinhold 		width = icon->Bounds().Width() + DefaultLabelSpacing() + 1;
19311b848ee7SIngo Weinhold 		height = icon->Bounds().Height() + 1;
19321b848ee7SIngo Weinhold 		textOffset = width;
19331b848ee7SIngo Weinhold 		availableWidth -= textOffset;
19341b848ee7SIngo Weinhold 	}
19351b848ee7SIngo Weinhold 
19361b848ee7SIngo Weinhold 	// truncate the label if necessary and get the width and height
19371b848ee7SIngo Weinhold 	BString truncatedLabel(label);
19381b848ee7SIngo Weinhold 
19391b848ee7SIngo Weinhold 	BFont font;
19401b848ee7SIngo Weinhold 	view->GetFont(&font);
19411b848ee7SIngo Weinhold 
19421b848ee7SIngo Weinhold 	font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth);
19436af520e2SIngo Weinhold 	width += ceilf(font.StringWidth(truncatedLabel.String()));
19441b848ee7SIngo Weinhold 
19451b848ee7SIngo Weinhold 	font_height fontHeight;
19461b848ee7SIngo Weinhold 	font.GetHeight(&fontHeight);
1947c79ddce4SJohn Scipione 	float textHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
19481b848ee7SIngo Weinhold 	height = std::max(height, textHeight);
19491b848ee7SIngo Weinhold 
19501b848ee7SIngo Weinhold 	// handle alignment
1951e439b003SJohn Scipione 	BRect alignedRect(BLayoutUtils::AlignOnRect(rect,
1952e439b003SJohn Scipione 		BSize(width - 1, height - 1), alignment));
1953c79ddce4SJohn Scipione 
1954c79ddce4SJohn Scipione 	if (icon != NULL) {
19554e8acd32SJohn Scipione 		BPoint location(alignedRect.LeftTop());
19561b848ee7SIngo Weinhold 		if (icon->Bounds().Height() + 1 < height)
19571b848ee7SIngo Weinhold 			location.y += ceilf((height - icon->Bounds().Height() - 1) / 2);
19581b848ee7SIngo Weinhold 
19591b848ee7SIngo Weinhold 		drawing_mode oldMode = view->DrawingMode();
19601b848ee7SIngo Weinhold 		view->SetDrawingMode(B_OP_OVER);
19611b848ee7SIngo Weinhold 		view->DrawBitmap(icon, location);
19621b848ee7SIngo Weinhold 		view->SetDrawingMode(oldMode);
1963c79ddce4SJohn Scipione 	}
19641b848ee7SIngo Weinhold 
1965c79ddce4SJohn Scipione 	BPoint location(alignedRect.left + textOffset,
19661b848ee7SIngo Weinhold 		alignedRect.top + ceilf(fontHeight.ascent));
19671b848ee7SIngo Weinhold 	if (textHeight < height)
19681b848ee7SIngo Weinhold 		location.y += ceilf((height - textHeight) / 2);
19694e8acd32SJohn Scipione 
19701b848ee7SIngo Weinhold 	DrawLabel(view, truncatedLabel.String(), base, flags, location);
19711b848ee7SIngo Weinhold }
19721b848ee7SIngo Weinhold 
19731b848ee7SIngo Weinhold 
19741b848ee7SIngo Weinhold void
19758719e0dcSIngo Weinhold BControlLook::GetFrameInsets(frame_type frameType, uint32 flags, float& _left,
19768719e0dcSIngo Weinhold 	float& _top, float& _right, float& _bottom)
19778719e0dcSIngo Weinhold {
19788719e0dcSIngo Weinhold 	// All frames have the same inset on each side.
19798719e0dcSIngo Weinhold 	float inset = 0;
19808719e0dcSIngo Weinhold 
19818719e0dcSIngo Weinhold 	switch (frameType) {
19828719e0dcSIngo Weinhold 		case B_BUTTON_FRAME:
198387f392c9SIngo Weinhold 			inset = (flags & B_DEFAULT_BUTTON) != 0 ? 5 : 2;
19848719e0dcSIngo Weinhold 			break;
19858719e0dcSIngo Weinhold 		case B_GROUP_FRAME:
19868719e0dcSIngo Weinhold 		case B_MENU_FIELD_FRAME:
19878719e0dcSIngo Weinhold 			inset = 3;
19888719e0dcSIngo Weinhold 			break;
19898719e0dcSIngo Weinhold 		case B_SCROLL_VIEW_FRAME:
19908719e0dcSIngo Weinhold 		case B_TEXT_CONTROL_FRAME:
19918719e0dcSIngo Weinhold 			inset = 2;
19928719e0dcSIngo Weinhold 			break;
19938719e0dcSIngo Weinhold 	}
19948719e0dcSIngo Weinhold 
19958719e0dcSIngo Weinhold 	_left = inset;
19968719e0dcSIngo Weinhold 	_top = inset;
19978719e0dcSIngo Weinhold 	_right = inset;
19988719e0dcSIngo Weinhold 	_bottom = inset;
19998719e0dcSIngo Weinhold }
20008719e0dcSIngo Weinhold 
20018719e0dcSIngo Weinhold 
20028719e0dcSIngo Weinhold void
20038719e0dcSIngo Weinhold BControlLook::GetBackgroundInsets(background_type backgroundType,
20048719e0dcSIngo Weinhold 	uint32 flags, float& _left, float& _top, float& _right, float& _bottom)
20058719e0dcSIngo Weinhold {
20068719e0dcSIngo Weinhold 	// Most backgrounds have the same inset on each side.
20078719e0dcSIngo Weinhold 	float inset = 0;
20088719e0dcSIngo Weinhold 
20098719e0dcSIngo Weinhold 	switch (backgroundType) {
20108719e0dcSIngo Weinhold 		case B_BUTTON_BACKGROUND:
20118719e0dcSIngo Weinhold 		case B_MENU_BACKGROUND:
20128719e0dcSIngo Weinhold 		case B_MENU_BAR_BACKGROUND:
20138719e0dcSIngo Weinhold 		case B_MENU_FIELD_BACKGROUND:
20148719e0dcSIngo Weinhold 		case B_MENU_ITEM_BACKGROUND:
20158719e0dcSIngo Weinhold 			inset = 1;
20168719e0dcSIngo Weinhold 			break;
2017a0848a19SIngo Weinhold 		case B_BUTTON_WITH_POP_UP_BACKGROUND:
2018a0848a19SIngo Weinhold 			_left = 1;
2019a0848a19SIngo Weinhold 			_top = 1;
2020a0848a19SIngo Weinhold 			_right = 1 + kButtonPopUpIndicatorWidth;
2021a0848a19SIngo Weinhold 			_bottom = 1;
2022a0848a19SIngo Weinhold 			return;
20238719e0dcSIngo Weinhold 		case B_HORIZONTAL_SCROLL_BAR_BACKGROUND:
20248719e0dcSIngo Weinhold 			_left = 2;
20258719e0dcSIngo Weinhold 			_top = 0;
20268719e0dcSIngo Weinhold 			_right = 1;
20278719e0dcSIngo Weinhold 			_bottom = 0;
20288719e0dcSIngo Weinhold 			return;
20298719e0dcSIngo Weinhold 		case B_VERTICAL_SCROLL_BAR_BACKGROUND:
20308719e0dcSIngo Weinhold 			_left = 0;
20318719e0dcSIngo Weinhold 			_top = 2;
20328719e0dcSIngo Weinhold 			_right = 0;
20338719e0dcSIngo Weinhold 			_bottom = 1;
20348719e0dcSIngo Weinhold 			return;
20358719e0dcSIngo Weinhold 	}
20368719e0dcSIngo Weinhold 
20378719e0dcSIngo Weinhold 	_left = inset;
20388719e0dcSIngo Weinhold 	_top = inset;
20398719e0dcSIngo Weinhold 	_right = inset;
20408719e0dcSIngo Weinhold 	_bottom = inset;
20418719e0dcSIngo Weinhold }
20428719e0dcSIngo Weinhold 
20438719e0dcSIngo Weinhold 
20448719e0dcSIngo Weinhold void
20458719e0dcSIngo Weinhold BControlLook::GetInsets(frame_type frameType, background_type backgroundType,
20468719e0dcSIngo Weinhold 	uint32 flags, float& _left, float& _top, float& _right, float& _bottom)
20478719e0dcSIngo Weinhold {
20488719e0dcSIngo Weinhold 	GetFrameInsets(frameType, flags, _left, _top, _right, _bottom);
20498719e0dcSIngo Weinhold 
20508719e0dcSIngo Weinhold 	float left, top, right, bottom;
20518719e0dcSIngo Weinhold 	GetBackgroundInsets(backgroundType, flags, left, top, right, bottom);
20528719e0dcSIngo Weinhold 
20538719e0dcSIngo Weinhold 	_left += left;
20548719e0dcSIngo Weinhold 	_top += top;
20558719e0dcSIngo Weinhold 	_right += right;
20568719e0dcSIngo Weinhold 	_bottom += bottom;
20578719e0dcSIngo Weinhold }
20588719e0dcSIngo Weinhold 
20598719e0dcSIngo Weinhold 
20608719e0dcSIngo Weinhold void
2061a0848a19SIngo Weinhold BControlLook::DrawButtonWithPopUpBackground(BView* view, BRect& rect,
2062a0848a19SIngo Weinhold 	const BRect& updateRect, const rgb_color& base, uint32 flags,
2063a0848a19SIngo Weinhold 	uint32 borders, orientation orientation)
2064a0848a19SIngo Weinhold {
2065a0848a19SIngo Weinhold 	_DrawButtonBackground(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f,
2066a0848a19SIngo Weinhold 		base, true, flags, borders, orientation);
2067a0848a19SIngo Weinhold }
2068a0848a19SIngo Weinhold 
2069a0848a19SIngo Weinhold 
2070a0848a19SIngo Weinhold void
2071a0848a19SIngo Weinhold BControlLook::DrawButtonWithPopUpBackground(BView* view, BRect& rect,
2072a0848a19SIngo Weinhold 	const BRect& updateRect, float radius, const rgb_color& base, uint32 flags,
2073a0848a19SIngo Weinhold 	uint32 borders, orientation orientation)
2074a0848a19SIngo Weinhold {
2075a0848a19SIngo Weinhold 	_DrawButtonBackground(view, rect, updateRect, radius, radius, radius,
2076a0848a19SIngo Weinhold 		radius, base, true, flags, borders, orientation);
2077a0848a19SIngo Weinhold }
2078a0848a19SIngo Weinhold 
2079a0848a19SIngo Weinhold 
2080a0848a19SIngo Weinhold void
2081a0848a19SIngo Weinhold BControlLook::DrawButtonWithPopUpBackground(BView* view, BRect& rect,
2082a0848a19SIngo Weinhold 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2083a0848a19SIngo Weinhold 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2084a0848a19SIngo Weinhold 	uint32 flags, uint32 borders, orientation orientation)
2085a0848a19SIngo Weinhold {
2086a0848a19SIngo Weinhold 	_DrawButtonBackground(view, rect, updateRect, leftTopRadius,
2087a0848a19SIngo Weinhold 		rightTopRadius, leftBottomRadius, rightBottomRadius, base, true, flags,
2088a0848a19SIngo Weinhold 		borders, orientation);
2089a0848a19SIngo Weinhold }
2090a0848a19SIngo Weinhold 
2091a0848a19SIngo Weinhold 
2092a0848a19SIngo Weinhold void
2093d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo)
2094d63b75faSPhilippe Saint-Pierre {
2095d452ff66SAxel Dörfler 	fBackgroundInfo = backgroundInfo;
2096d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace = -1;
2097d63b75faSPhilippe Saint-Pierre }
2098d63b75faSPhilippe Saint-Pierre 
2099d63b75faSPhilippe Saint-Pierre 
21002f86ba45SStephan Aßmus // #pragma mark -
21012f86ba45SStephan Aßmus 
21022f86ba45SStephan Aßmus 
21032f86ba45SStephan Aßmus void
210413cd46dfSStephan Aßmus BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
2105a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2106a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2107a884b43bSJohn Scipione 	const rgb_color& background, float contrast, float brightness,
2108a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
210913cd46dfSStephan Aßmus {
2110a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2111a884b43bSJohn Scipione 		return;
211213cd46dfSStephan Aßmus 
21134fa76719SJohn Scipione 	// save the clipping constraints of the view
21144fa76719SJohn Scipione 	view->PushState();
211513cd46dfSStephan Aßmus 
21165666b4f7SJohn Scipione 	// set clipping constraints to updateRect
21174fa76719SJohn Scipione 	BRegion clipping(updateRect);
2118a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2119a884b43bSJohn Scipione 
2120a249edfbSIngo Weinhold 	// If the button is flat and neither activated nor otherwise highlighted
2121a249edfbSIngo Weinhold 	// (mouse hovering or focussed), draw it flat.
2122a249edfbSIngo Weinhold 	if ((flags & B_FLAT) != 0
2123a249edfbSIngo Weinhold 		&& (flags & (B_ACTIVATED | B_PARTIALLY_ACTIVATED)) == 0
2124a249edfbSIngo Weinhold 		&& ((flags & (B_HOVER | B_FOCUSED)) == 0
2125a249edfbSIngo Weinhold 			|| (flags & B_DISABLED) != 0)) {
2126a249edfbSIngo Weinhold 		_DrawFrame(view, rect, background, background, background,
2127a249edfbSIngo Weinhold 			background, borders);
2128a249edfbSIngo Weinhold 		_DrawFrame(view, rect, background, background, background,
2129a249edfbSIngo Weinhold 			background, borders);
2130a249edfbSIngo Weinhold 		view->PopState();
2131a249edfbSIngo Weinhold 		return;
2132a249edfbSIngo Weinhold 	}
2133a249edfbSIngo Weinhold 
2134a884b43bSJohn Scipione 	// outer edge colors
2135a884b43bSJohn Scipione 	rgb_color edgeLightColor;
2136a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
2137a884b43bSJohn Scipione 
2138a884b43bSJohn Scipione 	// default button frame color
21394f579098SStephan Aßmus 	// TODO: B_BLEND_FRAME
2140a884b43bSJohn Scipione 	float defaultIndicatorTint = 1.2;
2141a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
2142a884b43bSJohn Scipione 		defaultIndicatorTint = (B_NO_TINT + defaultIndicatorTint) / 2;
214313cd46dfSStephan Aßmus 
2144a884b43bSJohn Scipione 	rgb_color defaultIndicatorColor = tint_color(base, defaultIndicatorTint);
214588969219SJohn Scipione 	rgb_color cornerBgColor;
214688969219SJohn Scipione 
214788969219SJohn Scipione 	drawing_mode oldMode = view->DrawingMode();
214813cd46dfSStephan Aßmus 
2149a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
215088969219SJohn Scipione 		cornerBgColor = defaultIndicatorColor;
2151a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(defaultIndicatorColor,
2152a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2153a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
2154a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(defaultIndicatorColor,
2155a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2156a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
215713cd46dfSStephan Aßmus 
215888969219SJohn Scipione 		// draw default button indicator
2159a884b43bSJohn Scipione 		view->SetHighColor(background);
2160a884b43bSJohn Scipione 		view->FillRect(rect);
216113cd46dfSStephan Aßmus 		view->SetHighColor(base);
2162a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
2163a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
216413cd46dfSStephan Aßmus 
2165a884b43bSJohn Scipione 		view->SetHighColor(defaultIndicatorColor);
2166a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
2167a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
216813cd46dfSStephan Aßmus 
2169a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
2170a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
217113cd46dfSStephan Aßmus 	} else {
217288969219SJohn Scipione 		cornerBgColor = background;
217341651bb3SJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
217441651bb3SJohn Scipione 			// set the background color to transparent for the case
217541651bb3SJohn Scipione 			// that we are on the desktop
217641651bb3SJohn Scipione 			cornerBgColor.alpha = 0;
217741651bb3SJohn Scipione 			view->SetDrawingMode(B_OP_ALPHA);
217841651bb3SJohn Scipione 		}
217988969219SJohn Scipione 
2180a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(background,
2181a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
2182a884b43bSJohn Scipione 			brightness * 1.0, flags);
2183a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(background,
2184a884b43bSJohn Scipione 			contrast * (flags & B_DISABLED) != 0 ? 0.0 : 1.0,
2185a884b43bSJohn Scipione 			brightness * 1.0, flags);
218613cd46dfSStephan Aßmus 	}
218713cd46dfSStephan Aßmus 
2188a884b43bSJohn Scipione 	// frame colors
2189a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
2190a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
2191a884b43bSJohn Scipione 
2192a884b43bSJohn Scipione 	// rounded corners
2193a884b43bSJohn Scipione 
2194a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2195a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2196a884b43bSJohn Scipione 		// draw left top rounded corner
2197a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2198a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius),
2199a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius));
2200a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2201a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect,
2202a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, frameLightColor);
2203a884b43bSJohn Scipione 	}
2204a884b43bSJohn Scipione 
2205a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2206a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2207a884b43bSJohn Scipione 		// draw right top rounded corner
2208a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius),
2209a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2210a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius));
2211a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2212a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect,
2213a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
2214a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
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),
2222a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius), floorf(rect.bottom));
2223a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2224a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect,
2225a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
2226a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
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),
2233a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius), floorf(rect.right),
2234a884b43bSJohn Scipione 			floorf(rect.bottom));
2235a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2236a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightBottom(view, rightBottomCorner,
2237a884b43bSJohn Scipione 			updateRect, cornerBgColor, edgeLightColor, frameShadowColor);
2238a884b43bSJohn Scipione 	}
2239a884b43bSJohn Scipione 
2240a884b43bSJohn Scipione 	// clip out the corners
2241a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2242a884b43bSJohn Scipione 
2243a884b43bSJohn Scipione 	// draw outer edge
2244a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
2245a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, defaultIndicatorColor,
2246a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2247a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9),
2248a884b43bSJohn Scipione 			flags, borders);
2249a884b43bSJohn Scipione 	} else {
2250a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, background,
2251a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
2252a884b43bSJohn Scipione 			brightness * 1.0, flags, borders);
2253a884b43bSJohn Scipione 	}
2254a884b43bSJohn Scipione 
225588969219SJohn Scipione 	view->SetDrawingMode(oldMode);
225688969219SJohn Scipione 
2257a884b43bSJohn Scipione 	// draw frame
2258a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
22594f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
22604f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
22614f579098SStephan Aßmus 
2262a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2263a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
22644f579098SStephan Aßmus 
22654f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
22664f579098SStephan Aßmus 	} else {
2267a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2268a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
22694f579098SStephan Aßmus 	}
2270a884b43bSJohn Scipione 
22714fa76719SJohn Scipione 	// restore the clipping constraints of the view
22724fa76719SJohn Scipione 	view->PopState();
227313cd46dfSStephan Aßmus }
227413cd46dfSStephan Aßmus 
227513cd46dfSStephan Aßmus 
227613cd46dfSStephan Aßmus void
22772f86ba45SStephan Aßmus BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
22784f579098SStephan Aßmus 	const rgb_color& base, float contrast, float brightness, uint32 flags,
22794f579098SStephan Aßmus 	uint32 borders)
22802f86ba45SStephan Aßmus {
2281a884b43bSJohn Scipione 	rgb_color edgeLightColor = _EdgeLightColor(base, contrast,
2282a884b43bSJohn Scipione 		brightness, flags);
2283a884b43bSJohn Scipione 	rgb_color edgeShadowColor = _EdgeShadowColor(base, contrast,
2284a884b43bSJohn Scipione 		brightness, flags);
2285a884b43bSJohn Scipione 
2286a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
22874f579098SStephan Aßmus 		// assumes the background has already been painted
22884f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
22894f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
22904f579098SStephan Aßmus 
2291a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2292a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
22934f579098SStephan Aßmus 
22944f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
22954f579098SStephan Aßmus 	} else {
2296a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2297a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
22982f86ba45SStephan Aßmus 	}
22994f579098SStephan Aßmus }
23002f86ba45SStephan Aßmus 
23012f86ba45SStephan Aßmus 
23022f86ba45SStephan Aßmus void
23032f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
23042f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
23052f86ba45SStephan Aßmus 	uint32 borders)
23062f86ba45SStephan Aßmus {
23072f86ba45SStephan Aßmus 	view->BeginLineArray(4);
23082f86ba45SStephan Aßmus 
23092f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
23102f86ba45SStephan Aßmus 		view->AddLine(
23112f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
23122f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top), left);
23132f86ba45SStephan Aßmus 		rect.left++;
23142f86ba45SStephan Aßmus 	}
23152f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
23162f86ba45SStephan Aßmus 		view->AddLine(
23172f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
23182f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), top);
23192f86ba45SStephan Aßmus 		rect.top++;
23202f86ba45SStephan Aßmus 	}
23212f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
23222f86ba45SStephan Aßmus 		view->AddLine(
23232f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top),
23242f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), right);
23252f86ba45SStephan Aßmus 		rect.right--;
23262f86ba45SStephan Aßmus 	}
23272f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
23282f86ba45SStephan Aßmus 		view->AddLine(
23292f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
23302f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
23312f86ba45SStephan Aßmus 		rect.bottom--;
23322f86ba45SStephan Aßmus 	}
23332f86ba45SStephan Aßmus 
23342f86ba45SStephan Aßmus 	view->EndLineArray();
23352f86ba45SStephan Aßmus }
23362f86ba45SStephan Aßmus 
23372f86ba45SStephan Aßmus 
23382f86ba45SStephan Aßmus void
23392f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
23402f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
23412f86ba45SStephan Aßmus 	const rgb_color& rightTop, const rgb_color& leftBottom, uint32 borders)
23422f86ba45SStephan Aßmus {
23432f86ba45SStephan Aßmus 	view->BeginLineArray(6);
23442f86ba45SStephan Aßmus 
23452f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
23462f86ba45SStephan Aßmus 		if (borders & B_RIGHT_BORDER) {
23472f86ba45SStephan Aßmus 			view->AddLine(
23482f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
23492f86ba45SStephan Aßmus 				BPoint(rect.right - 1, rect.top), top);
23502f86ba45SStephan Aßmus 			view->AddLine(
23512f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top),
23522f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), rightTop);
23532f86ba45SStephan Aßmus 		} else {
23542f86ba45SStephan Aßmus 			view->AddLine(
23552f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
23562f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), top);
23572f86ba45SStephan Aßmus 		}
23582f86ba45SStephan Aßmus 		rect.top++;
23592f86ba45SStephan Aßmus 	}
23602f86ba45SStephan Aßmus 
23612f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
23622f86ba45SStephan Aßmus 		view->AddLine(
23632f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
23642f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom - 1), left);
23652f86ba45SStephan Aßmus 		view->AddLine(
23662f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
23672f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom), leftBottom);
23682f86ba45SStephan Aßmus 		rect.left++;
23692f86ba45SStephan Aßmus 	}
23702f86ba45SStephan Aßmus 
23712f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
23722f86ba45SStephan Aßmus 		view->AddLine(
23732f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
23742f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
23752f86ba45SStephan Aßmus 		rect.bottom--;
23762f86ba45SStephan Aßmus 	}
23772f86ba45SStephan Aßmus 
23782f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
23792f86ba45SStephan Aßmus 		view->AddLine(
23802f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom),
23812f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), right);
23822f86ba45SStephan Aßmus 		rect.right--;
23832f86ba45SStephan Aßmus 	}
23842f86ba45SStephan Aßmus 
23852f86ba45SStephan Aßmus 	view->EndLineArray();
23862f86ba45SStephan Aßmus }
23872f86ba45SStephan Aßmus 
23882f86ba45SStephan Aßmus 
23892f86ba45SStephan Aßmus void
2390a884b43bSJohn Scipione BControlLook::_DrawButtonBackground(BView* view, BRect& rect,
2391a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2392a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2393a0848a19SIngo Weinhold 	bool popupIndicator, uint32 flags, uint32 borders, orientation orientation)
23942f86ba45SStephan Aßmus {
2395a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2396a884b43bSJohn Scipione 		return;
23972f86ba45SStephan Aßmus 
23984fa76719SJohn Scipione 	// save the clipping constraints of the view
23994fa76719SJohn Scipione 	view->PushState();
24002f86ba45SStephan Aßmus 
24015666b4f7SJohn Scipione 	// set clipping constraints to updateRect
24024fa76719SJohn Scipione 	BRegion clipping(updateRect);
2403a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
24042f86ba45SStephan Aßmus 
2405a249edfbSIngo Weinhold 	// If the button is flat and neither activated nor otherwise highlighted
2406a249edfbSIngo Weinhold 	// (mouse hovering or focussed), draw it flat.
2407a249edfbSIngo Weinhold 	if ((flags & B_FLAT) != 0
2408a249edfbSIngo Weinhold 		&& (flags & (B_ACTIVATED | B_PARTIALLY_ACTIVATED)) == 0
2409a249edfbSIngo Weinhold 		&& ((flags & (B_HOVER | B_FOCUSED)) == 0
2410a249edfbSIngo Weinhold 			|| (flags & B_DISABLED) != 0)) {
2411a0848a19SIngo Weinhold 		_DrawFlatButtonBackground(view, rect, updateRect, base, popupIndicator,
2412a0848a19SIngo Weinhold 			flags, borders, orientation);
2413a0848a19SIngo Weinhold 	} else {
2414a0848a19SIngo Weinhold 		_DrawNonFlatButtonBackground(view, rect, updateRect, clipping,
2415a0848a19SIngo Weinhold 			leftTopRadius, rightTopRadius, leftBottomRadius, rightBottomRadius,
2416a0848a19SIngo Weinhold 			base, popupIndicator, flags, borders, orientation);
2417a249edfbSIngo Weinhold 	}
2418a249edfbSIngo Weinhold 
2419a0848a19SIngo Weinhold 	// restore the clipping constraints of the view
2420a0848a19SIngo Weinhold 	view->PopState();
2421a0848a19SIngo Weinhold }
2422a0848a19SIngo Weinhold 
2423a0848a19SIngo Weinhold 
2424a0848a19SIngo Weinhold void
2425a0848a19SIngo Weinhold BControlLook::_DrawFlatButtonBackground(BView* view, BRect& rect,
2426a0848a19SIngo Weinhold 	const BRect& updateRect, const rgb_color& base, bool popupIndicator,
2427a0848a19SIngo Weinhold 	uint32 flags, uint32 borders, orientation orientation)
2428a0848a19SIngo Weinhold {
2429a0848a19SIngo Weinhold 	_DrawFrame(view, rect, base, base, base, base, borders);
2430a0848a19SIngo Weinhold 		// Not an actual frame, but the method insets our rect as needed.
2431a0848a19SIngo Weinhold 
2432a0848a19SIngo Weinhold 	view->SetHighColor(base);
2433a0848a19SIngo Weinhold 	view->FillRect(rect);
2434a0848a19SIngo Weinhold 
2435a0848a19SIngo Weinhold 	if (popupIndicator) {
2436a0848a19SIngo Weinhold 		BRect indicatorRect(rect);
2437a0848a19SIngo Weinhold 		rect.right -= kButtonPopUpIndicatorWidth;
2438a0848a19SIngo Weinhold 		indicatorRect.left = rect.right + 3;
2439a0848a19SIngo Weinhold 			// 2 pixels for the separator
2440a0848a19SIngo Weinhold 
2441a0848a19SIngo Weinhold 		view->SetHighColor(base);
2442a0848a19SIngo Weinhold 		view->FillRect(indicatorRect);
2443a0848a19SIngo Weinhold 
2444a0848a19SIngo Weinhold 		_DrawPopUpMarker(view, indicatorRect, base, flags);
2445a0848a19SIngo Weinhold 	}
2446a0848a19SIngo Weinhold }
2447a0848a19SIngo Weinhold 
2448a0848a19SIngo Weinhold 
2449a0848a19SIngo Weinhold void
2450a0848a19SIngo Weinhold BControlLook::_DrawNonFlatButtonBackground(BView* view, BRect& rect,
2451a0848a19SIngo Weinhold 	const BRect& updateRect, BRegion& clipping, float leftTopRadius,
2452a0848a19SIngo Weinhold 	float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
2453a0848a19SIngo Weinhold 	const rgb_color& base, bool popupIndicator, uint32 flags, uint32 borders,
2454a0848a19SIngo Weinhold 	orientation orientation)
2455a0848a19SIngo Weinhold {
2456a884b43bSJohn Scipione 	// inner bevel colors
2457a884b43bSJohn Scipione 	rgb_color bevelLightColor  = _BevelLightColor(base, flags);
2458a884b43bSJohn Scipione 	rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2459a884b43bSJohn Scipione 
2460a884b43bSJohn Scipione 	// button background color
2461a884b43bSJohn Scipione 	rgb_color buttonBgColor;
2462a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
2463a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, 0.7);
24642f86ba45SStephan Aßmus 	else
2465a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, B_LIGHTEN_1_TINT);
2466a884b43bSJohn Scipione 
2467a884b43bSJohn Scipione 	// surface top gradient
2468a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2469a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, base, flags, orientation);
2470a884b43bSJohn Scipione 
2471a884b43bSJohn Scipione 	// rounded corners
2472a884b43bSJohn Scipione 
2473a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2474a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2475a884b43bSJohn Scipione 		// draw left top rounded corner
2476a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2477a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2478a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2479a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2480a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2481a884b43bSJohn Scipione 			bevelLightColor, fillGradient);
2482a884b43bSJohn Scipione 	}
2483a884b43bSJohn Scipione 
2484a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2485a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2486a884b43bSJohn Scipione 		// draw right top rounded corner
2487a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2488a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2489a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2490a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2491a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner,
2492a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2493a884b43bSJohn Scipione 	}
2494a884b43bSJohn Scipione 
2495a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2496a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2497a884b43bSJohn Scipione 		// draw left bottom rounded corner
2498a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2499a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2500a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2501a884b43bSJohn Scipione 			floorf(rect.bottom));
2502a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2503a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2504a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2505a884b43bSJohn Scipione 	}
2506a884b43bSJohn Scipione 
2507a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2508a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2509a884b43bSJohn Scipione 		// draw right bottom rounded corner
2510a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2511a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2512a884b43bSJohn Scipione 			floorf(rect.bottom));
2513a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2514a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2515a884b43bSJohn Scipione 			updateRect, bevelShadowColor, fillGradient);
2516a884b43bSJohn Scipione 	}
2517a884b43bSJohn Scipione 
2518a884b43bSJohn Scipione 	// clip out the corners
2519a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2520a884b43bSJohn Scipione 
2521a884b43bSJohn Scipione 	// draw inner bevel
2522a884b43bSJohn Scipione 
2523a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
2524a884b43bSJohn Scipione 		view->BeginLineArray(4);
2525a884b43bSJohn Scipione 
2526a884b43bSJohn Scipione 		// shadow along left/top borders
2527a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2528a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2529a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelLightColor);
2530a884b43bSJohn Scipione 			rect.left++;
2531a884b43bSJohn Scipione 		}
2532a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2533a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2534a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelLightColor);
2535a884b43bSJohn Scipione 			rect.top++;
2536a884b43bSJohn Scipione 		}
2537a884b43bSJohn Scipione 
2538a884b43bSJohn Scipione 		// softer shadow along left/top borders
2539a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2540a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2541a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelShadowColor);
2542a884b43bSJohn Scipione 			rect.left++;
2543a884b43bSJohn Scipione 		}
2544a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2545a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2546a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelShadowColor);
2547a884b43bSJohn Scipione 			rect.top++;
2548a884b43bSJohn Scipione 		}
2549a884b43bSJohn Scipione 
2550a884b43bSJohn Scipione 		view->EndLineArray();
2551a884b43bSJohn Scipione 	} else {
2552a884b43bSJohn Scipione 		_DrawFrame(view, rect,
2553a884b43bSJohn Scipione 			bevelLightColor, bevelLightColor,
2554a884b43bSJohn Scipione 			bevelShadowColor, bevelShadowColor,
2555a884b43bSJohn Scipione 			buttonBgColor, buttonBgColor, borders);
2556a884b43bSJohn Scipione 	}
2557a884b43bSJohn Scipione 
2558a0848a19SIngo Weinhold 	if (popupIndicator) {
2559a0848a19SIngo Weinhold 		BRect indicatorRect(rect);
2560a0848a19SIngo Weinhold 		rect.right -= kButtonPopUpIndicatorWidth;
2561a0848a19SIngo Weinhold 		indicatorRect.left = rect.right + 3;
2562a0848a19SIngo Weinhold 			// 2 pixels for the separator
2563a0848a19SIngo Weinhold 
2564a0848a19SIngo Weinhold 		// Even when depressed we want the pop-up indicator background and
2565a0848a19SIngo Weinhold 		// separator to cover the area up to the top.
2566a0848a19SIngo Weinhold 		if ((flags & B_ACTIVATED) != 0)
2567a0848a19SIngo Weinhold 			indicatorRect.top--;
2568a0848a19SIngo Weinhold 
2569a0848a19SIngo Weinhold 		// draw the separator
2570a0848a19SIngo Weinhold 		rgb_color separatorBaseColor = base;
2571a0848a19SIngo Weinhold 		if ((flags & B_ACTIVATED) != 0)
2572a0848a19SIngo Weinhold 			separatorBaseColor = tint_color(base, B_DARKEN_1_TINT);
2573a0848a19SIngo Weinhold 
2574a0848a19SIngo Weinhold 		rgb_color separatorLightColor = _EdgeLightColor(separatorBaseColor,
2575a0848a19SIngo Weinhold 			(flags & B_DISABLED) != 0 ? 0.7 : 1.0, 1.0, flags);
2576a0848a19SIngo Weinhold 		rgb_color separatorShadowColor = _EdgeShadowColor(separatorBaseColor,
2577a0848a19SIngo Weinhold 			(flags & B_DISABLED) != 0 ? 0.7 : 1.0, 1.0, flags);
2578a0848a19SIngo Weinhold 
2579a0848a19SIngo Weinhold 		view->BeginLineArray(2);
2580a0848a19SIngo Weinhold 
2581a0848a19SIngo Weinhold 		view->AddLine(BPoint(indicatorRect.left - 2, indicatorRect.top),
2582a0848a19SIngo Weinhold 			BPoint(indicatorRect.left - 2, indicatorRect.bottom),
2583a0848a19SIngo Weinhold 			separatorShadowColor);
2584a0848a19SIngo Weinhold 		view->AddLine(BPoint(indicatorRect.left - 1, indicatorRect.top),
2585a0848a19SIngo Weinhold 			BPoint(indicatorRect.left - 1, indicatorRect.bottom),
2586a0848a19SIngo Weinhold 			separatorLightColor);
2587a0848a19SIngo Weinhold 
2588a0848a19SIngo Weinhold 		view->EndLineArray();
2589a0848a19SIngo Weinhold 
2590a0848a19SIngo Weinhold 		// draw background and pop-up marker
2591a0848a19SIngo Weinhold 		_DrawMenuFieldBackgroundInside(view, indicatorRect, updateRect,
2592a0848a19SIngo Weinhold 			0.0f, rightTopRadius, 0.0f, rightBottomRadius, base, flags, 0);
2593a0848a19SIngo Weinhold 
2594a0848a19SIngo Weinhold 		if ((flags & B_ACTIVATED) != 0)
2595a0848a19SIngo Weinhold 			indicatorRect.top++;
2596a0848a19SIngo Weinhold 
2597a0848a19SIngo Weinhold 		_DrawPopUpMarker(view, indicatorRect, base, flags);
2598a0848a19SIngo Weinhold 	}
2599a0848a19SIngo Weinhold 
2600a884b43bSJohn Scipione 	// fill in the background
2601a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2602a0848a19SIngo Weinhold }
2603a884b43bSJohn Scipione 
2604a0848a19SIngo Weinhold 
2605a0848a19SIngo Weinhold void
2606a0848a19SIngo Weinhold BControlLook::_DrawPopUpMarker(BView* view, const BRect& rect,
2607a0848a19SIngo Weinhold 	const rgb_color& base, uint32 flags)
2608a0848a19SIngo Weinhold {
2609a0848a19SIngo Weinhold 	BPoint center(roundf((rect.left + rect.right) / 2.0),
2610a0848a19SIngo Weinhold 		roundf((rect.top + rect.bottom) / 2.0));
2611a0848a19SIngo Weinhold 	BPoint triangle[3];
2612a0848a19SIngo Weinhold 	triangle[0] = center + BPoint(-2.5, -0.5);
2613a0848a19SIngo Weinhold 	triangle[1] = center + BPoint(2.5, -0.5);
2614a0848a19SIngo Weinhold 	triangle[2] = center + BPoint(0.0, 2.0);
2615a0848a19SIngo Weinhold 
2616a0848a19SIngo Weinhold 	uint32 viewFlags = view->Flags();
2617a0848a19SIngo Weinhold 	view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
2618a0848a19SIngo Weinhold 
2619a0848a19SIngo Weinhold 	rgb_color markColor;
2620a0848a19SIngo Weinhold 	if ((flags & B_DISABLED) != 0)
2621a0848a19SIngo Weinhold 		markColor = tint_color(base, 1.35);
2622a0848a19SIngo Weinhold 	else
2623a0848a19SIngo Weinhold 		markColor = tint_color(base, 1.65);
2624a0848a19SIngo Weinhold 
2625a0848a19SIngo Weinhold 	view->SetHighColor(markColor);
2626a0848a19SIngo Weinhold 	view->FillTriangle(triangle[0], triangle[1], triangle[2]);
2627a0848a19SIngo Weinhold 
2628a0848a19SIngo Weinhold 	view->SetFlags(viewFlags);
26292f86ba45SStephan Aßmus }
26302f86ba45SStephan Aßmus 
26312f86ba45SStephan Aßmus 
26322f86ba45SStephan Aßmus void
2633a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundOutside(BView* view, BRect& rect,
2634a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2635a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2636a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
26372f86ba45SStephan Aßmus {
2638a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2639a884b43bSJohn Scipione 		return;
2640a884b43bSJohn Scipione 
2641a884b43bSJohn Scipione 	if (popupIndicator) {
2642a884b43bSJohn Scipione 		BRect leftRect(rect);
2643a884b43bSJohn Scipione 		leftRect.right -= 10;
2644a884b43bSJohn Scipione 
2645a884b43bSJohn Scipione 		BRect rightRect(rect);
2646a884b43bSJohn Scipione 		rightRect.left = rightRect.right - 9;
2647a884b43bSJohn Scipione 
2648a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, leftRect, updateRect,
2649a884b43bSJohn Scipione 			leftTopRadius, 0.0f, leftBottomRadius, 0.0f, base, flags,
2650a884b43bSJohn Scipione 			B_LEFT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER);
2651a884b43bSJohn Scipione 
2652a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rightRect, updateRect,
2653a884b43bSJohn Scipione 			0.0f, rightTopRadius, 0.0f, rightBottomRadius, base, flags,
2654a884b43bSJohn Scipione 			B_TOP_BORDER | B_RIGHT_BORDER | B_BOTTOM_BORDER);
2655a884b43bSJohn Scipione 
2656a0848a19SIngo Weinhold 		_DrawPopUpMarker(view, rightRect, base, flags);
2657a884b43bSJohn Scipione 
2658a884b43bSJohn Scipione 		// draw a line on the left of the popup frame
2659a884b43bSJohn Scipione 		rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2660a884b43bSJohn Scipione 		view->SetHighColor(bevelShadowColor);
2661a884b43bSJohn Scipione 		BPoint leftTopCorner(floorf(rightRect.left - 1.0),
2662a884b43bSJohn Scipione 			floorf(rightRect.top - 1.0));
2663a884b43bSJohn Scipione 		BPoint leftBottomCorner(floorf(rightRect.left - 1.0),
2664a884b43bSJohn Scipione 			floorf(rightRect.bottom + 1.0));
2665a884b43bSJohn Scipione 		view->StrokeLine(leftTopCorner, leftBottomCorner);
2666a884b43bSJohn Scipione 
2667a884b43bSJohn Scipione 		rect = leftRect;
2668a884b43bSJohn Scipione 	} else {
2669a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rect, updateRect, leftTopRadius,
2670a884b43bSJohn Scipione 			rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags);
2671a884b43bSJohn Scipione 	}
26722f86ba45SStephan Aßmus }
26732f86ba45SStephan Aßmus 
26742f86ba45SStephan Aßmus 
2675a884b43bSJohn Scipione void
2676a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
2677a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2678a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2679a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
26802f86ba45SStephan Aßmus {
2681a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2682a884b43bSJohn Scipione 		return;
2683a884b43bSJohn Scipione 
26845666b4f7SJohn Scipione 	// save the clipping constraints of the view
26855666b4f7SJohn Scipione 	view->PushState();
2686a884b43bSJohn Scipione 
26875666b4f7SJohn Scipione 	// set clipping constraints to updateRect
26885666b4f7SJohn Scipione 	BRegion clipping(updateRect);
2689a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2690a884b43bSJohn Scipione 
2691a884b43bSJohn Scipione 	// frame colors
2692a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
2693a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
2694a884b43bSJohn Scipione 
2695a884b43bSJohn Scipione 	// indicator background color
2696a884b43bSJohn Scipione 	rgb_color indicatorBase;
2697a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0)
2698a884b43bSJohn Scipione 		indicatorBase = base;
2699a884b43bSJohn Scipione 	else {
2700a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2701a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.05);
2702a884b43bSJohn Scipione 		else
2703a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.12);
27042f86ba45SStephan Aßmus 	}
27052f86ba45SStephan Aßmus 
2706a884b43bSJohn Scipione 	// bevel colors
2707a884b43bSJohn Scipione 	rgb_color cornerColor = tint_color(indicatorBase, 0.85);
2708a884b43bSJohn Scipione 	rgb_color bevelColor1 = tint_color(indicatorBase, 0.3);
2709a884b43bSJohn Scipione 	rgb_color bevelColor2 = tint_color(indicatorBase, 0.5);
2710a884b43bSJohn Scipione 	rgb_color bevelColor3 = tint_color(indicatorBase, 1.03);
27112f86ba45SStephan Aßmus 
2712a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
2713a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.8);
2714a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.7);
2715a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.8);
2716a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.01);
27172f86ba45SStephan Aßmus 	} else {
2718a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.85);
2719a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.3);
2720a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.5);
2721a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.03);
27222f86ba45SStephan Aßmus 	}
2723a884b43bSJohn Scipione 
2724a884b43bSJohn Scipione 	// surface top gradient
2725a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2726a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, indicatorBase, flags);
2727a884b43bSJohn Scipione 
2728a884b43bSJohn Scipione 	// rounded corners
2729a884b43bSJohn Scipione 
2730a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2731a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2732a884b43bSJohn Scipione 		// draw left top rounded corner
2733a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2734a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2735a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2736a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2737a884b43bSJohn Scipione 
2738a884b43bSJohn Scipione 		BRegion cornerClipping(leftTopCorner);
2739a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2740a884b43bSJohn Scipione 
2741a884b43bSJohn Scipione 		BRect ellipseRect(leftTopCorner);
2742a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2743a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2744a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2745a884b43bSJohn Scipione 
2746a884b43bSJohn Scipione 		// draw the frame (again)
2747a884b43bSJohn Scipione 		view->SetHighColor(frameLightColor);
2748a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2749a884b43bSJohn Scipione 
2750a884b43bSJohn Scipione 		// draw the bevel and background
2751a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2752a884b43bSJohn Scipione 			bevelColor1, fillGradient);
2753a884b43bSJohn Scipione 	}
2754a884b43bSJohn Scipione 
2755a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2756a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2757a884b43bSJohn Scipione 		// draw right top rounded corner
2758a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2759a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2760a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2761a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2762a884b43bSJohn Scipione 
2763a884b43bSJohn Scipione 		BRegion cornerClipping(rightTopCorner);
2764a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2765a884b43bSJohn Scipione 
2766a884b43bSJohn Scipione 		BRect ellipseRect(rightTopCorner);
2767a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2768a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2769a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2770a884b43bSJohn Scipione 
2771a884b43bSJohn Scipione 		// draw the frame (again)
2772a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2773a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2774a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
27752f86ba45SStephan Aßmus 		} else {
2776a884b43bSJohn Scipione 			BGradientLinear gradient;
2777a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2778a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2779a884b43bSJohn Scipione 			gradient.SetStart(rightTopCorner.LeftTop());
2780a884b43bSJohn Scipione 			gradient.SetEnd(rightTopCorner.RightBottom());
2781a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
27822f86ba45SStephan Aßmus 		}
27832f86ba45SStephan Aßmus 
2784a884b43bSJohn Scipione 		// draw the bevel and background
2785a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect,
2786a884b43bSJohn Scipione 			bevelColor1, bevelColor3, fillGradient);
2787a884b43bSJohn Scipione 	}
27882f86ba45SStephan Aßmus 
2789a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2790a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2791a884b43bSJohn Scipione 		// draw left bottom rounded corner
2792a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2793a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2794a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2795a884b43bSJohn Scipione 			floorf(rect.bottom));
2796a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2797a884b43bSJohn Scipione 
2798a884b43bSJohn Scipione 		BRegion cornerClipping(leftBottomCorner);
2799a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2800a884b43bSJohn Scipione 
2801a884b43bSJohn Scipione 		BRect ellipseRect(leftBottomCorner);
2802a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2803a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2804a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2805a884b43bSJohn Scipione 
2806a884b43bSJohn Scipione 		// draw the frame (again)
2807a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2808a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2809a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
2810a884b43bSJohn Scipione 		} else {
2811a884b43bSJohn Scipione 			BGradientLinear gradient;
2812a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2813a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2814a884b43bSJohn Scipione 			gradient.SetStart(leftBottomCorner.LeftTop());
2815a884b43bSJohn Scipione 			gradient.SetEnd(leftBottomCorner.RightBottom());
2816a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
2817a884b43bSJohn Scipione 		}
2818a884b43bSJohn Scipione 
2819a884b43bSJohn Scipione 		// draw the bevel and background
2820a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2821a884b43bSJohn Scipione 			updateRect, bevelColor2, bevelColor3, fillGradient);
2822a884b43bSJohn Scipione 	}
2823a884b43bSJohn Scipione 
2824a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2825a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2826a884b43bSJohn Scipione 		// draw right bottom rounded corner
2827a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2828a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2829a884b43bSJohn Scipione 			floorf(rect.bottom));
2830a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2831a884b43bSJohn Scipione 
2832a884b43bSJohn Scipione 		BRegion cornerClipping(rightBottomCorner);
2833a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2834a884b43bSJohn Scipione 
2835a884b43bSJohn Scipione 		BRect ellipseRect(rightBottomCorner);
2836a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2837a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2838a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2839a884b43bSJohn Scipione 
2840a884b43bSJohn Scipione 		// draw the frame (again)
2841a884b43bSJohn Scipione 		view->SetHighColor(frameShadowColor);
2842a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2843a884b43bSJohn Scipione 
2844a884b43bSJohn Scipione 		// draw the bevel and background
2845a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2846a884b43bSJohn Scipione 			updateRect, bevelColor3, fillGradient);
2847a884b43bSJohn Scipione 	}
2848a884b43bSJohn Scipione 
2849a884b43bSJohn Scipione 	// clip out the corners
2850a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2851a884b43bSJohn Scipione 
2852a884b43bSJohn Scipione 	// draw the bevel
2853a884b43bSJohn Scipione 	_DrawFrame(view, rect,
2854a884b43bSJohn Scipione 		bevelColor2, bevelColor1,
2855a884b43bSJohn Scipione 		bevelColor3, bevelColor3,
2856a884b43bSJohn Scipione 		cornerColor, cornerColor,
2857a884b43bSJohn Scipione 		borders);
2858a884b43bSJohn Scipione 
2859a884b43bSJohn Scipione 	// fill in the background
2860a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2861a884b43bSJohn Scipione 
28625666b4f7SJohn Scipione 	// restore the clipping constraints of the view
28635666b4f7SJohn Scipione 	view->PopState();
2864a884b43bSJohn Scipione }
2865a884b43bSJohn Scipione 
2866a884b43bSJohn Scipione 
2867a884b43bSJohn Scipione void
2868a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftTop(BView* view, BRect& cornerRect,
2869a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2870a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2871a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2872a884b43bSJohn Scipione {
2873a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftTop(view, cornerRect, updateRect,
2874a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2875a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftTop(view, cornerRect, updateRect,
2876a884b43bSJohn Scipione 		bevelColor, fillGradient);
2877a884b43bSJohn Scipione }
2878a884b43bSJohn Scipione 
2879a884b43bSJohn Scipione 
2880a884b43bSJohn Scipione void
2881a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftTop(BView* view, BRect& cornerRect,
2882a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2883a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2884a884b43bSJohn Scipione {
2885a884b43bSJohn Scipione 	// constrain clipping region to corner
2886a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2887a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2888a884b43bSJohn Scipione 
2889a884b43bSJohn Scipione 	// background
2890a884b43bSJohn Scipione 	view->SetHighColor(background);
2891a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2892a884b43bSJohn Scipione 
2893a884b43bSJohn Scipione 	// outer edge
2894a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2895a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2896a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2897a884b43bSJohn Scipione 
2898a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2899a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2900a884b43bSJohn Scipione 
2901a884b43bSJohn Scipione 	// frame
2902a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2903a884b43bSJohn Scipione 	cornerRect.left++;
2904a884b43bSJohn Scipione 	cornerRect.top++;
2905a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2906a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2907a884b43bSJohn Scipione 
2908a884b43bSJohn Scipione 	// prepare for bevel
2909a884b43bSJohn Scipione 	cornerRect.left++;
2910a884b43bSJohn Scipione 	cornerRect.top++;
2911a884b43bSJohn Scipione }
2912a884b43bSJohn Scipione 
2913a884b43bSJohn Scipione 
2914a884b43bSJohn Scipione void
2915a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftTop(BView* view, BRect& cornerRect,
2916a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelColor,
2917a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2918a884b43bSJohn Scipione {
2919a884b43bSJohn Scipione 	// constrain clipping region to corner
2920a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2921a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2922a884b43bSJohn Scipione 
2923a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2924a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2925a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2926a884b43bSJohn Scipione 
2927a884b43bSJohn Scipione 	// bevel
2928a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2929a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2930a884b43bSJohn Scipione 
2931a884b43bSJohn Scipione 	// gradient
2932a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2933a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2934a884b43bSJohn Scipione }
2935a884b43bSJohn Scipione 
2936a884b43bSJohn Scipione 
2937a884b43bSJohn Scipione void
2938a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightTop(BView* view, BRect& cornerRect,
2939a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2940a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2941a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor,
2942a884b43bSJohn Scipione 	const rgb_color& bevelTopColor, const rgb_color& bevelRightColor,
2943a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2944a884b43bSJohn Scipione {
2945a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightTop(view, cornerRect, updateRect,
2946a884b43bSJohn Scipione 		background, edgeTopColor, edgeRightColor, frameTopColor,
2947a884b43bSJohn Scipione 		frameRightColor);
2948a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightTop(view, cornerRect, updateRect,
2949a884b43bSJohn Scipione 		bevelTopColor, bevelRightColor, fillGradient);
2950a884b43bSJohn Scipione }
2951a884b43bSJohn Scipione 
2952a884b43bSJohn Scipione 
2953a884b43bSJohn Scipione void
2954a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightTop(BView* view, BRect& cornerRect,
2955a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2956a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2957a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor)
2958a884b43bSJohn Scipione {
2959a884b43bSJohn Scipione 	// constrain clipping region to corner
2960a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2961a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2962a884b43bSJohn Scipione 
2963a884b43bSJohn Scipione 	// background
2964a884b43bSJohn Scipione 	view->SetHighColor(background);
2965a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2966a884b43bSJohn Scipione 
2967a884b43bSJohn Scipione 	// outer edge
2968a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2969a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2970a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2971a884b43bSJohn Scipione 
2972a884b43bSJohn Scipione 	BGradientLinear gradient;
2973a884b43bSJohn Scipione 	gradient.AddColor(edgeTopColor, 0);
2974a884b43bSJohn Scipione 	gradient.AddColor(edgeRightColor, 255);
2975a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2976a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2977a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2978a884b43bSJohn Scipione 
2979a884b43bSJohn Scipione 	// frame
2980a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2981a884b43bSJohn Scipione 	cornerRect.right--;
2982a884b43bSJohn Scipione 	cornerRect.top++;
2983a884b43bSJohn Scipione 	if (frameTopColor == frameRightColor) {
2984a884b43bSJohn Scipione 		view->SetHighColor(frameTopColor);
2985a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2986a884b43bSJohn Scipione 	} else {
2987a884b43bSJohn Scipione 		gradient.SetColor(0, frameTopColor);
2988a884b43bSJohn Scipione 		gradient.SetColor(1, frameRightColor);
2989a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2990a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2991a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2992a884b43bSJohn Scipione 	}
2993a884b43bSJohn Scipione 
2994a884b43bSJohn Scipione 	// prepare for bevel
2995a884b43bSJohn Scipione 	cornerRect.right--;
2996a884b43bSJohn Scipione 	cornerRect.top++;
2997a884b43bSJohn Scipione }
2998a884b43bSJohn Scipione 
2999a884b43bSJohn Scipione 
3000a884b43bSJohn Scipione void
3001a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightTop(BView* view, BRect& cornerRect,
3002a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelTopColor,
3003a884b43bSJohn Scipione 	const rgb_color& bevelRightColor, const BGradientLinear& fillGradient)
3004a884b43bSJohn Scipione {
3005a884b43bSJohn Scipione 	// constrain clipping region to corner
3006a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
3007a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
3008a884b43bSJohn Scipione 
3009a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
3010a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
3011a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
3012a884b43bSJohn Scipione 
3013a884b43bSJohn Scipione 	// bevel
3014a884b43bSJohn Scipione 	BGradientLinear gradient;
3015a884b43bSJohn Scipione 	gradient.AddColor(bevelTopColor, 0);
3016a884b43bSJohn Scipione 	gradient.AddColor(bevelRightColor, 255);
3017a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
3018a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
3019a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
3020a884b43bSJohn Scipione 
3021a884b43bSJohn Scipione 	// gradient
3022a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
3023a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
3024a884b43bSJohn Scipione }
3025a884b43bSJohn Scipione 
3026a884b43bSJohn Scipione 
3027a884b43bSJohn Scipione void
3028a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftBottom(BView* view, BRect& cornerRect,
3029a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
3030a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
3031a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor,
3032a884b43bSJohn Scipione 	const rgb_color& bevelLeftColor, const rgb_color& bevelBottomColor,
3033a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
3034a884b43bSJohn Scipione {
3035a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftBottom(view, cornerRect, updateRect,
3036a884b43bSJohn Scipione 		background, edgeLeftColor, edgeBottomColor, frameLeftColor,
3037a884b43bSJohn Scipione 		frameBottomColor);
3038a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftBottom(view, cornerRect, updateRect,
3039a884b43bSJohn Scipione 		bevelLeftColor, bevelBottomColor, fillGradient);
3040a884b43bSJohn Scipione }
3041a884b43bSJohn Scipione 
3042a884b43bSJohn Scipione 
3043a884b43bSJohn Scipione void
3044a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftBottom(BView* view, BRect& cornerRect,
3045a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
3046a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
3047a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor)
3048a884b43bSJohn Scipione {
3049a884b43bSJohn Scipione 	// constrain clipping region to corner
3050a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
3051a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
3052a884b43bSJohn Scipione 
3053a884b43bSJohn Scipione 	// background
3054a884b43bSJohn Scipione 	view->SetHighColor(background);
3055a884b43bSJohn Scipione 	view->FillRect(cornerRect);
3056a884b43bSJohn Scipione 
3057a884b43bSJohn Scipione 	// outer edge
3058a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
3059a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
3060a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
3061a884b43bSJohn Scipione 
3062a884b43bSJohn Scipione 	BGradientLinear gradient;
3063a884b43bSJohn Scipione 	gradient.AddColor(edgeLeftColor, 0);
3064a884b43bSJohn Scipione 	gradient.AddColor(edgeBottomColor, 255);
3065a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
3066a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
3067a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
3068a884b43bSJohn Scipione 
3069a884b43bSJohn Scipione 	// frame
3070a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
3071a884b43bSJohn Scipione 	cornerRect.left++;
3072a884b43bSJohn Scipione 	cornerRect.bottom--;
3073a884b43bSJohn Scipione 	if (frameLeftColor == frameBottomColor) {
3074a884b43bSJohn Scipione 		view->SetHighColor(frameLeftColor);
3075a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
3076a884b43bSJohn Scipione 	} else {
3077a884b43bSJohn Scipione 		gradient.SetColor(0, frameLeftColor);
3078a884b43bSJohn Scipione 		gradient.SetColor(1, frameBottomColor);
3079a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
3080a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
3081a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
3082a884b43bSJohn Scipione 	}
3083a884b43bSJohn Scipione 
3084a884b43bSJohn Scipione 	// prepare for bevel
3085a884b43bSJohn Scipione 	cornerRect.left++;
3086a884b43bSJohn Scipione 	cornerRect.bottom--;
3087a884b43bSJohn Scipione }
3088a884b43bSJohn Scipione 
3089a884b43bSJohn Scipione 
3090a884b43bSJohn Scipione void
3091a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftBottom(BView* view, BRect& cornerRect,
3092a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelLeftColor,
3093a884b43bSJohn Scipione 	const rgb_color& bevelBottomColor, const BGradientLinear& fillGradient)
3094a884b43bSJohn Scipione {
3095a884b43bSJohn Scipione 	// constrain clipping region to corner
3096a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
3097a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
3098a884b43bSJohn Scipione 
3099a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
3100a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
3101a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
3102a884b43bSJohn Scipione 
3103a884b43bSJohn Scipione 	// bevel
3104a884b43bSJohn Scipione 	BGradientLinear gradient;
3105a884b43bSJohn Scipione 	gradient.AddColor(bevelLeftColor, 0);
3106a884b43bSJohn Scipione 	gradient.AddColor(bevelBottomColor, 255);
3107a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
3108a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
3109a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
3110a884b43bSJohn Scipione 
3111a884b43bSJohn Scipione 	// gradient
3112a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
3113a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
3114a884b43bSJohn Scipione }
3115a884b43bSJohn Scipione 
3116a884b43bSJohn Scipione 
3117a884b43bSJohn Scipione void
3118a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightBottom(BView* view, BRect& cornerRect,
3119a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
3120a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
3121a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
3122a884b43bSJohn Scipione {
3123a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightBottom(view, cornerRect, updateRect,
3124a884b43bSJohn Scipione 		background, edgeColor, frameColor);
3125a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightBottom(view, cornerRect, updateRect,
3126a884b43bSJohn Scipione 		bevelColor, fillGradient);
3127a884b43bSJohn Scipione }
3128a884b43bSJohn Scipione 
3129a884b43bSJohn Scipione 
3130a884b43bSJohn Scipione void
3131a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect,
3132a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
3133a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
3134a884b43bSJohn Scipione {
3135a884b43bSJohn Scipione 	// constrain clipping region to corner
3136a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
3137a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
3138a884b43bSJohn Scipione 
3139a884b43bSJohn Scipione 	// background
3140a884b43bSJohn Scipione 	view->SetHighColor(background);
3141a884b43bSJohn Scipione 	view->FillRect(cornerRect);
3142a884b43bSJohn Scipione 
3143a884b43bSJohn Scipione 	// outer edge
3144a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
3145a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
3146a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
3147a884b43bSJohn Scipione 
3148a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
3149a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
3150a884b43bSJohn Scipione 
3151a884b43bSJohn Scipione 	// frame
3152a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
3153a884b43bSJohn Scipione 	cornerRect.right--;
3154a884b43bSJohn Scipione 	cornerRect.bottom++;
3155a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
3156a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
3157a884b43bSJohn Scipione 
3158a884b43bSJohn Scipione 	// prepare for bevel
3159a884b43bSJohn Scipione 	cornerRect.left++;
3160a884b43bSJohn Scipione 	cornerRect.bottom--;
3161a884b43bSJohn Scipione }
3162a884b43bSJohn Scipione 
3163a884b43bSJohn Scipione 
3164a884b43bSJohn Scipione void
3165a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightBottom(BView* view,
3166a884b43bSJohn Scipione 	BRect& cornerRect, const BRect& updateRect, const rgb_color& bevelColor,
3167a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
3168a884b43bSJohn Scipione {
3169a884b43bSJohn Scipione 	// constrain clipping region to corner
3170a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
3171a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
3172a884b43bSJohn Scipione 
3173a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
3174a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
3175a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
3176a884b43bSJohn Scipione 
3177a884b43bSJohn Scipione 	// bevel
3178a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
3179a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
3180a884b43bSJohn Scipione 
3181a884b43bSJohn Scipione 	// gradient
3182a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
3183a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
31842f86ba45SStephan Aßmus }
31852f86ba45SStephan Aßmus 
31862f86ba45SStephan Aßmus 
31872f86ba45SStephan Aßmus void
31882f86ba45SStephan Aßmus BControlLook::_DrawRoundBarCorner(BView* view, BRect& rect,
31892f86ba45SStephan Aßmus 	const BRect& updateRect,
31902f86ba45SStephan Aßmus 	const rgb_color& edgeLightColor, const rgb_color& edgeShadowColor,
31912f86ba45SStephan Aßmus 	const rgb_color& frameLightColor, const rgb_color& frameShadowColor,
31922f86ba45SStephan Aßmus 	const rgb_color& fillLightColor, const rgb_color& fillShadowColor,
31932f86ba45SStephan Aßmus 	float leftInset, float topInset, float rightInset, float bottomInset,
3194e724b26fSJohn Scipione 	orientation orientation)
31952f86ba45SStephan Aßmus {
31962f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
31972f86ba45SStephan Aßmus 		return;
31982f86ba45SStephan Aßmus 
31992f86ba45SStephan Aßmus 	BGradientLinear gradient;
32002f86ba45SStephan Aßmus 	gradient.AddColor(edgeShadowColor, 0);
32012f86ba45SStephan Aßmus 	gradient.AddColor(edgeLightColor, 255);
32022f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
32032f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
32042f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
32052f86ba45SStephan Aßmus 	else
32062f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
32072f86ba45SStephan Aßmus 
32082f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
32092f86ba45SStephan Aßmus 
32102f86ba45SStephan Aßmus 	rect.left += leftInset;
32112f86ba45SStephan Aßmus 	rect.top += topInset;
32122f86ba45SStephan Aßmus 	rect.right += rightInset;
32132f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
32142f86ba45SStephan Aßmus 
32152f86ba45SStephan Aßmus 	gradient.MakeEmpty();
32162f86ba45SStephan Aßmus 	gradient.AddColor(frameShadowColor, 0);
32172f86ba45SStephan Aßmus 	gradient.AddColor(frameLightColor, 255);
32182f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
32192f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
32202f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
32212f86ba45SStephan Aßmus 	else
32222f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
32232f86ba45SStephan Aßmus 
32242f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
32252f86ba45SStephan Aßmus 
32262f86ba45SStephan Aßmus 	rect.left += leftInset;
32272f86ba45SStephan Aßmus 	rect.top += topInset;
32282f86ba45SStephan Aßmus 	rect.right += rightInset;
32292f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
32302f86ba45SStephan Aßmus 
32312f86ba45SStephan Aßmus 	gradient.MakeEmpty();
32322f86ba45SStephan Aßmus 	gradient.AddColor(fillShadowColor, 0);
32332f86ba45SStephan Aßmus 	gradient.AddColor(fillLightColor, 255);
32342f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
32352f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
32362f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
32372f86ba45SStephan Aßmus 	else
32382f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
32392f86ba45SStephan Aßmus 
32402f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
32412f86ba45SStephan Aßmus }
32422f86ba45SStephan Aßmus 
32432f86ba45SStephan Aßmus 
3244a884b43bSJohn Scipione rgb_color
3245a884b43bSJohn Scipione BControlLook::_EdgeLightColor(const rgb_color& base, float contrast,
3246a884b43bSJohn Scipione 	float brightness, uint32 flags)
32472f86ba45SStephan Aßmus {
3248a884b43bSJohn Scipione 	rgb_color edgeLightColor;
32492f86ba45SStephan Aßmus 
3250a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
3251a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
325283864481SJérôme Duval 		uint8 white = uint8(255 * brightness);
32532f86ba45SStephan Aßmus 
3254a884b43bSJohn Scipione 		edgeLightColor = (rgb_color){ white, white, white, alpha };
32552f86ba45SStephan Aßmus 	} else {
3256a884b43bSJohn Scipione 		// colors
3257a884b43bSJohn Scipione 		float tintLight = kEdgeBevelLightTint;
3258a884b43bSJohn Scipione 
3259a884b43bSJohn Scipione 		if (contrast == 0.0)
3260a884b43bSJohn Scipione 			tintLight = B_NO_TINT;
3261a884b43bSJohn Scipione 		else if (contrast != 1.0)
3262a884b43bSJohn Scipione 			tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast;
3263a884b43bSJohn Scipione 
3264a884b43bSJohn Scipione 		edgeLightColor = tint_color(base, tintLight);
3265a884b43bSJohn Scipione 
3266a884b43bSJohn Scipione 		if (brightness < 1.0) {
3267a884b43bSJohn Scipione 			edgeLightColor.red = uint8(edgeLightColor.red * brightness);
3268a884b43bSJohn Scipione 			edgeLightColor.green = uint8(edgeLightColor.green * brightness);
3269a884b43bSJohn Scipione 			edgeLightColor.blue = uint8(edgeLightColor.blue * brightness);
3270a884b43bSJohn Scipione 		}
32712f86ba45SStephan Aßmus 	}
32722f86ba45SStephan Aßmus 
3273a884b43bSJohn Scipione 	return edgeLightColor;
3274a884b43bSJohn Scipione }
3275a884b43bSJohn Scipione 
3276a884b43bSJohn Scipione 
3277a884b43bSJohn Scipione rgb_color
3278a884b43bSJohn Scipione BControlLook::_EdgeShadowColor(const rgb_color& base, float contrast,
3279a884b43bSJohn Scipione 	float brightness, uint32 flags)
3280a884b43bSJohn Scipione {
3281a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
3282a884b43bSJohn Scipione 
3283a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
3284a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
3285a884b43bSJohn Scipione 		edgeShadowColor = (rgb_color){ 0, 0, 0, alpha };
3286a884b43bSJohn Scipione 	} else {
3287a884b43bSJohn Scipione 		float tintShadow = kEdgeBevelShadowTint;
3288a884b43bSJohn Scipione 
3289a884b43bSJohn Scipione 		if (contrast == 0.0)
3290a884b43bSJohn Scipione 			tintShadow = B_NO_TINT;
3291a884b43bSJohn Scipione 		else if (contrast != 1.0)
3292a884b43bSJohn Scipione 			tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast;
3293a884b43bSJohn Scipione 
3294a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, tintShadow);
3295a884b43bSJohn Scipione 
3296a884b43bSJohn Scipione 		if (brightness < 1.0) {
3297a884b43bSJohn Scipione 			edgeShadowColor.red = uint8(edgeShadowColor.red * brightness);
3298a884b43bSJohn Scipione 			edgeShadowColor.green = uint8(edgeShadowColor.green * brightness);
3299a884b43bSJohn Scipione 			edgeShadowColor.blue = uint8(edgeShadowColor.blue * brightness);
3300a884b43bSJohn Scipione 		}
3301a884b43bSJohn Scipione 	}
3302a884b43bSJohn Scipione 
3303a884b43bSJohn Scipione 	return edgeShadowColor;
3304a884b43bSJohn Scipione }
3305a884b43bSJohn Scipione 
3306a884b43bSJohn Scipione 
3307a884b43bSJohn Scipione rgb_color
3308a884b43bSJohn Scipione BControlLook::_FrameLightColor(const rgb_color& base, uint32 flags)
3309a884b43bSJohn Scipione {
3310a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
3311a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
3312a884b43bSJohn Scipione 
3313a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3314a884b43bSJohn Scipione 		return _FrameShadowColor(base, flags & ~B_ACTIVATED);
3315a884b43bSJohn Scipione 
3316a884b43bSJohn Scipione 	rgb_color frameLightColor;
3317a884b43bSJohn Scipione 
3318a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3319a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
3320a884b43bSJohn Scipione 		frameLightColor = tint_color(base, 1.145);
3321a884b43bSJohn Scipione 
3322a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3323a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.14);
3324a884b43bSJohn Scipione 	} else {
3325a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
3326a884b43bSJohn Scipione 			frameLightColor = (rgb_color){ 0, 0, 0, 75 };
3327a884b43bSJohn Scipione 		else
3328a884b43bSJohn Scipione 			frameLightColor = tint_color(base, 1.33);
3329a884b43bSJohn Scipione 
3330a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3331a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.35);
3332a884b43bSJohn Scipione 	}
3333a884b43bSJohn Scipione 
3334a884b43bSJohn Scipione 	return frameLightColor;
3335a884b43bSJohn Scipione }
3336a884b43bSJohn Scipione 
3337a884b43bSJohn Scipione 
3338a884b43bSJohn Scipione rgb_color
3339a884b43bSJohn Scipione BControlLook::_FrameShadowColor(const rgb_color& base, uint32 flags)
3340a884b43bSJohn Scipione {
3341a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
3342a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
3343a884b43bSJohn Scipione 
3344a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3345a884b43bSJohn Scipione 		return _FrameLightColor(base, flags & ~B_ACTIVATED);
3346a884b43bSJohn Scipione 
3347a884b43bSJohn Scipione 	rgb_color frameShadowColor;
3348a884b43bSJohn Scipione 
3349a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3350a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
3351a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.24);
3352a884b43bSJohn Scipione 
3353a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3354a884b43bSJohn Scipione 			frameShadowColor = tint_color(base, 1.145);
3355a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.12);
3356a884b43bSJohn Scipione 		}
3357a884b43bSJohn Scipione 	} else {
3358a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3359a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3360a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 75 };
3361a884b43bSJohn Scipione 			else
3362a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.33);
3363a884b43bSJohn Scipione 
3364a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.5);
3365a884b43bSJohn Scipione 		} else {
3366a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3367a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 95 };
3368a884b43bSJohn Scipione 			else
3369a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.47);
3370a884b43bSJohn Scipione 		}
3371a884b43bSJohn Scipione 	}
3372a884b43bSJohn Scipione 
3373a884b43bSJohn Scipione 	return frameShadowColor;
3374a884b43bSJohn Scipione }
3375a884b43bSJohn Scipione 
3376a884b43bSJohn Scipione 
3377a884b43bSJohn Scipione rgb_color
3378a884b43bSJohn Scipione BControlLook::_BevelLightColor(const rgb_color& base, uint32 flags)
3379a884b43bSJohn Scipione {
3380a884b43bSJohn Scipione 	rgb_color bevelLightColor = tint_color(base, 0.2);
3381a884b43bSJohn Scipione 
3382a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3383a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_LIGHTEN_1_TINT);
3384a884b43bSJohn Scipione 
3385a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3386a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_DARKEN_1_TINT);
3387a884b43bSJohn Scipione 
3388a884b43bSJohn Scipione 	return bevelLightColor;
3389a884b43bSJohn Scipione }
3390a884b43bSJohn Scipione 
3391a884b43bSJohn Scipione 
3392a884b43bSJohn Scipione rgb_color
3393a884b43bSJohn Scipione BControlLook::_BevelShadowColor(const rgb_color& base, uint32 flags)
3394a884b43bSJohn Scipione {
3395a884b43bSJohn Scipione 	rgb_color bevelShadowColor = tint_color(base, 1.08);
3396a884b43bSJohn Scipione 
3397a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3398a884b43bSJohn Scipione 		bevelShadowColor = base;
3399a884b43bSJohn Scipione 
3400a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3401a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, B_DARKEN_1_TINT);
3402a884b43bSJohn Scipione 
3403a884b43bSJohn Scipione 	return bevelShadowColor;
3404a884b43bSJohn Scipione }
3405a884b43bSJohn Scipione 
3406a884b43bSJohn Scipione 
3407a884b43bSJohn Scipione void
3408a884b43bSJohn Scipione BControlLook::_FillGradient(BView* view, const BRect& rect,
3409a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3410e724b26fSJohn Scipione 	orientation orientation)
3411a884b43bSJohn Scipione {
3412a884b43bSJohn Scipione 	BGradientLinear gradient;
3413a884b43bSJohn Scipione 	_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3414a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3415a884b43bSJohn Scipione }
3416a884b43bSJohn Scipione 
3417a884b43bSJohn Scipione 
3418a884b43bSJohn Scipione void
3419a884b43bSJohn Scipione BControlLook::_FillGlossyGradient(BView* view, const BRect& rect,
3420a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3421e724b26fSJohn Scipione 	float middle2Tint, float bottomTint, orientation orientation)
3422a884b43bSJohn Scipione {
3423a884b43bSJohn Scipione 	BGradientLinear gradient;
3424a884b43bSJohn Scipione 	_MakeGlossyGradient(gradient, rect, base, topTint, middle1Tint,
3425a884b43bSJohn Scipione 		middle2Tint, bottomTint, orientation);
3426a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3427a884b43bSJohn Scipione }
3428a884b43bSJohn Scipione 
3429a884b43bSJohn Scipione 
3430a884b43bSJohn Scipione void
3431a884b43bSJohn Scipione BControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect,
3432a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3433e724b26fSJohn Scipione 	orientation orientation) const
3434a884b43bSJohn Scipione {
3435a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3436a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
34372f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
3438a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3439a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3440a884b43bSJohn Scipione 	else
3441a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3442a884b43bSJohn Scipione }
34432f86ba45SStephan Aßmus 
34442f86ba45SStephan Aßmus 
3445a884b43bSJohn Scipione void
3446a884b43bSJohn Scipione BControlLook::_MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect,
3447a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3448a884b43bSJohn Scipione 	float middle2Tint, float bottomTint,
3449e724b26fSJohn Scipione 	orientation orientation) const
3450a884b43bSJohn Scipione {
3451a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3452a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle1Tint), 132);
3453a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle2Tint), 136);
3454a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
3455a884b43bSJohn Scipione 	gradient.SetStart(rect.LeftTop());
3456a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3457a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3458a884b43bSJohn Scipione 	else
3459a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3460a884b43bSJohn Scipione }
3461a884b43bSJohn Scipione 
3462a884b43bSJohn Scipione 
3463a884b43bSJohn Scipione void
3464a884b43bSJohn Scipione BControlLook::_MakeButtonGradient(BGradientLinear& gradient, BRect& rect,
3465e724b26fSJohn Scipione 	const rgb_color& base, uint32 flags, orientation orientation) const
3466a884b43bSJohn Scipione {
3467a884b43bSJohn Scipione 	float topTint = 0.49;
3468a884b43bSJohn Scipione 	float middleTint1 = 0.62;
3469a884b43bSJohn Scipione 	float middleTint2 = 0.76;
3470a884b43bSJohn Scipione 	float bottomTint = 0.90;
3471a884b43bSJohn Scipione 
3472a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3473a884b43bSJohn Scipione 		topTint = 1.11;
3474a884b43bSJohn Scipione 		bottomTint = 1.08;
3475a884b43bSJohn Scipione 	}
3476a884b43bSJohn Scipione 
3477a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3478a884b43bSJohn Scipione 		topTint = (topTint + B_NO_TINT) / 2;
3479a884b43bSJohn Scipione 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
3480a884b43bSJohn Scipione 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
3481a884b43bSJohn Scipione 		bottomTint = (bottomTint + B_NO_TINT) / 2;
3482a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
3483a884b43bSJohn Scipione 		topTint *= kHoverTintFactor;
3484a884b43bSJohn Scipione 		middleTint1 *= kHoverTintFactor;
3485a884b43bSJohn Scipione 		middleTint2 *= kHoverTintFactor;
3486a884b43bSJohn Scipione 		bottomTint *= kHoverTintFactor;
3487a884b43bSJohn Scipione 	}
3488a884b43bSJohn Scipione 
3489a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3490a884b43bSJohn Scipione 		_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3491a884b43bSJohn Scipione 	} else {
3492a884b43bSJohn Scipione 		_MakeGlossyGradient(gradient, rect, base, topTint, middleTint1,
3493a884b43bSJohn Scipione 			middleTint2, bottomTint, orientation);
3494a884b43bSJohn Scipione 	}
3495a884b43bSJohn Scipione }
3496a884b43bSJohn Scipione 
3497a884b43bSJohn Scipione 
3498a884b43bSJohn Scipione 
3499a884b43bSJohn Scipione bool
3500a884b43bSJohn Scipione BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,
3501a884b43bSJohn Scipione 	rgb_color& color, uint32 flags) const
3502a884b43bSJohn Scipione {
3503df37cd4eSIngo Weinhold 	if ((flags & (B_ACTIVATED | B_PARTIALLY_ACTIVATED | B_CLICKED)) == 0) {
3504a884b43bSJohn Scipione 		// no mark to be drawn at all
3505a884b43bSJohn Scipione 		return false;
3506a884b43bSJohn Scipione 	}
3507a884b43bSJohn Scipione 
35084bb5af76SJohn Scipione 	color = ui_color(B_CONTROL_MARK_COLOR);
3509a884b43bSJohn Scipione 
3510a884b43bSJohn Scipione 	float mix = 1.0;
3511a884b43bSJohn Scipione 
3512a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3513a884b43bSJohn Scipione 		// activated, but disabled
3514a884b43bSJohn Scipione 		mix = 0.4;
3515a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
3516a884b43bSJohn Scipione 		if ((flags & B_ACTIVATED) != 0) {
3517df37cd4eSIngo Weinhold 			// losing activation
3518a884b43bSJohn Scipione 			mix = 0.7;
3519a884b43bSJohn Scipione 		} else {
3520df37cd4eSIngo Weinhold 			// becoming activated (or losing partial activation)
3521a884b43bSJohn Scipione 			mix = 0.3;
3522a884b43bSJohn Scipione 		}
3523df37cd4eSIngo Weinhold 	} else if ((flags & B_PARTIALLY_ACTIVATED) != 0) {
3524df37cd4eSIngo Weinhold 		// partially activated
3525df37cd4eSIngo Weinhold 		mix = 0.5;
3526a884b43bSJohn Scipione 	} else {
3527a884b43bSJohn Scipione 		// simply activated
3528a884b43bSJohn Scipione 	}
3529a884b43bSJohn Scipione 
3530a884b43bSJohn Scipione 	color.red = uint8(color.red * mix + base.red * (1.0 - mix));
3531a884b43bSJohn Scipione 	color.green = uint8(color.green * mix + base.green * (1.0 - mix));
3532a884b43bSJohn Scipione 	color.blue = uint8(color.blue * mix + base.blue * (1.0 - mix));
3533a884b43bSJohn Scipione 
3534a884b43bSJohn Scipione 	return true;
35352f86ba45SStephan Aßmus }
35362f86ba45SStephan Aßmus 
35372f86ba45SStephan Aßmus 
35382f86ba45SStephan Aßmus // NOTE: May come from a add-on in the future. Initialized in
35392f86ba45SStephan Aßmus // InterfaceDefs.cpp
35402f86ba45SStephan Aßmus BControlLook* be_control_look = NULL;
35412f86ba45SStephan Aßmus 
3542a884b43bSJohn Scipione 
35432f86ba45SStephan Aßmus } // namespace BPrivate
3544