1 /* 2 * Copyright 2001-2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _STRING_VIEW_H 6 #define _STRING_VIEW_H 7 8 9 #include <View.h> 10 11 12 class BStringView : public BView { 13 public: 14 BStringView(BRect bounds, const char* name, 15 const char* text, uint32 resizeFlags 16 = B_FOLLOW_LEFT | B_FOLLOW_TOP, 17 uint32 flags = B_WILL_DRAW); 18 BStringView(const char* name, const char* text, 19 uint32 flags = B_WILL_DRAW); 20 BStringView(BMessage* archive); 21 virtual ~BStringView(); 22 23 static BArchivable* Instantiate(BMessage* archive); 24 virtual status_t Archive(BMessage* archive, 25 bool deep = true) const; 26 27 void SetText(const char* text); 28 const char* Text() const; 29 void SetAlignment(alignment flag); 30 alignment Alignment() const; 31 32 virtual void AttachedToWindow(); 33 virtual void DetachedFromWindow(); 34 virtual void AllAttached(); 35 virtual void AllDetached(); 36 37 virtual void MakeFocus(bool state = true); 38 39 virtual void GetPreferredSize(float* _width, 40 float* _height); 41 virtual BSize MinSize(); 42 virtual BSize MaxSize(); 43 virtual BSize PreferredSize(); 44 virtual void ResizeToPreferred(); 45 virtual BAlignment LayoutAlignment(); 46 virtual void FrameMoved(BPoint newPosition); 47 virtual void FrameResized(float newWidth, float newHeight); 48 49 virtual void Draw(BRect bounds); 50 51 virtual void MessageReceived(BMessage* message); 52 virtual void MouseDown(BPoint point); 53 virtual void MouseUp(BPoint point); 54 virtual void MouseMoved(BPoint point, uint32 transit, 55 const BMessage* dragMessage); 56 57 virtual BHandler* ResolveSpecifier(BMessage* message, 58 int32 index, BMessage* specifier, 59 int32 form, const char* property); 60 virtual status_t GetSupportedSuites(BMessage* data); 61 62 virtual void SetFont(const BFont* font, 63 uint32 mask = B_FONT_ALL); 64 65 protected: 66 virtual void LayoutInvalidated(bool descendants = false); 67 68 private: 69 // FBC padding and forbidden methods 70 virtual status_t Perform(perform_code code, void* data); 71 72 virtual void _ReservedStringView1(); 73 virtual void _ReservedStringView2(); 74 virtual void _ReservedStringView3(); 75 76 BStringView& operator=(const BStringView& other); 77 78 private: 79 BSize _ValidatePreferredSize(); 80 81 private: 82 char* fText; 83 float fStringWidth; 84 alignment fAlign; 85 BSize fPreferredSize; 86 }; 87 88 #endif // _STRING_VIEW_H 89