1 /*****************************************************************************/ 2 // ShowImageStatusView 3 // Written by Fernando Francisco de Oliveira, Michael Wilber 4 // 5 // ShowImageStatusView.cpp 6 // 7 // 8 // Copyright (c) 2003 OpenBeOS Project 9 // 10 // Permission is hereby granted, free of charge, to any person obtaining a 11 // copy of this software and associated documentation files (the "Software"), 12 // to deal in the Software without restriction, including without limitation 13 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 // and/or sell copies of the Software, and to permit persons to whom the 15 // Software is furnished to do so, subject to the following conditions: 16 // 17 // The above copyright notice and this permission notice shall be included 18 // in all copies or substantial portions of the Software. 19 // 20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 // DEALINGS IN THE SOFTWARE. 27 /*****************************************************************************/ 28 29 #include "ShowImageStatusView.h" 30 31 ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, 32 uint32 resizingMode, uint32 flags) 33 : BView(rect, name, resizingMode, flags) 34 { 35 SetViewColor(B_TRANSPARENT_32_BIT); 36 SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 37 SetHighColor(0, 0, 0, 255); 38 39 BFont font; 40 GetFont(&font); 41 font.SetSize(10.0); 42 SetFont(&font); 43 } 44 45 void 46 ShowImageStatusView::Draw(BRect updateRect) 47 { 48 rgb_color darkShadow = tint_color(LowColor(), B_DARKEN_2_TINT); 49 rgb_color shadow = tint_color(LowColor(), B_DARKEN_1_TINT); 50 rgb_color light = tint_color(LowColor(), B_LIGHTEN_MAX_TINT); 51 52 BRect b(Bounds()); 53 54 BeginLineArray(5); 55 AddLine(BPoint(b.left, b.top), 56 BPoint(b.right, b.top), darkShadow); 57 b.top += 1.0; 58 AddLine(BPoint(b.left, b.top), 59 BPoint(b.right, b.top), light); 60 AddLine(BPoint(b.right, b.top + 1.0), 61 BPoint(b.right, b.bottom), shadow); 62 AddLine(BPoint(b.right - 1.0, b.bottom), 63 BPoint(b.left + 1.0, b.bottom), shadow); 64 AddLine(BPoint(b.left, b.bottom), 65 BPoint(b.left, b.top + 1.0), light); 66 EndLineArray(); 67 68 b.InsetBy(1.0, 1.0); 69 70 // truncate and layout text 71 BString truncated(fText); 72 BFont font; 73 GetFont(&font); 74 font.TruncateString(&truncated, B_TRUNCATE_MIDDLE, b.Width() - 4.0); 75 font_height fh; 76 font.GetHeight(&fh); 77 78 FillRect(b, B_SOLID_LOW); 79 SetDrawingMode(B_OP_OVER); 80 DrawString(truncated.String(), BPoint(b.left + 2.0, 81 floorf(b.top + b.Height() / 2.0 82 + fh.ascent / 2.0))); 83 } 84 85 void 86 ShowImageStatusView::SetText(BString &text) 87 { 88 fText = text; 89 Invalidate(); 90 } 91