Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qtextlayout_p.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** ??? 00005 ** 00006 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00007 ** 00008 ** This file is part of the kernel module of the Qt GUI Toolkit. 00009 ** 00010 ** This file may be distributed and/or modified under the terms of the 00011 ** GNU General Public License version 2 as published by the Free Software 00012 ** Foundation and appearing in the file LICENSE.GPL included in the 00013 ** packaging of this file. 00014 ** 00015 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00016 ** licenses for Qt/Embedded may use this file in accordance with the 00017 ** Qt Embedded Commercial License Agreement provided with the Software. 00018 ** 00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00021 ** 00022 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00023 ** information about Qt Commercial License Agreements. 00024 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00025 ** 00026 ** Contact info@trolltech.com if any conditions of this licensing are 00027 ** not clear to you. 00028 ** 00029 **********************************************************************/ 00030 00031 #ifndef QTEXTLAYOUT_P_H 00032 #define QTEXTLAYOUT_P_H 00033 00034 #ifndef QT_H 00035 #include "qstring.h" 00036 #include "qnamespace.h" 00037 #include "qrect.h" 00038 #endif // QT_H 00039 00040 class QTextEngine; 00041 class QFont; 00042 00043 class Q_EXPORT QTextItem 00044 { 00045 public: 00046 inline QTextItem() : item(0), engine(0) {} 00047 inline bool isValid() const { return (bool)engine; } 00048 00049 QRect rect() const; 00050 int x() const; 00051 int y() const; 00052 int width() const; 00053 int ascent() const; 00054 int descent() const; 00055 00056 enum Edge { 00057 Leading, 00058 Trailing 00059 }; 00060 enum CursorPosition { 00061 BetweenCharacters, 00062 OnCharacters 00063 }; 00064 00065 /* cPos gets set to the valid position */ 00066 int cursorToX( int *cPos, Edge edge = Leading ) const; 00067 inline int cursorToX( int cPos, Edge edge = Leading ) const { return cursorToX( &cPos, edge ); } 00068 int xToCursor( int x, CursorPosition = BetweenCharacters ) const; 00069 00070 bool isRightToLeft() const; 00071 bool isObject() const; 00072 bool isSpace() const; 00073 bool isTab() const; 00074 00075 void setWidth( int w ); 00076 void setAscent( int a ); 00077 void setDescent( int d ); 00078 00079 int from() const; 00080 int length() const; 00081 00082 private: 00083 friend class QTextLayout; 00084 friend class QPainter; 00085 friend class QPSPrinter; 00086 friend class FLPosPrinter; 00087 QTextItem( int i, QTextEngine *e ) : item( i ), engine( e ) {} 00088 int item; 00089 QTextEngine *engine; 00090 }; 00091 00092 00093 class QPainter; 00094 00095 class Q_EXPORT QTextLayout 00096 { 00097 public: 00098 // does itemization 00099 QTextLayout(); 00100 QTextLayout( const QString& string, QPainter * = 0 ); 00101 QTextLayout( const QString& string, const QFont& fnt ); 00102 ~QTextLayout(); 00103 00104 void setText( const QString& string, const QFont& fnt ); 00105 00106 enum LineBreakStrategy { 00107 AtWordBoundaries, 00108 AtCharBoundaries 00109 }; 00110 00111 /* add an additional item boundary eg. for style change */ 00112 void setBoundary( int strPos ); 00113 00114 int numItems() const; 00115 QTextItem itemAt( int i ) const; 00116 QTextItem findItem( int strPos ) const; 00117 00118 enum LayoutMode { 00119 NoBidi, 00120 SingleLine, 00121 MultiLine 00122 }; 00123 void beginLayout( LayoutMode m = MultiLine ); 00124 void beginLine( int width ); 00125 00126 bool atEnd() const; 00127 QTextItem nextItem(); 00128 QTextItem currentItem(); 00129 /* ## maybe also currentItem() */ 00130 void setLineWidth( int newWidth ); 00131 int lineWidth() const; 00132 int widthUsed() const; 00133 int availableWidth() const; 00134 00135 enum Result { 00136 Ok, 00137 LineFull, 00138 LineEmpty, 00139 Error 00140 }; 00141 /* returns true if completely added */ 00142 Result addCurrentItem(); 00143 00144 /* Note: if ascent and descent are used they must be initialized to the minimum ascent/descent 00145 acceptable for the line. QFontMetrics::ascent/descent() is usually the right choice */ 00146 Result endLine( int x = 0, int y = 0, int alignment = Qt::AlignLeft, 00147 int *ascent = 0, int *descent = 0, int *left = 0, int *right = 0 ); 00148 void endLayout(); 00149 00150 enum CursorMode { 00151 SkipCharacters, 00152 SkipWords 00153 }; 00154 bool validCursorPosition( int pos ) const; 00155 int nextCursorPosition( int oldPos, CursorMode mode = SkipCharacters ) const; 00156 int previousCursorPosition( int oldPos, CursorMode mode = SkipCharacters ) const; 00157 00158 void setDirection(QChar::Direction); 00159 private: 00160 QTextLayout( QTextEngine *e ) : d( e ) {} 00161 /* disable copy and assignment */ 00162 QTextLayout( const QTextLayout & ) {} 00163 void operator = ( const QTextLayout & ) {} 00164 00165 friend class QTextItem; 00166 friend class QPainter; 00167 friend class QPSPrinter; 00168 QTextEngine *d; 00169 }; 00170 00171 00172 /* 00173 class QPainter { 00174 ..... 00175 void drawTextItem( int x, int y, QTextItem *item ); 00176 }; 00177 */ 00178 00179 #endif