summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-05 21:44:45 (UTC)
committer zecke <zecke>2004-02-05 21:44:45 (UTC)
commitc66c82f5d42f17668794747006d5c8cf6cb62476 (patch) (unidiff)
tree9c5346a4a0d54cb05c0cd5a0ed90daf412b94657
parent7c8214c06f13b9295df8ac3efaf021e66600d440 (diff)
downloadopie-c66c82f5d42f17668794747006d5c8cf6cb62476.zip
opie-c66c82f5d42f17668794747006d5c8cf6cb62476.tar.gz
opie-c66c82f5d42f17668794747006d5c8cf6cb62476.tar.bz2
Initial revision
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--examples/config.in4
-rw-r--r--examples/example.pro12
-rw-r--r--examples/exampleboardimpl.cpp157
-rw-r--r--examples/exampleboardimpl.h50
-rw-r--r--examples/inputmethod/config.in4
-rw-r--r--examples/inputmethod/example.pro12
-rw-r--r--examples/inputmethod/exampleboardimpl.cpp157
-rw-r--r--examples/inputmethod/exampleboardimpl.h50
8 files changed, 446 insertions, 0 deletions
diff --git a/examples/config.in b/examples/config.in
new file mode 100644
index 0000000..7afe926
--- a/dev/null
+++ b/examples/config.in
@@ -0,0 +1,4 @@
1 config EXAMPLE_BOARD
2 boolean "Input Method"
3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/examples/example.pro b/examples/example.pro
new file mode 100644
index 0000000..3c003af
--- a/dev/null
+++ b/examples/example.pro
@@ -0,0 +1,12 @@
1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on release
3 HEADERS= exampleboardimpl.h
4 SOURCES= exampleboardimpl.cpp
5 TARGET = example_board
6 DESTDIR = $(OPIEDIR)/plugins/inputmethods
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include ../../launcher
9LIBS += -lqpe
10 VERSION = 1.0.0
11
12include ( $(OPIEDIR)/include.pro )
diff --git a/examples/exampleboardimpl.cpp b/examples/exampleboardimpl.cpp
new file mode 100644
index 0000000..36989a2
--- a/dev/null
+++ b/examples/exampleboardimpl.cpp
@@ -0,0 +1,157 @@
1#include <qwidget.h>
2#include <qcheckbox.h>
3#include <qlabel.h>
4#include <qsignalmapper.h>
5#include <qpushbutton.h>
6#include <qpe/resource.h>
7
8#include "exampleboardimpl.h"
9
10ExampleBoard::ExampleBoard(QWidget* par, WFlags fl )
11 : QHBox(par, "name", fl )
12{
13 QCheckBox *box1 = new QCheckBox(tr("Alt"),this);
14 connect(box1,SIGNAL(toggled(bool)),
15 this,SLOT(slotAlt(bool)));
16 m_alt = box1;
17 box1 = new QCheckBox(tr("Shift"),this );
18 connect(box1,SIGNAL(toggled(bool)),
19 this,SLOT(slotShift(bool)));
20 m_shi = box1;
21 box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this );
22 connect(box1,SIGNAL(toggled(bool)),
23 this,SLOT(slotCtrl(bool)));
24 m_ctrl = box1;
25
26 QSignalMapper *map = new QSignalMapper(this);
27 QPushButton *btn = new QPushButton("a",this);
28 map->setMapping(btn,0);
29 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
30
31 btn = new QPushButton("b",this);
32 map->setMapping(btn,1);
33 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
34
35 btn = new QPushButton("c",this);
36 map->setMapping(btn,2);
37 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
38
39 connect(map,SIGNAL(mapped(int)),
40 this,SLOT(slotKey(int)));
41 resetState();
42}
43
44ExampleBoard::~ExampleBoard(){
45}
46
47void ExampleBoard::resetState(){
48 m_state = 0;
49 m_shi->setChecked(false);
50 m_ctrl->setChecked(false);
51 m_alt->setChecked(false);
52}
53
54 void ExampleBoard::slotKey(int _ke){
55 int ke = _ke + 0x61; // 0 + 65 = 0x41 == A
56 if(m_state & ShiftButton )
57 ke -= 0x20;
58
59 /*
60 * Send the key
61 * ke is the unicode
62 * _ke + 0x41 is the keycode
63 * m_state Normally the state
64 * down/up
65 * auto repeat
66 */
67 emit key(ke, _ke +0x41,m_state,true,false);
68 emit key(ke, _ke + 0x41,m_state,false,false);
69}
70
71void ExampleBoard::slotShift(bool b){
72 if(b)
73 m_state |= ShiftButton;
74 else
75 m_state &= ~ShiftButton;
76}
77
78void ExampleBoard::slotAlt(bool b){
79 if(b)
80 m_state |= AltButton;
81 else
82 m_state &= ~AltButton;
83}
84
85void ExampleBoard::slotCtrl(bool b){
86 if(b)
87 m_state |= ControlButton;
88 else
89 m_state &= ~ControlButton;
90}
91
92
93
94ExampleboardImpl::ExampleboardImpl()
95 : m_pickboard(0), m_icn(0)
96{
97}
98
99ExampleboardImpl::~ExampleboardImpl()
100{
101 delete m_pickboard;
102 delete m_icn;
103}
104
105QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
106{
107 if ( !m_pickboard )
108 m_pickboard = new ExampleBoard( parent, f );
109 return m_pickboard;
110}
111
112void ExampleboardImpl::resetState()
113{
114 if ( m_pickboard )
115 m_pickboard->resetState();
116}
117
118QPixmap *ExampleboardImpl::icon()
119{
120 if ( !m_icn )
121 m_icn = new QPixmap(Resource::loadPixmap("Tux"));
122 return m_icn;
123}
124
125QString ExampleboardImpl::name()
126{
127 return QObject::tr("Example Input");
128}
129
130void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot )
131{
132 if ( m_pickboard )
133 QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
134}
135
136#ifndef QT_NO_COMPONENT
137QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
138{
139 *iface = 0;
140 if ( uuid == IID_QUnknown )
141 *iface = this;
142 else if ( uuid == IID_InputMethod )
143 *iface = this;
144 else
145 return QS_FALSE;
146
147 if ( *iface )
148 (*iface)->addRef();
149 return QS_OK;
150}
151
152Q_EXPORT_INTERFACE()
153{
154 Q_CREATE_INSTANCE( ExampleboardImpl )
155}
156#endif
157
diff --git a/examples/exampleboardimpl.h b/examples/exampleboardimpl.h
new file mode 100644
index 0000000..37e2a5f
--- a/dev/null
+++ b/examples/exampleboardimpl.h
@@ -0,0 +1,50 @@
1#ifndef EXAMPLEBOARDIMPL_H
2#define EXAMPLEBOARDIMPL_H
3
4#include <qhbox.h>
5
6#include <qpe/inputmethodinterface.h>
7
8class QPixmap;
9class QCheckBox;
10class ExampleBoard : public QHBox {
11 Q_OBJECT
12public:
13 ExampleBoard( QWidget *par, WFlags f );
14 ~ExampleBoard();
15 void resetState();
16private slots:
17 void slotKey(int);
18 void slotShift(bool);
19 void slotAlt(bool);
20 void slotCtrl(bool);
21signals:
22 void key(ushort,ushort,ushort,bool,bool);
23private:
24 int m_state;
25 QCheckBox *m_alt,*m_shi,*m_ctrl;
26};
27
28class ExampleboardImpl : public InputMethodInterface
29{
30public:
31 ExampleboardImpl();
32 virtual ~ExampleboardImpl();
33
34#ifndef QT_NO_COMPONENT
35 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
36 Q_REFCOUNT
37#endif
38
39 virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f );
40 virtual void resetState();
41 virtual QPixmap *icon();
42 virtual QString name();
43 virtual void onKeyPress( QObject *receiver, const char *slot );
44
45private:
46 ExampleBoard *m_pickboard;
47 QPixmap *m_icn;
48};
49
50#endif
diff --git a/examples/inputmethod/config.in b/examples/inputmethod/config.in
new file mode 100644
index 0000000..7afe926
--- a/dev/null
+++ b/examples/inputmethod/config.in
@@ -0,0 +1,4 @@
1 config EXAMPLE_BOARD
2 boolean "Input Method"
3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/examples/inputmethod/example.pro b/examples/inputmethod/example.pro
new file mode 100644
index 0000000..3c003af
--- a/dev/null
+++ b/examples/inputmethod/example.pro
@@ -0,0 +1,12 @@
1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on release
3 HEADERS= exampleboardimpl.h
4 SOURCES= exampleboardimpl.cpp
5 TARGET = example_board
6 DESTDIR = $(OPIEDIR)/plugins/inputmethods
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include ../../launcher
9LIBS += -lqpe
10 VERSION = 1.0.0
11
12include ( $(OPIEDIR)/include.pro )
diff --git a/examples/inputmethod/exampleboardimpl.cpp b/examples/inputmethod/exampleboardimpl.cpp
new file mode 100644
index 0000000..36989a2
--- a/dev/null
+++ b/examples/inputmethod/exampleboardimpl.cpp
@@ -0,0 +1,157 @@
1#include <qwidget.h>
2#include <qcheckbox.h>
3#include <qlabel.h>
4#include <qsignalmapper.h>
5#include <qpushbutton.h>
6#include <qpe/resource.h>
7
8#include "exampleboardimpl.h"
9
10ExampleBoard::ExampleBoard(QWidget* par, WFlags fl )
11 : QHBox(par, "name", fl )
12{
13 QCheckBox *box1 = new QCheckBox(tr("Alt"),this);
14 connect(box1,SIGNAL(toggled(bool)),
15 this,SLOT(slotAlt(bool)));
16 m_alt = box1;
17 box1 = new QCheckBox(tr("Shift"),this );
18 connect(box1,SIGNAL(toggled(bool)),
19 this,SLOT(slotShift(bool)));
20 m_shi = box1;
21 box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this );
22 connect(box1,SIGNAL(toggled(bool)),
23 this,SLOT(slotCtrl(bool)));
24 m_ctrl = box1;
25
26 QSignalMapper *map = new QSignalMapper(this);
27 QPushButton *btn = new QPushButton("a",this);
28 map->setMapping(btn,0);
29 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
30
31 btn = new QPushButton("b",this);
32 map->setMapping(btn,1);
33 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
34
35 btn = new QPushButton("c",this);
36 map->setMapping(btn,2);
37 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
38
39 connect(map,SIGNAL(mapped(int)),
40 this,SLOT(slotKey(int)));
41 resetState();
42}
43
44ExampleBoard::~ExampleBoard(){
45}
46
47void ExampleBoard::resetState(){
48 m_state = 0;
49 m_shi->setChecked(false);
50 m_ctrl->setChecked(false);
51 m_alt->setChecked(false);
52}
53
54 void ExampleBoard::slotKey(int _ke){
55 int ke = _ke + 0x61; // 0 + 65 = 0x41 == A
56 if(m_state & ShiftButton )
57 ke -= 0x20;
58
59 /*
60 * Send the key
61 * ke is the unicode
62 * _ke + 0x41 is the keycode
63 * m_state Normally the state
64 * down/up
65 * auto repeat
66 */
67 emit key(ke, _ke +0x41,m_state,true,false);
68 emit key(ke, _ke + 0x41,m_state,false,false);
69}
70
71void ExampleBoard::slotShift(bool b){
72 if(b)
73 m_state |= ShiftButton;
74 else
75 m_state &= ~ShiftButton;
76}
77
78void ExampleBoard::slotAlt(bool b){
79 if(b)
80 m_state |= AltButton;
81 else
82 m_state &= ~AltButton;
83}
84
85void ExampleBoard::slotCtrl(bool b){
86 if(b)
87 m_state |= ControlButton;
88 else
89 m_state &= ~ControlButton;
90}
91
92
93
94ExampleboardImpl::ExampleboardImpl()
95 : m_pickboard(0), m_icn(0)
96{
97}
98
99ExampleboardImpl::~ExampleboardImpl()
100{
101 delete m_pickboard;
102 delete m_icn;
103}
104
105QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
106{
107 if ( !m_pickboard )
108 m_pickboard = new ExampleBoard( parent, f );
109 return m_pickboard;
110}
111
112void ExampleboardImpl::resetState()
113{
114 if ( m_pickboard )
115 m_pickboard->resetState();
116}
117
118QPixmap *ExampleboardImpl::icon()
119{
120 if ( !m_icn )
121 m_icn = new QPixmap(Resource::loadPixmap("Tux"));
122 return m_icn;
123}
124
125QString ExampleboardImpl::name()
126{
127 return QObject::tr("Example Input");
128}
129
130void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot )
131{
132 if ( m_pickboard )
133 QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
134}
135
136#ifndef QT_NO_COMPONENT
137QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
138{
139 *iface = 0;
140 if ( uuid == IID_QUnknown )
141 *iface = this;
142 else if ( uuid == IID_InputMethod )
143 *iface = this;
144 else
145 return QS_FALSE;
146
147 if ( *iface )
148 (*iface)->addRef();
149 return QS_OK;
150}
151
152Q_EXPORT_INTERFACE()
153{
154 Q_CREATE_INSTANCE( ExampleboardImpl )
155}
156#endif
157
diff --git a/examples/inputmethod/exampleboardimpl.h b/examples/inputmethod/exampleboardimpl.h
new file mode 100644
index 0000000..37e2a5f
--- a/dev/null
+++ b/examples/inputmethod/exampleboardimpl.h
@@ -0,0 +1,50 @@
1#ifndef EXAMPLEBOARDIMPL_H
2#define EXAMPLEBOARDIMPL_H
3
4#include <qhbox.h>
5
6#include <qpe/inputmethodinterface.h>
7
8class QPixmap;
9class QCheckBox;
10class ExampleBoard : public QHBox {
11 Q_OBJECT
12public:
13 ExampleBoard( QWidget *par, WFlags f );
14 ~ExampleBoard();
15 void resetState();
16private slots:
17 void slotKey(int);
18 void slotShift(bool);
19 void slotAlt(bool);
20 void slotCtrl(bool);
21signals:
22 void key(ushort,ushort,ushort,bool,bool);
23private:
24 int m_state;
25 QCheckBox *m_alt,*m_shi,*m_ctrl;
26};
27
28class ExampleboardImpl : public InputMethodInterface
29{
30public:
31 ExampleboardImpl();
32 virtual ~ExampleboardImpl();
33
34#ifndef QT_NO_COMPONENT
35 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
36 Q_REFCOUNT
37#endif
38
39 virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f );
40 virtual void resetState();
41 virtual QPixmap *icon();
42 virtual QString name();
43 virtual void onKeyPress( QObject *receiver, const char *slot );
44
45private:
46 ExampleBoard *m_pickboard;
47 QPixmap *m_icn;
48};
49
50#endif