xref: /haiku/src/kits/interface/ControlLook.cpp (revision 8719e0dc4bf8495cd70c2dc3d25a5165f7ea3d16)
12f86ba45SStephan Aßmus /*
22f86ba45SStephan Aßmus  * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3a884b43bSJohn Scipione  * Copyright 2012, Haiku Inc. All rights reserved.
42f86ba45SStephan Aßmus  * Distributed under the terms of the MIT License.
5a884b43bSJohn Scipione  *
6a884b43bSJohn Scipione  * Authors:
7a884b43bSJohn Scipione  *		John Scipione <jscipione@gmail.com>
82f86ba45SStephan Aßmus  */
9d452ff66SAxel Dörfler 
10d452ff66SAxel Dörfler 
112f86ba45SStephan Aßmus #include <ControlLook.h>
122f86ba45SStephan Aßmus 
132f86ba45SStephan Aßmus #include <Control.h>
142f86ba45SStephan Aßmus #include <GradientLinear.h>
152f86ba45SStephan Aßmus #include <Region.h>
162f86ba45SStephan Aßmus #include <Shape.h>
172f86ba45SStephan Aßmus #include <String.h>
182f86ba45SStephan Aßmus #include <View.h>
19d63b75faSPhilippe Saint-Pierre #include <Window.h>
202f86ba45SStephan Aßmus 
21a884b43bSJohn Scipione #include "ContainerWindow.h"
22a884b43bSJohn Scipione 
23a884b43bSJohn Scipione 
242f86ba45SStephan Aßmus namespace BPrivate {
252f86ba45SStephan Aßmus 
26a884b43bSJohn Scipione 
272f86ba45SStephan Aßmus static const float kEdgeBevelLightTint = 0.59;
282f86ba45SStephan Aßmus static const float kEdgeBevelShadowTint = 1.0735;
292f86ba45SStephan Aßmus 
302f86ba45SStephan Aßmus 
31d63b75faSPhilippe Saint-Pierre BControlLook::BControlLook():
32d63b75faSPhilippe Saint-Pierre 	fCachedOutline(false),
33d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace(-1)
342f86ba45SStephan Aßmus {
352f86ba45SStephan Aßmus }
362f86ba45SStephan Aßmus 
372f86ba45SStephan Aßmus 
382f86ba45SStephan Aßmus BControlLook::~BControlLook()
392f86ba45SStephan Aßmus {
402f86ba45SStephan Aßmus }
412f86ba45SStephan Aßmus 
422f86ba45SStephan Aßmus 
432f86ba45SStephan Aßmus BAlignment
442f86ba45SStephan Aßmus BControlLook::DefaultLabelAlignment() const
452f86ba45SStephan Aßmus {
462f86ba45SStephan Aßmus 	return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
472f86ba45SStephan Aßmus }
482f86ba45SStephan Aßmus 
492f86ba45SStephan Aßmus 
502f86ba45SStephan Aßmus float
512f86ba45SStephan Aßmus BControlLook::DefaultLabelSpacing() const
522f86ba45SStephan Aßmus {
5320a11271SAxel Dörfler 	return ceilf(be_plain_font->Size() / 2.0);
5420a11271SAxel Dörfler }
5520a11271SAxel Dörfler 
5620a11271SAxel Dörfler 
5720a11271SAxel Dörfler float
5820a11271SAxel Dörfler BControlLook::DefaultItemSpacing() const
5920a11271SAxel Dörfler {
6020a11271SAxel Dörfler 	return ceilf(be_plain_font->Size() * 0.85);
612f86ba45SStephan Aßmus }
622f86ba45SStephan Aßmus 
632f86ba45SStephan Aßmus 
6482ab3167SAlex Wilson float
656648dd3cSAlex Wilson BControlLook::ComposeSpacing(float spacing)
6682ab3167SAlex Wilson {
67d90a465eSAlex Wilson 	if (spacing == B_USE_DEFAULT_SPACING || spacing == B_USE_ITEM_SPACING) {
6882ab3167SAlex Wilson 		return be_control_look->DefaultItemSpacing();
696648dd3cSAlex Wilson 	} else if (spacing == B_USE_HALF_ITEM_SPACING) {
70a8b89c6bSStephan Aßmus 		return ceilf(be_control_look->DefaultItemSpacing() * 0.5f);
716648dd3cSAlex Wilson 	} else if (spacing == B_USE_WINDOW_INSETS) {
726648dd3cSAlex Wilson 		return be_control_look->DefaultItemSpacing();
736648dd3cSAlex Wilson 	} else if (spacing == B_USE_SMALL_SPACING) {
74a8b89c6bSStephan Aßmus 		return ceilf(be_control_look->DefaultItemSpacing() * 0.7f);
756648dd3cSAlex Wilson 	} else if (spacing == B_USE_BIG_SPACING) {
76a8b89c6bSStephan Aßmus 		return ceilf(be_control_look->DefaultItemSpacing() * 1.3f);
776648dd3cSAlex Wilson 	}
786648dd3cSAlex Wilson 	return spacing;
7982ab3167SAlex Wilson }
8082ab3167SAlex Wilson 
8182ab3167SAlex Wilson 
822f86ba45SStephan Aßmus uint32
832f86ba45SStephan Aßmus BControlLook::Flags(BControl* control) const
842f86ba45SStephan Aßmus {
852f86ba45SStephan Aßmus 	uint32 flags = 0;
862f86ba45SStephan Aßmus 
872f86ba45SStephan Aßmus 	if (!control->IsEnabled())
882f86ba45SStephan Aßmus 		flags |= B_DISABLED;
892f86ba45SStephan Aßmus 
90d38ba8f7SJohn Scipione 	if (control->IsFocus() && control->Window() != NULL
91d38ba8f7SJohn Scipione 		&& control->Window()->IsActive()) {
922f86ba45SStephan Aßmus 		flags |= B_FOCUSED;
9359655dcbSJohn Scipione 	}
942f86ba45SStephan Aßmus 
95df37cd4eSIngo Weinhold 	switch (control->Value()) {
96df37cd4eSIngo Weinhold 		case B_CONTROL_ON:
972f86ba45SStephan Aßmus 			flags |= B_ACTIVATED;
98df37cd4eSIngo Weinhold 			break;
99df37cd4eSIngo Weinhold 		case B_CONTROL_PARTIALLY_ON:
100df37cd4eSIngo Weinhold 			flags |= B_PARTIALLY_ACTIVATED;
101df37cd4eSIngo Weinhold 			break;
102df37cd4eSIngo Weinhold 	}
1032f86ba45SStephan Aßmus 
10461ac1a85SStephan Aßmus 	if (control->Parent() != NULL
10561ac1a85SStephan Aßmus 		&& (control->Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
10661ac1a85SStephan Aßmus 		// In this constellation, assume we want to render the control
10761ac1a85SStephan Aßmus 		// against the already existing view contents of the parent view.
10861ac1a85SStephan Aßmus 		flags |= B_BLEND_FRAME;
10961ac1a85SStephan Aßmus 	}
11061ac1a85SStephan Aßmus 
1112f86ba45SStephan Aßmus 	return flags;
1122f86ba45SStephan Aßmus }
1132f86ba45SStephan Aßmus 
1142f86ba45SStephan Aßmus 
1152f86ba45SStephan Aßmus // #pragma mark -
1162f86ba45SStephan Aßmus 
1172f86ba45SStephan Aßmus 
1182f86ba45SStephan Aßmus void
1192f86ba45SStephan Aßmus BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
120681c2e44SStephan Aßmus 	const rgb_color& base, const rgb_color& background, uint32 flags,
121681c2e44SStephan Aßmus 	uint32 borders)
1222f86ba45SStephan Aßmus {
123a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
124a884b43bSJohn Scipione 		background, 1.0, 1.0, flags, borders);
125a884b43bSJohn Scipione }
126a884b43bSJohn Scipione 
127a884b43bSJohn Scipione 
128a884b43bSJohn Scipione void
129a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
130a884b43bSJohn Scipione 	float radius, const rgb_color& base, const rgb_color& background, uint32 flags,
131a884b43bSJohn Scipione 	uint32 borders)
132a884b43bSJohn Scipione {
133a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
134a884b43bSJohn Scipione 		base, background, 1.0, 1.0, flags, borders);
135a884b43bSJohn Scipione }
136a884b43bSJohn Scipione 
137a884b43bSJohn Scipione 
138a884b43bSJohn Scipione void
139a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect,
140a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
141a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
142a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags,
143a884b43bSJohn Scipione 	uint32 borders)
144a884b43bSJohn Scipione {
145a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
146a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background,
147a884b43bSJohn Scipione 		1.0, 1.0, flags, borders);
1482f86ba45SStephan Aßmus }
1492f86ba45SStephan Aßmus 
1502f86ba45SStephan Aßmus 
1512f86ba45SStephan Aßmus void
1522f86ba45SStephan Aßmus BControlLook::DrawButtonBackground(BView* view, BRect& rect,
1532f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
154e724b26fSJohn Scipione 	uint32 borders, orientation orientation)
1552f86ba45SStephan Aßmus {
156a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f,
157a884b43bSJohn Scipione 		base, flags, borders, orientation);
1582f86ba45SStephan Aßmus }
1592f86ba45SStephan Aßmus 
1602f86ba45SStephan Aßmus 
161a884b43bSJohn Scipione void
162a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect,
163a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base, uint32 flags,
164e724b26fSJohn Scipione 	uint32 borders, orientation orientation)
165a884b43bSJohn Scipione {
166a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, radius, radius, radius,
167a884b43bSJohn Scipione 		radius, base, 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 leftTopRadius, float rightTopRadius,
174a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
175e724b26fSJohn Scipione 	uint32 flags, uint32 borders, orientation orientation)
176a884b43bSJohn Scipione {
177a884b43bSJohn Scipione 	_DrawButtonBackground(view, rect, updateRect, leftTopRadius,
178a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags,
179a884b43bSJohn Scipione 		borders, orientation);
1802f86ba45SStephan Aßmus }
1812f86ba45SStephan Aßmus 
1822f86ba45SStephan Aßmus 
1832f86ba45SStephan Aßmus void
1842f86ba45SStephan Aßmus BControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
1851a72cb41SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
1861a72cb41SStephan Aßmus 	uint32 borders)
1872f86ba45SStephan Aßmus {
188a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1892f86ba45SStephan Aßmus 		return;
1902f86ba45SStephan Aßmus 
1912f86ba45SStephan Aßmus 	// the surface edges
1922f86ba45SStephan Aßmus 
1932f86ba45SStephan Aßmus 	// colors
1941a72cb41SStephan Aßmus 	float topTint;
1951a72cb41SStephan Aßmus 	float bottomTint;
1961a72cb41SStephan Aßmus 
197a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
1981a72cb41SStephan Aßmus 		rgb_color bevelColor1 = tint_color(base, 1.40);
1991a72cb41SStephan Aßmus 		rgb_color bevelColor2 = tint_color(base, 1.25);
2001a72cb41SStephan Aßmus 
2011a72cb41SStephan Aßmus 		topTint = 1.25;
2021a72cb41SStephan Aßmus 		bottomTint = 1.20;
2032f86ba45SStephan Aßmus 
2042f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
2051a72cb41SStephan Aßmus 			bevelColor1, bevelColor1,
2061a72cb41SStephan Aßmus 			bevelColor2, bevelColor2,
2071a72cb41SStephan Aßmus 			borders & B_TOP_BORDER);
2081a72cb41SStephan Aßmus 	} else {
2091a72cb41SStephan Aßmus 		rgb_color cornerColor = tint_color(base, 0.9);
2101a72cb41SStephan Aßmus 		rgb_color bevelColorTop = tint_color(base, 0.5);
2111a72cb41SStephan Aßmus 		rgb_color bevelColorLeft = tint_color(base, 0.7);
2121a72cb41SStephan Aßmus 		rgb_color bevelColorRightBottom = tint_color(base, 1.08);
2131a72cb41SStephan Aßmus 
2141a72cb41SStephan Aßmus 		topTint = 0.69;
2151a72cb41SStephan Aßmus 		bottomTint = 1.03;
2161a72cb41SStephan Aßmus 
2171a72cb41SStephan Aßmus 		_DrawFrame(view, rect,
2181a72cb41SStephan Aßmus 			bevelColorLeft, bevelColorTop,
2191a72cb41SStephan Aßmus 			bevelColorRightBottom, bevelColorRightBottom,
2202f86ba45SStephan Aßmus 			cornerColor, cornerColor,
2212f86ba45SStephan Aßmus 			borders);
2221a72cb41SStephan Aßmus 	}
2232f86ba45SStephan Aßmus 
224a884b43bSJohn Scipione 	// draw surface top
2252f86ba45SStephan Aßmus 	_FillGradient(view, rect, base, topTint, bottomTint);
2262f86ba45SStephan Aßmus }
2272f86ba45SStephan Aßmus 
2282f86ba45SStephan Aßmus 
2292f86ba45SStephan Aßmus void
230681c2e44SStephan Aßmus BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
231681c2e44SStephan Aßmus 	const BRect& updateRect, const rgb_color& base,
232681c2e44SStephan Aßmus 	const rgb_color& background, uint32 flags, uint32 borders)
23313cd46dfSStephan Aßmus {
234a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base,
235a884b43bSJohn Scipione 		background, 0.6, 1.0, flags, borders);
236a884b43bSJohn Scipione }
237a884b43bSJohn Scipione 
238a884b43bSJohn Scipione 
239a884b43bSJohn Scipione void
240a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
241a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
242a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
243a884b43bSJohn Scipione {
244a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius,
245a884b43bSJohn Scipione 		base, 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 leftTopRadius,
252a884b43bSJohn Scipione 	float rightTopRadius, float leftBottomRadius,
253a884b43bSJohn Scipione 	float rightBottomRadius, const rgb_color& base,
254a884b43bSJohn Scipione 	const rgb_color& background, uint32 flags, uint32 borders)
255a884b43bSJohn Scipione {
256a884b43bSJohn Scipione 	_DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius,
257a884b43bSJohn Scipione 		leftBottomRadius, rightBottomRadius, base, background, 0.6, 1.0,
258a884b43bSJohn Scipione 		flags, borders);
25913cd46dfSStephan Aßmus }
26013cd46dfSStephan Aßmus 
26113cd46dfSStephan Aßmus 
26213cd46dfSStephan Aßmus void
2632f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
2642f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, bool popupIndicator,
2652f86ba45SStephan Aßmus 	uint32 flags)
2662f86ba45SStephan Aßmus {
267a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect,
268a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, popupIndicator, flags);
2692f86ba45SStephan Aßmus }
2702f86ba45SStephan Aßmus 
2712f86ba45SStephan Aßmus 
2722f86ba45SStephan Aßmus void
2732f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
2742f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
2752f86ba45SStephan Aßmus 	uint32 borders)
2762f86ba45SStephan Aßmus {
277a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundInside(view, rect, updateRect,
278a884b43bSJohn Scipione 		0.0f, 0.0f, 0.0f, 0.0f, base, flags, borders);
2792f86ba45SStephan Aßmus }
2802f86ba45SStephan Aßmus 
2812f86ba45SStephan Aßmus 
282a884b43bSJohn Scipione void
283a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
284a884b43bSJohn Scipione 	const BRect& updateRect, float radius, const rgb_color& base,
285a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
286a884b43bSJohn Scipione {
287a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, radius, radius,
288a884b43bSJohn Scipione 		radius, radius, base, popupIndicator, flags);
2892f86ba45SStephan Aßmus }
2902f86ba45SStephan Aßmus 
291a884b43bSJohn Scipione 
292a884b43bSJohn Scipione void
293a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
294a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
295a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
296a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
297a884b43bSJohn Scipione {
298a884b43bSJohn Scipione 	_DrawMenuFieldBackgroundOutside(view, rect, updateRect, leftTopRadius,
299a884b43bSJohn Scipione 		rightTopRadius, leftBottomRadius, rightBottomRadius, base,
300a884b43bSJohn Scipione 		popupIndicator, flags);
3012f86ba45SStephan Aßmus }
3022f86ba45SStephan Aßmus 
303a884b43bSJohn Scipione 
3042f86ba45SStephan Aßmus void
3052f86ba45SStephan Aßmus BControlLook::DrawMenuBackground(BView* view, BRect& rect,
3062f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
3072f86ba45SStephan Aßmus 	uint32 borders)
3082f86ba45SStephan Aßmus {
309a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3102f86ba45SStephan Aßmus 		return;
3112f86ba45SStephan Aßmus 
312a884b43bSJohn Scipione 	// surface top color
3132f86ba45SStephan Aßmus 	rgb_color background = tint_color(base, 0.75);
3142f86ba45SStephan Aßmus 
315a884b43bSJohn Scipione 	// inner bevel colors
316a884b43bSJohn Scipione 	rgb_color bevelLightColor;
317a884b43bSJohn Scipione 	rgb_color bevelShadowColor;
318a884b43bSJohn Scipione 
319a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3202f86ba45SStephan Aßmus 		bevelLightColor = tint_color(background, 0.80);
3212f86ba45SStephan Aßmus 		bevelShadowColor = tint_color(background, 1.07);
3222f86ba45SStephan Aßmus 	} else {
3232f86ba45SStephan Aßmus 		bevelLightColor = tint_color(background, 0.6);
3242f86ba45SStephan Aßmus 		bevelShadowColor = tint_color(background, 1.12);
3252f86ba45SStephan Aßmus 	}
3262f86ba45SStephan Aßmus 
327a884b43bSJohn Scipione 	// draw inner bevel
3282f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3292f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3302f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3312f86ba45SStephan Aßmus 		borders);
3322f86ba45SStephan Aßmus 
333a884b43bSJohn Scipione 	// draw surface top
3342f86ba45SStephan Aßmus 	view->SetHighColor(background);
3352f86ba45SStephan Aßmus 	view->FillRect(rect);
3362f86ba45SStephan Aßmus }
3372f86ba45SStephan Aßmus 
3382f86ba45SStephan Aßmus 
3392f86ba45SStephan Aßmus void
3402f86ba45SStephan Aßmus BControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
3412f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
3422f86ba45SStephan Aßmus 	uint32 borders)
3432f86ba45SStephan Aßmus {
344a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
3452f86ba45SStephan Aßmus 		return;
3462f86ba45SStephan Aßmus 
347a884b43bSJohn Scipione 	// surface edges
3482f86ba45SStephan Aßmus 	float topTint;
3492f86ba45SStephan Aßmus 	float bottomTint;
3502f86ba45SStephan Aßmus 	rgb_color selectedColor = base;
3512f86ba45SStephan Aßmus 
352a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3532f86ba45SStephan Aßmus 		topTint = 0.9;
3542f86ba45SStephan Aßmus 		bottomTint = 1.05;
355a884b43bSJohn Scipione 	} else if ((flags & B_DISABLED) != 0) {
3562f86ba45SStephan Aßmus 		topTint = 0.80;
3572f86ba45SStephan Aßmus 		bottomTint = 1.07;
3582f86ba45SStephan Aßmus 	} else {
3592f86ba45SStephan Aßmus 		topTint = 0.6;
3602f86ba45SStephan Aßmus 		bottomTint = 1.12;
3612f86ba45SStephan Aßmus 	}
3622f86ba45SStephan Aßmus 
3632f86ba45SStephan Aßmus 	rgb_color bevelLightColor = tint_color(selectedColor, topTint);
3642f86ba45SStephan Aßmus 	rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint);
3652f86ba45SStephan Aßmus 
366a884b43bSJohn Scipione 	// draw surface edges
3672f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
3682f86ba45SStephan Aßmus 		bevelLightColor, bevelLightColor,
3692f86ba45SStephan Aßmus 		bevelShadowColor, bevelShadowColor,
3702f86ba45SStephan Aßmus 		borders);
3712f86ba45SStephan Aßmus 
372a884b43bSJohn Scipione 	// draw surface top
3732f86ba45SStephan Aßmus 	view->SetLowColor(selectedColor);
3742f86ba45SStephan Aßmus //	_FillGradient(view, rect, selectedColor, topTint, bottomTint);
3752f86ba45SStephan Aßmus 	_FillGradient(view, rect, selectedColor, bottomTint, topTint);
3762f86ba45SStephan Aßmus }
3772f86ba45SStephan Aßmus 
3782f86ba45SStephan Aßmus 
3792f86ba45SStephan Aßmus void
3802f86ba45SStephan Aßmus BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect,
3812f86ba45SStephan Aßmus 	const rgb_color& base, const rgb_color& barColor, float progressPosition)
3822f86ba45SStephan Aßmus {
3832f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
3842f86ba45SStephan Aßmus 		return;
3852f86ba45SStephan Aßmus 
3862f86ba45SStephan Aßmus 	_DrawOuterResessedFrame(view, rect, base, 0.6);
3872f86ba45SStephan Aßmus 
3882f86ba45SStephan Aßmus 	// colors
3892f86ba45SStephan Aßmus 	rgb_color dark1BorderColor = tint_color(base, 1.3);
3902f86ba45SStephan Aßmus 	rgb_color dark2BorderColor = tint_color(base, 1.2);
3912f86ba45SStephan Aßmus 	rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
3922f86ba45SStephan Aßmus 	rgb_color dark2FilledBorderColor = tint_color(barColor, 1.45);
3932f86ba45SStephan Aßmus 
3942f86ba45SStephan Aßmus 	BRect filledRect(rect);
3952f86ba45SStephan Aßmus 	filledRect.right = progressPosition - 1;
3962f86ba45SStephan Aßmus 
3972f86ba45SStephan Aßmus 	BRect nonfilledRect(rect);
3982f86ba45SStephan Aßmus 	nonfilledRect.left = progressPosition;
3992f86ba45SStephan Aßmus 
4002f86ba45SStephan Aßmus 	bool filledSurface = filledRect.Width() > 0;
4012f86ba45SStephan Aßmus 	bool nonfilledSurface = nonfilledRect.Width() > 0;
4022f86ba45SStephan Aßmus 
4032f86ba45SStephan Aßmus 	if (filledSurface) {
4042f86ba45SStephan Aßmus 		_DrawFrame(view, filledRect,
4052f86ba45SStephan Aßmus 			dark1FilledBorderColor, dark1FilledBorderColor,
4062f86ba45SStephan Aßmus 			dark2FilledBorderColor, dark2FilledBorderColor);
4072f86ba45SStephan Aßmus 
4082f86ba45SStephan Aßmus 		_FillGlossyGradient(view, filledRect, barColor, 0.55, 0.68, 0.76, 0.90);
4092f86ba45SStephan Aßmus 	}
4102f86ba45SStephan Aßmus 
4112f86ba45SStephan Aßmus 	if (nonfilledSurface) {
4122f86ba45SStephan Aßmus 		_DrawFrame(view, nonfilledRect, dark1BorderColor, dark1BorderColor,
4132f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor,
4142f86ba45SStephan Aßmus 			B_TOP_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
4152f86ba45SStephan Aßmus 
4162f86ba45SStephan Aßmus 		if (nonfilledRect.left < nonfilledRect.right) {
4172f86ba45SStephan Aßmus 			// shadow from fill bar, or left border
4182f86ba45SStephan Aßmus 			rgb_color leftBorder = dark1BorderColor;
4192f86ba45SStephan Aßmus 			if (filledSurface)
4202f86ba45SStephan Aßmus 				leftBorder = tint_color(base, 0.50);
4212f86ba45SStephan Aßmus 			view->SetHighColor(leftBorder);
4222f86ba45SStephan Aßmus 			view->StrokeLine(nonfilledRect.LeftTop(),
4232f86ba45SStephan Aßmus 				nonfilledRect.LeftBottom());
4242f86ba45SStephan Aßmus 			nonfilledRect.left++;
4252f86ba45SStephan Aßmus 		}
4262f86ba45SStephan Aßmus 
4272f86ba45SStephan Aßmus 		_FillGradient(view, nonfilledRect, base, 0.25, 0.06);
4282f86ba45SStephan Aßmus 	}
4292f86ba45SStephan Aßmus }
4302f86ba45SStephan Aßmus 
4312f86ba45SStephan Aßmus 
4322f86ba45SStephan Aßmus void
4332f86ba45SStephan Aßmus BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect,
4342f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4352f86ba45SStephan Aßmus {
4362f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4372f86ba45SStephan Aßmus 		return;
4382f86ba45SStephan Aßmus 
4392f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
4402f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
4412f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
4422f86ba45SStephan Aßmus 
443a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4444f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags);
4452f86ba45SStephan Aßmus 
4462f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.15);
4472f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.15);
448a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
4492f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
4502f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.48);
4512f86ba45SStephan Aßmus 
4522f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
4532f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
4542f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
4552f86ba45SStephan Aßmus 
4562f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
4572f86ba45SStephan Aßmus 	} else {
4584f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags);
4592f86ba45SStephan Aßmus 
4602f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.40);
4612f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.38);
4622f86ba45SStephan Aßmus 	}
4632f86ba45SStephan Aßmus 
464a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
4652f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
4662f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
4672f86ba45SStephan Aßmus 	}
4682f86ba45SStephan Aßmus 
4692f86ba45SStephan Aßmus 	_DrawFrame(view, rect,
4702f86ba45SStephan Aßmus 		dark1BorderColor, dark1BorderColor,
4712f86ba45SStephan Aßmus 		dark2BorderColor, dark2BorderColor);
4722f86ba45SStephan Aßmus 
473a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
4742f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.4, 0.2);
4752f86ba45SStephan Aßmus 	} else {
4762f86ba45SStephan Aßmus 		_FillGradient(view, rect, base, 0.15, 0.0);
4772f86ba45SStephan Aßmus 	}
4782f86ba45SStephan Aßmus 
4792f86ba45SStephan Aßmus 	rgb_color markColor;
4802f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
4812f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
4822f86ba45SStephan Aßmus 
4832f86ba45SStephan Aßmus 		rect.InsetBy(2, 2);
4842f86ba45SStephan Aßmus 		view->SetPenSize(max_c(1.0, ceilf(rect.Width() / 3.5)));
4852f86ba45SStephan Aßmus 		view->SetDrawingMode(B_OP_OVER);
4862f86ba45SStephan Aßmus 
4872f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightBottom());
4882f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightTop());
4892f86ba45SStephan Aßmus 	}
4902f86ba45SStephan Aßmus }
4912f86ba45SStephan Aßmus 
4922f86ba45SStephan Aßmus 
4932f86ba45SStephan Aßmus void
4942f86ba45SStephan Aßmus BControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect,
4952f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags)
4962f86ba45SStephan Aßmus {
4972f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
4982f86ba45SStephan Aßmus 		return;
4992f86ba45SStephan Aßmus 
5002f86ba45SStephan Aßmus 	rgb_color borderColor;
5012f86ba45SStephan Aßmus 	rgb_color bevelLight;
5022f86ba45SStephan Aßmus 	rgb_color bevelShadow;
5032f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
5042f86ba45SStephan Aßmus 
505a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5062f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.15);
5072f86ba45SStephan Aßmus 		bevelLight = base;
5082f86ba45SStephan Aßmus 		bevelShadow = base;
509a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
5102f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.50);
5112f86ba45SStephan Aßmus 		bevelLight = borderColor;
5122f86ba45SStephan Aßmus 		bevelShadow = borderColor;
5132f86ba45SStephan Aßmus 	} else {
5142f86ba45SStephan Aßmus 		borderColor = tint_color(base, 1.45);
5152f86ba45SStephan Aßmus 		bevelLight = tint_color(base, 0.55);
5162f86ba45SStephan Aßmus 		bevelShadow = tint_color(base, 1.11);
5172f86ba45SStephan Aßmus 	}
5182f86ba45SStephan Aßmus 
519a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
5202f86ba45SStephan Aßmus 		borderColor = navigationColor;
5212f86ba45SStephan Aßmus 	}
5222f86ba45SStephan Aßmus 
5232f86ba45SStephan Aßmus 	BGradientLinear bevelGradient;
5242f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelShadow, 0);
5252f86ba45SStephan Aßmus 	bevelGradient.AddColor(bevelLight, 255);
5262f86ba45SStephan Aßmus 	bevelGradient.SetStart(rect.LeftTop());
5272f86ba45SStephan Aßmus 	bevelGradient.SetEnd(rect.RightBottom());
5282f86ba45SStephan Aßmus 
5292f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5302f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5312f86ba45SStephan Aßmus 
5322f86ba45SStephan Aßmus 	bevelGradient.MakeEmpty();
5332f86ba45SStephan Aßmus 	bevelGradient.AddColor(borderColor, 0);
5342f86ba45SStephan Aßmus 	bevelGradient.AddColor(tint_color(borderColor, 0.8), 255);
5352f86ba45SStephan Aßmus 	view->FillEllipse(rect, bevelGradient);
5362f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
5372f86ba45SStephan Aßmus 
5382f86ba45SStephan Aßmus 	float topTint;
5392f86ba45SStephan Aßmus 	float bottomTint;
540a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5412f86ba45SStephan Aßmus 		topTint = 0.4;
5422f86ba45SStephan Aßmus 		bottomTint = 0.2;
5432f86ba45SStephan Aßmus 	} else {
5442f86ba45SStephan Aßmus 		topTint = 0.15;
5452f86ba45SStephan Aßmus 		bottomTint = 0.0;
5462f86ba45SStephan Aßmus 	}
5472f86ba45SStephan Aßmus 
5482f86ba45SStephan Aßmus 	BGradientLinear gradient;
5492f86ba45SStephan Aßmus 	_MakeGradient(gradient, rect, base, topTint, bottomTint);
5502f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
5512f86ba45SStephan Aßmus 
5522f86ba45SStephan Aßmus 	rgb_color markColor;
5532f86ba45SStephan Aßmus 	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
5542f86ba45SStephan Aßmus 		view->SetHighColor(markColor);
5552f86ba45SStephan Aßmus 		rect.InsetBy(3, 3);
5562f86ba45SStephan Aßmus 		view->FillEllipse(rect);
5572f86ba45SStephan Aßmus 	}
5582f86ba45SStephan Aßmus }
5592f86ba45SStephan Aßmus 
5602f86ba45SStephan Aßmus 
5612f86ba45SStephan Aßmus void
5622f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2,
5632f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
564e724b26fSJohn Scipione 	orientation orientation)
5652f86ba45SStephan Aßmus {
5662f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect1, updateRect, base, flags, orientation);
5672f86ba45SStephan Aßmus 	DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation);
5682f86ba45SStephan Aßmus }
5692f86ba45SStephan Aßmus 
57088969219SJohn Scipione 
5712f86ba45SStephan Aßmus void
5722f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect,
5732f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
574e724b26fSJohn Scipione 	orientation orientation)
5752f86ba45SStephan Aßmus {
5762f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
5772f86ba45SStephan Aßmus 		return;
5782f86ba45SStephan Aßmus 
5792f86ba45SStephan Aßmus 	float gradient1Tint;
5802f86ba45SStephan Aßmus 	float gradient2Tint;
5812f86ba45SStephan Aßmus 	float darkEdge1Tint;
5822f86ba45SStephan Aßmus 	float darkEdge2Tint;
5832f86ba45SStephan Aßmus 	float shadowTint;
5842f86ba45SStephan Aßmus 
585a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
5862f86ba45SStephan Aßmus 		gradient1Tint = 0.9;
5872f86ba45SStephan Aßmus 		gradient2Tint = 0.8;
5882f86ba45SStephan Aßmus 		darkEdge1Tint = B_DARKEN_2_TINT;
5892f86ba45SStephan Aßmus 		darkEdge2Tint = B_DARKEN_2_TINT;
5902f86ba45SStephan Aßmus 		shadowTint = gradient1Tint;
5912f86ba45SStephan Aßmus 	} else {
5922f86ba45SStephan Aßmus 		gradient1Tint = 1.10;
5932f86ba45SStephan Aßmus 		gradient2Tint = 1.05;
5942f86ba45SStephan Aßmus 		darkEdge1Tint = B_DARKEN_3_TINT;
5952f86ba45SStephan Aßmus 		darkEdge2Tint = B_DARKEN_2_TINT;
5962f86ba45SStephan Aßmus 		shadowTint = gradient1Tint;
5972f86ba45SStephan Aßmus 	}
5982f86ba45SStephan Aßmus 
5992f86ba45SStephan Aßmus 	rgb_color darkEdge1 = tint_color(base, darkEdge1Tint);
6002f86ba45SStephan Aßmus 	rgb_color darkEdge2 = tint_color(base, darkEdge2Tint);
6012f86ba45SStephan Aßmus 	rgb_color shadow = tint_color(base, shadowTint);
6022f86ba45SStephan Aßmus 
6032f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
6042f86ba45SStephan Aßmus 		// dark vertical line on left edge
6052f86ba45SStephan Aßmus 		if (rect.Width() > 0) {
6062f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge1);
6072f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
6082f86ba45SStephan Aßmus 			rect.left++;
6092f86ba45SStephan Aßmus 		}
6102f86ba45SStephan Aßmus 		// dark vertical line on right edge
6112f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6122f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge2);
6132f86ba45SStephan Aßmus 			view->StrokeLine(rect.RightTop(), rect.RightBottom());
6142f86ba45SStephan Aßmus 			rect.right--;
6152f86ba45SStephan Aßmus 		}
6162f86ba45SStephan Aßmus 		// vertical shadow line after left edge
6172f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6182f86ba45SStephan Aßmus 			view->SetHighColor(shadow);
6192f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
6202f86ba45SStephan Aßmus 			rect.left++;
6212f86ba45SStephan Aßmus 		}
6222f86ba45SStephan Aßmus 		// fill
6232f86ba45SStephan Aßmus 		if (rect.Width() >= 0) {
6242f86ba45SStephan Aßmus 			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
6252f86ba45SStephan Aßmus 				orientation);
6262f86ba45SStephan Aßmus 		}
6272f86ba45SStephan Aßmus 	} else {
6282f86ba45SStephan Aßmus 		// dark vertical line on top edge
6292f86ba45SStephan Aßmus 		if (rect.Height() > 0) {
6302f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge1);
6312f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.RightTop());
6322f86ba45SStephan Aßmus 			rect.top++;
6332f86ba45SStephan Aßmus 		}
6342f86ba45SStephan Aßmus 		// dark vertical line on bottom edge
6352f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6362f86ba45SStephan Aßmus 			view->SetHighColor(darkEdge2);
6372f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
6382f86ba45SStephan Aßmus 			rect.bottom--;
6392f86ba45SStephan Aßmus 		}
6402f86ba45SStephan Aßmus 		// horizontal shadow line after top edge
6412f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6422f86ba45SStephan Aßmus 			view->SetHighColor(shadow);
6432f86ba45SStephan Aßmus 			view->StrokeLine(rect.LeftTop(), rect.RightTop());
6442f86ba45SStephan Aßmus 			rect.top++;
6452f86ba45SStephan Aßmus 		}
6462f86ba45SStephan Aßmus 		// fill
6472f86ba45SStephan Aßmus 		if (rect.Height() >= 0) {
6482f86ba45SStephan Aßmus 			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
6492f86ba45SStephan Aßmus 				orientation);
6502f86ba45SStephan Aßmus 		}
6512f86ba45SStephan Aßmus 	}
6522f86ba45SStephan Aßmus }
6532f86ba45SStephan Aßmus 
6542f86ba45SStephan Aßmus 
65540a10e1cSStephan Aßmus void
65674bb70aeSStephan Aßmus BControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
65774bb70aeSStephan Aßmus 	const BRect& updateRect, BRect verticalScrollBarFrame,
65874bb70aeSStephan Aßmus 	BRect horizontalScrollBarFrame, const rgb_color& base,
65974bb70aeSStephan Aßmus 	border_style border, uint32 flags, uint32 _borders)
66074bb70aeSStephan Aßmus {
661ce955579SStephan Aßmus 	// calculate scroll corner rect before messing with the "rect"
662ce955579SStephan Aßmus 	BRect scrollCornerFillRect(rect.right, rect.bottom,
663ce955579SStephan Aßmus 		rect.right, rect.bottom);
664ce955579SStephan Aßmus 	if (horizontalScrollBarFrame.IsValid())
665ce955579SStephan Aßmus 		scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1;
666ce955579SStephan Aßmus 	if (verticalScrollBarFrame.IsValid())
667ce955579SStephan Aßmus 		scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1;
668ce955579SStephan Aßmus 
669c44aa833SStephan Aßmus 	if (border == B_NO_BORDER) {
670c44aa833SStephan Aßmus 		if (scrollCornerFillRect.IsValid()) {
671c44aa833SStephan Aßmus 			view->SetHighColor(base);
672c44aa833SStephan Aßmus 			view->FillRect(scrollCornerFillRect);
673c44aa833SStephan Aßmus 		}
674c44aa833SStephan Aßmus 		return;
675c44aa833SStephan Aßmus 	}
676c44aa833SStephan Aßmus 
677c44aa833SStephan Aßmus 	bool excludeScrollCorner = border == B_FANCY_BORDER
678c44aa833SStephan Aßmus 		&& horizontalScrollBarFrame.IsValid()
679c44aa833SStephan Aßmus 		&& verticalScrollBarFrame.IsValid();
680c44aa833SStephan Aßmus 
68174bb70aeSStephan Aßmus 	uint32 borders = _borders;
68274bb70aeSStephan Aßmus 	if (excludeScrollCorner) {
68374bb70aeSStephan Aßmus 		rect.bottom = horizontalScrollBarFrame.top;
68474bb70aeSStephan Aßmus 		rect.right = verticalScrollBarFrame.left;
68574bb70aeSStephan Aßmus 		borders &= ~(B_RIGHT_BORDER | B_BOTTOM_BORDER);
68674bb70aeSStephan Aßmus 	}
68774bb70aeSStephan Aßmus 
68874bb70aeSStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
68974bb70aeSStephan Aßmus 
69074bb70aeSStephan Aßmus 	if (border == B_FANCY_BORDER)
6914f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
69274bb70aeSStephan Aßmus 
693a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
69474bb70aeSStephan Aßmus 		rgb_color focusColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
69574bb70aeSStephan Aßmus 		_DrawFrame(view, rect, focusColor, focusColor, focusColor, focusColor,
69674bb70aeSStephan Aßmus 			borders);
69774bb70aeSStephan Aßmus 	} else {
69874bb70aeSStephan Aßmus 		_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
69974bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, borders);
70074bb70aeSStephan Aßmus 	}
70174bb70aeSStephan Aßmus 
70274bb70aeSStephan Aßmus 	if (excludeScrollCorner) {
70374bb70aeSStephan Aßmus 		horizontalScrollBarFrame.InsetBy(-1, -1);
70474bb70aeSStephan Aßmus 		// do not overdraw the top edge
70574bb70aeSStephan Aßmus 		horizontalScrollBarFrame.top += 2;
70674bb70aeSStephan Aßmus 		borders = _borders;
70774bb70aeSStephan Aßmus 		borders &= ~B_TOP_BORDER;
70874bb70aeSStephan Aßmus 		_DrawOuterResessedFrame(view, horizontalScrollBarFrame, base,
7094f579098SStephan Aßmus 			1.0, 1.0, flags, borders);
71074bb70aeSStephan Aßmus 		_DrawFrame(view, horizontalScrollBarFrame, scrollbarFrameColor,
71174bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
71274bb70aeSStephan Aßmus 			borders);
71374bb70aeSStephan Aßmus 
71474bb70aeSStephan Aßmus 
71574bb70aeSStephan Aßmus 		verticalScrollBarFrame.InsetBy(-1, -1);
71674bb70aeSStephan Aßmus 		// do not overdraw the left edge
71774bb70aeSStephan Aßmus 		verticalScrollBarFrame.left += 2;
71874bb70aeSStephan Aßmus 		borders = _borders;
71974bb70aeSStephan Aßmus 		borders &= ~B_LEFT_BORDER;
72074bb70aeSStephan Aßmus 		_DrawOuterResessedFrame(view, verticalScrollBarFrame, base,
7214f579098SStephan Aßmus 			1.0, 1.0, flags, borders);
72274bb70aeSStephan Aßmus 		_DrawFrame(view, verticalScrollBarFrame, scrollbarFrameColor,
72374bb70aeSStephan Aßmus 			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
72474bb70aeSStephan Aßmus 			borders);
725ce955579SStephan Aßmus 
726ce955579SStephan Aßmus 		// exclude recessed frame
727ce955579SStephan Aßmus 		scrollCornerFillRect.top++;
728ce955579SStephan Aßmus 		scrollCornerFillRect.left++;
729ce955579SStephan Aßmus 	}
730ce955579SStephan Aßmus 
731ce955579SStephan Aßmus 	if (scrollCornerFillRect.IsValid()) {
732ce955579SStephan Aßmus 		view->SetHighColor(base);
733ce955579SStephan Aßmus 		view->FillRect(scrollCornerFillRect);
73474bb70aeSStephan Aßmus 	}
73574bb70aeSStephan Aßmus }
73674bb70aeSStephan Aßmus 
73774bb70aeSStephan Aßmus 
73874bb70aeSStephan Aßmus void
73940a10e1cSStephan Aßmus BControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect,
74040a10e1cSStephan Aßmus 	const rgb_color& base, uint32 direction, uint32 flags, float tint)
74140a10e1cSStephan Aßmus {
74240a10e1cSStephan Aßmus 	BPoint tri1, tri2, tri3;
74340a10e1cSStephan Aßmus 	float hInset = rect.Width() / 3;
74440a10e1cSStephan Aßmus 	float vInset = rect.Height() / 3;
74540a10e1cSStephan Aßmus 	rect.InsetBy(hInset, vInset);
74640a10e1cSStephan Aßmus 
74740a10e1cSStephan Aßmus 	switch (direction) {
74840a10e1cSStephan Aßmus 		case B_LEFT_ARROW:
74940a10e1cSStephan Aßmus 			tri1.Set(rect.right, rect.top);
75040a10e1cSStephan Aßmus 			tri2.Set(rect.right - rect.Width() / 1.33,
75140a10e1cSStephan Aßmus 				(rect.top + rect.bottom + 1) / 2);
75240a10e1cSStephan Aßmus 			tri3.Set(rect.right, rect.bottom + 1);
75340a10e1cSStephan Aßmus 			break;
75440a10e1cSStephan Aßmus 		case B_RIGHT_ARROW:
755f9b1a47fSRyan Leavengood 			tri1.Set(rect.left + 1, rect.bottom + 1);
756f9b1a47fSRyan Leavengood 			tri2.Set(rect.left + 1 + rect.Width() / 1.33,
75740a10e1cSStephan Aßmus 				(rect.top + rect.bottom + 1) / 2);
758f9b1a47fSRyan Leavengood 			tri3.Set(rect.left + 1, rect.top);
75940a10e1cSStephan Aßmus 			break;
76040a10e1cSStephan Aßmus 		case B_UP_ARROW:
76140a10e1cSStephan Aßmus 			tri1.Set(rect.left, rect.bottom);
76240a10e1cSStephan Aßmus 			tri2.Set((rect.left + rect.right + 1) / 2,
76340a10e1cSStephan Aßmus 				rect.bottom - rect.Height() / 1.33);
76440a10e1cSStephan Aßmus 			tri3.Set(rect.right + 1, rect.bottom);
76540a10e1cSStephan Aßmus 			break;
76640a10e1cSStephan Aßmus 		case B_DOWN_ARROW:
76740a10e1cSStephan Aßmus 		default:
768f9b1a47fSRyan Leavengood 			tri1.Set(rect.left, rect.top + 1);
76940a10e1cSStephan Aßmus 			tri2.Set((rect.left + rect.right + 1) / 2,
770f9b1a47fSRyan Leavengood 				rect.top + 1 + rect.Height() / 1.33);
771f9b1a47fSRyan Leavengood 			tri3.Set(rect.right + 1, rect.top + 1);
77240a10e1cSStephan Aßmus 			break;
7731b41173cSJohn Scipione 		case B_LEFT_UP_ARROW:
77417c9912bSJohn Scipione 			tri1.Set(rect.left, rect.bottom);
77517c9912bSJohn Scipione 			tri2.Set(rect.left, rect.top);
77617c9912bSJohn Scipione 			tri3.Set(rect.right - 1, rect.top);
7771b41173cSJohn Scipione 			break;
7781b41173cSJohn Scipione 		case B_RIGHT_UP_ARROW:
779348cd0c5SJohn Scipione 			tri1.Set(rect.left + 1, rect.top);
7801b41173cSJohn Scipione 			tri2.Set(rect.right, rect.top);
7811b41173cSJohn Scipione 			tri3.Set(rect.right, rect.bottom);
7821b41173cSJohn Scipione 			break;
7831b41173cSJohn Scipione 		case B_RIGHT_DOWN_ARROW:
7841b41173cSJohn Scipione 			tri1.Set(rect.right, rect.top);
7851b41173cSJohn Scipione 			tri2.Set(rect.right, rect.bottom);
786348cd0c5SJohn Scipione 			tri3.Set(rect.left + 1, rect.bottom);
7871b41173cSJohn Scipione 			break;
7881b41173cSJohn Scipione 		case B_LEFT_DOWN_ARROW:
78917c9912bSJohn Scipione 			tri1.Set(rect.right - 1, rect.bottom);
79017c9912bSJohn Scipione 			tri2.Set(rect.left, rect.bottom);
79117c9912bSJohn Scipione 			tri3.Set(rect.left, rect.top);
7921b41173cSJohn Scipione 			break;
79340a10e1cSStephan Aßmus 	}
79440a10e1cSStephan Aßmus 
79540a10e1cSStephan Aßmus 	BShape arrowShape;
79640a10e1cSStephan Aßmus 	arrowShape.MoveTo(tri1);
79740a10e1cSStephan Aßmus 	arrowShape.LineTo(tri2);
79840a10e1cSStephan Aßmus 	arrowShape.LineTo(tri3);
79940a10e1cSStephan Aßmus 
800a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
80140a10e1cSStephan Aßmus 		tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
80240a10e1cSStephan Aßmus 
80340a10e1cSStephan Aßmus 	view->SetHighColor(tint_color(base, tint));
80440a10e1cSStephan Aßmus 
80540a10e1cSStephan Aßmus 	float penSize = view->PenSize();
80640a10e1cSStephan Aßmus 	drawing_mode mode = view->DrawingMode();
80740a10e1cSStephan Aßmus 
808f44a56caSRyan Leavengood 	view->MovePenTo(BPoint(0, 0));
809f44a56caSRyan Leavengood 
81040a10e1cSStephan Aßmus 	view->SetPenSize(ceilf(hInset / 2.0));
81140a10e1cSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
81240a10e1cSStephan Aßmus 	view->StrokeShape(&arrowShape);
81340a10e1cSStephan Aßmus 
81440a10e1cSStephan Aßmus 	view->SetPenSize(penSize);
81540a10e1cSStephan Aßmus 	view->SetDrawingMode(mode);
81640a10e1cSStephan Aßmus }
81740a10e1cSStephan Aßmus 
81840a10e1cSStephan Aßmus 
8192f86ba45SStephan Aßmus rgb_color
8202f86ba45SStephan Aßmus BControlLook::SliderBarColor(const rgb_color& base)
8212f86ba45SStephan Aßmus {
8222f86ba45SStephan Aßmus 	return tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT);
8232f86ba45SStephan Aßmus }
8242f86ba45SStephan Aßmus 
8252f86ba45SStephan Aßmus 
8262f86ba45SStephan Aßmus void
8272f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
8282f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor,
829e724b26fSJohn Scipione 	float sliderScale, uint32 flags, orientation orientation)
8302f86ba45SStephan Aßmus {
8312f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
8322f86ba45SStephan Aßmus 		return;
8332f86ba45SStephan Aßmus 
8345666b4f7SJohn Scipione 	// save the clipping constraints of the view
8355666b4f7SJohn Scipione 	view->PushState();
8365666b4f7SJohn Scipione 
8372f86ba45SStephan Aßmus 	// separate the bar in two sides
8382f86ba45SStephan Aßmus 	float sliderPosition;
8392f86ba45SStephan Aßmus 	BRect leftBarSide = rect;
8402f86ba45SStephan Aßmus 	BRect rightBarSide = rect;
8412f86ba45SStephan Aßmus 
8422f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8432f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.left + 2 + (rect.Width() - 2)
8442f86ba45SStephan Aßmus 			* sliderScale);
8452f86ba45SStephan Aßmus 		leftBarSide.right = sliderPosition - 1;
8462f86ba45SStephan Aßmus 		rightBarSide.left = sliderPosition;
8472f86ba45SStephan Aßmus 	} else {
848f3997b74SStephan Aßmus 		// NOTE: position is reverse of coords
8492f86ba45SStephan Aßmus 		sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
850f3997b74SStephan Aßmus 			* (1.0 - sliderScale));
851f3997b74SStephan Aßmus 		leftBarSide.top = sliderPosition;
852f3997b74SStephan Aßmus 		rightBarSide.bottom = sliderPosition - 1;
8532f86ba45SStephan Aßmus 	}
8542f86ba45SStephan Aßmus 
8552f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
8562f86ba45SStephan Aßmus 	BRegion region(rect);
8572f86ba45SStephan Aßmus 	region.Exclude(rightBarSide);
8582f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8592f86ba45SStephan Aßmus 
8602f86ba45SStephan Aßmus 	view->PushState();
8612f86ba45SStephan Aßmus 
8622f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
8632f86ba45SStephan Aßmus 		orientation);
8642f86ba45SStephan Aßmus 
8652f86ba45SStephan Aßmus 	view->PopState();
8662f86ba45SStephan Aßmus 
8672f86ba45SStephan Aßmus 	region.Set(rect);
8682f86ba45SStephan Aßmus 	region.Exclude(leftBarSide);
8692f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
8702f86ba45SStephan Aßmus 
8712f86ba45SStephan Aßmus 	view->PushState();
8722f86ba45SStephan Aßmus 
8732f86ba45SStephan Aßmus 	DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
8742f86ba45SStephan Aßmus 		orientation);
8752f86ba45SStephan Aßmus 
8762f86ba45SStephan Aßmus 	view->PopState();
8773244c2bcSJohn Scipione 
8785666b4f7SJohn Scipione 	// restore the clipping constraints of the view
8795666b4f7SJohn Scipione 	view->PopState();
8802f86ba45SStephan Aßmus }
8812f86ba45SStephan Aßmus 
8822f86ba45SStephan Aßmus 
8832f86ba45SStephan Aßmus void
8842f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
8852f86ba45SStephan Aßmus 	const rgb_color& base, rgb_color fillColor, uint32 flags,
886e724b26fSJohn Scipione 	orientation orientation)
8872f86ba45SStephan Aßmus {
8882f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
8892f86ba45SStephan Aßmus 		return;
8902f86ba45SStephan Aßmus 
8912f86ba45SStephan Aßmus 	// separate the rect into corners
8922f86ba45SStephan Aßmus 	BRect leftCorner(rect);
8932f86ba45SStephan Aßmus 	BRect rightCorner(rect);
8942f86ba45SStephan Aßmus 	BRect barRect(rect);
8952f86ba45SStephan Aßmus 
8962f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
8972f86ba45SStephan Aßmus 		leftCorner.right = leftCorner.left + leftCorner.Height();
8982f86ba45SStephan Aßmus 		rightCorner.left = rightCorner.right - rightCorner.Height();
8992f86ba45SStephan Aßmus 		barRect.left += ceilf(barRect.Height() / 2);
9002f86ba45SStephan Aßmus 		barRect.right -= ceilf(barRect.Height() / 2);
9012f86ba45SStephan Aßmus 	} else {
9022f86ba45SStephan Aßmus 		leftCorner.bottom = leftCorner.top + leftCorner.Width();
9032f86ba45SStephan Aßmus 		rightCorner.top = rightCorner.bottom - rightCorner.Width();
9042f86ba45SStephan Aßmus 		barRect.top += ceilf(barRect.Width() / 2);
9052f86ba45SStephan Aßmus 		barRect.bottom -= ceilf(barRect.Width() / 2);
9062f86ba45SStephan Aßmus 	}
9072f86ba45SStephan Aßmus 
9082f86ba45SStephan Aßmus 	// fill the background for the corners, exclude the middle bar for now
9092f86ba45SStephan Aßmus 	BRegion region(rect);
9102f86ba45SStephan Aßmus 	region.Exclude(barRect);
9112f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&region);
9122f86ba45SStephan Aßmus 
91361ac1a85SStephan Aßmus 	if ((flags & B_BLEND_FRAME) == 0) {
9142f86ba45SStephan Aßmus 		view->SetHighColor(base);
9152f86ba45SStephan Aßmus 		view->FillRect(rect);
91661ac1a85SStephan Aßmus 	}
9172f86ba45SStephan Aßmus 
9182f86ba45SStephan Aßmus 	// figure out the tints to be used
9192f86ba45SStephan Aßmus 	float edgeLightTint;
9202f86ba45SStephan Aßmus 	float edgeShadowTint;
9212f86ba45SStephan Aßmus 	float frameLightTint;
9222f86ba45SStephan Aßmus 	float frameShadowTint;
9232f86ba45SStephan Aßmus 	float fillLightTint;
9242f86ba45SStephan Aßmus 	float fillShadowTint;
92561ac1a85SStephan Aßmus 	uint8 edgeLightAlpha;
92661ac1a85SStephan Aßmus 	uint8 edgeShadowAlpha;
92761ac1a85SStephan Aßmus 	uint8 frameLightAlpha;
92861ac1a85SStephan Aßmus 	uint8 frameShadowAlpha;
9292f86ba45SStephan Aßmus 
930a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
9312f86ba45SStephan Aßmus 		edgeLightTint = 1.0;
9322f86ba45SStephan Aßmus 		edgeShadowTint = 1.0;
9332f86ba45SStephan Aßmus 		frameLightTint = 1.20;
9342f86ba45SStephan Aßmus 		frameShadowTint = 1.25;
9352f86ba45SStephan Aßmus 		fillLightTint = 0.9;
9362f86ba45SStephan Aßmus 		fillShadowTint = 1.05;
93710ddee8dSStephan Aßmus 		edgeLightAlpha = 12;
93810ddee8dSStephan Aßmus 		edgeShadowAlpha = 12;
93961ac1a85SStephan Aßmus 		frameLightAlpha = 40;
94061ac1a85SStephan Aßmus 		frameShadowAlpha = 45;
9412f86ba45SStephan Aßmus 
9422f86ba45SStephan Aßmus 		fillColor.red = uint8(fillColor.red * 0.4 + base.red * 0.6);
9432f86ba45SStephan Aßmus 		fillColor.green = uint8(fillColor.green * 0.4 + base.green * 0.6);
9442f86ba45SStephan Aßmus 		fillColor.blue = uint8(fillColor.blue * 0.4 + base.blue * 0.6);
9452f86ba45SStephan Aßmus 	} else {
9462f86ba45SStephan Aßmus 		edgeLightTint = 0.65;
9472f86ba45SStephan Aßmus 		edgeShadowTint = 1.07;
9482f86ba45SStephan Aßmus 		frameLightTint = 1.40;
9492f86ba45SStephan Aßmus 		frameShadowTint = 1.50;
9502f86ba45SStephan Aßmus 		fillLightTint = 0.8;
9512f86ba45SStephan Aßmus 		fillShadowTint = 1.1;
95210ddee8dSStephan Aßmus 		edgeLightAlpha = 15;
95310ddee8dSStephan Aßmus 		edgeShadowAlpha = 15;
95461ac1a85SStephan Aßmus 		frameLightAlpha = 92;
95561ac1a85SStephan Aßmus 		frameShadowAlpha = 107;
9562f86ba45SStephan Aßmus 	}
9572f86ba45SStephan Aßmus 
95861ac1a85SStephan Aßmus 	rgb_color edgeLightColor;
95961ac1a85SStephan Aßmus 	rgb_color edgeShadowColor;
96061ac1a85SStephan Aßmus 	rgb_color frameLightColor;
96161ac1a85SStephan Aßmus 	rgb_color frameShadowColor;
9622f86ba45SStephan Aßmus 	rgb_color fillLightColor = tint_color(fillColor, fillLightTint);
9632f86ba45SStephan Aßmus 	rgb_color fillShadowColor = tint_color(fillColor, fillShadowTint);
9642f86ba45SStephan Aßmus 
96561ac1a85SStephan Aßmus 	drawing_mode oldMode = view->DrawingMode();
96661ac1a85SStephan Aßmus 
967a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
96861ac1a85SStephan Aßmus 		edgeLightColor = (rgb_color){ 255, 255, 255, edgeLightAlpha };
96961ac1a85SStephan Aßmus 		edgeShadowColor = (rgb_color){ 0, 0, 0, edgeShadowAlpha };
97061ac1a85SStephan Aßmus 		frameLightColor = (rgb_color){ 0, 0, 0, frameLightAlpha };
97161ac1a85SStephan Aßmus 		frameShadowColor = (rgb_color){ 0, 0, 0, frameShadowAlpha };
97261ac1a85SStephan Aßmus 
97361ac1a85SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
97461ac1a85SStephan Aßmus 	} else {
97561ac1a85SStephan Aßmus 		edgeLightColor = tint_color(base, edgeLightTint);
97661ac1a85SStephan Aßmus 		edgeShadowColor = tint_color(base, edgeShadowTint);
97761ac1a85SStephan Aßmus 		frameLightColor = tint_color(fillColor, frameLightTint);
97861ac1a85SStephan Aßmus 		frameShadowColor = tint_color(fillColor, frameShadowTint);
97961ac1a85SStephan Aßmus 	}
98061ac1a85SStephan Aßmus 
9812f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
9822f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
9832f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9842f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
9852f86ba45SStephan Aßmus 
9862f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
9872f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9882f86ba45SStephan Aßmus 			fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
9892f86ba45SStephan Aßmus 	} else {
9902f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
9912f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9922f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
9932f86ba45SStephan Aßmus 
9942f86ba45SStephan Aßmus 		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
9952f86ba45SStephan Aßmus 			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
9962f86ba45SStephan Aßmus 			fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
9972f86ba45SStephan Aßmus 	}
9982f86ba45SStephan Aßmus 
9992f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(NULL);
10002f86ba45SStephan Aßmus 
10012f86ba45SStephan Aßmus 	view->BeginLineArray(4);
10022f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
10032f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), edgeShadowColor);
10042f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
10052f86ba45SStephan Aßmus 			edgeLightColor);
10062f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
10072f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.RightTop(), frameShadowColor);
10082f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
10092f86ba45SStephan Aßmus 			frameLightColor);
10102f86ba45SStephan Aßmus 		barRect.InsetBy(0, 1);
10112f86ba45SStephan Aßmus 	} else {
10122f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), edgeShadowColor);
10132f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
10142f86ba45SStephan Aßmus 			edgeLightColor);
10152f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
10162f86ba45SStephan Aßmus 		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), frameShadowColor);
10172f86ba45SStephan Aßmus 		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
10182f86ba45SStephan Aßmus 			frameLightColor);
10192f86ba45SStephan Aßmus 		barRect.InsetBy(1, 0);
10202f86ba45SStephan Aßmus 	}
10212f86ba45SStephan Aßmus 	view->EndLineArray();
10222f86ba45SStephan Aßmus 
102361ac1a85SStephan Aßmus 	view->SetDrawingMode(oldMode);
102461ac1a85SStephan Aßmus 
10252f86ba45SStephan Aßmus 	_FillGradient(view, barRect, fillColor, fillShadowTint, fillLightTint,
10262f86ba45SStephan Aßmus 		orientation);
10272f86ba45SStephan Aßmus }
10282f86ba45SStephan Aßmus 
10292f86ba45SStephan Aßmus 
10302f86ba45SStephan Aßmus void
10312f86ba45SStephan Aßmus BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
1032e724b26fSJohn Scipione 	const rgb_color& base, uint32 flags, orientation orientation)
10332f86ba45SStephan Aßmus {
10342f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
10352f86ba45SStephan Aßmus 		return;
10362f86ba45SStephan Aßmus 
10372f86ba45SStephan Aßmus 	// figure out frame color
10382f86ba45SStephan Aßmus 	rgb_color frameLightColor;
10392f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
10402f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
10412f86ba45SStephan Aßmus 
1042a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
10432f86ba45SStephan Aßmus 		// focused
10442f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
10452f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
10462f86ba45SStephan Aßmus 	} else {
10472f86ba45SStephan Aßmus 		// figure out the tints to be used
10482f86ba45SStephan Aßmus 		float frameLightTint;
10492f86ba45SStephan Aßmus 		float frameShadowTint;
10502f86ba45SStephan Aßmus 
1051a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
10522f86ba45SStephan Aßmus 			frameLightTint = 1.30;
10532f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
10542f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
10552f86ba45SStephan Aßmus 		} else {
10562f86ba45SStephan Aßmus 			frameLightTint = 1.6;
10572f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
10582f86ba45SStephan Aßmus 		}
10592f86ba45SStephan Aßmus 
10602f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
10612f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
10622f86ba45SStephan Aßmus 	}
10632f86ba45SStephan Aßmus 
10642f86ba45SStephan Aßmus 	BRect originalRect(rect);
10652f86ba45SStephan Aßmus 	rect.right--;
10662f86ba45SStephan Aßmus 	rect.bottom--;
10672f86ba45SStephan Aßmus 
10682f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor,
10692f86ba45SStephan Aßmus 		frameShadowColor, frameShadowColor);
10702f86ba45SStephan Aßmus 
10712f86ba45SStephan Aßmus 	flags &= ~B_ACTIVATED;
10722f86ba45SStephan Aßmus 	DrawButtonBackground(view, rect, updateRect, base, flags);
10732f86ba45SStephan Aßmus 
10742f86ba45SStephan Aßmus 	// thumb shadow
10752f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
10762f86ba45SStephan Aßmus 	view->SetHighColor(shadowColor);
10772f86ba45SStephan Aßmus 	originalRect.left++;
10782f86ba45SStephan Aßmus 	originalRect.top++;
10792f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.LeftBottom(), originalRect.RightBottom());
10802f86ba45SStephan Aßmus 	originalRect.bottom--;
10812f86ba45SStephan Aßmus 	view->StrokeLine(originalRect.RightTop(), originalRect.RightBottom());
10822f86ba45SStephan Aßmus 
10832f86ba45SStephan Aßmus 	// thumb edge
10842f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
10852f86ba45SStephan Aßmus 		rect.InsetBy(0, floorf(rect.Height() / 4));
10862f86ba45SStephan Aßmus 		rect.left = floorf((rect.left + rect.right) / 2);
10872f86ba45SStephan Aßmus 		rect.right = rect.left + 1;
10882f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
10892f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
10902f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
10912f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
10922f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
10932f86ba45SStephan Aßmus 		lightColor.alpha = 128;
10942f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
10952f86ba45SStephan Aßmus 		view->StrokeLine(rect.RightTop(), rect.RightBottom());
10962f86ba45SStephan Aßmus 	} else {
10972f86ba45SStephan Aßmus 		rect.InsetBy(floorf(rect.Width() / 4), 0);
10982f86ba45SStephan Aßmus 		rect.top = floorf((rect.top + rect.bottom) / 2);
10992f86ba45SStephan Aßmus 		rect.bottom = rect.top + 1;
11002f86ba45SStephan Aßmus 		shadowColor = tint_color(base, B_DARKEN_2_TINT);
11012f86ba45SStephan Aßmus 		shadowColor.alpha = 128;
11022f86ba45SStephan Aßmus 		view->SetHighColor(shadowColor);
11032f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftTop(), rect.RightTop());
11042f86ba45SStephan Aßmus 		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
11052f86ba45SStephan Aßmus 		lightColor.alpha = 128;
11062f86ba45SStephan Aßmus 		view->SetHighColor(lightColor);
11072f86ba45SStephan Aßmus 		view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
11082f86ba45SStephan Aßmus 	}
11092f86ba45SStephan Aßmus 
11102f86ba45SStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
11112f86ba45SStephan Aßmus }
11122f86ba45SStephan Aßmus 
11132f86ba45SStephan Aßmus 
11142f86ba45SStephan Aßmus void
11152f86ba45SStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
11162f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
1117e724b26fSJohn Scipione 	orientation orientation)
11182f86ba45SStephan Aßmus {
11198ee9217eSStephan Aßmus 	DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation);
11208ee9217eSStephan Aßmus }
11218ee9217eSStephan Aßmus 
11228ee9217eSStephan Aßmus 
11238ee9217eSStephan Aßmus void
11248ee9217eSStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
11258ee9217eSStephan Aßmus 	const BRect& updateRect, const rgb_color& base, const rgb_color& fill,
1126e724b26fSJohn Scipione 	uint32 flags, orientation orientation)
11278ee9217eSStephan Aßmus {
11282f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
11292f86ba45SStephan Aßmus 		return;
11302f86ba45SStephan Aßmus 
11312f86ba45SStephan Aßmus 	// figure out frame color
11322f86ba45SStephan Aßmus 	rgb_color frameLightColor;
11332f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
11342f86ba45SStephan Aßmus 	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
11352f86ba45SStephan Aßmus 
11362f86ba45SStephan Aßmus 	float topTint = 0.49;
11372f86ba45SStephan Aßmus 	float middleTint1 = 0.62;
11382f86ba45SStephan Aßmus 	float middleTint2 = 0.76;
11392f86ba45SStephan Aßmus 	float bottomTint = 0.90;
11402f86ba45SStephan Aßmus 
1141a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
11422f86ba45SStephan Aßmus 		topTint = (topTint + B_NO_TINT) / 2;
11432f86ba45SStephan Aßmus 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
11442f86ba45SStephan Aßmus 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
11452f86ba45SStephan Aßmus 		bottomTint = (bottomTint + B_NO_TINT) / 2;
1146a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
11472f86ba45SStephan Aßmus 		static const float kHoverTintFactor = 0.85;
11482f86ba45SStephan Aßmus 		topTint *= kHoverTintFactor;
11492f86ba45SStephan Aßmus 		middleTint1 *= kHoverTintFactor;
11502f86ba45SStephan Aßmus 		middleTint2 *= kHoverTintFactor;
11512f86ba45SStephan Aßmus 		bottomTint *= kHoverTintFactor;
11522f86ba45SStephan Aßmus 	}
11532f86ba45SStephan Aßmus 
1154a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0) {
11552f86ba45SStephan Aßmus 		// focused
11562f86ba45SStephan Aßmus 		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
11572f86ba45SStephan Aßmus 		frameShadowColor = frameLightColor;
11582f86ba45SStephan Aßmus 	} else {
11592f86ba45SStephan Aßmus 		// figure out the tints to be used
11602f86ba45SStephan Aßmus 		float frameLightTint;
11612f86ba45SStephan Aßmus 		float frameShadowTint;
11622f86ba45SStephan Aßmus 
1163a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0) {
11642f86ba45SStephan Aßmus 			frameLightTint = 1.30;
11652f86ba45SStephan Aßmus 			frameShadowTint = 1.35;
11662f86ba45SStephan Aßmus 			shadowColor.alpha = 30;
11672f86ba45SStephan Aßmus 		} else {
11682f86ba45SStephan Aßmus 			frameLightTint = 1.6;
11692f86ba45SStephan Aßmus 			frameShadowTint = 1.65;
11702f86ba45SStephan Aßmus 		}
11712f86ba45SStephan Aßmus 
11722f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, frameLightTint);
11732f86ba45SStephan Aßmus 		frameShadowColor = tint_color(base, frameShadowTint);
11742f86ba45SStephan Aßmus 	}
11752f86ba45SStephan Aßmus 
11768ee9217eSStephan Aßmus 	// make room for the shadow
11778ee9217eSStephan Aßmus 	rect.right--;
11788ee9217eSStephan Aßmus 	rect.bottom--;
11792f86ba45SStephan Aßmus 
11802f86ba45SStephan Aßmus 	uint32 viewFlags = view->Flags();
11812f86ba45SStephan Aßmus 	view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
11822f86ba45SStephan Aßmus 	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
11832f86ba45SStephan Aßmus 
1184f3997b74SStephan Aßmus 	float centerh = (rect.left + rect.right) / 2;
1185f3997b74SStephan Aßmus 	float centerv = (rect.top + rect.bottom) / 2;
11862f86ba45SStephan Aßmus 
11878ee9217eSStephan Aßmus 	BShape shape;
1188f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
11898ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
11908ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
11918ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
1192f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5));
11938ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
1194f3997b74SStephan Aßmus 	} else {
1195f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5));
1196f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
1197f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5));
1198f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left + 0.5, centerv + 0.5));
1199f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5));
1200f3997b74SStephan Aßmus 	}
12018ee9217eSStephan Aßmus 	shape.Close();
12028ee9217eSStephan Aßmus 
12038ee9217eSStephan Aßmus 	view->MovePenTo(BPoint(1, 1));
12048ee9217eSStephan Aßmus 
12058ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_ALPHA);
12068ee9217eSStephan Aßmus 	view->SetHighColor(shadowColor);
12078ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
12088ee9217eSStephan Aßmus 
12098ee9217eSStephan Aßmus 	view->MovePenTo(B_ORIGIN);
12108ee9217eSStephan Aßmus 
12118ee9217eSStephan Aßmus 	view->SetDrawingMode(B_OP_COPY);
12122f86ba45SStephan Aßmus 	view->SetHighColor(frameLightColor);
12138ee9217eSStephan Aßmus 	view->StrokeShape(&shape);
12142f86ba45SStephan Aßmus 
12152f86ba45SStephan Aßmus 	rect.InsetBy(1, 1);
12168ee9217eSStephan Aßmus 	shape.Clear();
1217f3997b74SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12188ee9217eSStephan Aßmus 		shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
12198ee9217eSStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1220f3997b74SStephan Aßmus 		shape.LineTo(BPoint(centerh + 0.5, rect.top));
1221f3997b74SStephan Aßmus 	} else {
1222f3997b74SStephan Aßmus 		shape.MoveTo(BPoint(rect.right + 1, rect.top));
1223f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1224f3997b74SStephan Aßmus 		shape.LineTo(BPoint(rect.left, centerv + 0.5));
1225f3997b74SStephan Aßmus 	}
12268ee9217eSStephan Aßmus 	shape.Close();
12272f86ba45SStephan Aßmus 
12282f86ba45SStephan Aßmus 	BGradientLinear gradient;
1229a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12308ee9217eSStephan Aßmus 		_MakeGradient(gradient, rect, fill, topTint, bottomTint);
12312f86ba45SStephan Aßmus 	} else {
12328ee9217eSStephan Aßmus 		_MakeGlossyGradient(gradient, rect, fill, topTint, middleTint1,
12332f86ba45SStephan Aßmus 			middleTint2, bottomTint);
12342f86ba45SStephan Aßmus 	}
12352f86ba45SStephan Aßmus 
12368ee9217eSStephan Aßmus 	view->FillShape(&shape, gradient);
12372f86ba45SStephan Aßmus 
12382f86ba45SStephan Aßmus 	view->SetFlags(viewFlags);
12392f86ba45SStephan Aßmus }
12402f86ba45SStephan Aßmus 
12412f86ba45SStephan Aßmus 
12422f86ba45SStephan Aßmus void
12432f86ba45SStephan Aßmus BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
12442f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, int32 count,
1245e724b26fSJohn Scipione 	hash_mark_location location, uint32 flags, orientation orientation)
12462f86ba45SStephan Aßmus {
12472f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
12482f86ba45SStephan Aßmus 		return;
12492f86ba45SStephan Aßmus 
12502f86ba45SStephan Aßmus 	rgb_color lightColor;
12512f86ba45SStephan Aßmus 	rgb_color darkColor;
12522f86ba45SStephan Aßmus 
1253a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
12542f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.9);
12552f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.07);
12562f86ba45SStephan Aßmus 	} else {
12572f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.8);
12582f86ba45SStephan Aßmus 		darkColor = tint_color(base, 1.14);
12592f86ba45SStephan Aßmus 	}
12602f86ba45SStephan Aßmus 
12612f86ba45SStephan Aßmus 	int32 hashMarkCount = max_c(count, 2);
12622f86ba45SStephan Aßmus 		// draw at least two hashmarks at min/max if
12632f86ba45SStephan Aßmus 		// fHashMarks != B_HASH_MARKS_NONE
12642f86ba45SStephan Aßmus 	float factor;
12652f86ba45SStephan Aßmus 	float startPos;
12662f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
12672f86ba45SStephan Aßmus 		factor = (rect.Width() - 2) / (hashMarkCount - 1);
12682f86ba45SStephan Aßmus 		startPos = rect.left + 1;
12692f86ba45SStephan Aßmus 	} else {
12702f86ba45SStephan Aßmus 		factor = (rect.Height() - 2) / (hashMarkCount - 1);
12712f86ba45SStephan Aßmus 		startPos = rect.top + 1;
12722f86ba45SStephan Aßmus 	}
12732f86ba45SStephan Aßmus 
12742f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_TOP) {
12752f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
12762f86ba45SStephan Aßmus 
12772f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
12782f86ba45SStephan Aßmus 			float pos = startPos;
12792f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12802f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.top),
12812f86ba45SStephan Aßmus 							  BPoint(pos, rect.top + 4), darkColor);
12822f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.top),
12832f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.top + 4), lightColor);
12842f86ba45SStephan Aßmus 
12852f86ba45SStephan Aßmus 				pos += factor;
12862f86ba45SStephan Aßmus 			}
12872f86ba45SStephan Aßmus 		} else {
12882f86ba45SStephan Aßmus 			float pos = startPos;
12892f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
12902f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos),
12912f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos), darkColor);
12922f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.left, pos + 1),
12932f86ba45SStephan Aßmus 							  BPoint(rect.left + 4, pos + 1), lightColor);
12942f86ba45SStephan Aßmus 
12952f86ba45SStephan Aßmus 				pos += factor;
12962f86ba45SStephan Aßmus 			}
12972f86ba45SStephan Aßmus 		}
12982f86ba45SStephan Aßmus 
12992f86ba45SStephan Aßmus 		view->EndLineArray();
13002f86ba45SStephan Aßmus 	}
13012f86ba45SStephan Aßmus 
13022f86ba45SStephan Aßmus 	if (location & B_HASH_MARKS_BOTTOM) {
13032f86ba45SStephan Aßmus 
13042f86ba45SStephan Aßmus 		view->BeginLineArray(hashMarkCount * 2);
13052f86ba45SStephan Aßmus 
13062f86ba45SStephan Aßmus 		if (orientation == B_HORIZONTAL) {
13072f86ba45SStephan Aßmus 			float pos = startPos;
13082f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
13092f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos, rect.bottom - 4),
13102f86ba45SStephan Aßmus 							  BPoint(pos, rect.bottom), darkColor);
13112f86ba45SStephan Aßmus 				view->AddLine(BPoint(pos + 1, rect.bottom - 4),
13122f86ba45SStephan Aßmus 							  BPoint(pos + 1, rect.bottom), lightColor);
13132f86ba45SStephan Aßmus 
13142f86ba45SStephan Aßmus 				pos += factor;
13152f86ba45SStephan Aßmus 			}
13162f86ba45SStephan Aßmus 		} else {
13172f86ba45SStephan Aßmus 			float pos = startPos;
13182f86ba45SStephan Aßmus 			for (int32 i = 0; i < hashMarkCount; i++) {
13192f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos),
13202f86ba45SStephan Aßmus 							  BPoint(rect.right, pos), darkColor);
13212f86ba45SStephan Aßmus 				view->AddLine(BPoint(rect.right - 4, pos + 1),
13222f86ba45SStephan Aßmus 							  BPoint(rect.right, pos + 1), lightColor);
13232f86ba45SStephan Aßmus 
13242f86ba45SStephan Aßmus 				pos += factor;
13252f86ba45SStephan Aßmus 			}
13262f86ba45SStephan Aßmus 		}
13272f86ba45SStephan Aßmus 
13282f86ba45SStephan Aßmus 		view->EndLineArray();
13292f86ba45SStephan Aßmus 	}
13302f86ba45SStephan Aßmus }
13312f86ba45SStephan Aßmus 
13322f86ba45SStephan Aßmus 
13332f86ba45SStephan Aßmus void
13342f86ba45SStephan Aßmus BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
13352f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
13362f86ba45SStephan Aßmus {
13372f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
13382f86ba45SStephan Aßmus 		return;
13392f86ba45SStephan Aßmus 
13405666b4f7SJohn Scipione 	// save the clipping constraints of the view
13415666b4f7SJohn Scipione 	view->PushState();
1342a884b43bSJohn Scipione 
13435666b4f7SJohn Scipione 	// set clipping constraints to updateRect
13445666b4f7SJohn Scipione 	BRegion clipping(updateRect);
1345a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
1346a884b43bSJohn Scipione 
13472f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
13482f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
13492f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
13502f86ba45SStephan Aßmus 	rgb_color frameLightColor;
13512f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
13522f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
13532f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
13542f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
13552f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
13562f86ba45SStephan Aßmus 
1357a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
13582f86ba45SStephan Aßmus 		edgeLightColor = base;
1359a884b43bSJohn Scipione 		edgeShadowColor = base;
13602f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1361a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13622f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1363a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13642f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
13652f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
13662f86ba45SStephan Aßmus 	} else {
13672f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1368a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
13692f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1370a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
13712f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.6);
1372a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
13732f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.75), 0);
13742f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.03), 255);
13752f86ba45SStephan Aßmus 	}
137612ea5a2cSStephan Aßmus 
1377a884b43bSJohn Scipione 	static const float kRoundCornerRadius = 4.0f;
13782f86ba45SStephan Aßmus 
1379a884b43bSJohn Scipione 	// left top corner dimensions
1380a884b43bSJohn Scipione 	BRect leftTopCorner(rect);
1381a884b43bSJohn Scipione 	leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius);
1382a884b43bSJohn Scipione 	leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1383a884b43bSJohn Scipione 	clipping.Exclude(leftTopCorner);
13842f86ba45SStephan Aßmus 
1385a884b43bSJohn Scipione 	// draw the left top corner
1386a884b43bSJohn Scipione 	_DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base,
1387a884b43bSJohn Scipione 		edgeShadowColor, frameLightColor, bevelLightColor,
1388a884b43bSJohn Scipione 		fillGradient);
13892f86ba45SStephan Aßmus 
1390a884b43bSJohn Scipione 	// right top corner dimensions
1391a884b43bSJohn Scipione 	BRect rightTopCorner(rect);
1392a884b43bSJohn Scipione 	rightTopCorner.right = floorf(rect.right);
1393a884b43bSJohn Scipione 	rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius);
1394a884b43bSJohn Scipione 	rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius);
1395a884b43bSJohn Scipione 	clipping.Exclude(rightTopCorner);
13962f86ba45SStephan Aßmus 
1397a884b43bSJohn Scipione 	// draw the right top corner
1398a884b43bSJohn Scipione 	_DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base,
1399a884b43bSJohn Scipione 		edgeShadowColor, edgeLightColor, frameLightColor,
1400a884b43bSJohn Scipione 		frameShadowColor, bevelLightColor, bevelShadowColor,
1401a884b43bSJohn Scipione 		fillGradient);
14022f86ba45SStephan Aßmus 
1403a884b43bSJohn Scipione 	// clip out the corners
14042f86ba45SStephan Aßmus 	view->ConstrainClippingRegion(&clipping);
14052f86ba45SStephan Aßmus 
1406a884b43bSJohn Scipione 	// draw the rest of frame and fill
14072f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
14082f86ba45SStephan Aßmus 		edgeLightColor,
14092f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14102f86ba45SStephan Aßmus 	if ((borders & B_LEFT_BORDER) == 0)
14112f86ba45SStephan Aßmus 		rect.left++;
14122f86ba45SStephan Aßmus 	if ((borders & B_RIGHT_BORDER) == 0)
14132f86ba45SStephan Aßmus 		rect.right--;
14142f86ba45SStephan Aßmus 
14152f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
14162f86ba45SStephan Aßmus 		frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
14172f86ba45SStephan Aßmus 
14182f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
14192f86ba45SStephan Aßmus 		bevelShadowColor);
14202f86ba45SStephan Aßmus 
14212f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
14222f86ba45SStephan Aßmus 
14235666b4f7SJohn Scipione 	// restore the clipping constraints of the view
14245666b4f7SJohn Scipione 	view->PopState();
14252f86ba45SStephan Aßmus }
14262f86ba45SStephan Aßmus 
14272f86ba45SStephan Aßmus 
14282f86ba45SStephan Aßmus void
142983aff015SPhilippe Houdoin BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
14302f86ba45SStephan Aßmus 	const rgb_color& base, uint32 flags, uint32 borders)
14312f86ba45SStephan Aßmus {
14322f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
14332f86ba45SStephan Aßmus 		return;
14342f86ba45SStephan Aßmus 
14352f86ba45SStephan Aßmus 	rgb_color edgeShadowColor;
14362f86ba45SStephan Aßmus 	rgb_color edgeLightColor;
14372f86ba45SStephan Aßmus 	rgb_color frameShadowColor;
14382f86ba45SStephan Aßmus 	rgb_color frameLightColor;
14392f86ba45SStephan Aßmus 	rgb_color bevelShadowColor;
14402f86ba45SStephan Aßmus 	rgb_color bevelLightColor;
14412f86ba45SStephan Aßmus 	BGradientLinear fillGradient;
14422f86ba45SStephan Aßmus 	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
14432f86ba45SStephan Aßmus 	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
14442f86ba45SStephan Aßmus 
1445a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
14462f86ba45SStephan Aßmus 		edgeLightColor = base;
1447a884b43bSJohn Scipione 		edgeShadowColor = base;
14482f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.25);
1449a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14502f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 0.8);
1451a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.07);
14522f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 0.85), 0);
14532f86ba45SStephan Aßmus 		fillGradient.AddColor(base, 255);
14542f86ba45SStephan Aßmus 	} else {
14552f86ba45SStephan Aßmus 		edgeLightColor = tint_color(base, 0.80);
1456a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, 1.03);
14572f86ba45SStephan Aßmus 		frameLightColor = tint_color(base, 1.30);
1458a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.30);
14592f86ba45SStephan Aßmus 		bevelLightColor = tint_color(base, 1.10);
1460a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, 1.17);
14612f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.12), 0);
14622f86ba45SStephan Aßmus 		fillGradient.AddColor(tint_color(base, 1.08), 255);
14632f86ba45SStephan Aßmus 	}
14642f86ba45SStephan Aßmus 
14652f86ba45SStephan Aßmus 	// active tabs stand out at the top, but this is an inactive tab
14662f86ba45SStephan Aßmus 	view->SetHighColor(base);
14672f86ba45SStephan Aßmus 	view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
14682f86ba45SStephan Aßmus 	rect.top += 4;
14692f86ba45SStephan Aßmus 
14702f86ba45SStephan Aßmus 	// frame and fill
14712f86ba45SStephan Aßmus 	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
14722f86ba45SStephan Aßmus 		edgeLightColor,
14732f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14742f86ba45SStephan Aßmus 
14752f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
14762f86ba45SStephan Aßmus 		frameShadowColor,
14772f86ba45SStephan Aßmus 		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
14782f86ba45SStephan Aßmus 
1479b3601d82SStephan Aßmus 	if (rect.IsValid()) {
1480b3601d82SStephan Aßmus 		_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
1481b3601d82SStephan Aßmus 			bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
1482b3601d82SStephan Aßmus 	} else {
1483b3601d82SStephan Aßmus 		if ((B_LEFT_BORDER & ~borders) != 0)
1484b3601d82SStephan Aßmus 			rect.left++;
1485b3601d82SStephan Aßmus 	}
14862f86ba45SStephan Aßmus 
14872f86ba45SStephan Aßmus 	view->FillRect(rect, fillGradient);
14882f86ba45SStephan Aßmus }
14892f86ba45SStephan Aßmus 
14902f86ba45SStephan Aßmus 
14911f9fd6d8SStephan Aßmus void
14921f9fd6d8SStephan Aßmus BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
1493e724b26fSJohn Scipione 	const rgb_color& base, orientation orientation, uint32 flags,
14941f9fd6d8SStephan Aßmus 	uint32 borders)
14951f9fd6d8SStephan Aßmus {
1496a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
1497a884b43bSJohn Scipione 		return;
1498a884b43bSJohn Scipione 
14991f9fd6d8SStephan Aßmus 	rgb_color background;
15001f9fd6d8SStephan Aßmus 	if ((flags & (B_CLICKED | B_ACTIVATED)) != 0)
15011f9fd6d8SStephan Aßmus 		background = tint_color(base, B_DARKEN_1_TINT);
15021f9fd6d8SStephan Aßmus 	else
15031f9fd6d8SStephan Aßmus 		background = base;
15041f9fd6d8SStephan Aßmus 
15051f9fd6d8SStephan Aßmus 	rgb_color light = tint_color(background, 0.6);
15061f9fd6d8SStephan Aßmus 	rgb_color shadow = tint_color(background, 1.21);
15071f9fd6d8SStephan Aßmus 
15081f9fd6d8SStephan Aßmus 	// frame
15091f9fd6d8SStephan Aßmus 	if (borders != 0 && rect.Width() > 3 && rect.Height() > 3)
15101f9fd6d8SStephan Aßmus 		DrawRaisedBorder(view, rect, updateRect, background, flags, borders);
15111f9fd6d8SStephan Aßmus 
15121f9fd6d8SStephan Aßmus 	// dots and rest of background
15131f9fd6d8SStephan Aßmus 	if (orientation == B_HORIZONTAL) {
15141f9fd6d8SStephan Aßmus 		if (rect.Width() > 2) {
15151f9fd6d8SStephan Aßmus 			// background on left/right
15161f9fd6d8SStephan Aßmus 			BRegion region(rect);
15171f9fd6d8SStephan Aßmus 			rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5);
15181f9fd6d8SStephan Aßmus 			rect.right = rect.left + 1;
15191f9fd6d8SStephan Aßmus 			region.Exclude(rect);
15201f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
15211f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
15221f9fd6d8SStephan Aßmus 		}
15231f9fd6d8SStephan Aßmus 
15241f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15251f9fd6d8SStephan Aßmus 		BPoint stop = rect.LeftBottom();
15261f9fd6d8SStephan Aßmus 		int32 num = 1;
15271f9fd6d8SStephan Aßmus 		while (dot.y <= stop.y) {
15281f9fd6d8SStephan Aßmus 			rgb_color col1;
15291f9fd6d8SStephan Aßmus 			rgb_color col2;
15301f9fd6d8SStephan Aßmus 			switch (num) {
15311f9fd6d8SStephan Aßmus 				case 1:
15321f9fd6d8SStephan Aßmus 					col1 = background;
15331f9fd6d8SStephan Aßmus 					col2 = background;
15341f9fd6d8SStephan Aßmus 					break;
15351f9fd6d8SStephan Aßmus 				case 2:
15361f9fd6d8SStephan Aßmus 					col1 = shadow;
15371f9fd6d8SStephan Aßmus 					col2 = background;
15381f9fd6d8SStephan Aßmus 					break;
15391f9fd6d8SStephan Aßmus 				case 3:
1540a5339f65SStephan Aßmus 				default:
15411f9fd6d8SStephan Aßmus 					col1 = background;
15421f9fd6d8SStephan Aßmus 					col2 = light;
15431f9fd6d8SStephan Aßmus 					num = 0;
15441f9fd6d8SStephan Aßmus 					break;
15451f9fd6d8SStephan Aßmus 			}
15461f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15471f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15481f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15491f9fd6d8SStephan Aßmus 			dot.x++;
15501f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15511f9fd6d8SStephan Aßmus 			dot.x -= 1.0;
15521f9fd6d8SStephan Aßmus 			// next pixel
15531f9fd6d8SStephan Aßmus 			num++;
15541f9fd6d8SStephan Aßmus 			dot.y++;
15551f9fd6d8SStephan Aßmus 		}
15561f9fd6d8SStephan Aßmus 	} else {
15571f9fd6d8SStephan Aßmus 		if (rect.Height() > 2) {
15581f9fd6d8SStephan Aßmus 			// background on left/right
15591f9fd6d8SStephan Aßmus 			BRegion region(rect);
15601f9fd6d8SStephan Aßmus 			rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5);
15611f9fd6d8SStephan Aßmus 			rect.bottom = rect.top + 1;
15621f9fd6d8SStephan Aßmus 			region.Exclude(rect);
15631f9fd6d8SStephan Aßmus 			view->SetHighColor(background);
15641f9fd6d8SStephan Aßmus 			view->FillRegion(&region);
15651f9fd6d8SStephan Aßmus 		}
15661f9fd6d8SStephan Aßmus 
15671f9fd6d8SStephan Aßmus 		BPoint dot = rect.LeftTop();
15681f9fd6d8SStephan Aßmus 		BPoint stop = rect.RightTop();
15691f9fd6d8SStephan Aßmus 		int32 num = 1;
15701f9fd6d8SStephan Aßmus 		while (dot.x <= stop.x) {
15711f9fd6d8SStephan Aßmus 			rgb_color col1;
15721f9fd6d8SStephan Aßmus 			rgb_color col2;
15731f9fd6d8SStephan Aßmus 			switch (num) {
15741f9fd6d8SStephan Aßmus 				case 1:
15751f9fd6d8SStephan Aßmus 					col1 = background;
15761f9fd6d8SStephan Aßmus 					col2 = background;
15771f9fd6d8SStephan Aßmus 					break;
15781f9fd6d8SStephan Aßmus 				case 2:
15791f9fd6d8SStephan Aßmus 					col1 = shadow;
15801f9fd6d8SStephan Aßmus 					col2 = background;
15811f9fd6d8SStephan Aßmus 					break;
15821f9fd6d8SStephan Aßmus 				case 3:
15839f981a88SFrançois Revol 				default:
15841f9fd6d8SStephan Aßmus 					col1 = background;
15851f9fd6d8SStephan Aßmus 					col2 = light;
15861f9fd6d8SStephan Aßmus 					num = 0;
15871f9fd6d8SStephan Aßmus 					break;
15881f9fd6d8SStephan Aßmus 			}
15891f9fd6d8SStephan Aßmus 			view->SetHighColor(col1);
15901f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15911f9fd6d8SStephan Aßmus 			view->SetHighColor(col2);
15921f9fd6d8SStephan Aßmus 			dot.y++;
15931f9fd6d8SStephan Aßmus 			view->StrokeLine(dot, dot, B_SOLID_HIGH);
15941f9fd6d8SStephan Aßmus 			dot.y -= 1.0;
15951f9fd6d8SStephan Aßmus 			// next pixel
15961f9fd6d8SStephan Aßmus 			num++;
15971f9fd6d8SStephan Aßmus 			dot.x++;
15981f9fd6d8SStephan Aßmus 		}
15991f9fd6d8SStephan Aßmus 	}
16001f9fd6d8SStephan Aßmus }
16011f9fd6d8SStephan Aßmus 
16021f9fd6d8SStephan Aßmus 
16032f86ba45SStephan Aßmus // #pragma mark -
16042f86ba45SStephan Aßmus 
16052f86ba45SStephan Aßmus 
16062f86ba45SStephan Aßmus void
16072f86ba45SStephan Aßmus BControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
16082f86ba45SStephan Aßmus 	const rgb_color& base, border_style border, uint32 flags, uint32 borders)
16092f86ba45SStephan Aßmus {
16102f86ba45SStephan Aßmus 	if (border == B_NO_BORDER)
16112f86ba45SStephan Aßmus 		return;
16122f86ba45SStephan Aßmus 
16132f86ba45SStephan Aßmus 	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
1614a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
16152f86ba45SStephan Aßmus 		scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
16162f86ba45SStephan Aßmus 
16172f86ba45SStephan Aßmus 	if (border == B_FANCY_BORDER)
16184f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
16192f86ba45SStephan Aßmus 
16202f86ba45SStephan Aßmus 	_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
16212f86ba45SStephan Aßmus 		scrollbarFrameColor, scrollbarFrameColor, borders);
16222f86ba45SStephan Aßmus }
16232f86ba45SStephan Aßmus 
16242f86ba45SStephan Aßmus 
16252f86ba45SStephan Aßmus void
16262f86ba45SStephan Aßmus BControlLook::DrawRaisedBorder(BView* view, BRect& rect,
16272f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16282f86ba45SStephan Aßmus 	uint32 borders)
16292f86ba45SStephan Aßmus {
16302f86ba45SStephan Aßmus 	rgb_color lightColor;
16312f86ba45SStephan Aßmus 	rgb_color shadowColor;
16322f86ba45SStephan Aßmus 
1633a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16342f86ba45SStephan Aßmus 		lightColor = base;
16352f86ba45SStephan Aßmus 		shadowColor = base;
16362f86ba45SStephan Aßmus 	} else {
16372f86ba45SStephan Aßmus 		lightColor = tint_color(base, 0.85);
16382f86ba45SStephan Aßmus 		shadowColor = tint_color(base, 1.07);
16392f86ba45SStephan Aßmus 	}
16402f86ba45SStephan Aßmus 
16412f86ba45SStephan Aßmus 	_DrawFrame(view, rect, lightColor, lightColor, shadowColor, shadowColor,
16422f86ba45SStephan Aßmus 		borders);
16432f86ba45SStephan Aßmus }
16442f86ba45SStephan Aßmus 
16452f86ba45SStephan Aßmus 
16462f86ba45SStephan Aßmus void
16472f86ba45SStephan Aßmus BControlLook::DrawTextControlBorder(BView* view, BRect& rect,
16482f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
16492f86ba45SStephan Aßmus 	uint32 borders)
16502f86ba45SStephan Aßmus {
16512f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
16522f86ba45SStephan Aßmus 		return;
16532f86ba45SStephan Aßmus 
16542f86ba45SStephan Aßmus 	rgb_color dark1BorderColor;
16552f86ba45SStephan Aßmus 	rgb_color dark2BorderColor;
16562f86ba45SStephan Aßmus 	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
16572f86ba45SStephan Aßmus 
1658a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
16594f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags, borders);
16602f86ba45SStephan Aßmus 
1661a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
16624f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 40 };
16634f579098SStephan Aßmus 		else
16642f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.15);
16654f579098SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
1666a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
16672f86ba45SStephan Aßmus 		dark1BorderColor = tint_color(base, 1.50);
16682f86ba45SStephan Aßmus 		dark2BorderColor = tint_color(base, 1.49);
16692f86ba45SStephan Aßmus 
16704f579098SStephan Aßmus 		// BCheckBox uses this to indicate the clicked state...
16712f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
16722f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16732f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor);
16742f86ba45SStephan Aßmus 
16752f86ba45SStephan Aßmus 		dark2BorderColor = dark1BorderColor;
16762f86ba45SStephan Aßmus 	} else {
16774f579098SStephan Aßmus 		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags, borders);
16782f86ba45SStephan Aßmus 
1679a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
16804f579098SStephan Aßmus 			dark1BorderColor = (rgb_color){ 0, 0, 0, 102 };
16814f579098SStephan Aßmus 			dark2BorderColor = (rgb_color){ 0, 0, 0, 97 };
16824f579098SStephan Aßmus 		} else {
16832f86ba45SStephan Aßmus 			dark1BorderColor = tint_color(base, 1.40);
16842f86ba45SStephan Aßmus 			dark2BorderColor = tint_color(base, 1.38);
16852f86ba45SStephan Aßmus 		}
16864f579098SStephan Aßmus 	}
16872f86ba45SStephan Aßmus 
1688a884b43bSJohn Scipione 	if ((flags & B_DISABLED) == 0 && (flags & B_FOCUSED) != 0) {
16892f86ba45SStephan Aßmus 		dark1BorderColor = navigationColor;
16902f86ba45SStephan Aßmus 		dark2BorderColor = navigationColor;
16912f86ba45SStephan Aßmus 	}
16922f86ba45SStephan Aßmus 
1693a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
16944f579098SStephan Aßmus 		drawing_mode oldMode = view->DrawingMode();
16954f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
16964f579098SStephan Aßmus 
16972f86ba45SStephan Aßmus 		_DrawFrame(view, rect,
16982f86ba45SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
16992f86ba45SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
17004f579098SStephan Aßmus 
17014f579098SStephan Aßmus 		view->SetDrawingMode(oldMode);
17024f579098SStephan Aßmus 	} else {
17034f579098SStephan Aßmus 		_DrawFrame(view, rect,
17044f579098SStephan Aßmus 			dark1BorderColor, dark1BorderColor,
17054f579098SStephan Aßmus 			dark2BorderColor, dark2BorderColor, borders);
17064f579098SStephan Aßmus 	}
17072f86ba45SStephan Aßmus }
17082f86ba45SStephan Aßmus 
17092f86ba45SStephan Aßmus 
17102f86ba45SStephan Aßmus void
17112f86ba45SStephan Aßmus BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect,
17122f86ba45SStephan Aßmus 	const rgb_color& base, uint32 borders)
17132f86ba45SStephan Aßmus {
17142f86ba45SStephan Aßmus 	rgb_color frameColor = tint_color(base, 1.30);
17152f86ba45SStephan Aßmus 	rgb_color bevelLight = tint_color(base, 0.8);
17162f86ba45SStephan Aßmus 	rgb_color bevelShadow = tint_color(base, 1.03);
17172f86ba45SStephan Aßmus 
17182f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelShadow, bevelShadow, bevelLight, bevelLight,
17192f86ba45SStephan Aßmus 		borders);
17202f86ba45SStephan Aßmus 
17212f86ba45SStephan Aßmus 	_DrawFrame(view, rect, frameColor, frameColor, frameColor, frameColor,
17222f86ba45SStephan Aßmus 		borders);
17232f86ba45SStephan Aßmus 
17242f86ba45SStephan Aßmus 	_DrawFrame(view, rect, bevelLight, bevelLight, bevelShadow, bevelShadow,
17252f86ba45SStephan Aßmus 		borders);
17262f86ba45SStephan Aßmus }
17272f86ba45SStephan Aßmus 
17282f86ba45SStephan Aßmus 
17292f86ba45SStephan Aßmus void
17302f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17312f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags)
17322f86ba45SStephan Aßmus {
17332f86ba45SStephan Aßmus 	DrawLabel(view, label, rect, updateRect, base, flags,
17342f86ba45SStephan Aßmus 		DefaultLabelAlignment());
17352f86ba45SStephan Aßmus }
17362f86ba45SStephan Aßmus 
17372f86ba45SStephan Aßmus 
17382f86ba45SStephan Aßmus void
17392f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect,
17402f86ba45SStephan Aßmus 	const BRect& updateRect, const rgb_color& base, uint32 flags,
17412f86ba45SStephan Aßmus 	const BAlignment& alignment)
17422f86ba45SStephan Aßmus {
17432f86ba45SStephan Aßmus 	if (!rect.Intersects(updateRect))
17442f86ba45SStephan Aßmus 		return;
17452f86ba45SStephan Aßmus 
17462f86ba45SStephan Aßmus 	// truncate the label if necessary and get the width and height
17472f86ba45SStephan Aßmus 	BString truncatedLabel(label);
17482f86ba45SStephan Aßmus 
17492f86ba45SStephan Aßmus 	BFont font;
17502f86ba45SStephan Aßmus 	view->GetFont(&font);
17512f86ba45SStephan Aßmus 
17522f86ba45SStephan Aßmus 	float width = rect.Width();
17532f86ba45SStephan Aßmus 	font.TruncateString(&truncatedLabel, B_TRUNCATE_END, width);
17542f86ba45SStephan Aßmus 	width = font.StringWidth(truncatedLabel.String());
17552f86ba45SStephan Aßmus 
17562f86ba45SStephan Aßmus 	font_height fontHeight;
17572f86ba45SStephan Aßmus 	font.GetHeight(&fontHeight);
17582f86ba45SStephan Aßmus 	float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
17592f86ba45SStephan Aßmus 
17602f86ba45SStephan Aßmus 	// handle alignment
17612f86ba45SStephan Aßmus 	BPoint location;
17622f86ba45SStephan Aßmus 
17632f86ba45SStephan Aßmus 	switch (alignment.horizontal) {
17642f86ba45SStephan Aßmus 	default:
17652f86ba45SStephan Aßmus 		case B_ALIGN_LEFT:
17662f86ba45SStephan Aßmus 			location.x = rect.left;
17672f86ba45SStephan Aßmus 			break;
17682f86ba45SStephan Aßmus 		case B_ALIGN_RIGHT:
17692f86ba45SStephan Aßmus 			location.x = rect.right - width;
17702f86ba45SStephan Aßmus 			break;
17712f86ba45SStephan Aßmus 		case B_ALIGN_CENTER:
17722f86ba45SStephan Aßmus 			location.x = (rect.left + rect.right - width) / 2.0f;
17732f86ba45SStephan Aßmus 			break;
17742f86ba45SStephan Aßmus 	}
17752f86ba45SStephan Aßmus 
17762f86ba45SStephan Aßmus 	switch (alignment.vertical) {
17772f86ba45SStephan Aßmus 		case B_ALIGN_TOP:
17782f86ba45SStephan Aßmus 			location.y = rect.top + ceilf(fontHeight.ascent);
17792f86ba45SStephan Aßmus 			break;
17802f86ba45SStephan Aßmus 		default:
17812f86ba45SStephan Aßmus 		case B_ALIGN_MIDDLE:
17822f86ba45SStephan Aßmus 			location.y = floorf((rect.top + rect.bottom - height) / 2.0f + 0.5f)
17832f86ba45SStephan Aßmus 				+ ceilf(fontHeight.ascent);
17842f86ba45SStephan Aßmus 			break;
17852f86ba45SStephan Aßmus 		case B_ALIGN_BOTTOM:
17862f86ba45SStephan Aßmus 			location.y = rect.bottom - ceilf(fontHeight.descent);
17872f86ba45SStephan Aßmus 			break;
17882f86ba45SStephan Aßmus 	}
17892f86ba45SStephan Aßmus 
1790c4e211feSStephan Aßmus 	DrawLabel(view, truncatedLabel.String(), base, flags, location);
1791c4e211feSStephan Aßmus }
1792c4e211feSStephan Aßmus 
1793c4e211feSStephan Aßmus 
1794c4e211feSStephan Aßmus void
1795c4e211feSStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base,
1796c4e211feSStephan Aßmus 	uint32 flags, const BPoint& where)
1797c4e211feSStephan Aßmus {
1798c4e211feSStephan Aßmus 	// setup the text color
1799c4e211feSStephan Aßmus 	// TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here,
1800c4e211feSStephan Aßmus 	// or elliminate that constant alltogether (stippi: +1).
1801d63b75faSPhilippe Saint-Pierre 
1802d63b75faSPhilippe Saint-Pierre 	BWindow* window = view->Window();
1803d63b75faSPhilippe Saint-Pierre 	bool isDesktop = window
1804d63b75faSPhilippe Saint-Pierre 		&& window->Feel() == kPrivateDesktopWindowFeel
1805d63b75faSPhilippe Saint-Pierre 		&& window->Look() == kPrivateDesktopWindowLook
1806d63b75faSPhilippe Saint-Pierre 		&& view->Parent()
1807d63b75faSPhilippe Saint-Pierre 		&& view->Parent()->Parent() == NULL
1808d63b75faSPhilippe Saint-Pierre 		&& (flags & B_IGNORE_OUTLINE) == 0;
1809d63b75faSPhilippe Saint-Pierre 
1810d63b75faSPhilippe Saint-Pierre 	rgb_color	low;
1811c4e211feSStephan Aßmus 	rgb_color	color;
1812d63b75faSPhilippe Saint-Pierre 	rgb_color	glowColor;
1813d63b75faSPhilippe Saint-Pierre 
1814d63b75faSPhilippe Saint-Pierre 	if (isDesktop)
1815d63b75faSPhilippe Saint-Pierre 		low = view->Parent()->ViewColor();
1816c4e211feSStephan Aßmus 	else
1817d63b75faSPhilippe Saint-Pierre 		low = base;
1818d63b75faSPhilippe Saint-Pierre 
1819d63b75faSPhilippe Saint-Pierre 	if (low.red + low.green + low.blue > 128 * 3) {
1820d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_DARKEN_MAX_TINT);
1821d63b75faSPhilippe Saint-Pierre 		glowColor = kWhite;
1822d63b75faSPhilippe Saint-Pierre 	} else {
1823d63b75faSPhilippe Saint-Pierre 		color = tint_color(low, B_LIGHTEN_MAX_TINT);
1824d63b75faSPhilippe Saint-Pierre 		glowColor = kBlack;
1825d63b75faSPhilippe Saint-Pierre 	}
1826c4e211feSStephan Aßmus 
1827a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
1828d63b75faSPhilippe Saint-Pierre 		color.red = (uint8)(((int32)low.red + color.red + 1) / 2);
1829d63b75faSPhilippe Saint-Pierre 		color.green = (uint8)(((int32)low.green + color.green + 1) / 2);
1830d63b75faSPhilippe Saint-Pierre 		color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2);
1831d63b75faSPhilippe Saint-Pierre 	}
1832d63b75faSPhilippe Saint-Pierre 
1833d63b75faSPhilippe Saint-Pierre 	drawing_mode oldMode = view->DrawingMode();
1834d63b75faSPhilippe Saint-Pierre 
1835d63b75faSPhilippe Saint-Pierre 	if (isDesktop) {
1836a884b43bSJohn Scipione 		// drawing occurs on the desktop
1837d63b75faSPhilippe Saint-Pierre 		if (fCachedWorkspace != current_workspace()) {
1838d63b75faSPhilippe Saint-Pierre 			int8 indice = 0;
1839d63b75faSPhilippe Saint-Pierre 			int32 mask;
1840d63b75faSPhilippe Saint-Pierre 			bool tmpOutline;
1841d63b75faSPhilippe Saint-Pierre 			while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces",
1842d63b75faSPhilippe Saint-Pierre 					indice, &mask) == B_OK
1843d63b75faSPhilippe Saint-Pierre 				&& fBackgroundInfo.FindBool("be:bgndimginfoerasetext",
1844d63b75faSPhilippe Saint-Pierre 					indice, &tmpOutline) == B_OK) {
1845d63b75faSPhilippe Saint-Pierre 
1846d63b75faSPhilippe Saint-Pierre 				if (((1 << current_workspace()) & mask) != 0) {
1847d63b75faSPhilippe Saint-Pierre 					fCachedOutline = tmpOutline;
1848d63b75faSPhilippe Saint-Pierre 					fCachedWorkspace = current_workspace();
1849d63b75faSPhilippe Saint-Pierre 					break;
1850d63b75faSPhilippe Saint-Pierre 				}
1851d63b75faSPhilippe Saint-Pierre 				indice++;
1852d63b75faSPhilippe Saint-Pierre 			}
1853d63b75faSPhilippe Saint-Pierre 		}
1854d63b75faSPhilippe Saint-Pierre 
1855d63b75faSPhilippe Saint-Pierre 		if (fCachedOutline) {
1856d63b75faSPhilippe Saint-Pierre 			BFont font;
1857d63b75faSPhilippe Saint-Pierre 			view->GetFont(&font);
1858d63b75faSPhilippe Saint-Pierre 
1859d63b75faSPhilippe Saint-Pierre 			view->SetDrawingMode(B_OP_ALPHA);
1860d63b75faSPhilippe Saint-Pierre 			view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
1861d63b75faSPhilippe Saint-Pierre 			// Draw glow or outline
1862d63b75faSPhilippe Saint-Pierre 			if (glowColor == kWhite) {
1863d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(2.0);
1864d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1865d63b75faSPhilippe Saint-Pierre 
1866d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1867d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1868d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1869d63b75faSPhilippe Saint-Pierre 
1870d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1871d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1872d63b75faSPhilippe Saint-Pierre 
1873d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 65;
1874d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1875d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1876d63b75faSPhilippe Saint-Pierre 
1877d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1878d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1879d63b75faSPhilippe Saint-Pierre 			} else if (glowColor == kBlack) {
1880d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(1.0);
1881d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1882d63b75faSPhilippe Saint-Pierre 
1883d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 30;
1884d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1885d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, where);
1886d63b75faSPhilippe Saint-Pierre 
1887d63b75faSPhilippe Saint-Pierre 				font.SetFalseBoldWidth(0.0);
1888d63b75faSPhilippe Saint-Pierre 				view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
1889d63b75faSPhilippe Saint-Pierre 
1890d63b75faSPhilippe Saint-Pierre 				glowColor.alpha = 200;
1891d63b75faSPhilippe Saint-Pierre 				view->SetHighColor(glowColor);
1892d63b75faSPhilippe Saint-Pierre 				view->DrawString(label, BPoint(where.x + 1, where.y + 1));
1893d63b75faSPhilippe Saint-Pierre 			}
1894d63b75faSPhilippe Saint-Pierre 		}
1895c4e211feSStephan Aßmus 	}
1896c4e211feSStephan Aßmus 
1897c4e211feSStephan Aßmus 	view->SetHighColor(color);
1898c4e211feSStephan Aßmus 	view->SetDrawingMode(B_OP_OVER);
1899c4e211feSStephan Aßmus 	view->DrawString(label, where);
1900c4e211feSStephan Aßmus 	view->SetDrawingMode(oldMode);
19012f86ba45SStephan Aßmus }
19022f86ba45SStephan Aßmus 
19032f86ba45SStephan Aßmus 
1904d63b75faSPhilippe Saint-Pierre void
1905*8719e0dcSIngo Weinhold BControlLook::GetFrameInsets(frame_type frameType, uint32 flags, float& _left,
1906*8719e0dcSIngo Weinhold 	float& _top, float& _right, float& _bottom)
1907*8719e0dcSIngo Weinhold {
1908*8719e0dcSIngo Weinhold 	// All frames have the same inset on each side.
1909*8719e0dcSIngo Weinhold 	float inset = 0;
1910*8719e0dcSIngo Weinhold 
1911*8719e0dcSIngo Weinhold 	switch (frameType) {
1912*8719e0dcSIngo Weinhold 		case B_BUTTON_FRAME:
1913*8719e0dcSIngo Weinhold 			inset = (flags & B_DEFAULT_BUTTON) != 0 ? 6 : 3;
1914*8719e0dcSIngo Weinhold 			break;
1915*8719e0dcSIngo Weinhold 		case B_GROUP_FRAME:
1916*8719e0dcSIngo Weinhold 		case B_MENU_FIELD_FRAME:
1917*8719e0dcSIngo Weinhold 			inset = 3;
1918*8719e0dcSIngo Weinhold 			break;
1919*8719e0dcSIngo Weinhold 		case B_SCROLL_VIEW_FRAME:
1920*8719e0dcSIngo Weinhold 		case B_TEXT_CONTROL_FRAME:
1921*8719e0dcSIngo Weinhold 			inset = 2;
1922*8719e0dcSIngo Weinhold 			break;
1923*8719e0dcSIngo Weinhold 	}
1924*8719e0dcSIngo Weinhold 
1925*8719e0dcSIngo Weinhold 	_left = inset;
1926*8719e0dcSIngo Weinhold 	_top = inset;
1927*8719e0dcSIngo Weinhold 	_right = inset;
1928*8719e0dcSIngo Weinhold 	_bottom = inset;
1929*8719e0dcSIngo Weinhold }
1930*8719e0dcSIngo Weinhold 
1931*8719e0dcSIngo Weinhold 
1932*8719e0dcSIngo Weinhold void
1933*8719e0dcSIngo Weinhold BControlLook::GetBackgroundInsets(background_type backgroundType,
1934*8719e0dcSIngo Weinhold 	uint32 flags, float& _left, float& _top, float& _right, float& _bottom)
1935*8719e0dcSIngo Weinhold {
1936*8719e0dcSIngo Weinhold 	// Most backgrounds have the same inset on each side.
1937*8719e0dcSIngo Weinhold 	float inset = 0;
1938*8719e0dcSIngo Weinhold 
1939*8719e0dcSIngo Weinhold 	switch (backgroundType) {
1940*8719e0dcSIngo Weinhold 		case B_BUTTON_BACKGROUND:
1941*8719e0dcSIngo Weinhold 		case B_MENU_BACKGROUND:
1942*8719e0dcSIngo Weinhold 		case B_MENU_BAR_BACKGROUND:
1943*8719e0dcSIngo Weinhold 		case B_MENU_FIELD_BACKGROUND:
1944*8719e0dcSIngo Weinhold 		case B_MENU_ITEM_BACKGROUND:
1945*8719e0dcSIngo Weinhold 			inset = 1;
1946*8719e0dcSIngo Weinhold 			break;
1947*8719e0dcSIngo Weinhold 		case B_HORIZONTAL_SCROLL_BAR_BACKGROUND:
1948*8719e0dcSIngo Weinhold 			_left = 2;
1949*8719e0dcSIngo Weinhold 			_top = 0;
1950*8719e0dcSIngo Weinhold 			_right = 1;
1951*8719e0dcSIngo Weinhold 			_bottom = 0;
1952*8719e0dcSIngo Weinhold 			return;
1953*8719e0dcSIngo Weinhold 		case B_VERTICAL_SCROLL_BAR_BACKGROUND:
1954*8719e0dcSIngo Weinhold 			_left = 0;
1955*8719e0dcSIngo Weinhold 			_top = 2;
1956*8719e0dcSIngo Weinhold 			_right = 0;
1957*8719e0dcSIngo Weinhold 			_bottom = 1;
1958*8719e0dcSIngo Weinhold 			return;
1959*8719e0dcSIngo Weinhold 	}
1960*8719e0dcSIngo Weinhold 
1961*8719e0dcSIngo Weinhold 	_left = inset;
1962*8719e0dcSIngo Weinhold 	_top = inset;
1963*8719e0dcSIngo Weinhold 	_right = inset;
1964*8719e0dcSIngo Weinhold 	_bottom = inset;
1965*8719e0dcSIngo Weinhold }
1966*8719e0dcSIngo Weinhold 
1967*8719e0dcSIngo Weinhold 
1968*8719e0dcSIngo Weinhold void
1969*8719e0dcSIngo Weinhold BControlLook::GetInsets(frame_type frameType, background_type backgroundType,
1970*8719e0dcSIngo Weinhold 	uint32 flags, float& _left, float& _top, float& _right, float& _bottom)
1971*8719e0dcSIngo Weinhold {
1972*8719e0dcSIngo Weinhold 	GetFrameInsets(frameType, flags, _left, _top, _right, _bottom);
1973*8719e0dcSIngo Weinhold 
1974*8719e0dcSIngo Weinhold 	float left, top, right, bottom;
1975*8719e0dcSIngo Weinhold 	GetBackgroundInsets(backgroundType, flags, left, top, right, bottom);
1976*8719e0dcSIngo Weinhold 
1977*8719e0dcSIngo Weinhold 	_left += left;
1978*8719e0dcSIngo Weinhold 	_top += top;
1979*8719e0dcSIngo Weinhold 	_right += right;
1980*8719e0dcSIngo Weinhold 	_bottom += bottom;
1981*8719e0dcSIngo Weinhold }
1982*8719e0dcSIngo Weinhold 
1983*8719e0dcSIngo Weinhold 
1984*8719e0dcSIngo Weinhold void
1985d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo)
1986d63b75faSPhilippe Saint-Pierre {
1987d452ff66SAxel Dörfler 	fBackgroundInfo = backgroundInfo;
1988d63b75faSPhilippe Saint-Pierre 	fCachedWorkspace = -1;
1989d63b75faSPhilippe Saint-Pierre }
1990d63b75faSPhilippe Saint-Pierre 
1991d63b75faSPhilippe Saint-Pierre 
19922f86ba45SStephan Aßmus // #pragma mark -
19932f86ba45SStephan Aßmus 
19942f86ba45SStephan Aßmus 
19952f86ba45SStephan Aßmus void
199613cd46dfSStephan Aßmus BControlLook::_DrawButtonFrame(BView* view, BRect& rect,
1997a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
1998a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
1999a884b43bSJohn Scipione 	const rgb_color& background, float contrast, float brightness,
2000a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
200113cd46dfSStephan Aßmus {
2002a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2003a884b43bSJohn Scipione 		return;
200413cd46dfSStephan Aßmus 
20054fa76719SJohn Scipione 	// save the clipping constraints of the view
20064fa76719SJohn Scipione 	view->PushState();
200713cd46dfSStephan Aßmus 
20085666b4f7SJohn Scipione 	// set clipping constraints to updateRect
20094fa76719SJohn Scipione 	BRegion clipping(updateRect);
2010a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2011a884b43bSJohn Scipione 
2012a884b43bSJohn Scipione 	// outer edge colors
2013a884b43bSJohn Scipione 	rgb_color edgeLightColor;
2014a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
2015a884b43bSJohn Scipione 
2016a884b43bSJohn Scipione 	// default button frame color
20174f579098SStephan Aßmus 	// TODO: B_BLEND_FRAME
2018a884b43bSJohn Scipione 	float defaultIndicatorTint = 1.2;
2019a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
2020a884b43bSJohn Scipione 		defaultIndicatorTint = (B_NO_TINT + defaultIndicatorTint) / 2;
202113cd46dfSStephan Aßmus 
2022a884b43bSJohn Scipione 	rgb_color defaultIndicatorColor = tint_color(base, defaultIndicatorTint);
202388969219SJohn Scipione 	rgb_color cornerBgColor;
202488969219SJohn Scipione 
202588969219SJohn Scipione 	drawing_mode oldMode = view->DrawingMode();
202613cd46dfSStephan Aßmus 
2027a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
202888969219SJohn Scipione 		cornerBgColor = defaultIndicatorColor;
2029a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(defaultIndicatorColor,
2030a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2031a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
2032a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(defaultIndicatorColor,
2033a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2034a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags);
203513cd46dfSStephan Aßmus 
203688969219SJohn Scipione 		// draw default button indicator
2037a884b43bSJohn Scipione 		view->SetHighColor(background);
2038a884b43bSJohn Scipione 		view->FillRect(rect);
203913cd46dfSStephan Aßmus 		view->SetHighColor(base);
2040a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
2041a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
204213cd46dfSStephan Aßmus 
2043a884b43bSJohn Scipione 		view->SetHighColor(defaultIndicatorColor);
2044a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
2045a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
204613cd46dfSStephan Aßmus 
2047a884b43bSJohn Scipione 		view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius);
2048a884b43bSJohn Scipione 		rect.InsetBy(1, 1);
204913cd46dfSStephan Aßmus 	} else {
205088969219SJohn Scipione 		cornerBgColor = background;
205141651bb3SJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0) {
205241651bb3SJohn Scipione 			// set the background color to transparent for the case
205341651bb3SJohn Scipione 			// that we are on the desktop
205441651bb3SJohn Scipione 			cornerBgColor.alpha = 0;
205541651bb3SJohn Scipione 			view->SetDrawingMode(B_OP_ALPHA);
205641651bb3SJohn Scipione 		}
205788969219SJohn Scipione 
2058a884b43bSJohn Scipione 		edgeLightColor = _EdgeLightColor(background,
2059a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
2060a884b43bSJohn Scipione 			brightness * 1.0, flags);
2061a884b43bSJohn Scipione 		edgeShadowColor = _EdgeShadowColor(background,
2062a884b43bSJohn Scipione 			contrast * (flags & B_DISABLED) != 0 ? 0.0 : 1.0,
2063a884b43bSJohn Scipione 			brightness * 1.0, flags);
206413cd46dfSStephan Aßmus 	}
206513cd46dfSStephan Aßmus 
2066a884b43bSJohn Scipione 	// frame colors
2067a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
2068a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
2069a884b43bSJohn Scipione 
2070a884b43bSJohn Scipione 	// rounded corners
2071a884b43bSJohn Scipione 
2072a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2073a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2074a884b43bSJohn Scipione 		// draw left top rounded corner
2075a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2076a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius),
2077a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius));
2078a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2079a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect,
2080a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, frameLightColor);
2081a884b43bSJohn Scipione 	}
2082a884b43bSJohn Scipione 
2083a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2084a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2085a884b43bSJohn Scipione 		// draw right top rounded corner
2086a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius),
2087a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2088a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius));
2089a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2090a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect,
2091a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
2092a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
2093a884b43bSJohn Scipione 	}
2094a884b43bSJohn Scipione 
2095a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2096a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2097a884b43bSJohn Scipione 		// draw left bottom rounded corner
2098a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2099a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius),
2100a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius), floorf(rect.bottom));
2101a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2102a884b43bSJohn Scipione 		_DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect,
2103a884b43bSJohn Scipione 			cornerBgColor, edgeShadowColor, edgeLightColor,
2104a884b43bSJohn Scipione 			frameLightColor, frameShadowColor);
2105a884b43bSJohn Scipione 	}
2106a884b43bSJohn Scipione 
2107a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2108a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2109a884b43bSJohn Scipione 		// draw right bottom rounded corner
2110a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius),
2111a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius), floorf(rect.right),
2112a884b43bSJohn Scipione 			floorf(rect.bottom));
2113a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2114a884b43bSJohn Scipione 		_DrawRoundCornerFrameRightBottom(view, rightBottomCorner,
2115a884b43bSJohn Scipione 			updateRect, cornerBgColor, edgeLightColor, frameShadowColor);
2116a884b43bSJohn Scipione 	}
2117a884b43bSJohn Scipione 
2118a884b43bSJohn Scipione 	// clip out the corners
2119a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2120a884b43bSJohn Scipione 
2121a884b43bSJohn Scipione 	// draw outer edge
2122a884b43bSJohn Scipione 	if ((flags & B_DEFAULT_BUTTON) != 0) {
2123a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, defaultIndicatorColor,
2124a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8),
2125a884b43bSJohn Scipione 			brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9),
2126a884b43bSJohn Scipione 			flags, borders);
2127a884b43bSJohn Scipione 	} else {
2128a884b43bSJohn Scipione 		_DrawOuterResessedFrame(view, rect, background,
2129a884b43bSJohn Scipione 			contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0),
2130a884b43bSJohn Scipione 			brightness * 1.0, flags, borders);
2131a884b43bSJohn Scipione 	}
2132a884b43bSJohn Scipione 
213388969219SJohn Scipione 	view->SetDrawingMode(oldMode);
213488969219SJohn Scipione 
2135a884b43bSJohn Scipione 	// draw frame
2136a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
21374f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
21384f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
21394f579098SStephan Aßmus 
2140a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2141a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
21424f579098SStephan Aßmus 
21434f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
21444f579098SStephan Aßmus 	} else {
2145a884b43bSJohn Scipione 		_DrawFrame(view, rect, frameLightColor, frameLightColor,
2146a884b43bSJohn Scipione 			frameShadowColor, frameShadowColor, borders);
21474f579098SStephan Aßmus 	}
2148a884b43bSJohn Scipione 
21494fa76719SJohn Scipione 	// restore the clipping constraints of the view
21504fa76719SJohn Scipione 	view->PopState();
215113cd46dfSStephan Aßmus }
215213cd46dfSStephan Aßmus 
215313cd46dfSStephan Aßmus 
215413cd46dfSStephan Aßmus void
21552f86ba45SStephan Aßmus BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect,
21564f579098SStephan Aßmus 	const rgb_color& base, float contrast, float brightness, uint32 flags,
21574f579098SStephan Aßmus 	uint32 borders)
21582f86ba45SStephan Aßmus {
2159a884b43bSJohn Scipione 	rgb_color edgeLightColor = _EdgeLightColor(base, contrast,
2160a884b43bSJohn Scipione 		brightness, flags);
2161a884b43bSJohn Scipione 	rgb_color edgeShadowColor = _EdgeShadowColor(base, contrast,
2162a884b43bSJohn Scipione 		brightness, flags);
2163a884b43bSJohn Scipione 
2164a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
21654f579098SStephan Aßmus 		// assumes the background has already been painted
21664f579098SStephan Aßmus 		drawing_mode oldDrawingMode = view->DrawingMode();
21674f579098SStephan Aßmus 		view->SetDrawingMode(B_OP_ALPHA);
21684f579098SStephan Aßmus 
2169a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2170a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
21714f579098SStephan Aßmus 
21724f579098SStephan Aßmus 		view->SetDrawingMode(oldDrawingMode);
21734f579098SStephan Aßmus 	} else {
2174a884b43bSJohn Scipione 		_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor,
2175a884b43bSJohn Scipione 			edgeLightColor, edgeLightColor, borders);
21762f86ba45SStephan Aßmus 	}
21774f579098SStephan Aßmus }
21782f86ba45SStephan Aßmus 
21792f86ba45SStephan Aßmus 
21802f86ba45SStephan Aßmus void
21812f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
21822f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
21832f86ba45SStephan Aßmus 	uint32 borders)
21842f86ba45SStephan Aßmus {
21852f86ba45SStephan Aßmus 	view->BeginLineArray(4);
21862f86ba45SStephan Aßmus 
21872f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
21882f86ba45SStephan Aßmus 		view->AddLine(
21892f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
21902f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top), left);
21912f86ba45SStephan Aßmus 		rect.left++;
21922f86ba45SStephan Aßmus 	}
21932f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
21942f86ba45SStephan Aßmus 		view->AddLine(
21952f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
21962f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), top);
21972f86ba45SStephan Aßmus 		rect.top++;
21982f86ba45SStephan Aßmus 	}
21992f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
22002f86ba45SStephan Aßmus 		view->AddLine(
22012f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top),
22022f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), right);
22032f86ba45SStephan Aßmus 		rect.right--;
22042f86ba45SStephan Aßmus 	}
22052f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
22062f86ba45SStephan Aßmus 		view->AddLine(
22072f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
22082f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
22092f86ba45SStephan Aßmus 		rect.bottom--;
22102f86ba45SStephan Aßmus 	}
22112f86ba45SStephan Aßmus 
22122f86ba45SStephan Aßmus 	view->EndLineArray();
22132f86ba45SStephan Aßmus }
22142f86ba45SStephan Aßmus 
22152f86ba45SStephan Aßmus 
22162f86ba45SStephan Aßmus void
22172f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left,
22182f86ba45SStephan Aßmus 	const rgb_color& top, const rgb_color& right, const rgb_color& bottom,
22192f86ba45SStephan Aßmus 	const rgb_color& rightTop, const rgb_color& leftBottom, uint32 borders)
22202f86ba45SStephan Aßmus {
22212f86ba45SStephan Aßmus 	view->BeginLineArray(6);
22222f86ba45SStephan Aßmus 
22232f86ba45SStephan Aßmus 	if (borders & B_TOP_BORDER) {
22242f86ba45SStephan Aßmus 		if (borders & B_RIGHT_BORDER) {
22252f86ba45SStephan Aßmus 			view->AddLine(
22262f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
22272f86ba45SStephan Aßmus 				BPoint(rect.right - 1, rect.top), top);
22282f86ba45SStephan Aßmus 			view->AddLine(
22292f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top),
22302f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), rightTop);
22312f86ba45SStephan Aßmus 		} else {
22322f86ba45SStephan Aßmus 			view->AddLine(
22332f86ba45SStephan Aßmus 				BPoint(rect.left, rect.top),
22342f86ba45SStephan Aßmus 				BPoint(rect.right, rect.top), top);
22352f86ba45SStephan Aßmus 		}
22362f86ba45SStephan Aßmus 		rect.top++;
22372f86ba45SStephan Aßmus 	}
22382f86ba45SStephan Aßmus 
22392f86ba45SStephan Aßmus 	if (borders & B_LEFT_BORDER) {
22402f86ba45SStephan Aßmus 		view->AddLine(
22412f86ba45SStephan Aßmus 			BPoint(rect.left, rect.top),
22422f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom - 1), left);
22432f86ba45SStephan Aßmus 		view->AddLine(
22442f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
22452f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom), leftBottom);
22462f86ba45SStephan Aßmus 		rect.left++;
22472f86ba45SStephan Aßmus 	}
22482f86ba45SStephan Aßmus 
22492f86ba45SStephan Aßmus 	if (borders & B_BOTTOM_BORDER) {
22502f86ba45SStephan Aßmus 		view->AddLine(
22512f86ba45SStephan Aßmus 			BPoint(rect.left, rect.bottom),
22522f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom), bottom);
22532f86ba45SStephan Aßmus 		rect.bottom--;
22542f86ba45SStephan Aßmus 	}
22552f86ba45SStephan Aßmus 
22562f86ba45SStephan Aßmus 	if (borders & B_RIGHT_BORDER) {
22572f86ba45SStephan Aßmus 		view->AddLine(
22582f86ba45SStephan Aßmus 			BPoint(rect.right, rect.bottom),
22592f86ba45SStephan Aßmus 			BPoint(rect.right, rect.top), right);
22602f86ba45SStephan Aßmus 		rect.right--;
22612f86ba45SStephan Aßmus 	}
22622f86ba45SStephan Aßmus 
22632f86ba45SStephan Aßmus 	view->EndLineArray();
22642f86ba45SStephan Aßmus }
22652f86ba45SStephan Aßmus 
22662f86ba45SStephan Aßmus 
22672f86ba45SStephan Aßmus void
2268a884b43bSJohn Scipione BControlLook::_DrawButtonBackground(BView* view, BRect& rect,
2269a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2270a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2271e724b26fSJohn Scipione 	uint32 flags, uint32 borders, orientation orientation)
22722f86ba45SStephan Aßmus {
2273a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2274a884b43bSJohn Scipione 		return;
22752f86ba45SStephan Aßmus 
22764fa76719SJohn Scipione 	// save the clipping constraints of the view
22774fa76719SJohn Scipione 	view->PushState();
22782f86ba45SStephan Aßmus 
22795666b4f7SJohn Scipione 	// set clipping constraints to updateRect
22804fa76719SJohn Scipione 	BRegion clipping(updateRect);
2281a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
22822f86ba45SStephan Aßmus 
2283a884b43bSJohn Scipione 	// inner bevel colors
2284a884b43bSJohn Scipione 	rgb_color bevelLightColor  = _BevelLightColor(base, flags);
2285a884b43bSJohn Scipione 	rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2286a884b43bSJohn Scipione 
2287a884b43bSJohn Scipione 	// button background color
2288a884b43bSJohn Scipione 	rgb_color buttonBgColor;
2289a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
2290a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, 0.7);
22912f86ba45SStephan Aßmus 	else
2292a884b43bSJohn Scipione 		buttonBgColor = tint_color(base, B_LIGHTEN_1_TINT);
2293a884b43bSJohn Scipione 
2294a884b43bSJohn Scipione 	// surface top gradient
2295a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2296a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, base, flags, orientation);
2297a884b43bSJohn Scipione 
2298a884b43bSJohn Scipione 	// rounded corners
2299a884b43bSJohn Scipione 
2300a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2301a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2302a884b43bSJohn Scipione 		// draw left top rounded corner
2303a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2304a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2305a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2306a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2307a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2308a884b43bSJohn Scipione 			bevelLightColor, fillGradient);
2309a884b43bSJohn Scipione 	}
2310a884b43bSJohn Scipione 
2311a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2312a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2313a884b43bSJohn Scipione 		// draw right top rounded corner
2314a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2315a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2316a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2317a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2318a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner,
2319a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2320a884b43bSJohn Scipione 	}
2321a884b43bSJohn Scipione 
2322a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2323a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2324a884b43bSJohn Scipione 		// draw left bottom rounded corner
2325a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2326a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2327a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2328a884b43bSJohn Scipione 			floorf(rect.bottom));
2329a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2330a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2331a884b43bSJohn Scipione 			updateRect, bevelLightColor, bevelShadowColor, fillGradient);
2332a884b43bSJohn Scipione 	}
2333a884b43bSJohn Scipione 
2334a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2335a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2336a884b43bSJohn Scipione 		// draw right bottom rounded corner
2337a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2338a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2339a884b43bSJohn Scipione 			floorf(rect.bottom));
2340a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2341a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2342a884b43bSJohn Scipione 			updateRect, bevelShadowColor, fillGradient);
2343a884b43bSJohn Scipione 	}
2344a884b43bSJohn Scipione 
2345a884b43bSJohn Scipione 	// clip out the corners
2346a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2347a884b43bSJohn Scipione 
2348a884b43bSJohn Scipione 	// draw inner bevel
2349a884b43bSJohn Scipione 
2350a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
2351a884b43bSJohn Scipione 		view->BeginLineArray(4);
2352a884b43bSJohn Scipione 
2353a884b43bSJohn Scipione 		// shadow along left/top borders
2354a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2355a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2356a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelLightColor);
2357a884b43bSJohn Scipione 			rect.left++;
2358a884b43bSJohn Scipione 		}
2359a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2360a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2361a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelLightColor);
2362a884b43bSJohn Scipione 			rect.top++;
2363a884b43bSJohn Scipione 		}
2364a884b43bSJohn Scipione 
2365a884b43bSJohn Scipione 		// softer shadow along left/top borders
2366a884b43bSJohn Scipione 		if (borders & B_LEFT_BORDER) {
2367a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2368a884b43bSJohn Scipione 				BPoint(rect.left, rect.bottom), bevelShadowColor);
2369a884b43bSJohn Scipione 			rect.left++;
2370a884b43bSJohn Scipione 		}
2371a884b43bSJohn Scipione 		if (borders & B_TOP_BORDER) {
2372a884b43bSJohn Scipione 			view->AddLine(BPoint(rect.left, rect.top),
2373a884b43bSJohn Scipione 				BPoint(rect.right, rect.top), bevelShadowColor);
2374a884b43bSJohn Scipione 			rect.top++;
2375a884b43bSJohn Scipione 		}
2376a884b43bSJohn Scipione 
2377a884b43bSJohn Scipione 		view->EndLineArray();
2378a884b43bSJohn Scipione 	} else {
2379a884b43bSJohn Scipione 		_DrawFrame(view, rect,
2380a884b43bSJohn Scipione 			bevelLightColor, bevelLightColor,
2381a884b43bSJohn Scipione 			bevelShadowColor, bevelShadowColor,
2382a884b43bSJohn Scipione 			buttonBgColor, buttonBgColor, borders);
2383a884b43bSJohn Scipione 	}
2384a884b43bSJohn Scipione 
2385a884b43bSJohn Scipione 	// fill in the background
2386a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2387a884b43bSJohn Scipione 
23884fa76719SJohn Scipione 	// restore the clipping constraints of the view
23894fa76719SJohn Scipione 	view->PopState();
23902f86ba45SStephan Aßmus }
23912f86ba45SStephan Aßmus 
23922f86ba45SStephan Aßmus 
23932f86ba45SStephan Aßmus void
2394a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundOutside(BView* view, BRect& rect,
2395a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2396a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2397a884b43bSJohn Scipione 	bool popupIndicator, uint32 flags)
23982f86ba45SStephan Aßmus {
2399a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2400a884b43bSJohn Scipione 		return;
2401a884b43bSJohn Scipione 
2402a884b43bSJohn Scipione 	if (popupIndicator) {
2403a884b43bSJohn Scipione 		BRect leftRect(rect);
2404a884b43bSJohn Scipione 		leftRect.right -= 10;
2405a884b43bSJohn Scipione 
2406a884b43bSJohn Scipione 		BRect rightRect(rect);
2407a884b43bSJohn Scipione 		rightRect.left = rightRect.right - 9;
2408a884b43bSJohn Scipione 
2409a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, leftRect, updateRect,
2410a884b43bSJohn Scipione 			leftTopRadius, 0.0f, leftBottomRadius, 0.0f, base, flags,
2411a884b43bSJohn Scipione 			B_LEFT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER);
2412a884b43bSJohn Scipione 
2413a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rightRect, updateRect,
2414a884b43bSJohn Scipione 			0.0f, rightTopRadius, 0.0f, rightBottomRadius, base, flags,
2415a884b43bSJohn Scipione 			B_TOP_BORDER | B_RIGHT_BORDER | B_BOTTOM_BORDER);
2416a884b43bSJohn Scipione 
2417a884b43bSJohn Scipione 		// popup marker
2418a884b43bSJohn Scipione 		BPoint center(roundf((rightRect.left + rightRect.right) / 2.0),
2419a884b43bSJohn Scipione 					  roundf((rightRect.top + rightRect.bottom) / 2.0));
2420a884b43bSJohn Scipione 		BPoint triangle[3];
2421a884b43bSJohn Scipione 		triangle[0] = center + BPoint(-2.5, -0.5);
2422a884b43bSJohn Scipione 		triangle[1] = center + BPoint(2.5, -0.5);
2423a884b43bSJohn Scipione 		triangle[2] = center + BPoint(0.0, 2.0);
2424a884b43bSJohn Scipione 
2425a884b43bSJohn Scipione 		uint32 viewFlags = view->Flags();
2426a884b43bSJohn Scipione 		view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
2427a884b43bSJohn Scipione 
2428a884b43bSJohn Scipione 		rgb_color markColor;
2429a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2430a884b43bSJohn Scipione 			markColor = tint_color(base, 1.35);
24312f86ba45SStephan Aßmus 		else
2432a884b43bSJohn Scipione 			markColor = tint_color(base, 1.65);
2433a884b43bSJohn Scipione 
2434a884b43bSJohn Scipione 		view->SetHighColor(markColor);
2435a884b43bSJohn Scipione 		view->FillTriangle(triangle[0], triangle[1], triangle[2]);
2436a884b43bSJohn Scipione 
2437a884b43bSJohn Scipione 		// draw a line on the left of the popup frame
2438a884b43bSJohn Scipione 		rgb_color bevelShadowColor = _BevelShadowColor(base, flags);
2439a884b43bSJohn Scipione 		view->SetHighColor(bevelShadowColor);
2440a884b43bSJohn Scipione 		BPoint leftTopCorner(floorf(rightRect.left - 1.0),
2441a884b43bSJohn Scipione 			floorf(rightRect.top - 1.0));
2442a884b43bSJohn Scipione 		BPoint leftBottomCorner(floorf(rightRect.left - 1.0),
2443a884b43bSJohn Scipione 			floorf(rightRect.bottom + 1.0));
2444a884b43bSJohn Scipione 		view->StrokeLine(leftTopCorner, leftBottomCorner);
2445a884b43bSJohn Scipione 
2446a884b43bSJohn Scipione 		view->SetFlags(viewFlags);
2447a884b43bSJohn Scipione 
2448a884b43bSJohn Scipione 		rect = leftRect;
2449a884b43bSJohn Scipione 	} else {
2450a884b43bSJohn Scipione 		_DrawMenuFieldBackgroundInside(view, rect, updateRect, leftTopRadius,
2451a884b43bSJohn Scipione 			rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags);
2452a884b43bSJohn Scipione 	}
24532f86ba45SStephan Aßmus }
24542f86ba45SStephan Aßmus 
24552f86ba45SStephan Aßmus 
2456a884b43bSJohn Scipione void
2457a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect,
2458a884b43bSJohn Scipione 	const BRect& updateRect, float leftTopRadius, float rightTopRadius,
2459a884b43bSJohn Scipione 	float leftBottomRadius, float rightBottomRadius, const rgb_color& base,
2460a884b43bSJohn Scipione 	uint32 flags, uint32 borders)
24612f86ba45SStephan Aßmus {
2462a884b43bSJohn Scipione 	if (!rect.IsValid() || !rect.Intersects(updateRect))
2463a884b43bSJohn Scipione 		return;
2464a884b43bSJohn Scipione 
24655666b4f7SJohn Scipione 	// save the clipping constraints of the view
24665666b4f7SJohn Scipione 	view->PushState();
2467a884b43bSJohn Scipione 
24685666b4f7SJohn Scipione 	// set clipping constraints to updateRect
24695666b4f7SJohn Scipione 	BRegion clipping(updateRect);
2470a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2471a884b43bSJohn Scipione 
2472a884b43bSJohn Scipione 	// frame colors
2473a884b43bSJohn Scipione 	rgb_color frameLightColor  = _FrameLightColor(base, flags);
2474a884b43bSJohn Scipione 	rgb_color frameShadowColor = _FrameShadowColor(base, flags);
2475a884b43bSJohn Scipione 
2476a884b43bSJohn Scipione 	// indicator background color
2477a884b43bSJohn Scipione 	rgb_color indicatorBase;
2478a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0)
2479a884b43bSJohn Scipione 		indicatorBase = base;
2480a884b43bSJohn Scipione 	else {
2481a884b43bSJohn Scipione 		if ((flags & B_DISABLED) != 0)
2482a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.05);
2483a884b43bSJohn Scipione 		else
2484a884b43bSJohn Scipione 			indicatorBase = tint_color(base, 1.12);
24852f86ba45SStephan Aßmus 	}
24862f86ba45SStephan Aßmus 
2487a884b43bSJohn Scipione 	// bevel colors
2488a884b43bSJohn Scipione 	rgb_color cornerColor = tint_color(indicatorBase, 0.85);
2489a884b43bSJohn Scipione 	rgb_color bevelColor1 = tint_color(indicatorBase, 0.3);
2490a884b43bSJohn Scipione 	rgb_color bevelColor2 = tint_color(indicatorBase, 0.5);
2491a884b43bSJohn Scipione 	rgb_color bevelColor3 = tint_color(indicatorBase, 1.03);
24922f86ba45SStephan Aßmus 
2493a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
2494a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.8);
2495a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.7);
2496a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.8);
2497a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.01);
24982f86ba45SStephan Aßmus 	} else {
2499a884b43bSJohn Scipione 		cornerColor = tint_color(indicatorBase, 0.85);
2500a884b43bSJohn Scipione 		bevelColor1 = tint_color(indicatorBase, 0.3);
2501a884b43bSJohn Scipione 		bevelColor2 = tint_color(indicatorBase, 0.5);
2502a884b43bSJohn Scipione 		bevelColor3 = tint_color(indicatorBase, 1.03);
25032f86ba45SStephan Aßmus 	}
2504a884b43bSJohn Scipione 
2505a884b43bSJohn Scipione 	// surface top gradient
2506a884b43bSJohn Scipione 	BGradientLinear fillGradient;
2507a884b43bSJohn Scipione 	_MakeButtonGradient(fillGradient, rect, indicatorBase, flags);
2508a884b43bSJohn Scipione 
2509a884b43bSJohn Scipione 	// rounded corners
2510a884b43bSJohn Scipione 
2511a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0
2512a884b43bSJohn Scipione 		&& leftTopRadius > 0) {
2513a884b43bSJohn Scipione 		// draw left top rounded corner
2514a884b43bSJohn Scipione 		BRect leftTopCorner(floorf(rect.left), floorf(rect.top),
2515a884b43bSJohn Scipione 			floorf(rect.left + leftTopRadius - 2.0),
2516a884b43bSJohn Scipione 			floorf(rect.top + leftTopRadius - 2.0));
2517a884b43bSJohn Scipione 		clipping.Exclude(leftTopCorner);
2518a884b43bSJohn Scipione 
2519a884b43bSJohn Scipione 		BRegion cornerClipping(leftTopCorner);
2520a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2521a884b43bSJohn Scipione 
2522a884b43bSJohn Scipione 		BRect ellipseRect(leftTopCorner);
2523a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2524a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2525a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2526a884b43bSJohn Scipione 
2527a884b43bSJohn Scipione 		// draw the frame (again)
2528a884b43bSJohn Scipione 		view->SetHighColor(frameLightColor);
2529a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2530a884b43bSJohn Scipione 
2531a884b43bSJohn Scipione 		// draw the bevel and background
2532a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect,
2533a884b43bSJohn Scipione 			bevelColor1, fillGradient);
2534a884b43bSJohn Scipione 	}
2535a884b43bSJohn Scipione 
2536a884b43bSJohn Scipione 	if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0
2537a884b43bSJohn Scipione 		&& rightTopRadius > 0) {
2538a884b43bSJohn Scipione 		// draw right top rounded corner
2539a884b43bSJohn Scipione 		BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0),
2540a884b43bSJohn Scipione 			floorf(rect.top), floorf(rect.right),
2541a884b43bSJohn Scipione 			floorf(rect.top + rightTopRadius - 2.0));
2542a884b43bSJohn Scipione 		clipping.Exclude(rightTopCorner);
2543a884b43bSJohn Scipione 
2544a884b43bSJohn Scipione 		BRegion cornerClipping(rightTopCorner);
2545a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2546a884b43bSJohn Scipione 
2547a884b43bSJohn Scipione 		BRect ellipseRect(rightTopCorner);
2548a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2549a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2550a884b43bSJohn Scipione 		ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2551a884b43bSJohn Scipione 
2552a884b43bSJohn Scipione 		// draw the frame (again)
2553a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2554a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2555a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
25562f86ba45SStephan Aßmus 		} else {
2557a884b43bSJohn Scipione 			BGradientLinear gradient;
2558a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2559a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2560a884b43bSJohn Scipione 			gradient.SetStart(rightTopCorner.LeftTop());
2561a884b43bSJohn Scipione 			gradient.SetEnd(rightTopCorner.RightBottom());
2562a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
25632f86ba45SStephan Aßmus 		}
25642f86ba45SStephan Aßmus 
2565a884b43bSJohn Scipione 		// draw the bevel and background
2566a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect,
2567a884b43bSJohn Scipione 			bevelColor1, bevelColor3, fillGradient);
2568a884b43bSJohn Scipione 	}
25692f86ba45SStephan Aßmus 
2570a884b43bSJohn Scipione 	if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2571a884b43bSJohn Scipione 		&& leftBottomRadius > 0) {
2572a884b43bSJohn Scipione 		// draw left bottom rounded corner
2573a884b43bSJohn Scipione 		BRect leftBottomCorner(floorf(rect.left),
2574a884b43bSJohn Scipione 			floorf(rect.bottom - leftBottomRadius + 2.0),
2575a884b43bSJohn Scipione 			floorf(rect.left + leftBottomRadius - 2.0),
2576a884b43bSJohn Scipione 			floorf(rect.bottom));
2577a884b43bSJohn Scipione 		clipping.Exclude(leftBottomCorner);
2578a884b43bSJohn Scipione 
2579a884b43bSJohn Scipione 		BRegion cornerClipping(leftBottomCorner);
2580a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2581a884b43bSJohn Scipione 
2582a884b43bSJohn Scipione 		BRect ellipseRect(leftBottomCorner);
2583a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2584a884b43bSJohn Scipione 		ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2585a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2586a884b43bSJohn Scipione 
2587a884b43bSJohn Scipione 		// draw the frame (again)
2588a884b43bSJohn Scipione 		if (frameLightColor == frameShadowColor) {
2589a884b43bSJohn Scipione 			view->SetHighColor(frameLightColor);
2590a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect);
2591a884b43bSJohn Scipione 		} else {
2592a884b43bSJohn Scipione 			BGradientLinear gradient;
2593a884b43bSJohn Scipione 			gradient.AddColor(frameLightColor, 0);
2594a884b43bSJohn Scipione 			gradient.AddColor(frameShadowColor, 255);
2595a884b43bSJohn Scipione 			gradient.SetStart(leftBottomCorner.LeftTop());
2596a884b43bSJohn Scipione 			gradient.SetEnd(leftBottomCorner.RightBottom());
2597a884b43bSJohn Scipione 			view->FillEllipse(ellipseRect, gradient);
2598a884b43bSJohn Scipione 		}
2599a884b43bSJohn Scipione 
2600a884b43bSJohn Scipione 		// draw the bevel and background
2601a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner,
2602a884b43bSJohn Scipione 			updateRect, bevelColor2, bevelColor3, fillGradient);
2603a884b43bSJohn Scipione 	}
2604a884b43bSJohn Scipione 
2605a884b43bSJohn Scipione 	if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0
2606a884b43bSJohn Scipione 		&& rightBottomRadius > 0) {
2607a884b43bSJohn Scipione 		// draw right bottom rounded corner
2608a884b43bSJohn Scipione 		BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0),
2609a884b43bSJohn Scipione 			floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right),
2610a884b43bSJohn Scipione 			floorf(rect.bottom));
2611a884b43bSJohn Scipione 		clipping.Exclude(rightBottomCorner);
2612a884b43bSJohn Scipione 
2613a884b43bSJohn Scipione 		BRegion cornerClipping(rightBottomCorner);
2614a884b43bSJohn Scipione 		view->ConstrainClippingRegion(&cornerClipping);
2615a884b43bSJohn Scipione 
2616a884b43bSJohn Scipione 		BRect ellipseRect(rightBottomCorner);
2617a884b43bSJohn Scipione 		ellipseRect.InsetBy(-1.0, -1.0);
2618a884b43bSJohn Scipione 		ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2619a884b43bSJohn Scipione 		ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2620a884b43bSJohn Scipione 
2621a884b43bSJohn Scipione 		// draw the frame (again)
2622a884b43bSJohn Scipione 		view->SetHighColor(frameShadowColor);
2623a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2624a884b43bSJohn Scipione 
2625a884b43bSJohn Scipione 		// draw the bevel and background
2626a884b43bSJohn Scipione 		_DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner,
2627a884b43bSJohn Scipione 			updateRect, bevelColor3, fillGradient);
2628a884b43bSJohn Scipione 	}
2629a884b43bSJohn Scipione 
2630a884b43bSJohn Scipione 	// clip out the corners
2631a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2632a884b43bSJohn Scipione 
2633a884b43bSJohn Scipione 	// draw the bevel
2634a884b43bSJohn Scipione 	_DrawFrame(view, rect,
2635a884b43bSJohn Scipione 		bevelColor2, bevelColor1,
2636a884b43bSJohn Scipione 		bevelColor3, bevelColor3,
2637a884b43bSJohn Scipione 		cornerColor, cornerColor,
2638a884b43bSJohn Scipione 		borders);
2639a884b43bSJohn Scipione 
2640a884b43bSJohn Scipione 	// fill in the background
2641a884b43bSJohn Scipione 	view->FillRect(rect, fillGradient);
2642a884b43bSJohn Scipione 
26435666b4f7SJohn Scipione 	// restore the clipping constraints of the view
26445666b4f7SJohn Scipione 	view->PopState();
2645a884b43bSJohn Scipione }
2646a884b43bSJohn Scipione 
2647a884b43bSJohn Scipione 
2648a884b43bSJohn Scipione void
2649a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftTop(BView* view, BRect& cornerRect,
2650a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2651a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2652a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2653a884b43bSJohn Scipione {
2654a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftTop(view, cornerRect, updateRect,
2655a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2656a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftTop(view, cornerRect, updateRect,
2657a884b43bSJohn Scipione 		bevelColor, fillGradient);
2658a884b43bSJohn Scipione }
2659a884b43bSJohn Scipione 
2660a884b43bSJohn Scipione 
2661a884b43bSJohn Scipione void
2662a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftTop(BView* view, BRect& cornerRect,
2663a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2664a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2665a884b43bSJohn Scipione {
2666a884b43bSJohn Scipione 	// constrain clipping region to corner
2667a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2668a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2669a884b43bSJohn Scipione 
2670a884b43bSJohn Scipione 	// background
2671a884b43bSJohn Scipione 	view->SetHighColor(background);
2672a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2673a884b43bSJohn Scipione 
2674a884b43bSJohn Scipione 	// outer edge
2675a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2676a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2677a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2678a884b43bSJohn Scipione 
2679a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2680a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2681a884b43bSJohn Scipione 
2682a884b43bSJohn Scipione 	// frame
2683a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2684a884b43bSJohn Scipione 	cornerRect.left++;
2685a884b43bSJohn Scipione 	cornerRect.top++;
2686a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2687a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2688a884b43bSJohn Scipione 
2689a884b43bSJohn Scipione 	// prepare for bevel
2690a884b43bSJohn Scipione 	cornerRect.left++;
2691a884b43bSJohn Scipione 	cornerRect.top++;
2692a884b43bSJohn Scipione }
2693a884b43bSJohn Scipione 
2694a884b43bSJohn Scipione 
2695a884b43bSJohn Scipione void
2696a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftTop(BView* view, BRect& cornerRect,
2697a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelColor,
2698a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2699a884b43bSJohn Scipione {
2700a884b43bSJohn Scipione 	// constrain clipping region to corner
2701a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2702a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2703a884b43bSJohn Scipione 
2704a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2705a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2706a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2707a884b43bSJohn Scipione 
2708a884b43bSJohn Scipione 	// bevel
2709a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2710a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2711a884b43bSJohn Scipione 
2712a884b43bSJohn Scipione 	// gradient
2713a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2714a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2715a884b43bSJohn Scipione }
2716a884b43bSJohn Scipione 
2717a884b43bSJohn Scipione 
2718a884b43bSJohn Scipione void
2719a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightTop(BView* view, BRect& cornerRect,
2720a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2721a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2722a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor,
2723a884b43bSJohn Scipione 	const rgb_color& bevelTopColor, const rgb_color& bevelRightColor,
2724a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2725a884b43bSJohn Scipione {
2726a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightTop(view, cornerRect, updateRect,
2727a884b43bSJohn Scipione 		background, edgeTopColor, edgeRightColor, frameTopColor,
2728a884b43bSJohn Scipione 		frameRightColor);
2729a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightTop(view, cornerRect, updateRect,
2730a884b43bSJohn Scipione 		bevelTopColor, bevelRightColor, fillGradient);
2731a884b43bSJohn Scipione }
2732a884b43bSJohn Scipione 
2733a884b43bSJohn Scipione 
2734a884b43bSJohn Scipione void
2735a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightTop(BView* view, BRect& cornerRect,
2736a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2737a884b43bSJohn Scipione 	const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
2738a884b43bSJohn Scipione 	const rgb_color& frameTopColor, const rgb_color& frameRightColor)
2739a884b43bSJohn Scipione {
2740a884b43bSJohn Scipione 	// constrain clipping region to corner
2741a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2742a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2743a884b43bSJohn Scipione 
2744a884b43bSJohn Scipione 	// background
2745a884b43bSJohn Scipione 	view->SetHighColor(background);
2746a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2747a884b43bSJohn Scipione 
2748a884b43bSJohn Scipione 	// outer edge
2749a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2750a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2751a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2752a884b43bSJohn Scipione 
2753a884b43bSJohn Scipione 	BGradientLinear gradient;
2754a884b43bSJohn Scipione 	gradient.AddColor(edgeTopColor, 0);
2755a884b43bSJohn Scipione 	gradient.AddColor(edgeRightColor, 255);
2756a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2757a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2758a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2759a884b43bSJohn Scipione 
2760a884b43bSJohn Scipione 	// frame
2761a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2762a884b43bSJohn Scipione 	cornerRect.right--;
2763a884b43bSJohn Scipione 	cornerRect.top++;
2764a884b43bSJohn Scipione 	if (frameTopColor == frameRightColor) {
2765a884b43bSJohn Scipione 		view->SetHighColor(frameTopColor);
2766a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2767a884b43bSJohn Scipione 	} else {
2768a884b43bSJohn Scipione 		gradient.SetColor(0, frameTopColor);
2769a884b43bSJohn Scipione 		gradient.SetColor(1, frameRightColor);
2770a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2771a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2772a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2773a884b43bSJohn Scipione 	}
2774a884b43bSJohn Scipione 
2775a884b43bSJohn Scipione 	// prepare for bevel
2776a884b43bSJohn Scipione 	cornerRect.right--;
2777a884b43bSJohn Scipione 	cornerRect.top++;
2778a884b43bSJohn Scipione }
2779a884b43bSJohn Scipione 
2780a884b43bSJohn Scipione 
2781a884b43bSJohn Scipione void
2782a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightTop(BView* view, BRect& cornerRect,
2783a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelTopColor,
2784a884b43bSJohn Scipione 	const rgb_color& bevelRightColor, const BGradientLinear& fillGradient)
2785a884b43bSJohn Scipione {
2786a884b43bSJohn Scipione 	// constrain clipping region to corner
2787a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2788a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2789a884b43bSJohn Scipione 
2790a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2791a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2792a884b43bSJohn Scipione 	ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2;
2793a884b43bSJohn Scipione 
2794a884b43bSJohn Scipione 	// bevel
2795a884b43bSJohn Scipione 	BGradientLinear gradient;
2796a884b43bSJohn Scipione 	gradient.AddColor(bevelTopColor, 0);
2797a884b43bSJohn Scipione 	gradient.AddColor(bevelRightColor, 255);
2798a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2799a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2800a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2801a884b43bSJohn Scipione 
2802a884b43bSJohn Scipione 	// gradient
2803a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2804a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2805a884b43bSJohn Scipione }
2806a884b43bSJohn Scipione 
2807a884b43bSJohn Scipione 
2808a884b43bSJohn Scipione void
2809a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftBottom(BView* view, BRect& cornerRect,
2810a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2811a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
2812a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor,
2813a884b43bSJohn Scipione 	const rgb_color& bevelLeftColor, const rgb_color& bevelBottomColor,
2814a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2815a884b43bSJohn Scipione {
2816a884b43bSJohn Scipione 	_DrawRoundCornerFrameLeftBottom(view, cornerRect, updateRect,
2817a884b43bSJohn Scipione 		background, edgeLeftColor, edgeBottomColor, frameLeftColor,
2818a884b43bSJohn Scipione 		frameBottomColor);
2819a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundLeftBottom(view, cornerRect, updateRect,
2820a884b43bSJohn Scipione 		bevelLeftColor, bevelBottomColor, fillGradient);
2821a884b43bSJohn Scipione }
2822a884b43bSJohn Scipione 
2823a884b43bSJohn Scipione 
2824a884b43bSJohn Scipione void
2825a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftBottom(BView* view, BRect& cornerRect,
2826a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2827a884b43bSJohn Scipione 	const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor,
2828a884b43bSJohn Scipione 	const rgb_color& frameLeftColor, const rgb_color& frameBottomColor)
2829a884b43bSJohn Scipione {
2830a884b43bSJohn Scipione 	// constrain clipping region to corner
2831a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2832a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2833a884b43bSJohn Scipione 
2834a884b43bSJohn Scipione 	// background
2835a884b43bSJohn Scipione 	view->SetHighColor(background);
2836a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2837a884b43bSJohn Scipione 
2838a884b43bSJohn Scipione 	// outer edge
2839a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2840a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2841a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2842a884b43bSJohn Scipione 
2843a884b43bSJohn Scipione 	BGradientLinear gradient;
2844a884b43bSJohn Scipione 	gradient.AddColor(edgeLeftColor, 0);
2845a884b43bSJohn Scipione 	gradient.AddColor(edgeBottomColor, 255);
2846a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2847a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2848a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2849a884b43bSJohn Scipione 
2850a884b43bSJohn Scipione 	// frame
2851a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2852a884b43bSJohn Scipione 	cornerRect.left++;
2853a884b43bSJohn Scipione 	cornerRect.bottom--;
2854a884b43bSJohn Scipione 	if (frameLeftColor == frameBottomColor) {
2855a884b43bSJohn Scipione 		view->SetHighColor(frameLeftColor);
2856a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect);
2857a884b43bSJohn Scipione 	} else {
2858a884b43bSJohn Scipione 		gradient.SetColor(0, frameLeftColor);
2859a884b43bSJohn Scipione 		gradient.SetColor(1, frameBottomColor);
2860a884b43bSJohn Scipione 		gradient.SetStart(cornerRect.LeftTop());
2861a884b43bSJohn Scipione 		gradient.SetEnd(cornerRect.RightBottom());
2862a884b43bSJohn Scipione 		view->FillEllipse(ellipseRect, gradient);
2863a884b43bSJohn Scipione 	}
2864a884b43bSJohn Scipione 
2865a884b43bSJohn Scipione 	// prepare for bevel
2866a884b43bSJohn Scipione 	cornerRect.left++;
2867a884b43bSJohn Scipione 	cornerRect.bottom--;
2868a884b43bSJohn Scipione }
2869a884b43bSJohn Scipione 
2870a884b43bSJohn Scipione 
2871a884b43bSJohn Scipione void
2872a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftBottom(BView* view, BRect& cornerRect,
2873a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& bevelLeftColor,
2874a884b43bSJohn Scipione 	const rgb_color& bevelBottomColor, const BGradientLinear& fillGradient)
2875a884b43bSJohn Scipione {
2876a884b43bSJohn Scipione 	// constrain clipping region to corner
2877a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2878a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2879a884b43bSJohn Scipione 
2880a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2881a884b43bSJohn Scipione 	ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
2882a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2883a884b43bSJohn Scipione 
2884a884b43bSJohn Scipione 	// bevel
2885a884b43bSJohn Scipione 	BGradientLinear gradient;
2886a884b43bSJohn Scipione 	gradient.AddColor(bevelLeftColor, 0);
2887a884b43bSJohn Scipione 	gradient.AddColor(bevelBottomColor, 255);
2888a884b43bSJohn Scipione 	gradient.SetStart(cornerRect.LeftTop());
2889a884b43bSJohn Scipione 	gradient.SetEnd(cornerRect.RightBottom());
2890a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, gradient);
2891a884b43bSJohn Scipione 
2892a884b43bSJohn Scipione 	// gradient
2893a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2894a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
2895a884b43bSJohn Scipione 
2896a884b43bSJohn Scipione 	view->PopState();
2897a884b43bSJohn Scipione }
2898a884b43bSJohn Scipione 
2899a884b43bSJohn Scipione 
2900a884b43bSJohn Scipione void
2901a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightBottom(BView* view, BRect& cornerRect,
2902a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2903a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor,
2904a884b43bSJohn Scipione 	const rgb_color& bevelColor, const BGradientLinear& fillGradient)
2905a884b43bSJohn Scipione {
2906a884b43bSJohn Scipione 	_DrawRoundCornerFrameRightBottom(view, cornerRect, updateRect,
2907a884b43bSJohn Scipione 		background, edgeColor, frameColor);
2908a884b43bSJohn Scipione 	_DrawRoundCornerBackgroundRightBottom(view, cornerRect, updateRect,
2909a884b43bSJohn Scipione 		bevelColor, fillGradient);
2910a884b43bSJohn Scipione }
2911a884b43bSJohn Scipione 
2912a884b43bSJohn Scipione 
2913a884b43bSJohn Scipione void
2914a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect,
2915a884b43bSJohn Scipione 	const BRect& updateRect, const rgb_color& background,
2916a884b43bSJohn Scipione 	const rgb_color& edgeColor, const rgb_color& frameColor)
2917a884b43bSJohn Scipione {
2918a884b43bSJohn Scipione 	// constrain clipping region to corner
2919a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2920a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2921a884b43bSJohn Scipione 
2922a884b43bSJohn Scipione 	// background
2923a884b43bSJohn Scipione 	view->SetHighColor(background);
2924a884b43bSJohn Scipione 	view->FillRect(cornerRect);
2925a884b43bSJohn Scipione 
2926a884b43bSJohn Scipione 	// outer edge
2927a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2928a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2929a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2930a884b43bSJohn Scipione 
2931a884b43bSJohn Scipione 	view->SetHighColor(edgeColor);
2932a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2933a884b43bSJohn Scipione 
2934a884b43bSJohn Scipione 	// frame
2935a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2936a884b43bSJohn Scipione 	cornerRect.right--;
2937a884b43bSJohn Scipione 	cornerRect.bottom++;
2938a884b43bSJohn Scipione 	view->SetHighColor(frameColor);
2939a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2940a884b43bSJohn Scipione 
2941a884b43bSJohn Scipione 	// prepare for bevel
2942a884b43bSJohn Scipione 	cornerRect.left++;
2943a884b43bSJohn Scipione 	cornerRect.bottom--;
2944a884b43bSJohn Scipione }
2945a884b43bSJohn Scipione 
2946a884b43bSJohn Scipione 
2947a884b43bSJohn Scipione void
2948a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightBottom(BView* view,
2949a884b43bSJohn Scipione 	BRect& cornerRect, const BRect& updateRect, const rgb_color& bevelColor,
2950a884b43bSJohn Scipione 	const BGradientLinear& fillGradient)
2951a884b43bSJohn Scipione {
2952a884b43bSJohn Scipione 	// constrain clipping region to corner
2953a884b43bSJohn Scipione 	BRegion clipping(cornerRect);
2954a884b43bSJohn Scipione 	view->ConstrainClippingRegion(&clipping);
2955a884b43bSJohn Scipione 
2956a884b43bSJohn Scipione 	BRect ellipseRect(cornerRect);
2957a884b43bSJohn Scipione 	ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
2958a884b43bSJohn Scipione 	ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
2959a884b43bSJohn Scipione 
2960a884b43bSJohn Scipione 	// bevel
2961a884b43bSJohn Scipione 	view->SetHighColor(bevelColor);
2962a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect);
2963a884b43bSJohn Scipione 
2964a884b43bSJohn Scipione 	// gradient
2965a884b43bSJohn Scipione 	ellipseRect.InsetBy(1, 1);
2966a884b43bSJohn Scipione 	view->FillEllipse(ellipseRect, fillGradient);
29672f86ba45SStephan Aßmus }
29682f86ba45SStephan Aßmus 
29692f86ba45SStephan Aßmus 
29702f86ba45SStephan Aßmus void
29712f86ba45SStephan Aßmus BControlLook::_DrawRoundBarCorner(BView* view, BRect& rect,
29722f86ba45SStephan Aßmus 	const BRect& updateRect,
29732f86ba45SStephan Aßmus 	const rgb_color& edgeLightColor, const rgb_color& edgeShadowColor,
29742f86ba45SStephan Aßmus 	const rgb_color& frameLightColor, const rgb_color& frameShadowColor,
29752f86ba45SStephan Aßmus 	const rgb_color& fillLightColor, const rgb_color& fillShadowColor,
29762f86ba45SStephan Aßmus 	float leftInset, float topInset, float rightInset, float bottomInset,
2977e724b26fSJohn Scipione 	orientation orientation)
29782f86ba45SStephan Aßmus {
29792f86ba45SStephan Aßmus 	if (!rect.IsValid() || !rect.Intersects(updateRect))
29802f86ba45SStephan Aßmus 		return;
29812f86ba45SStephan Aßmus 
29822f86ba45SStephan Aßmus 	BGradientLinear gradient;
29832f86ba45SStephan Aßmus 	gradient.AddColor(edgeShadowColor, 0);
29842f86ba45SStephan Aßmus 	gradient.AddColor(edgeLightColor, 255);
29852f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
29862f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
29872f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
29882f86ba45SStephan Aßmus 	else
29892f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
29902f86ba45SStephan Aßmus 
29912f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
29922f86ba45SStephan Aßmus 
29932f86ba45SStephan Aßmus 	rect.left += leftInset;
29942f86ba45SStephan Aßmus 	rect.top += topInset;
29952f86ba45SStephan Aßmus 	rect.right += rightInset;
29962f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
29972f86ba45SStephan Aßmus 
29982f86ba45SStephan Aßmus 	gradient.MakeEmpty();
29992f86ba45SStephan Aßmus 	gradient.AddColor(frameShadowColor, 0);
30002f86ba45SStephan Aßmus 	gradient.AddColor(frameLightColor, 255);
30012f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
30022f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
30032f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
30042f86ba45SStephan Aßmus 	else
30052f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
30062f86ba45SStephan Aßmus 
30072f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
30082f86ba45SStephan Aßmus 
30092f86ba45SStephan Aßmus 	rect.left += leftInset;
30102f86ba45SStephan Aßmus 	rect.top += topInset;
30112f86ba45SStephan Aßmus 	rect.right += rightInset;
30122f86ba45SStephan Aßmus 	rect.bottom += bottomInset;
30132f86ba45SStephan Aßmus 
30142f86ba45SStephan Aßmus 	gradient.MakeEmpty();
30152f86ba45SStephan Aßmus 	gradient.AddColor(fillShadowColor, 0);
30162f86ba45SStephan Aßmus 	gradient.AddColor(fillLightColor, 255);
30172f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
30182f86ba45SStephan Aßmus 	if (orientation == B_HORIZONTAL)
30192f86ba45SStephan Aßmus 		gradient.SetEnd(rect.LeftBottom());
30202f86ba45SStephan Aßmus 	else
30212f86ba45SStephan Aßmus 		gradient.SetEnd(rect.RightTop());
30222f86ba45SStephan Aßmus 
30232f86ba45SStephan Aßmus 	view->FillEllipse(rect, gradient);
30242f86ba45SStephan Aßmus }
30252f86ba45SStephan Aßmus 
30262f86ba45SStephan Aßmus 
3027a884b43bSJohn Scipione rgb_color
3028a884b43bSJohn Scipione BControlLook::_EdgeLightColor(const rgb_color& base, float contrast,
3029a884b43bSJohn Scipione 	float brightness, uint32 flags)
30302f86ba45SStephan Aßmus {
3031a884b43bSJohn Scipione 	rgb_color edgeLightColor;
30322f86ba45SStephan Aßmus 
3033a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
3034a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
303583864481SJérôme Duval 		uint8 white = uint8(255 * brightness);
30362f86ba45SStephan Aßmus 
3037a884b43bSJohn Scipione 		edgeLightColor = (rgb_color){ white, white, white, alpha };
30382f86ba45SStephan Aßmus 	} else {
3039a884b43bSJohn Scipione 		// colors
3040a884b43bSJohn Scipione 		float tintLight = kEdgeBevelLightTint;
3041a884b43bSJohn Scipione 
3042a884b43bSJohn Scipione 		if (contrast == 0.0)
3043a884b43bSJohn Scipione 			tintLight = B_NO_TINT;
3044a884b43bSJohn Scipione 		else if (contrast != 1.0)
3045a884b43bSJohn Scipione 			tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast;
3046a884b43bSJohn Scipione 
3047a884b43bSJohn Scipione 		edgeLightColor = tint_color(base, tintLight);
3048a884b43bSJohn Scipione 
3049a884b43bSJohn Scipione 		if (brightness < 1.0) {
3050a884b43bSJohn Scipione 			edgeLightColor.red = uint8(edgeLightColor.red * brightness);
3051a884b43bSJohn Scipione 			edgeLightColor.green = uint8(edgeLightColor.green * brightness);
3052a884b43bSJohn Scipione 			edgeLightColor.blue = uint8(edgeLightColor.blue * brightness);
3053a884b43bSJohn Scipione 		}
30542f86ba45SStephan Aßmus 	}
30552f86ba45SStephan Aßmus 
3056a884b43bSJohn Scipione 	return edgeLightColor;
3057a884b43bSJohn Scipione }
3058a884b43bSJohn Scipione 
3059a884b43bSJohn Scipione 
3060a884b43bSJohn Scipione rgb_color
3061a884b43bSJohn Scipione BControlLook::_EdgeShadowColor(const rgb_color& base, float contrast,
3062a884b43bSJohn Scipione 	float brightness, uint32 flags)
3063a884b43bSJohn Scipione {
3064a884b43bSJohn Scipione 	rgb_color edgeShadowColor;
3065a884b43bSJohn Scipione 
3066a884b43bSJohn Scipione 	if ((flags & B_BLEND_FRAME) != 0) {
3067a884b43bSJohn Scipione 		uint8 alpha = uint8(20 * contrast);
3068a884b43bSJohn Scipione 		edgeShadowColor = (rgb_color){ 0, 0, 0, alpha };
3069a884b43bSJohn Scipione 	} else {
3070a884b43bSJohn Scipione 		float tintShadow = kEdgeBevelShadowTint;
3071a884b43bSJohn Scipione 
3072a884b43bSJohn Scipione 		if (contrast == 0.0)
3073a884b43bSJohn Scipione 			tintShadow = B_NO_TINT;
3074a884b43bSJohn Scipione 		else if (contrast != 1.0)
3075a884b43bSJohn Scipione 			tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast;
3076a884b43bSJohn Scipione 
3077a884b43bSJohn Scipione 		edgeShadowColor = tint_color(base, tintShadow);
3078a884b43bSJohn Scipione 
3079a884b43bSJohn Scipione 		if (brightness < 1.0) {
3080a884b43bSJohn Scipione 			edgeShadowColor.red = uint8(edgeShadowColor.red * brightness);
3081a884b43bSJohn Scipione 			edgeShadowColor.green = uint8(edgeShadowColor.green * brightness);
3082a884b43bSJohn Scipione 			edgeShadowColor.blue = uint8(edgeShadowColor.blue * brightness);
3083a884b43bSJohn Scipione 		}
3084a884b43bSJohn Scipione 	}
3085a884b43bSJohn Scipione 
3086a884b43bSJohn Scipione 	return edgeShadowColor;
3087a884b43bSJohn Scipione }
3088a884b43bSJohn Scipione 
3089a884b43bSJohn Scipione 
3090a884b43bSJohn Scipione rgb_color
3091a884b43bSJohn Scipione BControlLook::_FrameLightColor(const rgb_color& base, uint32 flags)
3092a884b43bSJohn Scipione {
3093a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
3094a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
3095a884b43bSJohn Scipione 
3096a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3097a884b43bSJohn Scipione 		return _FrameShadowColor(base, flags & ~B_ACTIVATED);
3098a884b43bSJohn Scipione 
3099a884b43bSJohn Scipione 	rgb_color frameLightColor;
3100a884b43bSJohn Scipione 
3101a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3102a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
3103a884b43bSJohn Scipione 		frameLightColor = tint_color(base, 1.145);
3104a884b43bSJohn Scipione 
3105a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3106a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.14);
3107a884b43bSJohn Scipione 	} else {
3108a884b43bSJohn Scipione 		if ((flags & B_BLEND_FRAME) != 0)
3109a884b43bSJohn Scipione 			frameLightColor = (rgb_color){ 0, 0, 0, 75 };
3110a884b43bSJohn Scipione 		else
3111a884b43bSJohn Scipione 			frameLightColor = tint_color(base, 1.33);
3112a884b43bSJohn Scipione 
3113a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0)
3114a884b43bSJohn Scipione 			frameLightColor = tint_color(frameLightColor, 1.35);
3115a884b43bSJohn Scipione 	}
3116a884b43bSJohn Scipione 
3117a884b43bSJohn Scipione 	return frameLightColor;
3118a884b43bSJohn Scipione }
3119a884b43bSJohn Scipione 
3120a884b43bSJohn Scipione 
3121a884b43bSJohn Scipione rgb_color
3122a884b43bSJohn Scipione BControlLook::_FrameShadowColor(const rgb_color& base, uint32 flags)
3123a884b43bSJohn Scipione {
3124a884b43bSJohn Scipione 	if ((flags & B_FOCUSED) != 0)
3125a884b43bSJohn Scipione 		return ui_color(B_KEYBOARD_NAVIGATION_COLOR);
3126a884b43bSJohn Scipione 
3127a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3128a884b43bSJohn Scipione 		return _FrameLightColor(base, flags & ~B_ACTIVATED);
3129a884b43bSJohn Scipione 
3130a884b43bSJohn Scipione 	rgb_color frameShadowColor;
3131a884b43bSJohn Scipione 
3132a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3133a884b43bSJohn Scipione 		// TODO: B_BLEND_FRAME
3134a884b43bSJohn Scipione 		frameShadowColor = tint_color(base, 1.24);
3135a884b43bSJohn Scipione 
3136a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3137a884b43bSJohn Scipione 			frameShadowColor = tint_color(base, 1.145);
3138a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.12);
3139a884b43bSJohn Scipione 		}
3140a884b43bSJohn Scipione 	} else {
3141a884b43bSJohn Scipione 		if ((flags & B_DEFAULT_BUTTON) != 0) {
3142a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3143a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 75 };
3144a884b43bSJohn Scipione 			else
3145a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.33);
3146a884b43bSJohn Scipione 
3147a884b43bSJohn Scipione 			frameShadowColor = tint_color(frameShadowColor, 1.5);
3148a884b43bSJohn Scipione 		} else {
3149a884b43bSJohn Scipione 			if ((flags & B_BLEND_FRAME) != 0)
3150a884b43bSJohn Scipione 				frameShadowColor = (rgb_color){ 0, 0, 0, 95 };
3151a884b43bSJohn Scipione 			else
3152a884b43bSJohn Scipione 				frameShadowColor = tint_color(base, 1.47);
3153a884b43bSJohn Scipione 		}
3154a884b43bSJohn Scipione 	}
3155a884b43bSJohn Scipione 
3156a884b43bSJohn Scipione 	return frameShadowColor;
3157a884b43bSJohn Scipione }
3158a884b43bSJohn Scipione 
3159a884b43bSJohn Scipione 
3160a884b43bSJohn Scipione rgb_color
3161a884b43bSJohn Scipione BControlLook::_BevelLightColor(const rgb_color& base, uint32 flags)
3162a884b43bSJohn Scipione {
3163a884b43bSJohn Scipione 	rgb_color bevelLightColor = tint_color(base, 0.2);
3164a884b43bSJohn Scipione 
3165a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3166a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_LIGHTEN_1_TINT);
3167a884b43bSJohn Scipione 
3168a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3169a884b43bSJohn Scipione 		bevelLightColor = tint_color(base, B_DARKEN_1_TINT);
3170a884b43bSJohn Scipione 
3171a884b43bSJohn Scipione 	return bevelLightColor;
3172a884b43bSJohn Scipione }
3173a884b43bSJohn Scipione 
3174a884b43bSJohn Scipione 
3175a884b43bSJohn Scipione rgb_color
3176a884b43bSJohn Scipione BControlLook::_BevelShadowColor(const rgb_color& base, uint32 flags)
3177a884b43bSJohn Scipione {
3178a884b43bSJohn Scipione 	rgb_color bevelShadowColor = tint_color(base, 1.08);
3179a884b43bSJohn Scipione 
3180a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0)
3181a884b43bSJohn Scipione 		bevelShadowColor = base;
3182a884b43bSJohn Scipione 
3183a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0)
3184a884b43bSJohn Scipione 		bevelShadowColor = tint_color(base, B_DARKEN_1_TINT);
3185a884b43bSJohn Scipione 
3186a884b43bSJohn Scipione 	return bevelShadowColor;
3187a884b43bSJohn Scipione }
3188a884b43bSJohn Scipione 
3189a884b43bSJohn Scipione 
3190a884b43bSJohn Scipione void
3191a884b43bSJohn Scipione BControlLook::_FillGradient(BView* view, const BRect& rect,
3192a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3193e724b26fSJohn Scipione 	orientation orientation)
3194a884b43bSJohn Scipione {
3195a884b43bSJohn Scipione 	BGradientLinear gradient;
3196a884b43bSJohn Scipione 	_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3197a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3198a884b43bSJohn Scipione }
3199a884b43bSJohn Scipione 
3200a884b43bSJohn Scipione 
3201a884b43bSJohn Scipione void
3202a884b43bSJohn Scipione BControlLook::_FillGlossyGradient(BView* view, const BRect& rect,
3203a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3204e724b26fSJohn Scipione 	float middle2Tint, float bottomTint, orientation orientation)
3205a884b43bSJohn Scipione {
3206a884b43bSJohn Scipione 	BGradientLinear gradient;
3207a884b43bSJohn Scipione 	_MakeGlossyGradient(gradient, rect, base, topTint, middle1Tint,
3208a884b43bSJohn Scipione 		middle2Tint, bottomTint, orientation);
3209a884b43bSJohn Scipione 	view->FillRect(rect, gradient);
3210a884b43bSJohn Scipione }
3211a884b43bSJohn Scipione 
3212a884b43bSJohn Scipione 
3213a884b43bSJohn Scipione void
3214a884b43bSJohn Scipione BControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect,
3215a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float bottomTint,
3216e724b26fSJohn Scipione 	orientation orientation) const
3217a884b43bSJohn Scipione {
3218a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3219a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
32202f86ba45SStephan Aßmus 	gradient.SetStart(rect.LeftTop());
3221a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3222a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3223a884b43bSJohn Scipione 	else
3224a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3225a884b43bSJohn Scipione }
32262f86ba45SStephan Aßmus 
32272f86ba45SStephan Aßmus 
3228a884b43bSJohn Scipione void
3229a884b43bSJohn Scipione BControlLook::_MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect,
3230a884b43bSJohn Scipione 	const rgb_color& base, float topTint, float middle1Tint,
3231a884b43bSJohn Scipione 	float middle2Tint, float bottomTint,
3232e724b26fSJohn Scipione 	orientation orientation) const
3233a884b43bSJohn Scipione {
3234a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, topTint), 0);
3235a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle1Tint), 132);
3236a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, middle2Tint), 136);
3237a884b43bSJohn Scipione 	gradient.AddColor(tint_color(base, bottomTint), 255);
3238a884b43bSJohn Scipione 	gradient.SetStart(rect.LeftTop());
3239a884b43bSJohn Scipione 	if (orientation == B_HORIZONTAL)
3240a884b43bSJohn Scipione 		gradient.SetEnd(rect.LeftBottom());
3241a884b43bSJohn Scipione 	else
3242a884b43bSJohn Scipione 		gradient.SetEnd(rect.RightTop());
3243a884b43bSJohn Scipione }
3244a884b43bSJohn Scipione 
3245a884b43bSJohn Scipione 
3246a884b43bSJohn Scipione void
3247a884b43bSJohn Scipione BControlLook::_MakeButtonGradient(BGradientLinear& gradient, BRect& rect,
3248e724b26fSJohn Scipione 	const rgb_color& base, uint32 flags, orientation orientation) const
3249a884b43bSJohn Scipione {
3250a884b43bSJohn Scipione 	float topTint = 0.49;
3251a884b43bSJohn Scipione 	float middleTint1 = 0.62;
3252a884b43bSJohn Scipione 	float middleTint2 = 0.76;
3253a884b43bSJohn Scipione 	float bottomTint = 0.90;
3254a884b43bSJohn Scipione 
3255a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3256a884b43bSJohn Scipione 		topTint = 1.11;
3257a884b43bSJohn Scipione 		bottomTint = 1.08;
3258a884b43bSJohn Scipione 	}
3259a884b43bSJohn Scipione 
3260a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3261a884b43bSJohn Scipione 		topTint = (topTint + B_NO_TINT) / 2;
3262a884b43bSJohn Scipione 		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
3263a884b43bSJohn Scipione 		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
3264a884b43bSJohn Scipione 		bottomTint = (bottomTint + B_NO_TINT) / 2;
3265a884b43bSJohn Scipione 	} else if ((flags & B_HOVER) != 0) {
3266a884b43bSJohn Scipione 		static const float kHoverTintFactor = 0.85;
3267a884b43bSJohn Scipione 		topTint *= kHoverTintFactor;
3268a884b43bSJohn Scipione 		middleTint1 *= kHoverTintFactor;
3269a884b43bSJohn Scipione 		middleTint2 *= kHoverTintFactor;
3270a884b43bSJohn Scipione 		bottomTint *= kHoverTintFactor;
3271a884b43bSJohn Scipione 	}
3272a884b43bSJohn Scipione 
3273a884b43bSJohn Scipione 	if ((flags & B_ACTIVATED) != 0) {
3274a884b43bSJohn Scipione 		_MakeGradient(gradient, rect, base, topTint, bottomTint, orientation);
3275a884b43bSJohn Scipione 	} else {
3276a884b43bSJohn Scipione 		_MakeGlossyGradient(gradient, rect, base, topTint, middleTint1,
3277a884b43bSJohn Scipione 			middleTint2, bottomTint, orientation);
3278a884b43bSJohn Scipione 	}
3279a884b43bSJohn Scipione }
3280a884b43bSJohn Scipione 
3281a884b43bSJohn Scipione 
3282a884b43bSJohn Scipione 
3283a884b43bSJohn Scipione bool
3284a884b43bSJohn Scipione BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base,
3285a884b43bSJohn Scipione 	rgb_color& color, uint32 flags) const
3286a884b43bSJohn Scipione {
3287df37cd4eSIngo Weinhold 	if ((flags & (B_ACTIVATED | B_PARTIALLY_ACTIVATED | B_CLICKED)) == 0) {
3288a884b43bSJohn Scipione 		// no mark to be drawn at all
3289a884b43bSJohn Scipione 		return false;
3290a884b43bSJohn Scipione 	}
3291a884b43bSJohn Scipione 
32924bb5af76SJohn Scipione 	color = ui_color(B_CONTROL_MARK_COLOR);
3293a884b43bSJohn Scipione 
3294a884b43bSJohn Scipione 	float mix = 1.0;
3295a884b43bSJohn Scipione 
3296a884b43bSJohn Scipione 	if ((flags & B_DISABLED) != 0) {
3297a884b43bSJohn Scipione 		// activated, but disabled
3298a884b43bSJohn Scipione 		mix = 0.4;
3299a884b43bSJohn Scipione 	} else if ((flags & B_CLICKED) != 0) {
3300a884b43bSJohn Scipione 		if ((flags & B_ACTIVATED) != 0) {
3301df37cd4eSIngo Weinhold 			// losing activation
3302a884b43bSJohn Scipione 			mix = 0.7;
3303a884b43bSJohn Scipione 		} else {
3304df37cd4eSIngo Weinhold 			// becoming activated (or losing partial activation)
3305a884b43bSJohn Scipione 			mix = 0.3;
3306a884b43bSJohn Scipione 		}
3307df37cd4eSIngo Weinhold 	} else if ((flags & B_PARTIALLY_ACTIVATED) != 0) {
3308df37cd4eSIngo Weinhold 		// partially activated
3309df37cd4eSIngo Weinhold 		mix = 0.5;
3310a884b43bSJohn Scipione 	} else {
3311a884b43bSJohn Scipione 		// simply activated
3312a884b43bSJohn Scipione 	}
3313a884b43bSJohn Scipione 
3314a884b43bSJohn Scipione 	color.red = uint8(color.red * mix + base.red * (1.0 - mix));
3315a884b43bSJohn Scipione 	color.green = uint8(color.green * mix + base.green * (1.0 - mix));
3316a884b43bSJohn Scipione 	color.blue = uint8(color.blue * mix + base.blue * (1.0 - mix));
3317a884b43bSJohn Scipione 
3318a884b43bSJohn Scipione 	return true;
33192f86ba45SStephan Aßmus }
33202f86ba45SStephan Aßmus 
33212f86ba45SStephan Aßmus 
33222f86ba45SStephan Aßmus // NOTE: May come from a add-on in the future. Initialized in
33232f86ba45SStephan Aßmus // InterfaceDefs.cpp
33242f86ba45SStephan Aßmus BControlLook* be_control_look = NULL;
33252f86ba45SStephan Aßmus 
3326a884b43bSJohn Scipione 
33272f86ba45SStephan Aßmus } // namespace BPrivate
3328