kwordwrap.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001 David Faure <david@mandrakesoft.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef kwordwrap_h 00020 #define kwordwrap_h 00021 00022 #include <tqfontmetrics.h> 00023 #include <tqvaluelist.h> 00024 #include <tqrect.h> 00025 #include <tqstring.h> 00026 00027 #include <tdelibs_export.h> 00028 00048 class TDEUI_EXPORT KWordWrap 00049 { 00050 public: 00056 enum { FadeOut = 0x10000000, Truncate = 0x20000000 }; 00057 00069 static KWordWrap* formatText( TQFontMetrics &fm, const TQRect & r, int flags, const TQString & str, int len = -1 ); 00070 00077 TQRect boundingRect() const { return m_boundingRect; } 00078 00083 TQString wrappedString() const; // gift for Dirk :) 00084 00090 TQString truncatedString( bool dots = true ) const; 00091 00104 void drawText( TQPainter *painter, int x, int y, int flags = TQt::AlignAuto ) const; 00105 00109 ~KWordWrap(); 00110 00123 static void drawFadeoutText( TQPainter *p, int x, int y, int maxW, 00124 const TQString &t ); 00125 00136 static void drawTruncateText( TQPainter *p, int x, int y, int maxW, 00137 const TQString &t ); 00138 00139 private: 00140 KWordWrap( const TQRect & r ); 00141 TQValueList<int> m_breakPositions; 00142 TQValueList<int> m_lineWidths; 00143 TQRect m_boundingRect; 00144 TQString m_text; 00145 private: 00146 class KWordWrapPrivate* d; 00147 }; 00148 00149 #endif