1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: StatusBar.h 23 // Author: Marc Flerackers (mflerackers@androme.be) 24 // Description: BStatusBar displays a "percentage-of-completion" gauge. 25 //------------------------------------------------------------------------------ 26 27 #ifndef _STATUS_BAR_H 28 #define _STATUS_BAR_H 29 30 // Standard Includes ----------------------------------------------------------- 31 32 // System Includes ------------------------------------------------------------- 33 #include <BeBuild.h> 34 #include <View.h> 35 36 // Project Includes ------------------------------------------------------------ 37 38 // Local Includes -------------------------------------------------------------- 39 40 // Local Defines --------------------------------------------------------------- 41 42 // Globals --------------------------------------------------------------------- 43 44 45 // BStatusBar class ------------------------------------------------------------ 46 class BStatusBar : public BView 47 { 48 public: 49 BStatusBar(BRect frame, const char *name, const char *label = NULL, 50 const char *trailingLabel = NULL); 51 BStatusBar(BMessage *archive); 52 53 virtual ~BStatusBar(); 54 55 static BArchivable *Instantiate(BMessage *archive); 56 virtual status_t Archive(BMessage *archive, bool deep = true) const; 57 58 virtual void AttachedToWindow(); 59 virtual void MessageReceived(BMessage *message); 60 virtual void Draw(BRect updateRect); 61 62 virtual void SetBarColor(rgb_color color); 63 virtual void SetBarHeight(float height); 64 virtual void SetText(const char *string); 65 virtual void SetTrailingText(const char *string); 66 virtual void SetMaxValue(float max); 67 68 void Update(float delta, const char *text = NULL, const char *trailingText = NULL); 69 virtual void Reset(const char *label = NULL, const char *trailingLabel = NULL); 70 71 float CurrentValue() const; 72 float MaxValue() const; 73 rgb_color BarColor() const; 74 float BarHeight() const; 75 const char *Text() const; 76 const char *TrailingText() const; 77 const char *Label() const; 78 const char *TrailingLabel() const; 79 80 virtual void MouseDown(BPoint point); 81 virtual void MouseUp(BPoint point); 82 virtual void WindowActivated(bool state); 83 virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); 84 virtual void DetachedFromWindow(); 85 virtual void FrameMoved(BPoint new_position); 86 virtual void FrameResized(float new_width, float new_height); 87 88 virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier, 89 int32 what, const char *property); 90 91 virtual void ResizeToPreferred(); 92 virtual void GetPreferredSize(float *width, float *height); 93 virtual void MakeFocus(bool state = true); 94 virtual void AllAttached(); 95 virtual void AllDetached(); 96 virtual status_t GetSupportedSuites(BMessage *data); 97 98 virtual status_t Perform(perform_code d, void *arg); 99 100 private: 101 virtual void _ReservedStatusBar1(); 102 virtual void _ReservedStatusBar2(); 103 virtual void _ReservedStatusBar3(); 104 virtual void _ReservedStatusBar4(); 105 106 BStatusBar &operator=(const BStatusBar &); 107 108 void InitObject(const char *l, const char *aux_l); 109 void SetTextData(char **pp, const char *str); 110 void FillBar(BRect r); 111 void Resize(); 112 void _Draw(BRect updateRect, bool bar_only); 113 114 char *fLabel; 115 char *fTrailingLabel; 116 char *fText; 117 char *fTrailingText; 118 float fMax; 119 float fCurrent; 120 float fBarHeight; 121 float fTrailingWidth; 122 rgb_color fBarColor; 123 float fEraseText; 124 float fEraseTrailingText; 125 bool fCustomBarHeight; 126 bool _pad1; 127 bool _pad2; 128 bool _pad3; 129 uint32 _reserved[3]; 130 }; 131 132 //------------------------------------------------------------------------------ 133 134 #endif // _STATUS_BAR_H 135 136 /* 137 * $Log $ 138 * 139 * $Id $ 140 * 141 */ 142