From 39f8a475b4ec5c87a11a7e9300a30ef1c5b4a7e1 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 31 Aug 2024 19:56:49 +0900 Subject: Rename remaining ntq[i-l]* related files to equivalent tq* Signed-off-by: Michele Calgaro --- src/kernel/ntqinputcontext.h | 131 ------ src/kernel/ntqjpegio.h | 52 --- src/kernel/ntqkeycode.h | 50 --- src/kernel/ntqkeysequence.h | 109 ----- src/kernel/ntqnamespace.h | 2 +- src/kernel/ntqt.h | 10 +- src/kernel/qapplication.cpp | 2 +- src/kernel/qapplication_x11.cpp | 2 +- src/kernel/qinputcontext.cpp | 849 ----------------------------------- src/kernel/qinputcontext_p.h | 115 ----- src/kernel/qinputcontext_x11.cpp | 75 ---- src/kernel/qjpegio.cpp | 595 ------------------------ src/kernel/qkeysequence.cpp | 736 ------------------------------ src/kernel/qscriptengine_x11.cpp | 2 +- src/kernel/qt_gfx.pri | 4 +- src/kernel/qt_kernel.pri | 16 +- src/kernel/qvariant.cpp | 2 +- src/kernel/tqaccel.h | 2 +- src/kernel/tqimage.cpp | 2 +- src/kernel/tqinputcontext.cpp | 849 +++++++++++++++++++++++++++++++++++ src/kernel/tqinputcontext.h | 131 ++++++ src/kernel/tqinputcontext_p.h | 115 +++++ src/kernel/tqinputcontext_x11.cpp | 75 ++++ src/kernel/tqjpegio.cpp | 595 ++++++++++++++++++++++++ src/kernel/tqjpegio.h | 52 +++ src/kernel/tqkeycode.h | 50 +++ src/kernel/tqkeysequence.cpp | 736 ++++++++++++++++++++++++++++++ src/kernel/tqkeysequence.h | 109 +++++ src/kernel/tqttdeintegration_x11.cpp | 2 +- src/kernel/tqwidget.cpp | 2 +- src/kernel/tqwidget_x11.cpp | 4 +- 31 files changed, 2738 insertions(+), 2738 deletions(-) delete mode 100644 src/kernel/ntqinputcontext.h delete mode 100644 src/kernel/ntqjpegio.h delete mode 100644 src/kernel/ntqkeycode.h delete mode 100644 src/kernel/ntqkeysequence.h delete mode 100644 src/kernel/qinputcontext.cpp delete mode 100644 src/kernel/qinputcontext_p.h delete mode 100644 src/kernel/qinputcontext_x11.cpp delete mode 100644 src/kernel/qjpegio.cpp delete mode 100644 src/kernel/qkeysequence.cpp create mode 100644 src/kernel/tqinputcontext.cpp create mode 100644 src/kernel/tqinputcontext.h create mode 100644 src/kernel/tqinputcontext_p.h create mode 100644 src/kernel/tqinputcontext_x11.cpp create mode 100644 src/kernel/tqjpegio.cpp create mode 100644 src/kernel/tqjpegio.h create mode 100644 src/kernel/tqkeycode.h create mode 100644 src/kernel/tqkeysequence.cpp create mode 100644 src/kernel/tqkeysequence.h (limited to 'src/kernel') diff --git a/src/kernel/ntqinputcontext.h b/src/kernel/ntqinputcontext.h deleted file mode 100644 index 426aa796a..000000000 --- a/src/kernel/ntqinputcontext.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** $Id: ntqinputcontext.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 QT_H -#include "tqobject.h" -#include "tqglobal.h" -#include "tqevent.h" -#include "tqstring.h" -#include "tqptrlist.h" -#endif - -class TQWidget; -class TQFont; -class TQPopupMenu; -class TQInputContextPrivate; - - -struct TQInputContextMenu { - enum Action { - NoSeparator, - InsertSeparator - }; - TQString title; - TQPopupMenu *popup; -}; - - -class TQ_EXPORT TQInputContext : public TQObject -{ - TQ_OBJECT -public: - TQInputContext( TQObject *parent = 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(); - - virtual TQPtrList *menus(); - void addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action = TQInputContextMenu::InsertSeparator ); - -#if defined(TQ_WS_X11) - // these functions are not recommended for ordinary use - virtual TQWidget *focusWidget() 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::null, - int cursorPosition = -1, int selLength = 0 ); - -private: - void sendIMEventInternal( TQEvent::Type type, - const TQString &text = TQString::null, - 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 //Q_NO_IM - -#endif // TQINPUTCONTEXT_H diff --git a/src/kernel/ntqjpegio.h b/src/kernel/ntqjpegio.h deleted file mode 100644 index 10ae8d7cf..000000000 --- a/src/kernel/ntqjpegio.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Definition of JPEG TQImage IOHandler -** -** Created : 970621 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQJPEGIO_H -#define TQJPEGIO_H - -#include "tqglobal.h" - -#ifndef TQT_NO_IMAGEIO_JPEG - -void qInitJpegIO(); - -#endif // TQT_NO_IMAGEIO_JPEG - -#endif // TQJPEGIO_H diff --git a/src/kernel/ntqkeycode.h b/src/kernel/ntqkeycode.h deleted file mode 100644 index bca9305ba..000000000 --- a/src/kernel/ntqkeycode.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Definition of keyboard codes -** -** Created : 931030 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQKEYCODE_H -#define TQKEYCODE_H - -#ifndef QT_H -#include "ntqnamespace.h" -#endif // QT_H - -// all key codes are now in the TQt namespace class - -#endif // TQKEYCODE_H diff --git a/src/kernel/ntqkeysequence.h b/src/kernel/ntqkeysequence.h deleted file mode 100644 index e4800839d..000000000 --- a/src/kernel/ntqkeysequence.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Definition of TQKeySequence class -** -** Created : 0108007 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQKEYSEQUENCE_H -#define TQKEYSEQUENCE_H - -#ifndef QT_H -#ifndef QT_H -#include "ntqnamespace.h" -#include "tqstring.h" -#endif // QT_H -#endif - -#ifndef TQT_NO_ACCEL - -/***************************************************************************** - TQKeySequence stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -class TQKeySequence; -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQKeySequence & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQKeySequence & ); -#endif - -class TQKeySequencePrivate; - -class TQ_EXPORT TQKeySequence : public TQt -{ -public: - TQKeySequence(); - TQKeySequence( const TQString& key ); - TQKeySequence( int key ); - TQKeySequence( int k1, int k2, int k3 = 0, int k4 = 0 ); - TQKeySequence( const TQKeySequence & ); - ~TQKeySequence(); - - uint count() const; - bool isEmpty() const; - TQt::SequenceMatch matches( const TQKeySequence & ) const; - - operator TQString() const; - operator int () const; - int operator[]( uint ) const; - TQKeySequence &operator=( const TQKeySequence & ); - bool operator==( const TQKeySequence& ) const; - bool operator!= ( const TQKeySequence& ) const; - -private: - static int decodeString( const TQString & ); - static TQString encodeString( int ); - int assign( TQString ); - void setKey( int key, int index ); - - TQKeySequencePrivate* d; - - friend TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQKeySequence & ); - friend TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQKeySequence & ); - friend class TQAccelManager; -}; - -#else - -class TQ_EXPORT TQKeySequence : public TQt -{ -public: - TQKeySequence() {} - TQKeySequence( int ) {} -}; - -#endif //TQT_NO_ACCEL - -#endif diff --git a/src/kernel/ntqnamespace.h b/src/kernel/ntqnamespace.h index c6bdd1b0d..f5ec7dd1d 100644 --- a/src/kernel/ntqnamespace.h +++ b/src/kernel/ntqnamespace.h @@ -335,7 +335,7 @@ public: }; #endif - // documented in qkeysequence.cpp + // documented in tqkeysequence.cpp enum SequenceMatch { NoMatch, PartialMatch, diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index e04574828..0a1ffc22b 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -28,7 +28,7 @@ #include "tqstring.h" #include "tqptrlist.h" #include "tqiodevice.h" -#include "ntqkeysequence.h" +#include "tqkeysequence.h" #include "ntqwindowdefs.h" #include "tqgdict.h" #include "tqfont.h" @@ -114,13 +114,13 @@ #include "tqpicture.h" #include #include -#include +#include #include #include "tqlabel.h" #include "tqlayout.h" #include -#include -#include +#include +#include #include "tqscrollbar.h" #include "tqscrollview.h" #include "tqdir.h" @@ -302,7 +302,7 @@ #include "private/tqdialogbuttons_p.h" #include "private/tqwidgetinterface_p.h" #include "private/tqwidgetresizehandler_p.h" -#include "private/qlibrary_p.h" +#include "private/tqlibrary_p.h" #endif // Private headers diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index a4fded7f0..8f04514cf 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -61,7 +61,7 @@ #include "tqdir.h" #include "tqfileinfo.h" #ifdef TQ_WS_WIN -#include "qinputcontext_p.h" +#include "tqinputcontext_p.h" #endif #include "tqfontdata_p.h" diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index b611778d7..c1d8345b1 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -90,7 +90,7 @@ // Input method stuff - UNFINISHED #ifndef TQT_NO_IM -#include "ntqinputcontext.h" +#include "tqinputcontext.h" #endif // TQT_NO_IM #include "qinternal_p.h" // shared double buffer cleanup diff --git a/src/kernel/qinputcontext.cpp b/src/kernel/qinputcontext.cpp deleted file mode 100644 index 8693da969..000000000 --- a/src/kernel/qinputcontext.cpp +++ /dev/null @@ -1,849 +0,0 @@ -/**************************************************************************** -** $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 "ntqinputcontext.h" - -#ifndef TQT_NO_IM - -#include "qplatformdefs.h" - -#include "ntqapplication.h" -#include "tqwidget.h" -#include "tqpopupmenu.h" - -#include -#include - -class TQInputContextPrivate -{ -public: - TQInputContextPrivate() - : holderWidget( 0 ), composingWidget( 0 ), hasFocus( FALSE ), - isComposing( FALSE ) -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - , preeditString( TQString::null ), - 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::null; - cursorPosition = -1; - selLength = 0; -#endif - } - -#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) - TQString preeditString; - int cursorPosition; - int selLength; -#endif -}; - - -// UPDATED COMMENT REQUIRED -- 2004-07-08 YamaKen -/*! - \class TQInputContext ntqinputcontext.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 *parent ) - : TQObject( parent ) -{ - 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 focusWidget() if the input - context is shared between several text widgets. - - \sa setHolderWidget(), focusWidget() -*/ -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::focusWidget() 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 focusWidget() -*/ -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 ) -{ - Q_UNUSED(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; -#endif - if ( ! receiver ) - return; - - if ( type == TQEvent::IMStart ) { - tqDebug( "sending IMStart with %d chars to %p", - text.length(), receiver ); - event = new TQIMEvent( type, text, cursorPosition ); - } else if ( type == TQEvent::IMEnd ) { - tqDebug( "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 ) { - tqDebug( "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 ( !focusWidget() ) - 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, focusWidget 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, focusWidget 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 ) -{ - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(w); - Q_UNUSED(h); - Q_UNUSED(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. - */ -void TQInputContext::mouseHandler( int x, TQEvent::Type type, - TQt::ButtonState button, - TQt::ButtonState state ) -{ - Q_UNUSED(x); - Q_UNUSED(button); - Q_UNUSED(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 ( !focusWidget() ) - return TQApplication::font(); //### absolutely last resort - - return focusWidget()->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 ""; -} - - -/*! - 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 children 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 *TQInputContext::menus() -{ - return 0; -} - -/*! - 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. - - \sa menus(), TQInputContextMenu::Action -*/ -void TQInputContext::addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action ) -{ - if ( ! popup ) - return; - - TQPtrList *imMenus = menus(); - if ( imMenus ) { - if ( action == TQInputContextMenu::InsertSeparator ) - popup->insertSeparator(); - for ( TQPtrList::Iterator it = imMenus->begin(); - it != imMenus->end(); - ++it ) { - TQInputContextMenu *imMenu = *it; - popup->insertItem( imMenu->title, imMenu->popup ); - } - imMenus->clear(); - delete imMenus; - } -} - -#endif //Q_NO_IM diff --git a/src/kernel/qinputcontext_p.h b/src/kernel/qinputcontext_p.h deleted file mode 100644 index 37ba52b6c..000000000 --- a/src/kernel/qinputcontext_p.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Definition of ??? -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQINPUTCONTEXT_P_H -#define TQINPUTCONTEXT_P_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. -// -// - -#include "tqglobal.h" - -class TQKeyEvent; -class TQWidget; -class TQFont; -class TQString; - - -#ifdef TQ_WS_X11 -#include "tqmemarray.h" -#include "ntqwindowdefs.h" -#include "qt_x11_p.h" -#endif - -#ifdef TQ_WS_WIN -#include "qt_windows.h" -#endif - -class TQInputContext -{ -public: -#ifdef TQ_WS_X11 - TQInputContext(TQWidget *); // should be a toplevel widget - ~TQInputContext(); - - void setFocus(); - void setComposePosition(int, int); - void setComposeArea(int, int, int, int); - void reset(); - - int lookupString(XKeyEvent *, TQCString &, KeySym *, Status *) const; - void setXFontSet(const TQFont &); - - void *ic; - TQString text; - TQWidget *focusWidget; - bool composing; - TQFont font; - XFontSet fontset; - TQMemArray selectedChars; -#endif // TQ_WS_X11 - -#ifdef TQ_WS_WIN - static void init(); - static void shutdown(); - - static void TranslateMessage( const MSG *msg); - static LRESULT DefWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); - - static void setFont( const TQWidget *w, const TQFont & ); - static void setFocusHint( int x, int y, int w, int h, const TQWidget *widget ); - static bool startComposition(); - static bool endComposition( TQWidget *fw = 0 ); - static bool composition( LPARAM lparam ); - - static void accept( TQWidget *fw = 0 ); - static void enable( TQWidget *w, bool b ); -#endif -}; - -#endif // TQINPUTCONTEXT_P_H diff --git a/src/kernel/qinputcontext_x11.cpp b/src/kernel/qinputcontext_x11.cpp deleted file mode 100644 index 0a314dfbb..000000000 --- a/src/kernel/qinputcontext_x11.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQInputContext class -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqinputcontext.h" - -#ifndef TQT_NO_IM - -#include "qplatformdefs.h" - -#include "ntqapplication.h" -#include "tqwidget.h" - -#include "qt_x11_p.h" - -/*! - This function may be overridden only if input method is depending - on X11 and you need raw XEvent. Otherwise, this function must not. - - This function is designed to filter raw key events for XIM, but - other input methods may use this to implement some special - features such as distinguishing Shift_L and Shift_R. - - Return TRUE if the \a event has been consumed. Otherwise, the - unfiltered \a event will be translated into TQEvent and forwarded - to filterEvent(). Filtering at both x11FilterEvent() and - filterEvent() in single input method is allowed. - - \a keywidget is a client widget into which a text is inputted. \a - event is inputted XEvent. - - \sa filterEvent() -*/ -bool TQInputContext::x11FilterEvent( TQWidget *keywidget, XEvent *event ) -{ - Q_UNUSED(keywidget); - Q_UNUSED(event); - return FALSE; -} - -#endif //Q_NO_IM diff --git a/src/kernel/qjpegio.cpp b/src/kernel/qjpegio.cpp deleted file mode 100644 index 56b22fbbf..000000000 --- a/src/kernel/qjpegio.cpp +++ /dev/null @@ -1,595 +0,0 @@ -/**************************************************************************** -** -** Implementation of JPEG TQImage IOHandler -** -** Created : 990521 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqimage.h" - -#ifndef TQT_NO_IMAGEIO_JPEG - -#include "tqiodevice.h" -#include "ntqjpegio.h" - -#include // jpeglib needs this to be pre-included -#include - - -// including jpeglib.h seems to be a little messy -extern "C" { -#define XMD_H // shut JPEGlib up -#if defined(Q_OS_UNIXWARE) -# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this -#endif -#include -#ifdef const -# undef const // remove crazy C hackery in jconfig.h -#endif -} - - -struct my_error_mgr : public jpeg_error_mgr { - jmp_buf setjmp_buffer; -}; - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif - -static -void my_error_exit (j_common_ptr cinfo) -{ - my_error_mgr* myerr = (my_error_mgr*) cinfo->err; - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - tqWarning("%s", buffer); - longjmp(myerr->setjmp_buffer, 1); -} - -#if defined(Q_C_CALLBACKS) -} -#endif - - -static const int max_buf = 4096; - -struct my_jpeg_source_mgr : public jpeg_source_mgr { - // Nothing dynamic - cannot rely on destruction over longjump - TQImageIO* iio; - JOCTET buffer[max_buf]; - -public: - my_jpeg_source_mgr(TQImageIO* iio); -}; - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif - -static -void tqt_init_source(j_decompress_ptr) -{ -} - -static -boolean qt_fill_input_buffer(j_decompress_ptr cinfo) -{ - int num_read; - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - TQIODevice* dev = src->iio->ioDevice(); - src->next_input_byte = src->buffer; - num_read = dev->readBlock((char*)src->buffer, max_buf); - if ( num_read <= 0 ) { - // Insert a fake EOI marker - as per jpeglib recommendation - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - src->bytes_in_buffer = 2; - } else { - src->bytes_in_buffer = num_read; - } -#if defined(Q_OS_UNIXWARE) - return B_TRUE; -#else - return TRUE; -#endif -} - -static -void qt_skip_input_data(j_decompress_ptr cinfo, long num_bytes) -{ - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - - // `dumb' implementation from jpeglib - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->bytes_in_buffer) { - num_bytes -= (long) src->bytes_in_buffer; - (void) qt_fill_input_buffer(cinfo); - /* note we assume that qt_fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->next_input_byte += (size_t) num_bytes; - src->bytes_in_buffer -= (size_t) num_bytes; - } -} - -static -void qt_term_source(j_decompress_ptr) -{ -} - -#if defined(Q_C_CALLBACKS) -} -#endif - - -inline my_jpeg_source_mgr::my_jpeg_source_mgr(TQImageIO* iioptr) -{ - jpeg_source_mgr::init_source = tqt_init_source; - jpeg_source_mgr::fill_input_buffer = qt_fill_input_buffer; - jpeg_source_mgr::skip_input_data = qt_skip_input_data; - jpeg_source_mgr::resync_to_restart = jpeg_resync_to_restart; - jpeg_source_mgr::term_source = qt_term_source; - iio = iioptr; - bytes_in_buffer = 0; - next_input_byte = buffer; -} - - -static -void scaleSize( int &reqW, int &reqH, int imgW, int imgH, TQImage::ScaleMode mode ) -{ - if ( mode == TQImage::ScaleFree ) - return; - int t1 = imgW * reqH; - int t2 = reqW * imgH; - if (( mode == TQImage::ScaleMin && (t1 > t2) ) || ( mode == TQImage::ScaleMax && (t1 < t2) )) - reqH = t2 / imgW; - else - reqW = t1 / imgH; -} - - -static -void read_jpeg_image(TQImageIO* iio) -{ - TQImage image; - - struct jpeg_decompress_struct cinfo; - - struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(iio); - struct my_error_mgr jerr; - - cinfo.err = jpeg_std_error(&jerr); - jerr.error_exit = my_error_exit; - - jpeg_create_decompress(&cinfo); - - cinfo.src = iod_src; - - if (!setjmp(jerr.setjmp_buffer)) { -#if defined(Q_OS_UNIXWARE) - (void) jpeg_read_header(&cinfo, B_TRUE); -#else - (void) jpeg_read_header(&cinfo, TRUE); -#endif - - (void) jpeg_start_decompress(&cinfo); - - TQString params = iio->parameters(); - params.simplifyWhiteSpace(); - int sWidth = 0, sHeight = 0; - char sModeStr[1024] = ""; - TQImage::ScaleMode sMode; - - if ( params.contains( "GetHeaderInformation" ) ) { - - // Create TQImage's without allocating the data - if ( cinfo.output_components == 3 || cinfo.output_components == 4) { - image = TQImage( NULL, cinfo.output_width, cinfo.output_height, 32, NULL, 0, TQImage::IgnoreEndian ); - } else if ( cinfo.output_components == 1 ) { - image = TQImage( NULL, cinfo.output_width, cinfo.output_height, 8, NULL, 0, TQImage::IgnoreEndian ); - } else { - // Unsupported format - } - - - } else if ( params.contains( "Scale" ) ) { - sscanf( params.latin1(), "Scale( %i, %i, %1023s )", - &sWidth, &sHeight, sModeStr ); - - TQString sModeTQStr( sModeStr ); - if ( sModeTQStr == "ScaleFree" ) { - sMode = TQImage::ScaleFree; - } else if ( sModeTQStr == "ScaleMin" ) { - sMode = TQImage::ScaleMin; - } else if ( sModeTQStr == "ScaleMax" ) { - sMode = TQImage::ScaleMax; - } else { - tqDebug("read_jpeg_image: invalid scale mode \"%s\", see TQImage::ScaleMode documentation", sModeStr); - sMode = TQImage::ScaleFree; - } - -// tqDebug( "Parameters ask to scale the image to %i x %i ScaleMode: %s", sWidth, sHeight, sModeStr ); - scaleSize( sWidth, sHeight, cinfo.output_width, cinfo.output_height, sMode ); -// tqDebug( "Scaling the jpeg to %i x %i", sWidth, sHeight, sModeStr ); - - bool created = FALSE; - if ( cinfo.output_components == 3 || cinfo.output_components == 4) { - created = image.create( sWidth, sHeight, 32 ); - } else if ( cinfo.output_components == 1 ) { - created = image.create( sWidth, sHeight, 8, 256 ); - for (int i=0; i<256; i++) - image.setColor(i, tqRgb(i,i,i)); - } else { - // Unsupported format - } - if (!created) - image = TQImage(); - - if (!image.isNull()) { - TQImage tmpImage( cinfo.output_width, 1, 32 ); - uchar** inLines = tmpImage.jumpTable(); - uchar** outLines = image.jumpTable(); - while (cinfo.output_scanline < cinfo.output_height) { - int outputLine = sHeight * cinfo.output_scanline / cinfo.output_height; - (void) jpeg_read_scanlines(&cinfo, inLines, 1); - if ( cinfo.output_components == 3 ) { - uchar *in = inLines[0]; - TQRgb *out = (TQRgb*)outLines[outputLine]; - for (uint i=0; i32 bpp. - for (uint j=0; jsetImage(image); - iio->setStatus(image.isNull()); - } - - jpeg_destroy_decompress(&cinfo); - delete iod_src; -} - - -struct my_jpeg_destination_mgr : public jpeg_destination_mgr { - // Nothing dynamic - cannot rely on destruction over longjump - TQImageIO* iio; - JOCTET buffer[max_buf]; - -public: - my_jpeg_destination_mgr(TQImageIO*); -}; - - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif - -static -void tqt_init_destination(j_compress_ptr) -{ -} - -static -void qt_exit_on_error(j_compress_ptr cinfo, TQIODevice* dev) -{ - if (dev->status() == IO_Ok) { - return; - } else { - // cinfo->err->msg_code = JERR_FILE_WRITE; - (*cinfo->err->error_exit)((j_common_ptr)cinfo); - } -} - -static -boolean qt_empty_output_buffer(j_compress_ptr cinfo) -{ - my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; - TQIODevice* dev = dest->iio->ioDevice(); - - if ( dev->writeBlock( (char*)dest->buffer, max_buf ) != max_buf ) - qt_exit_on_error(cinfo, dev); - - dest->next_output_byte = dest->buffer; - dest->free_in_buffer = max_buf; - -#if defined(Q_OS_UNIXWARE) - return B_TRUE; -#else - return TRUE; -#endif -} - -static -void qt_term_destination(j_compress_ptr cinfo) -{ - my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; - TQIODevice* dev = dest->iio->ioDevice(); - TQ_LONG n = max_buf - dest->free_in_buffer; - - if ( dev->writeBlock( (char*)dest->buffer, n ) != n ) - qt_exit_on_error(cinfo, dev); - - dev->flush(); - - qt_exit_on_error(cinfo, dev); -} - -#if defined(Q_C_CALLBACKS) -} -#endif - - -inline -my_jpeg_destination_mgr::my_jpeg_destination_mgr(TQImageIO* iioptr) -{ - jpeg_destination_mgr::init_destination = tqt_init_destination; - jpeg_destination_mgr::empty_output_buffer = qt_empty_output_buffer; - jpeg_destination_mgr::term_destination = qt_term_destination; - iio = iioptr; - next_output_byte = buffer; - free_in_buffer = max_buf; -} - - -static -void write_jpeg_image(TQImageIO* iio) -{ - TQImage image = iio->image(); - - struct jpeg_compress_struct cinfo; - JSAMPROW row_pointer[1]; - row_pointer[0] = 0; - - struct my_jpeg_destination_mgr *iod_dest = new my_jpeg_destination_mgr(iio); - struct my_error_mgr jerr; - - cinfo.err = jpeg_std_error(&jerr); - - jerr.error_exit = my_error_exit; - - if (!setjmp(jerr.setjmp_buffer)) { - jpeg_create_compress(&cinfo); - - cinfo.dest = iod_dest; - - cinfo.image_width = image.width(); - cinfo.image_height = image.height(); - - TQRgb* cmap=0; - bool gray=FALSE; - switch ( image.depth() ) { - case 1: - case 8: - cmap = image.colorTable(); - gray = TRUE; - int i; - for (i=image.numColors(); gray && i--; ) { - gray = gray & ( tqRed(cmap[i]) == tqGreen(cmap[i]) && - tqRed(cmap[i]) == tqBlue(cmap[i]) ); - } - cinfo.input_components = gray ? 1 : 3; - cinfo.in_color_space = gray ? JCS_GRAYSCALE : JCS_RGB; - break; - case 32: - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - } - - jpeg_set_defaults(&cinfo); - - float diffInch = TQABS(image.dotsPerMeterX()*2.54/100. - tqRound(image.dotsPerMeterX()*2.54/100.)) - + TQABS(image.dotsPerMeterY()*2.54/100. - tqRound(image.dotsPerMeterY()*2.54/100.)); - float diffCm = (TQABS(image.dotsPerMeterX()/100. - tqRound(image.dotsPerMeterX()/100.)) - + TQABS(image.dotsPerMeterY()/100. - tqRound(image.dotsPerMeterY()/100.)))*2.54; - if (diffInch < diffCm) { - cinfo.density_unit = 1; // dots/inch - cinfo.X_density = tqRound(image.dotsPerMeterX()*2.54/100.); - cinfo.Y_density = tqRound(image.dotsPerMeterY()*2.54/100.); - } else { - cinfo.density_unit = 2; // dots/cm - cinfo.X_density = (image.dotsPerMeterX()+50) / 100; - cinfo.Y_density = (image.dotsPerMeterY()+50) / 100; - } - - int quality = iio->quality() >= 0 ? TQMIN(iio->quality(),100) : 75; -#if defined(Q_OS_UNIXWARE) - jpeg_set_quality(&cinfo, quality, B_TRUE /* limit to baseline-JPEG values */); - jpeg_start_compress(&cinfo, B_TRUE); -#else - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - jpeg_start_compress(&cinfo, TRUE); -#endif - - row_pointer[0] = new uchar[cinfo.image_width*cinfo.input_components]; - int w = cinfo.image_width; - while (cinfo.next_scanline < cinfo.image_height) { - uchar *row = row_pointer[0]; - switch ( image.depth() ) { - case 1: - if (gray) { - uchar* data = image.scanLine(cinfo.next_scanline); - if ( image.bitOrder() == TQImage::LittleEndian ) { - for (int i=0; i> 3)) & (1 << (i & 7))); - row[i] = tqRed(cmap[bit]); - } - } else { - for (int i=0; i> 3)) & (1 << (7 -(i & 7)))); - row[i] = tqRed(cmap[bit]); - } - } - } else { - uchar* data = image.scanLine(cinfo.next_scanline); - if ( image.bitOrder() == TQImage::LittleEndian ) { - for (int i=0; i> 3)) & (1 << (i & 7))); - *row++ = tqRed(cmap[bit]); - *row++ = tqGreen(cmap[bit]); - *row++ = tqBlue(cmap[bit]); - } - } else { - for (int i=0; i> 3)) & (1 << (7 -(i & 7)))); - *row++ = tqRed(cmap[bit]); - *row++ = tqGreen(cmap[bit]); - *row++ = tqBlue(cmap[bit]); - } - } - } - break; - case 8: - if (gray) { - uchar* pix = image.scanLine(cinfo.next_scanline); - for (int i=0; isetStatus(0); - } - - delete iod_dest; - delete [] row_pointer[0]; -} - -void qInitJpegIO() -{ - // Not much to go on - just 3 bytes: 0xFF, M_SOI, 0xFF - // Even the third is not strictly specified as required. - TQImageIO::defineIOHandler("JPEG", "^\377\330\377", 0, read_jpeg_image, write_jpeg_image); -} - -#endif diff --git a/src/kernel/qkeysequence.cpp b/src/kernel/qkeysequence.cpp deleted file mode 100644 index 8fd7485b8..000000000 --- a/src/kernel/qkeysequence.cpp +++ /dev/null @@ -1,736 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQKeySequence class -** -** Created : 0108007 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqkeysequence.h" - -#ifndef TQT_NO_ACCEL - -#include "tqaccel.h" -#include "ntqshared.h" -#include "tqvaluelist.h" -#ifndef TQT_NO_REGEXP -# include "tqregexp.h" -#endif - -#ifdef TQ_WS_MAC -#define TQMAC_CTRL (TQString(TQChar(0x2318))) -#define TQMAC_META (TQString(TQChar(0x2303))) -#define TQMAC_ALT (TQString(TQChar(0x2325))) -#define TQMAC_SHIFT (TQString(TQChar(0x21E7))) -#endif - -/*! - \class TQKeySequence ntqkeysequence.h - \brief The TQKeySequence class encapsulates a key sequence as used - by accelerators. - - \ingroup misc - - A key sequence consists of up to four keyboard codes, each - optionally combined with modifiers, e.g. \c SHIFT, \c CTRL, \c - ALT, \c META, or \c UNICODE_ACCEL. For example, \c{CTRL + Key_P} - might be a sequence used as a shortcut for printing a document. - The key codes are listed in \c{ntqnamespace.h}. As an alternative, - use \c UNICODE_ACCEL with the unicode code point of the character. - For example, \c{UNICODE_ACCEL + 'A'} gives the same key sequence - as \c Key_A. - - Key sequences can be constructed either from an integer key code, - or from a human readable translatable string such as - "Ctrl+X,Alt+Space". A key sequence can be cast to a TQString to - obtain a human readable translated version of the sequence. - Translations are done in the "TQAccel" context. - - \sa TQAccel -*/ - -/*! - \enum TQt::SequenceMatch - - \value NoMatch Sequences have nothing in common - \value PartialMatch Sequences match partially, but are not complete - \value Identical Sequences do not differ -*/ - -static struct { - int key; - const char* name; -} keyname[] = { - { TQt::Key_Space, TQT_TRANSLATE_NOOP( "TQAccel", "Space" ) }, - { TQt::Key_Escape, TQT_TRANSLATE_NOOP( "TQAccel", "Esc" ) }, - { TQt::Key_Tab, TQT_TRANSLATE_NOOP( "TQAccel", "Tab" ) }, - { TQt::Key_Backtab, TQT_TRANSLATE_NOOP( "TQAccel", "Backtab" ) }, - { TQt::Key_Backspace, TQT_TRANSLATE_NOOP( "TQAccel", "Backspace" ) }, - { TQt::Key_Return, TQT_TRANSLATE_NOOP( "TQAccel", "Return" ) }, - { TQt::Key_Enter, TQT_TRANSLATE_NOOP( "TQAccel", "Enter" ) }, - { TQt::Key_Insert, TQT_TRANSLATE_NOOP( "TQAccel", "Ins" ) }, - { TQt::Key_Delete, TQT_TRANSLATE_NOOP( "TQAccel", "Del" ) }, - { TQt::Key_Pause, TQT_TRANSLATE_NOOP( "TQAccel", "Pause" ) }, - { TQt::Key_Print, TQT_TRANSLATE_NOOP( "TQAccel", "Print" ) }, - { TQt::Key_SysReq, TQT_TRANSLATE_NOOP( "TQAccel", "SysReq" ) }, - { TQt::Key_Home, TQT_TRANSLATE_NOOP( "TQAccel", "Home" ) }, - { TQt::Key_End, TQT_TRANSLATE_NOOP( "TQAccel", "End" ) }, - { TQt::Key_Left, TQT_TRANSLATE_NOOP( "TQAccel", "Left" ) }, - { TQt::Key_Up, TQT_TRANSLATE_NOOP( "TQAccel", "Up" ) }, - { TQt::Key_Right, TQT_TRANSLATE_NOOP( "TQAccel", "Right" ) }, - { TQt::Key_Down, TQT_TRANSLATE_NOOP( "TQAccel", "Down" ) }, - { TQt::Key_Prior, TQT_TRANSLATE_NOOP( "TQAccel", "PgUp" ) }, - { TQt::Key_Next, TQT_TRANSLATE_NOOP( "TQAccel", "PgDown" ) }, - { TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( "TQAccel", "CapsLock" ) }, - { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "NumLock" ) }, - { TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( "TQAccel", "ScrollLock" ) }, - { TQt::Key_Menu, TQT_TRANSLATE_NOOP( "TQAccel", "Menu" ) }, - { TQt::Key_Help, TQT_TRANSLATE_NOOP( "TQAccel", "Help" ) }, - - // Multimedia keys - { TQt::Key_Back, TQT_TRANSLATE_NOOP( "TQAccel", "Back" ) }, - { TQt::Key_Forward, TQT_TRANSLATE_NOOP( "TQAccel", "Forward" ) }, - { TQt::Key_Stop, TQT_TRANSLATE_NOOP( "TQAccel", "Stop" ) }, - { TQt::Key_Refresh, TQT_TRANSLATE_NOOP( "TQAccel", "Refresh" ) }, - { TQt::Key_VolumeDown, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Down" ) }, - { TQt::Key_VolumeMute, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Mute" ) }, - { TQt::Key_VolumeUp, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Up" ) }, - { TQt::Key_BassBoost, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Boost" ) }, - { TQt::Key_BassUp, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Up" ) }, - { TQt::Key_BassDown, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Down" ) }, - { TQt::Key_TrebleUp, TQT_TRANSLATE_NOOP( "TQAccel", "Treble Up" ) }, - { TQt::Key_TrebleDown, TQT_TRANSLATE_NOOP( "TQAccel", "Treble Down" ) }, - { TQt::Key_MediaPlay, TQT_TRANSLATE_NOOP( "TQAccel", "Media Play" ) }, - { TQt::Key_MediaStop, TQT_TRANSLATE_NOOP( "TQAccel", "Media Stop" ) }, - { TQt::Key_MediaPrev, TQT_TRANSLATE_NOOP( "TQAccel", "Media Previous" ) }, - { TQt::Key_MediaNext, TQT_TRANSLATE_NOOP( "TQAccel", "Media Next" ) }, - { TQt::Key_MediaRecord, TQT_TRANSLATE_NOOP( "TQAccel", "Media Record" ) }, - { TQt::Key_HomePage, TQT_TRANSLATE_NOOP( "TQAccel", "Home" ) }, - { TQt::Key_Favorites, TQT_TRANSLATE_NOOP( "TQAccel", "Favorites" ) }, - { TQt::Key_Search, TQT_TRANSLATE_NOOP( "TQAccel", "Search" ) }, - { TQt::Key_Standby, TQT_TRANSLATE_NOOP( "TQAccel", "Standby" ) }, - { TQt::Key_OpenUrl, TQT_TRANSLATE_NOOP( "TQAccel", "Open URL" ) }, - { TQt::Key_LaunchMail, TQT_TRANSLATE_NOOP( "TQAccel", "Launch Mail" ) }, - { TQt::Key_LaunchMedia, TQT_TRANSLATE_NOOP( "TQAccel", "Launch Media" ) }, - { TQt::Key_Launch0, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (0)" ) }, - { TQt::Key_Launch1, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (1)" ) }, - { TQt::Key_Launch2, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (2)" ) }, - { TQt::Key_Launch3, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (3)" ) }, - { TQt::Key_Launch4, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (4)" ) }, - { TQt::Key_Launch5, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (5)" ) }, - { TQt::Key_Launch6, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (6)" ) }, - { TQt::Key_Launch7, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (7)" ) }, - { TQt::Key_Launch8, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (8)" ) }, - { TQt::Key_Launch9, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (9)" ) }, - { TQt::Key_LaunchA, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (A)" ) }, - { TQt::Key_LaunchB, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (B)" ) }, - { TQt::Key_LaunchC, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (C)" ) }, - { TQt::Key_LaunchD, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (D)" ) }, - { TQt::Key_LaunchE, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (E)" ) }, - { TQt::Key_LaunchF, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (F)" ) }, - { TQt::Key_MonBrightnessUp, TQT_TRANSLATE_NOOP( "TQAccel", "Monitor Brightness Up" ) }, - { TQt::Key_MonBrightnessDown, TQT_TRANSLATE_NOOP( "TQAccel", "Monitor Brightness Down" ) }, - { TQt::Key_KeyboardLightOnOff, TQT_TRANSLATE_NOOP( "TQAccel", "Keyboard Light On Off" ) }, - { TQt::Key_KeyboardBrightnessUp, TQT_TRANSLATE_NOOP( "TQAccel", "Keyboard Brightness Up" ) }, - { TQt::Key_KeyboardBrightnessDown, TQT_TRANSLATE_NOOP( "TQAccel", "Keyboard Brightness Down" ) }, - - // -------------------------------------------------------------- - // More consistent namings - { TQt::Key_Print, TQT_TRANSLATE_NOOP( "TQAccel", "Print Screen" ) }, - { TQt::Key_Prior, TQT_TRANSLATE_NOOP( "TQAccel", "Page Up" ) }, - { TQt::Key_Next, TQT_TRANSLATE_NOOP( "TQAccel", "Page Down" ) }, - { TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( "TQAccel", "Caps Lock" ) }, - { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "Num Lock" ) }, - { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "Number Lock" ) }, - { TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( "TQAccel", "Scroll Lock" ) }, - { TQt::Key_Insert, TQT_TRANSLATE_NOOP( "TQAccel", "Insert" ) }, - { TQt::Key_Delete, TQT_TRANSLATE_NOOP( "TQAccel", "Delete" ) }, - { TQt::Key_Escape, TQT_TRANSLATE_NOOP( "TQAccel", "Escape" ) }, - { TQt::Key_SysReq, TQT_TRANSLATE_NOOP( "TQAccel", "System Request" ) }, - - { 0, 0 } -}; - - -class TQKeySequencePrivate : public TQShared -{ -public: - inline TQKeySequencePrivate() - { - key[0] = key[1] = key[2] = key[3] = 0; - } - inline TQKeySequencePrivate( TQKeySequencePrivate *copy ) - { - key[0] = copy->key[0]; - key[1] = copy->key[1]; - key[2] = copy->key[2]; - key[3] = copy->key[3]; - } - int key[4]; -}; - - -/*! - Constructs an empty key sequence. -*/ -TQKeySequence::TQKeySequence() -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); -} - -/*! - Creates a key sequence from the string \a key. For example - "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", - "Shift", "Alt" and "Meta" are recognized, as well as their - translated equivalents in the "TQAccel" context (using - TQObject::tr()). - - Multiple key codes (up to four) may be entered by separating them - with commas, e.g. "Alt+X,Ctrl+S,Q". - - This contructor is typically used with \link TQObject::tr() tr - \endlink(), so that accelerator keys can be replaced in - translations: - - \code - TQPopupMenu *file = new TQPopupMenu( this ); - file->insertItem( tr("&Open..."), this, TQ_SLOT(open()), - TQKeySequence( tr("Ctrl+O", "File|Open") ) ); - \endcode - - Note the \c "File|Open" translator comment. It is by no means - necessary, but it provides some context for the human translator. -*/ -TQKeySequence::TQKeySequence( const TQString& key ) -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); - assign( key ); -} - - -// ### BCI: Merge with constructor below for 4.0 -/*! - Constructs a key sequence that has a single \a key. - - The key codes are listed in \c{ntqnamespace.h} and can be - combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c - ALT, \c META or \c UNICODE_ACCEL. -*/ -TQKeySequence::TQKeySequence( int key ) -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); - d->key[0] = key; -} - -/*! - Constructs a key sequence with up to 4 keys \a k1, \a k2, - \a k3 and \a k4. - - The key codes are listed in \c{ntqnamespace.h} and can be - combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c - ALT, \c META or \c UNICODE_ACCEL. -*/ -TQKeySequence::TQKeySequence( int k1, int k2, int k3, int k4 ) -{ - d = new TQKeySequencePrivate(); - TQ_CHECK_PTR( d ); - d->key[0] = k1; - d->key[1] = k2; - d->key[2] = k3; - d->key[3] = k4; -} - -/*! - Copy constructor. Makes a copy of \a keysequence. - */ -TQKeySequence::TQKeySequence( const TQKeySequence& keysequence ) - : d( keysequence.d ) -{ - d->ref(); -} - - -/*! - Destroys the key sequence. - */ -TQKeySequence::~TQKeySequence() -{ - if ( d->deref() ) - delete d; -} - -/*! - \internal - KeySequences should never be modified, but rather just created. - Internally though we do need to modify to keep pace in event - delivery. -*/ - -void TQKeySequence::setKey( int key, int index ) -{ -#ifdef QT_CHECK_STATE - if ( 0 > index && 4 < index ) { - tqWarning( "TQKeySequence::setKey: index %u out of range", index ); - return; - } -#endif // QT_CHECK_STATE - - if ( 1 < d->count ) { - TQKeySequencePrivate *newd = new TQKeySequencePrivate( d ); - d->deref(); - d = newd; - } - d->key[index] = key; -} - -/*! - Returns the number of keys in the key sequence. - The maximum is 4. - */ -uint TQKeySequence::count() const -{ - if ( ! d->key[0] ) - return 0; - if ( ! d->key[1] ) - return 1; - if ( ! d->key[2] ) - return 2; - if ( ! d->key[3] ) - return 3; - return 4; -} - - -/*! - Returns TRUE if the key sequence is empty; otherwise returns - FALSE. -*/ -bool TQKeySequence::isEmpty() const -{ - return !d->key[0]; -} - - -/*! - Adds the string \a keyseq to the key sequence. \a keyseq may - contain up to four key codes, provided they are seperated by a - comma, e.g. "Alt+X,Ctrl+S,Z"). Returns the number of key codes - added. -*/ -int TQKeySequence::assign( TQString keyseq ) -{ - TQString part; - int n = 0; - int p = 0, diff = 0; - - // Run through the whole string, but stop - // if we have 4 keys before the end. - while ( keyseq.length() && n < 4 ) { - // We MUST use something to seperate each sequence, and space - // does not cut it, since some of the key names have space - // in them.. (Let's hope no one translate with a comma in it:) - p = keyseq.find( ',' ); - if ( -1 != p ) { - if ( ',' == keyseq[p+1] ) // e.g. 'Ctrl+,, Shift+,,' - p++; - if ( ' ' == keyseq[p+1] ) { // Space after comma - diff = 1; - p++; - } else if ( '\0' == keyseq[p+1] ) { // Last comma 'Ctrl+,' - p = -1; - } else { - diff = 0; - } - } - part = keyseq.left( -1==p?keyseq.length():p-diff ); - keyseq = keyseq.right( -1==p?0:keyseq.length() - ( p + 1 ) ); - d->key[n] = decodeString( part ); - n++; - } - return n; -} - -struct ModifKeyName { - ModifKeyName() { } - ModifKeyName(int q, TQString n) : qt_key(q), name(n) { } - int qt_key; - TQString name; -}; - -/*! - Constructs a single key from the string \str. - */ -int TQKeySequence::decodeString( const TQString& str ) -{ - int ret = 0; - TQString accel = str; - - TQValueList modifs; -#ifdef TQMAC_CTRL - modifs << ModifKeyName( CTRL, TQMAC_CTRL ); -#endif -#ifdef TQMAC_ALT - modifs << ModifKeyName( ALT, TQMAC_ALT ); -#endif -#ifdef TQMAC_META - modifs << ModifKeyName( META, TQMAC_META ); -#endif -#ifdef TQMAC_SHIFT - modifs << ModifKeyName( SHIFT, TQMAC_SHIFT ); -#endif - modifs << ModifKeyName( CTRL, "ctrl+" ) << ModifKeyName( CTRL, TQAccel::tr("Ctrl").lower().append('+') ); - modifs << ModifKeyName( SHIFT, "shift+" ) << ModifKeyName( SHIFT, TQAccel::tr("Shift").lower().append('+') ); - modifs << ModifKeyName( ALT, "alt+" ) << ModifKeyName( ALT, TQAccel::tr("Alt").lower().append('+') ); - modifs << ModifKeyName( META, "meta+" ) << ModifKeyName( ALT, TQAccel::tr("Meta").lower().append('+') ); - TQString sl = accel.lower(); - for( TQValueList::iterator it = modifs.begin(); it != modifs.end(); ++it ) { - if ( sl.contains( (*it).name ) ) { - ret |= (*it).qt_key; -#ifndef TQT_NO_REGEXP - accel.remove( TQRegExp(TQRegExp::escape((*it).name), FALSE) ); -#else - accel.remove( (*it).name ); -#endif - sl = accel.lower(); - } - } - - int p = accel.findRev( '+', str.length() - 2 ); // -2 so that Ctrl++ works - if( p > 0 ) - accel = accel.mid( p + 1 ); - - int fnum = 0; - if ( accel.length() == 1 ) { - char ltr = accel[0].upper().latin1(); - // We can only upper A-Z without problems. - if ( ltr < (char)Key_A || ltr > (char)Key_Z ) - ret |= accel[0].unicode(); - else - ret |= accel[0].upper().unicode(); - ret |= UNICODE_ACCEL; - } else if ( accel[0] == 'F' && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35) ) { - ret |= Key_F1 + fnum - 1; - } else { - // Check through translation table for the correct key name - // ...or fall back on english table. - bool found = FALSE; - for ( int tran = 0; tran < 2; tran++ ) { - for ( int i = 0; keyname[i].name; i++ ) { - if ( tran ? accel == TQAccel::tr(keyname[i].name) - : accel == keyname[i].name ) { - ret |= keyname[i].key; - found = TRUE; - break; - } - } - if(found) - break; - } - } - return ret; -} - - -/*! - Creates an accelerator string for \a key. For example, - CTRL+Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are - translated (using TQObject::tr()) in the "TQAccel" context. - */ -TQString TQKeySequence::encodeString( int key ) -{ - TQString s; -#if defined(Q_OS_MAC) - // On MAC the order is Meta, Alt, Shift, Control. - if ( (key & META) == META ) - s += TQMAC_META; - if ( (key & ALT) == ALT ) - s += TQMAC_ALT; - if ( (key & SHIFT) == SHIFT ) - s += TQMAC_SHIFT; - if ( (key & CTRL) == CTRL ) - s += TQMAC_CTRL; -#else - // On other systems the order is Meta, Control, Alt, Shift - if ( (key & META) == META ) - s += TQAccel::tr( "Meta" ); - if ( (key & CTRL) == CTRL ) { - if ( !s.isEmpty() ) - s += TQAccel::tr( "+" ); - s += TQAccel::tr( "Ctrl" ); - } - if ( (key & ALT) == ALT ) { - if ( !s.isEmpty() ) - s += TQAccel::tr( "+" ); - s += TQAccel::tr( "Alt" ); - } - if ( (key & SHIFT) == SHIFT ) { - if ( !s.isEmpty() ) - s += TQAccel::tr( "+" ); - s += TQAccel::tr( "Shift" ); - } -#endif - - - key &= ~(SHIFT | CTRL | ALT | META ); - TQString p; - - if ( (key & UNICODE_ACCEL) == UNICODE_ACCEL ) { - // Note: This character should NOT be upper()'ed, since - // the encoded string should indicate EXACTLY what the - // key represents! Hence a 'Ctrl+Shift+c' is posible to - // represent, but is clearly impossible to trigger... - p = TQChar(key & 0xffff); - } else if ( key >= Key_F1 && key <= Key_F35 ) { - p = TQAccel::tr( "F%1" ).arg(key - Key_F1 + 1); - } else if ( key > Key_Space && key <= Key_AsciiTilde ) { - p.sprintf( "%c", key ); - } else { - int i=0; - while (keyname[i].name) { - if ( key == keyname[i].key ) { - p = TQAccel::tr(keyname[i].name); - break; - } - ++i; - } - // If we can't find the actual translatable keyname, - // fall back on the unicode representation of it... - // Or else characters like Key_aring may not get displayed - // ( Really depends on you locale ) - if ( !keyname[i].name ) - // Note: This character should NOT be upper()'ed, see above! - p = TQChar(key & 0xffff); - } - -#ifndef Q_OS_MAC - if ( !s.isEmpty() ) - s += TQAccel::tr( "+" ); -#endif - - s += p; - return s; -} - -/*! - Matches the sequence with \a seq. Returns \c TQt::Identical if - successful, \c TQt::PartialMatch for matching but incomplete \a seq, - and \c TQt::NoMatch if the sequences have nothing in common. - Returns \c TQt::NoMatch if \a seq is shorter. -*/ -TQt::SequenceMatch TQKeySequence::matches( const TQKeySequence& seq ) const -{ - uint userN = count(), - seqN = seq.count(); - - if ( userN > seqN ) - return NoMatch; - - // If equal in length, we have a potential Identical sequence, - // else we already know it can only be partial. - SequenceMatch match = ( userN == seqN ? Identical : PartialMatch ); - - for ( uint i = 0; i < userN; i++ ) { - int userKey = (*this)[i], - sequenceKey = seq[i]; - - if ( (userKey & ~TQt::UNICODE_ACCEL) != - (sequenceKey & ~TQt::UNICODE_ACCEL) ) - return NoMatch; - } - return match; -} - - -/*! - Creates an accelerator string for the key sequence. - For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has - multiple key codes they are returned comma-separated, e.g. - "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are - translated (using TQObject::tr()) in the "TQAccel" scope. If the key - sequence has no keys, TQString::null is returned. - - On Mac OS X, the string returned resembles the sequence that is shown in - the menubar. -*/ -TQKeySequence::operator TQString() const -{ - int end = count(); - if ( !end ) return TQString::null; - - TQString complete; - int i = 0; - while ( i < end ) { - complete += encodeString( d->key[i] ); - i++; - if ( i != end) - complete += ", "; - } - return complete; -} - - -/*! - \obsolete - For backward compatibility: returns the first keycode - as integer. If the key sequence is empty, 0 is returned. - */ -TQKeySequence::operator int () const -{ - if ( 1 <= count() ) - return d->key[0]; - return 0; -} - - -/*! - Returns a reference to the element at position \a index in the key - sequence. This can only be used to read an element. - */ -int TQKeySequence::operator[]( uint index ) const -{ -#ifdef QT_CHECK_STATE - if ( index > 4 ) { - tqWarning( "TQKeySequence::operator[]: index %u out of range", index ); - return 0; - } -#endif // QT_CHECK_STATE - return d->key[index]; -} - - -/*! - Assignment operator. Assigns \a keysequence to this - object. - */ -TQKeySequence &TQKeySequence::operator=( const TQKeySequence & keysequence ) -{ - keysequence.d->ref(); - if ( d->deref() ) - delete d; - d = keysequence.d; - return *this; -} - - -/*! - Returns TRUE if \a keysequence is equal to this key - sequence; otherwise returns FALSE. - */ - - -bool TQKeySequence::operator==( const TQKeySequence& keysequence ) const -{ - return ( (d->key[0]&~UNICODE_ACCEL) == (keysequence.d->key[0]&~UNICODE_ACCEL) && - (d->key[1]&~UNICODE_ACCEL) == (keysequence.d->key[1]&~UNICODE_ACCEL) && - (d->key[2]&~UNICODE_ACCEL) == (keysequence.d->key[2]&~UNICODE_ACCEL) && - (d->key[3]&~UNICODE_ACCEL) == (keysequence.d->key[3]&~UNICODE_ACCEL) ); -} - - -/*! - Returns TRUE if \a keysequence is not equal to this key sequence; - otherwise returns FALSE. -*/ -bool TQKeySequence::operator!= ( const TQKeySequence& keysequence ) const -{ - TQKeySequence *that = (TQKeySequence*)this; - return !( (*that) == keysequence ); -} - - -/***************************************************************************** - TQKeySequence stream functions - *****************************************************************************/ -#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) -/*! - \relates TQKeySequence - - Writes the key sequence \a keysequence to the stream \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ -TQDataStream &operator<<( TQDataStream &s, const TQKeySequence &keysequence ) -{ - TQValueList list; - list += keysequence.d->key[0]; - list += keysequence.d->key[1]; - list += keysequence.d->key[2]; - list += keysequence.d->key[3]; - s << list; - - return s; -} - - -/*! - \relates TQKeySequence - - Reads a key sequence from the stream \a s into the key sequence \a - keysequence. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ -TQDataStream &operator>>( TQDataStream &s, TQKeySequence &keysequence ) -{ - TQValueList list; - s >> list; - -#ifdef QT_CHECK_STATE - if ( 1 != list.count() && 4 != list.count() ) { - tqWarning( "Invalid TQKeySequence data in the datastream." ); - return s; - } -#endif - - if ( 1 == list.count() ) { - keysequence.d->key[0] = *list.at( 0 ); - keysequence.d->key[1] = - keysequence.d->key[2] = - keysequence.d->key[3] = 0; - } else { - keysequence.d->key[0] = *list.at( 0 ); - keysequence.d->key[1] = *list.at( 1 ); - keysequence.d->key[2] = *list.at( 2 ); - keysequence.d->key[3] = *list.at( 3 ); - } - return s; -} - -#endif //TQT_NO_DATASTREAM - -#endif //TQT_NO_ACCEL diff --git a/src/kernel/qscriptengine_x11.cpp b/src/kernel/qscriptengine_x11.cpp index 6c1190fb3..5d22fdf49 100644 --- a/src/kernel/qscriptengine_x11.cpp +++ b/src/kernel/qscriptengine_x11.cpp @@ -1900,7 +1900,7 @@ static void indic_attributes(int script, const TQString &text, int from, int len // -------------------------------------------------------------------------------------------------------------------------------------------- #include -#include +#include static void thaiWordBreaks(const TQChar *string, const int len, TQCharAttributes *attributes) diff --git a/src/kernel/qt_gfx.pri b/src/kernel/qt_gfx.pri index c66f3141e..fadd1277f 100644 --- a/src/kernel/qt_gfx.pri +++ b/src/kernel/qt_gfx.pri @@ -39,8 +39,8 @@ mng { else:DEFINES += TQT_NO_IMAGEIO_MNG #jpeg support.. -HEADERS += $$KERNEL_H/ntqjpegio.h -SOURCES += $$KERNEL_CPP/qjpegio.cpp +HEADERS += $$KERNEL_H/tqjpegio.h +SOURCES += $$KERNEL_CPP/tqjpegio.cpp jpeg { system-jpeg { unix:LIBS += -ljpeg diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri index d52783f7c..03904d262 100644 --- a/src/kernel/qt_kernel.pri +++ b/src/kernel/qt_kernel.pri @@ -35,8 +35,8 @@ kernel { $$KERNEL_H/tqimage.h \ $$KERNEL_P/tqimageformatinterface_p.h \ $$KERNEL_H/tqimageformatplugin.h \ - $$KERNEL_H/ntqkeycode.h \ - $$KERNEL_H/ntqkeysequence.h \ + $$KERNEL_H/tqkeycode.h \ + $$KERNEL_H/tqkeysequence.h \ $$KERNEL_H/tqlayout.h \ $$KERNEL_P/tqlayoutengine_p.h \ $$KERNEL_H/tqtranslator.h \ @@ -100,9 +100,9 @@ kernel { inputmethod { unix:x11 { - HEADERS += $$KERNEL_H/ntqinputcontext.h + HEADERS += $$KERNEL_H/tqinputcontext.h } else { - HEADERS += $$KERNEL_P/qinputcontext_p.h + HEADERS += $$KERNEL_P/tqinputcontext_p.h } } @@ -118,7 +118,7 @@ kernel { $$KERNEL_CPP/qdnd_win.cpp \ $$KERNEL_CPP/tqeventloop_win.cpp \ $$KERNEL_CPP/tqfont_win.cpp \ - $$KERNEL_CPP/qinputcontext_win.cpp \ + $$KERNEL_CPP/tqinputcontext_win.cpp \ $$KERNEL_CPP/tqmime_win.cpp \ $$KERNEL_CPP/tqpixmap_win.cpp \ $$KERNEL_CPP/tqprinter_win.cpp \ @@ -140,8 +140,8 @@ kernel { $$KERNEL_CPP/qdnd_x11.cpp \ $$KERNEL_CPP/tqdesktopwidget_x11.cpp \ $$KERNEL_CPP/tqfont_x11.cpp \ - $$KERNEL_CPP/qinputcontext.cpp \ - $$KERNEL_CPP/qinputcontext_x11.cpp \ + $$KERNEL_CPP/tqinputcontext.cpp \ + $$KERNEL_CPP/tqinputcontext_x11.cpp \ $$KERNEL_CPP/tqmotifdnd_x11.cpp \ $$KERNEL_CPP/tqpixmap_x11.cpp \ $$KERNEL_CPP/tqpaintdevice_x11.cpp \ @@ -217,7 +217,7 @@ kernel { $$KERNEL_CPP/tqiconset.cpp \ $$KERNEL_CPP/tqimage.cpp \ $$KERNEL_CPP/tqimageformatplugin.cpp \ - $$KERNEL_CPP/qkeysequence.cpp \ + $$KERNEL_CPP/tqkeysequence.cpp \ $$KERNEL_CPP/tqlayout.cpp \ $$KERNEL_CPP/tqlayoutengine.cpp \ $$KERNEL_CPP/tqtranslator.cpp \ diff --git a/src/kernel/qvariant.cpp b/src/kernel/qvariant.cpp index ac94aea12..8f5768696 100644 --- a/src/kernel/qvariant.cpp +++ b/src/kernel/qvariant.cpp @@ -63,7 +63,7 @@ #include "tqsizepolicy.h" #include "ntqshared.h" #include "tqbitarray.h" -#include "ntqkeysequence.h" +#include "tqkeysequence.h" #include "tqpen.h" #ifndef DBL_DIG diff --git a/src/kernel/tqaccel.h b/src/kernel/tqaccel.h index 22c2f80e1..c883ba2ff 100644 --- a/src/kernel/tqaccel.h +++ b/src/kernel/tqaccel.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "tqobject.h" -#include "ntqkeysequence.h" +#include "tqkeysequence.h" #endif // QT_H #ifndef TQT_NO_ACCEL diff --git a/src/kernel/tqimage.cpp b/src/kernel/tqimage.cpp index 6c1d1ffad..b71804321 100644 --- a/src/kernel/tqimage.cpp +++ b/src/kernel/tqimage.cpp @@ -48,7 +48,7 @@ #include "tqasyncimageio.h" #include "tqpngio.h" #include "ntqmngio.h" -#include "ntqjpegio.h" +#include "tqjpegio.h" #include "tqmap.h" #include #include "tqimageformatinterface_p.h" diff --git a/src/kernel/tqinputcontext.cpp b/src/kernel/tqinputcontext.cpp new file mode 100644 index 000000000..7d15aa0c7 --- /dev/null +++ b/src/kernel/tqinputcontext.cpp @@ -0,0 +1,849 @@ +/**************************************************************************** +** $Id: tqinputcontext.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 "qplatformdefs.h" + +#include "ntqapplication.h" +#include "tqwidget.h" +#include "tqpopupmenu.h" + +#include +#include + +class TQInputContextPrivate +{ +public: + TQInputContextPrivate() + : holderWidget( 0 ), composingWidget( 0 ), hasFocus( FALSE ), + isComposing( FALSE ) +#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) + , preeditString( TQString::null ), + 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::null; + cursorPosition = -1; + selLength = 0; +#endif + } + +#if !defined(TQT_NO_IM_PREEDIT_RELOCATION) + TQString preeditString; + int cursorPosition; + int selLength; +#endif +}; + + +// UPDATED COMMENT REQUIRED -- 2004-07-08 YamaKen +/*! + \class TQInputContext tqinputcontext.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 *parent ) + : TQObject( parent ) +{ + 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 focusWidget() if the input + context is shared between several text widgets. + + \sa setHolderWidget(), focusWidget() +*/ +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::focusWidget() 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 focusWidget() +*/ +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 ) +{ + Q_UNUSED(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; +#endif + if ( ! receiver ) + return; + + if ( type == TQEvent::IMStart ) { + tqDebug( "sending IMStart with %d chars to %p", + text.length(), receiver ); + event = new TQIMEvent( type, text, cursorPosition ); + } else if ( type == TQEvent::IMEnd ) { + tqDebug( "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 ) { + tqDebug( "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 ( !focusWidget() ) + 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, focusWidget 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, focusWidget 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 ) +{ + Q_UNUSED(x); + Q_UNUSED(y); + Q_UNUSED(w); + Q_UNUSED(h); + Q_UNUSED(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. + */ +void TQInputContext::mouseHandler( int x, TQEvent::Type type, + TQt::ButtonState button, + TQt::ButtonState state ) +{ + Q_UNUSED(x); + Q_UNUSED(button); + Q_UNUSED(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 ( !focusWidget() ) + return TQApplication::font(); //### absolutely last resort + + return focusWidget()->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 ""; +} + + +/*! + 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 children 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 *TQInputContext::menus() +{ + return 0; +} + +/*! + 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. + + \sa menus(), TQInputContextMenu::Action +*/ +void TQInputContext::addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action ) +{ + if ( ! popup ) + return; + + TQPtrList *imMenus = menus(); + if ( imMenus ) { + if ( action == TQInputContextMenu::InsertSeparator ) + popup->insertSeparator(); + for ( TQPtrList::Iterator it = imMenus->begin(); + it != imMenus->end(); + ++it ) { + TQInputContextMenu *imMenu = *it; + popup->insertItem( imMenu->title, imMenu->popup ); + } + imMenus->clear(); + delete imMenus; + } +} + +#endif //Q_NO_IM diff --git a/src/kernel/tqinputcontext.h b/src/kernel/tqinputcontext.h new file mode 100644 index 000000000..06f72f206 --- /dev/null +++ b/src/kernel/tqinputcontext.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** $Id: tqinputcontext.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 QT_H +#include "tqobject.h" +#include "tqglobal.h" +#include "tqevent.h" +#include "tqstring.h" +#include "tqptrlist.h" +#endif + +class TQWidget; +class TQFont; +class TQPopupMenu; +class TQInputContextPrivate; + + +struct TQInputContextMenu { + enum Action { + NoSeparator, + InsertSeparator + }; + TQString title; + TQPopupMenu *popup; +}; + + +class TQ_EXPORT TQInputContext : public TQObject +{ + TQ_OBJECT +public: + TQInputContext( TQObject *parent = 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(); + + virtual TQPtrList *menus(); + void addMenusTo( TQPopupMenu *popup, TQInputContextMenu::Action action = TQInputContextMenu::InsertSeparator ); + +#if defined(TQ_WS_X11) + // these functions are not recommended for ordinary use + virtual TQWidget *focusWidget() 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::null, + int cursorPosition = -1, int selLength = 0 ); + +private: + void sendIMEventInternal( TQEvent::Type type, + const TQString &text = TQString::null, + 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 //Q_NO_IM + +#endif // TQINPUTCONTEXT_H diff --git a/src/kernel/tqinputcontext_p.h b/src/kernel/tqinputcontext_p.h new file mode 100644 index 000000000..37ba52b6c --- /dev/null +++ b/src/kernel/tqinputcontext_p.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Definition of ??? +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQINPUTCONTEXT_P_H +#define TQINPUTCONTEXT_P_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. +// +// + +#include "tqglobal.h" + +class TQKeyEvent; +class TQWidget; +class TQFont; +class TQString; + + +#ifdef TQ_WS_X11 +#include "tqmemarray.h" +#include "ntqwindowdefs.h" +#include "qt_x11_p.h" +#endif + +#ifdef TQ_WS_WIN +#include "qt_windows.h" +#endif + +class TQInputContext +{ +public: +#ifdef TQ_WS_X11 + TQInputContext(TQWidget *); // should be a toplevel widget + ~TQInputContext(); + + void setFocus(); + void setComposePosition(int, int); + void setComposeArea(int, int, int, int); + void reset(); + + int lookupString(XKeyEvent *, TQCString &, KeySym *, Status *) const; + void setXFontSet(const TQFont &); + + void *ic; + TQString text; + TQWidget *focusWidget; + bool composing; + TQFont font; + XFontSet fontset; + TQMemArray selectedChars; +#endif // TQ_WS_X11 + +#ifdef TQ_WS_WIN + static void init(); + static void shutdown(); + + static void TranslateMessage( const MSG *msg); + static LRESULT DefWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); + + static void setFont( const TQWidget *w, const TQFont & ); + static void setFocusHint( int x, int y, int w, int h, const TQWidget *widget ); + static bool startComposition(); + static bool endComposition( TQWidget *fw = 0 ); + static bool composition( LPARAM lparam ); + + static void accept( TQWidget *fw = 0 ); + static void enable( TQWidget *w, bool b ); +#endif +}; + +#endif // TQINPUTCONTEXT_P_H diff --git a/src/kernel/tqinputcontext_x11.cpp b/src/kernel/tqinputcontext_x11.cpp new file mode 100644 index 000000000..d0f8699b3 --- /dev/null +++ b/src/kernel/tqinputcontext_x11.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Implementation of TQInputContext class +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqinputcontext.h" + +#ifndef TQT_NO_IM + +#include "qplatformdefs.h" + +#include "ntqapplication.h" +#include "tqwidget.h" + +#include "qt_x11_p.h" + +/*! + This function may be overridden only if input method is depending + on X11 and you need raw XEvent. Otherwise, this function must not. + + This function is designed to filter raw key events for XIM, but + other input methods may use this to implement some special + features such as distinguishing Shift_L and Shift_R. + + Return TRUE if the \a event has been consumed. Otherwise, the + unfiltered \a event will be translated into TQEvent and forwarded + to filterEvent(). Filtering at both x11FilterEvent() and + filterEvent() in single input method is allowed. + + \a keywidget is a client widget into which a text is inputted. \a + event is inputted XEvent. + + \sa filterEvent() +*/ +bool TQInputContext::x11FilterEvent( TQWidget *keywidget, XEvent *event ) +{ + Q_UNUSED(keywidget); + Q_UNUSED(event); + return FALSE; +} + +#endif //Q_NO_IM diff --git a/src/kernel/tqjpegio.cpp b/src/kernel/tqjpegio.cpp new file mode 100644 index 000000000..f76aad44d --- /dev/null +++ b/src/kernel/tqjpegio.cpp @@ -0,0 +1,595 @@ +/**************************************************************************** +** +** Implementation of JPEG TQImage IOHandler +** +** Created : 990521 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqimage.h" + +#ifndef TQT_NO_IMAGEIO_JPEG + +#include "tqiodevice.h" +#include "tqjpegio.h" + +#include // jpeglib needs this to be pre-included +#include + + +// including jpeglib.h seems to be a little messy +extern "C" { +#define XMD_H // shut JPEGlib up +#if defined(Q_OS_UNIXWARE) +# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this +#endif +#include +#ifdef const +# undef const // remove crazy C hackery in jconfig.h +#endif +} + + +struct my_error_mgr : public jpeg_error_mgr { + jmp_buf setjmp_buffer; +}; + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +static +void my_error_exit (j_common_ptr cinfo) +{ + my_error_mgr* myerr = (my_error_mgr*) cinfo->err; + char buffer[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo, buffer); + tqWarning("%s", buffer); + longjmp(myerr->setjmp_buffer, 1); +} + +#if defined(Q_C_CALLBACKS) +} +#endif + + +static const int max_buf = 4096; + +struct my_jpeg_source_mgr : public jpeg_source_mgr { + // Nothing dynamic - cannot rely on destruction over longjump + TQImageIO* iio; + JOCTET buffer[max_buf]; + +public: + my_jpeg_source_mgr(TQImageIO* iio); +}; + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +static +void tqt_init_source(j_decompress_ptr) +{ +} + +static +boolean qt_fill_input_buffer(j_decompress_ptr cinfo) +{ + int num_read; + my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; + TQIODevice* dev = src->iio->ioDevice(); + src->next_input_byte = src->buffer; + num_read = dev->readBlock((char*)src->buffer, max_buf); + if ( num_read <= 0 ) { + // Insert a fake EOI marker - as per jpeglib recommendation + src->buffer[0] = (JOCTET) 0xFF; + src->buffer[1] = (JOCTET) JPEG_EOI; + src->bytes_in_buffer = 2; + } else { + src->bytes_in_buffer = num_read; + } +#if defined(Q_OS_UNIXWARE) + return B_TRUE; +#else + return TRUE; +#endif +} + +static +void qt_skip_input_data(j_decompress_ptr cinfo, long num_bytes) +{ + my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; + + // `dumb' implementation from jpeglib + + /* Just a dumb implementation for now. Could use fseek() except + * it doesn't work on pipes. Not clear that being smart is worth + * any trouble anyway --- large skips are infrequent. + */ + if (num_bytes > 0) { + while (num_bytes > (long) src->bytes_in_buffer) { + num_bytes -= (long) src->bytes_in_buffer; + (void) qt_fill_input_buffer(cinfo); + /* note we assume that qt_fill_input_buffer will never return FALSE, + * so suspension need not be handled. + */ + } + src->next_input_byte += (size_t) num_bytes; + src->bytes_in_buffer -= (size_t) num_bytes; + } +} + +static +void qt_term_source(j_decompress_ptr) +{ +} + +#if defined(Q_C_CALLBACKS) +} +#endif + + +inline my_jpeg_source_mgr::my_jpeg_source_mgr(TQImageIO* iioptr) +{ + jpeg_source_mgr::init_source = tqt_init_source; + jpeg_source_mgr::fill_input_buffer = qt_fill_input_buffer; + jpeg_source_mgr::skip_input_data = qt_skip_input_data; + jpeg_source_mgr::resync_to_restart = jpeg_resync_to_restart; + jpeg_source_mgr::term_source = qt_term_source; + iio = iioptr; + bytes_in_buffer = 0; + next_input_byte = buffer; +} + + +static +void scaleSize( int &reqW, int &reqH, int imgW, int imgH, TQImage::ScaleMode mode ) +{ + if ( mode == TQImage::ScaleFree ) + return; + int t1 = imgW * reqH; + int t2 = reqW * imgH; + if (( mode == TQImage::ScaleMin && (t1 > t2) ) || ( mode == TQImage::ScaleMax && (t1 < t2) )) + reqH = t2 / imgW; + else + reqW = t1 / imgH; +} + + +static +void read_jpeg_image(TQImageIO* iio) +{ + TQImage image; + + struct jpeg_decompress_struct cinfo; + + struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(iio); + struct my_error_mgr jerr; + + cinfo.err = jpeg_std_error(&jerr); + jerr.error_exit = my_error_exit; + + jpeg_create_decompress(&cinfo); + + cinfo.src = iod_src; + + if (!setjmp(jerr.setjmp_buffer)) { +#if defined(Q_OS_UNIXWARE) + (void) jpeg_read_header(&cinfo, B_TRUE); +#else + (void) jpeg_read_header(&cinfo, TRUE); +#endif + + (void) jpeg_start_decompress(&cinfo); + + TQString params = iio->parameters(); + params.simplifyWhiteSpace(); + int sWidth = 0, sHeight = 0; + char sModeStr[1024] = ""; + TQImage::ScaleMode sMode; + + if ( params.contains( "GetHeaderInformation" ) ) { + + // Create TQImage's without allocating the data + if ( cinfo.output_components == 3 || cinfo.output_components == 4) { + image = TQImage( NULL, cinfo.output_width, cinfo.output_height, 32, NULL, 0, TQImage::IgnoreEndian ); + } else if ( cinfo.output_components == 1 ) { + image = TQImage( NULL, cinfo.output_width, cinfo.output_height, 8, NULL, 0, TQImage::IgnoreEndian ); + } else { + // Unsupported format + } + + + } else if ( params.contains( "Scale" ) ) { + sscanf( params.latin1(), "Scale( %i, %i, %1023s )", + &sWidth, &sHeight, sModeStr ); + + TQString sModeTQStr( sModeStr ); + if ( sModeTQStr == "ScaleFree" ) { + sMode = TQImage::ScaleFree; + } else if ( sModeTQStr == "ScaleMin" ) { + sMode = TQImage::ScaleMin; + } else if ( sModeTQStr == "ScaleMax" ) { + sMode = TQImage::ScaleMax; + } else { + tqDebug("read_jpeg_image: invalid scale mode \"%s\", see TQImage::ScaleMode documentation", sModeStr); + sMode = TQImage::ScaleFree; + } + +// tqDebug( "Parameters ask to scale the image to %i x %i ScaleMode: %s", sWidth, sHeight, sModeStr ); + scaleSize( sWidth, sHeight, cinfo.output_width, cinfo.output_height, sMode ); +// tqDebug( "Scaling the jpeg to %i x %i", sWidth, sHeight, sModeStr ); + + bool created = FALSE; + if ( cinfo.output_components == 3 || cinfo.output_components == 4) { + created = image.create( sWidth, sHeight, 32 ); + } else if ( cinfo.output_components == 1 ) { + created = image.create( sWidth, sHeight, 8, 256 ); + for (int i=0; i<256; i++) + image.setColor(i, tqRgb(i,i,i)); + } else { + // Unsupported format + } + if (!created) + image = TQImage(); + + if (!image.isNull()) { + TQImage tmpImage( cinfo.output_width, 1, 32 ); + uchar** inLines = tmpImage.jumpTable(); + uchar** outLines = image.jumpTable(); + while (cinfo.output_scanline < cinfo.output_height) { + int outputLine = sHeight * cinfo.output_scanline / cinfo.output_height; + (void) jpeg_read_scanlines(&cinfo, inLines, 1); + if ( cinfo.output_components == 3 ) { + uchar *in = inLines[0]; + TQRgb *out = (TQRgb*)outLines[outputLine]; + for (uint i=0; i32 bpp. + for (uint j=0; jsetImage(image); + iio->setStatus(image.isNull()); + } + + jpeg_destroy_decompress(&cinfo); + delete iod_src; +} + + +struct my_jpeg_destination_mgr : public jpeg_destination_mgr { + // Nothing dynamic - cannot rely on destruction over longjump + TQImageIO* iio; + JOCTET buffer[max_buf]; + +public: + my_jpeg_destination_mgr(TQImageIO*); +}; + + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +static +void tqt_init_destination(j_compress_ptr) +{ +} + +static +void qt_exit_on_error(j_compress_ptr cinfo, TQIODevice* dev) +{ + if (dev->status() == IO_Ok) { + return; + } else { + // cinfo->err->msg_code = JERR_FILE_WRITE; + (*cinfo->err->error_exit)((j_common_ptr)cinfo); + } +} + +static +boolean qt_empty_output_buffer(j_compress_ptr cinfo) +{ + my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; + TQIODevice* dev = dest->iio->ioDevice(); + + if ( dev->writeBlock( (char*)dest->buffer, max_buf ) != max_buf ) + qt_exit_on_error(cinfo, dev); + + dest->next_output_byte = dest->buffer; + dest->free_in_buffer = max_buf; + +#if defined(Q_OS_UNIXWARE) + return B_TRUE; +#else + return TRUE; +#endif +} + +static +void qt_term_destination(j_compress_ptr cinfo) +{ + my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; + TQIODevice* dev = dest->iio->ioDevice(); + TQ_LONG n = max_buf - dest->free_in_buffer; + + if ( dev->writeBlock( (char*)dest->buffer, n ) != n ) + qt_exit_on_error(cinfo, dev); + + dev->flush(); + + qt_exit_on_error(cinfo, dev); +} + +#if defined(Q_C_CALLBACKS) +} +#endif + + +inline +my_jpeg_destination_mgr::my_jpeg_destination_mgr(TQImageIO* iioptr) +{ + jpeg_destination_mgr::init_destination = tqt_init_destination; + jpeg_destination_mgr::empty_output_buffer = qt_empty_output_buffer; + jpeg_destination_mgr::term_destination = qt_term_destination; + iio = iioptr; + next_output_byte = buffer; + free_in_buffer = max_buf; +} + + +static +void write_jpeg_image(TQImageIO* iio) +{ + TQImage image = iio->image(); + + struct jpeg_compress_struct cinfo; + JSAMPROW row_pointer[1]; + row_pointer[0] = 0; + + struct my_jpeg_destination_mgr *iod_dest = new my_jpeg_destination_mgr(iio); + struct my_error_mgr jerr; + + cinfo.err = jpeg_std_error(&jerr); + + jerr.error_exit = my_error_exit; + + if (!setjmp(jerr.setjmp_buffer)) { + jpeg_create_compress(&cinfo); + + cinfo.dest = iod_dest; + + cinfo.image_width = image.width(); + cinfo.image_height = image.height(); + + TQRgb* cmap=0; + bool gray=FALSE; + switch ( image.depth() ) { + case 1: + case 8: + cmap = image.colorTable(); + gray = TRUE; + int i; + for (i=image.numColors(); gray && i--; ) { + gray = gray & ( tqRed(cmap[i]) == tqGreen(cmap[i]) && + tqRed(cmap[i]) == tqBlue(cmap[i]) ); + } + cinfo.input_components = gray ? 1 : 3; + cinfo.in_color_space = gray ? JCS_GRAYSCALE : JCS_RGB; + break; + case 32: + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + } + + jpeg_set_defaults(&cinfo); + + float diffInch = TQABS(image.dotsPerMeterX()*2.54/100. - tqRound(image.dotsPerMeterX()*2.54/100.)) + + TQABS(image.dotsPerMeterY()*2.54/100. - tqRound(image.dotsPerMeterY()*2.54/100.)); + float diffCm = (TQABS(image.dotsPerMeterX()/100. - tqRound(image.dotsPerMeterX()/100.)) + + TQABS(image.dotsPerMeterY()/100. - tqRound(image.dotsPerMeterY()/100.)))*2.54; + if (diffInch < diffCm) { + cinfo.density_unit = 1; // dots/inch + cinfo.X_density = tqRound(image.dotsPerMeterX()*2.54/100.); + cinfo.Y_density = tqRound(image.dotsPerMeterY()*2.54/100.); + } else { + cinfo.density_unit = 2; // dots/cm + cinfo.X_density = (image.dotsPerMeterX()+50) / 100; + cinfo.Y_density = (image.dotsPerMeterY()+50) / 100; + } + + int quality = iio->quality() >= 0 ? TQMIN(iio->quality(),100) : 75; +#if defined(Q_OS_UNIXWARE) + jpeg_set_quality(&cinfo, quality, B_TRUE /* limit to baseline-JPEG values */); + jpeg_start_compress(&cinfo, B_TRUE); +#else + jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); + jpeg_start_compress(&cinfo, TRUE); +#endif + + row_pointer[0] = new uchar[cinfo.image_width*cinfo.input_components]; + int w = cinfo.image_width; + while (cinfo.next_scanline < cinfo.image_height) { + uchar *row = row_pointer[0]; + switch ( image.depth() ) { + case 1: + if (gray) { + uchar* data = image.scanLine(cinfo.next_scanline); + if ( image.bitOrder() == TQImage::LittleEndian ) { + for (int i=0; i> 3)) & (1 << (i & 7))); + row[i] = tqRed(cmap[bit]); + } + } else { + for (int i=0; i> 3)) & (1 << (7 -(i & 7)))); + row[i] = tqRed(cmap[bit]); + } + } + } else { + uchar* data = image.scanLine(cinfo.next_scanline); + if ( image.bitOrder() == TQImage::LittleEndian ) { + for (int i=0; i> 3)) & (1 << (i & 7))); + *row++ = tqRed(cmap[bit]); + *row++ = tqGreen(cmap[bit]); + *row++ = tqBlue(cmap[bit]); + } + } else { + for (int i=0; i> 3)) & (1 << (7 -(i & 7)))); + *row++ = tqRed(cmap[bit]); + *row++ = tqGreen(cmap[bit]); + *row++ = tqBlue(cmap[bit]); + } + } + } + break; + case 8: + if (gray) { + uchar* pix = image.scanLine(cinfo.next_scanline); + for (int i=0; isetStatus(0); + } + + delete iod_dest; + delete [] row_pointer[0]; +} + +void qInitJpegIO() +{ + // Not much to go on - just 3 bytes: 0xFF, M_SOI, 0xFF + // Even the third is not strictly specified as required. + TQImageIO::defineIOHandler("JPEG", "^\377\330\377", 0, read_jpeg_image, write_jpeg_image); +} + +#endif diff --git a/src/kernel/tqjpegio.h b/src/kernel/tqjpegio.h new file mode 100644 index 000000000..10ae8d7cf --- /dev/null +++ b/src/kernel/tqjpegio.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Definition of JPEG TQImage IOHandler +** +** Created : 970621 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQJPEGIO_H +#define TQJPEGIO_H + +#include "tqglobal.h" + +#ifndef TQT_NO_IMAGEIO_JPEG + +void qInitJpegIO(); + +#endif // TQT_NO_IMAGEIO_JPEG + +#endif // TQJPEGIO_H diff --git a/src/kernel/tqkeycode.h b/src/kernel/tqkeycode.h new file mode 100644 index 000000000..bca9305ba --- /dev/null +++ b/src/kernel/tqkeycode.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Definition of keyboard codes +** +** Created : 931030 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQKEYCODE_H +#define TQKEYCODE_H + +#ifndef QT_H +#include "ntqnamespace.h" +#endif // QT_H + +// all key codes are now in the TQt namespace class + +#endif // TQKEYCODE_H diff --git a/src/kernel/tqkeysequence.cpp b/src/kernel/tqkeysequence.cpp new file mode 100644 index 000000000..94ba5cf53 --- /dev/null +++ b/src/kernel/tqkeysequence.cpp @@ -0,0 +1,736 @@ +/**************************************************************************** +** +** Implementation of TQKeySequence class +** +** Created : 0108007 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqkeysequence.h" + +#ifndef TQT_NO_ACCEL + +#include "tqaccel.h" +#include "ntqshared.h" +#include "tqvaluelist.h" +#ifndef TQT_NO_REGEXP +# include "tqregexp.h" +#endif + +#ifdef TQ_WS_MAC +#define TQMAC_CTRL (TQString(TQChar(0x2318))) +#define TQMAC_META (TQString(TQChar(0x2303))) +#define TQMAC_ALT (TQString(TQChar(0x2325))) +#define TQMAC_SHIFT (TQString(TQChar(0x21E7))) +#endif + +/*! + \class TQKeySequence tqkeysequence.h + \brief The TQKeySequence class encapsulates a key sequence as used + by accelerators. + + \ingroup misc + + A key sequence consists of up to four keyboard codes, each + optionally combined with modifiers, e.g. \c SHIFT, \c CTRL, \c + ALT, \c META, or \c UNICODE_ACCEL. For example, \c{CTRL + Key_P} + might be a sequence used as a shortcut for printing a document. + The key codes are listed in \c{ntqnamespace.h}. As an alternative, + use \c UNICODE_ACCEL with the unicode code point of the character. + For example, \c{UNICODE_ACCEL + 'A'} gives the same key sequence + as \c Key_A. + + Key sequences can be constructed either from an integer key code, + or from a human readable translatable string such as + "Ctrl+X,Alt+Space". A key sequence can be cast to a TQString to + obtain a human readable translated version of the sequence. + Translations are done in the "TQAccel" context. + + \sa TQAccel +*/ + +/*! + \enum TQt::SequenceMatch + + \value NoMatch Sequences have nothing in common + \value PartialMatch Sequences match partially, but are not complete + \value Identical Sequences do not differ +*/ + +static struct { + int key; + const char* name; +} keyname[] = { + { TQt::Key_Space, TQT_TRANSLATE_NOOP( "TQAccel", "Space" ) }, + { TQt::Key_Escape, TQT_TRANSLATE_NOOP( "TQAccel", "Esc" ) }, + { TQt::Key_Tab, TQT_TRANSLATE_NOOP( "TQAccel", "Tab" ) }, + { TQt::Key_Backtab, TQT_TRANSLATE_NOOP( "TQAccel", "Backtab" ) }, + { TQt::Key_Backspace, TQT_TRANSLATE_NOOP( "TQAccel", "Backspace" ) }, + { TQt::Key_Return, TQT_TRANSLATE_NOOP( "TQAccel", "Return" ) }, + { TQt::Key_Enter, TQT_TRANSLATE_NOOP( "TQAccel", "Enter" ) }, + { TQt::Key_Insert, TQT_TRANSLATE_NOOP( "TQAccel", "Ins" ) }, + { TQt::Key_Delete, TQT_TRANSLATE_NOOP( "TQAccel", "Del" ) }, + { TQt::Key_Pause, TQT_TRANSLATE_NOOP( "TQAccel", "Pause" ) }, + { TQt::Key_Print, TQT_TRANSLATE_NOOP( "TQAccel", "Print" ) }, + { TQt::Key_SysReq, TQT_TRANSLATE_NOOP( "TQAccel", "SysReq" ) }, + { TQt::Key_Home, TQT_TRANSLATE_NOOP( "TQAccel", "Home" ) }, + { TQt::Key_End, TQT_TRANSLATE_NOOP( "TQAccel", "End" ) }, + { TQt::Key_Left, TQT_TRANSLATE_NOOP( "TQAccel", "Left" ) }, + { TQt::Key_Up, TQT_TRANSLATE_NOOP( "TQAccel", "Up" ) }, + { TQt::Key_Right, TQT_TRANSLATE_NOOP( "TQAccel", "Right" ) }, + { TQt::Key_Down, TQT_TRANSLATE_NOOP( "TQAccel", "Down" ) }, + { TQt::Key_Prior, TQT_TRANSLATE_NOOP( "TQAccel", "PgUp" ) }, + { TQt::Key_Next, TQT_TRANSLATE_NOOP( "TQAccel", "PgDown" ) }, + { TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( "TQAccel", "CapsLock" ) }, + { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "NumLock" ) }, + { TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( "TQAccel", "ScrollLock" ) }, + { TQt::Key_Menu, TQT_TRANSLATE_NOOP( "TQAccel", "Menu" ) }, + { TQt::Key_Help, TQT_TRANSLATE_NOOP( "TQAccel", "Help" ) }, + + // Multimedia keys + { TQt::Key_Back, TQT_TRANSLATE_NOOP( "TQAccel", "Back" ) }, + { TQt::Key_Forward, TQT_TRANSLATE_NOOP( "TQAccel", "Forward" ) }, + { TQt::Key_Stop, TQT_TRANSLATE_NOOP( "TQAccel", "Stop" ) }, + { TQt::Key_Refresh, TQT_TRANSLATE_NOOP( "TQAccel", "Refresh" ) }, + { TQt::Key_VolumeDown, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Down" ) }, + { TQt::Key_VolumeMute, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Mute" ) }, + { TQt::Key_VolumeUp, TQT_TRANSLATE_NOOP( "TQAccel", "Volume Up" ) }, + { TQt::Key_BassBoost, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Boost" ) }, + { TQt::Key_BassUp, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Up" ) }, + { TQt::Key_BassDown, TQT_TRANSLATE_NOOP( "TQAccel", "Bass Down" ) }, + { TQt::Key_TrebleUp, TQT_TRANSLATE_NOOP( "TQAccel", "Treble Up" ) }, + { TQt::Key_TrebleDown, TQT_TRANSLATE_NOOP( "TQAccel", "Treble Down" ) }, + { TQt::Key_MediaPlay, TQT_TRANSLATE_NOOP( "TQAccel", "Media Play" ) }, + { TQt::Key_MediaStop, TQT_TRANSLATE_NOOP( "TQAccel", "Media Stop" ) }, + { TQt::Key_MediaPrev, TQT_TRANSLATE_NOOP( "TQAccel", "Media Previous" ) }, + { TQt::Key_MediaNext, TQT_TRANSLATE_NOOP( "TQAccel", "Media Next" ) }, + { TQt::Key_MediaRecord, TQT_TRANSLATE_NOOP( "TQAccel", "Media Record" ) }, + { TQt::Key_HomePage, TQT_TRANSLATE_NOOP( "TQAccel", "Home" ) }, + { TQt::Key_Favorites, TQT_TRANSLATE_NOOP( "TQAccel", "Favorites" ) }, + { TQt::Key_Search, TQT_TRANSLATE_NOOP( "TQAccel", "Search" ) }, + { TQt::Key_Standby, TQT_TRANSLATE_NOOP( "TQAccel", "Standby" ) }, + { TQt::Key_OpenUrl, TQT_TRANSLATE_NOOP( "TQAccel", "Open URL" ) }, + { TQt::Key_LaunchMail, TQT_TRANSLATE_NOOP( "TQAccel", "Launch Mail" ) }, + { TQt::Key_LaunchMedia, TQT_TRANSLATE_NOOP( "TQAccel", "Launch Media" ) }, + { TQt::Key_Launch0, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (0)" ) }, + { TQt::Key_Launch1, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (1)" ) }, + { TQt::Key_Launch2, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (2)" ) }, + { TQt::Key_Launch3, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (3)" ) }, + { TQt::Key_Launch4, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (4)" ) }, + { TQt::Key_Launch5, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (5)" ) }, + { TQt::Key_Launch6, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (6)" ) }, + { TQt::Key_Launch7, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (7)" ) }, + { TQt::Key_Launch8, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (8)" ) }, + { TQt::Key_Launch9, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (9)" ) }, + { TQt::Key_LaunchA, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (A)" ) }, + { TQt::Key_LaunchB, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (B)" ) }, + { TQt::Key_LaunchC, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (C)" ) }, + { TQt::Key_LaunchD, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (D)" ) }, + { TQt::Key_LaunchE, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (E)" ) }, + { TQt::Key_LaunchF, TQT_TRANSLATE_NOOP( "TQAccel", "Launch (F)" ) }, + { TQt::Key_MonBrightnessUp, TQT_TRANSLATE_NOOP( "TQAccel", "Monitor Brightness Up" ) }, + { TQt::Key_MonBrightnessDown, TQT_TRANSLATE_NOOP( "TQAccel", "Monitor Brightness Down" ) }, + { TQt::Key_KeyboardLightOnOff, TQT_TRANSLATE_NOOP( "TQAccel", "Keyboard Light On Off" ) }, + { TQt::Key_KeyboardBrightnessUp, TQT_TRANSLATE_NOOP( "TQAccel", "Keyboard Brightness Up" ) }, + { TQt::Key_KeyboardBrightnessDown, TQT_TRANSLATE_NOOP( "TQAccel", "Keyboard Brightness Down" ) }, + + // -------------------------------------------------------------- + // More consistent namings + { TQt::Key_Print, TQT_TRANSLATE_NOOP( "TQAccel", "Print Screen" ) }, + { TQt::Key_Prior, TQT_TRANSLATE_NOOP( "TQAccel", "Page Up" ) }, + { TQt::Key_Next, TQT_TRANSLATE_NOOP( "TQAccel", "Page Down" ) }, + { TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( "TQAccel", "Caps Lock" ) }, + { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "Num Lock" ) }, + { TQt::Key_NumLock, TQT_TRANSLATE_NOOP( "TQAccel", "Number Lock" ) }, + { TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( "TQAccel", "Scroll Lock" ) }, + { TQt::Key_Insert, TQT_TRANSLATE_NOOP( "TQAccel", "Insert" ) }, + { TQt::Key_Delete, TQT_TRANSLATE_NOOP( "TQAccel", "Delete" ) }, + { TQt::Key_Escape, TQT_TRANSLATE_NOOP( "TQAccel", "Escape" ) }, + { TQt::Key_SysReq, TQT_TRANSLATE_NOOP( "TQAccel", "System Request" ) }, + + { 0, 0 } +}; + + +class TQKeySequencePrivate : public TQShared +{ +public: + inline TQKeySequencePrivate() + { + key[0] = key[1] = key[2] = key[3] = 0; + } + inline TQKeySequencePrivate( TQKeySequencePrivate *copy ) + { + key[0] = copy->key[0]; + key[1] = copy->key[1]; + key[2] = copy->key[2]; + key[3] = copy->key[3]; + } + int key[4]; +}; + + +/*! + Constructs an empty key sequence. +*/ +TQKeySequence::TQKeySequence() +{ + d = new TQKeySequencePrivate(); + TQ_CHECK_PTR( d ); +} + +/*! + Creates a key sequence from the string \a key. For example + "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", + "Shift", "Alt" and "Meta" are recognized, as well as their + translated equivalents in the "TQAccel" context (using + TQObject::tr()). + + Multiple key codes (up to four) may be entered by separating them + with commas, e.g. "Alt+X,Ctrl+S,Q". + + This contructor is typically used with \link TQObject::tr() tr + \endlink(), so that accelerator keys can be replaced in + translations: + + \code + TQPopupMenu *file = new TQPopupMenu( this ); + file->insertItem( tr("&Open..."), this, TQ_SLOT(open()), + TQKeySequence( tr("Ctrl+O", "File|Open") ) ); + \endcode + + Note the \c "File|Open" translator comment. It is by no means + necessary, but it provides some context for the human translator. +*/ +TQKeySequence::TQKeySequence( const TQString& key ) +{ + d = new TQKeySequencePrivate(); + TQ_CHECK_PTR( d ); + assign( key ); +} + + +// ### BCI: Merge with constructor below for 4.0 +/*! + Constructs a key sequence that has a single \a key. + + The key codes are listed in \c{ntqnamespace.h} and can be + combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c + ALT, \c META or \c UNICODE_ACCEL. +*/ +TQKeySequence::TQKeySequence( int key ) +{ + d = new TQKeySequencePrivate(); + TQ_CHECK_PTR( d ); + d->key[0] = key; +} + +/*! + Constructs a key sequence with up to 4 keys \a k1, \a k2, + \a k3 and \a k4. + + The key codes are listed in \c{ntqnamespace.h} and can be + combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c + ALT, \c META or \c UNICODE_ACCEL. +*/ +TQKeySequence::TQKeySequence( int k1, int k2, int k3, int k4 ) +{ + d = new TQKeySequencePrivate(); + TQ_CHECK_PTR( d ); + d->key[0] = k1; + d->key[1] = k2; + d->key[2] = k3; + d->key[3] = k4; +} + +/*! + Copy constructor. Makes a copy of \a keysequence. + */ +TQKeySequence::TQKeySequence( const TQKeySequence& keysequence ) + : d( keysequence.d ) +{ + d->ref(); +} + + +/*! + Destroys the key sequence. + */ +TQKeySequence::~TQKeySequence() +{ + if ( d->deref() ) + delete d; +} + +/*! + \internal + KeySequences should never be modified, but rather just created. + Internally though we do need to modify to keep pace in event + delivery. +*/ + +void TQKeySequence::setKey( int key, int index ) +{ +#ifdef QT_CHECK_STATE + if ( 0 > index && 4 < index ) { + tqWarning( "TQKeySequence::setKey: index %u out of range", index ); + return; + } +#endif // QT_CHECK_STATE + + if ( 1 < d->count ) { + TQKeySequencePrivate *newd = new TQKeySequencePrivate( d ); + d->deref(); + d = newd; + } + d->key[index] = key; +} + +/*! + Returns the number of keys in the key sequence. + The maximum is 4. + */ +uint TQKeySequence::count() const +{ + if ( ! d->key[0] ) + return 0; + if ( ! d->key[1] ) + return 1; + if ( ! d->key[2] ) + return 2; + if ( ! d->key[3] ) + return 3; + return 4; +} + + +/*! + Returns TRUE if the key sequence is empty; otherwise returns + FALSE. +*/ +bool TQKeySequence::isEmpty() const +{ + return !d->key[0]; +} + + +/*! + Adds the string \a keyseq to the key sequence. \a keyseq may + contain up to four key codes, provided they are seperated by a + comma, e.g. "Alt+X,Ctrl+S,Z"). Returns the number of key codes + added. +*/ +int TQKeySequence::assign( TQString keyseq ) +{ + TQString part; + int n = 0; + int p = 0, diff = 0; + + // Run through the whole string, but stop + // if we have 4 keys before the end. + while ( keyseq.length() && n < 4 ) { + // We MUST use something to seperate each sequence, and space + // does not cut it, since some of the key names have space + // in them.. (Let's hope no one translate with a comma in it:) + p = keyseq.find( ',' ); + if ( -1 != p ) { + if ( ',' == keyseq[p+1] ) // e.g. 'Ctrl+,, Shift+,,' + p++; + if ( ' ' == keyseq[p+1] ) { // Space after comma + diff = 1; + p++; + } else if ( '\0' == keyseq[p+1] ) { // Last comma 'Ctrl+,' + p = -1; + } else { + diff = 0; + } + } + part = keyseq.left( -1==p?keyseq.length():p-diff ); + keyseq = keyseq.right( -1==p?0:keyseq.length() - ( p + 1 ) ); + d->key[n] = decodeString( part ); + n++; + } + return n; +} + +struct ModifKeyName { + ModifKeyName() { } + ModifKeyName(int q, TQString n) : qt_key(q), name(n) { } + int qt_key; + TQString name; +}; + +/*! + Constructs a single key from the string \str. + */ +int TQKeySequence::decodeString( const TQString& str ) +{ + int ret = 0; + TQString accel = str; + + TQValueList modifs; +#ifdef TQMAC_CTRL + modifs << ModifKeyName( CTRL, TQMAC_CTRL ); +#endif +#ifdef TQMAC_ALT + modifs << ModifKeyName( ALT, TQMAC_ALT ); +#endif +#ifdef TQMAC_META + modifs << ModifKeyName( META, TQMAC_META ); +#endif +#ifdef TQMAC_SHIFT + modifs << ModifKeyName( SHIFT, TQMAC_SHIFT ); +#endif + modifs << ModifKeyName( CTRL, "ctrl+" ) << ModifKeyName( CTRL, TQAccel::tr("Ctrl").lower().append('+') ); + modifs << ModifKeyName( SHIFT, "shift+" ) << ModifKeyName( SHIFT, TQAccel::tr("Shift").lower().append('+') ); + modifs << ModifKeyName( ALT, "alt+" ) << ModifKeyName( ALT, TQAccel::tr("Alt").lower().append('+') ); + modifs << ModifKeyName( META, "meta+" ) << ModifKeyName( ALT, TQAccel::tr("Meta").lower().append('+') ); + TQString sl = accel.lower(); + for( TQValueList::iterator it = modifs.begin(); it != modifs.end(); ++it ) { + if ( sl.contains( (*it).name ) ) { + ret |= (*it).qt_key; +#ifndef TQT_NO_REGEXP + accel.remove( TQRegExp(TQRegExp::escape((*it).name), FALSE) ); +#else + accel.remove( (*it).name ); +#endif + sl = accel.lower(); + } + } + + int p = accel.findRev( '+', str.length() - 2 ); // -2 so that Ctrl++ works + if( p > 0 ) + accel = accel.mid( p + 1 ); + + int fnum = 0; + if ( accel.length() == 1 ) { + char ltr = accel[0].upper().latin1(); + // We can only upper A-Z without problems. + if ( ltr < (char)Key_A || ltr > (char)Key_Z ) + ret |= accel[0].unicode(); + else + ret |= accel[0].upper().unicode(); + ret |= UNICODE_ACCEL; + } else if ( accel[0] == 'F' && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35) ) { + ret |= Key_F1 + fnum - 1; + } else { + // Check through translation table for the correct key name + // ...or fall back on english table. + bool found = FALSE; + for ( int tran = 0; tran < 2; tran++ ) { + for ( int i = 0; keyname[i].name; i++ ) { + if ( tran ? accel == TQAccel::tr(keyname[i].name) + : accel == keyname[i].name ) { + ret |= keyname[i].key; + found = TRUE; + break; + } + } + if(found) + break; + } + } + return ret; +} + + +/*! + Creates an accelerator string for \a key. For example, + CTRL+Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are + translated (using TQObject::tr()) in the "TQAccel" context. + */ +TQString TQKeySequence::encodeString( int key ) +{ + TQString s; +#if defined(Q_OS_MAC) + // On MAC the order is Meta, Alt, Shift, Control. + if ( (key & META) == META ) + s += TQMAC_META; + if ( (key & ALT) == ALT ) + s += TQMAC_ALT; + if ( (key & SHIFT) == SHIFT ) + s += TQMAC_SHIFT; + if ( (key & CTRL) == CTRL ) + s += TQMAC_CTRL; +#else + // On other systems the order is Meta, Control, Alt, Shift + if ( (key & META) == META ) + s += TQAccel::tr( "Meta" ); + if ( (key & CTRL) == CTRL ) { + if ( !s.isEmpty() ) + s += TQAccel::tr( "+" ); + s += TQAccel::tr( "Ctrl" ); + } + if ( (key & ALT) == ALT ) { + if ( !s.isEmpty() ) + s += TQAccel::tr( "+" ); + s += TQAccel::tr( "Alt" ); + } + if ( (key & SHIFT) == SHIFT ) { + if ( !s.isEmpty() ) + s += TQAccel::tr( "+" ); + s += TQAccel::tr( "Shift" ); + } +#endif + + + key &= ~(SHIFT | CTRL | ALT | META ); + TQString p; + + if ( (key & UNICODE_ACCEL) == UNICODE_ACCEL ) { + // Note: This character should NOT be upper()'ed, since + // the encoded string should indicate EXACTLY what the + // key represents! Hence a 'Ctrl+Shift+c' is posible to + // represent, but is clearly impossible to trigger... + p = TQChar(key & 0xffff); + } else if ( key >= Key_F1 && key <= Key_F35 ) { + p = TQAccel::tr( "F%1" ).arg(key - Key_F1 + 1); + } else if ( key > Key_Space && key <= Key_AsciiTilde ) { + p.sprintf( "%c", key ); + } else { + int i=0; + while (keyname[i].name) { + if ( key == keyname[i].key ) { + p = TQAccel::tr(keyname[i].name); + break; + } + ++i; + } + // If we can't find the actual translatable keyname, + // fall back on the unicode representation of it... + // Or else characters like Key_aring may not get displayed + // ( Really depends on you locale ) + if ( !keyname[i].name ) + // Note: This character should NOT be upper()'ed, see above! + p = TQChar(key & 0xffff); + } + +#ifndef Q_OS_MAC + if ( !s.isEmpty() ) + s += TQAccel::tr( "+" ); +#endif + + s += p; + return s; +} + +/*! + Matches the sequence with \a seq. Returns \c TQt::Identical if + successful, \c TQt::PartialMatch for matching but incomplete \a seq, + and \c TQt::NoMatch if the sequences have nothing in common. + Returns \c TQt::NoMatch if \a seq is shorter. +*/ +TQt::SequenceMatch TQKeySequence::matches( const TQKeySequence& seq ) const +{ + uint userN = count(), + seqN = seq.count(); + + if ( userN > seqN ) + return NoMatch; + + // If equal in length, we have a potential Identical sequence, + // else we already know it can only be partial. + SequenceMatch match = ( userN == seqN ? Identical : PartialMatch ); + + for ( uint i = 0; i < userN; i++ ) { + int userKey = (*this)[i], + sequenceKey = seq[i]; + + if ( (userKey & ~TQt::UNICODE_ACCEL) != + (sequenceKey & ~TQt::UNICODE_ACCEL) ) + return NoMatch; + } + return match; +} + + +/*! + Creates an accelerator string for the key sequence. + For instance CTRL+Key_O gives "Ctrl+O". If the key sequence has + multiple key codes they are returned comma-separated, e.g. + "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are + translated (using TQObject::tr()) in the "TQAccel" scope. If the key + sequence has no keys, TQString::null is returned. + + On Mac OS X, the string returned resembles the sequence that is shown in + the menubar. +*/ +TQKeySequence::operator TQString() const +{ + int end = count(); + if ( !end ) return TQString::null; + + TQString complete; + int i = 0; + while ( i < end ) { + complete += encodeString( d->key[i] ); + i++; + if ( i != end) + complete += ", "; + } + return complete; +} + + +/*! + \obsolete + For backward compatibility: returns the first keycode + as integer. If the key sequence is empty, 0 is returned. + */ +TQKeySequence::operator int () const +{ + if ( 1 <= count() ) + return d->key[0]; + return 0; +} + + +/*! + Returns a reference to the element at position \a index in the key + sequence. This can only be used to read an element. + */ +int TQKeySequence::operator[]( uint index ) const +{ +#ifdef QT_CHECK_STATE + if ( index > 4 ) { + tqWarning( "TQKeySequence::operator[]: index %u out of range", index ); + return 0; + } +#endif // QT_CHECK_STATE + return d->key[index]; +} + + +/*! + Assignment operator. Assigns \a keysequence to this + object. + */ +TQKeySequence &TQKeySequence::operator=( const TQKeySequence & keysequence ) +{ + keysequence.d->ref(); + if ( d->deref() ) + delete d; + d = keysequence.d; + return *this; +} + + +/*! + Returns TRUE if \a keysequence is equal to this key + sequence; otherwise returns FALSE. + */ + + +bool TQKeySequence::operator==( const TQKeySequence& keysequence ) const +{ + return ( (d->key[0]&~UNICODE_ACCEL) == (keysequence.d->key[0]&~UNICODE_ACCEL) && + (d->key[1]&~UNICODE_ACCEL) == (keysequence.d->key[1]&~UNICODE_ACCEL) && + (d->key[2]&~UNICODE_ACCEL) == (keysequence.d->key[2]&~UNICODE_ACCEL) && + (d->key[3]&~UNICODE_ACCEL) == (keysequence.d->key[3]&~UNICODE_ACCEL) ); +} + + +/*! + Returns TRUE if \a keysequence is not equal to this key sequence; + otherwise returns FALSE. +*/ +bool TQKeySequence::operator!= ( const TQKeySequence& keysequence ) const +{ + TQKeySequence *that = (TQKeySequence*)this; + return !( (*that) == keysequence ); +} + + +/***************************************************************************** + TQKeySequence stream functions + *****************************************************************************/ +#if !defined(TQT_NO_DATASTREAM) && !defined(TQT_NO_IMAGEIO) +/*! + \relates TQKeySequence + + Writes the key sequence \a keysequence to the stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ +TQDataStream &operator<<( TQDataStream &s, const TQKeySequence &keysequence ) +{ + TQValueList list; + list += keysequence.d->key[0]; + list += keysequence.d->key[1]; + list += keysequence.d->key[2]; + list += keysequence.d->key[3]; + s << list; + + return s; +} + + +/*! + \relates TQKeySequence + + Reads a key sequence from the stream \a s into the key sequence \a + keysequence. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ +TQDataStream &operator>>( TQDataStream &s, TQKeySequence &keysequence ) +{ + TQValueList list; + s >> list; + +#ifdef QT_CHECK_STATE + if ( 1 != list.count() && 4 != list.count() ) { + tqWarning( "Invalid TQKeySequence data in the datastream." ); + return s; + } +#endif + + if ( 1 == list.count() ) { + keysequence.d->key[0] = *list.at( 0 ); + keysequence.d->key[1] = + keysequence.d->key[2] = + keysequence.d->key[3] = 0; + } else { + keysequence.d->key[0] = *list.at( 0 ); + keysequence.d->key[1] = *list.at( 1 ); + keysequence.d->key[2] = *list.at( 2 ); + keysequence.d->key[3] = *list.at( 3 ); + } + return s; +} + +#endif //TQT_NO_DATASTREAM + +#endif //TQT_NO_ACCEL diff --git a/src/kernel/tqkeysequence.h b/src/kernel/tqkeysequence.h new file mode 100644 index 000000000..e4800839d --- /dev/null +++ b/src/kernel/tqkeysequence.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Definition of TQKeySequence class +** +** Created : 0108007 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial 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 WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQKEYSEQUENCE_H +#define TQKEYSEQUENCE_H + +#ifndef QT_H +#ifndef QT_H +#include "ntqnamespace.h" +#include "tqstring.h" +#endif // QT_H +#endif + +#ifndef TQT_NO_ACCEL + +/***************************************************************************** + TQKeySequence stream functions + *****************************************************************************/ +#ifndef TQT_NO_DATASTREAM +class TQKeySequence; +TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQKeySequence & ); +TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQKeySequence & ); +#endif + +class TQKeySequencePrivate; + +class TQ_EXPORT TQKeySequence : public TQt +{ +public: + TQKeySequence(); + TQKeySequence( const TQString& key ); + TQKeySequence( int key ); + TQKeySequence( int k1, int k2, int k3 = 0, int k4 = 0 ); + TQKeySequence( const TQKeySequence & ); + ~TQKeySequence(); + + uint count() const; + bool isEmpty() const; + TQt::SequenceMatch matches( const TQKeySequence & ) const; + + operator TQString() const; + operator int () const; + int operator[]( uint ) const; + TQKeySequence &operator=( const TQKeySequence & ); + bool operator==( const TQKeySequence& ) const; + bool operator!= ( const TQKeySequence& ) const; + +private: + static int decodeString( const TQString & ); + static TQString encodeString( int ); + int assign( TQString ); + void setKey( int key, int index ); + + TQKeySequencePrivate* d; + + friend TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQKeySequence & ); + friend TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQKeySequence & ); + friend class TQAccelManager; +}; + +#else + +class TQ_EXPORT TQKeySequence : public TQt +{ +public: + TQKeySequence() {} + TQKeySequence( int ) {} +}; + +#endif //TQT_NO_ACCEL + +#endif diff --git a/src/kernel/tqttdeintegration_x11.cpp b/src/kernel/tqttdeintegration_x11.cpp index 6bd89a390..0b8e794c2 100644 --- a/src/kernel/tqttdeintegration_x11.cpp +++ b/src/kernel/tqttdeintegration_x11.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/kernel/tqwidget.cpp b/src/kernel/tqwidget.cpp index d0e37df41..4aa4a09ed 100644 --- a/src/kernel/tqwidget.cpp +++ b/src/kernel/tqwidget.cpp @@ -64,7 +64,7 @@ #endif #if defined(TQ_WS_WIN) #include "qt_windows.h" -#include "qinputcontext_p.h" +#include "tqinputcontext_p.h" #endif #include "tqfontdata_p.h" diff --git a/src/kernel/tqwidget_x11.cpp b/src/kernel/tqwidget_x11.cpp index bccd0110b..b7136818f 100644 --- a/src/kernel/tqwidget_x11.cpp +++ b/src/kernel/tqwidget_x11.cpp @@ -66,8 +66,8 @@ bool qt_wstate_iconified( WId ); void qt_updated_rootinfo(); #ifndef TQT_NO_IM -#include "ntqinputcontext.h" -#include "ntqinputcontextfactory.h" +#include "tqinputcontext.h" +#include "tqinputcontextfactory.h" #endif // Paint event clipping magic -- cgit v1.2.3