Browse code

Merge remote-tracking branch 'yab/master' into master

Lorenz Glaser authored onSun/Sep/2020 14:0:th
Showing119 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,252 @@
1
+// Calendar Control version 2.5
2
+// by Al.V. Sarikov.
3
+// Kherson, Ukraine, 2006.
4
+// E-mail: avix@ukrpost.net.
5
+// Home page: http://avix.pp.ru.
6
+
7
+// Updated for Haiku and removed all stuff that is not needed and refactored by jan__64 2009
8
+
9
+// Control which allows to work with dates:
10
+// enter date to text field and choose it from calendar.
11
+
12
+// Distributed under BSD license (see LICENSE file).
13
+
14
+#define __LANG_ENGLISH // to compile english version
15
+
16
+#include "CalendarControl.h"
17
+
18
+#define myButtonMessage 'DCBP'
19
+
20
+#include "DateTextView.cpp"
21
+#include "MonthWindow.cpp"
22
+
23
+#include <AppFileInfo.h>
24
+#include <FindDirectory.h>
25
+#include <File.h>
26
+#include <Path.h>
27
+#include <Point.h>
28
+#include <ControlLook.h>
29
+
30
+
31
+CalendarControl::CalendarControl(BPoint p, const char* name, int day, int month, int year, uint32 flags, uint32 look)
32
+                :BControl(BRect(100,100,200,200),name, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
33
+{
34
+ 
35
+	uint32 divider=look & CC_ALL_DIVIDERS;
36
+ 
37
+	myDateTextView = new DateTextView(day,month,year,flags,divider);
38
+	myButton = new CalendarButton(BRect(70,0,85,15), "CalendarButton", "", new BMessage(myButtonMessage), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
39
+	myOrigin = p;
40
+ 
41
+	AddChild(myDateTextView);
42
+	myDateTextView->MoveTo(3,3);
43
+	ResizeTo(myDateTextView->Bounds().Width()+6,myDateTextView->Bounds().Height()+7);
44
+ 
45
+	AddChild(myButton);
46
+ 
47
+	myButton->ResizeTo(Bounds().Height()*0.7,Bounds().Height()-1);
48
+	myButton->MoveTo(Bounds().right+1, Bounds().top);
49
+	ResizeBy(myButton->Bounds().Width()+1, 0);
50
+}
51
+
52
+
53
+CalendarControl::~CalendarControl()
54
+{
55
+	RemoveChild(myDateTextView);
56
+	delete myDateTextView;
57
+	RemoveChild(myButton);
58
+	delete myButton;
59
+}
60
+
61
+
62
+void CalendarControl::AttachedToWindow(void)
63
+{
64
+	BControl::AttachedToWindow();
65
+ 
66
+	myButton->SetTarget(this);
67
+ 
68
+	if(Parent()!=NULL) 
69
+		view_color=Parent()->ViewColor();
70
+	else
71
+		view_color.red=view_color.green=view_color.blue=view_color.alpha=255;
72
+
73
+	SetViewColor(view_color); // function of CalendarControl class
74
+
75
+	// MakeButton(); // for BeOS interface is called only from here,
76
+	MoveTo(myOrigin);
77
+}
78
+
79
+
80
+void CalendarControl::Draw(BRect r)
81
+{
82
+	BRect bounds(Bounds());
83
+	bounds.bottom--;
84
+	bounds.right = myButton->Frame().left - 1;
85
+
86
+	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
87
+
88
+	bool active = myDateTextView->IsFocus() && Window()->IsActive();
89
+	uint32 flags = 0;
90
+	if (!IsEnabled())
91
+		flags |= BControlLook::B_DISABLED;
92
+	if (active)
93
+		flags |= BControlLook::B_FOCUSED;
94
+	be_control_look->DrawTextControlBorder((BView*)this, bounds, r, base, flags, 15);
95
+}
96
+
97
+
98
+void CalendarControl::KeyDown(const char *bytes, int32 numBytes)
99
+{
100
+	BControl::KeyDown(bytes, numBytes);
101
+	if(bytes[0]==B_TAB) Draw(Bounds());
102
+}
103
+
104
+
105
+void CalendarControl::MakeFocus(bool focused)
106
+{
107
+	myDateTextView->MakeFocus(focused);
108
+}
109
+
110
+
111
+void CalendarControl::MessageReceived(BMessage *msg)
112
+{
113
+	switch(msg->what)
114
+ 	{
115
+  		case myButtonMessage:
116
+		{
117
+ 			if(IsEnabled())
118
+			{
119
+				MakeFocus(true);
120
+				int day, month, year;
121
+				int first_year, last_year;
122
+				GetDate(&day, &month, &year);
123
+				GetYearRange(&first_year, &last_year);
124
+				new MonthWindow(ConvertToScreen(BPoint(Bounds().left+1,Bounds().bottom+1)),
125
+					new BMessenger(this), day, month, year, first_year, last_year);
126
+   			}
127
+   			break;
128
+  		}
129
+		case 'MVME': // message has come from window with calendar
130
+		{
131
+			int32 day, month, year;
132
+			msg->FindInt32("day",&day);
133
+			msg->FindInt32("month",&month);
134
+			msg->FindInt32("year",&year);
135
+			SetDate((int)day, (int)month, (int)year);
136
+			break;
137
+		}
138
+		default:
139
+			BControl::MessageReceived(msg);
140
+	}
141
+}
142
+
143
+
144
+void CalendarControl::SetEnabled(bool enabled)
145
+{
146
+	if(enabled==IsEnabled()) return;
147
+	BControl::SetEnabled(enabled);
148
+	myButton->SetEnabled(enabled);
149
+	myDateTextView->SetEnabled(enabled);
150
+	Invalidate();
151
+}
152
+
153
+
154
+void CalendarControl::SetViewColor(rgb_color color)
155
+{
156
+	view_color=color;
157
+	BControl::SetViewColor(view_color);
158
+	Draw(Bounds());
159
+	Invalidate();
160
+}
161
+
162
+
163
+void CalendarControl::SetViewColor(uchar red, uchar green,
164
+                                   uchar blue, uchar alpha)
165
+{
166
+	rgb_color color={red, green, blue, alpha};
167
+	SetViewColor(color);
168
+}
169
+
170
+
171
+void CalendarControl::WindowActivated(bool active)
172
+{
173
+	myWindowActive = active; // true if window where control is placed is active
174
+	Draw(Bounds());
175
+}
176
+
177
+
178
+const char* CalendarControl::Text() const
179
+{
180
+	return myDateTextView->Text();
181
+}
182
+
183
+
184
+void CalendarControl::GetDate(int *day, int *month, int *year)
185
+{
186
+	myDateTextView->GetDate(day,month,year);
187
+}
188
+
189
+
190
+void CalendarControl::SetDate(int day, int month, int year)
191
+{
192
+	myDateTextView->SetDate(day,month,year);
193
+}
194
+
195
+
196
+void CalendarControl::SetDate(const char *tdate)
197
+{
198
+	myDateTextView->SetDate(tdate);
199
+}
200
+
201
+
202
+void CalendarControl::GetYearRange(int *first_year, int *last_year)
203
+{
204
+	myDateTextView->GetYearRange(first_year, last_year);
205
+}
206
+
207
+
208
+uint32 CalendarControl::GetLook()
209
+{
210
+	return (myDateTextView->GetDivider());
211
+}
212
+
213
+
214
+void CalendarControl::SetLook(uint32 look)
215
+{
216
+	myDateTextView->SetDivider(look & CC_ALL_DIVIDERS);
217
+}
218
+
219
+
220
+uint32 CalendarControl::GetFlags()
221
+{
222
+	return myDateTextView->GetDateFlags();
223
+}
224
+
225
+
226
+void CalendarControl::SetFlags(uint32 flags)
227
+{
228
+	myDateTextView->SetDateFlags(flags);
229
+}
230
+
231
+
232
+BTextView *CalendarControl::TextView(void) const
233
+{
234
+	return (BTextView *)myDateTextView;
235
+}
236
+
237
+
238
+void CalendarButton::Draw(BRect update)
239
+{
240
+	BButton::Draw(update);
241
+	BRect rect = Bounds();
242
+	rect.InsetBy(2.0,4.0);
243
+	uint32 flags = 0;
244
+        rgb_color base = ui_color(B_PANEL_TEXT_COLOR);
245
+        float tint = B_NO_TINT;
246
+        if(!IsEnabled())
247
+	{
248
+                tint = B_LIGHTEN_MAX_TINT;
249
+		flags |= BControlLook::B_DISABLED;
250
+	}
251
+        be_control_look->DrawArrowShape(this, rect, update, base, 3, flags, tint);
252
+}
0 253
new file mode 100644
... ...
@@ -0,0 +1,97 @@
1
+// Calendar Control version 2.5
2
+// by Al.V. Sarikov.
3
+// Kherson, Ukraine, 2006.
4
+// E-mail: avix@ukrpost.net.
5
+// Home page: http://avix.pp.ru.
6
+
7
+// Control which allows to work with dates:
8
+// enter date to text field and choose it from calendar.
9
+
10
+// Distributed under BSD license (see LICENSE file).
11
+
12
+#include <Control.h>
13
+#include <PictureButton.h>
14
+#include <Button.h>
15
+#include <TextView.h>
16
+
17
+class DateTextView;
18
+
19
+class CalendarButton : public BButton
20
+{
21
+	public:
22
+		CalendarButton(BRect frame, const char* name, const char* label,
23
+			BMessage* message, uint32 resizingMode, uint32 flags)
24
+			: BButton(frame, name, label, message, resizingMode, flags)
25
+		{};
26
+		~CalendarButton() {};
27
+		void Draw(BRect update);
28
+};
29
+
30
+// Formats of date
31
+
32
+enum date_format {
33
+	CC_DD_MM_YYYY_FORMAT = 0, 
34
+	CC_MM_DD_YYYY_FORMAT
35
+};
36
+
37
+enum full_short_year {
38
+	CC_FULL_YEAR = 0,  // DD.MM.YYYY
39
+	CC_SHORT_YEAR = 8 // DD.MM.YY
40
+};
41
+
42
+enum century_begin {
43
+	CC_FULL_CENTURY = 0,  // first year is first year of century (01-00)
44
+	CC_HALF_CENTURY = 16 // first year is 51th year of century (51-50)
45
+};
46
+
47
+enum divider_format {
48
+	CC_DOT_DIVIDER = 0, // .
49
+	CC_SLASH_DIVIDER,   // /
50
+	CC_MINUS_DIVIDER,   // -
51
+	CC_ALL_DIVIDERS     // 2 bits, and some one bit is reserved
52
+};
53
+
54
+
55
+class CalendarControl: public BControl
56
+{
57
+	public:
58
+		CalendarControl(BPoint p,
59
+               		   const char* name,
60
+		                  int day=0,
61
+                  		int month=0,
62
+                  		int year=0,
63
+                  		uint32 flags=CC_DD_MM_YYYY_FORMAT | CC_FULL_YEAR,
64
+                  		uint32 look=CC_DOT_DIVIDER);
65
+		~CalendarControl();
66
+		virtual void AttachedToWindow(void);
67
+		virtual void Draw(BRect r);
68
+		virtual void KeyDown(const char *bytes, int32 numBytes);
69
+		virtual void MakeFocus(bool focused=true);
70
+		virtual void MessageReceived(BMessage *msg);
71
+		virtual void SetEnabled(bool enabled);
72
+		virtual void SetViewColor(rgb_color color);
73
+		void SetViewColor(uchar red, uchar green, uchar blue, uchar alpha=255);
74
+		virtual void WindowActivated(bool active);
75
+  		
76
+		void GetDate(int *day, int *month, int *year);
77
+		void SetDate(int day=0, int month=0, int year=0);
78
+		void SetDate(const char *tdate);
79
+		void GetYearRange(int *first_year, int *last_year);
80
+		uint32 GetLook();
81
+		void SetLook(uint32 look);
82
+		uint32 GetFlags();
83
+		void SetFlags(uint32 flags);
84
+		const char* Text() const;
85
+		BTextView *TextView(void) const;
86
+		const char* Version();
87
+
88
+	private:
89
+		void MakeButton();
90
+  		
91
+		DateTextView *myDateTextView;
92
+		CalendarButton *myButton;
93
+		bool myWindowActive;
94
+		BPoint myOrigin;
95
+		rgb_color view_color;
96
+};
97
+
0 98
new file mode 100644
... ...
@@ -0,0 +1,2293 @@
1
+/*
2
+ * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
3
+ * Distributed under the terms of the MIT License.
4
+ */
5
+#include <ControlLook.h>
6
+
7
+#include <stdio.h>
8
+
9
+#include <Control.h>
10
+#include <GradientLinear.h>
11
+#include <Region.h>
12
+#include <Shape.h>
13
+#include <String.h>
14
+#include <View.h>
15
+
16
+namespace BPrivate {
17
+
18
+static const float kEdgeBevelLightTint = 0.59;
19
+static const float kEdgeBevelShadowTint = 1.0735;
20
+
21
+
22
+BControlLook::BControlLook()
23
+{
24
+}
25
+
26
+
27
+BControlLook::~BControlLook()
28
+{
29
+}
30
+
31
+
32
+BAlignment
33
+BControlLook::DefaultLabelAlignment() const
34
+{
35
+	return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
36
+}
37
+
38
+
39
+float
40
+BControlLook::DefaultLabelSpacing() const
41
+{
42
+	return 4.0;//ceilf(be_plain_font->Size() / 4.0);
43
+}
44
+
45
+
46
+uint32
47
+BControlLook::Flags(BControl* control) const
48
+{
49
+	uint32 flags = 0;
50
+
51
+	if (!control->IsEnabled())
52
+		flags |= B_DISABLED;
53
+
54
+	if (control->IsFocus())
55
+		flags |= B_FOCUSED;
56
+
57
+	if (control->Value() == B_CONTROL_ON)
58
+		flags |= B_ACTIVATED;
59
+
60
+	return flags;
61
+}
62
+
63
+
64
+// #pragma mark -
65
+
66
+
67
+void
68
+BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
69
+	const rgb_color& base, const rgb_color& background, uint32 flags,
70
+	uint32 borders)
71
+{
72
+	_DrawButtonFrame(view, rect, updateRect, base, background, 1.0, 1.0, flags,
73
+		borders);
74
+}
75
+
76
+
77
+void
78
+BControlLook::DrawButtonBackground(BView* view, BRect& rect,
79
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
80
+	uint32 borders, enum orientation orientation)
81
+{
82
+	if (!rect.IsValid() || !updateRect.Intersects(rect))
83
+		return;
84
+
85
+	// the surface edges
86
+
87
+	// colors
88
+	rgb_color buttonBgColor = tint_color(base, B_LIGHTEN_1_TINT);
89
+	rgb_color maxLightColor;
90
+
91
+	rgb_color bevelColor1;
92
+	rgb_color bevelColor2;
93
+
94
+	if ((flags & B_DISABLED) == 0) {
95
+		maxLightColor = tint_color(base, 0.2);
96
+		bevelColor1 = tint_color(base, 1.08);
97
+		bevelColor2 = base;
98
+	} else {
99
+		maxLightColor = tint_color(base, 0.7);
100
+		bevelColor1 = base;
101
+		bevelColor2 = buttonBgColor;
102
+		buttonBgColor = maxLightColor;
103
+	}
104
+
105
+	if (flags & B_ACTIVATED) {
106
+		view->BeginLineArray(4);
107
+
108
+		bevelColor1 = tint_color(bevelColor1, B_DARKEN_1_TINT);
109
+		bevelColor2 = tint_color(bevelColor2, B_DARKEN_1_TINT);
110
+
111
+		// shadow along left/top borders
112
+		if (borders & B_LEFT_BORDER) {
113
+			view->AddLine(BPoint(rect.left, rect.top),
114
+				BPoint(rect.left, rect.bottom), bevelColor1);
115
+			rect.left++;
116
+		}
117
+		if (borders & B_TOP_BORDER) {
118
+			view->AddLine(BPoint(rect.left, rect.top),
119
+				BPoint(rect.right, rect.top), bevelColor1);
120
+			rect.top++;
121
+		}
122
+
123
+		// softer shadow along left/top borders
124
+		if (borders & B_LEFT_BORDER) {
125
+			view->AddLine(BPoint(rect.left, rect.top),
126
+				BPoint(rect.left, rect.bottom), bevelColor2);
127
+			rect.left++;
128
+		}
129
+		if (borders & B_TOP_BORDER) {
130
+			view->AddLine(BPoint(rect.left, rect.top),
131
+				BPoint(rect.right, rect.top), bevelColor2);
132
+			rect.top++;
133
+		}
134
+
135
+		view->EndLineArray();
136
+	} else {
137
+		_DrawFrame(view, rect,
138
+			maxLightColor, maxLightColor,
139
+			bevelColor1, bevelColor1,
140
+			buttonBgColor, buttonBgColor, borders);
141
+	}
142
+
143
+	// the actual surface top
144
+
145
+	float topTint = 0.49;
146
+	float middleTint1 = 0.62;
147
+	float middleTint2 = 0.76;
148
+	float bottomTint = 0.90;
149
+
150
+	if (flags & B_ACTIVATED) {
151
+		topTint = 1.11;
152
+		bottomTint = 1.08;
153
+	}
154
+
155
+	if (flags & B_DISABLED) {
156
+		topTint = (topTint + B_NO_TINT) / 2;
157
+		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
158
+		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
159
+		bottomTint = (bottomTint + B_NO_TINT) / 2;
160
+	} else if (flags & B_HOVER) {
161
+		static const float kHoverTintFactor = 0.85;
162
+		topTint *= kHoverTintFactor;
163
+		middleTint1 *= kHoverTintFactor;
164
+		middleTint2 *= kHoverTintFactor;
165
+		bottomTint *= kHoverTintFactor;
166
+	}
167
+
168
+	if (flags & B_ACTIVATED) {
169
+		_FillGradient(view, rect, base, topTint, bottomTint, orientation);
170
+	} else {
171
+		_FillGlossyGradient(view, rect, base, topTint, middleTint1,
172
+			middleTint2, bottomTint, orientation);
173
+	}
174
+}
175
+
176
+
177
+void
178
+BControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
179
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
180
+	uint32 borders)
181
+{
182
+	if (!rect.IsValid() || !updateRect.Intersects(rect))
183
+		return;
184
+
185
+	// the surface edges
186
+
187
+	// colors
188
+	float topTint;
189
+	float bottomTint;
190
+
191
+	if (flags & B_ACTIVATED) {
192
+		rgb_color bevelColor1 = tint_color(base, 1.40);
193
+		rgb_color bevelColor2 = tint_color(base, 1.25);
194
+
195
+		topTint = 1.25;
196
+		bottomTint = 1.20;
197
+
198
+		_DrawFrame(view, rect,
199
+			bevelColor1, bevelColor1,
200
+			bevelColor2, bevelColor2,
201
+			borders & B_TOP_BORDER);
202
+	} else {
203
+		rgb_color cornerColor = tint_color(base, 0.9);
204
+		rgb_color bevelColorTop = tint_color(base, 0.5);
205
+		rgb_color bevelColorLeft = tint_color(base, 0.7);
206
+		rgb_color bevelColorRightBottom = tint_color(base, 1.08);
207
+
208
+		topTint = 0.69;
209
+		bottomTint = 1.03;
210
+
211
+		_DrawFrame(view, rect,
212
+			bevelColorLeft, bevelColorTop,
213
+			bevelColorRightBottom, bevelColorRightBottom,
214
+			cornerColor, cornerColor,
215
+			borders);
216
+	}
217
+
218
+	// the actual surface top
219
+
220
+	_FillGradient(view, rect, base, topTint, bottomTint);
221
+}
222
+
223
+
224
+void
225
+BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
226
+	const BRect& updateRect, const rgb_color& base,
227
+	const rgb_color& background, uint32 flags, uint32 borders)
228
+{
229
+	_DrawButtonFrame(view, rect, updateRect, base, background, 0.6, 1.0, flags,
230
+		borders);
231
+}
232
+
233
+
234
+void
235
+BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
236
+	const BRect& updateRect, const rgb_color& base, bool popupIndicator,
237
+	uint32 flags)
238
+{
239
+	if (popupIndicator) {
240
+		BRect leftRect(rect);
241
+		leftRect.right -= 10;
242
+
243
+		BRect rightRect(rect);
244
+		rightRect.left = rightRect.right - 9;
245
+
246
+		DrawMenuFieldBackground(view, leftRect, updateRect, base, flags,
247
+			B_LEFT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER);
248
+
249
+		rgb_color indicatorBase;
250
+		rgb_color markColor;
251
+		if (flags & B_DISABLED) {
252
+			indicatorBase = tint_color(base, 1.05);
253
+			markColor = tint_color(base, 1.35);
254
+		} else {
255
+			indicatorBase = tint_color(base, 1.12);
256
+			markColor = tint_color(base, 1.65);
257
+		}
258
+
259
+		DrawMenuFieldBackground(view, rightRect, updateRect, indicatorBase,
260
+			flags, B_RIGHT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER);
261
+
262
+		// popup marker
263
+		BPoint center(roundf((rightRect.left + rightRect.right) / 2.0),
264
+					  roundf((rightRect.top + rightRect.bottom) / 2.0));
265
+		BPoint triangle[3];
266
+		triangle[0] = center + BPoint(-2.5, -0.5);
267
+		triangle[1] = center + BPoint(2.5, -0.5);
268
+		triangle[2] = center + BPoint(0.0, 2.0);
269
+
270
+		uint32 viewFlags = view->Flags();
271
+		view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
272
+
273
+		view->SetHighColor(markColor);
274
+		view->FillTriangle(triangle[0], triangle[1], triangle[2]);
275
+
276
+		view->SetFlags(viewFlags);
277
+
278
+		rect = leftRect;
279
+	} else {
280
+		DrawMenuFieldBackground(view, rect, updateRect, base, flags);
281
+	}
282
+}
283
+
284
+void
285
+BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
286
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
287
+	uint32 borders)
288
+{
289
+	if (!rect.IsValid() || !updateRect.Intersects(rect))
290
+		return;
291
+
292
+	// the surface edges
293
+
294
+	// colors
295
+	rgb_color cornerColor = tint_color(base, 0.85);
296
+	rgb_color bevelColor1 = tint_color(base, 0.3);
297
+	rgb_color bevelColor2 = tint_color(base, 0.5);
298
+	rgb_color bevelColor3 = tint_color(base, 1.03);
299
+
300
+	if (flags & B_DISABLED) {
301
+		cornerColor = tint_color(base, 0.8);
302
+		bevelColor1 = tint_color(base, 0.7);
303
+		bevelColor2 = tint_color(base, 0.8);
304
+		bevelColor3 = tint_color(base, 1.01);
305
+	} else {
306
+		cornerColor = tint_color(base, 0.85);
307
+		bevelColor1 = tint_color(base, 0.3);
308
+		bevelColor2 = tint_color(base, 0.5);
309
+		bevelColor3 = tint_color(base, 1.03);
310
+	}
311
+
312
+	_DrawFrame(view, rect,
313
+		bevelColor2, bevelColor1,
314
+		bevelColor3, bevelColor3,
315
+		cornerColor, cornerColor,
316
+		borders);
317
+
318
+	// the actual surface top
319
+
320
+	float topTint = 0.49;
321
+	float middleTint1 = 0.62;
322
+	float middleTint2 = 0.76;
323
+	float bottomTint = 0.90;
324
+
325
+	if (flags & B_DISABLED) {
326
+		topTint = (topTint + B_NO_TINT) / 2;
327
+		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
328
+		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
329
+		bottomTint = (bottomTint + B_NO_TINT) / 2;
330
+	} else if (flags & B_HOVER) {
331
+		static const float kHoverTintFactor = 0.85;
332
+		topTint *= kHoverTintFactor;
333
+		middleTint1 *= kHoverTintFactor;
334
+		middleTint2 *= kHoverTintFactor;
335
+		bottomTint *= kHoverTintFactor;
336
+	}
337
+
338
+	_FillGlossyGradient(view, rect, base, topTint, middleTint1,
339
+		middleTint2, bottomTint);
340
+}
341
+
342
+void
343
+BControlLook::DrawMenuBackground(BView* view, BRect& rect,
344
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
345
+	uint32 borders)
346
+{
347
+	if (!rect.IsValid() || !updateRect.Intersects(rect))
348
+		return;
349
+
350
+	// the surface edges
351
+
352
+	rgb_color bevelLightColor;
353
+	rgb_color bevelShadowColor;
354
+	rgb_color background = tint_color(base, 0.75);
355
+
356
+	if (flags & B_DISABLED) {
357
+		bevelLightColor = tint_color(background, 0.80);
358
+		bevelShadowColor = tint_color(background, 1.07);
359
+	} else {
360
+		bevelLightColor = tint_color(background, 0.6);
361
+		bevelShadowColor = tint_color(background, 1.12);
362
+	}
363
+
364
+	_DrawFrame(view, rect,
365
+		bevelLightColor, bevelLightColor,
366
+		bevelShadowColor, bevelShadowColor,
367
+		borders);
368
+
369
+	// the actual surface top
370
+
371
+	view->SetHighColor(background);
372
+	view->FillRect(rect);
373
+}
374
+
375
+
376
+void
377
+BControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
378
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
379
+	uint32 borders)
380
+{
381
+	if (!rect.IsValid() || !updateRect.Intersects(rect))
382
+		return;
383
+
384
+	// the surface edges
385
+
386
+	float topTint;
387
+	float bottomTint;
388
+	rgb_color selectedColor = base;
389
+
390
+	if (flags & B_ACTIVATED) {
391
+		topTint = 0.9;
392
+		bottomTint = 1.05;
393
+		selectedColor = tint_color(base, 1.26);
394
+	} else if (flags & B_DISABLED) {
395
+		topTint = 0.80;
396
+		bottomTint = 1.07;
397
+	} else {
398
+		topTint = 0.6;
399
+		bottomTint = 1.12;
400
+	}
401
+
402
+	rgb_color bevelLightColor = tint_color(selectedColor, topTint);
403
+	rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint);
404
+
405
+	_DrawFrame(view, rect,
406
+		bevelLightColor, bevelLightColor,
407
+		bevelShadowColor, bevelShadowColor,
408
+		borders);
409
+
410
+	// the actual surface top
411
+
412
+	view->SetLowColor(selectedColor);
413
+//	_FillGradient(view, rect, selectedColor, topTint, bottomTint);
414
+	_FillGradient(view, rect, selectedColor, bottomTint, topTint);
415
+}
416
+
417
+
418
+void
419
+BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect,
420
+	const rgb_color& base, const rgb_color& barColor, float progressPosition)
421
+{
422
+	if (!rect.Intersects(updateRect))
423
+		return;
424
+
425
+	_DrawOuterResessedFrame(view, rect, base, 0.6);
426
+
427
+	// colors
428
+	rgb_color dark1BorderColor = tint_color(base, 1.3);
429
+	rgb_color dark2BorderColor = tint_color(base, 1.2);
430
+	rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20);
431
+	rgb_color dark2FilledBorderColor = tint_color(barColor, 1.45);
432
+
433
+	BRect filledRect(rect);
434
+	filledRect.right = progressPosition - 1;
435
+
436
+	BRect nonfilledRect(rect);
437
+	nonfilledRect.left = progressPosition;
438
+
439
+	bool filledSurface = filledRect.Width() > 0;
440
+	bool nonfilledSurface = nonfilledRect.Width() > 0;
441
+
442
+	if (filledSurface) {
443
+		_DrawFrame(view, filledRect,
444
+			dark1FilledBorderColor, dark1FilledBorderColor,
445
+			dark2FilledBorderColor, dark2FilledBorderColor);
446
+
447
+		_FillGlossyGradient(view, filledRect, barColor, 0.55, 0.68, 0.76, 0.90);
448
+	}
449
+
450
+	if (nonfilledSurface) {
451
+		_DrawFrame(view, nonfilledRect, dark1BorderColor, dark1BorderColor,
452
+			dark2BorderColor, dark2BorderColor,
453
+			B_TOP_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
454
+
455
+		if (nonfilledRect.left < nonfilledRect.right) {
456
+			// shadow from fill bar, or left border
457
+			rgb_color leftBorder = dark1BorderColor;
458
+			if (filledSurface)
459
+				leftBorder = tint_color(base, 0.50);
460
+			view->SetHighColor(leftBorder);
461
+			view->StrokeLine(nonfilledRect.LeftTop(),
462
+				nonfilledRect.LeftBottom());
463
+			nonfilledRect.left++;
464
+		}
465
+
466
+		_FillGradient(view, nonfilledRect, base, 0.25, 0.06);
467
+	}
468
+}
469
+
470
+
471
+void
472
+BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect,
473
+	const rgb_color& base, uint32 flags)
474
+{
475
+	if (!rect.Intersects(updateRect))
476
+		return;
477
+
478
+	rgb_color dark1BorderColor;
479
+	rgb_color dark2BorderColor;
480
+	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
481
+
482
+	if (flags & B_DISABLED) {
483
+		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags);
484
+
485
+		dark1BorderColor = tint_color(base, 1.15);
486
+		dark2BorderColor = tint_color(base, 1.15);
487
+	} else if (flags & B_CLICKED) {
488
+		dark1BorderColor = tint_color(base, 1.50);
489
+		dark2BorderColor = tint_color(base, 1.48);
490
+
491
+		_DrawFrame(view, rect,
492
+			dark1BorderColor, dark1BorderColor,
493
+			dark2BorderColor, dark2BorderColor);
494
+
495
+		dark2BorderColor = dark1BorderColor;
496
+	} else {
497
+		_DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags);
498
+
499
+		dark1BorderColor = tint_color(base, 1.40);
500
+		dark2BorderColor = tint_color(base, 1.38);
501
+	}
502
+
503
+	if (flags & B_FOCUSED) {
504
+		dark1BorderColor = navigationColor;
505
+		dark2BorderColor = navigationColor;
506
+	}
507
+
508
+	_DrawFrame(view, rect,
509
+		dark1BorderColor, dark1BorderColor,
510
+		dark2BorderColor, dark2BorderColor);
511
+
512
+	if (flags & B_DISABLED) {
513
+		_FillGradient(view, rect, base, 0.4, 0.2);
514
+	} else {
515
+		_FillGradient(view, rect, base, 0.15, 0.0);
516
+	}
517
+
518
+	rgb_color markColor;
519
+	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
520
+		view->SetHighColor(markColor);
521
+
522
+		rect.InsetBy(2, 2);
523
+		view->SetPenSize(max_c(1.0, ceilf(rect.Width() / 3.5)));
524
+		view->SetDrawingMode(B_OP_OVER);
525
+
526
+		view->StrokeLine(rect.LeftTop(), rect.RightBottom());
527
+		view->StrokeLine(rect.LeftBottom(), rect.RightTop());
528
+	}
529
+}
530
+
531
+
532
+void
533
+BControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect,
534
+	const rgb_color& base, uint32 flags)
535
+{
536
+	if (!rect.Intersects(updateRect))
537
+		return;
538
+
539
+	rgb_color borderColor;
540
+	rgb_color bevelLight;
541
+	rgb_color bevelShadow;
542
+	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
543
+
544
+	if (flags & B_DISABLED) {
545
+		borderColor = tint_color(base, 1.15);
546
+		bevelLight = base;
547
+		bevelShadow = base;
548
+	} else if (flags & B_CLICKED) {
549
+		borderColor = tint_color(base, 1.50);
550
+		bevelLight = borderColor;
551
+		bevelShadow = borderColor;
552
+	} else {
553
+		borderColor = tint_color(base, 1.45);
554
+		bevelLight = tint_color(base, 0.55);
555
+		bevelShadow = tint_color(base, 1.11);
556
+	}
557
+
558
+	if (flags & B_FOCUSED) {
559
+		borderColor = navigationColor;
560
+	}
561
+
562
+	BGradientLinear bevelGradient;
563
+	bevelGradient.AddColor(bevelShadow, 0);
564
+	bevelGradient.AddColor(bevelLight, 255);
565
+	bevelGradient.SetStart(rect.LeftTop());
566
+	bevelGradient.SetEnd(rect.RightBottom());
567
+
568
+	view->FillEllipse(rect, bevelGradient);
569
+	rect.InsetBy(1, 1);
570
+
571
+	bevelGradient.MakeEmpty();
572
+	bevelGradient.AddColor(borderColor, 0);
573
+	bevelGradient.AddColor(tint_color(borderColor, 0.8), 255);
574
+	view->FillEllipse(rect, bevelGradient);
575
+	rect.InsetBy(1, 1);
576
+
577
+	float topTint;
578
+	float bottomTint;
579
+	if (flags & B_DISABLED) {
580
+		topTint = 0.4;
581
+		bottomTint = 0.2;
582
+	} else {
583
+		topTint = 0.15;
584
+		bottomTint = 0.0;
585
+	}
586
+
587
+	BGradientLinear gradient;
588
+	_MakeGradient(gradient, rect, base, topTint, bottomTint);
589
+	view->FillEllipse(rect, gradient);
590
+
591
+	rgb_color markColor;
592
+	if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) {
593
+		view->SetHighColor(markColor);
594
+		rect.InsetBy(3, 3);
595
+		view->FillEllipse(rect);
596
+	}
597
+}
598
+
599
+
600
+void
601
+BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2,
602
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
603
+	enum orientation orientation)
604
+{
605
+	DrawScrollBarBackground(view, rect1, updateRect, base, flags, orientation);
606
+	DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation);
607
+}
608
+
609
+void
610
+BControlLook::DrawScrollBarBackground(BView* view, BRect& rect,
611
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
612
+	enum orientation orientation)
613
+{
614
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
615
+		return;
616
+
617
+	float gradient1Tint;
618
+	float gradient2Tint;
619
+	float darkEdge1Tint;
620
+	float darkEdge2Tint;
621
+	float shadowTint;
622
+
623
+	if (flags & B_DISABLED) {
624
+		gradient1Tint = 0.9;
625
+		gradient2Tint = 0.8;
626
+		darkEdge1Tint = B_DARKEN_2_TINT;
627
+		darkEdge2Tint = B_DARKEN_2_TINT;
628
+		shadowTint = gradient1Tint;
629
+	} else {
630
+		gradient1Tint = 1.10;
631
+		gradient2Tint = 1.05;
632
+		darkEdge1Tint = B_DARKEN_3_TINT;
633
+		darkEdge2Tint = B_DARKEN_2_TINT;
634
+		shadowTint = gradient1Tint;
635
+	}
636
+
637
+	rgb_color darkEdge1 = tint_color(base, darkEdge1Tint);
638
+	rgb_color darkEdge2 = tint_color(base, darkEdge2Tint);
639
+	rgb_color shadow = tint_color(base, shadowTint);
640
+
641
+	if (orientation == B_HORIZONTAL) {
642
+		// dark vertical line on left edge
643
+		if (rect.Width() > 0) {
644
+			view->SetHighColor(darkEdge1);
645
+			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
646
+			rect.left++;
647
+		}
648
+		// dark vertical line on right edge
649
+		if (rect.Width() >= 0) {
650
+			view->SetHighColor(darkEdge2);
651
+			view->StrokeLine(rect.RightTop(), rect.RightBottom());
652
+			rect.right--;
653
+		}
654
+		// vertical shadow line after left edge
655
+		if (rect.Width() >= 0) {
656
+			view->SetHighColor(shadow);
657
+			view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
658
+			rect.left++;
659
+		}
660
+		// fill
661
+		if (rect.Width() >= 0) {
662
+			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
663
+				orientation);
664
+		}
665
+	} else {
666
+		// dark vertical line on top edge
667
+		if (rect.Height() > 0) {
668
+			view->SetHighColor(darkEdge1);
669
+			view->StrokeLine(rect.LeftTop(), rect.RightTop());
670
+			rect.top++;
671
+		}
672
+		// dark vertical line on bottom edge
673
+		if (rect.Height() >= 0) {
674
+			view->SetHighColor(darkEdge2);
675
+			view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
676
+			rect.bottom--;
677
+		}
678
+		// horizontal shadow line after top edge
679
+		if (rect.Height() >= 0) {
680
+			view->SetHighColor(shadow);
681
+			view->StrokeLine(rect.LeftTop(), rect.RightTop());
682
+			rect.top++;
683
+		}
684
+		// fill
685
+		if (rect.Height() >= 0) {
686
+			_FillGradient(view, rect, base, gradient1Tint, gradient2Tint,
687
+				orientation);
688
+		}
689
+	}
690
+}
691
+
692
+
693
+void
694
+BControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
695
+	const BRect& updateRect, BRect verticalScrollBarFrame,
696
+	BRect horizontalScrollBarFrame, const rgb_color& base,
697
+	border_style border, uint32 flags, uint32 _borders)
698
+{
699
+	// calculate scroll corner rect before messing with the "rect"
700
+	BRect scrollCornerFillRect(rect.right, rect.bottom,
701
+		rect.right, rect.bottom);
702
+	if (horizontalScrollBarFrame.IsValid())
703
+		scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1;
704
+	if (verticalScrollBarFrame.IsValid())
705
+		scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1;
706
+
707
+	if (border == B_NO_BORDER) {
708
+		if (scrollCornerFillRect.IsValid()) {
709
+			view->SetHighColor(base);
710
+			view->FillRect(scrollCornerFillRect);
711
+		}
712
+		return;
713
+	}
714
+
715
+	bool excludeScrollCorner = border == B_FANCY_BORDER
716
+		&& horizontalScrollBarFrame.IsValid()
717
+		&& verticalScrollBarFrame.IsValid();
718
+
719
+	uint32 borders = _borders;
720
+	if (excludeScrollCorner) {
721
+		rect.bottom = horizontalScrollBarFrame.top;
722
+		rect.right = verticalScrollBarFrame.left;
723
+		borders &= ~(B_RIGHT_BORDER | B_BOTTOM_BORDER);
724
+	}
725
+
726
+	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
727
+
728
+	if (border == B_FANCY_BORDER)
729
+		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
730
+
731
+	if (flags & B_FOCUSED) {
732
+		rgb_color focusColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
733
+		_DrawFrame(view, rect, focusColor, focusColor, focusColor, focusColor,
734
+			borders);
735
+	} else {
736
+		_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
737
+			scrollbarFrameColor, scrollbarFrameColor, borders);
738
+	}
739
+
740
+	if (excludeScrollCorner) {
741
+		horizontalScrollBarFrame.InsetBy(-1, -1);
742
+		// do not overdraw the top edge
743
+		horizontalScrollBarFrame.top += 2;
744
+		borders = _borders;
745
+		borders &= ~B_TOP_BORDER;
746
+		_DrawOuterResessedFrame(view, horizontalScrollBarFrame, base,
747
+			1.0, 1.0, flags, borders);
748
+		_DrawFrame(view, horizontalScrollBarFrame, scrollbarFrameColor,
749
+			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
750
+			borders);
751
+
752
+
753
+		verticalScrollBarFrame.InsetBy(-1, -1);
754
+		// do not overdraw the left edge
755
+		verticalScrollBarFrame.left += 2;
756
+		borders = _borders;
757
+		borders &= ~B_LEFT_BORDER;
758
+		_DrawOuterResessedFrame(view, verticalScrollBarFrame, base,
759
+			1.0, 1.0, flags, borders);
760
+		_DrawFrame(view, verticalScrollBarFrame, scrollbarFrameColor,
761
+			scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
762
+			borders);
763
+
764
+		// exclude recessed frame
765
+		scrollCornerFillRect.top++;
766
+		scrollCornerFillRect.left++;
767
+	}
768
+
769
+	if (scrollCornerFillRect.IsValid()) {
770
+		view->SetHighColor(base);
771
+		view->FillRect(scrollCornerFillRect);
772
+	}
773
+}
774
+
775
+
776
+void
777
+BControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect,
778
+	const rgb_color& base, uint32 direction, uint32 flags, float tint)
779
+{
780
+	BPoint tri1, tri2, tri3;
781
+	float hInset = rect.Width() / 3;
782
+	float vInset = rect.Height() / 3;
783
+	rect.InsetBy(hInset, vInset);
784
+
785
+	switch (direction) {
786
+		case B_LEFT_ARROW:
787
+			tri1.Set(rect.right, rect.top);
788
+			tri2.Set(rect.right - rect.Width() / 1.33,
789
+				(rect.top + rect.bottom + 1) /2 );
790
+			tri3.Set(rect.right, rect.bottom + 1);
791
+			break;
792
+		case B_RIGHT_ARROW:
793
+			tri1.Set(rect.left, rect.bottom + 1);
794
+			tri2.Set(rect.left + rect.Width() / 1.33,
795
+				(rect.top + rect.bottom + 1) / 2);
796
+			tri3.Set(rect.left, rect.top);
797
+			break;
798
+		case B_UP_ARROW:
799
+			tri1.Set(rect.left, rect.bottom);
800
+			tri2.Set((rect.left + rect.right + 1) / 2,
801
+				rect.bottom - rect.Height() / 1.33);
802
+			tri3.Set(rect.right + 1, rect.bottom);
803
+			break;
804
+		case B_DOWN_ARROW:
805
+		default:
806
+			tri1.Set(rect.left, rect.top);
807
+			tri2.Set((rect.left + rect.right + 1) / 2,
808
+				rect.top + rect.Height() / 1.33);
809
+			tri3.Set(rect.right + 1, rect.top);
810
+			break;
811
+	}
812
+	// offset triangle if down
813
+	if (flags & B_ACTIVATED)
814
+		view->MovePenTo(BPoint(1, 1));
815
+	else
816
+		view->MovePenTo(BPoint(0, 0));
817
+
818
+	BShape arrowShape;
819
+	arrowShape.MoveTo(tri1);
820
+	arrowShape.LineTo(tri2);
821
+	arrowShape.LineTo(tri3);
822
+
823
+	if (flags & B_DISABLED)
824
+		tint = (tint + B_NO_TINT + B_NO_TINT) / 3;
825
+
826
+	view->SetHighColor(tint_color(base, tint));
827
+
828
+	float penSize = view->PenSize();
829
+	drawing_mode mode = view->DrawingMode();
830
+
831
+	view->SetPenSize(ceilf(hInset / 2.0));
832
+	view->SetDrawingMode(B_OP_OVER);
833
+	view->StrokeShape(&arrowShape);
834
+
835
+	view->SetPenSize(penSize);
836
+	view->SetDrawingMode(mode);
837
+}
838
+
839
+
840
+rgb_color
841
+BControlLook::SliderBarColor(const rgb_color& base)
842
+{
843
+	return tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT);
844
+}
845
+
846
+
847
+void
848
+BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
849
+	const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor,
850
+	float sliderScale, uint32 flags, enum orientation orientation)
851
+{
852
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
853
+		return;
854
+
855
+	// separate the bar in two sides
856
+	float sliderPosition;
857
+	BRect leftBarSide = rect;
858
+	BRect rightBarSide = rect;
859
+
860
+	if (orientation == B_HORIZONTAL) {
861
+		sliderPosition = floorf(rect.left + 2 + (rect.Width() - 2)
862
+			* sliderScale);
863
+		leftBarSide.right = sliderPosition - 1;
864
+		rightBarSide.left = sliderPosition;
865
+	} else {
866
+		sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
867
+			* sliderScale);
868
+		leftBarSide.bottom = sliderPosition - 1;
869
+		rightBarSide.top = sliderPosition;
870
+	}
871
+
872
+	// fill the background for the corners, exclude the middle bar for now
873
+	BRegion region(rect);
874
+	region.Exclude(rightBarSide);
875
+	view->ConstrainClippingRegion(&region);
876
+
877
+	view->PushState();
878
+
879
+	DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
880
+		orientation);
881
+
882
+	view->PopState();
883
+
884
+	region.Set(rect);
885
+	region.Exclude(leftBarSide);
886
+	view->ConstrainClippingRegion(&region);
887
+
888
+	view->PushState();
889
+
890
+	DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
891
+		orientation);
892
+
893
+	view->PopState();
894
+
895
+	view->ConstrainClippingRegion(NULL);
896
+}
897
+
898
+
899
+void
900
+BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
901
+	const rgb_color& base, rgb_color fillColor, uint32 flags,
902
+	enum orientation orientation)
903
+{
904
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
905
+		return;
906
+
907
+	// separate the rect into corners
908
+	BRect leftCorner(rect);
909
+	BRect rightCorner(rect);
910
+	BRect barRect(rect);
911
+
912
+	if (orientation == B_HORIZONTAL) {
913
+		leftCorner.right = leftCorner.left + leftCorner.Height();
914
+		rightCorner.left = rightCorner.right - rightCorner.Height();
915
+		barRect.left += ceilf(barRect.Height() / 2);
916
+		barRect.right -= ceilf(barRect.Height() / 2);
917
+	} else {
918
+		leftCorner.bottom = leftCorner.top + leftCorner.Width();
919
+		rightCorner.top = rightCorner.bottom - rightCorner.Width();
920
+		barRect.top += ceilf(barRect.Width() / 2);
921
+		barRect.bottom -= ceilf(barRect.Width() / 2);
922
+	}
923
+
924
+	// fill the background for the corners, exclude the middle bar for now
925
+	BRegion region(rect);
926
+	region.Exclude(barRect);
927
+	view->ConstrainClippingRegion(&region);
928
+
929
+	view->SetHighColor(base);
930
+	view->FillRect(rect);
931
+
932
+	// figure out the tints to be used
933
+	float edgeLightTint;
934
+	float edgeShadowTint;
935
+	float frameLightTint;
936
+	float frameShadowTint;
937
+	float fillLightTint;
938
+	float fillShadowTint;
939
+
940
+	if (flags & B_DISABLED) {
941
+		edgeLightTint = 1.0;
942
+		edgeShadowTint = 1.0;
943
+		frameLightTint = 1.20;
944
+		frameShadowTint = 1.25;
945
+		fillLightTint = 0.9;
946
+		fillShadowTint = 1.05;
947
+
948
+		fillColor.red = uint8(fillColor.red * 0.4 + base.red * 0.6);
949
+		fillColor.green = uint8(fillColor.green * 0.4 + base.green * 0.6);
950
+		fillColor.blue = uint8(fillColor.blue * 0.4 + base.blue * 0.6);
951
+	} else {
952
+		edgeLightTint = 0.65;
953
+		edgeShadowTint = 1.07;
954
+		frameLightTint = 1.40;
955
+		frameShadowTint = 1.50;
956
+		fillLightTint = 0.8;
957
+		fillShadowTint = 1.1;
958
+	}
959
+
960
+	rgb_color edgeLightColor = tint_color(base, edgeLightTint);
961
+	rgb_color edgeShadowColor = tint_color(base, edgeShadowTint);
962
+	rgb_color frameLightColor = tint_color(fillColor, frameLightTint);
963
+	rgb_color frameShadowColor = tint_color(fillColor, frameShadowTint);
964
+	rgb_color fillLightColor = tint_color(fillColor, fillLightTint);
965
+	rgb_color fillShadowColor = tint_color(fillColor, fillShadowTint);
966
+
967
+	if (orientation == B_HORIZONTAL) {
968
+		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
969
+			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
970
+			fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation);
971
+
972
+		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
973
+			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
974
+			fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation);
975
+	} else {
976
+		_DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor,
977
+			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
978
+			fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation);
979
+
980
+		_DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor,
981
+			edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor,
982
+			fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation);
983
+	}
984
+
985
+	view->ConstrainClippingRegion(NULL);
986
+
987
+	view->BeginLineArray(4);
988
+	if (orientation == B_HORIZONTAL) {
989
+		view->AddLine(barRect.LeftTop(), barRect.RightTop(), edgeShadowColor);
990
+		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
991
+			edgeLightColor);
992
+		barRect.InsetBy(0, 1);
993
+		view->AddLine(barRect.LeftTop(), barRect.RightTop(), frameShadowColor);
994
+		view->AddLine(barRect.LeftBottom(), barRect.RightBottom(),
995
+			frameLightColor);
996
+		barRect.InsetBy(0, 1);
997
+	} else {
998
+		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), edgeShadowColor);
999
+		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
1000
+			edgeLightColor);
1001
+		barRect.InsetBy(1, 0);
1002
+		view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), frameShadowColor);
1003
+		view->AddLine(barRect.RightTop(), barRect.RightBottom(),
1004
+			frameLightColor);
1005
+		barRect.InsetBy(1, 0);
1006
+	}
1007
+	view->EndLineArray();
1008
+
1009
+	_FillGradient(view, barRect, fillColor, fillShadowTint, fillLightTint,
1010
+		orientation);
1011
+}
1012
+
1013
+
1014
+void
1015
+BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
1016
+	const rgb_color& base, uint32 flags, enum orientation orientation)
1017
+{
1018
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
1019
+		return;
1020
+
1021
+	// figure out frame color
1022
+	rgb_color frameLightColor;
1023
+	rgb_color frameShadowColor;
1024
+	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
1025
+
1026
+	if (flags & B_FOCUSED) {
1027
+		// focused
1028
+		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
1029
+		frameShadowColor = frameLightColor;
1030
+	} else {
1031
+		// figure out the tints to be used
1032
+		float frameLightTint;
1033
+		float frameShadowTint;
1034
+
1035
+		if (flags & B_DISABLED) {
1036
+			frameLightTint = 1.30;
1037
+			frameShadowTint = 1.35;
1038
+			shadowColor.alpha = 30;
1039
+		} else {
1040
+			frameLightTint = 1.6;
1041
+			frameShadowTint = 1.65;
1042
+		}
1043
+
1044
+		frameLightColor = tint_color(base, frameLightTint);
1045
+		frameShadowColor = tint_color(base, frameShadowTint);
1046
+	}
1047
+
1048
+	BRect originalRect(rect);
1049
+	rect.right--;
1050
+	rect.bottom--;
1051
+
1052
+	_DrawFrame(view, rect, frameLightColor, frameLightColor,
1053
+		frameShadowColor, frameShadowColor);
1054
+
1055
+	flags &= ~B_ACTIVATED;
1056
+	DrawButtonBackground(view, rect, updateRect, base, flags);
1057
+
1058
+	// thumb shadow
1059
+	view->SetDrawingMode(B_OP_ALPHA);
1060
+	view->SetHighColor(shadowColor);
1061
+	originalRect.left++;
1062
+	originalRect.top++;
1063
+	view->StrokeLine(originalRect.LeftBottom(), originalRect.RightBottom());
1064
+	originalRect.bottom--;
1065
+	view->StrokeLine(originalRect.RightTop(), originalRect.RightBottom());
1066
+
1067
+	// thumb edge
1068
+	if (orientation == B_HORIZONTAL) {
1069
+		rect.InsetBy(0, floorf(rect.Height() / 4));
1070
+		rect.left = floorf((rect.left + rect.right) / 2);
1071
+		rect.right = rect.left + 1;
1072
+		shadowColor = tint_color(base, B_DARKEN_2_TINT);
1073
+		shadowColor.alpha = 128;
1074
+		view->SetHighColor(shadowColor);
1075
+		view->StrokeLine(rect.LeftTop(), rect.LeftBottom());
1076
+		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
1077
+		lightColor.alpha = 128;
1078
+		view->SetHighColor(lightColor);
1079
+		view->StrokeLine(rect.RightTop(), rect.RightBottom());
1080
+	} else {
1081
+		rect.InsetBy(floorf(rect.Width() / 4), 0);
1082
+		rect.top = floorf((rect.top + rect.bottom) / 2);
1083
+		rect.bottom = rect.top + 1;
1084
+		shadowColor = tint_color(base, B_DARKEN_2_TINT);
1085
+		shadowColor.alpha = 128;
1086
+		view->SetHighColor(shadowColor);
1087
+		view->StrokeLine(rect.LeftTop(), rect.RightTop());
1088
+		rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT);
1089
+		lightColor.alpha = 128;
1090
+		view->SetHighColor(lightColor);
1091
+		view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
1092
+	}
1093
+
1094
+	view->SetDrawingMode(B_OP_COPY);
1095
+}
1096
+
1097
+
1098
+void
1099
+BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
1100
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
1101
+	enum orientation orientation)
1102
+{
1103
+	DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation);
1104
+}
1105
+
1106
+
1107
+void
1108
+BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
1109
+	const BRect& updateRect, const rgb_color& base, const rgb_color& fill,
1110
+	uint32 flags, enum orientation orientation)
1111
+{
1112
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
1113
+		return;
1114
+
1115
+	// figure out frame color
1116
+	rgb_color frameLightColor;
1117
+	rgb_color frameShadowColor;
1118
+	rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 };
1119
+
1120
+	float topTint = 0.49;
1121
+	float middleTint1 = 0.62;
1122
+	float middleTint2 = 0.76;
1123
+	float bottomTint = 0.90;
1124
+
1125
+	if (flags & B_DISABLED) {
1126
+		topTint = (topTint + B_NO_TINT) / 2;
1127
+		middleTint1 = (middleTint1 + B_NO_TINT) / 2;
1128
+		middleTint2 = (middleTint2 + B_NO_TINT) / 2;
1129
+		bottomTint = (bottomTint + B_NO_TINT) / 2;
1130
+	} else if (flags & B_HOVER) {
1131
+		static const float kHoverTintFactor = 0.85;
1132
+		topTint *= kHoverTintFactor;
1133
+		middleTint1 *= kHoverTintFactor;
1134
+		middleTint2 *= kHoverTintFactor;
1135
+		bottomTint *= kHoverTintFactor;
1136
+	}
1137
+
1138
+	if (flags & B_FOCUSED) {
1139
+		// focused
1140
+		frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
1141
+		frameShadowColor = frameLightColor;
1142
+	} else {
1143
+		// figure out the tints to be used
1144
+		float frameLightTint;
1145
+		float frameShadowTint;
1146
+
1147
+		if (flags & B_DISABLED) {
1148
+			frameLightTint = 1.30;
1149
+			frameShadowTint = 1.35;
1150
+			shadowColor.alpha = 30;
1151
+		} else {
1152
+			frameLightTint = 1.6;
1153
+			frameShadowTint = 1.65;
1154
+		}
1155
+
1156
+		frameLightColor = tint_color(base, frameLightTint);
1157
+		frameShadowColor = tint_color(base, frameShadowTint);
1158
+	}
1159
+
1160
+	// make room for the shadow
1161
+	rect.right--;
1162
+	rect.bottom--;
1163
+
1164
+	uint32 viewFlags = view->Flags();
1165
+	view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
1166
+	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
1167
+
1168
+	float center = (rect.left + rect.right) / 2;
1169
+
1170
+	BShape shape;
1171
+	shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
1172
+	shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
1173
+	shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
1174
+	shape.LineTo(BPoint(center + 0.5, rect.top + 0.5));
1175
+	shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
1176
+	shape.Close();
1177
+
1178
+	view->MovePenTo(BPoint(1, 1));
1179
+
1180
+	view->SetDrawingMode(B_OP_ALPHA);
1181
+	view->SetHighColor(shadowColor);
1182
+	view->StrokeShape(&shape);
1183
+
1184
+	view->MovePenTo(B_ORIGIN);
1185
+
1186
+	view->SetDrawingMode(B_OP_COPY);
1187
+	view->SetHighColor(frameLightColor);
1188
+	view->StrokeShape(&shape);
1189
+
1190
+	rect.InsetBy(1, 1);
1191
+	shape.Clear();
1192
+	shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
1193
+	shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
1194
+	shape.LineTo(BPoint(center + 0.5, rect.top));
1195
+	shape.Close();
1196
+
1197
+	BGradientLinear gradient;
1198
+	if (flags & B_DISABLED) {
1199
+		_MakeGradient(gradient, rect, fill, topTint, bottomTint);
1200
+	} else {
1201
+		_MakeGlossyGradient(gradient, rect, fill, topTint, middleTint1,
1202
+			middleTint2, bottomTint);
1203
+	}
1204
+
1205
+	view->FillShape(&shape, gradient);
1206
+
1207
+	view->SetFlags(viewFlags);
1208
+}
1209
+
1210
+
1211
+void
1212
+BControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
1213
+	const BRect& updateRect, const rgb_color& base, int32 count,
1214
+	hash_mark_location location, uint32 flags, enum orientation orientation)
1215
+{
1216
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
1217
+		return;
1218
+
1219
+	rgb_color lightColor;
1220
+	rgb_color darkColor;
1221
+
1222
+	if (flags & B_DISABLED) {
1223
+		lightColor = tint_color(base, 0.9);
1224
+		darkColor = tint_color(base, 1.07);
1225
+	} else {
1226
+		lightColor = tint_color(base, 0.8);
1227
+		darkColor = tint_color(base, 1.14);
1228
+	}
1229
+
1230
+	int32 hashMarkCount = max_c(count, 2);
1231
+		// draw at least two hashmarks at min/max if
1232
+		// fHashMarks != B_HASH_MARKS_NONE
1233
+	float factor;
1234
+	float startPos;
1235
+	if (orientation == B_HORIZONTAL) {
1236
+		factor = (rect.Width() - 2) / (hashMarkCount - 1);
1237
+		startPos = rect.left + 1;
1238
+	} else {
1239
+		factor = (rect.Height() - 2) / (hashMarkCount - 1);
1240
+		startPos = rect.top + 1;
1241
+	}
1242
+
1243
+	if (location & B_HASH_MARKS_TOP) {
1244
+		view->BeginLineArray(hashMarkCount * 2);
1245
+
1246
+		if (orientation == B_HORIZONTAL) {
1247
+			float pos = startPos;
1248
+			for (int32 i = 0; i < hashMarkCount; i++) {
1249
+				view->AddLine(BPoint(pos, rect.top),
1250
+							  BPoint(pos, rect.top + 4), darkColor);
1251
+				view->AddLine(BPoint(pos + 1, rect.top),
1252
+							  BPoint(pos + 1, rect.top + 4), lightColor);
1253
+
1254
+				pos += factor;
1255
+			}
1256
+		} else {
1257
+			float pos = startPos;
1258
+			for (int32 i = 0; i < hashMarkCount; i++) {
1259
+				view->AddLine(BPoint(rect.left, pos),
1260
+							  BPoint(rect.left + 4, pos), darkColor);
1261
+				view->AddLine(BPoint(rect.left, pos + 1),
1262
+							  BPoint(rect.left + 4, pos + 1), lightColor);
1263
+
1264
+				pos += factor;
1265
+			}
1266
+		}
1267
+
1268
+		view->EndLineArray();
1269
+	}
1270
+
1271
+	if (location & B_HASH_MARKS_BOTTOM) {
1272
+
1273
+		view->BeginLineArray(hashMarkCount * 2);
1274
+
1275
+		if (orientation == B_HORIZONTAL) {
1276
+			float pos = startPos;
1277
+			for (int32 i = 0; i < hashMarkCount; i++) {
1278
+				view->AddLine(BPoint(pos, rect.bottom - 4),
1279
+							  BPoint(pos, rect.bottom), darkColor);
1280
+				view->AddLine(BPoint(pos + 1, rect.bottom - 4),
1281
+							  BPoint(pos + 1, rect.bottom), lightColor);
1282
+
1283
+				pos += factor;
1284
+			}
1285
+		} else {
1286
+			float pos = startPos;
1287
+			for (int32 i = 0; i < hashMarkCount; i++) {
1288
+				view->AddLine(BPoint(rect.right - 4, pos),
1289
+							  BPoint(rect.right, pos), darkColor);
1290
+				view->AddLine(BPoint(rect.right - 4, pos + 1),
1291
+							  BPoint(rect.right, pos + 1), lightColor);
1292
+
1293
+				pos += factor;
1294
+			}
1295
+		}
1296
+
1297
+		view->EndLineArray();
1298
+	}
1299
+}
1300
+
1301
+
1302
+void
1303
+BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
1304
+	const rgb_color& base, uint32 flags, uint32 borders)
1305
+{
1306
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
1307
+		return;
1308
+
1309
+	rgb_color edgeShadowColor;
1310
+	rgb_color edgeLightColor;
1311
+	rgb_color frameShadowColor;
1312
+	rgb_color frameLightColor;
1313
+	rgb_color bevelShadowColor;
1314
+	rgb_color bevelLightColor;
1315
+	BGradientLinear fillGradient;
1316
+	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
1317
+	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
1318
+
1319
+	if (flags & B_DISABLED) {
1320
+		edgeShadowColor = base;
1321
+		edgeLightColor = base;
1322
+		frameShadowColor = tint_color(base, 1.30);
1323
+		frameLightColor = tint_color(base, 1.25);
1324
+		bevelShadowColor = tint_color(base, 1.07);
1325
+		bevelLightColor = tint_color(base, 0.8);
1326
+		fillGradient.AddColor(tint_color(base, 0.85), 0);
1327
+		fillGradient.AddColor(base, 255);
1328
+	} else {
1329
+		edgeShadowColor = tint_color(base, 1.03);
1330
+		edgeLightColor = tint_color(base, 0.80);
1331
+		frameShadowColor = tint_color(base, 1.30);
1332
+		frameLightColor = tint_color(base, 1.30);
1333
+		bevelShadowColor = tint_color(base, 1.07);
1334
+		bevelLightColor = tint_color(base, 0.6);
1335
+		fillGradient.AddColor(tint_color(base, 0.75), 0);
1336
+		fillGradient.AddColor(tint_color(base, 1.03), 255);
1337
+	}
1338
+
1339
+	static const float kRoundCornerRadius = 4;
1340
+
1341
+	// left/top corner
1342
+	BRect cornerRect(rect);
1343
+	cornerRect.right = cornerRect.left + kRoundCornerRadius;
1344
+	cornerRect.bottom = cornerRect.top + kRoundCornerRadius;
1345
+
1346
+	BRegion clipping(rect);
1347
+	clipping.Exclude(cornerRect);
1348
+
1349
+	_DrawRoundCornerLeftTop(view, cornerRect, updateRect, base, edgeShadowColor,
1350
+		frameLightColor, bevelLightColor, fillGradient);
1351
+
1352
+	// left/top corner
1353
+	cornerRect.right = rect.right;
1354
+	cornerRect.left = cornerRect.right - kRoundCornerRadius;
1355
+
1356
+	clipping.Exclude(cornerRect);
1357
+
1358
+	_DrawRoundCornerRightTop(view, cornerRect, updateRect, base, edgeShadowColor,
1359
+		edgeLightColor, frameLightColor, frameShadowColor, bevelLightColor,
1360
+		bevelShadowColor, fillGradient);
1361
+
1362
+	// rest of frame and fill
1363
+	view->ConstrainClippingRegion(&clipping);
1364
+
1365
+	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
1366
+		edgeLightColor,
1367
+		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
1368
+	if ((borders & B_LEFT_BORDER) == 0)
1369
+		rect.left++;
1370
+	if ((borders & B_RIGHT_BORDER) == 0)
1371
+		rect.right--;
1372
+
1373
+	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
1374
+		frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER);
1375
+
1376
+	_DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor,
1377
+		bevelShadowColor);
1378
+
1379
+	view->FillRect(rect, fillGradient);
1380
+
1381
+	view->ConstrainClippingRegion(NULL);
1382
+}
1383
+
1384
+
1385
+void
1386
+BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect,
1387
+	const rgb_color& base, uint32 flags, uint32 borders)
1388
+{
1389
+	if (!rect.IsValid() || !rect.Intersects(updateRect))
1390
+		return;
1391
+
1392
+	rgb_color edgeShadowColor;
1393
+	rgb_color edgeLightColor;
1394
+	rgb_color frameShadowColor;
1395
+	rgb_color frameLightColor;
1396
+	rgb_color bevelShadowColor;
1397
+	rgb_color bevelLightColor;
1398
+	BGradientLinear fillGradient;
1399
+	fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3));
1400
+	fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3));
1401
+
1402
+	if (flags & B_DISABLED) {
1403
+		edgeShadowColor = base;
1404
+		edgeLightColor = base;
1405
+		frameShadowColor = tint_color(base, 1.30);
1406
+		frameLightColor = tint_color(base, 1.25);
1407
+		bevelShadowColor = tint_color(base, 1.07);
1408
+		bevelLightColor = tint_color(base, 0.8);
1409
+		fillGradient.AddColor(tint_color(base, 0.85), 0);
1410
+		fillGradient.AddColor(base, 255);
1411
+	} else {
1412
+		edgeShadowColor = tint_color(base, 1.03);
1413
+		edgeLightColor = tint_color(base, 0.80);
1414
+		frameShadowColor = tint_color(base, 1.30);
1415
+		frameLightColor = tint_color(base, 1.30);
1416
+		bevelShadowColor = tint_color(base, 1.17);
1417
+		bevelLightColor = tint_color(base, 1.10);
1418
+		fillGradient.AddColor(tint_color(base, 1.12), 0);
1419
+		fillGradient.AddColor(tint_color(base, 1.08), 255);
1420
+	}
1421
+
1422
+	// active tabs stand out at the top, but this is an inactive tab
1423
+	view->SetHighColor(base);
1424
+	view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4));
1425
+	rect.top += 4;
1426
+
1427
+	// frame and fill
1428
+	_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
1429
+		edgeLightColor,
1430
+		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
1431
+
1432
+	_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
1433
+		frameShadowColor,
1434
+		borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER));
1435
+
1436
+	if (rect.IsValid()) {
1437
+		_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
1438
+			bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
1439
+	} else {
1440
+		if ((B_LEFT_BORDER & ~borders) != 0)
1441
+			rect.left++;
1442
+	}
1443
+
1444
+	view->FillRect(rect, fillGradient);
1445
+}
1446
+
1447
+
1448
+void
1449
+BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
1450
+	const rgb_color& base, enum orientation orientation, uint32 flags,
1451
+	uint32 borders)
1452
+{
1453
+	rgb_color background;
1454
+	if ((flags & (B_CLICKED | B_ACTIVATED)) != 0)
1455
+		background = tint_color(base, B_DARKEN_1_TINT);
1456
+	else
1457
+		background = base;
1458
+
1459
+	rgb_color light = tint_color(background, 0.6);
1460
+	rgb_color shadow = tint_color(background, 1.21);
1461
+
1462
+	// frame
1463
+	if (borders != 0 && rect.Width() > 3 && rect.Height() > 3)
1464
+		DrawRaisedBorder(view, rect, updateRect, background, flags, borders);
1465
+
1466
+	// dots and rest of background
1467
+	if (orientation == B_HORIZONTAL) {
1468
+		if (rect.Width() > 2) {
1469
+			// background on left/right
1470
+			BRegion region(rect);
1471
+			rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5);
1472
+			rect.right = rect.left + 1;
1473
+			region.Exclude(rect);
1474
+			view->SetHighColor(background);
1475
+			view->FillRegion(&region);
1476
+		}
1477
+
1478
+		BPoint dot = rect.LeftTop();
1479
+		BPoint stop = rect.LeftBottom();
1480
+		int32 num = 1;
1481
+		while (dot.y <= stop.y) {
1482
+			rgb_color col1;
1483
+			rgb_color col2;
1484
+			switch (num) {
1485
+				case 1:
1486
+					col1 = background;
1487
+					col2 = background;
1488
+					break;
1489
+				case 2:
1490
+					col1 = shadow;
1491
+					col2 = background;
1492
+					break;
1493
+				case 3:
1494
+				default:
1495
+					col1 = background;
1496
+					col2 = light;
1497
+					num = 0;
1498
+					break;
1499
+			}
1500
+			view->SetHighColor(col1);
1501
+			view->StrokeLine(dot, dot, B_SOLID_HIGH);
1502
+			view->SetHighColor(col2);
1503
+			dot.x++;
1504
+			view->StrokeLine(dot, dot, B_SOLID_HIGH);
1505
+			dot.x -= 1.0;
1506
+			// next pixel
1507
+			num++;
1508
+			dot.y++;
1509
+		}
1510
+	} else {
1511
+		if (rect.Height() > 2) {
1512
+			// background on left/right
1513
+			BRegion region(rect);
1514
+			rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5);
1515
+			rect.bottom = rect.top + 1;
1516
+			region.Exclude(rect);
1517
+			view->SetHighColor(background);
1518
+			view->FillRegion(&region);
1519
+		}
1520
+
1521
+		BPoint dot = rect.LeftTop();
1522
+		BPoint stop = rect.RightTop();
1523
+		int32 num = 1;
1524
+		while (dot.x <= stop.x) {
1525
+			rgb_color col1;
1526
+			rgb_color col2;
1527
+			switch (num) {
1528
+				case 1:
1529
+					col1 = background;
1530
+					col2 = background;
1531
+					break;
1532
+				case 2:
1533
+					col1 = shadow;
1534
+					col2 = background;
1535
+					break;
1536
+				case 3:
1537
+				default:
1538
+					col1 = background;
1539
+					col2 = light;
1540
+					num = 0;
1541
+					break;
1542
+			}
1543
+			view->SetHighColor(col1);
1544
+			view->StrokeLine(dot, dot, B_SOLID_HIGH);
1545
+			view->SetHighColor(col2);
1546
+			dot.y++;
1547
+			view->StrokeLine(dot, dot, B_SOLID_HIGH);
1548
+			dot.y -= 1.0;
1549
+			// next pixel
1550
+			num++;
1551
+			dot.x++;
1552
+		}
1553
+	}
1554
+}
1555
+
1556
+
1557
+// #pragma mark -
1558
+
1559
+
1560
+void
1561
+BControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
1562
+	const rgb_color& base, border_style border, uint32 flags, uint32 borders)
1563
+{
1564
+	if (border == B_NO_BORDER)
1565
+		return;
1566
+
1567
+	rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT);
1568
+	if (flags & B_FOCUSED)
1569
+		scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
1570
+
1571
+	if (border == B_FANCY_BORDER)
1572
+		_DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders);
1573
+
1574
+	_DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor,
1575
+		scrollbarFrameColor, scrollbarFrameColor, borders);
1576
+}
1577
+
1578
+
1579
+void
1580
+BControlLook::DrawRaisedBorder(BView* view, BRect& rect,
1581
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
1582
+	uint32 borders)
1583
+{
1584
+	rgb_color lightColor;
1585
+	rgb_color shadowColor;
1586
+
1587
+	if (flags & B_DISABLED) {
1588
+		lightColor = base;
1589
+		shadowColor = base;
1590
+	} else {
1591
+		lightColor = tint_color(base, 0.85);
1592
+		shadowColor = tint_color(base, 1.07);
1593
+	}
1594
+
1595
+	_DrawFrame(view, rect, lightColor, lightColor, shadowColor, shadowColor,
1596
+		borders);
1597
+}
1598
+
1599
+
1600
+void
1601
+BControlLook::DrawTextControlBorder(BView* view, BRect& rect,
1602
+	const BRect& updateRect, const rgb_color& base, uint32 flags,
1603
+	uint32 borders)
1604
+{
1605
+	if (!rect.Intersects(updateRect))
1606
+		return;
1607
+
1608
+	rgb_color dark1BorderColor;
1609
+	rgb_color dark2BorderColor;
1610
+	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
1611
+
1612
+	if (flags & B_DISABLED) {
1613
+		_DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags, borders);
1614
+
1615
+		if (flags & B_BLEND_FRAME)
1616
+			dark1BorderColor = (rgb_color){ 0, 0, 0, 40 };
1617
+		else
1618
+			dark1BorderColor = tint_color(base, 1.15);
1619
+		dark2BorderColor = dark1BorderColor;