1 /** @file scim_uim_imengine.h 2 */ 3 4 /* 5 * Smart Common Input Method 6 * 7 * Copyright (c) 2004 James Su <suzhe@tsinghua.org.cn> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 * $Id: scim_uim_imengine.h,v 1.7 2007/04/10 04:36:37 makeinu Exp $ 24 */ 25 26 #if !defined (__SCIM_UIM_IMENGINE_H) 27 #define __SCIM_UIM_IMENGINE_H 28 29 #include <uim.h> 30 31 using namespace scim; 32 33 class UIMFactory : public IMEngineFactoryBase 34 { 35 String m_name; 36 String m_uuid; 37 38 friend class UIMInstance; 39 40 public: 41 UIMFactory (const String &name, 42 const String &lang, 43 const String &uuid); 44 45 virtual ~UIMFactory (); 46 47 virtual WideString get_name () const; 48 virtual WideString get_authors () const; 49 virtual WideString get_credits () const; 50 virtual WideString get_help () const; 51 virtual String get_uuid () const; 52 virtual String get_icon_file () const; 53 54 virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1); 55 }; 56 57 class UIMInstance : public IMEngineInstanceBase 58 { 59 uim_context m_uc; 60 61 WideString m_preedit_string; 62 AttributeList m_preedit_attrs; 63 int m_preedit_caret; 64 65 CommonLookupTable m_lookup_table; 66 67 bool m_show_lookup_table; 68 69 PropertyList m_properties; 70 71 public: 72 UIMInstance (UIMFactory *factory, 73 const String &uim_name, 74 const String &encoding, 75 int id = -1); 76 77 virtual ~UIMInstance (); 78 79 virtual bool process_key_event (const KeyEvent& key); 80 virtual void move_preedit_caret (unsigned int pos); 81 virtual void select_candidate (unsigned int item); 82 virtual void update_lookup_table_page_size (unsigned int page_size); 83 virtual void lookup_table_page_up (); 84 virtual void lookup_table_page_down (); 85 virtual void reset (); 86 virtual void focus_in (); 87 virtual void focus_out (); 88 virtual void trigger_property (const String &property); 89 90 private: 91 static int convert_keycode (int keycode); 92 static int convert_keymask (int mask); 93 94 static void uim_commit_cb (void *ptr, const char *str); 95 96 static void uim_preedit_clear_cb (void *ptr); 97 static void uim_preedit_pushback_cb (void *ptr, int attr, const char *str); 98 static void uim_preedit_update_cb (void *ptr); 99 100 static void uim_prop_list_update_cb (void *ptr, const char *str); 101 static void uim_prop_label_update_cb (void *ptr, const char *str); 102 103 static void uim_cand_activate_cb (void *ptr, int nr, int display_limit); 104 static void uim_cand_select_cb (void *ptr, int index); 105 static void uim_cand_shift_page_cb (void *ptr, int dir); 106 static void uim_cand_deactive_cb (void *ptr); 107 }; 108 #endif 109 /* 110 vi:ts=4:nowrap:ai:expandtab 111 */ 112