12f86ba45SStephan Aßmus /* 2*db68ff23SAugustin Cavalier * Copyright 2012-2017 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 9a884b43bSJohn Scipione 102f86ba45SStephan Aßmus namespace BPrivate { 112f86ba45SStephan Aßmus 12a884b43bSJohn Scipione 13*db68ff23SAugustin Cavalier BControlLook::BControlLook() 14*db68ff23SAugustin Cavalier : 15d63b75faSPhilippe Saint-Pierre fCachedWorkspace(-1) 162f86ba45SStephan Aßmus { 172f86ba45SStephan Aßmus } 182f86ba45SStephan Aßmus 192f86ba45SStephan Aßmus 202f86ba45SStephan Aßmus BControlLook::~BControlLook() 212f86ba45SStephan Aßmus { 222f86ba45SStephan Aßmus } 232f86ba45SStephan Aßmus 242f86ba45SStephan Aßmus 2582ab3167SAlex Wilson float 266648dd3cSAlex Wilson BControlLook::ComposeSpacing(float spacing) 2782ab3167SAlex Wilson { 28e047b40aSAxel Dörfler switch ((int)spacing) { 29e047b40aSAxel Dörfler case B_USE_DEFAULT_SPACING: 30e047b40aSAxel Dörfler case B_USE_ITEM_SPACING: 3182ab3167SAlex Wilson return be_control_look->DefaultItemSpacing(); 32e047b40aSAxel Dörfler case B_USE_HALF_ITEM_SPACING: 33a8b89c6bSStephan Aßmus return ceilf(be_control_look->DefaultItemSpacing() * 0.5f); 34e047b40aSAxel Dörfler case B_USE_WINDOW_SPACING: 356648dd3cSAlex Wilson return be_control_look->DefaultItemSpacing(); 36e047b40aSAxel Dörfler case B_USE_SMALL_SPACING: 37a8b89c6bSStephan Aßmus return ceilf(be_control_look->DefaultItemSpacing() * 0.7f); 38e047b40aSAxel Dörfler case B_USE_BIG_SPACING: 39a8b89c6bSStephan Aßmus return ceilf(be_control_look->DefaultItemSpacing() * 1.3f); 406648dd3cSAlex Wilson } 41e047b40aSAxel Dörfler 426648dd3cSAlex Wilson return spacing; 4382ab3167SAlex Wilson } 4482ab3167SAlex Wilson 4582ab3167SAlex Wilson 46d63b75faSPhilippe Saint-Pierre void 471b848ee7SIngo Weinhold BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, 487a96554cSlooncraz BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags, 497a96554cSlooncraz const rgb_color* textColor) 501b848ee7SIngo Weinhold { 511b848ee7SIngo Weinhold DrawLabel(view, label, icon, rect, updateRect, base, flags, 527a96554cSlooncraz DefaultLabelAlignment(), textColor); 531b848ee7SIngo Weinhold } 541b848ee7SIngo Weinhold 551b848ee7SIngo Weinhold 561b848ee7SIngo Weinhold void 578719e0dcSIngo Weinhold BControlLook::GetInsets(frame_type frameType, background_type backgroundType, 588719e0dcSIngo Weinhold uint32 flags, float& _left, float& _top, float& _right, float& _bottom) 598719e0dcSIngo Weinhold { 608719e0dcSIngo Weinhold GetFrameInsets(frameType, flags, _left, _top, _right, _bottom); 618719e0dcSIngo Weinhold 628719e0dcSIngo Weinhold float left, top, right, bottom; 638719e0dcSIngo Weinhold GetBackgroundInsets(backgroundType, flags, left, top, right, bottom); 648719e0dcSIngo Weinhold 658719e0dcSIngo Weinhold _left += left; 668719e0dcSIngo Weinhold _top += top; 678719e0dcSIngo Weinhold _right += right; 688719e0dcSIngo Weinhold _bottom += bottom; 698719e0dcSIngo Weinhold } 708719e0dcSIngo Weinhold 718719e0dcSIngo Weinhold 728719e0dcSIngo Weinhold void 73d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo) 74d63b75faSPhilippe Saint-Pierre { 75d452ff66SAxel Dörfler fBackgroundInfo = backgroundInfo; 76d63b75faSPhilippe Saint-Pierre fCachedWorkspace = -1; 77d63b75faSPhilippe Saint-Pierre } 78d63b75faSPhilippe Saint-Pierre 79d63b75faSPhilippe Saint-Pierre 802f86ba45SStephan Aßmus // NOTE: May come from a add-on in the future. Initialized in 812f86ba45SStephan Aßmus // InterfaceDefs.cpp 822f86ba45SStephan Aßmus BControlLook* be_control_look = NULL; 832f86ba45SStephan Aßmus 84a884b43bSJohn Scipione 852f86ba45SStephan Aßmus } // namespace BPrivate 86