00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qframe.h>
00021 #include <qmap.h>
00022 #include <pickboardcfg.h>
00023 #include <pickboardpicks.h>
00024 #include "configdlg.h"
00025
00026 class QTimer;
00027
00028 namespace MultiKey
00029 {
00030
00031 class KeyboardConfig : public DictFilterConfig
00032 {
00033 public:
00034 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }
00035 virtual void generateText(const QString &s);
00036 void decBackspaces() { if (backspaces) backspaces--; }
00037 void incBackspaces() { backspaces++; }
00038 void resetBackspaces() { backspaces = 0; }
00039 private:
00040 int backspaces;
00041 };
00042
00043
00044 class KeyboardPicks : public PickboardPicks
00045 {
00046 Q_OBJECT
00047 public:
00048 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
00049 : PickboardPicks(parent, name, f) { }
00050 void initialise();
00051 virtual QSize sizeHint() const;
00052 KeyboardConfig *dc;
00053 };
00054
00055
00056 class Keys {
00057 public:
00058
00059 Keys();
00060 Keys(const char * filename);
00061 ~Keys();
00062 int width(const int row, const int col);
00063 int rows();
00064 ushort uni(const int row, const int col);
00065 int qcode(const int row, const int col);
00066 bool pressed(const int row, const int col);
00067 bool *pressedPtr(const int row, const int col);
00068 ushort shift(const ushort);
00069 ushort meta(const ushort);
00070 ushort circumflex(const ushort);
00071 ushort diaeresis(const ushort);
00072 ushort baccent(const ushort);
00073 ushort accent(const ushort);
00074 QImage *pix(const int row, const int col);
00075 int numKeys(const int row);
00076 void setKeysFromFile(const char *filename);
00077 void setKey(const int row, const int qcode, const ushort unicode,
00078 const int width, QImage *pix);
00079 void setPressed(const int row, const int col, const bool pressed);
00080 QString lang;
00081 QString label;
00082
00083 private:
00084
00085 typedef struct Key {
00086 int qcode;
00087 ushort unicode;
00088 int width;
00089
00090
00091 bool *pressed;
00092 QImage *pix;
00093 };
00094
00095 QList<Key> keys[6];
00096 QMap<ushort,ushort> shiftMap;
00097 QMap<ushort,ushort> metaMap;
00098 QMap<ushort,ushort> circumflexMap;
00099 QMap<ushort,ushort> diaeresisMap;
00100 QMap<ushort,ushort> baccentMap;
00101 QMap<ushort,ushort> accentMap;
00102
00103 };
00104
00105 class Keyboard : public QFrame
00106 {
00107 Q_OBJECT
00108 public:
00109 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
00110 ~Keyboard();
00111
00112 void resetState();
00113
00114 void mousePressEvent(QMouseEvent*);
00115 void mouseReleaseEvent(QMouseEvent*);
00116 void resizeEvent(QResizeEvent*);
00117 void paintEvent(QPaintEvent* e);
00118
00119 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
00120
00121 QSize sizeHint() const;
00122
00123 signals:
00124 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
00125
00126 private slots:
00127 void repeat();
00128 void togglePickboard(bool on_off);
00129 void toggleRepeat(bool on_off);
00130 void setMapToDefault();
00131 void setMapToFile(QString map);
00132 void cleanupConfigDlg();
00133 void reloadSw();
00134
00135
00136 void reloadKeyboard();
00137 void receive( const QCString &msg, const QByteArray &data );
00138
00139 private:
00140 int getKey( int &w, int j = -1 );
00141 void clearHighlight();
00142
00143 bool *shift;
00144 bool *lock;
00145 bool *ctrl;
00146 bool *alt;
00147 bool *meta;
00148 bool *circumflex;
00149 bool *diaeresis;
00150 bool *baccent;
00151 bool *accent;
00152
00153 uint useLargeKeys:1;
00154 uint usePicks:1;
00155 uint useRepeat:1;
00156
00157 int pressedKeyRow;
00158 int pressedKeyCol;
00159
00160 KeyboardPicks *picks;
00161
00162 int keyHeight;
00163 int defaultKeyWidth;
00164 int xoffs;
00165
00166 int unicode;
00167 int qkeycode;
00168 int modifiers;
00169
00170 int pressTid;
00171 bool pressed;
00172
00173 Keys *keys;
00174
00175
00176 ushort schar, mchar, echar;
00177 ushort parseKoreanInput(ushort c);
00178 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
00179 ushort constoe(const ushort c);
00180
00181 QTimer *repeatTimer;
00182
00183
00184 void loadKeyboardColors();
00185 QColor keycolor;
00186 QColor keycolor_pressed;
00187 QColor keycolor_lines;
00188 QColor textcolor;
00189
00190 ConfigDlg *configdlg;
00191 };
00192
00193 }