HaikuControlLook.h revision ec1b18c5
1/*
2 * Copyright 2009-2017, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _HAIKU_CONTROL_LOOK_H
6#define _HAIKU_CONTROL_LOOK_H
7
8
9#include <ControlLook.h>
10
11
12class BBitmap;
13class BControl;
14class BGradientLinear;
15class BView;
16
17
18namespace BPrivate {
19
20
21class HaikuControlLook : public BControlLook {
22public:
23								HaikuControlLook();
24	virtual						~HaikuControlLook();
25
26	virtual BAlignment			DefaultLabelAlignment() const;
27	virtual float				DefaultLabelSpacing() const;
28
29	virtual	float				DefaultItemSpacing() const;
30
31	static	float				ComposeSpacing(float spacing);
32
33	virtual uint32				Flags(BControl* control) const;
34
35	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
36									const BRect& updateRect,
37									const rgb_color& base,
38									const rgb_color& background,
39									uint32 flags = 0,
40									uint32 borders = B_ALL_BORDERS);
41	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
42									const BRect& updateRect,
43									float radius,
44									const rgb_color& base,
45									const rgb_color& background,
46									uint32 flags = 0,
47									uint32 borders = B_ALL_BORDERS);
48	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
49									const BRect& updateRect,
50									float leftTopRadius,
51									float rightTopRadius,
52									float leftBottomRadius,
53									float rightBottomRadius,
54									const rgb_color& base,
55									const rgb_color& background,
56									uint32 flags = 0,
57									uint32 borders = B_ALL_BORDERS);
58
59	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
60									const BRect& updateRect,
61									const rgb_color& base,
62									uint32 flags = 0,
63									uint32 borders = B_ALL_BORDERS,
64									orientation orientation = B_HORIZONTAL);
65	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
66									const BRect& updateRect,
67									float radius,
68									const rgb_color& base,
69									uint32 flags = 0,
70									uint32 borders = B_ALL_BORDERS,
71									orientation orientation = B_HORIZONTAL);
72	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
73									const BRect& updateRect,
74									float leftTopRadius,
75									float rightTopRadius,
76									float leftBottomRadius,
77									float rightBottomRadius,
78									const rgb_color& base,
79									uint32 flags = 0,
80									uint32 borders = B_ALL_BORDERS,
81									orientation orientation = B_HORIZONTAL);
82
83	virtual	void				DrawMenuBarBackground(BView* view, BRect& rect,
84									const BRect& updateRect,
85									const rgb_color& base,
86									uint32 flags = 0,
87									uint32 borders = B_ALL_BORDERS);
88
89	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
90									const BRect& updateRect,
91									const rgb_color& base,
92									const rgb_color& background,
93									uint32 flags = 0,
94									uint32 borders = B_ALL_BORDERS);
95	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
96									const BRect& updateRect,
97									float radius,
98									const rgb_color& base,
99									const rgb_color& background,
100									uint32 flags = 0,
101									uint32 borders = B_ALL_BORDERS);
102	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
103									const BRect& updateRect,
104									float leftTopRadius,
105									float rightTopRadius,
106									float leftBottomRadius,
107									float rightBottomRadius,
108									const rgb_color& base,
109									const rgb_color& background,
110									uint32 flags = 0,
111									uint32 borders = B_ALL_BORDERS);
112
113	virtual	void				DrawMenuFieldBackground(BView* view,
114									BRect& rect, const BRect& updateRect,
115									const rgb_color& base, bool popupIndicator,
116									uint32 flags = 0);
117	virtual	void				DrawMenuFieldBackground(BView* view,
118									BRect& rect, const BRect& updateRect,
119									float radius, const rgb_color& base,
120									bool popupIndicator, uint32 flags = 0);
121	virtual	void				DrawMenuFieldBackground(BView* view,
122									BRect& rect, const BRect& updateRect,
123									float leftTopRadius,
124									float rightTopRadius,
125									float leftBottomRadius,
126									float rightBottomRadius,
127									const rgb_color& base,
128									bool popupIndicator, uint32 flags = 0);
129	virtual	void				DrawMenuFieldBackground(BView* view,
130									BRect& rect, const BRect& updateRect,
131									const rgb_color& base, uint32 flags = 0,
132									uint32 borders = B_ALL_BORDERS);
133
134	virtual	void				DrawMenuBackground(BView* view,
135									BRect& rect, const BRect& updateRect,
136									const rgb_color& base, uint32 flags = 0,
137									uint32 borders = B_ALL_BORDERS);
138
139	virtual	void				DrawMenuItemBackground(BView* view,
140									BRect& rect, const BRect& updateRect,
141									const rgb_color& base, uint32 flags = 0,
142									uint32 borders = B_ALL_BORDERS);
143
144	virtual	void				DrawStatusBar(BView* view, BRect& rect,
145									const BRect& updateRect,
146									const rgb_color& base,
147									const rgb_color& barColor,
148									float progressPosition);
149
150	virtual	void				DrawCheckBox(BView* view, BRect& rect,
151									const BRect& updateRect,
152									const rgb_color& base,
153									uint32 flags = 0);
154
155	virtual	void				DrawRadioButton(BView* view, BRect& rect,
156									const BRect& updateRect,
157									const rgb_color& base,
158									uint32 flags = 0);
159
160	virtual	void				DrawScrollBar(BView* view, BRect& rect,
161									const BRect& updateRect,
162									const rgb_color& base, uint32 flags,
163									orientation orientation,
164									bool doubleArrows = false,
165									int32 buttonDown = -1);
166	virtual	void				DrawScrollBarThumb(BView* view, BRect& rect,
167									BRect& thumbRect, const BRect& updateRect,
168									const rgb_color& base, uint32 flags,
169									orientation orientation,
170									uint32 knobStyle = 0);
171
172	virtual	void				DrawScrollViewFrame(BView* view,
173									BRect& rect, const BRect& updateRect,
174									BRect verticalScrollBarFrame,
175									BRect horizontalScrollBarFrame,
176									const rgb_color& base,
177									border_style borderStyle,
178									uint32 flags = 0,
179									uint32 borders = B_ALL_BORDERS);
180
181	virtual	void				DrawArrowShape(BView* view,
182									BRect& rect, const BRect& updateRect,
183									const rgb_color& base, uint32 direction,
184									uint32 flags = 0,
185									float tint = B_DARKEN_MAX_TINT);
186
187	virtual	rgb_color			SliderBarColor(const rgb_color& base);
188
189	virtual	void				DrawSliderBar(BView* view, BRect rect,
190									const BRect& updateRect,
191									const rgb_color& base,
192									rgb_color leftFillColor,
193									rgb_color rightFillColor,
194									float sliderScale, uint32 flags,
195									orientation orientation);
196	virtual	void				DrawSliderBar(BView* view, BRect rect,
197									const BRect& updateRect,
198									const rgb_color& base, rgb_color fillColor,
199									uint32 flags, orientation orientation);
200
201	virtual	void				DrawSliderThumb(BView* view, BRect& rect,
202									const BRect& updateRect,
203									const rgb_color& base, uint32 flags,
204									orientation orientation);
205
206	virtual	void				DrawSliderTriangle(BView* view, BRect& rect,
207									const BRect& updateRect,
208									const rgb_color& base, uint32 flags,
209									orientation orientation);
210	virtual	void				DrawSliderTriangle(BView* view, BRect& rect,
211									const BRect& updateRect,
212									const rgb_color& base,
213									const rgb_color& fill, uint32 flags,
214									orientation orientation);
215
216	virtual	void				DrawSliderHashMarks(BView* view, BRect& rect,
217									const BRect& updateRect,
218									const rgb_color& base, int32 count,
219									hash_mark_location location,
220									uint32 flags, orientation orientation);
221
222	virtual	void				DrawActiveTab(BView* view, BRect& rect,
223									const BRect& updateRect,
224									const rgb_color& base, uint32 flags = 0,
225									uint32 borders = B_ALL_BORDERS,
226									uint32 side = B_TOP_BORDER);
227
228	virtual	void				DrawInactiveTab(BView* view, BRect& rect,
229									const BRect& updateRect,
230									const rgb_color& base, uint32 flags = 0,
231									uint32 borders = B_ALL_BORDERS,
232									uint32 side = B_TOP_BORDER);
233
234	virtual	void				DrawSplitter(BView* view, BRect& rect,
235									const BRect& updateRect,
236									const rgb_color& base,
237									orientation orientation,
238									uint32 flags = 0,
239									uint32 borders = B_ALL_BORDERS);
240
241	// various borders
242
243	virtual	void				DrawBorder(BView* view, BRect& rect,
244									const BRect& updateRect,
245									const rgb_color& base,
246									border_style borderStyle, uint32 flags = 0,
247									uint32 borders = B_ALL_BORDERS);
248
249	virtual	void				DrawRaisedBorder(BView* view, BRect& rect,
250									const BRect& updateRect,
251									const rgb_color& base, uint32 flags = 0,
252									uint32 borders = B_ALL_BORDERS);
253
254	virtual	void				DrawGroupFrame(BView* view, BRect& rect,
255									const BRect& updateRect,
256									const rgb_color& base,
257									uint32 borders = B_ALL_BORDERS);
258
259	virtual	void				DrawTextControlBorder(BView* view, BRect& rect,
260									const BRect& updateRect,
261									const rgb_color& base, uint32 flags = 0,
262									uint32 borders = B_ALL_BORDERS);
263
264	// aligned labels
265
266	virtual	void				DrawLabel(BView* view, const char* label,
267									BRect rect, const BRect& updateRect,
268									const rgb_color& base, uint32 flags,
269									const rgb_color* textColor = NULL);
270	virtual	void				DrawLabel(BView* view, const char* label,
271									BRect rect, const BRect& updateRect,
272									const rgb_color& base, uint32 flags,
273									const BAlignment& alignment,
274									const rgb_color* textColor = NULL);
275	// TODO: Would be nice to have a (non-virtual) version of this method
276	// which takes an array of labels and locations. That would save some
277	// setup with the view graphics state.
278	virtual	void				DrawLabel(BView* view, const char* label,
279									const rgb_color& base, uint32 flags,
280									const BPoint& where,
281									const rgb_color* textColor = NULL);
282
283	virtual	void				DrawLabel(BView* view, const char* label,
284									const BBitmap* icon, BRect rect,
285									const BRect& updateRect,
286									const rgb_color& base, uint32 flags,
287									const BAlignment& alignment,
288									const rgb_color* textColor = NULL);
289
290	virtual	void				GetFrameInsets(frame_type frameType,
291									uint32 flags, float& _left, float& _top,
292									float& _right, float& _bottom);
293	virtual	void				GetBackgroundInsets(
294									background_type backgroundType,
295									uint32 flags, float& _left, float& _top,
296									float& _right, float& _bottom);
297
298	virtual	void				DrawButtonWithPopUpBackground(BView* view,
299									BRect& rect, const BRect& updateRect,
300									const rgb_color& base,
301									uint32 flags = 0,
302									uint32 borders = B_ALL_BORDERS,
303									orientation orientation = B_HORIZONTAL);
304	virtual	void				DrawButtonWithPopUpBackground(BView* view,
305									BRect& rect, const BRect& updateRect,
306									float radius,
307									const rgb_color& base,
308									uint32 flags = 0,
309									uint32 borders = B_ALL_BORDERS,
310									orientation orientation = B_HORIZONTAL);
311	virtual	void				DrawButtonWithPopUpBackground(BView* view,
312									BRect& rect, const BRect& updateRect,
313									float leftTopRadius,
314									float rightTopRadius,
315									float leftBottomRadius,
316									float rightBottomRadius,
317									const rgb_color& base,
318									uint32 flags = 0,
319									uint32 borders = B_ALL_BORDERS,
320									orientation orientation = B_HORIZONTAL);
321
322protected:
323			void				_DrawButtonFrame(BView* view, BRect& rect,
324									const BRect& updateRect,
325									float leftTopRadius,
326									float rightTopRadius,
327									float leftBottomRadius,
328									float rightBottomRadius,
329									const rgb_color& base,
330									const rgb_color& background,
331									float contrast, float brightness = 1.0,
332									uint32 flags = 0,
333									uint32 borders = B_ALL_BORDERS);
334
335			void				_DrawOuterResessedFrame(BView* view,
336									BRect& rect, const rgb_color& base,
337									float contrast = 1.0f,
338									float brightness = 1.0f,
339									uint32 flags = 0,
340									uint32 borders = B_ALL_BORDERS);
341
342			void				_DrawFrame(BView* view, BRect& rect,
343									const rgb_color& left,
344									const rgb_color& top,
345									const rgb_color& right,
346									const rgb_color& bottom,
347									uint32 borders = B_ALL_BORDERS);
348			void				_DrawFrame(BView* view, BRect& rect,
349									const rgb_color& left,
350									const rgb_color& top,
351									const rgb_color& right,
352									const rgb_color& bottom,
353									const rgb_color& rightTop,
354									const rgb_color& leftBottom,
355									uint32 borders = B_ALL_BORDERS);
356
357			void				_DrawButtonBackground(BView* view, BRect& rect,
358									const BRect& updateRect,
359									float leftTopRadius,
360									float rightTopRadius,
361									float leftBottomRadius,
362									float rightBottomRadius,
363									const rgb_color& base,
364									bool popupIndicator = false,
365									uint32 flags = 0,
366									uint32 borders = B_ALL_BORDERS,
367									orientation orientation = B_HORIZONTAL);
368			void				_DrawFlatButtonBackground(BView* view,
369									BRect& rect, const BRect& updateRect,
370									const rgb_color& base,
371									bool popupIndicator = false,
372									uint32 flags = 0,
373									uint32 borders = B_ALL_BORDERS,
374									orientation orientation = B_HORIZONTAL);
375			void				_DrawNonFlatButtonBackground(BView* view,
376									BRect& rect, const BRect& updateRect,
377									BRegion& clipping,
378									float leftTopRadius,
379									float rightTopRadius,
380									float leftBottomRadius,
381									float rightBottomRadius,
382									const rgb_color& base,
383									bool popupIndicator = false,
384									uint32 flags = 0,
385									uint32 borders = B_ALL_BORDERS,
386									orientation orientation = B_HORIZONTAL);
387
388			void				_DrawPopUpMarker(BView* view, const BRect& rect,
389									const rgb_color& base, uint32 flags);
390
391			void				_DrawMenuFieldBackgroundOutside(BView* view,
392									BRect& rect, const BRect& updateRect,
393									float leftTopRadius,
394									float rightTopRadius,
395									float leftBottomRadius,
396									float rightBottomRadius,
397									const rgb_color& base,
398									bool popupIndicator = false,
399									uint32 flags = 0);
400
401			void				_DrawMenuFieldBackgroundInside(BView* view,
402									BRect& rect, const BRect& updateRect,
403									float leftTopRadius,
404									float rightTopRadius,
405									float leftBottomRadius,
406									float rightBottomRadius,
407									const rgb_color& base, uint32 flags = 0,
408									uint32 borders = B_ALL_BORDERS);
409
410	// Rounded corner methods
411			void				_DrawRoundCornerLeftTop(BView* view,
412									BRect& cornerRect, const BRect& updateRect,
413									const rgb_color& background,
414									const rgb_color& edgeColor,
415									const rgb_color& frameColor,
416									const rgb_color& bevelColor,
417									const BGradientLinear& fillGradient);
418
419			void				_DrawRoundCornerFrameLeftTop(BView* view,
420									BRect& cornerRect, const BRect& updateRect,
421									const rgb_color& background,
422									const rgb_color& edgeColor,
423									const rgb_color& frameColor);
424
425			void				_DrawRoundCornerBackgroundLeftTop(BView* view,
426									BRect& cornerRect, const BRect& updateRect,
427									const rgb_color& bevelColor,
428									const BGradientLinear& fillGradient);
429
430			void				_DrawRoundCornerRightTop(BView* view,
431									BRect& cornerRect, const BRect& updateRect,
432									const rgb_color& background,
433									const rgb_color& edgeTopColor,
434									const rgb_color& edgeRightColor,
435									const rgb_color& frameTopColor,
436									const rgb_color& frameRightColor,
437									const rgb_color& bevelTopColor,
438									const rgb_color& bevelRightColor,
439									const BGradientLinear& fillGradient);
440
441			void				_DrawRoundCornerFrameRightTop(BView* view,
442									BRect& cornerRect, const BRect& updateRect,
443									const rgb_color& background,
444									const rgb_color& edgeTopColor,
445									const rgb_color& edgeRightColor,
446									const rgb_color& frameTopColor,
447									const rgb_color& frameRightColor);
448
449			void				_DrawRoundCornerBackgroundRightTop(BView* view,
450									BRect& cornerRect, const BRect& updateRect,
451									const rgb_color& bevelTopColor,
452									const rgb_color& bevelRightColor,
453									const BGradientLinear& fillGradient);
454
455			void				_DrawRoundCornerLeftBottom(BView* view,
456									BRect& cornerRect, const BRect& updateRect,
457									const rgb_color& background,
458									const rgb_color& edgeLeftColor,
459									const rgb_color& edgeBottomColor,
460									const rgb_color& frameLeftColor,
461									const rgb_color& frameBottomColor,
462									const rgb_color& bevelLeftColor,
463									const rgb_color& bevelBottomColor,
464									const BGradientLinear& fillGradient);
465
466			void				_DrawRoundCornerFrameLeftBottom(BView* view,
467									BRect& cornerRect, const BRect& updateRect,
468									const rgb_color& background,
469									const rgb_color& edgeLeftColor,
470									const rgb_color& edgeBottomColor,
471									const rgb_color& frameLeftColor,
472									const rgb_color& frameBottomColor);
473
474			void				_DrawRoundCornerBackgroundLeftBottom(BView* view,
475									BRect& cornerRect, const BRect& updateRect,
476									const rgb_color& bevelLeftColor,
477									const rgb_color& bevelBottomColor,
478									const BGradientLinear& fillGradient);
479
480			void				_DrawRoundCornerRightBottom(BView* view,
481									BRect& cornerRect, const BRect& updateRect,
482									const rgb_color& background,
483									const rgb_color& edgeColor,
484									const rgb_color& frameColor,
485									const rgb_color& bevelColor,
486									const BGradientLinear& fillGradient);
487
488			void				_DrawRoundCornerFrameRightBottom(BView* view,
489									BRect& cornerRect, const BRect& updateRect,
490									const rgb_color& background,
491									const rgb_color& edgeColor,
492									const rgb_color& frameColor);
493
494			void				_DrawRoundCornerBackgroundRightBottom(
495									BView* view,
496									BRect& cornerRect, const BRect& updateRect,
497									const rgb_color& bevelColor,
498									const BGradientLinear& fillGradient);
499
500			void				_DrawRoundBarCorner(BView* view, BRect& rect,
501									const BRect& updateRect,
502									const rgb_color& edgeLightColor,
503									const rgb_color& edgeShadowColor,
504									const rgb_color& frameLightColor,
505									const rgb_color& frameShadowColor,
506									const rgb_color& fillLightColor,
507									const rgb_color& fillShadowColor,
508									float leftInset, float topInset,
509									float rightInset, float bottomInset,
510									orientation orientation);
511
512	// Border color methods
513			rgb_color			_EdgeLightColor(const rgb_color& base,
514									float contrast, float brightness,
515									uint32 flags);
516
517			rgb_color			_EdgeShadowColor(const rgb_color& base,
518									float contrast, float brightness,
519									uint32 flags);
520
521			rgb_color			_FrameLightColor(const rgb_color& base,
522									uint32 flags);
523
524			rgb_color			_FrameShadowColor(const rgb_color& base,
525									uint32 flags);
526
527			rgb_color			_BevelLightColor(const rgb_color& base,
528									uint32 flags);
529
530			rgb_color			_BevelShadowColor(const rgb_color& base,
531									uint32 flags);
532
533	// Background gradient methods
534			void				_FillGradient(BView* view, const BRect& rect,
535									const rgb_color& base, float topTint,
536									float bottomTint,
537									orientation orientation = B_HORIZONTAL);
538
539			void				_FillGlossyGradient(BView* view,
540									const BRect& rect, const rgb_color& base,
541									float topTint, float middle1Tint,
542									float middle2Tint, float bottomTint,
543									orientation orientation = B_HORIZONTAL);
544
545			void				_MakeGradient(BGradientLinear& gradient,
546									const BRect& rect, const rgb_color& base,
547									float topTint, float bottomTint,
548									orientation orientation = B_HORIZONTAL) const;
549
550			void				_MakeGlossyGradient(BGradientLinear& gradient,
551									const BRect& rect, const rgb_color& base,
552									float topTint, float middle1Tint,
553									float middle2Tint, float bottomTint,
554									orientation orientation = B_HORIZONTAL) const;
555
556			void				_MakeButtonGradient(BGradientLinear& gradient,
557									BRect& rect, const rgb_color& base,
558									uint32 flags, orientation orientation = B_HORIZONTAL) const;
559
560			bool				_RadioButtonAndCheckBoxMarkColor(
561									const rgb_color& base, rgb_color& color,
562									uint32 flags) const;
563
564			void				_DrawScrollBarBackground(BView* view,
565									BRect& rect1, BRect& rect2,
566									const BRect& updateRect,
567									const rgb_color& base, uint32 flags,
568									orientation orientation);
569			void				_DrawScrollBarBackground(BView* view,
570									BRect& rect, const BRect& updateRect,
571									const rgb_color& base, uint32 flags,
572									orientation orientation);
573			void				_DrawDisabledScrollBarBackground(BView* view,
574									BRect rect, orientation orientation,
575									const rgb_color& light,
576									const rgb_color& dark,
577									const rgb_color& fill);
578			void				_DrawScrollBarArrowButton(BView* view,
579									BRect rect, const BRect& updateRect,
580									const rgb_color& base, uint32 flags,
581									int32 direction, orientation orientation,
582									bool doubleArrows, bool down);
583
584private:
585			bool				fCachedOutline;
586};
587
588
589} // namespace BPrivate
590
591#endif // _HAIKU_CONTROL_LOOK_H
592