lib

KoComplexText.h
1/****************************************************************************
2** $Id: KoComplexText.h 484817 2005-12-02 00:53:59Z dfaure $
3**
4** Internal header file.
5**
6** Created :
7**
8** Copyright (C) 2001 Trolltech AS. All rights reserved.
9**
10** This file is part of the kernel module of the TQt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.TQPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
22** licenses may use this file in accordance with the TQt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about TQt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for TQPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef TQCOMPLEXTEXT_H
39#define TQCOMPLEXTEXT_H
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the TQt API. It exists for the convenience
46// of TQt Remote Control. This header file may change from version to
47// version without notice, or even be removed.
48//
49// We mean it.
50//
51//
52
53#ifndef TQT_H
54#include <tqstring.h>
55#include <tqpointarray.h>
56#include <tqfont.h>
57#include <tqpainter.h>
58#include <tqptrlist.h>
59#include <tqshared.h>
60#endif // TQT_H
61
62#ifndef TQT_NO_COMPLEXTEXT
63
64// bidi helper classes. Internal to TQt
65struct TQ_EXPORT KoBidiStatus {
66 KoBidiStatus() {
67 eor = TQChar::DirON;
68 lastStrong = TQChar::DirON;
69 last = TQChar:: DirON;
70 }
71 TQChar::Direction eor;
72 TQChar::Direction lastStrong;
73 TQChar::Direction last;
74};
75
76struct TQ_EXPORT KoBidiContext : public TQShared {
77 // ### ref and deref parent?
78 KoBidiContext( uchar level, TQChar::Direction embedding, KoBidiContext *parent = 0, bool override = false );
79 ~KoBidiContext();
80
81 unsigned char level;
82 bool override : 1;
83 TQChar::Direction dir : 5;
84
85 KoBidiContext *parent;
86};
87
88struct TQ_EXPORT KoBidiControl {
89 KoBidiControl() { context = 0; }
90 KoBidiControl( KoBidiContext *c, KoBidiStatus s)
91 { context = c; if( context ) context->ref(); status = s; }
92 ~KoBidiControl() { if ( context && context->deref() ) delete context; }
93 void setContext( KoBidiContext *c ) { if ( context == c ) return; if ( context && context->deref() ) delete context; context = c; context->ref(); }
94 KoBidiContext *context;
95 KoBidiStatus status;
96};
97
98struct TQ_EXPORT KoTextRun {
99 KoTextRun(int _start, int _stop, KoBidiContext *context, TQChar::Direction dir);
100
101 int start;
102 int stop;
103 // explicit + implicit levels here
104 uchar level;
105};
106
107class TQ_EXPORT KoComplexText {
108public:
109 enum Shape {
110 XIsolated,
111 XFinal,
112 XInitial,
113 XMedial
114 };
115 static Shape glyphVariant( const TQString &str, int pos);
116 static Shape glyphVariantLogical( const TQString &str, int pos);
117
118 static TQString shapedString( const TQString &str, int from = 0, int len = -1, TQPainter::TextDirection dir = TQPainter::Auto, const TQFontMetrics *fm = 0);
119 static TQChar shapedCharacter(const TQString &str, int pos, const TQFontMetrics *fm = 0);
120
121 // positions non spacing marks relative to the base character at position pos.
122 //static TQPointArray positionMarks( TQFontPrivate *f, const TQString &str, int pos, TQRect *boundingRect = 0 );
123
124 static TQPtrList<KoTextRun> *bidiReorderLine( KoBidiControl *control, const TQString &str, int start, int len,
125 TQChar::Direction basicDir = TQChar::DirON );
126 static TQString bidiReorderString( const TQString &str, TQChar::Direction basicDir = TQChar::DirON );
127};
128
129#endif //TQT_NO_COMPLEXTEXT
130
131#endif