Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BText.h

Go to the documentation of this file.
00001 // BText.h (this is -*- C++ -*-)
00002 // 
00003 // \author: Bjoern Giesler <bjoern@giesler.de>
00004 // 
00005 // 
00006 // 
00007 // $Author: giesler $
00008 // $Locker$
00009 // $Revision$
00010 // $Date: 2002-08-19 10:41:28 +0200 (Mon, 19 Aug 2002) $
00011 
00012 #ifndef BTEXT_H
00013 #define BTEXT_H
00014 
00015 /* system includes */
00016 /* (none) */
00017 
00018 /* my includes */
00019 #include "BWidget.h"
00020 #include "BScrollable.h"
00021 
00022 class BText: public BScrollable {
00023 public:
00024   BText(BWidget* parent, const BRect& frame);
00025   ~BText();
00026 
00027   void setFirstLineColor(uint16 color) {
00028     _firstlinecolor = color;
00029     _firstlinecolorset = true;
00030     setNeedsRedraw(true);
00031   }
00032   void resetFirstLineColor() {
00033     _firstlinecolorset = false;
00034     setNeedsRedraw(true);
00035   }
00036   
00038   void setTextDirection(BWidget::TextDirection dir) {}
00039 
00040   void setText(const std::string& text);
00041   bool full() { return _full; }
00042   int indexOfLastCharacterOnScreen();
00043 
00044   void setStripSingleNewlines(bool stripSingleNL);
00045   bool stripSingleNewlines() { return _stripSingleNL; }
00046 
00047   virtual void setFont(BFont* font);
00048 
00049   virtual void draw(BImage& img);
00050 
00051   void clear();
00052 
00053   void setSlaveText(BText* slave);
00054   BText *slaveText() { return _slave; }
00055 
00056   virtual void updateScroller(BScroller *scroller);
00057   virtual void scrollToPosition(BScroller *scroller,
00058                                 unsigned int position);
00059   
00060   class Line {
00061   public:
00062     virtual ~Line() {}
00063     unsigned int index, length;
00064     int spacingBefore;
00065     int leftIndent, rightIndent;
00066     int height;
00067     uint16 color;
00068     BWidget::TextAlignment align;
00069 
00070     virtual void draw(BText* text, BImage& img, const BRect& clip, BPoint& pt,
00071                       uint16 color = RGB15(0, 0, 0)|BIT(15)) = 0;
00072   };
00073 
00074   class StringLine: public Line {
00075   public:
00076     std::string line;
00077     virtual void draw(BText* text, BImage& img, const BRect& clip, BPoint& pt,
00078                       uint16 color = RGB15(0, 0, 0)|BIT(15));
00079   };
00080 
00081 protected:
00082   void rewrap(unsigned int index, unsigned int length);
00083 
00084   std::string _text;
00085   bool _full;
00086 
00087   uint16 _firstlinecolor;
00088   bool _firstlinecolorset;
00089 
00090   bool _stripSingleNL;
00091 
00092   std::vector<Line*> _lines;
00093   int _firstline;
00094   BText* _slave;
00095 };
00096 
00097 #endif /* BTEXT_H */

Generated on Sat Dec 29 09:59:23 2007 for DSGUI by doxygen1.3-rc3