summaryrefslogtreecommitdiffstats
path: root/lib/kotext/KoComplexText.h
blob: 8a22d152b93b6048d9e2ed235e21b26f05164721 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/****************************************************************************
** $Id: KoComplexText.h 484817 2005-12-02 00:53:59Z dfaure $
**
** Internal header file.
**
** Created :
**
** Copyright (C) 2001 Trolltech AS.  All rights reserved.
**
** This file is part of the kernel module of the TQt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.TQPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
** licenses may use this file in accordance with the TQt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about TQt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef TQCOMPLEXTEXT_H
#define TQCOMPLEXTEXT_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the TQt API.  It exists for the convenience
// of TQt Remote Control. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
//

#ifndef TQT_H
#include <tqstring.h>
#include <tqpointarray.h>
#include <tqfont.h>
#include <tqpainter.h>
#include <tqptrlist.h>
#include <tqshared.h>
#endif // TQT_H

#ifndef TQT_NO_COMPLEXTEXT

// bidi helper classes. Internal to TQt
struct TQ_EXPORT KoBidiStatus {
    KoBidiStatus() {
	eor = TQChar::DirON;
	lastStrong = TQChar::DirON;
	last = TQChar:: DirON;
    }
    TQChar::Direction eor;
    TQChar::Direction lastStrong;
    TQChar::Direction last;
};

struct TQ_EXPORT KoBidiContext : public TQShared {
    // ### ref and deref parent?
    KoBidiContext( uchar level, TQChar::Direction embedding, KoBidiContext *parent = 0, bool override = FALSE );
    ~KoBidiContext();

    unsigned char level;
    bool override : 1;
    TQChar::Direction dir : 5;

    KoBidiContext *parent;
};

struct TQ_EXPORT KoBidiControl {
    KoBidiControl() { context = 0; }
    KoBidiControl( KoBidiContext *c, KoBidiStatus s)
    { context = c; if( context ) context->ref(); status = s; }
    ~KoBidiControl() { if ( context && context->deref() ) delete context; }
    void setContext( KoBidiContext *c ) { if ( context == c ) return; if ( context && context->deref() ) delete context; context = c; context->ref(); }
    KoBidiContext *context;
    KoBidiStatus status;
};

struct TQ_EXPORT KoTextRun {
    KoTextRun(int _start, int _stop, KoBidiContext *context, TQChar::Direction dir);

    int start;
    int stop;
    // explicit + implicit levels here
    uchar level;
};

class TQ_EXPORT KoComplexText {
public:
    enum Shape {
	XIsolated,
	XFinal,
	XInitial,
	XMedial
    };
    static Shape glyphVariant( const TQString &str, int pos);
    static Shape glyphVariantLogical( const TQString &str, int pos);

    static TQString shapedString( const TQString &str, int from = 0, int len = -1, TQPainter::TextDirection dir = TQPainter::Auto, const TQFontMetrics *fm = 0);
    static TQChar shapedCharacter(const TQString &str, int pos, const TQFontMetrics *fm = 0);

    // positions non spacing marks relative to the base character at position pos.
    //static TQPointArray positionMarks( TQFontPrivate *f, const TQString &str, int pos, TQRect *boundingRect = 0 );

    static TQPtrList<KoTextRun> *bidiReorderLine( KoBidiControl *control, const TQString &str, int start, int len,
						TQChar::Direction basicDir = TQChar::DirON );
    static TQString bidiReorderString( const TQString &str, TQChar::Direction basicDir = TQChar::DirON );
};

#endif //TQT_NO_COMPLEXTEXT

#endif