00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef QIMPENCHAR_H_
00022 #define QIMPENCHAR_H_
00023
00024 #include <qlist.h>
00025 #include <qvaluelist.h>
00026 #include <qcstring.h>
00027 #include "qimpenstroke.h"
00028
00029 struct QIMPenSpecialKeys {
00030 int code;
00031 char *name;
00032 };
00033
00034 extern const QIMPenSpecialKeys qimpen_specialKeys[];
00035
00036
00037 class QIMPenChar
00038 {
00039 public:
00040 QIMPenChar();
00041 QIMPenChar( const QIMPenChar & );
00042
00043 unsigned int character() const { return ch; }
00044 void setCharacter( unsigned int c ) { ch = c; }
00045
00046 const QString &data() const { return d; }
00047 void setData( const QString &ba ) { d = ba; }
00048
00049 QString name() const;
00050 bool isEmpty() const { return strokes.isEmpty(); }
00051 unsigned int strokeCount() const { return strokes.count(); }
00052 unsigned int strokeLength( int s ) const;
00053 void clear();
00054 int match( QIMPenChar *ch );
00055 const QIMPenStrokeList &penStrokes() { return strokes; }
00056 QPoint startingPoint() const { return strokes.getFirst()->startingPoint(); }
00057 QRect boundingRect();
00058
00059 void setFlag( int f ) { flags |= f; }
00060 void clearFlag( int f ) { flags &= ~f; }
00061 bool testFlag( int f ) { return flags & f; }
00062
00063 enum Flags { System=0x01, Deleted=0x02, CombineRight=0x04, Data=0x08, Combined=0x10 };
00064
00065 enum Mode { ModeBase=0x4000, Caps=0x4001, Shortcut=0x4002, CapsLock=0x4003,
00066 Punctuation=0x4004, Symbol=0x4005, Extended=0x4006 };
00067
00068 QIMPenChar &operator=( const QIMPenChar &s );
00069
00070 void addStroke( QIMPenStroke * );
00071
00072 protected:
00073 unsigned int ch;
00074 QString d;
00075 Q_UINT8 flags;
00076 QIMPenStrokeList strokes;
00077
00078 friend QDataStream &operator<< (QDataStream &, const QIMPenChar &);
00079 friend QDataStream &operator>> (QDataStream &, QIMPenChar &);
00080 };
00081
00082 typedef QList<QIMPenChar> QIMPenCharList;
00083 typedef QListIterator<QIMPenChar> QIMPenCharIterator;
00084
00085 QDataStream & operator<< (QDataStream & s, const QIMPenChar &ws);
00086 QDataStream & operator>> (QDataStream & s, QIMPenChar &ws);
00087
00088 struct QIMPenCharMatch
00089 {
00090 int error;
00091 QIMPenChar *penChar;
00092
00093 bool operator>( const QIMPenCharMatch &m );
00094 bool operator<( const QIMPenCharMatch &m );
00095 bool operator<=( const QIMPenCharMatch &m );
00096 };
00097
00098 typedef QValueList<QIMPenCharMatch> QIMPenCharMatchList;
00099
00100
00101 class QIMPenCharSet
00102 {
00103 public:
00104 QIMPenCharSet();
00105 QIMPenCharSet( const QString &fn );
00106
00107 bool isEmpty() const { return chars.isEmpty(); }
00108 unsigned int count() const { return chars.count(); }
00109 void clear() { chars.clear(); }
00110
00111 void setDescription( const QString &d ) { desc = d; }
00112 QString description() const { return desc; }
00113 void setTitle( const QString &t ) { csTitle = t; }
00114 QString title() const { return csTitle; }
00115
00116 QIMPenCharMatchList match( QIMPenChar *ch );
00117 void addChar( QIMPenChar *ch );
00118 void removeChar( QIMPenChar *ch );
00119 QIMPenChar *at( int i );
00120 void setHidden ( const bool &b ) { phidden = b; }
00121 bool hidden() const { return phidden; }
00122
00123 unsigned maximumStrokes() const { return maxStrokes; }
00124
00125 void up( QIMPenChar *ch );
00126 void down( QIMPenChar *ch );
00127
00128 enum Domain { System, User };
00129 enum Type { Unknown=0x00, Lower=0x01, Upper=0x02, Combining=0x04,
00130 Numeric=0x08, Punctuation=0x10, Symbol=0x20, Shortcut=0x40 };
00131
00132 const QIMPenCharList &characters() const { return chars; }
00133
00134 void setType( Type t ) { csType = t; }
00135 Type type() const { return csType; }
00136
00137 const QString &filename( Domain d ) const;
00138 void setFilename( const QString &fn, Domain d=System );
00139 bool load( const QString &fn, Domain d=System );
00140 bool save( Domain d=System );
00141
00142 protected:
00143 void markDeleted( uint ch );
00144
00145 protected:
00146 QString csTitle;
00147 QString desc;
00148 QString sysFilename;
00149 QString userFilename;
00150 Type csType;
00151 unsigned maxStrokes;
00152 QIMPenCharList chars;
00153 QIMPenCharMatchList matches;
00154 bool phidden : 1;
00155 };
00156
00157 typedef QList<QIMPenCharSet> QIMPenCharSetList;
00158 typedef QListIterator<QIMPenCharSet> QIMPenCharSetIterator;
00159
00160 #endif