1ff78e73cSDarkWyrm/*
25f5f085bSJohn Scipione * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3ff78e73cSDarkWyrm * Distributed under the terms of the MIT License.
4ff78e73cSDarkWyrm *
5ff78e73cSDarkWyrm * Authors:
687c51182SJohn Scipione *		Stephan A��mus, superstippi@gmx.de
787c51182SJohn Scipione *		DarkWyrm, bpmagic@columbus.rr.com
887c51182SJohn Scipione *		John Scipione, jscipione@gmail.com
987c51182SJohn Scipione *		Clemens Zeidler, haiku@clemens-zeidler.de
10ff78e73cSDarkWyrm */
11ff78e73cSDarkWyrm
123becd1d2SAdrien Destugues
135f5f085bSJohn Scipione/*! Decorator resembling BeOS R5 */
14ff78e73cSDarkWyrm
15ff78e73cSDarkWyrm
1630e06bbfSDarkWyrm#include "BeDecorator.h"
17ff78e73cSDarkWyrm
18db9c24a6SJohn Scipione#include <algorithm>
19db9c24a6SJohn Scipione#include <cmath>
201649544dSClemens Zeidler#include <new>
2175e29683SAdrien Destugues#include <stdio.h>
2275e29683SAdrien Destugues
23db9c24a6SJohn Scipione#include <WindowPrivate.h>
24db9c24a6SJohn Scipione
25db9c24a6SJohn Scipione#include <Autolock.h>
26db9c24a6SJohn Scipione#include <Debug.h>
27db9c24a6SJohn Scipione#include <GradientLinear.h>
28db9c24a6SJohn Scipione#include <Rect.h>
295a32087bSJohn Scipione#include <Region.h>
30db9c24a6SJohn Scipione#include <View.h>
31db9c24a6SJohn Scipione
32db9c24a6SJohn Scipione#include "BitmapDrawingEngine.h"
33d60b3b1bSAlexander von Gluck IV#include "Desktop.h"
34ff78e73cSDarkWyrm#include "DesktopSettings.h"
35ff78e73cSDarkWyrm#include "DrawingEngine.h"
36ff78e73cSDarkWyrm#include "DrawState.h"
37ff78e73cSDarkWyrm#include "FontManager.h"
38634831d8SDarkWyrm#include "PatternHandler.h"
395a32087bSJohn Scipione#include "RGBColor.h"
40db9c24a6SJohn Scipione#include "ServerBitmap.h"
41ff78e73cSDarkWyrm
4213696633SDarkWyrm
43ff78e73cSDarkWyrm//#define DEBUG_DECORATOR
4413696633SDarkWyrm#ifdef DEBUG_DECORATOR
452874b546SDarkWyrm#	define STRACE(x) printf x
462874b546SDarkWyrm#else
472874b546SDarkWyrm#	define STRACE(x) ;
4830e06bbfSDarkWyrm#endif
4930e06bbfSDarkWyrm
50ff78e73cSDarkWyrm
513becd1d2SAdrien Destuguesstatic const float kBorderResizeLength = 22.0;
523becd1d2SAdrien Destuguesstatic const float kResizeKnobSize = 18.0;
533becd1d2SAdrien Destugues
543becd1d2SAdrien Destugues
5531234326SJohn Scipionestatic const unsigned char f = 0xff; // way to write 0xff shorter
5631234326SJohn Scipione
5731234326SJohn Scipionestatic const unsigned char kInnerShadowBits[] = {
5831234326SJohn Scipione	f, f, f, f, f, f, f, f, f, 0,
5931234326SJohn Scipione	f, f, f, f, f, f, 0, f, 0, f,
6031234326SJohn Scipione	f, f, f, f, f, 0, f, 0, f, 0,
6131234326SJohn Scipione	f, f, f, f, 0, f, 0, 0, 0, 0,
6231234326SJohn Scipione	f, f, f, 0, f, 0, 0, 0, 0, 0,
6331234326SJohn Scipione	f, f, 0, f, 0, 0, 0, 0, 0, 0,
6431234326SJohn Scipione	f, 0, f, 0, 0, 0, 0, 0, 0, 0,
6531234326SJohn Scipione	f, f, 0, 0, 0, 0, 0, 0, 0, 0,
6631234326SJohn Scipione	f, 0, f, 0, 0, 0, 0, 0, 0, 0,
6731234326SJohn Scipione	0, f, 0, 0, 0, 0, 0, 0, 0, 0
6831234326SJohn Scipione};
6931234326SJohn Scipione
7031234326SJohn Scipionestatic const unsigned char kOuterShadowBits[] = {
7131234326SJohn Scipione	f, f, f, f, f, f, f, f, f, f,
7231234326SJohn Scipione	f, f, f, f, f, f, f, f, f, f,
7331234326SJohn Scipione	f, f, f, f, f, f, f, f, f, f,
7431234326SJohn Scipione	f, f, f, f, f, f, f, f, f, f,
7531234326SJohn Scipione	f, f, f, f, f, f, f, f, f, 0,
7631234326SJohn Scipione	f, f, f, f, f, f, f, 0, 0, 0,
7731234326SJohn Scipione	f, f, f, f, f, f, 0, f, 0, 0,
7831234326SJohn Scipione	f, f, f, f, f, 0, f, 0, 0, 0,
7931234326SJohn Scipione	f, f, f, f, f, 0, 0, 0, 0, 0,
8031234326SJohn Scipione	f, f, f, f, 0, 0, 0, 0, 0, 0
8131234326SJohn Scipione};
8231234326SJohn Scipione
8331234326SJohn Scipionestatic const unsigned char kBigInnerShadowBits[] = {
8431234326SJohn Scipione	f, f, f, f, f, f, f,
8531234326SJohn Scipione	f, f, f, f, f, f, 0,
8631234326SJohn Scipione	f, f, f, f, f, 0, 0,
8731234326SJohn Scipione	f, f, f, f, 0, f, 0,
8831234326SJohn Scipione	f, f, f, 0, f, 0, 0,
8931234326SJohn Scipione	f, f, 0, f, 0, 0, 0,
9031234326SJohn Scipione	f, 0, 0, 0, 0, 0, 0
9131234326SJohn Scipione};
9231234326SJohn Scipione
9331234326SJohn Scipionestatic const unsigned char kBigOuterShadowBits[] = {
9431234326SJohn Scipione	f, f, f, f, f, f, f,
9531234326SJohn Scipione	f, f, f, f, f, f, 0,
9631234326SJohn Scipione	f, f, f, f, f, f, 0,
9731234326SJohn Scipione	f, f, f, f, f, f, 0,
9831234326SJohn Scipione	f, f, f, f, f, f, 0,
9931234326SJohn Scipione	f, f, f, f, f, f, 0,
10031234326SJohn Scipione	f, 0, 0, 0, 0, 0, 0
10131234326SJohn Scipione};
10231234326SJohn Scipione
10331234326SJohn Scipionestatic const unsigned char kSmallInnerShadowBits[] = {
10431234326SJohn Scipione	f, f, f, 0, 0,
10531234326SJohn Scipione	f, f, 0, f, 0,
10631234326SJohn Scipione	f, 0, f, 0, 0,
10731234326SJohn Scipione	0, f, 0, 0, 0,
10831234326SJohn Scipione	0, 0, 0, 0, 0
10931234326SJohn Scipione};
11031234326SJohn Scipione
11131234326SJohn Scipionestatic const unsigned char kSmallOuterShadowBits[] = {
11231234326SJohn Scipione	f, f, f, f, f,
11331234326SJohn Scipione	f, f, f, f, f,
11431234326SJohn Scipione	f, f, f, f, f,
11531234326SJohn Scipione	f, f, f, f, 0,
11631234326SJohn Scipione	f, f, 0, 0, 0
11731234326SJohn Scipione};
11831234326SJohn Scipione
11931234326SJohn Scipionestatic const unsigned char kGlintBits[] = {
12031234326SJohn Scipione	0, f, 0,
12131234326SJohn Scipione	f, 0, f,
12231234326SJohn Scipione	0, f, f
12331234326SJohn Scipione};
12431234326SJohn Scipione
12531234326SJohn Scipione
126d60b3b1bSAlexander von Gluck IV//     #pragma mark - BeDecorAddOn
127ff78e73cSDarkWyrm
128ff78e73cSDarkWyrm
1291649544dSClemens ZeidlerBeDecorAddOn::BeDecorAddOn(image_id id, const char* name)
1301649544dSClemens Zeidler	:
1311649544dSClemens Zeidler	DecorAddOn(id, name)
1321649544dSClemens Zeidler{
1331649544dSClemens Zeidler}
1341649544dSClemens Zeidler
1351649544dSClemens Zeidler
1361649544dSClemens ZeidlerDecorator*
137d60b3b1bSAlexander von Gluck IVBeDecorAddOn::_AllocateDecorator(DesktopSettings& settings, BRect rect,
138d60b3b1bSAlexander von Gluck IV	Desktop* desktop)
1391649544dSClemens Zeidler{
140d60b3b1bSAlexander von Gluck IV	return new (std::nothrow)BeDecorator(settings, rect, desktop);
1411649544dSClemens Zeidler}
1421649544dSClemens Zeidler
1431649544dSClemens Zeidler
1445a32087bSJohn Scipione//	#pragma mark - BeDecorator
1455a32087bSJohn Scipione
1465a32087bSJohn Scipione
147ff78e73cSDarkWyrm// TODO: get rid of DesktopSettings here, and introduce private accessor
148ff78e73cSDarkWyrm//	methods to the Decorator base class
149d60b3b1bSAlexander von Gluck IVBeDecorator::BeDecorator(DesktopSettings& settings, BRect rect,
150d60b3b1bSAlexander von Gluck IV	Desktop* desktop)
1514d1aa4a6SClemens Zeidler	:
15231234326SJohn Scipione	SATDecorator(settings, rect, desktop),
15331234326SJohn Scipione	fCStatus(B_NO_INIT)
154ff78e73cSDarkWyrm{
155ff78e73cSDarkWyrm	STRACE(("BeDecorator:\n"));
15675e29683SAdrien Destugues	STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",
157ff78e73cSDarkWyrm		rect.left, rect.top, rect.right, rect.bottom));
15831234326SJohn Scipione
15931234326SJohn Scipione	fCloseBitmap = _CreateTemporaryBitmap(BRect(0, 0, 9, 9));
16031234326SJohn Scipione	fBigZoomBitmap = _CreateTemporaryBitmap(BRect(0, 0, 6, 6));
16131234326SJohn Scipione	fSmallZoomBitmap = _CreateTemporaryBitmap(BRect(0, 0, 4, 4));
16231234326SJohn Scipione	fGlintBitmap = _CreateTemporaryBitmap(BRect(0, 0, 2, 2));
16331234326SJohn Scipione		// glint bitmap is used by close and zoom buttons
16431234326SJohn Scipione
16531234326SJohn Scipione	if (fCloseBitmap == NULL || fBigZoomBitmap == NULL
16631234326SJohn Scipione		|| fSmallZoomBitmap == NULL || fGlintBitmap == NULL) {
16731234326SJohn Scipione		fCStatus = B_NO_MEMORY;
16831234326SJohn Scipione	} else
16931234326SJohn Scipione		fCStatus = B_OK;
17030e06bbfSDarkWyrm}
17130e06bbfSDarkWyrm
172ff78e73cSDarkWyrm
173ff78e73cSDarkWyrmBeDecorator::~BeDecorator()
17430e06bbfSDarkWyrm{
175ff78e73cSDarkWyrm	STRACE(("BeDecorator: ~BeDecorator()\n"));
17663720e0fSJohn Scipione	//delete[] fFrameColors;
17731234326SJohn Scipione
17831234326SJohn Scipione	if (fCloseBitmap != NULL)
17931234326SJohn Scipione		fCloseBitmap->ReleaseReference();
18031234326SJohn Scipione
18131234326SJohn Scipione	if (fBigZoomBitmap != NULL)
18231234326SJohn Scipione		fBigZoomBitmap->ReleaseReference();
18331234326SJohn Scipione
18431234326SJohn Scipione	if (fSmallZoomBitmap != NULL)
18531234326SJohn Scipione		fSmallZoomBitmap->ReleaseReference();
18631234326SJohn Scipione
18731234326SJohn Scipione	if (fGlintBitmap != NULL)
18831234326SJohn Scipione		fGlintBitmap->ReleaseReference();
18930e06bbfSDarkWyrm}
19030e06bbfSDarkWyrm
191ff78e73cSDarkWyrm
19263720e0fSJohn Scipione// #pragma mark - Public methods
19330e06bbfSDarkWyrm
19430e06bbfSDarkWyrm
1955a32087bSJohn Scipione/*!	Returns the frame colors for the specified decorator component.
1965a32087bSJohn Scipione
1975a32087bSJohn Scipione	The meaning of the color array elements depends on the specified component.
1985a32087bSJohn Scipione	For some components some array elements are unused.
1995a32087bSJohn Scipione
2005a32087bSJohn Scipione	\param component The component for which to return the frame colors.
2015a32087bSJohn Scipione	\param highlight The highlight set for the component.
2025a32087bSJohn Scipione	\param colors An array of colors to be initialized by the function.
2035a32087bSJohn Scipione*/
2045a32087bSJohn Scipionevoid
2055a32087bSJohn ScipioneBeDecorator::GetComponentColors(Component component, uint8 highlight,
2065a32087bSJohn Scipione	ComponentColors _colors, Decorator::Tab* _tab)
2075a32087bSJohn Scipione{
208e0cbe1aaSJohn Scipione	Decorator::Tab* tab = static_cast<Decorator::Tab*>(_tab);
2095a32087bSJohn Scipione	switch (component) {
2105a32087bSJohn Scipione		case COMPONENT_TAB:
21147c470c6SPuck Meerburg			if (highlight == HIGHLIGHT_STACK_AND_TILE) {
21247c470c6SPuck Meerburg				_colors[COLOR_TAB_FRAME_LIGHT]
213d60b3b1bSAlexander von Gluck IV					= tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
21447c470c6SPuck Meerburg				_colors[COLOR_TAB_FRAME_DARK]
215d60b3b1bSAlexander von Gluck IV					= tint_color(fFocusFrameColor, B_DARKEN_4_TINT);
216d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB] = tint_color(fFocusTabColor,
217d60b3b1bSAlexander von Gluck IV					B_DARKEN_1_TINT);
218d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_LIGHT] = tint_color(fFocusTabColorLight,
219d60b3b1bSAlexander von Gluck IV					B_DARKEN_1_TINT);
220d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
221d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
222d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_TEXT] = fFocusTextColor;
22347c470c6SPuck Meerburg			} else if (tab && tab->buttonFocus) {
2245a32087bSJohn Scipione				_colors[COLOR_TAB_FRAME_LIGHT]
225d60b3b1bSAlexander von Gluck IV					= tint_color(fFocusFrameColor, B_DARKEN_2_TINT);
2265a32087bSJohn Scipione				_colors[COLOR_TAB_FRAME_DARK]
227d60b3b1bSAlexander von Gluck IV					= tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
228d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB] = fFocusTabColor;
229d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_LIGHT] = fFocusTabColorLight;
230d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_BEVEL] = fFocusTabColorBevel;
231d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_SHADOW] = fFocusTabColorShadow;
232d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_TEXT] = fFocusTextColor;
2335a32087bSJohn Scipione			} else {
2345a32087bSJohn Scipione				_colors[COLOR_TAB_FRAME_LIGHT]
235d60b3b1bSAlexander von Gluck IV					= tint_color(fNonFocusFrameColor, B_DARKEN_2_TINT);
2365a32087bSJohn Scipione				_colors[COLOR_TAB_FRAME_DARK]
237d60b3b1bSAlexander von Gluck IV					= tint_color(fNonFocusFrameColor, B_DARKEN_3_TINT);
238d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB] = fNonFocusTabColor;
239d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_LIGHT] = fNonFocusTabColorLight;
240d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_BEVEL] = fNonFocusTabColorBevel;
241d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_SHADOW] = fNonFocusTabColorShadow;
242d60b3b1bSAlexander von Gluck IV				_colors[COLOR_TAB_TEXT] = fNonFocusTextColor;
2435a32087bSJohn Scipione			}
2445a32087bSJohn Scipione			break;
2455a32087bSJohn Scipione
2465a32087bSJohn Scipione		case COMPONENT_CLOSE_BUTTON:
2475a32087bSJohn Scipione		case COMPONENT_ZOOM_BUTTON:
24847c470c6SPuck Meerburg			if (highlight == HIGHLIGHT_STACK_AND_TILE) {
24931234326SJohn Scipione				_colors[COLOR_BUTTON] = tint_color(fFocusTabColor,
25031234326SJohn Scipione					B_DARKEN_1_TINT);
25131234326SJohn Scipione				_colors[COLOR_BUTTON_LIGHT] = tint_color(fFocusTabColorLight,
25231234326SJohn Scipione					B_DARKEN_1_TINT);
25347c470c6SPuck Meerburg			} else if (tab && tab->buttonFocus) {
254d60b3b1bSAlexander von Gluck IV				_colors[COLOR_BUTTON] = fFocusTabColor;
255d60b3b1bSAlexander von Gluck IV				_colors[COLOR_BUTTON_LIGHT] = fFocusTabColorLight;
2565a32087bSJohn Scipione			} else {
257d60b3b1bSAlexander von Gluck IV				_colors[COLOR_BUTTON] = fNonFocusTabColor;
258d60b3b1bSAlexander von Gluck IV				_colors[COLOR_BUTTON_LIGHT] = fNonFocusTabColorLight;
2595a32087bSJohn Scipione			}
2605a32087bSJohn Scipione			break;
2615a32087bSJohn Scipione
2625a32087bSJohn Scipione		case COMPONENT_LEFT_BORDER:
2635a32087bSJohn Scipione		case COMPONENT_RIGHT_BORDER:
2645a32087bSJohn Scipione		case COMPONENT_TOP_BORDER:
2655a32087bSJohn Scipione		case COMPONENT_BOTTOM_BORDER:
2665a32087bSJohn Scipione		case COMPONENT_RESIZE_CORNER:
2675a32087bSJohn Scipione		default:
2685a32087bSJohn Scipione		{
2695a32087bSJohn Scipione			rgb_color base;
27047c470c6SPuck Meerburg			if (highlight == HIGHLIGHT_STACK_AND_TILE)
271d60b3b1bSAlexander von Gluck IV				base = tint_color(fFocusFrameColor, B_DARKEN_3_TINT);
27247c470c6SPuck Meerburg			else if (tab && tab->buttonFocus)
273d60b3b1bSAlexander von Gluck IV				base = fFocusFrameColor;
2745a32087bSJohn Scipione			else
275d60b3b1bSAlexander von Gluck IV				base = fNonFocusFrameColor;
2765a32087bSJohn Scipione
2775a32087bSJohn Scipione			//_colors[0].SetColor(152, 152, 152);
2785a32087bSJohn Scipione			//_colors[1].SetColor(255, 255, 255);
2795a32087bSJohn Scipione			//_colors[2].SetColor(216, 216, 216);
2805a32087bSJohn Scipione			//_colors[3].SetColor(136, 136, 136);
2815a32087bSJohn Scipione			//_colors[4].SetColor(152, 152, 152);
2825a32087bSJohn Scipione			//_colors[5].SetColor(96, 96, 96);
2835a32087bSJohn Scipione
2845a32087bSJohn Scipione			_colors[0].red = std::max(0, base.red - 72);
2855a32087bSJohn Scipione			_colors[0].green = std::max(0, base.green - 72);
2865a32087bSJohn Scipione			_colors[0].blue = std::max(0, base.blue - 72);
2875a32087bSJohn Scipione			_colors[0].alpha = 255;
2885a32087bSJohn Scipione
2895a32087bSJohn Scipione			_colors[1].red = std::min(255, base.red + 64);
2905a32087bSJohn Scipione			_colors[1].green = std::min(255, base.green  + 64);
2915a32087bSJohn Scipione			_colors[1].blue = std::min(255, base.blue  + 64);
2925a32087bSJohn Scipione			_colors[1].alpha = 255;
2935a32087bSJohn Scipione
2945a32087bSJohn Scipione			_colors[2].red = std::max(0, base.red - 8);
2955a32087bSJohn Scipione			_colors[2].green = std::max(0, base.green - 8);
2965a32087bSJohn Scipione			_colors[2].blue = std::max(0, base.blue - 8);
2975a32087bSJohn Scipione			_colors[2].alpha = 255;
2985a32087bSJohn Scipione
2995a32087bSJohn Scipione			_colors[3].red = std::max(0, base.red - 88);
3005a32087bSJohn Scipione			_colors[3].green = std::max(0, base.green - 88);
3015a32087bSJohn Scipione			_colors[3].blue = std::max(0, base.blue - 88);
3025a32087bSJohn Scipione			_colors[3].alpha = 255;
3035a32087bSJohn Scipione
3045a32087bSJohn Scipione			_colors[4].red = std::max(0, base.red - 72);
3055a32087bSJohn Scipione			_colors[4].green = std::max(0, base.green - 72);
3065a32087bSJohn Scipione			_colors[4].blue = std::max(0, base.blue - 72);
3075a32087bSJohn Scipione			_colors[4].alpha = 255;
3085a32087bSJohn Scipione
3095a32087bSJohn Scipione			_colors[5].red = std::max(0, base.red - 128);
3105a32087bSJohn Scipione			_colors[5].green = std::max(0, base.green - 128);
3115a32087bSJohn Scipione			_colors[5].blue = std::max(0, base.blue - 128);
3125a32087bSJohn Scipione			_colors[5].alpha = 255;
3135a32087bSJohn Scipione
3145a32087bSJohn Scipione			// for the resize-border highlight dye everything bluish.
3155a32087bSJohn Scipione			if (highlight == HIGHLIGHT_RESIZE_BORDER) {
3165a32087bSJohn Scipione				for (int32 i = 0; i < 6; i++) {
3175a32087bSJohn Scipione					_colors[i].red = std::max((int)_colors[i].red - 80, 0);
3185a32087bSJohn Scipione					_colors[i].green = std::max((int)_colors[i].green - 80, 0);
3195a32087bSJohn Scipione					_colors[i].blue = 255;
3205a32087bSJohn Scipione				}
3215a32087bSJohn Scipione			}
3225a32087bSJohn Scipione			break;
3235a32087bSJohn Scipione		}
3245a32087bSJohn Scipione	}
3255a32087bSJohn Scipione}
3265a32087bSJohn Scipione
3275a32087bSJohn Scipione
32863720e0fSJohn Scipione// #pragma mark - Protected methods
32930e06bbfSDarkWyrm
330b83b202dSAdrien Destugues
331ff78e73cSDarkWyrmvoid
332ff78e73cSDarkWyrmBeDecorator::_DrawFrame(BRect invalid)
33330e06bbfSDarkWyrm{
334ff78e73cSDarkWyrm	STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
335ff78e73cSDarkWyrm		invalid.right, invalid.bottom));
33630e06bbfSDarkWyrm
337ff78e73cSDarkWyrm	// NOTE: the DrawingEngine needs to be locked for the entire
338ff78e73cSDarkWyrm	// time for the clipping to stay valid for this decorator
33913696633SDarkWyrm
340db9c24a6SJohn Scipione	if (fTopTab->look == B_NO_BORDER_WINDOW_LOOK)
34130e06bbfSDarkWyrm		return;
342ff78e73cSDarkWyrm
343ff78e73cSDarkWyrm	if (fBorderWidth <= 0)
344ff78e73cSDarkWyrm		return;
345ff78e73cSDarkWyrm
346ff78e73cSDarkWyrm	// Draw the border frame
347ff78e73cSDarkWyrm	BRect r = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
348db9c24a6SJohn Scipione	switch ((int)fTopTab->look) {
349ff78e73cSDarkWyrm		case B_TITLED_WINDOW_LOOK:
350ff78e73cSDarkWyrm		case B_DOCUMENT_WINDOW_LOOK:
351ff78e73cSDarkWyrm		case B_MODAL_WINDOW_LOOK:
352634831d8SDarkWyrm		{
353ff78e73cSDarkWyrm			// top
354ff78e73cSDarkWyrm			if (invalid.Intersects(fTopBorder)) {
35563720e0fSJohn Scipione				ComponentColors colors;
35663720e0fSJohn Scipione				_GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
35763720e0fSJohn Scipione
358ff78e73cSDarkWyrm				for (int8 i = 0; i < 5; i++) {
359ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
36063720e0fSJohn Scipione						BPoint(r.right - i, r.top + i), colors[i]);
361ff78e73cSDarkWyrm				}
362db9c24a6SJohn Scipione				if (fTitleBarRect.IsValid()) {
363b83b202dSAdrien Destugues					// grey along the bottom of the tab
364b83b202dSAdrien Destugues					// (overwrites "white" from frame)
365b83b202dSAdrien Destugues					fDrawingEngine->StrokeLine(
366db9c24a6SJohn Scipione						BPoint(fTitleBarRect.left + 2,
367db9c24a6SJohn Scipione							fTitleBarRect.bottom + 1),
368db9c24a6SJohn Scipione						BPoint(fTitleBarRect.right - 2,
369db9c24a6SJohn Scipione							fTitleBarRect.bottom + 1),
37063720e0fSJohn Scipione						colors[2]);
371ff78e73cSDarkWyrm				}
372634831d8SDarkWyrm			}
373ff78e73cSDarkWyrm			// left
374e0cbe1aaSJohn Scipione			if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
37563720e0fSJohn Scipione				ComponentColors colors;
37663720e0fSJohn Scipione				_GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
37763720e0fSJohn Scipione
378ff78e73cSDarkWyrm				for (int8 i = 0; i < 5; i++) {
379ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
38063720e0fSJohn Scipione						BPoint(r.left + i, r.bottom - i), colors[i]);
381ff78e73cSDarkWyrm				}
382634831d8SDarkWyrm			}
383ff78e73cSDarkWyrm			// bottom
384ff78e73cSDarkWyrm			if (invalid.Intersects(fBottomBorder)) {
38563720e0fSJohn Scipione				ComponentColors colors;
38663720e0fSJohn Scipione				_GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
38763720e0fSJohn Scipione
388ff78e73cSDarkWyrm				for (int8 i = 0; i < 5; i++) {
389ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
390b83b202dSAdrien Destugues						BPoint(r.right - i, r.bottom - i),
39163720e0fSJohn Scipione						colors[(4 - i) == 4 ? 5 : (4 - i)]);
392ff78e73cSDarkWyrm				}
393ff78e73cSDarkWyrm			}
394ff78e73cSDarkWyrm			// right
39531234326SJohn Scipione			if (invalid.Intersects(
39631234326SJohn Scipione					fRightBorder.InsetByCopy(0, -fBorderWidth))) {
39763720e0fSJohn Scipione				ComponentColors colors;
39863720e0fSJohn Scipione				_GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
39963720e0fSJohn Scipione
400ff78e73cSDarkWyrm				for (int8 i = 0; i < 5; i++) {
401ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
402b83b202dSAdrien Destugues						BPoint(r.right - i, r.bottom - i),
40363720e0fSJohn Scipione						colors[(4 - i) == 4 ? 5 : (4 - i)]);
404ff78e73cSDarkWyrm				}
405ff78e73cSDarkWyrm			}
406ff78e73cSDarkWyrm			break;
407634831d8SDarkWyrm		}
408d5e020e9SDarkWyrm
409ff78e73cSDarkWyrm		case B_FLOATING_WINDOW_LOOK:
410ff78e73cSDarkWyrm		case kLeftTitledWindowLook:
411634831d8SDarkWyrm		{
412ff78e73cSDarkWyrm			// top
413ff78e73cSDarkWyrm			if (invalid.Intersects(fTopBorder)) {
41463720e0fSJohn Scipione				ComponentColors colors;
41563720e0fSJohn Scipione				_GetComponentColors(COMPONENT_TOP_BORDER, colors, fTopTab);
41663720e0fSJohn Scipione
417ff78e73cSDarkWyrm				for (int8 i = 0; i < 3; i++) {
418ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
41963720e0fSJohn Scipione						BPoint(r.right - i, r.top + i), colors[i * 2]);
420ff78e73cSDarkWyrm				}
42131234326SJohn Scipione				if (fTitleBarRect.IsValid()
42231234326SJohn Scipione					&& fTopTab->look != kLeftTitledWindowLook) {
423b83b202dSAdrien Destugues					// grey along the bottom of the tab
424b83b202dSAdrien Destugues					// (overwrites "white" from frame)
425b83b202dSAdrien Destugues					fDrawingEngine->StrokeLine(
426db9c24a6SJohn Scipione						BPoint(fTitleBarRect.left + 2,
427db9c24a6SJohn Scipione							fTitleBarRect.bottom + 1),
428db9c24a6SJohn Scipione						BPoint(fTitleBarRect.right - 2,
42963720e0fSJohn Scipione							fTitleBarRect.bottom + 1), colors[2]);
430ff78e73cSDarkWyrm				}
431634831d8SDarkWyrm			}
432ff78e73cSDarkWyrm			// left
433e0cbe1aaSJohn Scipione			if (invalid.Intersects(fLeftBorder.InsetByCopy(0, -fBorderWidth))) {
43463720e0fSJohn Scipione				ComponentColors colors;
43563720e0fSJohn Scipione				_GetComponentColors(COMPONENT_LEFT_BORDER, colors, fTopTab);
43663720e0fSJohn Scipione
437ff78e73cSDarkWyrm				for (int8 i = 0; i < 3; i++) {
438ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.left + i, r.top + i),
43963720e0fSJohn Scipione						BPoint(r.left + i, r.bottom - i), colors[i * 2]);
440ff78e73cSDarkWyrm				}
441db9c24a6SJohn Scipione				if (fTopTab->look == kLeftTitledWindowLook
442db9c24a6SJohn Scipione					&& fTitleBarRect.IsValid()) {
443b83b202dSAdrien Destugues					// grey along the right side of the tab
444b83b202dSAdrien Destugues					// (overwrites "white" from frame)
445b83b202dSAdrien Destugues					fDrawingEngine->StrokeLine(
446db9c24a6SJohn Scipione						BPoint(fTitleBarRect.right + 1,
447db9c24a6SJohn Scipione							fTitleBarRect.top + 2),
448db9c24a6SJohn Scipione						BPoint(fTitleBarRect.right + 1,
44963720e0fSJohn Scipione							fTitleBarRect.bottom - 2), colors[2]);
450ff78e73cSDarkWyrm				}
451ff78e73cSDarkWyrm			}
452ff78e73cSDarkWyrm			// bottom
453ff78e73cSDarkWyrm			if (invalid.Intersects(fBottomBorder)) {
45463720e0fSJohn Scipione				ComponentColors colors;
45563720e0fSJohn Scipione				_GetComponentColors(COMPONENT_BOTTOM_BORDER, colors, fTopTab);
45663720e0fSJohn Scipione
457ff78e73cSDarkWyrm				for (int8 i = 0; i < 3; i++) {
458ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.left + i, r.bottom - i),
459b83b202dSAdrien Destugues						BPoint(r.right - i, r.bottom - i),
46063720e0fSJohn Scipione						colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
461ff78e73cSDarkWyrm				}
462634831d8SDarkWyrm			}
463ff78e73cSDarkWyrm			// right
464e0cbe1aaSJohn Scipione			if (invalid.Intersects(fRightBorder.InsetByCopy(0, -fBorderWidth))) {
46563720e0fSJohn Scipione				ComponentColors colors;
46663720e0fSJohn Scipione				_GetComponentColors(COMPONENT_RIGHT_BORDER, colors, fTopTab);
46763720e0fSJohn Scipione
468ff78e73cSDarkWyrm				for (int8 i = 0; i < 3; i++) {
469ff78e73cSDarkWyrm					fDrawingEngine->StrokeLine(BPoint(r.right - i, r.top + i),
470b83b202dSAdrien Destugues						BPoint(r.right - i, r.bottom - i),
47163720e0fSJohn Scipione						colors[(2 - i) == 2 ? 5 : (2 - i) * 2]);
472ff78e73cSDarkWyrm				}
473ff78e73cSDarkWyrm			}
474ff78e73cSDarkWyrm			break;
475634831d8SDarkWyrm		}
476