12f86ba45SStephan Aßmus /* 21482b250SJohn Scipione * Copyright 2012-2020 Haiku, Inc. All rights reserved. 32f86ba45SStephan Aßmus * Distributed under the terms of the MIT License. 42f86ba45SStephan Aßmus */ 5d452ff66SAxel Dörfler 6d452ff66SAxel Dörfler 72f86ba45SStephan Aßmus #include <ControlLook.h> 82f86ba45SStephan Aßmus 9fb3493dfSJohn Scipione #include <binary_compatibility/Interface.h> 10fb3493dfSJohn Scipione 11a884b43bSJohn Scipione 122f86ba45SStephan Aßmus namespace BPrivate { 132f86ba45SStephan Aßmus 14a884b43bSJohn Scipione 15db68ff23SAugustin Cavalier BControlLook::BControlLook() 16db68ff23SAugustin Cavalier : 17d63b75faSPhilippe Saint-Pierre fCachedWorkspace(-1) 182f86ba45SStephan Aßmus { 192f86ba45SStephan Aßmus } 202f86ba45SStephan Aßmus 212f86ba45SStephan Aßmus 222f86ba45SStephan Aßmus BControlLook::~BControlLook() 232f86ba45SStephan Aßmus { 242f86ba45SStephan Aßmus } 252f86ba45SStephan Aßmus 262f86ba45SStephan Aßmus 2782ab3167SAlex Wilson float 286648dd3cSAlex Wilson BControlLook::ComposeSpacing(float spacing) 2982ab3167SAlex Wilson { 30e047b40aSAxel Dörfler switch ((int)spacing) { 31e047b40aSAxel Dörfler case B_USE_DEFAULT_SPACING: 32e047b40aSAxel Dörfler case B_USE_ITEM_SPACING: 3382ab3167SAlex Wilson return be_control_look->DefaultItemSpacing(); 34e047b40aSAxel Dörfler case B_USE_HALF_ITEM_SPACING: 35a8b89c6bSStephan Aßmus return ceilf(be_control_look->DefaultItemSpacing() * 0.5f); 36e047b40aSAxel Dörfler case B_USE_WINDOW_SPACING: 376648dd3cSAlex Wilson return be_control_look->DefaultItemSpacing(); 38e047b40aSAxel Dörfler case B_USE_SMALL_SPACING: 39a8b89c6bSStephan Aßmus return ceilf(be_control_look->DefaultItemSpacing() * 0.7f); 40e047b40aSAxel Dörfler case B_USE_BIG_SPACING: 41a8b89c6bSStephan Aßmus return ceilf(be_control_look->DefaultItemSpacing() * 1.3f); 426648dd3cSAlex Wilson } 43e047b40aSAxel Dörfler 446648dd3cSAlex Wilson return spacing; 4582ab3167SAlex Wilson } 4682ab3167SAlex Wilson 4782ab3167SAlex Wilson 48d63b75faSPhilippe Saint-Pierre void 491b848ee7SIngo Weinhold BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, 507a96554cSlooncraz BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags, 517a96554cSlooncraz const rgb_color* textColor) 521b848ee7SIngo Weinhold { 531b848ee7SIngo Weinhold DrawLabel(view, label, icon, rect, updateRect, base, flags, 547a96554cSlooncraz DefaultLabelAlignment(), textColor); 551b848ee7SIngo Weinhold } 561b848ee7SIngo Weinhold 571b848ee7SIngo Weinhold 581b848ee7SIngo Weinhold void 598719e0dcSIngo Weinhold BControlLook::GetInsets(frame_type frameType, background_type backgroundType, 608719e0dcSIngo Weinhold uint32 flags, float& _left, float& _top, float& _right, float& _bottom) 618719e0dcSIngo Weinhold { 628719e0dcSIngo Weinhold GetFrameInsets(frameType, flags, _left, _top, _right, _bottom); 638719e0dcSIngo Weinhold 648719e0dcSIngo Weinhold float left, top, right, bottom; 658719e0dcSIngo Weinhold GetBackgroundInsets(backgroundType, flags, left, top, right, bottom); 668719e0dcSIngo Weinhold 678719e0dcSIngo Weinhold _left += left; 688719e0dcSIngo Weinhold _top += top; 698719e0dcSIngo Weinhold _right += right; 708719e0dcSIngo Weinhold _bottom += bottom; 718719e0dcSIngo Weinhold } 728719e0dcSIngo Weinhold 738719e0dcSIngo Weinhold 74*409d65c0SPascal Abresch float 75*409d65c0SPascal Abresch BControlLook::GetScrollBarWidth(orientation orientation) 76*409d65c0SPascal Abresch { 77*409d65c0SPascal Abresch // this matches HaikuControlLook.cpp currently 78*409d65c0SPascal Abresch if (be_plain_font->Size() <= 12.0f) { return 14.0f; } 79*409d65c0SPascal Abresch return be_plain_font->Size() / 12.0f * 14.0f; 80*409d65c0SPascal Abresch } 81*409d65c0SPascal Abresch 82*409d65c0SPascal Abresch 838719e0dcSIngo Weinhold void 84d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo) 85d63b75faSPhilippe Saint-Pierre { 86d452ff66SAxel Dörfler fBackgroundInfo = backgroundInfo; 87d63b75faSPhilippe Saint-Pierre fCachedWorkspace = -1; 88d63b75faSPhilippe Saint-Pierre } 89d63b75faSPhilippe Saint-Pierre 90d63b75faSPhilippe Saint-Pierre 91fb3493dfSJohn Scipione extern "C" void 92fb3493dfSJohn Scipione B_IF_GCC_2(_ReservedControlLook1__Q28BPrivate12BControlLook, 93fb3493dfSJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook1Ev)( 94fb3493dfSJohn Scipione BControlLook* controlLook, BView* view, BRect& rect, 95fb3493dfSJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 96fb3493dfSJohn Scipione uint32 borders, border_style borderStyle, uint32 side) 97fb3493dfSJohn Scipione { 98fb3493dfSJohn Scipione controlLook->DrawTabFrame(view, rect, updateRect, base, flags, borders, 99fb3493dfSJohn Scipione borderStyle, side); 100fb3493dfSJohn Scipione } 101fb3493dfSJohn Scipione 102fb3493dfSJohn Scipione 1031482b250SJohn Scipione extern "C" void 1041482b250SJohn Scipione B_IF_GCC_2(_ReservedControlLook2__Q28BPrivate12BControlLook, 1051482b250SJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook2Ev)( 1061482b250SJohn Scipione BControlLook* controlLook, BView* view, BRect rect, 1071482b250SJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 1081482b250SJohn Scipione int32 direction, orientation orientation, bool down) 1091482b250SJohn Scipione { 1101482b250SJohn Scipione controlLook->DrawScrollBarButton(view, rect, updateRect, base, flags, 1111482b250SJohn Scipione direction, orientation, down); 1121482b250SJohn Scipione } 1131482b250SJohn Scipione 1141482b250SJohn Scipione 1151482b250SJohn Scipione extern "C" void 1161482b250SJohn Scipione B_IF_GCC_2(_ReservedControlLook3__Q28BPrivate12BControlLook, 1171482b250SJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook3Ev)( 1181482b250SJohn Scipione BControlLook* controlLook, BView* view, BRect rect, 1191482b250SJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 1201482b250SJohn Scipione int32 direction, orientation orientation, uint32 knobStyle) 1211482b250SJohn Scipione { 1221482b250SJohn Scipione controlLook->DrawScrollBarThumb(view, rect, updateRect, base, flags, 1231482b250SJohn Scipione orientation, knobStyle); 1241482b250SJohn Scipione } 1251482b250SJohn Scipione 1261482b250SJohn Scipione 1271482b250SJohn Scipione extern "C" void 1281482b250SJohn Scipione B_IF_GCC_2(_ReservedControlLook4__Q28BPrivate12BControlLook, 1291482b250SJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook4Ev)( 1301482b250SJohn Scipione BControlLook* controlLook, BView* view, BRect rect, 1311482b250SJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 1321482b250SJohn Scipione orientation orientation) 1331482b250SJohn Scipione { 1341482b250SJohn Scipione controlLook->DrawScrollBarBorder(view, rect, updateRect, base, flags, 1351482b250SJohn Scipione orientation); 1361482b250SJohn Scipione } 1371482b250SJohn Scipione 1381482b250SJohn Scipione 139*409d65c0SPascal Abresch extern "C" float 140*409d65c0SPascal Abresch B_IF_GCC_2(_ReservedControlLook5__Q28BPrivate12BControlLook, 141*409d65c0SPascal Abresch _ZN8BPrivate12BControlLook21_ReservedControlLook5Ev)( 142*409d65c0SPascal Abresch BControlLook* controlLook, orientation orientation) 143*409d65c0SPascal Abresch { 144*409d65c0SPascal Abresch return controlLook->GetScrollBarWidth(orientation); 145*409d65c0SPascal Abresch } 146*409d65c0SPascal Abresch 147*409d65c0SPascal Abresch 148fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook6() {} 149fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook7() {} 150fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook8() {} 151fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook9() {} 152fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook10() {} 153fd25b902SAugustin Cavalier 154fd25b902SAugustin Cavalier 155629397f2SFrançois Revol // Initialized in InterfaceDefs.cpp 1562f86ba45SStephan Aßmus BControlLook* be_control_look = NULL; 1572f86ba45SStephan Aßmus 1582f86ba45SStephan Aßmus } // namespace BPrivate 159