NOTE: This will *likely* break compilation of TQt4 Please wait a few days for fixes to be committed as needed!pull/1/head
parent
d7be169483
commit
d3f7a9d6f1
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,107 @@
|
|||||||
|
immodule for TQt
|
||||||
|
|
||||||
|
|
||||||
|
* What is this?
|
||||||
|
|
||||||
|
immodule for TQt is a modular, extensible input method subsystem for
|
||||||
|
TQt.
|
||||||
|
|
||||||
|
This project brings functionality similar to the immodule for GTK+
|
||||||
|
to the TQt library. The main goal of the project is to extend and
|
||||||
|
enhance the input method support in the TQt library, in order to
|
||||||
|
provide a modern and powerful multi-language input system. Our short
|
||||||
|
term goal is to make TQt (especially TQt/X11) "up-to-date" with other
|
||||||
|
X11-based toolkits such as GTK+. We are also focusing on what the
|
||||||
|
input method API should be for future TQt versions.
|
||||||
|
|
||||||
|
See our webpage for further information.
|
||||||
|
|
||||||
|
http://immodule-qt.freedesktop.org/
|
||||||
|
|
||||||
|
|
||||||
|
* About this release
|
||||||
|
|
||||||
|
qt-x11-immodule-unified-qt3.3.3-20040910 is a stable release. Since
|
||||||
|
it breaks backward compatibility (source and binary) about immodule
|
||||||
|
with our previous releases qt-x11-immodule-unified-qt3.3.3-20040819
|
||||||
|
and qt-x11-immodule-bc-qt3.3.2-20040623, optional immodule plugins
|
||||||
|
must be updated to proper version. See 'Optional immodule plugins'
|
||||||
|
section of our download page.
|
||||||
|
|
||||||
|
http://immodule-qt.freedesktop.org/Software/ImmoduleTQtDownload
|
||||||
|
|
||||||
|
However, backward compatibility (source and binary) with normal TQt
|
||||||
|
3.3.3 is kept in 'Binary Compatible' mode.
|
||||||
|
|
||||||
|
|
||||||
|
* How to install
|
||||||
|
|
||||||
|
After extract the TQt archive, perform following instructions
|
||||||
|
|
||||||
|
cd qt-x11-free-3.3.3
|
||||||
|
patch -p0 < qt-x11-immodule-unified-qt3.3.3-20040910.diff
|
||||||
|
./make-symlinks.sh
|
||||||
|
./configure
|
||||||
|
|
||||||
|
Our patch provides following two configure options. Choose 'Binary
|
||||||
|
Compatible' for normal use.
|
||||||
|
|
||||||
|
Build TQt with 'Binary Compatible' immodule support (default)
|
||||||
|
|
||||||
|
configure -inputmethod
|
||||||
|
|
||||||
|
Build TQt without binary compatibility, but supports more advanced
|
||||||
|
immodule extensions. It cannot be used with ordinary application
|
||||||
|
binaries (i.e. the option is for developers)
|
||||||
|
|
||||||
|
configure -inputmethod -inputmethod-ext
|
||||||
|
|
||||||
|
|
||||||
|
* How to use
|
||||||
|
|
||||||
|
- See users manual of each input method plugins
|
||||||
|
|
||||||
|
- Run qtconfig to choose your favorite XIM input style
|
||||||
|
|
||||||
|
|
||||||
|
* Environment variables
|
||||||
|
|
||||||
|
Some environment variables are available for expert users and system
|
||||||
|
integrators. The specification is preliminary and may be changed
|
||||||
|
without notification. Be careful.
|
||||||
|
|
||||||
|
See following examples to use the variables.
|
||||||
|
|
||||||
|
|
||||||
|
- set "xim" input method as default
|
||||||
|
|
||||||
|
export TQT_IM_MODULE=xim
|
||||||
|
|
||||||
|
|
||||||
|
- set "simple" composing input method as default
|
||||||
|
|
||||||
|
export TQT_IM_MODULE=simple
|
||||||
|
|
||||||
|
|
||||||
|
- set "xim" input method as default, and disable input method
|
||||||
|
selection menu in the context menu
|
||||||
|
|
||||||
|
export TQT_IM_SWITCHER=imsw-none
|
||||||
|
export TQT_IM_MODULE=xim
|
||||||
|
|
||||||
|
|
||||||
|
- set "xim" input method as default, and enable input method
|
||||||
|
selection menu in the context menu (default configuration)
|
||||||
|
|
||||||
|
export TQT_IM_SWITCHER=imsw-multi
|
||||||
|
export TQT_IM_MODULE=xim
|
||||||
|
|
||||||
|
|
||||||
|
- set "iiimqcf" that has its own input method switching framework as
|
||||||
|
default, and disable input method selection menu in the context
|
||||||
|
menu. Such configuration is required by some system integrators to
|
||||||
|
provide unified user interface for global input method switching
|
||||||
|
over the desktop
|
||||||
|
|
||||||
|
export TQT_IM_SWITCHER=imsw-none
|
||||||
|
export TQT_IM_MODULE=iiimqcf
|
@ -0,0 +1,248 @@
|
|||||||
|
This file describes significant change from
|
||||||
|
qt-x11-immodule-bc-qt3.3.2-20040623.
|
||||||
|
|
||||||
|
Differences from previous release
|
||||||
|
(qt-x11-immodule-unified-qt3.3.3-20040819) are itemized with '+'
|
||||||
|
sign. Search it to track incremental change.
|
||||||
|
|
||||||
|
****************************************************************************
|
||||||
|
* For users *
|
||||||
|
****************************************************************************
|
||||||
|
|
||||||
|
General
|
||||||
|
-------
|
||||||
|
|
||||||
|
+ A strange character inversion problem on some input methods has been
|
||||||
|
fixed
|
||||||
|
|
||||||
|
|
||||||
|
Input methods
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Added "simple" input method which provides dead/multi key composing
|
||||||
|
for latin languages
|
||||||
|
|
||||||
|
|
||||||
|
User Interface
|
||||||
|
--------------
|
||||||
|
|
||||||
|
- Added input method selection menu in the context menu of text
|
||||||
|
widgets
|
||||||
|
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
+ default IM configuration feature of qtconfig has been disabled in BC
|
||||||
|
mode. This is a political change to avoid the confusion about input
|
||||||
|
method configuration in accordance with GTK+ environment.
|
||||||
|
|
||||||
|
See following discussion for further information.
|
||||||
|
|
||||||
|
http://freedesktop.org/pipermail/immodule-qt/2004-August/000416.html
|
||||||
|
|
||||||
|
- Added new environment variables TQT_IM_SWITCHER and TQT_IM_MODULE to
|
||||||
|
set user's favorite input method as default. See README.immodule for
|
||||||
|
examples.
|
||||||
|
|
||||||
|
|
||||||
|
Build & Install
|
||||||
|
---------------
|
||||||
|
|
||||||
|
+ configure options have been changed for internal reasons. See 'How
|
||||||
|
to install' section of README.immodule
|
||||||
|
|
||||||
|
- This version of immodule requires corresponding version of each
|
||||||
|
input method plugins (i.e. update your additional input method
|
||||||
|
plugins)
|
||||||
|
|
||||||
|
- Plugin directory has been changed from $TQTDIR/plugins/input/ to
|
||||||
|
$TQTDIR/plugins/inputmethods/. Delete old directory.
|
||||||
|
|
||||||
|
- Some codes have been changed to allow compiling against TQt 3.2.x or
|
||||||
|
earlier.
|
||||||
|
|
||||||
|
|
||||||
|
****************************************************************************
|
||||||
|
* For develpers *
|
||||||
|
****************************************************************************
|
||||||
|
|
||||||
|
Documents
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Almost description of TQInputContext and TQInputContextPlugin has been
|
||||||
|
filled. Feel free to ask obscure things at our mailinglist.
|
||||||
|
|
||||||
|
|
||||||
|
New features
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Pluggable input method switcher
|
||||||
|
|
||||||
|
Now we can write input method switcher as an ordinary input method
|
||||||
|
plugin. The two plugins 'imsw-multi' and 'imsw-none' are provided as
|
||||||
|
default. But the architecture needs more discussion about whether
|
||||||
|
the design is right or not. Join the discussion.
|
||||||
|
|
||||||
|
- Pluggable popup menu
|
||||||
|
|
||||||
|
Any input method can provide its own popup menu. See
|
||||||
|
http://freedesktop.org/pipermail/immodule-qt/2004-August/000266.html
|
||||||
|
for further information.
|
||||||
|
|
||||||
|
- TQInputContext proxying
|
||||||
|
|
||||||
|
Some methods of TQInputContext have been changed to enable
|
||||||
|
TQInputContext proxying. This feature is required to implement
|
||||||
|
pluggable input method switcher.
|
||||||
|
|
||||||
|
|
||||||
|
General
|
||||||
|
-------
|
||||||
|
|
||||||
|
+ TQInputContext has been source compatible with TQt4 version. Basic
|
||||||
|
input method plugin can be source compatible without #ifdef. Only
|
||||||
|
pluggable popup menu requires #ifdef'ed different code. In addition,
|
||||||
|
be careful about use of classes that is deprecated in TQt4.
|
||||||
|
|
||||||
|
- Our two development tree for TQt3 'Binary Compatible' and 'ALL' have
|
||||||
|
been merged into this unified source tree. The source tree is called
|
||||||
|
'Unified' patch.
|
||||||
|
|
||||||
|
- 'dead keys' for latin languages have been added into TQt::Key
|
||||||
|
|
||||||
|
- Added plugins/src/inputmethods directory to build input method
|
||||||
|
plugins within the TQt source tree. The directory name 'inputmethods'
|
||||||
|
is intended to be compatible with TQt/Embedded. Install directory
|
||||||
|
name is still kept as 'input' for backward compatibility
|
||||||
|
|
||||||
|
- Changed XIM input method to a plugin instead of directly link into
|
||||||
|
libqt
|
||||||
|
|
||||||
|
- Plugin directory has been changed from $TQTDIR/plugins/input/ to
|
||||||
|
$TQTDIR/plugins/inputmethods/. Replace install directory with new
|
||||||
|
one.
|
||||||
|
|
||||||
|
- Fixed some bugs in previous qt-x11-immodule-bc-qt3.3.2-20040623. See
|
||||||
|
following log for more detail.
|
||||||
|
|
||||||
|
* src/kernel/tqwidget_x11.cpp
|
||||||
|
- (destroyInputContext): Replace the code with original Simplified
|
||||||
|
API patch. See the comment to recognize the original intention
|
||||||
|
- (focusInputContext): Fix a condition to call qic->setFocus() as
|
||||||
|
originally written. See added comment to recognize the original
|
||||||
|
intention
|
||||||
|
|
||||||
|
- TQLocale dependency has been removed to be compiled on TQt 3.2.x or
|
||||||
|
earlier
|
||||||
|
|
||||||
|
- Many internal improvements and cleanups
|
||||||
|
|
||||||
|
|
||||||
|
API Changes in qt-x11-immodule-unified-qt3.3.3-20040910
|
||||||
|
-------------------------------------------------------
|
||||||
|
+ TQInputContext
|
||||||
|
|
||||||
|
* TQInputContext()
|
||||||
|
|
||||||
|
Added 'tqparent' arg to be compatible with TQt4. Since the arg
|
||||||
|
defaults to 0, no modification of plugins are required.
|
||||||
|
|
||||||
|
* language()
|
||||||
|
* identifierName()
|
||||||
|
|
||||||
|
Return type of these two methods have been changed from TQCString
|
||||||
|
which is deprecated in TQt4 to TQString to make plugins source
|
||||||
|
compatible with TQt4.
|
||||||
|
|
||||||
|
* addActionsTo()
|
||||||
|
|
||||||
|
New method for TQt4 text widget developer
|
||||||
|
|
||||||
|
|
||||||
|
API Changes in qt-x11-immodule-unified-qt3.3.3-20040812
|
||||||
|
-------------------------------------------------------
|
||||||
|
|
||||||
|
- TQInputContext proxying
|
||||||
|
|
||||||
|
TQInputContext have been changed as follows to enable TQInputContext
|
||||||
|
proxying.
|
||||||
|
|
||||||
|
1. Use signal to deliver TQIMEvent instead of explicit
|
||||||
|
postEvent(). This enables TQIMEvent proxying and better platform
|
||||||
|
abstraction. Corresponding slot is created as
|
||||||
|
TQApplication::imEventReceived().
|
||||||
|
|
||||||
|
2. Move some methods of TQInputContext to public from protected or
|
||||||
|
private. This enables that proxy-IM can access slave methods.
|
||||||
|
|
||||||
|
3. Make some methods of TQInputContext virtual. This enables
|
||||||
|
overriding the methods as proxy
|
||||||
|
|
||||||
|
4. Rename TQInputContext::name() to identifierName() to avoid
|
||||||
|
conflicting with TQObject::name()
|
||||||
|
|
||||||
|
|
||||||
|
- TQInputContext
|
||||||
|
|
||||||
|
* language()
|
||||||
|
|
||||||
|
New method to indicate current language
|
||||||
|
|
||||||
|
* menus()
|
||||||
|
|
||||||
|
New method for the pluggable popup menu feature
|
||||||
|
|
||||||
|
* addMenusTo()
|
||||||
|
|
||||||
|
New method for text widget developer
|
||||||
|
|
||||||
|
* deletionRequested()
|
||||||
|
|
||||||
|
New signal to request deletion of this instance. This is added for
|
||||||
|
fatal error handling
|
||||||
|
|
||||||
|
* identifierName()
|
||||||
|
|
||||||
|
This replaces name() of previous API to avoid conflicting with
|
||||||
|
TQObject::name(), and to distinguish the role from displayName()
|
||||||
|
|
||||||
|
* filterEvent()
|
||||||
|
|
||||||
|
Turn the argument into const. See
|
||||||
|
http://freedesktop.org/pipermail/immodule-qt/2004-August/000335.html
|
||||||
|
for further information
|
||||||
|
|
||||||
|
* isComposing
|
||||||
|
* isPreeditRelocationEnabled
|
||||||
|
|
||||||
|
Move to public from protected to allow proxying
|
||||||
|
|
||||||
|
* setFocusWidget
|
||||||
|
* setHolderWidget
|
||||||
|
* releaseComposingWidget
|
||||||
|
|
||||||
|
Move to public from private to allow proxying
|
||||||
|
|
||||||
|
* tqfocusWidget
|
||||||
|
* holderWidget
|
||||||
|
|
||||||
|
- Make public from protected to allow proxying
|
||||||
|
- Make virtual to allow overriding the method as proxy
|
||||||
|
|
||||||
|
- TQInputContextPlugin
|
||||||
|
|
||||||
|
* languages()
|
||||||
|
|
||||||
|
New method which returns what languages are supported by the
|
||||||
|
TQInputContext instance
|
||||||
|
|
||||||
|
* displayName()
|
||||||
|
|
||||||
|
New method which returns a user friendly i18n-ized name of the
|
||||||
|
TQInputContext instance
|
||||||
|
|
||||||
|
* description()
|
||||||
|
|
||||||
|
New method which returns a i18n-ized brief description of the
|
||||||
|
TQInputContext instance
|
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd include
|
||||||
|
rm -f q*.h
|
||||||
|
ln -s ../src/*/tq*.h .
|
||||||
|
ln -s ../extensions/*/src/q*.h .
|
||||||
|
ln -s ../tools/assistant/lib/qassistantclient.h .
|
||||||
|
ln -s ../tools/designer/uilib/qwidgetfactory.h .
|
||||||
|
rm -f q*_p.h
|
||||||
|
cd private
|
||||||
|
rm -f q*_p.h
|
||||||
|
ln -s ../../src/*/tq*_p.h .
|
||||||
|
|
@ -0,0 +1,89 @@
|
|||||||
|
#
|
||||||
|
#
|
||||||
|
# qmake configuration for linux-g++
|
||||||
|
#
|
||||||
|
|
||||||
|
MAKEFILE_GENERATOR = UNIX
|
||||||
|
TEMPLATE = app
|
||||||
|
CONFIG += qt warn_on release incremental link_prl thread
|
||||||
|
TQMAKE_INCREMENTAL_STYLE = sublib
|
||||||
|
|
||||||
|
TQMAKE_CC = gcc
|
||||||
|
TQMAKE_LEX = flex
|
||||||
|
TQMAKE_LEXFLAGS =
|
||||||
|
TQMAKE_YACC = yacc
|
||||||
|
TQMAKE_YACCFLAGS = -d
|
||||||
|
TQMAKE_YACCFLAGS_MANGLE = -p $base -b $base
|
||||||
|
TQMAKE_YACC_HEADER = $base.tab.h
|
||||||
|
TQMAKE_YACC_SOURCE = $base.tab.c
|
||||||
|
TQMAKE_CFLAGS = -pipe -g
|
||||||
|
TQMAKE_CFLAGS_DEPS = -M
|
||||||
|
TQMAKE_CFLAGS_WARN_ON = -Wall -W
|
||||||
|
TQMAKE_CFLAGS_WARN_OFF = -w
|
||||||
|
TQMAKE_CFLAGS_RELEASE = -O1
|
||||||
|
TQMAKE_CFLAGS_DEBUG = -O0
|
||||||
|
TQMAKE_CFLAGS_SHLIB = -fPIC
|
||||||
|
TQMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
|
||||||
|
TQMAKE_CFLAGS_THREAD = -D_REENTRANT
|
||||||
|
|
||||||
|
TQMAKE_CXX = g++
|
||||||
|
TQMAKE_CXXFLAGS = $$TQMAKE_CFLAGS
|
||||||
|
TQMAKE_CXXFLAGS_DEPS = $$TQMAKE_CFLAGS_DEPS
|
||||||
|
TQMAKE_CXXFLAGS_WARN_ON = $$TQMAKE_CFLAGS_WARN_ON
|
||||||
|
TQMAKE_CXXFLAGS_WARN_OFF = $$TQMAKE_CFLAGS_WARN_OFF
|
||||||
|
TQMAKE_CXXFLAGS_RELEASE = $$TQMAKE_CFLAGS_RELEASE
|
||||||
|
TQMAKE_CXXFLAGS_DEBUG = $$TQMAKE_CFLAGS_DEBUG
|
||||||
|
TQMAKE_CXXFLAGS_SHLIB = $$TQMAKE_CFLAGS_SHLIB
|
||||||
|
TQMAKE_CXXFLAGS_YACC = $$TQMAKE_CFLAGS_YACC
|
||||||
|
TQMAKE_CXXFLAGS_THREAD = $$TQMAKE_CFLAGS_THREAD
|
||||||
|
|
||||||
|
TQMAKE_INCDIR =
|
||||||
|
TQMAKE_LIBDIR =
|
||||||
|
TQMAKE_INCDIR_X11 = /usr/X11R6/include
|
||||||
|
TQMAKE_LIBDIR_X11 = /usr/X11R6/lib
|
||||||
|
TQMAKE_INCDIR_QT = $(TQTDIR)/include
|
||||||
|
TQMAKE_LIBDIR_QT = $(TQTDIR)/lib
|
||||||
|
TQMAKE_INCDIR_OPENGL = /usr/X11R6/include
|
||||||
|
TQMAKE_LIBDIR_OPENGL = /usr/X11R6/lib
|
||||||
|
|
||||||
|
TQMAKE_LINK = g++
|
||||||
|
TQMAKE_LINK_SHLIB = g++
|
||||||
|
TQMAKE_LFLAGS =
|
||||||
|
TQMAKE_LFLAGS_RELEASE =
|
||||||
|
TQMAKE_LFLAGS_DEBUG =
|
||||||
|
TQMAKE_LFLAGS_SHLIB = -shared
|
||||||
|
TQMAKE_LFLAGS_PLUGIN = $$TQMAKE_LFLAGS_SHLIB
|
||||||
|
TQMAKE_LFLAGS_SONAME = -Wl,-soname,
|
||||||
|
TQMAKE_LFLAGS_THREAD =
|
||||||
|
TQMAKE_RPATH =
|
||||||
|
|
||||||
|
TQMAKE_LIBS =
|
||||||
|
TQMAKE_LIBS_DYNLOAD = -ldl
|
||||||
|
TQMAKE_LIBS_X11 = -lXext -lX11 -lm
|
||||||
|
TQMAKE_LIBS_X11SM = -lSM -lICE
|
||||||
|
TQMAKE_LIBS_NIS = -lnsl
|
||||||
|
TQMAKE_LIBS_QT = -lqt
|
||||||
|
TQMAKE_LIBS_TQT_THREAD = -lqt-mt
|
||||||
|
TQMAKE_LIBS_OPENGL = -lGLU -lGL -lXmu
|
||||||
|
TQMAKE_LIBS_OPENGL_QT = -lGL -lXmu
|
||||||
|
TQMAKE_LIBS_THREAD = -lpthread
|
||||||
|
|
||||||
|
TQMAKE_TQMOC = $(TQTDIR)/bin/tqmoc
|
||||||
|
TQMAKE_UIC = $(TQTDIR)/bin/uic
|
||||||
|
|
||||||
|
TQMAKE_AR = ar cqs
|
||||||
|
TQMAKE_RANLIB =
|
||||||
|
|
||||||
|
TQMAKE_TAR = tar -cf
|
||||||
|
TQMAKE_GZIP = gzip -9f
|
||||||
|
|
||||||
|
TQMAKE_COPY = cp -f
|
||||||
|
TQMAKE_COPY_FILE = $(COPY)
|
||||||
|
TQMAKE_COPY_DIR = $(COPY) -r
|
||||||
|
TQMAKE_MOVE = mv -f
|
||||||
|
TQMAKE_DEL_FILE = rm -f
|
||||||
|
TQMAKE_DEL_DIR = rmdir
|
||||||
|
TQMAKE_STRIP =
|
||||||
|
TQMAKE_STRIPFLAGS_LIB += --strip-unneeded
|
||||||
|
TQMAKE_CHK_DIR_EXISTS = test -d
|
||||||
|
TQMAKE_MKDIR = mkdir -p
|
@ -0,0 +1,107 @@
|
|||||||
|
#ifndef TQPLATFORMDEFS_H
|
||||||
|
#define TQPLATFORMDEFS_H
|
||||||
|
|
||||||
|
// Get TQt defines/settings
|
||||||
|
|
||||||
|
#include "tqglobal.h"
|
||||||
|
|
||||||
|
// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
|
||||||
|
|
||||||
|
// DNS system header files are a mess!
|
||||||
|
// <resolv.h> includes <arpa/nameser.h>. <arpa/nameser.h> is using
|
||||||
|
// 'u_char' and includes <sys/types.h>. Now the problem is that
|
||||||
|
// <sys/types.h> defines 'u_char' only if __USE_BSD is defined.
|
||||||
|
// __USE_BSD is defined in <features.h> if _BSD_SOURCE is defined.
|
||||||
|
#ifndef _BSD_SOURCE
|
||||||
|
# define _BSD_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 1) need to reset default environment if _BSD_SOURCE is defined
|
||||||
|
// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
|
||||||
|
// 3) it seems older glibc need this to include the X/Open stuff
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
// We are hot - unistd.h should have turned on the specific APIs we requested
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TQT_THREAD_SUPPORT
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <grp.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
// DNS header files are not fully covered by X/Open specifications.
|
||||||
|
// In particular nothing is said about res_* :/
|
||||||
|
// Header files <netinet/in.h> and <arpa/nameser.h> are not included
|
||||||
|
// by <resolv.h> on older versions of the GNU C library. Note that
|
||||||
|
// <arpa/nameser.h> must be included before <resolv.h>.
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/nameser.h>
|
||||||
|
#include <resolv.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_COMPAT)
|
||||||
|
#define TQT_STATBUF struct stat
|
||||||
|
#define TQT_STATBUF4TSTAT struct stat
|
||||||
|
#define TQT_STAT ::stat
|
||||||
|
#define TQT_FSTAT ::fstat
|
||||||
|
#define TQT_STAT_REG S_IFREG
|
||||||
|
#define TQT_STAT_DIR S_IFDIR
|
||||||
|
#define TQT_STAT_MASK S_IFMT
|
||||||
|
#define TQT_STAT_LNK S_IFLNK
|
||||||
|
#define TQT_FILENO fileno
|
||||||
|
#define TQT_OPEN ::open
|
||||||
|
#define TQT_CLOSE ::close
|
||||||
|
#define TQT_LSEEK ::lseek
|
||||||
|
#define TQT_READ ::read
|
||||||
|
#define TQT_WRITE ::write
|
||||||
|
#define TQT_ACCESS ::access
|
||||||
|
#define TQT_GETCWD ::getcwd
|
||||||
|
#define TQT_CHDIR ::chdir
|
||||||
|
#define TQT_MKDIR ::mkdir
|
||||||
|
#define TQT_RMDIR ::rmdir
|
||||||
|
#define TQT_OPEN_RDONLY O_RDONLY
|
||||||
|
#define TQT_OPEN_WRONLY O_WRONLY
|
||||||
|
#define TQT_OPEN_RDWR O_RDWR
|
||||||
|
#define TQT_OPEN_CREAT O_CREAT
|
||||||
|
#define TQT_OPEN_TRUNC O_TRUNC
|
||||||
|
#define TQT_OPEN_APPEND O_APPEND
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TQT_SIGNAL_RETTYPE void
|
||||||
|
#define TQT_SIGNAL_ARGS int
|
||||||
|
#define TQT_SIGNAL_IGNORE SIG_IGN
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && (__GLIBC__ >= 2)
|
||||||
|
#define TQT_SOCKLEN_T socklen_t
|
||||||
|
#else
|
||||||
|
#define TQT_SOCKLEN_T int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
|
||||||
|
#define TQT_SNPRINTF ::snprintf
|
||||||
|
#define TQT_VSNPRINTF ::vsnprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TQT_MITSHM
|
||||||
|
|
||||||
|
#endif // TQPLATFORMDEFS_H
|
@ -0,0 +1,14 @@
|
|||||||
|
TEMPLATE = lib
|
||||||
|
TARGET = qimsw-multi
|
||||||
|
DESTDIR = ../../../inputmethods
|
||||||
|
|
||||||
|
INCLUDEPATH += .
|
||||||
|
CONFIG += qt warn_on debug plugin
|
||||||
|
target.path += $$plugins.path/inputmethods
|
||||||
|
INSTALLS += target
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += qmultiinputcontext.h \
|
||||||
|
qmultiinputcontextplugin.h
|
||||||
|
SOURCES += qmultiinputcontext.cpp \
|
||||||
|
qmultiinputcontextplugin.cpp
|
@ -0,0 +1,379 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Implementation of TQMultiInputContext class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqmultiinputcontext.h"
|
||||||
|
#include <tqinputcontextfactory.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
#include <tqpopupmenu.h>
|
||||||
|
#ifndef TQT_NO_IM_EXTENSIONS
|
||||||
|
#include <tqsettings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#define TQT_NO_IM_TQMULTIINPUTCONTEXT_IMINDEX
|
||||||
|
|
||||||
|
TQMultiInputContext::TQMultiInputContext()
|
||||||
|
: TQInputContext(), _slave( 0 ), imIndex( 0 ), cachedFocus( FALSE ),
|
||||||
|
cachedFocusWidget( 0 ), cachedHolderWidget( 0 ),
|
||||||
|
beIndirectlyConnected( FALSE ), popup( NULL ), currentIMKey( TQString() )
|
||||||
|
{
|
||||||
|
keyDict.setAutoDelete( true );
|
||||||
|
keyDict.clear();
|
||||||
|
|
||||||
|
if ( getenv( "TQT_IM_MODULE" ) ) {
|
||||||
|
currentIMKey = getenv( "TQT_IM_MODULE" );
|
||||||
|
} else {
|
||||||
|
#ifndef TQT_NO_IM_EXTENSIONS
|
||||||
|
TQSettings settings;
|
||||||
|
currentIMKey = settings.readEntry( "/qt/DefaultInputMethod", "xim" );
|
||||||
|
#else
|
||||||
|
currentIMKey = "xim";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TQMultiInputContext::~TQMultiInputContext()
|
||||||
|
{
|
||||||
|
keyDict.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQString TQMultiInputContext::identifierName()
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->identifierName() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQMultiInputContext::language()
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->language() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
bool TQMultiInputContext::x11FilterEvent( TQWidget *keywidget, XEvent *event )
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->x11FilterEvent( keywidget, event ) : FALSE;
|
||||||
|
}
|
||||||
|
#endif // TQ_WS_X11
|
||||||
|
|
||||||
|
|
||||||
|
bool TQMultiInputContext::filterEvent( const TQEvent *event )
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_IM_TQMULTIINPUTCONTEXT_IMINDEX)
|
||||||
|
if ( event->type() == TQEvent::KeyPress ) {
|
||||||
|
TQKeyEvent *keyevent = (TQKeyEvent *)event;
|
||||||
|
|
||||||
|
// filter selection key
|
||||||
|
// Control+Alt+Key_Down: change to next input method
|
||||||
|
// Control+Alt+Key_Up: change to previous input method
|
||||||
|
if ( ( keyevent->state() & TQt::ControlButton ) &&
|
||||||
|
( keyevent->state() & TQt::AltButton ) ) {
|
||||||
|
if ( keyevent->key() == TQt::Key_Up ) {
|
||||||
|
changeInputMethod( --imIndex );
|
||||||
|
return TRUE;
|
||||||
|
} else if ( keyevent->key() == TQt::Key_Down ) {
|
||||||
|
changeInputMethod( ++imIndex );
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ( slave() ) ? slave()->filterEvent( event ) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::reset()
|
||||||
|
{
|
||||||
|
if ( slave() )
|
||||||
|
slave()->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQMultiInputContext::setFocus()
|
||||||
|
{
|
||||||
|
cachedFocus = TRUE;
|
||||||
|
if ( slave() )
|
||||||
|
slave()->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::unsetFocus()
|
||||||
|
{
|
||||||
|
cachedFocus = FALSE;
|
||||||
|
if ( slave() )
|
||||||
|
slave()->unsetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::setMicroFocus( int x, int y, int w, int h, TQFont *f )
|
||||||
|
{
|
||||||
|
if ( slave() )
|
||||||
|
slave()->setMicroFocus( x, y, w, h, f );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button,
|
||||||
|
TQt::ButtonState state )
|
||||||
|
{
|
||||||
|
if ( slave() )
|
||||||
|
slave()->mouseHandler( x, type, button, state );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQFont TQMultiInputContext::font() const
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->font() : TQInputContext::font();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::destroyInputContext()
|
||||||
|
{
|
||||||
|
if ( _slave ) {
|
||||||
|
// _slave->reset() may not properly work in the case, so we
|
||||||
|
// manually resets the composing state of text widget
|
||||||
|
if ( _slave->tqfocusWidget() ) {
|
||||||
|
TQIMEvent *terminator = new TQIMEvent( TQEvent::IMEnd, TQString(), -1 );
|
||||||
|
emit imEventGenerated( _slave->tqfocusWidget(), terminator );
|
||||||
|
}
|
||||||
|
_slave->deleteLater();
|
||||||
|
_slave = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function is a placeholder for future experiment or extension
|
||||||
|
such as commit string snooping. set beIndirectlyConnected = TRUE
|
||||||
|
to activate this virtual function.
|
||||||
|
*/
|
||||||
|
void TQMultiInputContext::postIMEvent( TQObject *receiver, TQIMEvent *event )
|
||||||
|
{
|
||||||
|
emit imEventGenerated( receiver, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
TQWidget *TQMultiInputContext::tqfocusWidget() const
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->tqfocusWidget() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQWidget *TQMultiInputContext::holderWidget() const
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->holderWidget() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQMultiInputContext::setFocusWidget( TQWidget *w )
|
||||||
|
{
|
||||||
|
cachedFocusWidget = w;
|
||||||
|
if ( slave() )
|
||||||
|
slave()->setFocusWidget( w );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::setHolderWidget( TQWidget *w )
|
||||||
|
{
|
||||||
|
cachedHolderWidget = w;
|
||||||
|
if ( slave() )
|
||||||
|
slave()->setHolderWidget( w );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::releaseComposingWidget( TQWidget *w )
|
||||||
|
{
|
||||||
|
if ( slave() )
|
||||||
|
slave()->releaseComposingWidget( w );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool TQMultiInputContext::isComposing() const
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->isComposing() : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TQMultiInputContext::isPreeditRelocationEnabled()
|
||||||
|
{
|
||||||
|
return ( slave() ) ? slave()->isPreeditRelocationEnabled() : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContext *TQMultiInputContext::slave()
|
||||||
|
{
|
||||||
|
if ( ! _slave ) {
|
||||||
|
#if !defined(TQT_NO_IM_TQMULTIINPUTCONTEXT_IMINDEX)
|
||||||
|
changeInputMethod( imIndex );
|
||||||
|
#else
|
||||||
|
changeInputMethod( currentIMKey );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return _slave;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TQInputContext *TQMultiInputContext::slave() const
|
||||||
|
{
|
||||||
|
return _slave;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::changeInputMethod( int newIndex )
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_IM_TQMULTIINPUTCONTEXT_IMINDEX)
|
||||||
|
TQStringList keys = TQInputContextFactory::keys();
|
||||||
|
if ( keys.size() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( newIndex >= (int)keys.size() ) {
|
||||||
|
imIndex = 0;
|
||||||
|
} else if ( newIndex < 0 ) {
|
||||||
|
imIndex = keys.size() - 1;
|
||||||
|
} else {
|
||||||
|
imIndex = newIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeInputMethod( keys[imIndex] );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::changeInputMethod( TQString key )
|
||||||
|
{
|
||||||
|
TQStringList keys = TQInputContextFactory::keys();
|
||||||
|
if ( keys.size() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( key.isEmpty() )
|
||||||
|
key = keys[0];
|
||||||
|
|
||||||
|
if ( _slave ) {
|
||||||
|
_slave->reset();
|
||||||
|
delete _slave;
|
||||||
|
}
|
||||||
|
|
||||||
|
_slave = TQInputContextFactory::create( key, cachedHolderWidget );
|
||||||
|
if ( _slave ) {
|
||||||
|
insertChild( _slave );
|
||||||
|
|
||||||
|
const char *method;
|
||||||
|
if ( beIndirectlyConnected ) {
|
||||||
|
method = TQT_SLOT(imEventReceived(TQObject *,TQIMEvent *));
|
||||||
|
} else {
|
||||||
|
method = TQT_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *));
|
||||||
|
}
|
||||||
|
connect( _slave, TQT_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)),
|
||||||
|
this, method );
|
||||||
|
connect( _slave, TQT_SIGNAL(deletionRequested()),
|
||||||
|
this, TQT_SLOT(destroyInputContext()) );
|
||||||
|
|
||||||
|
if ( cachedFocus ) {
|
||||||
|
_slave->setFocus();
|
||||||
|
_slave->setFocusWidget( cachedFocusWidget );
|
||||||
|
}
|
||||||
|
|
||||||
|
currentIMKey = key;
|
||||||
|
|
||||||
|
//qDebug( "TQMultiInputContext::changeInputMethod(): index=%d, slave=%s",
|
||||||
|
// imIndex, (const char *)_slave->identifierName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TQPtrList<TQInputContextMenu> *TQMultiInputContext::menus()
|
||||||
|
{
|
||||||
|
TQInputContextMenu *imSelMenu = new TQInputContextMenu;
|
||||||
|
imSelMenu->title = tr( "Select Input &Method" );
|
||||||
|
imSelMenu->popup = createImSelPopup();
|
||||||
|
|
||||||
|
TQPtrList<TQInputContextMenu> *result = new TQPtrList<TQInputContextMenu>;
|
||||||
|
result->append( imSelMenu );
|
||||||
|
|
||||||
|
TQPtrList<TQInputContextMenu> *slaveMenus = ( slave() ) ? slave()->menus() : 0;
|
||||||
|
if ( slaveMenus ) {
|
||||||
|
for ( TQPtrList<TQInputContextMenu>::Iterator it = slaveMenus->begin();
|
||||||
|
it != slaveMenus->end();
|
||||||
|
++it ) {
|
||||||
|
TQInputContextMenu *slaveMenu = *it;
|
||||||
|
result->append( slaveMenu );
|
||||||
|
}
|
||||||
|
delete slaveMenus;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQPopupMenu *TQMultiInputContext::createImSelPopup()
|
||||||
|
{
|
||||||
|
if ( popup )
|
||||||
|
delete popup;
|
||||||
|
|
||||||
|
popup = new TQPopupMenu();
|
||||||
|
keyDict.clear();
|
||||||
|
|
||||||
|
TQStringList keys = TQInputContextFactory::keys();
|
||||||
|
for ( uint i=0; i < keys.size(); i++ ) {
|
||||||
|
TQString idName = keys[i];
|
||||||
|
bool isIMSwitcher = idName.startsWith( "imsw-" );
|
||||||
|
|
||||||
|
if ( ! isIMSwitcher ) {
|
||||||
|
TQString dispName = TQInputContextFactory::displayName( idName );
|
||||||
|
if ( dispName.isEmpty() )
|
||||||
|
dispName = idName;
|
||||||
|
|
||||||
|
int id = popup->insertItem( dispName );
|
||||||
|
keyDict.insert( (long)id, new TQString( idName ) );
|
||||||
|
|
||||||
|
if ( idName == currentIMKey )
|
||||||
|
popup->setItemChecked( id, true );
|
||||||
|
|
||||||
|
TQString descriptionStr = TQInputContextFactory::description( idName );
|
||||||
|
if ( ! descriptionStr.isEmpty() )
|
||||||
|
popup->setWhatsThis( id, descriptionStr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TQObject::connect( popup, TQT_SIGNAL(activated(int)),
|
||||||
|
this, TQT_SLOT(changeInputMethodWithMenuId(int)) );
|
||||||
|
|
||||||
|
return popup;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQMultiInputContext::changeInputMethodWithMenuId( int menuid )
|
||||||
|
{
|
||||||
|
TQString *key = keyDict.tqfind( (long)menuid );
|
||||||
|
changeInputMethod( (*key) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,124 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Definition of TQMultiInputContext class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQMULTIINPUTCONTEXT_H
|
||||||
|
#define TQMULTIINPUTCONTEXT_H
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
|
||||||
|
#include <tqnamespace.h>
|
||||||
|
#include <tqwidget.h>
|
||||||
|
#include <tqinputcontext.h>
|
||||||
|
#include <tqguardedptr.h>
|
||||||
|
#include <tqintdict.h>
|
||||||
|
|
||||||
|
class TQPopupMenu;
|
||||||
|
|
||||||
|
class TQMultiInputContext : public TQInputContext
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQMultiInputContext();
|
||||||
|
~TQMultiInputContext();
|
||||||
|
|
||||||
|
TQString identifierName();
|
||||||
|
TQString language();
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
bool x11FilterEvent( TQWidget *keywidget, XEvent *event );
|
||||||
|
#endif // TQ_WS_X11
|
||||||
|
bool filterEvent( const TQEvent *event );
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void setFocus();
|
||||||
|
void unsetFocus();
|
||||||
|
void setMicroFocus( int x, int y, int w, int h, TQFont *f = 0 );
|
||||||
|
void mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button, TQt::ButtonState state );
|
||||||
|
TQFont font() const;
|
||||||
|
bool isComposing() const;
|
||||||
|
bool isPreeditRelocationEnabled();
|
||||||
|
|
||||||
|
#if ([[[TQT_VERSION IS DEPRECATED]]]-0 >= 0x040000)
|
||||||
|
TQPtrList<TQMenu> *qt4menus();
|
||||||
|
#endif
|
||||||
|
TQPtrList<TQInputContextMenu> *menus();
|
||||||
|
TQPopupMenu *createImSelPopup();
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
TQWidget *tqfocusWidget() const;
|
||||||
|
TQWidget *holderWidget() const;
|
||||||
|
|
||||||
|
void setFocusWidget( TQWidget *w );
|
||||||
|
void setHolderWidget( TQWidget *w );
|
||||||
|
void releaseComposingWidget( TQWidget *w );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void destroyInputContext();
|
||||||
|
virtual void postIMEvent( TQObject *receiver, TQIMEvent *event );
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void changeInputMethodWithMenuId( int menuid );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TQInputContext *slave();
|
||||||
|
const TQInputContext *slave() const;
|
||||||
|
|
||||||
|
void changeInputMethod( int newIndex );
|
||||||
|
void changeInputMethod( TQString name );
|
||||||
|
|
||||||
|
TQInputContext *_slave;
|
||||||
|
int imIndex;
|
||||||
|
bool cachedFocus;
|
||||||
|
TQWidget *cachedFocusWidget;
|
||||||
|
TQWidget *cachedHolderWidget;
|
||||||
|
bool beIndirectlyConnected;
|
||||||
|
|
||||||
|
TQIntDict<TQString> keyDict;
|
||||||
|
TQGuardedPtr<TQPopupMenu> popup;
|
||||||
|
TQString currentIMKey;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //TQ_NO_IM
|
||||||
|
|
||||||
|
#endif // TQMULTIINPUTCONTEXT_H
|
@ -0,0 +1,88 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Implementation of TQMultiInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqmultiinputcontext.h"
|
||||||
|
#include "tqmultiinputcontextplugin.h"
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
TQMultiInputContextPlugin::TQMultiInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQMultiInputContextPlugin::~TQMultiInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQMultiInputContextPlugin::keys() const
|
||||||
|
{
|
||||||
|
// input method switcher should named with "imsw-" prefix to
|
||||||
|
// prevent to be listed in ordinary input method list.
|
||||||
|
return TQStringList( "imsw-multi" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContext *TQMultiInputContextPlugin::create( const TQString &key )
|
||||||
|
{
|
||||||
|
return new TQMultiInputContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQMultiInputContextPlugin::languages( const TQString &key )
|
||||||
|
{
|
||||||
|
return TQStringList( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQMultiInputContextPlugin::displayName( const TQString &key )
|
||||||
|
{
|
||||||
|
return tr( "Multiple Input Method Switcher" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQMultiInputContextPlugin::description( const TQString &key )
|
||||||
|
{
|
||||||
|
return tr( "Multiple input method switcher that uses the context menu of the text widgets" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQ_EXPORT_PLUGIN( TQMultiInputContextPlugin )
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Definition of TQMultiInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqmultiinputcontext.h"
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
class TQMultiInputContextPlugin : public TQInputContextPlugin
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQMultiInputContextPlugin();
|
||||||
|
~TQMultiInputContextPlugin();
|
||||||
|
|
||||||
|
TQStringList keys() const;
|
||||||
|
TQInputContext *create( const TQString &key );
|
||||||
|
TQStringList languages( const TQString &key );
|
||||||
|
TQString displayName( const TQString &key );
|
||||||
|
TQString description( const TQString &key );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,12 @@
|
|||||||
|
TEMPLATE = lib
|
||||||
|
TARGET = qimsw-none
|
||||||
|
DESTDIR = ../../../inputmethods
|
||||||
|
|
||||||
|
INCLUDEPATH += .
|
||||||
|
CONFIG += qt warn_on debug plugin
|
||||||
|
target.path += $$plugins.path/inputmethods
|
||||||
|
INSTALLS += target
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += qnoneinputcontextplugin.h
|
||||||
|
SOURCES += qnoneinputcontextplugin.cpp
|
@ -0,0 +1,101 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Implementation of TQNoneInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqnoneinputcontextplugin.h"
|
||||||
|
#include <tqinputcontextfactory.h>
|
||||||
|
#include <tqsettings.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
|
TQNoneInputContextPlugin::TQNoneInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQNoneInputContextPlugin::~TQNoneInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQNoneInputContextPlugin::keys() const
|
||||||
|
{
|
||||||
|
// input method switcher should named with "imsw-" prefix to
|
||||||
|
// prevent to be listed in ordinary input method list.
|
||||||
|
return TQStringList( "imsw-none" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContext *TQNoneInputContextPlugin::create( const TQString &key )
|
||||||
|
{
|
||||||
|
TQString actuallySpecifiedKey;
|
||||||
|
|
||||||
|
bool isIMSwitcher = key.startsWith( "imsw-" );
|
||||||
|
if ( ! isIMSwitcher )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ( getenv( "TQT_IM_MODULE" ) ) {
|
||||||
|
actuallySpecifiedKey = getenv( "TQT_IM_MODULE" );
|
||||||
|
} else {
|
||||||
|
TQSettings settings;
|
||||||
|
actuallySpecifiedKey = settings.readEntry( "/qt/DefaultInputMethod", "xim" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return TQInputContextFactory::create( actuallySpecifiedKey, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQNoneInputContextPlugin::languages( const TQString &key )
|
||||||
|
{
|
||||||
|
return TQStringList( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQNoneInputContextPlugin::displayName( const TQString &key )
|
||||||
|
{
|
||||||
|
return tr( "Dummy Input Method Switcher" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQNoneInputContextPlugin::description( const TQString &key )
|
||||||
|
{
|
||||||
|
return tr( "Dummy input method switcher that uses the context menu of the text widgets" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQ_EXPORT_PLUGIN( TQNoneInputContextPlugin )
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,62 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Definition of TQNoneInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
class TQNoneInputContextPlugin : public TQInputContextPlugin
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQNoneInputContextPlugin();
|
||||||
|
~TQNoneInputContextPlugin();
|
||||||
|
|
||||||
|
TQStringList keys() const;
|
||||||
|
TQInputContext *create( const TQString &key );
|
||||||
|
TQStringList languages( const TQString &key );
|
||||||
|
TQString displayName( const TQString &key );
|
||||||
|
TQString description( const TQString &key );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,11 @@
|
|||||||
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
|
unix {
|
||||||
|
!embedded:!mac:CONFIG += x11
|
||||||
|
}
|
||||||
|
# XIM should be enabled only for X11 platform, but following
|
||||||
|
# configuration is not working properly yet
|
||||||
|
#im:x11:SUBDIRS += xim
|
||||||
|
|
||||||
|
inputmethod:SUBDIRS += imsw-none imsw-multi simple
|
||||||
|
inputmethod:SUBDIRS += xim
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@
|
|||||||
|
TEMPLATE = lib
|
||||||
|
TARGET = qsimple
|
||||||
|
DESTDIR = ../../../inputmethods
|
||||||
|
|
||||||
|
INCLUDEPATH += .
|
||||||
|
CONFIG += qt warn_on debug plugin
|
||||||
|
target.path += $$plugins.path/inputmethods
|
||||||
|
INSTALLS += target
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += qsimpleinputcontext.h \
|
||||||
|
qsimpleinputcontextplugin.h
|
||||||
|
SOURCES += qsimpleinputcontext.cpp \
|
||||||
|
qsimpleinputcontextplugin.cpp \
|
||||||
|
composetable.cpp
|
@ -0,0 +1,285 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Implementation of TQSimpleInputContext class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "tqsimpleinputcontext.h"
|
||||||
|
|
||||||
|
#include <tqnamespace.h>
|
||||||
|
#include <tqevent.h>
|
||||||
|
#include <tqglobal.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
static const int ignoreKeys[] = {
|
||||||
|
TQt::Key_Shift,
|
||||||
|
TQt::Key_Control,
|
||||||
|
TQt::Key_Meta,
|
||||||
|
TQt::Key_Alt,
|
||||||
|
TQt::Key_CapsLock,
|
||||||
|
TQt::Key_Super_L,
|
||||||
|
TQt::Key_Super_R,
|
||||||
|
TQt::Key_Hyper_L,
|
||||||
|
TQt::Key_Hyper_R,
|
||||||
|
TQt::Key_Mode_switch
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int composingKeys[] = {
|
||||||
|
TQt::Key_Multi_key,
|
||||||
|
TQt::Key_Dead_Grave,
|
||||||
|
TQt::Key_Dead_Acute,
|
||||||
|
TQt::Key_Dead_Circumflex,
|
||||||
|
TQt::Key_Dead_Tilde,
|
||||||
|
TQt::Key_Dead_Macron,
|
||||||
|
TQt::Key_Dead_Breve,
|
||||||
|
TQt::Key_Dead_Abovedot,
|
||||||
|
TQt::Key_Dead_Diaeresis,
|
||||||
|
TQt::Key_Dead_Abovering,
|
||||||
|
TQt::Key_Dead_Doubleacute,
|
||||||
|
TQt::Key_Dead_Caron,
|
||||||
|
TQt::Key_Dead_Cedilla,
|
||||||
|
TQt::Key_Dead_Ogonek,
|
||||||
|
TQt::Key_Dead_Iota,
|
||||||
|
TQt::Key_Dead_Voiced_Sound,
|
||||||
|
TQt::Key_Dead_Semivoiced_Sound,
|
||||||
|
TQt::Key_Dead_Belowdot,
|
||||||
|
TQt::Key_Dead_Hook,
|
||||||
|
TQt::Key_Dead_Horn
|
||||||
|
};
|
||||||
|
|
||||||
|
class Cmp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool operator () (const TQComposeTableElement &lhs, const TQComposeTableElement &rhs) const {
|
||||||
|
for ( size_t i=0; i < TQT_KEYSEQUENCE_MAX_LEN; i++ ) {
|
||||||
|
if ( lhs.keys[i] < rhs.keys[i] ) return TRUE;
|
||||||
|
else
|
||||||
|
if ( lhs.keys[i] > rhs.keys[i] ) return FALSE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator () (const TQComposeTableElement &lhs, const uint rhs[TQT_KEYSEQUENCE_MAX_LEN]) const {
|
||||||
|
for ( size_t i=0; i < TQT_KEYSEQUENCE_MAX_LEN; i++ ) {
|
||||||
|
if ( lhs.keys[i] < rhs[i] ) return TRUE;
|
||||||
|
else
|
||||||
|
if ( lhs.keys[i] > rhs[i] ) return FALSE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TQSimpleInputContext::TQSimpleInputContext()
|
||||||
|
: TQInputContext()
|
||||||
|
{
|
||||||
|
clearComposeBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
TQSimpleInputContext::~TQSimpleInputContext()
|
||||||
|
{
|
||||||
|
clearComposeBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TQSimpleInputContext::filterEvent( const TQEvent *event )
|
||||||
|
{
|
||||||
|
if ( event->type() != TQEvent::KeyPress )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
TQKeyEvent *keyevent = (TQKeyEvent *)event;
|
||||||
|
int keyval = keyevent->key();
|
||||||
|
int val = 0;
|
||||||
|
|
||||||
|
if ( isIgnoreKeys( keyval ) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if ( isComposingKeys( keyval ) ) {
|
||||||
|
// If composing keys are pressed, use keyval directly
|
||||||
|
val = UNITIZE( keyval );
|
||||||
|
} else {
|
||||||
|
TQString text = keyevent->text();
|
||||||
|
if ( text.isEmpty() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// If not composing keys are pressed, use the character's tqunicode value
|
||||||
|
// NOTE : The contents of TQKeyEvent::text() is restricted to
|
||||||
|
// only one character. See description of
|
||||||
|
// TQInputContext::filterEvent() about key compression.
|
||||||
|
val = text[0].tqunicode();
|
||||||
|
// qDebug( "str = %s", (const char*)keyevent->text().local8Bit() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store value
|
||||||
|
int nCompose = 0;
|
||||||
|
while ( composeBuffer[nCompose] != 0 && nCompose < TQT_KEYSEQUENCE_MAX_LEN )
|
||||||
|
nCompose++;
|
||||||
|
|
||||||
|
if ( nCompose == TQT_KEYSEQUENCE_MAX_LEN ) {
|
||||||
|
clearComposeBuffer();
|
||||||
|
nCompose = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
composeBuffer[nCompose] = val;
|
||||||
|
|
||||||
|
// check sequence
|
||||||
|
if( checkComposeTable( composeBuffer, &defaultComposeTable ) )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQSimpleInputContext::setFocus()
|
||||||
|
{
|
||||||
|
//qDebug( "TQSimpleInputContext: %p->setFocus(), tqfocusWidget()=%p",
|
||||||
|
//this, tqfocusWidget() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQSimpleInputContext::unsetFocus()
|
||||||
|
{
|
||||||
|
//qDebug( "TQSimpleInputContext: %p->unsetFocus(), tqfocusWidget()=%p",
|
||||||
|
//this, tqfocusWidget() );
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQSimpleInputContext::setMicroFocus( int x, int y, int w, int h, TQFont *f )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQSimpleInputContext::mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button,
|
||||||
|
TQt::ButtonState state )
|
||||||
|
{
|
||||||
|
switch ( type ) {
|
||||||
|
case TQEvent::MouseButtonPress:
|
||||||
|
case TQEvent::MouseButtonRelease:
|
||||||
|
case TQEvent::MouseButtonDblClick:
|
||||||
|
case TQEvent::MouseMove:
|
||||||
|
// qDebug( "TQSimpleInputContext::mouseHandler: "
|
||||||
|
// "x=%d, type=%d, button=%d, state=%d", x, type, button, state );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQSimpleInputContext::reset()
|
||||||
|
{
|
||||||
|
clearComposeBuffer();
|
||||||
|
TQInputContext::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQSimpleInputContext::identifierName()
|
||||||
|
{
|
||||||
|
return "simple";
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQSimpleInputContext::language()
|
||||||
|
{
|
||||||
|
return ""; // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TQSimpleInputContext::isIgnoreKeys( int keyval )
|
||||||
|
{
|
||||||
|
for ( uint i = 0; i < (sizeof(ignoreKeys)/sizeof(ignoreKeys[0])); i++ )
|
||||||
|
if ( keyval == ignoreKeys[i] )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TQSimpleInputContext::isComposingKeys( int keyval )
|
||||||
|
{
|
||||||
|
for ( uint i = 0; i < (sizeof(composingKeys)/sizeof(composingKeys[0])); i++ )
|
||||||
|
if ( keyval == composingKeys[i] )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TQSimpleInputContext::checkComposeTable( uint* composeBuffer, const TQComposeTable *composeTable )
|
||||||
|
{
|
||||||
|
const TQComposeTableElement *p = std::lower_bound( composeTable->data,
|
||||||
|
composeTable->data + composeTable->size,
|
||||||
|
composeBuffer,
|
||||||
|
Cmp() );
|
||||||
|
|
||||||
|
// no entries were found
|
||||||
|
if ( p == composeTable->data + composeTable->size ) {
|
||||||
|
// qDebug( "no match" );
|
||||||
|
clearComposeBuffer();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if compose buffer is matched
|
||||||
|
for ( int i=0; i < TQT_KEYSEQUENCE_MAX_LEN; i++ ) {
|
||||||
|
|
||||||
|
// check if partial match
|
||||||
|
if ( composeBuffer[i] == 0 && p->keys[i] ) {
|
||||||
|
// qDebug("partial match");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( composeBuffer[i] != p->keys[i] ) {
|
||||||
|
// qDebug("different entry");
|
||||||
|
clearComposeBuffer();
|
||||||
|
return i!=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// qDebug("match exactly");
|
||||||
|
|
||||||
|
// match exactly
|
||||||
|
commitChar( p->value );
|
||||||
|
clearComposeBuffer();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQSimpleInputContext::commitChar( uint c )
|
||||||
|
{
|
||||||
|
sendIMEvent( TQEvent::IMStart );
|
||||||
|
sendIMEvent( TQEvent::IMEnd, TQString(TQChar(c)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQSimpleInputContext::clearComposeBuffer(void)
|
||||||
|
{
|
||||||
|
for ( uint i=0; i < (sizeof(composeBuffer)/sizeof(int)); i++ )
|
||||||
|
composeBuffer[i] = 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Definition of TQSimpleInputContext class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQSIMPLEINPUT_CONTEXT_H
|
||||||
|
#define TQSIMPLEINPUT_CONTEXT_H
|
||||||
|
|
||||||
|
#include <tqinputcontext.h>
|
||||||
|
#include <tqnamespace.h>
|
||||||
|
|
||||||
|
#define TQT_KEYSEQUENCE_MAX_LEN 6
|
||||||
|
#define UNITIZE(qkey) (0x02000000|qkey)
|
||||||
|
|
||||||
|
struct TQComposeTableElement {
|
||||||
|
uint keys[TQT_KEYSEQUENCE_MAX_LEN];
|
||||||
|
uint value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TQComposeTable {
|
||||||
|
const TQComposeTableElement *data;
|
||||||
|
uint size;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TQSimpleInputContext : public TQInputContext {
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQSimpleInputContext();
|
||||||
|
~TQSimpleInputContext();
|
||||||
|
|
||||||
|
virtual TQString identifierName();
|
||||||
|
virtual TQString language();
|
||||||
|
|
||||||
|
virtual bool filterEvent( const TQEvent *event );
|
||||||
|
virtual void reset();
|
||||||
|
virtual void setFocus();
|
||||||
|
virtual void unsetFocus();
|
||||||
|
virtual void setMicroFocus( int x, int y, int w, int h, TQFont *f = 0 );
|
||||||
|
virtual void mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button, TQt::ButtonState state );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool isIgnoreKeys(int keyval );
|
||||||
|
bool isComposingKeys( int keyval );
|
||||||
|
bool checkComposeTable( uint composeBuffer[], const TQComposeTable *composeTable );
|
||||||
|
void commitChar( uint c );
|
||||||
|
|
||||||
|
void clearComposeBuffer(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint composeBuffer[TQT_KEYSEQUENCE_MAX_LEN + 1];
|
||||||
|
static const TQComposeTable defaultComposeTable;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TQSIMPLEINPUT_CONTEXT_H
|
@ -0,0 +1,86 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Implementation of TQSimpleInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqsimpleinputcontext.h"
|
||||||
|
#include "tqsimpleinputcontextplugin.h"
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
TQSimpleInputContextPlugin::TQSimpleInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQSimpleInputContextPlugin::~TQSimpleInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQSimpleInputContextPlugin::keys() const
|
||||||
|
{
|
||||||
|
return TQStringList( "simple" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContext *TQSimpleInputContextPlugin::create( const TQString & )
|
||||||
|
{
|
||||||
|
return new TQSimpleInputContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQSimpleInputContextPlugin::languages( const TQString & )
|
||||||
|
{
|
||||||
|
return TQStringList( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQSimpleInputContextPlugin::displayName( const TQString & )
|
||||||
|
{
|
||||||
|
return tr( "Simple Composing Input Method" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQSimpleInputContextPlugin::description( const TQString & )
|
||||||
|
{
|
||||||
|
return tr( "Simple composing input method" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQ_EXPORT_PLUGIN( TQSimpleInputContextPlugin )
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Definition of TQSimpleInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqsimpleinputcontext.h"
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
class TQSimpleInputContextPlugin : public TQInputContextPlugin
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQSimpleInputContextPlugin();
|
||||||
|
~TQSimpleInputContextPlugin();
|
||||||
|
|
||||||
|
TQStringList keys() const;
|
||||||
|
TQInputContext *create( const TQString &key );
|
||||||
|
TQStringList languages( const TQString &key );
|
||||||
|
TQString displayName( const TQString &key );
|
||||||
|
TQString description( const TQString &key );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,450 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
# xcompose2q.rb: X Compose table to TQSimpleInputContext table translator
|
||||||
|
# Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
#
|
||||||
|
# This file is written to contribute to Trolltech AS under their own
|
||||||
|
# licence. You may use this file under your TQt license. Following
|
||||||
|
# description is copied from their original file headers. Contact
|
||||||
|
# immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
# not clear to you.
|
||||||
|
|
||||||
|
# This file may be distributed under the terms of the Q Public License
|
||||||
|
# as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
# LICENSE.TQPL included in the packaging of this file.
|
||||||
|
#
|
||||||
|
# This file may be distributed and/or modified under the terms of the
|
||||||
|
# GNU General Public License version 2 as published by the Free Software
|
||||||
|
# Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
# packaging of this file.
|
||||||
|
#
|
||||||
|
# Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
# licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
# Agreement provided with the Software.
|
||||||
|
#
|
||||||
|
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
#
|
||||||
|
# See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
# information about TQt Commercial License Agreements.
|
||||||
|
# See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
# See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
#
|
||||||
|
# Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
# not clear to you.
|
||||||
|
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# xcompose2q.rb /usr/X11R6/lib/X11/locale/en_US.UTF-8/Compose
|
||||||
|
|
||||||
|
require 'uconv'
|
||||||
|
|
||||||
|
# translation table for lazy sorting
|
||||||
|
raw2key = {
|
||||||
|
"0y1120" => "UNITIZE(TQt::Key_Multi_key)",
|
||||||
|
"0y1250" => "UNITIZE(TQt::Key_Dead_Grave)",
|
||||||
|
"0y1251" => "UNITIZE(TQt::Key_Dead_Acute)",
|
||||||
|
"0y1252" => "UNITIZE(TQt::Key_Dead_Circumflex)",
|
||||||
|
"0y1253" => "UNITIZE(TQt::Key_Dead_Tilde)",
|
||||||
|
"0y1254" => "UNITIZE(TQt::Key_Dead_Macron)",
|
||||||
|
"0y1255" => "UNITIZE(TQt::Key_Dead_Breve)",
|
||||||
|
"0y1256" => "UNITIZE(TQt::Key_Dead_Abovedot)",
|
||||||
|
"0y1257" => "UNITIZE(TQt::Key_Dead_Diaeresis)",
|
||||||
|
"0y1258" => "UNITIZE(TQt::Key_Dead_Abovering)",
|
||||||
|
"0y1259" => "UNITIZE(TQt::Key_Dead_Doubleacute)",
|
||||||
|
"0y125a" => "UNITIZE(TQt::Key_Dead_Caron)",
|
||||||
|
"0y125b" => "UNITIZE(TQt::Key_Dead_Cedilla)",
|
||||||
|
"0y125c" => "UNITIZE(TQt::Key_Dead_Ogonek)",
|
||||||
|
"0y125d" => "UNITIZE(TQt::Key_Dead_Iota)",
|
||||||
|
"0y125e" => "UNITIZE(TQt::Key_Dead_Voiced_Sound)",
|
||||||
|
"0y125f" => "UNITIZE(TQt::Key_Dead_Semivoiced_Sound)",
|
||||||
|
"0y1260" => "UNITIZE(TQt::Key_Dead_Belowdot)",
|
||||||
|
"0y1261" => "UNITIZE(TQt::Key_Dead_Hook)",
|
||||||
|
"0y1262" => "UNITIZE(TQt::Key_Dead_Horn)",
|
||||||
|
}
|
||||||
|
|
||||||
|
# X's KeySym to Unicode translation table. The tqunicode value is
|
||||||
|
# extracted from
|
||||||
|
# TQETWidget::translateKeyEventInternal(). Translation for some
|
||||||
|
# keys are not available
|
||||||
|
x2q = {
|
||||||
|
"Multi_key" => "0y1120",
|
||||||
|
"dead_grave" => "0y1250",
|
||||||
|
"dead_acute" => "0y1251",
|
||||||
|
"dead_circumflex" => "0y1252",
|
||||||
|
"dead_tilde" => "0y1253",
|
||||||
|
"dead_macron" => "0y1254",
|
||||||
|
"dead_breve" => "0y1255",
|
||||||
|
"dead_abovedot" => "0y1256",
|
||||||
|
"dead_diaeresis" => "0y1257",
|
||||||
|
"dead_abovering" => "0y1258",
|
||||||
|
"dead_doubleacute" => "0y1259",
|
||||||
|
"dead_caron" => "0y125a",
|
||||||
|
"dead_cedilla" => "0y125b",
|
||||||
|
"dead_ogonek" => "0y125c",
|
||||||
|
"dead_iota" => "0y125d",
|
||||||
|
"dead_voiced_sound" => "0y125e",
|
||||||
|
"dead_semivoiced_sound" => "0y125f",
|
||||||
|
"dead_belowdot" => "0y1260",
|
||||||
|
"dead_hook" => "0y1261",
|
||||||
|
"dead_horn" => "0y1262",
|
||||||
|
|
||||||
|
"0" => "0x0030",
|
||||||
|
"1" => "0x0031",
|
||||||
|
"2" => "0x0032",
|
||||||
|
"3" => "0x0033",
|
||||||
|
"4" => "0x0034",
|
||||||
|
"5" => "0x0035",
|
||||||
|
"6" => "0x0036",
|
||||||
|
"7" => "0x0037",
|
||||||
|
"8" => "0x0038",
|
||||||
|
"9" => "0x0039",
|
||||||
|
"A" => "0x0041",
|
||||||
|
"AE" => "0x00c6",
|
||||||
|
"Abreve" => "0x0102",
|
||||||
|
"Acircumflex" => "0x00c2",
|
||||||
|
"Adiaeresis" => "0x00c4",
|
||||||
|
"Arabic_alef" => "0x0627",
|
||||||
|
"Arabic_waw" => "0x0648",
|
||||||
|
"Arabic_yeh" => "0x064a",
|
||||||
|
"Aring" => "0x00c5",
|
||||||
|
"B" => "0x0042",
|
||||||
|
"C" => "0x0043",
|
||||||
|
"Ccedilla" => "0x00c7",
|
||||||
|
"Cyrillic_A" => "0x0410",
|
||||||
|
"Cyrillic_CHE" => "0x0427",
|
||||||
|
"Cyrillic_E" => "0x042d",
|
||||||
|
"Cyrillic_GHE" => "0x0413",
|
||||||
|
"Cyrillic_I" => "0x0418",
|
||||||
|
"Cyrillic_IE" => "0x0415",
|
||||||
|
"Cyrillic_KA" => "0x041a",
|
||||||
|
"Cyrillic_O" => "0x041e",
|
||||||
|
"Cyrillic_U" => "0x0423",
|
||||||
|
"Cyrillic_YERU" => "0x042b",
|
||||||
|
"Cyrillic_ZE" => "0x0417",
|
||||||
|
"Cyrillic_ZHE" => "0x0416",
|
||||||
|
"Cyrillic_a" => "0x0430",
|
||||||
|
"Cyrillic_che" => "0x0447",
|
||||||
|
"Cyrillic_e" => "0x044d",
|
||||||
|
"Cyrillic_ghe" => "0x0433",
|
||||||
|
"Cyrillic_i" => "0x0438",
|
||||||
|
"Cyrillic_ie" => "0x0435",
|
||||||
|
"Cyrillic_ka" => "0x043a",
|
||||||
|
"Cyrillic_o" => "0x043e",
|
||||||
|
"Cyrillic_u" => "0x0443",
|
||||||
|
"Cyrillic_yeru" => "0x044b",
|
||||||
|
"Cyrillic_ze" => "0x0437",
|
||||||
|
"Cyrillic_zhe" => "0x0436",
|
||||||
|
"D" => "0x0044",
|
||||||
|
"E" => "0x0045",
|
||||||
|
"Ecircumflex" => "0x00ca",
|
||||||
|
"Emacron" => "0x0112",
|
||||||
|
"F" => "0x0046",
|
||||||
|
"G" => "0x0047",
|
||||||
|
"Greek_ALPHA" => "0x0391",
|
||||||
|
"Greek_EPSILON" => "0x0395",
|
||||||
|
"Greek_ETA" => "0x0397",
|
||||||
|
"Greek_IOTA" => "0x0399",
|
||||||
|
"Greek_OMEGA" => "0x03a9",
|
||||||
|
"Greek_OMICRON" => "0x039f",
|
||||||
|
"Greek_RHO" => "0x03a1",
|
||||||
|
"Greek_UPSILON" => "0x03a5",
|
||||||
|
"Greek_alpha" => "0x03b1",
|
||||||
|
"Greek_alphaaccent" => "0x03ac",
|
||||||
|
"Greek_epsilon" => "0x03b5",
|
||||||
|
"Greek_eta" => "0x03b7",
|
||||||
|
"Greek_etaaccent" => "0x03ae",
|
||||||
|
"Greek_iota" => "0x03b9",
|
||||||
|
"Greek_iotadieresis" => "0x03ca",
|
||||||
|
"Greek_omega" => "0x03c9",
|
||||||
|
"Greek_omegaaccent" => "0x03ce",
|
||||||
|
"Greek_omicron" => "0x03bf",
|
||||||
|
"Greek_rho" => "0x03c1",
|
||||||
|
"Greek_upsilon" => "0x03c5",
|
||||||
|
"Greek_upsilondieresis" => "0x03cb",
|
||||||
|
"H" => "0x0048",
|
||||||
|
"I" => "0x0049",
|
||||||
|
"Idiaeresis" => "0x00cf",
|
||||||
|
"J" => "0x004a",
|
||||||
|
"K" => "0x004b",
|
||||||
|
"KP_0" => "0x0000",
|
||||||
|
"KP_1" => "0x0000",
|
||||||
|
"KP_2" => "0x0000",
|
||||||
|
"KP_3" => "0x0000",
|
||||||
|
"KP_4" => "0x0000",
|
||||||
|
"KP_5" => "0x0000",
|
||||||
|
"KP_6" => "0x0000",
|
||||||
|
"KP_7" => "0x0000",
|
||||||
|
"KP_8" => "0x0000",
|
||||||
|
"KP_9" => "0x0000",
|
||||||
|
"KP_Add" => "0x0000",
|
||||||
|
"KP_Divide" => "0x0000",
|
||||||
|
"KP_Equal" => "0x0000",
|
||||||
|
"KP_Space" => "0x0000",
|
||||||
|
"L" => "0x004c",
|
||||||
|
"M" => "0x004d",
|
||||||
|
"N" => "0x004e",
|
||||||
|
"O" => "0x004f",
|
||||||
|
"Ocircumflex" => "0x00d4",
|
||||||
|
"Odiaeresis" => "0x00d6",
|
||||||
|
"Ohorn" => "0x0000",
|
||||||
|
"Omacron" => "0x014c",
|
||||||
|
"Ooblique" => "0x00d8",
|
||||||
|
"Otilde" => "0x00d5",
|
||||||
|
"P" => "0x0050",
|
||||||
|
"Q" => "0x0051",
|
||||||
|
"R" => "0x0052",
|
||||||
|
"S" => "0x0053",
|
||||||
|
"Sacute" => "0x015a",
|
||||||
|
"Scaron" => "0x0160",
|
||||||
|
"T" => "0x0054",
|
||||||
|
"U" => "0x0055",
|
||||||
|
"Udiaeresis" => "0x00dc",
|
||||||
|
"Uhorn" => "0x0000",
|
||||||
|
"Ukrainian_I" => "0x0406",
|
||||||
|
"Ukrainian_i" => "0x0456",
|
||||||
|
"Umacron" => "0x016a",
|
||||||
|
"Utilde" => "0x0168",
|
||||||
|
"V" => "0x0056",
|
||||||
|
"W" => "0x0057",
|
||||||
|
"X" => "0x0058",
|
||||||
|
"Y" => "0x0059",
|
||||||
|
"Z" => "0x005a",
|
||||||
|
"a" => "0x0061",
|
||||||
|
"abreve" => "0x0103",
|
||||||
|
"acircumflex" => "0x00e2",
|
||||||
|
"acute" => "0x00b4",
|
||||||
|
"adiaeresis" => "0x00e4",
|
||||||
|
"ae" => "0x00e6",
|
||||||
|
"ampersand" => "0x0026",
|
||||||
|
"apostrophe" => "0x0027",
|
||||||
|
"approximate" => "0x223c",
|
||||||
|
"aring" => "0x00e5",
|
||||||
|
"asciicircum" => "0x005e",
|
||||||
|
"asciitilde" => "0x007e",
|
||||||
|
"asterisk" => "0x002a",
|
||||||
|
"at" => "0x0040",
|
||||||
|
"b" => "0x0062",
|
||||||
|
"backslash" => "0x005c",
|
||||||
|
"bar" => "0x007c",
|
||||||
|
"braceleft" => "0x007b",
|
||||||
|
"braceright" => "0x007d",
|
||||||
|
"bracketleft" => "0x005b",
|
||||||
|
"bracketright" => "0x005d",
|
||||||
|
"c" => "0x0063",
|
||||||
|
"ccedilla" => "0x00e7",
|
||||||
|
"colon" => "0x003a",
|
||||||
|
"combining_acute" => "0x0000",
|
||||||
|
"combining_belowdot" => "0x0000",
|
||||||
|
"combining_grave" => "0x0000",
|
||||||
|
"combining_hook" => "0x0000",
|
||||||
|
"combining_tilde" => "0x0000",
|
||||||
|
"comma" => "0x002c",
|
||||||
|
"d" => "0x0064",
|
||||||
|
"diaeresis" => "0x00a8",
|
||||||
|
"dollar" => "0x0024",
|
||||||
|
"e" => "0x0065",
|
||||||
|
"ecircumflex" => "0x00ea",
|
||||||
|
"emacron" => "0x0113",
|
||||||
|
"equal" => "0x003d",
|
||||||
|
"exclam" => "0x0021",
|
||||||
|
"f" => "0x0066",
|
||||||
|
"g" => "0x0067",
|
||||||
|
"grave" => "0x0060",
|
||||||
|
"greater" => "0x003e",
|
||||||
|
"greaterthanequal" => "0x2265",
|
||||||
|
"h" => "0x0068",
|
||||||
|
"hebrew_aleph" => "0x05d0",
|
||||||
|
"hebrew_bet" => "0x05d1",
|
||||||
|
"hebrew_beth" => "0x05d1",
|
||||||
|
"hebrew_dalet" => "0x05d3",
|
||||||
|
"hebrew_daleth" => "0x05d3",
|
||||||
|
"hebrew_finalkaph" => "0x05da",
|
||||||
|
"hebrew_finalpe" => "0x05e3",
|
||||||
|
"hebrew_gimel" => "0x05d2",
|
||||||
|
"hebrew_gimmel" => "0x05d2",
|
||||||
|
"hebrew_he" => "0x05d4",
|
||||||
|
"hebrew_kaph" => "0x05db",
|
||||||
|
"hebrew_kuf" => "0x05e7",
|
||||||
|
"hebrew_lamed" => "0x05dc",
|
||||||
|
"hebrew_mem" => "0x05de",
|
||||||
|
"hebrew_nun" => "0x05e0",
|
||||||
|
"hebrew_pe" => "0x05e4",
|
||||||
|
"hebrew_qoph" => "0x05e7",
|
||||||
|
"hebrew_resh" => "0x05e8",
|
||||||
|
"hebrew_samech" => "0x05e1",
|
||||||
|
"hebrew_samekh" => "0x05e1",
|
||||||
|
"hebrew_shin" => "0x05e9",
|
||||||
|
"hebrew_taf" => "0x05ea",
|
||||||
|
"hebrew_taw" => "0x05ea",
|
||||||
|
"hebrew_tet" => "0x05d8",
|
||||||
|
"hebrew_teth" => "0x05d8",
|
||||||
|
"hebrew_waw" => "0x05d5",
|
||||||
|
"hebrew_yod" => "0x05d9",
|
||||||
|
"hebrew_zade" => "0x05e6",
|
||||||
|
"hebrew_zadi" => "0x05e6",
|
||||||
|
"hebrew_zain" => "0x05d6",
|
||||||
|
"hebrew_zayin" => "0x05d6",
|
||||||
|
"i" => "0x0069",
|
||||||
|
"identical" => "0x2261",
|
||||||
|
"idiaeresis" => "0x00ef",
|
||||||
|
"includedin" => "0x2282",
|
||||||
|
"includes" => "0x2283",
|
||||||
|
"j" => "0x006a",
|
||||||
|
"k" => "0x006b",
|
||||||
|
"kana_A" => "0x30a2",
|
||||||
|
"kana_CHI" => "0x30c1",
|
||||||
|
"kana_E" => "0x30a8",
|
||||||
|
"kana_FU" => "0x30d5",
|
||||||
|
"kana_HA" => "0x30cf",
|
||||||
|
"kana_HE" => "0x30d8",
|
||||||
|
"kana_HI" => "0x30d2",
|
||||||
|
"kana_HO" => "0x30db",
|
||||||
|
"kana_I" => "0x30a4",
|
||||||
|
"kana_KA" => "0x30ab",
|
||||||
|
"kana_KE" => "0x30b1",
|
||||||
|
"kana_KI" => "0x30ad",
|
||||||
|
"kana_KO" => "0x30b3",
|
||||||
|
"kana_KU" => "0x30af",
|
||||||
|
"kana_MA" => "0x30de",
|
||||||
|
"kana_ME" => "0x30e1",
|
||||||
|
"kana_MI" => "0x30df",
|
||||||
|
"kana_MO" => "0x30e2",
|
||||||
|
"kana_MU" => "0x30e0",
|
||||||
|
"kana_NA" => "0x30ca",
|
||||||
|
"kana_NE" => "0x30cd",
|
||||||
|
"kana_NI" => "0x30cb",
|
||||||
|
"kana_NO" => "0x30ce",
|
||||||
|
"kana_NU" => "0x30cc",
|
||||||
|
"kana_O" => "0x30aa",
|
||||||
|
"kana_RA" => "0x30e9",
|
||||||
|
"kana_RE" => "0x30ec",
|
||||||
|
"kana_RI" => "0x30ea",
|
||||||
|
"kana_RO" => "0x30ed",
|
||||||
|
"kana_RU" => "0x30eb",
|
||||||
|
"kana_SA" => "0x30b5",
|
||||||
|
"kana_SE" => "0x30bb",
|
||||||
|
"kana_SHI" => "0x30b7",
|
||||||
|
"kana_SO" => "0x30bd",
|
||||||
|
"kana_SU" => "0x30b9",
|
||||||
|
"kana_TA" => "0x30bf",
|
||||||
|
"kana_TE" => "0x30c6",
|
||||||
|
"kana_TO" => "0x30c8",
|
||||||
|
"kana_TSU" => "0x30c4",
|
||||||
|
"kana_U" => "0x30a6",
|
||||||
|
"kana_WA" => "0x30ef",
|
||||||
|
"kana_WO" => "0x30f2",
|
||||||
|
"kana_YA" => "0x30e4",
|
||||||
|
"kana_YO" => "0x30e8",
|
||||||
|
"kana_YU" => "0x30e6",
|
||||||
|
"l" => "0x006c",
|
||||||
|
"leftarrow" => "0x2190",
|
||||||
|
"leftcaret" => "0x003c",
|
||||||
|
"leftshoe" => "0x2282",
|
||||||
|
"less" => "0x003c",
|
||||||
|
"lessthanequal" => "0x2264",
|
||||||
|
"m" => "0x006d",
|
||||||
|
"macron" => "0x00af",
|
||||||
|
"minus" => "0x002d",
|
||||||
|
"n" => "0x006e",
|
||||||
|
"numbersign" => "0x0023",
|
||||||
|
"o" => "0x006f",
|
||||||
|
"ocircumflex" => "0x00f4",
|
||||||
|
"odiaeresis" => "0x00f6",
|
||||||
|
"ohorn" => "0x0000",
|
||||||
|
"omacron" => "0x014d",
|
||||||
|
"oslash" => "0x00f8",
|
||||||
|
"otilde" => "0x00f5",
|
||||||
|
"p" => "0x0070",
|
||||||
|
"parenleft" => "0x0028",
|
||||||
|
"parenright" => "0x0029",
|
||||||
|
"percent" => "0x0025",
|
||||||
|
"period" => "0x002e",
|
||||||
|
"plus" => "0x002b",
|
||||||
|
"q" => "0x0071",
|
||||||
|
"question" => "0x003f",
|
||||||
|
"quotedbl" => "0x0022",
|
||||||
|
"r" => "0x0072",
|
||||||
|
"rightarrow" => "0x2192",
|
||||||
|
"rightcaret" => "0x003e",
|
||||||
|
"rightshoe" => "0x2283",
|
||||||
|
"righttack" => "0x22a3",
|
||||||
|
"s" => "0x0073",
|
||||||
|
"sacute" => "0x015b",
|
||||||
|
"scaron" => "0x0161",
|
||||||
|
"semicolon" => "0x003b",
|
||||||
|
"slash" => "0x002f",
|
||||||
|
"space" => "0x0020",
|
||||||
|
"t" => "0x0074",
|
||||||
|
"u" => "0x0075",
|
||||||
|
"udiaeresis" => "0x00fc",
|
||||||
|
"uhorn" => "0x0000",
|
||||||
|
"umacron" => "0x016b",
|
||||||
|
"underbar" => "0x005f",
|
||||||
|
"underscore" => "0x005f",
|
||||||
|
"utilde" => "0x0169",
|
||||||
|
"v" => "0x0076",
|
||||||
|
"w" => "0x0077",
|
||||||
|
"x" => "0x0078",
|
||||||
|
"y" => "0x0079",
|
||||||
|
"z" => "0x007a",
|
||||||
|
}
|
||||||
|
|
||||||
|
readlines.collect {
|
||||||
|
|line|
|
||||||
|
|
||||||
|
broken = ""
|
||||||
|
seq = ["0", "0", "0", "0", "0", "0"]
|
||||||
|
index = 0
|
||||||
|
rhs = "0x0000"
|
||||||
|
comment = ""
|
||||||
|
|
||||||
|
case line
|
||||||
|
when /^(#|XCOMM)(.*)$/
|
||||||
|
comment = "// #{$2}\n"
|
||||||
|
rhs = :isCommentLine
|
||||||
|
when /^$/
|
||||||
|
comment = "\n"
|
||||||
|
rhs = :isCommentLine
|
||||||
|
else
|
||||||
|
line.scan(/<([^>]+)>/) {
|
||||||
|
|args|
|
||||||
|
keysym = args[0]
|
||||||
|
unit = x2q[keysym] || keysym.sub(/^U([\da-fA-F]{4,5})$/, "0x\\1")
|
||||||
|
if (/^(0x(0000|[\da-fA-F]{5,})|dead_space)$/ =~ unit)
|
||||||
|
broken = "// /* broken */"
|
||||||
|
end
|
||||||
|
seq[index] = unit
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Regexp.new(':\s+"(.+)"\s+(.+)$', nil, 'u') =~ line
|
||||||
|
rhs = Uconv::u8tou16($1).unpack('v')[0]
|
||||||
|
rhs = format("0x%04x", rhs)
|
||||||
|
comment = $2
|
||||||
|
end
|
||||||
|
|
||||||
|
entry = {
|
||||||
|
:broken => broken,
|
||||||
|
:seq => seq,
|
||||||
|
:rhs => rhs,
|
||||||
|
:comment => comment
|
||||||
|
}
|
||||||
|
}.sort {
|
||||||
|
|entry_a, entry_b|
|
||||||
|
|
||||||
|
entry_a[:seq] <=> entry_b[:seq]
|
||||||
|
}.each {
|
||||||
|
|entry|
|
||||||
|
|
||||||
|
broken, seq, rhs, comment = entry.values_at(:broken, :seq, :rhs, :comment)
|
||||||
|
if (rhs == :isCommentLine)
|
||||||
|
print comment
|
||||||
|
else
|
||||||
|
seq = seq.collect {
|
||||||
|
|unit|
|
||||||
|
raw2key[unit] || unit
|
||||||
|
}
|
||||||
|
print "#{broken} { {#{seq.join(", ")}}, #{rhs} }, // #{comment}\n"
|
||||||
|
end
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qximinputcontext_p.h,v 1.6 2004/06/22 06:47:27 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Definition of TQXIMInputContext
|
||||||
|
**
|
||||||
|
** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQXIMINPUTCONTEXT_H
|
||||||
|
#define TQXIMINPUTCONTEXT_H
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G
|
||||||
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is not part of the TQt API. It exists for the convenience
|
||||||
|
// of internal files. This header file may change from version to version
|
||||||
|
// without notice, or even be removed.
|
||||||
|
//
|
||||||
|
// We mean it.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#if !defined(TQ_NO_IM)
|
||||||
|
|
||||||
|
#include "tqglobal.h"
|
||||||
|
#include <tqinputcontext.h>
|
||||||
|
#include <tqfont.h>
|
||||||
|
#include <tqcstring.h>
|
||||||
|
|
||||||
|
class TQKeyEvent;
|
||||||
|
class TQWidget;
|
||||||
|
class TQFont;
|
||||||
|
class TQString;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TQ_WS_X11
|
||||||
|
#include "tqarray.h"
|
||||||
|
#include "tqwindowdefs.h"
|
||||||
|
#include <private/tqt_x11_p.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TQXIMInputContext : public TQInputContext
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
#ifdef TQ_WS_X11
|
||||||
|
TQXIMInputContext();
|
||||||
|
~TQXIMInputContext();
|
||||||
|
|
||||||
|
TQString identifierName();
|
||||||
|
TQString language();
|
||||||
|
|
||||||
|
bool x11FilterEvent( TQWidget *keywidget, XEvent *event );
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void setFocus();
|
||||||
|
void unsetFocus();
|
||||||
|
void setMicroFocus( int x, int y, int w, int h, TQFont *f = 0 );
|
||||||
|
void mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button, TQt::ButtonState state );
|
||||||
|
bool isPreeditRelocationEnabled();
|
||||||
|
|
||||||
|
void setHolderWidget( TQWidget *widget );
|
||||||
|
|
||||||
|
bool hasFocus() const;
|
||||||
|
void resetClientState();
|
||||||
|
void close( const TQString &errMsg );
|
||||||
|
|
||||||
|
void sendIMEvent( TQEvent::Type type,
|
||||||
|
const TQString &text = TQString(),
|
||||||
|
int cursorPosition = -1, int selLength = 0 );
|
||||||
|
|
||||||
|
static void init_xim();
|
||||||
|
static void create_xim();
|
||||||
|
static void close_xim();
|
||||||
|
|
||||||
|
void *ic;
|
||||||
|
TQString composingText;
|
||||||
|
TQFont font;
|
||||||
|
XFontSet fontset;
|
||||||
|
TQMemArray<bool> selectedChars;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool isPreeditPreservationEnabled(); // not a TQInputContext func
|
||||||
|
|
||||||
|
TQCString _language;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setComposePosition(int, int);
|
||||||
|
void setComposeArea(int, int, int, int);
|
||||||
|
void setXFontSet(const TQFont &);
|
||||||
|
|
||||||
|
int lookupString(XKeyEvent *, TQCString &, KeySym *, tqStatus *) const;
|
||||||
|
|
||||||
|
#endif // TQ_WS_X11
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //TQ_NO_IM
|
||||||
|
|
||||||
|
#endif // TQXIMINPUTCONTEXT_H
|
@ -0,0 +1,930 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qximinputcontext_x11.cpp,v 1.10 2004/06/22 06:47:27 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Implementation of TQXIMInputContext class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses for Unix/X11 may use this file in accordance with the TQt Commercial
|
||||||
|
** License Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "tqximinputcontext.h"
|
||||||
|
|
||||||
|
const int XKeyPress = KeyPress;
|
||||||
|
const int XKeyRelease = KeyRelease;
|
||||||
|
#undef KeyPress
|
||||||
|
#undef KeyRelease
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_IM)
|
||||||
|
|
||||||
|
#include "tqplatformdefs.h"
|
||||||
|
|
||||||
|
#include "tqapplication.h"
|
||||||
|
#include "tqwidget.h"
|
||||||
|
#include "tqstring.h"
|
||||||
|
#include "tqptrlist.h"
|
||||||
|
#include "tqintdict.h"
|
||||||
|
#include "tqtextcodec.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
|
||||||
|
#define XK_MISCELLANY
|
||||||
|
#define XK_LATIN1
|
||||||
|
#include <X11/keysymdef.h>
|
||||||
|
|
||||||
|
// #define TQT_XIM_DEBUG
|
||||||
|
|
||||||
|
// from qapplication_x11.cpp
|
||||||
|
static XIM qt_xim = 0;
|
||||||
|
extern XIMStyle qt_xim_style;
|
||||||
|
extern XIMStyle qt_xim_preferred_style;
|
||||||
|
extern char *qt_ximServer;
|
||||||
|
static bool isInitXIM = FALSE;
|
||||||
|
static TQPtrList<TQXIMInputContext> *ximContextList = 0;
|
||||||
|
#endif
|
||||||
|
extern int qt_ximComposingKeycode;
|
||||||
|
extern TQTextCodec * qt_input_mapper;
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
|
||||||
|
#if defined(TQ_C_CALLBACKS)
|
||||||
|
extern "C" {
|
||||||
|
#endif // TQ_C_CALLBACKS
|
||||||
|
|
||||||
|
#ifdef USE_X11R6_XIM
|
||||||
|
static void xim_create_callback(XIM /*im*/,
|
||||||
|
XPointer /*client_data*/,
|
||||||
|
XPointer /*call_data*/)
|
||||||
|
{
|
||||||
|
// qDebug("xim_create_callback");
|
||||||
|
TQXIMInputContext::create_xim();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xim_destroy_callback(XIM /*im*/,
|
||||||
|
XPointer /*client_data*/,
|
||||||
|
XPointer /*call_data*/)
|
||||||
|
{
|
||||||
|
// qDebug("xim_destroy_callback");
|
||||||
|
TQXIMInputContext::close_xim();
|
||||||
|
Display *dpy = TQPaintDevice::x11AppDisplay();
|
||||||
|
XRegisterIMInstantiateCallback(dpy, 0, 0, 0,
|
||||||
|
(XIMProc) xim_create_callback, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_X11R6_XIM
|
||||||
|
|
||||||
|
#if defined(TQ_C_CALLBACKS)
|
||||||
|
}
|
||||||
|
#endif // TQ_C_CALLBACKS
|
||||||
|
|
||||||
|
#endif // TQT_NO_XIM
|
||||||
|
|
||||||
|
#ifndef TQT_NO_XIM
|
||||||
|
|
||||||
|
/* The cache here is needed, as X11 leaks a few kb for every
|
||||||
|
XFreeFontSet call, so we avoid creating and deletion of fontsets as
|
||||||
|
much as possible
|
||||||
|
*/
|
||||||
|
static XFontSet fontsetCache[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
static int fontsetRefCount = 0;
|
||||||
|
|
||||||
|
static const char * const fontsetnames[] = {
|
||||||
|
"-*-fixed-medium-r-*-*-16-*,-*-*-medium-r-*-*-16-*",
|
||||||
|
"-*-fixed-medium-i-*-*-16-*,-*-*-medium-i-*-*-16-*",
|
||||||
|
"-*-fixed-bold-r-*-*-16-*,-*-*-bold-r-*-*-16-*",
|
||||||
|
"-*-fixed-bold-i-*-*-16-*,-*-*-bold-i-*-*-16-*",
|
||||||
|
"-*-fixed-medium-r-*-*-24-*,-*-*-medium-r-*-*-24-*",
|
||||||
|
"-*-fixed-medium-i-*-*-24-*,-*-*-medium-i-*-*-24-*",
|
||||||
|
"-*-fixed-bold-r-*-*-24-*,-*-*-bold-r-*-*-24-*",
|
||||||
|
"-*-fixed-bold-i-*-*-24-*,-*-*-bold-i-*-*-24-*"
|
||||||
|
};
|
||||||
|
|
||||||
|
static XFontSet getFontSet( const TQFont &f )
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
if (f.italic())
|
||||||
|
i |= 1;
|
||||||
|
if (f.bold())
|
||||||
|
i |= 2;
|
||||||
|
|
||||||
|
if ( f.pointSize() > 20 )
|
||||||
|
i += 4;
|
||||||
|
|
||||||
|
if ( !fontsetCache[i] ) {
|
||||||
|
Display* dpy = TQPaintDevice::x11AppDisplay();
|
||||||
|
int missCount;
|
||||||
|
char** missList;
|
||||||
|
fontsetCache[i] = XCreateFontSet(dpy, fontsetnames[i], &missList, &missCount, 0);
|
||||||
|
if(missCount > 0)
|
||||||
|
XFreeStringList(missList);
|
||||||
|
if ( !fontsetCache[i] ) {
|
||||||
|
fontsetCache[i] = XCreateFontSet(dpy, "-*-fixed-*-*-*-*-16-*", &missList, &missCount, 0);
|
||||||
|
if(missCount > 0)
|
||||||
|
XFreeStringList(missList);
|
||||||
|
if ( !fontsetCache[i] )
|
||||||
|
fontsetCache[i] = (XFontSet)-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (fontsetCache[i] == (XFontSet)-1) ? 0 : fontsetCache[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TQ_C_CALLBACKS
|
||||||
|
extern "C" {
|
||||||
|
#endif // TQ_C_CALLBACKS
|
||||||
|
|
||||||
|
// These static functions should be rewritten as member of
|
||||||
|
// TQXIMInputContext
|
||||||
|
|
||||||
|
static int xic_start_callback(XIC, XPointer client_data, XPointer) {
|
||||||
|
TQXIMInputContext *qic = (TQXIMInputContext *) client_data;
|
||||||
|
if (! qic) {
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug("compose start: no qic");
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qic->resetClientState();
|
||||||
|
qic->sendIMEvent( TQEvent::IMStart );
|
||||||
|
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug("compose start");
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int xic_draw_callback(XIC, XPointer client_data, XPointer call_data) {
|
||||||
|
TQXIMInputContext *qic = (TQXIMInputContext *) client_data;
|
||||||
|
if (! qic) {
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug("compose event: invalid compose event %p", qic);
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool send_imstart = FALSE;
|
||||||
|
if( ! qic->isComposing() && qic->hasFocus() ) {
|
||||||
|
qic->resetClientState();
|
||||||
|
send_imstart = TRUE;
|
||||||
|
} else if ( ! qic->isComposing() || ! qic->hasFocus() ) {
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug( "compose event: invalid compose event composing=%d hasFocus=%d",
|
||||||
|
qic->isComposing(), qic->hasFocus() );
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( send_imstart )
|
||||||
|
qic->sendIMEvent( TQEvent::IMStart );
|
||||||
|
|
||||||
|
XIMPreeditDrawCallbackStruct *drawstruct =
|
||||||
|
(XIMPreeditDrawCallbackStruct *) call_data;
|
||||||
|
XIMText *text = (XIMText *) drawstruct->text;
|
||||||
|
int cursor = drawstruct->caret, sellen = 0;
|
||||||
|
|
||||||
|
if ( ! drawstruct->caret && ! drawstruct->chg_first &&
|
||||||
|
! drawstruct->chg_length && ! text ) {
|
||||||
|
if( qic->composingText.isEmpty() ) {
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug( "compose emptied" );
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
// if the composition string has been emptied, we need
|
||||||
|
// to send an IMEnd event
|
||||||
|
qic->sendIMEvent( TQEvent::IMEnd );
|
||||||
|
qic->resetClientState();
|
||||||
|
// if the commit string has coming after here, IMStart
|
||||||
|
// will be sent dynamically
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
char *str = 0;
|
||||||
|
if (text->encoding_is_wchar) {
|
||||||
|
int l = wcstombs(NULL, text->string.wide_char, text->length);
|
||||||
|
if (l != -1) {
|
||||||
|
str = new char[l + 1];
|
||||||
|
wcstombs(str, text->string.wide_char, l);
|
||||||
|
str[l] = 0;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
str = text->string.multi_byte;
|
||||||
|
|
||||||
|
if (! str)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
TQString s = TQString::fromLocal8Bit(str);
|
||||||
|
|
||||||
|
if (text->encoding_is_wchar)
|
||||||
|
delete [] str;
|
||||||
|
|
||||||
|
if (drawstruct->chg_length < 0)
|
||||||
|
qic->composingText.tqreplace(drawstruct->chg_first, UINT_MAX, s);
|
||||||
|
else
|
||||||
|
qic->composingText.tqreplace(drawstruct->chg_first, drawstruct->chg_length, s);
|
||||||
|
|
||||||
|
if ( qic->selectedChars.size() < qic->composingText.length() ) {
|
||||||
|
// expand the selectedChars array if the compose string is longer
|
||||||
|
uint from = qic->selectedChars.size();
|
||||||
|
qic->selectedChars.resize( qic->composingText.length() );
|
||||||
|
for ( uint x = from; from < qic->selectedChars.size(); ++x )
|
||||||
|
qic->selectedChars[x] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint x;
|
||||||
|
bool *p = qic->selectedChars.data() + drawstruct->chg_first;
|
||||||
|
// determine if the changed chars are selected based on text->feedback
|
||||||
|
for ( x = 0; x < s.length(); ++x )
|
||||||
|
*p++ = ( text->feedback ? ( text->feedback[x] & XIMReverse ) : 0 );
|
||||||
|
|
||||||
|
// figure out where the selection starts, and how long it is
|
||||||
|
p = qic->selectedChars.data();
|
||||||
|
bool started = FALSE;
|
||||||
|
for ( x = 0; x < TQMIN(qic->composingText.length(), qic->selectedChars.size()); ++x ) {
|
||||||
|
if ( started ) {
|
||||||
|
if ( *p ) ++sellen;
|
||||||
|
else break;
|
||||||
|
} else {
|
||||||
|
if ( *p ) {
|
||||||
|
cursor = x;
|
||||||
|
started = TRUE;
|
||||||
|
sellen = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (drawstruct->chg_length == 0)
|
||||||
|
drawstruct->chg_length = -1;
|
||||||
|
|
||||||
|
qic->composingText.remove(drawstruct->chg_first, drawstruct->chg_length);
|
||||||
|
bool qt_compose_emptied = qic->composingText.isEmpty();
|
||||||
|
if ( qt_compose_emptied ) {
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug( "compose emptied" );
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
// if the composition string has been emptied, we need
|
||||||
|
// to send an IMEnd event
|
||||||
|
qic->sendIMEvent( TQEvent::IMEnd );
|
||||||
|
qic->resetClientState();
|
||||||
|
// if the commit string has coming after here, IMStart
|
||||||
|
// will be sent dynamically
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qic->sendIMEvent( TQEvent::IMCompose,
|
||||||
|
qic->composingText, cursor, sellen );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int xic_done_callback(XIC, XPointer client_data, XPointer) {
|
||||||
|
TQXIMInputContext *qic = (TQXIMInputContext *) client_data;
|
||||||
|
if (! qic)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Don't send IMEnd here. TQXIMInputContext::x11FilterEvent()
|
||||||
|
// handles IMEnd with commit string.
|
||||||
|
#if 0
|
||||||
|
if ( qic->isComposing() )
|
||||||
|
qic->sendIMEvent( TQEvent::IMEnd );
|
||||||
|
qic->resetClientState();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TQ_C_CALLBACKS
|
||||||
|
}
|
||||||
|
#endif // TQ_C_CALLBACKS
|
||||||
|
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TQXIMInputContext::TQXIMInputContext()
|
||||||
|
: TQInputContext(), ic(0), fontset(0)
|
||||||
|
{
|
||||||
|
if(!isInitXIM)
|
||||||
|
TQXIMInputContext::init_xim();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::setHolderWidget( TQWidget *widget )
|
||||||
|
{
|
||||||
|
if ( ! widget )
|
||||||
|
return;
|
||||||
|
|
||||||
|
TQInputContext::setHolderWidget( widget );
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
fontsetRefCount++;
|
||||||
|
if (! qt_xim) {
|
||||||
|
qWarning("TQInputContext: no input method context available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! widget->isTopLevel()) {
|
||||||
|
// qWarning("TQInputContext: cannot create input context for non-toplevel widgets");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
XPoint spot;
|
||||||
|
XRectangle rect;
|
||||||
|
XVaNestedList preedit_attr = 0;
|
||||||
|
XIMCallback startcallback, drawcallback, donecallback;
|
||||||
|
|
||||||
|
font = widget->font();
|
||||||
|
fontset = getFontSet( font );
|
||||||
|
|
||||||
|
if (qt_xim_style & XIMPreeditArea) {
|
||||||
|
rect.x = 0;
|
||||||
|
rect.y = 0;
|
||||||
|
rect.width = widget->width();
|
||||||
|
rect.height = widget->height();
|
||||||
|
|
||||||
|
preedit_attr = XVaCreateNestedList(0,
|
||||||
|
XNArea, &rect,
|
||||||
|
XNFontSet, fontset,
|
||||||
|
(char *) 0);
|
||||||
|
} else if (qt_xim_style & XIMPreeditPosition) {
|
||||||
|
spot.x = 1;
|
||||||
|
spot.y = 1;
|
||||||
|
|
||||||
|
preedit_attr = XVaCreateNestedList(0,
|
||||||
|
XNSpotLocation, &spot,
|
||||||
|
XNFontSet, fontset,
|
||||||
|
(char *) 0);
|
||||||
|
} else if (qt_xim_style & XIMPreeditCallbacks) {
|
||||||
|
startcallback.client_data = (XPointer) this;
|
||||||
|
startcallback.callback = (XIMProc) xic_start_callback;
|
||||||
|
drawcallback.client_data = (XPointer) this;
|
||||||
|
drawcallback.callback = (XIMProc)xic_draw_callback;
|
||||||
|
donecallback.client_data = (XPointer) this;
|
||||||
|
donecallback.callback = (XIMProc) xic_done_callback;
|
||||||
|
|
||||||
|
preedit_attr = XVaCreateNestedList(0,
|
||||||
|
XNPreeditStartCallback, &startcallback,
|
||||||
|
XNPreeditDrawCallback, &drawcallback,
|
||||||
|
XNPreeditDoneCallback, &donecallback,
|
||||||
|
(char *) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preedit_attr) {
|
||||||
|
ic = XCreateIC(qt_xim,
|
||||||
|
XNInputStyle, qt_xim_style,
|
||||||
|
XNClientWindow, widget->winId(),
|
||||||
|
XNPreeditAttributes, preedit_attr,
|
||||||
|
(char *) 0);
|
||||||
|
XFree(preedit_attr);
|
||||||
|
} else
|
||||||
|
ic = XCreateIC(qt_xim,
|
||||||
|
XNInputStyle, qt_xim_style,
|
||||||
|
XNClientWindow, widget->winId(),
|
||||||
|
(char *) 0);
|
||||||
|
|
||||||
|
if (! ic)
|
||||||
|
qFatal("Failed to create XIM input context!");
|
||||||
|
|
||||||
|
// when resetting the input context, preserve the input state
|
||||||
|
(void) XSetICValues((XIC) ic, XNResetState, XIMPreserveState, (char *) 0);
|
||||||
|
|
||||||
|
if( ! ximContextList )
|
||||||
|
ximContextList = new TQPtrList<TQXIMInputContext>;
|
||||||
|
ximContextList->append( this );
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQXIMInputContext::~TQXIMInputContext()
|
||||||
|
{
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if (ic)
|
||||||
|
XDestroyIC((XIC) ic);
|
||||||
|
|
||||||
|
if ( --fontsetRefCount == 0 ) {
|
||||||
|
Display *dpy = TQPaintDevice::x11AppDisplay();
|
||||||
|
for ( int i = 0; i < 8; i++ ) {
|
||||||
|
if ( fontsetCache[i] && fontsetCache[i] != (XFontSet)-1 ) {
|
||||||
|
XFreeFontSet(dpy, fontsetCache[i]);
|
||||||
|
fontsetCache[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ximContextList ) {
|
||||||
|
ximContextList->remove( this );
|
||||||
|
if(ximContextList->isEmpty()) {
|
||||||
|
// Calling XCloseIM gives a Purify FMR error
|
||||||
|
// XCloseIM( qt_xim );
|
||||||
|
// We prefer a less serious memory leak
|
||||||
|
if( qt_xim ) {
|
||||||
|
qt_xim = 0;
|
||||||
|
isInitXIM = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete ximContextList;
|
||||||
|
ximContextList = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
|
||||||
|
ic = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQXIMInputContext::init_xim()
|
||||||
|
{
|
||||||
|
#ifndef TQT_NO_XIM
|
||||||
|
if(!isInitXIM)
|
||||||
|
isInitXIM = TRUE;
|
||||||
|
|
||||||
|
qt_xim = 0;
|
||||||
|
TQString ximServerName(qt_ximServer);
|
||||||
|
if (qt_ximServer)
|
||||||
|
ximServerName.prepend("@im=");
|
||||||
|
else
|
||||||
|
ximServerName = "";
|
||||||
|
|
||||||
|
if ( !XSupportsLocale() )
|
||||||
|
qWarning("TQt: Locales not supported on X server");
|
||||||
|
|
||||||
|
#ifdef USE_X11R6_XIM
|
||||||
|
else if ( XSetLocaleModifiers (ximServerName.ascii()) == 0 )
|
||||||
|
qWarning( "TQt: Cannot set locale modifiers: %s",
|
||||||
|
ximServerName.ascii());
|
||||||
|
else {
|
||||||
|
Display *dpy = TQPaintDevice::x11AppDisplay();
|
||||||
|
XWindowAttributes attr; // XIM unselects all events on the root window
|
||||||
|
XGetWindowAttributes( dpy, TQPaintDevice::x11AppRootWindow(),&attr );
|
||||||
|
XRegisterIMInstantiateCallback(dpy, 0, 0, 0,
|
||||||
|
(XIMProc) xim_create_callback, 0);
|
||||||
|
XSelectInput( dpy, TQPaintDevice::x11AppRootWindow(), attr.your_event_tqmask );
|
||||||
|
}
|
||||||
|
#else // !USE_X11R6_XIM
|
||||||
|
else if ( XSetLocaleModifiers ("") == 0 )
|
||||||
|
qWarning("TQt: Cannot set locale modifiers");
|
||||||
|
else
|
||||||
|
TQXIMInputContext::create_xim();
|
||||||
|
#endif // USE_X11R6_XIM
|
||||||
|
#endif // TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \internal
|
||||||
|
Creates the application input method.
|
||||||
|
*/
|
||||||
|
void TQXIMInputContext::create_xim()
|
||||||
|
{
|
||||||
|
#ifndef TQT_NO_XIM
|
||||||
|
Display *appDpy = TQPaintDevice::x11AppDisplay();
|
||||||
|
qt_xim = XOpenIM( appDpy, 0, 0, 0 );
|
||||||
|
if ( qt_xim ) {
|
||||||
|
|
||||||
|
#ifdef USE_X11R6_XIM
|
||||||
|
XIMCallback destroy;
|
||||||
|
destroy.callback = (XIMProc) xim_destroy_callback;
|
||||||
|
destroy.client_data = 0;
|
||||||
|
if ( XSetIMValues( qt_xim, XNDestroyCallback, &destroy, (char *) 0 ) != 0 )
|
||||||
|
qWarning( "Xlib doesn't support destroy callback");
|
||||||
|
#endif // USE_X11R6_XIM
|
||||||
|
|
||||||
|
XIMStyles *styles = 0;
|
||||||
|
XGetIMValues(qt_xim, XNQueryInputStyle, &styles, (char *) 0, (char *) 0);
|
||||||
|
if ( styles ) {
|
||||||
|
int i;
|
||||||
|
for ( i = 0; !qt_xim_style && i < styles->count_styles; i++ ) {
|
||||||
|
if ( styles->supported_styles[i] == qt_xim_preferred_style ) {
|
||||||
|
qt_xim_style = qt_xim_preferred_style;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the preferred input style couldn't be found, look for
|
||||||
|
// Nothing
|
||||||
|
for ( i = 0; !qt_xim_style && i < styles->count_styles; i++ ) {
|
||||||
|
if ( styles->supported_styles[i] == (XIMPreeditNothing |
|
||||||
|
XIMStatusNothing) ) {
|
||||||
|
qt_xim_style = XIMPreeditNothing | XIMStatusNothing;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ... and failing that, None.
|
||||||
|
for ( i = 0; !qt_xim_style && i < styles->count_styles; i++ ) {
|
||||||
|
if ( styles->supported_styles[i] == (XIMPreeditNone |
|
||||||
|
XIMStatusNone) ) {
|
||||||
|
qt_xim_style = XIMPreeditNone | XIMStatusNone;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// qDebug("TQApplication: using im style %lx", qt_xim_style);
|
||||||
|
XFree( (char *)styles );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( qt_xim_style ) {
|
||||||
|
|
||||||
|
#ifdef USE_X11R6_XIM
|
||||||
|
XUnregisterIMInstantiateCallback(appDpy, 0, 0, 0,
|
||||||
|
(XIMProc) xim_create_callback, 0);
|
||||||
|
#endif // USE_X11R6_XIM
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Give up
|
||||||
|
qWarning( "No supported input style found."
|
||||||
|
" See InputMethod documentation.");
|
||||||
|
TQXIMInputContext::close_xim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \internal
|
||||||
|
Closes the application input method.
|
||||||
|
*/
|
||||||
|
void TQXIMInputContext::close_xim()
|
||||||
|
{
|
||||||
|
#ifndef TQT_NO_XIM
|
||||||
|
TQString errMsg( "TQXIMInputContext::close_xim() has been called" );
|
||||||
|
|
||||||
|
// Calling XCloseIM gives a Purify FMR error
|
||||||
|
// XCloseIM( qt_xim );
|
||||||
|
// We prefer a less serious memory leak
|
||||||
|
|
||||||
|
qt_xim = 0;
|
||||||
|
if( ximContextList ) {
|
||||||
|
TQPtrList<TQXIMInputContext> contexts( *ximContextList );
|
||||||
|
TQPtrList<TQXIMInputContext>::Iterator it = contexts.begin();
|
||||||
|
while( it != contexts.end() ) {
|
||||||
|
(*it)->close( errMsg );
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
// ximContextList will be deleted in ~TQXIMInputContext
|
||||||
|
}
|
||||||
|
#endif // TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TQXIMInputContext::x11FilterEvent( TQWidget *keywidget, XEvent *event )
|
||||||
|
{
|
||||||
|
#ifndef TQT_NO_XIM
|
||||||
|
int xkey_keycode = event->xkey.keycode;
|
||||||
|
if ( XFilterEvent( event, keywidget->tqtopLevelWidget()->winId() ) ) {
|
||||||
|
qt_ximComposingKeycode = xkey_keycode; // ### not documented in xlib
|
||||||
|
|
||||||
|
// Cancel of the composition is realizable even if
|
||||||
|
// follwing codes don't exist
|
||||||
|
#if 0
|
||||||
|
if ( event->type != XKeyPress || ! (qt_xim_style & XIMPreeditCallbacks) )
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The Solaris htt input method will transform a ClientMessage
|
||||||
|
* event into a filtered KeyPress event, in which case our
|
||||||
|
* keywidget is still zero.
|
||||||
|
*/
|
||||||
|
TQETWidget *widget = (TQETWidget*)TQWidget::tqfind( (WId)event->xany.window );
|
||||||
|
if ( ! keywidget ) {
|
||||||
|
keywidget = (TQETWidget*)TQWidget::keyboardGrabber();
|
||||||
|
if ( keywidget ) {
|
||||||
|
grabbed = TRUE;
|
||||||
|
} else {
|
||||||
|
if ( focus_widget )
|
||||||
|
keywidget = (TQETWidget*)focus_widget;
|
||||||
|
if ( !keywidget ) {
|
||||||
|
if ( tqApp->inPopupMode() ) // no focus widget, see if we have a popup
|
||||||
|
keywidget = (TQETWidget*) tqApp->activePopupWidget();
|
||||||
|
else if ( widget )
|
||||||
|
keywidget = (TQETWidget*)widget->tqtopLevelWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if the composition string has been emptied, we need to send
|
||||||
|
an IMEnd event. however, we have no way to tell if the user
|
||||||
|
has cancelled input, or if the user has accepted the
|
||||||
|
composition.
|
||||||
|
|
||||||
|
so, we have to look for the next keypress and see if it is
|
||||||
|
the 'commit' key press (keycode == 0). if it is, we deliver
|
||||||
|
an IMEnd event with the final text, otherwise we deliver an
|
||||||
|
IMEnd with empty text (meaning the user has cancelled the
|
||||||
|
input).
|
||||||
|
*/
|
||||||
|
if ( composing && tqfocusWidget && qt_compose_emptied ) {
|
||||||
|
XEvent event2;
|
||||||
|
bool found = FALSE;
|
||||||
|
if ( XCheckTypedEvent( TQPaintDevice::x11AppDisplay(),
|
||||||
|
XKeyPress, &event2 ) ) {
|
||||||
|
if ( event2.xkey.keycode == 0 ) {
|
||||||
|
// found a key event with the 'commit' string
|
||||||
|
found = TRUE;
|
||||||
|
XPutBackEvent( TQPaintDevice::x11AppDisplay(), &event2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !found ) {
|
||||||
|
// no key event, so the user must have cancelled the composition
|
||||||
|
TQIMEvent endevent( TQEvent::IMEnd, TQString(), -1 );
|
||||||
|
TQApplication::sendEvent( tqfocusWidget, &endevent );
|
||||||
|
|
||||||
|
tqfocusWidget = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qt_compose_emptied = FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
} else if ( tqfocusWidget() ) {
|
||||||
|
if ( event->type == XKeyPress && event->xkey.keycode == 0 ) {
|
||||||
|
// input method has sent us a commit string
|
||||||
|
TQCString data(513);
|
||||||
|
KeySym sym; // unused
|
||||||
|
tqStatus status; // unused
|
||||||
|
TQString inputText;
|
||||||
|
int count = lookupString( &(event->xkey), data, &sym, &status );
|
||||||
|
if ( count > 0 )
|
||||||
|
inputText = qt_input_mapper->toUnicode( data, count );
|
||||||
|
|
||||||
|
if ( ! ( qt_xim_style & XIMPreeditCallbacks ) || ! isComposing() ) {
|
||||||
|
// there is no composing state
|
||||||
|
sendIMEvent( TQEvent::IMStart );
|
||||||
|
}
|
||||||
|
|
||||||
|
sendIMEvent( TQEvent::IMEnd, inputText );
|
||||||
|
resetClientState();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::sendIMEvent( TQEvent::Type type, const TQString &text,
|
||||||
|
int cursorPosition, int selLength )
|
||||||
|
{
|
||||||
|
TQInputContext::sendIMEvent( type, text, cursorPosition, selLength );
|
||||||
|
if ( type == TQEvent::IMCompose )
|
||||||
|
composingText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::reset()
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if ( tqfocusWidget() && isComposing() && ! composingText.isNull() ) {
|
||||||
|
#ifdef TQT_XIM_DEBUG
|
||||||
|
qDebug("TQXIMInputContext::reset: composing - sending IMEnd (empty) to %p",
|
||||||
|
tqfocusWidget() );
|
||||||
|
#endif // TQT_XIM_DEBUG
|
||||||
|
|
||||||
|
TQInputContext::reset();
|
||||||
|
resetClientState();
|
||||||
|
|
||||||
|
char *mb = XmbResetIC((XIC) ic);
|
||||||
|
if (mb)
|
||||||
|
XFree(mb);
|
||||||
|
}
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::resetClientState()
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
composingText = TQString();
|
||||||
|
if ( selectedChars.size() < 128 )
|
||||||
|
selectedChars.resize( 128 );
|
||||||
|
selectedChars.fill( 0 );
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::close( const TQString &errMsg )
|
||||||
|
{
|
||||||
|
qDebug( errMsg );
|
||||||
|
emit deletionRequested();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TQXIMInputContext::hasFocus() const
|
||||||
|
{
|
||||||
|
return ( tqfocusWidget() != 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::setMicroFocus(int x, int y, int, int h, TQFont *f)
|
||||||
|
{
|
||||||
|
TQWidget *widget = tqfocusWidget();
|
||||||
|
if ( qt_xim && widget ) {
|
||||||
|
TQPoint p( x, y );
|
||||||
|
TQPoint p2 = widget->mapTo( widget->tqtopLevelWidget(), TQPoint( 0, 0 ) );
|
||||||
|
p = widget->tqtopLevelWidget()->mapFromGlobal( p );
|
||||||
|
setXFontSet( f ? *f : widget->font() );
|
||||||
|
setComposePosition(p.x(), p.y() + h);
|
||||||
|
setComposeArea(p2.x(), p2.y(), widget->width(), widget->height());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQXIMInputContext::mouseHandler( int , TQEvent::Type type,
|
||||||
|
TQt::ButtonState button,
|
||||||
|
TQt::ButtonState)
|
||||||
|
{
|
||||||
|
if ( type == TQEvent::MouseButtonPress ||
|
||||||
|
type == TQEvent::MouseButtonDblClick ) {
|
||||||
|
// Don't reset Japanese input context here. Japanese input
|
||||||
|
// context sometimes contains a whole paragraph and has
|
||||||
|
// minutes of lifetime different to ephemeral one in other
|
||||||
|
// languages. The input context should be survived until
|
||||||
|
// focused again.
|
||||||
|
if ( ! isPreeditPreservationEnabled() )
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQXIMInputContext::setComposePosition(int x, int y)
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if (qt_xim && ic) {
|
||||||
|
XPoint point;
|
||||||
|
point.x = x;
|
||||||
|
point.y = y;
|
||||||
|
|
||||||
|
XVaNestedList preedit_attr =
|
||||||
|
XVaCreateNestedList(0,
|
||||||
|
XNSpotLocation, &point,
|
||||||
|
|
||||||
|
(char *) 0);
|
||||||
|
XSetICValues((XIC) ic, XNPreeditAttributes, preedit_attr, (char *) 0);
|
||||||
|
XFree(preedit_attr);
|
||||||
|
}
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::setComposeArea(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if (qt_xim && ic) {
|
||||||
|
XRectangle rect;
|
||||||
|
rect.x = x;
|
||||||
|
rect.y = y;
|
||||||
|
rect.width = w;
|
||||||
|
rect.height = h;
|
||||||
|
|
||||||
|
XVaNestedList preedit_attr = XVaCreateNestedList(0,
|
||||||
|
XNArea, &rect,
|
||||||
|
|
||||||
|
(char *) 0);
|
||||||
|
XSetICValues((XIC) ic, XNPreeditAttributes, preedit_attr, (char *) 0);
|
||||||
|
XFree(preedit_attr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TQXIMInputContext::setXFontSet(const TQFont &f)
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if (font == f) return; // nothing to do
|
||||||
|
font = f;
|
||||||
|
|
||||||
|
XFontSet fs = getFontSet(font);
|
||||||
|
if (fontset == fs) return; // nothing to do
|
||||||
|
fontset = fs;
|
||||||
|
|
||||||
|
XVaNestedList preedit_attr = XVaCreateNestedList(0, XNFontSet, fontset, (char *) 0);
|
||||||
|
XSetICValues((XIC) ic, XNPreeditAttributes, preedit_attr, (char *) 0);
|
||||||
|
XFree(preedit_attr);
|
||||||
|
#else
|
||||||
|
Q_UNUSED( f );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int TQXIMInputContext::lookupString(XKeyEvent *event, TQCString &chars,
|
||||||
|
KeySym *key, tqStatus *status) const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if (qt_xim && ic) {
|
||||||
|
count = XmbLookupString((XIC) ic, event, chars.data(),
|
||||||
|
chars.size(), key, status);
|
||||||
|
|
||||||
|
if ((*status) == XBufferOverflow ) {
|
||||||
|
chars.resize(count + 1);
|
||||||
|
count = XmbLookupString((XIC) ic, event, chars.data(),
|
||||||
|
chars.size(), key, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TQT_NO_XIM
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQXIMInputContext::setFocus()
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if ( qt_xim && ic )
|
||||||
|
XSetICFocus((XIC) ic);
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
}
|
||||||
|
|
||||||
|
void TQXIMInputContext::unsetFocus()
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if (qt_xim && ic)
|
||||||
|
XUnsetICFocus((XIC) ic);
|
||||||
|
#endif // !TQT_NO_XIM
|
||||||
|
|
||||||
|
// Don't reset Japanese input context here. Japanese input context
|
||||||
|
// sometimes contains a whole paragraph and has minutes of
|
||||||
|
// lifetime different to ephemeral one in other languages. The
|
||||||
|
// input context should be survived until focused again.
|
||||||
|
if ( ! isPreeditPreservationEnabled() )
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TQXIMInputContext::isPreeditRelocationEnabled()
|
||||||
|
{
|
||||||
|
return ( language() == "ja" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TQXIMInputContext::isPreeditPreservationEnabled()
|
||||||
|
{
|
||||||
|
return ( language() == "ja" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQString TQXIMInputContext::identifierName()
|
||||||
|
{
|
||||||
|
// the name should be "xim" rather than "XIM" to be consistent
|
||||||
|
// with corresponding immodule of GTK+
|
||||||
|
return "xim";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQString TQXIMInputContext::language()
|
||||||
|
{
|
||||||
|
#if !defined(TQT_NO_XIM)
|
||||||
|
if ( qt_xim ) {
|
||||||
|
TQString locale( XLocaleOfIM( qt_xim ) );
|
||||||
|
|
||||||
|
if ( locale.startsWith( "zh" ) ) {
|
||||||
|
// Chinese language should be formed as "zh_CN", "zh_TW", "zh_HK"
|
||||||
|
_language = locale.left( 5 );
|
||||||
|
} else {
|
||||||
|
// other languages should be two-letter ISO 639 language code
|
||||||
|
_language = locale.left( 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return _language;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //TQT_NO_IM
|
@ -0,0 +1,86 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Implementation of TQXIMInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqximinputcontext.h"
|
||||||
|
#include "tqximinputcontextplugin.h"
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
TQXIMInputContextPlugin::TQXIMInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQXIMInputContextPlugin::~TQXIMInputContextPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQXIMInputContextPlugin::keys() const
|
||||||
|
{
|
||||||
|
return TQStringList( "xim" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContext *TQXIMInputContextPlugin::create( const TQString & )
|
||||||
|
{
|
||||||
|
return new TQXIMInputContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQXIMInputContextPlugin::languages( const TQString & )
|
||||||
|
{
|
||||||
|
return TQStringList( "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQXIMInputContextPlugin::displayName( const TQString & )
|
||||||
|
{
|
||||||
|
return tr( "XIM" );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQXIMInputContextPlugin::description( const TQString & )
|
||||||
|
{
|
||||||
|
return tr( "XIM input method" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQ_EXPORT_PLUGIN( TQXIMInputContextPlugin )
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id$
|
||||||
|
**
|
||||||
|
** Definition of TQXIMInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2004 immodule for TQt Project. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is written to contribute to Trolltech AS under their own
|
||||||
|
** licence. You may use this file under your TQt license. Following
|
||||||
|
** description is copied from their original file headers. Contact
|
||||||
|
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** This file is part of the input method module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#include "tqximinputcontext.h"
|
||||||
|
#include <tqinputcontextplugin.h>
|
||||||
|
#include <tqstringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
class TQXIMInputContextPlugin : public TQInputContextPlugin
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQXIMInputContextPlugin();
|
||||||
|
~TQXIMInputContextPlugin();
|
||||||
|
|
||||||
|
TQStringList keys() const;
|
||||||
|
TQInputContext *create( const TQString &key );
|
||||||
|
TQStringList languages( const TQString &key );
|
||||||
|
TQString displayName( const TQString &key );
|
||||||
|
TQString description( const TQString &key );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,14 @@
|
|||||||
|
TEMPLATE = lib
|
||||||
|
TARGET = qxim
|
||||||
|
DESTDIR = ../../../inputmethods
|
||||||
|
|
||||||
|
INCLUDEPATH += .
|
||||||
|
CONFIG += qt warn_on debug plugin
|
||||||
|
target.path += $$plugins.path/inputmethods
|
||||||
|
INSTALLS += target
|
||||||
|
|
||||||
|
# Input
|
||||||
|
HEADERS += qximinputcontext.h \
|
||||||
|
qximinputcontextplugin.h
|
||||||
|
SOURCES += qximinputcontext_x11.cpp \
|
||||||
|
qximinputcontextplugin.cpp
|
@ -1,10 +1,10 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
shared {
|
shared {
|
||||||
SUBDIRS *= accessible codecs imageformats sqldrivers styles
|
SUBDIRS *= accessible codecs imageformats inputmethods sqldrivers styles
|
||||||
embedded:SUBDIRS *= gfxdrivers
|
embedded:SUBDIRS *= gfxdrivers
|
||||||
}
|
}
|
||||||
dll {
|
dll {
|
||||||
SUBDIRS *= accessible codecs imageformats sqldrivers styles
|
SUBDIRS *= accessible codecs imageformats inputmethods sqldrivers styles
|
||||||
embedded:SUBDIRS *= gfxdrivers
|
embedded:SUBDIRS *= gfxdrivers
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
// Use the __NO_INLINE__ hack below to prevent sys/stat.h from
|
||||||
|
// exporting __extern_inline definitions of the symbols [fl]?stat64
|
||||||
|
// with g++-4.3 or later and glibc6 >= 2.7 or later. This flag has no
|
||||||
|
// impact on [fl]?stat(64)? symbol export for glibc6 << 2.7
|
||||||
|
//
|
||||||
|
#ifndef __NO_INLINE__
|
||||||
|
# define __NO_INLINE__
|
||||||
|
# define INLINE_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 7)
|
||||||
|
|
||||||
|
// We must ensure that [fl]?stat64 are exported in the dynamic symbol
|
||||||
|
// table of libqt-mt.so.3 as weak symbols to preserve ABI.
|
||||||
|
int stat64 (__const char *__path, struct stat64 *__statbuf) __attribute__((weak));
|
||||||
|
int lstat64 (__const char *__path, struct stat64 *__statbuf) __attribute__((weak));
|
||||||
|
int fstat64 (int __fd, struct stat64 *__statbuf) __attribute__((weak));
|
||||||
|
|
||||||
|
int stat64 (__const char *__path, struct stat64 *__statbuf)
|
||||||
|
{
|
||||||
|
return __xstat64 (_STAT_VER, __path, __statbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lstat64 (__const char *__path, struct stat64 *__statbuf)
|
||||||
|
{
|
||||||
|
return __lxstat64 (_STAT_VER, __path, __statbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstat64 (int __fd, struct stat64 *__statbuf)
|
||||||
|
{
|
||||||
|
return __fxstat64 (_STAT_VER, __fd, __statbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
# ifndef INLINE_ENABLED
|
||||||
|
/*
|
||||||
|
* Trigger export of the extern __inline [fl]?stat64 symbols
|
||||||
|
* (defined at <sys/stat.h>) by referencing them in the dummy
|
||||||
|
* hidden function below. It's very important to reference
|
||||||
|
* [fl]?stat64 via their [fl]?stat aliases (because LARGEFILE
|
||||||
|
* is enabled) for these weak symbols to get exported.
|
||||||
|
*
|
||||||
|
* This hack is compatible with libc6-dev << 2.7 headers.
|
||||||
|
*
|
||||||
|
* This source file must be compiled with -fno-inline to have
|
||||||
|
* expected effect.
|
||||||
|
**/
|
||||||
|
void __stat_extern_inline_export_hack()
|
||||||
|
__attribute__((visibility("hidden")));
|
||||||
|
|
||||||
|
void __stat_extern_inline_export_hack() {
|
||||||
|
struct stat buf;
|
||||||
|
stat("", &buf);
|
||||||
|
lstat("", &buf);
|
||||||
|
fstat(0, &buf);
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
# error "This file must be compiled with inline disabled for the hack to be effective."
|
||||||
|
# endif /* INLINES_ENABLED */
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,186 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontextfactory.cpp,v 1.2 2004/06/20 18:43:11 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Implementation of TQInputContextFactory class
|
||||||
|
**
|
||||||
|
** Created : 001103
|
||||||
|
**
|
||||||
|
** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the widgets module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition licenses may use this
|
||||||
|
** file in accordance with the TQt Commercial License Agreement provided
|
||||||
|
** with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "tqinputcontextinterface_p.h" // up here for GCC 2.7.* compatibility
|
||||||
|
#include "tqinputcontextfactory.h"
|
||||||
|
#include "tqinputcontext.h"
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
|
||||||
|
#include "tqapplication.h"
|
||||||
|
|
||||||
|
#ifdef TQT_THREAD_SUPPORT
|
||||||
|
#include <private/tqmutexpool_p.h>
|
||||||
|
#endif // TQT_THREAD_SUPPORT
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "tqcleanuphandler.h"
|
||||||
|
#include <private/tqpluginmanager_p.h>
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
|
||||||
|
static TQPluginManager<TQInputContextFactoryInterface> *manager = 0;
|
||||||
|
static TQSingleCleanupHandler< TQPluginManager<TQInputContextFactoryInterface> > cleanup_manager;
|
||||||
|
|
||||||
|
static void create_manager()
|
||||||
|
{
|
||||||
|
if( manager ) // already created
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef TQT_THREAD_SUPPORT
|
||||||
|
// protect manager creation
|
||||||
|
TQMutexLocker locker( qt_global_mutexpool ?
|
||||||
|
qt_global_mutexpool->get( &manager ) : 0);
|
||||||
|
|
||||||
|
// we check the manager pointer again to make sure that another thread
|
||||||
|
// has not created the manager before us.
|
||||||
|
|
||||||
|
if ( manager ) // already created
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
manager = new TQPluginManager<TQInputContextFactoryInterface>( IID_TQInputContextFactory, TQApplication::libraryPaths(), "/inputmethods", FALSE );
|
||||||
|
|
||||||
|
Q_CHECK_PTR( manager );
|
||||||
|
cleanup_manager.set( &manager );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function generates the input context that has the identifier
|
||||||
|
name which is in agreement with \a key. \a widget is the client
|
||||||
|
widget of TQInputContext. \a widget may be null.
|
||||||
|
*/
|
||||||
|
TQInputContext *TQInputContextFactory::create( const TQString& key, TQWidget *widget )
|
||||||
|
{
|
||||||
|
TQInputContext *ret = 0;
|
||||||
|
TQString inputcontext = key;
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
// make sure the manager is created
|
||||||
|
create_manager();
|
||||||
|
|
||||||
|
TQInterfacePtr<TQInputContextFactoryInterface> iface;
|
||||||
|
manager->queryInterface( inputcontext, &iface );
|
||||||
|
|
||||||
|
if ( iface ) {
|
||||||
|
ret = iface->create( inputcontext );
|
||||||
|
#ifdef TQ_WS_X11
|
||||||
|
if ( ret )
|
||||||
|
ret->setHolderWidget( widget );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function returns the list of the names input methods.
|
||||||
|
Only input methods included in default and placed under
|
||||||
|
$TQTDIR/plugins/inputmethods are listed.
|
||||||
|
*/
|
||||||
|
TQStringList TQInputContextFactory::keys()
|
||||||
|
{
|
||||||
|
TQStringList list;
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
// make sure the manager is created
|
||||||
|
create_manager();
|
||||||
|
|
||||||
|
list = manager->featureList();
|
||||||
|
#endif //TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQStringList TQInputContextFactory::languages( const TQString &key )
|
||||||
|
{
|
||||||
|
TQStringList result;
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
// make sure the manager is created
|
||||||
|
create_manager();
|
||||||
|
|
||||||
|
TQInterfacePtr<TQInputContextFactoryInterface> iface;
|
||||||
|
manager->queryInterface( key, &iface );
|
||||||
|
|
||||||
|
if ( iface )
|
||||||
|
result = iface->languages( key );
|
||||||
|
#endif //TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQString TQInputContextFactory::displayName( const TQString &key )
|
||||||
|
{
|
||||||
|
TQString result( "" );
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
// make sure the manager is created
|
||||||
|
create_manager();
|
||||||
|
|
||||||
|
TQInterfacePtr<TQInputContextFactoryInterface> iface;
|
||||||
|
manager->queryInterface( key, &iface );
|
||||||
|
|
||||||
|
if ( iface )
|
||||||
|
result = iface->displayName( key );
|
||||||
|
#endif //TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TQString TQInputContextFactory::description( const TQString &key )
|
||||||
|
{
|
||||||
|
TQString result( "" );
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
// make sure the manager is created
|
||||||
|
create_manager();
|
||||||
|
|
||||||
|
TQInterfacePtr<TQInputContextFactoryInterface> iface;
|
||||||
|
manager->queryInterface( key, &iface );
|
||||||
|
|
||||||
|
if ( iface )
|
||||||
|
result = iface->description( key );
|
||||||
|
#endif //TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TQT_NO_IM
|
@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontextfactory.h,v 1.1.1.1 2004/05/11 11:16:49 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Definition of TQInputContextFactory class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the widgets module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQINPUTCONTEXTFACTORY_H
|
||||||
|
#define TQINPUTCONTEXTFACTORY_H
|
||||||
|
|
||||||
|
#ifndef TQT_H
|
||||||
|
#include "tqstringlist.h"
|
||||||
|
#endif // TQT_H
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
|
||||||
|
class TQInputContext;
|
||||||
|
class TQWidget;
|
||||||
|
|
||||||
|
class TQ_EXPORT TQInputContextFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static TQStringList keys();
|
||||||
|
static TQInputContext *create( const TQString &key, TQWidget *widget ); // should be a toplevel widget
|
||||||
|
static TQStringList languages( const TQString &key );
|
||||||
|
static TQString displayName( const TQString &key );
|
||||||
|
static TQString description( const TQString &key );
|
||||||
|
};
|
||||||
|
#endif //TQT_NO_IM
|
||||||
|
|
||||||
|
#endif //TQINPUTCONTEXTFACTORY_H
|
@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontextinterface_p.h,v 1.2 2004/06/20 18:43:11 daisuke Exp $
|
||||||
|
**
|
||||||
|
** ...
|
||||||
|
**
|
||||||
|
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the widgets module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQINPUTCONTEXTINTERFACE_P_H
|
||||||
|
#define TQINPUTCONTEXTINTERFACE_P_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G
|
||||||
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is not part of the TQt API. This header file may
|
||||||
|
// change from version to version without notice, or even be
|
||||||
|
// removed.
|
||||||
|
//
|
||||||
|
// We mean it.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef TQT_H
|
||||||
|
#include <private/tqcom_p.h>
|
||||||
|
#endif // TQT_H
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
class TQWidget;
|
||||||
|
class TQInputContext;
|
||||||
|
|
||||||
|
// old version interface in qt-x11-immodule-bc-qt3.3.2-20040623.diff:
|
||||||
|
// {6C2B9EDE-B63C-14c9-A729-3C7643739C4C}
|
||||||
|
//
|
||||||
|
// new version interface:
|
||||||
|
// {a5f5c63d-e044-11d8-9718-000d6077a78d}
|
||||||
|
// {b0bf3e59-e526-11d8-80da-000d6077a78d}
|
||||||
|
// {9ef05c7f-0272-11d9-846c-000d6077a78d}
|
||||||
|
|
||||||
|
#ifndef IID_TQInputContextFactory
|
||||||
|
//#define IID_TQInputContextFactory TQUuid(0x6c2b9ede, 0xb63c, 0x14c9, 0xa7, 0x29, 0x3c, 0x76, 0x43, 0x73, 0x9c, 0x4c)
|
||||||
|
//#define IID_TQInputContextFactory TQUuid(0xa5f5c63d, 0xe044, 0x11d8, 0x97, 0x18, 0x00, 0x0d, 0x60, 0x77, 0xa7, 0x8d)
|
||||||
|
//#define IID_TQInputContextFactory TQUuid(0xb0bf3e59, 0xe526, 0x11d8, 0x80, 0xda, 0x00, 0x0d, 0x60, 0x77, 0xa7, 0x8d)
|
||||||
|
#define IID_TQInputContextFactory TQUuid(0x9ef05c7f, 0x0272, 0x11d9, 0x84, 0x6c, 0x00, 0x0d, 0x60, 0x77, 0xa7, 0x8d)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct TQ_EXPORT TQInputContextFactoryInterface : public TQFeatureListInterface
|
||||||
|
{
|
||||||
|
virtual TQInputContext *create( const TQString &key ) = 0;
|
||||||
|
virtual TQStringList languages( const TQString &key ) = 0;
|
||||||
|
virtual TQString displayName( const TQString &key ) = 0;
|
||||||
|
virtual TQString description( const TQString &key ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //TQT_NO_COMPONENT
|
||||||
|
#endif //TQT_NO_IM
|
||||||
|
|
||||||
|
#endif //TQINPUTCONTEXTINTERFACE_P_H
|
@ -0,0 +1,231 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontextplugin.cpp,v 1.2 2004/06/20 18:43:11 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Implementation of TQInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Created : 010920
|
||||||
|
**
|
||||||
|
** Copyright (C) 2001 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the widgets module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "tqinputcontextplugin.h"
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
#ifndef TQT_NO_COMPONENT
|
||||||
|
|
||||||
|
#include "tqinputcontextinterface_p.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class TQInputContextPlugin qinputcontextplugin.h
|
||||||
|
\brief The TQInputContextPlugin class provides an abstract base for custom TQInputContext plugins.
|
||||||
|
\reentrant
|
||||||
|
\ingroup plugins
|
||||||
|
|
||||||
|
The input context plugin is a simple plugin interface that makes it
|
||||||
|
easy to create custom input contexts that can be loaded dynamically
|
||||||
|
into applications.
|
||||||
|
|
||||||
|
Writing a input context plugin is achieved by subclassing this
|
||||||
|
base class, reimplementing the pure virtual functions keys(),
|
||||||
|
create(), languages(), displayName() description() and exporting
|
||||||
|
the class with the \c TQ_EXPORT_PLUGIN macro. See the \link
|
||||||
|
plugins-howto.html TQt Plugins documentation \endlink for details.
|
||||||
|
|
||||||
|
\sa TQInputContext
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn TQStringList TQInputContextPlugin::keys() const
|
||||||
|
|
||||||
|
Returns the list of TQInputContext keys this plugin provides.
|
||||||
|
|
||||||
|
These keys are usually the class names of the custom input context
|
||||||
|
that are implemented in the plugin.
|
||||||
|
|
||||||
|
Return value is the names to identify and specify input methods
|
||||||
|
for the input method switching mechanism and so on. The names have
|
||||||
|
to be consistent with TQInputContext::identifierName(). The names
|
||||||
|
have to consist of ASCII characters only. See also
|
||||||
|
TQInputContext::identifierName() for further information.
|
||||||
|
|
||||||
|
\sa create(), displayName(), TQInputContext::identifierName()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn TQInputContext* TQInputContextPlugin::create( const TQString& key )
|
||||||
|
|
||||||
|
Creates and returns a TQInputContext instance for the input context key \a key.
|
||||||
|
The input context key is usually the class name of the required input method.
|
||||||
|
|
||||||
|
\sa keys()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn TQStringList languages( const TQString &key )
|
||||||
|
|
||||||
|
Returns what languages are supported by the TQInputContext instance
|
||||||
|
specified by \a key.
|
||||||
|
|
||||||
|
The languages are expressed as language code (e.g. "zh_CN",
|
||||||
|
"zh_TW", "zh_HK", "ja", "ko", ...). An input context that suports
|
||||||
|
multiple languages can return all supported languages as
|
||||||
|
TQStringList. The name has to be consistent with
|
||||||
|
TQInputContextPlugin::language().
|
||||||
|
|
||||||
|
This information may be used to optimize user interface.
|
||||||
|
|
||||||
|
\sa TQInputContext::language()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn TQString displayName( const TQString &key )
|
||||||
|
|
||||||
|
Returns a user friendly i18n-ized name of the TQInputContext
|
||||||
|
instance specified by \a key. This string may be appeared in a
|
||||||
|
menu and so on for users.
|
||||||
|
|
||||||
|
There are two different names with different responsibility in the
|
||||||
|
input method domain. This function returns one of them. Another
|
||||||
|
name is called 'identifier name' to identify and specify input
|
||||||
|
methods for the input method switching mechanism and so on.
|
||||||
|
|
||||||
|
Although tr( identifierName ) can provide user friendly i18n-ized
|
||||||
|
name without this function, the message catalog have to be managed
|
||||||
|
by TQt in the case. However, some sophisticated input method
|
||||||
|
framework manages their own message catalogs to provide this
|
||||||
|
i18n-ized name string. So we need this function rather than just
|
||||||
|
call tr() for identifier name.
|
||||||
|
|
||||||
|
\sa keys(), TQInputContext::identifierName()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn TQString description( const TQString &key )
|
||||||
|
|
||||||
|
Returns a i18n-ized brief description of the TQInputContext
|
||||||
|
instance specified by \a key. This string may be appeared in some
|
||||||
|
user interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TQInputContextPluginPrivate : public TQInputContextFactoryInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TQInputContextPluginPrivate( TQInputContextPlugin *p )
|
||||||
|
: plugin( p )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~TQInputContextPluginPrivate();
|
||||||
|
|
||||||
|
TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface );
|
||||||
|
TQ_REFCOUNT;
|
||||||
|
|
||||||
|
TQStringList featureList() const;
|
||||||
|
TQInputContext *create( const TQString &key );
|
||||||
|
TQStringList languages( const TQString &key );
|
||||||
|
TQString displayName( const TQString &key );
|
||||||
|
TQString description( const TQString &key );
|
||||||
|
|
||||||
|
private:
|
||||||
|
TQInputContextPlugin *plugin;
|
||||||
|
};
|
||||||
|
|
||||||
|
TQRESULT TQInputContextPluginPrivate::queryInterface( const TQUuid &iid, TQUnknownInterface **iface )
|
||||||
|
{
|
||||||
|
*iface = 0;
|
||||||
|
|
||||||
|
if ( iid == IID_TQUnknown )
|
||||||
|
*iface = this;
|
||||||
|
else if ( iid == IID_TQFeatureList )
|
||||||
|
*iface = this;
|
||||||
|
else if ( iid == IID_TQInputContextFactory )
|
||||||
|
*iface = this;
|
||||||
|
else
|
||||||
|
return TQE_NOINTERFACE;
|
||||||
|
|
||||||
|
(*iface)->addRef();
|
||||||
|
return TQS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContextPluginPrivate::~TQInputContextPluginPrivate()
|
||||||
|
{
|
||||||
|
delete plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQInputContextPluginPrivate::featureList() const
|
||||||
|
{
|
||||||
|
return plugin->keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
TQInputContext *TQInputContextPluginPrivate::create( const TQString &key )
|
||||||
|
{
|
||||||
|
return plugin->create( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQStringList TQInputContextPluginPrivate::languages( const TQString &key )
|
||||||
|
{
|
||||||
|
return plugin->languages( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQInputContextPluginPrivate::displayName( const TQString &key )
|
||||||
|
{
|
||||||
|
return plugin->displayName( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
TQString TQInputContextPluginPrivate::description( const TQString &key )
|
||||||
|
{
|
||||||
|
return plugin->description( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs a input context plugin. This is invoked automatically by the
|
||||||
|
\c TQ_EXPORT_PLUGIN macro.
|
||||||
|
*/
|
||||||
|
TQInputContextPlugin::TQInputContextPlugin()
|
||||||
|
: TQGPlugin( d = new TQInputContextPluginPrivate( this ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destroys the input context plugin.
|
||||||
|
|
||||||
|
You never have to call this explicitly. TQt destroys a plugin
|
||||||
|
automatically when it is no longer used.
|
||||||
|
*/
|
||||||
|
TQInputContextPlugin::~TQInputContextPlugin()
|
||||||
|
{
|
||||||
|
// don't delete d, as this is deleted by d
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TQT_NO_COMPONENT
|
||||||
|
#endif // TQT_NO_IM
|
@ -0,0 +1,67 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontextplugin.h,v 1.2 2004/06/20 18:43:11 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Definition of TQInputContextPlugin class
|
||||||
|
**
|
||||||
|
** Created : 010920
|
||||||
|
**
|
||||||
|
** Copyright (C) 2001 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the tools module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQINPUTCONTEXTPLUGIN_H
|
||||||
|
#define TQINPUTCONTEXTPLUGIN_H
|
||||||
|
|
||||||
|
#ifndef TQT_H
|
||||||
|
#include "tqgplugin.h"
|
||||||
|
#include "tqstringlist.h"
|
||||||
|
#endif // TQT_H
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
class TQInputContext;
|
||||||
|
class TQInputContextPluginPrivate;
|
||||||
|
|
||||||
|
class TQ_EXPORT TQInputContextPlugin : public TQGPlugin
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQInputContextPlugin();
|
||||||
|
~TQInputContextPlugin();
|
||||||
|
|
||||||
|
virtual TQStringList keys() const = 0;
|
||||||
|
virtual TQInputContext *create( const TQString &key ) = 0;
|
||||||
|
virtual TQStringList languages( const TQString &key ) = 0;
|
||||||
|
virtual TQString displayName( const TQString &key ) = 0;
|
||||||
|
virtual TQString description( const TQString &key ) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TQInputContextPluginPrivate *d;
|
||||||
|
};
|
||||||
|
#endif // TQT_NO_IM
|
||||||
|
#endif // TQINPUTCONTEXTPLUGIN_H
|
@ -0,0 +1,10 @@
|
|||||||
|
# TQt inputmetod module
|
||||||
|
|
||||||
|
inputmethod {
|
||||||
|
INPUTMETHOD_P = inputmethod
|
||||||
|
HEADERS +=$$INPUTMETHOD_H/qinputcontextfactory.h \
|
||||||
|
$$INPUTMETHOD_P/qinputcontextinterface_p.h \
|
||||||
|
$$INPUTMETHOD_H/qinputcontextplugin.h
|
||||||
|
SOURCES +=$$INPUTMETHOD_CPP/qinputcontextfactory.cpp \
|
||||||
|
$$INPUTMETHOD_CPP/qinputcontextplugin.cpp
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,856 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontext.cpp,v 1.6 2004/06/22 06:47:30 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Implementation of TQInputContext class
|
||||||
|
**
|
||||||
|
** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the kernel module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses for Unix/X11 may use this file in accordance with the TQt Commercial
|
||||||
|
** License Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
//#define TQT_NO_IM_PREEDIT_RELOCATION
|
||||||
|
|
||||||
|
#include "tqinputcontext.h"
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
|
||||||
|
#include "tqplatformdefs.h"
|
||||||
|
|
||||||
|
#include "tqapplication.h"
|
||||||
|
#include "tqwidget.h"
|
||||||
|
#include "tqpopupmenu.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
class TQInputContextPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TQInputContextPrivate()
|
||||||
|
: holderWidget( 0 ), composingWidget( 0 ), hasFocus( FALSE ),
|
||||||
|
isComposing( FALSE )
|
||||||
|
#if !defined(TQT_NO_IM_PREEDIT_RELOCATION)
|
||||||
|
, preeditString( TQString() ),
|
||||||
|
cursorPosition( -1 ), selLength ( 0 )
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
|
|
||||||
|
TQWidget *holderWidget; // widget to which TQInputContext instance belongs.
|
||||||
|
TQWidget *composingWidget;
|
||||||
|
bool hasFocus;
|
||||||
|
bool isComposing;
|
||||||
|
|
||||||
|
void updateComposingState( const TQString &text,
|
||||||
|
int newCursorPosition, int newSelLength ) {
|
||||||
|
#if !defined(TQT_NO_IM_PREEDIT_RELOCATION)
|
||||||
|
preeditString = text;
|
||||||
|
cursorPosition = newCursorPosition;
|
||||||
|
selLength = newSelLength;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetComposingState() {
|
||||||
|
isComposing = FALSE;
|
||||||
|
#if !defined(TQT_NO_IM_PREEDIT_RELOCATION)
|
||||||
|
preeditString = TQString();
|
||||||
|
cursorPosition = -1;
|
||||||
|
selLength = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(TQT_NO_IM_PREEDIT_RELOCATION)
|
||||||
|
TQString preeditString;
|
||||||
|
int cursorPosition;
|
||||||
|
int selLength;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// UPDATED COMMENT RETQUIRED -- 2004-07-08 YamaKen
|
||||||
|
/*!
|
||||||
|
\class TQInputContext qinputcontext.h
|
||||||
|
\brief The TQInputContext class abstracts the input method dependent data and composing state.
|
||||||
|
|
||||||
|
\ingroup i18n
|
||||||
|
|
||||||
|
An input method is responsible to input complex text that cannot
|
||||||
|
be inputted via simple keymap. It converts a sequence of input
|
||||||
|
events (typically key events) into a text string through the input
|
||||||
|
method specific converting process. The class of the processes are
|
||||||
|
widely ranging from simple finite state machine to complex text
|
||||||
|
translator that pools a whole paragraph of a text with text
|
||||||
|
editing capability to perform grammar and semantic analysis.
|
||||||
|
|
||||||
|
To abstract such different input method specific intermediate
|
||||||
|
information, TQt offers the TQInputContext as base class. The
|
||||||
|
concept is well known as 'input context' in the input method
|
||||||
|
domain. an input context is created for a text widget in response
|
||||||
|
to a demand. It is ensured that an input context is prepared for
|
||||||
|
an input method before input to a text widget.
|
||||||
|
|
||||||
|
Multiple input contexts that is belonging to a single input method
|
||||||
|
may concurrently coexist. Suppose multi-window text editor. Each
|
||||||
|
text widget of window A and B holds different TQInputContext
|
||||||
|
instance which contains different state information such as
|
||||||
|
partially composed text.
|
||||||
|
|
||||||
|
\section1 Groups of functions:
|
||||||
|
|
||||||
|
\table
|
||||||
|
\header \i Context \i Functions
|
||||||
|
|
||||||
|
\row \i Receiving information \i
|
||||||
|
x11FilterEvent(),
|
||||||
|
filterEvent(),
|
||||||
|
setMicroFocus(),
|
||||||
|
mouseHandler()
|
||||||
|
|
||||||
|
\row \i Sending back composed text \i
|
||||||
|
sendIMEvent(),
|
||||||
|
|
||||||
|
\row \i State change notification \i
|
||||||
|
setFocus(),
|
||||||
|
unsetFocus(),
|
||||||
|
reset()
|
||||||
|
|
||||||
|
\row \i Context information \i
|
||||||
|
identifierName(),
|
||||||
|
language(),
|
||||||
|
font(),
|
||||||
|
isComposing(),
|
||||||
|
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Sharing input context between text widgets
|
||||||
|
|
||||||
|
Any input context can be shared between several text widgets to
|
||||||
|
reduce resource consumption. In ideal case, each text widgets
|
||||||
|
should be allocated dedicated input context. But some complex
|
||||||
|
input contexts require slightly heavy resource such as 100
|
||||||
|
kilobytes of memory. It prevents quite many text widgets from
|
||||||
|
being used concurrently.
|
||||||
|
|
||||||
|
To resolve such problem, we can share an input context. There is
|
||||||
|
one 'input context holder widget' per text widgets that shares
|
||||||
|
identical input context. In this model, the holder widget owns the
|
||||||
|
shared input context. Other text widgets access the input context
|
||||||
|
via TQApplication::locateICHolderWidget(). But the access
|
||||||
|
convention is transparently hidden into TQWidget, so developers are
|
||||||
|
not required to aware of it.
|
||||||
|
|
||||||
|
What developer should know is only the mapping function
|
||||||
|
TQApplication::locateICHolderWidget(). It accepts a widget as
|
||||||
|
argument and returns its holder widget. Default implementation
|
||||||
|
returns the top-level widget of the widget as reasonable
|
||||||
|
assumption. But some applications should reimplement the function
|
||||||
|
to fit application specific usability. See
|
||||||
|
TQApplication::locateICHolderWidget() for further information.
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Preedit preservation
|
||||||
|
|
||||||
|
As described above, input contexts have wide variety of amount of
|
||||||
|
the state information in accordance with belonging input
|
||||||
|
method. It is ranging from 2-3 keystrokes of sequence in
|
||||||
|
deterministic input methods to hundreds of keystrokes with
|
||||||
|
semantic text refinement in complex input methods such as ordinary
|
||||||
|
Japanese input method. The difference requires the different reset
|
||||||
|
policies in losing input focus.
|
||||||
|
|
||||||
|
The former simple input method case, users will prefer resetting
|
||||||
|
the context to back to the neutral state when something
|
||||||
|
happened. Suppose a web browsing. The user scroll the page by
|
||||||
|
scrollbar after he or she has typed a half of the valid key
|
||||||
|
sequence into a text widget. In the case, the input context should
|
||||||
|
be reset in losing focus when he or she has dragged the
|
||||||
|
scrollbar. He or she will be confused if the input context is
|
||||||
|
still preserved until focused back to the text widget because he
|
||||||
|
or she will restart typing with first key of the sequence as a
|
||||||
|
habitual operation.
|
||||||
|
|
||||||
|
On the other hand, we should choose completely different policy
|
||||||
|
for the latter complex input method case. Suppose same situation
|
||||||
|
as above but he or she is using a complex input method. In the
|
||||||
|
case, he or she will be angry if the input context has been lost
|
||||||
|
when he or she has dragged the scrollbar because the input context
|
||||||
|
contained a valuably composed text made up by considerable input
|
||||||
|
cost. So we should not reset the input context in the case. And
|
||||||
|
the input context should be preserved until focused back to the
|
||||||
|
text widget. This behavior is named as 'preedit preservation'.
|
||||||
|
|
||||||
|
The two policies can be switched by calling or not calling reset()
|
||||||
|
in unsetFocus(). Default implementation of unsetFocus() calls
|
||||||
|
reset() to fit the simple input methods. The implementation is
|
||||||
|
expressed as 'preedit preservation is disabled'.
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Preedit relocation
|
||||||
|
|
||||||
|
Although the most case of the preedit preservation problem for
|
||||||
|
complex input methods is resolved as described above, there is a
|
||||||
|
special case. Suppose the case that matches all of the following
|
||||||
|
conditions.
|
||||||
|
|
||||||
|
\list
|
||||||
|
|
||||||
|
\i a input focus has been moved from a text widget to another text
|
||||||
|
widget directly
|
||||||
|
|
||||||
|
\i the input context is shared between the two text widgets
|
||||||
|
|
||||||
|
\i preedit preservation is enabled for the input context
|
||||||
|
|
||||||
|
\endlist
|
||||||
|
|
||||||
|
In the case, there are the following two requirements that
|
||||||
|
contradicts each other. The input context sharing causes it.
|
||||||
|
|
||||||
|
\list
|
||||||
|
|
||||||
|
\i the input context has to be reset to prepare to input to the
|
||||||
|
newly focused text widget
|
||||||
|
|
||||||
|
\i the input context has to be preserved until focused back to the
|
||||||
|
previous text widget
|
||||||
|
|
||||||
|
\endlist
|
||||||
|
|
||||||
|
A intrinsic feature named 'preedit relocation' is available to
|
||||||
|
compromise the requirements. If the feature is enabled for the
|
||||||
|
input context, it is simply moved to the new text widget with the
|
||||||
|
preedit string. The user continues the input on the new text
|
||||||
|
widget, or relocate it to another text widget. The preedit of
|
||||||
|
previous text widget is automatically cleared to back to the
|
||||||
|
neutral state of the widget.
|
||||||
|
|
||||||
|
This strange behavior is just a compromise. As described in
|
||||||
|
previous section, complex input method user should not be exposed
|
||||||
|
to the risk losing the input context because it contains valuable
|
||||||
|
long text made up with considerable input cost. The user will
|
||||||
|
immediately focus back to the previous text widget to continue the
|
||||||
|
input in the correct text widget if the preedit relocation
|
||||||
|
occurred. The feature is mainly existing as safety.
|
||||||
|
|
||||||
|
The feature properly works even if the focus is moved as
|
||||||
|
following. Input method developers are not required to be aware of
|
||||||
|
the relocation protocol since TQInputContext transparently handles
|
||||||
|
it.
|
||||||
|
|
||||||
|
a text widget -> a non-text widget -> another text widget
|
||||||
|
|
||||||
|
To enable the preedit relocation feature, the input context class
|
||||||
|
have to reimplement isPreeditRelocationEnabled() as returns TRUE.
|
||||||
|
The implementation requires that the preedit preservation is also
|
||||||
|
enabled since preedit relocation is a special case of the preedit
|
||||||
|
preservation. If the preedit relocation is disabled, the input
|
||||||
|
context is simply reset in the relocation case.
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Input context instanciation
|
||||||
|
\section1 Input method switching
|
||||||
|
|
||||||
|
\section1 Text widget implementor's guide
|
||||||
|
|
||||||
|
Add following code fragment into createPopupMenu() to add input
|
||||||
|
method dependent submenus.
|
||||||
|
|
||||||
|
\code
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
TQInputContext *qic = getInputContext();
|
||||||
|
if ( qic )
|
||||||
|
qic->addMenusTo( popup );
|
||||||
|
#endif
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
\sa TQInputContextPlugin, TQInputContextFactory, TQApplication::locateICHolderWidget(), TQApplication::defaultInputMethod()
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs an input context.
|
||||||
|
|
||||||
|
holderWidget is set immediately after this constructor has been
|
||||||
|
returned on the X11 platform.
|
||||||
|
*/
|
||||||
|
TQInputContext::TQInputContext( TQObject *tqparent )
|
||||||
|
: TQObject( tqparent )
|
||||||
|
{
|
||||||
|
d = new TQInputContextPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destroys the input context.
|
||||||
|
*/
|
||||||
|
TQInputContext::~TQInputContext()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
Returns the owner of this input context. Ordinary input methods
|
||||||
|
should not call this function directly to keep platform
|
||||||
|
independence and flexible configuration possibility.
|
||||||
|
|
||||||
|
The return value may differ from tqfocusWidget() if the input
|
||||||
|
context is shared between several text widgets.
|
||||||
|
|
||||||
|
\sa setHolderWidget(), tqfocusWidget()
|
||||||
|
*/
|
||||||
|
TQWidget *TQInputContext::holderWidget() const
|
||||||
|
{
|
||||||
|
return d->holderWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
Sets the owner of this input context. Ordinary input methods
|
||||||
|
must not call this function directly.
|
||||||
|
|
||||||
|
\sa holderWidget()
|
||||||
|
*/
|
||||||
|
void TQInputContext::setHolderWidget( TQWidget *w )
|
||||||
|
{
|
||||||
|
d->holderWidget = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
Returns the widget that has an input focus for this input
|
||||||
|
context. Ordinary input methods should not call this function
|
||||||
|
directly to keep platform independence and flexible configuration
|
||||||
|
possibility.
|
||||||
|
|
||||||
|
The return value may differ from holderWidget() if the input
|
||||||
|
context is shared between several text widgets.
|
||||||
|
|
||||||
|
\sa setFocusWidget(), holderWidget()
|
||||||
|
*/
|
||||||
|
TQWidget *TQInputContext::tqfocusWidget() const
|
||||||
|
{
|
||||||
|
return d->hasFocus ? d->composingWidget : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
Sets the widget that has an input focus for this input
|
||||||
|
context. Ordinary input methods must not call this function
|
||||||
|
directly.
|
||||||
|
|
||||||
|
\sa tqfocusWidget()
|
||||||
|
*/
|
||||||
|
void TQInputContext::setFocusWidget( TQWidget *w )
|
||||||
|
{
|
||||||
|
if ( w ) {
|
||||||
|
bool isFocusingBack = ( w == d->composingWidget );
|
||||||
|
bool isPreeditRelocation = ( ! isFocusingBack && isComposing() &&
|
||||||
|
d->composingWidget );
|
||||||
|
// invoke sendIMEventInternal() rather than sendIMEvent() to
|
||||||
|
// avoid altering the composing state
|
||||||
|
if ( isPreeditRelocation == TRUE ) {
|
||||||
|
// clear preedit of previously focused text
|
||||||
|
// widget. preserved preedit may be exist even if
|
||||||
|
// isPreeditRelocationEnabled() == FALSE.
|
||||||
|
sendIMEventInternal( TQEvent::IMEnd );
|
||||||
|
}
|
||||||
|
d->composingWidget = w; // changes recipient of TQIMEvent
|
||||||
|
if ( isPreeditRelocation == TRUE ) {
|
||||||
|
#if !defined(TQT_NO_IM_PREEDIT_RELOCATION)
|
||||||
|
if ( isPreeditRelocationEnabled() ) {
|
||||||
|
// copy preedit state to the widget that gaining focus
|
||||||
|
sendIMEventInternal( TQEvent::IMStart );
|
||||||
|
sendIMEventInternal( TQEvent::IMCompose, d->preeditString,
|
||||||
|
d->cursorPosition, d->selLength );
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// reset input context when the shared context has
|
||||||
|
// focused on another text widget
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d->hasFocus = w ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
This function is called from TQWidget to keep input state
|
||||||
|
consistency. Ordinary input method must not call this function
|
||||||
|
directly.
|
||||||
|
*/
|
||||||
|
void TQInputContext::releaseComposingWidget( TQWidget *w )
|
||||||
|
{
|
||||||
|
if ( d->composingWidget == w ) {
|
||||||
|
d->composingWidget = 0;
|
||||||
|
d->hasFocus = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // TQ_WS_X11
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
This function can be reimplemented in a subclass as returning TRUE
|
||||||
|
if you want making your input method enable the preedit
|
||||||
|
relocation. See the description for preedit relocation of
|
||||||
|
TQInputContext.
|
||||||
|
|
||||||
|
/sa TQInputContext
|
||||||
|
*/
|
||||||
|
bool TQInputContext::isPreeditRelocationEnabled()
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function indicates whether IMStart event had been sent to the
|
||||||
|
text widget. It is ensured that an input context can send IMCompose
|
||||||
|
or IMEnd event safely if this function returned TRUE.
|
||||||
|
|
||||||
|
The state is automatically being tracked through sendIMEvent().
|
||||||
|
|
||||||
|
\sa sendIMEvent()
|
||||||
|
*/
|
||||||
|
bool TQInputContext::isComposing() const
|
||||||
|
{
|
||||||
|
return d->isComposing;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function can be reimplemented in a subclass to filter input
|
||||||
|
events.
|
||||||
|
|
||||||
|
Return TRUE if the \a event has been consumed. Otherwise, the
|
||||||
|
unfiltered \a event will be forwarded to widgets as ordinary
|
||||||
|
way. Although the input events have accept() and ignore()
|
||||||
|
methods, leave it untouched.
|
||||||
|
|
||||||
|
\a event is currently restricted to TQKeyEvent. But some input
|
||||||
|
method related events such as TQWheelEvent or TQTabletEvent may be
|
||||||
|
added in future.
|
||||||
|
|
||||||
|
The filtering opportunity is always given to the input context as
|
||||||
|
soon as possible. It has to be taken place before any other key
|
||||||
|
event consumers such as eventfilters and accelerators because some
|
||||||
|
input methods require quite various key combination and
|
||||||
|
sequences. It often conflicts with accelerators and so on, so we
|
||||||
|
must give the input context the filtering opportunity first to
|
||||||
|
ensure all input methods work properly regardless of application
|
||||||
|
design.
|
||||||
|
|
||||||
|
Ordinary input methods require discrete key events to work
|
||||||
|
properly, so TQt's key compression is always disabled for any input
|
||||||
|
contexts.
|
||||||
|
|
||||||
|
\sa TQKeyEvent, x11FilterEvent()
|
||||||
|
*/
|
||||||
|
bool TQInputContext::filterEvent( const TQEvent *event )
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void TQInputContext::deletionRequested()
|
||||||
|
|
||||||
|
Emit this signal when a fatal error has been caused in the input
|
||||||
|
context. The input context will be deleted by the owner which is
|
||||||
|
usually the holder widget.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void TQInputContext::imEventGenerated( TQObject *receiver, TQIMEvent *e )
|
||||||
|
|
||||||
|
\internal
|
||||||
|
This signal is emitted when the user has sent a TQIMEvent through
|
||||||
|
sendIMEvent(). Ordinary input methods should not emit this signal
|
||||||
|
directly.
|
||||||
|
|
||||||
|
\a receiver is a platform dependent destination of the \a e.
|
||||||
|
|
||||||
|
\sa TQIMEvent, sendIMEvent(), sendIMEventInternal(),
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
Sends a TQIMEvent to the client via imEventGenerated()
|
||||||
|
signal. Ordinary input method should not call this function
|
||||||
|
directly.
|
||||||
|
|
||||||
|
\sa TQIMEvent, TQIMComposeEvent, sendIMEvent(), imEventGenerated()
|
||||||
|
*/
|
||||||
|
void TQInputContext::sendIMEventInternal( TQEvent::Type type,
|
||||||
|
const TQString &text,
|
||||||
|
int cursorPosition, int selLength )
|
||||||
|
{
|
||||||
|
TQObject *receiver = 0;
|
||||||
|
TQIMEvent *event = 0;
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
receiver = d->composingWidget;
|
||||||
|
#elif defined(TQ_WS_TQWS)
|
||||||
|
// just a placeholder
|
||||||
|
#endif
|
||||||
|
if ( ! receiver )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( type == TQEvent::IMStart ) {
|
||||||
|
qDebug( "sending IMStart with %d chars to %p",
|
||||||
|
text.length(), receiver );
|
||||||
|
event = new TQIMEvent( type, text, cursorPosition );
|
||||||
|
} else if ( type == TQEvent::IMEnd ) {
|
||||||
|
qDebug( "sending IMEnd with %d chars to %p, text=%s",
|
||||||
|
text.length(), receiver, (const char*)text.local8Bit() );
|
||||||
|
event = new TQIMEvent( type, text, cursorPosition );
|
||||||
|
} else if ( type == TQEvent::IMCompose ) {
|
||||||
|
qDebug( "sending IMCompose to %p with %d chars, cpos=%d, sellen=%d, text=%s",
|
||||||
|
receiver, text.length(), cursorPosition, selLength,
|
||||||
|
(const char*)text.local8Bit() );
|
||||||
|
event = new TQIMComposeEvent( type, text, cursorPosition, selLength );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( event )
|
||||||
|
emit imEventGenerated( receiver, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Call this function to send TQIMEvent to the text widget. This
|
||||||
|
function constructs a TQIMEvent based on the arguments and send it
|
||||||
|
to the appropriate widget. Ordinary input method should not
|
||||||
|
reimplement this function.
|
||||||
|
|
||||||
|
\a type is either \c TQEvent::IMStart or \c TQEvent::IMCompose or \c
|
||||||
|
TQEvent::IMEnd. You have to send a \c TQEvent::IMStart to start
|
||||||
|
composing, then send several \c TQEvent::IMCompose to update the
|
||||||
|
preedit of the widget, and finalize the composition with sending
|
||||||
|
\c TQEvent::IMEnd.
|
||||||
|
|
||||||
|
\c TQEvent::IMStart should always be sent without arguments as:
|
||||||
|
\code
|
||||||
|
sendIMEvent( TQEvent::IMStart )
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
And \c TQEvent::IMCompose can be sent without cursor:
|
||||||
|
\code
|
||||||
|
sendIMEvent( TQEvent::IMCompose, TQString( "a text" ) )
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
Or optionally with cursor with \a cursorPosition:
|
||||||
|
\code
|
||||||
|
sendIMEvent( TQEvent::IMCompose, TQString( "a text with cursor" ), 12 )
|
||||||
|
\endcode
|
||||||
|
Note that \a cursorPosition also specifies microfocus position.
|
||||||
|
|
||||||
|
Or optionally with selection text:
|
||||||
|
\code
|
||||||
|
sendIMEvent( TQEvent::IMCompose, TQString( "a text with selection" ), 12, 9 )
|
||||||
|
\endcode
|
||||||
|
\a cursorPosition and \a selLength must be within the \a text. The
|
||||||
|
\a cursorPosition also specifies microfocus position in the case:
|
||||||
|
|
||||||
|
\c TQEvent::IMEnd can be sent without arguments to terminate the
|
||||||
|
composition with null string:
|
||||||
|
\code
|
||||||
|
sendIMEvent( TQEvent::IMEnd )
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
Or optionally accepts \a text to commit a string:
|
||||||
|
\code
|
||||||
|
sendIMEvent( TQEvent::IMEnd, TQString( "a text" ) )
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
\sa TQIMEvent, TQIMComposeEvent, setMicroFocus()
|
||||||
|
*/
|
||||||
|
void TQInputContext::sendIMEvent( TQEvent::Type type, const TQString &text,
|
||||||
|
int cursorPosition, int selLength )
|
||||||
|
{
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
if ( !tqfocusWidget() )
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( type == TQEvent::IMStart ) {
|
||||||
|
sendIMEventInternal( type, text, cursorPosition, selLength );
|
||||||
|
d->isComposing = TRUE;
|
||||||
|
} else if ( type == TQEvent::IMEnd ) {
|
||||||
|
d->resetComposingState();
|
||||||
|
sendIMEventInternal( type, text, cursorPosition, selLength );
|
||||||
|
} else if ( type == TQEvent::IMCompose ) {
|
||||||
|
d->updateComposingState( text, cursorPosition, selLength );
|
||||||
|
sendIMEventInternal( type, text, cursorPosition, selLength );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function can be reimplemented in a subclass to detect
|
||||||
|
that the input context has been focused on.
|
||||||
|
|
||||||
|
The input context will receive input events through
|
||||||
|
x11FilterEvent() and filterEvent() after setFocus() until
|
||||||
|
unsetFocus() has been called.
|
||||||
|
|
||||||
|
an input context is ensured that setFocus() is called exactly once
|
||||||
|
until unsetFocus() has been called even if preedit relocation has
|
||||||
|
occurred. This means that an input focus will survive between
|
||||||
|
several widgets that sharing the input context.
|
||||||
|
|
||||||
|
On the X11 platform, tqfocusWidget is already set before this
|
||||||
|
function has been called.
|
||||||
|
|
||||||
|
\sa unsetFocus()
|
||||||
|
*/
|
||||||
|
void TQInputContext::setFocus()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function can be reimplemented in a subclass to detect
|
||||||
|
that the input context has lost the focus.
|
||||||
|
|
||||||
|
an input context is ensured that unsetFocus() is not called during
|
||||||
|
preedit relocation. This means that an input focus will survive
|
||||||
|
between several widgets that sharing the input context.
|
||||||
|
|
||||||
|
Default implementation that calls reset() is sufficient for simple
|
||||||
|
input methods. You can override this function to alter the
|
||||||
|
behavior. For example, most Japanese input contexts should not be
|
||||||
|
reset on losing focus. The context sometimes contains a whole
|
||||||
|
paragraph and has minutes of lifetime different to ephemeral one
|
||||||
|
in other languages. The piled input context should be survived
|
||||||
|
until focused again since Japanese user naturally expects so.
|
||||||
|
|
||||||
|
On the X11 platform, tqfocusWidget is valid until this function has
|
||||||
|
been returned.
|
||||||
|
|
||||||
|
\sa setFocus()
|
||||||
|
*/
|
||||||
|
void TQInputContext::unsetFocus()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function can be implemented in a subclass to handle
|
||||||
|
microfocus changes.
|
||||||
|
|
||||||
|
'microfocus' stands for the input method focus point in the
|
||||||
|
preedit (XIM "spot" point) for complex language input handling. It
|
||||||
|
can be used to place auxiliary GUI widgets such as candidate
|
||||||
|
selection window.
|
||||||
|
|
||||||
|
\a x, \a y, \a w and \a h represents the position and size of the
|
||||||
|
cursor in the preedit string. \a f is the font on the location of
|
||||||
|
the cursor.
|
||||||
|
*/
|
||||||
|
void TQInputContext::setMicroFocus( int x, int y, int w, int h, TQFont *f )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function can be reimplemented in a subclass to handle mouse
|
||||||
|
presses/releases/doubleclicks/moves within the preedit text. You
|
||||||
|
can use the function to implement mouse-oriented user interface
|
||||||
|
such as text selection or popup menu for candidate selection.
|
||||||
|
|
||||||
|
The parameter \a x is the offset within the string that was sent
|
||||||
|
with the IMCompose event. The alteration boundary of \a x is
|
||||||
|
ensured as character boundary of preedit string accurately.
|
||||||
|
|
||||||
|
\a type is either \c TQEvent::MouseButtonPress or \c
|
||||||
|
TQEvent::MouseButtonRelease or \c TQEvent::MouseButtonDblClick or \c
|
||||||
|
TQEvent::MouseButtonMove. Refer \a button and \a state to determine
|
||||||
|
what operation has performed.
|
||||||
|
|
||||||
|
The method interface is imported from
|
||||||
|
TQWSInputMethod::mouseHandler() of TQt/Embedded 2.3.7 and extended
|
||||||
|
for desktop system.
|
||||||
|
*/
|
||||||
|
void TQInputContext::mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button,
|
||||||
|
TQt::ButtonState state )
|
||||||
|
{
|
||||||
|
// Default behavior for simple ephemeral input contexts. Some
|
||||||
|
// complex input contexts should not be reset here.
|
||||||
|
if ( type == TQEvent::MouseButtonPress ||
|
||||||
|
type == TQEvent::MouseButtonDblClick )
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the font of the current input widget
|
||||||
|
*/
|
||||||
|
TQFont TQInputContext::font() const
|
||||||
|
{
|
||||||
|
if ( !tqfocusWidget() )
|
||||||
|
return TQApplication::font(); //### absolutely last resort
|
||||||
|
|
||||||
|
return tqfocusWidget()->font();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function can be reimplemented in a subclass to reset the
|
||||||
|
state of the input method.
|
||||||
|
|
||||||
|
This function is called by several widgets to reset input
|
||||||
|
state. For example, a text widget call this function before
|
||||||
|
inserting a text to make widget ready to accept a text.
|
||||||
|
|
||||||
|
Default implementation is sufficient for simple input method. You
|
||||||
|
can override this function to reset external input method engines
|
||||||
|
in complex input method. In the case, call TQInputContext::reset()
|
||||||
|
to ensure proper termination of inputting.
|
||||||
|
|
||||||
|
You must not send any TQIMEvent except empty IMEnd event using
|
||||||
|
TQInputContext::reset() at reimplemented reset(). It will break
|
||||||
|
input state consistency.
|
||||||
|
*/
|
||||||
|
void TQInputContext::reset()
|
||||||
|
{
|
||||||
|
if ( isComposing() )
|
||||||
|
sendIMEvent( TQEvent::IMEnd );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function must be implemented in any subclasses to return the
|
||||||
|
identifier name of the input method.
|
||||||
|
|
||||||
|
Return value is the name to identify and specify input methods for
|
||||||
|
the input method switching mechanism and so on. The name has to be
|
||||||
|
consistent with TQInputContextPlugin::keys(). The name has to
|
||||||
|
consist of ASCII characters only.
|
||||||
|
|
||||||
|
There are two different names with different responsibility in the
|
||||||
|
input method domain. This function returns one of them. Another
|
||||||
|
name is called 'display name' that stands for the name for
|
||||||
|
endusers appeared in a menu and so on.
|
||||||
|
|
||||||
|
\sa TQInputContextPlugin::keys(), TQInputContextPlugin::displayName()
|
||||||
|
*/
|
||||||
|
TQString TQInputContext::identifierName()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function must be implemented in any subclasses to return a
|
||||||
|
language code (e.g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...)
|
||||||
|
of the input context. If the input context can handle multiple
|
||||||
|
languages, return the currently used one. The name has to be
|
||||||
|
consistent with TQInputContextPlugin::language().
|
||||||
|
|
||||||
|
This information will be used by language tagging feature in
|
||||||
|
TQIMEvent. It is required to distinguish unified han characters
|
||||||
|
correctly. It enables proper font and character code
|
||||||
|
handling. Suppose CJK-awared multilingual web browser
|
||||||
|
(that automatically modifies fonts in CJK-mixed text) and XML editor
|
||||||
|
(that automatically inserts lang attr).
|
||||||
|
|
||||||
|
\sa TQInputContextPlugin::language()
|
||||||
|
*/
|
||||||
|
TQString TQInputContext::language()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if ([[[TQT_VERSION IS DEPRECATED]]]-0 >= 0x040000)
|
||||||
|
/*!
|
||||||
|
This is a preliminary interface for TQt4
|
||||||
|
*/
|
||||||
|
TQList<TQAction *> TQInputContext::actions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/*!
|
||||||
|
This function can be reimplemented in a subclass to provide input
|
||||||
|
method dependent popup menus. Return 0 if the menus are
|
||||||
|
unnecessary.
|
||||||
|
|
||||||
|
Ownership of the object and tqchildren are transferred to the
|
||||||
|
caller, and the result must not be called
|
||||||
|
setAutoDelete(). TQInputContextMenu::title is used for label text
|
||||||
|
of the popup menu as submenu.
|
||||||
|
|
||||||
|
\sa addMenusTo()
|
||||||
|
*/
|
||||||
|
TQPtrList<TQInputContextMenu> *TQInputContext::menus()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Appends input method dependent submenus into \a popup. A separator
|
||||||
|
is also inserted into \a popup if \a action is InsertSeparator.
|
||||||
|
|
||||||
|
This is an utility function only for convenience in limited
|
||||||
|
situation. This function is used by input context owner such as
|
||||||
|
text widgets to add the submenus to its own context menu. If you
|
||||||
|
want to insert the submenus in more flexible way, use
|
||||||
|
TQInputContext::menus() manually. \a popup is not restricted to
|
||||||
|
context menu of a text widget. For example, the owner may be a
|
||||||
|
input method menu of TQtopia taskbar in TQt/Embedded platform.
|
||||||
|
|
||||||
|
\sa menus(), TQInputContextMenu::Action
|
||||||
|
*/
|
||||||
|
void TQInputContext::addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action )
|
||||||
|
{
|
||||||
|
if ( ! popup )
|
||||||
|
return;
|
||||||
|
|
||||||
|
TQPtrList<TQInputContextMenu> *imMenus = menus();
|
||||||
|
if ( imMenus ) {
|
||||||
|
if ( action == TQInputContextMenu::InsertSeparator )
|
||||||
|
popup->insertSeparator();
|
||||||
|
for ( TQPtrList<TQInputContextMenu>::Iterator it = imMenus->begin();
|
||||||
|
it != imMenus->end();
|
||||||
|
++it ) {
|
||||||
|
TQInputContextMenu *imMenu = *it;
|
||||||
|
popup->insertItem( imMenu->title, imMenu->popup );
|
||||||
|
}
|
||||||
|
imMenus->clear();
|
||||||
|
delete imMenus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //TQ_NO_IM
|
@ -0,0 +1,143 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** $Id: qinputcontext.h,v 1.8 2004/06/22 06:47:30 daisuke Exp $
|
||||||
|
**
|
||||||
|
** Definition of TQInputContext
|
||||||
|
**
|
||||||
|
** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
|
||||||
|
**
|
||||||
|
** This file is part of the kernel module of the TQt GUI Toolkit.
|
||||||
|
**
|
||||||
|
** This file may be distributed under the terms of the Q Public License
|
||||||
|
** as defined by Trolltech AS of Norway and appearing in the file
|
||||||
|
** LICENSE.TQPL included in the packaging of this file.
|
||||||
|
**
|
||||||
|
** This file may be distributed and/or modified under the terms of the
|
||||||
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
|
** packaging of this file.
|
||||||
|
**
|
||||||
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||||||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||||||
|
** Agreement provided with the Software.
|
||||||
|
**
|
||||||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
**
|
||||||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||||||
|
** information about TQt Commercial License Agreements.
|
||||||
|
** See http://www.trolltech.com/qpl/ for TQPL licensing information.
|
||||||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||||||
|
**
|
||||||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||||||
|
** not clear to you.
|
||||||
|
**
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef TQINPUTCONTEXT_H
|
||||||
|
#define TQINPUTCONTEXT_H
|
||||||
|
|
||||||
|
#ifndef TQT_NO_IM
|
||||||
|
|
||||||
|
#ifndef TQT_H
|
||||||
|
#include "tqobject.h"
|
||||||
|
#include "tqglobal.h"
|
||||||
|
#include "tqevent.h"
|
||||||
|
#include "tqstring.h"
|
||||||
|
#if ([[[TQT_VERSION IS DEPRECATED]]]-0 >= 0x040000)
|
||||||
|
#include "tqlist.h"
|
||||||
|
#include "tqaction.h"
|
||||||
|
#else
|
||||||
|
#include "tqptrlist.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TQWidget;
|
||||||
|
class TQFont;
|
||||||
|
class TQPopupMenu;
|
||||||
|
class TQInputContextPrivate;
|
||||||
|
|
||||||
|
|
||||||
|
struct TQInputContextMenu {
|
||||||
|
enum Action {
|
||||||
|
NoSeparator,
|
||||||
|
InsertSeparator
|
||||||
|
};
|
||||||
|
#if !([[[TQT_VERSION IS DEPRECATED]]]-0 >= 0x040000)
|
||||||
|
TQString title;
|
||||||
|
TQPopupMenu *popup;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TQInputContext : public TQObject
|
||||||
|
{
|
||||||
|
TQ_OBJECT
|
||||||
|
public:
|
||||||
|
TQInputContext( TQObject *tqparent = 0 );
|
||||||
|
virtual ~TQInputContext();
|
||||||
|
|
||||||
|
virtual TQString identifierName();
|
||||||
|
virtual TQString language();
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
virtual bool x11FilterEvent( TQWidget *keywidget, XEvent *event );
|
||||||
|
#endif // TQ_WS_X11
|
||||||
|
virtual bool filterEvent( const TQEvent *event );
|
||||||
|
virtual void reset();
|
||||||
|
|
||||||
|
virtual void setFocus();
|
||||||
|
virtual void unsetFocus();
|
||||||
|
virtual void setMicroFocus( int x, int y, int w, int h, TQFont *f = 0 );
|
||||||
|
virtual void mouseHandler( int x, TQEvent::Type type,
|
||||||
|
TQt::ButtonState button, TQt::ButtonState state );
|
||||||
|
virtual TQFont font() const;
|
||||||
|
virtual bool isComposing() const;
|
||||||
|
virtual bool isPreeditRelocationEnabled();
|
||||||
|
|
||||||
|
#if ([[[TQT_VERSION IS DEPRECATED]]]-0 >= 0x040000)
|
||||||
|
virtual TQList<TQAction *> actions();
|
||||||
|
void addActionsTo( TQMenu *menu, TQInputContextMenu::Action action = TQInputContextMenu::InsertSeparator );
|
||||||
|
#else
|
||||||
|
virtual TQPtrList<TQInputContextMenu> *menus();
|
||||||
|
void addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action = TQInputContextMenu::InsertSeparator );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TQ_WS_X11)
|
||||||
|
// these functions are not recommended for ordinary use
|
||||||
|
virtual TQWidget *tqfocusWidget() const;
|
||||||
|
virtual TQWidget *holderWidget() const;
|
||||||
|
|
||||||
|
// these functions must not be used by ordinary input method
|
||||||
|
virtual void setFocusWidget( TQWidget *w );
|
||||||
|
virtual void setHolderWidget( TQWidget *w );
|
||||||
|
virtual void releaseComposingWidget( TQWidget *w );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void deletionRequested();
|
||||||
|
void imEventGenerated( TQObject *receiver, TQIMEvent *e );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void sendIMEvent( TQEvent::Type type,
|
||||||
|
const TQString &text = TQString(),
|
||||||
|
int cursorPosition = -1, int selLength = 0 );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void sendIMEventInternal( TQEvent::Type type,
|
||||||
|
const TQString &text = TQString(),
|
||||||
|
int cursorPosition = -1, int selLength = 0 );
|
||||||
|
|
||||||
|
TQInputContextPrivate *d;
|
||||||
|
|
||||||
|
friend class TQWidget;
|
||||||
|
friend class TQInputContextFactory;
|
||||||
|
|
||||||
|
private: // Disabled copy constructor and operator=
|
||||||
|
TQInputContext( const TQInputContext & );
|
||||||
|
TQInputContext &operator=( const TQInputContext & );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //TQ_NO_IM
|
||||||
|
|
||||||
|
#endif // TQINPUTCONTEXT_H
|
Loading…
Reference in new issue