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: StringView.h 23 // Author: Frans van Nispen (xlr8@tref.nl) 24 // Description: BStringView draw a non-editable text string 25 //------------------------------------------------------------------------------ 26 27 #ifndef _STRING_VIEW_H 28 #define _STRING_VIEW_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 // BStringView class ----------------------------------------------------------- 46 class BStringView : public BView{ 47 public: 48 BStringView(BRect bounds, const char* name, const char* text, 49 uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, 50 uint32 flags = B_WILL_DRAW); 51 BStringView(BMessage* data); 52 virtual ~BStringView(); 53 static BArchivable *Instantiate(BMessage* data); 54 virtual status_t Archive(BMessage* data, bool deep = true) const; 55 56 void SetText(const char* text); 57 const char *Text() const; 58 void SetAlignment(alignment flag); 59 alignment Alignment() const; 60 61 virtual void AttachedToWindow(); 62 virtual void Draw(BRect bounds); 63 64 virtual void MessageReceived(BMessage* msg); 65 virtual void MouseDown(BPoint pt); 66 virtual void MouseUp(BPoint pt); 67 virtual void MouseMoved(BPoint pt, uint32 code, const BMessage* msg); 68 virtual void DetachedFromWindow(); 69 virtual void FrameMoved(BPoint new_position); 70 virtual void FrameResized(float new_width, float new_height); 71 72 virtual BHandler *ResolveSpecifier( BMessage* msg, int32 index, BMessage* specifier, 73 int32 form, const char* property); 74 75 virtual void ResizeToPreferred(); 76 virtual void GetPreferredSize(float* width, float* height); 77 virtual void MakeFocus(bool state = true); 78 virtual void AllAttached(); 79 virtual void AllDetached(); 80 virtual status_t GetSupportedSuites(BMessage* data); 81 82 83 // Private or reserved --------------------------------------------------------- 84 virtual status_t Perform(perform_code d, void* arg); 85 86 private: 87 virtual void _ReservedStringView1(); 88 virtual void _ReservedStringView2(); 89 virtual void _ReservedStringView3(); 90 91 BStringView &operator=(const BStringView&); 92 93 char* fText; 94 alignment fAlign; 95 uint32 _reserved[3]; 96 }; 97 //------------------------------------------------------------------------------ 98 99 #endif // _STRINGVIEW_H 100 101 /* 102 * $Log $ 103 * 104 * $Id $ 105 * 106 */ 107 108