00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qapplication.h>
00021 #include <qpixmap.h>
00022 #include "keyboard.h"
00023 #include "keyboardimpl.h"
00024
00025
00026 static const char * const kb_xpm[] = {
00027 "28 13 4 1",
00028 " c None",
00029 ". c #4C4C4C",
00030 "+ c #FFF7DD",
00031 "@ c #D6CFBA",
00032 " .......................... ",
00033 " .+++.+++.+++.+++.+++.++++. ",
00034 " .+@@.+@@.+@@.+@@.+@@.+@@@. ",
00035 " .......................... ",
00036 " .+++++.+++.+++.+++.++++++. ",
00037 " .+@@@@.+@@.+@@.+@@.+@@@@@. ",
00038 " .......................... ",
00039 " .++++++.+++.+++.+++.+++++. ",
00040 " .+@@@@@.+@@.+@@.+@@.+@@@@. ",
00041 " .......................... ",
00042 " .++++.++++++++++++++.++++. ",
00043 " .+@@@.+@@@@@@@@@@@@@.+@@@. ",
00044 " .......................... "};
00045
00046
00047
00048 static const char * const ipti_xpm[] = {
00049 "28 13 4 1",
00050 " c None",
00051 ". c #4C4C4C",
00052 "+ c #FFF7DD",
00053 "@ c #D6CFBA",
00054 " ......................... ",
00055 " .+++.+++.+++.+++.+++.+++. ",
00056 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00057 " ......................... ",
00058 " .+++.+++.+++.+++.+++.+++. ",
00059 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00060 " ......................... ",
00061 " .+++.+++.+++.+++.+++.+++. ",
00062 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00063 " ......................... ",
00064 " .+++.+++.+++.+++.+++.+++. ",
00065 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00066 " ......................... "};
00067
00068 KeyboardImpl::KeyboardImpl()
00069 : input(0), icn(0)
00070 {
00071 }
00072
00073 KeyboardImpl::~KeyboardImpl()
00074 {
00075 delete input;
00076 delete icn;
00077 }
00078
00079 QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
00080 {
00081 if ( !input )
00082 input = new KeyboardInput::Keyboard( parent, "Keyboard", f );
00083 return input;
00084 }
00085
00086 void KeyboardImpl::resetState()
00087 {
00088 if ( input )
00089 input->resetState();
00090 }
00091
00092 QPixmap *KeyboardImpl::icon()
00093 {
00094 if ( !icn )
00095 icn = new QPixmap( (const char **)kb_xpm );
00096 return icn;
00097 }
00098
00099 QString KeyboardImpl::name()
00100 {
00101 return qApp->translate( "InputMethods", "Keyboard" );
00102 }
00103
00104 void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
00105 {
00106 if ( input )
00107 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
00108 }
00109
00110 #ifndef QT_NO_COMPONENT
00111 QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
00112 {
00113 *iface = 0;
00114 if ( uuid == IID_QUnknown )
00115 *iface = this;
00116 else if ( uuid == IID_InputMethod )
00117 *iface = this;
00118 else
00119 return QS_FALSE;
00120
00121 if ( *iface )
00122 (*iface)->addRef();
00123 return QS_OK;
00124 }
00125
00126 Q_EXPORT_INTERFACE()
00127 {
00128 Q_CREATE_INSTANCE( KeyboardImpl )
00129 }
00130 #endif