1 /** @file scim_rawcode_imengine.h 2 * definition of RawCode related classes. 3 */ 4 5 /* 6 * Smart Common Input Method 7 * 8 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn> 9 * 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this program; if not, write to the 23 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 24 * Boston, MA 02111-1307 USA 25 * 26 * $Id: scim_rawcode_imengine.h,v 1.5.4.3 2006/01/12 07:00:36 suzhe Exp $ 27 */ 28 29 #if !defined (__SCIM_RAWCODE_IMENGINE_H) 30 #define __SCIM_RAWCODE_IMENGINE_H 31 32 using namespace scim; 33 34 class RawCodeFactory : public IMEngineFactoryBase 35 { 36 friend class RawCodeInstance; 37 38 public: 39 RawCodeFactory (); 40 virtual ~RawCodeFactory (); 41 42 virtual WideString get_name () const; 43 virtual WideString get_authors () const; 44 virtual WideString get_credits () const; 45 virtual WideString get_help () const; 46 virtual String get_uuid () const; 47 virtual String get_icon_file () const; 48 virtual String get_language () const; 49 50 virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1); 51 52 private: 53 int get_maxlen (const String &encoding); 54 }; 55 56 class RawCodeInstance : public IMEngineInstanceBase 57 { 58 Pointer <RawCodeFactory> m_factory; 59 60 CommonLookupTable m_lookup_table; 61 std::vector<WideString> m_lookup_table_labels; 62 WideString m_preedit_string; 63 String m_working_encoding; 64 bool m_unicode; 65 66 size_t m_max_preedit_len; 67 68 IConvert m_working_iconv; 69 IConvert m_client_iconv; 70 71 public: 72 RawCodeInstance (RawCodeFactory *factory, 73 const String& encoding, 74 int id = -1); 75 virtual ~RawCodeInstance (); 76 77 virtual bool process_key_event (const KeyEvent& key); 78 virtual void move_preedit_caret (unsigned int pos); 79 virtual void select_candidate (unsigned int item); 80 virtual void update_lookup_table_page_size (unsigned int page_size); 81 virtual void lookup_table_page_up (); 82 virtual void lookup_table_page_down (); 83 virtual void reset (); 84 virtual void focus_in (); 85 virtual void focus_out (); 86 virtual void trigger_property (const String &property); 87 88 private: 89 int create_lookup_table (); 90 void process_preedit_string (); 91 92 void initialize_properties (); 93 void refresh_encoding_property (); 94 95 void set_working_encoding (const String &encoding); 96 97 String get_multibyte_string (const WideString& preedit); 98 ucs4_t get_unicode_value (const WideString& preedit); 99 }; 100 101 #endif 102 /* 103 vi:ts=4:nowrap:ai:expandtab 104 */ 105 106