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