Back to index

im-sdk  12.3.91
iiimqccontext.h
Go to the documentation of this file.
00001 /*
00002   iiimqccontext.h
00003   Copyright (C) 2003 Free Standards Group
00004 
00005   Permission is hereby granted, free of charge, to any person obtaining a
00006   copy of this software and associated documentation files (the
00007   "Software"), to deal in the Software without restriction, including
00008   without limitation the rights to use, copy, modify, merge, publish,
00009   distribute, sublicense, and/or sell copies of the Software, and to
00010   permit persons to whom the Software is furnished to do so, subject to
00011   the following conditions: The above copyright notice and this
00012   permission notice shall be included in all copies or substantial
00013   portions of the Software.
00014 
00015   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018   IN NO EVENT SHALL OPENI18N WG OR FREE STANDARDS GROUP. BE LIABLE
00019   FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020   CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021   THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022   ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024   Except as contained in this notice, the names of OpenI18N WG and/or
00025   Free Standards Group shall not be used in advertising or otherwise to
00026   promote the sale, use or other dealings in this Software without prior
00027   written authorization from OpenI18N WG and/or Free Standards Group
00028   as applicable.
00029 
00030   Author: ILGYOUNG PARK <Karl.Park@Sun.COM>
00031          TuBo <Gavin.Tu@Sun.COM>
00032 
00033 */
00034 
00035 #ifndef __IIIM_QC_CONTEXT_H__
00036 #define __IIIM_QC_CONTEXT_H__
00037 
00038 #include <qobject.h>
00039 #include <qinputcontext.h>
00040 #include <qvaluelist.h>
00041 #include <iiimcf.h>
00042 #include "keymapper.h"
00043 
00044 
00045 class IIIMInputContextPrivate;
00046 class IIIMQCFLookup;
00047 
00048 class Q_EXPORT IIIMInputContext : public QInputContext
00049 {
00050  public:
00051   IIIMInputContext ();
00052   virtual ~IIIMInputContext ();
00053 
00054   virtual QString identifierName ();
00055   virtual QString language ();
00056   virtual bool filterEvent (const QEvent *event);
00057   virtual void reset(); 
00058   virtual void setFocus ();
00059   virtual void unsetFocus ();
00060   virtual void setMicroFocus( int x, int y, int w, int h, QFont *f = 0 );
00061   virtual void mouseHandler( int x, QEvent::Type type,
00062                           Qt::ButtonState button, Qt::ButtonState state );
00063 
00064   virtual bool isPreeditRelocationEnabled(); 
00065 
00066   IIIMCF_handle get_iiimcf_handle();
00067   void im_context_aux_set_values (IIIMCF_context , IIIMCF_event);
00068   void im_context_change_conversion_mode(IIIMCF_context, char *); 
00069   QWidget*  get_focus_widget();
00070   
00071   struct  _aux *aux;
00072   IIIMCF_context cur_context; 
00073   int cursor_x;
00074   int cursor_y;
00075   int cursor_h;
00076 
00077  protected:
00078   virtual bool isPreeditPreservationEnabled();
00079   class IIIMInputContextID;
00080   typedef QValueList<IIIMInputContextID> IIIMICLIST;
00081   typedef IIIMICLIST::iterator IIIMICLISTITR;
00082 
00083  protected:
00084   IIIMCF_handle iiimqcf_init_iiim (void);
00085 
00086   bool forwardEvent (QWidget *, IIIMCF_event, IIIMF_status *);
00087   IIIMCF_keyevent *get_iiimcf_keyevent_from (QKeyEvent *kev);
00088   
00089   bool set_current_iiimcf_session_context (QWidget *widget);
00090   IIIMICLISTITR get_iiimcf_session_context (QWidget *widget, bool doCreate = TRUE);
00091   bool iiimqcf_event_dispatch (QWidget *);
00092 
00093   bool get_preedit_data (QWidget *w, QString &text, int *cursor);
00094   bool get_committed_text (QWidget *w, QString &text);
00095   
00096  
00097  private:
00098 
00099   /*to handle iiimcf related low level operations*/
00100   friend class IIIMInputContextPrivate;
00101   IIIMInputContextPrivate *d;
00102   
00103   IIIMICLISTITR search_iiimiclist_for (QWidget *widget);
00104   IIIMICLISTITR create_iiimcf_session_context (QWidget *widget);
00105 
00106   bool iiimcfIsInitialized;
00107   
00108   IIIMCF_handle _h;
00109   
00110   static int counter;
00111 
00112   IIIMICLISTITR _curic;
00113   IIIMICLIST _iclist;
00114   KeyMapper *keymapper;
00115   IIIMQCFLookup *iiimlookup;
00116 
00117 };
00118 
00119 class IIIMInputContext::IIIMInputContextID {
00120 public:
00121   QWidget *_w;
00122   IIIMCF_context _c;    
00123 
00124   IIIMInputContextID (QWidget * w = 0, IIIMCF_context ic = 0)
00125     : _w (w), _c (ic) {}
00126   bool operator==(const IIIMInputContextID &obj) const {
00127     return (_w == obj._w) ? TRUE : FALSE;
00128   }
00129   bool operator!=(const IIIMInputContextID &obj) const {
00130     return (_w != obj._w) ? TRUE : FALSE;
00131   }
00132     
00133 };
00134 
00135 
00136 #endif // __IIIM_QC_CONTEXT_H__