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 48874a2a72SAugustin Cavalier BSize 49874a2a72SAugustin Cavalier BControlLook::ComposeIconSize(int32 size) 50874a2a72SAugustin Cavalier { 51874a2a72SAugustin Cavalier float scale = be_plain_font->Size() / 12.0f; 52874a2a72SAugustin Cavalier if (scale < 1.0f) 53874a2a72SAugustin Cavalier scale = 1.0f; 54874a2a72SAugustin Cavalier 55*1be85605SAugustin Cavalier const int32 scaled = (int32)(size * scale); 56874a2a72SAugustin Cavalier return BSize(scaled - 1, scaled - 1); 57874a2a72SAugustin Cavalier } 58874a2a72SAugustin Cavalier 59874a2a72SAugustin Cavalier 60d63b75faSPhilippe Saint-Pierre void 611b848ee7SIngo Weinhold BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, 627a96554cSlooncraz BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags, 637a96554cSlooncraz const rgb_color* textColor) 641b848ee7SIngo Weinhold { 651b848ee7SIngo Weinhold DrawLabel(view, label, icon, rect, updateRect, base, flags, 667a96554cSlooncraz DefaultLabelAlignment(), textColor); 671b848ee7SIngo Weinhold } 681b848ee7SIngo Weinhold 691b848ee7SIngo Weinhold 701b848ee7SIngo Weinhold void 718719e0dcSIngo Weinhold BControlLook::GetInsets(frame_type frameType, background_type backgroundType, 728719e0dcSIngo Weinhold uint32 flags, float& _left, float& _top, float& _right, float& _bottom) 738719e0dcSIngo Weinhold { 748719e0dcSIngo Weinhold GetFrameInsets(frameType, flags, _left, _top, _right, _bottom); 758719e0dcSIngo Weinhold 768719e0dcSIngo Weinhold float left, top, right, bottom; 778719e0dcSIngo Weinhold GetBackgroundInsets(backgroundType, flags, left, top, right, bottom); 788719e0dcSIngo Weinhold 798719e0dcSIngo Weinhold _left += left; 808719e0dcSIngo Weinhold _top += top; 818719e0dcSIngo Weinhold _right += right; 828719e0dcSIngo Weinhold _bottom += bottom; 838719e0dcSIngo Weinhold } 848719e0dcSIngo Weinhold 858719e0dcSIngo Weinhold 86409d65c0SPascal Abresch float 87409d65c0SPascal Abresch BControlLook::GetScrollBarWidth(orientation orientation) 88409d65c0SPascal Abresch { 89409d65c0SPascal Abresch // this matches HaikuControlLook.cpp currently 90325ab89bSPascal Abresch if (be_plain_font->Size() <= 12.0f) 91325ab89bSPascal Abresch return 14.0f; 92409d65c0SPascal Abresch return be_plain_font->Size() / 12.0f * 14.0f; 93409d65c0SPascal Abresch } 94409d65c0SPascal Abresch 95409d65c0SPascal Abresch 968719e0dcSIngo Weinhold void 97d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo) 98d63b75faSPhilippe Saint-Pierre { 99d452ff66SAxel Dörfler fBackgroundInfo = backgroundInfo; 100d63b75faSPhilippe Saint-Pierre fCachedWorkspace = -1; 101d63b75faSPhilippe Saint-Pierre } 102d63b75faSPhilippe Saint-Pierre 103d63b75faSPhilippe Saint-Pierre 104fb3493dfSJohn Scipione extern "C" void 105fb3493dfSJohn Scipione B_IF_GCC_2(_ReservedControlLook1__Q28BPrivate12BControlLook, 106fb3493dfSJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook1Ev)( 107fb3493dfSJohn Scipione BControlLook* controlLook, BView* view, BRect& rect, 108fb3493dfSJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 109fb3493dfSJohn Scipione uint32 borders, border_style borderStyle, uint32 side) 110fb3493dfSJohn Scipione { 111fb3493dfSJohn Scipione controlLook->DrawTabFrame(view, rect, updateRect, base, flags, borders, 112fb3493dfSJohn Scipione borderStyle, side); 113fb3493dfSJohn Scipione } 114fb3493dfSJohn Scipione 115fb3493dfSJohn Scipione 1161482b250SJohn Scipione extern "C" void 1171482b250SJohn Scipione B_IF_GCC_2(_ReservedControlLook2__Q28BPrivate12BControlLook, 1181482b250SJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook2Ev)( 1191482b250SJohn Scipione BControlLook* controlLook, BView* view, BRect rect, 1201482b250SJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 1211482b250SJohn Scipione int32 direction, orientation orientation, bool down) 1221482b250SJohn Scipione { 1231482b250SJohn Scipione controlLook->DrawScrollBarButton(view, rect, updateRect, base, flags, 1241482b250SJohn Scipione direction, orientation, down); 1251482b250SJohn Scipione } 1261482b250SJohn Scipione 1271482b250SJohn Scipione 1281482b250SJohn Scipione extern "C" void 1291482b250SJohn Scipione B_IF_GCC_2(_ReservedControlLook3__Q28BPrivate12BControlLook, 1301482b250SJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook3Ev)( 1311482b250SJohn Scipione BControlLook* controlLook, BView* view, BRect rect, 1321482b250SJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 1331482b250SJohn Scipione int32 direction, orientation orientation, uint32 knobStyle) 1341482b250SJohn Scipione { 1351482b250SJohn Scipione controlLook->DrawScrollBarThumb(view, rect, updateRect, base, flags, 1361482b250SJohn Scipione orientation, knobStyle); 1371482b250SJohn Scipione } 1381482b250SJohn Scipione 1391482b250SJohn Scipione 1401482b250SJohn Scipione extern "C" void 1411482b250SJohn Scipione B_IF_GCC_2(_ReservedControlLook4__Q28BPrivate12BControlLook, 1421482b250SJohn Scipione _ZN8BPrivate12BControlLook21_ReservedControlLook4Ev)( 1431482b250SJohn Scipione BControlLook* controlLook, BView* view, BRect rect, 1441482b250SJohn Scipione const BRect& updateRect, const rgb_color& base, uint32 flags, 1451482b250SJohn Scipione orientation orientation) 1461482b250SJohn Scipione { 1471482b250SJohn Scipione controlLook->DrawScrollBarBorder(view, rect, updateRect, base, flags, 1481482b250SJohn Scipione orientation); 1491482b250SJohn Scipione } 1501482b250SJohn Scipione 1511482b250SJohn Scipione 152409d65c0SPascal Abresch extern "C" float 153409d65c0SPascal Abresch B_IF_GCC_2(_ReservedControlLook5__Q28BPrivate12BControlLook, 154409d65c0SPascal Abresch _ZN8BPrivate12BControlLook21_ReservedControlLook5Ev)( 155409d65c0SPascal Abresch BControlLook* controlLook, orientation orientation) 156409d65c0SPascal Abresch { 157409d65c0SPascal Abresch return controlLook->GetScrollBarWidth(orientation); 158409d65c0SPascal Abresch } 159409d65c0SPascal Abresch 160409d65c0SPascal Abresch 161fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook6() {} 162fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook7() {} 163fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook8() {} 164fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook9() {} 165fd25b902SAugustin Cavalier void BControlLook::_ReservedControlLook10() {} 166fd25b902SAugustin Cavalier 167fd25b902SAugustin Cavalier 168629397f2SFrançois Revol // Initialized in InterfaceDefs.cpp 1692f86ba45SStephan Aßmus BControlLook* be_control_look = NULL; 1702f86ba45SStephan Aßmus 1712f86ba45SStephan Aßmus } // namespace BPrivate 172