1/*
2 * Copyright 2009-2017, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _CONTROL_LOOK_H
6#define _CONTROL_LOOK_H
7
8
9#include <Alignment.h>
10#include <Font.h>
11#include <Rect.h>
12#include <Slider.h>
13
14
15class BBitmap;
16class BControl;
17class BGradientLinear;
18class BView;
19
20
21// WARNING! This is experimental API and may change! Be prepared to
22// recompile your software in a next version of haiku.
23
24
25namespace BPrivate {
26
27
28class BControlLook {
29public:
30								BControlLook();
31	virtual						~BControlLook();
32
33	// TODO: Probably more convenient to pull these enums into global
34	// namespace and rename them to e.g. "B_CONTROL_LOOK_FOCUSED" instead of
35	// "BControlLook::B_FOCUSED".
36
37	enum frame_type {
38		B_BUTTON_FRAME,
39		B_GROUP_FRAME,
40		B_MENU_FIELD_FRAME,
41		B_SCROLL_VIEW_FRAME,
42		B_TEXT_CONTROL_FRAME,
43	};
44
45	enum background_type {
46		B_BUTTON_BACKGROUND,
47		B_BUTTON_WITH_POP_UP_BACKGROUND,
48		B_MENU_BACKGROUND,
49		B_MENU_BAR_BACKGROUND,
50		B_MENU_FIELD_BACKGROUND,
51		B_MENU_ITEM_BACKGROUND,
52		B_HORIZONTAL_SCROLL_BAR_BACKGROUND,
53		B_VERTICAL_SCROLL_BAR_BACKGROUND,
54	};
55
56	enum {
57		B_LEFT_BORDER		= 1 << 0,
58		B_RIGHT_BORDER		= 1 << 1,
59		B_TOP_BORDER		= 1 << 2,
60		B_BOTTOM_BORDER		= 1 << 3,
61
62		B_ALL_BORDERS		= B_LEFT_BORDER | B_RIGHT_BORDER
63								| B_TOP_BORDER | B_BOTTOM_BORDER
64	};
65
66	enum {
67		B_LEFT_ARROW		= 0,
68		B_RIGHT_ARROW		= 1,
69		B_UP_ARROW			= 2,
70		B_DOWN_ARROW		= 3,
71		B_LEFT_UP_ARROW		= 4,
72		B_RIGHT_UP_ARROW	= 5,
73		B_RIGHT_DOWN_ARROW	= 6,
74		B_LEFT_DOWN_ARROW	= 7
75	};
76
77	enum {
78		B_FOCUSED				= 1 << 0,
79		B_CLICKED				= 1 << 1, // some controls activate on mouse up
80		B_ACTIVATED				= 1 << 2,
81		B_HOVER					= 1 << 3,
82		B_DISABLED				= 1 << 4,
83		B_DEFAULT_BUTTON		= 1 << 5,
84		B_IGNORE_OUTLINE		= 1 << 6,
85		B_PARTIALLY_ACTIVATED	= 1 << 7, // like B_ACTIVATED, but for tri-state
86		B_FLAT					= 1 << 8, // flat look (e.g. button background)
87		B_INVALID				= 1 << 9, // invalid value, use B_FAILURE_COLOR
88		B_IS_CONTROL			= 1 << 10, // use control colors
89
90		B_BLEND_FRAME			= 1 << 16,
91	};
92
93	virtual BAlignment			DefaultLabelAlignment() const = 0;
94	virtual float				DefaultLabelSpacing() const = 0;
95
96	virtual	float				DefaultItemSpacing() const = 0;
97
98	static	float				ComposeSpacing(float spacing);
99
100	virtual uint32				Flags(BControl* control) const = 0;
101
102	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
103									const BRect& updateRect,
104									const rgb_color& base,
105									const rgb_color& background,
106									uint32 flags = 0,
107									uint32 borders = B_ALL_BORDERS) = 0;
108	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
109									const BRect& updateRect,
110									float radius,
111									const rgb_color& base,
112									const rgb_color& background,
113									uint32 flags = 0,
114									uint32 borders = B_ALL_BORDERS) = 0;
115	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
116									const BRect& updateRect,
117									float leftTopRadius,
118									float rightTopRadius,
119									float leftBottomRadius,
120									float rightBottomRadius,
121									const rgb_color& base,
122									const rgb_color& background,
123									uint32 flags = 0,
124									uint32 borders = B_ALL_BORDERS) = 0;
125
126	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
127									const BRect& updateRect,
128									const rgb_color& base,
129									uint32 flags = 0,
130									uint32 borders = B_ALL_BORDERS,
131									orientation orientation = B_HORIZONTAL) = 0;
132	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
133									const BRect& updateRect,
134									float radius,
135									const rgb_color& base,
136									uint32 flags = 0,
137									uint32 borders = B_ALL_BORDERS,
138									orientation orientation = B_HORIZONTAL) = 0;
139	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
140									const BRect& updateRect,
141									float leftTopRadius,
142									float rightTopRadius,
143									float leftBottomRadius,
144									float rightBottomRadius,
145									const rgb_color& base,
146									uint32 flags = 0,
147									uint32 borders = B_ALL_BORDERS,
148									orientation orientation = B_HORIZONTAL) = 0;
149
150	virtual	void				DrawMenuBarBackground(BView* view, BRect& rect,
151									const BRect& updateRect,
152									const rgb_color& base,
153									uint32 flags = 0,
154									uint32 borders = B_ALL_BORDERS) = 0;
155
156	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
157									const BRect& updateRect,
158									const rgb_color& base,
159									const rgb_color& background,
160									uint32 flags = 0,
161									uint32 borders = B_ALL_BORDERS) = 0;
162	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
163									const BRect& updateRect,
164									float radius,
165									const rgb_color& base,
166									const rgb_color& background,
167									uint32 flags = 0,
168									uint32 borders = B_ALL_BORDERS) = 0;
169	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
170									const BRect& updateRect,
171									float leftTopRadius,
172									float rightTopRadius,
173									float leftBottomRadius,
174									float rightBottomRadius,
175									const rgb_color& base,
176									const rgb_color& background,
177									uint32 flags = 0,
178									uint32 borders = B_ALL_BORDERS) = 0;
179
180	virtual	void				DrawMenuFieldBackground(BView* view,
181									BRect& rect, const BRect& updateRect,
182									const rgb_color& base, bool popupIndicator,
183									uint32 flags = 0) = 0;
184	virtual	void				DrawMenuFieldBackground(BView* view,
185									BRect& rect, const BRect& updateRect,
186									float radius, const rgb_color& base,
187									bool popupIndicator, uint32 flags = 0) = 0;
188	virtual	void				DrawMenuFieldBackground(BView* view,
189									BRect& rect, const BRect& updateRect,
190									float leftTopRadius,
191									float rightTopRadius,
192									float leftBottomRadius,
193									float rightBottomRadius,
194									const rgb_color& base,
195									bool popupIndicator, uint32 flags = 0) = 0;
196	virtual	void				DrawMenuFieldBackground(BView* view,
197									BRect& rect, const BRect& updateRect,
198									const rgb_color& base, uint32 flags = 0,
199									uint32 borders = B_ALL_BORDERS) = 0;
200
201	virtual	void				DrawMenuBackground(BView* view,
202									BRect& rect, const BRect& updateRect,
203									const rgb_color& base, uint32 flags = 0,
204									uint32 borders = B_ALL_BORDERS) = 0;
205
206	virtual	void				DrawMenuItemBackground(BView* view,
207									BRect& rect, const BRect& updateRect,
208									const rgb_color& base, uint32 flags = 0,
209									uint32 borders = B_ALL_BORDERS) = 0;
210
211	virtual	void				DrawStatusBar(BView* view, BRect& rect,
212									const BRect& updateRect,
213									const rgb_color& base,
214									const rgb_color& barColor,
215									float progressPosition) = 0;
216
217	virtual	void				DrawCheckBox(BView* view, BRect& rect,
218									const BRect& updateRect,
219									const rgb_color& base,
220									uint32 flags = 0) = 0;
221
222	virtual	void				DrawRadioButton(BView* view, BRect& rect,
223									const BRect& updateRect,
224									const rgb_color& base,
225									uint32 flags = 0) = 0;
226
227	virtual	void				DrawScrollBarBackground(BView* view,
228									BRect& rect1, BRect& rect2,
229									const BRect& updateRect,
230									const rgb_color& base, uint32 flags,
231									orientation orientation) = 0;
232	virtual	void				DrawScrollBarBackground(BView* view,
233									BRect& rect, const BRect& updateRect,
234									const rgb_color& base, uint32 flags,
235									orientation orientation) = 0;
236
237	virtual	void				DrawScrollViewFrame(BView* view,
238									BRect& rect, const BRect& updateRect,
239									BRect verticalScrollBarFrame,
240									BRect horizontalScrollBarFrame,
241									const rgb_color& base,
242									border_style borderStyle,
243									uint32 flags = 0,
244									uint32 borders = B_ALL_BORDERS) = 0;
245
246	virtual	void				DrawArrowShape(BView* view,
247									BRect& rect, const BRect& updateRect,
248									const rgb_color& base, uint32 direction,
249									uint32 flags = 0,
250									float tint = B_DARKEN_MAX_TINT) = 0;
251
252	virtual	rgb_color			SliderBarColor(const rgb_color& base) = 0;
253
254	virtual	void				DrawSliderBar(BView* view, BRect rect,
255									const BRect& updateRect,
256									const rgb_color& base,
257									rgb_color leftFillColor,
258									rgb_color rightFillColor,
259									float sliderScale, uint32 flags,
260									orientation orientation) = 0;
261	virtual	void				DrawSliderBar(BView* view, BRect rect,
262									const BRect& updateRect,
263									const rgb_color& base, rgb_color fillColor,
264									uint32 flags, orientation orientation) = 0;
265
266	virtual	void				DrawSliderThumb(BView* view, BRect& rect,
267									const BRect& updateRect,
268									const rgb_color& base, uint32 flags,
269									orientation orientation) = 0;
270
271	virtual	void				DrawSliderTriangle(BView* view, BRect& rect,
272									const BRect& updateRect,
273									const rgb_color& base, uint32 flags,
274									orientation orientation) = 0;
275	virtual	void				DrawSliderTriangle(BView* view, BRect& rect,
276									const BRect& updateRect,
277									const rgb_color& base,
278									const rgb_color& fill, uint32 flags,
279									orientation orientation) = 0;
280
281	virtual	void				DrawSliderHashMarks(BView* view, BRect& rect,
282									const BRect& updateRect,
283									const rgb_color& base, int32 count,
284									hash_mark_location location,
285									uint32 flags, orientation orientation) = 0;
286
287	virtual	void				DrawActiveTab(BView* view, BRect& rect,
288									const BRect& updateRect,
289									const rgb_color& base, uint32 flags = 0,
290									uint32 borders = B_ALL_BORDERS,
291									uint32 side = B_TOP_BORDER) = 0;
292	virtual	void				DrawInactiveTab(BView* view, BRect& rect,
293									const BRect& updateRect,
294									const rgb_color& base, uint32 flags = 0,
295									uint32 borders = B_ALL_BORDERS,
296									uint32 side = B_TOP_BORDER) = 0;
297
298	virtual	void				DrawSplitter(BView* view, BRect& rect,
299									const BRect& updateRect,
300									const rgb_color& base,
301									orientation orientation,
302									uint32 flags = 0,
303									uint32 borders = B_ALL_BORDERS) = 0;
304
305	// various borders
306
307	virtual	void				DrawBorder(BView* view, BRect& rect,
308									const BRect& updateRect,
309									const rgb_color& base,
310									border_style borderStyle, uint32 flags = 0,
311									uint32 borders = B_ALL_BORDERS) = 0;
312
313	virtual	void				DrawRaisedBorder(BView* view, BRect& rect,
314									const BRect& updateRect,
315									const rgb_color& base, uint32 flags = 0,
316									uint32 borders = B_ALL_BORDERS) = 0;
317
318	virtual	void				DrawGroupFrame(BView* view, BRect& rect,
319									const BRect& updateRect,
320									const rgb_color& base,
321									uint32 borders = B_ALL_BORDERS) = 0;
322
323	virtual	void				DrawTextControlBorder(BView* view, BRect& rect,
324									const BRect& updateRect,
325									const rgb_color& base, uint32 flags = 0,
326									uint32 borders = B_ALL_BORDERS) = 0;
327
328	// aligned labels
329
330	virtual	void				DrawLabel(BView* view, const char* label,
331									BRect rect, const BRect& updateRect,
332									const rgb_color& base, uint32 flags,
333									const rgb_color* textColor = NULL) = 0;
334	virtual	void				DrawLabel(BView* view, const char* label,
335									BRect rect, const BRect& updateRect,
336									const rgb_color& base, uint32 flags,
337									const BAlignment& alignment,
338									const rgb_color* textColor = NULL) = 0;
339	// TODO: Would be nice to have a (non-virtual) version of this method
340	// which takes an array of labels and locations. That would save some
341	// setup with the view graphics state.
342	virtual	void				DrawLabel(BView* view, const char* label,
343									const rgb_color& base, uint32 flags,
344									const BPoint& where,
345									const rgb_color* textColor = NULL) = 0;
346
347			void				DrawLabel(BView* view, const char* label,
348									const BBitmap* icon, BRect rect,
349									const BRect& updateRect,
350									const rgb_color& base, uint32 flags,
351									const rgb_color* textColor = NULL);
352	virtual	void				DrawLabel(BView* view, const char* label,
353									const BBitmap* icon, BRect rect,
354									const BRect& updateRect,
355									const rgb_color& base, uint32 flags,
356									const BAlignment& alignment,
357									const rgb_color* textColor = NULL) = 0;
358
359	virtual	void				GetFrameInsets(frame_type frameType,
360									uint32 flags, float& _left, float& _top,
361									float& _right, float& _bottom) = 0;
362	virtual	void				GetBackgroundInsets(
363									background_type backgroundType,
364									uint32 flags, float& _left, float& _top,
365									float& _right, float& _bottom) = 0;
366			void				GetInsets(frame_type frameType,
367									background_type backgroundType,
368									uint32 flags, float& _left, float& _top,
369									float& _right, float& _bottom);
370
371	virtual	void				DrawButtonWithPopUpBackground(BView* view,
372									BRect& rect, const BRect& updateRect,
373									const rgb_color& base,
374									uint32 flags = 0,
375									uint32 borders = B_ALL_BORDERS,
376									orientation orientation = B_HORIZONTAL) = 0;
377	virtual	void				DrawButtonWithPopUpBackground(BView* view,
378									BRect& rect, const BRect& updateRect,
379									float radius,
380									const rgb_color& base,
381									uint32 flags = 0,
382									uint32 borders = B_ALL_BORDERS,
383									orientation orientation = B_HORIZONTAL) = 0;
384	virtual	void				DrawButtonWithPopUpBackground(BView* view,
385									BRect& rect, const BRect& updateRect,
386									float leftTopRadius,
387									float rightTopRadius,
388									float leftBottomRadius,
389									float rightBottomRadius,
390									const rgb_color& base,
391									uint32 flags = 0,
392									uint32 borders = B_ALL_BORDERS,
393									orientation orientation = B_HORIZONTAL) = 0;
394
395			void				SetBackgroundInfo(
396									const BMessage& backgroundInfo);
397
398	virtual	void				DrawTabFrame(BView* view, BRect& rect,
399									const BRect& updateRect,
400									const rgb_color& base, uint32 flags = 0,
401									uint32 borders = B_ALL_BORDERS,
402									border_style borderStyle = B_FANCY_BORDER,
403									uint32 side = B_TOP_BORDER) = 0;
404private:
405	// FBC padding
406	virtual	void				_ReservedControlLook2();
407	virtual	void				_ReservedControlLook3();
408	virtual	void				_ReservedControlLook4();
409	virtual	void				_ReservedControlLook5();
410	virtual	void				_ReservedControlLook6();
411	virtual	void				_ReservedControlLook7();
412	virtual	void				_ReservedControlLook8();
413	virtual	void				_ReservedControlLook9();
414	virtual	void				_ReservedControlLook10();
415
416protected:
417			int32				fCachedWorkspace;
418			BMessage			fBackgroundInfo;
419
420			uint32				_reserved[20];
421};
422
423extern BControlLook* be_control_look;
424
425extern "C" _EXPORT BControlLook *instantiate_control_look(image_id id);
426
427
428} // namespace BPrivate
429
430using BPrivate::BControlLook;
431using BPrivate::be_control_look;
432
433
434#endif // _CONTROL_LOOK_H
435