PageRenderTime 23ms CodeModel.GetById 1ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/scim-python-engine.h

http://scim-python.googlecode.com/
C++ Header | 121 lines | 79 code | 15 blank | 27 comment | 0 complexity | c97b08ae06f59150a9207f77bd63b3b9 MD5 | raw file
  1/* vim:set noet ts=4: */
  2/** 
  3 * scim-python
  4 * 
  5 * Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
  6 *
  7 *
  8 * This library is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU Lesser General Public
 10 * License as published by the Free Software Foundation; either
 11 * version 2 of the License, or (at your option) any later version.
 12 *
 13 * This library is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 * GNU Lesser General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU Lesser General Public
 19 * License along with this program; if not, write to the
 20 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 21 * Boston, MA  02111-1307  USA
 22 *
 23 * $Id: $
 24 */
 25#ifndef __SCIM_PYTHON_ENGINE_H_
 26#define __SCIM_PYTHON_ENGINE_H_
 27#define Uses_SCIM_IMENGINE
 28#include <Python.h>
 29#include <scim.h>
 30
 31using namespace scim;
 32
 33struct PyIMEngineObject;
 34
 35class PyIMEngine : public IMEngineInstanceBase 
 36{
 37private:
 38	PyObject *self;
 39	PyObject *factory;
 40	PyObject *config;
 41	Connection reload_signal_connection;
 42
 43private:
 44	PyIMEngine (PyObject *self,
 45			PyObject			*factory,
 46			PyObject			*config,
 47			const String		&encoding,
 48			int					id = -1);
 49	virtual ~PyIMEngine ();
 50
 51public:
 52	virtual bool process_key_event (const KeyEvent &key);
 53	virtual void move_preedit_caret (unsigned int pos);
 54	virtual void select_candidate (unsigned int index);
 55	virtual void update_lookup_table_page_size (unsigned int page_size);
 56	virtual void lookup_table_page_up ();
 57	virtual void lookup_table_page_down ();
 58	virtual void reset ();
 59	virtual void focus_in ();
 60	virtual void focus_out ();
 61	virtual void trigger_property (const String &property);
 62	virtual void process_helper_event (const String &helper_uuid, const Transaction &trans);
 63	virtual void update_client_capabilities (unsigned int cap);
 64
 65private:
 66	void reload_config (const ConfigPointer &config);
 67
 68public:
 69
 70	/* 
 71	 * Wrapper functions
 72	 */
 73
 74	static PyObject *py_process_key_event (PyIMEngineObject *self, PyObject *args);
 75	static PyObject *py_move_preedit_caret (PyIMEngineObject *self, PyObject *args);
 76	static PyObject *py_select_candidate (PyIMEngineObject *self, PyObject *args);
 77	static PyObject *py_update_lookup_table_page_size (PyIMEngineObject *self, PyObject *args);
 78	static PyObject *py_lookup_table_page_up (PyIMEngineObject *self);
 79	static PyObject *py_lookup_table_page_down (PyIMEngineObject *self);
 80	static PyObject *py_reset (PyIMEngineObject *self);
 81	static PyObject *py_focus_in (PyIMEngineObject *self);
 82	static PyObject *py_focus_out (PyIMEngineObject *self);
 83	static PyObject *py_trigger_property (PyIMEngineObject *self, PyObject *arg);
 84	static PyObject *py_process_helper_event (PyIMEngineObject *self, PyObject *args);
 85	static PyObject *py_update_client_capabilities (PyIMEngineObject *self, PyObject *arg);
 86
 87	static PyObject *py_show_preedit_string (PyIMEngineObject *self);
 88	static PyObject *py_show_aux_string (PyIMEngineObject *self);
 89	static PyObject *py_show_lookup_table (PyIMEngineObject *self);
 90	static PyObject *py_hide_preedit_string (PyIMEngineObject *self);
 91	static PyObject *py_hide_aux_string (PyIMEngineObject *self);
 92	static PyObject *py_hide_lookup_table (PyIMEngineObject *self);
 93	static PyObject *py_update_preedit_caret (PyIMEngineObject *self, PyObject *args);
 94	static PyObject *py_update_preedit_string (PyIMEngineObject *self, PyObject *args);
 95	static PyObject *py_update_aux_string (PyIMEngineObject *self, PyObject *args);
 96	static PyObject *py_update_lookup_table (PyIMEngineObject *self, PyObject *args);
 97	static PyObject *py_commit_string (PyIMEngineObject *self, PyObject *args);
 98	static PyObject *py_forward_key_event (PyIMEngineObject *self, PyObject *args);
 99	static PyObject *py_register_properties (PyIMEngineObject *self, PyObject *args);
100	static PyObject *py_update_property	 (PyIMEngineObject *self, PyObject *args);
101	static PyObject *py_beep (PyIMEngineObject *self);
102	static PyObject *py_start_helper (PyIMEngineObject *self, PyObject *args);
103	static PyObject *py_stop_helper (PyIMEngineObject *self, PyObject *args);
104	static PyObject *py_send_helper_event (PyIMEngineObject *self, PyObject *args);
105	static PyObject *py_get_surrounding_text (PyIMEngineObject *self, PyObject *args);
106	static PyObject *py_delete_surrounding_text (PyIMEngineObject *self, PyObject *args);
107
108	static PyObject *py_new (PyTypeObject *type, PyObject *args, PyObject *kwds);
109	static int py_init (PyIMEngineObject *self, PyObject *args, PyObject *kwds);
110	static void py_dealloc (PyIMEngineObject *self);
111
112	static IMEngineInstanceBase *from_pyobject (PyObject *object);
113	static PyMethodDef py_methods[];
114
115public:
116	static void operator delete (void *p);
117};
118
119void init_engine (PyObject *module);
120
121#endif /*__SCIM_PYTHON_ENGINE_H_*/