1 | /****************************************************************************␊ |
2 | **␊ |
3 | ** This file is part of the Qt Extended Opensource Package.␊ |
4 | **␊ |
5 | ** Copyright (C) 2009 Trolltech ASA.␊ |
6 | **␊ |
7 | ** Contact: Qt Extended Information (info@qtextended.org)␊ |
8 | **␊ |
9 | ** This file may be used under the terms of the GNU General Public License␊ |
10 | ** version 2.0 as published by the Free Software Foundation and appearing␊ |
11 | ** in the file LICENSE.GPL included in the packaging of this file.␊ |
12 | **␊ |
13 | ** Please review the following information to ensure GNU General Public␊ |
14 | ** Licensing requirements will be met:␊ |
15 | ** http://www.fsf.org/licensing/licenses/info/GPLv2.html.␊ |
16 | **␊ |
17 | **␊ |
18 | ****************************************************************************/␊ |
19 | ␊ |
20 | #ifndef KEYBOARDFRAME_H␊ |
21 | #define KEYBOARDFRAME_H␊ |
22 | ␊ |
23 | #include "pickboardcfg.h"␊ |
24 | #include "pickboardpicks.h"␊ |
25 | #include <QDebug>␊ |
26 | ␊ |
27 | class QTimer;␊ |
28 | ␊ |
29 | enum currentPosition␊ |
30 | {␊ |
31 | Top,␊ |
32 | Bottom␊ |
33 | };␊ |
34 | ␊ |
35 | //#define STANDARD_LAYOUT_NUMBER 0␊ |
36 | #define NATIONAL_LAYOUT_NUMBER 1␊ |
37 | #define OPTI_LAYOUT_NUMBER 2␊ |
38 | #define LAYOUTS_COUNT 3␊ |
39 | ␊ |
40 | class KeyboardConfig : public DictFilterConfig␊ |
41 | {␊ |
42 | public:␊ |
43 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }␊ |
44 | virtual ~KeyboardConfig();␊ |
45 | virtual void generateText(const QString &s);␊ |
46 | void decBackspaces() { if (backspaces) backspaces--; }␊ |
47 | void incBackspaces() { backspaces++; }␊ |
48 | void resetBackspaces() { backspaces = 0; }␊ |
49 | private:␊ |
50 | int backspaces;␊ |
51 | };␊ |
52 | ␊ |
53 | ␊ |
54 | class KeyboardPicks : public PickboardPicks␊ |
55 | {␊ |
56 | Q_OBJECT␊ |
57 | public:␊ |
58 | KeyboardPicks(QWidget* parent=0, Qt::WFlags f=0)␊ |
59 | : PickboardPicks(parent, f), dc(0) { }␊ |
60 | virtual ~KeyboardPicks();␊ |
61 | void initialise();␊ |
62 | virtual QSize sizeHint() const;␊ |
63 | KeyboardConfig *dc;␊ |
64 | };␊ |
65 | ␊ |
66 | /*␊ |
67 | KeyboardFrame is the primary widget for the Keyboard inputmethod.␊ |
68 | It is responsible for marshalling pickboards for displaying the pickboard,␊ |
69 | and for handling mouseevents.␊ |
70 | ␊ |
71 | It currently also creates and dispatches keyevents, although this is␊ |
72 | expected to be re-routed through Keyboard in the future.␊ |
73 | */␊ |
74 | ␊ |
75 | class KeyboardFrame : public QFrame // was QFrame␊ |
76 | {␊ |
77 | Q_OBJECT␊ |
78 | public:␊ |
79 | explicit KeyboardFrame( QWidget* parent=0, Qt::WFlags f=0 );␊ |
80 | virtual ~KeyboardFrame();␊ |
81 | ␊ |
82 | void resetState();␊ |
83 | ␊ |
84 | void mousePressEvent(QMouseEvent*);␊ |
85 | void mouseReleaseEvent(QMouseEvent*);␊ |
86 | void resizeEvent(QResizeEvent*);␊ |
87 | void showEvent(QShowEvent*);␊ |
88 | void paintEvent(QPaintEvent* e);␊ |
89 | void timerEvent(QTimerEvent* e);␊ |
90 | void drawKeyboard(QPainter &p, const QRect& clip, int key = -1);␊ |
91 | ␊ |
92 | void hideEvent ( QHideEvent * );␊ |
93 | ␊ |
94 | void setMode(int mode)␊ |
95 | {␊ |
96 | //useOptiKeys = mode;␊ |
97 | layoutNumber = mode;␊ |
98 | }␊ |
99 | ␊ |
100 | QSize sizeHint() const;␊ |
101 | ␊ |
102 | bool obscures( const QPoint &point );␊ |
103 | ␊ |
104 | void focusInEvent ( QFocusEvent *e){␊ |
105 | Q_UNUSED(e);␊ |
106 | qWarning() << "Warning: keyboard got focus";␊ |
107 | };␊ |
108 | ␊ |
109 | bool filter(int /*unicode*/, int /*keycode*/, int /*modifiers*/,␊ |
110 | bool /*isPress*/, bool /*autoRepeat*/){return false;};␊ |
111 | ␊ |
112 | bool filter(const QPoint &, int /*state*/, int /*wheel*/){return false;};␊ |
113 | ␊ |
114 | signals:␊ |
115 | void needsPositionConfirmation();␊ |
116 | void hiding();␊ |
117 | void showing();␊ |
118 | ␊ |
119 | public slots:␊ |
120 | void swapPosition();␊ |
121 | ␊ |
122 | protected:␊ |
123 | // void reset(){QWSInputMethod::reset();};␊ |
124 | // void updateHandler(int type){};␊ |
125 | // void mouseHandler(int pos, int state){};␊ |
126 | // void queryResponse(int property, const QVariant&){};␊ |
127 | ␊ |
128 | ␊ |
129 | private slots:␊ |
130 | void repeat();␊ |
131 | ␊ |
132 | private:␊ |
133 | int keycode( int i2, int j, const uchar **keyboard, QRect *repaintrect );␊ |
134 | int getKey( int &w, int j = -1 );␊ |
135 | void clearHighlight();␊ |
136 | int FindShifted(int k);␊ |
137 | void LoadNationalLayout();␊ |
138 | QString FindInSandboxes();␊ |
139 | void LoadSet(QString s);␊ |
140 | ␊ |
141 | uint shift:1;␊ |
142 | uint lock:1;␊ |
143 | uint ctrl:1;␊ |
144 | uint alt:1;␊ |
145 | uint useLargeKeys:1;␊ |
146 | //uint useOptiKeys:1;␊ |
147 | uint layoutNumber;␊ |
148 | ␊ |
149 | int pressedKey;␊ |
150 | QRect pressedKeyRect;␊ |
151 | ␊ |
152 | KeyboardPicks *picks;␊ |
153 | ␊ |
154 | int keyHeight;␊ |
155 | int defaultKeyWidth;␊ |
156 | int xoffs;␊ |
157 | ␊ |
158 | int unicode;␊ |
159 | int qkeycode;␊ |
160 | Qt::KeyboardModifiers modifiers;␊ |
161 | ␊ |
162 | int pressTid;␊ |
163 | bool pressed;␊ |
164 | ␊ |
165 | bool microFocusPending;␊ |
166 | bool showPending;␊ |
167 | ␊ |
168 | bool positionTop;␊ |
169 | ␊ |
170 | QTimer *repeatTimer;␊ |
171 | ␊ |
172 | bool nationalLoaded;␊ |
173 | QString layoutFileName;␊ |
174 | };␊ |
175 | ␊ |
176 | #endif␊ |