1 /* 2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef TEXT_VIEW_H 6 #define TEXT_VIEW_H 7 8 #include <String.h> 9 #include <View.h> 10 11 #include "Paragraph.h" 12 #include "ParagraphLayout.h" 13 14 15 class TextView : public BView { 16 public: 17 TextView(const char* name = NULL); 18 virtual ~TextView(); 19 20 virtual void Draw(BRect updateRect); 21 22 virtual void AttachedToWindow(); 23 virtual void FrameResized(float width, float height); 24 25 virtual BSize MinSize(); 26 virtual BSize MaxSize(); 27 virtual BSize PreferredSize(); 28 29 virtual bool HasHeightForWidth(); 30 virtual void GetHeightForWidth(float width, float* min, 31 float* max, float* preferred); 32 33 void SetText(const BString& text); 34 void SetParagraphStyle(const ::ParagraphStyle& style); 35 const ::ParagraphStyle& ParagraphStyle() const 36 { return fText.Style(); } 37 38 private: 39 Paragraph fText; 40 ParagraphLayout fTextLayout; 41 }; 42 43 #endif // TEXT_VIEW_H 44