xref: /haiku/src/kits/interface/ControlLook.cpp (revision 1a3518cf757c2da8006753f83962da5935bbc82b)
1 /*
2  * Copyright 2012-2020 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <ControlLook.h>
8 
9 #include <binary_compatibility/Interface.h>
10 
11 
12 namespace BPrivate {
13 
14 
15 BControlLook::BControlLook()
16 	:
17 	fCachedWorkspace(-1)
18 {
19 }
20 
21 
22 BControlLook::~BControlLook()
23 {
24 }
25 
26 
27 float
28 BControlLook::ComposeSpacing(float spacing)
29 {
30 	switch ((int)spacing) {
31 		case B_USE_DEFAULT_SPACING:
32 		case B_USE_ITEM_SPACING:
33 			return be_control_look->DefaultItemSpacing();
34 		case B_USE_HALF_ITEM_SPACING:
35 			return ceilf(be_control_look->DefaultItemSpacing() * 0.5f);
36 		case B_USE_WINDOW_SPACING:
37 			return be_control_look->DefaultItemSpacing();
38 		case B_USE_SMALL_SPACING:
39 			return ceilf(be_control_look->DefaultItemSpacing() * 0.7f);
40 		case B_USE_BIG_SPACING:
41 			return ceilf(be_control_look->DefaultItemSpacing() * 1.3f);
42 	}
43 
44 	return spacing;
45 }
46 
47 
48 void
49 BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
50 	BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags,
51 	const rgb_color* textColor)
52 {
53 	DrawLabel(view, label, icon, rect, updateRect, base, flags,
54 		DefaultLabelAlignment(), textColor);
55 }
56 
57 
58 void
59 BControlLook::GetInsets(frame_type frameType, background_type backgroundType,
60 	uint32 flags, float& _left, float& _top, float& _right, float& _bottom)
61 {
62 	GetFrameInsets(frameType, flags, _left, _top, _right, _bottom);
63 
64 	float left, top, right, bottom;
65 	GetBackgroundInsets(backgroundType, flags, left, top, right, bottom);
66 
67 	_left += left;
68 	_top += top;
69 	_right += right;
70 	_bottom += bottom;
71 }
72 
73 
74 void
75 BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo)
76 {
77 	fBackgroundInfo = backgroundInfo;
78 	fCachedWorkspace = -1;
79 }
80 
81 
82 extern "C" void
83 B_IF_GCC_2(_ReservedControlLook1__Q28BPrivate12BControlLook,
84 		_ZN8BPrivate12BControlLook21_ReservedControlLook1Ev)(
85 	BControlLook* controlLook, BView* view, BRect& rect,
86 	const BRect& updateRect, const rgb_color& base, uint32 flags,
87 	uint32 borders, border_style borderStyle, uint32 side)
88 {
89 	controlLook->DrawTabFrame(view, rect, updateRect, base, flags, borders,
90 		borderStyle, side);
91 }
92 
93 
94 extern "C" void
95 B_IF_GCC_2(_ReservedControlLook2__Q28BPrivate12BControlLook,
96 		_ZN8BPrivate12BControlLook21_ReservedControlLook2Ev)(
97 	BControlLook* controlLook, BView* view, BRect rect,
98 		const BRect& updateRect, const rgb_color& base, uint32 flags,
99 		int32 direction, orientation orientation, bool down)
100 {
101 	controlLook->DrawScrollBarButton(view, rect, updateRect, base, flags,
102 		direction, orientation, down);
103 }
104 
105 
106 extern "C" void
107 B_IF_GCC_2(_ReservedControlLook3__Q28BPrivate12BControlLook,
108 		_ZN8BPrivate12BControlLook21_ReservedControlLook3Ev)(
109 	BControlLook* controlLook, BView* view, BRect rect,
110 		const BRect& updateRect, const rgb_color& base, uint32 flags,
111 		int32 direction, orientation orientation, uint32 knobStyle)
112 {
113 	controlLook->DrawScrollBarThumb(view, rect, updateRect, base, flags,
114 		orientation, knobStyle);
115 }
116 
117 
118 extern "C" void
119 B_IF_GCC_2(_ReservedControlLook4__Q28BPrivate12BControlLook,
120 		_ZN8BPrivate12BControlLook21_ReservedControlLook4Ev)(
121 	BControlLook* controlLook, BView* view, BRect rect,
122 		const BRect& updateRect, const rgb_color& base, uint32 flags,
123 		orientation orientation)
124 {
125 	controlLook->DrawScrollBarBorder(view, rect, updateRect, base, flags,
126 		orientation);
127 }
128 
129 
130 void BControlLook::_ReservedControlLook5() {}
131 void BControlLook::_ReservedControlLook6() {}
132 void BControlLook::_ReservedControlLook7() {}
133 void BControlLook::_ReservedControlLook8() {}
134 void BControlLook::_ReservedControlLook9() {}
135 void BControlLook::_ReservedControlLook10() {}
136 
137 
138 // Initialized in InterfaceDefs.cpp
139 BControlLook* be_control_look = NULL;
140 
141 } // namespace BPrivate
142