summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpenchar.h
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpenchar.h') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenchar.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/inputmethods/handwriting/qimpenchar.h b/inputmethods/handwriting/qimpenchar.h
new file mode 100644
index 0000000..9a5f687
--- a/dev/null
+++ b/inputmethods/handwriting/qimpenchar.h
@@ -0,0 +1,157 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef QIMPENCHAR_H_
22#define QIMPENCHAR_H_
23
24#include <qlist.h>
25#include <qvaluelist.h>
26#include <qcstring.h>
27#include "qimpenstroke.h"
28
29struct QIMPenSpecialKeys {
30 int code;
31 char *name;
32};
33
34extern const QIMPenSpecialKeys qimpen_specialKeys[];
35
36
37class QIMPenChar
38{
39public:
40 QIMPenChar();
41 QIMPenChar( const QIMPenChar & );
42
43 unsigned int character() const { return ch; }
44 void setCharacter( unsigned int c ) { ch = c; }
45
46 const QString &data() const { return d; }
47 void setData( const QString &ba ) { d = ba; }
48
49 QString name() const;
50 bool isEmpty() const { return strokes.isEmpty(); }
51 unsigned int strokeCount() const { return strokes.count(); }
52 unsigned int strokeLength( int s ) const;
53 void clear();
54 int match( QIMPenChar *ch );
55 const QIMPenStrokeList &penStrokes() { return strokes; }
56 QPoint startingPoint() const { return strokes.getFirst()->startingPoint(); }
57 QRect boundingRect();
58
59 void setFlag( int f ) { flags |= f; }
60 void clearFlag( int f ) { flags &= ~f; }
61 bool testFlag( int f ) { return flags & f; }
62
63 enum Flags { System=0x01, Deleted=0x02, CombineRight=0x04, Data=0x08 };
64 // Correspond to codes in template files. Do not change values.
65 enum Mode { ModeBase=0x4000, Caps=0x4001, Shortcut=0x4002, CapsLock=0x4003,
66 Punctuation=0x4004, Symbol=0x4005, Extended=0x4006 };
67
68 QIMPenChar &operator=( const QIMPenChar &s );
69
70 void addStroke( QIMPenStroke * );
71
72protected:
73 unsigned int ch;
74 QString d;
75 Q_UINT8 flags;
76 QIMPenStrokeList strokes;
77
78 friend QDataStream &operator<< (QDataStream &, const QIMPenChar &);
79 friend QDataStream &operator>> (QDataStream &, QIMPenChar &);
80};
81
82typedef QList<QIMPenChar> QIMPenCharList;
83typedef QListIterator<QIMPenChar> QIMPenCharIterator;
84
85QDataStream & operator<< (QDataStream & s, const QIMPenChar &ws);
86QDataStream & operator>> (QDataStream & s, QIMPenChar &ws);
87
88struct QIMPenCharMatch
89{
90 int error;
91 QIMPenChar *penChar;
92
93 bool operator>( const QIMPenCharMatch &m );
94 bool operator<( const QIMPenCharMatch &m );
95 bool operator<=( const QIMPenCharMatch &m );
96};
97
98typedef QValueList<QIMPenCharMatch> QIMPenCharMatchList;
99
100
101class QIMPenCharSet
102{
103public:
104 QIMPenCharSet();
105 QIMPenCharSet( const QString &fn );
106
107 bool isEmpty() const { return chars.isEmpty(); }
108 unsigned int count() const { return chars.count(); }
109 void clear() { chars.clear(); }
110
111 void setDescription( const QString &d ) { desc = d; }
112 QString description() const { return desc; }
113 void setTitle( const QString &t ) { csTitle = t; }
114 QString title() const { return csTitle; }
115
116 QIMPenCharMatchList match( QIMPenChar *ch );
117 void addChar( QIMPenChar *ch );
118 void removeChar( QIMPenChar *ch );
119 QIMPenChar *at( int i );
120
121 unsigned maximumStrokes() const { return maxStrokes; }
122
123 void up( QIMPenChar *ch );
124 void down( QIMPenChar *ch );
125
126 enum Domain { System, User };
127 enum Type { Unknown=0x00, Lower=0x01, Upper=0x02, Combining=0x04,
128 Numeric=0x08, Punctuation=0x10, Symbol=0x20, Shortcut=0x40 };
129
130 const QIMPenCharList &characters() const { return chars; }
131
132 void setType( Type t ) { csType = t; }
133 Type type() const { return csType; }
134
135 const QString &filename( Domain d ) const;
136 void setFilename( const QString &fn, Domain d=System );
137 bool load( const QString &fn, Domain d=System );
138 bool save( Domain d=System );
139
140protected:
141 void markDeleted( uint ch );
142
143protected:
144 QString csTitle;
145 QString desc;
146 QString sysFilename;
147 QString userFilename;
148 Type csType;
149 unsigned maxStrokes;
150 QIMPenCharList chars;
151 QIMPenCharMatchList matches;
152};
153
154typedef QList<QIMPenCharSet> QIMPenCharSetList;
155typedef QListIterator<QIMPenCharSet> QIMPenCharSetIterator;
156
157#endif