From 0917fbb5387978eb7b2e2fd68bcb6beaa8c46505 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 25 Aug 2024 15:36:25 +0900 Subject: Rename remaining ntq[a-c]* related files to equivalent tq* (except ntqapplication.h and ntqconfig.h) Signed-off-by: Michele Calgaro --- src/codecs/tqtextcodecfactory.cpp | 2 +- src/dialogs/qmessagebox.cpp | 4 +- src/dialogs/tqdialog.cpp | 4 +- src/dialogs/tqfiledialog.cpp | 4 +- src/dialogs/tqprogressdialog.cpp | 4 +- src/dialogs/tqwizard.cpp | 4 +- src/inputmethod/qinputcontextfactory.cpp | 2 +- src/kernel/ntqaccel.h | 110 --- src/kernel/ntqaccessible.h | 295 ------- src/kernel/ntqasyncimageio.h | 111 --- src/kernel/ntqasyncio.h | 120 --- src/kernel/ntqconnection.h | 78 -- src/kernel/ntqcursor.h | 138 ---- src/kernel/ntqmetaobject.h | 2 +- src/kernel/ntqnamespace.h | 2 +- src/kernel/ntqt.h | 14 +- src/kernel/qaccel.cpp | 1089 ------------------------ src/kernel/qaccessible.cpp | 719 ---------------- src/kernel/qapplication.cpp | 4 +- src/kernel/qapplication_x11.cpp | 4 +- src/kernel/qasyncimageio.cpp | 1319 ------------------------------ src/kernel/qasyncio.cpp | 360 -------- src/kernel/qconnection.cpp | 94 --- src/kernel/qcursor.cpp | 287 ------- src/kernel/qcursor_x11.cpp | 833 ------------------- src/kernel/qdnd_x11.cpp | 2 +- src/kernel/qinternal.cpp | 2 +- src/kernel/qkeysequence.cpp | 2 +- src/kernel/qmngio.cpp | 4 +- src/kernel/qrichtext.cpp | 6 +- src/kernel/qt_kernel.pri | 34 +- src/kernel/qt_pch.h | 2 +- src/kernel/qvariant.cpp | 2 +- src/kernel/tqaccel.cpp | 1089 ++++++++++++++++++++++++ src/kernel/tqaccel.h | 110 +++ src/kernel/tqaccessible.cpp | 719 ++++++++++++++++ src/kernel/tqaccessible.h | 295 +++++++ src/kernel/tqasyncimageio.cpp | 1319 ++++++++++++++++++++++++++++++ src/kernel/tqasyncimageio.h | 111 +++ src/kernel/tqasyncio.cpp | 360 ++++++++ src/kernel/tqasyncio.h | 120 +++ src/kernel/tqconnection.cpp | 94 +++ src/kernel/tqconnection.h | 78 ++ src/kernel/tqcursor.cpp | 287 +++++++ src/kernel/tqcursor.h | 138 ++++ src/kernel/tqcursor_x11.cpp | 833 +++++++++++++++++++ src/kernel/tqevent.cpp | 2 +- src/kernel/tqfont.cpp | 2 +- src/kernel/tqfont_x11.cpp | 2 +- src/kernel/tqfontdatabase.cpp | 2 +- src/kernel/tqiconset.cpp | 2 +- src/kernel/tqimage.cpp | 2 +- src/kernel/tqmime.cpp | 2 +- src/kernel/tqmovie.cpp | 4 +- src/kernel/tqpainter.cpp | 2 +- src/kernel/tqpalette.cpp | 2 +- src/kernel/tqpixmapcache.cpp | 2 +- src/kernel/tqpngio.cpp | 4 +- src/kernel/tqprocess_unix.cpp | 2 +- src/kernel/tqsignalslotimp.h | 2 +- src/kernel/tqstylesheet.cpp | 2 +- src/kernel/tqwidget.cpp | 6 +- src/kernel/tqwidget_x11.cpp | 2 +- src/network/tqdns.cpp | 2 +- src/opengl/tqgl.cpp | 2 +- src/sql/tqdatatable.cpp | 2 +- src/sql/tqeditorfactory.cpp | 2 +- src/sql/tqsqldatabase.cpp | 2 +- src/sql/tqsqleditorfactory.cpp | 2 +- src/sql/tqsqlpropertymap.cpp | 2 +- src/styles/tqwindowsstyle.cpp | 2 +- src/table/tqtable.cpp | 2 +- src/tools/ntqcleanuphandler.h | 130 --- src/tools/qcomlibrary.cpp | 2 +- src/tools/qcomponentfactory.cpp | 355 -------- src/tools/qcomponentfactory_p.h | 76 -- src/tools/qt_tools.pri | 6 +- src/tools/qwinexport.cpp | 4 +- src/tools/tqcleanuphandler.h | 130 +++ src/tools/tqcomponentfactory.cpp | 355 ++++++++ src/tools/tqcomponentfactory_p.h | 76 ++ src/tools/tqregexp.cpp | 2 +- src/tools/tqstring.cpp | 2 +- src/widgets/qdockwindow.cpp | 2 +- src/widgets/qtitlebar.cpp | 2 +- src/widgets/tqaction.cpp | 2 +- src/widgets/tqbutton.cpp | 4 +- src/widgets/tqcombobox.cpp | 2 +- src/widgets/tqdial.cpp | 2 +- src/widgets/tqgroupbox.cpp | 4 +- src/widgets/tqiconview.cpp | 4 +- src/widgets/tqlabel.cpp | 2 +- src/widgets/tqlineedit.cpp | 2 +- src/widgets/tqlistbox.cpp | 2 +- src/widgets/tqlistview.cpp | 6 +- src/widgets/tqmainwindow.cpp | 2 +- src/widgets/tqmenubar.cpp | 6 +- src/widgets/tqmultilineedit.cpp | 2 +- src/widgets/tqpopupmenu.cpp | 6 +- src/widgets/tqprogressbar.cpp | 2 +- src/widgets/tqpushbutton.cpp | 2 +- src/widgets/tqscrollbar.cpp | 4 +- src/widgets/tqscrollview.cpp | 2 +- src/widgets/tqslider.cpp | 2 +- src/widgets/tqspinbox.cpp | 4 +- src/widgets/tqtabbar.cpp | 6 +- src/widgets/tqtabwidget.cpp | 2 +- src/widgets/tqtextbrowser.cpp | 2 +- src/widgets/tqtextedit.cpp | 2 +- src/widgets/tqtoolbar.cpp | 2 +- src/widgets/tqwhatsthis.cpp | 4 +- src/widgets/tqwhatsthis.h | 2 +- src/widgets/tqwidgetresizehandler.cpp | 2 +- src/workspace/tqworkspace.cpp | 4 +- 114 files changed, 6250 insertions(+), 6250 deletions(-) delete mode 100644 src/kernel/ntqaccel.h delete mode 100644 src/kernel/ntqaccessible.h delete mode 100644 src/kernel/ntqasyncimageio.h delete mode 100644 src/kernel/ntqasyncio.h delete mode 100644 src/kernel/ntqconnection.h delete mode 100644 src/kernel/ntqcursor.h delete mode 100644 src/kernel/qaccel.cpp delete mode 100644 src/kernel/qaccessible.cpp delete mode 100644 src/kernel/qasyncimageio.cpp delete mode 100644 src/kernel/qasyncio.cpp delete mode 100644 src/kernel/qconnection.cpp delete mode 100644 src/kernel/qcursor.cpp delete mode 100644 src/kernel/qcursor_x11.cpp create mode 100644 src/kernel/tqaccel.cpp create mode 100644 src/kernel/tqaccel.h create mode 100644 src/kernel/tqaccessible.cpp create mode 100644 src/kernel/tqaccessible.h create mode 100644 src/kernel/tqasyncimageio.cpp create mode 100644 src/kernel/tqasyncimageio.h create mode 100644 src/kernel/tqasyncio.cpp create mode 100644 src/kernel/tqasyncio.h create mode 100644 src/kernel/tqconnection.cpp create mode 100644 src/kernel/tqconnection.h create mode 100644 src/kernel/tqcursor.cpp create mode 100644 src/kernel/tqcursor.h create mode 100644 src/kernel/tqcursor_x11.cpp delete mode 100644 src/tools/ntqcleanuphandler.h delete mode 100644 src/tools/qcomponentfactory.cpp delete mode 100644 src/tools/qcomponentfactory_p.h create mode 100644 src/tools/tqcleanuphandler.h create mode 100644 src/tools/tqcomponentfactory.cpp create mode 100644 src/tools/tqcomponentfactory_p.h (limited to 'src') diff --git a/src/codecs/tqtextcodecfactory.cpp b/src/codecs/tqtextcodecfactory.cpp index b98155587..9e081c51c 100644 --- a/src/codecs/tqtextcodecfactory.cpp +++ b/src/codecs/tqtextcodecfactory.cpp @@ -44,7 +44,7 @@ #ifndef TQT_NO_COMPONENT #include "ntqapplication.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include #include "tqtextcodecinterface_p.h" diff --git a/src/dialogs/qmessagebox.cpp b/src/dialogs/qmessagebox.cpp index 836470eb4..381a9f4f0 100644 --- a/src/dialogs/qmessagebox.cpp +++ b/src/dialogs/qmessagebox.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_MESSAGEBOX -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqlabel.h" #include "tqpushbutton.h" #include "tqimage.h" @@ -50,7 +50,7 @@ #include "tqstyle.h" #include "tqobjectlist.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #ifdef TQ_WS_X11 diff --git a/src/dialogs/tqdialog.cpp b/src/dialogs/tqdialog.cpp index 1852d6d6a..8b1298728 100644 --- a/src/dialogs/tqdialog.cpp +++ b/src/dialogs/tqdialog.cpp @@ -51,9 +51,9 @@ #include "tqsizegrip.h" #include "tqwhatsthis.h" #include "tqpopupmenu.h" -#include "ntqcursor.h" +#include "tqcursor.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #if defined( Q_OS_TEMP ) #include "qt_windows.h" diff --git a/src/dialogs/tqfiledialog.cpp b/src/dialogs/tqfiledialog.cpp index 4ae0469d6..6eb5006a6 100644 --- a/src/dialogs/tqfiledialog.cpp +++ b/src/dialogs/tqfiledialog.cpp @@ -59,10 +59,10 @@ #include "tqbitmap.h" #include "tqbuttongroup.h" #include "tqcheckbox.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqcombobox.h" #include "tqcstring.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqdragobject.h" #include "tqfile.h" #include "tqguardedptr.h" diff --git a/src/dialogs/tqprogressdialog.cpp b/src/dialogs/tqprogressdialog.cpp index 5731fd240..c8a164d1f 100644 --- a/src/dialogs/tqprogressdialog.cpp +++ b/src/dialogs/tqprogressdialog.cpp @@ -42,14 +42,14 @@ #ifndef TQT_NO_PROGRESSDIALOG -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqpainter.h" #include "ntqdrawutil.h" #include "tqdatetime.h" #include "ntqapplication.h" #include "tqstyle.h" #include "tqpushbutton.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqtimer.h" #include diff --git a/src/dialogs/tqwizard.cpp b/src/dialogs/tqwizard.cpp index b7dfa91ce..233857250 100644 --- a/src/dialogs/tqwizard.cpp +++ b/src/dialogs/tqwizard.cpp @@ -44,13 +44,13 @@ #include "tqlayout.h" #include "tqpushbutton.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqlabel.h" #include "tqwidgetstack.h" #include "ntqapplication.h" #include "tqptrlist.h" #include "tqpainter.h" -#include "ntqaccel.h" +#include "tqaccel.h" /*! \file wizard/wizard.cpp */ /*! \file wizard/wizard.h */ diff --git a/src/inputmethod/qinputcontextfactory.cpp b/src/inputmethod/qinputcontextfactory.cpp index 9199f8088..63aff8375 100644 --- a/src/inputmethod/qinputcontextfactory.cpp +++ b/src/inputmethod/qinputcontextfactory.cpp @@ -49,7 +49,7 @@ #include -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include #ifndef TQT_NO_COMPONENT diff --git a/src/kernel/ntqaccel.h b/src/kernel/ntqaccel.h deleted file mode 100644 index 22c2f80e1..000000000 --- a/src/kernel/ntqaccel.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Definition of TQAccel class -** -** Created : 950419 -** -** 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 TQACCEL_H -#define TQACCEL_H - -#ifndef QT_H -#include "tqobject.h" -#include "ntqkeysequence.h" -#endif // QT_H - -#ifndef TQT_NO_ACCEL - -class TQAccelPrivate; - -class TQ_EXPORT TQAccel : public TQObject // accelerator class -{ - TQ_OBJECT -public: - TQAccel( TQWidget *parent, const char *name=0 ); - TQAccel( TQWidget* watch, TQObject *parent, const char *name=0 ); - ~TQAccel(); - - bool isEnabled() const; - void setEnabled( bool ); - - uint count() const; - - int insertItem( const TQKeySequence& key, int id=-1); - void removeItem( int id ); - void clear(); - - TQKeySequence key( int id ); - int findKey( const TQKeySequence& key ) const; - - bool isItemEnabled( int id ) const; - void setItemEnabled( int id, bool enable ); - - bool connectItem( int id, const TQObject *receiver, const char* member ); - bool disconnectItem( int id, const TQObject *receiver, const char* member ); - - void repairEventFilter(); - - void setWhatsThis( int id, const TQString& ); - TQString whatsThis( int id ) const; - void setIgnoreWhatsThis( bool ); - bool ignoreWhatsThis() const; - - static TQKeySequence shortcutKey( const TQString & ); - static TQString keyToString(TQKeySequence k ); - static TQKeySequence stringToKey( const TQString & ); - -signals: - void activated( int id ); - void activatedAmbiguously( int id ); - -protected: - bool eventFilter( TQObject *, TQEvent * ); - -private: - TQAccelPrivate * d; - -private: -#if defined(TQ_DISABLE_COPY) - TQAccel( const TQAccel & ); - TQAccel &operator=( const TQAccel & ); -#endif - friend class TQAccelPrivate; - friend class TQAccelManager; -}; - -#endif // TQT_NO_ACCEL -#endif // TQACCEL_H diff --git a/src/kernel/ntqaccessible.h b/src/kernel/ntqaccessible.h deleted file mode 100644 index 25b12077e..000000000 --- a/src/kernel/ntqaccessible.h +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************** -** -** Definition of TQAccessible and TQAccessibleObject classes -** -** 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. -** -**********************************************************************/ - -#ifndef TQACCESSIBLE_H -#define TQACCESSIBLE_H - -#ifndef QT_H -#include "tqobject.h" -#include -#include "tqrect.h" -#include "tqguardedptr.h" -#include "tqmemarray.h" -#endif // QT_H - -#if defined(QT_ACCESSIBILITY_SUPPORT) - -struct TQAccessibleInterface; - -class TQ_EXPORT TQAccessible -{ -private: -#ifdef TQ_WS_MAC - static TQMAC_PASCAL OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *); - static TQObject *queryAccessibleObject(TQAccessibleInterface *); -#endif -public: - enum Event { - SoundPlayed = 0x0001, - Alert = 0x0002, - ForegroundChanged = 0x0003, - MenuStart = 0x0004, - MenuEnd = 0x0005, - PopupMenuStart = 0x0006, - PopupMenuEnd = 0x0007, - ContextHelpStart = 0x000C, - ContextHelpEnd = 0x000D, - DragDropStart = 0x000E, - DragDropEnd = 0x000F, - DialogStart = 0x0010, - DialogEnd = 0x0011, - ScrollingStart = 0x0012, - ScrollingEnd = 0x0013, - - MenuCommand = 0x0018, - - ObjectCreated = 0x8000, - ObjectDestroyed = 0x8001, - ObjectShow = 0x8002, - ObjectHide = 0x8003, - ObjectReorder = 0x8004, - Focus = 0x8005, - Selection = 0x8006, - SelectionAdd = 0x8007, - SelectionRemove = 0x8008, - SelectionWithin = 0x8009, - StateChanged = 0x800A, - LocationChanged = 0x800B, - NameChanged = 0x800C, - DescriptionChanged = 0x800D, - ValueChanged = 0x800E, - ParentChanged = 0x800F, - HelpChanged = 0x80A0, - DefaultActionChanged= 0x80B0, - AcceleratorChanged = 0x80C0 - }; - - enum State { - Normal = 0x00000000, - Unavailable = 0x00000001, - Selected = 0x00000002, - Focused = 0x00000004, - Pressed = 0x00000008, - Checked = 0x00000010, - Mixed = 0x00000020, - ReadOnly = 0x00000040, - HotTracked = 0x00000080, - Default = 0x00000100, - Expanded = 0x00000200, - Collapsed = 0x00000400, - Busy = 0x00000800, - Floating = 0x00001000, - Marqueed = 0x00002000, - Animated = 0x00004000, - Invisible = 0x00008000, - Offscreen = 0x00010000, - Sizeable = 0x00020000, - Moveable = 0x00040000, - SelfVoicing = 0x00080000, - Focusable = 0x00100000, - Selectable = 0x00200000, - Linked = 0x00400000, - Traversed = 0x00800000, - MultiSelectable = 0x01000000, - ExtSelectable = 0x02000000, - AlertLow = 0x04000000, - AlertMedium = 0x08000000, - AlertHigh = 0x10000000, - Protected = 0x20000000, - Valid = 0x3fffffff - }; - - enum Role { - NoRole = 0x00000000, - TitleBar = 0x00000001, - MenuBar = 0x00000002, - ScrollBar = 0x00000003, - Grip = 0x00000004, - Sound = 0x00000005, - Cursor = 0x00000006, - Caret = 0x00000007, - AlertMessage = 0x00000008, - Window = 0x00000009, - Client = 0x0000000A, - PopupMenu = 0x0000000B, - MenuItem = 0x0000000C, - ToolTip = 0x0000000D, - Application = 0x0000000E, - Document = 0x0000000F, - Pane = 0x00000010, - Chart = 0x00000011, - Dialog = 0x00000012, - Border = 0x00000013, - Grouping = 0x00000014, - Separator = 0x00000015, - ToolBar = 0x00000016, - StatusBar = 0x00000017, - Table = 0x00000018, - ColumnHeader = 0x00000019, - RowHeader = 0x0000001A, - Column = 0x0000001B, - Row = 0x0000001C, - Cell = 0x0000001D, - Link = 0x0000001E, - HelpBalloon = 0x0000001F, - Character = 0x00000020, - List = 0x00000021, - ListItem = 0x00000022, - Outline = 0x00000023, - OutlineItem = 0x00000024, - PageTab = 0x00000025, - PropertyPage = 0x00000026, - Indicator = 0x00000027, - Graphic = 0x00000028, - StaticText = 0x00000029, - EditableText = 0x0000002A, // Editable, selectable, etc. - PushButton = 0x0000002B, - CheckBox = 0x0000002C, - RadioButton = 0x0000002D, - ComboBox = 0x0000002E, - DropLest = 0x0000002F, - ProgressBar = 0x00000030, - Dial = 0x00000031, - HotkeyField = 0x00000032, - Slider = 0x00000033, - SpinBox = 0x00000034, - Diagram = 0x00000035, - Animation = 0x00000036, - Equation = 0x00000037, - ButtonDropDown = 0x00000038, - ButtonMenu = 0x00000039, - ButtonDropGrid = 0x0000003A, - Whitespace = 0x0000003B, - PageTabList = 0x0000003C, - Clock = 0x0000003D - }; - - enum NavDirection { - NavUp = 0x00000001, - NavDown = 0x00000002, - NavLeft = 0x00000003, - NavRight = 0x00000004, - NavNext = 0x00000005, - NavPrevious = 0x00000006, - NavFirstChild = 0x00000007, - NavLastChild = 0x00000008, - NavFocusChild = 0x00000009 - }; - - enum Text { - Name = 0, - Description, - Value, - Help, - Accelerator, - DefaultAction - }; - - static TQRESULT queryAccessibleInterface( TQObject *, TQAccessibleInterface ** ); - static void updateAccessibility( TQObject *, int who, Event reason ); - static bool isActive(); - - static void initialize(); - static void cleanup(); -}; - -// {EC86CB9C-5DA0-4c43-A739-13EBDF1C6B14} -#define IID_QAccessible TQUuid( 0xec86cb9c, 0x5da0, 0x4c43, 0xa7, 0x39, 0x13, 0xeb, 0xdf, 0x1c, 0x6b, 0x14 ) - -struct TQ_EXPORT TQAccessibleInterface : public TQAccessible, public TQUnknownInterface -{ - // check for valid pointers - virtual bool isValid() const = 0; - - // hierarchy - virtual int childCount() const = 0; - virtual TQRESULT queryChild( int control, TQAccessibleInterface** ) const = 0; - virtual TQRESULT queryParent( TQAccessibleInterface** ) const = 0; - - // navigation - virtual int controlAt( int x, int y ) const = 0; - virtual TQRect rect( int control ) const = 0; - virtual int navigate( NavDirection direction, int startControl ) const = 0; - - // properties and state - virtual TQString text( Text t, int control ) const = 0; - virtual void setText( Text t, int control, const TQString &text ) = 0; - virtual Role role( int control ) const = 0; - virtual State state( int control ) const = 0; - virtual TQMemArray selection() const = 0; - - // methods - virtual bool doDefaultAction( int control ) = 0; - virtual bool setFocus( int control ) = 0; - virtual bool setSelected( int control, bool on, bool extend ) = 0; - virtual void clearSelection() = 0; -}; - -// {49F4C6A7-412F-41DE-9E24-648843421FD3} -#ifndef IID_QAccessibleFactory -#define IID_QAccessibleFactory TQUuid( 0x49f4c6a7, 0x412f, 0x41de, 0x9e, 0x24, 0x64, 0x88, 0x43, 0x42, 0x1f, 0xd3 ) -#endif - -struct TQ_EXPORT TQAccessibleFactoryInterface : public TQAccessible, public TQFeatureListInterface -{ - virtual TQRESULT createAccessibleInterface( const TQString &, TQObject *, TQAccessibleInterface** ) = 0; -}; - -class TQ_EXPORT TQAccessibleObject : public TQObject, public TQAccessibleInterface -{ -public: - TQAccessibleObject( TQObject *object ); - virtual ~TQAccessibleObject(); - - TQRESULT queryInterface( const TQUuid &, TQUnknownInterface** ); - TQ_REFCOUNT - - bool isValid() const; - -protected: - TQObject *object() const; - -private: - TQGuardedPtr object_; -}; - -#define Q_DEFINED_QACCESSIBLE_OBJECT -#include "ntqwinexport.h" -#endif //QT_ACCESSIBILITY_SUPPORT - -#endif //TQACCESSIBLE_H diff --git a/src/kernel/ntqasyncimageio.h b/src/kernel/ntqasyncimageio.h deleted file mode 100644 index 28d5bd50e..000000000 --- a/src/kernel/ntqasyncimageio.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Definition of asynchronous image/movie loading classes -** -** Created : 970617 -** -** 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 TQASYNCIMAGEIO_H -#define TQASYNCIMAGEIO_H - -#ifndef QT_H -#include "tqimage.h" -#endif // QT_H - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -#if __GNUC__ - 0 > 3 -#pragma GCC system_header -#endif - -class TQ_EXPORT TQImageConsumer { -public: - virtual void end()=0; - - // Change transfer type 1. - virtual void changed( const TQRect& ) = 0; - virtual void frameDone() = 0; - - // Change transfer type 2. - virtual void frameDone( const TQPoint&, const TQRect& ) = 0; - - virtual void setLooping( int ) = 0; - virtual void setFramePeriod( int ) = 0; - virtual void setSize( int, int ) = 0; -}; - -class TQ_EXPORT TQImageFormat { -public: - virtual ~TQImageFormat(); - virtual int decode( TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length ) = 0; -}; - -class TQ_EXPORT TQImageFormatType { -public: - virtual ~TQImageFormatType(); - virtual TQImageFormat* decoderFor( const uchar* buffer, int length ) = 0; - virtual const char* formatName() const = 0; -protected: - TQImageFormatType(); -}; - -class TQImageDecoderPrivate; -class TQ_EXPORT TQImageDecoder { -public: - TQImageDecoder( TQImageConsumer* c ); - ~TQImageDecoder(); - - const TQImage& image() { return img; } - int decode( const uchar* buffer, int length ); - - static const char* formatName( const uchar* buffer, int length ); - static TQImageFormatType* format( const char* name ); // direct use - no decode() - - static TQStrList inputFormats(); - static void registerDecoderFactory( TQImageFormatType* ); - static void unregisterDecoderFactory( TQImageFormatType* ); - -private: - TQImageFormat* actual_decoder; - TQImageConsumer* consumer; - TQImage img; - TQImageDecoderPrivate *d; -}; - -#endif // TQT_NO_ASYNC_IMAGE_IO - -#endif // TQASYNCIMAGEIO_H diff --git a/src/kernel/ntqasyncio.h b/src/kernel/ntqasyncio.h deleted file mode 100644 index 6c1687e9d..000000000 --- a/src/kernel/ntqasyncio.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Definition of asynchronous I/O classes -** -** Created : 970617 -** -** 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 TQASYNCIO_H -#define TQASYNCIO_H - -#ifndef QT_H -#include "tqobject.h" -#include "tqsignal.h" -#include "tqtimer.h" -#endif // QT_H - -#ifndef TQT_NO_ASYNC_IO - -class TQIODevice; - -class TQ_EXPORT TQAsyncIO { -public: - virtual ~TQAsyncIO(); - void connect(TQObject*, const char *member); - -protected: - void ready(); - -private: - TQSignal signal; -}; - -class TQ_EXPORT TQDataSink : public TQAsyncIO { -public: - // Call this to know how much I can take. - virtual int readyToReceive()=0; - virtual void receive(const uchar*, int count)=0; - virtual void eof()=0; - void maybeReady(); -}; - -class TQ_EXPORT TQDataSource : public TQAsyncIO { -public: - virtual int readyToSend()=0; // returns -1 when never any more ready - virtual void sendTo(TQDataSink*, int count)=0; - void maybeReady(); - - virtual bool rewindable() const; - virtual void enableRewind(bool); - virtual void rewind(); -}; - -class TQ_EXPORT TQIODeviceSource : public TQDataSource { - const int buf_size; - uchar *buffer; - TQIODevice* iod; - bool rew; - -public: - TQIODeviceSource(TQIODevice*, int bufsize=4096); - ~TQIODeviceSource(); - - int readyToSend(); - void sendTo(TQDataSink* sink, int n); - bool rewindable() const; - void enableRewind(bool on); - void rewind(); -}; - -class TQ_EXPORT TQDataPump : public TQObject { - TQ_OBJECT - int interval; - TQTimer timer; - TQDataSource* source; - TQDataSink* sink; - -public: - TQDataPump(TQDataSource*, TQDataSink*); - -private slots: - void kickStart(); - void tryToPump(); -}; - -#endif // TQT_NO_ASYNC_IO - -#endif diff --git a/src/kernel/ntqconnection.h b/src/kernel/ntqconnection.h deleted file mode 100644 index 6906184b7..000000000 --- a/src/kernel/ntqconnection.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Definition of TQConnection class -** -** Created : 930417 -** -** 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 TQCONNECTION_H -#define TQCONNECTION_H - -#ifndef QT_H -#include "tqobject.h" -#endif // QT_H - -class TQ_EXPORT TQConnection -{ -public: - TQConnection( const TQObject *, int, const char *memberName, int memberType ); - ~TQConnection() {} - - bool isConnected() const { return obj != 0; } - - TQObject *object() const { return obj; } // get object/member pointer - int member() const { return mbr; } - const char *memberName() const { return mbr_name; } - int memberType() const { return mbr_type; } - int numArgs() const { return nargs; } - -private: - TQObject *obj; // object connected to - int mbr; // member connected to - const char *mbr_name; - int mbr_type; - int nargs; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQConnection( const TQConnection & ); - TQConnection &operator=( const TQConnection & ); -#endif -}; - -#define Q_DEFINED_QCONNECTION -#include "ntqwinexport.h" -#endif // TQCONNECTION_H diff --git a/src/kernel/ntqcursor.h b/src/kernel/ntqcursor.h deleted file mode 100644 index aeb36d2f0..000000000 --- a/src/kernel/ntqcursor.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Definition of TQCursor class -** -** Created : 940219 -** -** 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 TQCURSOR_H -#define TQCURSOR_H - -#ifndef QT_H -#include "tqpoint.h" -#include "ntqshared.h" -#endif // QT_H - -/* - ### The fake cursor has to go first with old qdoc. -*/ -#ifdef TQT_NO_CURSOR - -class TQ_EXPORT TQCursor : public TQt -{ -public: - static TQPoint pos(); - static void setPos( int x, int y ); - static void setPos( const TQPoint & ); -private: - TQCursor(); -}; - -#endif // TQT_NO_CURSOR - -#ifndef TQT_NO_CURSOR - -struct TQCursorData; - - -class TQ_EXPORT TQCursor : public TQt -{ -public: - TQCursor(); // create default arrow cursor - TQCursor( int shape ); - TQCursor( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX=-1, int hotY=-1 ); - TQCursor( const TQPixmap &pixmap, - int hotX=-1, int hotY=-1 ); - TQCursor( const TQCursor & ); - ~TQCursor(); - TQCursor &operator=( const TQCursor & ); - - int shape() const; - void setShape( int ); - - const TQBitmap *bitmap() const; - const TQBitmap *mask() const; - TQPoint hotSpot() const; - -#if defined(TQ_WS_WIN) - HCURSOR handle() const; - TQCursor( HCURSOR ); -#elif defined(TQ_WS_X11) - HANDLE handle() const; - TQCursor( HANDLE ); -#elif defined(TQ_WS_MAC) - HANDLE handle() const; -#endif - - static TQPoint pos(); - static void setPos( int x, int y ); - static void setPos( const TQPoint & ); - - static void initialize(); - static void cleanup(); - -#if defined(TQ_WS_X11) - static int x11Screen(); -#endif -private: - void setBitmap( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX, int hotY ); - void update() const; - TQCursorData *data; - TQCursor *find_cur(int); -#if defined(TQ_WS_MAC) - friend void qt_mac_set_cursor(const TQCursor *c, const Point *p); -#endif -}; - - -/***************************************************************************** - TQCursor stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQCursor & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQCursor & ); -#endif -#endif // TQT_NO_CURSOR - - -inline void TQCursor::setPos( const TQPoint &p ) -{ - setPos( p.x(), p.y() ); -} - -#endif // TQCURSOR_H diff --git a/src/kernel/ntqmetaobject.h b/src/kernel/ntqmetaobject.h index 857b491c5..9db397f47 100644 --- a/src/kernel/ntqmetaobject.h +++ b/src/kernel/ntqmetaobject.h @@ -42,7 +42,7 @@ #define TQMETAOBJECT_H #ifndef QT_H -#include "ntqconnection.h" +#include "tqconnection.h" #include "tqstrlist.h" #endif // QT_H diff --git a/src/kernel/ntqnamespace.h b/src/kernel/ntqnamespace.h index cace88141..c6bdd1b0d 100644 --- a/src/kernel/ntqnamespace.h +++ b/src/kernel/ntqnamespace.h @@ -866,7 +866,7 @@ public: UI_AnimateToolBox }; - // documented in qcursor.cpp + // documented in tqcursor.cpp enum CursorShape { ArrowCursor, UpArrowCursor, diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index e7ee77271..477e2ca68 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -115,7 +115,7 @@ #include #include #include -#include +#include #include "tqlabel.h" #include "tqlayout.h" #include @@ -125,7 +125,7 @@ #include "tqscrollview.h" #include "tqdir.h" #include "tqwindowsstyle.h" -#include "ntqconnection.h" +#include "tqconnection.h" #include "tqbitmap.h" #include "ntqvariant.h" #include "tqsignal.h" @@ -155,7 +155,7 @@ #include #include #include -#include +#include #include #include #include "tqpopupmenu.h" @@ -165,7 +165,7 @@ #include "tqprogressbar.h" #include #include "tqptrdict.h" -#include +#include #include #include #include "tqstylesheet.h" @@ -236,7 +236,7 @@ #include "tqtoolbar.h" #include #include "tqwaitcondition.h" -#include +#include #include #include #include @@ -249,7 +249,7 @@ #include #include #include -#include +#include #include #include #include @@ -285,7 +285,7 @@ #include "private/tqsqldriverinterface_p.h" #include "private/tqsqlmanager_p.h" #include "private/qlock_p.h" -#include "private/qcomponentfactory_p.h" +#include "private/tqcomponentfactory_p.h" #include "private/tqstyleinterface_p.h" #include "private/qrichtext_p.h" #include "private/qsvgdevice_p.h" diff --git a/src/kernel/qaccel.cpp b/src/kernel/qaccel.cpp deleted file mode 100644 index e2f55f01e..000000000 --- a/src/kernel/qaccel.cpp +++ /dev/null @@ -1,1089 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQAccel class -** -** Created : 950419 -** -** 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 "ntqaccel.h" - -#ifndef TQT_NO_ACCEL - -#include "tqsignal.h" -#include "ntqapplication.h" -#include "tqwidget.h" -#include "tqptrlist.h" -#include "tqwhatsthis.h" -#include "tqguardedptr.h" -#include "tqstatusbar.h" -#include "ntqdockwindow.h" -#include "tqsignalslotimp.h" -/*! - \class TQAccel ntqaccel.h - \brief The TQAccel class handles keyboard accelerator and shortcut keys. - - \ingroup misc - - A keyboard accelerator triggers an action when a certain key - combination is pressed. The accelerator handles all keyboard - activity for all the children of one top-level widget, so it is - not affected by the keyboard focus. - - In most cases, you will not need to use this class directly. Use - the TQAction class to create actions with accelerators that can be - used in both menus and toolbars. If you're only interested in - menus use TQMenuData::insertItem() or TQMenuData::setAccel() to make - accelerators for operations that are also available on menus. Many - widgets automatically generate accelerators, such as TQButton, - TQGroupBox, TQLabel (with TQLabel::setBuddy()), TQMenuBar and TQTabBar. - Example: - \code - TQPushButton p( "&Exit", parent ); // automatic shortcut ALT+Key_E - TQPopupMenu *fileMenu = new fileMenu( parent ); - fileMenu->insertItem( "Undo", parent, TQ_SLOT(undo()), CTRL+Key_Z ); - \endcode - - A TQAccel contains a list of accelerator items that can be - manipulated using insertItem(), removeItem(), clear(), key() and - findKey(). - - Each accelerator item consists of an identifier and a \l - TQKeySequence. A single key sequence consists of a keyboard code - combined with modifiers (\c SHIFT, \c CTRL, \c ALT or \c - UNICODE_ACCEL). For example, \c{CTRL + Key_P} could be 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 accelerator as \c Key_A. - - When an accelerator key is pressed, the accelerator sends out the - signal activated() with a number that identifies this particular - accelerator item. Accelerator items can also be individually - connected, so that two different keys will activate two different - slots (see connectItem() and disconnectItem()). - - The activated() signal is \e not emitted when two or more - accelerators match the same key. Instead, the first matching - accelerator sends out the activatedAmbiguously() signal. By - pressing the key multiple times, users can navigate between all - matching accelerators. Some standard controls like TQPushButton and - TQCheckBox connect the activatedAmbiguously() signal to the - harmless setFocus() slot, whereas activated() is connected to a - slot invoking the button's action. Most controls, like TQLabel and - TQTabBar, treat activated() and activatedAmbiguously() as - equivalent. - - Use setEnabled() to enable or disable all the items in an - accelerator, or setItemEnabled() to enable or disable individual - items. An item is active only when both the TQAccel and the item - itself are enabled. - - The function setWhatsThis() specifies a help text that appears - when the user presses an accelerator key in What's This mode. - - The accelerator will be deleted when \e parent is deleted, - and will consume relevant key events until then. - - Please note that the accelerator - \code - accelerator->insertItem( TQKeySequence("M") ); - \endcode - can be triggered with both the 'M' key, and with Shift+M, - unless a second accelerator is defined for the Shift+M - combination. - - - Example: - \code - TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow - a->connectItem( a->insertItem(Key_P+CTRL), // adds Ctrl+P accelerator - myWindow, // connected to myWindow's - TQ_SLOT(printDoc()) ); // printDoc() slot - \endcode - - \sa TQKeyEvent TQWidget::keyPressEvent() TQMenuData::setAccel() - TQButton::setAccel() TQLabel::setBuddy() TQKeySequence - \link guibooks.html#fowler GUI Design Handbook: Keyboard Shortcuts \endlink. -*/ - - -struct TQAccelItem { // internal accelerator item - TQAccelItem( const TQKeySequence &k, int i ) - { key=k; id=i; enabled=TRUE; signal=0; } - ~TQAccelItem() { delete signal; } - int id; - TQKeySequence key; - bool enabled; - TQSignal *signal; - TQString whatsthis; -}; - - -typedef TQPtrList TQAccelList; // internal accelerator list - -class TQAccelPrivate : public TQt { -public: - TQAccelPrivate( TQAccel* p ); - ~TQAccelPrivate(); - TQAccelList aitems; - bool enabled; - TQGuardedPtr watch; - bool ignorewhatsthis; - TQAccel* parent; - - void activate( TQAccelItem* item ); - void activateAmbiguously( TQAccelItem* item ); -}; - -class TQAccelManager : public TQt { -public: - static TQAccelManager* self() { return self_ptr ? self_ptr : new TQAccelManager; } - void registerAccel( TQAccelPrivate* a ) { accels.append( a ); } - void unregisterAccel( TQAccelPrivate* a ) { accels.removeRef( a ); if ( accels.isEmpty() ) delete this; } - bool tryAccelEvent( TQWidget* w, TQKeyEvent* e ); - bool dispatchAccelEvent( TQWidget* w, TQKeyEvent* e ); - bool tryComposeUnicode( TQWidget* w, TQKeyEvent* e ); - -private: - TQAccelManager():currentState(TQt::NoMatch), clash(-1) { self_ptr = this; } - ~TQAccelManager() { self_ptr = 0; } - - bool correctSubWindow( TQWidget *w, TQAccelPrivate* d ); - SequenceMatch match( TQKeyEvent* e, TQAccelItem* item, TQKeySequence& temp ); - int translateModifiers( ButtonState state ); - - TQPtrList accels; - static TQAccelManager* self_ptr; - TQt::SequenceMatch currentState; - TQKeySequence intermediate; - int clash; -}; -TQAccelManager* TQAccelManager::self_ptr = 0; - -bool TQ_EXPORT tqt_tryAccelEvent( TQWidget* w, TQKeyEvent* e){ - return TQAccelManager::self()->tryAccelEvent( w, e ); -} - -bool TQ_EXPORT tqt_dispatchAccelEvent( TQWidget* w, TQKeyEvent* e){ - return TQAccelManager::self()->dispatchAccelEvent( w, e ); -} - -bool TQ_EXPORT tqt_tryComposeUnicode( TQWidget* w, TQKeyEvent* e){ - return TQAccelManager::self()->tryComposeUnicode( w, e ); -} - -#ifdef TQ_WS_MAC -static bool qt_accel_no_shortcuts = TRUE; -#else -static bool qt_accel_no_shortcuts = FALSE; -#endif -void TQ_EXPORT tqt_setAccelAutoShortcuts(bool b) { qt_accel_no_shortcuts = b; } - -/* - \internal - Returns TRUE if the accel is in the current subwindow, else FALSE. -*/ -bool TQAccelManager::correctSubWindow( TQWidget* w, TQAccelPrivate* d ) { -#if !defined ( Q_OS_MACX ) - if ( !d->watch || !d->watch->isVisible() || !d->watch->isEnabled() ) -#else - if ( !d->watch || (!d->watch->isVisible() && !d->watch->inherits( "TQMenuBar" )) || !d->watch->isEnabled() ) -#endif - return FALSE; - TQWidget* tlw = w->topLevelWidget(); - TQWidget* wtlw = d->watch->topLevelWidget(); - - /* if we live in a floating dock window, keep our parent's - * accelerators working */ -#ifndef TQT_NO_MAINWINDOW - if ( tlw->isDialog() && tlw->parentWidget() && ::tqt_cast(tlw) ) - return tlw->parentWidget()->topLevelWidget() == wtlw; - - if ( wtlw != tlw ) - return FALSE; -#endif - /* if we live in a MDI subwindow, ignore the event if we are - not the active document window */ - TQWidget* sw = d->watch; - while ( sw && !sw->testWFlags( WSubWindow ) ) - sw = sw->parentWidget( TRUE ); - if ( sw ) { // we are in a subwindow indeed - TQWidget* fw = w; - while ( fw && fw != sw ) - fw = fw->parentWidget( TRUE ); - if ( fw != sw ) // focus widget not in our subwindow - return FALSE; - } - return TRUE; -} - -inline int TQAccelManager::translateModifiers( ButtonState state ) -{ - int result = 0; - if ( state & ShiftButton ) - result |= SHIFT; - if ( state & ControlButton ) - result |= CTRL; - if ( state & MetaButton ) - result |= META; - if ( state & AltButton ) - result |= ALT; - return result; -} - -/* - \internal - Matches the current intermediate key sequence + the latest - keyevent, with and AccelItem. Returns Identical, - PartialMatch or NoMatch, and fills \a temp with the - resulting key sequence. -*/ -TQt::SequenceMatch TQAccelManager::match( TQKeyEvent *e, TQAccelItem* item, TQKeySequence& temp ) -{ - SequenceMatch result = TQt::NoMatch; - int index = intermediate.count(); - temp = intermediate; - - int modifier = translateModifiers( e->state() ); - - if ( e->key() && e->key() != Key_unknown) { - int key = e->key() | modifier; - if ( e->key() == Key_BackTab ) { - /* - In TQApplication, we map shift+tab to shift+backtab. - This code here reverts the mapping in a way that keeps - backtab and shift+tab accelerators working, in that - order, meaning backtab has priority.*/ - key &= ~SHIFT; - - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - if ( e->state() & ShiftButton ) - key |= SHIFT; - key = Key_Tab | ( key & MODIFIER_MASK ); - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - } else { - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - } - - if ( key == Key_BackTab ) { - if ( e->state() & ShiftButton ) - key |= SHIFT; - temp.setKey( key, index ); - if ( TQt::NoMatch != (result = temp.matches( item->key )) ) - return result; - } - } - if ( !e->text().isEmpty() ) { - temp.setKey( (int)e->text()[0].unicode() | UNICODE_ACCEL | modifier, index ); - result = temp.matches( item->key ); - } - return result; -} - -bool TQAccelManager::tryAccelEvent( TQWidget* w, TQKeyEvent* e ) -{ - if ( TQt::NoMatch == currentState ) { - e->t = TQEvent::AccelOverride; - e->ignore(); - TQApplication::sendSpontaneousEvent( w, e ); - if ( e->isAccepted() ) - return FALSE; - } - e->t = TQEvent::Accel; - e->ignore(); - TQApplication::sendSpontaneousEvent( w, e ); - return e->isAccepted(); -} - -bool TQAccelManager::tryComposeUnicode( TQWidget* w, TQKeyEvent* e ) -{ - if ( TQApplication::metaComposeUnicode ) { - int value = e->key() - Key_0; - // Ignore acceloverrides so we don't trigger - // accels on keypad when Meta compose is on - if ( (e->type() == TQEvent::AccelOverride) && - (e->state() == TQt::Keypad + TQt::MetaButton) ) { - e->accept(); - // Meta compose start/continue - } else if ( (e->type() == TQEvent::KeyPress) && - (e->state() == TQt::Keypad + TQt::MetaButton) ) { - if ( value >= 0 && value <= 9 ) { - TQApplication::composedUnicode *= 10; - TQApplication::composedUnicode += value; - return TRUE; - } else { - // Composing interrupted, dispatch! - if ( TQApplication::composedUnicode ) { - TQChar ch( TQApplication::composedUnicode ); - TQString s( ch ); - TQKeyEvent kep( TQEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQKeyEvent ker( TQEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQApplication::sendEvent( w, &kep ); - TQApplication::sendEvent( w, &ker ); - } - TQApplication::composedUnicode = 0; - return TRUE; - } - // Meta compose end, dispatch - } else if ( (e->type() == TQEvent::KeyRelease) && - (e->key() == Key_Meta) && - (TQApplication::composedUnicode != 0) ) { - if ( (TQApplication::composedUnicode > 0) && - (TQApplication::composedUnicode < 0xFFFE) ) { - TQChar ch( TQApplication::composedUnicode ); - TQString s( ch ); - TQKeyEvent kep( TQEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQKeyEvent ker( TQEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s ); - TQApplication::sendEvent( w, &kep ); - TQApplication::sendEvent( w, &ker ); - } - TQApplication::composedUnicode = 0; - return TRUE; - } - } - return FALSE; -} - -/* - \internal - Checks for possible accelerators, if no widget - ate the keypres, or we are in the middle of a - partial key sequence. -*/ -bool TQAccelManager::dispatchAccelEvent( TQWidget* w, TQKeyEvent* e ) -{ -#ifndef TQT_NO_STATUSBAR - // Needs to be declared and used here because of "goto doclash" - TQStatusBar* mainStatusBar = 0; -#endif - - // Modifiers can NOT be accelerators... - if ( e->key() >= Key_Shift && - e->key() <= Key_Alt ) - return FALSE; - - SequenceMatch result = TQt::NoMatch; - TQKeySequence tocheck, partial; - TQAccelPrivate* accel = 0; - TQAccelItem* item = 0; - TQAccelPrivate* firstaccel = 0; - TQAccelItem* firstitem = 0; - TQAccelPrivate* lastaccel = 0; - TQAccelItem* lastitem = 0; - - TQKeyEvent pe = *e; - int n = -1; - int hasShift = (e->state()&TQt::ShiftButton)?1:0; - bool identicalDisabled = FALSE; - bool matchFound = FALSE; - do { - accel = accels.first(); - matchFound = FALSE; - while ( accel ) { - if ( correctSubWindow( w, accel ) ) { - if ( accel->enabled ) { - item = accel->aitems.last(); - while( item ) { - if ( TQt::Identical == (result = match( &pe, item, tocheck )) ) { - if ( item->enabled ) { - if ( !firstaccel ) { - firstaccel = accel; - firstitem = item; - } - lastaccel = accel; - lastitem = item; - n++; - matchFound = TRUE; - if ( n > TQMAX(clash,0) ) - goto doclash; - } else { - identicalDisabled = TRUE; - } - } - if ( item->enabled && TQt::PartialMatch == result ) { - partial = tocheck; - matchFound = TRUE; - } - item = accel->aitems.prev(); - } - } else { - item = accel->aitems.last(); - while( item ) { - if ( TQt::Identical == match( &pe, item, tocheck ) ) - identicalDisabled = TRUE; - item = accel->aitems.prev(); - } - } - } - accel = accels.next(); - } - pe = TQKeyEvent( TQEvent::Accel, pe.key(), pe.ascii(), pe.state()&~TQt::ShiftButton, pe.text() ); - } while ( hasShift-- && !matchFound && !identicalDisabled ); - -#ifndef TQT_NO_STATUSBAR - mainStatusBar = (TQStatusBar*) w->topLevelWidget()->child( 0, "TQStatusBar" ); -#endif - if ( n < 0 ) { // no match found - currentState = partial.count() ? PartialMatch : NoMatch; -#ifndef TQT_NO_STATUSBAR - // Only display message if we are, or were, in a partial match - if ( mainStatusBar && (PartialMatch == currentState || intermediate.count() ) ) { - if ( currentState == TQt::PartialMatch ) { - mainStatusBar->message( (TQString)partial + ", ...", 0 ); - } else if (!identicalDisabled) { - TQString message = TQAccel::tr("%1, %2 not defined"). - arg( (TQString)intermediate ). - arg( TQKeySequence::encodeString( e->key() | translateModifiers(e->state()) ) ); - mainStatusBar->message( message, 2000 ); - // Since we're a NoMatch, reset the clash count - clash = -1; - } else { - mainStatusBar->clear(); - } - } -#endif - - bool eatKey = (PartialMatch == currentState || intermediate.count() ); - intermediate = partial; - if ( eatKey ) - e->accept(); - return eatKey; - } else if ( n == 0 ) { // found exactly one match - clash = -1; // reset -#ifndef TQT_NO_STATUSBAR - if ( currentState == TQt::PartialMatch && mainStatusBar ) - mainStatusBar->clear(); -#endif - currentState = TQt::NoMatch; // Free sequence keylock - intermediate = TQKeySequence(); - lastaccel->activate( lastitem ); - e->accept(); - return TRUE; - } - - doclash: // found more than one match -#ifndef TQT_NO_STATUSBAR - if ( !mainStatusBar ) // if "goto doclash", we need to get statusbar again. - mainStatusBar = (TQStatusBar*) w->topLevelWidget()->child( 0, "TQStatusBar" ); -#endif - - TQString message = TQAccel::tr( "Ambiguous \"%1\" not handled" ).arg( (TQString)tocheck ); - if ( clash >= 0 && n > clash ) { // pick next match - intermediate = TQKeySequence(); - currentState = TQt::NoMatch; // Free sequence keylock - clash++; -#ifndef TQT_NO_STATUSBAR - if ( mainStatusBar && - !lastitem->signal && - !(lastaccel->parent->receivers( "activatedAmbiguously(int)" )) ) - mainStatusBar->message( message, 2000 ); -#endif - lastaccel->activateAmbiguously( lastitem ); - } else { // start (or wrap) with the first matching - intermediate = TQKeySequence(); - currentState = TQt::NoMatch; // Free sequence keylock - clash = 0; -#ifndef TQT_NO_STATUSBAR - if ( mainStatusBar && - !firstitem->signal && - !(firstaccel->parent->receivers( "activatedAmbiguously(int)" )) ) - mainStatusBar->message( message, 2000 ); -#endif - firstaccel->activateAmbiguously( firstitem ); - } - e->accept(); - return TRUE; -} - -TQAccelPrivate::TQAccelPrivate( TQAccel* p ) - : parent( p ) -{ - TQAccelManager::self()->registerAccel( this ); - aitems.setAutoDelete( TRUE ); - ignorewhatsthis = FALSE; -} - -TQAccelPrivate::~TQAccelPrivate() -{ - TQAccelManager::self()->unregisterAccel( this ); -} - -static TQAccelItem *find_id( TQAccelList &list, int id ) -{ - TQAccelItem *item = list.first(); - while ( item && item->id != id ) - item = list.next(); - return item; -} - -static TQAccelItem *find_key( TQAccelList &list, const TQKeySequence &key ) -{ - TQAccelItem *item = list.first(); - while ( item && !( item->key == key ) ) - item = list.next(); - return item; -} - -/*! - Constructs a TQAccel object called \a name, with parent \a parent. - The accelerator operates on \a parent. -*/ - -TQAccel::TQAccel( TQWidget *parent, const char *name ) - : TQObject( parent, name ) -{ - d = new TQAccelPrivate( this ); - d->enabled = TRUE; - d->watch = parent; -#if defined(QT_CHECK_NULL) - if ( !d->watch ) - tqWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); -#endif -} - -/*! - Constructs a TQAccel object called \a name, that operates on \a - watch, and is a child of \a parent. - - This constructor is not needed for normal application programming. -*/ -TQAccel::TQAccel( TQWidget* watch, TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ - d = new TQAccelPrivate( this ); - d->enabled = TRUE; - d->watch = watch; -#if defined(QT_CHECK_NULL) - if ( !d->watch ) - tqWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); -#endif -} - -/*! - Destroys the accelerator object and frees all allocated resources. -*/ - -TQAccel::~TQAccel() -{ - delete d; -} - - -/*! - \fn void TQAccel::activated( int id ) - - This signal is emitted when an accelerator key is pressed. \a id - is a number that identifies this particular accelerator item. - - \sa activatedAmbiguously() -*/ - -/*! - \fn void TQAccel::activatedAmbiguously( int id ) - - This signal is emitted when an accelerator key is pressed. \a id - is a number that identifies this particular accelerator item. - - \sa activated() -*/ - - -/*! - Returns TRUE if the accelerator is enabled; otherwise returns - FALSE. - - \sa setEnabled(), isItemEnabled() -*/ - -bool TQAccel::isEnabled() const -{ - return d->enabled; -} - - -/*! - Enables the accelerator if \a enable is TRUE, or disables it if \a - enable is FALSE. - - Individual keys can also be enabled or disabled using - setItemEnabled(). To work, a key must be an enabled item in an - enabled TQAccel. - - \sa isEnabled(), setItemEnabled() -*/ - -void TQAccel::setEnabled( bool enable ) -{ - d->enabled = enable; -} - - -/*! - Returns the number of accelerator items in this accelerator. -*/ - -uint TQAccel::count() const -{ - return d->aitems.count(); -} - - -static int get_seq_id() -{ - static int seq_no = -2; // -1 is used as return value in findKey() - return seq_no--; -} - -/*! - Inserts an accelerator item and returns the item's identifier. - - \a key is a key code and an optional combination of SHIFT, CTRL - and ALT. \a id is the accelerator item id. - - If \a id is negative, then the item will be assigned a unique - negative identifier less than -1. - - \code - TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow - a->insertItem( CTRL + Key_P, 200 ); // Ctrl+P, e.g. to print document - a->insertItem( ALT + Key_X, 201 ); // Alt+X, e.g. to quit - a->insertItem( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q', e.g. to quit - a->insertItem( Key_D ); // gets a unique negative id < -1 - a->insertItem( CTRL + SHIFT + Key_P ); // gets a unique negative id < -1 - \endcode -*/ - -int TQAccel::insertItem( const TQKeySequence& key, int id ) -{ - if ( id == -1 ) - id = get_seq_id(); - d->aitems.insert( 0, new TQAccelItem(key,id) ); - return id; -} - -/*! - Removes the accelerator item with the identifier \a id. -*/ - -void TQAccel::removeItem( int id ) -{ - if ( find_id( d->aitems, id) ) - d->aitems.remove(); -} - - -/*! - Removes all accelerator items. -*/ - -void TQAccel::clear() -{ - d->aitems.clear(); -} - - -/*! - Returns the key sequence of the accelerator item with identifier - \a id, or an invalid key sequence (0) if the id cannot be found. -*/ - -TQKeySequence TQAccel::key( int id ) -{ - TQAccelItem *item = find_id( d->aitems, id); - return item ? item->key : TQKeySequence( 0 ); -} - - -/*! - Returns the identifier of the accelerator item with the key code - \a key, or -1 if the item cannot be found. -*/ - -int TQAccel::findKey( const TQKeySequence& key ) const -{ - TQAccelItem *item = find_key( d->aitems, key ); - return item ? item->id : -1; -} - - -/*! - Returns TRUE if the accelerator item with the identifier \a id is - enabled. Returns FALSE if the item is disabled or cannot be found. - - \sa setItemEnabled(), isEnabled() -*/ - -bool TQAccel::isItemEnabled( int id ) const -{ - TQAccelItem *item = find_id( d->aitems, id); - return item ? item->enabled : FALSE; -} - - -/*! - Enables the accelerator item with the identifier \a id if \a - enable is TRUE, and disables item \a id if \a enable is FALSE. - - To work, an item must be enabled and be in an enabled TQAccel. - - \sa isItemEnabled(), isEnabled() -*/ - -void TQAccel::setItemEnabled( int id, bool enable ) -{ - TQAccelItem *item = find_id( d->aitems, id); - if ( item ) - item->enabled = enable; -} - - -/*! - Connects the accelerator item \a id to the slot \a member of \a - receiver. - - \code - a->connectItem( 201, mainView, TQ_SLOT(quit()) ); - \endcode - - Of course, you can also send a signal as \a member. - - Normally accelerators are connected to slots which then receive - the \c activated(int id) signal with the id of the accelerator - item that was activated. If you choose to connect a specific - accelerator item using this function, the \c activated() signal is - emitted if the associated key sequence is pressed but no \c - activated(int id) signal is emitted. - - \sa disconnectItem() -*/ - -bool TQAccel::connectItem( int id, const TQObject *receiver, const char *member ) -{ - TQAccelItem *item = find_id( d->aitems, id); - if ( item ) { - if ( !item->signal ) { - item->signal = new TQSignal; - TQ_CHECK_PTR( item->signal ); - } - return item->signal->connect( receiver, member ); - } - return FALSE; -} - -/*! - Disconnects an accelerator item with id \a id from the function - called \a member in the \a receiver object. - - \sa connectItem() -*/ - -bool TQAccel::disconnectItem( int id, const TQObject *receiver, - const char *member ) -{ - TQAccelItem *item = find_id( d->aitems, id); - if ( item && item->signal ) - return item->signal->disconnect( receiver, member ); - return FALSE; -} - -void TQAccelPrivate::activate( TQAccelItem* item ) -{ -#ifndef TQT_NO_WHATSTHIS - if ( TQWhatsThis::inWhatsThisMode() && !ignorewhatsthis ) { - TQWhatsThis::leaveWhatsThisMode( item->whatsthis ); - return; - } -#endif - if ( item->signal ) - item->signal->activate(); - else - emit parent->activated( item->id ); -} - -void TQAccelPrivate::activateAmbiguously( TQAccelItem* item ) -{ - if ( item->signal ) - item->signal->activate(); - else - emit parent->activatedAmbiguously( item->id ); -} - - -/*! - Returns the shortcut key sequence for \a str, or an invalid key - sequence (0) if \a str has no shortcut sequence. - - For example, shortcutKey("E&xit") returns ALT+Key_X, - shortcutKey("&Quit") returns ALT+Key_Q and shortcutKey("Quit") - returns 0. (In code that does not inherit the TQt namespace class, - you must write e.g. TQt::ALT+TQt::Key_Q.) - - We provide a \link accelerators.html list of common accelerators - \endlink in English. At the time of writing, Microsoft and Open - Group do not appear to have issued equivalent recommendations for - other languages. -*/ - -TQKeySequence TQAccel::shortcutKey( const TQString &str ) -{ - if(qt_accel_no_shortcuts) - return TQKeySequence(); - - int p = 0; - while ( p >= 0 ) { - p = str.find( '&', p ) + 1; - if ( p <= 0 || p >= (int)str.length() ) - return 0; - if ( str[p] != '&' ) { - TQChar c = str[p]; - if ( c.isPrint() ) { - char ltr = c.upper().latin1(); - if ( ltr >= (char)Key_A && ltr <= (char)Key_Z ) - c = ltr; - else - c = c.lower(); - return TQKeySequence( c.unicode() + ALT + UNICODE_ACCEL ); - } - } - p++; - } - return TQKeySequence(); -} - -/*! \obsolete - - Creates an accelerator string for the key \a k. - For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc. - are translated (using TQObject::tr()) in the "TQAccel" context. - - The function is superfluous. Cast the TQKeySequence \a k to a - TQString for the same effect. -*/ -TQString TQAccel::keyToString( TQKeySequence k ) -{ - return (TQString) k; -} - -/*!\obsolete - - Returns an accelerator code for the string \a s. For example - "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", - "Shift", "Alt" are recognized, as well as their translated - equivalents in the "TQAccel" context (using TQObject::tr()). Returns 0 - if \a s is not recognized. - - This function 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( p1, tr("&Open..."), this, TQ_SLOT(open()), - TQAccel::stringToKey(tr("Ctrl+O", "File|Open")) ); - \endcode - - Notice the \c "File|Open" translator comment. It is by no means - necessary, but it provides some context for the human translator. - - - The function is superfluous. Construct a TQKeySequence from the - string \a s for the same effect. - - \sa TQObject::tr() - \link i18n.html Internationalization with TQt \endlink -*/ -TQKeySequence TQAccel::stringToKey( const TQString & s ) -{ - return TQKeySequence( s ); -} - - -/*! - Sets a What's This help text for the accelerator item \a id to \a - text. - - The text will be shown when the application is in What's This mode - and the user hits the accelerator key. - - To set What's This help on a menu item (with or without an - accelerator key), use TQMenuData::setWhatsThis(). - - \sa whatsThis(), TQWhatsThis::inWhatsThisMode(), - TQMenuData::setWhatsThis(), TQAction::setWhatsThis() -*/ -void TQAccel::setWhatsThis( int id, const TQString& text ) -{ - - TQAccelItem *item = find_id( d->aitems, id); - if ( item ) - item->whatsthis = text; -} - -/*! - Returns the What's This help text for the specified item \a id or - TQString::null if no text has been specified. - - \sa setWhatsThis() -*/ -TQString TQAccel::whatsThis( int id ) const -{ - - TQAccelItem *item = find_id( d->aitems, id); - return item? item->whatsthis : TQString::null; -} - -/*!\internal */ -void TQAccel::setIgnoreWhatsThis( bool b) -{ - d->ignorewhatsthis = b; -} - -/*!\internal */ -bool TQAccel::ignoreWhatsThis() const -{ - return d->ignorewhatsthis; -} - - -/*! - -\page accelerators.html - -\title Standard Accelerator Keys - -Applications invariably need to define accelerator keys for actions. -TQt fully supports accelerators, for example with \l TQAccel::shortcutKey(). - -Here are Microsoft's recommendations for accelerator keys, with -comments about the Open Group's recommendations where they exist -and differ. For most commands, the Open Group either has no advice or -agrees with Microsoft. - -The emboldened letter plus Alt is Microsoft's recommended choice, and -we recommend supporting it. For an Apply button, for example, we -recommend TQButton::setText( \link TQWidget::tr() tr \endlink("&Apply") ); - -If you have conflicting commands (e.g. About and Apply buttons in the -same dialog), you must decide for yourself. - -\list -\i About -\i Always on Top -\i Apply -\i Back -\i Browse -\i Close (CDE: Alt+F4; Alt+F4 is "close window" in Windows) -\i Copy (CDE: Ctrl+C, Ctrl+Insert) -\i Copy Here -\i Create Shortcut -\i Create Shortcut Here -\i Cut -\i Delete -\i Edit -\i Exit (CDE: Exit) -\i Explore -\i File -\i Find -\i Help -\i Help Topics -\i Hide -\i Insert -\i Insert Object -\i Link Here -\i Maximize -\i Minimize -\i Move -\i Move Here -\i New -\i Next -\i No -\i Open -\i Open With -\i Page Setup -\i Paste -\i Paste Link -\i Paste Shortcut -\i Paste Special -\i Pause -\i Play -\i Print -\i Print Here -\i Properties -\i Quick View -\i Redo (CDE: Ctrl+Y, Shift+Alt+Backspace) -\i Repeat -\i Restore -\i Resume -\i Retry -\i Run -\i Save -\i Save As -\i Select All -\i Send To -\i Show -\i Size -\i Split -\i Stop -\i Undo (CDE: Ctrl+Z or Alt+Backspace) -\i View -\i What's This? -\i Window -\i Yes -\endlist - -There are also a lot of other keys and actions (that use other -modifier keys than Alt). See the Microsoft and The Open Group -documentation for details. - -The \link http://www.amazon.com/exec/obidos/ASIN/0735605661/trolltech/t -Microsoft book \endlink has ISBN 0735605661. The corresponding Open Group -book is very hard to find, rather expensive and we cannot recommend -it. However, if you really want it, OGPubs@opengroup.org might be able -to help. Ask them for ISBN 1859121047. - -*/ - -/*! \obsolete serves no purpose anymore */ -void TQAccel::repairEventFilter() {} -/*! \obsolete serves no purpose anymore */ -bool TQAccel::eventFilter( TQObject *, TQEvent * ) { return FALSE; } -#endif // TQT_NO_ACCEL diff --git a/src/kernel/qaccessible.cpp b/src/kernel/qaccessible.cpp deleted file mode 100644 index d486607ca..000000000 --- a/src/kernel/qaccessible.cpp +++ /dev/null @@ -1,719 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQAccessible and TQAccessibleObject classes -** -** 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 "ntqaccessible.h" - -#if defined(QT_ACCESSIBILITY_SUPPORT) - -#include "tqptrdict.h" -#include "ntqmetaobject.h" -#include -#include "ntqapplication.h" -#include - -/*! - \class TQAccessible ntqaccessible.h - \brief The TQAccessible class provides enums and static functions - relating to accessibility. - - \ingroup misc - - Accessibility clients use implementations of the - TQAccessibleInterface to read the information an accessible object - exposes, or to call functions to manipulate the accessible object. - -\omit - TQt provides implementations of the TQAccessibleInterface for most - widget classes in a plugin. This plugin is located in the \e - accessibility subdirectory of the plugins installation directory. - The default installation directory for plugins is \c INSTALL/plugins, - where \c INSTALL is the directory where TQt was installed. Calling - queryAccessibleInterface( TQObject *object, TQAccessibleInterface - **iface ) will ask all plugins located in this directory for an - implementation that exposes the information for objects of the - class of \e object. - - To make a TQt application accessible you have to distribute the - accessibility plugin provded with TQt together with your - application. Simply add the plugins created in - INSTALL/plugins/accessibility to your distribution process. Use \l - TQApplication::addLibraryPath() to specify a plugin directory for - your application, and copy the files into an \e accessibility - subdirectory of one of those plugin directories. TQt's - accessibility framework will load the plugins upon request and use - the implementations provided to expose an object's accessibility - information. -\endomit - - See the \link plugins-howto.html plugin documentation \endlink for - more details about how to redistribute TQt plugins. -*/ - -/*! - \enum TQAccessible::State - - This enum type defines bitflags that can be combined to indicate - the state of the accessible object. The values are: - - \value Normal - \value Unavailable - \value Selected - \value Focused - \value Pressed - \value Checked - \value Mixed - \value ReadOnly - \value HotTracked - \value Default - \value Expanded - \value Collapsed - \value Busy - \value Floating - \value Marqueed - \value Animated - \value Invisible - \value Offscreen - \value Sizeable - \value Moveable - \value SelfVoicing - \value Focusable - \value Selectable - \value Linked - \value Traversed - \value MultiSelectable - \value ExtSelectable - \value AlertLow - \value AlertMedium - \value AlertHigh - \value Protected - \value Valid -*/ - -/*! - \enum TQAccessible::Event - - This enum type defines event types when the state of the - accessible object has changed. The event types are: - - \value SoundPlayed - \value Alert - \value ForegroundChanged - \value MenuStart - \value MenuEnd - \value PopupMenuStart - \value PopupMenuEnd - \value ContextHelpStart - \value ContextHelpEnd - \value DragDropStart - \value DragDropEnd - \value DialogStart - \value DialogEnd - \value ScrollingStart - \value ScrollingEnd - \value ObjectCreated - \value ObjectDestroyed - \value ObjectShow - \value ObjectHide - \value ObjectReorder - \value Focus - \value Selection - \value SelectionAdd - \value SelectionRemove - \value SelectionWithin - \value StateChanged - \value LocationChanged - \value NameChanged - \value DescriptionChanged - \value ValueChanged - \value ParentChanged - \value HelpChanged - \value DefaultActionChanged - \value AcceleratorChanged - \value MenuCommand -*/ - -/*! - \enum TQAccessible::Role - - This enum defines a number of roles an accessible object can have. - The roles are: - - \value NoRole - \value TitleBar - \value MenuBar - \value ScrollBar - \value Grip - \value Sound - \value Cursor - \value Caret - \value AlertMessage - \value Window - \value Client - \value PopupMenu - \value MenuItem - \value ToolTip - \value Application - \value Document - \value Pane - \value Chart - \value Dialog - \value Border - \value Grouping - \value Separator - \value ToolBar - \value StatusBar - \value Table - \value ColumnHeader - \value RowHeader - \value Column - \value Row - \value Cell - \value Link - \value HelpBalloon - \value Character - \value List - \value ListItem - \value Outline - \value OutlineItem - \value PageTab - \value PropertyPage - \value Indicator - \value Graphic - \value StaticText - \value EditableText - \value PushButton - \value CheckBox - \value RadioButton - \value ComboBox - \value DropLest - \value ProgressBar - \value Dial - \value HotkeyField - \value Slider - \value SpinBox - \value Diagram - \value Animation - \value Equation - \value ButtonDropDown - \value ButtonMenu - \value ButtonDropGrid - \value Whitespace - \value PageTabList - \value Clock -*/ - -/*! - \enum TQAccessible::NavDirection - - This enum specifies which item to move to when navigating. - - \value NavUp sibling above - \value NavDown sibling below - \value NavLeft left sibling - \value NavRight right sibling - \value NavNext next sibling - \value NavPrevious previous sibling - \value NavFirstChild first child - \value NavLastChild last child - \value NavFocusChild child with focus -*/ - -/*! - \enum TQAccessible::Text - - This enum specifies string information that an accessible object - returns. - - \value Name The name of the object - \value Description A short text describing the object - \value Value The value of the object - \value Help A longer text giving information about how - to use the object - \value DefaultAction The default method to interact with the object - \value Accelerator The keyboard shortcut that executes the - default action -*/ - -/*! - \fn static void TQAccessible::updateAccessibility( TQObject *object, int control, Event reason ) - - Notifies accessibility clients about a change in \a object's - accessibility information. - - \a reason specifies the cause of the change, for example, - ValueChange when the position of a slider has been changed. \a - control is the ID of the child element that has changed. When \a - control is 0, the object itself has changed. - - Call this function whenever the state of your accessible object or - one of it's sub-elements has been changed either programmatically - (e.g. by calling TQLabel::setText()) or by user interaction. - - If there are no accessibility tools listening to this event, the - performance penalty for calling this function is minor, but if determining - the parameters of the call is expensive you can use isActive() to - avoid unnecessary performance penalties if no client is listening. -*/ - -static TQPluginManager *qAccessibleManager = 0; - -class AccessibleCache : public TQObject, public TQPtrDict -{ - TQ_OBJECT -public: - AccessibleCache() - : TQPtrDict(73) - { - } - - void addObject(TQObject *object, TQAccessibleInterface *iface) - { - insert(object, iface); - connect(object, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(removeObject(TQObject*))); - } - -public slots: - void removeObject(TQObject *object); -}; - -#include "qaccessible.moc" - -static AccessibleCache *qAccessibleInterface = 0; -static bool cleanupAdded = FALSE; - -static void qAccessibleCleanup() -{ - if ( qAccessibleInterface && qAccessibleInterface->count() && qAccessibleManager ) - qAccessibleManager->setAutoUnload( FALSE ); - - delete qAccessibleInterface; - qAccessibleInterface = 0; - delete qAccessibleManager; - qAccessibleManager = 0; -} - -#ifdef TQ_WS_MAC -TQObject *TQAccessible::queryAccessibleObject(TQAccessibleInterface *o) -{ - if(qAccessibleInterface) { - for(TQPtrDictIterator it(*qAccessibleInterface); it.current(); ++it) { - if(it.current() == o) - return (TQObject*)it.currentKey(); - } - } - return NULL; -} -#endif - -void AccessibleCache::removeObject(TQObject *object) -{ - if (!object) - return; - - remove(object); - if (!count()) { - delete this; - qAccessibleInterface = 0; - } -} - - -/*! - Sets \a iface to point to the implementation of the - TQAccessibleInterface for \a object, and returns \c TQS_OK if - successfull, or sets \a iface to 0 and returns \c TQE_NOCOMPONENT if - no accessibility implementation for \a object exists. - - The function uses the \link TQObject::className() classname - \endlink of \a object to find a suitable implementation. If no - implementation for the object's class is available the function - tries to find an implementation for the object's parent class. - - This function is called to answer an accessibility client's - request for object information. You should never need to call this - function yourself. -*/ -TQRESULT TQAccessible::queryAccessibleInterface( TQObject *object, TQAccessibleInterface **iface ) -{ - *iface = 0; - if ( !object ) - return TQE_INVALIDARG; - - if ( qAccessibleInterface ) { - *iface = qAccessibleInterface->find( object ); - if ( *iface ) { - (*iface)->addRef(); - return TQS_OK; - } - } - - if ( !qAccessibleManager ) { - qAccessibleManager = new TQPluginManager( IID_QAccessibleFactory, TQApplication::libraryPaths(), "/accessible" ); - if ( !cleanupAdded ) { - tqAddPostRoutine( qAccessibleCleanup ); - cleanupAdded = TRUE; - } - } - - TQInterfacePtr factory = 0; - TQMetaObject *mo = object->metaObject(); - while ( mo ) { - qAccessibleManager->queryInterface( mo->className(), &factory ); - if ( factory ) - break; - mo = mo->superClass(); - } - if ( factory ) - return factory->createAccessibleInterface( mo->className(), object, iface ); - - return TQE_NOCOMPONENT; -} - -/*! - Returns TRUE if an accessibility implementation has been requested, - during the runtime of the application, otherwise returns FALSE. - - Use this function to prevent potentially expensive notifications via - updateAccessibility(). - - \omit - TQListView uses this function to prevent index-lookups for item based - notifications. - \endomit -*/ -bool TQAccessible::isActive() -{ - return qAccessibleManager != 0; -} - -/*! - \class TQAccessibleInterface ntqaccessible.h - \brief The TQAccessibleInterface class defines an interface that exposes information about accessible objects. - - \ingroup misc -*/ - -/*! - \fn bool TQAccessibleInterface::isValid() const - - Returns TRUE if all the data necessary to use this interface - implementation is valid (e.g. all pointers are non-null), - otherwise returns FALSE. -*/ - -/*! - \fn int TQAccessibleInterface::childCount() const - - Returns the number of children that belong to this object. A child - can provide accessibility information on it's own (e.g. a child - widget), or be a sub-element of this accessible object. - - All objects provide this information. - - \sa queryChild() -*/ - -/*! - \fn TQRESULT TQAccessibleInterface::queryChild( int control, TQAccessibleInterface **iface ) const - - Sets \a iface to point to the implementation of the - TQAccessibleInterface for the child specified with \a control. If - the child doesn't provide accessibility information on it's own, - the value of \a iface is set to 0. For those elements, this - object is responsible for exposing the child's properties. - - All objects provide this information. - - \sa childCount(), queryParent() -*/ - -/*! - \fn TQRESULT TQAccessibleInterface::queryParent( TQAccessibleInterface **iface ) const - - Sets \a iface to point to the implementation of the - TQAccessibleInterface for the parent object, or to 0 if there is - no such implementation or object. - - All objects provide this information. - - \sa queryChild() -*/ - -/*! - \fn int TQAccessibleInterface::controlAt( int x, int y ) const - - Returns the ID of the child that contains the screen coordinates - (\a x, \a y). This function returns 0 if the point is positioned - on the object itself. If the tested point is outside the - boundaries of the object this function returns -1. - - All visual objects provide this information. -*/ - -/*! - \fn TQRect TQAccessibleInterface::rect( int control ) const - - Returns the location of the child specified with \a control in - screen coordinates. This function returns the location of the - object itself if \a control is 0. - - All visual objects provide this information. -*/ - -/*! - \fn int TQAccessibleInterface::navigate( NavDirection direction, int startControl ) const - - This function traverses to another object, or to a sub-element of - the current object. \a direction specifies in which direction to - navigate, and \a startControl specifies the start point of the - navigation, which is either 0 if the navigation starts at the - object itself, or an ID of one of the object's sub-elements. - - The function returns the ID of the sub-element located in the \a - direction specified. If there is nothing in the navigated \a - direction, this function returns -1. - - All objects support navigation. -*/ - -/*! - \fn TQString TQAccessibleInterface::text( Text t, int control ) const - - Returns a string property \a t of the child object specified by \a - control, or the string property of the object itself if \a control - is 0. - - The \e Name is a string used by clients to identify, find or - announce an accessible object for the user. All objects must have - a name that is unique within their container. - - An accessible object's \e Description provides textual information - about an object's visual appearance. The description is primarily - used to provide greater context for low-vision or blind users, but - is also used for context searching or other applications. Not all - objects have a description. An "OK" button would not need a - description, but a toolbutton that shows a picture of a smiley - would. - - The \e Value of an accessible object represents visual information - contained by the object, e.g. the text in a line edit. Usually, - the value can be modified by the user. Not all objects have a - value, e.g. static text labels don't, and some objects have a - state that already is the value, e.g. toggle buttons. - - The \e Help text provides information about the function and - usage of an accessible object. Not all objects provide this - information. - - An accessible object's \e DefaultAction describes the object's - primary method of manipulation, and should be a verb or a short - phrase, e.g. "Press" for a button. - - The accelerator is a keyboard shortcut that activates the default - action of the object. A keyboard shortcut is the underlined - character in the text of a menu, menu item or control, and is - either the character itself, or a combination of this character - and a modifier key like ALT, CTRL or SHIFT. Command controls like - tool buttons also have shortcut keys and usually display them in - their tooltip. - - \sa role(), state(), selection() -*/ - -/*! - \fn void TQAccessibleInterface::setText( Text t, int control, const TQString &text ) - - Sets the text property \a t of the child object \a control to \a - text. If \a control is 0, the text property of the object itself - is set. -*/ - -/*! - \fn TQAccessible::Role TQAccessibleInterface::role( int control ) const - - Returns the role of the object if \a control is 0, or the role of - the object's sub-element with ID \a control. The role of an object - is usually static. All accessible objects have a role. - - \sa text(), state(), selection() -*/ - -/*! - \fn TQAccessible::State TQAccessibleInterface::state( int control ) const - - Returns the current state of the object if \a control is 0, or the - state of the object's sub-element element with ID \a control. All - objects have a state. - - \sa text(), role(), selection() -*/ - -/*! - \fn TQMemArray TQAccessibleInterface::selection() const - - Returns the list of all the element IDs that are selected. - - \sa text(), role(), state() -*/ - -/*! - \fn bool TQAccessibleInterface::doDefaultAction( int control ) - - Calling this function performs the default action of the child - object specified by \a control, or the default action of the - object itself if \a control is 0. -*/ - -/*! - \fn bool TQAccessibleInterface::setFocus( int control ) - - Gives the focus to the child object specified by \a control, or to - the object itself if \a control is 0. - - Returns TRUE if the focus could be set; otherwise returns FALSE. -*/ - -/*! - \fn bool TQAccessibleInterface::setSelected( int control, bool on, bool extend ) - - Sets the selection of the child object with ID \a control to \a - on. If \a extend is TRUE, all child elements between the focused - item and the specified child object have their selection set to \a - on. - - Returns TRUE if the selection could be set; otherwise returns - FALSE. - - \sa setFocus(), clearSelection() -*/ - -/*! - \fn void TQAccessibleInterface::clearSelection() - - Removes any selection from the object. - - \sa setSelected() -*/ - - - -/*! - \class TQAccessibleObject ntqaccessible.h - \brief The TQAccessibleObject class implements parts of the - TQAccessibleInterface for TQObjects. - - \ingroup misc - - This class is mainly provided for convenience. All subclasses of - the TQAccessibleInterface should use this class as the base class. -*/ - -/*! - Creates a TQAccessibleObject for \a object. -*/ -TQAccessibleObject::TQAccessibleObject( TQObject *object ) -: object_(object) -{ - if ( !qAccessibleInterface ) { - qAccessibleInterface = new AccessibleCache; - if ( !cleanupAdded ) { - tqAddPostRoutine( qAccessibleCleanup ); - cleanupAdded = TRUE; - } - } - - qAccessibleInterface->addObject(object, this); -} - -/*! - Destroys the TQAccessibleObject. - - This only happens when a call to release() decrements the internal - reference counter to zero. -*/ -TQAccessibleObject::~TQAccessibleObject() -{ - if ( qAccessibleInterface ) { - qAccessibleInterface->removeObject(object_); - if ( !qAccessibleInterface->count() ) { - delete qAccessibleInterface; - qAccessibleInterface = 0; - } - } -} - -/*! - \reimp -*/ -TQRESULT TQAccessibleObject::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) -{ - *iface = 0; - if ( uuid == IID_QAccessible ) - *iface = (TQAccessibleInterface*)this; - else if ( uuid == IID_QUnknown ) - *iface = (TQUnknownInterface*)this; - else - return TQE_NOINTERFACE; - - (*iface)->addRef(); - return TQS_OK; -} - -/*! - Returns the TQObject for which this TQAccessibleInterface - implementation provides information. Use isValid() to make sure - the object pointer is safe to use. -*/ -TQObject *TQAccessibleObject::object() const -{ -#if defined(QT_CHECK_RANGE) - if ( !isValid() ) - tqWarning( "TQAccessibleInterface is invalid. Crash pending..." ); -#endif - return object_; -} - -/*! - \reimp -*/ -bool TQAccessibleObject::isValid() const -{ - return !object_.isNull(); -} - -#endif diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 7abbbd56f..6e1926e45 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -46,14 +46,14 @@ #include "tqwidgetlist.h" #include "tqwidgetintdict.h" #include "tqptrdict.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqtranslator.h" #include "tqtextcodec.h" #include "tqsessionmanager.h" #include "tqdragobject.h" #include "tqclipboard.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqstyle.h" #include "tqstylefactory.h" #include "tqfile.h" diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index f3252b296..b611778d7 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -64,7 +64,7 @@ #include "ntqapplication.h" #include "qapplication_p.h" #include "tqcolor_p.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqwidget.h" #include "tqwidget_p.h" #include "tqobjectlist.h" @@ -446,7 +446,7 @@ int qt_visual_option = -1; bool qt_cmap_option = FALSE; TQWidget *qt_button_down = 0; // widget got last button-down -extern bool tqt_tryAccelEvent( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp +extern bool tqt_tryAccelEvent( TQWidget*, TQKeyEvent* ); // def in tqaccel.cpp struct TQScrollInProgress { static long serial; diff --git a/src/kernel/qasyncimageio.cpp b/src/kernel/qasyncimageio.cpp deleted file mode 100644 index c89036719..000000000 --- a/src/kernel/qasyncimageio.cpp +++ /dev/null @@ -1,1319 +0,0 @@ -/**************************************************************************** -** -** Implementation of asynchronous image/movie loading classes -** -** Created : 970617 -** -** 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 "ntqasyncimageio.h" - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -#include "tqptrlist.h" -#include "ntqgif.h" -#include - -extern void tqt_init_image_handlers(); -extern void tqt_init_image_plugins(); - -#define Q_TRANSPARENT 0x00ffffff - -/*! - \class TQImageConsumer ntqasyncimageio.h - \brief The TQImageConsumer class is an abstraction used by TQImageDecoder. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - The TQMovie class, or TQLabel::setMovie(), are easy to use and for - most situations do what you want with regards animated images. - - A TQImageConsumer consumes information about changes to the TQImage - maintained by a TQImageDecoder. Think of the TQImage as the model or - source of the image data, with the TQImageConsumer as a view of - that data and the TQImageDecoder being the controller that - orchestrates the relationship between the model and the view. - - You'd use the TQImageConsumer class, for example, if you were - implementing a web browser with your own image loaders. - - \sa TQImageDecoder -*/ - -/*! - \fn void TQImageConsumer::changed(const TQRect&) - - Called when the given area of the image has changed. -*/ - -/*! - \fn void TQImageConsumer::end() - - Called when all the data from all the frames has been decoded and - revealed as changed(). -*/ - -/*! - \fn void TQImageConsumer::frameDone() - - One of the two frameDone() functions will be called when a frame - of an animated image has ended and been revealed as changed(). - - When this function is called, the current image should be - displayed. - - The decoder will not make any further changes to the image until - the next call to TQImageFormat::decode(). -*/ - -/*! - \overload void TQImageConsumer::frameDone( const TQPoint& offset, const TQRect& rect ) - - One of the two frameDone() functions will be called when a frame - of an animated image has ended and been revealed as changed(). - - When this function is called, the area \a rect in the current - image should be moved by \a offset and displayed. - - The decoder will not make any further changes to the image until - the next call to TQImageFormat::decode(). -*/ - -/*! - \fn void TQImageConsumer::setLooping(int n) - - Called to indicate that the sequence of frames in the image - should be repeated \a n times, including the sequence during - decoding. - - \list - \i 0 = Forever - \i 1 = Only display frames the first time through - \i 2 = Repeat once after first pass through images - \i etc. - \endlist - - To make the TQImageDecoder do this, just delete it and pass the - information to it again for decoding (setLooping() will be called - again, of course, but that can be ignored), or keep copies of the - changed areas at the ends of frames. -*/ - -/*! - \fn void TQImageConsumer::setFramePeriod(int milliseconds) - - Notes that the frame about to be decoded should not be displayed - until the given number of \a milliseconds after the time that this - function is called. Of course, the image may not have been - decoded by then, in which case the frame should not be displayed - until it is complete. A value of -1 (the assumed default) - indicates that the image should be displayed even while it is only - partially loaded. -*/ - -/*! - \fn void TQImageConsumer::setSize(int, int) - - This function is called as soon as the size of the image has been - determined. -*/ - - -/*! - \class TQImageDecoder ntqasyncimageio.h - \brief The TQImageDecoder class is an incremental image decoder for all supported image formats. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - New formats are installed by creating objects of class - TQImageFormatType; the TQMovie class can be used for all installed - incremental image formats. TQImageDecoder is only useful for - creating new ways of feeding data to an TQImageConsumer. - - A TQImageDecoder is a machine that decodes images. It takes encoded - image data via its decode() method and expresses its decoding by - supplying information to a TQImageConsumer. It implements its - decoding by using a TQImageFormat created by one of the - currently-existing TQImageFormatType factory objects. - - TQImageFormatType and TQImageFormat are the classes that you might - need to implement support for additional image formats. - - \legalese - - TQt supports GIF reading if it is configured that way during - installation (see ntqgif.h). If it is, we are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - - \warning If you are in a country that recognizes software patents - and in which Unisys holds a patent on LZW compression and/or - decompression and you want to use GIF, Unisys may require you to - license that technology. Such countries include Canada, Japan, - the USA, France, Germany, Italy and the UK. - - GIF support may be removed completely in a future version of TQt. - We recommend using the MNG or PNG format. -*/ - -static const int max_header = 32; - - - - - -// See ntqgif.h for important information regarding this option -#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 -class TQGIFFormat : public TQImageFormat { -public: - TQGIFFormat(); - virtual ~TQGIFFormat(); - - int decode(TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length); - -private: - void fillRect(TQImage&, int x, int y, int w, int h, TQRgb col); - TQRgb color( uchar index ) const; - - // GIF specific stuff - TQRgb* globalcmap; - TQRgb* localcmap; - TQImage backingstore; - unsigned char hold[16]; - bool gif89; - int count; - int ccount; - int expectcount; - enum State { - Header, - LogicalScreenDescriptor, - GlobalColorMap, - LocalColorMap, - Introducer, - ImageDescriptor, - TableImageLZWSize, - ImageDataBlockSize, - ImageDataBlock, - ExtensionLabel, - GraphicControlExtension, - ApplicationExtension, - NetscapeExtensionBlockSize, - NetscapeExtensionBlock, - SkipBlockSize, - SkipBlock, - Done, - Error - } state; - int gncols; - int lncols; - int ncols; - int lzwsize; - bool lcmap; - int swidth, sheight; - int width, height; - int left, top, right, bottom; - enum Disposal { NoDisposal, DoNotChange, RestoreBackground, RestoreImage }; - Disposal disposal; - bool disposed; - int trans_index; - bool gcmap; - int bgcol; - int interlace; - int accum; - int bitcount; - - enum { max_lzw_bits=12 }; // (poor-compiler's static const int) - - int code_size, clear_code, end_code, max_code_size, max_code; - int firstcode, oldcode, incode; - short table[2][1<< max_lzw_bits]; - short stack[(1<<(max_lzw_bits))*2]; - short *sp; - bool needfirst; - int x, y; - int frame; - bool out_of_bounds; - bool digress; - void nextY(TQImage& img, TQImageConsumer* consumer); - void disposePrevious( TQImage& img, TQImageConsumer* consumer ); -}; - -class TQGIFFormatType : public TQImageFormatType -{ - TQImageFormat* decoderFor(const uchar* buffer, int length); - const char* formatName() const; -}; - -#endif - - -class TQImageDecoderPrivate -{ -public: - TQImageDecoderPrivate() - { - count = 0; - } - - static void cleanup(); - - static void ensureFactories() - { - if ( !factories ) { - factories = new TQPtrList; -// See ntqgif.h for important information regarding this option -#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 - gif_decoder_factory = new TQGIFFormatType; -#endif - tqt_init_image_handlers(); - tqAddPostRoutine( cleanup ); - } - } - - static TQPtrList * factories; - -// See ntqgif.h for important information regarding this option -#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 - static TQGIFFormatType * gif_decoder_factory; -#endif - - uchar header[max_header]; - int count; -}; - -TQPtrList * TQImageDecoderPrivate::factories = 0; -// See ntqgif.h for important information regarding this option -#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 -TQGIFFormatType * TQImageDecoderPrivate::gif_decoder_factory = 0; -#endif - - -void TQImageDecoderPrivate::cleanup() -{ - delete factories; - factories = 0; -// See ntqgif.h for important information regarding this option -#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 - delete gif_decoder_factory; - gif_decoder_factory = 0; -#endif -} - - -/*! - Constructs a TQImageDecoder that will send change information to - the TQImageConsumer \a c. -*/ -TQImageDecoder::TQImageDecoder(TQImageConsumer* c) -{ - tqt_init_image_handlers(); - d = new TQImageDecoderPrivate; - TQ_CHECK_PTR(d); - consumer = c; - actual_decoder = 0; -} - -/*! - Destroys a TQImageDecoder. The image it built is destroyed. The - decoder built by the factory for the file format is destroyed. The - consumer for which it decoded the image is \e not destroyed. -*/ -TQImageDecoder::~TQImageDecoder() -{ - delete d; - delete actual_decoder; -} - -/*! - \fn const TQImage& TQImageDecoder::image() - - Returns the image currently being decoded. -*/ - -static bool plugins_loaded = FALSE; - -/*! - Call this function to decode some data into image changes. The - data in \a buffer will be decoded, sending change information to - the TQImageConsumer of this TQImageDecoder until one of the change - functions of the consumer returns FALSE. The length of the data is - given in \a length. - - Returns the number of bytes consumed: 0 if consumption is - complete, and -1 if decoding fails due to invalid data. -*/ -int TQImageDecoder::decode(const uchar* buffer, int length) -{ - if (!actual_decoder) { - int i=0; - - while (i < length && d->count < max_header) - d->header[d->count++] = buffer[i++]; - - TQImageDecoderPrivate::ensureFactories(); - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !actual_decoder; - f = TQImageDecoderPrivate::factories->next()) - { - actual_decoder = f->decoderFor(d->header, d->count); - } - if ( !actual_decoder && !plugins_loaded) { - tqt_init_image_plugins(); - plugins_loaded = TRUE; - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !actual_decoder; - f = TQImageDecoderPrivate::factories->next()) - { - actual_decoder = f->decoderFor(d->header, d->count); - } - } - - if (!actual_decoder) { - if ( d->count < max_header ) { - // not enough info yet - return i; - } else { - // failure - nothing matches max_header bytes - return -1; - } - } - } - return actual_decoder->decode(img, consumer, buffer, length); -} - -/*! - Returns a TQImageFormatType by name. This might be used when the - user needs to force data to be interpreted as being in a certain - format. \a name is one of the formats listed by - TQImageDecoder::inputFormats(). Note that you will still need to - supply decodable data to result->decoderFor() before you can begin - decoding the data. -*/ -TQImageFormatType* TQImageDecoder::format( const char* name ) -{ - TQImageDecoderPrivate::ensureFactories(); - tqt_init_image_plugins(); - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f; - f = TQImageDecoderPrivate::factories->next()) - { - if ( tqstricmp(name,f->formatName())==0 ) - return f; - } - return 0; -} - -/*! - Call this function to find the name of the format of the given - header. The returned string is statically allocated. The function - will look at the first \a length characters in the \a buffer. - - Returns 0 if the format is not recognized. -*/ -const char* TQImageDecoder::formatName(const uchar* buffer, int length) -{ - TQImageDecoderPrivate::ensureFactories(); - - const char* name = 0; - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !name; - f = TQImageDecoderPrivate::factories->next()) - { - TQImageFormat *decoder = f->decoderFor(buffer, length); - if (decoder) { - name = f->formatName(); - delete decoder; - } - } - if ( !name && !plugins_loaded) { - tqt_init_image_plugins(); - plugins_loaded = TRUE; - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f && !name; - f = TQImageDecoderPrivate::factories->next()) - { - TQImageFormat *decoder = f->decoderFor(buffer, length); - if (decoder) { - name = f->formatName(); - delete decoder; - } - } - } - - return name; -} - -/*! - Returns a sorted list of formats for which asynchronous loading is - supported. -*/ -TQStrList TQImageDecoder::inputFormats() -{ - TQImageDecoderPrivate::ensureFactories(); - tqt_init_image_plugins(); - - TQStrList result; - - for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); - f; - f = TQImageDecoderPrivate::factories->next()) - { - if ( !result.contains( f->formatName() ) ) { - result.inSort( f->formatName() ); - } - } - - return result; -} - -/*! - Registers the new TQImageFormatType \a f. This is not needed in - application code because factories call this themselves. -*/ -void TQImageDecoder::registerDecoderFactory(TQImageFormatType* f) -{ - TQImageDecoderPrivate::ensureFactories(); - - TQImageDecoderPrivate::factories->insert(0,f); -} - -/*! - Unregisters the TQImageFormatType \a f. This is not needed in - application code because factories call this themselves. -*/ -void TQImageDecoder::unregisterDecoderFactory(TQImageFormatType* f) -{ - if ( !TQImageDecoderPrivate::factories ) - return; - - TQImageDecoderPrivate::factories->remove(f); -} - -/*! - \class TQImageFormat ntqasyncimageio.h - \brief The TQImageFormat class is an incremental image decoder for a specific image format. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - By making a derived class of TQImageFormatType, which in turn - creates objects that are a subclass of TQImageFormat, you can add - support for more incremental image formats, allowing such formats - to be sources for a TQMovie or for the first frame of the image - stream to be loaded as a TQImage or TQPixmap. - - Your new subclass must reimplement the decode() function in order - to process your new format. - - New TQImageFormat objects are generated by new TQImageFormatType - factories. -*/ - -/*! - Destroys the object. - - \internal - More importantly, destroys derived classes. -*/ -TQImageFormat::~TQImageFormat() -{ -} - -/*! - \fn int TQImageFormat::decode(TQImage& img, TQImageConsumer* consumer, const uchar* buffer, int length) - - New subclasses must reimplement this method. - - It should decode some or all of the bytes from \a buffer into \a - img, calling the methods of \a consumer as the decoding proceeds - to inform that consumer of changes to the image. The length of the - data is given in \a length. The consumer may be 0, in which case - the function should just process the data into \a img without - telling any consumer about the changes. Note that the decoder must - store enough state to be able to continue in subsequent calls to - this method - this is the essence of the incremental image - loading. - - The function should return without processing all the data if it - reaches the end of a frame in the input. - - The function must return the number of bytes it has processed. -*/ - -/*! - \class TQImageFormatType ntqasyncimageio.h - \brief The TQImageFormatType class is a factory that makes TQImageFormat objects. - - \ingroup images - \ingroup graphics - \ingroup multimedia - - Whereas the TQImageIO class allows for \e complete loading of - images, TQImageFormatType allows for \e incremental loading of - images. - - New image file formats are installed by creating objects of - derived classes of TQImageFormatType. They must implement - decoderFor() and formatName(). - - TQImageFormatType is a very simple class. Its only task is to - recognize image data in some format and make a new object, - subclassed from TQImageFormat, which can decode that format. - - The factories for formats built into TQt are automatically defined - before any other factory is initialized. If two factories would - recognize an image format, the factory created last will override - the earlier one; you can thus override current and future built-in - formats. -*/ - -/*! - \fn virtual TQImageFormat* TQImageFormatType::decoderFor(const uchar* buffer, int length) - - Returns a decoder for decoding an image that starts with the bytes - in \a buffer. The length of the data is given in \a length. This - function should only return a decoder if it is certain that the - decoder applies to data with the given header. Returns 0 if there - is insufficient data in the header to make a positive - identification or if the data is not recognized. -*/ - -/*! - \fn virtual const char* TQImageFormatType::formatName() const - - Returns the name of the format supported by decoders from this - factory. The string is statically allocated. -*/ - -/*! - Constructs a factory. It automatically registers itself with - TQImageDecoder. -*/ -TQImageFormatType::TQImageFormatType() -{ - TQImageDecoder::registerDecoderFactory(this); -} - -/*! - Destroys a factory. It automatically unregisters itself from - TQImageDecoder. -*/ -TQImageFormatType::~TQImageFormatType() -{ - TQImageDecoder::unregisterDecoderFactory(this); -} - - -/*! - Returns TRUE if TQt was compiled with built-in GIF reading support; - otherwise returns FALSE. -*/ -bool qt_builtin_gif_reader() -{ -#if defined(QT_BUILTIN_GIF_READER) - return QT_BUILTIN_GIF_READER == 1; -#else - return 0; -#endif -} - -// See ntqgif.h for important information regarding this option -#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 - -/* -- NOTDOC - \class TQGIFFormat ntqasyncimageio.h - \brief Incremental image decoder for GIF image format. - - \ingroup images - \ingroup graphics - - This subclass of TQImageFormat decodes GIF format images, - including animated GIFs. Internally in -*/ - -/*! - Constructs a TQGIFFormat. -*/ -TQGIFFormat::TQGIFFormat() -{ - globalcmap = 0; - localcmap = 0; - lncols = 0; - gncols = 0; - disposal = NoDisposal; - out_of_bounds = FALSE; - disposed = TRUE; - frame = -1; - state = Header; - count = 0; - lcmap = FALSE; -} - -/*! - Destroys a TQGIFFormat. -*/ -TQGIFFormat::~TQGIFFormat() -{ - if (globalcmap) delete[] globalcmap; - if ( localcmap ) delete[] localcmap; -} - - -/* -- NOTDOC - \class TQGIFFormatType ntqasyncimageio.h - \brief Incremental image decoder for GIF image format. - - \ingroup images - \ingroup graphics - - This subclass of TQImageFormatType recognizes GIF - format images, creating a TQGIFFormat when required. An instance - of this class is created automatically before any other factories, - so you should have no need for such objects. -*/ - -TQImageFormat* TQGIFFormatType::decoderFor( - const uchar* buffer, int length) -{ - if (length < 6) return 0; - if (buffer[0]=='G' - && buffer[1]=='I' - && buffer[2]=='F' - && buffer[3]=='8' - && (buffer[4]=='9' || buffer[4]=='7') - && buffer[5]=='a') - return new TQGIFFormat; - return 0; -} - -const char* TQGIFFormatType::formatName() const -{ - return "GIF"; -} - - -void TQGIFFormat::disposePrevious( TQImage& img, TQImageConsumer* consumer ) -{ - if ( out_of_bounds ) // flush anything that survived - consumer->changed(TQRect(0,0,swidth,sheight)); - - // Handle disposal of previous image before processing next one - - if ( disposed ) return; - - int l = TQMIN(swidth-1,left); - int r = TQMIN(swidth-1,right); - int t = TQMIN(sheight-1,top); - int b = TQMIN(sheight-1,bottom); - - switch (disposal) { - case NoDisposal: - break; - case DoNotChange: - break; - case RestoreBackground: - if (trans_index>=0) { - // Easy: we use the transparent color - fillRect(img, l, t, r-l+1, b-t+1, Q_TRANSPARENT); - } else if (bgcol>=0) { - // Easy: we use the bgcol given - fillRect(img, l, t, r-l+1, b-t+1, color(bgcol)); - } else { - // Impossible: We don't know of a bgcol - use pixel 0 - TQRgb** line = (TQRgb **)img.jumpTable(); - fillRect(img, l, t, r-l+1, b-t+1, line[0][0]); - } - if (consumer) - consumer->changed(TQRect(l, t, r-l+1, b-t+1)); - break; - case RestoreImage: { - if ( frame >= 0 ) { - TQRgb** line = (TQRgb **)img.jumpTable(); - for (int ln=t; ln<=b; ln++) { - memcpy(line[ln]+l, - backingstore.scanLine(ln-t), - (r-l+1)*sizeof(TQRgb) ); - } - consumer->changed(TQRect(l, t, r-l+1, b-t+1)); - } - } - } - disposal = NoDisposal; // Until an extension says otherwise. - - disposed = TRUE; -} - -/*! - This function decodes some data into image changes. - - Returns the number of bytes consumed. -*/ -int TQGIFFormat::decode(TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length) -{ - // We are required to state that - // "The Graphics Interchange Format(c) is the Copyright property of - // CompuServe Incorporated. GIF(sm) is a Service Mark property of - // CompuServe Incorporated." - -#define LM(l, m) (((m)<<8)|l) - digress = FALSE; - int initial = length; - TQRgb** line = (TQRgb **)img.jumpTable(); - while (!digress && length) { - length--; - unsigned char ch=*buffer++; - switch (state) { - case Header: - hold[count++]=ch; - if (count==6) { - // Header - gif89=(hold[3]!='8' || hold[4]!='7'); - state=LogicalScreenDescriptor; - count=0; - } - break; - case LogicalScreenDescriptor: - hold[count++]=ch; - if (count==7) { - // Logical Screen Descriptor - swidth=LM(hold[0], hold[1]); - sheight=LM(hold[2], hold[3]); - gcmap=!!(hold[4]&0x80); - //UNUSED: bpchan=(((hold[4]&0x70)>>3)+1); - //UNUSED: gcmsortflag=!!(hold[4]&0x08); - gncols=2<<(hold[4]&0x7); - bgcol=(gcmap) ? hold[5] : -1; - //aspect=hold[6] ? double(hold[6]+15)/64.0 : 1.0; - - trans_index = -1; - count=0; - ncols=gncols; - if (gcmap) { - ccount=0; - state=GlobalColorMap; - globalcmap = new TQRgb[gncols+1]; // +1 for trans_index - globalcmap[gncols] = Q_TRANSPARENT; - } else { - state=Introducer; - } - } - break; - case GlobalColorMap: case LocalColorMap: - hold[count++]=ch; - if (count==3) { - TQRgb rgb = tqRgb(hold[0], hold[1], hold[2]); - if ( state == LocalColorMap ) { - if ( ccount < lncols ) - localcmap[ccount] = rgb; - } else { - globalcmap[ccount] = rgb; - } - if (++ccount >= ncols) { - if ( state == LocalColorMap ) - state=TableImageLZWSize; - else - state=Introducer; - } - count=0; - } - break; - case Introducer: - hold[count++]=ch; - switch (ch) { - case ',': - state=ImageDescriptor; - break; - case '!': - state=ExtensionLabel; - break; - case ';': - if (consumer) { - if ( out_of_bounds ) // flush anything that survived - consumer->changed(TQRect(0,0,swidth,sheight)); - consumer->end(); - } - state=Done; - break; - default: - digress=TRUE; - // Unexpected Introducer - ignore block - state=Error; - } - break; - case ImageDescriptor: - hold[count++]=ch; - if (count==10) { - int newleft=LM(hold[1], hold[2]); - int newtop=LM(hold[3], hold[4]); - int newwidth=LM(hold[5], hold[6]); - int newheight=LM(hold[7], hold[8]); - - // disbelieve ridiculous logical screen sizes, - // unless the image frames are also large. - if ( swidth/10 > TQMAX(newwidth,200) ) - swidth = -1; - if ( sheight/10 > TQMAX(newheight,200) ) - sheight = -1; - - if ( swidth <= 0 ) - swidth = newleft + newwidth; - if ( sheight <= 0 ) - sheight = newtop + newheight; - - if (img.isNull()) { - if (!img.create(swidth, sheight, 32)) { - // Check if the attempt to create the image failed. If - // it did, the image is broken and we should give up. - state = Error; - return -1; - } - memset( img.bits(), 0, img.numBytes() ); - if (consumer) consumer->setSize(swidth, sheight); - } - img.setAlphaBuffer(trans_index >= 0); - line = (TQRgb **)img.jumpTable(); - - disposePrevious( img, consumer ); - disposed = FALSE; - - left = newleft; - top = newtop; - width = newwidth; - height = newheight; - - right=TQMAX( 0, TQMIN(left+width, swidth)-1); - bottom=TQMAX(0, TQMIN(top+height, sheight)-1); - lcmap=!!(hold[9]&0x80); - interlace=!!(hold[9]&0x40); - //bool lcmsortflag=!!(hold[9]&0x20); - lncols=lcmap ? (2<<(hold[9]&0x7)) : 0; - if (lncols) { - if ( localcmap ) - delete [] localcmap; - localcmap = new TQRgb[lncols+1]; - localcmap[lncols] = Q_TRANSPARENT; - ncols = lncols; - } else { - ncols = gncols; - } - frame++; - if ( frame == 0 ) { - if ( left || top || width= 0 ) { - fillRect(img, 0, 0, swidth, sheight, color(trans_index)); - if (consumer) consumer->changed(TQRect(0,0,swidth,sheight)); - } else if ( bgcol>=0 ) { - fillRect(img, 0, 0, swidth, sheight, color(bgcol)); - if (consumer) consumer->changed(TQRect(0,0,swidth,sheight)); - } - } - } - - if ( disposal == RestoreImage ) { - int l = TQMIN(swidth-1,left); - int r = TQMIN(swidth-1,right); - int t = TQMIN(sheight-1,top); - int b = TQMIN(sheight-1,bottom); - int w = r-l+1; - int h = b-t+1; - - if (backingstore.width() < w - || backingstore.height() < h) { - // We just use the backing store as a byte array - if(!backingstore.create( TQMAX(backingstore.width(), w), - TQMAX(backingstore.height(), h), - 32)) { - state = Error; - return -1; - } - memset( img.bits(), 0, img.numBytes() ); - } - for (int ln=0; ln=swidth || y>=sheight; - } - break; - case TableImageLZWSize: { - lzwsize=ch; - if ( lzwsize > max_lzw_bits ) { - state=Error; - } else { - code_size=lzwsize+1; - clear_code=1<frameDone(); - digress = TRUE; - } - - state=Introducer; - } - break; - case ImageDataBlock: - count++; - accum|=(ch<=code_size && state==ImageDataBlock) { - int code=accum&((1<>=code_size; - - if (code==clear_code) { - if (!needfirst) { - int i; - code_size=lzwsize+1; - max_code_size=2*clear_code; - max_code=clear_code+2; - for (i=0; i=swidth) out_of_bounds = TRUE; - needfirst=FALSE; - if (x>=left+width) { - x=left; - out_of_bounds = left>=swidth || y>=sheight; - nextY(img,consumer); - } - } else { - incode=code; - if (code>=max_code) { - *sp++=firstcode; - code=oldcode; - } - while (code>=clear_code) { - *sp++=table[1][code]; - if (code==table[0][code]) { - state=Error; - break; - } - if (sp-stack>=(1<<(max_lzw_bits))*2) { - state=Error; - break; - } - code=table[0][code]; - } - *sp++=firstcode=table[1][code]; - code=max_code; - if (code<(1<=max_code_size) - && (max_code_size<(1<stack) { - --sp; - if (!out_of_bounds && line && *sp!=trans_index) - line[y][x] = color(*sp); - x++; - if (x>=swidth) out_of_bounds = TRUE; - if (x>=left+width) { - x=left; - out_of_bounds = left>=swidth || y>=sheight; - nextY(img,consumer); - } - } - } - } - } - if (count==expectcount) { - count=0; - state=ImageDataBlockSize; - } - break; - case ExtensionLabel: - switch (ch) { - case 0xf9: - state=GraphicControlExtension; - break; - case 0xff: - state=ApplicationExtension; - break; -#if 0 - case 0xfe: - state=CommentExtension; - break; - case 0x01: - break; -#endif - default: - state=SkipBlockSize; - } - count=0; - break; - case ApplicationExtension: - if (count<11) hold[count]=ch; - count++; - if (count==hold[0]+1) { - if (tqstrncmp((char*)(hold+1), "NETSCAPE", 8)==0) { - // Looping extension - state=NetscapeExtensionBlockSize; - } else { - state=SkipBlockSize; - } - count=0; - } - break; - case NetscapeExtensionBlockSize: - expectcount=ch; - count=0; - if (expectcount) state=NetscapeExtensionBlock; - else state=Introducer; - break; - case NetscapeExtensionBlock: - if (count<3) hold[count]=ch; - count++; - if (count==expectcount) { - int loop = hold[0]+hold[1]*256; - if (consumer) consumer->setLooping(loop); - state=SkipBlockSize; // Ignore further blocks - } - break; - case GraphicControlExtension: - if (count<5) hold[count]=ch; - count++; - if (count==hold[0]+1) { - disposePrevious( img, consumer ); - disposal=Disposal((hold[1]>>2)&0x7); - //UNUSED: waitforuser=!!((hold[1]>>1)&0x1); - int delay=count>3 ? LM(hold[2], hold[3]) : 1; - // IE and mozilla use a minimum delay of 10. With the minumum delay of 10 - // we are compatible to them and avoid huge loads on the app and xserver. - if ( delay < 10 ) - delay = 10; - - bool havetrans=hold[1]&0x1; - trans_index = havetrans ? hold[4] : -1; - - if (consumer) consumer->setFramePeriod(delay*10); - count=0; - state=SkipBlockSize; - } - break; - case SkipBlockSize: - expectcount=ch; - count=0; - if (expectcount) state=SkipBlock; - else state=Introducer; - break; - case SkipBlock: - count++; - if (count==expectcount) state=SkipBlockSize; - break; - case Done: - digress=TRUE; - /* Netscape ignores the junk, so we do too. - length++; // Unget - state=Error; // More calls to this is an error - */ - break; - case Error: - return -1; // Called again after done. - } - } - return initial-length; -} - -void TQGIFFormat::fillRect(TQImage& img, int col, int row, int w, int h, TQRgb color) -{ - if (w>0) { - TQRgb** line = (TQRgb **)img.jumpTable() + row; - for (int j=0; jchanged(TQRect(left, y, right-left+1, 1)); - y++; - break; - case 1: - { - int i; - my = TQMIN(7, bottom-y); - if ( trans_index < 0 ) // Don't dup with transparency - for (i=1; i<=my; i++) - memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, - (right-left+1)*sizeof(TQRgb)); - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, my+1)); - y+=8; - if (y>bottom) { - interlace++; y=top+4; - if (y > bottom) { // for really broken GIFs with bottom < 5 - interlace=2; - y = top + 2; - if (y > bottom) { // for really broken GIF with bottom < 3 - interlace = 0; - y = top + 1; - } - } - } - } break; - case 2: - { - int i; - my = TQMIN(3, bottom-y); - if ( trans_index < 0 ) // Don't dup with transparency - for (i=1; i<=my; i++) - memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, - (right-left+1)*sizeof(TQRgb)); - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, my+1)); - y+=8; - if (y>bottom) { - interlace++; y=top+2; - if (y > bottom) { // for really broken GIF with bottom < 3 - interlace = 3; - y = top + 1; - } - } - } break; - case 3: - { - int i; - my = TQMIN(1, bottom-y); - if ( trans_index < 0 ) // Don't dup with transparency - for (i=1; i<=my; i++) - memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, - (right-left+1)*sizeof(TQRgb)); - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, my+1)); - y+=4; - if (y>bottom) { interlace++; y=top+1; } - } break; - case 4: - if (consumer && !out_of_bounds) - consumer->changed(TQRect(left, y, right-left+1, 1)); - y+=2; - } - - // Consume bogus extra lines - if (y >= sheight) out_of_bounds=TRUE; //y=bottom; -} - -TQRgb TQGIFFormat::color( uchar index ) const -{ - if ( index == trans_index || index > ncols ) - return Q_TRANSPARENT; - TQRgb *map = lcmap ? localcmap : globalcmap; - return map ? map[index] : 0; -} - - - -#endif // QT_BUILTIN_GIF_READER - -#endif // TQT_NO_ASYNC_IMAGE_IO diff --git a/src/kernel/qasyncio.cpp b/src/kernel/qasyncio.cpp deleted file mode 100644 index 4d3acff73..000000000 --- a/src/kernel/qasyncio.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/**************************************************************************** -** -** Implementation of asynchronous I/O classes -** -** Created : 970617 -** -** 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 "ntqasyncio.h" -#include "tqiodevice.h" -#include - -#ifndef TQT_NO_ASYNC_IO - -/*! - \class TQAsyncIO ntqasyncio.h - \obsolete - \brief The TQAsyncIO class encapsulates I/O asynchronicity. - - The TQt classes for asynchronous input/output provide a simple - mechanism to allow large files or slow data sources to be processed - without using large amounts of memory or blocking the user interface. - - This facility is used in TQt to drive animated images. See TQImageConsumer. -*/ - - -/*! - Destroys the async IO object. -*/ -TQAsyncIO::~TQAsyncIO() -{ -} - -/*! - Ensures that only one object, \a obj and function, \a member, can - respond to changes in readiness. -*/ -void TQAsyncIO::connect(TQObject* obj, const char *member) -{ - signal.disconnect(0, 0); - signal.connect(obj, member); -} - -/*! - Derived classes should call this when they change from being - unready to ready. -*/ -void TQAsyncIO::ready() -{ - signal.activate(); -} - - - -/*! - \class TQDataSink ntqasyncio.h - \obsolete - \brief The TQDataSink class is an asynchronous consumer of data. - - A data sink is an object which receives data from some source in an - asynchronous manner. This means that at some time not determined by - the data sink, blocks of data are given to it from processing. The - data sink is able to limit the maximum size of such blocks which it - is currently able to process. - - \sa TQAsyncIO, TQDataSource, TQDataPump -*/ - -/*! - \fn int TQDataSink::readyToReceive() - - The data sink should return a value indicating how much data it is ready - to consume. This may be 0. -*/ - -/*! - This should be called whenever readyToReceive() might have become non-zero. - It is merely calls TQAsyncIO::ready() if readyToReceive() is non-zero. -*/ -void TQDataSink::maybeReady() -{ - if (readyToReceive()) ready(); -} - -/*! - \fn void TQDataSink::receive(const uchar*, int count) - - This function is called to provide data for the data sink. The \a count - will be no more than the amount indicated by the most recent call to - readyToReceive(). The sink must use all the provided data. -*/ - -/*! - \fn void TQDataSink::eof() - - This function will be called when no more data is available for - processing. -*/ - - -/*! - \class TQDataSource ntqasyncio.h - \obsolete - \brief The TQDataSource class is an asynchronous producer of data. - - A data source is an object which provides data from some source in an - asynchronous manner. This means that at some time not determined by - the data source, blocks of data will be taken from it for processing. - The data source is able to limit the maximum size of such blocks which - it is currently able to provide. - - \sa TQAsyncIO, TQDataSink, TQDataPump -*/ - -/*! - \fn int TQDataSource::readyToSend() - - The data source should return a value indicating how much data it is ready - to provide. This may be 0. If the data source knows it will never be - able to provide any more data (until after a rewind()), it may return -1. -*/ - -/*! - This should be called whenever readyToSend() might have become non-zero. - It is merely calls TQAsyncIO::ready() if readyToSend() is non-zero. -*/ -void TQDataSource::maybeReady() -{ - if (readyToSend()) ready(); -} - -/*! - \fn void TQDataSource::sendTo(TQDataSink*, int count) - - This function is called to extract data from the source, by sending - it to the given data sink. The \a count will be no more than the amount - indicated by the most recent call to readyToSend(). The source must - use all the provided data, and the sink will be prepared to accept at - least this much data. -*/ - -/*! - This function should return TRUE if the data source can be rewound. - - The default returns FALSE. -*/ -bool TQDataSource::rewindable() const -{ - return FALSE; -} - -/*! - If this function is called with \a on set to TRUE, and rewindable() - is TRUE, then the data source must take measures to allow the rewind() - function to subsequently operate as described. If rewindable() is FALSE, - the function should call TQDataSource::enableRewind(), which aborts with - a tqFatal() error. - - For example, a network connection may choose to use a disk cache - of input only if rewinding is enabled before the first buffer-full of - data is discarded, returning FALSE in rewindable() if that first buffer - is discarded. -*/ -void TQDataSource::enableRewind( bool /* on */ ) -{ - tqFatal( "Attempted to make unrewindable TQDataSource rewindable" ); -} - -/*! - This function rewinds the data source. This may only be called if - enableRewind(TRUE) has been previously called. -*/ -void TQDataSource::rewind() -{ - tqFatal("Attempted to rewind unrewindable TQDataSource"); -} - -/*! - \class TQIODeviceSource ntqasyncio.h - \obsolete - \brief The TQIODeviceSource class is a TQDataSource that draws data from a TQIODevice. - - This class encapsulates retrieving data from a TQIODevice (such as a TQFile). -*/ - -/*! - Constructs a TQIODeviceSource from the TQIODevice \a device. The TQIODevice - \e must be dynamically allocated, becomes owned by the TQIODeviceSource, - and will be deleted when the TQIODeviceSource is destroyed. \a buffer_size - determines the size of buffering to use between asynchronous operations. - The higher the \a buffer_size, the more efficient, but the less interleaved - the operation will be with other processing. -*/ -TQIODeviceSource::TQIODeviceSource(TQIODevice* device, int buffer_size) : - buf_size(buffer_size), - buffer(new uchar[buf_size]), - iod(device), - rew(FALSE) -{ -} - -/*! - Destroys the TQIODeviceSource, deleting the TQIODevice from which it was - constructed. -*/ -TQIODeviceSource::~TQIODeviceSource() -{ - delete iod; - delete [] buffer; -} - -/*! - Ready until end-of-file. -*/ -int TQIODeviceSource::readyToSend() -{ - if ( iod->status() != IO_Ok || !(iod->state() & IO_Open) ) - return -1; - - int n = TQMIN((uint)buf_size, iod->size()-iod->at()); // ### not 64-bit safe - // ### not large file safe - return n ? n : -1; -} - -/*! - Reads a block of data and sends up to \a n bytes to the \a sink. -*/ -void TQIODeviceSource::sendTo(TQDataSink* sink, int n) -{ - iod->readBlock((char*)buffer, n); - sink->receive(buffer, n); -} - -/*! - All TQIODeviceSource's are rewindable. -*/ -bool TQIODeviceSource::rewindable() const -{ - return TRUE; -} - -/*! - If \a on is set to TRUE then rewinding is enabled. - No special action is taken. If \a on is set to - FALSE then rewinding is disabled. -*/ -void TQIODeviceSource::enableRewind(bool on) -{ - rew = on; -} - -/*! - Calls reset() on the TQIODevice. -*/ -void TQIODeviceSource::rewind() -{ - if (!rew) { - TQDataSource::rewind(); - } else { - iod->reset(); - ready(); - } -} - - -/*! - \class TQDataPump ntqasyncio.h - \obsolete - \brief The TQDataPump class moves data from a TQDataSource to a TQDataSink during event processing. - - For a TQDataSource to provide data to a TQDataSink, a controller must exist - to examine the TQDataSource::readyToSend() and TQDataSink::readyToReceive() - methods and respond to the TQASyncIO::activate() signal of the source and - sink. One very useful way to do this is interleaved with other event - processing. TQDataPump provides this - create a pipe between a source - and a sink, and data will be moved during subsequent event processing. - - Note that each source can only provide data to one sink and each sink - can only receive data from one source (although it is quite possible - to write a multiplexing sink that is multiple sources). -*/ - -/*! - Constructs a TQDataPump to move data from a given \a data_source - to a given \a data_sink. -*/ -TQDataPump::TQDataPump(TQDataSource* data_source, TQDataSink* data_sink) : - source(data_source), sink(data_sink) -{ - source->connect(this, TQ_SLOT(kickStart())); - sink->connect(this, TQ_SLOT(kickStart())); - connect(&timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(tryToPump())); - timer.start(0, TRUE); -} - -void TQDataPump::kickStart() -{ - if (!timer.isActive()) { - interval = 0; - timer.start(0, TRUE); - } -} - -void TQDataPump::tryToPump() -{ - int supply, demand; - - supply = source->readyToSend(); - demand = sink->readyToReceive(); - if (demand <= 0) { - return; - } - interval = 0; - if (supply < 0) { - // All done (until source signals change in readiness) - sink->eof(); - return; - } - if (!supply) - return; - source->sendTo(sink, TQMIN(supply, demand)); - - timer.start(0, TRUE); -} - -#endif // TQT_NO_ASYNC_IO - diff --git a/src/kernel/qconnection.cpp b/src/kernel/qconnection.cpp deleted file mode 100644 index b30a76413..000000000 --- a/src/kernel/qconnection.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQConnection class -** -** Created : 930417 -** -** 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 "ntqconnection.h" - -/*! \class TQConnection ntqconnection.h - \brief The TQConnection class is an internal class, used in the signal/slot mechanism. - - \internal - - Do not use this class directly in application programs. - - TQObject has a list of TQConnection for each signal that is connected to the - outside world. -*/ - -TQConnection::TQConnection( const TQObject *object, int member, - const char *memberName, int memberType ) -{ - obj = (TQObject *)object; - mbr = member; - mbr_name = memberName; - mbr_type = memberType; - nargs = 0; - if ( strstr(memberName,"()") == 0 ) { - const char *p = memberName; - nargs++; - while ( *p ) { - if ( *p++ == ',' ) - nargs++; - } - } -} - -/*! - \fn TQConnection::~TQConnection() -*/ - -/*! - \fn bool TQConnection::isConnected() const -*/ - -/*! - \fn TQObject *TQConnection::object() const -*/ - -/*! - \fn int TQConnection::member() const -*/ - -/*! - \fn const char *TQConnection::memberName() const -*/ - -/*! - \fn int TQConnection::numArgs() const -*/ diff --git a/src/kernel/qcursor.cpp b/src/kernel/qcursor.cpp deleted file mode 100644 index 08100ccb7..000000000 --- a/src/kernel/qcursor.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQCursor class -** -** Created : 940220 -** -** 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 "ntqcursor.h" - -#ifndef TQT_NO_CURSOR - -#include "tqbitmap.h" -#include "tqimage.h" -#include "tqdatastream.h" - - -/*! - \class TQCursor ntqcursor.h - - \brief The TQCursor class provides a mouse cursor with an arbitrary - shape. - - \ingroup appearance - \ingroup shared - - This class is mainly used to create mouse cursors that are - associated with particular widgets and to get and set the position - of the mouse cursor. - - TQt has a number of standard cursor shapes, but you can also make - custom cursor shapes based on a TQBitmap, a mask and a hotspot. - - To associate a cursor with a widget, use TQWidget::setCursor(). To - associate a cursor with all widgets (normally for a short period - of time), use TQApplication::setOverrideCursor(). - - To set a cursor shape use TQCursor::setShape() or use the TQCursor - constructor which takes the shape as argument, or you can use one - of the predefined cursors defined in the \l CursorShape enum. - - If you want to create a cursor with your own bitmap, either use - the TQCursor constructor which takes a bitmap and a mask or the - constructor which takes a pixmap as arguments. - - To set or get the position of the mouse cursor use the static - methods TQCursor::pos() and TQCursor::setPos(). - - \img cursors.png Cursor Shapes - - \sa TQWidget \link guibooks.html#fowler GUI Design Handbook: - Cursors\endlink - - On X11, TQt supports the \link - http://www.xfree86.org/4.3.0/Xcursor.3.html Xcursor\endlink - library, which allows for full color icon themes. The table below - shows the cursor name used for each TQt::CursorShape value. If a - cursor cannot be found using the name shown below, a standard X11 - cursor will be used instead. Note: X11 does not provide - appropriate cursors for all possible TQt::CursorShape values. It - is possible that some cursors will be taken from the Xcursor - theme, while others will use an internal bitmap cursor. - - \table - \header \i TQt::CursorShape Values \i Cursor Names - \row \i TQt::ArrowCursor \i left_ptr - \row \i TQt::UpArrowCursor \i up_arrow - \row \i TQt::CrossCursor \i cross - \row \i TQt::WaitCursor \i wait - \row \i TQt::BusyCursor \i left_ptr_watch - \row \i TQt::IbeamCursor \i ibeam - \row \i TQt::SizeVerCursor \i size_ver - \row \i TQt::SizeHorCursor \i size_hor - \row \i TQt::SizeBDiagCursor \i size_bdiag - \row \i TQt::SizeFDiagCursor \i size_fdiag - \row \i TQt::SizeAllCursor \i size_all - \row \i TQt::SplitVCursor \i split_v - \row \i TQt::SplitHCursor \i split_h - \row \i TQt::PointingHandCursor \i pointing_hand - \row \i TQt::ForbiddenCursor \i forbidden - \row \i TQt::WhatsThisCursor \i whats_this - \endtable -*/ - -/*! - \enum TQt::CursorShape - - This enum type defines the various cursors that can be used. - - \value ArrowCursor standard arrow cursor - \value UpArrowCursor upwards arrow - \value CrossCursor crosshair - \value WaitCursor hourglass/watch - \value BusyCursor standard arrow with hourglass/watch - \value IbeamCursor ibeam/text entry - \value SizeVerCursor vertical resize - \value SizeHorCursor horizontal resize - \value SizeFDiagCursor diagonal resize (\) - \value SizeBDiagCursor diagonal resize (/) - \value SizeAllCursor all directions resize - \value BlankCursor blank/invisible cursor - \value SplitVCursor vertical splitting - \value SplitHCursor horizontal splitting - \value PointingHandCursor a pointing hand - \value ForbiddenCursor a slashed circle - \value WhatsThisCursor an arrow with a question mark - \value BitmapCursor - - ArrowCursor is the default for widgets in a normal state. - - \img cursors.png Cursor Shapes -*/ - -/***************************************************************************** - TQCursor stream functions - *****************************************************************************/ - -#ifndef TQT_NO_DATASTREAM - - -/*! - \relates TQCursor - Writes the cursor \a c to the stream \a s. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQCursor &c ) -{ - s << (TQ_INT16)c.shape(); // write shape id to stream - if ( c.shape() == TQt::BitmapCursor ) { // bitmap cursor -#if !defined(TQT_NO_IMAGEIO) - s << *c.bitmap() << *c.mask(); - s << c.hotSpot(); -#else - tqWarning("No Image Cursor I/O"); -#endif - } - return s; -} - -/*! - \relates TQCursor - Reads a cursor from the stream \a s and sets \a c to the read data. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQCursor &c ) -{ - TQ_INT16 shape; - s >> shape; // read shape id from stream - if ( shape == TQt::BitmapCursor ) { // read bitmap cursor -#if !defined(TQT_NO_IMAGEIO) - TQBitmap bm, bmm; - TQPoint hot; - s >> bm >> bmm >> hot; - c = TQCursor( bm, bmm, hot.x(), hot.y() ); -#else - tqWarning("No Image Cursor I/O"); -#endif - } else { - c.setShape( (int)shape ); // create cursor with shape - } - return s; -} -#endif // TQT_NO_DATASTREAM - - -/*! - Constructs a custom pixmap cursor. - - \a pixmap is the image. It is usual to give it a mask (set using - TQPixmap::setMask()). \a hotX and \a hotY define the cursor's hot - spot. - - If \a hotX is negative, it is set to the \c{pixmap().width()/2}. - If \a hotY is negative, it is set to the \c{pixmap().height()/2}. - - Valid cursor sizes depend on the display hardware (or the - underlying window system). We recommend using 32x32 cursors, - because this size is supported on all platforms. Some platforms - also support 16x16, 48x48 and 64x64 cursors. - - Currently, only black-and-white pixmaps can be used. - - \sa TQPixmap::TQPixmap(), TQPixmap::setMask() -*/ - -TQCursor::TQCursor( const TQPixmap &pixmap, int hotX, int hotY ) -{ - TQImage img = pixmap.convertToImage(). - convertDepth( 8, TQt::ThresholdDither|TQt::AvoidDither ); - TQBitmap bm; - bm.convertFromImage( img, TQt::ThresholdDither|TQt::AvoidDither ); - TQBitmap bmm; - if ( bm.mask() ) { - bmm = *bm.mask(); - TQBitmap nullBm; - bm.setMask( nullBm ); - } - else if ( pixmap.mask() ) { - TQImage mimg = pixmap.mask()->convertToImage(). - convertDepth( 8, TQt::ThresholdDither|TQt::AvoidDither ); - bmm.convertFromImage( mimg, TQt::ThresholdDither|TQt::AvoidDither ); - } - else { - bmm.resize( bm.size() ); - bmm.fill( TQt::color1 ); - } - - setBitmap(bm,bmm,hotX,hotY); -} - - - -/*! - Constructs a custom bitmap cursor. - - \a bitmap and - \a mask make up the bitmap. - \a hotX and - \a hotY define the cursor's hot spot. - - If \a hotX is negative, it is set to the \c{bitmap().width()/2}. - If \a hotY is negative, it is set to the \c{bitmap().height()/2}. - - The cursor \a bitmap (B) and \a mask (M) bits are combined like this: - \list - \i B=1 and M=1 gives black. - \i B=0 and M=1 gives white. - \i B=0 and M=0 gives transparent. - \i B=1 and M=0 gives an undefined result. - \endlist - - Use the global TQt color \c color0 to draw 0-pixels and \c color1 to - draw 1-pixels in the bitmaps. - - Valid cursor sizes depend on the display hardware (or the - underlying window system). We recommend using 32x32 cursors, - because this size is supported on all platforms. Some platforms - also support 16x16, 48x48 and 64x64 cursors. - - \sa TQBitmap::TQBitmap(), TQBitmap::setMask() -*/ - -TQCursor::TQCursor( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX, int hotY ) -{ - setBitmap(bitmap,mask,hotX,hotY); -} - -#endif // TQT_NO_CURSOR - - diff --git a/src/kernel/qcursor_x11.cpp b/src/kernel/qcursor_x11.cpp deleted file mode 100644 index dffa45ce6..000000000 --- a/src/kernel/qcursor_x11.cpp +++ /dev/null @@ -1,833 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQCursor class for X11 -** -** Created : 940219 -** -** 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 "ntqcursor.h" -#include "tqbitmap.h" -#include "tqimage.h" -#include "ntqapplication.h" -#include "tqdatastream.h" -#include "ntqnamespace.h" -#include "qt_x11_p.h" -#include - -#ifndef TQT_NO_XCURSOR -# include -#endif // TQT_NO_XCURSOR - -// Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to -// use the ugly X11 cursors. - -/***************************************************************************** - Internal TQCursorData class - *****************************************************************************/ - -struct TQCursorData : public TQShared -{ - TQCursorData( int s = 0 ); - ~TQCursorData(); - int cshape; - TQBitmap *bm, *bmm; - short hx, hy; - XColor fg,bg; - Cursor hcurs; - Pixmap pm, pmm; -}; - -TQCursorData::TQCursorData( int s ) -{ - cshape = s; - hcurs = 0; - bm = bmm = 0; - hx = hy = 0; - pm = pmm = 0; -} - -TQCursorData::~TQCursorData() -{ - Display *dpy = TQPaintDevice::x11AppDisplay(); - - // Add in checking for the display too as on HP-UX - // we seem to get a core dump as the cursor data is - // deleted again from main() on exit... - if ( hcurs && dpy ) - XFreeCursor( dpy, hcurs ); - if ( pm && dpy ) - XFreePixmap( dpy, pm ); - if ( pmm && dpy ) - XFreePixmap( dpy, pmm ); - delete bm; - delete bmm; -} - - -/***************************************************************************** - Global cursors - *****************************************************************************/ - -static TQCursor cursorTable[TQt::LastCursor+1]; - -static const int arrowCursorIdx = 0; - -const TQCursor & TQt::arrowCursor = cursorTable[0]; -const TQCursor & TQt::upArrowCursor = cursorTable[1]; -const TQCursor & TQt::crossCursor = cursorTable[2]; -const TQCursor & TQt::waitCursor = cursorTable[3]; -const TQCursor & TQt::ibeamCursor = cursorTable[4]; -const TQCursor & TQt::sizeVerCursor = cursorTable[5]; -const TQCursor & TQt::sizeHorCursor = cursorTable[6]; -const TQCursor & TQt::sizeBDiagCursor = cursorTable[7]; -const TQCursor & TQt::sizeFDiagCursor = cursorTable[8]; -const TQCursor & TQt::sizeAllCursor = cursorTable[9]; -const TQCursor & TQt::blankCursor = cursorTable[10]; -const TQCursor & TQt::splitVCursor = cursorTable[11]; -const TQCursor & TQt::splitHCursor = cursorTable[12]; -const TQCursor & TQt::pointingHandCursor = cursorTable[13]; -const TQCursor & TQt::forbiddenCursor = cursorTable[14]; -const TQCursor & TQt::whatsThisCursor = cursorTable[15]; -const TQCursor & TQt::busyCursor = cursorTable[16]; - - -TQCursor *TQCursor::find_cur( int shape ) // find predefined cursor -{ - return (uint)shape <= LastCursor ? &cursorTable[shape] : 0; -} - - -static bool initialized = FALSE; - -/*! - Internal function that deinitializes the predefined cursors. - This function is called from the TQApplication destructor. - - \sa initialize() -*/ -void TQCursor::cleanup() -{ - if ( !initialized ) - return; - - int shape; - for( shape = 0; shape <= LastCursor; shape++ ) { - if ( cursorTable[shape].data && cursorTable[shape].data->deref() ) - delete cursorTable[shape].data; - cursorTable[shape].data = 0; - } - initialized = FALSE; -} - - -/*! - Internal function that initializes the predefined cursors. - This function is called from the TQApplication constructor. - - \sa cleanup() -*/ - -void TQCursor::initialize() -{ - int shape; - for( shape = 0; shape <= LastCursor; shape++ ) - cursorTable[shape].data = new TQCursorData( shape ); - initialized = TRUE; - tqAddPostRoutine( cleanup ); -} - - -/*! - Constructs a cursor with the default arrow shape. -*/ -TQCursor::TQCursor() -{ - if ( !initialized ) { - if ( tqApp->startingUp() ) { - data = 0; - return; - } - initialize(); - } - TQCursor* c = &cursorTable[arrowCursorIdx]; - c->data->ref(); - data = c->data; -} - - - -/*! - Constructs a cursor with the specified \a shape. - - See \l CursorShape for a list of shapes. - - \sa setShape() -*/ - -TQCursor::TQCursor( int shape ) -{ - if ( !initialized ) - initialize(); - TQCursor *c = find_cur( shape ); - if ( !c ) // not found - c = &cursorTable[arrowCursorIdx]; // then use arrowCursor - c->data->ref(); - data = c->data; -} - -/*! - Constructs a cursor from the window system cursor \a cursor. - - \warning Using this function is not portable. This function is only - available on X11 and Windows. -*/ -TQCursor::TQCursor( HANDLE cursor ) -{ - if ( !initialized ) - initialize(); - - data = new TQCursorData; - TQ_CHECK_PTR( data ); - data->hcurs = cursor; -} - - - -void TQCursor::setBitmap( const TQBitmap &bitmap, const TQBitmap &mask, - int hotX, int hotY ) -{ - if ( !initialized ) - initialize(); - if ( bitmap.depth() != 1 || mask.depth() != 1 || - bitmap.size() != mask.size() ) { -#if defined(QT_CHECK_NULL) - tqWarning( "TQCursor: Cannot create bitmap cursor; invalid bitmap(s)" ); -#endif - TQCursor *c = &cursorTable[arrowCursorIdx]; - c->data->ref(); - data = c->data; - return; - } - data = new TQCursorData; - TQ_CHECK_PTR( data ); - data->bm = new TQBitmap( bitmap ); - data->bmm = new TQBitmap( mask ); - data->hcurs = 0; - data->cshape = BitmapCursor; - data->hx = hotX >= 0 ? hotX : bitmap.width()/2; - data->hy = hotY >= 0 ? hotY : bitmap.height()/2; - data->fg.red = 0 << 8; - data->fg.green = 0 << 8; - data->fg.blue = 0 << 8; - data->bg.red = 255 << 8; - data->bg.green = 255 << 8; - data->bg.blue = 255 << 8; - update(); // Xcursor's backward compatibility hack needs the cursor to be created - // right after the bitmaps are created and filled with data -} - - -/*! - Constructs a copy of the cursor \a c. -*/ - -TQCursor::TQCursor( const TQCursor &c ) -{ - if ( !initialized ) - initialize(); - data = c.data; // shallow copy - data->ref(); -} - -/*! - Destroys the cursor. -*/ - -TQCursor::~TQCursor() -{ - if ( data && data->deref() ) - delete data; -} - - -/*! - Assigns \a c to this cursor and returns a reference to this - cursor. -*/ - -TQCursor &TQCursor::operator=( const TQCursor &c ) -{ - if ( !initialized ) - initialize(); - c.data->ref(); // avoid c = c - if ( data->deref() ) - delete data; - data = c.data; - return *this; -} - - -/*! - Returns the cursor shape identifier. The return value is one of - the \l CursorShape enum values (cast to an int). - - \sa setShape() -*/ - -int TQCursor::shape() const -{ - if ( !initialized ) - initialize(); - return data->cshape; -} - -/*! - Sets the cursor to the shape identified by \a shape. - - See \l CursorShape for the list of cursor shapes. - - \sa shape() -*/ - -void TQCursor::setShape( int shape ) -{ - if ( !initialized ) - initialize(); - TQCursor *c = find_cur( shape ); // find one of the global ones - if ( !c ) // not found - c = &cursorTable[arrowCursorIdx]; // then use arrowCursor - c->data->ref(); - if ( data->deref() ) // make shallow copy - delete data; - data = c->data; -} - - -/*! - Returns the cursor bitmap, or 0 if it is one of the standard - cursors. -*/ -const TQBitmap *TQCursor::bitmap() const -{ - if ( !initialized ) - initialize(); - return data->bm; -} - -/*! - Returns the cursor bitmap mask, or 0 if it is one of the standard - cursors. -*/ - -const TQBitmap *TQCursor::mask() const -{ - if ( !initialized ) - initialize(); - return data->bmm; -} - -/*! - Returns the cursor hot spot, or (0, 0) if it is one of the - standard cursors. -*/ - -TQPoint TQCursor::hotSpot() const -{ - if ( !initialized ) - initialize(); - return TQPoint( data->hx, data->hy ); -} - - -/*! - Returns the window system cursor handle. - - \warning - Portable in principle, but if you use it you are probably about to - do something non-portable. Be careful. -*/ - -TQt::HANDLE TQCursor::handle() const -{ - if ( !initialized ) - initialize(); - if ( !data->hcurs ) - update(); - return data->hcurs; -} - -/*! - \fn TQCursor::TQCursor( HCURSOR handle ) - - Creates a cursor with the specified window system handle \a - handle. - - \warning - Portable in principle, but if you use it you are probably about to - do something non-portable. Be careful. -*/ - -/*! - Returns the position of the cursor (hot spot) in global screen - coordinates. - - You can call TQWidget::mapFromGlobal() to translate it to widget - coordinates. - - \sa setPos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal() -*/ -TQPoint TQCursor::pos() -{ - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint buttons; - Display* dpy = TQPaintDevice::x11AppDisplay(); - for ( int i = 0; i < ScreenCount( dpy ); i++ ) { - if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child, - &root_x, &root_y, &win_x, &win_y, &buttons ) ) - - return TQPoint( root_x, root_y ); - } - return TQPoint(); -} - -/*! \internal -*/ -int TQCursor::x11Screen() -{ - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint buttons; - Display* dpy = TQPaintDevice::x11AppDisplay(); - for ( int i = 0; i < ScreenCount( dpy ); i++ ) { - if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child, - &root_x, &root_y, &win_x, &win_y, &buttons ) ) - return i; - } - return -1; -} - -/*! - Moves the cursor (hot spot) to the global screen position (\a x, - \a y). - - You can call TQWidget::mapToGlobal() to translate widget - coordinates to global screen coordinates. - - \sa pos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal() -*/ - -void TQCursor::setPos( int x, int y ) -{ - TQPoint current, target(x, y); - - // this is copied from pos(), since we need the screen number for the correct - // root window in the XWarpPointer call - Window root; - Window child; - int root_x, root_y, win_x, win_y; - uint buttons; - Display* dpy = TQPaintDevice::x11AppDisplay(); - int screen; - for ( screen = 0; screen < ScreenCount( dpy ); screen++ ) { - if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( screen ), &root, &child, - &root_x, &root_y, &win_x, &win_y, &buttons ) ) { - current = TQPoint( root_x, root_y ); - break; - } - } - - if ( screen >= ScreenCount( dpy ) ) - return; - - // Need to check, since some X servers generate null mouse move - // events, causing looping in applications which call setPos() on - // every mouse move event. - // - if ( current == target ) - return; - - XWarpPointer( TQPaintDevice::x11AppDisplay(), None, - TQPaintDevice::x11AppRootWindow( screen ), - 0, 0, 0, 0, x, y ); -} - -/*! - \overload void TQCursor::setPos ( const TQPoint & ) -*/ - - -/*! - \internal - - Creates the cursor. -*/ - -void TQCursor::update() const -{ - if ( !initialized ) - initialize(); - TQCursorData *d = data; // cheat const! - if ( d->hcurs ) // already loaded - return; - - Display *dpy = TQPaintDevice::x11AppDisplay(); - Window rootwin = TQPaintDevice::x11AppRootWindow(); - - if ( d->cshape == BitmapCursor ) { - d->hcurs = XCreatePixmapCursor( dpy, d->bm->handle(), d->bmm->handle(), - &d->fg, &d->bg, d->hx, d->hy ); - return; - } - -#ifndef TQT_NO_XCURSOR - static const char *cursorNames[] = { - "left_ptr", - "up_arrow", - "cross", - "wait", - "ibeam", - "size_ver", - "size_hor", - "size_bdiag", - "size_fdiag", - "size_all", - "blank", - "split_v", - "split_h", - "pointing_hand", - "forbidden", - "whats_this", - "left_ptr_watch" - }; - - d->hcurs = XcursorLibraryLoadCursor( dpy, cursorNames[d->cshape] ); - if ( d->hcurs ) - return; -#endif // TQT_NO_XCURSOR - - static uchar cur_blank_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - // Non-standard X11 cursors are created from bitmaps - -#ifndef QT_USE_APPROXIMATE_CURSORS - static const uchar cur_ver_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, - 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; - static const uchar mcur_ver_bits[] = { - 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, - 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, - 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; - static const uchar cur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, - 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar mcur_hor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, - 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, - 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; - static const uchar cur_bdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, - 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, - 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar mcur_bdiag_bits[] = { - 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, - 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, - 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; - static const uchar cur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, - 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, - 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; - static const uchar mcur_fdiag_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, - 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, - 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; - static const uchar *cursor_bits16[] = { - cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, - cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, - 0, 0, cur_blank_bits, cur_blank_bits }; - - static const uchar vsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar vsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, - 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar hsplit_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, - 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, - 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar hsplitm_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, - 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, - 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - static const uchar whatsthis_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, - 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, - 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, - 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, - 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, - 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static const uchar whatsthism_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, - 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, - 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, - 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, - 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, - 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - static const uchar busy_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, - 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, - 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, - 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, - 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - static const uchar busym_bits[] = { - 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, - 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, - 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, - 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, - 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, - 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - static const uchar * const cursor_bits32[] = { - vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, - 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits - }; - - static const uchar forbidden_bits[] = { - 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, - 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, - 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, - 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; - - static const unsigned char forbiddenm_bits[] = { - 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, - 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, - 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, - 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; - - static const uchar * const cursor_bits20[] = { - forbidden_bits, forbiddenm_bits - }; - - if ( ( d->cshape >= SizeVerCursor && d->cshape < SizeAllCursor ) || - d->cshape == BlankCursor ) { - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - int i = (d->cshape - SizeVerCursor)*2; - d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i], - 16, 16 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i+1], - 16,16); - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 8, 8 ); - return; - } - if ( ( d->cshape >= SplitVCursor && d->cshape <= SplitHCursor ) || - d->cshape == WhatsThisCursor || d->cshape == BusyCursor ) { - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - int i = (d->cshape - SplitVCursor)*2; - d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i], - 32, 32 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i+1], - 32, 32); - int hs = ( d->cshape == PointingHandCursor || - d->cshape == WhatsThisCursor || - d->cshape == BusyCursor ) ? 0 : 16; - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, hs, hs ); - return; - } - if ( d->cshape == ForbiddenCursor ) { - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - int i = (d->cshape - ForbiddenCursor)*2; - d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i], - 20, 20 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i+1], - 20, 20); - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 10, 10 ); - return; - } -#endif /* ! QT_USE_APPROXIMATE_CURSORS */ - - uint sh; - switch ( d->cshape ) { // map Q cursor to X cursor - case ArrowCursor: - sh = XC_left_ptr; - break; - case UpArrowCursor: - sh = XC_center_ptr; - break; - case CrossCursor: - sh = XC_crosshair; - break; - case WaitCursor: - sh = XC_watch; - break; - case IbeamCursor: - sh = XC_xterm; - break; - case SizeAllCursor: - sh = XC_fleur; - break; - case PointingHandCursor: - sh = XC_hand2; - break; -#ifdef QT_USE_APPROXIMATE_CURSORS - case SizeBDiagCursor: - sh = XC_top_right_corner; - break; - case SizeFDiagCursor: - sh = XC_bottom_right_corner; - break; - case BlankCursor: - XColor bg, fg; - bg.red = 255 << 8; - bg.green = 255 << 8; - bg.blue = 255 << 8; - fg.red = 0; - fg.green = 0; - fg.blue = 0; - d->pm = XCreateBitmapFromData( dpy, rootwin, - (char *)cur_blank_bits, 16, 16 ); - d->pmm = XCreateBitmapFromData( dpy, rootwin, - (char *)cur_blank_bits, 16,16); - d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, - &bg, 8, 8 ); - return; - break; - case SizeVerCursor: - case SplitVCursor: - sh = XC_sb_v_double_arrow; - break; - case SizeHorCursor: - case SplitHCursor: - sh = XC_sb_h_double_arrow; - break; - case WhatsThisCursor: - sh = XC_question_arrow; - break; - case ForbiddenCursor: - sh = XC_circle; - break; - case BusyCursor: - sh = XC_watch; - break; -#endif /* QT_USE_APPROXIMATE_CURSORS */ - default: -#if defined(QT_CHECK_RANGE) - tqWarning( "TQCursor::update: Invalid cursor shape %d", d->cshape ); -#endif - return; - } - d->hcurs = XCreateFontCursor( dpy, sh ); -} diff --git a/src/kernel/qdnd_x11.cpp b/src/kernel/qdnd_x11.cpp index c35bca0a4..4d4dad5f5 100644 --- a/src/kernel/qdnd_x11.cpp +++ b/src/kernel/qdnd_x11.cpp @@ -51,7 +51,7 @@ #include "tqguardedptr.h" #include "tqdragobject.h" #include "tqobjectlist.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqbitmap.h" #include "tqpainter.h" diff --git a/src/kernel/qinternal.cpp b/src/kernel/qinternal.cpp index 82afee051..96297bb8d 100644 --- a/src/kernel/qinternal.cpp +++ b/src/kernel/qinternal.cpp @@ -42,7 +42,7 @@ #include "tqwidget.h" #include "tqpixmap.h" #include "tqpainter.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" // Modern systems (year 2011) have very large screens in excess of 1000 pixels wide // Some may even have screens in excess of 4000 pixels wide(!) diff --git a/src/kernel/qkeysequence.cpp b/src/kernel/qkeysequence.cpp index a1bf49832..8fd7485b8 100644 --- a/src/kernel/qkeysequence.cpp +++ b/src/kernel/qkeysequence.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_ACCEL -#include "ntqaccel.h" +#include "tqaccel.h" #include "ntqshared.h" #include "tqvaluelist.h" #ifndef TQT_NO_REGEXP diff --git a/src/kernel/qmngio.cpp b/src/kernel/qmngio.cpp index 63e08c830..3e1678c4e 100644 --- a/src/kernel/qmngio.cpp +++ b/src/kernel/qmngio.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_IMAGEIO_MNG #include "tqimage.h" -#include "ntqasyncimageio.h" +#include "tqasyncimageio.h" #include "tqiodevice.h" #include "ntqmngio.h" @@ -237,7 +237,7 @@ TODO: decide on this point. gIFg gives disposal types, so it can be done. */ /* - \class TQMNGFormatType ntqasyncimageio.h + \class TQMNGFormatType tqasyncimageio.h \brief Incremental image decoder for MNG image format. \ingroup images diff --git a/src/kernel/qrichtext.cpp b/src/kernel/qrichtext.cpp index 4da7dc3e6..3e378fb47 100644 --- a/src/kernel/qrichtext.cpp +++ b/src/kernel/qrichtext.cpp @@ -57,11 +57,11 @@ #include "tqpaintdevicemetrics.h" #include "tqpainter.h" #include "ntqdrawutil.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqptrstack.h" #include "tqptrdict.h" #include "tqstyle.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqtextengine_p.h" #include @@ -6695,7 +6695,7 @@ void TQTextImage::adjustToPainter( TQPainter* p ) #if !defined(TQ_WS_X11) #include -#include +#include static TQPixmap *qrt_selection = 0; static TQSingleCleanupHandler qrt_cleanup_pixmap; static void qrt_createSelectionPixmap( const TQColorGroup &cg ) diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri index fbde927e1..c3b5c4b2d 100644 --- a/src/kernel/qt_kernel.pri +++ b/src/kernel/qt_kernel.pri @@ -3,19 +3,19 @@ kernel { KERNEL_P = kernel HEADERS += \ - $$KERNEL_H/ntqaccel.h \ + $$KERNEL_H/tqaccel.h \ $$KERNEL_P/qucomextra_p.h \ $$KERNEL_H/ntqapplication.h \ $$KERNEL_P/qapplication_p.h \ - $$KERNEL_H/ntqasyncimageio.h \ - $$KERNEL_H/ntqasyncio.h \ + $$KERNEL_H/tqasyncimageio.h \ + $$KERNEL_H/tqasyncio.h \ $$KERNEL_H/tqbitmap.h \ $$KERNEL_H/tqbrush.h \ $$KERNEL_H/tqclipboard.h \ $$KERNEL_H/tqcolor.h \ $$KERNEL_P/tqcolor_p.h \ - $$KERNEL_H/ntqconnection.h \ - $$KERNEL_H/ntqcursor.h \ + $$KERNEL_H/tqconnection.h \ + $$KERNEL_H/tqcursor.h \ $$KERNEL_H/tqdesktopwidget.h \ $$KERNEL_H/tqdragobject.h \ $$KERNEL_H/ntqdrawutil.h \ @@ -113,7 +113,7 @@ kernel { win32:SOURCES += $$KERNEL_CPP/qapplication_win.cpp \ $$KERNEL_CPP/tqclipboard_win.cpp \ $$KERNEL_CPP/tqcolor_win.cpp \ - $$KERNEL_CPP/qcursor_win.cpp \ + $$KERNEL_CPP/tqcursor_win.cpp \ $$KERNEL_CPP/tqdesktopwidget_win.cpp \ $$KERNEL_CPP/qdnd_win.cpp \ $$KERNEL_CPP/tqeventloop_win.cpp \ @@ -136,7 +136,7 @@ kernel { SOURCES += $$KERNEL_CPP/qapplication_x11.cpp \ $$KERNEL_CPP/tqclipboard_x11.cpp \ $$KERNEL_CPP/tqcolor_x11.cpp \ - $$KERNEL_CPP/qcursor_x11.cpp \ + $$KERNEL_CPP/tqcursor_x11.cpp \ $$KERNEL_CPP/qdnd_x11.cpp \ $$KERNEL_CPP/tqdesktopwidget_x11.cpp \ $$KERNEL_CPP/tqfont_x11.cpp \ @@ -166,7 +166,7 @@ kernel { SOURCES += $$KERNEL_CPP/qapplication_mac.cpp \ $$KERNEL_CPP/tqclipboard_mac.cpp \ $$KERNEL_CPP/tqcolor_mac.cpp \ - $$KERNEL_CPP/qcursor_mac.cpp \ + $$KERNEL_CPP/tqcursor_mac.cpp \ $$KERNEL_CPP/tqmime_mac.cpp \ $$KERNEL_CPP/qdnd_mac.cpp \ $$KERNEL_CPP/tqdesktopwidget_mac.cpp \ @@ -195,16 +195,16 @@ kernel { SOURCES += $$KERNEL_CPP/tqabstractlayout.cpp \ $$KERNEL_CPP/qucomextra.cpp \ - $$KERNEL_CPP/qaccel.cpp \ + $$KERNEL_CPP/tqaccel.cpp \ $$KERNEL_CPP/qapplication.cpp \ - $$KERNEL_CPP/qasyncimageio.cpp \ - $$KERNEL_CPP/qasyncio.cpp \ + $$KERNEL_CPP/tqasyncimageio.cpp \ + $$KERNEL_CPP/tqasyncio.cpp \ $$KERNEL_CPP/tqbitmap.cpp \ $$KERNEL_CPP/tqclipboard.cpp \ $$KERNEL_CPP/tqcolor.cpp \ $$KERNEL_CPP/tqcolor_p.cpp \ - $$KERNEL_CPP/qconnection.cpp \ - $$KERNEL_CPP/qcursor.cpp \ + $$KERNEL_CPP/tqconnection.cpp \ + $$KERNEL_CPP/tqcursor.cpp \ $$KERNEL_CPP/tqdragobject.cpp \ $$KERNEL_CPP/qdrawutil.cpp \ $$KERNEL_CPP/tqdropsite.cpp \ @@ -270,10 +270,10 @@ kernel { $$KERNEL_H/tqfontdatabase.h accessibility { - HEADERS += $$KERNEL_H/ntqaccessible.h - SOURCES += $$KERNEL_CPP/qaccessible.cpp + HEADERS += $$KERNEL_H/tqaccessible.h + SOURCES += $$KERNEL_CPP/tqaccessible.cpp - !embedded:!x11:mac:SOURCES += $$KERNEL_CPP/qaccessible_mac.cpp - else:win32:SOURCES += $$KERNEL_CPP/qaccessible_win.cpp + !embedded:!x11:mac:SOURCES += $$KERNEL_CPP/tqaccessible_mac.cpp + else:win32:SOURCES += $$KERNEL_CPP/tqaccessible_win.cpp } } diff --git a/src/kernel/qt_pch.h b/src/kernel/qt_pch.h index 611076c97..982ea2946 100644 --- a/src/kernel/qt_pch.h +++ b/src/kernel/qt_pch.h @@ -25,7 +25,7 @@ #include // All moc genereated code has this include #include #include -#include +#include #include #include #include diff --git a/src/kernel/qvariant.cpp b/src/kernel/qvariant.cpp index 884ef1ed5..ac94aea12 100644 --- a/src/kernel/qvariant.cpp +++ b/src/kernel/qvariant.cpp @@ -58,7 +58,7 @@ #include "tqregion.h" #include "tqpointarray.h" #include "tqbitmap.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqdatetime.h" #include "tqsizepolicy.h" #include "ntqshared.h" diff --git a/src/kernel/tqaccel.cpp b/src/kernel/tqaccel.cpp new file mode 100644 index 000000000..c5fcc30e6 --- /dev/null +++ b/src/kernel/tqaccel.cpp @@ -0,0 +1,1089 @@ +/**************************************************************************** +** +** Implementation of TQAccel class +** +** Created : 950419 +** +** 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 "tqaccel.h" + +#ifndef TQT_NO_ACCEL + +#include "tqsignal.h" +#include "ntqapplication.h" +#include "tqwidget.h" +#include "tqptrlist.h" +#include "tqwhatsthis.h" +#include "tqguardedptr.h" +#include "tqstatusbar.h" +#include "ntqdockwindow.h" +#include "tqsignalslotimp.h" +/*! + \class TQAccel tqaccel.h + \brief The TQAccel class handles keyboard accelerator and shortcut keys. + + \ingroup misc + + A keyboard accelerator triggers an action when a certain key + combination is pressed. The accelerator handles all keyboard + activity for all the children of one top-level widget, so it is + not affected by the keyboard focus. + + In most cases, you will not need to use this class directly. Use + the TQAction class to create actions with accelerators that can be + used in both menus and toolbars. If you're only interested in + menus use TQMenuData::insertItem() or TQMenuData::setAccel() to make + accelerators for operations that are also available on menus. Many + widgets automatically generate accelerators, such as TQButton, + TQGroupBox, TQLabel (with TQLabel::setBuddy()), TQMenuBar and TQTabBar. + Example: + \code + TQPushButton p( "&Exit", parent ); // automatic shortcut ALT+Key_E + TQPopupMenu *fileMenu = new fileMenu( parent ); + fileMenu->insertItem( "Undo", parent, TQ_SLOT(undo()), CTRL+Key_Z ); + \endcode + + A TQAccel contains a list of accelerator items that can be + manipulated using insertItem(), removeItem(), clear(), key() and + findKey(). + + Each accelerator item consists of an identifier and a \l + TQKeySequence. A single key sequence consists of a keyboard code + combined with modifiers (\c SHIFT, \c CTRL, \c ALT or \c + UNICODE_ACCEL). For example, \c{CTRL + Key_P} could be 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 accelerator as \c Key_A. + + When an accelerator key is pressed, the accelerator sends out the + signal activated() with a number that identifies this particular + accelerator item. Accelerator items can also be individually + connected, so that two different keys will activate two different + slots (see connectItem() and disconnectItem()). + + The activated() signal is \e not emitted when two or more + accelerators match the same key. Instead, the first matching + accelerator sends out the activatedAmbiguously() signal. By + pressing the key multiple times, users can navigate between all + matching accelerators. Some standard controls like TQPushButton and + TQCheckBox connect the activatedAmbiguously() signal to the + harmless setFocus() slot, whereas activated() is connected to a + slot invoking the button's action. Most controls, like TQLabel and + TQTabBar, treat activated() and activatedAmbiguously() as + equivalent. + + Use setEnabled() to enable or disable all the items in an + accelerator, or setItemEnabled() to enable or disable individual + items. An item is active only when both the TQAccel and the item + itself are enabled. + + The function setWhatsThis() specifies a help text that appears + when the user presses an accelerator key in What's This mode. + + The accelerator will be deleted when \e parent is deleted, + and will consume relevant key events until then. + + Please note that the accelerator + \code + accelerator->insertItem( TQKeySequence("M") ); + \endcode + can be triggered with both the 'M' key, and with Shift+M, + unless a second accelerator is defined for the Shift+M + combination. + + + Example: + \code + TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow + a->connectItem( a->insertItem(Key_P+CTRL), // adds Ctrl+P accelerator + myWindow, // connected to myWindow's + TQ_SLOT(printDoc()) ); // printDoc() slot + \endcode + + \sa TQKeyEvent TQWidget::keyPressEvent() TQMenuData::setAccel() + TQButton::setAccel() TQLabel::setBuddy() TQKeySequence + \link guibooks.html#fowler GUI Design Handbook: Keyboard Shortcuts \endlink. +*/ + + +struct TQAccelItem { // internal accelerator item + TQAccelItem( const TQKeySequence &k, int i ) + { key=k; id=i; enabled=TRUE; signal=0; } + ~TQAccelItem() { delete signal; } + int id; + TQKeySequence key; + bool enabled; + TQSignal *signal; + TQString whatsthis; +}; + + +typedef TQPtrList TQAccelList; // internal accelerator list + +class TQAccelPrivate : public TQt { +public: + TQAccelPrivate( TQAccel* p ); + ~TQAccelPrivate(); + TQAccelList aitems; + bool enabled; + TQGuardedPtr watch; + bool ignorewhatsthis; + TQAccel* parent; + + void activate( TQAccelItem* item ); + void activateAmbiguously( TQAccelItem* item ); +}; + +class TQAccelManager : public TQt { +public: + static TQAccelManager* self() { return self_ptr ? self_ptr : new TQAccelManager; } + void registerAccel( TQAccelPrivate* a ) { accels.append( a ); } + void unregisterAccel( TQAccelPrivate* a ) { accels.removeRef( a ); if ( accels.isEmpty() ) delete this; } + bool tryAccelEvent( TQWidget* w, TQKeyEvent* e ); + bool dispatchAccelEvent( TQWidget* w, TQKeyEvent* e ); + bool tryComposeUnicode( TQWidget* w, TQKeyEvent* e ); + +private: + TQAccelManager():currentState(TQt::NoMatch), clash(-1) { self_ptr = this; } + ~TQAccelManager() { self_ptr = 0; } + + bool correctSubWindow( TQWidget *w, TQAccelPrivate* d ); + SequenceMatch match( TQKeyEvent* e, TQAccelItem* item, TQKeySequence& temp ); + int translateModifiers( ButtonState state ); + + TQPtrList accels; + static TQAccelManager* self_ptr; + TQt::SequenceMatch currentState; + TQKeySequence intermediate; + int clash; +}; +TQAccelManager* TQAccelManager::self_ptr = 0; + +bool TQ_EXPORT tqt_tryAccelEvent( TQWidget* w, TQKeyEvent* e){ + return TQAccelManager::self()->tryAccelEvent( w, e ); +} + +bool TQ_EXPORT tqt_dispatchAccelEvent( TQWidget* w, TQKeyEvent* e){ + return TQAccelManager::self()->dispatchAccelEvent( w, e ); +} + +bool TQ_EXPORT tqt_tryComposeUnicode( TQWidget* w, TQKeyEvent* e){ + return TQAccelManager::self()->tryComposeUnicode( w, e ); +} + +#ifdef TQ_WS_MAC +static bool qt_accel_no_shortcuts = TRUE; +#else +static bool qt_accel_no_shortcuts = FALSE; +#endif +void TQ_EXPORT tqt_setAccelAutoShortcuts(bool b) { qt_accel_no_shortcuts = b; } + +/* + \internal + Returns TRUE if the accel is in the current subwindow, else FALSE. +*/ +bool TQAccelManager::correctSubWindow( TQWidget* w, TQAccelPrivate* d ) { +#if !defined ( Q_OS_MACX ) + if ( !d->watch || !d->watch->isVisible() || !d->watch->isEnabled() ) +#else + if ( !d->watch || (!d->watch->isVisible() && !d->watch->inherits( "TQMenuBar" )) || !d->watch->isEnabled() ) +#endif + return FALSE; + TQWidget* tlw = w->topLevelWidget(); + TQWidget* wtlw = d->watch->topLevelWidget(); + + /* if we live in a floating dock window, keep our parent's + * accelerators working */ +#ifndef TQT_NO_MAINWINDOW + if ( tlw->isDialog() && tlw->parentWidget() && ::tqt_cast(tlw) ) + return tlw->parentWidget()->topLevelWidget() == wtlw; + + if ( wtlw != tlw ) + return FALSE; +#endif + /* if we live in a MDI subwindow, ignore the event if we are + not the active document window */ + TQWidget* sw = d->watch; + while ( sw && !sw->testWFlags( WSubWindow ) ) + sw = sw->parentWidget( TRUE ); + if ( sw ) { // we are in a subwindow indeed + TQWidget* fw = w; + while ( fw && fw != sw ) + fw = fw->parentWidget( TRUE ); + if ( fw != sw ) // focus widget not in our subwindow + return FALSE; + } + return TRUE; +} + +inline int TQAccelManager::translateModifiers( ButtonState state ) +{ + int result = 0; + if ( state & ShiftButton ) + result |= SHIFT; + if ( state & ControlButton ) + result |= CTRL; + if ( state & MetaButton ) + result |= META; + if ( state & AltButton ) + result |= ALT; + return result; +} + +/* + \internal + Matches the current intermediate key sequence + the latest + keyevent, with and AccelItem. Returns Identical, + PartialMatch or NoMatch, and fills \a temp with the + resulting key sequence. +*/ +TQt::SequenceMatch TQAccelManager::match( TQKeyEvent *e, TQAccelItem* item, TQKeySequence& temp ) +{ + SequenceMatch result = TQt::NoMatch; + int index = intermediate.count(); + temp = intermediate; + + int modifier = translateModifiers( e->state() ); + + if ( e->key() && e->key() != Key_unknown) { + int key = e->key() | modifier; + if ( e->key() == Key_BackTab ) { + /* + In TQApplication, we map shift+tab to shift+backtab. + This code here reverts the mapping in a way that keeps + backtab and shift+tab accelerators working, in that + order, meaning backtab has priority.*/ + key &= ~SHIFT; + + temp.setKey( key, index ); + if ( TQt::NoMatch != (result = temp.matches( item->key )) ) + return result; + if ( e->state() & ShiftButton ) + key |= SHIFT; + key = Key_Tab | ( key & MODIFIER_MASK ); + temp.setKey( key, index ); + if ( TQt::NoMatch != (result = temp.matches( item->key )) ) + return result; + } else { + temp.setKey( key, index ); + if ( TQt::NoMatch != (result = temp.matches( item->key )) ) + return result; + } + + if ( key == Key_BackTab ) { + if ( e->state() & ShiftButton ) + key |= SHIFT; + temp.setKey( key, index ); + if ( TQt::NoMatch != (result = temp.matches( item->key )) ) + return result; + } + } + if ( !e->text().isEmpty() ) { + temp.setKey( (int)e->text()[0].unicode() | UNICODE_ACCEL | modifier, index ); + result = temp.matches( item->key ); + } + return result; +} + +bool TQAccelManager::tryAccelEvent( TQWidget* w, TQKeyEvent* e ) +{ + if ( TQt::NoMatch == currentState ) { + e->t = TQEvent::AccelOverride; + e->ignore(); + TQApplication::sendSpontaneousEvent( w, e ); + if ( e->isAccepted() ) + return FALSE; + } + e->t = TQEvent::Accel; + e->ignore(); + TQApplication::sendSpontaneousEvent( w, e ); + return e->isAccepted(); +} + +bool TQAccelManager::tryComposeUnicode( TQWidget* w, TQKeyEvent* e ) +{ + if ( TQApplication::metaComposeUnicode ) { + int value = e->key() - Key_0; + // Ignore acceloverrides so we don't trigger + // accels on keypad when Meta compose is on + if ( (e->type() == TQEvent::AccelOverride) && + (e->state() == TQt::Keypad + TQt::MetaButton) ) { + e->accept(); + // Meta compose start/continue + } else if ( (e->type() == TQEvent::KeyPress) && + (e->state() == TQt::Keypad + TQt::MetaButton) ) { + if ( value >= 0 && value <= 9 ) { + TQApplication::composedUnicode *= 10; + TQApplication::composedUnicode += value; + return TRUE; + } else { + // Composing interrupted, dispatch! + if ( TQApplication::composedUnicode ) { + TQChar ch( TQApplication::composedUnicode ); + TQString s( ch ); + TQKeyEvent kep( TQEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s ); + TQKeyEvent ker( TQEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s ); + TQApplication::sendEvent( w, &kep ); + TQApplication::sendEvent( w, &ker ); + } + TQApplication::composedUnicode = 0; + return TRUE; + } + // Meta compose end, dispatch + } else if ( (e->type() == TQEvent::KeyRelease) && + (e->key() == Key_Meta) && + (TQApplication::composedUnicode != 0) ) { + if ( (TQApplication::composedUnicode > 0) && + (TQApplication::composedUnicode < 0xFFFE) ) { + TQChar ch( TQApplication::composedUnicode ); + TQString s( ch ); + TQKeyEvent kep( TQEvent::KeyPress, 0, ch.row() ? 0 : ch.cell(), 0, s ); + TQKeyEvent ker( TQEvent::KeyRelease, 0, ch.row() ? 0 : ch.cell(), 0, s ); + TQApplication::sendEvent( w, &kep ); + TQApplication::sendEvent( w, &ker ); + } + TQApplication::composedUnicode = 0; + return TRUE; + } + } + return FALSE; +} + +/* + \internal + Checks for possible accelerators, if no widget + ate the keypres, or we are in the middle of a + partial key sequence. +*/ +bool TQAccelManager::dispatchAccelEvent( TQWidget* w, TQKeyEvent* e ) +{ +#ifndef TQT_NO_STATUSBAR + // Needs to be declared and used here because of "goto doclash" + TQStatusBar* mainStatusBar = 0; +#endif + + // Modifiers can NOT be accelerators... + if ( e->key() >= Key_Shift && + e->key() <= Key_Alt ) + return FALSE; + + SequenceMatch result = TQt::NoMatch; + TQKeySequence tocheck, partial; + TQAccelPrivate* accel = 0; + TQAccelItem* item = 0; + TQAccelPrivate* firstaccel = 0; + TQAccelItem* firstitem = 0; + TQAccelPrivate* lastaccel = 0; + TQAccelItem* lastitem = 0; + + TQKeyEvent pe = *e; + int n = -1; + int hasShift = (e->state()&TQt::ShiftButton)?1:0; + bool identicalDisabled = FALSE; + bool matchFound = FALSE; + do { + accel = accels.first(); + matchFound = FALSE; + while ( accel ) { + if ( correctSubWindow( w, accel ) ) { + if ( accel->enabled ) { + item = accel->aitems.last(); + while( item ) { + if ( TQt::Identical == (result = match( &pe, item, tocheck )) ) { + if ( item->enabled ) { + if ( !firstaccel ) { + firstaccel = accel; + firstitem = item; + } + lastaccel = accel; + lastitem = item; + n++; + matchFound = TRUE; + if ( n > TQMAX(clash,0) ) + goto doclash; + } else { + identicalDisabled = TRUE; + } + } + if ( item->enabled && TQt::PartialMatch == result ) { + partial = tocheck; + matchFound = TRUE; + } + item = accel->aitems.prev(); + } + } else { + item = accel->aitems.last(); + while( item ) { + if ( TQt::Identical == match( &pe, item, tocheck ) ) + identicalDisabled = TRUE; + item = accel->aitems.prev(); + } + } + } + accel = accels.next(); + } + pe = TQKeyEvent( TQEvent::Accel, pe.key(), pe.ascii(), pe.state()&~TQt::ShiftButton, pe.text() ); + } while ( hasShift-- && !matchFound && !identicalDisabled ); + +#ifndef TQT_NO_STATUSBAR + mainStatusBar = (TQStatusBar*) w->topLevelWidget()->child( 0, "TQStatusBar" ); +#endif + if ( n < 0 ) { // no match found + currentState = partial.count() ? PartialMatch : NoMatch; +#ifndef TQT_NO_STATUSBAR + // Only display message if we are, or were, in a partial match + if ( mainStatusBar && (PartialMatch == currentState || intermediate.count() ) ) { + if ( currentState == TQt::PartialMatch ) { + mainStatusBar->message( (TQString)partial + ", ...", 0 ); + } else if (!identicalDisabled) { + TQString message = TQAccel::tr("%1, %2 not defined"). + arg( (TQString)intermediate ). + arg( TQKeySequence::encodeString( e->key() | translateModifiers(e->state()) ) ); + mainStatusBar->message( message, 2000 ); + // Since we're a NoMatch, reset the clash count + clash = -1; + } else { + mainStatusBar->clear(); + } + } +#endif + + bool eatKey = (PartialMatch == currentState || intermediate.count() ); + intermediate = partial; + if ( eatKey ) + e->accept(); + return eatKey; + } else if ( n == 0 ) { // found exactly one match + clash = -1; // reset +#ifndef TQT_NO_STATUSBAR + if ( currentState == TQt::PartialMatch && mainStatusBar ) + mainStatusBar->clear(); +#endif + currentState = TQt::NoMatch; // Free sequence keylock + intermediate = TQKeySequence(); + lastaccel->activate( lastitem ); + e->accept(); + return TRUE; + } + + doclash: // found more than one match +#ifndef TQT_NO_STATUSBAR + if ( !mainStatusBar ) // if "goto doclash", we need to get statusbar again. + mainStatusBar = (TQStatusBar*) w->topLevelWidget()->child( 0, "TQStatusBar" ); +#endif + + TQString message = TQAccel::tr( "Ambiguous \"%1\" not handled" ).arg( (TQString)tocheck ); + if ( clash >= 0 && n > clash ) { // pick next match + intermediate = TQKeySequence(); + currentState = TQt::NoMatch; // Free sequence keylock + clash++; +#ifndef TQT_NO_STATUSBAR + if ( mainStatusBar && + !lastitem->signal && + !(lastaccel->parent->receivers( "activatedAmbiguously(int)" )) ) + mainStatusBar->message( message, 2000 ); +#endif + lastaccel->activateAmbiguously( lastitem ); + } else { // start (or wrap) with the first matching + intermediate = TQKeySequence(); + currentState = TQt::NoMatch; // Free sequence keylock + clash = 0; +#ifndef TQT_NO_STATUSBAR + if ( mainStatusBar && + !firstitem->signal && + !(firstaccel->parent->receivers( "activatedAmbiguously(int)" )) ) + mainStatusBar->message( message, 2000 ); +#endif + firstaccel->activateAmbiguously( firstitem ); + } + e->accept(); + return TRUE; +} + +TQAccelPrivate::TQAccelPrivate( TQAccel* p ) + : parent( p ) +{ + TQAccelManager::self()->registerAccel( this ); + aitems.setAutoDelete( TRUE ); + ignorewhatsthis = FALSE; +} + +TQAccelPrivate::~TQAccelPrivate() +{ + TQAccelManager::self()->unregisterAccel( this ); +} + +static TQAccelItem *find_id( TQAccelList &list, int id ) +{ + TQAccelItem *item = list.first(); + while ( item && item->id != id ) + item = list.next(); + return item; +} + +static TQAccelItem *find_key( TQAccelList &list, const TQKeySequence &key ) +{ + TQAccelItem *item = list.first(); + while ( item && !( item->key == key ) ) + item = list.next(); + return item; +} + +/*! + Constructs a TQAccel object called \a name, with parent \a parent. + The accelerator operates on \a parent. +*/ + +TQAccel::TQAccel( TQWidget *parent, const char *name ) + : TQObject( parent, name ) +{ + d = new TQAccelPrivate( this ); + d->enabled = TRUE; + d->watch = parent; +#if defined(QT_CHECK_NULL) + if ( !d->watch ) + tqWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); +#endif +} + +/*! + Constructs a TQAccel object called \a name, that operates on \a + watch, and is a child of \a parent. + + This constructor is not needed for normal application programming. +*/ +TQAccel::TQAccel( TQWidget* watch, TQObject *parent, const char *name ) + : TQObject( parent, name ) +{ + d = new TQAccelPrivate( this ); + d->enabled = TRUE; + d->watch = watch; +#if defined(QT_CHECK_NULL) + if ( !d->watch ) + tqWarning( "TQAccel: An accelerator must have a parent or a watch widget" ); +#endif +} + +/*! + Destroys the accelerator object and frees all allocated resources. +*/ + +TQAccel::~TQAccel() +{ + delete d; +} + + +/*! + \fn void TQAccel::activated( int id ) + + This signal is emitted when an accelerator key is pressed. \a id + is a number that identifies this particular accelerator item. + + \sa activatedAmbiguously() +*/ + +/*! + \fn void TQAccel::activatedAmbiguously( int id ) + + This signal is emitted when an accelerator key is pressed. \a id + is a number that identifies this particular accelerator item. + + \sa activated() +*/ + + +/*! + Returns TRUE if the accelerator is enabled; otherwise returns + FALSE. + + \sa setEnabled(), isItemEnabled() +*/ + +bool TQAccel::isEnabled() const +{ + return d->enabled; +} + + +/*! + Enables the accelerator if \a enable is TRUE, or disables it if \a + enable is FALSE. + + Individual keys can also be enabled or disabled using + setItemEnabled(). To work, a key must be an enabled item in an + enabled TQAccel. + + \sa isEnabled(), setItemEnabled() +*/ + +void TQAccel::setEnabled( bool enable ) +{ + d->enabled = enable; +} + + +/*! + Returns the number of accelerator items in this accelerator. +*/ + +uint TQAccel::count() const +{ + return d->aitems.count(); +} + + +static int get_seq_id() +{ + static int seq_no = -2; // -1 is used as return value in findKey() + return seq_no--; +} + +/*! + Inserts an accelerator item and returns the item's identifier. + + \a key is a key code and an optional combination of SHIFT, CTRL + and ALT. \a id is the accelerator item id. + + If \a id is negative, then the item will be assigned a unique + negative identifier less than -1. + + \code + TQAccel *a = new TQAccel( myWindow ); // create accels for myWindow + a->insertItem( CTRL + Key_P, 200 ); // Ctrl+P, e.g. to print document + a->insertItem( ALT + Key_X, 201 ); // Alt+X, e.g. to quit + a->insertItem( UNICODE_ACCEL + 'q', 202 ); // Unicode 'q', e.g. to quit + a->insertItem( Key_D ); // gets a unique negative id < -1 + a->insertItem( CTRL + SHIFT + Key_P ); // gets a unique negative id < -1 + \endcode +*/ + +int TQAccel::insertItem( const TQKeySequence& key, int id ) +{ + if ( id == -1 ) + id = get_seq_id(); + d->aitems.insert( 0, new TQAccelItem(key,id) ); + return id; +} + +/*! + Removes the accelerator item with the identifier \a id. +*/ + +void TQAccel::removeItem( int id ) +{ + if ( find_id( d->aitems, id) ) + d->aitems.remove(); +} + + +/*! + Removes all accelerator items. +*/ + +void TQAccel::clear() +{ + d->aitems.clear(); +} + + +/*! + Returns the key sequence of the accelerator item with identifier + \a id, or an invalid key sequence (0) if the id cannot be found. +*/ + +TQKeySequence TQAccel::key( int id ) +{ + TQAccelItem *item = find_id( d->aitems, id); + return item ? item->key : TQKeySequence( 0 ); +} + + +/*! + Returns the identifier of the accelerator item with the key code + \a key, or -1 if the item cannot be found. +*/ + +int TQAccel::findKey( const TQKeySequence& key ) const +{ + TQAccelItem *item = find_key( d->aitems, key ); + return item ? item->id : -1; +} + + +/*! + Returns TRUE if the accelerator item with the identifier \a id is + enabled. Returns FALSE if the item is disabled or cannot be found. + + \sa setItemEnabled(), isEnabled() +*/ + +bool TQAccel::isItemEnabled( int id ) const +{ + TQAccelItem *item = find_id( d->aitems, id); + return item ? item->enabled : FALSE; +} + + +/*! + Enables the accelerator item with the identifier \a id if \a + enable is TRUE, and disables item \a id if \a enable is FALSE. + + To work, an item must be enabled and be in an enabled TQAccel. + + \sa isItemEnabled(), isEnabled() +*/ + +void TQAccel::setItemEnabled( int id, bool enable ) +{ + TQAccelItem *item = find_id( d->aitems, id); + if ( item ) + item->enabled = enable; +} + + +/*! + Connects the accelerator item \a id to the slot \a member of \a + receiver. + + \code + a->connectItem( 201, mainView, TQ_SLOT(quit()) ); + \endcode + + Of course, you can also send a signal as \a member. + + Normally accelerators are connected to slots which then receive + the \c activated(int id) signal with the id of the accelerator + item that was activated. If you choose to connect a specific + accelerator item using this function, the \c activated() signal is + emitted if the associated key sequence is pressed but no \c + activated(int id) signal is emitted. + + \sa disconnectItem() +*/ + +bool TQAccel::connectItem( int id, const TQObject *receiver, const char *member ) +{ + TQAccelItem *item = find_id( d->aitems, id); + if ( item ) { + if ( !item->signal ) { + item->signal = new TQSignal; + TQ_CHECK_PTR( item->signal ); + } + return item->signal->connect( receiver, member ); + } + return FALSE; +} + +/*! + Disconnects an accelerator item with id \a id from the function + called \a member in the \a receiver object. + + \sa connectItem() +*/ + +bool TQAccel::disconnectItem( int id, const TQObject *receiver, + const char *member ) +{ + TQAccelItem *item = find_id( d->aitems, id); + if ( item && item->signal ) + return item->signal->disconnect( receiver, member ); + return FALSE; +} + +void TQAccelPrivate::activate( TQAccelItem* item ) +{ +#ifndef TQT_NO_WHATSTHIS + if ( TQWhatsThis::inWhatsThisMode() && !ignorewhatsthis ) { + TQWhatsThis::leaveWhatsThisMode( item->whatsthis ); + return; + } +#endif + if ( item->signal ) + item->signal->activate(); + else + emit parent->activated( item->id ); +} + +void TQAccelPrivate::activateAmbiguously( TQAccelItem* item ) +{ + if ( item->signal ) + item->signal->activate(); + else + emit parent->activatedAmbiguously( item->id ); +} + + +/*! + Returns the shortcut key sequence for \a str, or an invalid key + sequence (0) if \a str has no shortcut sequence. + + For example, shortcutKey("E&xit") returns ALT+Key_X, + shortcutKey("&Quit") returns ALT+Key_Q and shortcutKey("Quit") + returns 0. (In code that does not inherit the TQt namespace class, + you must write e.g. TQt::ALT+TQt::Key_Q.) + + We provide a \link accelerators.html list of common accelerators + \endlink in English. At the time of writing, Microsoft and Open + Group do not appear to have issued equivalent recommendations for + other languages. +*/ + +TQKeySequence TQAccel::shortcutKey( const TQString &str ) +{ + if(qt_accel_no_shortcuts) + return TQKeySequence(); + + int p = 0; + while ( p >= 0 ) { + p = str.find( '&', p ) + 1; + if ( p <= 0 || p >= (int)str.length() ) + return 0; + if ( str[p] != '&' ) { + TQChar c = str[p]; + if ( c.isPrint() ) { + char ltr = c.upper().latin1(); + if ( ltr >= (char)Key_A && ltr <= (char)Key_Z ) + c = ltr; + else + c = c.lower(); + return TQKeySequence( c.unicode() + ALT + UNICODE_ACCEL ); + } + } + p++; + } + return TQKeySequence(); +} + +/*! \obsolete + + Creates an accelerator string for the key \a k. + For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc. + are translated (using TQObject::tr()) in the "TQAccel" context. + + The function is superfluous. Cast the TQKeySequence \a k to a + TQString for the same effect. +*/ +TQString TQAccel::keyToString( TQKeySequence k ) +{ + return (TQString) k; +} + +/*!\obsolete + + Returns an accelerator code for the string \a s. For example + "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl", + "Shift", "Alt" are recognized, as well as their translated + equivalents in the "TQAccel" context (using TQObject::tr()). Returns 0 + if \a s is not recognized. + + This function 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( p1, tr("&Open..."), this, TQ_SLOT(open()), + TQAccel::stringToKey(tr("Ctrl+O", "File|Open")) ); + \endcode + + Notice the \c "File|Open" translator comment. It is by no means + necessary, but it provides some context for the human translator. + + + The function is superfluous. Construct a TQKeySequence from the + string \a s for the same effect. + + \sa TQObject::tr() + \link i18n.html Internationalization with TQt \endlink +*/ +TQKeySequence TQAccel::stringToKey( const TQString & s ) +{ + return TQKeySequence( s ); +} + + +/*! + Sets a What's This help text for the accelerator item \a id to \a + text. + + The text will be shown when the application is in What's This mode + and the user hits the accelerator key. + + To set What's This help on a menu item (with or without an + accelerator key), use TQMenuData::setWhatsThis(). + + \sa whatsThis(), TQWhatsThis::inWhatsThisMode(), + TQMenuData::setWhatsThis(), TQAction::setWhatsThis() +*/ +void TQAccel::setWhatsThis( int id, const TQString& text ) +{ + + TQAccelItem *item = find_id( d->aitems, id); + if ( item ) + item->whatsthis = text; +} + +/*! + Returns the What's This help text for the specified item \a id or + TQString::null if no text has been specified. + + \sa setWhatsThis() +*/ +TQString TQAccel::whatsThis( int id ) const +{ + + TQAccelItem *item = find_id( d->aitems, id); + return item? item->whatsthis : TQString::null; +} + +/*!\internal */ +void TQAccel::setIgnoreWhatsThis( bool b) +{ + d->ignorewhatsthis = b; +} + +/*!\internal */ +bool TQAccel::ignoreWhatsThis() const +{ + return d->ignorewhatsthis; +} + + +/*! + +\page accelerators.html + +\title Standard Accelerator Keys + +Applications invariably need to define accelerator keys for actions. +TQt fully supports accelerators, for example with \l TQAccel::shortcutKey(). + +Here are Microsoft's recommendations for accelerator keys, with +comments about the Open Group's recommendations where they exist +and differ. For most commands, the Open Group either has no advice or +agrees with Microsoft. + +The emboldened letter plus Alt is Microsoft's recommended choice, and +we recommend supporting it. For an Apply button, for example, we +recommend TQButton::setText( \link TQWidget::tr() tr \endlink("&Apply") ); + +If you have conflicting commands (e.g. About and Apply buttons in the +same dialog), you must decide for yourself. + +\list +\i About +\i Always on Top +\i Apply +\i Back +\i Browse +\i Close (CDE: Alt+F4; Alt+F4 is "close window" in Windows) +\i Copy (CDE: Ctrl+C, Ctrl+Insert) +\i Copy Here +\i Create Shortcut +\i Create Shortcut Here +\i Cut +\i Delete +\i Edit +\i Exit (CDE: Exit) +\i Explore +\i File +\i Find +\i Help +\i Help Topics +\i Hide +\i Insert +\i Insert Object +\i Link Here +\i Maximize +\i Minimize +\i Move +\i Move Here +\i New +\i Next +\i No +\i Open +\i Open With +\i Page Setup +\i Paste +\i Paste Link +\i Paste Shortcut +\i Paste Special +\i Pause +\i Play +\i Print +\i Print Here +\i Properties +\i Quick View +\i Redo (CDE: Ctrl+Y, Shift+Alt+Backspace) +\i Repeat +\i Restore +\i Resume +\i Retry +\i Run +\i Save +\i Save As +\i Select All +\i Send To +\i Show +\i Size +\i Split +\i Stop +\i Undo (CDE: Ctrl+Z or Alt+Backspace) +\i View +\i What's This? +\i Window +\i Yes +\endlist + +There are also a lot of other keys and actions (that use other +modifier keys than Alt). See the Microsoft and The Open Group +documentation for details. + +The \link http://www.amazon.com/exec/obidos/ASIN/0735605661/trolltech/t +Microsoft book \endlink has ISBN 0735605661. The corresponding Open Group +book is very hard to find, rather expensive and we cannot recommend +it. However, if you really want it, OGPubs@opengroup.org might be able +to help. Ask them for ISBN 1859121047. + +*/ + +/*! \obsolete serves no purpose anymore */ +void TQAccel::repairEventFilter() {} +/*! \obsolete serves no purpose anymore */ +bool TQAccel::eventFilter( TQObject *, TQEvent * ) { return FALSE; } +#endif // TQT_NO_ACCEL diff --git a/src/kernel/tqaccel.h b/src/kernel/tqaccel.h new file mode 100644 index 000000000..22c2f80e1 --- /dev/null +++ b/src/kernel/tqaccel.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Definition of TQAccel class +** +** Created : 950419 +** +** 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 TQACCEL_H +#define TQACCEL_H + +#ifndef QT_H +#include "tqobject.h" +#include "ntqkeysequence.h" +#endif // QT_H + +#ifndef TQT_NO_ACCEL + +class TQAccelPrivate; + +class TQ_EXPORT TQAccel : public TQObject // accelerator class +{ + TQ_OBJECT +public: + TQAccel( TQWidget *parent, const char *name=0 ); + TQAccel( TQWidget* watch, TQObject *parent, const char *name=0 ); + ~TQAccel(); + + bool isEnabled() const; + void setEnabled( bool ); + + uint count() const; + + int insertItem( const TQKeySequence& key, int id=-1); + void removeItem( int id ); + void clear(); + + TQKeySequence key( int id ); + int findKey( const TQKeySequence& key ) const; + + bool isItemEnabled( int id ) const; + void setItemEnabled( int id, bool enable ); + + bool connectItem( int id, const TQObject *receiver, const char* member ); + bool disconnectItem( int id, const TQObject *receiver, const char* member ); + + void repairEventFilter(); + + void setWhatsThis( int id, const TQString& ); + TQString whatsThis( int id ) const; + void setIgnoreWhatsThis( bool ); + bool ignoreWhatsThis() const; + + static TQKeySequence shortcutKey( const TQString & ); + static TQString keyToString(TQKeySequence k ); + static TQKeySequence stringToKey( const TQString & ); + +signals: + void activated( int id ); + void activatedAmbiguously( int id ); + +protected: + bool eventFilter( TQObject *, TQEvent * ); + +private: + TQAccelPrivate * d; + +private: +#if defined(TQ_DISABLE_COPY) + TQAccel( const TQAccel & ); + TQAccel &operator=( const TQAccel & ); +#endif + friend class TQAccelPrivate; + friend class TQAccelManager; +}; + +#endif // TQT_NO_ACCEL +#endif // TQACCEL_H diff --git a/src/kernel/tqaccessible.cpp b/src/kernel/tqaccessible.cpp new file mode 100644 index 000000000..243c4384c --- /dev/null +++ b/src/kernel/tqaccessible.cpp @@ -0,0 +1,719 @@ +/**************************************************************************** +** +** Implementation of TQAccessible and TQAccessibleObject classes +** +** 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 "tqaccessible.h" + +#if defined(QT_ACCESSIBILITY_SUPPORT) + +#include "tqptrdict.h" +#include "ntqmetaobject.h" +#include +#include "ntqapplication.h" +#include + +/*! + \class TQAccessible tqaccessible.h + \brief The TQAccessible class provides enums and static functions + relating to accessibility. + + \ingroup misc + + Accessibility clients use implementations of the + TQAccessibleInterface to read the information an accessible object + exposes, or to call functions to manipulate the accessible object. + +\omit + TQt provides implementations of the TQAccessibleInterface for most + widget classes in a plugin. This plugin is located in the \e + accessibility subdirectory of the plugins installation directory. + The default installation directory for plugins is \c INSTALL/plugins, + where \c INSTALL is the directory where TQt was installed. Calling + queryAccessibleInterface( TQObject *object, TQAccessibleInterface + **iface ) will ask all plugins located in this directory for an + implementation that exposes the information for objects of the + class of \e object. + + To make a TQt application accessible you have to distribute the + accessibility plugin provded with TQt together with your + application. Simply add the plugins created in + INSTALL/plugins/accessibility to your distribution process. Use \l + TQApplication::addLibraryPath() to specify a plugin directory for + your application, and copy the files into an \e accessibility + subdirectory of one of those plugin directories. TQt's + accessibility framework will load the plugins upon request and use + the implementations provided to expose an object's accessibility + information. +\endomit + + See the \link plugins-howto.html plugin documentation \endlink for + more details about how to redistribute TQt plugins. +*/ + +/*! + \enum TQAccessible::State + + This enum type defines bitflags that can be combined to indicate + the state of the accessible object. The values are: + + \value Normal + \value Unavailable + \value Selected + \value Focused + \value Pressed + \value Checked + \value Mixed + \value ReadOnly + \value HotTracked + \value Default + \value Expanded + \value Collapsed + \value Busy + \value Floating + \value Marqueed + \value Animated + \value Invisible + \value Offscreen + \value Sizeable + \value Moveable + \value SelfVoicing + \value Focusable + \value Selectable + \value Linked + \value Traversed + \value MultiSelectable + \value ExtSelectable + \value AlertLow + \value AlertMedium + \value AlertHigh + \value Protected + \value Valid +*/ + +/*! + \enum TQAccessible::Event + + This enum type defines event types when the state of the + accessible object has changed. The event types are: + + \value SoundPlayed + \value Alert + \value ForegroundChanged + \value MenuStart + \value MenuEnd + \value PopupMenuStart + \value PopupMenuEnd + \value ContextHelpStart + \value ContextHelpEnd + \value DragDropStart + \value DragDropEnd + \value DialogStart + \value DialogEnd + \value ScrollingStart + \value ScrollingEnd + \value ObjectCreated + \value ObjectDestroyed + \value ObjectShow + \value ObjectHide + \value ObjectReorder + \value Focus + \value Selection + \value SelectionAdd + \value SelectionRemove + \value SelectionWithin + \value StateChanged + \value LocationChanged + \value NameChanged + \value DescriptionChanged + \value ValueChanged + \value ParentChanged + \value HelpChanged + \value DefaultActionChanged + \value AcceleratorChanged + \value MenuCommand +*/ + +/*! + \enum TQAccessible::Role + + This enum defines a number of roles an accessible object can have. + The roles are: + + \value NoRole + \value TitleBar + \value MenuBar + \value ScrollBar + \value Grip + \value Sound + \value Cursor + \value Caret + \value AlertMessage + \value Window + \value Client + \value PopupMenu + \value MenuItem + \value ToolTip + \value Application + \value Document + \value Pane + \value Chart + \value Dialog + \value Border + \value Grouping + \value Separator + \value ToolBar + \value StatusBar + \value Table + \value ColumnHeader + \value RowHeader + \value Column + \value Row + \value Cell + \value Link + \value HelpBalloon + \value Character + \value List + \value ListItem + \value Outline + \value OutlineItem + \value PageTab + \value PropertyPage + \value Indicator + \value Graphic + \value StaticText + \value EditableText + \value PushButton + \value CheckBox + \value RadioButton + \value ComboBox + \value DropLest + \value ProgressBar + \value Dial + \value HotkeyField + \value Slider + \value SpinBox + \value Diagram + \value Animation + \value Equation + \value ButtonDropDown + \value ButtonMenu + \value ButtonDropGrid + \value Whitespace + \value PageTabList + \value Clock +*/ + +/*! + \enum TQAccessible::NavDirection + + This enum specifies which item to move to when navigating. + + \value NavUp sibling above + \value NavDown sibling below + \value NavLeft left sibling + \value NavRight right sibling + \value NavNext next sibling + \value NavPrevious previous sibling + \value NavFirstChild first child + \value NavLastChild last child + \value NavFocusChild child with focus +*/ + +/*! + \enum TQAccessible::Text + + This enum specifies string information that an accessible object + returns. + + \value Name The name of the object + \value Description A short text describing the object + \value Value The value of the object + \value Help A longer text giving information about how + to use the object + \value DefaultAction The default method to interact with the object + \value Accelerator The keyboard shortcut that executes the + default action +*/ + +/*! + \fn static void TQAccessible::updateAccessibility( TQObject *object, int control, Event reason ) + + Notifies accessibility clients about a change in \a object's + accessibility information. + + \a reason specifies the cause of the change, for example, + ValueChange when the position of a slider has been changed. \a + control is the ID of the child element that has changed. When \a + control is 0, the object itself has changed. + + Call this function whenever the state of your accessible object or + one of it's sub-elements has been changed either programmatically + (e.g. by calling TQLabel::setText()) or by user interaction. + + If there are no accessibility tools listening to this event, the + performance penalty for calling this function is minor, but if determining + the parameters of the call is expensive you can use isActive() to + avoid unnecessary performance penalties if no client is listening. +*/ + +static TQPluginManager *qAccessibleManager = 0; + +class AccessibleCache : public TQObject, public TQPtrDict +{ + TQ_OBJECT +public: + AccessibleCache() + : TQPtrDict(73) + { + } + + void addObject(TQObject *object, TQAccessibleInterface *iface) + { + insert(object, iface); + connect(object, TQ_SIGNAL(destroyed(TQObject*)), this, TQ_SLOT(removeObject(TQObject*))); + } + +public slots: + void removeObject(TQObject *object); +}; + +#include "tqaccessible.moc" + +static AccessibleCache *qAccessibleInterface = 0; +static bool cleanupAdded = FALSE; + +static void qAccessibleCleanup() +{ + if ( qAccessibleInterface && qAccessibleInterface->count() && qAccessibleManager ) + qAccessibleManager->setAutoUnload( FALSE ); + + delete qAccessibleInterface; + qAccessibleInterface = 0; + delete qAccessibleManager; + qAccessibleManager = 0; +} + +#ifdef TQ_WS_MAC +TQObject *TQAccessible::queryAccessibleObject(TQAccessibleInterface *o) +{ + if(qAccessibleInterface) { + for(TQPtrDictIterator it(*qAccessibleInterface); it.current(); ++it) { + if(it.current() == o) + return (TQObject*)it.currentKey(); + } + } + return NULL; +} +#endif + +void AccessibleCache::removeObject(TQObject *object) +{ + if (!object) + return; + + remove(object); + if (!count()) { + delete this; + qAccessibleInterface = 0; + } +} + + +/*! + Sets \a iface to point to the implementation of the + TQAccessibleInterface for \a object, and returns \c TQS_OK if + successfull, or sets \a iface to 0 and returns \c TQE_NOCOMPONENT if + no accessibility implementation for \a object exists. + + The function uses the \link TQObject::className() classname + \endlink of \a object to find a suitable implementation. If no + implementation for the object's class is available the function + tries to find an implementation for the object's parent class. + + This function is called to answer an accessibility client's + request for object information. You should never need to call this + function yourself. +*/ +TQRESULT TQAccessible::queryAccessibleInterface( TQObject *object, TQAccessibleInterface **iface ) +{ + *iface = 0; + if ( !object ) + return TQE_INVALIDARG; + + if ( qAccessibleInterface ) { + *iface = qAccessibleInterface->find( object ); + if ( *iface ) { + (*iface)->addRef(); + return TQS_OK; + } + } + + if ( !qAccessibleManager ) { + qAccessibleManager = new TQPluginManager( IID_QAccessibleFactory, TQApplication::libraryPaths(), "/accessible" ); + if ( !cleanupAdded ) { + tqAddPostRoutine( qAccessibleCleanup ); + cleanupAdded = TRUE; + } + } + + TQInterfacePtr factory = 0; + TQMetaObject *mo = object->metaObject(); + while ( mo ) { + qAccessibleManager->queryInterface( mo->className(), &factory ); + if ( factory ) + break; + mo = mo->superClass(); + } + if ( factory ) + return factory->createAccessibleInterface( mo->className(), object, iface ); + + return TQE_NOCOMPONENT; +} + +/*! + Returns TRUE if an accessibility implementation has been requested, + during the runtime of the application, otherwise returns FALSE. + + Use this function to prevent potentially expensive notifications via + updateAccessibility(). + + \omit + TQListView uses this function to prevent index-lookups for item based + notifications. + \endomit +*/ +bool TQAccessible::isActive() +{ + return qAccessibleManager != 0; +} + +/*! + \class TQAccessibleInterface tqaccessible.h + \brief The TQAccessibleInterface class defines an interface that exposes information about accessible objects. + + \ingroup misc +*/ + +/*! + \fn bool TQAccessibleInterface::isValid() const + + Returns TRUE if all the data necessary to use this interface + implementation is valid (e.g. all pointers are non-null), + otherwise returns FALSE. +*/ + +/*! + \fn int TQAccessibleInterface::childCount() const + + Returns the number of children that belong to this object. A child + can provide accessibility information on it's own (e.g. a child + widget), or be a sub-element of this accessible object. + + All objects provide this information. + + \sa queryChild() +*/ + +/*! + \fn TQRESULT TQAccessibleInterface::queryChild( int control, TQAccessibleInterface **iface ) const + + Sets \a iface to point to the implementation of the + TQAccessibleInterface for the child specified with \a control. If + the child doesn't provide accessibility information on it's own, + the value of \a iface is set to 0. For those elements, this + object is responsible for exposing the child's properties. + + All objects provide this information. + + \sa childCount(), queryParent() +*/ + +/*! + \fn TQRESULT TQAccessibleInterface::queryParent( TQAccessibleInterface **iface ) const + + Sets \a iface to point to the implementation of the + TQAccessibleInterface for the parent object, or to 0 if there is + no such implementation or object. + + All objects provide this information. + + \sa queryChild() +*/ + +/*! + \fn int TQAccessibleInterface::controlAt( int x, int y ) const + + Returns the ID of the child that contains the screen coordinates + (\a x, \a y). This function returns 0 if the point is positioned + on the object itself. If the tested point is outside the + boundaries of the object this function returns -1. + + All visual objects provide this information. +*/ + +/*! + \fn TQRect TQAccessibleInterface::rect( int control ) const + + Returns the location of the child specified with \a control in + screen coordinates. This function returns the location of the + object itself if \a control is 0. + + All visual objects provide this information. +*/ + +/*! + \fn int TQAccessibleInterface::navigate( NavDirection direction, int startControl ) const + + This function traverses to another object, or to a sub-element of + the current object. \a direction specifies in which direction to + navigate, and \a startControl specifies the start point of the + navigation, which is either 0 if the navigation starts at the + object itself, or an ID of one of the object's sub-elements. + + The function returns the ID of the sub-element located in the \a + direction specified. If there is nothing in the navigated \a + direction, this function returns -1. + + All objects support navigation. +*/ + +/*! + \fn TQString TQAccessibleInterface::text( Text t, int control ) const + + Returns a string property \a t of the child object specified by \a + control, or the string property of the object itself if \a control + is 0. + + The \e Name is a string used by clients to identify, find or + announce an accessible object for the user. All objects must have + a name that is unique within their container. + + An accessible object's \e Description provides textual information + about an object's visual appearance. The description is primarily + used to provide greater context for low-vision or blind users, but + is also used for context searching or other applications. Not all + objects have a description. An "OK" button would not need a + description, but a toolbutton that shows a picture of a smiley + would. + + The \e Value of an accessible object represents visual information + contained by the object, e.g. the text in a line edit. Usually, + the value can be modified by the user. Not all objects have a + value, e.g. static text labels don't, and some objects have a + state that already is the value, e.g. toggle buttons. + + The \e Help text provides information about the function and + usage of an accessible object. Not all objects provide this + information. + + An accessible object's \e DefaultAction describes the object's + primary method of manipulation, and should be a verb or a short + phrase, e.g. "Press" for a button. + + The accelerator is a keyboard shortcut that activates the default + action of the object. A keyboard shortcut is the underlined + character in the text of a menu, menu item or control, and is + either the character itself, or a combination of this character + and a modifier key like ALT, CTRL or SHIFT. Command controls like + tool buttons also have shortcut keys and usually display them in + their tooltip. + + \sa role(), state(), selection() +*/ + +/*! + \fn void TQAccessibleInterface::setText( Text t, int control, const TQString &text ) + + Sets the text property \a t of the child object \a control to \a + text. If \a control is 0, the text property of the object itself + is set. +*/ + +/*! + \fn TQAccessible::Role TQAccessibleInterface::role( int control ) const + + Returns the role of the object if \a control is 0, or the role of + the object's sub-element with ID \a control. The role of an object + is usually static. All accessible objects have a role. + + \sa text(), state(), selection() +*/ + +/*! + \fn TQAccessible::State TQAccessibleInterface::state( int control ) const + + Returns the current state of the object if \a control is 0, or the + state of the object's sub-element element with ID \a control. All + objects have a state. + + \sa text(), role(), selection() +*/ + +/*! + \fn TQMemArray TQAccessibleInterface::selection() const + + Returns the list of all the element IDs that are selected. + + \sa text(), role(), state() +*/ + +/*! + \fn bool TQAccessibleInterface::doDefaultAction( int control ) + + Calling this function performs the default action of the child + object specified by \a control, or the default action of the + object itself if \a control is 0. +*/ + +/*! + \fn bool TQAccessibleInterface::setFocus( int control ) + + Gives the focus to the child object specified by \a control, or to + the object itself if \a control is 0. + + Returns TRUE if the focus could be set; otherwise returns FALSE. +*/ + +/*! + \fn bool TQAccessibleInterface::setSelected( int control, bool on, bool extend ) + + Sets the selection of the child object with ID \a control to \a + on. If \a extend is TRUE, all child elements between the focused + item and the specified child object have their selection set to \a + on. + + Returns TRUE if the selection could be set; otherwise returns + FALSE. + + \sa setFocus(), clearSelection() +*/ + +/*! + \fn void TQAccessibleInterface::clearSelection() + + Removes any selection from the object. + + \sa setSelected() +*/ + + + +/*! + \class TQAccessibleObject tqaccessible.h + \brief The TQAccessibleObject class implements parts of the + TQAccessibleInterface for TQObjects. + + \ingroup misc + + This class is mainly provided for convenience. All subclasses of + the TQAccessibleInterface should use this class as the base class. +*/ + +/*! + Creates a TQAccessibleObject for \a object. +*/ +TQAccessibleObject::TQAccessibleObject( TQObject *object ) +: object_(object) +{ + if ( !qAccessibleInterface ) { + qAccessibleInterface = new AccessibleCache; + if ( !cleanupAdded ) { + tqAddPostRoutine( qAccessibleCleanup ); + cleanupAdded = TRUE; + } + } + + qAccessibleInterface->addObject(object, this); +} + +/*! + Destroys the TQAccessibleObject. + + This only happens when a call to release() decrements the internal + reference counter to zero. +*/ +TQAccessibleObject::~TQAccessibleObject() +{ + if ( qAccessibleInterface ) { + qAccessibleInterface->removeObject(object_); + if ( !qAccessibleInterface->count() ) { + delete qAccessibleInterface; + qAccessibleInterface = 0; + } + } +} + +/*! + \reimp +*/ +TQRESULT TQAccessibleObject::queryInterface( const TQUuid &uuid, TQUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QAccessible ) + *iface = (TQAccessibleInterface*)this; + else if ( uuid == IID_QUnknown ) + *iface = (TQUnknownInterface*)this; + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +/*! + Returns the TQObject for which this TQAccessibleInterface + implementation provides information. Use isValid() to make sure + the object pointer is safe to use. +*/ +TQObject *TQAccessibleObject::object() const +{ +#if defined(QT_CHECK_RANGE) + if ( !isValid() ) + tqWarning( "TQAccessibleInterface is invalid. Crash pending..." ); +#endif + return object_; +} + +/*! + \reimp +*/ +bool TQAccessibleObject::isValid() const +{ + return !object_.isNull(); +} + +#endif diff --git a/src/kernel/tqaccessible.h b/src/kernel/tqaccessible.h new file mode 100644 index 000000000..25b12077e --- /dev/null +++ b/src/kernel/tqaccessible.h @@ -0,0 +1,295 @@ +/**************************************************************************** +** +** Definition of TQAccessible and TQAccessibleObject classes +** +** 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. +** +**********************************************************************/ + +#ifndef TQACCESSIBLE_H +#define TQACCESSIBLE_H + +#ifndef QT_H +#include "tqobject.h" +#include +#include "tqrect.h" +#include "tqguardedptr.h" +#include "tqmemarray.h" +#endif // QT_H + +#if defined(QT_ACCESSIBILITY_SUPPORT) + +struct TQAccessibleInterface; + +class TQ_EXPORT TQAccessible +{ +private: +#ifdef TQ_WS_MAC + static TQMAC_PASCAL OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *); + static TQObject *queryAccessibleObject(TQAccessibleInterface *); +#endif +public: + enum Event { + SoundPlayed = 0x0001, + Alert = 0x0002, + ForegroundChanged = 0x0003, + MenuStart = 0x0004, + MenuEnd = 0x0005, + PopupMenuStart = 0x0006, + PopupMenuEnd = 0x0007, + ContextHelpStart = 0x000C, + ContextHelpEnd = 0x000D, + DragDropStart = 0x000E, + DragDropEnd = 0x000F, + DialogStart = 0x0010, + DialogEnd = 0x0011, + ScrollingStart = 0x0012, + ScrollingEnd = 0x0013, + + MenuCommand = 0x0018, + + ObjectCreated = 0x8000, + ObjectDestroyed = 0x8001, + ObjectShow = 0x8002, + ObjectHide = 0x8003, + ObjectReorder = 0x8004, + Focus = 0x8005, + Selection = 0x8006, + SelectionAdd = 0x8007, + SelectionRemove = 0x8008, + SelectionWithin = 0x8009, + StateChanged = 0x800A, + LocationChanged = 0x800B, + NameChanged = 0x800C, + DescriptionChanged = 0x800D, + ValueChanged = 0x800E, + ParentChanged = 0x800F, + HelpChanged = 0x80A0, + DefaultActionChanged= 0x80B0, + AcceleratorChanged = 0x80C0 + }; + + enum State { + Normal = 0x00000000, + Unavailable = 0x00000001, + Selected = 0x00000002, + Focused = 0x00000004, + Pressed = 0x00000008, + Checked = 0x00000010, + Mixed = 0x00000020, + ReadOnly = 0x00000040, + HotTracked = 0x00000080, + Default = 0x00000100, + Expanded = 0x00000200, + Collapsed = 0x00000400, + Busy = 0x00000800, + Floating = 0x00001000, + Marqueed = 0x00002000, + Animated = 0x00004000, + Invisible = 0x00008000, + Offscreen = 0x00010000, + Sizeable = 0x00020000, + Moveable = 0x00040000, + SelfVoicing = 0x00080000, + Focusable = 0x00100000, + Selectable = 0x00200000, + Linked = 0x00400000, + Traversed = 0x00800000, + MultiSelectable = 0x01000000, + ExtSelectable = 0x02000000, + AlertLow = 0x04000000, + AlertMedium = 0x08000000, + AlertHigh = 0x10000000, + Protected = 0x20000000, + Valid = 0x3fffffff + }; + + enum Role { + NoRole = 0x00000000, + TitleBar = 0x00000001, + MenuBar = 0x00000002, + ScrollBar = 0x00000003, + Grip = 0x00000004, + Sound = 0x00000005, + Cursor = 0x00000006, + Caret = 0x00000007, + AlertMessage = 0x00000008, + Window = 0x00000009, + Client = 0x0000000A, + PopupMenu = 0x0000000B, + MenuItem = 0x0000000C, + ToolTip = 0x0000000D, + Application = 0x0000000E, + Document = 0x0000000F, + Pane = 0x00000010, + Chart = 0x00000011, + Dialog = 0x00000012, + Border = 0x00000013, + Grouping = 0x00000014, + Separator = 0x00000015, + ToolBar = 0x00000016, + StatusBar = 0x00000017, + Table = 0x00000018, + ColumnHeader = 0x00000019, + RowHeader = 0x0000001A, + Column = 0x0000001B, + Row = 0x0000001C, + Cell = 0x0000001D, + Link = 0x0000001E, + HelpBalloon = 0x0000001F, + Character = 0x00000020, + List = 0x00000021, + ListItem = 0x00000022, + Outline = 0x00000023, + OutlineItem = 0x00000024, + PageTab = 0x00000025, + PropertyPage = 0x00000026, + Indicator = 0x00000027, + Graphic = 0x00000028, + StaticText = 0x00000029, + EditableText = 0x0000002A, // Editable, selectable, etc. + PushButton = 0x0000002B, + CheckBox = 0x0000002C, + RadioButton = 0x0000002D, + ComboBox = 0x0000002E, + DropLest = 0x0000002F, + ProgressBar = 0x00000030, + Dial = 0x00000031, + HotkeyField = 0x00000032, + Slider = 0x00000033, + SpinBox = 0x00000034, + Diagram = 0x00000035, + Animation = 0x00000036, + Equation = 0x00000037, + ButtonDropDown = 0x00000038, + ButtonMenu = 0x00000039, + ButtonDropGrid = 0x0000003A, + Whitespace = 0x0000003B, + PageTabList = 0x0000003C, + Clock = 0x0000003D + }; + + enum NavDirection { + NavUp = 0x00000001, + NavDown = 0x00000002, + NavLeft = 0x00000003, + NavRight = 0x00000004, + NavNext = 0x00000005, + NavPrevious = 0x00000006, + NavFirstChild = 0x00000007, + NavLastChild = 0x00000008, + NavFocusChild = 0x00000009 + }; + + enum Text { + Name = 0, + Description, + Value, + Help, + Accelerator, + DefaultAction + }; + + static TQRESULT queryAccessibleInterface( TQObject *, TQAccessibleInterface ** ); + static void updateAccessibility( TQObject *, int who, Event reason ); + static bool isActive(); + + static void initialize(); + static void cleanup(); +}; + +// {EC86CB9C-5DA0-4c43-A739-13EBDF1C6B14} +#define IID_QAccessible TQUuid( 0xec86cb9c, 0x5da0, 0x4c43, 0xa7, 0x39, 0x13, 0xeb, 0xdf, 0x1c, 0x6b, 0x14 ) + +struct TQ_EXPORT TQAccessibleInterface : public TQAccessible, public TQUnknownInterface +{ + // check for valid pointers + virtual bool isValid() const = 0; + + // hierarchy + virtual int childCount() const = 0; + virtual TQRESULT queryChild( int control, TQAccessibleInterface** ) const = 0; + virtual TQRESULT queryParent( TQAccessibleInterface** ) const = 0; + + // navigation + virtual int controlAt( int x, int y ) const = 0; + virtual TQRect rect( int control ) const = 0; + virtual int navigate( NavDirection direction, int startControl ) const = 0; + + // properties and state + virtual TQString text( Text t, int control ) const = 0; + virtual void setText( Text t, int control, const TQString &text ) = 0; + virtual Role role( int control ) const = 0; + virtual State state( int control ) const = 0; + virtual TQMemArray selection() const = 0; + + // methods + virtual bool doDefaultAction( int control ) = 0; + virtual bool setFocus( int control ) = 0; + virtual bool setSelected( int control, bool on, bool extend ) = 0; + virtual void clearSelection() = 0; +}; + +// {49F4C6A7-412F-41DE-9E24-648843421FD3} +#ifndef IID_QAccessibleFactory +#define IID_QAccessibleFactory TQUuid( 0x49f4c6a7, 0x412f, 0x41de, 0x9e, 0x24, 0x64, 0x88, 0x43, 0x42, 0x1f, 0xd3 ) +#endif + +struct TQ_EXPORT TQAccessibleFactoryInterface : public TQAccessible, public TQFeatureListInterface +{ + virtual TQRESULT createAccessibleInterface( const TQString &, TQObject *, TQAccessibleInterface** ) = 0; +}; + +class TQ_EXPORT TQAccessibleObject : public TQObject, public TQAccessibleInterface +{ +public: + TQAccessibleObject( TQObject *object ); + virtual ~TQAccessibleObject(); + + TQRESULT queryInterface( const TQUuid &, TQUnknownInterface** ); + TQ_REFCOUNT + + bool isValid() const; + +protected: + TQObject *object() const; + +private: + TQGuardedPtr object_; +}; + +#define Q_DEFINED_QACCESSIBLE_OBJECT +#include "ntqwinexport.h" +#endif //QT_ACCESSIBILITY_SUPPORT + +#endif //TQACCESSIBLE_H diff --git a/src/kernel/tqasyncimageio.cpp b/src/kernel/tqasyncimageio.cpp new file mode 100644 index 000000000..56126b3d8 --- /dev/null +++ b/src/kernel/tqasyncimageio.cpp @@ -0,0 +1,1319 @@ +/**************************************************************************** +** +** Implementation of asynchronous image/movie loading classes +** +** Created : 970617 +** +** 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 "tqasyncimageio.h" + +#ifndef TQT_NO_ASYNC_IMAGE_IO + +#include "tqptrlist.h" +#include "ntqgif.h" +#include + +extern void tqt_init_image_handlers(); +extern void tqt_init_image_plugins(); + +#define Q_TRANSPARENT 0x00ffffff + +/*! + \class TQImageConsumer tqasyncimageio.h + \brief The TQImageConsumer class is an abstraction used by TQImageDecoder. + + \ingroup images + \ingroup graphics + \ingroup multimedia + + The TQMovie class, or TQLabel::setMovie(), are easy to use and for + most situations do what you want with regards animated images. + + A TQImageConsumer consumes information about changes to the TQImage + maintained by a TQImageDecoder. Think of the TQImage as the model or + source of the image data, with the TQImageConsumer as a view of + that data and the TQImageDecoder being the controller that + orchestrates the relationship between the model and the view. + + You'd use the TQImageConsumer class, for example, if you were + implementing a web browser with your own image loaders. + + \sa TQImageDecoder +*/ + +/*! + \fn void TQImageConsumer::changed(const TQRect&) + + Called when the given area of the image has changed. +*/ + +/*! + \fn void TQImageConsumer::end() + + Called when all the data from all the frames has been decoded and + revealed as changed(). +*/ + +/*! + \fn void TQImageConsumer::frameDone() + + One of the two frameDone() functions will be called when a frame + of an animated image has ended and been revealed as changed(). + + When this function is called, the current image should be + displayed. + + The decoder will not make any further changes to the image until + the next call to TQImageFormat::decode(). +*/ + +/*! + \overload void TQImageConsumer::frameDone( const TQPoint& offset, const TQRect& rect ) + + One of the two frameDone() functions will be called when a frame + of an animated image has ended and been revealed as changed(). + + When this function is called, the area \a rect in the current + image should be moved by \a offset and displayed. + + The decoder will not make any further changes to the image until + the next call to TQImageFormat::decode(). +*/ + +/*! + \fn void TQImageConsumer::setLooping(int n) + + Called to indicate that the sequence of frames in the image + should be repeated \a n times, including the sequence during + decoding. + + \list + \i 0 = Forever + \i 1 = Only display frames the first time through + \i 2 = Repeat once after first pass through images + \i etc. + \endlist + + To make the TQImageDecoder do this, just delete it and pass the + information to it again for decoding (setLooping() will be called + again, of course, but that can be ignored), or keep copies of the + changed areas at the ends of frames. +*/ + +/*! + \fn void TQImageConsumer::setFramePeriod(int milliseconds) + + Notes that the frame about to be decoded should not be displayed + until the given number of \a milliseconds after the time that this + function is called. Of course, the image may not have been + decoded by then, in which case the frame should not be displayed + until it is complete. A value of -1 (the assumed default) + indicates that the image should be displayed even while it is only + partially loaded. +*/ + +/*! + \fn void TQImageConsumer::setSize(int, int) + + This function is called as soon as the size of the image has been + determined. +*/ + + +/*! + \class TQImageDecoder tqasyncimageio.h + \brief The TQImageDecoder class is an incremental image decoder for all supported image formats. + + \ingroup images + \ingroup graphics + \ingroup multimedia + + New formats are installed by creating objects of class + TQImageFormatType; the TQMovie class can be used for all installed + incremental image formats. TQImageDecoder is only useful for + creating new ways of feeding data to an TQImageConsumer. + + A TQImageDecoder is a machine that decodes images. It takes encoded + image data via its decode() method and expresses its decoding by + supplying information to a TQImageConsumer. It implements its + decoding by using a TQImageFormat created by one of the + currently-existing TQImageFormatType factory objects. + + TQImageFormatType and TQImageFormat are the classes that you might + need to implement support for additional image formats. + + \legalese + + TQt supports GIF reading if it is configured that way during + installation (see ntqgif.h). If it is, we are required to state that + "The Graphics Interchange Format(c) is the Copyright property of + CompuServe Incorporated. GIF(sm) is a Service Mark property of + CompuServe Incorporated." + + \warning If you are in a country that recognizes software patents + and in which Unisys holds a patent on LZW compression and/or + decompression and you want to use GIF, Unisys may require you to + license that technology. Such countries include Canada, Japan, + the USA, France, Germany, Italy and the UK. + + GIF support may be removed completely in a future version of TQt. + We recommend using the MNG or PNG format. +*/ + +static const int max_header = 32; + + + + + +// See ntqgif.h for important information regarding this option +#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 +class TQGIFFormat : public TQImageFormat { +public: + TQGIFFormat(); + virtual ~TQGIFFormat(); + + int decode(TQImage& img, TQImageConsumer* consumer, + const uchar* buffer, int length); + +private: + void fillRect(TQImage&, int x, int y, int w, int h, TQRgb col); + TQRgb color( uchar index ) const; + + // GIF specific stuff + TQRgb* globalcmap; + TQRgb* localcmap; + TQImage backingstore; + unsigned char hold[16]; + bool gif89; + int count; + int ccount; + int expectcount; + enum State { + Header, + LogicalScreenDescriptor, + GlobalColorMap, + LocalColorMap, + Introducer, + ImageDescriptor, + TableImageLZWSize, + ImageDataBlockSize, + ImageDataBlock, + ExtensionLabel, + GraphicControlExtension, + ApplicationExtension, + NetscapeExtensionBlockSize, + NetscapeExtensionBlock, + SkipBlockSize, + SkipBlock, + Done, + Error + } state; + int gncols; + int lncols; + int ncols; + int lzwsize; + bool lcmap; + int swidth, sheight; + int width, height; + int left, top, right, bottom; + enum Disposal { NoDisposal, DoNotChange, RestoreBackground, RestoreImage }; + Disposal disposal; + bool disposed; + int trans_index; + bool gcmap; + int bgcol; + int interlace; + int accum; + int bitcount; + + enum { max_lzw_bits=12 }; // (poor-compiler's static const int) + + int code_size, clear_code, end_code, max_code_size, max_code; + int firstcode, oldcode, incode; + short table[2][1<< max_lzw_bits]; + short stack[(1<<(max_lzw_bits))*2]; + short *sp; + bool needfirst; + int x, y; + int frame; + bool out_of_bounds; + bool digress; + void nextY(TQImage& img, TQImageConsumer* consumer); + void disposePrevious( TQImage& img, TQImageConsumer* consumer ); +}; + +class TQGIFFormatType : public TQImageFormatType +{ + TQImageFormat* decoderFor(const uchar* buffer, int length); + const char* formatName() const; +}; + +#endif + + +class TQImageDecoderPrivate +{ +public: + TQImageDecoderPrivate() + { + count = 0; + } + + static void cleanup(); + + static void ensureFactories() + { + if ( !factories ) { + factories = new TQPtrList; +// See ntqgif.h for important information regarding this option +#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 + gif_decoder_factory = new TQGIFFormatType; +#endif + tqt_init_image_handlers(); + tqAddPostRoutine( cleanup ); + } + } + + static TQPtrList * factories; + +// See ntqgif.h for important information regarding this option +#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 + static TQGIFFormatType * gif_decoder_factory; +#endif + + uchar header[max_header]; + int count; +}; + +TQPtrList * TQImageDecoderPrivate::factories = 0; +// See ntqgif.h for important information regarding this option +#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 +TQGIFFormatType * TQImageDecoderPrivate::gif_decoder_factory = 0; +#endif + + +void TQImageDecoderPrivate::cleanup() +{ + delete factories; + factories = 0; +// See ntqgif.h for important information regarding this option +#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 + delete gif_decoder_factory; + gif_decoder_factory = 0; +#endif +} + + +/*! + Constructs a TQImageDecoder that will send change information to + the TQImageConsumer \a c. +*/ +TQImageDecoder::TQImageDecoder(TQImageConsumer* c) +{ + tqt_init_image_handlers(); + d = new TQImageDecoderPrivate; + TQ_CHECK_PTR(d); + consumer = c; + actual_decoder = 0; +} + +/*! + Destroys a TQImageDecoder. The image it built is destroyed. The + decoder built by the factory for the file format is destroyed. The + consumer for which it decoded the image is \e not destroyed. +*/ +TQImageDecoder::~TQImageDecoder() +{ + delete d; + delete actual_decoder; +} + +/*! + \fn const TQImage& TQImageDecoder::image() + + Returns the image currently being decoded. +*/ + +static bool plugins_loaded = FALSE; + +/*! + Call this function to decode some data into image changes. The + data in \a buffer will be decoded, sending change information to + the TQImageConsumer of this TQImageDecoder until one of the change + functions of the consumer returns FALSE. The length of the data is + given in \a length. + + Returns the number of bytes consumed: 0 if consumption is + complete, and -1 if decoding fails due to invalid data. +*/ +int TQImageDecoder::decode(const uchar* buffer, int length) +{ + if (!actual_decoder) { + int i=0; + + while (i < length && d->count < max_header) + d->header[d->count++] = buffer[i++]; + + TQImageDecoderPrivate::ensureFactories(); + + for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); + f && !actual_decoder; + f = TQImageDecoderPrivate::factories->next()) + { + actual_decoder = f->decoderFor(d->header, d->count); + } + if ( !actual_decoder && !plugins_loaded) { + tqt_init_image_plugins(); + plugins_loaded = TRUE; + + for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); + f && !actual_decoder; + f = TQImageDecoderPrivate::factories->next()) + { + actual_decoder = f->decoderFor(d->header, d->count); + } + } + + if (!actual_decoder) { + if ( d->count < max_header ) { + // not enough info yet + return i; + } else { + // failure - nothing matches max_header bytes + return -1; + } + } + } + return actual_decoder->decode(img, consumer, buffer, length); +} + +/*! + Returns a TQImageFormatType by name. This might be used when the + user needs to force data to be interpreted as being in a certain + format. \a name is one of the formats listed by + TQImageDecoder::inputFormats(). Note that you will still need to + supply decodable data to result->decoderFor() before you can begin + decoding the data. +*/ +TQImageFormatType* TQImageDecoder::format( const char* name ) +{ + TQImageDecoderPrivate::ensureFactories(); + tqt_init_image_plugins(); + + for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); + f; + f = TQImageDecoderPrivate::factories->next()) + { + if ( tqstricmp(name,f->formatName())==0 ) + return f; + } + return 0; +} + +/*! + Call this function to find the name of the format of the given + header. The returned string is statically allocated. The function + will look at the first \a length characters in the \a buffer. + + Returns 0 if the format is not recognized. +*/ +const char* TQImageDecoder::formatName(const uchar* buffer, int length) +{ + TQImageDecoderPrivate::ensureFactories(); + + const char* name = 0; + for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); + f && !name; + f = TQImageDecoderPrivate::factories->next()) + { + TQImageFormat *decoder = f->decoderFor(buffer, length); + if (decoder) { + name = f->formatName(); + delete decoder; + } + } + if ( !name && !plugins_loaded) { + tqt_init_image_plugins(); + plugins_loaded = TRUE; + for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); + f && !name; + f = TQImageDecoderPrivate::factories->next()) + { + TQImageFormat *decoder = f->decoderFor(buffer, length); + if (decoder) { + name = f->formatName(); + delete decoder; + } + } + } + + return name; +} + +/*! + Returns a sorted list of formats for which asynchronous loading is + supported. +*/ +TQStrList TQImageDecoder::inputFormats() +{ + TQImageDecoderPrivate::ensureFactories(); + tqt_init_image_plugins(); + + TQStrList result; + + for (TQImageFormatType* f = TQImageDecoderPrivate::factories->first(); + f; + f = TQImageDecoderPrivate::factories->next()) + { + if ( !result.contains( f->formatName() ) ) { + result.inSort( f->formatName() ); + } + } + + return result; +} + +/*! + Registers the new TQImageFormatType \a f. This is not needed in + application code because factories call this themselves. +*/ +void TQImageDecoder::registerDecoderFactory(TQImageFormatType* f) +{ + TQImageDecoderPrivate::ensureFactories(); + + TQImageDecoderPrivate::factories->insert(0,f); +} + +/*! + Unregisters the TQImageFormatType \a f. This is not needed in + application code because factories call this themselves. +*/ +void TQImageDecoder::unregisterDecoderFactory(TQImageFormatType* f) +{ + if ( !TQImageDecoderPrivate::factories ) + return; + + TQImageDecoderPrivate::factories->remove(f); +} + +/*! + \class TQImageFormat tqasyncimageio.h + \brief The TQImageFormat class is an incremental image decoder for a specific image format. + + \ingroup images + \ingroup graphics + \ingroup multimedia + + By making a derived class of TQImageFormatType, which in turn + creates objects that are a subclass of TQImageFormat, you can add + support for more incremental image formats, allowing such formats + to be sources for a TQMovie or for the first frame of the image + stream to be loaded as a TQImage or TQPixmap. + + Your new subclass must reimplement the decode() function in order + to process your new format. + + New TQImageFormat objects are generated by new TQImageFormatType + factories. +*/ + +/*! + Destroys the object. + + \internal + More importantly, destroys derived classes. +*/ +TQImageFormat::~TQImageFormat() +{ +} + +/*! + \fn int TQImageFormat::decode(TQImage& img, TQImageConsumer* consumer, const uchar* buffer, int length) + + New subclasses must reimplement this method. + + It should decode some or all of the bytes from \a buffer into \a + img, calling the methods of \a consumer as the decoding proceeds + to inform that consumer of changes to the image. The length of the + data is given in \a length. The consumer may be 0, in which case + the function should just process the data into \a img without + telling any consumer about the changes. Note that the decoder must + store enough state to be able to continue in subsequent calls to + this method - this is the essence of the incremental image + loading. + + The function should return without processing all the data if it + reaches the end of a frame in the input. + + The function must return the number of bytes it has processed. +*/ + +/*! + \class TQImageFormatType tqasyncimageio.h + \brief The TQImageFormatType class is a factory that makes TQImageFormat objects. + + \ingroup images + \ingroup graphics + \ingroup multimedia + + Whereas the TQImageIO class allows for \e complete loading of + images, TQImageFormatType allows for \e incremental loading of + images. + + New image file formats are installed by creating objects of + derived classes of TQImageFormatType. They must implement + decoderFor() and formatName(). + + TQImageFormatType is a very simple class. Its only task is to + recognize image data in some format and make a new object, + subclassed from TQImageFormat, which can decode that format. + + The factories for formats built into TQt are automatically defined + before any other factory is initialized. If two factories would + recognize an image format, the factory created last will override + the earlier one; you can thus override current and future built-in + formats. +*/ + +/*! + \fn virtual TQImageFormat* TQImageFormatType::decoderFor(const uchar* buffer, int length) + + Returns a decoder for decoding an image that starts with the bytes + in \a buffer. The length of the data is given in \a length. This + function should only return a decoder if it is certain that the + decoder applies to data with the given header. Returns 0 if there + is insufficient data in the header to make a positive + identification or if the data is not recognized. +*/ + +/*! + \fn virtual const char* TQImageFormatType::formatName() const + + Returns the name of the format supported by decoders from this + factory. The string is statically allocated. +*/ + +/*! + Constructs a factory. It automatically registers itself with + TQImageDecoder. +*/ +TQImageFormatType::TQImageFormatType() +{ + TQImageDecoder::registerDecoderFactory(this); +} + +/*! + Destroys a factory. It automatically unregisters itself from + TQImageDecoder. +*/ +TQImageFormatType::~TQImageFormatType() +{ + TQImageDecoder::unregisterDecoderFactory(this); +} + + +/*! + Returns TRUE if TQt was compiled with built-in GIF reading support; + otherwise returns FALSE. +*/ +bool qt_builtin_gif_reader() +{ +#if defined(QT_BUILTIN_GIF_READER) + return QT_BUILTIN_GIF_READER == 1; +#else + return 0; +#endif +} + +// See ntqgif.h for important information regarding this option +#if defined(QT_BUILTIN_GIF_READER) && QT_BUILTIN_GIF_READER == 1 + +/* -- NOTDOC + \class TQGIFFormat tqasyncimageio.h + \brief Incremental image decoder for GIF image format. + + \ingroup images + \ingroup graphics + + This subclass of TQImageFormat decodes GIF format images, + including animated GIFs. Internally in +*/ + +/*! + Constructs a TQGIFFormat. +*/ +TQGIFFormat::TQGIFFormat() +{ + globalcmap = 0; + localcmap = 0; + lncols = 0; + gncols = 0; + disposal = NoDisposal; + out_of_bounds = FALSE; + disposed = TRUE; + frame = -1; + state = Header; + count = 0; + lcmap = FALSE; +} + +/*! + Destroys a TQGIFFormat. +*/ +TQGIFFormat::~TQGIFFormat() +{ + if (globalcmap) delete[] globalcmap; + if ( localcmap ) delete[] localcmap; +} + + +/* -- NOTDOC + \class TQGIFFormatType tqasyncimageio.h + \brief Incremental image decoder for GIF image format. + + \ingroup images + \ingroup graphics + + This subclass of TQImageFormatType recognizes GIF + format images, creating a TQGIFFormat when required. An instance + of this class is created automatically before any other factories, + so you should have no need for such objects. +*/ + +TQImageFormat* TQGIFFormatType::decoderFor( + const uchar* buffer, int length) +{ + if (length < 6) return 0; + if (buffer[0]=='G' + && buffer[1]=='I' + && buffer[2]=='F' + && buffer[3]=='8' + && (buffer[4]=='9' || buffer[4]=='7') + && buffer[5]=='a') + return new TQGIFFormat; + return 0; +} + +const char* TQGIFFormatType::formatName() const +{ + return "GIF"; +} + + +void TQGIFFormat::disposePrevious( TQImage& img, TQImageConsumer* consumer ) +{ + if ( out_of_bounds ) // flush anything that survived + consumer->changed(TQRect(0,0,swidth,sheight)); + + // Handle disposal of previous image before processing next one + + if ( disposed ) return; + + int l = TQMIN(swidth-1,left); + int r = TQMIN(swidth-1,right); + int t = TQMIN(sheight-1,top); + int b = TQMIN(sheight-1,bottom); + + switch (disposal) { + case NoDisposal: + break; + case DoNotChange: + break; + case RestoreBackground: + if (trans_index>=0) { + // Easy: we use the transparent color + fillRect(img, l, t, r-l+1, b-t+1, Q_TRANSPARENT); + } else if (bgcol>=0) { + // Easy: we use the bgcol given + fillRect(img, l, t, r-l+1, b-t+1, color(bgcol)); + } else { + // Impossible: We don't know of a bgcol - use pixel 0 + TQRgb** line = (TQRgb **)img.jumpTable(); + fillRect(img, l, t, r-l+1, b-t+1, line[0][0]); + } + if (consumer) + consumer->changed(TQRect(l, t, r-l+1, b-t+1)); + break; + case RestoreImage: { + if ( frame >= 0 ) { + TQRgb** line = (TQRgb **)img.jumpTable(); + for (int ln=t; ln<=b; ln++) { + memcpy(line[ln]+l, + backingstore.scanLine(ln-t), + (r-l+1)*sizeof(TQRgb) ); + } + consumer->changed(TQRect(l, t, r-l+1, b-t+1)); + } + } + } + disposal = NoDisposal; // Until an extension says otherwise. + + disposed = TRUE; +} + +/*! + This function decodes some data into image changes. + + Returns the number of bytes consumed. +*/ +int TQGIFFormat::decode(TQImage& img, TQImageConsumer* consumer, + const uchar* buffer, int length) +{ + // We are required to state that + // "The Graphics Interchange Format(c) is the Copyright property of + // CompuServe Incorporated. GIF(sm) is a Service Mark property of + // CompuServe Incorporated." + +#define LM(l, m) (((m)<<8)|l) + digress = FALSE; + int initial = length; + TQRgb** line = (TQRgb **)img.jumpTable(); + while (!digress && length) { + length--; + unsigned char ch=*buffer++; + switch (state) { + case Header: + hold[count++]=ch; + if (count==6) { + // Header + gif89=(hold[3]!='8' || hold[4]!='7'); + state=LogicalScreenDescriptor; + count=0; + } + break; + case LogicalScreenDescriptor: + hold[count++]=ch; + if (count==7) { + // Logical Screen Descriptor + swidth=LM(hold[0], hold[1]); + sheight=LM(hold[2], hold[3]); + gcmap=!!(hold[4]&0x80); + //UNUSED: bpchan=(((hold[4]&0x70)>>3)+1); + //UNUSED: gcmsortflag=!!(hold[4]&0x08); + gncols=2<<(hold[4]&0x7); + bgcol=(gcmap) ? hold[5] : -1; + //aspect=hold[6] ? double(hold[6]+15)/64.0 : 1.0; + + trans_index = -1; + count=0; + ncols=gncols; + if (gcmap) { + ccount=0; + state=GlobalColorMap; + globalcmap = new TQRgb[gncols+1]; // +1 for trans_index + globalcmap[gncols] = Q_TRANSPARENT; + } else { + state=Introducer; + } + } + break; + case GlobalColorMap: case LocalColorMap: + hold[count++]=ch; + if (count==3) { + TQRgb rgb = tqRgb(hold[0], hold[1], hold[2]); + if ( state == LocalColorMap ) { + if ( ccount < lncols ) + localcmap[ccount] = rgb; + } else { + globalcmap[ccount] = rgb; + } + if (++ccount >= ncols) { + if ( state == LocalColorMap ) + state=TableImageLZWSize; + else + state=Introducer; + } + count=0; + } + break; + case Introducer: + hold[count++]=ch; + switch (ch) { + case ',': + state=ImageDescriptor; + break; + case '!': + state=ExtensionLabel; + break; + case ';': + if (consumer) { + if ( out_of_bounds ) // flush anything that survived + consumer->changed(TQRect(0,0,swidth,sheight)); + consumer->end(); + } + state=Done; + break; + default: + digress=TRUE; + // Unexpected Introducer - ignore block + state=Error; + } + break; + case ImageDescriptor: + hold[count++]=ch; + if (count==10) { + int newleft=LM(hold[1], hold[2]); + int newtop=LM(hold[3], hold[4]); + int newwidth=LM(hold[5], hold[6]); + int newheight=LM(hold[7], hold[8]); + + // disbelieve ridiculous logical screen sizes, + // unless the image frames are also large. + if ( swidth/10 > TQMAX(newwidth,200) ) + swidth = -1; + if ( sheight/10 > TQMAX(newheight,200) ) + sheight = -1; + + if ( swidth <= 0 ) + swidth = newleft + newwidth; + if ( sheight <= 0 ) + sheight = newtop + newheight; + + if (img.isNull()) { + if (!img.create(swidth, sheight, 32)) { + // Check if the attempt to create the image failed. If + // it did, the image is broken and we should give up. + state = Error; + return -1; + } + memset( img.bits(), 0, img.numBytes() ); + if (consumer) consumer->setSize(swidth, sheight); + } + img.setAlphaBuffer(trans_index >= 0); + line = (TQRgb **)img.jumpTable(); + + disposePrevious( img, consumer ); + disposed = FALSE; + + left = newleft; + top = newtop; + width = newwidth; + height = newheight; + + right=TQMAX( 0, TQMIN(left+width, swidth)-1); + bottom=TQMAX(0, TQMIN(top+height, sheight)-1); + lcmap=!!(hold[9]&0x80); + interlace=!!(hold[9]&0x40); + //bool lcmsortflag=!!(hold[9]&0x20); + lncols=lcmap ? (2<<(hold[9]&0x7)) : 0; + if (lncols) { + if ( localcmap ) + delete [] localcmap; + localcmap = new TQRgb[lncols+1]; + localcmap[lncols] = Q_TRANSPARENT; + ncols = lncols; + } else { + ncols = gncols; + } + frame++; + if ( frame == 0 ) { + if ( left || top || width= 0 ) { + fillRect(img, 0, 0, swidth, sheight, color(trans_index)); + if (consumer) consumer->changed(TQRect(0,0,swidth,sheight)); + } else if ( bgcol>=0 ) { + fillRect(img, 0, 0, swidth, sheight, color(bgcol)); + if (consumer) consumer->changed(TQRect(0,0,swidth,sheight)); + } + } + } + + if ( disposal == RestoreImage ) { + int l = TQMIN(swidth-1,left); + int r = TQMIN(swidth-1,right); + int t = TQMIN(sheight-1,top); + int b = TQMIN(sheight-1,bottom); + int w = r-l+1; + int h = b-t+1; + + if (backingstore.width() < w + || backingstore.height() < h) { + // We just use the backing store as a byte array + if(!backingstore.create( TQMAX(backingstore.width(), w), + TQMAX(backingstore.height(), h), + 32)) { + state = Error; + return -1; + } + memset( img.bits(), 0, img.numBytes() ); + } + for (int ln=0; ln=swidth || y>=sheight; + } + break; + case TableImageLZWSize: { + lzwsize=ch; + if ( lzwsize > max_lzw_bits ) { + state=Error; + } else { + code_size=lzwsize+1; + clear_code=1<frameDone(); + digress = TRUE; + } + + state=Introducer; + } + break; + case ImageDataBlock: + count++; + accum|=(ch<=code_size && state==ImageDataBlock) { + int code=accum&((1<>=code_size; + + if (code==clear_code) { + if (!needfirst) { + int i; + code_size=lzwsize+1; + max_code_size=2*clear_code; + max_code=clear_code+2; + for (i=0; i=swidth) out_of_bounds = TRUE; + needfirst=FALSE; + if (x>=left+width) { + x=left; + out_of_bounds = left>=swidth || y>=sheight; + nextY(img,consumer); + } + } else { + incode=code; + if (code>=max_code) { + *sp++=firstcode; + code=oldcode; + } + while (code>=clear_code) { + *sp++=table[1][code]; + if (code==table[0][code]) { + state=Error; + break; + } + if (sp-stack>=(1<<(max_lzw_bits))*2) { + state=Error; + break; + } + code=table[0][code]; + } + *sp++=firstcode=table[1][code]; + code=max_code; + if (code<(1<=max_code_size) + && (max_code_size<(1<stack) { + --sp; + if (!out_of_bounds && line && *sp!=trans_index) + line[y][x] = color(*sp); + x++; + if (x>=swidth) out_of_bounds = TRUE; + if (x>=left+width) { + x=left; + out_of_bounds = left>=swidth || y>=sheight; + nextY(img,consumer); + } + } + } + } + } + if (count==expectcount) { + count=0; + state=ImageDataBlockSize; + } + break; + case ExtensionLabel: + switch (ch) { + case 0xf9: + state=GraphicControlExtension; + break; + case 0xff: + state=ApplicationExtension; + break; +#if 0 + case 0xfe: + state=CommentExtension; + break; + case 0x01: + break; +#endif + default: + state=SkipBlockSize; + } + count=0; + break; + case ApplicationExtension: + if (count<11) hold[count]=ch; + count++; + if (count==hold[0]+1) { + if (tqstrncmp((char*)(hold+1), "NETSCAPE", 8)==0) { + // Looping extension + state=NetscapeExtensionBlockSize; + } else { + state=SkipBlockSize; + } + count=0; + } + break; + case NetscapeExtensionBlockSize: + expectcount=ch; + count=0; + if (expectcount) state=NetscapeExtensionBlock; + else state=Introducer; + break; + case NetscapeExtensionBlock: + if (count<3) hold[count]=ch; + count++; + if (count==expectcount) { + int loop = hold[0]+hold[1]*256; + if (consumer) consumer->setLooping(loop); + state=SkipBlockSize; // Ignore further blocks + } + break; + case GraphicControlExtension: + if (count<5) hold[count]=ch; + count++; + if (count==hold[0]+1) { + disposePrevious( img, consumer ); + disposal=Disposal((hold[1]>>2)&0x7); + //UNUSED: waitforuser=!!((hold[1]>>1)&0x1); + int delay=count>3 ? LM(hold[2], hold[3]) : 1; + // IE and mozilla use a minimum delay of 10. With the minumum delay of 10 + // we are compatible to them and avoid huge loads on the app and xserver. + if ( delay < 10 ) + delay = 10; + + bool havetrans=hold[1]&0x1; + trans_index = havetrans ? hold[4] : -1; + + if (consumer) consumer->setFramePeriod(delay*10); + count=0; + state=SkipBlockSize; + } + break; + case SkipBlockSize: + expectcount=ch; + count=0; + if (expectcount) state=SkipBlock; + else state=Introducer; + break; + case SkipBlock: + count++; + if (count==expectcount) state=SkipBlockSize; + break; + case Done: + digress=TRUE; + /* Netscape ignores the junk, so we do too. + length++; // Unget + state=Error; // More calls to this is an error + */ + break; + case Error: + return -1; // Called again after done. + } + } + return initial-length; +} + +void TQGIFFormat::fillRect(TQImage& img, int col, int row, int w, int h, TQRgb color) +{ + if (w>0) { + TQRgb** line = (TQRgb **)img.jumpTable() + row; + for (int j=0; jchanged(TQRect(left, y, right-left+1, 1)); + y++; + break; + case 1: + { + int i; + my = TQMIN(7, bottom-y); + if ( trans_index < 0 ) // Don't dup with transparency + for (i=1; i<=my; i++) + memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, + (right-left+1)*sizeof(TQRgb)); + if (consumer && !out_of_bounds) + consumer->changed(TQRect(left, y, right-left+1, my+1)); + y+=8; + if (y>bottom) { + interlace++; y=top+4; + if (y > bottom) { // for really broken GIFs with bottom < 5 + interlace=2; + y = top + 2; + if (y > bottom) { // for really broken GIF with bottom < 3 + interlace = 0; + y = top + 1; + } + } + } + } break; + case 2: + { + int i; + my = TQMIN(3, bottom-y); + if ( trans_index < 0 ) // Don't dup with transparency + for (i=1; i<=my; i++) + memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, + (right-left+1)*sizeof(TQRgb)); + if (consumer && !out_of_bounds) + consumer->changed(TQRect(left, y, right-left+1, my+1)); + y+=8; + if (y>bottom) { + interlace++; y=top+2; + if (y > bottom) { // for really broken GIF with bottom < 3 + interlace = 3; + y = top + 1; + } + } + } break; + case 3: + { + int i; + my = TQMIN(1, bottom-y); + if ( trans_index < 0 ) // Don't dup with transparency + for (i=1; i<=my; i++) + memcpy(img.scanLine(y+i)+left, img.scanLine(y)+left, + (right-left+1)*sizeof(TQRgb)); + if (consumer && !out_of_bounds) + consumer->changed(TQRect(left, y, right-left+1, my+1)); + y+=4; + if (y>bottom) { interlace++; y=top+1; } + } break; + case 4: + if (consumer && !out_of_bounds) + consumer->changed(TQRect(left, y, right-left+1, 1)); + y+=2; + } + + // Consume bogus extra lines + if (y >= sheight) out_of_bounds=TRUE; //y=bottom; +} + +TQRgb TQGIFFormat::color( uchar index ) const +{ + if ( index == trans_index || index > ncols ) + return Q_TRANSPARENT; + TQRgb *map = lcmap ? localcmap : globalcmap; + return map ? map[index] : 0; +} + + + +#endif // QT_BUILTIN_GIF_READER + +#endif // TQT_NO_ASYNC_IMAGE_IO diff --git a/src/kernel/tqasyncimageio.h b/src/kernel/tqasyncimageio.h new file mode 100644 index 000000000..28d5bd50e --- /dev/null +++ b/src/kernel/tqasyncimageio.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Definition of asynchronous image/movie loading classes +** +** Created : 970617 +** +** 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 TQASYNCIMAGEIO_H +#define TQASYNCIMAGEIO_H + +#ifndef QT_H +#include "tqimage.h" +#endif // QT_H + +#ifndef TQT_NO_ASYNC_IMAGE_IO + +#if __GNUC__ - 0 > 3 +#pragma GCC system_header +#endif + +class TQ_EXPORT TQImageConsumer { +public: + virtual void end()=0; + + // Change transfer type 1. + virtual void changed( const TQRect& ) = 0; + virtual void frameDone() = 0; + + // Change transfer type 2. + virtual void frameDone( const TQPoint&, const TQRect& ) = 0; + + virtual void setLooping( int ) = 0; + virtual void setFramePeriod( int ) = 0; + virtual void setSize( int, int ) = 0; +}; + +class TQ_EXPORT TQImageFormat { +public: + virtual ~TQImageFormat(); + virtual int decode( TQImage& img, TQImageConsumer* consumer, + const uchar* buffer, int length ) = 0; +}; + +class TQ_EXPORT TQImageFormatType { +public: + virtual ~TQImageFormatType(); + virtual TQImageFormat* decoderFor( const uchar* buffer, int length ) = 0; + virtual const char* formatName() const = 0; +protected: + TQImageFormatType(); +}; + +class TQImageDecoderPrivate; +class TQ_EXPORT TQImageDecoder { +public: + TQImageDecoder( TQImageConsumer* c ); + ~TQImageDecoder(); + + const TQImage& image() { return img; } + int decode( const uchar* buffer, int length ); + + static const char* formatName( const uchar* buffer, int length ); + static TQImageFormatType* format( const char* name ); // direct use - no decode() + + static TQStrList inputFormats(); + static void registerDecoderFactory( TQImageFormatType* ); + static void unregisterDecoderFactory( TQImageFormatType* ); + +private: + TQImageFormat* actual_decoder; + TQImageConsumer* consumer; + TQImage img; + TQImageDecoderPrivate *d; +}; + +#endif // TQT_NO_ASYNC_IMAGE_IO + +#endif // TQASYNCIMAGEIO_H diff --git a/src/kernel/tqasyncio.cpp b/src/kernel/tqasyncio.cpp new file mode 100644 index 000000000..c8fe10ce4 --- /dev/null +++ b/src/kernel/tqasyncio.cpp @@ -0,0 +1,360 @@ +/**************************************************************************** +** +** Implementation of asynchronous I/O classes +** +** Created : 970617 +** +** 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 "tqasyncio.h" +#include "tqiodevice.h" +#include + +#ifndef TQT_NO_ASYNC_IO + +/*! + \class TQAsyncIO tqasyncio.h + \obsolete + \brief The TQAsyncIO class encapsulates I/O asynchronicity. + + The TQt classes for asynchronous input/output provide a simple + mechanism to allow large files or slow data sources to be processed + without using large amounts of memory or blocking the user interface. + + This facility is used in TQt to drive animated images. See TQImageConsumer. +*/ + + +/*! + Destroys the async IO object. +*/ +TQAsyncIO::~TQAsyncIO() +{ +} + +/*! + Ensures that only one object, \a obj and function, \a member, can + respond to changes in readiness. +*/ +void TQAsyncIO::connect(TQObject* obj, const char *member) +{ + signal.disconnect(0, 0); + signal.connect(obj, member); +} + +/*! + Derived classes should call this when they change from being + unready to ready. +*/ +void TQAsyncIO::ready() +{ + signal.activate(); +} + + + +/*! + \class TQDataSink tqasyncio.h + \obsolete + \brief The TQDataSink class is an asynchronous consumer of data. + + A data sink is an object which receives data from some source in an + asynchronous manner. This means that at some time not determined by + the data sink, blocks of data are given to it from processing. The + data sink is able to limit the maximum size of such blocks which it + is currently able to process. + + \sa TQAsyncIO, TQDataSource, TQDataPump +*/ + +/*! + \fn int TQDataSink::readyToReceive() + + The data sink should return a value indicating how much data it is ready + to consume. This may be 0. +*/ + +/*! + This should be called whenever readyToReceive() might have become non-zero. + It is merely calls TQAsyncIO::ready() if readyToReceive() is non-zero. +*/ +void TQDataSink::maybeReady() +{ + if (readyToReceive()) ready(); +} + +/*! + \fn void TQDataSink::receive(const uchar*, int count) + + This function is called to provide data for the data sink. The \a count + will be no more than the amount indicated by the most recent call to + readyToReceive(). The sink must use all the provided data. +*/ + +/*! + \fn void TQDataSink::eof() + + This function will be called when no more data is available for + processing. +*/ + + +/*! + \class TQDataSource tqasyncio.h + \obsolete + \brief The TQDataSource class is an asynchronous producer of data. + + A data source is an object which provides data from some source in an + asynchronous manner. This means that at some time not determined by + the data source, blocks of data will be taken from it for processing. + The data source is able to limit the maximum size of such blocks which + it is currently able to provide. + + \sa TQAsyncIO, TQDataSink, TQDataPump +*/ + +/*! + \fn int TQDataSource::readyToSend() + + The data source should return a value indicating how much data it is ready + to provide. This may be 0. If the data source knows it will never be + able to provide any more data (until after a rewind()), it may return -1. +*/ + +/*! + This should be called whenever readyToSend() might have become non-zero. + It is merely calls TQAsyncIO::ready() if readyToSend() is non-zero. +*/ +void TQDataSource::maybeReady() +{ + if (readyToSend()) ready(); +} + +/*! + \fn void TQDataSource::sendTo(TQDataSink*, int count) + + This function is called to extract data from the source, by sending + it to the given data sink. The \a count will be no more than the amount + indicated by the most recent call to readyToSend(). The source must + use all the provided data, and the sink will be prepared to accept at + least this much data. +*/ + +/*! + This function should return TRUE if the data source can be rewound. + + The default returns FALSE. +*/ +bool TQDataSource::rewindable() const +{ + return FALSE; +} + +/*! + If this function is called with \a on set to TRUE, and rewindable() + is TRUE, then the data source must take measures to allow the rewind() + function to subsequently operate as described. If rewindable() is FALSE, + the function should call TQDataSource::enableRewind(), which aborts with + a tqFatal() error. + + For example, a network connection may choose to use a disk cache + of input only if rewinding is enabled before the first buffer-full of + data is discarded, returning FALSE in rewindable() if that first buffer + is discarded. +*/ +void TQDataSource::enableRewind( bool /* on */ ) +{ + tqFatal( "Attempted to make unrewindable TQDataSource rewindable" ); +} + +/*! + This function rewinds the data source. This may only be called if + enableRewind(TRUE) has been previously called. +*/ +void TQDataSource::rewind() +{ + tqFatal("Attempted to rewind unrewindable TQDataSource"); +} + +/*! + \class TQIODeviceSource tqasyncio.h + \obsolete + \brief The TQIODeviceSource class is a TQDataSource that draws data from a TQIODevice. + + This class encapsulates retrieving data from a TQIODevice (such as a TQFile). +*/ + +/*! + Constructs a TQIODeviceSource from the TQIODevice \a device. The TQIODevice + \e must be dynamically allocated, becomes owned by the TQIODeviceSource, + and will be deleted when the TQIODeviceSource is destroyed. \a buffer_size + determines the size of buffering to use between asynchronous operations. + The higher the \a buffer_size, the more efficient, but the less interleaved + the operation will be with other processing. +*/ +TQIODeviceSource::TQIODeviceSource(TQIODevice* device, int buffer_size) : + buf_size(buffer_size), + buffer(new uchar[buf_size]), + iod(device), + rew(FALSE) +{ +} + +/*! + Destroys the TQIODeviceSource, deleting the TQIODevice from which it was + constructed. +*/ +TQIODeviceSource::~TQIODeviceSource() +{ + delete iod; + delete [] buffer; +} + +/*! + Ready until end-of-file. +*/ +int TQIODeviceSource::readyToSend() +{ + if ( iod->status() != IO_Ok || !(iod->state() & IO_Open) ) + return -1; + + int n = TQMIN((uint)buf_size, iod->size()-iod->at()); // ### not 64-bit safe + // ### not large file safe + return n ? n : -1; +} + +/*! + Reads a block of data and sends up to \a n bytes to the \a sink. +*/ +void TQIODeviceSource::sendTo(TQDataSink* sink, int n) +{ + iod->readBlock((char*)buffer, n); + sink->receive(buffer, n); +} + +/*! + All TQIODeviceSource's are rewindable. +*/ +bool TQIODeviceSource::rewindable() const +{ + return TRUE; +} + +/*! + If \a on is set to TRUE then rewinding is enabled. + No special action is taken. If \a on is set to + FALSE then rewinding is disabled. +*/ +void TQIODeviceSource::enableRewind(bool on) +{ + rew = on; +} + +/*! + Calls reset() on the TQIODevice. +*/ +void TQIODeviceSource::rewind() +{ + if (!rew) { + TQDataSource::rewind(); + } else { + iod->reset(); + ready(); + } +} + + +/*! + \class TQDataPump tqasyncio.h + \obsolete + \brief The TQDataPump class moves data from a TQDataSource to a TQDataSink during event processing. + + For a TQDataSource to provide data to a TQDataSink, a controller must exist + to examine the TQDataSource::readyToSend() and TQDataSink::readyToReceive() + methods and respond to the TQASyncIO::activate() signal of the source and + sink. One very useful way to do this is interleaved with other event + processing. TQDataPump provides this - create a pipe between a source + and a sink, and data will be moved during subsequent event processing. + + Note that each source can only provide data to one sink and each sink + can only receive data from one source (although it is quite possible + to write a multiplexing sink that is multiple sources). +*/ + +/*! + Constructs a TQDataPump to move data from a given \a data_source + to a given \a data_sink. +*/ +TQDataPump::TQDataPump(TQDataSource* data_source, TQDataSink* data_sink) : + source(data_source), sink(data_sink) +{ + source->connect(this, TQ_SLOT(kickStart())); + sink->connect(this, TQ_SLOT(kickStart())); + connect(&timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(tryToPump())); + timer.start(0, TRUE); +} + +void TQDataPump::kickStart() +{ + if (!timer.isActive()) { + interval = 0; + timer.start(0, TRUE); + } +} + +void TQDataPump::tryToPump() +{ + int supply, demand; + + supply = source->readyToSend(); + demand = sink->readyToReceive(); + if (demand <= 0) { + return; + } + interval = 0; + if (supply < 0) { + // All done (until source signals change in readiness) + sink->eof(); + return; + } + if (!supply) + return; + source->sendTo(sink, TQMIN(supply, demand)); + + timer.start(0, TRUE); +} + +#endif // TQT_NO_ASYNC_IO + diff --git a/src/kernel/tqasyncio.h b/src/kernel/tqasyncio.h new file mode 100644 index 000000000..6c1687e9d --- /dev/null +++ b/src/kernel/tqasyncio.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Definition of asynchronous I/O classes +** +** Created : 970617 +** +** 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 TQASYNCIO_H +#define TQASYNCIO_H + +#ifndef QT_H +#include "tqobject.h" +#include "tqsignal.h" +#include "tqtimer.h" +#endif // QT_H + +#ifndef TQT_NO_ASYNC_IO + +class TQIODevice; + +class TQ_EXPORT TQAsyncIO { +public: + virtual ~TQAsyncIO(); + void connect(TQObject*, const char *member); + +protected: + void ready(); + +private: + TQSignal signal; +}; + +class TQ_EXPORT TQDataSink : public TQAsyncIO { +public: + // Call this to know how much I can take. + virtual int readyToReceive()=0; + virtual void receive(const uchar*, int count)=0; + virtual void eof()=0; + void maybeReady(); +}; + +class TQ_EXPORT TQDataSource : public TQAsyncIO { +public: + virtual int readyToSend()=0; // returns -1 when never any more ready + virtual void sendTo(TQDataSink*, int count)=0; + void maybeReady(); + + virtual bool rewindable() const; + virtual void enableRewind(bool); + virtual void rewind(); +}; + +class TQ_EXPORT TQIODeviceSource : public TQDataSource { + const int buf_size; + uchar *buffer; + TQIODevice* iod; + bool rew; + +public: + TQIODeviceSource(TQIODevice*, int bufsize=4096); + ~TQIODeviceSource(); + + int readyToSend(); + void sendTo(TQDataSink* sink, int n); + bool rewindable() const; + void enableRewind(bool on); + void rewind(); +}; + +class TQ_EXPORT TQDataPump : public TQObject { + TQ_OBJECT + int interval; + TQTimer timer; + TQDataSource* source; + TQDataSink* sink; + +public: + TQDataPump(TQDataSource*, TQDataSink*); + +private slots: + void kickStart(); + void tryToPump(); +}; + +#endif // TQT_NO_ASYNC_IO + +#endif diff --git a/src/kernel/tqconnection.cpp b/src/kernel/tqconnection.cpp new file mode 100644 index 000000000..14c7ca41c --- /dev/null +++ b/src/kernel/tqconnection.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Implementation of TQConnection class +** +** Created : 930417 +** +** 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 "tqconnection.h" + +/*! \class TQConnection tqconnection.h + \brief The TQConnection class is an internal class, used in the signal/slot mechanism. + + \internal + + Do not use this class directly in application programs. + + TQObject has a list of TQConnection for each signal that is connected to the + outside world. +*/ + +TQConnection::TQConnection( const TQObject *object, int member, + const char *memberName, int memberType ) +{ + obj = (TQObject *)object; + mbr = member; + mbr_name = memberName; + mbr_type = memberType; + nargs = 0; + if ( strstr(memberName,"()") == 0 ) { + const char *p = memberName; + nargs++; + while ( *p ) { + if ( *p++ == ',' ) + nargs++; + } + } +} + +/*! + \fn TQConnection::~TQConnection() +*/ + +/*! + \fn bool TQConnection::isConnected() const +*/ + +/*! + \fn TQObject *TQConnection::object() const +*/ + +/*! + \fn int TQConnection::member() const +*/ + +/*! + \fn const char *TQConnection::memberName() const +*/ + +/*! + \fn int TQConnection::numArgs() const +*/ diff --git a/src/kernel/tqconnection.h b/src/kernel/tqconnection.h new file mode 100644 index 000000000..6906184b7 --- /dev/null +++ b/src/kernel/tqconnection.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Definition of TQConnection class +** +** Created : 930417 +** +** 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 TQCONNECTION_H +#define TQCONNECTION_H + +#ifndef QT_H +#include "tqobject.h" +#endif // QT_H + +class TQ_EXPORT TQConnection +{ +public: + TQConnection( const TQObject *, int, const char *memberName, int memberType ); + ~TQConnection() {} + + bool isConnected() const { return obj != 0; } + + TQObject *object() const { return obj; } // get object/member pointer + int member() const { return mbr; } + const char *memberName() const { return mbr_name; } + int memberType() const { return mbr_type; } + int numArgs() const { return nargs; } + +private: + TQObject *obj; // object connected to + int mbr; // member connected to + const char *mbr_name; + int mbr_type; + int nargs; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQConnection( const TQConnection & ); + TQConnection &operator=( const TQConnection & ); +#endif +}; + +#define Q_DEFINED_QCONNECTION +#include "ntqwinexport.h" +#endif // TQCONNECTION_H diff --git a/src/kernel/tqcursor.cpp b/src/kernel/tqcursor.cpp new file mode 100644 index 000000000..c29d51311 --- /dev/null +++ b/src/kernel/tqcursor.cpp @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Implementation of TQCursor class +** +** Created : 940220 +** +** 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 "tqcursor.h" + +#ifndef TQT_NO_CURSOR + +#include "tqbitmap.h" +#include "tqimage.h" +#include "tqdatastream.h" + + +/*! + \class TQCursor tqcursor.h + + \brief The TQCursor class provides a mouse cursor with an arbitrary + shape. + + \ingroup appearance + \ingroup shared + + This class is mainly used to create mouse cursors that are + associated with particular widgets and to get and set the position + of the mouse cursor. + + TQt has a number of standard cursor shapes, but you can also make + custom cursor shapes based on a TQBitmap, a mask and a hotspot. + + To associate a cursor with a widget, use TQWidget::setCursor(). To + associate a cursor with all widgets (normally for a short period + of time), use TQApplication::setOverrideCursor(). + + To set a cursor shape use TQCursor::setShape() or use the TQCursor + constructor which takes the shape as argument, or you can use one + of the predefined cursors defined in the \l CursorShape enum. + + If you want to create a cursor with your own bitmap, either use + the TQCursor constructor which takes a bitmap and a mask or the + constructor which takes a pixmap as arguments. + + To set or get the position of the mouse cursor use the static + methods TQCursor::pos() and TQCursor::setPos(). + + \img cursors.png Cursor Shapes + + \sa TQWidget \link guibooks.html#fowler GUI Design Handbook: + Cursors\endlink + + On X11, TQt supports the \link + http://www.xfree86.org/4.3.0/Xcursor.3.html Xcursor\endlink + library, which allows for full color icon themes. The table below + shows the cursor name used for each TQt::CursorShape value. If a + cursor cannot be found using the name shown below, a standard X11 + cursor will be used instead. Note: X11 does not provide + appropriate cursors for all possible TQt::CursorShape values. It + is possible that some cursors will be taken from the Xcursor + theme, while others will use an internal bitmap cursor. + + \table + \header \i TQt::CursorShape Values \i Cursor Names + \row \i TQt::ArrowCursor \i left_ptr + \row \i TQt::UpArrowCursor \i up_arrow + \row \i TQt::CrossCursor \i cross + \row \i TQt::WaitCursor \i wait + \row \i TQt::BusyCursor \i left_ptr_watch + \row \i TQt::IbeamCursor \i ibeam + \row \i TQt::SizeVerCursor \i size_ver + \row \i TQt::SizeHorCursor \i size_hor + \row \i TQt::SizeBDiagCursor \i size_bdiag + \row \i TQt::SizeFDiagCursor \i size_fdiag + \row \i TQt::SizeAllCursor \i size_all + \row \i TQt::SplitVCursor \i split_v + \row \i TQt::SplitHCursor \i split_h + \row \i TQt::PointingHandCursor \i pointing_hand + \row \i TQt::ForbiddenCursor \i forbidden + \row \i TQt::WhatsThisCursor \i whats_this + \endtable +*/ + +/*! + \enum TQt::CursorShape + + This enum type defines the various cursors that can be used. + + \value ArrowCursor standard arrow cursor + \value UpArrowCursor upwards arrow + \value CrossCursor crosshair + \value WaitCursor hourglass/watch + \value BusyCursor standard arrow with hourglass/watch + \value IbeamCursor ibeam/text entry + \value SizeVerCursor vertical resize + \value SizeHorCursor horizontal resize + \value SizeFDiagCursor diagonal resize (\) + \value SizeBDiagCursor diagonal resize (/) + \value SizeAllCursor all directions resize + \value BlankCursor blank/invisible cursor + \value SplitVCursor vertical splitting + \value SplitHCursor horizontal splitting + \value PointingHandCursor a pointing hand + \value ForbiddenCursor a slashed circle + \value WhatsThisCursor an arrow with a question mark + \value BitmapCursor + + ArrowCursor is the default for widgets in a normal state. + + \img cursors.png Cursor Shapes +*/ + +/***************************************************************************** + TQCursor stream functions + *****************************************************************************/ + +#ifndef TQT_NO_DATASTREAM + + +/*! + \relates TQCursor + Writes the cursor \a c to the stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator<<( TQDataStream &s, const TQCursor &c ) +{ + s << (TQ_INT16)c.shape(); // write shape id to stream + if ( c.shape() == TQt::BitmapCursor ) { // bitmap cursor +#if !defined(TQT_NO_IMAGEIO) + s << *c.bitmap() << *c.mask(); + s << c.hotSpot(); +#else + tqWarning("No Image Cursor I/O"); +#endif + } + return s; +} + +/*! + \relates TQCursor + Reads a cursor from the stream \a s and sets \a c to the read data. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQCursor &c ) +{ + TQ_INT16 shape; + s >> shape; // read shape id from stream + if ( shape == TQt::BitmapCursor ) { // read bitmap cursor +#if !defined(TQT_NO_IMAGEIO) + TQBitmap bm, bmm; + TQPoint hot; + s >> bm >> bmm >> hot; + c = TQCursor( bm, bmm, hot.x(), hot.y() ); +#else + tqWarning("No Image Cursor I/O"); +#endif + } else { + c.setShape( (int)shape ); // create cursor with shape + } + return s; +} +#endif // TQT_NO_DATASTREAM + + +/*! + Constructs a custom pixmap cursor. + + \a pixmap is the image. It is usual to give it a mask (set using + TQPixmap::setMask()). \a hotX and \a hotY define the cursor's hot + spot. + + If \a hotX is negative, it is set to the \c{pixmap().width()/2}. + If \a hotY is negative, it is set to the \c{pixmap().height()/2}. + + Valid cursor sizes depend on the display hardware (or the + underlying window system). We recommend using 32x32 cursors, + because this size is supported on all platforms. Some platforms + also support 16x16, 48x48 and 64x64 cursors. + + Currently, only black-and-white pixmaps can be used. + + \sa TQPixmap::TQPixmap(), TQPixmap::setMask() +*/ + +TQCursor::TQCursor( const TQPixmap &pixmap, int hotX, int hotY ) +{ + TQImage img = pixmap.convertToImage(). + convertDepth( 8, TQt::ThresholdDither|TQt::AvoidDither ); + TQBitmap bm; + bm.convertFromImage( img, TQt::ThresholdDither|TQt::AvoidDither ); + TQBitmap bmm; + if ( bm.mask() ) { + bmm = *bm.mask(); + TQBitmap nullBm; + bm.setMask( nullBm ); + } + else if ( pixmap.mask() ) { + TQImage mimg = pixmap.mask()->convertToImage(). + convertDepth( 8, TQt::ThresholdDither|TQt::AvoidDither ); + bmm.convertFromImage( mimg, TQt::ThresholdDither|TQt::AvoidDither ); + } + else { + bmm.resize( bm.size() ); + bmm.fill( TQt::color1 ); + } + + setBitmap(bm,bmm,hotX,hotY); +} + + + +/*! + Constructs a custom bitmap cursor. + + \a bitmap and + \a mask make up the bitmap. + \a hotX and + \a hotY define the cursor's hot spot. + + If \a hotX is negative, it is set to the \c{bitmap().width()/2}. + If \a hotY is negative, it is set to the \c{bitmap().height()/2}. + + The cursor \a bitmap (B) and \a mask (M) bits are combined like this: + \list + \i B=1 and M=1 gives black. + \i B=0 and M=1 gives white. + \i B=0 and M=0 gives transparent. + \i B=1 and M=0 gives an undefined result. + \endlist + + Use the global TQt color \c color0 to draw 0-pixels and \c color1 to + draw 1-pixels in the bitmaps. + + Valid cursor sizes depend on the display hardware (or the + underlying window system). We recommend using 32x32 cursors, + because this size is supported on all platforms. Some platforms + also support 16x16, 48x48 and 64x64 cursors. + + \sa TQBitmap::TQBitmap(), TQBitmap::setMask() +*/ + +TQCursor::TQCursor( const TQBitmap &bitmap, const TQBitmap &mask, + int hotX, int hotY ) +{ + setBitmap(bitmap,mask,hotX,hotY); +} + +#endif // TQT_NO_CURSOR + + diff --git a/src/kernel/tqcursor.h b/src/kernel/tqcursor.h new file mode 100644 index 000000000..aeb36d2f0 --- /dev/null +++ b/src/kernel/tqcursor.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Definition of TQCursor class +** +** Created : 940219 +** +** 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 TQCURSOR_H +#define TQCURSOR_H + +#ifndef QT_H +#include "tqpoint.h" +#include "ntqshared.h" +#endif // QT_H + +/* + ### The fake cursor has to go first with old qdoc. +*/ +#ifdef TQT_NO_CURSOR + +class TQ_EXPORT TQCursor : public TQt +{ +public: + static TQPoint pos(); + static void setPos( int x, int y ); + static void setPos( const TQPoint & ); +private: + TQCursor(); +}; + +#endif // TQT_NO_CURSOR + +#ifndef TQT_NO_CURSOR + +struct TQCursorData; + + +class TQ_EXPORT TQCursor : public TQt +{ +public: + TQCursor(); // create default arrow cursor + TQCursor( int shape ); + TQCursor( const TQBitmap &bitmap, const TQBitmap &mask, + int hotX=-1, int hotY=-1 ); + TQCursor( const TQPixmap &pixmap, + int hotX=-1, int hotY=-1 ); + TQCursor( const TQCursor & ); + ~TQCursor(); + TQCursor &operator=( const TQCursor & ); + + int shape() const; + void setShape( int ); + + const TQBitmap *bitmap() const; + const TQBitmap *mask() const; + TQPoint hotSpot() const; + +#if defined(TQ_WS_WIN) + HCURSOR handle() const; + TQCursor( HCURSOR ); +#elif defined(TQ_WS_X11) + HANDLE handle() const; + TQCursor( HANDLE ); +#elif defined(TQ_WS_MAC) + HANDLE handle() const; +#endif + + static TQPoint pos(); + static void setPos( int x, int y ); + static void setPos( const TQPoint & ); + + static void initialize(); + static void cleanup(); + +#if defined(TQ_WS_X11) + static int x11Screen(); +#endif +private: + void setBitmap( const TQBitmap &bitmap, const TQBitmap &mask, + int hotX, int hotY ); + void update() const; + TQCursorData *data; + TQCursor *find_cur(int); +#if defined(TQ_WS_MAC) + friend void qt_mac_set_cursor(const TQCursor *c, const Point *p); +#endif +}; + + +/***************************************************************************** + TQCursor stream functions + *****************************************************************************/ +#ifndef TQT_NO_DATASTREAM +TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQCursor & ); +TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQCursor & ); +#endif +#endif // TQT_NO_CURSOR + + +inline void TQCursor::setPos( const TQPoint &p ) +{ + setPos( p.x(), p.y() ); +} + +#endif // TQCURSOR_H diff --git a/src/kernel/tqcursor_x11.cpp b/src/kernel/tqcursor_x11.cpp new file mode 100644 index 000000000..fd2aea158 --- /dev/null +++ b/src/kernel/tqcursor_x11.cpp @@ -0,0 +1,833 @@ +/**************************************************************************** +** +** Implementation of TQCursor class for X11 +** +** Created : 940219 +** +** 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 "tqcursor.h" +#include "tqbitmap.h" +#include "tqimage.h" +#include "ntqapplication.h" +#include "tqdatastream.h" +#include "ntqnamespace.h" +#include "qt_x11_p.h" +#include + +#ifndef TQT_NO_XCURSOR +# include +#endif // TQT_NO_XCURSOR + +// Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to +// use the ugly X11 cursors. + +/***************************************************************************** + Internal TQCursorData class + *****************************************************************************/ + +struct TQCursorData : public TQShared +{ + TQCursorData( int s = 0 ); + ~TQCursorData(); + int cshape; + TQBitmap *bm, *bmm; + short hx, hy; + XColor fg,bg; + Cursor hcurs; + Pixmap pm, pmm; +}; + +TQCursorData::TQCursorData( int s ) +{ + cshape = s; + hcurs = 0; + bm = bmm = 0; + hx = hy = 0; + pm = pmm = 0; +} + +TQCursorData::~TQCursorData() +{ + Display *dpy = TQPaintDevice::x11AppDisplay(); + + // Add in checking for the display too as on HP-UX + // we seem to get a core dump as the cursor data is + // deleted again from main() on exit... + if ( hcurs && dpy ) + XFreeCursor( dpy, hcurs ); + if ( pm && dpy ) + XFreePixmap( dpy, pm ); + if ( pmm && dpy ) + XFreePixmap( dpy, pmm ); + delete bm; + delete bmm; +} + + +/***************************************************************************** + Global cursors + *****************************************************************************/ + +static TQCursor cursorTable[TQt::LastCursor+1]; + +static const int arrowCursorIdx = 0; + +const TQCursor & TQt::arrowCursor = cursorTable[0]; +const TQCursor & TQt::upArrowCursor = cursorTable[1]; +const TQCursor & TQt::crossCursor = cursorTable[2]; +const TQCursor & TQt::waitCursor = cursorTable[3]; +const TQCursor & TQt::ibeamCursor = cursorTable[4]; +const TQCursor & TQt::sizeVerCursor = cursorTable[5]; +const TQCursor & TQt::sizeHorCursor = cursorTable[6]; +const TQCursor & TQt::sizeBDiagCursor = cursorTable[7]; +const TQCursor & TQt::sizeFDiagCursor = cursorTable[8]; +const TQCursor & TQt::sizeAllCursor = cursorTable[9]; +const TQCursor & TQt::blankCursor = cursorTable[10]; +const TQCursor & TQt::splitVCursor = cursorTable[11]; +const TQCursor & TQt::splitHCursor = cursorTable[12]; +const TQCursor & TQt::pointingHandCursor = cursorTable[13]; +const TQCursor & TQt::forbiddenCursor = cursorTable[14]; +const TQCursor & TQt::whatsThisCursor = cursorTable[15]; +const TQCursor & TQt::busyCursor = cursorTable[16]; + + +TQCursor *TQCursor::find_cur( int shape ) // find predefined cursor +{ + return (uint)shape <= LastCursor ? &cursorTable[shape] : 0; +} + + +static bool initialized = FALSE; + +/*! + Internal function that deinitializes the predefined cursors. + This function is called from the TQApplication destructor. + + \sa initialize() +*/ +void TQCursor::cleanup() +{ + if ( !initialized ) + return; + + int shape; + for( shape = 0; shape <= LastCursor; shape++ ) { + if ( cursorTable[shape].data && cursorTable[shape].data->deref() ) + delete cursorTable[shape].data; + cursorTable[shape].data = 0; + } + initialized = FALSE; +} + + +/*! + Internal function that initializes the predefined cursors. + This function is called from the TQApplication constructor. + + \sa cleanup() +*/ + +void TQCursor::initialize() +{ + int shape; + for( shape = 0; shape <= LastCursor; shape++ ) + cursorTable[shape].data = new TQCursorData( shape ); + initialized = TRUE; + tqAddPostRoutine( cleanup ); +} + + +/*! + Constructs a cursor with the default arrow shape. +*/ +TQCursor::TQCursor() +{ + if ( !initialized ) { + if ( tqApp->startingUp() ) { + data = 0; + return; + } + initialize(); + } + TQCursor* c = &cursorTable[arrowCursorIdx]; + c->data->ref(); + data = c->data; +} + + + +/*! + Constructs a cursor with the specified \a shape. + + See \l CursorShape for a list of shapes. + + \sa setShape() +*/ + +TQCursor::TQCursor( int shape ) +{ + if ( !initialized ) + initialize(); + TQCursor *c = find_cur( shape ); + if ( !c ) // not found + c = &cursorTable[arrowCursorIdx]; // then use arrowCursor + c->data->ref(); + data = c->data; +} + +/*! + Constructs a cursor from the window system cursor \a cursor. + + \warning Using this function is not portable. This function is only + available on X11 and Windows. +*/ +TQCursor::TQCursor( HANDLE cursor ) +{ + if ( !initialized ) + initialize(); + + data = new TQCursorData; + TQ_CHECK_PTR( data ); + data->hcurs = cursor; +} + + + +void TQCursor::setBitmap( const TQBitmap &bitmap, const TQBitmap &mask, + int hotX, int hotY ) +{ + if ( !initialized ) + initialize(); + if ( bitmap.depth() != 1 || mask.depth() != 1 || + bitmap.size() != mask.size() ) { +#if defined(QT_CHECK_NULL) + tqWarning( "TQCursor: Cannot create bitmap cursor; invalid bitmap(s)" ); +#endif + TQCursor *c = &cursorTable[arrowCursorIdx]; + c->data->ref(); + data = c->data; + return; + } + data = new TQCursorData; + TQ_CHECK_PTR( data ); + data->bm = new TQBitmap( bitmap ); + data->bmm = new TQBitmap( mask ); + data->hcurs = 0; + data->cshape = BitmapCursor; + data->hx = hotX >= 0 ? hotX : bitmap.width()/2; + data->hy = hotY >= 0 ? hotY : bitmap.height()/2; + data->fg.red = 0 << 8; + data->fg.green = 0 << 8; + data->fg.blue = 0 << 8; + data->bg.red = 255 << 8; + data->bg.green = 255 << 8; + data->bg.blue = 255 << 8; + update(); // Xcursor's backward compatibility hack needs the cursor to be created + // right after the bitmaps are created and filled with data +} + + +/*! + Constructs a copy of the cursor \a c. +*/ + +TQCursor::TQCursor( const TQCursor &c ) +{ + if ( !initialized ) + initialize(); + data = c.data; // shallow copy + data->ref(); +} + +/*! + Destroys the cursor. +*/ + +TQCursor::~TQCursor() +{ + if ( data && data->deref() ) + delete data; +} + + +/*! + Assigns \a c to this cursor and returns a reference to this + cursor. +*/ + +TQCursor &TQCursor::operator=( const TQCursor &c ) +{ + if ( !initialized ) + initialize(); + c.data->ref(); // avoid c = c + if ( data->deref() ) + delete data; + data = c.data; + return *this; +} + + +/*! + Returns the cursor shape identifier. The return value is one of + the \l CursorShape enum values (cast to an int). + + \sa setShape() +*/ + +int TQCursor::shape() const +{ + if ( !initialized ) + initialize(); + return data->cshape; +} + +/*! + Sets the cursor to the shape identified by \a shape. + + See \l CursorShape for the list of cursor shapes. + + \sa shape() +*/ + +void TQCursor::setShape( int shape ) +{ + if ( !initialized ) + initialize(); + TQCursor *c = find_cur( shape ); // find one of the global ones + if ( !c ) // not found + c = &cursorTable[arrowCursorIdx]; // then use arrowCursor + c->data->ref(); + if ( data->deref() ) // make shallow copy + delete data; + data = c->data; +} + + +/*! + Returns the cursor bitmap, or 0 if it is one of the standard + cursors. +*/ +const TQBitmap *TQCursor::bitmap() const +{ + if ( !initialized ) + initialize(); + return data->bm; +} + +/*! + Returns the cursor bitmap mask, or 0 if it is one of the standard + cursors. +*/ + +const TQBitmap *TQCursor::mask() const +{ + if ( !initialized ) + initialize(); + return data->bmm; +} + +/*! + Returns the cursor hot spot, or (0, 0) if it is one of the + standard cursors. +*/ + +TQPoint TQCursor::hotSpot() const +{ + if ( !initialized ) + initialize(); + return TQPoint( data->hx, data->hy ); +} + + +/*! + Returns the window system cursor handle. + + \warning + Portable in principle, but if you use it you are probably about to + do something non-portable. Be careful. +*/ + +TQt::HANDLE TQCursor::handle() const +{ + if ( !initialized ) + initialize(); + if ( !data->hcurs ) + update(); + return data->hcurs; +} + +/*! + \fn TQCursor::TQCursor( HCURSOR handle ) + + Creates a cursor with the specified window system handle \a + handle. + + \warning + Portable in principle, but if you use it you are probably about to + do something non-portable. Be careful. +*/ + +/*! + Returns the position of the cursor (hot spot) in global screen + coordinates. + + You can call TQWidget::mapFromGlobal() to translate it to widget + coordinates. + + \sa setPos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal() +*/ +TQPoint TQCursor::pos() +{ + Window root; + Window child; + int root_x, root_y, win_x, win_y; + uint buttons; + Display* dpy = TQPaintDevice::x11AppDisplay(); + for ( int i = 0; i < ScreenCount( dpy ); i++ ) { + if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child, + &root_x, &root_y, &win_x, &win_y, &buttons ) ) + + return TQPoint( root_x, root_y ); + } + return TQPoint(); +} + +/*! \internal +*/ +int TQCursor::x11Screen() +{ + Window root; + Window child; + int root_x, root_y, win_x, win_y; + uint buttons; + Display* dpy = TQPaintDevice::x11AppDisplay(); + for ( int i = 0; i < ScreenCount( dpy ); i++ ) { + if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child, + &root_x, &root_y, &win_x, &win_y, &buttons ) ) + return i; + } + return -1; +} + +/*! + Moves the cursor (hot spot) to the global screen position (\a x, + \a y). + + You can call TQWidget::mapToGlobal() to translate widget + coordinates to global screen coordinates. + + \sa pos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal() +*/ + +void TQCursor::setPos( int x, int y ) +{ + TQPoint current, target(x, y); + + // this is copied from pos(), since we need the screen number for the correct + // root window in the XWarpPointer call + Window root; + Window child; + int root_x, root_y, win_x, win_y; + uint buttons; + Display* dpy = TQPaintDevice::x11AppDisplay(); + int screen; + for ( screen = 0; screen < ScreenCount( dpy ); screen++ ) { + if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( screen ), &root, &child, + &root_x, &root_y, &win_x, &win_y, &buttons ) ) { + current = TQPoint( root_x, root_y ); + break; + } + } + + if ( screen >= ScreenCount( dpy ) ) + return; + + // Need to check, since some X servers generate null mouse move + // events, causing looping in applications which call setPos() on + // every mouse move event. + // + if ( current == target ) + return; + + XWarpPointer( TQPaintDevice::x11AppDisplay(), None, + TQPaintDevice::x11AppRootWindow( screen ), + 0, 0, 0, 0, x, y ); +} + +/*! + \overload void TQCursor::setPos ( const TQPoint & ) +*/ + + +/*! + \internal + + Creates the cursor. +*/ + +void TQCursor::update() const +{ + if ( !initialized ) + initialize(); + TQCursorData *d = data; // cheat const! + if ( d->hcurs ) // already loaded + return; + + Display *dpy = TQPaintDevice::x11AppDisplay(); + Window rootwin = TQPaintDevice::x11AppRootWindow(); + + if ( d->cshape == BitmapCursor ) { + d->hcurs = XCreatePixmapCursor( dpy, d->bm->handle(), d->bmm->handle(), + &d->fg, &d->bg, d->hx, d->hy ); + return; + } + +#ifndef TQT_NO_XCURSOR + static const char *cursorNames[] = { + "left_ptr", + "up_arrow", + "cross", + "wait", + "ibeam", + "size_ver", + "size_hor", + "size_bdiag", + "size_fdiag", + "size_all", + "blank", + "split_v", + "split_h", + "pointing_hand", + "forbidden", + "whats_this", + "left_ptr_watch" + }; + + d->hcurs = XcursorLibraryLoadCursor( dpy, cursorNames[d->cshape] ); + if ( d->hcurs ) + return; +#endif // TQT_NO_XCURSOR + + static uchar cur_blank_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + // Non-standard X11 cursors are created from bitmaps + +#ifndef QT_USE_APPROXIMATE_CURSORS + static const uchar cur_ver_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, + 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; + static const uchar mcur_ver_bits[] = { + 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, + 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, + 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; + static const uchar cur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, + 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const uchar mcur_hor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, + 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, + 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; + static const uchar cur_bdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, + 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, + 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const uchar mcur_bdiag_bits[] = { + 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, + 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, + 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; + static const uchar cur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, + 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, + 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; + static const uchar mcur_fdiag_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, + 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, + 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; + static const uchar *cursor_bits16[] = { + cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, + cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, + 0, 0, cur_blank_bits, cur_blank_bits }; + + static const uchar vsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const uchar vsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, + 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, + 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, + 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const uchar hsplit_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, + 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const uchar hsplitm_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, + 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, + 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, + 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, + 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + static const uchar whatsthis_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, + 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, + 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, + 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, + 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, + 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + static const uchar whatsthism_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, + 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, + 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, + 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, + 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, + 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, + 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; + static const uchar busy_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, + 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, + 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, + 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, + 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static const uchar busym_bits[] = { + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, + 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, + 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, + 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, + 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, + 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + static const uchar * const cursor_bits32[] = { + vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, + 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits + }; + + static const uchar forbidden_bits[] = { + 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, + 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, + 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, + 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; + + static const unsigned char forbiddenm_bits[] = { + 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, + 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, + 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, + 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; + + static const uchar * const cursor_bits20[] = { + forbidden_bits, forbiddenm_bits + }; + + if ( ( d->cshape >= SizeVerCursor && d->cshape < SizeAllCursor ) || + d->cshape == BlankCursor ) { + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + int i = (d->cshape - SizeVerCursor)*2; + d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i], + 16, 16 ); + d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i+1], + 16,16); + d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 8, 8 ); + return; + } + if ( ( d->cshape >= SplitVCursor && d->cshape <= SplitHCursor ) || + d->cshape == WhatsThisCursor || d->cshape == BusyCursor ) { + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + int i = (d->cshape - SplitVCursor)*2; + d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i], + 32, 32 ); + d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i+1], + 32, 32); + int hs = ( d->cshape == PointingHandCursor || + d->cshape == WhatsThisCursor || + d->cshape == BusyCursor ) ? 0 : 16; + d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, hs, hs ); + return; + } + if ( d->cshape == ForbiddenCursor ) { + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + int i = (d->cshape - ForbiddenCursor)*2; + d->pm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i], + 20, 20 ); + d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i+1], + 20, 20); + d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 10, 10 ); + return; + } +#endif /* ! QT_USE_APPROXIMATE_CURSORS */ + + uint sh; + switch ( d->cshape ) { // map Q cursor to X cursor + case ArrowCursor: + sh = XC_left_ptr; + break; + case UpArrowCursor: + sh = XC_center_ptr; + break; + case CrossCursor: + sh = XC_crosshair; + break; + case WaitCursor: + sh = XC_watch; + break; + case IbeamCursor: + sh = XC_xterm; + break; + case SizeAllCursor: + sh = XC_fleur; + break; + case PointingHandCursor: + sh = XC_hand2; + break; +#ifdef QT_USE_APPROXIMATE_CURSORS + case SizeBDiagCursor: + sh = XC_top_right_corner; + break; + case SizeFDiagCursor: + sh = XC_bottom_right_corner; + break; + case BlankCursor: + XColor bg, fg; + bg.red = 255 << 8; + bg.green = 255 << 8; + bg.blue = 255 << 8; + fg.red = 0; + fg.green = 0; + fg.blue = 0; + d->pm = XCreateBitmapFromData( dpy, rootwin, + (char *)cur_blank_bits, 16, 16 ); + d->pmm = XCreateBitmapFromData( dpy, rootwin, + (char *)cur_blank_bits, 16,16); + d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, + &bg, 8, 8 ); + return; + break; + case SizeVerCursor: + case SplitVCursor: + sh = XC_sb_v_double_arrow; + break; + case SizeHorCursor: + case SplitHCursor: + sh = XC_sb_h_double_arrow; + break; + case WhatsThisCursor: + sh = XC_question_arrow; + break; + case ForbiddenCursor: + sh = XC_circle; + break; + case BusyCursor: + sh = XC_watch; + break; +#endif /* QT_USE_APPROXIMATE_CURSORS */ + default: +#if defined(QT_CHECK_RANGE) + tqWarning( "TQCursor::update: Invalid cursor shape %d", d->cshape ); +#endif + return; + } + d->hcurs = XCreateFontCursor( dpy, sh ); +} diff --git a/src/kernel/tqevent.cpp b/src/kernel/tqevent.cpp index 5f4894e92..e8d042b06 100644 --- a/src/kernel/tqevent.cpp +++ b/src/kernel/tqevent.cpp @@ -39,7 +39,7 @@ **********************************************************************/ #include "tqevent.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "ntqapplication.h" diff --git a/src/kernel/tqfont.cpp b/src/kernel/tqfont.cpp index 1549b1836..fa050a234 100644 --- a/src/kernel/tqfont.cpp +++ b/src/kernel/tqfont.cpp @@ -49,7 +49,7 @@ #include "tqcache.h" #include "tqdatastream.h" #include "ntqapplication.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqstringlist.h" #ifdef TQ_WS_MAC #include "tqpaintdevicemetrics.h" diff --git a/src/kernel/tqfont_x11.cpp b/src/kernel/tqfont_x11.cpp index 9acbddd59..a54e13dc2 100644 --- a/src/kernel/tqfont_x11.cpp +++ b/src/kernel/tqfont_x11.cpp @@ -46,7 +46,7 @@ #include "tqfont.h" #include "ntqapplication.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqfontinfo.h" #include "tqfontdatabase.h" #include "tqfontmetrics.h" diff --git a/src/kernel/tqfontdatabase.cpp b/src/kernel/tqfontdatabase.cpp index 56c1a9ed7..36bcfcfef 100644 --- a/src/kernel/tqfontdatabase.cpp +++ b/src/kernel/tqfontdatabase.cpp @@ -48,7 +48,7 @@ #include #include "tqfontengine_p.h" -#include +#include #ifdef TQ_WS_X11 #include diff --git a/src/kernel/tqiconset.cpp b/src/kernel/tqiconset.cpp index a327e554f..2a251c2ff 100644 --- a/src/kernel/tqiconset.cpp +++ b/src/kernel/tqiconset.cpp @@ -44,7 +44,7 @@ #include "ntqapplication.h" #include "tqbitmap.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqimage.h" #include "tqpainter.h" diff --git a/src/kernel/tqimage.cpp b/src/kernel/tqimage.cpp index 733bb10d7..6c1d1ffad 100644 --- a/src/kernel/tqimage.cpp +++ b/src/kernel/tqimage.cpp @@ -45,7 +45,7 @@ #include "tqtextstream.h" #include "tqbuffer.h" #include "tqptrlist.h" -#include "ntqasyncimageio.h" +#include "tqasyncimageio.h" #include "tqpngio.h" #include "ntqmngio.h" #include "ntqjpegio.h" diff --git a/src/kernel/tqmime.cpp b/src/kernel/tqmime.cpp index 14e8f8306..d230d88d8 100644 --- a/src/kernel/tqmime.cpp +++ b/src/kernel/tqmime.cpp @@ -45,7 +45,7 @@ #include "tqfileinfo.h" #include "tqdir.h" #include "tqdragobject.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "ntqapplication.h" // ### for now #include "tqclipboard.h" // ### for now diff --git a/src/kernel/tqmovie.cpp b/src/kernel/tqmovie.cpp index 54743cbd6..1a29a4315 100644 --- a/src/kernel/tqmovie.cpp +++ b/src/kernel/tqmovie.cpp @@ -52,8 +52,8 @@ #ifndef TQT_NO_MOVIE -#include "ntqasyncio.h" -#include "ntqasyncimageio.h" +#include "tqasyncio.h" +#include "tqasyncimageio.h" #include diff --git a/src/kernel/tqpainter.cpp b/src/kernel/tqpainter.cpp index 5303d5549..359954168 100644 --- a/src/kernel/tqpainter.cpp +++ b/src/kernel/tqpainter.cpp @@ -50,7 +50,7 @@ #include "ntqapplication.h" #include "qrichtext_p.h" #include "tqregexp.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include #include "tqtextlayout_p.h" diff --git a/src/kernel/tqpalette.cpp b/src/kernel/tqpalette.cpp index 6ae0459d1..fad57ce13 100644 --- a/src/kernel/tqpalette.cpp +++ b/src/kernel/tqpalette.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_PALETTE #include "tqdatastream.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" /***************************************************************************** TQColorGroup member functions diff --git a/src/kernel/tqpixmapcache.cpp b/src/kernel/tqpixmapcache.cpp index a61b0aa71..369df0c08 100644 --- a/src/kernel/tqpixmapcache.cpp +++ b/src/kernel/tqpixmapcache.cpp @@ -41,7 +41,7 @@ #include "tqpixmapcache.h" #include "tqcache.h" #include "tqobject.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" // REVISED: paul diff --git a/src/kernel/tqpngio.cpp b/src/kernel/tqpngio.cpp index 16d17eb6f..cf4d5ca60 100644 --- a/src/kernel/tqpngio.cpp +++ b/src/kernel/tqpngio.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_IMAGEIO_PNG -#include "ntqasyncimageio.h" +#include "tqasyncimageio.h" #include "tqiodevice.h" #include @@ -999,7 +999,7 @@ class TQPNGFormatType : public TQImageFormatType */ /* - \class TQPNGFormatType ntqasyncimageio.h + \class TQPNGFormatType tqasyncimageio.h \brief The TQPNGFormatType class provides an incremental image decoder for PNG image format. diff --git a/src/kernel/tqprocess_unix.cpp b/src/kernel/tqprocess_unix.cpp index e065de514..c3bb2ba70 100644 --- a/src/kernel/tqprocess_unix.cpp +++ b/src/kernel/tqprocess_unix.cpp @@ -54,7 +54,7 @@ #include "tqptrlist.h" #include "tqsocketnotifier.h" #include "tqtimer.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqregexp.h" #include "private/qinternal_p.h" diff --git a/src/kernel/tqsignalslotimp.h b/src/kernel/tqsignalslotimp.h index 80c18b5d2..e7e67a280 100644 --- a/src/kernel/tqsignalslotimp.h +++ b/src/kernel/tqsignalslotimp.h @@ -42,7 +42,7 @@ #define TQSIGNALSLOTIMP_H #ifndef QT_H -#include "ntqconnection.h" +#include "tqconnection.h" #include "tqptrlist.h" #include "tqptrvector.h" #endif // QT_H diff --git a/src/kernel/tqstylesheet.cpp b/src/kernel/tqstylesheet.cpp index 350c813c8..dbc8d4670 100644 --- a/src/kernel/tqstylesheet.cpp +++ b/src/kernel/tqstylesheet.cpp @@ -45,7 +45,7 @@ #include "private/qrichtext_p.h" #include "tqlayout.h" #include "tqpainter.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include diff --git a/src/kernel/tqwidget.cpp b/src/kernel/tqwidget.cpp index 1e9a809cb..9fe528f78 100644 --- a/src/kernel/tqwidget.cpp +++ b/src/kernel/tqwidget.cpp @@ -45,14 +45,14 @@ #include "tqwidgetintdict.h" #include "tqptrdict.h" #include "ntqfocusdata.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqpixmap.h" #include "ntqapplication.h" #include "qapplication_p.h" #include "tqbrush.h" #include "tqlayout.h" #include "tqstylefactory.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqstyle.h" #include "ntqmetaobject.h" #include "tqguardedptr.h" @@ -60,7 +60,7 @@ #include "tqthread.h" #endif #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #if defined(TQ_WS_WIN) #include "qt_windows.h" diff --git a/src/kernel/tqwidget_x11.cpp b/src/kernel/tqwidget_x11.cpp index 85367b133..bccd0110b 100644 --- a/src/kernel/tqwidget_x11.cpp +++ b/src/kernel/tqwidget_x11.cpp @@ -49,7 +49,7 @@ #include "tqlayout.h" #include "tqtextcodec.h" #include "tqdatetime.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "qt_x11_p.h" #include diff --git a/src/network/tqdns.cpp b/src/network/tqdns.cpp index 4b215eb1d..8bc081bb5 100644 --- a/src/network/tqdns.cpp +++ b/src/network/tqdns.cpp @@ -76,7 +76,7 @@ #include "tqfile.h" #include "tqtextstream.h" #include "tqsocketdevice.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include #ifdef Q_OS_MAC #include "../3rdparty/dlcompat/dlfcn.h" diff --git a/src/opengl/tqgl.cpp b/src/opengl/tqgl.cpp index 1e8edd59a..991d697af 100644 --- a/src/opengl/tqgl.cpp +++ b/src/opengl/tqgl.cpp @@ -42,7 +42,7 @@ #include "tqpixmap.h" #include "tqpaintdevicemetrics.h" #include "tqimage.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqptrdict.h" static TQGLFormat* qgl_default_format = 0; diff --git a/src/sql/tqdatatable.cpp b/src/sql/tqdatatable.cpp index 2bcad69ff..1e8826d3c 100644 --- a/src/sql/tqdatatable.cpp +++ b/src/sql/tqdatatable.cpp @@ -52,7 +52,7 @@ #include "tqvaluelist.h" #include "tqsqlmanager_p.h" #include "tqdatetime.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqtimer.h" //#define QT_DEBUG_DATATABLE diff --git a/src/sql/tqeditorfactory.cpp b/src/sql/tqeditorfactory.cpp index 76fa71996..098d850c7 100644 --- a/src/sql/tqeditorfactory.cpp +++ b/src/sql/tqeditorfactory.cpp @@ -38,7 +38,7 @@ ** **********************************************************************/ -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqlabel.h" #include "tqlineedit.h" #include "tqspinbox.h" diff --git a/src/sql/tqsqldatabase.cpp b/src/sql/tqsqldatabase.cpp index 4a7657248..1f8cfe6c2 100644 --- a/src/sql/tqsqldatabase.cpp +++ b/src/sql/tqsqldatabase.cpp @@ -83,7 +83,7 @@ #include #include "tqobject.h" #include "tqguardedptr.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqdict.h" #include diff --git a/src/sql/tqsqleditorfactory.cpp b/src/sql/tqsqleditorfactory.cpp index 31d9108f2..3598a7cac 100644 --- a/src/sql/tqsqleditorfactory.cpp +++ b/src/sql/tqsqleditorfactory.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_SQL_EDIT_WIDGETS #include "tqsqlfield.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqlabel.h" #include "tqlineedit.h" #include "tqspinbox.h" diff --git a/src/sql/tqsqlpropertymap.cpp b/src/sql/tqsqlpropertymap.cpp index 6e4f2d4cc..81a0dd4a5 100644 --- a/src/sql/tqsqlpropertymap.cpp +++ b/src/sql/tqsqlpropertymap.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_SQL_FORM #include "tqwidget.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "ntqmetaobject.h" #include "tqmap.h" diff --git a/src/styles/tqwindowsstyle.cpp b/src/styles/tqwindowsstyle.cpp index 844ff294a..42d07b2b7 100644 --- a/src/styles/tqwindowsstyle.cpp +++ b/src/styles/tqwindowsstyle.cpp @@ -61,7 +61,7 @@ #include "tqtabbar.h" #include "tqlistview.h" #include "tqbitmap.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "ntqdockwindow.h" #include "tqobjectlist.h" #include "tqmenubar.h" diff --git a/src/table/tqtable.cpp b/src/table/tqtable.cpp index 002fcc502..8244304cc 100644 --- a/src/table/tqtable.cpp +++ b/src/table/tqtable.cpp @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/tools/ntqcleanuphandler.h b/src/tools/ntqcleanuphandler.h deleted file mode 100644 index b6347f7ea..000000000 --- a/src/tools/ntqcleanuphandler.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** ... -** -** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools 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 TQCLEANUPHANDLER_H -#define TQCLEANUPHANDLER_H - -#ifndef QT_H -#include "tqptrlist.h" -#endif // QT_H - -template -class TQCleanupHandler -{ -public: - TQCleanupHandler() : cleanupObjects( 0 ) {} - ~TQCleanupHandler() { clear(); } - - Type* add( Type **object ) { - if ( !cleanupObjects ) - cleanupObjects = new TQPtrList; - cleanupObjects->insert( 0, object ); - return *object; - } - - void remove( Type **object ) { - if ( !cleanupObjects ) - return; - if ( cleanupObjects->findRef( object ) >= 0 ) - (void) cleanupObjects->take(); - } - - bool isEmpty() const { - return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; - } - - void clear() { - if ( !cleanupObjects ) - return; - TQPtrListIterator it( *cleanupObjects ); - Type **object; - while ( ( object = it.current() ) ) { - delete *object; - *object = 0; - cleanupObjects->remove( object ); - } - delete cleanupObjects; - cleanupObjects = 0; - } - -private: - TQPtrList *cleanupObjects; -}; - -template -class TQSingleCleanupHandler -{ -public: - TQSingleCleanupHandler() : object( 0 ) {} - ~TQSingleCleanupHandler() { - if ( object ) { - delete *object; - *object = 0; - } - } - Type* set( Type **o ) { - object = o; - return *object; - } - void reset() { object = 0; } -private: - Type **object; -}; - -template -class TQSharedCleanupHandler -{ -public: - TQSharedCleanupHandler() : object( 0 ) {} - ~TQSharedCleanupHandler() { - if ( object ) { - if ( (*object)->deref() ) - delete *object; - *object = 0; - } - } - Type* set( Type **o ) { - object = o; - return *object; - } - void reset() { object = 0; } -private: - Type **object; -}; - -#endif //TQCLEANUPHANDLER_H diff --git a/src/tools/qcomlibrary.cpp b/src/tools/qcomlibrary.cpp index 2d95ce54a..5f40bdc9f 100644 --- a/src/tools/qcomlibrary.cpp +++ b/src/tools/qcomlibrary.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #ifndef NO_ERRNO_H #include #endif // NO_ERROR_H diff --git a/src/tools/qcomponentfactory.cpp b/src/tools/qcomponentfactory.cpp deleted file mode 100644 index 0186e7843..000000000 --- a/src/tools/qcomponentfactory.cpp +++ /dev/null @@ -1,355 +0,0 @@ -/**************************************************************************** -** -** Implementation of the TQComponentFactory class -** -** Created : 990101 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools 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 "qcomponentfactory_p.h" - -#ifndef TQT_NO_COMPONENT -#include "tqsettings.h" -#include -#include "tqdir.h" -#include "ntqapplication.h" - -/*! - \class TQComponentFactory qcomponentfactory.h - \brief The TQComponentFactory class provides static functions to create and register components. - - \internal - - The static convenience functions can be used both by applications to instantiate components, - and by component servers to register components. - - The createInstance() function provides a pointer to an interface implemented in a specific - component if the component requested has been installed properly and implements the interface. - - Use registerServer() to load a component server and register its components, and unregisterServer() - to unregister the components. The component exported by the component server has to implement the - TQComponentRegistrationInterface. - - The static functions registerComponent() and unregisterComponent() register and unregister a single - component in the system component registry, and should be used when implementing the - \link TQComponentRegistrationInterface::registerComponents() registerCompontents() \endlink and - \link TQComponentRegistrationInterface::unregisterComponents() unregisterCompontents() \endlink functions - in the TQComponentRegistrationInterface. - - A component is registered using a UUID, but can additionally be registered with a name, version and - description. A component registered with a name and a version can be instantiated by client applications - using the name and specific version number, or the highest available version number for that component by - just using the name. A component that is registered calling - - \code - TQComponentFactory::registerComponent( TQUuid(...), filename, "MyProgram.Component", 1 ); - \endcode - - can be instantiated calling either: - - \code - TQComponentFactory::createInstance( TQUuid(...), IID_XYZ, (TQUnknownInterface**)&iface ); - \endcode - or - \code - TQComponentFactory::createInstance( "MyProgram.Component", IID_XYZ, (TQUnknownInterface**)&iface ); - \endcode - or - \code - TQComponentFactory::createInstance( "MyProgram.Component.1", IID_XYZ, (TQUnknownInterface**)&iface ); - \endcode - - The first and the last way will always instantiate exactly the component registered above, while - the second call might also return a later version of the same component. This allows smoother upgrading - of components, and is easier to use in application source code, but should only be used when new versions - of the component are guaranteed to work with the application. - - The component name can be anything, but should be unique on the system the component is being - installed on. A common naming convention for components is \e application.component. - - \sa TQComponentRegistrationInterface TQComponentFactoryInterface -*/ - - -static TQPtrList *libraries = 0; - -static void cleanup() -{ - delete libraries; - libraries = 0; -} - -static TQPtrList *liblist() -{ - if ( !libraries ) { - libraries = new TQPtrList(); - libraries->setAutoDelete( TRUE ); - tqAddPostRoutine( cleanup ); - } - return libraries; -} - -/*! - Searches for the component identifier \a cid in the system component registry, - loads the corresponding component server and queries for the interface \a iid. - \a iface is set to the resulting interface pointer. \a cid can either be the - UUID or the name of the component. - - The parameter \a outer is a pointer to the outer interface used - for containment and aggregation and is propagated to the \link - TQComponentFactoryInterface::createInstance() createInstance() \endlink - implementation of the TQComponentFactoryInterface in the component server if - provided. - - The function returns TQS_OK if the interface was successfully instantiated, TQE_NOINTERFACE if - the component does not provide an interface \a iid, or TQE_NOCOMPONENT if there was - an error loading the component. - - Example: - \code - TQInterfacePtr iface; - if ( TQComponentFactory::createInstance( IID_MyInterface, CID_MyComponent, (TQUnknownInterface**)&iface ) == TQS_OK ) - iface->doSomething(); - ... - } - \endcode -*/ -TQRESULT TQComponentFactory::createInstance( const TQString &cid, const TQUuid &iid, TQUnknownInterface** iface, TQUnknownInterface *outer ) -{ - TQSettings settings; - settings.insertSearchPath( TQSettings::Windows, "/Classes" ); - bool ok = FALSE; - TQString cidStr = cid; - TQRESULT res = TQE_NOCOMPONENT; - - TQUuid uuid( cidStr ); // try to parse, and resolve CLSID if necessary - if ( uuid.isNull() ) { - uuid = settings.readEntry( "/" + cid + "/CLSID/Default", TQString::null, &ok ); - cidStr = uuid.toString().upper(); - } - - if ( cidStr.isEmpty() ) - return res; - - TQString file = settings.readEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", TQString::null, &ok ); - if ( !ok ) - return res; - - TQComLibrary *library = new TQComLibrary( file ); - library->setAutoUnload( FALSE ); - - TQComponentFactoryInterface *cfIface =0; - library->queryInterface( IID_QComponentFactory, (TQUnknownInterface**)&cfIface ); - - if ( cfIface ) { - res = cfIface->createInstance( uuid, iid, iface, outer ); - cfIface->release(); - } else { - res = library->queryInterface( iid, iface ); - } - TQLibraryInterface *libiface = 0; - if ( library->queryInterface( IID_QLibrary, (TQUnknownInterface**)&libiface ) != TQS_OK || !tqApp ) { - delete library; // only deletes the object, thanks to TQLibrary::Manual - } else { - libiface->release(); - library->setAutoUnload( TRUE ); - liblist()->prepend( library ); - } - return res; -} - -/*! - Loads the shared library \a filename and queries for a - TQComponentRegistrationInterface. If the library implements this interface, - the \link TQComponentRegistrationInterface::registerComponents() - registerComponents() \endlink function is called. - - Returns TRUE if the interface is found and successfully called, - otherwise returns FALSE. -*/ -TQRESULT TQComponentFactory::registerServer( const TQString &filename ) -{ - TQComLibrary lib( filename ); - lib.load(); - TQComponentRegistrationInterface *iface = 0; - TQRESULT res = lib.queryInterface( IID_QComponentRegistration, (TQUnknownInterface**)&iface ); - if ( res != TQS_OK ) - return res; - TQDir dir( filename ); - bool ok = iface->registerComponents( dir.absPath() ); - iface->release(); - return ok ? TQS_OK : TQS_FALSE; -} - -/*! - Loads the shared library \a filename and queries for a - TQComponentRegistrationInterface. If the library implements this interface, - the \link TQComponentRegistrationInterface::unregisterComponents() - unregisterComponents() \endlink function is called. - - Returns TRUE if the interface is found and successfully unregistered, - otherwise returns FALSE. -*/ -TQRESULT TQComponentFactory::unregisterServer( const TQString &filename ) -{ - TQComLibrary lib( filename ); - lib.load(); - TQComponentRegistrationInterface *iface = 0; - TQRESULT res = lib.queryInterface( IID_QComponentRegistration, (TQUnknownInterface**)&iface ); - if ( res != TQS_OK ) - return res; - bool ok = iface->unregisterComponents(); - iface->release(); - return ok ? TQS_OK : TQS_FALSE; -} - -/*! - Registers the component with id \a cid in the system component registry and - returns TRUE if the component was registerd successfully, otherwise returns - FALSE. The component is provided by the component server at \a filepath and - registered with an optional \a name, \a version and \a description. - - This function does nothing and returns FALSE if a component with an identical - \a cid does already exist on the system. - - A component that has been registered with a \a name can be created using both the - \a cid and the \a name value using createInstance(). - - Call this function for each component in an implementation of - \link TQComponentRegistrationInterface::registerComponents() registerComponents() \endlink. - - \sa unregisterComponent(), registerServer(), createInstance() -*/ -bool TQComponentFactory::registerComponent( const TQUuid &cid, const TQString &filepath, const TQString &name, int version, const TQString &description ) -{ - bool ok = FALSE; - TQSettings settings; - settings.insertSearchPath( TQSettings::Windows, "/Classes" ); - - TQString cidStr = cid.toString().upper(); - settings.readEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", TQString::null, &ok ); - if ( ok ) // don't overwrite existing component - return FALSE; - - ok = settings.writeEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", filepath ); - if ( ok && !!description ) - settings.writeEntry( "/CLSID/" + cidStr + "/Default", description ); - - // register the human readable part - if ( ok && !!name ) { - TQString vName = version ? name + "." + TQString::number( version ) : name; - settings.writeEntry( "/CLSID/" + cidStr + "/ProgID/Default", vName ); - ok = settings.writeEntry( "/" + vName + "/CLSID/Default", cidStr ); - if ( ok && !!description ) - settings.writeEntry( "/" + vName + "/Default", description ); - - if ( ok && version ) { - settings.writeEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default", name ); - TQString curVer = settings.readEntry( "/" + name + "/CurVer/Default" ); - if ( !curVer || curVer < vName ) { // no previous, or a lesser version installed - settings.writeEntry( "/" + name + "/CurVer/Default", vName ); - ok = settings.writeEntry( "/" + name + "/CLSID/Default", cidStr ); - if ( ok && !!description ) - settings.writeEntry( "/" + name + "/Default", description ); - } - } - } - - return ok; -} - -/*! - Unregisters the component with id \a cid from the system component registry and returns - TRUE if the component was unregistered successfully, otherwise returns FALSE. - - Call this function for each component in an implementation of - \link TQComponentRegistrationInterface::unregisterComponents() unregisterComponents() \endlink. - - \sa registerComponent(), unregisterServer() -*/ -bool TQComponentFactory::unregisterComponent( const TQUuid &cid ) -{ - TQSettings settings; - bool ok = FALSE; - settings.insertSearchPath( TQSettings::Windows, "/Classes" ); - - TQString cidStr = cid.toString().upper(); - if ( cidStr.isEmpty() ) - return FALSE; - - // unregister the human readable part - TQString vName = settings.readEntry( "/CLSID/" + cidStr + "/ProgID/Default", TQString::null, &ok ); - if ( ok ) { - TQString name = settings.readEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default", TQString::null ); - if ( !!name && settings.readEntry( "/" + name + "/CurVer/Default" ) == vName ) { - // unregistering the current version -> change CurVer to previous version - TQString version = vName.right( vName.length() - name.length() - 1 ); - TQString newVerName; - TQString newCidStr; - if ( version.find( '.' ) == -1 ) { - int ver = version.toInt(); - // see if a lesser version is installed, and make that the CurVer - while ( ver-- ) { - newVerName = name + "." + TQString::number( ver ); - newCidStr = settings.readEntry( "/" + newVerName + "/CLSID/Default" ); - if ( !!newCidStr ) - break; - } - } else { - // oh well... - } - if ( !!newCidStr ) { - settings.writeEntry( "/" + name + "/CurVer/Default", newVerName ); - settings.writeEntry( "/" + name + "/CLSID/Default", newCidStr ); - } else { - settings.removeEntry( "/" + name + "/CurVer/Default" ); - settings.removeEntry( "/" + name + "/CLSID/Default" ); - settings.removeEntry( "/" + name + "/Default" ); - } - } - - settings.removeEntry( "/" + vName + "/CLSID/Default" ); - settings.removeEntry( "/" + vName + "/Default" ); - } - - settings.removeEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default" ); - settings.removeEntry( "/CLSID/" + cidStr + "/ProgID/Default" ); - settings.removeEntry( "/CLSID/" + cidStr + "/InprocServer32/Default" ); - ok = settings.removeEntry( "/CLSID/" + cidStr + "/Default" ); - - return ok; -} - -#endif // TQT_NO_COMPONENT diff --git a/src/tools/qcomponentfactory_p.h b/src/tools/qcomponentfactory_p.h deleted file mode 100644 index 89399152f..000000000 --- a/src/tools/qcomponentfactory_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Definition of the TQComponentFactory class -** -** Created : 990101 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools 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 TQCOMPONENTFACTORY_P_H -#define TQCOMPONENTFACTORY_P_H - -#ifndef QT_H -#include "qcom_p.h" -#endif // QT_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of a number of TQt sources files. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef TQT_NO_COMPONENT - -class TQ_EXPORT TQComponentFactory -{ -public: - static TQRESULT createInstance( const TQString &cid, const TQUuid &iid, TQUnknownInterface** instance, TQUnknownInterface *outer = 0 ); - static TQRESULT registerServer( const TQString &filename ); - static TQRESULT unregisterServer( const TQString &filename ); - - static bool registerComponent( const TQUuid &cid, const TQString &filename, const TQString &name = TQString::null, - int version = 0, const TQString &description = TQString::null ); - static bool unregisterComponent( const TQUuid &cid ); -}; - -#endif // TQT_NO_COMPONENT - -#endif // TQCOMPONENTFACTORY_P_H diff --git a/src/tools/qt_tools.pri b/src/tools/qt_tools.pri index 8a2ce897f..ba4e5dd79 100644 --- a/src/tools/qt_tools.pri +++ b/src/tools/qt_tools.pri @@ -8,8 +8,8 @@ tools { $$TOOLS_H/tqbitarray.h \ $$TOOLS_H/tqbuffer.h \ $$TOOLS_H/tqcache.h \ - $$TOOLS_H/ntqcleanuphandler.h \ - $$TOOLS_P/qcomponentfactory_p.h \ + $$TOOLS_H/tqcleanuphandler.h \ + $$TOOLS_P/tqcomponentfactory_p.h \ $$TOOLS_P/qcomlibrary_p.h \ $$TOOLS_H/tqcstring.h \ $$TOOLS_H/tqdatastream.h \ @@ -107,7 +107,7 @@ tools { SOURCES += $$TOOLS_CPP/tqbitarray.cpp \ $$TOOLS_CPP/tqbuffer.cpp \ - $$TOOLS_CPP/qcomponentfactory.cpp \ + $$TOOLS_CPP/tqcomponentfactory.cpp \ $$TOOLS_CPP/qcomlibrary.cpp \ $$TOOLS_CPP/tqcstring.cpp \ $$TOOLS_CPP/tqdatastream.cpp \ diff --git a/src/tools/qwinexport.cpp b/src/tools/qwinexport.cpp index 82d5ebc61..92bda3eb7 100644 --- a/src/tools/qwinexport.cpp +++ b/src/tools/qwinexport.cpp @@ -1,8 +1,8 @@ #define Q_EXPORT_TEMPLATES #include -#include -#include +#include +#include #include #include #include diff --git a/src/tools/tqcleanuphandler.h b/src/tools/tqcleanuphandler.h new file mode 100644 index 000000000..b6347f7ea --- /dev/null +++ b/src/tools/tqcleanuphandler.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools 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 TQCLEANUPHANDLER_H +#define TQCLEANUPHANDLER_H + +#ifndef QT_H +#include "tqptrlist.h" +#endif // QT_H + +template +class TQCleanupHandler +{ +public: + TQCleanupHandler() : cleanupObjects( 0 ) {} + ~TQCleanupHandler() { clear(); } + + Type* add( Type **object ) { + if ( !cleanupObjects ) + cleanupObjects = new TQPtrList; + cleanupObjects->insert( 0, object ); + return *object; + } + + void remove( Type **object ) { + if ( !cleanupObjects ) + return; + if ( cleanupObjects->findRef( object ) >= 0 ) + (void) cleanupObjects->take(); + } + + bool isEmpty() const { + return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; + } + + void clear() { + if ( !cleanupObjects ) + return; + TQPtrListIterator it( *cleanupObjects ); + Type **object; + while ( ( object = it.current() ) ) { + delete *object; + *object = 0; + cleanupObjects->remove( object ); + } + delete cleanupObjects; + cleanupObjects = 0; + } + +private: + TQPtrList *cleanupObjects; +}; + +template +class TQSingleCleanupHandler +{ +public: + TQSingleCleanupHandler() : object( 0 ) {} + ~TQSingleCleanupHandler() { + if ( object ) { + delete *object; + *object = 0; + } + } + Type* set( Type **o ) { + object = o; + return *object; + } + void reset() { object = 0; } +private: + Type **object; +}; + +template +class TQSharedCleanupHandler +{ +public: + TQSharedCleanupHandler() : object( 0 ) {} + ~TQSharedCleanupHandler() { + if ( object ) { + if ( (*object)->deref() ) + delete *object; + *object = 0; + } + } + Type* set( Type **o ) { + object = o; + return *object; + } + void reset() { object = 0; } +private: + Type **object; +}; + +#endif //TQCLEANUPHANDLER_H diff --git a/src/tools/tqcomponentfactory.cpp b/src/tools/tqcomponentfactory.cpp new file mode 100644 index 000000000..6bac4b618 --- /dev/null +++ b/src/tools/tqcomponentfactory.cpp @@ -0,0 +1,355 @@ +/**************************************************************************** +** +** Implementation of the TQComponentFactory class +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools 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 "tqcomponentfactory_p.h" + +#ifndef TQT_NO_COMPONENT +#include "tqsettings.h" +#include +#include "tqdir.h" +#include "ntqapplication.h" + +/*! + \class TQComponentFactory tqcomponentfactory.h + \brief The TQComponentFactory class provides static functions to create and register components. + + \internal + + The static convenience functions can be used both by applications to instantiate components, + and by component servers to register components. + + The createInstance() function provides a pointer to an interface implemented in a specific + component if the component requested has been installed properly and implements the interface. + + Use registerServer() to load a component server and register its components, and unregisterServer() + to unregister the components. The component exported by the component server has to implement the + TQComponentRegistrationInterface. + + The static functions registerComponent() and unregisterComponent() register and unregister a single + component in the system component registry, and should be used when implementing the + \link TQComponentRegistrationInterface::registerComponents() registerCompontents() \endlink and + \link TQComponentRegistrationInterface::unregisterComponents() unregisterCompontents() \endlink functions + in the TQComponentRegistrationInterface. + + A component is registered using a UUID, but can additionally be registered with a name, version and + description. A component registered with a name and a version can be instantiated by client applications + using the name and specific version number, or the highest available version number for that component by + just using the name. A component that is registered calling + + \code + TQComponentFactory::registerComponent( TQUuid(...), filename, "MyProgram.Component", 1 ); + \endcode + + can be instantiated calling either: + + \code + TQComponentFactory::createInstance( TQUuid(...), IID_XYZ, (TQUnknownInterface**)&iface ); + \endcode + or + \code + TQComponentFactory::createInstance( "MyProgram.Component", IID_XYZ, (TQUnknownInterface**)&iface ); + \endcode + or + \code + TQComponentFactory::createInstance( "MyProgram.Component.1", IID_XYZ, (TQUnknownInterface**)&iface ); + \endcode + + The first and the last way will always instantiate exactly the component registered above, while + the second call might also return a later version of the same component. This allows smoother upgrading + of components, and is easier to use in application source code, but should only be used when new versions + of the component are guaranteed to work with the application. + + The component name can be anything, but should be unique on the system the component is being + installed on. A common naming convention for components is \e application.component. + + \sa TQComponentRegistrationInterface TQComponentFactoryInterface +*/ + + +static TQPtrList *libraries = 0; + +static void cleanup() +{ + delete libraries; + libraries = 0; +} + +static TQPtrList *liblist() +{ + if ( !libraries ) { + libraries = new TQPtrList(); + libraries->setAutoDelete( TRUE ); + tqAddPostRoutine( cleanup ); + } + return libraries; +} + +/*! + Searches for the component identifier \a cid in the system component registry, + loads the corresponding component server and queries for the interface \a iid. + \a iface is set to the resulting interface pointer. \a cid can either be the + UUID or the name of the component. + + The parameter \a outer is a pointer to the outer interface used + for containment and aggregation and is propagated to the \link + TQComponentFactoryInterface::createInstance() createInstance() \endlink + implementation of the TQComponentFactoryInterface in the component server if + provided. + + The function returns TQS_OK if the interface was successfully instantiated, TQE_NOINTERFACE if + the component does not provide an interface \a iid, or TQE_NOCOMPONENT if there was + an error loading the component. + + Example: + \code + TQInterfacePtr iface; + if ( TQComponentFactory::createInstance( IID_MyInterface, CID_MyComponent, (TQUnknownInterface**)&iface ) == TQS_OK ) + iface->doSomething(); + ... + } + \endcode +*/ +TQRESULT TQComponentFactory::createInstance( const TQString &cid, const TQUuid &iid, TQUnknownInterface** iface, TQUnknownInterface *outer ) +{ + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/Classes" ); + bool ok = FALSE; + TQString cidStr = cid; + TQRESULT res = TQE_NOCOMPONENT; + + TQUuid uuid( cidStr ); // try to parse, and resolve CLSID if necessary + if ( uuid.isNull() ) { + uuid = settings.readEntry( "/" + cid + "/CLSID/Default", TQString::null, &ok ); + cidStr = uuid.toString().upper(); + } + + if ( cidStr.isEmpty() ) + return res; + + TQString file = settings.readEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", TQString::null, &ok ); + if ( !ok ) + return res; + + TQComLibrary *library = new TQComLibrary( file ); + library->setAutoUnload( FALSE ); + + TQComponentFactoryInterface *cfIface =0; + library->queryInterface( IID_QComponentFactory, (TQUnknownInterface**)&cfIface ); + + if ( cfIface ) { + res = cfIface->createInstance( uuid, iid, iface, outer ); + cfIface->release(); + } else { + res = library->queryInterface( iid, iface ); + } + TQLibraryInterface *libiface = 0; + if ( library->queryInterface( IID_QLibrary, (TQUnknownInterface**)&libiface ) != TQS_OK || !tqApp ) { + delete library; // only deletes the object, thanks to TQLibrary::Manual + } else { + libiface->release(); + library->setAutoUnload( TRUE ); + liblist()->prepend( library ); + } + return res; +} + +/*! + Loads the shared library \a filename and queries for a + TQComponentRegistrationInterface. If the library implements this interface, + the \link TQComponentRegistrationInterface::registerComponents() + registerComponents() \endlink function is called. + + Returns TRUE if the interface is found and successfully called, + otherwise returns FALSE. +*/ +TQRESULT TQComponentFactory::registerServer( const TQString &filename ) +{ + TQComLibrary lib( filename ); + lib.load(); + TQComponentRegistrationInterface *iface = 0; + TQRESULT res = lib.queryInterface( IID_QComponentRegistration, (TQUnknownInterface**)&iface ); + if ( res != TQS_OK ) + return res; + TQDir dir( filename ); + bool ok = iface->registerComponents( dir.absPath() ); + iface->release(); + return ok ? TQS_OK : TQS_FALSE; +} + +/*! + Loads the shared library \a filename and queries for a + TQComponentRegistrationInterface. If the library implements this interface, + the \link TQComponentRegistrationInterface::unregisterComponents() + unregisterComponents() \endlink function is called. + + Returns TRUE if the interface is found and successfully unregistered, + otherwise returns FALSE. +*/ +TQRESULT TQComponentFactory::unregisterServer( const TQString &filename ) +{ + TQComLibrary lib( filename ); + lib.load(); + TQComponentRegistrationInterface *iface = 0; + TQRESULT res = lib.queryInterface( IID_QComponentRegistration, (TQUnknownInterface**)&iface ); + if ( res != TQS_OK ) + return res; + bool ok = iface->unregisterComponents(); + iface->release(); + return ok ? TQS_OK : TQS_FALSE; +} + +/*! + Registers the component with id \a cid in the system component registry and + returns TRUE if the component was registerd successfully, otherwise returns + FALSE. The component is provided by the component server at \a filepath and + registered with an optional \a name, \a version and \a description. + + This function does nothing and returns FALSE if a component with an identical + \a cid does already exist on the system. + + A component that has been registered with a \a name can be created using both the + \a cid and the \a name value using createInstance(). + + Call this function for each component in an implementation of + \link TQComponentRegistrationInterface::registerComponents() registerComponents() \endlink. + + \sa unregisterComponent(), registerServer(), createInstance() +*/ +bool TQComponentFactory::registerComponent( const TQUuid &cid, const TQString &filepath, const TQString &name, int version, const TQString &description ) +{ + bool ok = FALSE; + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/Classes" ); + + TQString cidStr = cid.toString().upper(); + settings.readEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", TQString::null, &ok ); + if ( ok ) // don't overwrite existing component + return FALSE; + + ok = settings.writeEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", filepath ); + if ( ok && !!description ) + settings.writeEntry( "/CLSID/" + cidStr + "/Default", description ); + + // register the human readable part + if ( ok && !!name ) { + TQString vName = version ? name + "." + TQString::number( version ) : name; + settings.writeEntry( "/CLSID/" + cidStr + "/ProgID/Default", vName ); + ok = settings.writeEntry( "/" + vName + "/CLSID/Default", cidStr ); + if ( ok && !!description ) + settings.writeEntry( "/" + vName + "/Default", description ); + + if ( ok && version ) { + settings.writeEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default", name ); + TQString curVer = settings.readEntry( "/" + name + "/CurVer/Default" ); + if ( !curVer || curVer < vName ) { // no previous, or a lesser version installed + settings.writeEntry( "/" + name + "/CurVer/Default", vName ); + ok = settings.writeEntry( "/" + name + "/CLSID/Default", cidStr ); + if ( ok && !!description ) + settings.writeEntry( "/" + name + "/Default", description ); + } + } + } + + return ok; +} + +/*! + Unregisters the component with id \a cid from the system component registry and returns + TRUE if the component was unregistered successfully, otherwise returns FALSE. + + Call this function for each component in an implementation of + \link TQComponentRegistrationInterface::unregisterComponents() unregisterComponents() \endlink. + + \sa registerComponent(), unregisterServer() +*/ +bool TQComponentFactory::unregisterComponent( const TQUuid &cid ) +{ + TQSettings settings; + bool ok = FALSE; + settings.insertSearchPath( TQSettings::Windows, "/Classes" ); + + TQString cidStr = cid.toString().upper(); + if ( cidStr.isEmpty() ) + return FALSE; + + // unregister the human readable part + TQString vName = settings.readEntry( "/CLSID/" + cidStr + "/ProgID/Default", TQString::null, &ok ); + if ( ok ) { + TQString name = settings.readEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default", TQString::null ); + if ( !!name && settings.readEntry( "/" + name + "/CurVer/Default" ) == vName ) { + // unregistering the current version -> change CurVer to previous version + TQString version = vName.right( vName.length() - name.length() - 1 ); + TQString newVerName; + TQString newCidStr; + if ( version.find( '.' ) == -1 ) { + int ver = version.toInt(); + // see if a lesser version is installed, and make that the CurVer + while ( ver-- ) { + newVerName = name + "." + TQString::number( ver ); + newCidStr = settings.readEntry( "/" + newVerName + "/CLSID/Default" ); + if ( !!newCidStr ) + break; + } + } else { + // oh well... + } + if ( !!newCidStr ) { + settings.writeEntry( "/" + name + "/CurVer/Default", newVerName ); + settings.writeEntry( "/" + name + "/CLSID/Default", newCidStr ); + } else { + settings.removeEntry( "/" + name + "/CurVer/Default" ); + settings.removeEntry( "/" + name + "/CLSID/Default" ); + settings.removeEntry( "/" + name + "/Default" ); + } + } + + settings.removeEntry( "/" + vName + "/CLSID/Default" ); + settings.removeEntry( "/" + vName + "/Default" ); + } + + settings.removeEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default" ); + settings.removeEntry( "/CLSID/" + cidStr + "/ProgID/Default" ); + settings.removeEntry( "/CLSID/" + cidStr + "/InprocServer32/Default" ); + ok = settings.removeEntry( "/CLSID/" + cidStr + "/Default" ); + + return ok; +} + +#endif // TQT_NO_COMPONENT diff --git a/src/tools/tqcomponentfactory_p.h b/src/tools/tqcomponentfactory_p.h new file mode 100644 index 000000000..89399152f --- /dev/null +++ b/src/tools/tqcomponentfactory_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Definition of the TQComponentFactory class +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools 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 TQCOMPONENTFACTORY_P_H +#define TQCOMPONENTFACTORY_P_H + +#ifndef QT_H +#include "qcom_p.h" +#endif // QT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef TQT_NO_COMPONENT + +class TQ_EXPORT TQComponentFactory +{ +public: + static TQRESULT createInstance( const TQString &cid, const TQUuid &iid, TQUnknownInterface** instance, TQUnknownInterface *outer = 0 ); + static TQRESULT registerServer( const TQString &filename ); + static TQRESULT unregisterServer( const TQString &filename ); + + static bool registerComponent( const TQUuid &cid, const TQString &filename, const TQString &name = TQString::null, + int version = 0, const TQString &description = TQString::null ); + static bool unregisterComponent( const TQUuid &cid ); +}; + +#endif // TQT_NO_COMPONENT + +#endif // TQCOMPONENTFACTORY_P_H diff --git a/src/tools/tqregexp.cpp b/src/tools/tqregexp.cpp index 19758f95c..1aed2ca4c 100644 --- a/src/tools/tqregexp.cpp +++ b/src/tools/tqregexp.cpp @@ -45,7 +45,7 @@ #include "tqmemarray.h" #include "tqbitarray.h" #include "tqcache.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqintdict.h" #include "tqmap.h" #include "tqptrvector.h" diff --git a/src/tools/tqstring.cpp b/src/tools/tqstring.cpp index 546069d48..5247289df 100644 --- a/src/tools/tqstring.cpp +++ b/src/tools/tqstring.cpp @@ -75,7 +75,7 @@ #include #endif #if !defined( TQT_NO_COMPONENT ) && !defined( QT_LITE_COMPONENT ) -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #endif #if defined(Q_OS_LINUX) diff --git a/src/widgets/qdockwindow.cpp b/src/widgets/qdockwindow.cpp index bfe89fcda..9886e9ea0 100644 --- a/src/widgets/qdockwindow.cpp +++ b/src/widgets/qdockwindow.cpp @@ -54,7 +54,7 @@ #include "tqtimer.h" #include "tqtooltip.h" #include "tqguardedptr.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqstyle.h" #if defined(TQ_WS_MAC9) diff --git a/src/widgets/qtitlebar.cpp b/src/widgets/qtitlebar.cpp index c97c47320..f0aa7bce8 100644 --- a/src/widgets/qtitlebar.cpp +++ b/src/widgets/qtitlebar.cpp @@ -44,7 +44,7 @@ #ifndef TQT_NO_TITLEBAR -#include +#include #include "ntqapplication.h" #include "tqstyle.h" #include "tqdatetime.h" diff --git a/src/widgets/tqaction.cpp b/src/widgets/tqaction.cpp index a7e5c0e58..63a7896c5 100644 --- a/src/widgets/tqaction.cpp +++ b/src/widgets/tqaction.cpp @@ -43,7 +43,7 @@ #include "tqtoolbar.h" #include "tqptrlist.h" #include "tqpopupmenu.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqtoolbutton.h" #include "tqcombobox.h" #include "tqtooltip.h" diff --git a/src/widgets/tqbutton.cpp b/src/widgets/tqbutton.cpp index d44c5baa0..333ff6270 100644 --- a/src/widgets/tqbutton.cpp +++ b/src/widgets/tqbutton.cpp @@ -44,7 +44,7 @@ #include "tqbitmap.h" #include "tqpainter.h" #include "tqtimer.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqpixmapcache.h" #include "ntqapplication.h" #include "tqpushbutton.h" @@ -53,7 +53,7 @@ #include "../kernel/qinternal_p.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #define AUTO_REPEAT_DELAY 300 diff --git a/src/widgets/tqcombobox.cpp b/src/widgets/tqcombobox.cpp index 4d315b848..d431bea96 100644 --- a/src/widgets/tqcombobox.cpp +++ b/src/widgets/tqcombobox.cpp @@ -56,7 +56,7 @@ #include "tqstyle.h" #include #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif /*! diff --git a/src/widgets/tqdial.cpp b/src/widgets/tqdial.cpp index 75793b5c1..6c9b4d499 100644 --- a/src/widgets/tqdial.cpp +++ b/src/widgets/tqdial.cpp @@ -50,7 +50,7 @@ #include "tqbitmap.h" #include "tqstyle.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #include // sin(), cos(), atan() diff --git a/src/widgets/tqgroupbox.cpp b/src/widgets/tqgroupbox.cpp index 54b5dd5cf..4a7c84902 100644 --- a/src/widgets/tqgroupbox.cpp +++ b/src/widgets/tqgroupbox.cpp @@ -43,7 +43,7 @@ #include "tqlayout.h" #include "tqpainter.h" #include "tqbitmap.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqradiobutton.h" #include "ntqfocusdata.h" #include "tqobjectlist.h" @@ -53,7 +53,7 @@ #include "tqcheckbox.h" #include "tqbuttongroup.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif /*! diff --git a/src/widgets/tqiconview.cpp b/src/widgets/tqiconview.cpp index e897ccc42..35b144b81 100644 --- a/src/widgets/tqiconview.cpp +++ b/src/widgets/tqiconview.cpp @@ -57,7 +57,7 @@ #include "tqpen.h" #include "tqbrush.h" #include "tqtimer.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "ntqapplication.h" #include "tqtextedit.h" #include "tqmemarray.h" @@ -68,7 +68,7 @@ #include "tqpixmapcache.h" #include "tqptrdict.h" #include "tqstringlist.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "private/qrichtext_p.h" #include "tqstyle.h" diff --git a/src/widgets/tqlabel.cpp b/src/widgets/tqlabel.cpp index 7f9d858bb..414e730e5 100644 --- a/src/widgets/tqlabel.cpp +++ b/src/widgets/tqlabel.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_LABEL #include "tqpainter.h" #include "ntqdrawutil.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqmovie.h" #include "tqimage.h" #include "tqbitmap.h" diff --git a/src/widgets/tqlineedit.cpp b/src/widgets/tqlineedit.cpp index b781b4814..2137a01d4 100644 --- a/src/widgets/tqlineedit.cpp +++ b/src/widgets/tqlineedit.cpp @@ -67,7 +67,7 @@ #include #endif #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #ifndef TQT_NO_ACCEL diff --git a/src/widgets/tqlistbox.cpp b/src/widgets/tqlistbox.cpp index fcda9ac5f..e7c90ddcb 100644 --- a/src/widgets/tqlistbox.cpp +++ b/src/widgets/tqlistbox.cpp @@ -59,7 +59,7 @@ #include "tqpopupmenu.h" #include "tqguardedptr.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #include diff --git a/src/widgets/tqlistview.cpp b/src/widgets/tqlistview.cpp index 104362f9b..084fcf203 100644 --- a/src/widgets/tqlistview.cpp +++ b/src/widgets/tqlistview.cpp @@ -43,7 +43,7 @@ #include "tqtimer.h" #include "tqheader.h" #include "tqpainter.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqptrstack.h" #include "tqptrlist.h" #include "tqstrlist.h" @@ -53,7 +53,7 @@ #include "tqptrdict.h" #include "tqptrvector.h" #include "tqiconset.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "tqpixmapcache.h" #include "tqpopupmenu.h" #include "ntqtl.h" @@ -65,7 +65,7 @@ #include "tqstylesheet.h" #include "../kernel/qinternal_p.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif const int Unsorted = 16383; diff --git a/src/widgets/tqmainwindow.cpp b/src/widgets/tqmainwindow.cpp index c84e7fe65..f301d2085 100644 --- a/src/widgets/tqmainwindow.cpp +++ b/src/widgets/tqmainwindow.cpp @@ -48,7 +48,7 @@ #include "ntqapplication.h" #include "tqptrlist.h" #include "tqmap.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqpainter.h" #include "tqmenubar.h" #include "tqpopupmenu.h" diff --git a/src/widgets/tqmenubar.cpp b/src/widgets/tqmenubar.cpp index 6432d432b..192301ad7 100644 --- a/src/widgets/tqmenubar.cpp +++ b/src/widgets/tqmenubar.cpp @@ -45,18 +45,18 @@ #ifndef TQT_NO_MENUBAR #include "tqmenubar.h" #include "tqpopupmenu.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqpainter.h" #include "ntqdrawutil.h" #include "ntqapplication.h" #include "tqguardedptr.h" #include "tqlayout.h" -#include "ntqcleanuphandler.h" +#include "tqcleanuphandler.h" #include "../kernel/qinternal_p.h" #include "tqstyle.h" #include "tqtimer.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif class TQMenuDataData { diff --git a/src/widgets/tqmultilineedit.cpp b/src/widgets/tqmultilineedit.cpp index 8ef23e266..8311291b3 100644 --- a/src/widgets/tqmultilineedit.cpp +++ b/src/widgets/tqmultilineedit.cpp @@ -42,7 +42,7 @@ #ifndef TQT_NO_MULTILINEEDIT #include "tqpainter.h" #include "tqscrollbar.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqclipboard.h" #include "tqpixmap.h" #include "tqregexp.h" diff --git a/src/widgets/tqpopupmenu.cpp b/src/widgets/tqpopupmenu.cpp index 8030b23e8..5aba3873a 100644 --- a/src/widgets/tqpopupmenu.cpp +++ b/src/widgets/tqpopupmenu.cpp @@ -41,7 +41,7 @@ #include "tqpopupmenu.h" #ifndef TQT_NO_POPUPMENU #include "tqmenubar.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqpainter.h" #include "ntqdrawutil.h" #include "ntqapplication.h" @@ -52,12 +52,12 @@ #include "tqobjectlist.h" #include "tqguardedptr.h" #include "qeffects_p.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqstyle.h" #include "tqtimer.h" #include "tqdatetime.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif //#define ANIMATED_POPUP diff --git a/src/widgets/tqprogressbar.cpp b/src/widgets/tqprogressbar.cpp index fb51aa9c3..d3cde6821 100644 --- a/src/widgets/tqprogressbar.cpp +++ b/src/widgets/tqprogressbar.cpp @@ -47,7 +47,7 @@ #include "tqwmatrix.h" #include "../kernel/qinternal_p.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #include diff --git a/src/widgets/tqpushbutton.cpp b/src/widgets/tqpushbutton.cpp index 2b329e9d7..22c054e2d 100644 --- a/src/widgets/tqpushbutton.cpp +++ b/src/widgets/tqpushbutton.cpp @@ -52,7 +52,7 @@ #include "tqtoolbar.h" #include "tqstyle.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif /*! diff --git a/src/widgets/tqscrollbar.cpp b/src/widgets/tqscrollbar.cpp index 383ce44bd..3f6c683c7 100644 --- a/src/widgets/tqscrollbar.cpp +++ b/src/widgets/tqscrollbar.cpp @@ -46,10 +46,10 @@ #include "tqtimer.h" #include "tqstyle.h" #ifndef TQT_NO_CURSOR -#include +#include #endif #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #include diff --git a/src/widgets/tqscrollview.cpp b/src/widgets/tqscrollview.cpp index de60cccf3..71fa86123 100644 --- a/src/widgets/tqscrollview.cpp +++ b/src/widgets/tqscrollview.cpp @@ -44,7 +44,7 @@ #include "tqobjectlist.h" #include "tqpainter.h" #include "tqpixmap.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "ntqfocusdata.h" #include "tqscrollview.h" #include "tqptrdict.h" diff --git a/src/widgets/tqslider.cpp b/src/widgets/tqslider.cpp index 98d61b68d..ce25334a0 100644 --- a/src/widgets/tqslider.cpp +++ b/src/widgets/tqslider.cpp @@ -47,7 +47,7 @@ #include "ntqapplication.h" #include "tqstyle.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif static const int thresholdTime = 300; diff --git a/src/widgets/tqspinbox.cpp b/src/widgets/tqspinbox.cpp index ff336035d..f805b65ba 100644 --- a/src/widgets/tqspinbox.cpp +++ b/src/widgets/tqspinbox.cpp @@ -41,7 +41,7 @@ #include "tqspinbox.h" #ifndef TQT_NO_SPINBOX -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqpushbutton.h" #include "tqpainter.h" #include "tqbitmap.h" @@ -51,7 +51,7 @@ #include "ntqapplication.h" #include "tqstyle.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif static bool sumOutOfRange(int current, int add) diff --git a/src/widgets/tqtabbar.cpp b/src/widgets/tqtabbar.cpp index 3e3f623f7..140473e6a 100644 --- a/src/widgets/tqtabbar.cpp +++ b/src/widgets/tqtabbar.cpp @@ -38,7 +38,7 @@ #include "tqtabbar.h" #ifndef TQT_NO_TABBAR -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqbitmap.h" #include "tqtoolbutton.h" #include "tqtooltip.h" @@ -46,10 +46,10 @@ #include "tqstyle.h" #include "tqpainter.h" #include "tqiconset.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "../kernel/qinternal_p.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #ifdef TQ_WS_MACX diff --git a/src/widgets/tqtabwidget.cpp b/src/widgets/tqtabwidget.cpp index f5781754f..fdf857050 100644 --- a/src/widgets/tqtabwidget.cpp +++ b/src/widgets/tqtabwidget.cpp @@ -45,7 +45,7 @@ #include "ntqapplication.h" #include "tqwidgetstack.h" #include "tqbitmap.h" -#include "ntqaccel.h" +#include "tqaccel.h" #include "tqstyle.h" #include "tqpainter.h" #include "tqtoolbutton.h" diff --git a/src/widgets/tqtextbrowser.cpp b/src/widgets/tqtextbrowser.cpp index 504209717..69ae10d56 100644 --- a/src/widgets/tqtextbrowser.cpp +++ b/src/widgets/tqtextbrowser.cpp @@ -57,7 +57,7 @@ #include "tqsimplerichtext.h" #include "tqdragobject.h" #include "tqurl.h" -#include "ntqcursor.h" +#include "tqcursor.h" /*! \class TQTextBrowser tqtextbrowser.h diff --git a/src/widgets/tqtextedit.cpp b/src/widgets/tqtextedit.cpp index 1d5805f6d..135c981cc 100644 --- a/src/widgets/tqtextedit.cpp +++ b/src/widgets/tqtextedit.cpp @@ -68,7 +68,7 @@ #include "tqstylesheet.h" #include "tqdragobject.h" #include "tqurl.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqregexp.h" #include "tqpopupmenu.h" #include "tqptrstack.h" diff --git a/src/widgets/tqtoolbar.cpp b/src/widgets/tqtoolbar.cpp index 27c06fb64..a2cfdbf1c 100644 --- a/src/widgets/tqtoolbar.cpp +++ b/src/widgets/tqtoolbar.cpp @@ -43,7 +43,7 @@ #include "tqmainwindow.h" #include "tqtooltip.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqlayout.h" #include "tqframe.h" #include "tqobjectlist.h" diff --git a/src/widgets/tqwhatsthis.cpp b/src/widgets/tqwhatsthis.cpp index 1328c49ea..242016454 100644 --- a/src/widgets/tqwhatsthis.cpp +++ b/src/widgets/tqwhatsthis.cpp @@ -46,13 +46,13 @@ #include "tqptrdict.h" #include "tqtoolbutton.h" #include "ntqshared.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqbitmap.h" #include "tqtooltip.h" #include "tqsimplerichtext.h" #include "tqstylesheet.h" #if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" +#include "tqaccessible.h" #endif #if defined(TQ_WS_WIN) #include "qt_windows.h" diff --git a/src/widgets/tqwhatsthis.h b/src/widgets/tqwhatsthis.h index 66b4b3c90..6fc2538e5 100644 --- a/src/widgets/tqwhatsthis.h +++ b/src/widgets/tqwhatsthis.h @@ -45,7 +45,7 @@ #ifndef TQT_NO_WHATSTHIS -#include "ntqcursor.h" +#include "tqcursor.h" class TQToolButton; class TQPopupMenu; diff --git a/src/widgets/tqwidgetresizehandler.cpp b/src/widgets/tqwidgetresizehandler.cpp index 248d1b3f9..342626e53 100644 --- a/src/widgets/tqwidgetresizehandler.cpp +++ b/src/widgets/tqwidgetresizehandler.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_RESIZEHANDLER #include "tqframe.h" #include "ntqapplication.h" -#include "ntqcursor.h" +#include "tqcursor.h" #include "tqsizegrip.h" #if defined(TQ_WS_WIN) #include "qt_windows.h" diff --git a/src/workspace/tqworkspace.cpp b/src/workspace/tqworkspace.cpp index 48973398a..5803cd664 100644 --- a/src/workspace/tqworkspace.cpp +++ b/src/workspace/tqworkspace.cpp @@ -47,8 +47,8 @@ #include "tqtoolbutton.h" #include "tqlabel.h" #include "tqvbox.h" -#include "ntqaccel.h" -#include "ntqcursor.h" +#include "tqaccel.h" +#include "tqcursor.h" #include "tqpopupmenu.h" #include "tqmenubar.h" #include "tqguardedptr.h" -- cgit v1.2.3