1 /* 2 * Copyright 2012 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione <jscipione@gmail.com> 7 */ 8 9 10 #include "GearsView.h" 11 12 #include <Bitmap.h> 13 #include <Locale.h> 14 #include <Size.h> 15 #include <TranslationUtils.h> 16 #include <TranslatorFormats.h> 17 18 19 static const float kStripeWidth = 30.0; 20 21 GearsView::GearsView() 22 : 23 BView("GearsView", B_WILL_DRAW), 24 fGears(NULL) 25 { 26 SetExplicitMinSize(BSize(64.0 + 10.0, B_SIZE_UNSET)); 27 SetExplicitPreferredSize(BSize(64.0 + 10.0, B_SIZE_UNLIMITED)); 28 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 29 _InitGearsBitmap(); 30 } 31 32 33 GearsView::~GearsView() 34 { 35 delete fGears; 36 } 37 38 39 void 40 GearsView::Draw(BRect updateRect) 41 { 42 SetHighColor(ViewColor()); 43 FillRect(updateRect); 44 45 BRect stripeRect = Bounds(); 46 stripeRect.right = kStripeWidth; 47 SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); 48 FillRect(stripeRect); 49 50 if (fGears == NULL) 51 return; 52 53 SetDrawingMode(B_OP_ALPHA); 54 SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); 55 DrawBitmapAsync(fGears, BPoint(5.0, 10.0)); 56 } 57 58 59 // #pragma mark - 60 61 62 void 63 GearsView::_InitGearsBitmap() 64 { 65 fGears = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "gears_64.png"); 66 } 67