1 /* 2 ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. 3 Copyright (C) 2004 beunited.org 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 21 #include "NoiseBarMenuItem.h" 22 23 #include "Colors.h" 24 #include "ProcessController.h" 25 26 27 NoiseBarMenuItem::NoiseBarMenuItem() 28 : BMenuItem("Gone Teams...", NULL) 29 { 30 fBusyWaiting = -1; 31 fLost = -1; 32 fGrenze1 = -1; 33 fGrenze2 = -1; 34 } 35 36 37 void 38 NoiseBarMenuItem::DrawContent() 39 { 40 DrawBar(true); 41 Menu()->MovePenTo(ContentLocation()); 42 BMenuItem::DrawContent(); 43 } 44 45 46 void 47 NoiseBarMenuItem::DrawBar(bool force) 48 { 49 bool selected = IsSelected(); 50 BRect frame = Frame(); 51 BMenu* menu = Menu(); 52 frame.right -= 24; 53 frame.left = frame.right - kBarWidth; 54 frame.top += 5; 55 frame.bottom = frame.top + 8; 56 if (fBusyWaiting < 0) 57 return; 58 59 if (fGrenze1 < 0) 60 force = true; 61 62 if (force) { 63 if (selected) 64 menu->SetHighColor(gFrameColorSelected); 65 else 66 menu->SetHighColor(gFrameColor); 67 menu->StrokeRect(frame); 68 } 69 70 frame.InsetBy(1, 1); 71 BRect r = frame; 72 float grenze1 = frame.left+(frame.right-frame.left)*fBusyWaiting; 73 float grenze2 = frame.left+(frame.right-frame.left)*(fBusyWaiting+fLost); 74 if (grenze1 > frame.right) 75 grenze1 = frame.right; 76 if (grenze2 > frame.right) 77 grenze2 = frame.right; 78 r.right = grenze1; 79 if (!force) 80 r.left = fGrenze1; 81 if (r.left < r.right) { 82 if (selected) 83 menu->SetHighColor(tint_color (kGreen, B_HIGHLIGHT_BACKGROUND_TINT)); 84 else 85 menu->SetHighColor(kGreen); 86 // menu->SetHighColor(gKernelColor); 87 menu->FillRect(r); 88 } 89 r.left = grenze1; 90 r.right = grenze2; 91 if (!force) { 92 if (fGrenze2 > r.left && r.left >= fGrenze1) 93 r.left = fGrenze2; 94 if (fGrenze1 < r.right && r.right <= fGrenze2) 95 r.right = fGrenze1; 96 } 97 if (r.left < r.right) { 98 menu->SetHighColor(kBlack); 99 // menu->SetHighColor(gUserColor); 100 menu->FillRect(r); 101 } 102 r.left = grenze2; 103 r.right = frame.right; 104 if (!force) 105 r.right = fGrenze2; 106 if (r.left < r.right) { 107 if (selected) 108 menu->SetHighColor(gWhiteSelected); 109 else 110 menu->SetHighColor(kWhite); 111 menu->FillRect(r); 112 } 113 menu->SetHighColor(kBlack); 114 fGrenze1 = grenze1; 115 fGrenze2 = grenze2; 116 } 117 118 119 void 120 NoiseBarMenuItem::GetContentSize(float* width, float* height) 121 { 122 BMenuItem::GetContentSize(width, height); 123 if (*height < 16) 124 *height = 16; 125 *width += 20 + kBarWidth; 126 } 127