From 8ac0e970e4464d9f8f73c0fb34a178ff135be8c3 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 2 Jun 2024 23:07:22 +0900 Subject: Rename ntqwidget* related files to equivalent tqwidget* Signed-off-by: Michele Calgaro --- src/widgets/ntqbutton.h | 2 +- src/widgets/ntqcombobox.h | 2 +- src/widgets/ntqdatetimeedit.h | 2 +- src/widgets/ntqdial.h | 2 +- src/widgets/ntqdockarea.h | 2 +- src/widgets/ntqframe.h | 2 +- src/widgets/ntqhbox.h | 2 +- src/widgets/ntqheader.h | 2 +- src/widgets/ntqmainwindow.h | 2 +- src/widgets/ntqscrollbar.h | 2 +- src/widgets/ntqslider.h | 2 +- src/widgets/ntqspinbox.h | 2 +- src/widgets/ntqsplashscreen.h | 2 +- src/widgets/ntqstatusbar.h | 2 +- src/widgets/ntqtabbar.h | 2 +- src/widgets/ntqtabwidget.h | 2 +- src/widgets/ntqtooltip.h | 2 +- src/widgets/ntqwidgetplugin.h | 120 ------ src/widgets/ntqwidgetstack.h | 112 ------ src/widgets/qdialogbuttons_p.h | 2 +- src/widgets/qdockarea.cpp | 2 +- src/widgets/qdockwindow.cpp | 2 +- src/widgets/qeffects.cpp | 2 +- src/widgets/qscrollview.cpp | 2 +- src/widgets/qt_widgets.pri | 14 +- src/widgets/qtabwidget.cpp | 2 +- src/widgets/qtoolbar.cpp | 2 +- src/widgets/qtoolbox.cpp | 2 +- src/widgets/qwidgetinterface_p.h | 145 ------- src/widgets/qwidgetplugin.cpp | 729 ---------------------------------- src/widgets/qwidgetresizehandler.cpp | 516 ------------------------ src/widgets/qwidgetresizehandler_p.h | 137 ------- src/widgets/qwidgetstack.cpp | 605 ---------------------------- src/widgets/tqwidgetinterface_p.h | 145 +++++++ src/widgets/tqwidgetplugin.cpp | 729 ++++++++++++++++++++++++++++++++++ src/widgets/tqwidgetplugin.h | 120 ++++++ src/widgets/tqwidgetresizehandler.cpp | 516 ++++++++++++++++++++++++ src/widgets/tqwidgetresizehandler_p.h | 137 +++++++ src/widgets/tqwidgetstack.cpp | 605 ++++++++++++++++++++++++++++ src/widgets/tqwidgetstack.h | 112 ++++++ 40 files changed, 2396 insertions(+), 2396 deletions(-) delete mode 100644 src/widgets/ntqwidgetplugin.h delete mode 100644 src/widgets/ntqwidgetstack.h delete mode 100644 src/widgets/qwidgetinterface_p.h delete mode 100644 src/widgets/qwidgetplugin.cpp delete mode 100644 src/widgets/qwidgetresizehandler.cpp delete mode 100644 src/widgets/qwidgetresizehandler_p.h delete mode 100644 src/widgets/qwidgetstack.cpp create mode 100644 src/widgets/tqwidgetinterface_p.h create mode 100644 src/widgets/tqwidgetplugin.cpp create mode 100644 src/widgets/tqwidgetplugin.h create mode 100644 src/widgets/tqwidgetresizehandler.cpp create mode 100644 src/widgets/tqwidgetresizehandler_p.h create mode 100644 src/widgets/tqwidgetstack.cpp create mode 100644 src/widgets/tqwidgetstack.h (limited to 'src/widgets') diff --git a/src/widgets/ntqbutton.h b/src/widgets/ntqbutton.h index 0d0aa65ef..5683e44b7 100644 --- a/src/widgets/ntqbutton.h +++ b/src/widgets/ntqbutton.h @@ -42,7 +42,7 @@ #define TQBUTTON_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqkeysequence.h" #endif // QT_H diff --git a/src/widgets/ntqcombobox.h b/src/widgets/ntqcombobox.h index f7bf2e422..296148549 100644 --- a/src/widgets/ntqcombobox.h +++ b/src/widgets/ntqcombobox.h @@ -42,7 +42,7 @@ #define TQCOMBOBOX_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_COMBOBOX diff --git a/src/widgets/ntqdatetimeedit.h b/src/widgets/ntqdatetimeedit.h index 6ff8f0215..75a0ef4d2 100644 --- a/src/widgets/ntqdatetimeedit.h +++ b/src/widgets/ntqdatetimeedit.h @@ -42,7 +42,7 @@ #define TQDATETIMEEDIT_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqstring.h" #include "ntqdatetime.h" #endif // QT_H diff --git a/src/widgets/ntqdial.h b/src/widgets/ntqdial.h index b4dba6eec..7baf98e53 100644 --- a/src/widgets/ntqdial.h +++ b/src/widgets/ntqdial.h @@ -43,7 +43,7 @@ #define TQDIAL_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqrangecontrol.h" #endif // QT_H diff --git a/src/widgets/ntqdockarea.h b/src/widgets/ntqdockarea.h index e3a767c4d..ee9201597 100644 --- a/src/widgets/ntqdockarea.h +++ b/src/widgets/ntqdockarea.h @@ -42,7 +42,7 @@ #define TQDOCKAREA_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqptrlist.h" #include "ntqdockwindow.h" #include "ntqlayout.h" diff --git a/src/widgets/ntqframe.h b/src/widgets/ntqframe.h index e0afe5923..db565f474 100644 --- a/src/widgets/ntqframe.h +++ b/src/widgets/ntqframe.h @@ -42,7 +42,7 @@ #define TQFRAME_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_FRAME diff --git a/src/widgets/ntqhbox.h b/src/widgets/ntqhbox.h index 8b45cb751..f92379514 100644 --- a/src/widgets/ntqhbox.h +++ b/src/widgets/ntqhbox.h @@ -39,7 +39,7 @@ #define TQHBOX_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_HBOX diff --git a/src/widgets/ntqheader.h b/src/widgets/ntqheader.h index 7030fe11d..9fe9917a5 100644 --- a/src/widgets/ntqheader.h +++ b/src/widgets/ntqheader.h @@ -42,7 +42,7 @@ #define TQHEADER_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqstring.h" #include "ntqiconset.h" // conversion TQPixmap->TQIconset #endif // QT_H diff --git a/src/widgets/ntqmainwindow.h b/src/widgets/ntqmainwindow.h index 02e2939a3..647c23206 100644 --- a/src/widgets/ntqmainwindow.h +++ b/src/widgets/ntqmainwindow.h @@ -42,7 +42,7 @@ #define TQMAINWINDOW_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqtoolbar.h" #include "ntqptrlist.h" #include "ntqtextstream.h" diff --git a/src/widgets/ntqscrollbar.h b/src/widgets/ntqscrollbar.h index ab52ff626..6a298c96f 100644 --- a/src/widgets/ntqscrollbar.h +++ b/src/widgets/ntqscrollbar.h @@ -44,7 +44,7 @@ class TQTimer; #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqrangecontrol.h" #endif // QT_H diff --git a/src/widgets/ntqslider.h b/src/widgets/ntqslider.h index 1bf9a6c6b..af60245e3 100644 --- a/src/widgets/ntqslider.h +++ b/src/widgets/ntqslider.h @@ -42,7 +42,7 @@ #define TQSLIDER_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqrangecontrol.h" #endif // QT_H diff --git a/src/widgets/ntqspinbox.h b/src/widgets/ntqspinbox.h index 5b1abd8b0..345857c74 100644 --- a/src/widgets/ntqspinbox.h +++ b/src/widgets/ntqspinbox.h @@ -42,7 +42,7 @@ #define TQSPINBOX_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqrangecontrol.h" #endif // QT_H diff --git a/src/widgets/ntqsplashscreen.h b/src/widgets/ntqsplashscreen.h index 6649923e6..9670a1476 100644 --- a/src/widgets/ntqsplashscreen.h +++ b/src/widgets/ntqsplashscreen.h @@ -41,7 +41,7 @@ #ifndef QT_H #include "ntqpixmap.h" -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_SPLASHSCREEN diff --git a/src/widgets/ntqstatusbar.h b/src/widgets/ntqstatusbar.h index 4b3f98f32..b4c84ea17 100644 --- a/src/widgets/ntqstatusbar.h +++ b/src/widgets/ntqstatusbar.h @@ -42,7 +42,7 @@ #define TQSTATUSBAR_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_STATUSBAR diff --git a/src/widgets/ntqtabbar.h b/src/widgets/ntqtabbar.h index 9e8f71667..c7010ed53 100644 --- a/src/widgets/ntqtabbar.h +++ b/src/widgets/ntqtabbar.h @@ -40,7 +40,7 @@ #define TQTABBAR_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqptrlist.h" #endif // QT_H diff --git a/src/widgets/ntqtabwidget.h b/src/widgets/ntqtabwidget.h index e2ba055c4..c2d3242dd 100644 --- a/src/widgets/ntqtabwidget.h +++ b/src/widgets/ntqtabwidget.h @@ -42,7 +42,7 @@ #define TQTABWIDGET_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqiconset.h" #endif // QT_H diff --git a/src/widgets/ntqtooltip.h b/src/widgets/ntqtooltip.h index e5673511d..3058ed0e0 100644 --- a/src/widgets/ntqtooltip.h +++ b/src/widgets/ntqtooltip.h @@ -40,7 +40,7 @@ #define TQTOOLTIP_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_TOOLTIP diff --git a/src/widgets/ntqwidgetplugin.h b/src/widgets/ntqwidgetplugin.h deleted file mode 100644 index cd40860d3..000000000 --- a/src/widgets/ntqwidgetplugin.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Definition of TQWidgetPlugin class -** -** Created : 010920 -** -** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the widgets 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 TQWIDGETPLUGIN_H -#define TQWIDGETPLUGIN_H - -#ifndef QT_H -#include "ntqgplugin.h" -#include "ntqstringlist.h" -#include "ntqiconset.h" -#endif // QT_H -#ifndef TQT_NO_WIDGETPLUGIN - -#ifdef TQ_WS_WIN -#ifdef QT_PLUGIN -#define QT_WIDGET_PLUGIN_EXPORT __declspec(dllexport) -#else -#define QT_WIDGET_PLUGIN_EXPORT __declspec(dllimport) -#endif -#else -#define QT_WIDGET_PLUGIN_EXPORT -#endif - -class TQWidgetPluginPrivate; -class TQWidget; - -class TQ_EXPORT TQWidgetPlugin : public TQGPlugin -{ - TQ_OBJECT -public: - TQWidgetPlugin(); - ~TQWidgetPlugin(); - - virtual TQStringList keys() const = 0; - virtual TQWidget *create( const TQString &key, TQWidget *parent = 0, const char *name = 0 ) = 0; - - virtual TQString group( const TQString &key ) const; - virtual TQIconSet iconSet( const TQString &key ) const; - virtual TQString includeFile( const TQString &key ) const; - virtual TQString toolTip( const TQString &key ) const; - virtual TQString whatsThis( const TQString &key ) const; - virtual bool isContainer( const TQString &key ) const; - -private: - TQWidgetPluginPrivate *d; -}; - -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - -class TQWidgetContainerPluginPrivate; - -class TQ_EXPORT TQWidgetContainerPlugin : public TQWidgetPlugin -{ - -public: - TQWidgetContainerPlugin(); - ~TQWidgetContainerPlugin(); - - virtual TQWidget* containerOfWidget( const TQString &key, TQWidget *container ) const; - virtual bool isPassiveInteractor( const TQString &key, TQWidget *container ) const; - - virtual bool supportsPages( const TQString &key ) const; - - virtual TQWidget *addPage( const TQString &key, TQWidget *container, - const TQString &name, int index ) const; - virtual void insertPage( const TQString &key, TQWidget *container, - const TQString &name, int index, TQWidget *page ) const; - virtual void removePage( const TQString &key, TQWidget *container, int index ) const; - virtual void movePage( const TQString &key, TQWidget *container, int fromIndex, int toIndex ) const; - virtual int count( const TQString &key, TQWidget *container ) const; - virtual int currentIndex( const TQString &key, TQWidget *container ) const; - virtual TQString pageLabel( const TQString &key, TQWidget *container, int index ) const; - virtual TQWidget *page( const TQString &key, TQWidget *container, int index ) const; - virtual void renamePage( const TQString &key, TQWidget *container, - int index, const TQString &newName ) const; - virtual TQWidgetList pages( const TQString &key, TQWidget *container ) const; - virtual TQString createCode( const TQString &key, const TQString &container, - const TQString &page, const TQString &pageName ) const; -}; - -#endif // QT_CONTAINER_CUSTOM_WIDGETS -#endif // TQT_NO_WIDGETPLUGIN -#endif // TQWIDGETPLUGIN_H diff --git a/src/widgets/ntqwidgetstack.h b/src/widgets/ntqwidgetstack.h deleted file mode 100644 index 4967804c8..000000000 --- a/src/widgets/ntqwidgetstack.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Definition of TQWidgetStack class -** -** Created : 980306 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the widgets 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 TQWIDGETSTACK_H -#define TQWIDGETSTACK_H - -#ifndef QT_H -#include "ntqframe.h" -#include "ntqintdict.h" -#include "ntqptrdict.h" -#endif // QT_H - -#ifndef TQT_NO_WIDGETSTACK - - -class TQWidgetStackPrivate; - - -class TQ_EXPORT TQWidgetStack: public TQFrame -{ - TQ_OBJECT -public: - TQWidgetStack( TQWidget* parent=0, const char* name=0 ); - TQWidgetStack( TQWidget* parent, const char* name, WFlags f); - - ~TQWidgetStack(); - - int addWidget( TQWidget *, int = -1 ); - void removeWidget( TQWidget * ); - - TQSize sizeHint() const; - TQSize minimumSizeHint() const; - void show(); - - TQWidget * widget( int ) const; - int id( TQWidget * ) const; - - TQWidget * visibleWidget() const; - - void setFrameRect( const TQRect & ); - -signals: - void aboutToShow( int ); - void aboutToShow( TQWidget * ); - -public slots: - void raiseWidget( int ); - void raiseWidget( TQWidget * ); - -protected: - void frameChanged(); - void resizeEvent( TQResizeEvent * ); - - virtual void setChildGeometries(); - void childEvent( TQChildEvent * ); - -private: - void init(); - - TQWidgetStackPrivate * d; - TQIntDict * dict; - TQPtrDict * focusWidgets; - TQWidget * topWidget; - TQWidget * invisible; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQWidgetStack( const TQWidgetStack & ); - TQWidgetStack& operator=( const TQWidgetStack & ); -#endif -}; - -#endif // TQT_NO_WIDGETSTACK - -#endif // TQWIDGETSTACK_H diff --git a/src/widgets/qdialogbuttons_p.h b/src/widgets/qdialogbuttons_p.h index 90e645b80..a5667245f 100644 --- a/src/widgets/qdialogbuttons_p.h +++ b/src/widgets/qdialogbuttons_p.h @@ -41,7 +41,7 @@ #ifndef QT_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #endif diff --git a/src/widgets/qdockarea.cpp b/src/widgets/qdockarea.cpp index a763cdc53..3693a036d 100644 --- a/src/widgets/qdockarea.cpp +++ b/src/widgets/qdockarea.cpp @@ -46,7 +46,7 @@ #include "ntqptrvector.h" #include "ntqapplication.h" #include "ntqpainter.h" -#include "ntqwidgetlist.h" +#include "tqwidgetlist.h" #include "ntqmap.h" #include "ntqmainwindow.h" diff --git a/src/widgets/qdockwindow.cpp b/src/widgets/qdockwindow.cpp index e889e5a4d..4ebe27aca 100644 --- a/src/widgets/qdockwindow.cpp +++ b/src/widgets/qdockwindow.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_MAINWINDOW #include "ntqdesktopwidget.h" #include "ntqdockarea.h" -#include "qwidgetresizehandler_p.h" +#include "tqwidgetresizehandler_p.h" #include "qtitlebar_p.h" #include "ntqpainter.h" #include "ntqapplication.h" diff --git a/src/widgets/qeffects.cpp b/src/widgets/qeffects.cpp index ddf0dd70b..d40cdb868 100644 --- a/src/widgets/qeffects.cpp +++ b/src/widgets/qeffects.cpp @@ -40,7 +40,7 @@ #include "ntqapplication.h" #ifndef TQT_NO_EFFECTS -#include "ntqwidget.h" +#include "tqwidget.h" #include "qeffects_p.h" #include "ntqpixmap.h" #include "ntqimage.h" diff --git a/src/widgets/qscrollview.cpp b/src/widgets/qscrollview.cpp index 4198e3132..8b9981ffa 100644 --- a/src/widgets/qscrollview.cpp +++ b/src/widgets/qscrollview.cpp @@ -38,7 +38,7 @@ ** **********************************************************************/ -#include "ntqwidget.h" +#include "tqwidget.h" #ifndef TQT_NO_SCROLLVIEW #include "ntqscrollbar.h" #include "tqobjectlist.h" diff --git a/src/widgets/qt_widgets.pri b/src/widgets/qt_widgets.pri index a678e21de..8be28d1cf 100644 --- a/src/widgets/qt_widgets.pri +++ b/src/widgets/qt_widgets.pri @@ -8,7 +8,7 @@ widgets { $$WIDGETS_P/qdialogbuttons_p.h \ $$WIDGETS_H/ntqcheckbox.h \ $$WIDGETS_H/ntqcombobox.h \ - $$WIDGETS_P/qwidgetresizehandler_p.h \ + $$WIDGETS_P/tqwidgetresizehandler_p.h \ $$WIDGETS_H/ntqdial.h \ $$WIDGETS_H/ntqdockarea.h \ $$WIDGETS_H/ntqdockwindow.h \ @@ -56,21 +56,21 @@ widgets { $$WIDGETS_H/ntqvbuttongroup.h \ $$WIDGETS_H/ntqvgroupbox.h \ $$WIDGETS_H/ntqwhatsthis.h \ - $$WIDGETS_H/ntqwidgetstack.h \ + $$WIDGETS_H/tqwidgetstack.h \ $$WIDGETS_H/ntqaction.h \ $$WIDGETS_H/ntqdatetimeedit.h \ $$WIDGETS_H/ntqtextview.h \ $$WIDGETS_H/ntqtextbrowser.h \ $$WIDGETS_H/ntqtextedit.h \ - $$WIDGETS_P/qwidgetinterface_p.h \ - $$WIDGETS_H/ntqwidgetplugin.h + $$WIDGETS_P/tqwidgetinterface_p.h \ + $$WIDGETS_H/tqwidgetplugin.h SOURCES += $$WIDGETS_CPP/qbuttongroup.cpp \ $$WIDGETS_CPP/qbutton.cpp \ $$WIDGETS_CPP/qdialogbuttons.cpp \ $$WIDGETS_CPP/qcheckbox.cpp \ $$WIDGETS_CPP/qcombobox.cpp \ - $$WIDGETS_CPP/qwidgetresizehandler.cpp \ + $$WIDGETS_CPP/tqwidgetresizehandler.cpp \ $$WIDGETS_CPP/qdial.cpp \ $$WIDGETS_CPP/qdockarea.cpp \ $$WIDGETS_CPP/qdockwindow.cpp \ @@ -118,14 +118,14 @@ widgets { $$WIDGETS_CPP/qvbuttongroup.cpp \ $$WIDGETS_CPP/qvgroupbox.cpp \ $$WIDGETS_CPP/qwhatsthis.cpp \ - $$WIDGETS_CPP/qwidgetstack.cpp \ + $$WIDGETS_CPP/tqwidgetstack.cpp \ $$WIDGETS_CPP/qaction.cpp \ $$WIDGETS_CPP/qdatetimeedit.cpp \ $$WIDGETS_CPP/qeffects.cpp \ $$WIDGETS_CPP/qtextview.cpp \ $$WIDGETS_CPP/qtextbrowser.cpp \ $$WIDGETS_CPP/qtextedit.cpp \ - $$WIDGETS_CPP/qwidgetplugin.cpp + $$WIDGETS_CPP/tqwidgetplugin.cpp !embedded:mac:SOURCES += $$WIDGETS_CPP/qmenubar_mac.cpp } diff --git a/src/widgets/qtabwidget.cpp b/src/widgets/qtabwidget.cpp index f6c54524c..464affb58 100644 --- a/src/widgets/qtabwidget.cpp +++ b/src/widgets/qtabwidget.cpp @@ -43,7 +43,7 @@ #include "tqobjectlist.h" #include "ntqtabbar.h" #include "ntqapplication.h" -#include "ntqwidgetstack.h" +#include "tqwidgetstack.h" #include "ntqbitmap.h" #include "ntqaccel.h" #include "ntqstyle.h" diff --git a/src/widgets/qtoolbar.cpp b/src/widgets/qtoolbar.cpp index fd5bf56a2..a3d390e43 100644 --- a/src/widgets/qtoolbar.cpp +++ b/src/widgets/qtoolbar.cpp @@ -53,7 +53,7 @@ #include "ntqpopupmenu.h" #include "ntqcombobox.h" #include "ntqtimer.h" -#include "ntqwidgetlist.h" +#include "tqwidgetlist.h" #include "ntqstyle.h" static const char * const arrow_v_xpm[] = { diff --git a/src/widgets/qtoolbox.cpp b/src/widgets/qtoolbox.cpp index a8d2523ac..a04c78dbe 100644 --- a/src/widgets/qtoolbox.cpp +++ b/src/widgets/qtoolbox.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/widgets/qwidgetinterface_p.h b/src/widgets/qwidgetinterface_p.h deleted file mode 100644 index 5cfd43e48..000000000 --- a/src/widgets/qwidgetinterface_p.h +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** ... -** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the widgets 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 TQWIDGETINTERFACE_P_H -#define TQWIDGETINTERFACE_P_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 QT_H -#include -#include "ntqiconset.h" -#endif // QT_H - -#ifndef TQT_NO_WIDGETPLUGIN - -class TQWidget; - -// {55184143-f18f-42c0-a8eb-71c01516019a} -#ifndef IID_QWidgetFactory -#define IID_QWidgetFactory TQUuid( 0x55184143, 0xf18f, 0x42c0, 0xa8, 0xeb, 0x71, 0xc0, 0x15, 0x16, 0x1, 0x9a ) -#endif - -/*! To add custom widgets to the TQt Designer, implement that interface - in your custom widget plugin. - - You also have to implement the function featureList() (\sa - TQFeatureListInterface) and return there all widgets (names of it) - which this interface provides. -*/ - -struct TQWidgetFactoryInterface : public TQFeatureListInterface -{ -public: - - /*! In the implementation create and return the widget \a widget - here, use \a parent and \a name when creating the widget */ - virtual TQWidget* create( const TQString &widget, TQWidget* parent = 0, const char* name = 0 ) = 0; - - /*! In the implementation return the name of the group of the - widget \a widget */ - virtual TQString group( const TQString &widget ) const = 0; - - /*! In the implementation return the iconset, which should be used - in the TQt Designer menubar and toolbar to represent the widget - \a widget */ - virtual TQIconSet iconSet( const TQString &widget ) const = 0; - - /*! In the implementation return the include file which is needed - for the widget \a widget in the generated code which uic - generates. */ - virtual TQString includeFile( const TQString &widget ) const = 0; - - /*! In the implementation return the text which should be - displayed as tooltip for the widget \a widget */ - virtual TQString toolTip( const TQString &widget ) const = 0; - - /*! In the implementation return the text which should be used for - what's this help for the widget \a widget. */ - virtual TQString whatsThis( const TQString &widget ) const = 0; - - /*! In the implementation return TRUE here, of the \a widget - should be able to contain other widget in the TQt Designer, else - FALSE. */ - virtual bool isContainer( const TQString &widget ) const = 0; -}; - -#ifdef QT_CONTAINER_CUSTOM_WIDGETS -// {15976628-e3c3-47f4-b525-d124a3caf30e} -#ifndef IID_QWidgetContainer -#define IID_QWidgetContainer TQUuid( 0x15976628, 0xe3c3, 0x47f4, 0xb5, 0x25, 0xd1, 0x24, 0xa3, 0xca, 0xf3, 0x0e ) -#endif - -struct TQWidgetContainerInterfacePrivate : public TQUnknownInterface -{ -public: - virtual TQWidget *containerOfWidget( const TQString &f, TQWidget *container ) const = 0; - virtual bool isPassiveInteractor( const TQString &f, TQWidget *container ) const = 0; - - virtual bool supportsPages( const TQString &f ) const = 0; - - virtual TQWidget *addPage( const TQString &f, TQWidget *container, - const TQString &name, int index ) const = 0; - virtual void insertPage( const TQString &f, TQWidget *container, - const TQString &name, int index, TQWidget *page ) const = 0; - virtual void removePage( const TQString &f, TQWidget *container, int index ) const = 0; - virtual void movePage( const TQString &f, TQWidget *container, int fromIndex, int toIndex ) const = 0; - virtual int count( const TQString &key, TQWidget *container ) const = 0; - virtual int currentIndex( const TQString &key, TQWidget *container ) const = 0; - virtual TQString pageLabel( const TQString &key, TQWidget *container, int index ) const = 0; - virtual TQWidget *page( const TQString &key, TQWidget *container, int index ) const = 0; - virtual void renamePage( const TQString &key, TQWidget *container, - int index, const TQString &newName ) const = 0; - virtual TQWidgetList pages( const TQString &f, TQWidget *container ) const = 0; - virtual TQString createCode( const TQString &f, const TQString &container, - const TQString &page, const TQString &pageName ) const = 0; -}; - -#endif // QT_CONTAINER_CUSTOM_WIDGETS -#endif // TQT_NO_WIDGETPLUGIN -#endif // TQWIDGETINTERFACE_P_H diff --git a/src/widgets/qwidgetplugin.cpp b/src/widgets/qwidgetplugin.cpp deleted file mode 100644 index 2d026221c..000000000 --- a/src/widgets/qwidgetplugin.cpp +++ /dev/null @@ -1,729 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQWidgetPlugin class -** -** Created : 010920 -** -** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the widgets 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 "ntqwidgetplugin.h" - -#ifndef TQT_NO_WIDGETPLUGIN -#include "qwidgetinterface_p.h" -#include "tqobjectcleanuphandler.h" -#include "ntqwidget.h" -#ifdef QT_CONTAINER_CUSTOM_WIDGETS -#include "ntqwidgetlist.h" -#endif - -/*! - \class TQWidgetPlugin ntqwidgetplugin.h - \brief The TQWidgetPlugin class provides an abstract base for custom TQWidget plugins. - - \ingroup plugins - - The widget plugin is a simple plugin interface that makes it easy - to create custom widgets that can be included in forms using \link - designer-manual.book TQt Designer\endlink and used by applications. - - Writing a widget plugin is achieved by subclassing this base - class, reimplementing the pure virtual functions keys(), create(), - group(), iconSet(), includeFile(), toolTip(), whatsThis() and - isContainer(), and exporting the class with the \c TQ_EXPORT_PLUGIN - macro. - - See the \link designer-manual.book TQt Designer manual's\endlink, - 'Creating Custom Widgets' section in the 'Creating Custom Widgets' - chapter, for a complete example of a TQWidgetPlugin. - - See also the \link plugins-howto.html Plugins - documentation\endlink and the \l{TQWidgetFactory} class that is - supplied with \link designer-manual.book TQt Designer\endlink. -*/ - -class TQWidgetPluginPrivate : public TQWidgetFactoryInterface, -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - public TQWidgetContainerInterfacePrivate, -#endif - private TQLibraryInterface -{ -public: - TQWidgetPluginPrivate( TQWidgetPlugin *p ) - : plugin( p ) - { - } - - virtual ~TQWidgetPluginPrivate(); - - TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface ); - TQ_REFCOUNT; - - TQStringList featureList() const; - TQWidget *create( const TQString &key, TQWidget *parent, const char *name ); - TQString group( const TQString &widget ) const; - TQIconSet iconSet( const TQString &widget ) const; - TQString includeFile( const TQString &widget ) const; - TQString toolTip( const TQString &widget ) const; - TQString whatsThis( const TQString &widget ) const; - bool isContainer( const TQString &widget ) const; -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - TQWidget* containerOfWidget( const TQString &key, TQWidget *widget ) const; - bool isPassiveInteractor( const TQString &key, TQWidget *widget ) const; - bool supportsPages( const TQString &key ) const; - TQWidget *addPage( const TQString &key, TQWidget *container, const TQString &name, int index ) const; - void insertPage( const TQString &key, TQWidget *container, - const TQString &name, int index, TQWidget *page ) const; - void Page( const TQString &key, TQWidget *container, - const TQString &name, int index, TQWidget *page ) const; - void removePage( const TQString &key, TQWidget *container, int index ) const; - void movePage( const TQString &key, TQWidget *container, int fromIndex, int toIndex ) const; - int count( const TQString &key, TQWidget *container ) const; - int currentIndex( const TQString &key, TQWidget *container ) const; - TQString pageLabel( const TQString &key, TQWidget *container, int index ) const; - TQWidget *page( const TQString &key, TQWidget *container, int index ) const; - void renamePage( const TQString &key, TQWidget *container, int index, const TQString &newName ) const; - TQWidgetList pages( const TQString &key, TQWidget *container ) const; - TQString createCode( const TQString &key, const TQString &container, - const TQString &page, const TQString &pageName ) const; -#endif // QT_CONTAINER_CUSTOM_WIDGETS - bool init(); - void cleanup(); - bool canUnload() const; - -private: - TQWidgetPlugin *plugin; - TQObjectCleanupHandler widgets; -}; - -TQRESULT TQWidgetPluginPrivate::queryInterface( const TQUuid &iid, TQUnknownInterface **iface ) -{ - *iface = 0; - - if ( iid == IID_QUnknown ) - *iface = (TQWidgetFactoryInterface*)this; - else if ( iid == IID_QFeatureList ) - *iface = (TQFeatureListInterface*)this; - else if ( iid == IID_QWidgetFactory ) - *iface = (TQWidgetFactoryInterface*)this; - else if ( iid == IID_QLibrary ) - *iface = (TQLibraryInterface*)this; -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - else if ( iid == IID_QWidgetContainer ) - *iface = (TQWidgetContainerInterfacePrivate*)this; -#endif - else - return TQE_NOINTERFACE; - - (*iface)->addRef(); - return TQS_OK; -} - -/*! - \fn TQStringList TQWidgetPlugin::keys() const - - Returns the list of widget keys this plugin supports. - - These keys must be the class names of the custom widgets that are - implemented in the plugin. - - \sa create() -*/ - -/*! - \fn TQWidget *TQWidgetPlugin::create( const TQString &, TQWidget *, const char * ) - - Creates and returns a TQWidget object for the widget key \a key. - The widget key is the class name of the required widget. The \a - name and \a parent arguments are passed to the custom widget's - constructor. - - \sa keys() -*/ - -TQWidgetPluginPrivate::~TQWidgetPluginPrivate() -{ - delete plugin; -} - -TQStringList TQWidgetPluginPrivate::featureList() const -{ - return plugin->keys(); -} - -TQWidget *TQWidgetPluginPrivate::create( const TQString &key, TQWidget *parent, const char *name ) -{ - TQWidget *w = plugin->create( key, parent, name ); - widgets.add( w ); - return w; -} - -TQString TQWidgetPluginPrivate::group( const TQString &widget ) const -{ - return plugin->group( widget ); -} - -TQIconSet TQWidgetPluginPrivate::iconSet( const TQString &widget ) const -{ - return plugin->iconSet( widget ); -} - -TQString TQWidgetPluginPrivate::includeFile( const TQString &widget ) const -{ - return plugin->includeFile( widget ); -} - -TQString TQWidgetPluginPrivate::toolTip( const TQString &widget ) const -{ - return plugin->toolTip( widget ); -} - -TQString TQWidgetPluginPrivate::whatsThis( const TQString &widget ) const -{ - return plugin->whatsThis( widget ); -} - -bool TQWidgetPluginPrivate::isContainer( const TQString &widget ) const -{ - return plugin->isContainer( widget ); -} - -bool TQWidgetPluginPrivate::init() -{ - return TRUE; -} - -void TQWidgetPluginPrivate::cleanup() -{ - widgets.clear(); -} - -bool TQWidgetPluginPrivate::canUnload() const -{ - return widgets.isEmpty(); -} - -#ifdef QT_CONTAINER_CUSTOM_WIDGETS -TQWidget* TQWidgetPluginPrivate::containerOfWidget( const TQString &key, TQWidget *widget ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->containerOfWidget( key, widget ); - return widget; -} - -int TQWidgetPluginPrivate::count( const TQString &key, TQWidget *container ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->count( key, container ); - return 0; -} - -int TQWidgetPluginPrivate::currentIndex( const TQString &key, TQWidget *container ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->currentIndex( key, container ); - return -1; -} - -TQString TQWidgetPluginPrivate::pageLabel( const TQString &key, TQWidget *container, int index ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->pageLabel( key, container, index ); - return TQString::null; -} - -TQWidget *TQWidgetPluginPrivate::page( const TQString &key, TQWidget *container, int index ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->page( key, container, index ); - return 0; -} - -bool TQWidgetPluginPrivate::isPassiveInteractor( const TQString &key, TQWidget *widget ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->isPassiveInteractor( key, widget ); - return FALSE; -} - -bool TQWidgetPluginPrivate::supportsPages( const TQString &key ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->supportsPages( key ); - return 0; -} - -TQWidget *TQWidgetPluginPrivate::addPage( const TQString &key, TQWidget *container, - const TQString &name, int index ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->addPage( key, container, name, index ); - return 0; -} - -void TQWidgetPluginPrivate::insertPage( const TQString &key, TQWidget *container, - const TQString &name, int index, TQWidget *page ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - p->insertPage( key, container, name, index, page ); -} - -void TQWidgetPluginPrivate::removePage( const TQString &key, TQWidget *container, int index ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - p->removePage( key, container, index ); -} - -void TQWidgetPluginPrivate::movePage( const TQString &key, TQWidget *container, - int fromIndex, int toIndex ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - p->movePage( key, container, fromIndex, toIndex ); -} - -void TQWidgetPluginPrivate::renamePage( const TQString &key, TQWidget *container, - int index, const TQString &newName ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - p->renamePage( key, container, index, newName ); -} - -TQWidgetList TQWidgetPluginPrivate::pages( const TQString &key, TQWidget *container ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->pages( key, container ); - return TQWidgetList(); -} - -TQString TQWidgetPluginPrivate::createCode( const TQString &key, const TQString &container, - const TQString &page, const TQString &pageName ) const -{ - TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); - if ( p ) - return p->createCode( key, container, page, pageName ); - return TQString::null; -} -#endif // QT_CONTAINER_CUSTOM_WIDGETS - -/*! - Constructs a widget plugin. This is invoked automatically by the - \c TQ_EXPORT_PLUGIN macro. -*/ -TQWidgetPlugin::TQWidgetPlugin() - : TQGPlugin( (TQWidgetFactoryInterface*)(d = new TQWidgetPluginPrivate( this )) ) -{ -} - -/*! - Destroys the widget plugin. - - You never have to call this explicitly. TQt destroys a plugin - automatically when it is no longer used. -*/ -TQWidgetPlugin::~TQWidgetPlugin() -{ - // don't delete d, as this is deleted by d -} - -/*! - Returns the group (toolbar name) that the custom widget of class - \a key should be part of when \e{TQt Designer} loads it. - - The default implementation returns TQString::null. -*/ -TQString TQWidgetPlugin::group( const TQString & ) const -{ - return TQString::null; -} - -/*! - Returns the iconset that \e{TQt Designer} should use to represent - the custom widget of class \a key in the toolbar. - - The default implementation returns an null iconset. -*/ -TQIconSet TQWidgetPlugin::iconSet( const TQString & ) const -{ - return TQIconSet(); -} - -/*! - Returns the name of the include file that \e{TQt Designer} and \c - uic should use to include the custom widget of class \a key in - generated code. - - The default implementation returns TQString::null. -*/ -TQString TQWidgetPlugin::includeFile( const TQString & ) const -{ - return TQString::null; -} - -/*! - Returns the text of the tooltip that \e{TQt Designer} should use - for the custom widget of class \a key's toolbar button. - - The default implementation returns TQString::null. -*/ -TQString TQWidgetPlugin::toolTip( const TQString & ) const -{ - return TQString::null; -} - -/*! - Returns the text of the whatsThis text that \e{TQt Designer} should - use when the user requests whatsThis help for the custom widget of - class \a key. - - The default implementation returns TQString::null. -*/ -TQString TQWidgetPlugin::whatsThis( const TQString & ) const -{ - return TQString::null; -} - -/*! - Returns TRUE if the custom widget of class \a key can contain - other widgets, e.g. like TQFrame; otherwise returns FALSE. - - The default implementation returns FALSE. -*/ -bool TQWidgetPlugin::isContainer( const TQString & ) const -{ - return FALSE; -} - -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - -/*! - \class TQWidgetContainerPlugin ntqwidgetplugin.h - \brief The TQWidgetContainerPlugin class provides an abstract base - for complex custom container TQWidget plugins. - - \internal - - \ingroup plugins - - The widget container plugin is a subclass of TQWidgetPlugin and - extends the interface with functions necessary for supporting - complex container widgets via plugins. These container widgets are - widgets that have one or multiple sub widgets which act as the - widget's containers. If the widget has multiple container - subwidgets, they are referred to as "pages", and only one can be - active at a time. Examples of complex container widgets include: - TQTabWidget, TQWidgetStack and TQToolBox. - - Writing a complex container widget plugin is achieved by - subclassing this base class. First by reimplementing - TQWidgetPlugin's pure virtual functions keys(), create(), group(), - iconSet(), includeFile(), toolTip(), whatsThis() and - isContainer(), and exporting the class with the \c TQ_EXPORT_PLUGIN - macro. In addition containerOfWidget(), isPassiveInteractor() and - supportsPages() must be reimplemented. If the widget - supportsPages(), count(), currentIndex(), pageLabel(), page(), - pages() and createCode() must be implemented. If the widget - supportsPages() and you want to allow the containers pages to be - modified, you must also reimplement addPage(), insertPage(), - removePage(), movePage() and renamePage(). - - \sa TQWidgetPlugin -*/ - -/*! - Constructs a complex container widget plugin. This is invoked - automatically by the \c TQ_EXPORT_PLUGIN macro. -*/ - -TQWidgetContainerPlugin::TQWidgetContainerPlugin() - : TQWidgetPlugin() -{ -} - -/*! - Destroys the complex container widget plugin. - - You never have to call this explicitly. TQt destroys a plugin - automatically when it is no longer used. -*/ - -TQWidgetContainerPlugin::~TQWidgetContainerPlugin() -{ -} - -/*! - Operates on the plugin's \a key class. - - Returns the current \a container's custom widget. If the custom - widget is a tab widget, this function takes the \a container as - input and returns the widget's current page. - - The default implementation returns \a container. -*/ - -TQWidget* TQWidgetContainerPlugin::containerOfWidget( const TQString &, - TQWidget *container ) const -{ - return container; -} - -/*! - Operates on the plugin's \a key class. - - Returns the \a container custom widget's number of pages. If the - custom widget is a tab widget, this function returns the number of - tabs. - - The default implementation returns 0. -*/ - -int TQWidgetContainerPlugin::count( const TQString &, TQWidget * ) const -{ - return 0; -} - -/*! - Operates on the plugin's \a key class. - - Returns the \a container custom widget's current page index. If - the custom widget is a tab widget, this function returns the - current tab's index. - - The default implementation returns -1. -*/ - -int TQWidgetContainerPlugin::currentIndex( const TQString &, TQWidget * ) const -{ - return -1; -} - -/*! - Operates on the plugin's \a key class. - - Returns the \a container custom widget's label at position \a - index. If the custom widget is a tab widget, this function returns - the current tab's label. - - The default implementation returns a null string. -*/ - -TQString TQWidgetContainerPlugin::pageLabel( const TQString &, TQWidget *, int ) const -{ - return TQString::null; -} - -/*! - Operates on the plugin's \a key class. - - Returns the \a container custom widget's page at position \a - index. If the custom widget is a tab widget, this function returns - the tab at index position \e index. - - - The default implementation returns 0. -*/ - -TQWidget *TQWidgetContainerPlugin::page( const TQString &, TQWidget *, int ) const -{ - return 0; -} - -/*! - Operates on the plugin's \a key class. - - Returns TRUE if the \a container custom widget is a passive - interactor for class \e key; otherwise returns FALSE. The \a - container is a child widget of the actual custom widget. - - Usually, when a custom widget is used in \e{TQt Designer}'s design - mode, no widget receives any mouse or key events, since \e{TQt - Designer} filters and processes them itself. If one or more - widgets of a custom widget still need to receive such events, for - example, because the widget needs to change pages, this function - must return TRUE for the widget. In such cases \e{TQt Designer} - will not filter out key and mouse events destined for the widget. - - If the custom widget is a tab widget, the tab bar is the passive - interactor, since that's what the user will use to change pages. - - The default implementation returns FALSE. -*/ - -bool TQWidgetContainerPlugin::isPassiveInteractor( const TQString &, - TQWidget *container ) const -{ - Q_UNUSED( container ) - return FALSE; -} - -/*! - Operates on the plugin's \a key class. - - Returns TRUE if the widget supports pages; otherwise returns - FALSE. If the custom widget is a tab widget this function should - return TRUE. - - The default implementation returns FALSE. -*/ - -bool TQWidgetContainerPlugin::supportsPages( const TQString & ) const -{ - return FALSE; -} - -/*! - Operates on the plugin's \a key class. - - This function is called when a new page with the given \a name - should be added to the \a container custom widget at position \a - index. - - The default implementation does nothing. -*/ - -TQWidget* TQWidgetContainerPlugin::addPage( const TQString &, TQWidget *, - const TQString &, int ) const -{ - return 0; -} - -/*! - Operates on the plugin's \a key class. - - This function is called when a new page, \a page, with the given - \a name should be added to the \a container custom widget at - position \a index. - - The default implementation does nothing. -*/ - -void TQWidgetContainerPlugin::insertPage( const TQString &, TQWidget *, - const TQString &, int, TQWidget * ) const -{ -} - -/*! - Operates on the plugin's \a key class. - - This function is called when the page at position \a index should - be removed from the \a container custom widget. - - The default implementation does nothing. -*/ - -void TQWidgetContainerPlugin::removePage( const TQString &, TQWidget *, int ) const -{ -} - -/*! - Operates on the plugin's \a key class. - - This function is called when the page at position \a fromIndex should - be moved to position \a toIndex in the \a container custom widget. - - The default implementation does nothing. -*/ - -void TQWidgetContainerPlugin::movePage( const TQString &, TQWidget *, int, int ) const -{ -} - -/*! - Operates on the plugin's \a key class. - - This function is called when the page at position \a index should - be renamed (have its label changed) to \a newName in the \a - container custom widget. - - The default implementation does nothing. -*/ - -void TQWidgetContainerPlugin::renamePage( const TQString &, TQWidget *, - int, const TQString & ) const -{ -} - -/*! - Operates on the plugin's \a key class. - - This function should return a list of the \a container custom - widget's pages. -*/ - -TQWidgetList TQWidgetContainerPlugin::pages( const TQString &, TQWidget * ) const -{ - return TQWidgetList(); -} - -/*! - Operates on the plugin's \a key class. - - This function is called from \e{TQt Designer}'s User Interface - Compiler \c uic, when generating C++ code for inserting a page in - the \a container custom widget. The name of the page widget which - should be inserted at the end of the container is \a page, and the - label of the page should be \a pageName. - - If the custom widget was a TQTabWidget, the implementation of this - function should return: - - \code - return widget + "->addTab( " + page + ", \"" + pageName + "\" )"; - \endcode - - Warning: If the code returned by this function contains invalid - C++ syntax, the generated \c uic code will not compile. -*/ - -TQString TQWidgetContainerPlugin::createCode( const TQString &, const TQString &, - const TQString &, const TQString & ) const -{ - return TQString::null; -} - -#endif // QT_CONTAINER_CUSTOM_WIDGETS - -#endif //TQT_NO_WIDGETPLUGIN diff --git a/src/widgets/qwidgetresizehandler.cpp b/src/widgets/qwidgetresizehandler.cpp deleted file mode 100644 index bcddde86b..000000000 --- a/src/widgets/qwidgetresizehandler.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/**************************************************************************** -** -** Implementation of the TQWidgetResizeHandler class -** -** Created : 001010 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the workspace 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 "qwidgetresizehandler_p.h" - -#ifndef TQT_NO_RESIZEHANDLER -#include "ntqframe.h" -#include "ntqapplication.h" -#include "ntqcursor.h" -#include "ntqsizegrip.h" -#if defined(TQ_WS_WIN) -#include "qt_windows.h" -#endif - -#define RANGE 4 - -static bool resizeHorizontalDirectionFixed = FALSE; -static bool resizeVerticalDirectionFixed = FALSE; - -TQWidgetResizeHandler::TQWidgetResizeHandler( TQWidget *parent, TQWidget *cw, const char *name ) - : TQObject( parent, name ), widget( parent ), childWidget( cw ? cw : parent ), - extrahei( 0 ), buttonDown( FALSE ), moveResizeMode( FALSE ), sizeprotect( TRUE ), moving( TRUE ) -{ - mode = Nowhere; - widget->setMouseTracking( TRUE ); - TQFrame *frame = ::tqt_cast(widget); - range = frame ? frame->frameWidth() : RANGE; - range = TQMAX( RANGE, range ); - activeForMove = activeForResize = TRUE; - tqApp->installEventFilter( this ); -} - -void TQWidgetResizeHandler::setActive( Action ac, bool b ) -{ - if ( ac & Move ) - activeForMove = b; - if ( ac & Resize ) - activeForResize = b; - - if ( !isActive() ) - setMouseCursor( Nowhere ); -} - -bool TQWidgetResizeHandler::isActive( Action ac ) const -{ - bool b = FALSE; - if ( ac & Move ) b = activeForMove; - if ( ac & Resize ) b |= activeForResize; - - return b; -} - -static TQWidget *childOf( TQWidget *w, TQWidget *child ) -{ - while ( child ) { - if ( child == w ) - return child; - if ( child->isTopLevel() ) - break; - child = child->parentWidget(); - } - return 0; -} - -bool TQWidgetResizeHandler::eventFilter( TQObject *o, TQEvent *ee ) -{ - if ( !isActive() || !o->isWidgetType() || !ee->spontaneous()) - return FALSE; - - if ( ee->type() != TQEvent::MouseButtonPress && - ee->type() != TQEvent::MouseButtonRelease && - ee->type() != TQEvent::MouseMove && - ee->type() != TQEvent::KeyPress && - ee->type() != TQEvent::AccelOverride ) - return FALSE; - - TQWidget *w = childOf( widget, (TQWidget*)o ); - if ( !w -#ifndef TQT_NO_SIZEGRIP - || ::tqt_cast(o) -#endif - || tqApp->activePopupWidget() ) { - if ( buttonDown && ee->type() == TQEvent::MouseButtonRelease ) - buttonDown = FALSE; - return FALSE; - } - - TQMouseEvent *e = (TQMouseEvent*)ee; - switch ( e->type() ) { - case TQEvent::MouseButtonPress: { - if ( w->isMaximized() ) - break; - if ( !widget->rect().contains( widget->mapFromGlobal( e->globalPos() ) ) ) - return FALSE; - if ( e->button() == LeftButton ) { - emit activate(); - bool me = isMovingEnabled(); - setMovingEnabled( me && o == widget ); - mouseMoveEvent( e ); - setMovingEnabled( me ); - buttonDown = TRUE; - moveOffset = widget->mapFromGlobal( e->globalPos() ); - invertedMoveOffset = widget->rect().bottomRight() - moveOffset; - } - } break; - case TQEvent::MouseButtonRelease: - if ( w->isMaximized() ) - break; - if ( e->button() == LeftButton ) { - moveResizeMode = FALSE; - buttonDown = FALSE; - widget->releaseMouse(); - widget->releaseKeyboard(); - } - break; - case TQEvent::MouseMove: { - if ( w->isMaximized() ) - break; - bool me = isMovingEnabled(); - setMovingEnabled( me && o == widget ); - mouseMoveEvent( e ); - setMovingEnabled( me ); - if ( buttonDown && mode != Center ) - return TRUE; - } break; - case TQEvent::KeyPress: - keyPressEvent( (TQKeyEvent*)e ); - break; - case TQEvent::AccelOverride: - if ( buttonDown ) { - ((TQKeyEvent*)ee)->accept(); - return TRUE; - } - break; - default: - break; - } - return FALSE; -} - -void TQWidgetResizeHandler::mouseMoveEvent( TQMouseEvent *e ) -{ - TQPoint pos = widget->mapFromGlobal( e->globalPos() ); - if ( !moveResizeMode && ( !buttonDown || ( e->state() & LeftButton ) == 0 ) ) { - if ( pos.y() <= range && pos.x() <= range) - mode = TopLeft; - else if ( pos.y() >= widget->height()-range && pos.x() >= widget->width()-range) - mode = BottomRight; - else if ( pos.y() >= widget->height()-range && pos.x() <= range) - mode = BottomLeft; - else if ( pos.y() <= range && pos.x() >= widget->width()-range) - mode = TopRight; - else if ( pos.y() <= range ) - mode = Top; - else if ( pos.y() >= widget->height()-range ) - mode = Bottom; - else if ( pos.x() <= range ) - mode = Left; - else if ( pos.x() >= widget->width()-range ) - mode = Right; - else - mode = Center; - - if ( widget->isMinimized() || !isActive(Resize) ) - mode = Center; -#ifndef TQT_NO_CURSOR - setMouseCursor( mode ); -#endif - return; - } - - if ( buttonDown && !isMovingEnabled() && mode == Center && !moveResizeMode ) - return; - - if ( widget->testWState( WState_ConfigPending ) ) - return; - - TQPoint globalPos = widget->parentWidget( TRUE ) ? - widget->parentWidget( TRUE )->mapFromGlobal( e->globalPos() ) : e->globalPos(); - if ( widget->parentWidget( TRUE ) && !widget->parentWidget( TRUE )->rect().contains( globalPos ) ) { - if ( globalPos.x() < 0 ) - globalPos.rx() = 0; - if ( globalPos.y() < 0 ) - globalPos.ry() = 0; - if ( sizeprotect && globalPos.x() > widget->parentWidget()->width() ) - globalPos.rx() = widget->parentWidget()->width(); - if ( sizeprotect && globalPos.y() > widget->parentWidget()->height() ) - globalPos.ry() = widget->parentWidget()->height(); - } - - TQPoint p = globalPos + invertedMoveOffset; - TQPoint pp = globalPos - moveOffset; - - int fw = 0; - int mw = TQMAX( childWidget->minimumSizeHint().width(), - childWidget->minimumWidth() ); - int mh = TQMAX( childWidget->minimumSizeHint().height(), - childWidget->minimumHeight() ); - if ( childWidget != widget ) { - TQFrame *frame = ::tqt_cast(widget); - if ( frame ) - fw = frame->frameWidth(); - mw += 2 * fw; - mh += 2 * fw + extrahei; - } - - TQSize mpsize( widget->geometry().right() - pp.x() + 1, - widget->geometry().bottom() - pp.y() + 1 ); - mpsize = mpsize.expandedTo( widget->minimumSize() ).expandedTo( TQSize(mw, mh) ); - TQPoint mp( widget->geometry().right() - mpsize.width() + 1, - widget->geometry().bottom() - mpsize.height() + 1 ); - - TQRect geom = widget->geometry(); - - switch ( mode ) { - case TopLeft: - geom = TQRect( mp, widget->geometry().bottomRight() ) ; - break; - case BottomRight: - geom = TQRect( widget->geometry().topLeft(), p ) ; - break; - case BottomLeft: - geom = TQRect( TQPoint(mp.x(), widget->geometry().y() ), TQPoint( widget->geometry().right(), p.y()) ) ; - break; - case TopRight: - geom = TQRect( TQPoint( widget->geometry().x(), mp.y() ), TQPoint( p.x(), widget->geometry().bottom()) ) ; - break; - case Top: - geom = TQRect( TQPoint( widget->geometry().left(), mp.y() ), widget->geometry().bottomRight() ) ; - break; - case Bottom: - geom = TQRect( widget->geometry().topLeft(), TQPoint( widget->geometry().right(), p.y() ) ) ; - break; - case Left: - geom = TQRect( TQPoint( mp.x(), widget->geometry().top() ), widget->geometry().bottomRight() ) ; - break; - case Right: - geom = TQRect( widget->geometry().topLeft(), TQPoint( p.x(), widget->geometry().bottom() ) ) ; - break; - case Center: - if ( isMovingEnabled() || moveResizeMode ) - geom.moveTopLeft( pp ); - break; - default: - break; - } - - TQSize maxsize( childWidget->maximumSize() ); - if ( childWidget != widget ) - maxsize += TQSize( 2 * fw, 2 * fw + extrahei ); - - geom = TQRect( geom.topLeft(), - geom.size().expandedTo( widget->minimumSize() ) - .expandedTo( TQSize(mw, mh) ) - .boundedTo( maxsize ) ); - - if ( geom != widget->geometry() && - ( widget->isTopLevel() || widget->parentWidget()->rect().intersects( geom ) ) ) { - if ( widget->isMinimized() ) - widget->move( geom.topLeft() ); - else - widget->setGeometry( geom ); - } - -#if defined(TQ_WS_WIN) - MSG msg; - QT_WA( { - while(PeekMessageW( &msg, widget->winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE )) - ; - } , { - while(PeekMessageA( &msg, widget->winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE )) - ; - } ); -#endif - - TQApplication::syncX(); -} - -void TQWidgetResizeHandler::setMouseCursor( MousePosition m ) -{ -#ifndef TQT_NO_CURSOR - switch ( m ) { - case TopLeft: - case BottomRight: - widget->setCursor( sizeFDiagCursor ); - break; - case BottomLeft: - case TopRight: - widget->setCursor( sizeBDiagCursor ); - break; - case Top: - case Bottom: - widget->setCursor( sizeVerCursor ); - break; - case Left: - case Right: - widget->setCursor( sizeHorCursor ); - break; - default: - widget->setCursor( arrowCursor ); - break; - } -#endif -} - -void TQWidgetResizeHandler::keyPressEvent( TQKeyEvent * e ) -{ - if ( !isMove() && !isResize() ) - return; - bool is_control = e->state() & ControlButton; - int delta = is_control?1:8; - TQPoint pos = TQCursor::pos(); - switch ( e->key() ) { - case Key_Left: - pos.rx() -= delta; - if ( pos.x() <= TQApplication::desktop()->geometry().left() ) { - if ( mode == TopLeft || mode == BottomLeft ) { - moveOffset.rx() += delta; - invertedMoveOffset.rx() += delta; - } else { - moveOffset.rx() -= delta; - invertedMoveOffset.rx() -= delta; - } - } - if ( isResize() && !resizeHorizontalDirectionFixed ) { - resizeHorizontalDirectionFixed = TRUE; - if ( mode == BottomRight ) - mode = BottomLeft; - else if ( mode == TopRight ) - mode = TopLeft; -#ifndef TQT_NO_CURSOR - setMouseCursor( mode ); - widget->grabMouse( widget->cursor() ); -#else - widget->grabMouse(); -#endif - } - break; - case Key_Right: - pos.rx() += delta; - if ( pos.x() >= TQApplication::desktop()->geometry().right() ) { - if ( mode == TopRight || mode == BottomRight ) { - moveOffset.rx() += delta; - invertedMoveOffset.rx() += delta; - } else { - moveOffset.rx() -= delta; - invertedMoveOffset.rx() -= delta; - } - } - if ( isResize() && !resizeHorizontalDirectionFixed ) { - resizeHorizontalDirectionFixed = TRUE; - if ( mode == BottomLeft ) - mode = BottomRight; - else if ( mode == TopLeft ) - mode = TopRight; -#ifndef TQT_NO_CURSOR - setMouseCursor( mode ); - widget->grabMouse( widget->cursor() ); -#else - widget->grabMouse(); -#endif - } - break; - case Key_Up: - pos.ry() -= delta; - if ( pos.y() <= TQApplication::desktop()->geometry().top() ) { - if ( mode == TopLeft || mode == TopRight ) { - moveOffset.ry() += delta; - invertedMoveOffset.ry() += delta; - } else { - moveOffset.ry() -= delta; - invertedMoveOffset.ry() -= delta; - } - } - if ( isResize() && !resizeVerticalDirectionFixed ) { - resizeVerticalDirectionFixed = TRUE; - if ( mode == BottomLeft ) - mode = TopLeft; - else if ( mode == BottomRight ) - mode = TopRight; -#ifndef TQT_NO_CURSOR - setMouseCursor( mode ); - widget->grabMouse( widget->cursor() ); -#else - widget->grabMouse(); -#endif - } - break; - case Key_Down: - pos.ry() += delta; - if ( pos.y() >= TQApplication::desktop()->geometry().bottom() ) { - if ( mode == BottomLeft || mode == BottomRight ) { - moveOffset.ry() += delta; - invertedMoveOffset.ry() += delta; - } else { - moveOffset.ry() -= delta; - invertedMoveOffset.ry() -= delta; - } - } - if ( isResize() && !resizeVerticalDirectionFixed ) { - resizeVerticalDirectionFixed = TRUE; - if ( mode == TopLeft ) - mode = BottomLeft; - else if ( mode == TopRight ) - mode = BottomRight; -#ifndef TQT_NO_CURSOR - setMouseCursor( mode ); - widget->grabMouse( widget->cursor() ); -#else - widget->grabMouse(); -#endif - } - break; - case Key_Space: - case Key_Return: - case Key_Enter: - case Key_Escape: - moveResizeMode = FALSE; - widget->releaseMouse(); - widget->releaseKeyboard(); - buttonDown = FALSE; - break; - default: - return; - } - TQCursor::setPos( pos ); -} - - -void TQWidgetResizeHandler::doResize() -{ - if ( !activeForResize ) - return; - - moveResizeMode = TRUE; - buttonDown = TRUE; - moveOffset = widget->mapFromGlobal( TQCursor::pos() ); - if ( moveOffset.x() < widget->width()/2) { - if ( moveOffset.y() < widget->height()/2) - mode = TopLeft; - else - mode = BottomLeft; - } else { - if ( moveOffset.y() < widget->height()/2) - mode = TopRight; - else - mode = BottomRight; - } - invertedMoveOffset = widget->rect().bottomRight() - moveOffset; -#ifndef TQT_NO_CURSOR - setMouseCursor( mode ); - widget->grabMouse( widget->cursor() ); -#else - widget->grabMouse(); -#endif - widget->grabKeyboard(); - resizeHorizontalDirectionFixed = FALSE; - resizeVerticalDirectionFixed = FALSE; -} - -void TQWidgetResizeHandler::doMove() -{ - if ( !activeForMove ) - return; - - mode = Center; - moveResizeMode = TRUE; - buttonDown = TRUE; - moveOffset = widget->mapFromGlobal( TQCursor::pos() ); - invertedMoveOffset = widget->rect().bottomRight() - moveOffset; -#ifndef TQT_NO_CURSOR - widget->grabMouse( SizeAllCursor ); -#else - widget->grabMouse(); -#endif - widget->grabKeyboard(); -} - -#endif //TQT_NO_RESIZEHANDLER diff --git a/src/widgets/qwidgetresizehandler_p.h b/src/widgets/qwidgetresizehandler_p.h deleted file mode 100644 index 30f8e088c..000000000 --- a/src/widgets/qwidgetresizehandler_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Definition of the TQWidgetResizeHandler class -** -** Created : 001010 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the workspace 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 TQWIDGETRESIZEHANDLER_P_H -#define TQWIDGETRESIZEHANDLER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. This header file may -// change from version to version without notice, or even be -// removed. -// -// We mean it. -// -// - -#ifndef QT_H -#include "tqobject.h" -#endif // QT_H -#ifndef TQT_NO_RESIZEHANDLER -class TQMouseEvent; -class TQKeyEvent; - -class TQ_EXPORT TQWidgetResizeHandler : public TQObject -{ - TQ_OBJECT - -public: - enum Action { - Move = 0x01, - Resize = 0x02, - Any = Move|Resize - }; - - TQWidgetResizeHandler( TQWidget *parent, TQWidget *cw = 0, const char *name = 0 ); - void setActive( bool b ) { setActive( Any, b ); } - void setActive( Action ac, bool b ); - bool isActive() const { return isActive( Any ); } - bool isActive( Action ac ) const; - void setMovingEnabled( bool b ) { moving = b; } - bool isMovingEnabled() const { return moving; } - - bool isButtonDown() const { return buttonDown; } - - void setExtraHeight( int h ) { extrahei = h; } - void setSizeProtection( bool b ) { sizeprotect = b; } - - void doResize(); - void doMove(); - -signals: - void activate(); - -protected: - bool eventFilter( TQObject *o, TQEvent *e ); - void mouseMoveEvent( TQMouseEvent *e ); - void keyPressEvent( TQKeyEvent *e ); - -private: - enum MousePosition { - Nowhere, - TopLeft, BottomRight, BottomLeft, TopRight, - Top, Bottom, Left, Right, - Center - }; - - TQWidget *widget; - TQWidget *childWidget; - TQPoint moveOffset; - TQPoint invertedMoveOffset; - MousePosition mode; - int extrahei; - int range; - uint buttonDown :1; - uint moveResizeMode :1; - uint activeForResize :1; - uint sizeprotect :1; - uint moving :1; - uint activeForMove :1; - - void setMouseCursor( MousePosition m ); - bool isMove() const { - return moveResizeMode && mode == Center; - } - bool isResize() const { - return moveResizeMode && !isMove(); - } - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQWidgetResizeHandler( const TQWidgetResizeHandler & ); - TQWidgetResizeHandler& operator=( const TQWidgetResizeHandler & ); -#endif - -}; - -#endif //TQT_NO_RESIZEHANDLER -#endif diff --git a/src/widgets/qwidgetstack.cpp b/src/widgets/qwidgetstack.cpp deleted file mode 100644 index b8cb9e76a..000000000 --- a/src/widgets/qwidgetstack.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQWidgetStack class -** -** Created : 980128 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the widgets 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 "ntqwidgetstack.h" -#include "ntqlayout.h" -#include "../kernel/qlayoutengine_p.h" -#ifndef TQT_NO_WIDGETSTACK - -#include "tqobjectlist.h" -#include "ntqfocusdata.h" -#include "ntqbutton.h" -#include "ntqbuttongroup.h" - -#include "ntqapplication.h" - -class TQWidgetStackPrivate { -public: - class Invisible: public TQWidget - { - public: - Invisible( TQWidgetStack * parent ): TQWidget( parent, "qt_invisible_widgetstack" ) - { - setBackgroundMode( NoBackground ); - } - const char * className() const - { - return "TQWidgetStackPrivate::Invisible"; - } - }; -}; - - -class TQWidgetStackEventFilter : public TQObject -{ - /* For binary compatibility, since we cannot implement virtual - functions and rely on them being called. This is what we should - have - - bool TQWidgetStack::event( TQEvent* e ) - { - if ( e->type() == TQEvent::LayoutHint ) - updateGeometry(); // propgate layout hints to parent - return TQFrame::event( e ); - } - */ -public: - - TQWidgetStackEventFilter( TQObject *parent = 0, const char * name = 0 ) - : TQObject( parent, name ) {} - bool eventFilter( TQObject *o, TQEvent * e ) { - if ( e->type() == TQEvent::LayoutHint && o->isWidgetType() ) - ((TQWidget*)o)->updateGeometry(); - return FALSE; - } -}; - - -/*! - \class TQWidgetStack - \brief The TQWidgetStack class provides a stack of widgets of which - only the top widget is user-visible. - - \ingroup organizers - \mainclass - - The application programmer can move any widget to the top of the - stack at any time using raiseWidget(), and add or remove widgets - using addWidget() and removeWidget(). It is not sufficient to pass - the widget stack as parent to a widget which should be inserted into - the widgetstack. - - visibleWidget() is the \e get equivalent of raiseWidget(); it - returns a pointer to the widget that is currently at the top of - the stack. - - TQWidgetStack also provides the ability to manipulate widgets - through application-specified integer IDs. You can also translate - from widget pointers to IDs using id() and from IDs to widget - pointers using widget(). These numeric IDs are unique (per - TQWidgetStack, not globally), but TQWidgetStack does not attach any - additional meaning to them. - - The default widget stack is frameless, but you can use the usual - TQFrame functions (such as setFrameStyle()) to add a frame. - - TQWidgetStack provides a signal, aboutToShow(), which is emitted - just before a managed widget is shown. - - \sa TQTabDialog TQTabBar TQFrame -*/ - - -/*! - Constructs an empty widget stack. - - The \a parent and \a name arguments are passed to the TQFrame - constructor. -*/ - -TQWidgetStack::TQWidgetStack( TQWidget * parent, const char *name ) - : TQFrame( parent, name ) -{ - init(); -} - -/*! - Constructs an empty widget stack. - - The \a parent, \a name and \a f arguments are passed to the TQFrame - constructor. -*/ -TQWidgetStack::TQWidgetStack( TQWidget * parent, const char *name, WFlags f ) - : TQFrame( parent, name, f ) //## merge constructors in 4.0 -{ - init(); -} - -void TQWidgetStack::init() -{ - d = 0; - TQWidgetStackEventFilter *ef = new TQWidgetStackEventFilter( this ); - installEventFilter( ef ); - dict = new TQIntDict; - focusWidgets = 0; - topWidget = 0; - invisible = new TQWidgetStackPrivate::Invisible( this ); - invisible->hide(); -} - - -/*! - Destroys the object and frees any allocated resources. -*/ - -TQWidgetStack::~TQWidgetStack() -{ - delete focusWidgets; - delete d; - delete dict; -} - - -/*! - Adds widget \a w to this stack of widgets, with ID \a id. - - If you pass an id \>= 0 this ID is used. If you pass an \a id of - -1 (the default), the widgets will be numbered automatically. If - you pass -2 a unique negative integer will be generated. No widget - has an ID of -1. Returns the ID or -1 on failure (e.g. \a w is 0). - - If you pass an id that is already used, then a unique negative - integer will be generated to prevent two widgets having the same - id. - - If \a w already exists in the stack the widget will be removed first. - - If \a w is not a child of this TQWidgetStack moves it using - reparent(). -*/ - -int TQWidgetStack::addWidget( TQWidget * w, int id ) -{ - static int nseq_no = -2; - static int pseq_no = 0; - - if ( !w || w == invisible ) - return -1; - - // prevent duplicates - removeWidget( w ); - - if ( id >= 0 && dict->find( id ) ) - id = -2; - if ( id < -1 ) - id = nseq_no--; - else if ( id == -1 ) - id = pseq_no++; - else - pseq_no = TQMAX(pseq_no, id + 1); - // use id >= 0 as-is - - dict->insert( id, w ); - - // preserve existing focus - TQWidget * f = w->focusWidget(); - while( f && f != w ) - f = f->parentWidget(); - if ( f ) { - if ( !focusWidgets ) - focusWidgets = new TQPtrDict( 17 ); - focusWidgets->replace( w, w->focusWidget() ); - } - - w->hide(); - if ( w->parent() != this ) - w->reparent( this, contentsRect().topLeft(), FALSE ); - w->setGeometry( contentsRect() ); - updateGeometry(); - return id; -} - - -/*! - Removes widget \a w from this stack of widgets. Does not delete \a - w. If \a w is the currently visible widget, no other widget is - substituted. - - \sa visibleWidget() raiseWidget() -*/ - -void TQWidgetStack::removeWidget( TQWidget * w ) -{ - if ( !w ) - return; - int i = id( w ); - if ( i != -1 ) - dict->take( i ); - - if ( w == topWidget ) - topWidget = 0; - if ( dict->isEmpty() ) - invisible->hide(); // let background shine through again - updateGeometry(); -} - - -/*! - Raises the widget with ID \a id to the top of the widget stack. - - \sa visibleWidget() -*/ - -void TQWidgetStack::raiseWidget( int id ) -{ - if ( id == -1 ) - return; - TQWidget * w = dict->find( id ); - if ( w ) - raiseWidget( w ); -} - -static bool isChildOf( TQWidget* child, TQWidget *parent ) -{ - const TQObjectList *list = parent->children(); - if ( !child || !list ) - return FALSE; - TQObjectListIt it(*list); - TQObject *obj; - while ( (obj = it.current()) ) { - ++it; - if ( !obj->isWidgetType() || ((TQWidget *)obj)->isTopLevel() ) - continue; - TQWidget *widget = (TQWidget *)obj; - if ( widget == child || isChildOf( child, widget ) ) - return TRUE; - } - return FALSE; -} - -/*! - \overload - - Raises widget \a w to the top of the widget stack. -*/ - -void TQWidgetStack::raiseWidget( TQWidget *w ) -{ - if ( !w || w == invisible || w->parent() != this || w == topWidget ) - return; - - if ( id(w) == -1 ) - addWidget( w ); - if ( !isVisible() ) { - topWidget = w; - return; - } - - if (w->maximumSize().width() < invisible->width() - || w->maximumSize().height() < invisible->height()) - invisible->setBackgroundMode(backgroundMode()); - else if (invisible->backgroundMode() != NoBackground) - invisible->setBackgroundMode(NoBackground); - - if ( invisible->isHidden() ) { - invisible->setGeometry( contentsRect() ); - invisible->lower(); - invisible->show(); - TQApplication::sendPostedEvents( invisible, TQEvent::ShowWindowRequest ); - } - - // try to move focus onto the incoming widget if focus - // was somewhere on the outgoing widget. - if ( topWidget ) { - TQWidget * fw = focusWidget(); - TQWidget* p = fw; - while ( p && p != topWidget ) - p = p->parentWidget(); - if ( p == topWidget ) { // focus was on old page - if ( !focusWidgets ) - focusWidgets = new TQPtrDict( 17 ); - focusWidgets->replace( topWidget, fw ); - fw->clearFocus(); - // look for the best focus widget we can find - // best == what we had (which may be deleted) - fw = focusWidgets->take( w ); - if ( isChildOf( fw, w ) ) { - fw->setFocus(); - } else { - // second best == first child widget in the focus chain - TQFocusData *f = focusData(); - TQWidget* home = f->home(); - TQWidget *i = home; - do { - if ( ( ( i->focusPolicy() & TabFocus ) == TabFocus ) - && !i->focusProxy() && i->isVisibleTo(w) && i->isEnabled() ) { - p = i; - while ( p && p != w ) - p = p->parentWidget(); - if ( p == w ) { - i->setFocus(); - break; - } - } - i = f->next(); - } while( i != home ); - } - } - } - - if ( isVisible() ) { - emit aboutToShow( w ); - int i = id( w ); - if ( i != -1 ) - emit aboutToShow( i ); - } - - topWidget = w; - - const TQObjectList * c = children(); - TQObjectListIt it( *c ); - TQObject * o; - - while( (o=it.current()) != 0 ) { - ++it; - if ( o->isWidgetType() && o != w && o != invisible ) - ((TQWidget *)o)->hide(); - } - - w->setGeometry( invisible->geometry() ); - w->show(); -} - -/*! - \reimp -*/ - -void TQWidgetStack::frameChanged() -{ - TQFrame::frameChanged(); - setChildGeometries(); -} - - -/*! - \reimp -*/ - -void TQWidgetStack::setFrameRect( const TQRect & r ) -{ - TQFrame::setFrameRect( r ); - setChildGeometries(); -} - - -/*! - Fixes up the children's geometries. -*/ - -void TQWidgetStack::setChildGeometries() -{ - invisible->setGeometry( contentsRect() ); - if ( topWidget ) - topWidget->setGeometry( invisible->geometry() ); -} - - -/*! - \reimp -*/ -void TQWidgetStack::show() -{ - // Reimplemented in order to set the children's geometries - // appropriately and to pick the first widget as topWidget if no - // topwidget was defined - if ( !isVisible() && children() ) { - const TQObjectList * c = children(); - TQObjectListIt it( *c ); - TQObject * o; - - while( (o=it.current()) != 0 ) { - ++it; - if ( o->isWidgetType() ) { - if ( !topWidget && o != invisible ) - topWidget = (TQWidget*)o; - if ( o == topWidget ) - ((TQWidget *)o)->show(); - else - ((TQWidget *)o)->hide(); - } - } - setChildGeometries(); - } - TQFrame::show(); -} - - -/*! - Returns the widget with ID \a id. Returns 0 if this widget stack - does not manage a widget with ID \a id. - - \sa id() addWidget() -*/ - -TQWidget * TQWidgetStack::widget( int id ) const -{ - return id != -1 ? dict->find( id ) : 0; -} - - -/*! - Returns the ID of the \a widget. Returns -1 if \a widget is 0 or - is not being managed by this widget stack. - - \sa widget() addWidget() -*/ - -int TQWidgetStack::id( TQWidget * widget ) const -{ - if ( !widget ) - return -1; - - TQIntDictIterator it( *dict ); - while ( it.current() && it.current() != widget ) - ++it; - return it.current() == widget ? it.currentKey() : -1; -} - - -/*! - Returns the currently visible widget (the one at the top of the - stack), or 0 if nothing is currently being shown. - - \sa aboutToShow() id() raiseWidget() -*/ - -TQWidget * TQWidgetStack::visibleWidget() const -{ - return topWidget; -} - - -/*! - \fn void TQWidgetStack::aboutToShow( int ) - - This signal is emitted just before a managed widget is shown if - that managed widget has an ID != -1. The argument is the numeric - ID of the widget. - - If you call visibleWidget() in a slot connected to aboutToShow(), - the widget it returns is the one that is currently visible, not - the one that is about to be shown. -*/ - - -/*! - \fn void TQWidgetStack::aboutToShow( TQWidget * ) - - \overload - - This signal is emitted just before a managed widget is shown. The - argument is a pointer to the widget. - - If you call visibleWidget() in a slot connected to aboutToShow(), - the widget returned is the one that is currently visible, not the - one that is about to be shown. -*/ - - -/*! - \reimp -*/ - -void TQWidgetStack::resizeEvent( TQResizeEvent * e ) -{ - TQFrame::resizeEvent( e ); - setChildGeometries(); -} - - -/*! - \reimp -*/ - -TQSize TQWidgetStack::sizeHint() const -{ - constPolish(); - - TQSize size( 0, 0 ); - - TQIntDictIterator it( *dict ); - TQWidget *w; - - while ( (w = it.current()) != 0 ) { - ++it; - TQSize sh = w->sizeHint(); - if ( w->sizePolicy().horData() == TQSizePolicy::Ignored ) - sh.rwidth() = 0; - if ( w->sizePolicy().verData() == TQSizePolicy::Ignored ) - sh.rheight() = 0; -#ifndef TQT_NO_LAYOUT - size = size.expandedTo( sh ).expandedTo( qSmartMinSize(w) ); -#endif - } - if ( size.isNull() ) - size = TQSize( 128, 64 ); - size += TQSize( 2*frameWidth(), 2*frameWidth() ); - return size; -} - - -/*! - \reimp -*/ -TQSize TQWidgetStack::minimumSizeHint() const -{ - constPolish(); - - TQSize size( 0, 0 ); - - TQIntDictIterator it( *dict ); - TQWidget *w; - - while ( (w = it.current()) != 0 ) { - ++it; - TQSize sh = w->minimumSizeHint(); - if ( w->sizePolicy().horData() == TQSizePolicy::Ignored ) - sh.rwidth() = 0; - if ( w->sizePolicy().verData() == TQSizePolicy::Ignored ) - sh.rheight() = 0; -#ifndef TQT_NO_LAYOUT - size = size.expandedTo( sh ).expandedTo( w->minimumSize() ); -#endif - } - if ( size.isNull() ) - size = TQSize( 64, 32 ); - size += TQSize( 2*frameWidth(), 2*frameWidth() ); - return size; -} - -/*! - \reimp -*/ -void TQWidgetStack::childEvent( TQChildEvent * e) -{ - if ( e->child()->isWidgetType() && e->removed() ) - removeWidget( (TQWidget*) e->child() ); -} -#endif diff --git a/src/widgets/tqwidgetinterface_p.h b/src/widgets/tqwidgetinterface_p.h new file mode 100644 index 000000000..5cfd43e48 --- /dev/null +++ b/src/widgets/tqwidgetinterface_p.h @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets 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 TQWIDGETINTERFACE_P_H +#define TQWIDGETINTERFACE_P_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 QT_H +#include +#include "ntqiconset.h" +#endif // QT_H + +#ifndef TQT_NO_WIDGETPLUGIN + +class TQWidget; + +// {55184143-f18f-42c0-a8eb-71c01516019a} +#ifndef IID_QWidgetFactory +#define IID_QWidgetFactory TQUuid( 0x55184143, 0xf18f, 0x42c0, 0xa8, 0xeb, 0x71, 0xc0, 0x15, 0x16, 0x1, 0x9a ) +#endif + +/*! To add custom widgets to the TQt Designer, implement that interface + in your custom widget plugin. + + You also have to implement the function featureList() (\sa + TQFeatureListInterface) and return there all widgets (names of it) + which this interface provides. +*/ + +struct TQWidgetFactoryInterface : public TQFeatureListInterface +{ +public: + + /*! In the implementation create and return the widget \a widget + here, use \a parent and \a name when creating the widget */ + virtual TQWidget* create( const TQString &widget, TQWidget* parent = 0, const char* name = 0 ) = 0; + + /*! In the implementation return the name of the group of the + widget \a widget */ + virtual TQString group( const TQString &widget ) const = 0; + + /*! In the implementation return the iconset, which should be used + in the TQt Designer menubar and toolbar to represent the widget + \a widget */ + virtual TQIconSet iconSet( const TQString &widget ) const = 0; + + /*! In the implementation return the include file which is needed + for the widget \a widget in the generated code which uic + generates. */ + virtual TQString includeFile( const TQString &widget ) const = 0; + + /*! In the implementation return the text which should be + displayed as tooltip for the widget \a widget */ + virtual TQString toolTip( const TQString &widget ) const = 0; + + /*! In the implementation return the text which should be used for + what's this help for the widget \a widget. */ + virtual TQString whatsThis( const TQString &widget ) const = 0; + + /*! In the implementation return TRUE here, of the \a widget + should be able to contain other widget in the TQt Designer, else + FALSE. */ + virtual bool isContainer( const TQString &widget ) const = 0; +}; + +#ifdef QT_CONTAINER_CUSTOM_WIDGETS +// {15976628-e3c3-47f4-b525-d124a3caf30e} +#ifndef IID_QWidgetContainer +#define IID_QWidgetContainer TQUuid( 0x15976628, 0xe3c3, 0x47f4, 0xb5, 0x25, 0xd1, 0x24, 0xa3, 0xca, 0xf3, 0x0e ) +#endif + +struct TQWidgetContainerInterfacePrivate : public TQUnknownInterface +{ +public: + virtual TQWidget *containerOfWidget( const TQString &f, TQWidget *container ) const = 0; + virtual bool isPassiveInteractor( const TQString &f, TQWidget *container ) const = 0; + + virtual bool supportsPages( const TQString &f ) const = 0; + + virtual TQWidget *addPage( const TQString &f, TQWidget *container, + const TQString &name, int index ) const = 0; + virtual void insertPage( const TQString &f, TQWidget *container, + const TQString &name, int index, TQWidget *page ) const = 0; + virtual void removePage( const TQString &f, TQWidget *container, int index ) const = 0; + virtual void movePage( const TQString &f, TQWidget *container, int fromIndex, int toIndex ) const = 0; + virtual int count( const TQString &key, TQWidget *container ) const = 0; + virtual int currentIndex( const TQString &key, TQWidget *container ) const = 0; + virtual TQString pageLabel( const TQString &key, TQWidget *container, int index ) const = 0; + virtual TQWidget *page( const TQString &key, TQWidget *container, int index ) const = 0; + virtual void renamePage( const TQString &key, TQWidget *container, + int index, const TQString &newName ) const = 0; + virtual TQWidgetList pages( const TQString &f, TQWidget *container ) const = 0; + virtual TQString createCode( const TQString &f, const TQString &container, + const TQString &page, const TQString &pageName ) const = 0; +}; + +#endif // QT_CONTAINER_CUSTOM_WIDGETS +#endif // TQT_NO_WIDGETPLUGIN +#endif // TQWIDGETINTERFACE_P_H diff --git a/src/widgets/tqwidgetplugin.cpp b/src/widgets/tqwidgetplugin.cpp new file mode 100644 index 000000000..a12f13418 --- /dev/null +++ b/src/widgets/tqwidgetplugin.cpp @@ -0,0 +1,729 @@ +/**************************************************************************** +** +** Implementation of TQWidgetPlugin class +** +** Created : 010920 +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets 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 "tqwidgetplugin.h" + +#ifndef TQT_NO_WIDGETPLUGIN +#include "tqwidgetinterface_p.h" +#include "tqobjectcleanuphandler.h" +#include "tqwidget.h" +#ifdef QT_CONTAINER_CUSTOM_WIDGETS +#include "tqwidgetlist.h" +#endif + +/*! + \class TQWidgetPlugin tqwidgetplugin.h + \brief The TQWidgetPlugin class provides an abstract base for custom TQWidget plugins. + + \ingroup plugins + + The widget plugin is a simple plugin interface that makes it easy + to create custom widgets that can be included in forms using \link + designer-manual.book TQt Designer\endlink and used by applications. + + Writing a widget plugin is achieved by subclassing this base + class, reimplementing the pure virtual functions keys(), create(), + group(), iconSet(), includeFile(), toolTip(), whatsThis() and + isContainer(), and exporting the class with the \c TQ_EXPORT_PLUGIN + macro. + + See the \link designer-manual.book TQt Designer manual's\endlink, + 'Creating Custom Widgets' section in the 'Creating Custom Widgets' + chapter, for a complete example of a TQWidgetPlugin. + + See also the \link plugins-howto.html Plugins + documentation\endlink and the \l{TQWidgetFactory} class that is + supplied with \link designer-manual.book TQt Designer\endlink. +*/ + +class TQWidgetPluginPrivate : public TQWidgetFactoryInterface, +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + public TQWidgetContainerInterfacePrivate, +#endif + private TQLibraryInterface +{ +public: + TQWidgetPluginPrivate( TQWidgetPlugin *p ) + : plugin( p ) + { + } + + virtual ~TQWidgetPluginPrivate(); + + TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface ); + TQ_REFCOUNT; + + TQStringList featureList() const; + TQWidget *create( const TQString &key, TQWidget *parent, const char *name ); + TQString group( const TQString &widget ) const; + TQIconSet iconSet( const TQString &widget ) const; + TQString includeFile( const TQString &widget ) const; + TQString toolTip( const TQString &widget ) const; + TQString whatsThis( const TQString &widget ) const; + bool isContainer( const TQString &widget ) const; +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + TQWidget* containerOfWidget( const TQString &key, TQWidget *widget ) const; + bool isPassiveInteractor( const TQString &key, TQWidget *widget ) const; + bool supportsPages( const TQString &key ) const; + TQWidget *addPage( const TQString &key, TQWidget *container, const TQString &name, int index ) const; + void insertPage( const TQString &key, TQWidget *container, + const TQString &name, int index, TQWidget *page ) const; + void Page( const TQString &key, TQWidget *container, + const TQString &name, int index, TQWidget *page ) const; + void removePage( const TQString &key, TQWidget *container, int index ) const; + void movePage( const TQString &key, TQWidget *container, int fromIndex, int toIndex ) const; + int count( const TQString &key, TQWidget *container ) const; + int currentIndex( const TQString &key, TQWidget *container ) const; + TQString pageLabel( const TQString &key, TQWidget *container, int index ) const; + TQWidget *page( const TQString &key, TQWidget *container, int index ) const; + void renamePage( const TQString &key, TQWidget *container, int index, const TQString &newName ) const; + TQWidgetList pages( const TQString &key, TQWidget *container ) const; + TQString createCode( const TQString &key, const TQString &container, + const TQString &page, const TQString &pageName ) const; +#endif // QT_CONTAINER_CUSTOM_WIDGETS + bool init(); + void cleanup(); + bool canUnload() const; + +private: + TQWidgetPlugin *plugin; + TQObjectCleanupHandler widgets; +}; + +TQRESULT TQWidgetPluginPrivate::queryInterface( const TQUuid &iid, TQUnknownInterface **iface ) +{ + *iface = 0; + + if ( iid == IID_QUnknown ) + *iface = (TQWidgetFactoryInterface*)this; + else if ( iid == IID_QFeatureList ) + *iface = (TQFeatureListInterface*)this; + else if ( iid == IID_QWidgetFactory ) + *iface = (TQWidgetFactoryInterface*)this; + else if ( iid == IID_QLibrary ) + *iface = (TQLibraryInterface*)this; +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + else if ( iid == IID_QWidgetContainer ) + *iface = (TQWidgetContainerInterfacePrivate*)this; +#endif + else + return TQE_NOINTERFACE; + + (*iface)->addRef(); + return TQS_OK; +} + +/*! + \fn TQStringList TQWidgetPlugin::keys() const + + Returns the list of widget keys this plugin supports. + + These keys must be the class names of the custom widgets that are + implemented in the plugin. + + \sa create() +*/ + +/*! + \fn TQWidget *TQWidgetPlugin::create( const TQString &, TQWidget *, const char * ) + + Creates and returns a TQWidget object for the widget key \a key. + The widget key is the class name of the required widget. The \a + name and \a parent arguments are passed to the custom widget's + constructor. + + \sa keys() +*/ + +TQWidgetPluginPrivate::~TQWidgetPluginPrivate() +{ + delete plugin; +} + +TQStringList TQWidgetPluginPrivate::featureList() const +{ + return plugin->keys(); +} + +TQWidget *TQWidgetPluginPrivate::create( const TQString &key, TQWidget *parent, const char *name ) +{ + TQWidget *w = plugin->create( key, parent, name ); + widgets.add( w ); + return w; +} + +TQString TQWidgetPluginPrivate::group( const TQString &widget ) const +{ + return plugin->group( widget ); +} + +TQIconSet TQWidgetPluginPrivate::iconSet( const TQString &widget ) const +{ + return plugin->iconSet( widget ); +} + +TQString TQWidgetPluginPrivate::includeFile( const TQString &widget ) const +{ + return plugin->includeFile( widget ); +} + +TQString TQWidgetPluginPrivate::toolTip( const TQString &widget ) const +{ + return plugin->toolTip( widget ); +} + +TQString TQWidgetPluginPrivate::whatsThis( const TQString &widget ) const +{ + return plugin->whatsThis( widget ); +} + +bool TQWidgetPluginPrivate::isContainer( const TQString &widget ) const +{ + return plugin->isContainer( widget ); +} + +bool TQWidgetPluginPrivate::init() +{ + return TRUE; +} + +void TQWidgetPluginPrivate::cleanup() +{ + widgets.clear(); +} + +bool TQWidgetPluginPrivate::canUnload() const +{ + return widgets.isEmpty(); +} + +#ifdef QT_CONTAINER_CUSTOM_WIDGETS +TQWidget* TQWidgetPluginPrivate::containerOfWidget( const TQString &key, TQWidget *widget ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->containerOfWidget( key, widget ); + return widget; +} + +int TQWidgetPluginPrivate::count( const TQString &key, TQWidget *container ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->count( key, container ); + return 0; +} + +int TQWidgetPluginPrivate::currentIndex( const TQString &key, TQWidget *container ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->currentIndex( key, container ); + return -1; +} + +TQString TQWidgetPluginPrivate::pageLabel( const TQString &key, TQWidget *container, int index ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->pageLabel( key, container, index ); + return TQString::null; +} + +TQWidget *TQWidgetPluginPrivate::page( const TQString &key, TQWidget *container, int index ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->page( key, container, index ); + return 0; +} + +bool TQWidgetPluginPrivate::isPassiveInteractor( const TQString &key, TQWidget *widget ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->isPassiveInteractor( key, widget ); + return FALSE; +} + +bool TQWidgetPluginPrivate::supportsPages( const TQString &key ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->supportsPages( key ); + return 0; +} + +TQWidget *TQWidgetPluginPrivate::addPage( const TQString &key, TQWidget *container, + const TQString &name, int index ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->addPage( key, container, name, index ); + return 0; +} + +void TQWidgetPluginPrivate::insertPage( const TQString &key, TQWidget *container, + const TQString &name, int index, TQWidget *page ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + p->insertPage( key, container, name, index, page ); +} + +void TQWidgetPluginPrivate::removePage( const TQString &key, TQWidget *container, int index ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + p->removePage( key, container, index ); +} + +void TQWidgetPluginPrivate::movePage( const TQString &key, TQWidget *container, + int fromIndex, int toIndex ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + p->movePage( key, container, fromIndex, toIndex ); +} + +void TQWidgetPluginPrivate::renamePage( const TQString &key, TQWidget *container, + int index, const TQString &newName ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + p->renamePage( key, container, index, newName ); +} + +TQWidgetList TQWidgetPluginPrivate::pages( const TQString &key, TQWidget *container ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->pages( key, container ); + return TQWidgetList(); +} + +TQString TQWidgetPluginPrivate::createCode( const TQString &key, const TQString &container, + const TQString &page, const TQString &pageName ) const +{ + TQWidgetContainerPlugin *p = (TQWidgetContainerPlugin*)plugin->tqt_cast( "TQWidgetContainerPlugin" ); + if ( p ) + return p->createCode( key, container, page, pageName ); + return TQString::null; +} +#endif // QT_CONTAINER_CUSTOM_WIDGETS + +/*! + Constructs a widget plugin. This is invoked automatically by the + \c TQ_EXPORT_PLUGIN macro. +*/ +TQWidgetPlugin::TQWidgetPlugin() + : TQGPlugin( (TQWidgetFactoryInterface*)(d = new TQWidgetPluginPrivate( this )) ) +{ +} + +/*! + Destroys the widget plugin. + + You never have to call this explicitly. TQt destroys a plugin + automatically when it is no longer used. +*/ +TQWidgetPlugin::~TQWidgetPlugin() +{ + // don't delete d, as this is deleted by d +} + +/*! + Returns the group (toolbar name) that the custom widget of class + \a key should be part of when \e{TQt Designer} loads it. + + The default implementation returns TQString::null. +*/ +TQString TQWidgetPlugin::group( const TQString & ) const +{ + return TQString::null; +} + +/*! + Returns the iconset that \e{TQt Designer} should use to represent + the custom widget of class \a key in the toolbar. + + The default implementation returns an null iconset. +*/ +TQIconSet TQWidgetPlugin::iconSet( const TQString & ) const +{ + return TQIconSet(); +} + +/*! + Returns the name of the include file that \e{TQt Designer} and \c + uic should use to include the custom widget of class \a key in + generated code. + + The default implementation returns TQString::null. +*/ +TQString TQWidgetPlugin::includeFile( const TQString & ) const +{ + return TQString::null; +} + +/*! + Returns the text of the tooltip that \e{TQt Designer} should use + for the custom widget of class \a key's toolbar button. + + The default implementation returns TQString::null. +*/ +TQString TQWidgetPlugin::toolTip( const TQString & ) const +{ + return TQString::null; +} + +/*! + Returns the text of the whatsThis text that \e{TQt Designer} should + use when the user requests whatsThis help for the custom widget of + class \a key. + + The default implementation returns TQString::null. +*/ +TQString TQWidgetPlugin::whatsThis( const TQString & ) const +{ + return TQString::null; +} + +/*! + Returns TRUE if the custom widget of class \a key can contain + other widgets, e.g. like TQFrame; otherwise returns FALSE. + + The default implementation returns FALSE. +*/ +bool TQWidgetPlugin::isContainer( const TQString & ) const +{ + return FALSE; +} + +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + +/*! + \class TQWidgetContainerPlugin tqwidgetplugin.h + \brief The TQWidgetContainerPlugin class provides an abstract base + for complex custom container TQWidget plugins. + + \internal + + \ingroup plugins + + The widget container plugin is a subclass of TQWidgetPlugin and + extends the interface with functions necessary for supporting + complex container widgets via plugins. These container widgets are + widgets that have one or multiple sub widgets which act as the + widget's containers. If the widget has multiple container + subwidgets, they are referred to as "pages", and only one can be + active at a time. Examples of complex container widgets include: + TQTabWidget, TQWidgetStack and TQToolBox. + + Writing a complex container widget plugin is achieved by + subclassing this base class. First by reimplementing + TQWidgetPlugin's pure virtual functions keys(), create(), group(), + iconSet(), includeFile(), toolTip(), whatsThis() and + isContainer(), and exporting the class with the \c TQ_EXPORT_PLUGIN + macro. In addition containerOfWidget(), isPassiveInteractor() and + supportsPages() must be reimplemented. If the widget + supportsPages(), count(), currentIndex(), pageLabel(), page(), + pages() and createCode() must be implemented. If the widget + supportsPages() and you want to allow the containers pages to be + modified, you must also reimplement addPage(), insertPage(), + removePage(), movePage() and renamePage(). + + \sa TQWidgetPlugin +*/ + +/*! + Constructs a complex container widget plugin. This is invoked + automatically by the \c TQ_EXPORT_PLUGIN macro. +*/ + +TQWidgetContainerPlugin::TQWidgetContainerPlugin() + : TQWidgetPlugin() +{ +} + +/*! + Destroys the complex container widget plugin. + + You never have to call this explicitly. TQt destroys a plugin + automatically when it is no longer used. +*/ + +TQWidgetContainerPlugin::~TQWidgetContainerPlugin() +{ +} + +/*! + Operates on the plugin's \a key class. + + Returns the current \a container's custom widget. If the custom + widget is a tab widget, this function takes the \a container as + input and returns the widget's current page. + + The default implementation returns \a container. +*/ + +TQWidget* TQWidgetContainerPlugin::containerOfWidget( const TQString &, + TQWidget *container ) const +{ + return container; +} + +/*! + Operates on the plugin's \a key class. + + Returns the \a container custom widget's number of pages. If the + custom widget is a tab widget, this function returns the number of + tabs. + + The default implementation returns 0. +*/ + +int TQWidgetContainerPlugin::count( const TQString &, TQWidget * ) const +{ + return 0; +} + +/*! + Operates on the plugin's \a key class. + + Returns the \a container custom widget's current page index. If + the custom widget is a tab widget, this function returns the + current tab's index. + + The default implementation returns -1. +*/ + +int TQWidgetContainerPlugin::currentIndex( const TQString &, TQWidget * ) const +{ + return -1; +} + +/*! + Operates on the plugin's \a key class. + + Returns the \a container custom widget's label at position \a + index. If the custom widget is a tab widget, this function returns + the current tab's label. + + The default implementation returns a null string. +*/ + +TQString TQWidgetContainerPlugin::pageLabel( const TQString &, TQWidget *, int ) const +{ + return TQString::null; +} + +/*! + Operates on the plugin's \a key class. + + Returns the \a container custom widget's page at position \a + index. If the custom widget is a tab widget, this function returns + the tab at index position \e index. + + + The default implementation returns 0. +*/ + +TQWidget *TQWidgetContainerPlugin::page( const TQString &, TQWidget *, int ) const +{ + return 0; +} + +/*! + Operates on the plugin's \a key class. + + Returns TRUE if the \a container custom widget is a passive + interactor for class \e key; otherwise returns FALSE. The \a + container is a child widget of the actual custom widget. + + Usually, when a custom widget is used in \e{TQt Designer}'s design + mode, no widget receives any mouse or key events, since \e{TQt + Designer} filters and processes them itself. If one or more + widgets of a custom widget still need to receive such events, for + example, because the widget needs to change pages, this function + must return TRUE for the widget. In such cases \e{TQt Designer} + will not filter out key and mouse events destined for the widget. + + If the custom widget is a tab widget, the tab bar is the passive + interactor, since that's what the user will use to change pages. + + The default implementation returns FALSE. +*/ + +bool TQWidgetContainerPlugin::isPassiveInteractor( const TQString &, + TQWidget *container ) const +{ + Q_UNUSED( container ) + return FALSE; +} + +/*! + Operates on the plugin's \a key class. + + Returns TRUE if the widget supports pages; otherwise returns + FALSE. If the custom widget is a tab widget this function should + return TRUE. + + The default implementation returns FALSE. +*/ + +bool TQWidgetContainerPlugin::supportsPages( const TQString & ) const +{ + return FALSE; +} + +/*! + Operates on the plugin's \a key class. + + This function is called when a new page with the given \a name + should be added to the \a container custom widget at position \a + index. + + The default implementation does nothing. +*/ + +TQWidget* TQWidgetContainerPlugin::addPage( const TQString &, TQWidget *, + const TQString &, int ) const +{ + return 0; +} + +/*! + Operates on the plugin's \a key class. + + This function is called when a new page, \a page, with the given + \a name should be added to the \a container custom widget at + position \a index. + + The default implementation does nothing. +*/ + +void TQWidgetContainerPlugin::insertPage( const TQString &, TQWidget *, + const TQString &, int, TQWidget * ) const +{ +} + +/*! + Operates on the plugin's \a key class. + + This function is called when the page at position \a index should + be removed from the \a container custom widget. + + The default implementation does nothing. +*/ + +void TQWidgetContainerPlugin::removePage( const TQString &, TQWidget *, int ) const +{ +} + +/*! + Operates on the plugin's \a key class. + + This function is called when the page at position \a fromIndex should + be moved to position \a toIndex in the \a container custom widget. + + The default implementation does nothing. +*/ + +void TQWidgetContainerPlugin::movePage( const TQString &, TQWidget *, int, int ) const +{ +} + +/*! + Operates on the plugin's \a key class. + + This function is called when the page at position \a index should + be renamed (have its label changed) to \a newName in the \a + container custom widget. + + The default implementation does nothing. +*/ + +void TQWidgetContainerPlugin::renamePage( const TQString &, TQWidget *, + int, const TQString & ) const +{ +} + +/*! + Operates on the plugin's \a key class. + + This function should return a list of the \a container custom + widget's pages. +*/ + +TQWidgetList TQWidgetContainerPlugin::pages( const TQString &, TQWidget * ) const +{ + return TQWidgetList(); +} + +/*! + Operates on the plugin's \a key class. + + This function is called from \e{TQt Designer}'s User Interface + Compiler \c uic, when generating C++ code for inserting a page in + the \a container custom widget. The name of the page widget which + should be inserted at the end of the container is \a page, and the + label of the page should be \a pageName. + + If the custom widget was a TQTabWidget, the implementation of this + function should return: + + \code + return widget + "->addTab( " + page + ", \"" + pageName + "\" )"; + \endcode + + Warning: If the code returned by this function contains invalid + C++ syntax, the generated \c uic code will not compile. +*/ + +TQString TQWidgetContainerPlugin::createCode( const TQString &, const TQString &, + const TQString &, const TQString & ) const +{ + return TQString::null; +} + +#endif // QT_CONTAINER_CUSTOM_WIDGETS + +#endif //TQT_NO_WIDGETPLUGIN diff --git a/src/widgets/tqwidgetplugin.h b/src/widgets/tqwidgetplugin.h new file mode 100644 index 000000000..cd40860d3 --- /dev/null +++ b/src/widgets/tqwidgetplugin.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Definition of TQWidgetPlugin class +** +** Created : 010920 +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets 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 TQWIDGETPLUGIN_H +#define TQWIDGETPLUGIN_H + +#ifndef QT_H +#include "ntqgplugin.h" +#include "ntqstringlist.h" +#include "ntqiconset.h" +#endif // QT_H +#ifndef TQT_NO_WIDGETPLUGIN + +#ifdef TQ_WS_WIN +#ifdef QT_PLUGIN +#define QT_WIDGET_PLUGIN_EXPORT __declspec(dllexport) +#else +#define QT_WIDGET_PLUGIN_EXPORT __declspec(dllimport) +#endif +#else +#define QT_WIDGET_PLUGIN_EXPORT +#endif + +class TQWidgetPluginPrivate; +class TQWidget; + +class TQ_EXPORT TQWidgetPlugin : public TQGPlugin +{ + TQ_OBJECT +public: + TQWidgetPlugin(); + ~TQWidgetPlugin(); + + virtual TQStringList keys() const = 0; + virtual TQWidget *create( const TQString &key, TQWidget *parent = 0, const char *name = 0 ) = 0; + + virtual TQString group( const TQString &key ) const; + virtual TQIconSet iconSet( const TQString &key ) const; + virtual TQString includeFile( const TQString &key ) const; + virtual TQString toolTip( const TQString &key ) const; + virtual TQString whatsThis( const TQString &key ) const; + virtual bool isContainer( const TQString &key ) const; + +private: + TQWidgetPluginPrivate *d; +}; + +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + +class TQWidgetContainerPluginPrivate; + +class TQ_EXPORT TQWidgetContainerPlugin : public TQWidgetPlugin +{ + +public: + TQWidgetContainerPlugin(); + ~TQWidgetContainerPlugin(); + + virtual TQWidget* containerOfWidget( const TQString &key, TQWidget *container ) const; + virtual bool isPassiveInteractor( const TQString &key, TQWidget *container ) const; + + virtual bool supportsPages( const TQString &key ) const; + + virtual TQWidget *addPage( const TQString &key, TQWidget *container, + const TQString &name, int index ) const; + virtual void insertPage( const TQString &key, TQWidget *container, + const TQString &name, int index, TQWidget *page ) const; + virtual void removePage( const TQString &key, TQWidget *container, int index ) const; + virtual void movePage( const TQString &key, TQWidget *container, int fromIndex, int toIndex ) const; + virtual int count( const TQString &key, TQWidget *container ) const; + virtual int currentIndex( const TQString &key, TQWidget *container ) const; + virtual TQString pageLabel( const TQString &key, TQWidget *container, int index ) const; + virtual TQWidget *page( const TQString &key, TQWidget *container, int index ) const; + virtual void renamePage( const TQString &key, TQWidget *container, + int index, const TQString &newName ) const; + virtual TQWidgetList pages( const TQString &key, TQWidget *container ) const; + virtual TQString createCode( const TQString &key, const TQString &container, + const TQString &page, const TQString &pageName ) const; +}; + +#endif // QT_CONTAINER_CUSTOM_WIDGETS +#endif // TQT_NO_WIDGETPLUGIN +#endif // TQWIDGETPLUGIN_H diff --git a/src/widgets/tqwidgetresizehandler.cpp b/src/widgets/tqwidgetresizehandler.cpp new file mode 100644 index 000000000..0f75eb797 --- /dev/null +++ b/src/widgets/tqwidgetresizehandler.cpp @@ -0,0 +1,516 @@ +/**************************************************************************** +** +** Implementation of the TQWidgetResizeHandler class +** +** Created : 001010 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the workspace 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 "tqwidgetresizehandler_p.h" + +#ifndef TQT_NO_RESIZEHANDLER +#include "ntqframe.h" +#include "ntqapplication.h" +#include "ntqcursor.h" +#include "ntqsizegrip.h" +#if defined(TQ_WS_WIN) +#include "qt_windows.h" +#endif + +#define RANGE 4 + +static bool resizeHorizontalDirectionFixed = FALSE; +static bool resizeVerticalDirectionFixed = FALSE; + +TQWidgetResizeHandler::TQWidgetResizeHandler( TQWidget *parent, TQWidget *cw, const char *name ) + : TQObject( parent, name ), widget( parent ), childWidget( cw ? cw : parent ), + extrahei( 0 ), buttonDown( FALSE ), moveResizeMode( FALSE ), sizeprotect( TRUE ), moving( TRUE ) +{ + mode = Nowhere; + widget->setMouseTracking( TRUE ); + TQFrame *frame = ::tqt_cast(widget); + range = frame ? frame->frameWidth() : RANGE; + range = TQMAX( RANGE, range ); + activeForMove = activeForResize = TRUE; + tqApp->installEventFilter( this ); +} + +void TQWidgetResizeHandler::setActive( Action ac, bool b ) +{ + if ( ac & Move ) + activeForMove = b; + if ( ac & Resize ) + activeForResize = b; + + if ( !isActive() ) + setMouseCursor( Nowhere ); +} + +bool TQWidgetResizeHandler::isActive( Action ac ) const +{ + bool b = FALSE; + if ( ac & Move ) b = activeForMove; + if ( ac & Resize ) b |= activeForResize; + + return b; +} + +static TQWidget *childOf( TQWidget *w, TQWidget *child ) +{ + while ( child ) { + if ( child == w ) + return child; + if ( child->isTopLevel() ) + break; + child = child->parentWidget(); + } + return 0; +} + +bool TQWidgetResizeHandler::eventFilter( TQObject *o, TQEvent *ee ) +{ + if ( !isActive() || !o->isWidgetType() || !ee->spontaneous()) + return FALSE; + + if ( ee->type() != TQEvent::MouseButtonPress && + ee->type() != TQEvent::MouseButtonRelease && + ee->type() != TQEvent::MouseMove && + ee->type() != TQEvent::KeyPress && + ee->type() != TQEvent::AccelOverride ) + return FALSE; + + TQWidget *w = childOf( widget, (TQWidget*)o ); + if ( !w +#ifndef TQT_NO_SIZEGRIP + || ::tqt_cast(o) +#endif + || tqApp->activePopupWidget() ) { + if ( buttonDown && ee->type() == TQEvent::MouseButtonRelease ) + buttonDown = FALSE; + return FALSE; + } + + TQMouseEvent *e = (TQMouseEvent*)ee; + switch ( e->type() ) { + case TQEvent::MouseButtonPress: { + if ( w->isMaximized() ) + break; + if ( !widget->rect().contains( widget->mapFromGlobal( e->globalPos() ) ) ) + return FALSE; + if ( e->button() == LeftButton ) { + emit activate(); + bool me = isMovingEnabled(); + setMovingEnabled( me && o == widget ); + mouseMoveEvent( e ); + setMovingEnabled( me ); + buttonDown = TRUE; + moveOffset = widget->mapFromGlobal( e->globalPos() ); + invertedMoveOffset = widget->rect().bottomRight() - moveOffset; + } + } break; + case TQEvent::MouseButtonRelease: + if ( w->isMaximized() ) + break; + if ( e->button() == LeftButton ) { + moveResizeMode = FALSE; + buttonDown = FALSE; + widget->releaseMouse(); + widget->releaseKeyboard(); + } + break; + case TQEvent::MouseMove: { + if ( w->isMaximized() ) + break; + bool me = isMovingEnabled(); + setMovingEnabled( me && o == widget ); + mouseMoveEvent( e ); + setMovingEnabled( me ); + if ( buttonDown && mode != Center ) + return TRUE; + } break; + case TQEvent::KeyPress: + keyPressEvent( (TQKeyEvent*)e ); + break; + case TQEvent::AccelOverride: + if ( buttonDown ) { + ((TQKeyEvent*)ee)->accept(); + return TRUE; + } + break; + default: + break; + } + return FALSE; +} + +void TQWidgetResizeHandler::mouseMoveEvent( TQMouseEvent *e ) +{ + TQPoint pos = widget->mapFromGlobal( e->globalPos() ); + if ( !moveResizeMode && ( !buttonDown || ( e->state() & LeftButton ) == 0 ) ) { + if ( pos.y() <= range && pos.x() <= range) + mode = TopLeft; + else if ( pos.y() >= widget->height()-range && pos.x() >= widget->width()-range) + mode = BottomRight; + else if ( pos.y() >= widget->height()-range && pos.x() <= range) + mode = BottomLeft; + else if ( pos.y() <= range && pos.x() >= widget->width()-range) + mode = TopRight; + else if ( pos.y() <= range ) + mode = Top; + else if ( pos.y() >= widget->height()-range ) + mode = Bottom; + else if ( pos.x() <= range ) + mode = Left; + else if ( pos.x() >= widget->width()-range ) + mode = Right; + else + mode = Center; + + if ( widget->isMinimized() || !isActive(Resize) ) + mode = Center; +#ifndef TQT_NO_CURSOR + setMouseCursor( mode ); +#endif + return; + } + + if ( buttonDown && !isMovingEnabled() && mode == Center && !moveResizeMode ) + return; + + if ( widget->testWState( WState_ConfigPending ) ) + return; + + TQPoint globalPos = widget->parentWidget( TRUE ) ? + widget->parentWidget( TRUE )->mapFromGlobal( e->globalPos() ) : e->globalPos(); + if ( widget->parentWidget( TRUE ) && !widget->parentWidget( TRUE )->rect().contains( globalPos ) ) { + if ( globalPos.x() < 0 ) + globalPos.rx() = 0; + if ( globalPos.y() < 0 ) + globalPos.ry() = 0; + if ( sizeprotect && globalPos.x() > widget->parentWidget()->width() ) + globalPos.rx() = widget->parentWidget()->width(); + if ( sizeprotect && globalPos.y() > widget->parentWidget()->height() ) + globalPos.ry() = widget->parentWidget()->height(); + } + + TQPoint p = globalPos + invertedMoveOffset; + TQPoint pp = globalPos - moveOffset; + + int fw = 0; + int mw = TQMAX( childWidget->minimumSizeHint().width(), + childWidget->minimumWidth() ); + int mh = TQMAX( childWidget->minimumSizeHint().height(), + childWidget->minimumHeight() ); + if ( childWidget != widget ) { + TQFrame *frame = ::tqt_cast(widget); + if ( frame ) + fw = frame->frameWidth(); + mw += 2 * fw; + mh += 2 * fw + extrahei; + } + + TQSize mpsize( widget->geometry().right() - pp.x() + 1, + widget->geometry().bottom() - pp.y() + 1 ); + mpsize = mpsize.expandedTo( widget->minimumSize() ).expandedTo( TQSize(mw, mh) ); + TQPoint mp( widget->geometry().right() - mpsize.width() + 1, + widget->geometry().bottom() - mpsize.height() + 1 ); + + TQRect geom = widget->geometry(); + + switch ( mode ) { + case TopLeft: + geom = TQRect( mp, widget->geometry().bottomRight() ) ; + break; + case BottomRight: + geom = TQRect( widget->geometry().topLeft(), p ) ; + break; + case BottomLeft: + geom = TQRect( TQPoint(mp.x(), widget->geometry().y() ), TQPoint( widget->geometry().right(), p.y()) ) ; + break; + case TopRight: + geom = TQRect( TQPoint( widget->geometry().x(), mp.y() ), TQPoint( p.x(), widget->geometry().bottom()) ) ; + break; + case Top: + geom = TQRect( TQPoint( widget->geometry().left(), mp.y() ), widget->geometry().bottomRight() ) ; + break; + case Bottom: + geom = TQRect( widget->geometry().topLeft(), TQPoint( widget->geometry().right(), p.y() ) ) ; + break; + case Left: + geom = TQRect( TQPoint( mp.x(), widget->geometry().top() ), widget->geometry().bottomRight() ) ; + break; + case Right: + geom = TQRect( widget->geometry().topLeft(), TQPoint( p.x(), widget->geometry().bottom() ) ) ; + break; + case Center: + if ( isMovingEnabled() || moveResizeMode ) + geom.moveTopLeft( pp ); + break; + default: + break; + } + + TQSize maxsize( childWidget->maximumSize() ); + if ( childWidget != widget ) + maxsize += TQSize( 2 * fw, 2 * fw + extrahei ); + + geom = TQRect( geom.topLeft(), + geom.size().expandedTo( widget->minimumSize() ) + .expandedTo( TQSize(mw, mh) ) + .boundedTo( maxsize ) ); + + if ( geom != widget->geometry() && + ( widget->isTopLevel() || widget->parentWidget()->rect().intersects( geom ) ) ) { + if ( widget->isMinimized() ) + widget->move( geom.topLeft() ); + else + widget->setGeometry( geom ); + } + +#if defined(TQ_WS_WIN) + MSG msg; + QT_WA( { + while(PeekMessageW( &msg, widget->winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE )) + ; + } , { + while(PeekMessageA( &msg, widget->winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE )) + ; + } ); +#endif + + TQApplication::syncX(); +} + +void TQWidgetResizeHandler::setMouseCursor( MousePosition m ) +{ +#ifndef TQT_NO_CURSOR + switch ( m ) { + case TopLeft: + case BottomRight: + widget->setCursor( sizeFDiagCursor ); + break; + case BottomLeft: + case TopRight: + widget->setCursor( sizeBDiagCursor ); + break; + case Top: + case Bottom: + widget->setCursor( sizeVerCursor ); + break; + case Left: + case Right: + widget->setCursor( sizeHorCursor ); + break; + default: + widget->setCursor( arrowCursor ); + break; + } +#endif +} + +void TQWidgetResizeHandler::keyPressEvent( TQKeyEvent * e ) +{ + if ( !isMove() && !isResize() ) + return; + bool is_control = e->state() & ControlButton; + int delta = is_control?1:8; + TQPoint pos = TQCursor::pos(); + switch ( e->key() ) { + case Key_Left: + pos.rx() -= delta; + if ( pos.x() <= TQApplication::desktop()->geometry().left() ) { + if ( mode == TopLeft || mode == BottomLeft ) { + moveOffset.rx() += delta; + invertedMoveOffset.rx() += delta; + } else { + moveOffset.rx() -= delta; + invertedMoveOffset.rx() -= delta; + } + } + if ( isResize() && !resizeHorizontalDirectionFixed ) { + resizeHorizontalDirectionFixed = TRUE; + if ( mode == BottomRight ) + mode = BottomLeft; + else if ( mode == TopRight ) + mode = TopLeft; +#ifndef TQT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Right: + pos.rx() += delta; + if ( pos.x() >= TQApplication::desktop()->geometry().right() ) { + if ( mode == TopRight || mode == BottomRight ) { + moveOffset.rx() += delta; + invertedMoveOffset.rx() += delta; + } else { + moveOffset.rx() -= delta; + invertedMoveOffset.rx() -= delta; + } + } + if ( isResize() && !resizeHorizontalDirectionFixed ) { + resizeHorizontalDirectionFixed = TRUE; + if ( mode == BottomLeft ) + mode = BottomRight; + else if ( mode == TopLeft ) + mode = TopRight; +#ifndef TQT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Up: + pos.ry() -= delta; + if ( pos.y() <= TQApplication::desktop()->geometry().top() ) { + if ( mode == TopLeft || mode == TopRight ) { + moveOffset.ry() += delta; + invertedMoveOffset.ry() += delta; + } else { + moveOffset.ry() -= delta; + invertedMoveOffset.ry() -= delta; + } + } + if ( isResize() && !resizeVerticalDirectionFixed ) { + resizeVerticalDirectionFixed = TRUE; + if ( mode == BottomLeft ) + mode = TopLeft; + else if ( mode == BottomRight ) + mode = TopRight; +#ifndef TQT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Down: + pos.ry() += delta; + if ( pos.y() >= TQApplication::desktop()->geometry().bottom() ) { + if ( mode == BottomLeft || mode == BottomRight ) { + moveOffset.ry() += delta; + invertedMoveOffset.ry() += delta; + } else { + moveOffset.ry() -= delta; + invertedMoveOffset.ry() -= delta; + } + } + if ( isResize() && !resizeVerticalDirectionFixed ) { + resizeVerticalDirectionFixed = TRUE; + if ( mode == TopLeft ) + mode = BottomLeft; + else if ( mode == TopRight ) + mode = BottomRight; +#ifndef TQT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Space: + case Key_Return: + case Key_Enter: + case Key_Escape: + moveResizeMode = FALSE; + widget->releaseMouse(); + widget->releaseKeyboard(); + buttonDown = FALSE; + break; + default: + return; + } + TQCursor::setPos( pos ); +} + + +void TQWidgetResizeHandler::doResize() +{ + if ( !activeForResize ) + return; + + moveResizeMode = TRUE; + buttonDown = TRUE; + moveOffset = widget->mapFromGlobal( TQCursor::pos() ); + if ( moveOffset.x() < widget->width()/2) { + if ( moveOffset.y() < widget->height()/2) + mode = TopLeft; + else + mode = BottomLeft; + } else { + if ( moveOffset.y() < widget->height()/2) + mode = TopRight; + else + mode = BottomRight; + } + invertedMoveOffset = widget->rect().bottomRight() - moveOffset; +#ifndef TQT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + widget->grabKeyboard(); + resizeHorizontalDirectionFixed = FALSE; + resizeVerticalDirectionFixed = FALSE; +} + +void TQWidgetResizeHandler::doMove() +{ + if ( !activeForMove ) + return; + + mode = Center; + moveResizeMode = TRUE; + buttonDown = TRUE; + moveOffset = widget->mapFromGlobal( TQCursor::pos() ); + invertedMoveOffset = widget->rect().bottomRight() - moveOffset; +#ifndef TQT_NO_CURSOR + widget->grabMouse( SizeAllCursor ); +#else + widget->grabMouse(); +#endif + widget->grabKeyboard(); +} + +#endif //TQT_NO_RESIZEHANDLER diff --git a/src/widgets/tqwidgetresizehandler_p.h b/src/widgets/tqwidgetresizehandler_p.h new file mode 100644 index 000000000..30f8e088c --- /dev/null +++ b/src/widgets/tqwidgetresizehandler_p.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Definition of the TQWidgetResizeHandler class +** +** Created : 001010 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the workspace 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 TQWIDGETRESIZEHANDLER_P_H +#define TQWIDGETRESIZEHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. This header file may +// change from version to version without notice, or even be +// removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "tqobject.h" +#endif // QT_H +#ifndef TQT_NO_RESIZEHANDLER +class TQMouseEvent; +class TQKeyEvent; + +class TQ_EXPORT TQWidgetResizeHandler : public TQObject +{ + TQ_OBJECT + +public: + enum Action { + Move = 0x01, + Resize = 0x02, + Any = Move|Resize + }; + + TQWidgetResizeHandler( TQWidget *parent, TQWidget *cw = 0, const char *name = 0 ); + void setActive( bool b ) { setActive( Any, b ); } + void setActive( Action ac, bool b ); + bool isActive() const { return isActive( Any ); } + bool isActive( Action ac ) const; + void setMovingEnabled( bool b ) { moving = b; } + bool isMovingEnabled() const { return moving; } + + bool isButtonDown() const { return buttonDown; } + + void setExtraHeight( int h ) { extrahei = h; } + void setSizeProtection( bool b ) { sizeprotect = b; } + + void doResize(); + void doMove(); + +signals: + void activate(); + +protected: + bool eventFilter( TQObject *o, TQEvent *e ); + void mouseMoveEvent( TQMouseEvent *e ); + void keyPressEvent( TQKeyEvent *e ); + +private: + enum MousePosition { + Nowhere, + TopLeft, BottomRight, BottomLeft, TopRight, + Top, Bottom, Left, Right, + Center + }; + + TQWidget *widget; + TQWidget *childWidget; + TQPoint moveOffset; + TQPoint invertedMoveOffset; + MousePosition mode; + int extrahei; + int range; + uint buttonDown :1; + uint moveResizeMode :1; + uint activeForResize :1; + uint sizeprotect :1; + uint moving :1; + uint activeForMove :1; + + void setMouseCursor( MousePosition m ); + bool isMove() const { + return moveResizeMode && mode == Center; + } + bool isResize() const { + return moveResizeMode && !isMove(); + } + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQWidgetResizeHandler( const TQWidgetResizeHandler & ); + TQWidgetResizeHandler& operator=( const TQWidgetResizeHandler & ); +#endif + +}; + +#endif //TQT_NO_RESIZEHANDLER +#endif diff --git a/src/widgets/tqwidgetstack.cpp b/src/widgets/tqwidgetstack.cpp new file mode 100644 index 000000000..b065fc35a --- /dev/null +++ b/src/widgets/tqwidgetstack.cpp @@ -0,0 +1,605 @@ +/**************************************************************************** +** +** Implementation of TQWidgetStack class +** +** Created : 980128 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets 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 "tqwidgetstack.h" +#include "ntqlayout.h" +#include "../kernel/qlayoutengine_p.h" +#ifndef TQT_NO_WIDGETSTACK + +#include "tqobjectlist.h" +#include "ntqfocusdata.h" +#include "ntqbutton.h" +#include "ntqbuttongroup.h" + +#include "ntqapplication.h" + +class TQWidgetStackPrivate { +public: + class Invisible: public TQWidget + { + public: + Invisible( TQWidgetStack * parent ): TQWidget( parent, "qt_invisible_widgetstack" ) + { + setBackgroundMode( NoBackground ); + } + const char * className() const + { + return "TQWidgetStackPrivate::Invisible"; + } + }; +}; + + +class TQWidgetStackEventFilter : public TQObject +{ + /* For binary compatibility, since we cannot implement virtual + functions and rely on them being called. This is what we should + have + + bool TQWidgetStack::event( TQEvent* e ) + { + if ( e->type() == TQEvent::LayoutHint ) + updateGeometry(); // propgate layout hints to parent + return TQFrame::event( e ); + } + */ +public: + + TQWidgetStackEventFilter( TQObject *parent = 0, const char * name = 0 ) + : TQObject( parent, name ) {} + bool eventFilter( TQObject *o, TQEvent * e ) { + if ( e->type() == TQEvent::LayoutHint && o->isWidgetType() ) + ((TQWidget*)o)->updateGeometry(); + return FALSE; + } +}; + + +/*! + \class TQWidgetStack + \brief The TQWidgetStack class provides a stack of widgets of which + only the top widget is user-visible. + + \ingroup organizers + \mainclass + + The application programmer can move any widget to the top of the + stack at any time using raiseWidget(), and add or remove widgets + using addWidget() and removeWidget(). It is not sufficient to pass + the widget stack as parent to a widget which should be inserted into + the widgetstack. + + visibleWidget() is the \e get equivalent of raiseWidget(); it + returns a pointer to the widget that is currently at the top of + the stack. + + TQWidgetStack also provides the ability to manipulate widgets + through application-specified integer IDs. You can also translate + from widget pointers to IDs using id() and from IDs to widget + pointers using widget(). These numeric IDs are unique (per + TQWidgetStack, not globally), but TQWidgetStack does not attach any + additional meaning to them. + + The default widget stack is frameless, but you can use the usual + TQFrame functions (such as setFrameStyle()) to add a frame. + + TQWidgetStack provides a signal, aboutToShow(), which is emitted + just before a managed widget is shown. + + \sa TQTabDialog TQTabBar TQFrame +*/ + + +/*! + Constructs an empty widget stack. + + The \a parent and \a name arguments are passed to the TQFrame + constructor. +*/ + +TQWidgetStack::TQWidgetStack( TQWidget * parent, const char *name ) + : TQFrame( parent, name ) +{ + init(); +} + +/*! + Constructs an empty widget stack. + + The \a parent, \a name and \a f arguments are passed to the TQFrame + constructor. +*/ +TQWidgetStack::TQWidgetStack( TQWidget * parent, const char *name, WFlags f ) + : TQFrame( parent, name, f ) //## merge constructors in 4.0 +{ + init(); +} + +void TQWidgetStack::init() +{ + d = 0; + TQWidgetStackEventFilter *ef = new TQWidgetStackEventFilter( this ); + installEventFilter( ef ); + dict = new TQIntDict; + focusWidgets = 0; + topWidget = 0; + invisible = new TQWidgetStackPrivate::Invisible( this ); + invisible->hide(); +} + + +/*! + Destroys the object and frees any allocated resources. +*/ + +TQWidgetStack::~TQWidgetStack() +{ + delete focusWidgets; + delete d; + delete dict; +} + + +/*! + Adds widget \a w to this stack of widgets, with ID \a id. + + If you pass an id \>= 0 this ID is used. If you pass an \a id of + -1 (the default), the widgets will be numbered automatically. If + you pass -2 a unique negative integer will be generated. No widget + has an ID of -1. Returns the ID or -1 on failure (e.g. \a w is 0). + + If you pass an id that is already used, then a unique negative + integer will be generated to prevent two widgets having the same + id. + + If \a w already exists in the stack the widget will be removed first. + + If \a w is not a child of this TQWidgetStack moves it using + reparent(). +*/ + +int TQWidgetStack::addWidget( TQWidget * w, int id ) +{ + static int nseq_no = -2; + static int pseq_no = 0; + + if ( !w || w == invisible ) + return -1; + + // prevent duplicates + removeWidget( w ); + + if ( id >= 0 && dict->find( id ) ) + id = -2; + if ( id < -1 ) + id = nseq_no--; + else if ( id == -1 ) + id = pseq_no++; + else + pseq_no = TQMAX(pseq_no, id + 1); + // use id >= 0 as-is + + dict->insert( id, w ); + + // preserve existing focus + TQWidget * f = w->focusWidget(); + while( f && f != w ) + f = f->parentWidget(); + if ( f ) { + if ( !focusWidgets ) + focusWidgets = new TQPtrDict( 17 ); + focusWidgets->replace( w, w->focusWidget() ); + } + + w->hide(); + if ( w->parent() != this ) + w->reparent( this, contentsRect().topLeft(), FALSE ); + w->setGeometry( contentsRect() ); + updateGeometry(); + return id; +} + + +/*! + Removes widget \a w from this stack of widgets. Does not delete \a + w. If \a w is the currently visible widget, no other widget is + substituted. + + \sa visibleWidget() raiseWidget() +*/ + +void TQWidgetStack::removeWidget( TQWidget * w ) +{ + if ( !w ) + return; + int i = id( w ); + if ( i != -1 ) + dict->take( i ); + + if ( w == topWidget ) + topWidget = 0; + if ( dict->isEmpty() ) + invisible->hide(); // let background shine through again + updateGeometry(); +} + + +/*! + Raises the widget with ID \a id to the top of the widget stack. + + \sa visibleWidget() +*/ + +void TQWidgetStack::raiseWidget( int id ) +{ + if ( id == -1 ) + return; + TQWidget * w = dict->find( id ); + if ( w ) + raiseWidget( w ); +} + +static bool isChildOf( TQWidget* child, TQWidget *parent ) +{ + const TQObjectList *list = parent->children(); + if ( !child || !list ) + return FALSE; + TQObjectListIt it(*list); + TQObject *obj; + while ( (obj = it.current()) ) { + ++it; + if ( !obj->isWidgetType() || ((TQWidget *)obj)->isTopLevel() ) + continue; + TQWidget *widget = (TQWidget *)obj; + if ( widget == child || isChildOf( child, widget ) ) + return TRUE; + } + return FALSE; +} + +/*! + \overload + + Raises widget \a w to the top of the widget stack. +*/ + +void TQWidgetStack::raiseWidget( TQWidget *w ) +{ + if ( !w || w == invisible || w->parent() != this || w == topWidget ) + return; + + if ( id(w) == -1 ) + addWidget( w ); + if ( !isVisible() ) { + topWidget = w; + return; + } + + if (w->maximumSize().width() < invisible->width() + || w->maximumSize().height() < invisible->height()) + invisible->setBackgroundMode(backgroundMode()); + else if (invisible->backgroundMode() != NoBackground) + invisible->setBackgroundMode(NoBackground); + + if ( invisible->isHidden() ) { + invisible->setGeometry( contentsRect() ); + invisible->lower(); + invisible->show(); + TQApplication::sendPostedEvents( invisible, TQEvent::ShowWindowRequest ); + } + + // try to move focus onto the incoming widget if focus + // was somewhere on the outgoing widget. + if ( topWidget ) { + TQWidget * fw = focusWidget(); + TQWidget* p = fw; + while ( p && p != topWidget ) + p = p->parentWidget(); + if ( p == topWidget ) { // focus was on old page + if ( !focusWidgets ) + focusWidgets = new TQPtrDict( 17 ); + focusWidgets->replace( topWidget, fw ); + fw->clearFocus(); + // look for the best focus widget we can find + // best == what we had (which may be deleted) + fw = focusWidgets->take( w ); + if ( isChildOf( fw, w ) ) { + fw->setFocus(); + } else { + // second best == first child widget in the focus chain + TQFocusData *f = focusData(); + TQWidget* home = f->home(); + TQWidget *i = home; + do { + if ( ( ( i->focusPolicy() & TabFocus ) == TabFocus ) + && !i->focusProxy() && i->isVisibleTo(w) && i->isEnabled() ) { + p = i; + while ( p && p != w ) + p = p->parentWidget(); + if ( p == w ) { + i->setFocus(); + break; + } + } + i = f->next(); + } while( i != home ); + } + } + } + + if ( isVisible() ) { + emit aboutToShow( w ); + int i = id( w ); + if ( i != -1 ) + emit aboutToShow( i ); + } + + topWidget = w; + + const TQObjectList * c = children(); + TQObjectListIt it( *c ); + TQObject * o; + + while( (o=it.current()) != 0 ) { + ++it; + if ( o->isWidgetType() && o != w && o != invisible ) + ((TQWidget *)o)->hide(); + } + + w->setGeometry( invisible->geometry() ); + w->show(); +} + +/*! + \reimp +*/ + +void TQWidgetStack::frameChanged() +{ + TQFrame::frameChanged(); + setChildGeometries(); +} + + +/*! + \reimp +*/ + +void TQWidgetStack::setFrameRect( const TQRect & r ) +{ + TQFrame::setFrameRect( r ); + setChildGeometries(); +} + + +/*! + Fixes up the children's geometries. +*/ + +void TQWidgetStack::setChildGeometries() +{ + invisible->setGeometry( contentsRect() ); + if ( topWidget ) + topWidget->setGeometry( invisible->geometry() ); +} + + +/*! + \reimp +*/ +void TQWidgetStack::show() +{ + // Reimplemented in order to set the children's geometries + // appropriately and to pick the first widget as topWidget if no + // topwidget was defined + if ( !isVisible() && children() ) { + const TQObjectList * c = children(); + TQObjectListIt it( *c ); + TQObject * o; + + while( (o=it.current()) != 0 ) { + ++it; + if ( o->isWidgetType() ) { + if ( !topWidget && o != invisible ) + topWidget = (TQWidget*)o; + if ( o == topWidget ) + ((TQWidget *)o)->show(); + else + ((TQWidget *)o)->hide(); + } + } + setChildGeometries(); + } + TQFrame::show(); +} + + +/*! + Returns the widget with ID \a id. Returns 0 if this widget stack + does not manage a widget with ID \a id. + + \sa id() addWidget() +*/ + +TQWidget * TQWidgetStack::widget( int id ) const +{ + return id != -1 ? dict->find( id ) : 0; +} + + +/*! + Returns the ID of the \a widget. Returns -1 if \a widget is 0 or + is not being managed by this widget stack. + + \sa widget() addWidget() +*/ + +int TQWidgetStack::id( TQWidget * widget ) const +{ + if ( !widget ) + return -1; + + TQIntDictIterator it( *dict ); + while ( it.current() && it.current() != widget ) + ++it; + return it.current() == widget ? it.currentKey() : -1; +} + + +/*! + Returns the currently visible widget (the one at the top of the + stack), or 0 if nothing is currently being shown. + + \sa aboutToShow() id() raiseWidget() +*/ + +TQWidget * TQWidgetStack::visibleWidget() const +{ + return topWidget; +} + + +/*! + \fn void TQWidgetStack::aboutToShow( int ) + + This signal is emitted just before a managed widget is shown if + that managed widget has an ID != -1. The argument is the numeric + ID of the widget. + + If you call visibleWidget() in a slot connected to aboutToShow(), + the widget it returns is the one that is currently visible, not + the one that is about to be shown. +*/ + + +/*! + \fn void TQWidgetStack::aboutToShow( TQWidget * ) + + \overload + + This signal is emitted just before a managed widget is shown. The + argument is a pointer to the widget. + + If you call visibleWidget() in a slot connected to aboutToShow(), + the widget returned is the one that is currently visible, not the + one that is about to be shown. +*/ + + +/*! + \reimp +*/ + +void TQWidgetStack::resizeEvent( TQResizeEvent * e ) +{ + TQFrame::resizeEvent( e ); + setChildGeometries(); +} + + +/*! + \reimp +*/ + +TQSize TQWidgetStack::sizeHint() const +{ + constPolish(); + + TQSize size( 0, 0 ); + + TQIntDictIterator it( *dict ); + TQWidget *w; + + while ( (w = it.current()) != 0 ) { + ++it; + TQSize sh = w->sizeHint(); + if ( w->sizePolicy().horData() == TQSizePolicy::Ignored ) + sh.rwidth() = 0; + if ( w->sizePolicy().verData() == TQSizePolicy::Ignored ) + sh.rheight() = 0; +#ifndef TQT_NO_LAYOUT + size = size.expandedTo( sh ).expandedTo( qSmartMinSize(w) ); +#endif + } + if ( size.isNull() ) + size = TQSize( 128, 64 ); + size += TQSize( 2*frameWidth(), 2*frameWidth() ); + return size; +} + + +/*! + \reimp +*/ +TQSize TQWidgetStack::minimumSizeHint() const +{ + constPolish(); + + TQSize size( 0, 0 ); + + TQIntDictIterator it( *dict ); + TQWidget *w; + + while ( (w = it.current()) != 0 ) { + ++it; + TQSize sh = w->minimumSizeHint(); + if ( w->sizePolicy().horData() == TQSizePolicy::Ignored ) + sh.rwidth() = 0; + if ( w->sizePolicy().verData() == TQSizePolicy::Ignored ) + sh.rheight() = 0; +#ifndef TQT_NO_LAYOUT + size = size.expandedTo( sh ).expandedTo( w->minimumSize() ); +#endif + } + if ( size.isNull() ) + size = TQSize( 64, 32 ); + size += TQSize( 2*frameWidth(), 2*frameWidth() ); + return size; +} + +/*! + \reimp +*/ +void TQWidgetStack::childEvent( TQChildEvent * e) +{ + if ( e->child()->isWidgetType() && e->removed() ) + removeWidget( (TQWidget*) e->child() ); +} +#endif diff --git a/src/widgets/tqwidgetstack.h b/src/widgets/tqwidgetstack.h new file mode 100644 index 000000000..4967804c8 --- /dev/null +++ b/src/widgets/tqwidgetstack.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Definition of TQWidgetStack class +** +** Created : 980306 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets 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 TQWIDGETSTACK_H +#define TQWIDGETSTACK_H + +#ifndef QT_H +#include "ntqframe.h" +#include "ntqintdict.h" +#include "ntqptrdict.h" +#endif // QT_H + +#ifndef TQT_NO_WIDGETSTACK + + +class TQWidgetStackPrivate; + + +class TQ_EXPORT TQWidgetStack: public TQFrame +{ + TQ_OBJECT +public: + TQWidgetStack( TQWidget* parent=0, const char* name=0 ); + TQWidgetStack( TQWidget* parent, const char* name, WFlags f); + + ~TQWidgetStack(); + + int addWidget( TQWidget *, int = -1 ); + void removeWidget( TQWidget * ); + + TQSize sizeHint() const; + TQSize minimumSizeHint() const; + void show(); + + TQWidget * widget( int ) const; + int id( TQWidget * ) const; + + TQWidget * visibleWidget() const; + + void setFrameRect( const TQRect & ); + +signals: + void aboutToShow( int ); + void aboutToShow( TQWidget * ); + +public slots: + void raiseWidget( int ); + void raiseWidget( TQWidget * ); + +protected: + void frameChanged(); + void resizeEvent( TQResizeEvent * ); + + virtual void setChildGeometries(); + void childEvent( TQChildEvent * ); + +private: + void init(); + + TQWidgetStackPrivate * d; + TQIntDict * dict; + TQPtrDict * focusWidgets; + TQWidget * topWidget; + TQWidget * invisible; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQWidgetStack( const TQWidgetStack & ); + TQWidgetStack& operator=( const TQWidgetStack & ); +#endif +}; + +#endif // TQT_NO_WIDGETSTACK + +#endif // TQWIDGETSTACK_H -- cgit v1.2.1