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: Box.h 23 // Author: Marc Flerackers (mflerackers@androme.be) 24 // Description: BBox objects group views together and draw a border 25 // around them. 26 //------------------------------------------------------------------------------ 27 28 #ifndef _BOX_H 29 #define _BOX_H 30 31 // Standard Includes ----------------------------------------------------------- 32 33 // System Includes ------------------------------------------------------------- 34 #include <BeBuild.h> 35 #include <View.h> 36 37 // Project Includes ------------------------------------------------------------ 38 39 // Local Includes -------------------------------------------------------------- 40 41 // Local Defines --------------------------------------------------------------- 42 43 // Globals --------------------------------------------------------------------- 44 45 46 // BBox class ------------------------------------------------------------------ 47 class BBox : public BView { 48 49 public: 50 BBox(BRect frame, 51 const char *name = NULL, 52 uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, 53 uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | 54 B_NAVIGABLE_JUMP, 55 border_style border = B_FANCY_BORDER); 56 virtual ~BBox(); 57 58 /* Archiving */ 59 BBox(BMessage *archive); 60 static BArchivable *Instantiate(BMessage *archive); 61 virtual status_t Archive(BMessage *archive, bool deep = true) const; 62 63 virtual void SetBorder(border_style border); 64 border_style Border() const; 65 66 void SetLabel(const char *string); 67 status_t SetLabel(BView *viewLabel); 68 69 const char *Label() const; 70 BView *LabelView() const; 71 72 virtual void Draw(BRect updateRect); 73 virtual void AttachedToWindow(); 74 virtual void DetachedFromWindow(); 75 virtual void AllAttached(); 76 virtual void AllDetached(); 77 virtual void FrameResized(float width, float height); 78 virtual void MessageReceived(BMessage *message); 79 virtual void MouseDown(BPoint point); 80 virtual void MouseUp(BPoint point); 81 virtual void WindowActivated(bool active); 82 virtual void MouseMoved(BPoint point, uint32 transit, 83 const BMessage *message); 84 virtual void FrameMoved(BPoint newLocation); 85 86 virtual BHandler *ResolveSpecifier(BMessage *message, 87 int32 index, 88 BMessage *specifier, 89 int32 what, 90 const char *property); 91 92 virtual void ResizeToPreferred(); 93 virtual void GetPreferredSize(float *width, float *height); 94 virtual void MakeFocus(bool focused = true); 95 virtual status_t GetSupportedSuites(BMessage *message); 96 97 virtual status_t Perform(perform_code d, void *arg); 98 99 private: 100 101 virtual void _ReservedBox1(); 102 virtual void _ReservedBox2(); 103 104 BBox &operator=(const BBox &); 105 106 void InitObject(BMessage *data = NULL); 107 void DrawPlain(); 108 void DrawFancy(); 109 void ClearAnyLabel(); 110 111 char *fLabel; 112 BRect fBounds; 113 border_style fStyle; 114 BView *fLabelView; 115 uint32 _reserved[1]; 116 }; 117 //------------------------------------------------------------------------------ 118 119 #endif // _BOX_H 120 121 /* 122 * $Log $ 123 * 124 * $Id $ 125 * 126 */ 127