lib
KoComplexText.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QCOMPLEXTEXT_H
00039 #define QCOMPLEXTEXT_H
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef QT_H
00054 #include <qstring.h>
00055 #include <qpointarray.h>
00056 #include <qfont.h>
00057 #include <qpainter.h>
00058 #include <qptrlist.h>
00059 #include <qshared.h>
00060 #endif // QT_H
00061
00062 #ifndef QT_NO_COMPLEXTEXT
00063
00064
00065 struct Q_EXPORT KoBidiStatus {
00066 KoBidiStatus() {
00067 eor = QChar::DirON;
00068 lastStrong = QChar::DirON;
00069 last = QChar:: DirON;
00070 }
00071 QChar::Direction eor;
00072 QChar::Direction lastStrong;
00073 QChar::Direction last;
00074 };
00075
00076 struct Q_EXPORT KoBidiContext : public QShared {
00077
00078 KoBidiContext( uchar level, QChar::Direction embedding, KoBidiContext *parent = 0, bool override = FALSE );
00079 ~KoBidiContext();
00080
00081 unsigned char level;
00082 bool override : 1;
00083 QChar::Direction dir : 5;
00084
00085 KoBidiContext *parent;
00086 };
00087
00088 struct Q_EXPORT KoBidiControl {
00089 KoBidiControl() { context = 0; }
00090 KoBidiControl( KoBidiContext *c, KoBidiStatus s)
00091 { context = c; if( context ) context->ref(); status = s; }
00092 ~KoBidiControl() { if ( context && context->deref() ) delete context; }
00093 void setContext( KoBidiContext *c ) { if ( context == c ) return; if ( context && context->deref() ) delete context; context = c; context->ref(); }
00094 KoBidiContext *context;
00095 KoBidiStatus status;
00096 };
00097
00098 struct Q_EXPORT KoTextRun {
00099 KoTextRun(int _start, int _stop, KoBidiContext *context, QChar::Direction dir);
00100
00101 int start;
00102 int stop;
00103
00104 uchar level;
00105 };
00106
00107 class Q_EXPORT KoComplexText {
00108 public:
00109 enum Shape {
00110 XIsolated,
00111 XFinal,
00112 XInitial,
00113 XMedial
00114 };
00115 static Shape glyphVariant( const QString &str, int pos);
00116 static Shape glyphVariantLogical( const QString &str, int pos);
00117
00118 static QString shapedString( const QString &str, int from = 0, int len = -1, QPainter::TextDirection dir = QPainter::Auto, const QFontMetrics *fm = 0);
00119 static QChar shapedCharacter(const QString &str, int pos, const QFontMetrics *fm = 0);
00120
00121
00122
00123
00124 static QPtrList<KoTextRun> *bidiReorderLine( KoBidiControl *control, const QString &str, int start, int len,
00125 QChar::Direction basicDir = QChar::DirON );
00126 static QString bidiReorderString( const QString &str, QChar::Direction basicDir = QChar::DirON );
00127 };
00128
00129 #endif //QT_NO_COMPLEXTEXT
00130
00131 #endif
|