From 0582c90a9ed4b965629267713f51c0da7c38b39d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 4 Sep 2024 11:53:23 +0900 Subject: Rename remaining ntq[m-r]* related files to equivalent tq* (except ntqmodules.h) Signed-off-by: Michele Calgaro --- src/canvas/tqcanvas.cpp | 2 +- src/codecs/tqtextcodec.cpp | 2 +- src/dialogs/ntqmessagebox.h | 223 ----- src/dialogs/ntqprintdialog.h | 103 --- src/dialogs/qmessagebox.cpp | 1664 --------------------------------- src/dialogs/qprintdialog.cpp | 1677 ---------------------------------- src/dialogs/qt_dialogs.pri | 8 +- src/dialogs/tqdialog.cpp | 4 +- src/dialogs/tqerrormessage.cpp | 2 +- src/dialogs/tqfiledialog.cpp | 2 +- src/dialogs/tqmessagebox.cpp | 1664 +++++++++++++++++++++++++++++++++ src/dialogs/tqmessagebox.h | 223 +++++ src/dialogs/tqprintdialog.cpp | 1677 ++++++++++++++++++++++++++++++++++ src/dialogs/tqprintdialog.h | 103 +++ src/kernel/ntqmetaobject.h | 286 ------ src/kernel/ntqmngio.h | 53 -- src/kernel/ntqnamespace.h | 1035 --------------------- src/kernel/ntqpolygonscanner.h | 61 -- src/kernel/ntqt.h | 14 +- src/kernel/ntqwindowdefs.h | 2 +- src/kernel/qapplication.cpp | 4 +- src/kernel/qinternal_p.h | 2 +- src/kernel/qmetaobject.cpp | 1251 ------------------------- src/kernel/qmngio.cpp | 460 ---------- src/kernel/qpolygonscanner.cpp | 937 ------------------- src/kernel/qt_gfx.pri | 4 +- src/kernel/qt_kernel.pri | 10 +- src/kernel/qt_pch.h | 2 +- src/kernel/tqaccel.cpp | 2 +- src/kernel/tqaccessible.cpp | 2 +- src/kernel/tqcolor.cpp | 2 +- src/kernel/tqcursor_x11.cpp | 2 +- src/kernel/tqdrawutil.h | 2 +- src/kernel/tqevent.h | 2 +- src/kernel/tqfont.cpp | 4 +- src/kernel/tqimage.cpp | 2 +- src/kernel/tqkeycode.h | 2 +- src/kernel/tqkeysequence.cpp | 6 +- src/kernel/tqkeysequence.h | 2 +- src/kernel/tqmetaobject.cpp | 1251 +++++++++++++++++++++++++ src/kernel/tqmetaobject.h | 286 ++++++ src/kernel/tqmngio.cpp | 460 ++++++++++ src/kernel/tqmngio.h | 53 ++ src/kernel/tqnamespace.h | 1035 +++++++++++++++++++++ src/kernel/tqobject.cpp | 4 +- src/kernel/tqobject.h | 2 +- src/kernel/tqobjectdict.h | 2 +- src/kernel/tqpixmap.h | 2 +- src/kernel/tqpolygonscanner.cpp | 937 +++++++++++++++++++ src/kernel/tqpolygonscanner.h | 61 ++ src/kernel/tqprinter_unix.cpp | 2 +- src/kernel/tqsignal.cpp | 2 +- src/kernel/tqsimplerichtext.h | 2 +- src/kernel/tqsize.h | 2 +- src/kernel/tqtextengine_p.h | 2 +- src/kernel/tqtextlayout_p.h | 2 +- src/kernel/tqttdeintegration_x11.cpp | 2 +- src/kernel/tqwidget.cpp | 2 +- src/kernel/tqwidget_x11.cpp | 2 +- src/moc/moc.y | 6 +- src/moc/moc_yacc.cpp | 6 +- src/sql/tqsqlerror.cpp | 2 +- src/sql/tqsqlmanager_p.cpp | 2 +- src/sql/tqsqlpropertymap.cpp | 2 +- src/sql/tqsqlrecord.cpp | 2 +- src/styles/qt_styles.pri | 6 +- src/styles/tqcommonstyle.cpp | 4 +- src/styles/tqinterlacestyle.cpp | 2 +- src/styles/tqstylefactory.cpp | 2 +- src/styles/tqwindowsstyle.cpp | 2 +- src/tools/tqdatetime.h | 2 +- src/tools/tqfeatures.txt | 4 +- src/tools/tqlocale.cpp | 2 +- src/widgets/ntqrangecontrol.h | 194 ---- src/widgets/qeffects_p.h | 2 +- src/widgets/qrangecontrol.cpp | 565 ------------ src/widgets/qt_widgets.pri | 4 +- src/widgets/tqdatetimeedit.cpp | 2 +- src/widgets/tqdial.h | 2 +- src/widgets/tqmenudata.cpp | 10 +- src/widgets/tqrangecontrol.cpp | 565 ++++++++++++ src/widgets/tqrangecontrol.h | 194 ++++ src/widgets/tqscrollbar.h | 2 +- src/widgets/tqslider.h | 2 +- src/widgets/tqspinbox.h | 2 +- src/widgets/tqspinwidget.cpp | 2 +- src/widgets/tqtabbar.cpp | 2 +- src/widgets/tqtabwidget.cpp | 2 +- src/widgets/tqtextedit.cpp | 2 +- 89 files changed, 8605 insertions(+), 8605 deletions(-) delete mode 100644 src/dialogs/ntqmessagebox.h delete mode 100644 src/dialogs/ntqprintdialog.h delete mode 100644 src/dialogs/qmessagebox.cpp delete mode 100644 src/dialogs/qprintdialog.cpp create mode 100644 src/dialogs/tqmessagebox.cpp create mode 100644 src/dialogs/tqmessagebox.h create mode 100644 src/dialogs/tqprintdialog.cpp create mode 100644 src/dialogs/tqprintdialog.h delete mode 100644 src/kernel/ntqmetaobject.h delete mode 100644 src/kernel/ntqmngio.h delete mode 100644 src/kernel/ntqnamespace.h delete mode 100644 src/kernel/ntqpolygonscanner.h delete mode 100644 src/kernel/qmetaobject.cpp delete mode 100644 src/kernel/qmngio.cpp delete mode 100644 src/kernel/qpolygonscanner.cpp create mode 100644 src/kernel/tqmetaobject.cpp create mode 100644 src/kernel/tqmetaobject.h create mode 100644 src/kernel/tqmngio.cpp create mode 100644 src/kernel/tqmngio.h create mode 100644 src/kernel/tqnamespace.h create mode 100644 src/kernel/tqpolygonscanner.cpp create mode 100644 src/kernel/tqpolygonscanner.h delete mode 100644 src/widgets/ntqrangecontrol.h delete mode 100644 src/widgets/qrangecontrol.cpp create mode 100644 src/widgets/tqrangecontrol.cpp create mode 100644 src/widgets/tqrangecontrol.h (limited to 'src') diff --git a/src/canvas/tqcanvas.cpp b/src/canvas/tqcanvas.cpp index 2e0afadb2..2958a50f2 100644 --- a/src/canvas/tqcanvas.cpp +++ b/src/canvas/tqcanvas.cpp @@ -45,7 +45,7 @@ #include "tqimage.h" #include "tqptrdict.h" #include "tqpainter.h" -#include "ntqpolygonscanner.h" +#include "tqpolygonscanner.h" #include "tqtimer.h" #include "ntqtl.h" diff --git a/src/codecs/tqtextcodec.cpp b/src/codecs/tqtextcodec.cpp index ac22ea7f1..6c495df8f 100644 --- a/src/codecs/tqtextcodec.cpp +++ b/src/codecs/tqtextcodec.cpp @@ -51,7 +51,7 @@ #include "tqvaluelist.h" #include "tqtextcodecfactory.h" #include "tqutfcodec.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #ifndef TQT_NO_CODECS #include "tqhebrewcodec.h" #include "tqtsciicodec.h" diff --git a/src/dialogs/ntqmessagebox.h b/src/dialogs/ntqmessagebox.h deleted file mode 100644 index abaf25761..000000000 --- a/src/dialogs/ntqmessagebox.h +++ /dev/null @@ -1,223 +0,0 @@ -/**************************************************************************** -** -** Definition of TQMessageBox class -** -** Created : 950503 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs 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 TQMESSAGEBOX_H -#define TQMESSAGEBOX_H - -#ifndef QT_H -#include "tqdialog.h" -#endif // QT_H - -#ifndef TQT_NO_MESSAGEBOX - -class TQLabel; -class TQPushButton; -struct TQMessageBoxData; - -class TQ_EXPORT TQMessageBox : public TQDialog -{ - TQ_OBJECT - TQ_ENUMS( Icon ) - TQ_PROPERTY( TQString text READ text WRITE setText ) - TQ_PROPERTY( Icon icon READ icon WRITE setIcon ) - TQ_PROPERTY( TQPixmap iconPixmap READ iconPixmap WRITE setIconPixmap ) - TQ_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat ) - -public: - enum Icon { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, - Question = 4 }; - - TQMessageBox( TQWidget* parent=0, const char* name=0 ); - TQMessageBox( const TQString& caption, const TQString &text, Icon icon, - int button0, int button1, int button2, - TQWidget* parent=0, const char* name=0, bool modal=TRUE, - WFlags f=WStyle_DialogBorder ); - ~TQMessageBox(); - - enum { NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5, - Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, ButtonMask = 0xff, - Default = 0x100, Escape = 0x200, FlagMask = 0x300 }; - - static int information( TQWidget *parent, const TQString &caption, - const TQString& text, - int button0, int button1=0, int button2=0 ); - static int information( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text = TQString::null, - const TQString& button1Text = TQString::null, - const TQString& button2Text = TQString::null, - int defaultButtonNumber = 0, - int escapeButtonNumber = -1 ); - - static int question( TQWidget *parent, const TQString &caption, - const TQString& text, - int button0, int button1=0, int button2=0 ); - static int question( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text = TQString::null, - const TQString& button1Text = TQString::null, - const TQString& button2Text = TQString::null, - int defaultButtonNumber = 0, - int escapeButtonNumber = -1 ); - - static int warning( TQWidget *parent, const TQString &caption, - const TQString& text, - int button0, int button1, int button2=0 ); - static int warning( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text = TQString::null, - const TQString& button1Text = TQString::null, - const TQString& button2Text = TQString::null, - int defaultButtonNumber = 0, - int escapeButtonNumber = -1 ); - - static int critical( TQWidget *parent, const TQString &caption, - const TQString& text, - int button0, int button1, int button2=0 ); - static int critical( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text = TQString::null, - const TQString& button1Text = TQString::null, - const TQString& button2Text = TQString::null, - int defaultButtonNumber = 0, - int escapeButtonNumber = -1 ); - - static void about( TQWidget *parent, const TQString &caption, - const TQString& text ); - - static void aboutTQt( TQWidget *parent, - const TQString& caption=TQString::null ); - -/* OBSOLETE */ - static int message( const TQString &caption, - const TQString& text, - const TQString& buttonText=TQString::null, - TQWidget *parent=0, const char * =0 ) { - return TQMessageBox::information( parent, caption, text, - buttonText.isEmpty() - ? tr("OK") : buttonText ) == 0; - } - -/* OBSOLETE */ - static bool query( const TQString &caption, - const TQString& text, - const TQString& yesButtonText=TQString::null, - const TQString& noButtonText=TQString::null, - TQWidget *parent=0, const char * = 0 ) { - return TQMessageBox::information( parent, caption, text, - yesButtonText.isEmpty() - ? tr("OK") : yesButtonText, - noButtonText ) == 0; - } - - TQString text() const; - void setText( const TQString &); - - Icon icon() const; - - void setIcon( Icon ); - void setIcon( const TQPixmap & ); - - const TQPixmap *iconPixmap() const; - void setIconPixmap( const TQPixmap & ); - - TQString buttonText( int button ) const; - void setButtonText( int button, const TQString &); - - void adjustSize(); - -/* OBSOLETE */ - static TQPixmap standardIcon( Icon icon, GUIStyle ); - - static TQPixmap standardIcon( Icon icon ); - - TextFormat textFormat() const; - void setTextFormat( TextFormat ); - -protected: - void resizeEvent( TQResizeEvent * ); - void showEvent( TQShowEvent * ); - void closeEvent( TQCloseEvent * ); - void keyPressEvent( TQKeyEvent * ); - void styleChanged( TQStyle& ); - -private slots: - void buttonClicked(); - -private: - void init( int, int, int ); - int indexOf( int ) const; - void resizeButtons(); - TQLabel *label; - TQMessageBoxData *mbd; - void *reserved1; - void *reserved2; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQMessageBox( const TQMessageBox & ); - TQMessageBox &operator=( const TQMessageBox & ); -#endif -}; - -/* -* Macro to be used at the beginning of main(), e.g. -* -* #include -* #include -* int main( int argc, char**argv ) -* { -* QT_REQUIRE_VERSION( argc, argv, "3.0.5" ) -* ... -* } -*/ -#define QT_REQUIRE_VERSION( argc, argv, str ) { TQString s=TQString::fromLatin1(str);\ -TQString sq=TQString::fromLatin1(tqVersion()); if ( (sq.section('.',0,0).toInt()<<16)+\ -(sq.section('.',1,1).toInt()<<8)+sq.section('.',2,2).toInt()<(s.section('.',0,0).toInt()<<16)+\ -(s.section('.',1,1).toInt()<<8)+s.section('.',2,2).toInt() ){if ( !tqApp){ int c=0; new \ -TQApplication(argc,argv);} TQString s = TQApplication::tr("Executable '%1' requires TQt "\ - "%2, found TQt %3.").arg(TQString::fromLatin1(tqAppName())).arg(TQString::fromLatin1(\ -str)).arg(TQString::fromLatin1(tqVersion()) ); TQMessageBox::critical( 0, TQApplication::tr(\ -"Incompatible TQt Library Error" ), s, TQMessageBox::Abort,0 ); tqFatal(s.ascii()); }} - - -#endif // TQT_NO_MESSAGEBOX - -#endif // TQMESSAGEBOX_H diff --git a/src/dialogs/ntqprintdialog.h b/src/dialogs/ntqprintdialog.h deleted file mode 100644 index 29824416a..000000000 --- a/src/dialogs/ntqprintdialog.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Definition of print dialog. -** -** Created : 950829 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs 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 TQPRINTDIALOG_H -#define TQPRINTDIALOG_H - -#ifndef QT_H -#include "tqdialog.h" -#endif // QT_H - -#ifndef TQT_NO_PRINTDIALOG - -class TQGroupBox; -class TQPrintDialogPrivate; -class TQListView; - -class TQ_EXPORT TQPrintDialog : public TQDialog -{ - TQ_OBJECT -public: - TQPrintDialog( TQPrinter *, TQWidget* parent=0, const char* name=0 ); - ~TQPrintDialog(); - - static bool getPrinterSetup( TQPrinter *, TQWidget* = 0 ); - static void setGlobalPrintDialog( TQPrintDialog * ); - - void setPrinter( TQPrinter *, bool = FALSE ); - TQPrinter * printer() const; - - void addButton( TQPushButton *but ); - -private slots: - void browseClicked(); - void okClicked(); - - void printerOrFileSelected( int ); - void landscapeSelected( int ); - void paperSizeSelected( int ); - void orientSelected( int ); - void pageOrderSelected( int ); - void colorModeSelected( int ); - void setNumCopies( int ); - void printRangeSelected( int ); - void setFirstPage( int ); - void setLastPage( int ); - - void fileNameEditChanged( const TQString &text ); - -private: - TQPrintDialogPrivate *d; - - TQGroupBox * setupDestination(); - TQGroupBox * setupOptions(); - TQGroupBox * setupPaper(); - TQGroupBox * setupPrinterSettings(); - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQPrintDialog( const TQPrintDialog & ); - TQPrintDialog &operator=( const TQPrintDialog & ); -#endif -}; - -#endif - -#endif // TQPRINTDIALOG_H diff --git a/src/dialogs/qmessagebox.cpp b/src/dialogs/qmessagebox.cpp deleted file mode 100644 index 381a9f4f0..000000000 --- a/src/dialogs/qmessagebox.cpp +++ /dev/null @@ -1,1664 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQMessageBox class -** -** Created : 950503 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs 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 "ntqmessagebox.h" - -#ifndef TQT_NO_MESSAGEBOX - -#include "tqaccel.h" -#include "tqlabel.h" -#include "tqpushbutton.h" -#include "tqimage.h" -#include "ntqapplication.h" -#include "tqstyle.h" -#include "tqobjectlist.h" -#if defined(QT_ACCESSIBILITY_SUPPORT) -#include "tqaccessible.h" -#endif - -#ifdef TQ_WS_X11 -#include "private/tqttdeintegration_x11_p.h" -#endif - -extern bool tqt_use_native_dialogs; - -// Internal class - don't touch - -class TQMessageBoxLabel : public TQLabel -{ - TQ_OBJECT -public: - TQMessageBoxLabel( TQWidget* parent ) : TQLabel( parent, "messageBoxText") - { - setAlignment( AlignAuto|ExpandTabs ); - } -}; -#include "qmessagebox.moc" - - - -// the TQt logo, for aboutTQt -/* XPM */ -static const char * const qtlogo_xpm[] = { -/* width height ncolors chars_per_pixel */ -"50 50 17 1", -/* colors */ -" c #000000", -". c #495808", -"X c #2A3304", -"o c #242B04", -"O c #030401", -"+ c #9EC011", -"@ c #93B310", -"# c #748E0C", -"$ c #A2C511", -"% c #8BA90E", -"& c #99BA10", -"* c #060701", -"= c #181D02", -"- c #212804", -"; c #61770A", -": c #0B0D01", -"/ c None", -/* pixels */ -"/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$+++$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$@;.o=::=o.;@$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$+#X* **X#+$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$#oO* O **o#+$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$&.* OO O*.&$$$$$$$$$$$$$", -"$$$$$$$$$$$$@XOO * OO X&$$$$$$$$$$$$", -"$$$$$$$$$$$@XO OO O **:::OOO OOO X@$$$$$$$$$$$", -"$$$$$$$$$$&XO O-;#@++@%.oOO X&$$$$$$$$$$", -"$$$$$$$$$$.O : *-#+$$$$$$$$+#- : O O*.$$$$$$$$$$", -"$$$$$$$$$#*OO O*.&$$$$$$$$$$$$+.OOOO **#$$$$$$$$$", -"$$$$$$$$+-OO O *;$$$$$$$$$$$&$$$$;* o+$$$$$$$$", -"$$$$$$$$#O* O .+$$$$$$$$$$@X;$$$+.O *#$$$$$$$$", -"$$$$$$$$X* -&$$$$$$$$$$@- :;$$$&- OX$$$$$$$$", -"$$$$$$$@*O *O#$$$$$$$$$$@oOO**;$$$# O*%$$$$$$$", -"$$$$$$$; -+$$$$$$$$$@o O OO ;+$$-O *;$$$$$$$", -"$$$$$$$. ;$$$$$$$$$@-OO OO X&$$;O .$$$$$$$", -"$$$$$$$o *#$$$$$$$$@o O O O-@$$$#O *o$$$$$$$", -"$$$$$$+= *@$$$$$$$@o* OO -@$$$$&: =$$$$$$$", -"$$$$$$+: :+$$$$$$@- *-@$$$$$$: :+$$$$$$", -"$$$$$$+: :+$$$$$@o* O *-@$$$$$$: :+$$$$$$", -"$$$$$$$= :@$$$$@o*OOO -@$$$$@: =+$$$$$$", -"$$$$$$$- O%$$$@o* O O O O-@$$$#* OX$$$$$$$", -"$$$$$$$. O *O;$$&o O*O* *O -@$$; O.$$$$$$$", -"$$$$$$$;* Oo+$$;O*O:OO-- Oo@+= *;$$$$$$$", -"$$$$$$$@* O O#$$$;*OOOo@@-O Oo;O* **@$$$$$$$", -"$$$$$$$$X* OOO-+$$$;O o@$$@- O O OX$$$$$$$$", -"$$$$$$$$#* * O.$$$$;X@$$$$@-O O O#$$$$$$$$", -"$$$$$$$$+oO O OO.+$$+&$$$$$$@-O o+$$$$$$$$", -"$$$$$$$$$#* **.&$$$$$$$$$$@o OO:#$$$$$$$$$", -"$$$$$$$$$+. O* O-#+$$$$$$$$+;O OOO:@$$$$$$$$$", -"$$$$$$$$$$&X *O -;#@++@#;=O O -@$$$$$$$$", -"$$$$$$$$$$$&X O O*O::::O OO Oo@$$$$$$$", -"$$$$$$$$$$$$@XOO OO O*X+$$$$$$", -"$$$$$$$$$$$$$&.* ** O :: *:#$$$$$$$", -"$$$$$$$$$$$$$$$#o*OO O Oo#@-OOO=#$$$$$$$$", -"$$$$$$$$$$$$$$$$+#X:* * O**X#+$$@-*:#$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$%;.o=::=o.#@$$$$$$@X#$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$+++$$$$$$$$$$$+$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", -"/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/", -}; - - -/*! - \class TQMessageBox - \brief The TQMessageBox class provides a modal dialog with a short message, an icon, and some buttons. - \ingroup dialogs - \mainclass - - Message boxes are used to provide informative messages and to ask - simple questions. - - TQMessageBox provides a range of different messages, arranged - roughly along two axes: severity and complexity. - - Severity is - \table - \row - \i \img qmessagebox-quest.png - \i Question - \i For message boxes that ask a question as part of normal - operation. Some style guides recommend using Information for this - purpose. - \row - \i \img qmessagebox-info.png - \i Information - \i For message boxes that are part of normal operation. - \row - \i \img qmessagebox-warn.png - \i Warning - \i For message boxes that tell the user about unusual errors. - \row - \i \img qmessagebox-crit.png - \i Critical - \i For message boxes that tell the user about critical errors. - \endtable - - The message box has a different icon for each of the severity levels. - - Complexity is one button (OK) for simple messages, or two or even - three buttons for questions. - - There are static functions for the most common cases. - - Examples: - - If a program is unable to find a supporting file, but can do perfectly - well without it: - - \code - TQMessageBox::information( this, "Application name", - "Unable to find the user preferences file.\n" - "The factory default will be used instead." ); - \endcode - - question() is useful for simple yes/no questions: - - \code - if ( TQFile::exists( filename ) && - TQMessageBox::question( - this, - tr("Overwrite File? -- Application Name"), - tr("A file called %1 already exists." - "Do you want to overwrite it?") - .arg( filename ), - tr("&Yes"), tr("&No"), - TQString::null, 0, 1 ) ) - return false; - \endcode - - warning() can be used to tell the user about unusual errors, or - errors which can't be easily fixed: - - \code - switch( TQMessageBox::warning( this, "Application name", - "Could not connect to the server.\n" - "This program can't function correctly " - "without the server.\n\n", - "Retry", - "Quit", 0, 0, 1 ) ) { - case 0: // The user clicked the Retry again button or pressed Enter - // try again - break; - case 1: // The user clicked the Quit or pressed Escape - // exit - break; - } - \endcode - - The text part of all message box messages can be either rich text - or plain text. If you specify a rich text formatted string, it - will be rendered using the default stylesheet. See - TQStyleSheet::defaultSheet() for details. With certain strings that - contain XML meta characters, the auto-rich text detection may - fail, interpreting plain text incorrectly as rich text. In these - rare cases, use TQStyleSheet::convertFromPlainText() to convert - your plain text string to a visually equivalent rich text string - or set the text format explicitly with setTextFormat(). - - Note that the Microsoft Windows User Interface Guidelines - recommend using the application name as the window's caption. - - Below are more examples of how to use the static member functions. - After these examples you will find an overview of the non-static - member functions. - - Exiting a program is part of its normal operation. If there is - unsaved data the user probably should be asked if they want to - save the data. For example: - - \code - switch( TQMessageBox::information( this, "Application name here", - "The document contains unsaved changes\n" - "Do you want to save the changes before exiting?", - "&Save", "&Discard", "Cancel", - 0, // Enter == button 0 - 2 ) ) { // Escape == button 2 - case 0: // Save clicked or Alt+S pressed or Enter pressed. - // save - break; - case 1: // Discard clicked or Alt+D pressed - // don't save but exit - break; - case 2: // Cancel clicked or Escape pressed - // don't exit - break; - } - \endcode - - The Escape button cancels the entire exit operation, and pressing - Enter causes the changes to be saved before the exit occurs. - - Disk full errors are unusual and they certainly can be hard to - correct. This example uses predefined buttons instead of - hard-coded button texts: - - \code - switch( TQMessageBox::warning( this, "Application name here", - "Could not save the user preferences,\n" - "because the disk is full. You can delete\n" - "some files and press Retry, or you can\n" - "abort the Save Preferences operation.", - TQMessageBox::Retry | TQMessageBox::Default, - TQMessageBox::Abort | TQMessageBox::Escape )) { - case TQMessageBox::Retry: // Retry clicked or Enter pressed - // try again - break; - case TQMessageBox::Abort: // Abort clicked or Escape pressed - // abort - break; - } - \endcode - - The critical() function should be reserved for critical errors. In - this example errorDetails is a TQString or const char*, and TQString - is used to concatenate several strings: - - \code - TQMessageBox::critical( 0, "Application name here", - TQString("An internal error occurred. Please ") + - "call technical support at 1234-56789 and report\n"+ - "these numbers:\n\n" + errorDetails + - "\n\nApplication will now exit." ); - \endcode - - In this example an OK button is displayed. - - TQMessageBox provides a very simple About box which displays an - appropriate icon and the string you provide: - - \code - TQMessageBox::about( this, "About ", - " is a \n\n" - "Copyright 1991-2003 Such-and-such. " - "\n\n" - "For technical support, call 1234-56789 or see\n" - "http://www.such-and-such.com/Application/\n" ); - \endcode - - See about() for more information. - - If you want your users to know that the application is built using - TQt (so they know that you use high quality tools) you might like - to add an "About TQt" menu option under the Help menu to invoke - aboutTQt(). - - If none of the standard message boxes is suitable, you can create a - TQMessageBox from scratch and use custom button texts: - - \code - TQMessageBox mb( "Application name here", - "Saving the file will overwrite the original file on the disk.\n" - "Do you really want to save?", - TQMessageBox::Information, - TQMessageBox::Yes | TQMessageBox::Default, - TQMessageBox::No, - TQMessageBox::Cancel | TQMessageBox::Escape ); - mb.setButtonText( TQMessageBox::Yes, "Save" ); - mb.setButtonText( TQMessageBox::No, "Discard" ); - switch( mb.exec() ) { - case TQMessageBox::Yes: - // save and exit - break; - case TQMessageBox::No: - // exit without saving - break; - case TQMessageBox::Cancel: - // don't save and don't exit - break; - } - \endcode - - TQMessageBox defines two enum types: Icon and an unnamed button type. - Icon defines the \c Question, \c Information, \c Warning, and \c - Critical icons for each GUI style. It is used by the constructor - and by the static member functions question(), information(), - warning() and critical(). A function called standardIcon() gives - you access to the various icons. - - The button types are: - \list - \i Ok - the default for single-button message boxes - \i Cancel - note that this is \e not automatically Escape - \i Yes - \i No - \i Abort - \i Retry - \i Ignore - \i YesAll - \i NoAll - \endlist - - Button types can be combined with two modifiers by using OR, '|': - \list - \i Default - makes pressing Enter equivalent to - clicking this button. Normally used with Ok, Yes or similar. - \i Escape - makes pressing Escape equivalent to clicking this button. - Normally used with Abort, Cancel or similar. - \endlist - - The text(), icon() and iconPixmap() functions provide access to the - current text and pixmap of the message box. The setText(), setIcon() - and setIconPixmap() let you change it. The difference between - setIcon() and setIconPixmap() is that the former accepts a - TQMessageBox::Icon and can be used to set standard icons, whereas the - latter accepts a TQPixmap and can be used to set custom icons. - - setButtonText() and buttonText() provide access to the buttons. - - TQMessageBox has no signals or slots. - - - - \sa TQDialog, - \link http://www.iarchitect.com/errormsg.htm - Isys on error messages \endlink, - \link guibooks.html#fowler GUI Design Handbook: Message Box \endlink -*/ - - -/*! - \enum TQMessageBox::Icon - - This enum has the following values: - - \value NoIcon the message box does not have any icon. - - \value Question an icon indicating that - the message is asking a question. - - \value Information an icon indicating that - the message is nothing out of the ordinary. - - \value Warning an icon indicating that the - message is a warning, but can be dealt with. - - \value Critical an icon indicating that - the message represents a critical problem. - -*/ - - -struct TQMessageBoxData { - TQMessageBoxData(TQMessageBox* parent) : - iconLabel( parent, "icon" ) - { - } - - int numButtons; // number of buttons - TQMessageBox::Icon icon; // message box icon - TQLabel iconLabel; // label holding any icon - int button[3]; // button types - int defButton; // default button (index) - int escButton; // escape button (index) - TQSize buttonSize; // button size - TQPushButton *pb[3]; // buttons -}; - -static const int LastButton = TQMessageBox::NoAll; - -/* - NOTE: The table of button texts correspond to the button enum. -*/ - -#ifndef Q_OS_TEMP -static const char * const mb_texts[] = { -#else -const char * mb_texts[] = { -#endif - 0, - TQT_TRANSLATE_NOOP("TQMessageBox","OK"), - TQT_TRANSLATE_NOOP("TQMessageBox","Cancel"), - TQT_TRANSLATE_NOOP("TQMessageBox","&Yes"), - TQT_TRANSLATE_NOOP("TQMessageBox","&No"), - TQT_TRANSLATE_NOOP("TQMessageBox","&Abort"), - TQT_TRANSLATE_NOOP("TQMessageBox","&Retry"), - TQT_TRANSLATE_NOOP("TQMessageBox","&Ignore"), - TQT_TRANSLATE_NOOP("TQMessageBox","Yes to &All"), - TQT_TRANSLATE_NOOP("TQMessageBox","N&o to All"), - 0 -}; - -/*! - Constructs a message box with no text and a button with the label - "OK". - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - The \a parent and \a name arguments are passed to the TQDialog - constructor. -*/ - -TQMessageBox::TQMessageBox( TQWidget *parent, const char *name ) - : TQDialog( parent, name, TRUE, WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu ) -{ - init( Ok, 0, 0 ); -} - - -/*! - Constructs a message box with a \a caption, a \a text, an \a icon, - and up to three buttons. - - The \a icon must be one of the following: - \list - \i TQMessageBox::NoIcon - \i TQMessageBox::Question - \i TQMessageBox::Information - \i TQMessageBox::Warning - \i TQMessageBox::Critical - \endlist - - Each button, \a button0, \a button1 and \a button2, can have one - of the following values: - \list - \i TQMessageBox::NoButton - \i TQMessageBox::Ok - \i TQMessageBox::Cancel - \i TQMessageBox::Yes - \i TQMessageBox::No - \i TQMessageBox::Abort - \i TQMessageBox::Retry - \i TQMessageBox::Ignore - \i TQMessageBox::YesAll - \i TQMessageBox::NoAll - \endlist - - Use TQMessageBox::NoButton for the later parameters to have fewer - than three buttons in your message box. If you don't specify any - buttons at all, TQMessageBox will provide an Ok button. - - One of the buttons can be OR-ed with the \c TQMessageBox::Default - flag to make it the default button (clicked when Enter is - pressed). - - One of the buttons can be OR-ed with the \c TQMessageBox::Escape - flag to make it the cancel or close button (clicked when Escape is - pressed). - - Example: - \code - TQMessageBox mb( "Application Name", - "Hardware failure.\n\nDisk error detected\nDo you want to stop?", - TQMessageBox::Question, - TQMessageBox::Yes | TQMessageBox::Default, - TQMessageBox::No | TQMessageBox::Escape, - TQMessageBox::NoButton ); - if ( mb.exec() == TQMessageBox::No ) - // try again - \endcode - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - If \a modal is TRUE the message box is modal; otherwise it - is modeless. - - The \a parent, \a name, \a modal, and \a f arguments are passed to - the TQDialog constructor. - - \sa setCaption(), setText(), setIcon() -*/ - -TQMessageBox::TQMessageBox( const TQString& caption, - const TQString &text, Icon icon, - int button0, int button1, int button2, - TQWidget *parent, const char *name, - bool modal, WFlags f ) - : TQDialog( parent, name, modal, f | WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu ) -{ - init( button0, button1, button2 ); -#ifndef TQT_NO_WIDGET_TOPEXTRA - setCaption( caption ); -#endif - setText( text ); - setIcon( icon ); -} - - -/*! - Destroys the message box. -*/ - -TQMessageBox::~TQMessageBox() -{ - delete mbd; -} - -static TQString * translatedTextAboutTQt = 0; - -void TQMessageBox::init( int button0, int button1, int button2 ) -{ - if ( !translatedTextAboutTQt ) { - translatedTextAboutTQt = new TQString; - - *translatedTextAboutTQt = tr( - "

About TQt

" - "

This program uses TQt version %1.

" - "

TQt is a C++ toolkit for multiplatform GUI & " - "application development.

" - "

TQt provides single-source " - "portability across MS Windows, Mac OS X, " - "Linux, and all major commercial Unix variants.

" - "

See https://trinitydesktop.org/docs/qt3/ " - "for more information.

" - ).arg( TQT_VERSION_STR ); - - } - label = new TQMessageBoxLabel( this ); - TQ_CHECK_PTR( label ); - - if ( (button2 && !button1) || (button1 && !button0) ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQMessageBox: Inconsistent button parameters" ); -#endif - button0 = button1 = button2 = 0; - } - mbd = new TQMessageBoxData(this); - TQ_CHECK_PTR( mbd ); - mbd->icon = NoIcon; - mbd->iconLabel.setPixmap( TQPixmap() ); - mbd->numButtons = 0; - mbd->button[0] = button0; - mbd->button[1] = button1; - mbd->button[2] = button2; - mbd->defButton = -1; - mbd->escButton = -1; - int i; - for ( i=0; i<3; i++ ) { - int b = mbd->button[i]; - if ( (b & Default) ) { - if ( mbd->defButton >= 0 ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQMessageBox: There can be at most one " - "default button" ); -#endif - } else { - mbd->defButton = i; - } - } - if ( (b & Escape) ) { - if ( mbd->escButton >= 0 ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQMessageBox: There can be at most one " - "escape button" ); -#endif - } else { - mbd->escButton = i; - } - } - b &= ButtonMask; - if ( b == 0 ) { - if ( i == 0 ) // no buttons, add an Ok button - b = Ok; - } else if ( b < 0 || b > LastButton ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQMessageBox: Invalid button specifier" ); -#endif - b = Ok; - } else { - if ( i > 0 && mbd->button[i-1] == 0 ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQMessageBox: Inconsistent button parameters; " - "button %d defined but not button %d", - i+1, i ); -#endif - b = 0; - } - } - mbd->button[i] = b; - if ( b ) - mbd->numButtons++; - } - for ( i=0; i<3; i++ ) { - if ( i >= mbd->numButtons ) { - mbd->pb[i] = 0; - } else { - TQCString buttonName; - buttonName.sprintf( "button%d", i+1 ); - mbd->pb[i] = new TQPushButton( - tr(mb_texts[mbd->button[i]]), - this, buttonName ); - if ( mbd->defButton == i ) { - mbd->pb[i]->setDefault( TRUE ); - mbd->pb[i]->setFocus(); - } - mbd->pb[i]->setAutoDefault( TRUE ); - mbd->pb[i]->setFocusPolicy( TQWidget::StrongFocus ); - connect( mbd->pb[i], TQ_SIGNAL(clicked()), TQ_SLOT(buttonClicked()) ); - } - } - resizeButtons(); - reserved1 = reserved2 = 0; -} - - -int TQMessageBox::indexOf( int button ) const -{ - int index = -1; - for ( int i=0; inumButtons; i++ ) { - if ( mbd->button[i] == button ) { - index = i; - break; - } - } - return index; -} - - -void TQMessageBox::resizeButtons() -{ - int i; - TQSize maxSize; - for ( i=0; inumButtons; i++ ) { - TQSize s = mbd->pb[i]->sizeHint(); - maxSize.setWidth( TQMAX(maxSize.width(), s.width()) ); - maxSize.setHeight( TQMAX(maxSize.height(),s.height()) ); - } - mbd->buttonSize = maxSize; - for ( i=0; inumButtons; i++ ) - mbd->pb[i]->resize( maxSize ); -} - - -/*! - \property TQMessageBox::text - \brief the message box text to be displayed. - - The text will be interpreted either as a plain text or as rich - text, depending on the text format setting (\l - TQMessageBox::textFormat). The default setting is \c AutoText, i.e. - the message box will try to auto-detect the format of the text. - - The default value of this property is TQString::null. - - \sa textFormat -*/ -TQString TQMessageBox::text() const -{ - return label->text(); -} - - -void TQMessageBox::setText( const TQString &text ) -{ - label->setText( text ); -} - - -/*! - \property TQMessageBox::icon - \brief the message box's icon - - The icon of the message box can be one of the following predefined - icons: - \list - \i TQMessageBox::NoIcon - \i TQMessageBox::Question - \i TQMessageBox::Information - \i TQMessageBox::Warning - \i TQMessageBox::Critical - \endlist - - The actual pixmap used for displaying the icon depends on the - current \link TQWidget::style() GUI style\endlink. You can also set - a custom pixmap icon using the \l TQMessageBox::iconPixmap - property. The default icon is TQMessageBox::NoIcon. - - \sa iconPixmap -*/ - -TQMessageBox::Icon TQMessageBox::icon() const -{ - return mbd->icon; -} - -void TQMessageBox::setIcon( Icon icon ) -{ - setIconPixmap( standardIcon(icon) ); - mbd->icon = icon; -} - -/*! - \obsolete - - Returns the pixmap used for a standard icon. This - allows the pixmaps to be used in more complex message boxes. - \a icon specifies the required icon, e.g. TQMessageBox::Information, - TQMessageBox::Warning or TQMessageBox::Critical. - - \a style is unused. -*/ - -TQPixmap TQMessageBox::standardIcon( Icon icon, GUIStyle style) -{ - Q_UNUSED(style); - return TQMessageBox::standardIcon(icon); -} - - -/*! - Returns the pixmap used for a standard icon. This allows the - pixmaps to be used in more complex message boxes. \a icon - specifies the required icon, e.g. TQMessageBox::Question, - TQMessageBox::Information, TQMessageBox::Warning or - TQMessageBox::Critical. -*/ - -TQPixmap TQMessageBox::standardIcon( Icon icon ) -{ - TQPixmap pm; - switch ( icon ) { - case Information: - pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxInformation ); - break; - case Warning: - pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxWarning ); - break; - case Critical: - pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxCritical ); - break; - case Question: - pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxQuestion ); - default: - break; - } - return pm; -} - - -/*! - \property TQMessageBox::iconPixmap - \brief the current icon - - The icon currently used by the message box. Note that it's often - hard to draw one pixmap that looks appropriate in both Motif and - Windows GUI styles; you may want to draw two pixmaps. - - \sa icon -*/ - -const TQPixmap *TQMessageBox::iconPixmap() const -{ - return mbd->iconLabel.pixmap(); -} - - -void TQMessageBox::setIconPixmap( const TQPixmap &pixmap ) -{ - mbd->iconLabel.setPixmap(pixmap); - mbd->icon = NoIcon; -} - - -/*! - Returns the text of the message box button \a button, or - TQString::null if the message box does not contain the button. - - \sa setButtonText() -*/ - -TQString TQMessageBox::buttonText( int button ) const -{ - int index = indexOf(button); - return index >= 0 && mbd->pb[index] - ? mbd->pb[index]->text() - : TQString::null; -} - - -/*! - Sets the text of the message box button \a button to \a text. - Setting the text of a button that is not in the message box is - silently ignored. - - \sa buttonText() -*/ - -void TQMessageBox::setButtonText( int button, const TQString &text ) -{ - int index = indexOf(button); - if ( index >= 0 && mbd->pb[index] ) { - mbd->pb[index]->setText( text ); - resizeButtons(); - } -} - - -/*! - \internal - Internal slot to handle button clicks. -*/ - -void TQMessageBox::buttonClicked() -{ - int reply = 0; - const TQObject *s = sender(); - for ( int i=0; inumButtons; i++ ) { - if ( mbd->pb[i] == s ) - reply = mbd->button[i]; - } - done( reply ); -} - - -/*! - Adjusts the size of the message box to fit the contents just before - TQDialog::exec() or TQDialog::show() is called. - - This function will not be called if the message box has been explicitly - resized before showing it. -*/ -void TQMessageBox::adjustSize() -{ - if ( !testWState(WState_Polished) ) - polish(); - resizeButtons(); - label->adjustSize(); - TQSize labelSize( label->size() ); - int n = mbd->numButtons; - int bw = mbd->buttonSize.width(); - int bh = mbd->buttonSize.height(); - int border = bh / 2 - style().pixelMetric(TQStyle::PM_ButtonDefaultIndicator); - if ( border <= 0 ) - border = 10; - int btn_spacing = 7; - if ( style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle ) - btn_spacing = border; -#ifndef Q_OS_TEMP - int buttons = mbd->numButtons * bw + (n-1) * btn_spacing; - int h = bh; -#else - int visibleButtons = 0; - for ( int i = 0; i < mbd->numButtons; ++i ) - visibleButtons += mbd->pb[i]->isVisible() ? 1 : 0; - int buttons = visibleButtons == 0 ? 0 : visibleButtons * bw + (visibleButtons-1) * btn_spacing; - int h = visibleButtons == 0 ? 0 : bh; - n = visibleButtons; -#endif - if ( labelSize.height() ) - h += labelSize.height() + 3*border; - else - h += 2*border; - int lmargin = 0; - if ( mbd->iconLabel.pixmap() && mbd->iconLabel.pixmap()->width() ) { - mbd->iconLabel.adjustSize(); - lmargin += mbd->iconLabel.width() + border; - if ( h < mbd->iconLabel.height() + 3*border + bh && n ) - h = mbd->iconLabel.height() + 3*border + bh; - } - int w = TQMAX( buttons, labelSize.width() + lmargin ) + 2*border; - TQRect screen = TQApplication::desktop()->screenGeometry( pos() ); - if ( w > screen.width() ) - w = screen.width(); - resize( w, h ); - setMinimumSize( size() ); -#ifdef TQ_WS_MAC - setMaximumSize(size()); -#endif -} - - -/*!\reimp -*/ -void TQMessageBox::resizeEvent( TQResizeEvent * ) -{ - int i; - int n = mbd->numButtons; - int bw = mbd->buttonSize.width(); - int bh = mbd->buttonSize.height(); -#ifdef Q_OS_TEMP - int visibleButtons = 0; - for ( i = 0; i < n; ++i ) - visibleButtons += mbd->pb[i]->isVisible() ? 1 : 0; - n = visibleButtons; - bw = visibleButtons == 0 ? 0 : bw; - bh = visibleButtons == 0 ? 0 : bh; -#endif - int border = bh / 2 - style().pixelMetric(TQStyle::PM_ButtonDefaultIndicator); - if ( border <= 0 ) - border = 10; - int btn_spacing = 7; - if ( style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle ) - btn_spacing = border; - int lmargin = 0; - mbd->iconLabel.adjustSize(); - bool rtl = TQApplication::reverseLayout(); - if (rtl) - mbd->iconLabel.move(width() - border - mbd->iconLabel.width(), border); - else - mbd->iconLabel.move(border, border); - if ( mbd->iconLabel.pixmap() && mbd->iconLabel.pixmap()->width() ) - lmargin += mbd->iconLabel.width() + border; - label->setGeometry((rtl ? 0 : lmargin) + border, - border, - width() - lmargin -2*border, - height() - 3*border - bh); - int extra_space = (width() - bw*n - 2*border - (n-1)*btn_spacing); - if ( style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle ) - for ( i=0; ipb[rtl ? n - i - 1 : i]->move(border + i*bw + i*btn_spacing + extra_space*(i+1)/(n+1), - height() - border - bh ); - else - for ( i=0; ipb[rtl ? n - i - 1 : i]->move(border + i*bw + extra_space/2 + i*btn_spacing, - height() - border - bh ); -} - - -/*!\reimp -*/ -void TQMessageBox::keyPressEvent( TQKeyEvent *e ) -{ - if ( e->key() == Key_Escape ) { - if ( mbd->escButton >= 0 ) { - TQPushButton *pb = mbd->pb[mbd->escButton]; - pb->animateClick(); - e->accept(); - return; - } - } -#ifndef TQT_NO_ACCEL - if ( !( e->state() & AltButton ) ) { - TQObjectList *list = queryList( "TQPushButton" ); - TQObjectListIt it( *list ); - TQPushButton *pb; - while ( (pb = (TQPushButton*)it.current()) ) { - int key = e->key() & ~(MODIFIER_MASK|UNICODE_ACCEL); - int acc = pb->accel() & ~(MODIFIER_MASK|UNICODE_ACCEL); - if ( key && acc && acc == key ) { - delete list; - emit pb->animateClick(); - return; - } - ++it; - } - delete list; - } -#endif - TQDialog::keyPressEvent( e ); -} - -/*!\reimp -*/ -void TQMessageBox::showEvent( TQShowEvent *e ) -{ -#if defined(QT_ACCESSIBILITY_SUPPORT) - TQAccessible::updateAccessibility( this, 0, TQAccessible::Alert ); -#endif - TQDialog::showEvent( e ); -} - -/*!\reimp -*/ -void TQMessageBox::closeEvent( TQCloseEvent *e ) -{ - TQDialog::closeEvent( e ); - if ( mbd->escButton != -1 ) - setResult( mbd->button[mbd->escButton] ); -} - -/***************************************************************************** - Static TQMessageBox functions - *****************************************************************************/ - -/*!\fn int TQMessageBox::message( const TQString &,const TQString&,const TQString&,TQWidget*,const char * ) - \obsolete - Opens a modal message box directly using the specified parameters. - - Please use information(), warning(), question(), or critical() instead. -*/ - -/*! \fn bool TQMessageBox::query( const TQString &,const TQString&,const TQString&,const TQString&,TQWidget *, const char * ) - \obsolete - Queries the user using a modal message box with two buttons. - Note that \a caption is not always shown, it depends on the window manager. - - Please use information(), question(), warning(), or critical() instead. -*/ - -/*! - Opens an information message box with the caption \a caption and - the text \a text. The dialog may have up to three buttons. Each of - the buttons, \a button0, \a button1 and \a button2 may be set to - one of the following values: - - \list - \i TQMessageBox::NoButton - \i TQMessageBox::Ok - \i TQMessageBox::Cancel - \i TQMessageBox::Yes - \i TQMessageBox::No - \i TQMessageBox::Abort - \i TQMessageBox::Retry - \i TQMessageBox::Ignore - \i TQMessageBox::YesAll - \i TQMessageBox::NoAll - \endlist - - If you don't want all three buttons, set the last button, or last - two buttons to TQMessageBox::NoButton. - - One button can be OR-ed with \c TQMessageBox::Default, and one - button can be OR-ed with \c TQMessageBox::Escape. - - Returns the identity (TQMessageBox::Ok, or TQMessageBox::No, etc.) - of the button that was clicked. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - \sa question(), warning(), critical() -*/ - -int TQMessageBox::information( TQWidget *parent, - const TQString& caption, const TQString& text, - int button0, int button1, int button2 ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::information( parent, caption, text, button0, button1, button2 ); -#endif - TQMessageBox *mb = new TQMessageBox( caption, text, Information, - button0, button1, button2, - parent, "qt_msgbox_information", TRUE, - WDestructiveClose); - TQ_CHECK_PTR( mb ); - return mb->exec(); -} - -/*! - Opens a question message box with the caption \a caption and the - text \a text. The dialog may have up to three buttons. Each of the - buttons, \a button0, \a button1 and \a button2 may be set to one - of the following values: - - \list - \i TQMessageBox::NoButton - \i TQMessageBox::Ok - \i TQMessageBox::Cancel - \i TQMessageBox::Yes - \i TQMessageBox::No - \i TQMessageBox::Abort - \i TQMessageBox::Retry - \i TQMessageBox::Ignore - \i TQMessageBox::YesAll - \i TQMessageBox::NoAll - \endlist - - If you don't want all three buttons, set the last button, or last - two buttons to TQMessageBox::NoButton. - - One button can be OR-ed with \c TQMessageBox::Default, and one - button can be OR-ed with \c TQMessageBox::Escape. - - Returns the identity (TQMessageBox::Yes, or TQMessageBox::No, etc.) - of the button that was clicked. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - \sa information(), warning(), critical() -*/ - -int TQMessageBox::question( TQWidget *parent, - const TQString& caption, const TQString& text, - int button0, int button1, int button2 ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::question( parent, caption, text, button0, button1, button2 ); -#endif - TQMessageBox *mb = new TQMessageBox( caption, text, Question, - button0, button1, button2, - parent, "qt_msgbox_information", TRUE, - WDestructiveClose); - TQ_CHECK_PTR( mb ); - return mb->exec(); -} - - -/*! - Opens a warning message box with the caption \a caption and the - text \a text. The dialog may have up to three buttons. Each of the - button parameters, \a button0, \a button1 and \a button2 may be - set to one of the following values: - - \list - \i TQMessageBox::NoButton - \i TQMessageBox::Ok - \i TQMessageBox::Cancel - \i TQMessageBox::Yes - \i TQMessageBox::No - \i TQMessageBox::Abort - \i TQMessageBox::Retry - \i TQMessageBox::Ignore - \i TQMessageBox::YesAll - \i TQMessageBox::NoAll - \endlist - - If you don't want all three buttons, set the last button, or last - two buttons to TQMessageBox::NoButton. - - One button can be OR-ed with \c TQMessageBox::Default, and one - button can be OR-ed with \c TQMessageBox::Escape. - - Returns the identity (TQMessageBox::Ok, or TQMessageBox::No, etc.) - of the button that was clicked. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - \sa information(), question(), critical() -*/ - -int TQMessageBox::warning( TQWidget *parent, - const TQString& caption, const TQString& text, - int button0, int button1, int button2 ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::warning( parent, caption, text, button0, button1, button2 ); -#endif - TQMessageBox *mb = new TQMessageBox( caption, text, Warning, - button0, button1, button2, - parent, "qt_msgbox_warning", TRUE, - WDestructiveClose); - TQ_CHECK_PTR( mb ); - return mb->exec(); -} - - -/*! - Opens a critical message box with the caption \a caption and the - text \a text. The dialog may have up to three buttons. Each of the - button parameters, \a button0, \a button1 and \a button2 may be - set to one of the following values: - - \list - \i TQMessageBox::NoButton - \i TQMessageBox::Ok - \i TQMessageBox::Cancel - \i TQMessageBox::Yes - \i TQMessageBox::No - \i TQMessageBox::Abort - \i TQMessageBox::Retry - \i TQMessageBox::Ignore - \i TQMessageBox::YesAll - \i TQMessageBox::NoAll - \endlist - - If you don't want all three buttons, set the last button, or last - two buttons to TQMessageBox::NoButton. - - One button can be OR-ed with \c TQMessageBox::Default, and one - button can be OR-ed with \c TQMessageBox::Escape. - - Returns the identity (TQMessageBox::Ok, or TQMessageBox::No, etc.) - of the button that was clicked. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - \sa information(), question(), warning() -*/ - -int TQMessageBox::critical( TQWidget *parent, - const TQString& caption, const TQString& text, - int button0, int button1, int button2 ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::critical( parent, caption, text, button0, button1, button2 ); -#endif - TQMessageBox *mb = new TQMessageBox( caption, text, Critical, - button0, button1, button2, - parent, "qt_msgbox_critical", TRUE, - WDestructiveClose); - TQ_CHECK_PTR( mb ); - return mb->exec(); -} - - -/*! - Displays a simple about box with caption \a caption and text \a - text. The about box's parent is \a parent. - - about() looks for a suitable icon in four locations: - \list 1 - \i It prefers \link TQWidget::icon() parent->icon() \endlink if that exists. - \i If not, it tries the top-level widget containing \a parent. - \i If that fails, it tries the \link - TQApplication::mainWidget() main widget. \endlink - \i As a last resort it uses the Information icon. - \endlist - - The about box has a single button labelled "OK". - - \sa TQWidget::icon() TQApplication::mainWidget() -*/ - -void TQMessageBox::about( TQWidget *parent, const TQString &caption, - const TQString& text ) -{ - TQMessageBox *mb = new TQMessageBox( caption, text, - Information, - Ok + Default, 0, 0, - parent, "qt_msgbox_simple_about_box", TRUE, - WDestructiveClose); - TQ_CHECK_PTR( mb ); -#ifndef TQT_NO_WIDGET_TOPEXTRA - const TQPixmap *pm = parent ? parent->icon() : 0; - if ( pm && !pm->isNull() ) - mb->setIconPixmap( *pm ); - else { - pm = parent ? parent->topLevelWidget()->icon() : 0; - if ( pm && !pm->isNull() ) - mb->setIconPixmap( *pm ); - else { - pm = tqApp && tqApp->mainWidget() ? tqApp->mainWidget()->icon() : 0; - if ( pm && !pm->isNull() ) - mb->setIconPixmap( *pm ); - } - } -#endif - mb->exec(); -} - - -/*! \reimp -*/ - -void TQMessageBox::styleChanged( TQStyle& ) -{ - if ( mbd->icon != NoIcon ) { - // Reload icon for new style - setIcon( mbd->icon ); - } -} - - -static int textBox( TQWidget *parent, TQMessageBox::Icon severity, - const TQString& caption, const TQString& text, - const TQString& button0Text, - const TQString& button1Text, - const TQString& button2Text, - int defaultButtonNumber, - int escapeButtonNumber ) -{ - int b[3]; - b[0] = 1; - b[1] = button1Text.isEmpty() ? 0 : 2; - b[2] = button2Text.isEmpty() ? 0 : 3; - - int i; - for( i=0; i<3; i++ ) { - if ( b[i] && defaultButtonNumber == i ) - b[i] += TQMessageBox::Default; - if ( b[i] && escapeButtonNumber == i ) - b[i] += TQMessageBox::Escape; - } - - TQMessageBox *mb = new TQMessageBox( caption, text, severity, - b[0], b[1], b[2], - parent, "qt_msgbox_information", TRUE, - TQt::WDestructiveClose); - TQ_CHECK_PTR( mb ); - if ( button0Text.isEmpty() ) - mb->setButtonText( 1, TQMessageBox::tr(mb_texts[TQMessageBox::Ok]) ); - else - mb->setButtonText( 1, button0Text ); - if ( b[1] ) - mb->setButtonText( 2, button1Text ); - if ( b[2] ) - mb->setButtonText( 3, button2Text ); - -#ifndef TQT_NO_CURSOR - mb->setCursor( TQt::arrowCursor ); -#endif - return mb->exec() - 1; -} - - -/*! - \overload - - Displays an information message box with caption \a caption, text - \a text and one, two or three buttons. Returns the index of the - button that was clicked (0, 1 or 2). - - \a button0Text is the text of the first button, and is optional. - If \a button0Text is not supplied, "OK" (translated) will be used. - \a button1Text is the text of the second button, and is optional. - \a button2Text is the text of the third button, and is optional. - \a defaultButtonNumber (0, 1 or 2) is the index of the default - button; pressing Return or Enter is the same as clicking the - default button. It defaults to 0 (the first button). \a - escapeButtonNumber is the index of the Escape button; pressing - Escape is the same as clicking this button. It defaults to -1; - supply 0, 1 or 2 to make pressing Escape equivalent to clicking - the relevant button. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - Note: If you do not specify an Escape button then if the Escape - button is pressed then -1 will be returned. It is suggested that - you specify an Escape button to prevent this from happening. - - \sa question(), warning(), critical() -*/ - -int TQMessageBox::information( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text, - const TQString& button1Text, - const TQString& button2Text, - int defaultButtonNumber, - int escapeButtonNumber ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::information( parent, caption, text, - button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); -#endif - return textBox( parent, Information, caption, text, - button0Text, button1Text, button2Text, - defaultButtonNumber, escapeButtonNumber ); -} - -/*! - \overload - - Displays a question message box with caption \a caption, text \a - text and one, two or three buttons. Returns the index of the - button that was clicked (0, 1 or 2). - - \a button0Text is the text of the first button, and is optional. - If \a button0Text is not supplied, "OK" (translated) will be used. - \a button1Text is the text of the second button, and is optional. - \a button2Text is the text of the third button, and is optional. - \a defaultButtonNumber (0, 1 or 2) is the index of the default - button; pressing Return or Enter is the same as clicking the - default button. It defaults to 0 (the first button). \a - escapeButtonNumber is the index of the Escape button; pressing - Escape is the same as clicking this button. It defaults to -1; - supply 0, 1 or 2 to make pressing Escape equivalent to clicking - the relevant button. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - Note: If you do not specify an Escape button then if the Escape - button is pressed then -1 will be returned. It is suggested that - you specify an Escape button to prevent this from happening. - - \sa information(), warning(), critical() -*/ -int TQMessageBox::question( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text, - const TQString& button1Text, - const TQString& button2Text, - int defaultButtonNumber, - int escapeButtonNumber ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::question( parent, caption, text, - button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); -#endif - return textBox( parent, Question, caption, text, - button0Text, button1Text, button2Text, - defaultButtonNumber, escapeButtonNumber ); -} - - -/*! - \overload - - Displays a warning message box with a caption, a text, and 1, 2 or - 3 buttons. Returns the number of the button that was clicked (0, - 1, or 2). - - \a button0Text is the text of the first button, and is optional. - If \a button0Text is not supplied, "OK" (translated) will be used. - \a button1Text is the text of the second button, and is optional, - and \a button2Text is the text of the third button, and is - optional. \a defaultButtonNumber (0, 1 or 2) is the index of the - default button; pressing Return or Enter is the same as clicking - the default button. It defaults to 0 (the first button). \a - escapeButtonNumber is the index of the Escape button; pressing - Escape is the same as clicking this button. It defaults to -1; - supply 0, 1, or 2 to make pressing Escape equivalent to clicking - the relevant button. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - Note: If you do not specify an Escape button then if the Escape - button is pressed then -1 will be returned. It is suggested that - you specify an Escape button to prevent this from happening. - - \sa information(), question(), critical() -*/ - -int TQMessageBox::warning( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text, - const TQString& button1Text, - const TQString& button2Text, - int defaultButtonNumber, - int escapeButtonNumber ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::warning( parent, caption, text, - button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); -#endif - return textBox( parent, Warning, caption, text, - button0Text, button1Text, button2Text, - defaultButtonNumber, escapeButtonNumber ); -} - - -/*! - \overload - - Displays a critical error message box with a caption, a text, and - 1, 2 or 3 buttons. Returns the number of the button that was - clicked (0, 1 or 2). - - \a button0Text is the text of the first button, and is optional. - If \a button0Text is not supplied, "OK" (translated) will be used. - \a button1Text is the text of the second button, and is optional, - and \a button2Text is the text of the third button, and is - optional. \a defaultButtonNumber (0, 1 or 2) is the index of the - default button; pressing Return or Enter is the same as clicking - the default button. It defaults to 0 (the first button). \a - escapeButtonNumber is the index of the Escape button; pressing - Escape is the same as clicking this button. It defaults to -1; - supply 0, 1, or 2 to make pressing Escape equivalent to clicking - the relevant button. - - If \a parent is 0, the message box becomes an application-global - modal dialog box. If \a parent is a widget, the message box - becomes modal relative to \a parent. - - \sa information(), question(), warning() -*/ - -int TQMessageBox::critical( TQWidget *parent, const TQString &caption, - const TQString& text, - const TQString& button0Text, - const TQString& button1Text, - const TQString& button2Text, - int defaultButtonNumber, - int escapeButtonNumber ) -{ -#if defined(TQ_WS_X11) - if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) - return TQTDEIntegration::critical( parent, caption, text, - button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); -#endif - return textBox( parent, Critical, caption, text, - button0Text, button1Text, button2Text, - defaultButtonNumber, escapeButtonNumber ); -} - - -/*! - Displays a simple message box about TQt, with caption \a caption - and centered over \a parent (if \a parent is not 0). The message - includes the version number of TQt being used by the application. - - This is useful for inclusion in the Help menu of an application. - See the examples/menu/menu.cpp example. - - TQApplication provides this functionality as a slot. - - \sa TQApplication::aboutTQt() -*/ - -void TQMessageBox::aboutTQt( TQWidget *parent, const TQString &caption ) -{ - TQMessageBox *mb = new TQMessageBox( parent, "qt_msgbox_about_qt" ); - TQ_CHECK_PTR( mb ); - mb->setWFlags( WDestructiveClose ); - -#ifndef TQT_NO_WIDGET_TOPEXTRA - TQString c = caption; - if ( c.isNull() ) - c = tr( "About TQt" ); - mb->setCaption( c ); -#endif - mb->setText( *translatedTextAboutTQt ); -#ifndef TQT_NO_IMAGEIO - TQPixmap pm; - TQImage logo( (const char **)qtlogo_xpm); - if ( tqGray(mb->palette().active().text().rgb()) > - tqGray(mb->palette().active().base().rgb()) ) - { - // light on dark, adjust some colors (where's 10?) - logo.setColor( 0, 0xffffffff ); - logo.setColor( 1, 0xff666666 ); - logo.setColor( 2, 0xffcccc66 ); - logo.setColor( 4, 0xffcccccc ); - logo.setColor( 6, 0xffffff66 ); - logo.setColor( 7, 0xff999999 ); - logo.setColor( 8, 0xff3333ff ); - logo.setColor( 9, 0xffffff33 ); - logo.setColor( 11, 0xffcccc99 ); - } - if ( pm.convertFromImage( logo ) ) - mb->setIconPixmap( pm ); -#endif - mb->setButtonText( 0, tr("OK") ); - if ( mb->mbd && mb->mbd->pb[0] ) { - mb->mbd->pb[0]->setAutoDefault( TRUE ); - mb->mbd->pb[0]->setFocusPolicy( TQWidget::StrongFocus ); - mb->mbd->pb[0]->setDefault( TRUE ); - mb->mbd->pb[0]->setFocus(); - } - mb->exec(); -} - -/*! - \reimp -*/ - -void TQMessageBox::setIcon( const TQPixmap &pix ) -{ - //reimplemented to avoid compiler warning. -#ifndef TQT_NO_WIDGET_TOPEXTRA - TQDialog::setIcon( pix ); -#endif -} - - -/*! - \property TQMessageBox::textFormat - \brief the format of the text displayed by the message box - - The current text format used by the message box. See the \l - TQt::TextFormat enum for an explanation of the possible options. - - The default format is \c AutoText. - - \sa setText() -*/ - -TQt::TextFormat TQMessageBox::textFormat() const -{ - return label->textFormat(); -} - - -void TQMessageBox::setTextFormat( TQt::TextFormat format ) -{ - label->setTextFormat( format ); -} - - -#endif diff --git a/src/dialogs/qprintdialog.cpp b/src/dialogs/qprintdialog.cpp deleted file mode 100644 index 9096ff9f6..000000000 --- a/src/dialogs/qprintdialog.cpp +++ /dev/null @@ -1,1677 +0,0 @@ -/**************************************************************************** -** -** Implementation of internal print dialog (X11) used by TQPrinter::select(). -** -** Created : 950829 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the dialogs 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 "ntqprintdialog.h" - -#ifndef TQT_NO_PRINTDIALOG - -#include "tqfiledialog.h" -#include "tqfile.h" -#include "tqtextstream.h" -#include "tqcombobox.h" -#include "tqframe.h" -#include "tqlabel.h" -#include "tqlineedit.h" -#include "tqpushbutton.h" -#include "tqprinter.h" -#include "tqlistview.h" -#include "tqlayout.h" -#include "tqbuttongroup.h" -#include "tqradiobutton.h" -#include "tqspinbox.h" -#include "ntqapplication.h" -#include "tqheader.h" -#include "tqstyle.h" -#include "tqstring.h" -#include "tqregexp.h" -#if !defined(TQT_NO_CUPS) || !defined(TQT_NO_NIS) -#include "tqlibrary.h" -#endif - -#ifndef TQT_NO_NIS - -#ifndef BOOL_DEFINED -#define BOOL_DEFINED -#endif - -#include -#include - -// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. -#if defined(connect) -# undef connect -#endif - -#endif // TQT_NO_NIS - -// UNIX Large File Support redefines open -> open64 -#if defined(open) -# undef open -#endif - -#include -#include - - -class TQPrintDialogSpinBox : public TQSpinBox -{ -public: - TQPrintDialogSpinBox(int min, int max, int steps, TQWidget *parent, const char *name) - : TQSpinBox(min, max, steps, parent, name) - {} - - void interpretText() - { - TQSpinBox::interpretText(); - } -}; - - - - -enum { Success = 's', Unavail = 'u', NotFound = 'n', TryAgain = 't' }; -enum { Continue = 'c', Return = 'r' }; - -class TQPrintDialogPrivate -{ -public: - TQPrinter * printer; - - TQButtonGroup * printerOrFile; - - bool outputToFile; - TQListView * printers; - TQLineEdit * fileName; - TQPushButton * browse, *ok; - - TQButtonGroup * printRange; - TQLabel * firstPageLabel; - TQPrintDialogSpinBox * firstPage; - TQLabel * lastPageLabel; - TQPrintDialogSpinBox * lastPage; - TQRadioButton * printAllButton; - TQRadioButton * printRangeButton; - TQRadioButton * printSelectionButton; - TQRadioButton * printToFileButton; - TQComboBox *orientationCombo, *sizeCombo; - - TQPrinter::PageSize pageSize; - TQPrinter::Orientation orientation; - - TQButtonGroup * pageOrder; - TQPrinter::PageOrder pageOrder2; - - TQButtonGroup * colorMode; - TQPrinter::ColorMode colorMode2; - - TQPrintDialogSpinBox * copies; - int numCopies; - - TQBoxLayout *customLayout; - - TQPrinter::PageSize indexToPageSize[TQPrinter::NPageSize]; -}; - - -typedef void (*Q_PrintDialogHook)(TQListView *); -static Q_PrintDialogHook addPrinterHook = 0; - -void qt_set_printdialog_hook( Q_PrintDialogHook hook ) -{ - addPrinterHook = hook; -} - -static void isc( TQPrintDialogPrivate * d, const TQString & text, - TQPrinter::PageSize ps ); - -class TQPrinterListViewItem : public TQListViewItem -{ -public: - TQPrinterListViewItem( TQListView * printers, const TQString& name, - const TQString& host, const TQString& comment, - const TQStringList& aliases ) - : TQListViewItem( printers, name, host, comment ), ali( aliases ) { } - - bool samePrinter( const TQString& name ) { - return text( 0 ) == name || ali.find( name ) != ali.end(); - } - - TQStringList ali; -}; - -static void perhapsAddPrinter( TQListView * printers, const TQString &name, - TQString host, TQString comment, - TQStringList aliases = TQStringList() ) -{ - const TQListViewItem * i = printers->firstChild(); - while ( i && !((TQPrinterListViewItem *) i)->samePrinter(name) ) - i = i->nextSibling(); - if ( i ) - return; - if ( host.isEmpty() ) - host = TQPrintDialog::tr( "locally connected" ); - (void)new TQPrinterListViewItem( printers, - name.simplifyWhiteSpace(), - host.simplifyWhiteSpace(), - comment.simplifyWhiteSpace(), aliases ); -} - -static void parsePrinterDesc( TQString printerDesc, TQListView * printers ) -{ - if ( printerDesc.length() < 1 ) - return; - - printerDesc = printerDesc.simplifyWhiteSpace(); - int i = printerDesc.find( ':' ); - TQString printerName, printerComment, printerHost; - TQStringList aliases; - - if ( i >= 0 ) { - // have ':' want '|' - int j = printerDesc.find( '|' ); - if ( j > 0 && j < i ) { - printerName = printerDesc.left( j ); - aliases = TQStringList::split( '|', - printerDesc.mid(j + 1, i - j - 1) ); - // try extracting a comment from the aliases - printerComment = TQPrintDialog::tr( "Aliases: %1" ) - .arg( aliases.join(", ") ); - } else { - printerName = printerDesc.left( i ); - } - // look for lprng pseudo all printers entry - i = printerDesc.find( TQRegExp(TQString::fromLatin1(": *all *=")) ); - if ( i >= 0 ) - printerName = ""; - // look for signs of this being a remote printer - i = printerDesc.find( TQRegExp(TQString::fromLatin1(": *rm *=")) ); - if ( i >= 0 ) { - // point k at the end of remote host name - while ( printerDesc[i] != '=' ) - i++; - while ( printerDesc[i] == '=' || printerDesc[i].isSpace() ) - i++; - j = i; - while ( j < (int)printerDesc.length() && printerDesc[j] != ':' ) - j++; - - // and stuff that into the string - printerHost = printerDesc.mid( i, j - i ); - } - } - if ( printerName.length() ) - perhapsAddPrinter( printers, printerName, printerHost, printerComment, - aliases ); -} - -static int parsePrintcap( TQListView * printers, const TQString& fileName ) -{ - TQFile printcap( fileName ); - if ( !printcap.open( IO_ReadOnly ) ) - return NotFound; - - char * line_ascii = new char[1025]; - line_ascii[1024] = '\0'; - - TQString printerDesc; - bool atEnd = FALSE; - - while ( !atEnd ) { - if ( printcap.atEnd() || printcap.readLine( line_ascii, 1024 ) <= 0 ) - atEnd = TRUE; - TQString line = line_ascii; - line = line.stripWhiteSpace(); - if ( line.length() >= 1 && line[int(line.length()) - 1] == '\\' ) - line.truncate( line.length() - 1 ); - if ( line[0] == '#' ) { - if ( !atEnd ) - continue; - } else if ( line[0] == '|' || line[0] == ':' ) { - printerDesc += line; - if ( !atEnd ) - continue; - } - - parsePrinterDesc( printerDesc, printers ); - - // add the first line of the new printer definition - printerDesc = line; - } - delete[] line_ascii; - return Success; -} - - -// solaris, not 2.6 -static void parseEtcLpPrinters( TQListView * printers ) -{ - TQDir lp( TQString::fromLatin1("/etc/lp/printers") ); - const TQFileInfoList * dirs = lp.entryInfoList(); - if ( !dirs ) - return; - - TQFileInfoListIterator it( *dirs ); - TQFileInfo *printer; - TQString tmp; - while ( (printer = it.current()) != 0 ) { - ++it; - if ( printer->isDir() ) { - tmp.sprintf( "/etc/lp/printers/%s/configuration", - printer->fileName().ascii() ); - TQFile configuration( tmp ); - char * line = new char[1025]; - TQString remote( TQString::fromLatin1("Remote:") ); - TQString contentType( TQString::fromLatin1("Content types:") ); - TQString printerHost; - bool canPrintPostscript = FALSE; - if ( configuration.open( IO_ReadOnly ) ) { - while ( !configuration.atEnd() && - configuration.readLine( line, 1024 ) > 0 ) { - if ( TQString::fromLatin1(line).startsWith( remote ) ) { - const char * p = line; - while ( *p != ':' ) - p++; - p++; - while ( isspace((uchar) *p) ) - p++; - printerHost = TQString::fromLocal8Bit(p); - printerHost = printerHost.simplifyWhiteSpace(); - } else if ( TQString::fromLatin1(line).startsWith( contentType ) ) { - char * p = line; - while ( *p != ':' ) - p++; - p++; - char * e; - while ( *p ) { - while ( isspace((uchar) *p) ) - p++; - if ( *p ) { - char s; - e = p; - while ( isalnum((uchar) *e) ) - e++; - s = *e; - *e = '\0'; - if ( !qstrcmp( p, "postscript" ) || - !qstrcmp( p, "any" ) ) - canPrintPostscript = TRUE; - *e = s; - if ( s == ',' ) - e++; - p = e; - } - } - } - } - if ( canPrintPostscript ) - perhapsAddPrinter( printers, printer->fileName(), - printerHost, TQString::fromLatin1("") ); - } - delete[] line; - } - } -} - - -// solaris 2.6 -static char * parsePrintersConf( TQListView * printers, bool *found = 0 ) -{ - TQFile pc( TQString::fromLatin1("/etc/printers.conf") ); - if ( !pc.open( IO_ReadOnly ) ) { - if ( found ) - *found = FALSE; - return 0; - } - if ( found ) - *found = TRUE; - - char * line = new char[1025]; - line[1024] = '\0'; - - TQString printerDesc; - int lineLength = 0; - - char * defaultPrinter = 0; - - while ( !pc.atEnd() && - (lineLength=pc.readLine( line, 1024 )) > 0 ) { - if ( *line == '#' ) { - *line = '\0'; - lineLength = 0; - } - if ( lineLength >= 2 && line[lineLength-2] == '\\' ) { - line[lineLength-2] = '\0'; - printerDesc += TQString::fromLocal8Bit(line); - } else { - printerDesc += TQString::fromLocal8Bit(line); - printerDesc = printerDesc.simplifyWhiteSpace(); - int i = printerDesc.find( ':' ); - TQString printerName, printerHost, printerComment; - TQStringList aliases; - if ( i >= 0 ) { - // have : want | - int j = printerDesc.find( '|', 0 ); - if ( j >= i ) - j = -1; - printerName = printerDesc.mid( 0, j < 0 ? i : j ); - if ( printerName == TQString::fromLatin1("_default") ) { - i = printerDesc.find( - TQRegExp( TQString::fromLatin1(": *use *=") ) ); - while ( printerDesc[i] != '=' ) - i++; - while ( printerDesc[i] == '=' || printerDesc[i].isSpace() ) - i++; - j = i; - while ( j < (int)printerDesc.length() && - printerDesc[j] != ':' && printerDesc[j] != ',' ) - j++; - // that's our default printer - defaultPrinter = - tqstrdup( printerDesc.mid( i, j-i ).ascii() ); - printerName = ""; - printerDesc = ""; - } else if ( printerName == TQString::fromLatin1("_all") ) { - // skip it.. any other cases we want to skip? - printerName = ""; - printerDesc = ""; - } - - if ( j > 0 ) { - // try extracting a comment from the aliases - aliases = TQStringList::split( '|', - printerDesc.mid(j + 1, i - j - 1) ); - printerComment = TQPrintDialog::tr( "Aliases: %1" ) - .arg( aliases.join(", ") ); - } - // look for signs of this being a remote printer - i = printerDesc.find( - TQRegExp( TQString::fromLatin1(": *bsdaddr *=") ) ); - if ( i >= 0 ) { - // point k at the end of remote host name - while ( printerDesc[i] != '=' ) - i++; - while ( printerDesc[i] == '=' || printerDesc[i].isSpace() ) - i++; - j = i; - while ( j < (int)printerDesc.length() && - printerDesc[j] != ':' && printerDesc[j] != ',' ) - j++; - // and stuff that into the string - printerHost = printerDesc.mid( i, j-i ); - // maybe stick the remote printer name into the comment - if ( printerDesc[j] == ',' ) { - i = ++j; - while ( printerDesc[i].isSpace() ) - i++; - j = i; - while ( j < (int)printerDesc.length() && - printerDesc[j] != ':' && printerDesc[j] != ',' ) - j++; - if ( printerName != printerDesc.mid( i, j-i ) ) { - printerComment = - TQString::fromLatin1("Remote name: "); - printerComment += printerDesc.mid( i, j-i ); - } - } - } - } - if ( printerComment == ":" ) - printerComment = ""; // for cups - if ( printerName.length() ) - perhapsAddPrinter( printers, printerName, printerHost, - printerComment, aliases ); - // chop away the line, for processing the next one - printerDesc = ""; - } - } - delete[] line; - return defaultPrinter; -} - -#ifndef TQT_NO_NIS - -#if defined(Q_C_CALLBACKS) -extern "C" { -#endif - -static int foreach( int /* status */, char * /* key */, int /* keyLen */, - char * val, int valLen, char * data ) -{ - parsePrinterDesc( TQString::fromLatin1(val, valLen), (TQListView *) data ); - return 0; -} - -#if defined(Q_C_CALLBACKS) -} -#endif - -static int retrieveNisPrinters( TQListView * printers ) -{ - typedef int (*WildCast)( int, char *, int, char *, int, char * ); - char printersConfByname[] = "printers.conf.byname"; - char *domain; - int err; - - TQLibrary lib( "nsl" ); - typedef int (*ypGetDefaultDomain)(char **); - ypGetDefaultDomain _ypGetDefaultDomain = (ypGetDefaultDomain)lib.resolve( "yp_get_default_domain" ); - typedef int (*ypAll)(const char *, const char *, const struct ypall_callback *); - ypAll _ypAll = (ypAll)lib.resolve( "yp_all" ); - - if ( _ypGetDefaultDomain && _ypAll ) { - err = _ypGetDefaultDomain( &domain ); - if ( err == 0 ) { - ypall_callback cb; - // wild cast to support K&R-style system headers - (WildCast &) cb.foreach = (WildCast) foreach; - cb.data = (char *) printers; - err = _ypAll( domain, printersConfByname, &cb ); - } - if ( !err ) - return Success; - } - return Unavail; -} - -#endif // TQT_NO_NIS - -static char *parseNsswitchPrintersEntry( TQListView * printers, char *line ) -{ -#define skipSpaces() \ - while ( isspace((uchar) line[k]) ) \ - k++ - - char *defaultPrinter = 0; - bool stop = FALSE; - int lastStatus = NotFound; - - int k = 8; - skipSpaces(); - if ( line[k] != ':' ) - return 0; - k++; - - char *cp = strchr( line, '#' ); - if ( cp != 0 ) - *cp = '\0'; - - while ( line[k] != '\0' ) { - if ( isspace((uchar) line[k]) ) { - k++; - } else if ( line[k] == '[' ) { - k++; - skipSpaces(); - while ( line[k] != '\0' ) { - char status = tolower( line[k] ); - char action = '?'; - - while ( line[k] != '=' && line[k] != ']' && - line[k] != '\0' ) - k++; - if ( line[k] == '=' ) { - k++; - skipSpaces(); - action = tolower( line[k] ); - while ( line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != ']' ) - k++; - } else if ( line[k] == ']' ) { - k++; - break; - } - skipSpaces(); - - if ( lastStatus == status ) - stop = ( action == (char) Return ); - } - } else { - if ( stop ) - break; - - TQCString source; - while ( line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != '[' ) { - source += line[k]; - k++; - } - - if ( source == "user" ) { - lastStatus = parsePrintcap( printers, - TQDir::homeDirPath() + "/.printers" ); - } else if ( source == "files" ) { - bool found; - defaultPrinter = parsePrintersConf( printers, &found ); - if ( found ) - lastStatus = Success; -#ifndef TQT_NO_NIS - } else if ( source == "nis" ) { - lastStatus = retrieveNisPrinters( printers ); -#endif - } else { - // nisplus, dns, etc., are not implemented yet - lastStatus = NotFound; - } - stop = ( lastStatus == Success ); - } - } - return defaultPrinter; -} - -static char *parseNsswitchConf( TQListView * printers ) -{ - TQFile nc( TQString::fromLatin1("/etc/nsswitch.conf") ); - if ( !nc.open(IO_ReadOnly) ) - return 0; - - char *defaultPrinter = 0; - - char *line = new char[1025]; - line[1024] = '\0'; - - while ( !nc.atEnd() && - nc.readLine(line, 1024) > 0 ) { - if ( strncmp(line, "printers", 8) == 0 ) { - defaultPrinter = parseNsswitchPrintersEntry( printers, line ); - delete[] line; - return defaultPrinter; - } - } - - strcpy( line, "printers: user files nis nisplus xfn" ); - defaultPrinter = parseNsswitchPrintersEntry( printers, line ); - delete[] line; - return defaultPrinter; -} - -// HP-UX -static void parseEtcLpMember( TQListView * printers ) -{ - TQDir lp( TQString::fromLatin1("/etc/lp/member") ); - if ( !lp.exists() ) - return; - const TQFileInfoList * dirs = lp.entryInfoList(); - if ( !dirs ) - return; - - TQFileInfoListIterator it( *dirs ); - TQFileInfo *printer; - TQString tmp; - while ( (printer = it.current()) != 0 ) { - ++it; - // I haven't found any real documentation, so I'm guessing that - // since lpstat uses /etc/lp/member rather than one of the - // other directories, it's the one to use. I did not find a - // decent way to locate aliases and remote printers. - if ( printer->isFile() ) - perhapsAddPrinter( printers, printer->fileName(), - TQPrintDialog::tr("unknown"), - TQString::fromLatin1("") ); - } -} - -// IRIX 6.x -static void parseSpoolInterface( TQListView * printers ) -{ - TQDir lp( TQString::fromLatin1("/usr/spool/lp/interface") ); - if ( !lp.exists() ) - return; - const TQFileInfoList * files = lp.entryInfoList(); - if( !files ) - return; - - TQFileInfoListIterator it( *files ); - TQFileInfo *printer; - while ( (printer = it.current()) != 0) { - ++it; - - if ( !printer->isFile() ) - continue; - - // parse out some information - TQFile configFile( printer->filePath() ); - if ( !configFile.open( IO_ReadOnly ) ) - continue; - - TQCString line( 1025 ); - TQString namePrinter; - TQString hostName; - TQString hostPrinter; - TQString printerType; - - TQString nameKey( TQString::fromLatin1("NAME=") ); - TQString typeKey( TQString::fromLatin1("TYPE=") ); - TQString hostKey( TQString::fromLatin1("HOSTNAME=") ); - TQString hostPrinterKey( TQString::fromLatin1("HOSTPRINTER=") ); - - while ( !configFile.atEnd() && - (configFile.readLine(line.data(), 1024)) > 0 ) { - TQString uline = line; - if ( uline.startsWith( typeKey ) ) { - printerType = line.mid( nameKey.length() ); - printerType = printerType.simplifyWhiteSpace(); - } else if ( uline.startsWith( hostKey ) ) { - hostName = line.mid( hostKey.length() ); - hostName = hostName.simplifyWhiteSpace(); - } else if ( uline.startsWith( hostPrinterKey ) ) { - hostPrinter = line.mid( hostPrinterKey.length() ); - hostPrinter = hostPrinter.simplifyWhiteSpace(); - } else if ( uline.startsWith( nameKey ) ) { - namePrinter = line.mid( nameKey.length() ); - namePrinter = namePrinter.simplifyWhiteSpace(); - } - } - configFile.close(); - - printerType = printerType.stripWhiteSpace(); - if ( printerType.find("postscript", 0, FALSE) < 0 ) - continue; - - int ii = 0; - while ( (ii = namePrinter.find('"', ii)) >= 0 ) - namePrinter.remove( ii, 1 ); - - if ( hostName.isEmpty() || hostPrinter.isEmpty() ) { - perhapsAddPrinter( printers, printer->fileName(), - TQString::fromLatin1(""), namePrinter ); - } else { - TQString comment; - comment = namePrinter; - comment += " ("; - comment += hostPrinter; - comment += ")"; - perhapsAddPrinter( printers, printer->fileName(), - hostName, comment ); - } - } -} - - -// Every unix must have its own. It's a standard. Here is AIX. -static void parseQconfig( TQListView * printers ) -{ - TQFile qconfig( TQString::fromLatin1("/etc/qconfig") ); - if ( !qconfig.open( IO_ReadOnly ) ) - return; - - TQTextStream ts( &qconfig ); - TQString line; - - TQString stanzaName; // either a queue or a device name - bool up = TRUE; // queue up? default TRUE, can be FALSE - TQString remoteHost; // null if local - TQString deviceName; // null if remote - - TQRegExp newStanza( TQString::fromLatin1("^[0-z\\-]+:$") ); - - // our basic strategy here is to process each line, detecting new - // stanzas. each time we see a new stanza, we check if the - // previous stanza was a valid queue for a) a remote printer or b) - // a local printer. if it wasn't, we assume that what we see is - // the start of the first stanza, or that the previous stanza was - // a device stanza, or that there is some syntax error (we don't - // report those). - - do { - line = ts.readLine(); - bool indented = line[0].isSpace(); - line = line.simplifyWhiteSpace(); - - int i = line.find('='); - if ( indented && i != -1 ) { // line in stanza - TQString variable = line.left( i ).simplifyWhiteSpace(); - TQString value=line.mid( i+1, line.length() ).simplifyWhiteSpace(); - if ( variable == TQString::fromLatin1("device") ) - deviceName = value; - else if ( variable == TQString::fromLatin1("host") ) - remoteHost = value; - else if ( variable == TQString::fromLatin1("up") ) - up = !(value.lower() == TQString::fromLatin1("false")); - } else if ( line[0] == '*' ) { // comment - // nothing to do - } else if ( ts.atEnd() || // end of file, or beginning of new stanza - ( !indented && line.find( newStanza ) != -1 ) ) { - if ( up && stanzaName.length() > 0 && stanzaName.length() < 21 ) { - if ( remoteHost.length() ) // remote printer - perhapsAddPrinter( printers, stanzaName, remoteHost, - TQString::null ); - else if ( deviceName.length() ) // local printer - perhapsAddPrinter( printers, stanzaName, TQString::null, - TQString::null ); - } - line.truncate( line.length()-1 ); - if ( line.length() >= 1 && line.length() <= 20 ) - stanzaName = line; - up = TRUE; - remoteHost = TQString::null; - deviceName = TQString::null; - } else { - // syntax error? ignore. - } - } while ( !ts.atEnd() ); -} - - -#ifndef TQT_NO_CUPS -#include - -static char * parseCupsOutput( TQListView * printers ) -{ - char * defaultPrinter = 0; - int nd; - cups_dest_t * d; - TQLibrary lib( "cups" ); - typedef int (*CupsGetDests)(cups_dest_t **dests); - typedef void (*CupsFreeDests)(int num_dents, cups_dest_t *dests); - CupsGetDests _cupsGetDests = (CupsGetDests)lib.resolve( "cupsGetDests" ); - CupsFreeDests _cupsFreeDests = (CupsFreeDests)lib.resolve( "cupsFreeDests" ); - if ( _cupsGetDests ) { - nd = _cupsGetDests( &d ); - if ( nd < 1 ) - return 0; - - int n = 0; - while ( n < nd ) { - perhapsAddPrinter( printers, d[n].name, - TQPrintDialog::tr("Unknown Location"), 0 ); - if ( d[n].is_default && !defaultPrinter ) - defaultPrinter = tqstrdup( d[n].instance ); - n++; - } - if ( _cupsFreeDests ) { - _cupsFreeDests(nd, d); - } - } - return defaultPrinter; -} -#endif - -static TQPrintDialog * globalPrintDialog = 0; - -static void qpd_cleanup_globaldialog() -{ - if ( globalPrintDialog != 0 ) - delete globalPrintDialog; - globalPrintDialog = 0; -} - -/*! - \class TQPrintDialog ntqprintdialog.h - - \brief The TQPrintDialog class provides a dialog for specifying - the printer's configuration. - - \internal - - \warning The use of this class is not recommended since it is not - present on all platforms; use TQPrinter::setup() instead. - - \omit - - (ingroup dialogs) - - THIS DOCUMENTATION IS Not Revised. It must be revised before - becoming public API. - - It encompasses both the sort of details needed for doing a simple - print-out and some print configuration setup. - - The easiest way to use the class is through the static - function getPrinterSetup(). You can also subclass the TQPrintDialog - and add some custom buttons with addButton() to extend the - functionality of the print dialog. - -
- The printer dialog, on a large screen, in Motif style. -*/ - - -/*! Constructs a new modal printer dialog that configures \a prn and is a - child of \a parent named \a name. -*/ - -TQPrintDialog::TQPrintDialog( TQPrinter *prn, TQWidget *parent, const char *name ) - : TQDialog( parent, name, TRUE ) -{ - d = new TQPrintDialogPrivate; - d->numCopies = 1; - - TQBoxLayout * tll = new TQBoxLayout( this, TQBoxLayout::Down, 12, 0 ); - - // destination - TQGroupBox * g; - g = setupDestination(); - tll->addWidget( g, 1 ); - - tll->addSpacing( 12 ); - - // printer and paper settings - TQBoxLayout * lay = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( lay ); - - g = setupPrinterSettings(); - lay->addWidget( g, 1 ); - - lay->addSpacing( 12 ); - - g = setupPaper(); - lay->addWidget( g ); - - tll->addSpacing( 12 ); - - // options - g = setupOptions(); - tll->addWidget( g ); - tll->addSpacing( 12 ); - - TQBoxLayout *l = new TQBoxLayout( TQBoxLayout::LeftToRight ); - d->customLayout = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( l ); - l->addLayout( d->customLayout ); - l->addStretch(); - tll->addSpacing( 12 ); - - // buttons - TQBoxLayout *horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( horiz ); - - bool rightalign = - bool(style().styleHint(TQStyle::SH_PrintDialog_RightAlignButtons, this)); - - if (rightalign) - horiz->addStretch( 1 ); - - d->ok = new TQPushButton( this, "ok" ); - d->ok->setText( tr("OK") ); - d->ok->setDefault( TRUE ); - horiz->addWidget( d->ok ); - if (! rightalign) - horiz->addStretch( 1 ); - horiz->addSpacing( 6 ); - - TQPushButton * cancel = new TQPushButton( this, "cancel" ); - cancel->setText( tr("Cancel") ); - horiz->addWidget( cancel ); - - TQSize s1 = d->ok->sizeHint(); - TQSize s2 = cancel->sizeHint(); - s1 = TQSize( TQMAX(s1.width(), s2.width()), - TQMAX(s1.height(), s2.height()) ); - - d->ok->setFixedSize( s1 ); - cancel->setFixedSize( s1 ); - - tll->activate(); - - connect( d->ok, TQ_SIGNAL(clicked()), TQ_SLOT(okClicked()) ); - connect( cancel, TQ_SIGNAL(clicked()), TQ_SLOT(reject()) ); - - TQSize ms( minimumSize() ); - TQSize ss( TQApplication::desktop()->screenGeometry( pos() ).size() ); - if ( ms.height() < 512 && ss.height() >= 600 ) - ms.setHeight( 512 ); - else if ( ms.height() < 460 && ss.height() >= 480 ) - ms.setHeight( 460 ); - resize( ms ); - - setPrinter( prn, TRUE ); - d->printers->setFocus(); -} - - -/*! Destroys the object and frees any allocated resources. Does not - delete the associated TQPrinter object. -*/ - -TQPrintDialog::~TQPrintDialog() -{ - if ( this == globalPrintDialog ) - globalPrintDialog = 0; - delete d; -} - -/*! - This method allows you to specify a global print dialog, given in \a - pd, that will be used instead of the default dialog provided by TQt. - - This is useful, since there are many different printing systems on - Unix, and we cannot support all of them. Calling this method before - using a printer for the first time allows you to set up your own - print dialog. - - \sa setupPrinters() -*/ -void TQPrintDialog::setGlobalPrintDialog( TQPrintDialog *pd ) -{ - TQPrintDialog *oldPd = globalPrintDialog; - globalPrintDialog = pd; - if ( oldPd ) - delete oldPd; - else - tqAddPostRoutine( qpd_cleanup_globaldialog ); - globalPrintDialog->adjustSize(); -} - -TQGroupBox * TQPrintDialog::setupPrinterSettings() -{ - TQGroupBox * g = new TQGroupBox( 1, Horizontal, tr( "Printer settings"), - this, "settings group box" ); - - d->colorMode = new TQButtonGroup( this ); - d->colorMode->hide(); - connect( d->colorMode, TQ_SIGNAL(clicked(int)), - this, TQ_SLOT(colorModeSelected(int)) ); - - TQRadioButton *rb; - rb = new TQRadioButton( tr( "Print in color if available" ), - g, "color" ); - d->colorMode->insert( rb, TQPrinter::Color ); - rb->setChecked( TRUE ); - - rb = new TQRadioButton( tr("Print in grayscale"), - g, "graysacle" ); - d->colorMode->insert( rb, TQPrinter::GrayScale ); - - return g; -} - -TQGroupBox * TQPrintDialog::setupDestination() -{ - TQGroupBox * g = new TQGroupBox( 0, Horizontal, tr( "Print destination"), - this, "destination group box" ); - - TQBoxLayout * tll = new TQBoxLayout( g->layout(), TQBoxLayout::Down ); - - d->printerOrFile = new TQButtonGroup( this ); - d->printerOrFile->hide(); - connect( d->printerOrFile, TQ_SIGNAL(clicked(int)), - this, TQ_SLOT(printerOrFileSelected(int)) ); - - // printer radio button, list - TQRadioButton * rb = new TQRadioButton( tr( "Print to printer:" ), g, - "printer" ); - tll->addWidget( rb ); - d->printerOrFile->insert( rb, 0 ); - rb->setChecked( TRUE ); - d->outputToFile = FALSE; - - TQBoxLayout * horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( horiz, 3 ); - horiz->addSpacing( 19 ); - - d->printers = new TQListView( g, "list of printers" ); - d->printers->setAllColumnsShowFocus( TRUE ); - d->printers->addColumn( tr("Printer"), 125 ); - d->printers->addColumn( tr("Host"), 125 ); - d->printers->addColumn( tr("Comment"), 150 ); - -#if defined(Q_OS_UNIX) - char * etcLpDefault = 0; - -#ifndef TQT_NO_CUPS - etcLpDefault = parseCupsOutput( d->printers ); -#endif - if ( d->printers->childCount() == 0 ) { - // we only use other schemes when cups fails. - - parsePrintcap( d->printers, TQString::fromLatin1("/etc/printcap") ); - parseEtcLpMember( d->printers ); - parseSpoolInterface( d->printers ); - parseQconfig( d->printers ); - if ( addPrinterHook ) - (*addPrinterHook)( d->printers ); - - TQFileInfo f; - f.setFile( TQString::fromLatin1("/etc/lp/printers") ); - if ( f.isDir() ) { - parseEtcLpPrinters( d->printers ); - TQFile def( TQString::fromLatin1("/etc/lp/default") ); - if ( def.open( IO_ReadOnly ) ) { - if ( etcLpDefault ) - delete[] etcLpDefault; - etcLpDefault = new char[1025]; - def.readLine( etcLpDefault, 1024 ); - char * p = etcLpDefault; - while ( p && *p ) { - if ( !isprint((uchar) *p) || isspace((uchar) *p) ) - *p = 0; - else - p++; - } - } - } - - char * def = 0; - f.setFile( TQString::fromLatin1("/etc/nsswitch.conf") ); - if ( f.isFile() ) { - def = parseNsswitchConf( d->printers ); - } else { - f.setFile( TQString::fromLatin1("/etc/printers.conf") ); - if ( f.isFile() ) - def = parsePrintersConf( d->printers ); - } - - if ( def ) { - if ( etcLpDefault ) - delete[] etcLpDefault; - etcLpDefault = def; - } - } - - // all printers hopefully known. try to find a good default - TQString dollarPrinter; - { - const char * t = getenv( "PRINTER" ); - if ( !t || !*t ) - t = getenv( "LPDEST" ); - dollarPrinter = TQString::fromLatin1( t ); - if ( !dollarPrinter.isEmpty() ) - perhapsAddPrinter( d->printers, dollarPrinter, - TQPrintDialog::tr("unknown"), - TQString::fromLatin1("") ); - } - int quality = 0; - - // bang the best default into the listview - const TQListViewItem * lvi = d->printers->firstChild(); - d->printers->setCurrentItem( (TQListViewItem *)lvi ); - while ( lvi ) { - TQRegExp ps( TQString::fromLatin1("[^a-z]ps(?:[^a-z]|$)") ); - TQRegExp lp( TQString::fromLatin1("[^a-z]lp(?:[^a-z]|$)") ); - - if ( quality < 4 && lvi->text(0) == dollarPrinter ) { - d->printers->setCurrentItem( (TQListViewItem *)lvi ); - quality = 4; - } else if ( quality < 3 && etcLpDefault && - lvi->text(0) == TQString::fromLatin1(etcLpDefault) ) { - d->printers->setCurrentItem( (TQListViewItem *)lvi ); - quality = 3; - } else if ( quality < 2 && - ( lvi->text(0) == TQString::fromLatin1("ps") || - ps.search(lvi->text(2)) != -1 ) ) { - d->printers->setCurrentItem( (TQListViewItem *)lvi ); - quality = 2; - } else if ( quality < 1 && - ( lvi->text(0) == TQString::fromLatin1("lp") || - lp.search(lvi->text(2)) > -1 ) ) { - d->printers->setCurrentItem( (TQListViewItem *)lvi ); - quality = 1; - } - lvi = lvi->nextSibling(); - } - - if ( d->printers->currentItem() ) - d->printers->setSelected( d->printers->currentItem(), TRUE ); - - if ( etcLpDefault ) // Avoid purify complaint - delete[] etcLpDefault; -#endif - - int h = fontMetrics().height(); - if ( d->printers->firstChild() ) - h = d->printers->firstChild()->height(); - d->printers->setMinimumSize( d->printers->sizeHint().width(), - d->printers->header()->height() + - 3 * h ); - horiz->addWidget( d->printers, 3 ); - - tll->addSpacing( 6 ); - - // file radio button, edit/browse - d->printToFileButton = new TQRadioButton( tr( "Print to file:" ), g, "file" ); - tll->addWidget( d->printToFileButton ); - d->printerOrFile->insert( d->printToFileButton, 1 ); - - horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( horiz ); - horiz->addSpacing( 19 ); - - d->fileName = new TQLineEdit( g, "file name" ); - connect( d->fileName, TQ_SIGNAL( textChanged(const TQString&) ), - this, TQ_SLOT( fileNameEditChanged(const TQString&) ) ); - horiz->addWidget( d->fileName, 1 ); - horiz->addSpacing( 6 ); - d->browse = new TQPushButton( tr("Browse..."), g, "browse files" ); - d->browse->setAutoDefault( FALSE ); -#ifdef TQT_NO_FILEDIALOG - d->browse->setEnabled( FALSE ); -#endif - connect( d->browse, TQ_SIGNAL(clicked()), - this, TQ_SLOT(browseClicked()) ); - horiz->addWidget( d->browse ); - - d->fileName->setEnabled( FALSE ); - d->browse->setEnabled( FALSE ); - - tll->activate(); - - return g; -} - - -TQGroupBox * TQPrintDialog::setupOptions() -{ - TQGroupBox * g = new TQGroupBox( 0, Horizontal, tr( "Options"), - this, "options group box" ); - - TQBoxLayout * tll = new TQBoxLayout( g->layout(), TQBoxLayout::Down ); - - TQBoxLayout *lay = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( lay ); - - tll = new TQBoxLayout( lay, TQBoxLayout::Down ); - - d->printRange = new TQButtonGroup( this ); - d->printRange->hide(); - connect( d->printRange, TQ_SIGNAL(clicked(int)), - this, TQ_SLOT(printRangeSelected(int)) ); - - d->pageOrder = new TQButtonGroup( this ); - d->pageOrder->hide(); - connect( d->pageOrder, TQ_SIGNAL(clicked(int)), - this, TQ_SLOT(pageOrderSelected(int)) ); - - d->printAllButton = new TQRadioButton( tr("Print all"), g, "print all" ); - d->printRange->insert( d->printAllButton, 0 ); - tll->addWidget( d->printAllButton ); - - d->printSelectionButton = new TQRadioButton( tr("Print selection"), - g, "print selection" ); - d->printRange->insert( d->printSelectionButton, 1 ); - tll->addWidget( d->printSelectionButton ); - - d->printRangeButton = new TQRadioButton( tr("Print range"), - g, "print range" ); - d->printRange->insert( d->printRangeButton, 2 ); - tll->addWidget( d->printRangeButton ); - - TQBoxLayout * horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( horiz ); - - d->firstPageLabel = new TQLabel( tr("From page:"), g, "first page" ); - horiz->addSpacing( 19 ); - horiz->addWidget( d->firstPageLabel ); - - d->firstPage = new TQPrintDialogSpinBox( 1, 9999, 1, g, "first page" ); - d->firstPage->setValue( 1 ); - horiz->addWidget( d->firstPage, 1 ); - connect( d->firstPage, TQ_SIGNAL(valueChanged(int)), - this, TQ_SLOT(setFirstPage(int)) ); - - horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( horiz ); - - d->lastPageLabel = new TQLabel( tr("To page:"), g, "last page" ); - horiz->addSpacing( 19 ); - horiz->addWidget( d->lastPageLabel ); - - d->lastPage = new TQPrintDialogSpinBox( 1, 9999, 1, g, "last page" ); - d->lastPage->setValue( 9999 ); - horiz->addWidget( d->lastPage, 1 ); - connect( d->lastPage, TQ_SIGNAL(valueChanged(int)), - this, TQ_SLOT(setLastPage(int)) ); - - lay->addSpacing( 25 ); - tll = new TQBoxLayout( lay, TQBoxLayout::Down ); - - // print order - TQRadioButton * rb = new TQRadioButton( tr("Print first page first"), - g, "first page first" ); - tll->addWidget( rb ); - d->pageOrder->insert( rb, TQPrinter::FirstPageFirst ); - rb->setChecked( TRUE ); - - rb = new TQRadioButton( tr("Print last page first"), - g, "last page first" ); - tll->addWidget( rb ); - d->pageOrder->insert( rb, TQPrinter::LastPageFirst ); - - tll->addStretch(); - - // copies - - horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); - tll->addLayout( horiz ); - - TQLabel * l = new TQLabel( tr("Number of copies:"), g, "Number of copies" ); - horiz->addWidget( l ); - - d->copies = new TQPrintDialogSpinBox( 1, 99, 1, g, "copies" ); - d->copies->setValue( 1 ); - horiz->addWidget( d->copies, 1 ); - connect( d->copies, TQ_SIGNAL(valueChanged(int)), - this, TQ_SLOT(setNumCopies(int)) ); - - TQSize s = d->firstPageLabel->sizeHint() - .expandedTo( d->lastPageLabel->sizeHint() ) - .expandedTo( l->sizeHint() ); - d->firstPageLabel->setMinimumSize( s ); - d->lastPageLabel->setMinimumSize( s ); - l->setMinimumSize( s.width() + 19, s.height() ); - - tll->activate(); - - return g; -} - - -void isc( TQPrintDialogPrivate * d, - const TQString & text, - TQPrinter::PageSize ps ) -{ - if ( d && text && ps < TQPrinter::NPageSize ) { - d->sizeCombo->insertItem( text, -1 ); - int index = d->sizeCombo->count()-1; - if ( index >= 0 && index < TQPrinter::NPageSize ) - d->indexToPageSize[index] = ps; - } -} - -TQGroupBox * TQPrintDialog::setupPaper() -{ - TQGroupBox * g = new TQGroupBox( 1, Horizontal, tr( "Paper format"), - this, "Paper format" ); - d->pageSize = TQPrinter::A4; - - // page orientation - d->orientationCombo = new TQComboBox( FALSE, g ); - d->orientationCombo->insertItem( tr( "Portrait" ), -1 ); - d->orientationCombo->insertItem( tr( "Landscape" ), -1 ); - - d->orientation = TQPrinter::Portrait; - - g->addSpace( 8 ); - - connect( d->orientationCombo, TQ_SIGNAL( activated(int) ), - this, TQ_SLOT( orientSelected(int) ) ); - - // paper size - d->sizeCombo = new TQComboBox( FALSE, g ); - - int n; - for( n=0; nindexToPageSize[n] = TQPrinter::A4; - - isc( d, tr( "A0 (841 x 1189 mm)" ), TQPrinter::A0 ); - isc( d, tr( "A1 (594 x 841 mm)" ), TQPrinter::A1 ); - isc( d, tr( "A2 (420 x 594 mm)" ), TQPrinter::A2 ); - isc( d, tr( "A3 (297 x 420 mm)" ), TQPrinter::A3 ); - isc( d, tr( "A4 (210x297 mm, 8.26x11.7 inches)" ), TQPrinter::A4 ); - isc( d, tr( "A5 (148 x 210 mm)" ), TQPrinter::A5 ); - isc( d, tr( "A6 (105 x 148 mm)" ), TQPrinter::A6 ); - isc( d, tr( "A7 (74 x 105 mm)" ), TQPrinter::A7 ); - isc( d, tr( "A8 (52 x 74 mm)" ), TQPrinter::A8 ); - isc( d, tr( "A9 (37 x 52 mm)" ), TQPrinter::A9 ); - isc( d, tr( "B0 (1000 x 1414 mm)" ), TQPrinter::B0 ); - isc( d, tr( "B1 (707 x 1000 mm)" ), TQPrinter::B1 ); - isc( d, tr( "B2 (500 x 707 mm)" ), TQPrinter::B2 ); - isc( d, tr( "B3 (353 x 500 mm)" ), TQPrinter::B3 ); - isc( d, tr( "B4 (250 x 353 mm)" ), TQPrinter::B4 ); - isc( d, tr( "B5 (176 x 250 mm, 6.93x9.84 inches)" ), TQPrinter::B5 ); - isc( d, tr( "B6 (125 x 176 mm)" ), TQPrinter::B6 ); - isc( d, tr( "B7 (88 x 125 mm)" ), TQPrinter::B7 ); - isc( d, tr( "B8 (62 x 88 mm)" ), TQPrinter::B8 ); - isc( d, tr( "B9 (44 x 62 mm)" ), TQPrinter::B9 ); - isc( d, tr( "B10 (31 x 44 mm)" ), TQPrinter::B10 ); - isc( d, tr( "C5E (163 x 229 mm)" ), TQPrinter::C5E ); - isc( d, tr( "DLE (110 x 220 mm)" ), TQPrinter::DLE ); - isc( d, tr( "Executive (7.5x10 inches, 191x254 mm)" ), TQPrinter::Executive ); - isc( d, tr( "Folio (210 x 330 mm)" ), TQPrinter::Folio ); - isc( d, tr( "Ledger (432 x 279 mm)" ), TQPrinter::Ledger ); - isc( d, tr( "Legal (8.5x14 inches, 216x356 mm)" ), TQPrinter::Legal ); - isc( d, tr( "Letter (8.5x11 inches, 216x279 mm)" ), TQPrinter::Letter ); - isc( d, tr( "Tabloid (279 x 432 mm)" ), TQPrinter::Tabloid ); - isc( d, tr( "US Common #10 Envelope (105 x 241 mm)" ), TQPrinter::Comm10E ); - - connect( d->sizeCombo, TQ_SIGNAL( activated(int) ), - this, TQ_SLOT( paperSizeSelected(int) ) ); - - return g; -} - - -/*! - Display a dialog and allow the user to configure the TQPrinter \a - p for an optional widget \a w. Returns TRUE if the user clicks OK or - presses Enter, FALSE if the user clicks Cancel or presses Esc. - - getPrinterSetup() remembers the settings and provides the same - settings the next time the dialog is shown. -*/ - -bool TQPrintDialog::getPrinterSetup( TQPrinter * p, TQWidget* w ) -{ - if ( !globalPrintDialog ) { - globalPrintDialog = new TQPrintDialog( 0, 0, "global print dialog" ); -#ifndef TQT_NO_WIDGET_TOPEXTRA - globalPrintDialog->setCaption( TQPrintDialog::tr( "Setup Printer" ) ); -#endif - tqAddPostRoutine( qpd_cleanup_globaldialog ); - globalPrintDialog->setPrinter( p, TRUE ); - globalPrintDialog->adjustSize(); - } else { - globalPrintDialog->setPrinter( p, TRUE ); - } - globalPrintDialog->adjustPosition( w ); - #ifndef TQT_NO_WIDGET_TOPEXTRA - if ( w ) { - const TQPixmap *pm = w->icon(); - if ( pm && !pm->isNull() ) - globalPrintDialog->setIcon( *pm ); - else { - w = w ? w->topLevelWidget() : 0; - pm = w ? w->icon() : 0; - if ( pm && !pm->isNull() ) - globalPrintDialog->setIcon( *pm ); - } - } -#endif - bool r = globalPrintDialog->exec() == TQDialog::Accepted; - globalPrintDialog->setPrinter( 0 ); - return r; -} - - -void TQPrintDialog::printerOrFileSelected( int id ) -{ - d->outputToFile = id ? TRUE : FALSE; - if ( d->outputToFile ) { - d->ok->setEnabled( TRUE ); - fileNameEditChanged( d->fileName->text() ); - if ( !d->fileName->edited() && d->fileName->text().isEmpty() ) { - TQString home = TQString::fromLatin1( ::getenv( "HOME" ) ); - TQString cur = TQDir::currentDirPath(); - if ( home.at(home.length()-1) != '/' ) - home += '/'; - if ( cur.at(cur.length()-1) != '/' ) - cur += '/'; - if ( cur.left( home.length() ) != home ) - cur = home; -#ifdef TQ_WS_X11 - cur += "print.ps"; -#endif - d->fileName->setText( cur ); - d->fileName->setCursorPosition( cur.length() ); - d->fileName->selectAll(); - } - d->browse->setEnabled( TRUE ); - d->fileName->setEnabled( TRUE ); - d->fileName->setFocus(); - d->printers->setEnabled( FALSE ); - } else { - d->ok->setEnabled( d->printers->childCount() != 0 ); - d->printers->setEnabled( TRUE ); - if ( d->fileName->hasFocus() || d->browse->hasFocus() ) - d->printers->setFocus(); - d->browse->setEnabled( FALSE ); - d->fileName->setEnabled( FALSE ); - } -} - - -void TQPrintDialog::landscapeSelected( int id ) -{ - d->orientation = (TQPrinter::Orientation)id; -} - - -void TQPrintDialog::paperSizeSelected( int id ) -{ - if ( id < TQPrinter::NPageSize ) - d->pageSize = TQPrinter::PageSize( d->indexToPageSize[id] ); -} - - -void TQPrintDialog::orientSelected( int id ) -{ - d->orientation = (TQPrinter::Orientation)id; -} - - -void TQPrintDialog::pageOrderSelected( int id ) -{ - d->pageOrder2 = (TQPrinter::PageOrder)id; -} - - -void TQPrintDialog::setNumCopies( int copies ) -{ - d->numCopies = copies; -} - - -void TQPrintDialog::browseClicked() -{ -#ifndef TQT_NO_FILEDIALOG - TQString fn = TQFileDialog::getSaveFileName( d->fileName->text(), tr( "PostScript Files (*.ps);;All Files (*)" ), this ); - if ( !fn.isNull() ) - d->fileName->setText( fn ); -#endif -} - - -void TQPrintDialog::okClicked() -{ - d->lastPage->interpretText(); - d->firstPage->interpretText(); - d->copies->interpretText(); - if ( d->outputToFile ) { - d->printer->setOutputToFile( TRUE ); - d->printer->setOutputFileName( d->fileName->text() ); - } else { - d->printer->setOutputToFile( FALSE ); - TQListViewItem * l = d->printers->currentItem(); - if ( l ) - d->printer->setPrinterName( l->text( 0 ) ); - } - - d->printer->setOrientation( d->orientation ); - d->printer->setPageSize( d->pageSize ); - d->printer->setPageOrder( d->pageOrder2 ); - d->printer->setColorMode( d->colorMode2 ); - d->printer->setNumCopies( d->numCopies ); - if ( d->printAllButton->isChecked() ) { - d->printer->setPrintRange(TQPrinter::AllPages); - d->printer->setFromTo( d->printer->minPage(), d->printer->maxPage() ); - } else { - if (d->printSelectionButton->isChecked()) - d->printer->setPrintRange(TQPrinter::Selection); - else - d->printer->setPrintRange(TQPrinter::PageRange); - d->printer->setFromTo( d->firstPage->value(), d->lastPage->value() ); - } - - accept(); -} - - -void TQPrintDialog::printRangeSelected( int id ) -{ - bool enable = id == 2 ? TRUE : FALSE; - d->firstPage->setEnabled( enable ); - d->lastPage->setEnabled( enable ); - d->firstPageLabel->setEnabled( enable ); - d->lastPageLabel->setEnabled( enable ); -} - - -void TQPrintDialog::setFirstPage( int fp ) -{ - if ( d->printer ) - d->lastPage->setRange( fp, TQMAX(fp, TQPrintDialog::d->printer->maxPage()) ); -} - - -void TQPrintDialog::setLastPage( int lp ) -{ - if ( d->printer ) - d->firstPage->setRange( TQMIN(lp, TQPrintDialog::d->printer->minPage()), lp ); -} - - -/*! - Sets this dialog to configure printer \a p, or no printer if \a p - is null. If \a pickUpSettings is TRUE, the dialog reads most of - its settings from \a p. If \a pickUpSettings is FALSE (the - default) the dialog keeps its old settings. -*/ - -void TQPrintDialog::setPrinter( TQPrinter * p, bool pickUpSettings ) -{ - d->printer = p; - - if ( p && pickUpSettings ) { - // top to botton in the old dialog. - // printer or file - d->printerOrFile->setButton( p->outputToFile() ); - printerOrFileSelected( p->outputToFile() ); - - // printer name - if ( !!p->printerName() ) { - TQListViewItem * i = d->printers->firstChild(); - while ( i && i->text( 0 ) != p->printerName() ) - i = i->nextSibling(); - if ( i ) { - d->printers->setSelected( i, TRUE ); - d->ok->setEnabled( TRUE ); - } else if ( d->fileName->text().isEmpty() ) { - d->ok->setEnabled( d->printers->childCount() != 0 ); - } - } - - // print command does not exist any more - - // file name - d->printToFileButton->setEnabled( d->printer->isOptionEnabled( TQPrinter::PrintToFile ) ); - d->fileName->setText( p->outputFileName() ); - - // orientation - d->orientationCombo->setCurrentItem( (int)p->orientation() ); - orientSelected( p->orientation() ); - - // page size - int n = 0; - while ( n < TQPrinter::NPageSize && - d->indexToPageSize[n] != p->pageSize() ) - n++; - d->sizeCombo->setCurrentItem( n ); - paperSizeSelected( n ); - - // New stuff (Options) - - // page order - d->pageOrder->setButton( (int)p->pageOrder() ); - pageOrderSelected( p->pageOrder() ); - - // color mode - d->colorMode->setButton( (int)p->colorMode() ); - colorModeSelected( p->colorMode() ); - - // number of copies - d->copies->setValue( p->numCopies() ); - setNumCopies( p->numCopies() ); - } - - if( p ) { - d->printAllButton->setEnabled( TRUE ); - d->printSelectionButton - ->setEnabled( d->printer->isOptionEnabled( TQPrinter::PrintSelection ) ); - d->printRangeButton - ->setEnabled( d->printer->isOptionEnabled( TQPrinter::PrintPageRange ) ); - - TQPrinter::PrintRange range = p->printRange(); - switch ( range ) { - case TQPrinter::AllPages: - d->printAllButton->setChecked(TRUE); - printRangeSelected( d->printRange->id( d->printAllButton ) ); - break; - case TQPrinter::Selection: - d->printSelectionButton->setChecked(TRUE); - printRangeSelected( d->printRange->id( d->printSelectionButton ) ); - break; - case TQPrinter::PageRange: - d->printRangeButton->setChecked(TRUE); - printRangeSelected( d->printRange->id( d->printRangeButton ) ); - break; - } - } - - if ( p && p->maxPage() ) { - d->firstPage->setRange( p->minPage(), p->maxPage() ); - d->lastPage->setRange( p->minPage(), p->maxPage() ); - if ( p->fromPage() || p->toPage() ) { - setFirstPage( p->fromPage() ); - setLastPage( p->toPage() ); - d->firstPage->setValue(p->fromPage()); - d->lastPage->setValue(p->toPage()); - } - } -} - - -/*! Returns a pointer to the printer this dialog configures, or 0 if - this dialog does not operate on any printer. */ - -TQPrinter * TQPrintDialog::printer() const -{ - return d->printer; -} - - -void TQPrintDialog::colorModeSelected( int id ) -{ - d->colorMode2 = (TQPrinter::ColorMode)id; -} - -/*! - Adds the button \a but to the layout of the print dialog. The added - buttons are arranged from the left to the right below the - last groupbox of the printdialog. -*/ - -void TQPrintDialog::addButton( TQPushButton *but ) -{ - d->customLayout->addWidget( but ); -} - -void TQPrintDialog::fileNameEditChanged( const TQString &text ) -{ - if ( d->fileName->isEnabled() ) - d->ok->setEnabled( !text.isEmpty() ); -} - -#endif diff --git a/src/dialogs/qt_dialogs.pri b/src/dialogs/qt_dialogs.pri index 9702afad1..555633b88 100644 --- a/src/dialogs/qt_dialogs.pri +++ b/src/dialogs/qt_dialogs.pri @@ -8,7 +8,7 @@ dialogs { $$DIALOGS_H/tqerrormessage.h \ $$DIALOGS_H/tqfiledialog.h \ $$DIALOGS_H/tqfontdialog.h \ - $$DIALOGS_H/ntqmessagebox.h \ + $$DIALOGS_H/tqmessagebox.h \ $$DIALOGS_H/tqprogressdialog.h \ $$DIALOGS_H/tqtabdialog.h \ $$DIALOGS_H/tqwizard.h \ @@ -16,15 +16,15 @@ dialogs { !embedded:mac:SOURCES += $$DIALOGS_CPP/tqfiledialog_mac.cpp $$DIALOGS_CPP/tqcolordialog_mac.cpp win32:SOURCES += $$DIALOGS_CPP/tqfiledialog_win.cpp - unix:SOURCES += $$DIALOGS_CPP/qprintdialog.cpp - unix:HEADERS += $$DIALOGS_H/ntqprintdialog.h + unix:SOURCES += $$DIALOGS_CPP/tqprintdialog.cpp + unix:HEADERS += $$DIALOGS_H/tqprintdialog.h SOURCES += $$DIALOGS_CPP/tqcolordialog.cpp \ $$DIALOGS_CPP/tqdialog.cpp \ $$DIALOGS_CPP/tqerrormessage.cpp \ $$DIALOGS_CPP/tqfiledialog.cpp \ $$DIALOGS_CPP/tqfontdialog.cpp \ - $$DIALOGS_CPP/qmessagebox.cpp \ + $$DIALOGS_CPP/tqmessagebox.cpp \ $$DIALOGS_CPP/tqprogressdialog.cpp \ $$DIALOGS_CPP/tqtabdialog.cpp \ $$DIALOGS_CPP/tqwizard.cpp \ diff --git a/src/dialogs/tqdialog.cpp b/src/dialogs/tqdialog.cpp index 1f620cb6a..42853e00a 100644 --- a/src/dialogs/tqdialog.cpp +++ b/src/dialogs/tqdialog.cpp @@ -344,8 +344,8 @@ void TQDialog::hideDefault() Hides special buttons which are rather shown in the titlebar on WinCE, to conserve screen space. */ -# include "ntqmessagebox.h" -extern const char * mb_texts[]; // Defined in qmessagebox.cpp +# include "tqmessagebox.h" +extern const char * mb_texts[]; // Defined in tqmessagebox.cpp void TQDialog::hideSpecial() { // "OK" buttons are hidden, and (Ok) shown on titlebar diff --git a/src/dialogs/tqerrormessage.cpp b/src/dialogs/tqerrormessage.cpp index 2caa09498..f99db2c7a 100644 --- a/src/dialogs/tqerrormessage.cpp +++ b/src/dialogs/tqerrormessage.cpp @@ -47,7 +47,7 @@ #include "tqdict.h" #include "tqlabel.h" #include "tqlayout.h" -#include "ntqmessagebox.h" +#include "tqmessagebox.h" #include "tqpushbutton.h" #include "tqstringlist.h" #include "tqstylesheet.h" diff --git a/src/dialogs/tqfiledialog.cpp b/src/dialogs/tqfiledialog.cpp index 77de59b62..9937f69a7 100644 --- a/src/dialogs/tqfiledialog.cpp +++ b/src/dialogs/tqfiledialog.cpp @@ -75,7 +75,7 @@ #include "tqlistbox.h" #include "tqlistview.h" #include "tqmap.h" -#include "ntqmessagebox.h" +#include "tqmessagebox.h" #include "tqmime.h" #include "tqnetworkprotocol.h" #include "tqobjectlist.h" diff --git a/src/dialogs/tqmessagebox.cpp b/src/dialogs/tqmessagebox.cpp new file mode 100644 index 000000000..2a7178260 --- /dev/null +++ b/src/dialogs/tqmessagebox.cpp @@ -0,0 +1,1664 @@ +/**************************************************************************** +** +** Implementation of TQMessageBox class +** +** Created : 950503 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs 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 "tqmessagebox.h" + +#ifndef TQT_NO_MESSAGEBOX + +#include "tqaccel.h" +#include "tqlabel.h" +#include "tqpushbutton.h" +#include "tqimage.h" +#include "ntqapplication.h" +#include "tqstyle.h" +#include "tqobjectlist.h" +#if defined(QT_ACCESSIBILITY_SUPPORT) +#include "tqaccessible.h" +#endif + +#ifdef TQ_WS_X11 +#include "private/tqttdeintegration_x11_p.h" +#endif + +extern bool tqt_use_native_dialogs; + +// Internal class - don't touch + +class TQMessageBoxLabel : public TQLabel +{ + TQ_OBJECT +public: + TQMessageBoxLabel( TQWidget* parent ) : TQLabel( parent, "messageBoxText") + { + setAlignment( AlignAuto|ExpandTabs ); + } +}; +#include "tqmessagebox.moc" + + + +// the TQt logo, for aboutTQt +/* XPM */ +static const char * const qtlogo_xpm[] = { +/* width height ncolors chars_per_pixel */ +"50 50 17 1", +/* colors */ +" c #000000", +". c #495808", +"X c #2A3304", +"o c #242B04", +"O c #030401", +"+ c #9EC011", +"@ c #93B310", +"# c #748E0C", +"$ c #A2C511", +"% c #8BA90E", +"& c #99BA10", +"* c #060701", +"= c #181D02", +"- c #212804", +"; c #61770A", +": c #0B0D01", +"/ c None", +/* pixels */ +"/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$+++$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$@;.o=::=o.;@$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$+#X* **X#+$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$#oO* O **o#+$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$&.* OO O*.&$$$$$$$$$$$$$", +"$$$$$$$$$$$$@XOO * OO X&$$$$$$$$$$$$", +"$$$$$$$$$$$@XO OO O **:::OOO OOO X@$$$$$$$$$$$", +"$$$$$$$$$$&XO O-;#@++@%.oOO X&$$$$$$$$$$", +"$$$$$$$$$$.O : *-#+$$$$$$$$+#- : O O*.$$$$$$$$$$", +"$$$$$$$$$#*OO O*.&$$$$$$$$$$$$+.OOOO **#$$$$$$$$$", +"$$$$$$$$+-OO O *;$$$$$$$$$$$&$$$$;* o+$$$$$$$$", +"$$$$$$$$#O* O .+$$$$$$$$$$@X;$$$+.O *#$$$$$$$$", +"$$$$$$$$X* -&$$$$$$$$$$@- :;$$$&- OX$$$$$$$$", +"$$$$$$$@*O *O#$$$$$$$$$$@oOO**;$$$# O*%$$$$$$$", +"$$$$$$$; -+$$$$$$$$$@o O OO ;+$$-O *;$$$$$$$", +"$$$$$$$. ;$$$$$$$$$@-OO OO X&$$;O .$$$$$$$", +"$$$$$$$o *#$$$$$$$$@o O O O-@$$$#O *o$$$$$$$", +"$$$$$$+= *@$$$$$$$@o* OO -@$$$$&: =$$$$$$$", +"$$$$$$+: :+$$$$$$@- *-@$$$$$$: :+$$$$$$", +"$$$$$$+: :+$$$$$@o* O *-@$$$$$$: :+$$$$$$", +"$$$$$$$= :@$$$$@o*OOO -@$$$$@: =+$$$$$$", +"$$$$$$$- O%$$$@o* O O O O-@$$$#* OX$$$$$$$", +"$$$$$$$. O *O;$$&o O*O* *O -@$$; O.$$$$$$$", +"$$$$$$$;* Oo+$$;O*O:OO-- Oo@+= *;$$$$$$$", +"$$$$$$$@* O O#$$$;*OOOo@@-O Oo;O* **@$$$$$$$", +"$$$$$$$$X* OOO-+$$$;O o@$$@- O O OX$$$$$$$$", +"$$$$$$$$#* * O.$$$$;X@$$$$@-O O O#$$$$$$$$", +"$$$$$$$$+oO O OO.+$$+&$$$$$$@-O o+$$$$$$$$", +"$$$$$$$$$#* **.&$$$$$$$$$$@o OO:#$$$$$$$$$", +"$$$$$$$$$+. O* O-#+$$$$$$$$+;O OOO:@$$$$$$$$$", +"$$$$$$$$$$&X *O -;#@++@#;=O O -@$$$$$$$$", +"$$$$$$$$$$$&X O O*O::::O OO Oo@$$$$$$$", +"$$$$$$$$$$$$@XOO OO O*X+$$$$$$", +"$$$$$$$$$$$$$&.* ** O :: *:#$$$$$$$", +"$$$$$$$$$$$$$$$#o*OO O Oo#@-OOO=#$$$$$$$$", +"$$$$$$$$$$$$$$$$+#X:* * O**X#+$$@-*:#$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$%;.o=::=o.#@$$$$$$@X#$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$+++$$$$$$$$$$$+$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", +"/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/", +}; + + +/*! + \class TQMessageBox + \brief The TQMessageBox class provides a modal dialog with a short message, an icon, and some buttons. + \ingroup dialogs + \mainclass + + Message boxes are used to provide informative messages and to ask + simple questions. + + TQMessageBox provides a range of different messages, arranged + roughly along two axes: severity and complexity. + + Severity is + \table + \row + \i \img tqmessagebox-quest.png + \i Question + \i For message boxes that ask a question as part of normal + operation. Some style guides recommend using Information for this + purpose. + \row + \i \img tqmessagebox-info.png + \i Information + \i For message boxes that are part of normal operation. + \row + \i \img tqmessagebox-warn.png + \i Warning + \i For message boxes that tell the user about unusual errors. + \row + \i \img tqmessagebox-crit.png + \i Critical + \i For message boxes that tell the user about critical errors. + \endtable + + The message box has a different icon for each of the severity levels. + + Complexity is one button (OK) for simple messages, or two or even + three buttons for questions. + + There are static functions for the most common cases. + + Examples: + + If a program is unable to find a supporting file, but can do perfectly + well without it: + + \code + TQMessageBox::information( this, "Application name", + "Unable to find the user preferences file.\n" + "The factory default will be used instead." ); + \endcode + + question() is useful for simple yes/no questions: + + \code + if ( TQFile::exists( filename ) && + TQMessageBox::question( + this, + tr("Overwrite File? -- Application Name"), + tr("A file called %1 already exists." + "Do you want to overwrite it?") + .arg( filename ), + tr("&Yes"), tr("&No"), + TQString::null, 0, 1 ) ) + return false; + \endcode + + warning() can be used to tell the user about unusual errors, or + errors which can't be easily fixed: + + \code + switch( TQMessageBox::warning( this, "Application name", + "Could not connect to the server.\n" + "This program can't function correctly " + "without the server.\n\n", + "Retry", + "Quit", 0, 0, 1 ) ) { + case 0: // The user clicked the Retry again button or pressed Enter + // try again + break; + case 1: // The user clicked the Quit or pressed Escape + // exit + break; + } + \endcode + + The text part of all message box messages can be either rich text + or plain text. If you specify a rich text formatted string, it + will be rendered using the default stylesheet. See + TQStyleSheet::defaultSheet() for details. With certain strings that + contain XML meta characters, the auto-rich text detection may + fail, interpreting plain text incorrectly as rich text. In these + rare cases, use TQStyleSheet::convertFromPlainText() to convert + your plain text string to a visually equivalent rich text string + or set the text format explicitly with setTextFormat(). + + Note that the Microsoft Windows User Interface Guidelines + recommend using the application name as the window's caption. + + Below are more examples of how to use the static member functions. + After these examples you will find an overview of the non-static + member functions. + + Exiting a program is part of its normal operation. If there is + unsaved data the user probably should be asked if they want to + save the data. For example: + + \code + switch( TQMessageBox::information( this, "Application name here", + "The document contains unsaved changes\n" + "Do you want to save the changes before exiting?", + "&Save", "&Discard", "Cancel", + 0, // Enter == button 0 + 2 ) ) { // Escape == button 2 + case 0: // Save clicked or Alt+S pressed or Enter pressed. + // save + break; + case 1: // Discard clicked or Alt+D pressed + // don't save but exit + break; + case 2: // Cancel clicked or Escape pressed + // don't exit + break; + } + \endcode + + The Escape button cancels the entire exit operation, and pressing + Enter causes the changes to be saved before the exit occurs. + + Disk full errors are unusual and they certainly can be hard to + correct. This example uses predefined buttons instead of + hard-coded button texts: + + \code + switch( TQMessageBox::warning( this, "Application name here", + "Could not save the user preferences,\n" + "because the disk is full. You can delete\n" + "some files and press Retry, or you can\n" + "abort the Save Preferences operation.", + TQMessageBox::Retry | TQMessageBox::Default, + TQMessageBox::Abort | TQMessageBox::Escape )) { + case TQMessageBox::Retry: // Retry clicked or Enter pressed + // try again + break; + case TQMessageBox::Abort: // Abort clicked or Escape pressed + // abort + break; + } + \endcode + + The critical() function should be reserved for critical errors. In + this example errorDetails is a TQString or const char*, and TQString + is used to concatenate several strings: + + \code + TQMessageBox::critical( 0, "Application name here", + TQString("An internal error occurred. Please ") + + "call technical support at 1234-56789 and report\n"+ + "these numbers:\n\n" + errorDetails + + "\n\nApplication will now exit." ); + \endcode + + In this example an OK button is displayed. + + TQMessageBox provides a very simple About box which displays an + appropriate icon and the string you provide: + + \code + TQMessageBox::about( this, "About ", + " is a \n\n" + "Copyright 1991-2003 Such-and-such. " + "\n\n" + "For technical support, call 1234-56789 or see\n" + "http://www.such-and-such.com/Application/\n" ); + \endcode + + See about() for more information. + + If you want your users to know that the application is built using + TQt (so they know that you use high quality tools) you might like + to add an "About TQt" menu option under the Help menu to invoke + aboutTQt(). + + If none of the standard message boxes is suitable, you can create a + TQMessageBox from scratch and use custom button texts: + + \code + TQMessageBox mb( "Application name here", + "Saving the file will overwrite the original file on the disk.\n" + "Do you really want to save?", + TQMessageBox::Information, + TQMessageBox::Yes | TQMessageBox::Default, + TQMessageBox::No, + TQMessageBox::Cancel | TQMessageBox::Escape ); + mb.setButtonText( TQMessageBox::Yes, "Save" ); + mb.setButtonText( TQMessageBox::No, "Discard" ); + switch( mb.exec() ) { + case TQMessageBox::Yes: + // save and exit + break; + case TQMessageBox::No: + // exit without saving + break; + case TQMessageBox::Cancel: + // don't save and don't exit + break; + } + \endcode + + TQMessageBox defines two enum types: Icon and an unnamed button type. + Icon defines the \c Question, \c Information, \c Warning, and \c + Critical icons for each GUI style. It is used by the constructor + and by the static member functions question(), information(), + warning() and critical(). A function called standardIcon() gives + you access to the various icons. + + The button types are: + \list + \i Ok - the default for single-button message boxes + \i Cancel - note that this is \e not automatically Escape + \i Yes + \i No + \i Abort + \i Retry + \i Ignore + \i YesAll + \i NoAll + \endlist + + Button types can be combined with two modifiers by using OR, '|': + \list + \i Default - makes pressing Enter equivalent to + clicking this button. Normally used with Ok, Yes or similar. + \i Escape - makes pressing Escape equivalent to clicking this button. + Normally used with Abort, Cancel or similar. + \endlist + + The text(), icon() and iconPixmap() functions provide access to the + current text and pixmap of the message box. The setText(), setIcon() + and setIconPixmap() let you change it. The difference between + setIcon() and setIconPixmap() is that the former accepts a + TQMessageBox::Icon and can be used to set standard icons, whereas the + latter accepts a TQPixmap and can be used to set custom icons. + + setButtonText() and buttonText() provide access to the buttons. + + TQMessageBox has no signals or slots. + + + + \sa TQDialog, + \link http://www.iarchitect.com/errormsg.htm + Isys on error messages \endlink, + \link guibooks.html#fowler GUI Design Handbook: Message Box \endlink +*/ + + +/*! + \enum TQMessageBox::Icon + + This enum has the following values: + + \value NoIcon the message box does not have any icon. + + \value Question an icon indicating that + the message is asking a question. + + \value Information an icon indicating that + the message is nothing out of the ordinary. + + \value Warning an icon indicating that the + message is a warning, but can be dealt with. + + \value Critical an icon indicating that + the message represents a critical problem. + +*/ + + +struct TQMessageBoxData { + TQMessageBoxData(TQMessageBox* parent) : + iconLabel( parent, "icon" ) + { + } + + int numButtons; // number of buttons + TQMessageBox::Icon icon; // message box icon + TQLabel iconLabel; // label holding any icon + int button[3]; // button types + int defButton; // default button (index) + int escButton; // escape button (index) + TQSize buttonSize; // button size + TQPushButton *pb[3]; // buttons +}; + +static const int LastButton = TQMessageBox::NoAll; + +/* + NOTE: The table of button texts correspond to the button enum. +*/ + +#ifndef Q_OS_TEMP +static const char * const mb_texts[] = { +#else +const char * mb_texts[] = { +#endif + 0, + TQT_TRANSLATE_NOOP("TQMessageBox","OK"), + TQT_TRANSLATE_NOOP("TQMessageBox","Cancel"), + TQT_TRANSLATE_NOOP("TQMessageBox","&Yes"), + TQT_TRANSLATE_NOOP("TQMessageBox","&No"), + TQT_TRANSLATE_NOOP("TQMessageBox","&Abort"), + TQT_TRANSLATE_NOOP("TQMessageBox","&Retry"), + TQT_TRANSLATE_NOOP("TQMessageBox","&Ignore"), + TQT_TRANSLATE_NOOP("TQMessageBox","Yes to &All"), + TQT_TRANSLATE_NOOP("TQMessageBox","N&o to All"), + 0 +}; + +/*! + Constructs a message box with no text and a button with the label + "OK". + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + The \a parent and \a name arguments are passed to the TQDialog + constructor. +*/ + +TQMessageBox::TQMessageBox( TQWidget *parent, const char *name ) + : TQDialog( parent, name, TRUE, WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu ) +{ + init( Ok, 0, 0 ); +} + + +/*! + Constructs a message box with a \a caption, a \a text, an \a icon, + and up to three buttons. + + The \a icon must be one of the following: + \list + \i TQMessageBox::NoIcon + \i TQMessageBox::Question + \i TQMessageBox::Information + \i TQMessageBox::Warning + \i TQMessageBox::Critical + \endlist + + Each button, \a button0, \a button1 and \a button2, can have one + of the following values: + \list + \i TQMessageBox::NoButton + \i TQMessageBox::Ok + \i TQMessageBox::Cancel + \i TQMessageBox::Yes + \i TQMessageBox::No + \i TQMessageBox::Abort + \i TQMessageBox::Retry + \i TQMessageBox::Ignore + \i TQMessageBox::YesAll + \i TQMessageBox::NoAll + \endlist + + Use TQMessageBox::NoButton for the later parameters to have fewer + than three buttons in your message box. If you don't specify any + buttons at all, TQMessageBox will provide an Ok button. + + One of the buttons can be OR-ed with the \c TQMessageBox::Default + flag to make it the default button (clicked when Enter is + pressed). + + One of the buttons can be OR-ed with the \c TQMessageBox::Escape + flag to make it the cancel or close button (clicked when Escape is + pressed). + + Example: + \code + TQMessageBox mb( "Application Name", + "Hardware failure.\n\nDisk error detected\nDo you want to stop?", + TQMessageBox::Question, + TQMessageBox::Yes | TQMessageBox::Default, + TQMessageBox::No | TQMessageBox::Escape, + TQMessageBox::NoButton ); + if ( mb.exec() == TQMessageBox::No ) + // try again + \endcode + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + If \a modal is TRUE the message box is modal; otherwise it + is modeless. + + The \a parent, \a name, \a modal, and \a f arguments are passed to + the TQDialog constructor. + + \sa setCaption(), setText(), setIcon() +*/ + +TQMessageBox::TQMessageBox( const TQString& caption, + const TQString &text, Icon icon, + int button0, int button1, int button2, + TQWidget *parent, const char *name, + bool modal, WFlags f ) + : TQDialog( parent, name, modal, f | WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu ) +{ + init( button0, button1, button2 ); +#ifndef TQT_NO_WIDGET_TOPEXTRA + setCaption( caption ); +#endif + setText( text ); + setIcon( icon ); +} + + +/*! + Destroys the message box. +*/ + +TQMessageBox::~TQMessageBox() +{ + delete mbd; +} + +static TQString * translatedTextAboutTQt = 0; + +void TQMessageBox::init( int button0, int button1, int button2 ) +{ + if ( !translatedTextAboutTQt ) { + translatedTextAboutTQt = new TQString; + + *translatedTextAboutTQt = tr( + "

About TQt

" + "

This program uses TQt version %1.

" + "

TQt is a C++ toolkit for multiplatform GUI & " + "application development.

" + "

TQt provides single-source " + "portability across MS Windows, Mac OS X, " + "Linux, and all major commercial Unix variants.

" + "

See https://trinitydesktop.org/docs/qt3/ " + "for more information.

" + ).arg( TQT_VERSION_STR ); + + } + label = new TQMessageBoxLabel( this ); + TQ_CHECK_PTR( label ); + + if ( (button2 && !button1) || (button1 && !button0) ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQMessageBox: Inconsistent button parameters" ); +#endif + button0 = button1 = button2 = 0; + } + mbd = new TQMessageBoxData(this); + TQ_CHECK_PTR( mbd ); + mbd->icon = NoIcon; + mbd->iconLabel.setPixmap( TQPixmap() ); + mbd->numButtons = 0; + mbd->button[0] = button0; + mbd->button[1] = button1; + mbd->button[2] = button2; + mbd->defButton = -1; + mbd->escButton = -1; + int i; + for ( i=0; i<3; i++ ) { + int b = mbd->button[i]; + if ( (b & Default) ) { + if ( mbd->defButton >= 0 ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQMessageBox: There can be at most one " + "default button" ); +#endif + } else { + mbd->defButton = i; + } + } + if ( (b & Escape) ) { + if ( mbd->escButton >= 0 ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQMessageBox: There can be at most one " + "escape button" ); +#endif + } else { + mbd->escButton = i; + } + } + b &= ButtonMask; + if ( b == 0 ) { + if ( i == 0 ) // no buttons, add an Ok button + b = Ok; + } else if ( b < 0 || b > LastButton ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQMessageBox: Invalid button specifier" ); +#endif + b = Ok; + } else { + if ( i > 0 && mbd->button[i-1] == 0 ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQMessageBox: Inconsistent button parameters; " + "button %d defined but not button %d", + i+1, i ); +#endif + b = 0; + } + } + mbd->button[i] = b; + if ( b ) + mbd->numButtons++; + } + for ( i=0; i<3; i++ ) { + if ( i >= mbd->numButtons ) { + mbd->pb[i] = 0; + } else { + TQCString buttonName; + buttonName.sprintf( "button%d", i+1 ); + mbd->pb[i] = new TQPushButton( + tr(mb_texts[mbd->button[i]]), + this, buttonName ); + if ( mbd->defButton == i ) { + mbd->pb[i]->setDefault( TRUE ); + mbd->pb[i]->setFocus(); + } + mbd->pb[i]->setAutoDefault( TRUE ); + mbd->pb[i]->setFocusPolicy( TQWidget::StrongFocus ); + connect( mbd->pb[i], TQ_SIGNAL(clicked()), TQ_SLOT(buttonClicked()) ); + } + } + resizeButtons(); + reserved1 = reserved2 = 0; +} + + +int TQMessageBox::indexOf( int button ) const +{ + int index = -1; + for ( int i=0; inumButtons; i++ ) { + if ( mbd->button[i] == button ) { + index = i; + break; + } + } + return index; +} + + +void TQMessageBox::resizeButtons() +{ + int i; + TQSize maxSize; + for ( i=0; inumButtons; i++ ) { + TQSize s = mbd->pb[i]->sizeHint(); + maxSize.setWidth( TQMAX(maxSize.width(), s.width()) ); + maxSize.setHeight( TQMAX(maxSize.height(),s.height()) ); + } + mbd->buttonSize = maxSize; + for ( i=0; inumButtons; i++ ) + mbd->pb[i]->resize( maxSize ); +} + + +/*! + \property TQMessageBox::text + \brief the message box text to be displayed. + + The text will be interpreted either as a plain text or as rich + text, depending on the text format setting (\l + TQMessageBox::textFormat). The default setting is \c AutoText, i.e. + the message box will try to auto-detect the format of the text. + + The default value of this property is TQString::null. + + \sa textFormat +*/ +TQString TQMessageBox::text() const +{ + return label->text(); +} + + +void TQMessageBox::setText( const TQString &text ) +{ + label->setText( text ); +} + + +/*! + \property TQMessageBox::icon + \brief the message box's icon + + The icon of the message box can be one of the following predefined + icons: + \list + \i TQMessageBox::NoIcon + \i TQMessageBox::Question + \i TQMessageBox::Information + \i TQMessageBox::Warning + \i TQMessageBox::Critical + \endlist + + The actual pixmap used for displaying the icon depends on the + current \link TQWidget::style() GUI style\endlink. You can also set + a custom pixmap icon using the \l TQMessageBox::iconPixmap + property. The default icon is TQMessageBox::NoIcon. + + \sa iconPixmap +*/ + +TQMessageBox::Icon TQMessageBox::icon() const +{ + return mbd->icon; +} + +void TQMessageBox::setIcon( Icon icon ) +{ + setIconPixmap( standardIcon(icon) ); + mbd->icon = icon; +} + +/*! + \obsolete + + Returns the pixmap used for a standard icon. This + allows the pixmaps to be used in more complex message boxes. + \a icon specifies the required icon, e.g. TQMessageBox::Information, + TQMessageBox::Warning or TQMessageBox::Critical. + + \a style is unused. +*/ + +TQPixmap TQMessageBox::standardIcon( Icon icon, GUIStyle style) +{ + Q_UNUSED(style); + return TQMessageBox::standardIcon(icon); +} + + +/*! + Returns the pixmap used for a standard icon. This allows the + pixmaps to be used in more complex message boxes. \a icon + specifies the required icon, e.g. TQMessageBox::Question, + TQMessageBox::Information, TQMessageBox::Warning or + TQMessageBox::Critical. +*/ + +TQPixmap TQMessageBox::standardIcon( Icon icon ) +{ + TQPixmap pm; + switch ( icon ) { + case Information: + pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxInformation ); + break; + case Warning: + pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxWarning ); + break; + case Critical: + pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxCritical ); + break; + case Question: + pm = TQApplication::style().stylePixmap( TQStyle::SP_MessageBoxQuestion ); + default: + break; + } + return pm; +} + + +/*! + \property TQMessageBox::iconPixmap + \brief the current icon + + The icon currently used by the message box. Note that it's often + hard to draw one pixmap that looks appropriate in both Motif and + Windows GUI styles; you may want to draw two pixmaps. + + \sa icon +*/ + +const TQPixmap *TQMessageBox::iconPixmap() const +{ + return mbd->iconLabel.pixmap(); +} + + +void TQMessageBox::setIconPixmap( const TQPixmap &pixmap ) +{ + mbd->iconLabel.setPixmap(pixmap); + mbd->icon = NoIcon; +} + + +/*! + Returns the text of the message box button \a button, or + TQString::null if the message box does not contain the button. + + \sa setButtonText() +*/ + +TQString TQMessageBox::buttonText( int button ) const +{ + int index = indexOf(button); + return index >= 0 && mbd->pb[index] + ? mbd->pb[index]->text() + : TQString::null; +} + + +/*! + Sets the text of the message box button \a button to \a text. + Setting the text of a button that is not in the message box is + silently ignored. + + \sa buttonText() +*/ + +void TQMessageBox::setButtonText( int button, const TQString &text ) +{ + int index = indexOf(button); + if ( index >= 0 && mbd->pb[index] ) { + mbd->pb[index]->setText( text ); + resizeButtons(); + } +} + + +/*! + \internal + Internal slot to handle button clicks. +*/ + +void TQMessageBox::buttonClicked() +{ + int reply = 0; + const TQObject *s = sender(); + for ( int i=0; inumButtons; i++ ) { + if ( mbd->pb[i] == s ) + reply = mbd->button[i]; + } + done( reply ); +} + + +/*! + Adjusts the size of the message box to fit the contents just before + TQDialog::exec() or TQDialog::show() is called. + + This function will not be called if the message box has been explicitly + resized before showing it. +*/ +void TQMessageBox::adjustSize() +{ + if ( !testWState(WState_Polished) ) + polish(); + resizeButtons(); + label->adjustSize(); + TQSize labelSize( label->size() ); + int n = mbd->numButtons; + int bw = mbd->buttonSize.width(); + int bh = mbd->buttonSize.height(); + int border = bh / 2 - style().pixelMetric(TQStyle::PM_ButtonDefaultIndicator); + if ( border <= 0 ) + border = 10; + int btn_spacing = 7; + if ( style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle ) + btn_spacing = border; +#ifndef Q_OS_TEMP + int buttons = mbd->numButtons * bw + (n-1) * btn_spacing; + int h = bh; +#else + int visibleButtons = 0; + for ( int i = 0; i < mbd->numButtons; ++i ) + visibleButtons += mbd->pb[i]->isVisible() ? 1 : 0; + int buttons = visibleButtons == 0 ? 0 : visibleButtons * bw + (visibleButtons-1) * btn_spacing; + int h = visibleButtons == 0 ? 0 : bh; + n = visibleButtons; +#endif + if ( labelSize.height() ) + h += labelSize.height() + 3*border; + else + h += 2*border; + int lmargin = 0; + if ( mbd->iconLabel.pixmap() && mbd->iconLabel.pixmap()->width() ) { + mbd->iconLabel.adjustSize(); + lmargin += mbd->iconLabel.width() + border; + if ( h < mbd->iconLabel.height() + 3*border + bh && n ) + h = mbd->iconLabel.height() + 3*border + bh; + } + int w = TQMAX( buttons, labelSize.width() + lmargin ) + 2*border; + TQRect screen = TQApplication::desktop()->screenGeometry( pos() ); + if ( w > screen.width() ) + w = screen.width(); + resize( w, h ); + setMinimumSize( size() ); +#ifdef TQ_WS_MAC + setMaximumSize(size()); +#endif +} + + +/*!\reimp +*/ +void TQMessageBox::resizeEvent( TQResizeEvent * ) +{ + int i; + int n = mbd->numButtons; + int bw = mbd->buttonSize.width(); + int bh = mbd->buttonSize.height(); +#ifdef Q_OS_TEMP + int visibleButtons = 0; + for ( i = 0; i < n; ++i ) + visibleButtons += mbd->pb[i]->isVisible() ? 1 : 0; + n = visibleButtons; + bw = visibleButtons == 0 ? 0 : bw; + bh = visibleButtons == 0 ? 0 : bh; +#endif + int border = bh / 2 - style().pixelMetric(TQStyle::PM_ButtonDefaultIndicator); + if ( border <= 0 ) + border = 10; + int btn_spacing = 7; + if ( style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle ) + btn_spacing = border; + int lmargin = 0; + mbd->iconLabel.adjustSize(); + bool rtl = TQApplication::reverseLayout(); + if (rtl) + mbd->iconLabel.move(width() - border - mbd->iconLabel.width(), border); + else + mbd->iconLabel.move(border, border); + if ( mbd->iconLabel.pixmap() && mbd->iconLabel.pixmap()->width() ) + lmargin += mbd->iconLabel.width() + border; + label->setGeometry((rtl ? 0 : lmargin) + border, + border, + width() - lmargin -2*border, + height() - 3*border - bh); + int extra_space = (width() - bw*n - 2*border - (n-1)*btn_spacing); + if ( style().styleHint(TQStyle::SH_GUIStyle) == MotifStyle ) + for ( i=0; ipb[rtl ? n - i - 1 : i]->move(border + i*bw + i*btn_spacing + extra_space*(i+1)/(n+1), + height() - border - bh ); + else + for ( i=0; ipb[rtl ? n - i - 1 : i]->move(border + i*bw + extra_space/2 + i*btn_spacing, + height() - border - bh ); +} + + +/*!\reimp +*/ +void TQMessageBox::keyPressEvent( TQKeyEvent *e ) +{ + if ( e->key() == Key_Escape ) { + if ( mbd->escButton >= 0 ) { + TQPushButton *pb = mbd->pb[mbd->escButton]; + pb->animateClick(); + e->accept(); + return; + } + } +#ifndef TQT_NO_ACCEL + if ( !( e->state() & AltButton ) ) { + TQObjectList *list = queryList( "TQPushButton" ); + TQObjectListIt it( *list ); + TQPushButton *pb; + while ( (pb = (TQPushButton*)it.current()) ) { + int key = e->key() & ~(MODIFIER_MASK|UNICODE_ACCEL); + int acc = pb->accel() & ~(MODIFIER_MASK|UNICODE_ACCEL); + if ( key && acc && acc == key ) { + delete list; + emit pb->animateClick(); + return; + } + ++it; + } + delete list; + } +#endif + TQDialog::keyPressEvent( e ); +} + +/*!\reimp +*/ +void TQMessageBox::showEvent( TQShowEvent *e ) +{ +#if defined(QT_ACCESSIBILITY_SUPPORT) + TQAccessible::updateAccessibility( this, 0, TQAccessible::Alert ); +#endif + TQDialog::showEvent( e ); +} + +/*!\reimp +*/ +void TQMessageBox::closeEvent( TQCloseEvent *e ) +{ + TQDialog::closeEvent( e ); + if ( mbd->escButton != -1 ) + setResult( mbd->button[mbd->escButton] ); +} + +/***************************************************************************** + Static TQMessageBox functions + *****************************************************************************/ + +/*!\fn int TQMessageBox::message( const TQString &,const TQString&,const TQString&,TQWidget*,const char * ) + \obsolete + Opens a modal message box directly using the specified parameters. + + Please use information(), warning(), question(), or critical() instead. +*/ + +/*! \fn bool TQMessageBox::query( const TQString &,const TQString&,const TQString&,const TQString&,TQWidget *, const char * ) + \obsolete + Queries the user using a modal message box with two buttons. + Note that \a caption is not always shown, it depends on the window manager. + + Please use information(), question(), warning(), or critical() instead. +*/ + +/*! + Opens an information message box with the caption \a caption and + the text \a text. The dialog may have up to three buttons. Each of + the buttons, \a button0, \a button1 and \a button2 may be set to + one of the following values: + + \list + \i TQMessageBox::NoButton + \i TQMessageBox::Ok + \i TQMessageBox::Cancel + \i TQMessageBox::Yes + \i TQMessageBox::No + \i TQMessageBox::Abort + \i TQMessageBox::Retry + \i TQMessageBox::Ignore + \i TQMessageBox::YesAll + \i TQMessageBox::NoAll + \endlist + + If you don't want all three buttons, set the last button, or last + two buttons to TQMessageBox::NoButton. + + One button can be OR-ed with \c TQMessageBox::Default, and one + button can be OR-ed with \c TQMessageBox::Escape. + + Returns the identity (TQMessageBox::Ok, or TQMessageBox::No, etc.) + of the button that was clicked. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + \sa question(), warning(), critical() +*/ + +int TQMessageBox::information( TQWidget *parent, + const TQString& caption, const TQString& text, + int button0, int button1, int button2 ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::information( parent, caption, text, button0, button1, button2 ); +#endif + TQMessageBox *mb = new TQMessageBox( caption, text, Information, + button0, button1, button2, + parent, "qt_msgbox_information", TRUE, + WDestructiveClose); + TQ_CHECK_PTR( mb ); + return mb->exec(); +} + +/*! + Opens a question message box with the caption \a caption and the + text \a text. The dialog may have up to three buttons. Each of the + buttons, \a button0, \a button1 and \a button2 may be set to one + of the following values: + + \list + \i TQMessageBox::NoButton + \i TQMessageBox::Ok + \i TQMessageBox::Cancel + \i TQMessageBox::Yes + \i TQMessageBox::No + \i TQMessageBox::Abort + \i TQMessageBox::Retry + \i TQMessageBox::Ignore + \i TQMessageBox::YesAll + \i TQMessageBox::NoAll + \endlist + + If you don't want all three buttons, set the last button, or last + two buttons to TQMessageBox::NoButton. + + One button can be OR-ed with \c TQMessageBox::Default, and one + button can be OR-ed with \c TQMessageBox::Escape. + + Returns the identity (TQMessageBox::Yes, or TQMessageBox::No, etc.) + of the button that was clicked. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + \sa information(), warning(), critical() +*/ + +int TQMessageBox::question( TQWidget *parent, + const TQString& caption, const TQString& text, + int button0, int button1, int button2 ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::question( parent, caption, text, button0, button1, button2 ); +#endif + TQMessageBox *mb = new TQMessageBox( caption, text, Question, + button0, button1, button2, + parent, "qt_msgbox_information", TRUE, + WDestructiveClose); + TQ_CHECK_PTR( mb ); + return mb->exec(); +} + + +/*! + Opens a warning message box with the caption \a caption and the + text \a text. The dialog may have up to three buttons. Each of the + button parameters, \a button0, \a button1 and \a button2 may be + set to one of the following values: + + \list + \i TQMessageBox::NoButton + \i TQMessageBox::Ok + \i TQMessageBox::Cancel + \i TQMessageBox::Yes + \i TQMessageBox::No + \i TQMessageBox::Abort + \i TQMessageBox::Retry + \i TQMessageBox::Ignore + \i TQMessageBox::YesAll + \i TQMessageBox::NoAll + \endlist + + If you don't want all three buttons, set the last button, or last + two buttons to TQMessageBox::NoButton. + + One button can be OR-ed with \c TQMessageBox::Default, and one + button can be OR-ed with \c TQMessageBox::Escape. + + Returns the identity (TQMessageBox::Ok, or TQMessageBox::No, etc.) + of the button that was clicked. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + \sa information(), question(), critical() +*/ + +int TQMessageBox::warning( TQWidget *parent, + const TQString& caption, const TQString& text, + int button0, int button1, int button2 ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::warning( parent, caption, text, button0, button1, button2 ); +#endif + TQMessageBox *mb = new TQMessageBox( caption, text, Warning, + button0, button1, button2, + parent, "qt_msgbox_warning", TRUE, + WDestructiveClose); + TQ_CHECK_PTR( mb ); + return mb->exec(); +} + + +/*! + Opens a critical message box with the caption \a caption and the + text \a text. The dialog may have up to three buttons. Each of the + button parameters, \a button0, \a button1 and \a button2 may be + set to one of the following values: + + \list + \i TQMessageBox::NoButton + \i TQMessageBox::Ok + \i TQMessageBox::Cancel + \i TQMessageBox::Yes + \i TQMessageBox::No + \i TQMessageBox::Abort + \i TQMessageBox::Retry + \i TQMessageBox::Ignore + \i TQMessageBox::YesAll + \i TQMessageBox::NoAll + \endlist + + If you don't want all three buttons, set the last button, or last + two buttons to TQMessageBox::NoButton. + + One button can be OR-ed with \c TQMessageBox::Default, and one + button can be OR-ed with \c TQMessageBox::Escape. + + Returns the identity (TQMessageBox::Ok, or TQMessageBox::No, etc.) + of the button that was clicked. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + \sa information(), question(), warning() +*/ + +int TQMessageBox::critical( TQWidget *parent, + const TQString& caption, const TQString& text, + int button0, int button1, int button2 ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::critical( parent, caption, text, button0, button1, button2 ); +#endif + TQMessageBox *mb = new TQMessageBox( caption, text, Critical, + button0, button1, button2, + parent, "qt_msgbox_critical", TRUE, + WDestructiveClose); + TQ_CHECK_PTR( mb ); + return mb->exec(); +} + + +/*! + Displays a simple about box with caption \a caption and text \a + text. The about box's parent is \a parent. + + about() looks for a suitable icon in four locations: + \list 1 + \i It prefers \link TQWidget::icon() parent->icon() \endlink if that exists. + \i If not, it tries the top-level widget containing \a parent. + \i If that fails, it tries the \link + TQApplication::mainWidget() main widget. \endlink + \i As a last resort it uses the Information icon. + \endlist + + The about box has a single button labelled "OK". + + \sa TQWidget::icon() TQApplication::mainWidget() +*/ + +void TQMessageBox::about( TQWidget *parent, const TQString &caption, + const TQString& text ) +{ + TQMessageBox *mb = new TQMessageBox( caption, text, + Information, + Ok + Default, 0, 0, + parent, "qt_msgbox_simple_about_box", TRUE, + WDestructiveClose); + TQ_CHECK_PTR( mb ); +#ifndef TQT_NO_WIDGET_TOPEXTRA + const TQPixmap *pm = parent ? parent->icon() : 0; + if ( pm && !pm->isNull() ) + mb->setIconPixmap( *pm ); + else { + pm = parent ? parent->topLevelWidget()->icon() : 0; + if ( pm && !pm->isNull() ) + mb->setIconPixmap( *pm ); + else { + pm = tqApp && tqApp->mainWidget() ? tqApp->mainWidget()->icon() : 0; + if ( pm && !pm->isNull() ) + mb->setIconPixmap( *pm ); + } + } +#endif + mb->exec(); +} + + +/*! \reimp +*/ + +void TQMessageBox::styleChanged( TQStyle& ) +{ + if ( mbd->icon != NoIcon ) { + // Reload icon for new style + setIcon( mbd->icon ); + } +} + + +static int textBox( TQWidget *parent, TQMessageBox::Icon severity, + const TQString& caption, const TQString& text, + const TQString& button0Text, + const TQString& button1Text, + const TQString& button2Text, + int defaultButtonNumber, + int escapeButtonNumber ) +{ + int b[3]; + b[0] = 1; + b[1] = button1Text.isEmpty() ? 0 : 2; + b[2] = button2Text.isEmpty() ? 0 : 3; + + int i; + for( i=0; i<3; i++ ) { + if ( b[i] && defaultButtonNumber == i ) + b[i] += TQMessageBox::Default; + if ( b[i] && escapeButtonNumber == i ) + b[i] += TQMessageBox::Escape; + } + + TQMessageBox *mb = new TQMessageBox( caption, text, severity, + b[0], b[1], b[2], + parent, "qt_msgbox_information", TRUE, + TQt::WDestructiveClose); + TQ_CHECK_PTR( mb ); + if ( button0Text.isEmpty() ) + mb->setButtonText( 1, TQMessageBox::tr(mb_texts[TQMessageBox::Ok]) ); + else + mb->setButtonText( 1, button0Text ); + if ( b[1] ) + mb->setButtonText( 2, button1Text ); + if ( b[2] ) + mb->setButtonText( 3, button2Text ); + +#ifndef TQT_NO_CURSOR + mb->setCursor( TQt::arrowCursor ); +#endif + return mb->exec() - 1; +} + + +/*! + \overload + + Displays an information message box with caption \a caption, text + \a text and one, two or three buttons. Returns the index of the + button that was clicked (0, 1 or 2). + + \a button0Text is the text of the first button, and is optional. + If \a button0Text is not supplied, "OK" (translated) will be used. + \a button1Text is the text of the second button, and is optional. + \a button2Text is the text of the third button, and is optional. + \a defaultButtonNumber (0, 1 or 2) is the index of the default + button; pressing Return or Enter is the same as clicking the + default button. It defaults to 0 (the first button). \a + escapeButtonNumber is the index of the Escape button; pressing + Escape is the same as clicking this button. It defaults to -1; + supply 0, 1 or 2 to make pressing Escape equivalent to clicking + the relevant button. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + Note: If you do not specify an Escape button then if the Escape + button is pressed then -1 will be returned. It is suggested that + you specify an Escape button to prevent this from happening. + + \sa question(), warning(), critical() +*/ + +int TQMessageBox::information( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text, + const TQString& button1Text, + const TQString& button2Text, + int defaultButtonNumber, + int escapeButtonNumber ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::information( parent, caption, text, + button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); +#endif + return textBox( parent, Information, caption, text, + button0Text, button1Text, button2Text, + defaultButtonNumber, escapeButtonNumber ); +} + +/*! + \overload + + Displays a question message box with caption \a caption, text \a + text and one, two or three buttons. Returns the index of the + button that was clicked (0, 1 or 2). + + \a button0Text is the text of the first button, and is optional. + If \a button0Text is not supplied, "OK" (translated) will be used. + \a button1Text is the text of the second button, and is optional. + \a button2Text is the text of the third button, and is optional. + \a defaultButtonNumber (0, 1 or 2) is the index of the default + button; pressing Return or Enter is the same as clicking the + default button. It defaults to 0 (the first button). \a + escapeButtonNumber is the index of the Escape button; pressing + Escape is the same as clicking this button. It defaults to -1; + supply 0, 1 or 2 to make pressing Escape equivalent to clicking + the relevant button. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + Note: If you do not specify an Escape button then if the Escape + button is pressed then -1 will be returned. It is suggested that + you specify an Escape button to prevent this from happening. + + \sa information(), warning(), critical() +*/ +int TQMessageBox::question( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text, + const TQString& button1Text, + const TQString& button2Text, + int defaultButtonNumber, + int escapeButtonNumber ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::question( parent, caption, text, + button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); +#endif + return textBox( parent, Question, caption, text, + button0Text, button1Text, button2Text, + defaultButtonNumber, escapeButtonNumber ); +} + + +/*! + \overload + + Displays a warning message box with a caption, a text, and 1, 2 or + 3 buttons. Returns the number of the button that was clicked (0, + 1, or 2). + + \a button0Text is the text of the first button, and is optional. + If \a button0Text is not supplied, "OK" (translated) will be used. + \a button1Text is the text of the second button, and is optional, + and \a button2Text is the text of the third button, and is + optional. \a defaultButtonNumber (0, 1 or 2) is the index of the + default button; pressing Return or Enter is the same as clicking + the default button. It defaults to 0 (the first button). \a + escapeButtonNumber is the index of the Escape button; pressing + Escape is the same as clicking this button. It defaults to -1; + supply 0, 1, or 2 to make pressing Escape equivalent to clicking + the relevant button. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + Note: If you do not specify an Escape button then if the Escape + button is pressed then -1 will be returned. It is suggested that + you specify an Escape button to prevent this from happening. + + \sa information(), question(), critical() +*/ + +int TQMessageBox::warning( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text, + const TQString& button1Text, + const TQString& button2Text, + int defaultButtonNumber, + int escapeButtonNumber ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::warning( parent, caption, text, + button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); +#endif + return textBox( parent, Warning, caption, text, + button0Text, button1Text, button2Text, + defaultButtonNumber, escapeButtonNumber ); +} + + +/*! + \overload + + Displays a critical error message box with a caption, a text, and + 1, 2 or 3 buttons. Returns the number of the button that was + clicked (0, 1 or 2). + + \a button0Text is the text of the first button, and is optional. + If \a button0Text is not supplied, "OK" (translated) will be used. + \a button1Text is the text of the second button, and is optional, + and \a button2Text is the text of the third button, and is + optional. \a defaultButtonNumber (0, 1 or 2) is the index of the + default button; pressing Return or Enter is the same as clicking + the default button. It defaults to 0 (the first button). \a + escapeButtonNumber is the index of the Escape button; pressing + Escape is the same as clicking this button. It defaults to -1; + supply 0, 1, or 2 to make pressing Escape equivalent to clicking + the relevant button. + + If \a parent is 0, the message box becomes an application-global + modal dialog box. If \a parent is a widget, the message box + becomes modal relative to \a parent. + + \sa information(), question(), warning() +*/ + +int TQMessageBox::critical( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text, + const TQString& button1Text, + const TQString& button2Text, + int defaultButtonNumber, + int escapeButtonNumber ) +{ +#if defined(TQ_WS_X11) + if ( tqt_use_native_dialogs && TQTDEIntegration::enabled()) + return TQTDEIntegration::critical( parent, caption, text, + button0Text, button1Text, button2Text, defaultButtonNumber, escapeButtonNumber ); +#endif + return textBox( parent, Critical, caption, text, + button0Text, button1Text, button2Text, + defaultButtonNumber, escapeButtonNumber ); +} + + +/*! + Displays a simple message box about TQt, with caption \a caption + and centered over \a parent (if \a parent is not 0). The message + includes the version number of TQt being used by the application. + + This is useful for inclusion in the Help menu of an application. + See the examples/menu/menu.cpp example. + + TQApplication provides this functionality as a slot. + + \sa TQApplication::aboutTQt() +*/ + +void TQMessageBox::aboutTQt( TQWidget *parent, const TQString &caption ) +{ + TQMessageBox *mb = new TQMessageBox( parent, "qt_msgbox_about_qt" ); + TQ_CHECK_PTR( mb ); + mb->setWFlags( WDestructiveClose ); + +#ifndef TQT_NO_WIDGET_TOPEXTRA + TQString c = caption; + if ( c.isNull() ) + c = tr( "About TQt" ); + mb->setCaption( c ); +#endif + mb->setText( *translatedTextAboutTQt ); +#ifndef TQT_NO_IMAGEIO + TQPixmap pm; + TQImage logo( (const char **)qtlogo_xpm); + if ( tqGray(mb->palette().active().text().rgb()) > + tqGray(mb->palette().active().base().rgb()) ) + { + // light on dark, adjust some colors (where's 10?) + logo.setColor( 0, 0xffffffff ); + logo.setColor( 1, 0xff666666 ); + logo.setColor( 2, 0xffcccc66 ); + logo.setColor( 4, 0xffcccccc ); + logo.setColor( 6, 0xffffff66 ); + logo.setColor( 7, 0xff999999 ); + logo.setColor( 8, 0xff3333ff ); + logo.setColor( 9, 0xffffff33 ); + logo.setColor( 11, 0xffcccc99 ); + } + if ( pm.convertFromImage( logo ) ) + mb->setIconPixmap( pm ); +#endif + mb->setButtonText( 0, tr("OK") ); + if ( mb->mbd && mb->mbd->pb[0] ) { + mb->mbd->pb[0]->setAutoDefault( TRUE ); + mb->mbd->pb[0]->setFocusPolicy( TQWidget::StrongFocus ); + mb->mbd->pb[0]->setDefault( TRUE ); + mb->mbd->pb[0]->setFocus(); + } + mb->exec(); +} + +/*! + \reimp +*/ + +void TQMessageBox::setIcon( const TQPixmap &pix ) +{ + //reimplemented to avoid compiler warning. +#ifndef TQT_NO_WIDGET_TOPEXTRA + TQDialog::setIcon( pix ); +#endif +} + + +/*! + \property TQMessageBox::textFormat + \brief the format of the text displayed by the message box + + The current text format used by the message box. See the \l + TQt::TextFormat enum for an explanation of the possible options. + + The default format is \c AutoText. + + \sa setText() +*/ + +TQt::TextFormat TQMessageBox::textFormat() const +{ + return label->textFormat(); +} + + +void TQMessageBox::setTextFormat( TQt::TextFormat format ) +{ + label->setTextFormat( format ); +} + + +#endif diff --git a/src/dialogs/tqmessagebox.h b/src/dialogs/tqmessagebox.h new file mode 100644 index 000000000..a8b563830 --- /dev/null +++ b/src/dialogs/tqmessagebox.h @@ -0,0 +1,223 @@ +/**************************************************************************** +** +** Definition of TQMessageBox class +** +** Created : 950503 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs 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 TQMESSAGEBOX_H +#define TQMESSAGEBOX_H + +#ifndef QT_H +#include "tqdialog.h" +#endif // QT_H + +#ifndef TQT_NO_MESSAGEBOX + +class TQLabel; +class TQPushButton; +struct TQMessageBoxData; + +class TQ_EXPORT TQMessageBox : public TQDialog +{ + TQ_OBJECT + TQ_ENUMS( Icon ) + TQ_PROPERTY( TQString text READ text WRITE setText ) + TQ_PROPERTY( Icon icon READ icon WRITE setIcon ) + TQ_PROPERTY( TQPixmap iconPixmap READ iconPixmap WRITE setIconPixmap ) + TQ_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat ) + +public: + enum Icon { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, + Question = 4 }; + + TQMessageBox( TQWidget* parent=0, const char* name=0 ); + TQMessageBox( const TQString& caption, const TQString &text, Icon icon, + int button0, int button1, int button2, + TQWidget* parent=0, const char* name=0, bool modal=TRUE, + WFlags f=WStyle_DialogBorder ); + ~TQMessageBox(); + + enum { NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5, + Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, ButtonMask = 0xff, + Default = 0x100, Escape = 0x200, FlagMask = 0x300 }; + + static int information( TQWidget *parent, const TQString &caption, + const TQString& text, + int button0, int button1=0, int button2=0 ); + static int information( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text = TQString::null, + const TQString& button1Text = TQString::null, + const TQString& button2Text = TQString::null, + int defaultButtonNumber = 0, + int escapeButtonNumber = -1 ); + + static int question( TQWidget *parent, const TQString &caption, + const TQString& text, + int button0, int button1=0, int button2=0 ); + static int question( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text = TQString::null, + const TQString& button1Text = TQString::null, + const TQString& button2Text = TQString::null, + int defaultButtonNumber = 0, + int escapeButtonNumber = -1 ); + + static int warning( TQWidget *parent, const TQString &caption, + const TQString& text, + int button0, int button1, int button2=0 ); + static int warning( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text = TQString::null, + const TQString& button1Text = TQString::null, + const TQString& button2Text = TQString::null, + int defaultButtonNumber = 0, + int escapeButtonNumber = -1 ); + + static int critical( TQWidget *parent, const TQString &caption, + const TQString& text, + int button0, int button1, int button2=0 ); + static int critical( TQWidget *parent, const TQString &caption, + const TQString& text, + const TQString& button0Text = TQString::null, + const TQString& button1Text = TQString::null, + const TQString& button2Text = TQString::null, + int defaultButtonNumber = 0, + int escapeButtonNumber = -1 ); + + static void about( TQWidget *parent, const TQString &caption, + const TQString& text ); + + static void aboutTQt( TQWidget *parent, + const TQString& caption=TQString::null ); + +/* OBSOLETE */ + static int message( const TQString &caption, + const TQString& text, + const TQString& buttonText=TQString::null, + TQWidget *parent=0, const char * =0 ) { + return TQMessageBox::information( parent, caption, text, + buttonText.isEmpty() + ? tr("OK") : buttonText ) == 0; + } + +/* OBSOLETE */ + static bool query( const TQString &caption, + const TQString& text, + const TQString& yesButtonText=TQString::null, + const TQString& noButtonText=TQString::null, + TQWidget *parent=0, const char * = 0 ) { + return TQMessageBox::information( parent, caption, text, + yesButtonText.isEmpty() + ? tr("OK") : yesButtonText, + noButtonText ) == 0; + } + + TQString text() const; + void setText( const TQString &); + + Icon icon() const; + + void setIcon( Icon ); + void setIcon( const TQPixmap & ); + + const TQPixmap *iconPixmap() const; + void setIconPixmap( const TQPixmap & ); + + TQString buttonText( int button ) const; + void setButtonText( int button, const TQString &); + + void adjustSize(); + +/* OBSOLETE */ + static TQPixmap standardIcon( Icon icon, GUIStyle ); + + static TQPixmap standardIcon( Icon icon ); + + TextFormat textFormat() const; + void setTextFormat( TextFormat ); + +protected: + void resizeEvent( TQResizeEvent * ); + void showEvent( TQShowEvent * ); + void closeEvent( TQCloseEvent * ); + void keyPressEvent( TQKeyEvent * ); + void styleChanged( TQStyle& ); + +private slots: + void buttonClicked(); + +private: + void init( int, int, int ); + int indexOf( int ) const; + void resizeButtons(); + TQLabel *label; + TQMessageBoxData *mbd; + void *reserved1; + void *reserved2; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQMessageBox( const TQMessageBox & ); + TQMessageBox &operator=( const TQMessageBox & ); +#endif +}; + +/* +* Macro to be used at the beginning of main(), e.g. +* +* #include +* #include +* int main( int argc, char**argv ) +* { +* QT_REQUIRE_VERSION( argc, argv, "3.0.5" ) +* ... +* } +*/ +#define QT_REQUIRE_VERSION( argc, argv, str ) { TQString s=TQString::fromLatin1(str);\ +TQString sq=TQString::fromLatin1(tqVersion()); if ( (sq.section('.',0,0).toInt()<<16)+\ +(sq.section('.',1,1).toInt()<<8)+sq.section('.',2,2).toInt()<(s.section('.',0,0).toInt()<<16)+\ +(s.section('.',1,1).toInt()<<8)+s.section('.',2,2).toInt() ){if ( !tqApp){ int c=0; new \ +TQApplication(argc,argv);} TQString s = TQApplication::tr("Executable '%1' requires TQt "\ + "%2, found TQt %3.").arg(TQString::fromLatin1(tqAppName())).arg(TQString::fromLatin1(\ +str)).arg(TQString::fromLatin1(tqVersion()) ); TQMessageBox::critical( 0, TQApplication::tr(\ +"Incompatible TQt Library Error" ), s, TQMessageBox::Abort,0 ); tqFatal(s.ascii()); }} + + +#endif // TQT_NO_MESSAGEBOX + +#endif // TQMESSAGEBOX_H diff --git a/src/dialogs/tqprintdialog.cpp b/src/dialogs/tqprintdialog.cpp new file mode 100644 index 000000000..a82ae4ee4 --- /dev/null +++ b/src/dialogs/tqprintdialog.cpp @@ -0,0 +1,1677 @@ +/**************************************************************************** +** +** Implementation of internal print dialog (X11) used by TQPrinter::select(). +** +** Created : 950829 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs 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 "tqprintdialog.h" + +#ifndef TQT_NO_PRINTDIALOG + +#include "tqfiledialog.h" +#include "tqfile.h" +#include "tqtextstream.h" +#include "tqcombobox.h" +#include "tqframe.h" +#include "tqlabel.h" +#include "tqlineedit.h" +#include "tqpushbutton.h" +#include "tqprinter.h" +#include "tqlistview.h" +#include "tqlayout.h" +#include "tqbuttongroup.h" +#include "tqradiobutton.h" +#include "tqspinbox.h" +#include "ntqapplication.h" +#include "tqheader.h" +#include "tqstyle.h" +#include "tqstring.h" +#include "tqregexp.h" +#if !defined(TQT_NO_CUPS) || !defined(TQT_NO_NIS) +#include "tqlibrary.h" +#endif + +#ifndef TQT_NO_NIS + +#ifndef BOOL_DEFINED +#define BOOL_DEFINED +#endif + +#include +#include + +// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. +#if defined(connect) +# undef connect +#endif + +#endif // TQT_NO_NIS + +// UNIX Large File Support redefines open -> open64 +#if defined(open) +# undef open +#endif + +#include +#include + + +class TQPrintDialogSpinBox : public TQSpinBox +{ +public: + TQPrintDialogSpinBox(int min, int max, int steps, TQWidget *parent, const char *name) + : TQSpinBox(min, max, steps, parent, name) + {} + + void interpretText() + { + TQSpinBox::interpretText(); + } +}; + + + + +enum { Success = 's', Unavail = 'u', NotFound = 'n', TryAgain = 't' }; +enum { Continue = 'c', Return = 'r' }; + +class TQPrintDialogPrivate +{ +public: + TQPrinter * printer; + + TQButtonGroup * printerOrFile; + + bool outputToFile; + TQListView * printers; + TQLineEdit * fileName; + TQPushButton * browse, *ok; + + TQButtonGroup * printRange; + TQLabel * firstPageLabel; + TQPrintDialogSpinBox * firstPage; + TQLabel * lastPageLabel; + TQPrintDialogSpinBox * lastPage; + TQRadioButton * printAllButton; + TQRadioButton * printRangeButton; + TQRadioButton * printSelectionButton; + TQRadioButton * printToFileButton; + TQComboBox *orientationCombo, *sizeCombo; + + TQPrinter::PageSize pageSize; + TQPrinter::Orientation orientation; + + TQButtonGroup * pageOrder; + TQPrinter::PageOrder pageOrder2; + + TQButtonGroup * colorMode; + TQPrinter::ColorMode colorMode2; + + TQPrintDialogSpinBox * copies; + int numCopies; + + TQBoxLayout *customLayout; + + TQPrinter::PageSize indexToPageSize[TQPrinter::NPageSize]; +}; + + +typedef void (*Q_PrintDialogHook)(TQListView *); +static Q_PrintDialogHook addPrinterHook = 0; + +void qt_set_printdialog_hook( Q_PrintDialogHook hook ) +{ + addPrinterHook = hook; +} + +static void isc( TQPrintDialogPrivate * d, const TQString & text, + TQPrinter::PageSize ps ); + +class TQPrinterListViewItem : public TQListViewItem +{ +public: + TQPrinterListViewItem( TQListView * printers, const TQString& name, + const TQString& host, const TQString& comment, + const TQStringList& aliases ) + : TQListViewItem( printers, name, host, comment ), ali( aliases ) { } + + bool samePrinter( const TQString& name ) { + return text( 0 ) == name || ali.find( name ) != ali.end(); + } + + TQStringList ali; +}; + +static void perhapsAddPrinter( TQListView * printers, const TQString &name, + TQString host, TQString comment, + TQStringList aliases = TQStringList() ) +{ + const TQListViewItem * i = printers->firstChild(); + while ( i && !((TQPrinterListViewItem *) i)->samePrinter(name) ) + i = i->nextSibling(); + if ( i ) + return; + if ( host.isEmpty() ) + host = TQPrintDialog::tr( "locally connected" ); + (void)new TQPrinterListViewItem( printers, + name.simplifyWhiteSpace(), + host.simplifyWhiteSpace(), + comment.simplifyWhiteSpace(), aliases ); +} + +static void parsePrinterDesc( TQString printerDesc, TQListView * printers ) +{ + if ( printerDesc.length() < 1 ) + return; + + printerDesc = printerDesc.simplifyWhiteSpace(); + int i = printerDesc.find( ':' ); + TQString printerName, printerComment, printerHost; + TQStringList aliases; + + if ( i >= 0 ) { + // have ':' want '|' + int j = printerDesc.find( '|' ); + if ( j > 0 && j < i ) { + printerName = printerDesc.left( j ); + aliases = TQStringList::split( '|', + printerDesc.mid(j + 1, i - j - 1) ); + // try extracting a comment from the aliases + printerComment = TQPrintDialog::tr( "Aliases: %1" ) + .arg( aliases.join(", ") ); + } else { + printerName = printerDesc.left( i ); + } + // look for lprng pseudo all printers entry + i = printerDesc.find( TQRegExp(TQString::fromLatin1(": *all *=")) ); + if ( i >= 0 ) + printerName = ""; + // look for signs of this being a remote printer + i = printerDesc.find( TQRegExp(TQString::fromLatin1(": *rm *=")) ); + if ( i >= 0 ) { + // point k at the end of remote host name + while ( printerDesc[i] != '=' ) + i++; + while ( printerDesc[i] == '=' || printerDesc[i].isSpace() ) + i++; + j = i; + while ( j < (int)printerDesc.length() && printerDesc[j] != ':' ) + j++; + + // and stuff that into the string + printerHost = printerDesc.mid( i, j - i ); + } + } + if ( printerName.length() ) + perhapsAddPrinter( printers, printerName, printerHost, printerComment, + aliases ); +} + +static int parsePrintcap( TQListView * printers, const TQString& fileName ) +{ + TQFile printcap( fileName ); + if ( !printcap.open( IO_ReadOnly ) ) + return NotFound; + + char * line_ascii = new char[1025]; + line_ascii[1024] = '\0'; + + TQString printerDesc; + bool atEnd = FALSE; + + while ( !atEnd ) { + if ( printcap.atEnd() || printcap.readLine( line_ascii, 1024 ) <= 0 ) + atEnd = TRUE; + TQString line = line_ascii; + line = line.stripWhiteSpace(); + if ( line.length() >= 1 && line[int(line.length()) - 1] == '\\' ) + line.truncate( line.length() - 1 ); + if ( line[0] == '#' ) { + if ( !atEnd ) + continue; + } else if ( line[0] == '|' || line[0] == ':' ) { + printerDesc += line; + if ( !atEnd ) + continue; + } + + parsePrinterDesc( printerDesc, printers ); + + // add the first line of the new printer definition + printerDesc = line; + } + delete[] line_ascii; + return Success; +} + + +// solaris, not 2.6 +static void parseEtcLpPrinters( TQListView * printers ) +{ + TQDir lp( TQString::fromLatin1("/etc/lp/printers") ); + const TQFileInfoList * dirs = lp.entryInfoList(); + if ( !dirs ) + return; + + TQFileInfoListIterator it( *dirs ); + TQFileInfo *printer; + TQString tmp; + while ( (printer = it.current()) != 0 ) { + ++it; + if ( printer->isDir() ) { + tmp.sprintf( "/etc/lp/printers/%s/configuration", + printer->fileName().ascii() ); + TQFile configuration( tmp ); + char * line = new char[1025]; + TQString remote( TQString::fromLatin1("Remote:") ); + TQString contentType( TQString::fromLatin1("Content types:") ); + TQString printerHost; + bool canPrintPostscript = FALSE; + if ( configuration.open( IO_ReadOnly ) ) { + while ( !configuration.atEnd() && + configuration.readLine( line, 1024 ) > 0 ) { + if ( TQString::fromLatin1(line).startsWith( remote ) ) { + const char * p = line; + while ( *p != ':' ) + p++; + p++; + while ( isspace((uchar) *p) ) + p++; + printerHost = TQString::fromLocal8Bit(p); + printerHost = printerHost.simplifyWhiteSpace(); + } else if ( TQString::fromLatin1(line).startsWith( contentType ) ) { + char * p = line; + while ( *p != ':' ) + p++; + p++; + char * e; + while ( *p ) { + while ( isspace((uchar) *p) ) + p++; + if ( *p ) { + char s; + e = p; + while ( isalnum((uchar) *e) ) + e++; + s = *e; + *e = '\0'; + if ( !qstrcmp( p, "postscript" ) || + !qstrcmp( p, "any" ) ) + canPrintPostscript = TRUE; + *e = s; + if ( s == ',' ) + e++; + p = e; + } + } + } + } + if ( canPrintPostscript ) + perhapsAddPrinter( printers, printer->fileName(), + printerHost, TQString::fromLatin1("") ); + } + delete[] line; + } + } +} + + +// solaris 2.6 +static char * parsePrintersConf( TQListView * printers, bool *found = 0 ) +{ + TQFile pc( TQString::fromLatin1("/etc/printers.conf") ); + if ( !pc.open( IO_ReadOnly ) ) { + if ( found ) + *found = FALSE; + return 0; + } + if ( found ) + *found = TRUE; + + char * line = new char[1025]; + line[1024] = '\0'; + + TQString printerDesc; + int lineLength = 0; + + char * defaultPrinter = 0; + + while ( !pc.atEnd() && + (lineLength=pc.readLine( line, 1024 )) > 0 ) { + if ( *line == '#' ) { + *line = '\0'; + lineLength = 0; + } + if ( lineLength >= 2 && line[lineLength-2] == '\\' ) { + line[lineLength-2] = '\0'; + printerDesc += TQString::fromLocal8Bit(line); + } else { + printerDesc += TQString::fromLocal8Bit(line); + printerDesc = printerDesc.simplifyWhiteSpace(); + int i = printerDesc.find( ':' ); + TQString printerName, printerHost, printerComment; + TQStringList aliases; + if ( i >= 0 ) { + // have : want | + int j = printerDesc.find( '|', 0 ); + if ( j >= i ) + j = -1; + printerName = printerDesc.mid( 0, j < 0 ? i : j ); + if ( printerName == TQString::fromLatin1("_default") ) { + i = printerDesc.find( + TQRegExp( TQString::fromLatin1(": *use *=") ) ); + while ( printerDesc[i] != '=' ) + i++; + while ( printerDesc[i] == '=' || printerDesc[i].isSpace() ) + i++; + j = i; + while ( j < (int)printerDesc.length() && + printerDesc[j] != ':' && printerDesc[j] != ',' ) + j++; + // that's our default printer + defaultPrinter = + tqstrdup( printerDesc.mid( i, j-i ).ascii() ); + printerName = ""; + printerDesc = ""; + } else if ( printerName == TQString::fromLatin1("_all") ) { + // skip it.. any other cases we want to skip? + printerName = ""; + printerDesc = ""; + } + + if ( j > 0 ) { + // try extracting a comment from the aliases + aliases = TQStringList::split( '|', + printerDesc.mid(j + 1, i - j - 1) ); + printerComment = TQPrintDialog::tr( "Aliases: %1" ) + .arg( aliases.join(", ") ); + } + // look for signs of this being a remote printer + i = printerDesc.find( + TQRegExp( TQString::fromLatin1(": *bsdaddr *=") ) ); + if ( i >= 0 ) { + // point k at the end of remote host name + while ( printerDesc[i] != '=' ) + i++; + while ( printerDesc[i] == '=' || printerDesc[i].isSpace() ) + i++; + j = i; + while ( j < (int)printerDesc.length() && + printerDesc[j] != ':' && printerDesc[j] != ',' ) + j++; + // and stuff that into the string + printerHost = printerDesc.mid( i, j-i ); + // maybe stick the remote printer name into the comment + if ( printerDesc[j] == ',' ) { + i = ++j; + while ( printerDesc[i].isSpace() ) + i++; + j = i; + while ( j < (int)printerDesc.length() && + printerDesc[j] != ':' && printerDesc[j] != ',' ) + j++; + if ( printerName != printerDesc.mid( i, j-i ) ) { + printerComment = + TQString::fromLatin1("Remote name: "); + printerComment += printerDesc.mid( i, j-i ); + } + } + } + } + if ( printerComment == ":" ) + printerComment = ""; // for cups + if ( printerName.length() ) + perhapsAddPrinter( printers, printerName, printerHost, + printerComment, aliases ); + // chop away the line, for processing the next one + printerDesc = ""; + } + } + delete[] line; + return defaultPrinter; +} + +#ifndef TQT_NO_NIS + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +static int foreach( int /* status */, char * /* key */, int /* keyLen */, + char * val, int valLen, char * data ) +{ + parsePrinterDesc( TQString::fromLatin1(val, valLen), (TQListView *) data ); + return 0; +} + +#if defined(Q_C_CALLBACKS) +} +#endif + +static int retrieveNisPrinters( TQListView * printers ) +{ + typedef int (*WildCast)( int, char *, int, char *, int, char * ); + char printersConfByname[] = "printers.conf.byname"; + char *domain; + int err; + + TQLibrary lib( "nsl" ); + typedef int (*ypGetDefaultDomain)(char **); + ypGetDefaultDomain _ypGetDefaultDomain = (ypGetDefaultDomain)lib.resolve( "yp_get_default_domain" ); + typedef int (*ypAll)(const char *, const char *, const struct ypall_callback *); + ypAll _ypAll = (ypAll)lib.resolve( "yp_all" ); + + if ( _ypGetDefaultDomain && _ypAll ) { + err = _ypGetDefaultDomain( &domain ); + if ( err == 0 ) { + ypall_callback cb; + // wild cast to support K&R-style system headers + (WildCast &) cb.foreach = (WildCast) foreach; + cb.data = (char *) printers; + err = _ypAll( domain, printersConfByname, &cb ); + } + if ( !err ) + return Success; + } + return Unavail; +} + +#endif // TQT_NO_NIS + +static char *parseNsswitchPrintersEntry( TQListView * printers, char *line ) +{ +#define skipSpaces() \ + while ( isspace((uchar) line[k]) ) \ + k++ + + char *defaultPrinter = 0; + bool stop = FALSE; + int lastStatus = NotFound; + + int k = 8; + skipSpaces(); + if ( line[k] != ':' ) + return 0; + k++; + + char *cp = strchr( line, '#' ); + if ( cp != 0 ) + *cp = '\0'; + + while ( line[k] != '\0' ) { + if ( isspace((uchar) line[k]) ) { + k++; + } else if ( line[k] == '[' ) { + k++; + skipSpaces(); + while ( line[k] != '\0' ) { + char status = tolower( line[k] ); + char action = '?'; + + while ( line[k] != '=' && line[k] != ']' && + line[k] != '\0' ) + k++; + if ( line[k] == '=' ) { + k++; + skipSpaces(); + action = tolower( line[k] ); + while ( line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != ']' ) + k++; + } else if ( line[k] == ']' ) { + k++; + break; + } + skipSpaces(); + + if ( lastStatus == status ) + stop = ( action == (char) Return ); + } + } else { + if ( stop ) + break; + + TQCString source; + while ( line[k] != '\0' && !isspace((uchar) line[k]) && line[k] != '[' ) { + source += line[k]; + k++; + } + + if ( source == "user" ) { + lastStatus = parsePrintcap( printers, + TQDir::homeDirPath() + "/.printers" ); + } else if ( source == "files" ) { + bool found; + defaultPrinter = parsePrintersConf( printers, &found ); + if ( found ) + lastStatus = Success; +#ifndef TQT_NO_NIS + } else if ( source == "nis" ) { + lastStatus = retrieveNisPrinters( printers ); +#endif + } else { + // nisplus, dns, etc., are not implemented yet + lastStatus = NotFound; + } + stop = ( lastStatus == Success ); + } + } + return defaultPrinter; +} + +static char *parseNsswitchConf( TQListView * printers ) +{ + TQFile nc( TQString::fromLatin1("/etc/nsswitch.conf") ); + if ( !nc.open(IO_ReadOnly) ) + return 0; + + char *defaultPrinter = 0; + + char *line = new char[1025]; + line[1024] = '\0'; + + while ( !nc.atEnd() && + nc.readLine(line, 1024) > 0 ) { + if ( strncmp(line, "printers", 8) == 0 ) { + defaultPrinter = parseNsswitchPrintersEntry( printers, line ); + delete[] line; + return defaultPrinter; + } + } + + strcpy( line, "printers: user files nis nisplus xfn" ); + defaultPrinter = parseNsswitchPrintersEntry( printers, line ); + delete[] line; + return defaultPrinter; +} + +// HP-UX +static void parseEtcLpMember( TQListView * printers ) +{ + TQDir lp( TQString::fromLatin1("/etc/lp/member") ); + if ( !lp.exists() ) + return; + const TQFileInfoList * dirs = lp.entryInfoList(); + if ( !dirs ) + return; + + TQFileInfoListIterator it( *dirs ); + TQFileInfo *printer; + TQString tmp; + while ( (printer = it.current()) != 0 ) { + ++it; + // I haven't found any real documentation, so I'm guessing that + // since lpstat uses /etc/lp/member rather than one of the + // other directories, it's the one to use. I did not find a + // decent way to locate aliases and remote printers. + if ( printer->isFile() ) + perhapsAddPrinter( printers, printer->fileName(), + TQPrintDialog::tr("unknown"), + TQString::fromLatin1("") ); + } +} + +// IRIX 6.x +static void parseSpoolInterface( TQListView * printers ) +{ + TQDir lp( TQString::fromLatin1("/usr/spool/lp/interface") ); + if ( !lp.exists() ) + return; + const TQFileInfoList * files = lp.entryInfoList(); + if( !files ) + return; + + TQFileInfoListIterator it( *files ); + TQFileInfo *printer; + while ( (printer = it.current()) != 0) { + ++it; + + if ( !printer->isFile() ) + continue; + + // parse out some information + TQFile configFile( printer->filePath() ); + if ( !configFile.open( IO_ReadOnly ) ) + continue; + + TQCString line( 1025 ); + TQString namePrinter; + TQString hostName; + TQString hostPrinter; + TQString printerType; + + TQString nameKey( TQString::fromLatin1("NAME=") ); + TQString typeKey( TQString::fromLatin1("TYPE=") ); + TQString hostKey( TQString::fromLatin1("HOSTNAME=") ); + TQString hostPrinterKey( TQString::fromLatin1("HOSTPRINTER=") ); + + while ( !configFile.atEnd() && + (configFile.readLine(line.data(), 1024)) > 0 ) { + TQString uline = line; + if ( uline.startsWith( typeKey ) ) { + printerType = line.mid( nameKey.length() ); + printerType = printerType.simplifyWhiteSpace(); + } else if ( uline.startsWith( hostKey ) ) { + hostName = line.mid( hostKey.length() ); + hostName = hostName.simplifyWhiteSpace(); + } else if ( uline.startsWith( hostPrinterKey ) ) { + hostPrinter = line.mid( hostPrinterKey.length() ); + hostPrinter = hostPrinter.simplifyWhiteSpace(); + } else if ( uline.startsWith( nameKey ) ) { + namePrinter = line.mid( nameKey.length() ); + namePrinter = namePrinter.simplifyWhiteSpace(); + } + } + configFile.close(); + + printerType = printerType.stripWhiteSpace(); + if ( printerType.find("postscript", 0, FALSE) < 0 ) + continue; + + int ii = 0; + while ( (ii = namePrinter.find('"', ii)) >= 0 ) + namePrinter.remove( ii, 1 ); + + if ( hostName.isEmpty() || hostPrinter.isEmpty() ) { + perhapsAddPrinter( printers, printer->fileName(), + TQString::fromLatin1(""), namePrinter ); + } else { + TQString comment; + comment = namePrinter; + comment += " ("; + comment += hostPrinter; + comment += ")"; + perhapsAddPrinter( printers, printer->fileName(), + hostName, comment ); + } + } +} + + +// Every unix must have its own. It's a standard. Here is AIX. +static void parseQconfig( TQListView * printers ) +{ + TQFile qconfig( TQString::fromLatin1("/etc/qconfig") ); + if ( !qconfig.open( IO_ReadOnly ) ) + return; + + TQTextStream ts( &qconfig ); + TQString line; + + TQString stanzaName; // either a queue or a device name + bool up = TRUE; // queue up? default TRUE, can be FALSE + TQString remoteHost; // null if local + TQString deviceName; // null if remote + + TQRegExp newStanza( TQString::fromLatin1("^[0-z\\-]+:$") ); + + // our basic strategy here is to process each line, detecting new + // stanzas. each time we see a new stanza, we check if the + // previous stanza was a valid queue for a) a remote printer or b) + // a local printer. if it wasn't, we assume that what we see is + // the start of the first stanza, or that the previous stanza was + // a device stanza, or that there is some syntax error (we don't + // report those). + + do { + line = ts.readLine(); + bool indented = line[0].isSpace(); + line = line.simplifyWhiteSpace(); + + int i = line.find('='); + if ( indented && i != -1 ) { // line in stanza + TQString variable = line.left( i ).simplifyWhiteSpace(); + TQString value=line.mid( i+1, line.length() ).simplifyWhiteSpace(); + if ( variable == TQString::fromLatin1("device") ) + deviceName = value; + else if ( variable == TQString::fromLatin1("host") ) + remoteHost = value; + else if ( variable == TQString::fromLatin1("up") ) + up = !(value.lower() == TQString::fromLatin1("false")); + } else if ( line[0] == '*' ) { // comment + // nothing to do + } else if ( ts.atEnd() || // end of file, or beginning of new stanza + ( !indented && line.find( newStanza ) != -1 ) ) { + if ( up && stanzaName.length() > 0 && stanzaName.length() < 21 ) { + if ( remoteHost.length() ) // remote printer + perhapsAddPrinter( printers, stanzaName, remoteHost, + TQString::null ); + else if ( deviceName.length() ) // local printer + perhapsAddPrinter( printers, stanzaName, TQString::null, + TQString::null ); + } + line.truncate( line.length()-1 ); + if ( line.length() >= 1 && line.length() <= 20 ) + stanzaName = line; + up = TRUE; + remoteHost = TQString::null; + deviceName = TQString::null; + } else { + // syntax error? ignore. + } + } while ( !ts.atEnd() ); +} + + +#ifndef TQT_NO_CUPS +#include + +static char * parseCupsOutput( TQListView * printers ) +{ + char * defaultPrinter = 0; + int nd; + cups_dest_t * d; + TQLibrary lib( "cups" ); + typedef int (*CupsGetDests)(cups_dest_t **dests); + typedef void (*CupsFreeDests)(int num_dents, cups_dest_t *dests); + CupsGetDests _cupsGetDests = (CupsGetDests)lib.resolve( "cupsGetDests" ); + CupsFreeDests _cupsFreeDests = (CupsFreeDests)lib.resolve( "cupsFreeDests" ); + if ( _cupsGetDests ) { + nd = _cupsGetDests( &d ); + if ( nd < 1 ) + return 0; + + int n = 0; + while ( n < nd ) { + perhapsAddPrinter( printers, d[n].name, + TQPrintDialog::tr("Unknown Location"), 0 ); + if ( d[n].is_default && !defaultPrinter ) + defaultPrinter = tqstrdup( d[n].instance ); + n++; + } + if ( _cupsFreeDests ) { + _cupsFreeDests(nd, d); + } + } + return defaultPrinter; +} +#endif + +static TQPrintDialog * globalPrintDialog = 0; + +static void qpd_cleanup_globaldialog() +{ + if ( globalPrintDialog != 0 ) + delete globalPrintDialog; + globalPrintDialog = 0; +} + +/*! + \class TQPrintDialog tqprintdialog.h + + \brief The TQPrintDialog class provides a dialog for specifying + the printer's configuration. + + \internal + + \warning The use of this class is not recommended since it is not + present on all platforms; use TQPrinter::setup() instead. + + \omit + + (ingroup dialogs) + + THIS DOCUMENTATION IS Not Revised. It must be revised before + becoming public API. + + It encompasses both the sort of details needed for doing a simple + print-out and some print configuration setup. + + The easiest way to use the class is through the static + function getPrinterSetup(). You can also subclass the TQPrintDialog + and add some custom buttons with addButton() to extend the + functionality of the print dialog. + +
+ The printer dialog, on a large screen, in Motif style. +*/ + + +/*! Constructs a new modal printer dialog that configures \a prn and is a + child of \a parent named \a name. +*/ + +TQPrintDialog::TQPrintDialog( TQPrinter *prn, TQWidget *parent, const char *name ) + : TQDialog( parent, name, TRUE ) +{ + d = new TQPrintDialogPrivate; + d->numCopies = 1; + + TQBoxLayout * tll = new TQBoxLayout( this, TQBoxLayout::Down, 12, 0 ); + + // destination + TQGroupBox * g; + g = setupDestination(); + tll->addWidget( g, 1 ); + + tll->addSpacing( 12 ); + + // printer and paper settings + TQBoxLayout * lay = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( lay ); + + g = setupPrinterSettings(); + lay->addWidget( g, 1 ); + + lay->addSpacing( 12 ); + + g = setupPaper(); + lay->addWidget( g ); + + tll->addSpacing( 12 ); + + // options + g = setupOptions(); + tll->addWidget( g ); + tll->addSpacing( 12 ); + + TQBoxLayout *l = new TQBoxLayout( TQBoxLayout::LeftToRight ); + d->customLayout = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( l ); + l->addLayout( d->customLayout ); + l->addStretch(); + tll->addSpacing( 12 ); + + // buttons + TQBoxLayout *horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( horiz ); + + bool rightalign = + bool(style().styleHint(TQStyle::SH_PrintDialog_RightAlignButtons, this)); + + if (rightalign) + horiz->addStretch( 1 ); + + d->ok = new TQPushButton( this, "ok" ); + d->ok->setText( tr("OK") ); + d->ok->setDefault( TRUE ); + horiz->addWidget( d->ok ); + if (! rightalign) + horiz->addStretch( 1 ); + horiz->addSpacing( 6 ); + + TQPushButton * cancel = new TQPushButton( this, "cancel" ); + cancel->setText( tr("Cancel") ); + horiz->addWidget( cancel ); + + TQSize s1 = d->ok->sizeHint(); + TQSize s2 = cancel->sizeHint(); + s1 = TQSize( TQMAX(s1.width(), s2.width()), + TQMAX(s1.height(), s2.height()) ); + + d->ok->setFixedSize( s1 ); + cancel->setFixedSize( s1 ); + + tll->activate(); + + connect( d->ok, TQ_SIGNAL(clicked()), TQ_SLOT(okClicked()) ); + connect( cancel, TQ_SIGNAL(clicked()), TQ_SLOT(reject()) ); + + TQSize ms( minimumSize() ); + TQSize ss( TQApplication::desktop()->screenGeometry( pos() ).size() ); + if ( ms.height() < 512 && ss.height() >= 600 ) + ms.setHeight( 512 ); + else if ( ms.height() < 460 && ss.height() >= 480 ) + ms.setHeight( 460 ); + resize( ms ); + + setPrinter( prn, TRUE ); + d->printers->setFocus(); +} + + +/*! Destroys the object and frees any allocated resources. Does not + delete the associated TQPrinter object. +*/ + +TQPrintDialog::~TQPrintDialog() +{ + if ( this == globalPrintDialog ) + globalPrintDialog = 0; + delete d; +} + +/*! + This method allows you to specify a global print dialog, given in \a + pd, that will be used instead of the default dialog provided by TQt. + + This is useful, since there are many different printing systems on + Unix, and we cannot support all of them. Calling this method before + using a printer for the first time allows you to set up your own + print dialog. + + \sa setupPrinters() +*/ +void TQPrintDialog::setGlobalPrintDialog( TQPrintDialog *pd ) +{ + TQPrintDialog *oldPd = globalPrintDialog; + globalPrintDialog = pd; + if ( oldPd ) + delete oldPd; + else + tqAddPostRoutine( qpd_cleanup_globaldialog ); + globalPrintDialog->adjustSize(); +} + +TQGroupBox * TQPrintDialog::setupPrinterSettings() +{ + TQGroupBox * g = new TQGroupBox( 1, Horizontal, tr( "Printer settings"), + this, "settings group box" ); + + d->colorMode = new TQButtonGroup( this ); + d->colorMode->hide(); + connect( d->colorMode, TQ_SIGNAL(clicked(int)), + this, TQ_SLOT(colorModeSelected(int)) ); + + TQRadioButton *rb; + rb = new TQRadioButton( tr( "Print in color if available" ), + g, "color" ); + d->colorMode->insert( rb, TQPrinter::Color ); + rb->setChecked( TRUE ); + + rb = new TQRadioButton( tr("Print in grayscale"), + g, "graysacle" ); + d->colorMode->insert( rb, TQPrinter::GrayScale ); + + return g; +} + +TQGroupBox * TQPrintDialog::setupDestination() +{ + TQGroupBox * g = new TQGroupBox( 0, Horizontal, tr( "Print destination"), + this, "destination group box" ); + + TQBoxLayout * tll = new TQBoxLayout( g->layout(), TQBoxLayout::Down ); + + d->printerOrFile = new TQButtonGroup( this ); + d->printerOrFile->hide(); + connect( d->printerOrFile, TQ_SIGNAL(clicked(int)), + this, TQ_SLOT(printerOrFileSelected(int)) ); + + // printer radio button, list + TQRadioButton * rb = new TQRadioButton( tr( "Print to printer:" ), g, + "printer" ); + tll->addWidget( rb ); + d->printerOrFile->insert( rb, 0 ); + rb->setChecked( TRUE ); + d->outputToFile = FALSE; + + TQBoxLayout * horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( horiz, 3 ); + horiz->addSpacing( 19 ); + + d->printers = new TQListView( g, "list of printers" ); + d->printers->setAllColumnsShowFocus( TRUE ); + d->printers->addColumn( tr("Printer"), 125 ); + d->printers->addColumn( tr("Host"), 125 ); + d->printers->addColumn( tr("Comment"), 150 ); + +#if defined(Q_OS_UNIX) + char * etcLpDefault = 0; + +#ifndef TQT_NO_CUPS + etcLpDefault = parseCupsOutput( d->printers ); +#endif + if ( d->printers->childCount() == 0 ) { + // we only use other schemes when cups fails. + + parsePrintcap( d->printers, TQString::fromLatin1("/etc/printcap") ); + parseEtcLpMember( d->printers ); + parseSpoolInterface( d->printers ); + parseQconfig( d->printers ); + if ( addPrinterHook ) + (*addPrinterHook)( d->printers ); + + TQFileInfo f; + f.setFile( TQString::fromLatin1("/etc/lp/printers") ); + if ( f.isDir() ) { + parseEtcLpPrinters( d->printers ); + TQFile def( TQString::fromLatin1("/etc/lp/default") ); + if ( def.open( IO_ReadOnly ) ) { + if ( etcLpDefault ) + delete[] etcLpDefault; + etcLpDefault = new char[1025]; + def.readLine( etcLpDefault, 1024 ); + char * p = etcLpDefault; + while ( p && *p ) { + if ( !isprint((uchar) *p) || isspace((uchar) *p) ) + *p = 0; + else + p++; + } + } + } + + char * def = 0; + f.setFile( TQString::fromLatin1("/etc/nsswitch.conf") ); + if ( f.isFile() ) { + def = parseNsswitchConf( d->printers ); + } else { + f.setFile( TQString::fromLatin1("/etc/printers.conf") ); + if ( f.isFile() ) + def = parsePrintersConf( d->printers ); + } + + if ( def ) { + if ( etcLpDefault ) + delete[] etcLpDefault; + etcLpDefault = def; + } + } + + // all printers hopefully known. try to find a good default + TQString dollarPrinter; + { + const char * t = getenv( "PRINTER" ); + if ( !t || !*t ) + t = getenv( "LPDEST" ); + dollarPrinter = TQString::fromLatin1( t ); + if ( !dollarPrinter.isEmpty() ) + perhapsAddPrinter( d->printers, dollarPrinter, + TQPrintDialog::tr("unknown"), + TQString::fromLatin1("") ); + } + int quality = 0; + + // bang the best default into the listview + const TQListViewItem * lvi = d->printers->firstChild(); + d->printers->setCurrentItem( (TQListViewItem *)lvi ); + while ( lvi ) { + TQRegExp ps( TQString::fromLatin1("[^a-z]ps(?:[^a-z]|$)") ); + TQRegExp lp( TQString::fromLatin1("[^a-z]lp(?:[^a-z]|$)") ); + + if ( quality < 4 && lvi->text(0) == dollarPrinter ) { + d->printers->setCurrentItem( (TQListViewItem *)lvi ); + quality = 4; + } else if ( quality < 3 && etcLpDefault && + lvi->text(0) == TQString::fromLatin1(etcLpDefault) ) { + d->printers->setCurrentItem( (TQListViewItem *)lvi ); + quality = 3; + } else if ( quality < 2 && + ( lvi->text(0) == TQString::fromLatin1("ps") || + ps.search(lvi->text(2)) != -1 ) ) { + d->printers->setCurrentItem( (TQListViewItem *)lvi ); + quality = 2; + } else if ( quality < 1 && + ( lvi->text(0) == TQString::fromLatin1("lp") || + lp.search(lvi->text(2)) > -1 ) ) { + d->printers->setCurrentItem( (TQListViewItem *)lvi ); + quality = 1; + } + lvi = lvi->nextSibling(); + } + + if ( d->printers->currentItem() ) + d->printers->setSelected( d->printers->currentItem(), TRUE ); + + if ( etcLpDefault ) // Avoid purify complaint + delete[] etcLpDefault; +#endif + + int h = fontMetrics().height(); + if ( d->printers->firstChild() ) + h = d->printers->firstChild()->height(); + d->printers->setMinimumSize( d->printers->sizeHint().width(), + d->printers->header()->height() + + 3 * h ); + horiz->addWidget( d->printers, 3 ); + + tll->addSpacing( 6 ); + + // file radio button, edit/browse + d->printToFileButton = new TQRadioButton( tr( "Print to file:" ), g, "file" ); + tll->addWidget( d->printToFileButton ); + d->printerOrFile->insert( d->printToFileButton, 1 ); + + horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( horiz ); + horiz->addSpacing( 19 ); + + d->fileName = new TQLineEdit( g, "file name" ); + connect( d->fileName, TQ_SIGNAL( textChanged(const TQString&) ), + this, TQ_SLOT( fileNameEditChanged(const TQString&) ) ); + horiz->addWidget( d->fileName, 1 ); + horiz->addSpacing( 6 ); + d->browse = new TQPushButton( tr("Browse..."), g, "browse files" ); + d->browse->setAutoDefault( FALSE ); +#ifdef TQT_NO_FILEDIALOG + d->browse->setEnabled( FALSE ); +#endif + connect( d->browse, TQ_SIGNAL(clicked()), + this, TQ_SLOT(browseClicked()) ); + horiz->addWidget( d->browse ); + + d->fileName->setEnabled( FALSE ); + d->browse->setEnabled( FALSE ); + + tll->activate(); + + return g; +} + + +TQGroupBox * TQPrintDialog::setupOptions() +{ + TQGroupBox * g = new TQGroupBox( 0, Horizontal, tr( "Options"), + this, "options group box" ); + + TQBoxLayout * tll = new TQBoxLayout( g->layout(), TQBoxLayout::Down ); + + TQBoxLayout *lay = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( lay ); + + tll = new TQBoxLayout( lay, TQBoxLayout::Down ); + + d->printRange = new TQButtonGroup( this ); + d->printRange->hide(); + connect( d->printRange, TQ_SIGNAL(clicked(int)), + this, TQ_SLOT(printRangeSelected(int)) ); + + d->pageOrder = new TQButtonGroup( this ); + d->pageOrder->hide(); + connect( d->pageOrder, TQ_SIGNAL(clicked(int)), + this, TQ_SLOT(pageOrderSelected(int)) ); + + d->printAllButton = new TQRadioButton( tr("Print all"), g, "print all" ); + d->printRange->insert( d->printAllButton, 0 ); + tll->addWidget( d->printAllButton ); + + d->printSelectionButton = new TQRadioButton( tr("Print selection"), + g, "print selection" ); + d->printRange->insert( d->printSelectionButton, 1 ); + tll->addWidget( d->printSelectionButton ); + + d->printRangeButton = new TQRadioButton( tr("Print range"), + g, "print range" ); + d->printRange->insert( d->printRangeButton, 2 ); + tll->addWidget( d->printRangeButton ); + + TQBoxLayout * horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( horiz ); + + d->firstPageLabel = new TQLabel( tr("From page:"), g, "first page" ); + horiz->addSpacing( 19 ); + horiz->addWidget( d->firstPageLabel ); + + d->firstPage = new TQPrintDialogSpinBox( 1, 9999, 1, g, "first page" ); + d->firstPage->setValue( 1 ); + horiz->addWidget( d->firstPage, 1 ); + connect( d->firstPage, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(setFirstPage(int)) ); + + horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( horiz ); + + d->lastPageLabel = new TQLabel( tr("To page:"), g, "last page" ); + horiz->addSpacing( 19 ); + horiz->addWidget( d->lastPageLabel ); + + d->lastPage = new TQPrintDialogSpinBox( 1, 9999, 1, g, "last page" ); + d->lastPage->setValue( 9999 ); + horiz->addWidget( d->lastPage, 1 ); + connect( d->lastPage, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(setLastPage(int)) ); + + lay->addSpacing( 25 ); + tll = new TQBoxLayout( lay, TQBoxLayout::Down ); + + // print order + TQRadioButton * rb = new TQRadioButton( tr("Print first page first"), + g, "first page first" ); + tll->addWidget( rb ); + d->pageOrder->insert( rb, TQPrinter::FirstPageFirst ); + rb->setChecked( TRUE ); + + rb = new TQRadioButton( tr("Print last page first"), + g, "last page first" ); + tll->addWidget( rb ); + d->pageOrder->insert( rb, TQPrinter::LastPageFirst ); + + tll->addStretch(); + + // copies + + horiz = new TQBoxLayout( TQBoxLayout::LeftToRight ); + tll->addLayout( horiz ); + + TQLabel * l = new TQLabel( tr("Number of copies:"), g, "Number of copies" ); + horiz->addWidget( l ); + + d->copies = new TQPrintDialogSpinBox( 1, 99, 1, g, "copies" ); + d->copies->setValue( 1 ); + horiz->addWidget( d->copies, 1 ); + connect( d->copies, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(setNumCopies(int)) ); + + TQSize s = d->firstPageLabel->sizeHint() + .expandedTo( d->lastPageLabel->sizeHint() ) + .expandedTo( l->sizeHint() ); + d->firstPageLabel->setMinimumSize( s ); + d->lastPageLabel->setMinimumSize( s ); + l->setMinimumSize( s.width() + 19, s.height() ); + + tll->activate(); + + return g; +} + + +void isc( TQPrintDialogPrivate * d, + const TQString & text, + TQPrinter::PageSize ps ) +{ + if ( d && text && ps < TQPrinter::NPageSize ) { + d->sizeCombo->insertItem( text, -1 ); + int index = d->sizeCombo->count()-1; + if ( index >= 0 && index < TQPrinter::NPageSize ) + d->indexToPageSize[index] = ps; + } +} + +TQGroupBox * TQPrintDialog::setupPaper() +{ + TQGroupBox * g = new TQGroupBox( 1, Horizontal, tr( "Paper format"), + this, "Paper format" ); + d->pageSize = TQPrinter::A4; + + // page orientation + d->orientationCombo = new TQComboBox( FALSE, g ); + d->orientationCombo->insertItem( tr( "Portrait" ), -1 ); + d->orientationCombo->insertItem( tr( "Landscape" ), -1 ); + + d->orientation = TQPrinter::Portrait; + + g->addSpace( 8 ); + + connect( d->orientationCombo, TQ_SIGNAL( activated(int) ), + this, TQ_SLOT( orientSelected(int) ) ); + + // paper size + d->sizeCombo = new TQComboBox( FALSE, g ); + + int n; + for( n=0; nindexToPageSize[n] = TQPrinter::A4; + + isc( d, tr( "A0 (841 x 1189 mm)" ), TQPrinter::A0 ); + isc( d, tr( "A1 (594 x 841 mm)" ), TQPrinter::A1 ); + isc( d, tr( "A2 (420 x 594 mm)" ), TQPrinter::A2 ); + isc( d, tr( "A3 (297 x 420 mm)" ), TQPrinter::A3 ); + isc( d, tr( "A4 (210x297 mm, 8.26x11.7 inches)" ), TQPrinter::A4 ); + isc( d, tr( "A5 (148 x 210 mm)" ), TQPrinter::A5 ); + isc( d, tr( "A6 (105 x 148 mm)" ), TQPrinter::A6 ); + isc( d, tr( "A7 (74 x 105 mm)" ), TQPrinter::A7 ); + isc( d, tr( "A8 (52 x 74 mm)" ), TQPrinter::A8 ); + isc( d, tr( "A9 (37 x 52 mm)" ), TQPrinter::A9 ); + isc( d, tr( "B0 (1000 x 1414 mm)" ), TQPrinter::B0 ); + isc( d, tr( "B1 (707 x 1000 mm)" ), TQPrinter::B1 ); + isc( d, tr( "B2 (500 x 707 mm)" ), TQPrinter::B2 ); + isc( d, tr( "B3 (353 x 500 mm)" ), TQPrinter::B3 ); + isc( d, tr( "B4 (250 x 353 mm)" ), TQPrinter::B4 ); + isc( d, tr( "B5 (176 x 250 mm, 6.93x9.84 inches)" ), TQPrinter::B5 ); + isc( d, tr( "B6 (125 x 176 mm)" ), TQPrinter::B6 ); + isc( d, tr( "B7 (88 x 125 mm)" ), TQPrinter::B7 ); + isc( d, tr( "B8 (62 x 88 mm)" ), TQPrinter::B8 ); + isc( d, tr( "B9 (44 x 62 mm)" ), TQPrinter::B9 ); + isc( d, tr( "B10 (31 x 44 mm)" ), TQPrinter::B10 ); + isc( d, tr( "C5E (163 x 229 mm)" ), TQPrinter::C5E ); + isc( d, tr( "DLE (110 x 220 mm)" ), TQPrinter::DLE ); + isc( d, tr( "Executive (7.5x10 inches, 191x254 mm)" ), TQPrinter::Executive ); + isc( d, tr( "Folio (210 x 330 mm)" ), TQPrinter::Folio ); + isc( d, tr( "Ledger (432 x 279 mm)" ), TQPrinter::Ledger ); + isc( d, tr( "Legal (8.5x14 inches, 216x356 mm)" ), TQPrinter::Legal ); + isc( d, tr( "Letter (8.5x11 inches, 216x279 mm)" ), TQPrinter::Letter ); + isc( d, tr( "Tabloid (279 x 432 mm)" ), TQPrinter::Tabloid ); + isc( d, tr( "US Common #10 Envelope (105 x 241 mm)" ), TQPrinter::Comm10E ); + + connect( d->sizeCombo, TQ_SIGNAL( activated(int) ), + this, TQ_SLOT( paperSizeSelected(int) ) ); + + return g; +} + + +/*! + Display a dialog and allow the user to configure the TQPrinter \a + p for an optional widget \a w. Returns TRUE if the user clicks OK or + presses Enter, FALSE if the user clicks Cancel or presses Esc. + + getPrinterSetup() remembers the settings and provides the same + settings the next time the dialog is shown. +*/ + +bool TQPrintDialog::getPrinterSetup( TQPrinter * p, TQWidget* w ) +{ + if ( !globalPrintDialog ) { + globalPrintDialog = new TQPrintDialog( 0, 0, "global print dialog" ); +#ifndef TQT_NO_WIDGET_TOPEXTRA + globalPrintDialog->setCaption( TQPrintDialog::tr( "Setup Printer" ) ); +#endif + tqAddPostRoutine( qpd_cleanup_globaldialog ); + globalPrintDialog->setPrinter( p, TRUE ); + globalPrintDialog->adjustSize(); + } else { + globalPrintDialog->setPrinter( p, TRUE ); + } + globalPrintDialog->adjustPosition( w ); + #ifndef TQT_NO_WIDGET_TOPEXTRA + if ( w ) { + const TQPixmap *pm = w->icon(); + if ( pm && !pm->isNull() ) + globalPrintDialog->setIcon( *pm ); + else { + w = w ? w->topLevelWidget() : 0; + pm = w ? w->icon() : 0; + if ( pm && !pm->isNull() ) + globalPrintDialog->setIcon( *pm ); + } + } +#endif + bool r = globalPrintDialog->exec() == TQDialog::Accepted; + globalPrintDialog->setPrinter( 0 ); + return r; +} + + +void TQPrintDialog::printerOrFileSelected( int id ) +{ + d->outputToFile = id ? TRUE : FALSE; + if ( d->outputToFile ) { + d->ok->setEnabled( TRUE ); + fileNameEditChanged( d->fileName->text() ); + if ( !d->fileName->edited() && d->fileName->text().isEmpty() ) { + TQString home = TQString::fromLatin1( ::getenv( "HOME" ) ); + TQString cur = TQDir::currentDirPath(); + if ( home.at(home.length()-1) != '/' ) + home += '/'; + if ( cur.at(cur.length()-1) != '/' ) + cur += '/'; + if ( cur.left( home.length() ) != home ) + cur = home; +#ifdef TQ_WS_X11 + cur += "print.ps"; +#endif + d->fileName->setText( cur ); + d->fileName->setCursorPosition( cur.length() ); + d->fileName->selectAll(); + } + d->browse->setEnabled( TRUE ); + d->fileName->setEnabled( TRUE ); + d->fileName->setFocus(); + d->printers->setEnabled( FALSE ); + } else { + d->ok->setEnabled( d->printers->childCount() != 0 ); + d->printers->setEnabled( TRUE ); + if ( d->fileName->hasFocus() || d->browse->hasFocus() ) + d->printers->setFocus(); + d->browse->setEnabled( FALSE ); + d->fileName->setEnabled( FALSE ); + } +} + + +void TQPrintDialog::landscapeSelected( int id ) +{ + d->orientation = (TQPrinter::Orientation)id; +} + + +void TQPrintDialog::paperSizeSelected( int id ) +{ + if ( id < TQPrinter::NPageSize ) + d->pageSize = TQPrinter::PageSize( d->indexToPageSize[id] ); +} + + +void TQPrintDialog::orientSelected( int id ) +{ + d->orientation = (TQPrinter::Orientation)id; +} + + +void TQPrintDialog::pageOrderSelected( int id ) +{ + d->pageOrder2 = (TQPrinter::PageOrder)id; +} + + +void TQPrintDialog::setNumCopies( int copies ) +{ + d->numCopies = copies; +} + + +void TQPrintDialog::browseClicked() +{ +#ifndef TQT_NO_FILEDIALOG + TQString fn = TQFileDialog::getSaveFileName( d->fileName->text(), tr( "PostScript Files (*.ps);;All Files (*)" ), this ); + if ( !fn.isNull() ) + d->fileName->setText( fn ); +#endif +} + + +void TQPrintDialog::okClicked() +{ + d->lastPage->interpretText(); + d->firstPage->interpretText(); + d->copies->interpretText(); + if ( d->outputToFile ) { + d->printer->setOutputToFile( TRUE ); + d->printer->setOutputFileName( d->fileName->text() ); + } else { + d->printer->setOutputToFile( FALSE ); + TQListViewItem * l = d->printers->currentItem(); + if ( l ) + d->printer->setPrinterName( l->text( 0 ) ); + } + + d->printer->setOrientation( d->orientation ); + d->printer->setPageSize( d->pageSize ); + d->printer->setPageOrder( d->pageOrder2 ); + d->printer->setColorMode( d->colorMode2 ); + d->printer->setNumCopies( d->numCopies ); + if ( d->printAllButton->isChecked() ) { + d->printer->setPrintRange(TQPrinter::AllPages); + d->printer->setFromTo( d->printer->minPage(), d->printer->maxPage() ); + } else { + if (d->printSelectionButton->isChecked()) + d->printer->setPrintRange(TQPrinter::Selection); + else + d->printer->setPrintRange(TQPrinter::PageRange); + d->printer->setFromTo( d->firstPage->value(), d->lastPage->value() ); + } + + accept(); +} + + +void TQPrintDialog::printRangeSelected( int id ) +{ + bool enable = id == 2 ? TRUE : FALSE; + d->firstPage->setEnabled( enable ); + d->lastPage->setEnabled( enable ); + d->firstPageLabel->setEnabled( enable ); + d->lastPageLabel->setEnabled( enable ); +} + + +void TQPrintDialog::setFirstPage( int fp ) +{ + if ( d->printer ) + d->lastPage->setRange( fp, TQMAX(fp, TQPrintDialog::d->printer->maxPage()) ); +} + + +void TQPrintDialog::setLastPage( int lp ) +{ + if ( d->printer ) + d->firstPage->setRange( TQMIN(lp, TQPrintDialog::d->printer->minPage()), lp ); +} + + +/*! + Sets this dialog to configure printer \a p, or no printer if \a p + is null. If \a pickUpSettings is TRUE, the dialog reads most of + its settings from \a p. If \a pickUpSettings is FALSE (the + default) the dialog keeps its old settings. +*/ + +void TQPrintDialog::setPrinter( TQPrinter * p, bool pickUpSettings ) +{ + d->printer = p; + + if ( p && pickUpSettings ) { + // top to botton in the old dialog. + // printer or file + d->printerOrFile->setButton( p->outputToFile() ); + printerOrFileSelected( p->outputToFile() ); + + // printer name + if ( !!p->printerName() ) { + TQListViewItem * i = d->printers->firstChild(); + while ( i && i->text( 0 ) != p->printerName() ) + i = i->nextSibling(); + if ( i ) { + d->printers->setSelected( i, TRUE ); + d->ok->setEnabled( TRUE ); + } else if ( d->fileName->text().isEmpty() ) { + d->ok->setEnabled( d->printers->childCount() != 0 ); + } + } + + // print command does not exist any more + + // file name + d->printToFileButton->setEnabled( d->printer->isOptionEnabled( TQPrinter::PrintToFile ) ); + d->fileName->setText( p->outputFileName() ); + + // orientation + d->orientationCombo->setCurrentItem( (int)p->orientation() ); + orientSelected( p->orientation() ); + + // page size + int n = 0; + while ( n < TQPrinter::NPageSize && + d->indexToPageSize[n] != p->pageSize() ) + n++; + d->sizeCombo->setCurrentItem( n ); + paperSizeSelected( n ); + + // New stuff (Options) + + // page order + d->pageOrder->setButton( (int)p->pageOrder() ); + pageOrderSelected( p->pageOrder() ); + + // color mode + d->colorMode->setButton( (int)p->colorMode() ); + colorModeSelected( p->colorMode() ); + + // number of copies + d->copies->setValue( p->numCopies() ); + setNumCopies( p->numCopies() ); + } + + if( p ) { + d->printAllButton->setEnabled( TRUE ); + d->printSelectionButton + ->setEnabled( d->printer->isOptionEnabled( TQPrinter::PrintSelection ) ); + d->printRangeButton + ->setEnabled( d->printer->isOptionEnabled( TQPrinter::PrintPageRange ) ); + + TQPrinter::PrintRange range = p->printRange(); + switch ( range ) { + case TQPrinter::AllPages: + d->printAllButton->setChecked(TRUE); + printRangeSelected( d->printRange->id( d->printAllButton ) ); + break; + case TQPrinter::Selection: + d->printSelectionButton->setChecked(TRUE); + printRangeSelected( d->printRange->id( d->printSelectionButton ) ); + break; + case TQPrinter::PageRange: + d->printRangeButton->setChecked(TRUE); + printRangeSelected( d->printRange->id( d->printRangeButton ) ); + break; + } + } + + if ( p && p->maxPage() ) { + d->firstPage->setRange( p->minPage(), p->maxPage() ); + d->lastPage->setRange( p->minPage(), p->maxPage() ); + if ( p->fromPage() || p->toPage() ) { + setFirstPage( p->fromPage() ); + setLastPage( p->toPage() ); + d->firstPage->setValue(p->fromPage()); + d->lastPage->setValue(p->toPage()); + } + } +} + + +/*! Returns a pointer to the printer this dialog configures, or 0 if + this dialog does not operate on any printer. */ + +TQPrinter * TQPrintDialog::printer() const +{ + return d->printer; +} + + +void TQPrintDialog::colorModeSelected( int id ) +{ + d->colorMode2 = (TQPrinter::ColorMode)id; +} + +/*! + Adds the button \a but to the layout of the print dialog. The added + buttons are arranged from the left to the right below the + last groupbox of the printdialog. +*/ + +void TQPrintDialog::addButton( TQPushButton *but ) +{ + d->customLayout->addWidget( but ); +} + +void TQPrintDialog::fileNameEditChanged( const TQString &text ) +{ + if ( d->fileName->isEnabled() ) + d->ok->setEnabled( !text.isEmpty() ); +} + +#endif diff --git a/src/dialogs/tqprintdialog.h b/src/dialogs/tqprintdialog.h new file mode 100644 index 000000000..29824416a --- /dev/null +++ b/src/dialogs/tqprintdialog.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Definition of print dialog. +** +** Created : 950829 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the dialogs 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 TQPRINTDIALOG_H +#define TQPRINTDIALOG_H + +#ifndef QT_H +#include "tqdialog.h" +#endif // QT_H + +#ifndef TQT_NO_PRINTDIALOG + +class TQGroupBox; +class TQPrintDialogPrivate; +class TQListView; + +class TQ_EXPORT TQPrintDialog : public TQDialog +{ + TQ_OBJECT +public: + TQPrintDialog( TQPrinter *, TQWidget* parent=0, const char* name=0 ); + ~TQPrintDialog(); + + static bool getPrinterSetup( TQPrinter *, TQWidget* = 0 ); + static void setGlobalPrintDialog( TQPrintDialog * ); + + void setPrinter( TQPrinter *, bool = FALSE ); + TQPrinter * printer() const; + + void addButton( TQPushButton *but ); + +private slots: + void browseClicked(); + void okClicked(); + + void printerOrFileSelected( int ); + void landscapeSelected( int ); + void paperSizeSelected( int ); + void orientSelected( int ); + void pageOrderSelected( int ); + void colorModeSelected( int ); + void setNumCopies( int ); + void printRangeSelected( int ); + void setFirstPage( int ); + void setLastPage( int ); + + void fileNameEditChanged( const TQString &text ); + +private: + TQPrintDialogPrivate *d; + + TQGroupBox * setupDestination(); + TQGroupBox * setupOptions(); + TQGroupBox * setupPaper(); + TQGroupBox * setupPrinterSettings(); + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQPrintDialog( const TQPrintDialog & ); + TQPrintDialog &operator=( const TQPrintDialog & ); +#endif +}; + +#endif + +#endif // TQPRINTDIALOG_H diff --git a/src/kernel/ntqmetaobject.h b/src/kernel/ntqmetaobject.h deleted file mode 100644 index 9db397f47..000000000 --- a/src/kernel/ntqmetaobject.h +++ /dev/null @@ -1,286 +0,0 @@ -/**************************************************************************** -** -** Definition of TQMetaObject class -** -** Created : 930419 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMETAOBJECT_H -#define TQMETAOBJECT_H - -#ifndef QT_H -#include "tqconnection.h" -#include "tqstrlist.h" -#endif // QT_H - -#ifndef Q_MOC_OUTPUT_REVISION -#define Q_MOC_OUTPUT_REVISION 26 -#endif - -class TQObject; -struct TQUMethod; -class TQMetaObjectPrivate; - -struct TQMetaData // - member function meta data -{ // for signal and slots - const char *name; // - member name - const TQUMethod* method; // - detailed method description - enum Access { Private, Protected, Public }; - Access access; // - access permission -}; - -#ifndef TQT_NO_PROPERTIES -struct TQMetaEnum // enumerator meta data -{ // for properties - const char *name; // - enumerator name - uint count; // - number of values - struct Item // - a name/value pair - { - const char *key; - int value; - }; - const Item *items; // - the name/value pairs - bool set; // whether enum has to be treated as a set -}; -#endif - -#ifndef TQT_NO_PROPERTIES - -class TQ_EXPORT TQMetaProperty // property meta data -{ -public: - const char* type() const { return t; } // type of the property - const char* name() const { return n; } // name of the property - - bool writable() const; - bool isValid() const; - - bool isSetType() const; - bool isEnumType() const; - TQStrList enumKeys() const; // enumeration names - - int keyToValue( const char* key ) const; // enum and set conversion functions - const char* valueToKey( int value ) const; - int keysToValue( const TQStrList& keys ) const; - TQStrList valueToKeys( int value ) const; - - bool designable( TQObject* = 0 ) const; - bool scriptable( TQObject* = 0 ) const; - bool stored( TQObject* = 0 ) const; - - bool reset( TQObject* ) const; - - const char* t; // internal - const char* n; // internal - - enum Flags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - EnumOrSet = 0x00000004, - UnresolvedEnum = 0x00000008, - StdSet = 0x00000100, - Override = 0x00000200 - }; - - uint flags; // internal - bool testFlags( uint f ) const; // internal - bool stdSet() const; // internal - int id() const; // internal - - TQMetaObject** meta; // internal - - const TQMetaEnum* enumData; // internal - int _id; // internal - void clear(); // internal -}; - -inline bool TQMetaProperty::testFlags( uint f ) const -{ return (flags & (uint)f) != (uint)0; } - -#endif // TQT_NO_PROPERTIES - -struct TQClassInfo // class info meta data -{ - const char* name; // - name of the info - const char* value; // - value of the info -}; - -class TQ_EXPORT TQMetaObject // meta object class -{ -public: - TQMetaObject( const char * const class_name, TQMetaObject *superclass, - const TQMetaData * const slot_data, int n_slots, - const TQMetaData * const signal_data, int n_signals, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, -#endif - const TQClassInfo *const class_info, int n_info ); - -#ifndef TQT_NO_PROPERTIES - TQMetaObject( const char * const class_name, TQMetaObject *superclass, - const TQMetaData * const slot_data, int n_slots, - const TQMetaData * const signal_data, int n_signals, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo *const class_info, int n_info ); -#endif - - - virtual ~TQMetaObject(); - - const char *className() const { return classname; } - const char *superClassName() const { return superclassname; } - - TQMetaObject *superClass() const { return superclass; } - - bool inherits( const char* clname ) const; - - int numSlots( bool super = FALSE ) const; - int numSignals( bool super = FALSE ) const; - - int findSlot( const char *, bool super = FALSE ) const; - int findSignal( const char *, bool super = FALSE ) const; - - const TQMetaData *slot( int index, bool super = FALSE ) const; - const TQMetaData *signal( int index, bool super = FALSE ) const; - - TQStrList slotNames( bool super = FALSE ) const; - TQStrList signalNames( bool super = FALSE ) const; - - int slotOffset() const; - int signalOffset() const; - int propertyOffset() const; - - int numClassInfo( bool super = FALSE ) const; - const TQClassInfo *classInfo( int index, bool super = FALSE ) const; - const char *classInfo( const char* name, bool super = FALSE ) const; - -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *property( int index, bool super = FALSE ) const; - int findProperty( const char *name, bool super = FALSE ) const; - int indexOfProperty( const TQMetaProperty*, bool super = FALSE ) const; - const TQMetaProperty* resolveProperty( const TQMetaProperty* ) const; - int resolveProperty( int ) const; - TQStrList propertyNames( bool super = FALSE ) const; - int numProperties( bool super = FALSE ) const; -#endif - - // static wrappers around constructors, necessary to work around a - // Windows-DLL limitation: objects can only be deleted within a - // DLL if they were actually created within that DLL. - static TQMetaObject *new_metaobject( const char *, TQMetaObject *, - const TQMetaData *const, int, - const TQMetaData *const, int, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, -#endif - const TQClassInfo *const class_info, int n_info ); -#ifndef TQT_NO_PROPERTIES - static TQMetaObject *new_metaobject( const char *, TQMetaObject *, - const TQMetaData *const, int, - const TQMetaData *const, int, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo *const class_info, int n_info ); - TQStrList enumeratorNames( bool super = FALSE ) const; - int numEnumerators( bool super = FALSE ) const; - const TQMetaEnum *enumerator( const char* name, bool super = FALSE ) const; -#endif - - static TQMetaObject *metaObject( const char *class_name ); - static bool hasMetaObject( const char *class_name ); - -private: - TQMemberDict *init( const TQMetaData *, int ); - - const char *classname; // class name - const char *superclassname; // super class name - TQMetaObject *superclass; // super class meta object - TQMetaObjectPrivate *d; // private data for... - void *reserved; // ...binary compatibility - const TQMetaData *slotData; // slot meta data - TQMemberDict *slotDict; // slot dictionary - const TQMetaData *signalData; // signal meta data - TQMemberDict *signalDict; // signal dictionary - int signaloffset; - int slotoffset; -#ifndef TQT_NO_PROPERTIES - int propertyoffset; -public: - bool tqt_static_property( TQObject* o, int id, int f, TQVariant* v); -private: - friend class TQMetaProperty; -#endif - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQMetaObject( const TQMetaObject & ); - TQMetaObject &operator=( const TQMetaObject & ); -#endif -}; - -inline int TQMetaObject::slotOffset() const -{ return slotoffset; } - -inline int TQMetaObject::signalOffset() const -{ return signaloffset; } - -#ifndef TQT_NO_PROPERTIES -inline int TQMetaObject::propertyOffset() const -{ return propertyoffset; } -#endif - -typedef TQMetaObject *(*TQtStaticMetaObjectFunction)(); - -class TQ_EXPORT TQMetaObjectCleanUp -{ -public: - TQMetaObjectCleanUp( const char *mo_name, TQtStaticMetaObjectFunction ); - TQMetaObjectCleanUp(); - ~TQMetaObjectCleanUp(); - - void setMetaObject( TQMetaObject *&mo ); - -private: - TQMetaObject **metaObject; -}; - -#endif // TQMETAOBJECT_H diff --git a/src/kernel/ntqmngio.h b/src/kernel/ntqmngio.h deleted file mode 100644 index 530a0aa1d..000000000 --- a/src/kernel/ntqmngio.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Definition of MNG TQImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMNGIO_H -#define TQMNGIO_H - -#ifndef QT_H -#endif // QT_H - -#ifndef TQT_NO_IMAGEIO_MNG - -void qInitMngIO(); - -#endif // TQT_NO_IMAGEIO_MNG - -#endif // TQMNGIO_H diff --git a/src/kernel/ntqnamespace.h b/src/kernel/ntqnamespace.h deleted file mode 100644 index f5ec7dd1d..000000000 --- a/src/kernel/ntqnamespace.h +++ /dev/null @@ -1,1035 +0,0 @@ -/**************************************************************************** -** -** Definition of TQt namespace (as class for compiler compatibility) -** -** Created : 980927 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQNAMESPACE_H -#define TQNAMESPACE_H - -#ifndef QT_H -#include "tqglobal.h" -#endif // QT_H - - -class TQColor; -class TQCursor; - - -class TQ_EXPORT TQt { -public: - static const TQColor & color0; - static const TQColor & color1; - static const TQColor & black; - static const TQColor & white; - static const TQColor & darkGray; - static const TQColor & gray; - static const TQColor & lightGray; - static const TQColor & red; - static const TQColor & green; - static const TQColor & blue; - static const TQColor & cyan; - static const TQColor & magenta; - static const TQColor & yellow; - static const TQColor & darkRed; - static const TQColor & darkGreen; - static const TQColor & darkBlue; - static const TQColor & darkCyan; - static const TQColor & darkMagenta; - static const TQColor & darkYellow; - - // documented in tqevent.cpp - enum ButtonState { // mouse/keyboard state values - NoButton = 0x0000, - LeftButton = 0x0001, - RightButton = 0x0002, - MidButton = 0x0004, - HistoryBackButton = 0x0008, - HistoryForwardButton = 0x0010, - MouseButtonMask = 0x001f, - ShiftButton = 0x0100, - ControlButton = 0x0200, - AltButton = 0x0400, - MetaButton = 0x0800, - KeyButtonMask = 0x0f00, - Keypad = 0x4000 - }; - - // documented in tqobject.cpp - // ideally would start at 1, as in TQSizePolicy, but that breaks other things - enum Orientation { - Horizontal = 0, - Vertical - }; - - // documented in tqlistview.cpp - enum SortOrder { - Ascending, - Descending - }; - - // Text formatting flags for TQPainter::drawText and TQLabel - // the following four enums can be combined to one integer which - // is passed as textflag to drawText and qt_format_text. - - // documented in tqpainter.cpp - enum AlignmentFlags { - AlignAuto = 0x0000, // text alignment - AlignLeft = 0x0001, - AlignRight = 0x0002, - AlignHCenter = 0x0004, - AlignJustify = 0x0008, - AlignHorizontal_Mask = AlignLeft | AlignRight | AlignHCenter | AlignJustify, - AlignTop = 0x0010, - AlignBottom = 0x0020, - AlignVCenter = 0x0040, - AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter, - AlignCenter = AlignVCenter | AlignHCenter - }; - - // documented in tqpainter.cpp - enum TextFlags { - SingleLine = 0x0080, // misc. flags - DontClip = 0x0100, - ExpandTabs = 0x0200, - ShowPrefix = 0x0400, - WordBreak = 0x0800, - BreakAnywhere = 0x1000, -#ifndef Q_QDOC - DontPrint = 0x2000, - Underline = 0x01000000, - Overline = 0x02000000, - StrikeOut = 0x04000000, - IncludeTrailingSpaces = 0x08000000, -#endif - NoAccel = 0x4000 - }; - - // Widget flags; documented in tqwidget.cpp - typedef uint WState; - - // TQWidget state flags (internal, barely documented in tqwidget.cpp) - enum WidgetState { - WState_Created = 0x00000001, - WState_Disabled = 0x00000002, - WState_Visible = 0x00000004, - WState_ForceHide = 0x00000008, - WState_OwnCursor = 0x00000010, - WState_MouseTracking = 0x00000020, - WState_CompressKeys = 0x00000040, - WState_BlockUpdates = 0x00000080, - WState_InPaintEvent = 0x00000100, - WState_Reparented = 0x00000200, - WState_ConfigPending = 0x00000400, - WState_Resized = 0x00000800, - WState_AutoMask = 0x00001000, - WState_Polished = 0x00002000, - WState_DND = 0x00004000, - WState_Reserved0 = 0x00008000, - WState_FullScreen = 0x00010000, - WState_OwnSizePolicy = 0x00020000, - WState_CreatedHidden = 0x00040000, - WState_Maximized = 0x00080000, - WState_Minimized = 0x00100000, - WState_ForceDisabled = 0x00200000, - WState_Exposed = 0x00400000, - WState_HasMouse = 0x00800000 - }; - - // NetWM flags; documented in tqwidget.cpp - typedef uint NFlags; - - // documented in tqwidget.cpp - enum NETWMFlags { -#if defined(TQ_WS_X11) - WX11DisableMove = 0x00000001, - WX11DisableClose = 0x00000002, - WX11DisableResize = 0x00000004, - WX11DisableMinimize = 0x00000008, - WX11DisableMaximize = 0x00000010, - WX11DisableShade = 0x00000020 -#else - WX11DisableMove = 0x00000000, - WX11DisableClose = 0x00000000, - WX11DisableResize = 0x00000000, - WX11DisableMinimize = 0x00000000, - WX11DisableMaximize = 0x00000000, - WX11DisableShade = 0x00000000 -#endif - }; - - // Widget flags2; documented in tqwidget.cpp - typedef uint WFlags; - - // documented in tqwidget.cpp - enum WidgetFlags { - WType_TopLevel = 0x00000001, // widget type flags - WType_Dialog = 0x00000002, - WType_Popup = 0x00000004, - WType_Desktop = 0x00000008, - WType_Mask = 0x0000000f, - - WStyle_Customize = 0x00000010, // window style flags - WStyle_NormalBorder = 0x00000020, - WStyle_DialogBorder = 0x00000040, // MS-Windows only - WStyle_NoBorder = 0x00002000, - WStyle_Title = 0x00000080, - WStyle_SysMenu = 0x00000100, - WStyle_Minimize = 0x00000200, - WStyle_Maximize = 0x00000400, - WStyle_MinMax = WStyle_Minimize | WStyle_Maximize, - WStyle_Tool = 0x00000800, - WStyle_StaysOnTop = 0x00001000, - WStyle_ContextHelp = 0x00004000, - WStyle_Reserved = 0x00008000, - WStyle_Mask = 0x0000fff0, - - WDestructiveClose = 0x00010000, // misc flags - WPaintDesktop = 0x00020000, - WPaintUnclipped = 0x00040000, - WPaintClever = 0x00080000, - WResizeNoErase = 0x00100000, // OBSOLETE - WMouseNoMask = 0x00200000, - WStaticContents = 0x00400000, - WRepaintNoErase = 0x00800000, // OBSOLETE -#if defined(TQ_WS_X11) - WX11BypassWM = 0x01000000, - WWinOwnDC = 0x00000000, - WMacNoSheet = 0x00000000, - WMacDrawer = 0x00000000, -#elif defined(TQ_WS_MAC) - WX11BypassWM = 0x00000000, - WWinOwnDC = 0x00000000, - WMacNoSheet = 0x01000000, - WMacDrawer = 0x20000000, -#else - WX11BypassWM = 0x00000000, - WWinOwnDC = 0x01000000, - WMacNoSheet = 0x00000000, - WMacDrawer = 0x00000000, -#endif - WGroupLeader = 0x02000000, - WShowModal = 0x04000000, - WNoMousePropagation = 0x08000000, - WSubWindow = 0x10000000, -#if defined(TQ_WS_X11) - WStyle_Splash = 0x20000000, -#else - WStyle_Splash = WStyle_NoBorder | WMacNoSheet | WStyle_Tool | WWinOwnDC, -#endif - WNoAutoErase = WRepaintNoErase | WResizeNoErase -#ifndef TQT_NO_COMPAT - , - WNorthWestGravity = WStaticContents, - WType_Modal = WType_Dialog | WShowModal, - WStyle_Dialog = WType_Dialog, - WStyle_NoBorderEx = WStyle_NoBorder -#endif - }; - - enum WindowState { - WindowNoState = 0x00000000, - WindowMinimized = 0x00000001, - WindowMaximized = 0x00000002, - WindowFullScreen = 0x00000004, - WindowActive = 0x00000008 - }; - - - // Image conversion flags. The unusual ordering is caused by - // compatibility and default requirements. - // Documented in tqimage.cpp - - enum ImageConversionFlags { - ColorMode_Mask = 0x00000003, - AutoColor = 0x00000000, - ColorOnly = 0x00000003, - MonoOnly = 0x00000002, - // Reserved = 0x00000001, - - AlphaDither_Mask = 0x0000000c, - ThresholdAlphaDither = 0x00000000, - OrderedAlphaDither = 0x00000004, - DiffuseAlphaDither = 0x00000008, - NoAlpha = 0x0000000c, // Not supported - - Dither_Mask = 0x00000030, - DiffuseDither = 0x00000000, - OrderedDither = 0x00000010, - ThresholdDither = 0x00000020, - // ReservedDither= 0x00000030, - - DitherMode_Mask = 0x000000c0, - AutoDither = 0x00000000, - PreferDither = 0x00000040, - AvoidDither = 0x00000080 - }; - - // documented in tqpainter.cpp - enum BGMode { // background mode - TransparentMode, - OpaqueMode - }; - -#ifndef TQT_NO_COMPAT - // documented in tqpainter.cpp - enum PaintUnit { // paint unit - PixelUnit, - LoMetricUnit, // OBSOLETE - HiMetricUnit, // OBSOLETE - LoEnglishUnit, // OBSOLETE - HiEnglishUnit, // OBSOLETE - TwipsUnit // OBSOLETE - }; -#endif - - // documented in tqstyle.cpp -#ifdef TQT_NO_COMPAT - enum GUIStyle { - WindowsStyle = 1, // ### TQt 4.0: either remove the obsolete enums or clean up compat vs. - MotifStyle = 4, // ### TQT_NO_COMPAT by reordering or combination into one enum. - GtkStyle = 6 // Gtk compability mode - }; -#else - enum GUIStyle { - MacStyle, // OBSOLETE - WindowsStyle, - Win3Style, // OBSOLETE - PMStyle, // OBSOLETE - MotifStyle, - GtkStyle = 6 // Gtk compability mode - }; -#endif - - // documented in tqkeysequence.cpp - enum SequenceMatch { - NoMatch, - PartialMatch, - Identical - }; - - // documented in tqevent.cpp - enum Modifier { // accelerator modifiers - META = 0x00100000, - SHIFT = 0x00200000, - CTRL = 0x00400000, - ALT = 0x00800000, - MODIFIER_MASK = 0x00f00000, - UNICODE_ACCEL = 0x10000000, - - ASCII_ACCEL = UNICODE_ACCEL // 1.x compat - }; - - // documented in tqevent.cpp - enum Key { - Key_Escape = 0x1000, // misc keys - Key_Tab = 0x1001, - Key_Backtab = 0x1002, Key_BackTab = Key_Backtab, - Key_Backspace = 0x1003, Key_BackSpace = Key_Backspace, - Key_Return = 0x1004, - Key_Enter = 0x1005, - Key_Insert = 0x1006, - Key_Delete = 0x1007, - Key_Pause = 0x1008, - Key_Print = 0x1009, - Key_SysReq = 0x100a, - Key_Clear = 0x100b, - Key_Home = 0x1010, // cursor movement - Key_End = 0x1011, - Key_Left = 0x1012, - Key_Up = 0x1013, - Key_Right = 0x1014, - Key_Down = 0x1015, - Key_Prior = 0x1016, Key_PageUp = Key_Prior, - Key_Next = 0x1017, Key_PageDown = Key_Next, - Key_Shift = 0x1020, // modifiers - Key_Control = 0x1021, - Key_Meta = 0x1022, - Key_Alt = 0x1023, - Key_CapsLock = 0x1024, - Key_NumLock = 0x1025, - Key_ScrollLock = 0x1026, - Key_F1 = 0x1030, // function keys - Key_F2 = 0x1031, - Key_F3 = 0x1032, - Key_F4 = 0x1033, - Key_F5 = 0x1034, - Key_F6 = 0x1035, - Key_F7 = 0x1036, - Key_F8 = 0x1037, - Key_F9 = 0x1038, - Key_F10 = 0x1039, - Key_F11 = 0x103a, - Key_F12 = 0x103b, - Key_F13 = 0x103c, - Key_F14 = 0x103d, - Key_F15 = 0x103e, - Key_F16 = 0x103f, - Key_F17 = 0x1040, - Key_F18 = 0x1041, - Key_F19 = 0x1042, - Key_F20 = 0x1043, - Key_F21 = 0x1044, - Key_F22 = 0x1045, - Key_F23 = 0x1046, - Key_F24 = 0x1047, - Key_F25 = 0x1048, // F25 .. F35 only on X11 - Key_F26 = 0x1049, - Key_F27 = 0x104a, - Key_F28 = 0x104b, - Key_F29 = 0x104c, - Key_F30 = 0x104d, - Key_F31 = 0x104e, - Key_F32 = 0x104f, - Key_F33 = 0x1050, - Key_F34 = 0x1051, - Key_F35 = 0x1052, - Key_Super_L = 0x1053, // extra keys - Key_Super_R = 0x1054, - Key_Menu = 0x1055, - Key_Hyper_L = 0x1056, - Key_Hyper_R = 0x1057, - Key_Help = 0x1058, - Key_Direction_L = 0x1059, - Key_Direction_R = 0x1060, - - // International input method support (X keycode - 0xEE00). - // Only interesting if you are writing your own input method - - // International & multi-key character composition - Key_Multi_key = 0x1120, // Multi-key character compose - Key_Codeinput = 0x1137, - Key_SingleCandidate = 0x113c, - Key_MultipleCandidate = 0x113d, - Key_PreviousCandidate = 0x113e, - - // Misc Functions - Key_Mode_switch = 0x117e, // Character set switch - //Key_script_switch = 0x117e, // Alias for mode_switch - - // Japanese keyboard support - Key_Kanji = 0x1121, // Kanji, Kanji convert - Key_Muhenkan = 0x1122, // Cancel Conversion - //Key_Henkan_Mode = 0x1123, // Start/Stop Conversion - Key_Henkan = 0x1123, // Alias for Henkan_Mode - Key_Romaji = 0x1124, // to Romaji - Key_Hiragana = 0x1125, // to Hiragana - Key_Katakana = 0x1126, // to Katakana - Key_Hiragana_Katakana = 0x1127, // Hiragana/Katakana toggle - Key_Zenkaku = 0x1128, // to Zenkaku - Key_Hankaku = 0x1129, // to Hankaku - Key_Zenkaku_Hankaku = 0x112a, // Zenkaku/Hankaku toggle - Key_Touroku = 0x112b, // Add to Dictionary - Key_Massyo = 0x112c, // Delete from Dictionary - Key_Kana_Lock = 0x112d, // Kana Lock - Key_Kana_Shift = 0x112e, // Kana Shift - Key_Eisu_Shift = 0x112f, // Alphanumeric Shift - Key_Eisu_toggle = 0x1130, // Alphanumeric toggle - //Key_Kanji_Bangou = 0x1137, // Codeinput - //Key_Zen_Koho = 0x113d, // Multiple/All Candidate(s) - //Key_Mae_Koho = 0x113e, // Previous Candidate - - // Korean keyboard support - // - // In fact, many Korean users need only 2 keys, Key_Hangul and - // Key_Hangul_Hanja. But rest of the keys are good for future. - - Key_Hangul = 0x1131, // Hangul start/stop(toggle) - Key_Hangul_Start = 0x1132, // Hangul start - Key_Hangul_End = 0x1133, // Hangul end, English start - Key_Hangul_Hanja = 0x1134, // Start Hangul->Hanja Conversion - Key_Hangul_Jamo = 0x1135, // Hangul Jamo mode - Key_Hangul_Romaja = 0x1136, // Hangul Romaja mode - //Key_Hangul_Codeinput = 0x1137, // Hangul code input mode - Key_Hangul_Jeonja = 0x1138, // Jeonja mode - Key_Hangul_Banja = 0x1139, // Banja mode - Key_Hangul_PreHanja = 0x113a, // Pre Hanja conversion - Key_Hangul_PostHanja = 0x113b, // Post Hanja conversion - //Key_Hangul_SingleCandidate = 0x113c, // Single candidate - //Key_Hangul_MultipleCandidate = 0x113d, // Multiple candidate - //Key_Hangul_PreviousCandidate = 0x113e, // Previous candidate - Key_Hangul_Special = 0x113f, // Special symbols - //Key_Hangul_switch = 0x117e, // Alias for mode_switch - - // dead keys (X keycode - 0xED00 to avoid the conflict) - Key_Dead_Grave = 0x1250, - Key_Dead_Acute = 0x1251, - Key_Dead_Circumflex = 0x1252, - Key_Dead_Tilde = 0x1253, - Key_Dead_Macron = 0x1254, - Key_Dead_Breve = 0x1255, - Key_Dead_Abovedot = 0x1256, - Key_Dead_Diaeresis = 0x1257, - Key_Dead_Abovering = 0x1258, - Key_Dead_Doubleacute = 0x1259, - Key_Dead_Caron = 0x125a, - Key_Dead_Cedilla = 0x125b, - Key_Dead_Ogonek = 0x125c, - Key_Dead_Iota = 0x125d, - Key_Dead_Voiced_Sound = 0x125e, - Key_Dead_Semivoiced_Sound = 0x125f, - Key_Dead_Belowdot = 0x1260, - Key_Dead_Hook = 0x1261, - Key_Dead_Horn = 0x1262, - - Key_Space = 0x20, // 7 bit printable ASCII - Key_Any = Key_Space, - Key_Exclam = 0x21, - Key_QuoteDbl = 0x22, - Key_NumberSign = 0x23, - Key_Dollar = 0x24, - Key_Percent = 0x25, - Key_Ampersand = 0x26, - Key_Apostrophe = 0x27, - Key_ParenLeft = 0x28, - Key_ParenRight = 0x29, - Key_Asterisk = 0x2a, - Key_Plus = 0x2b, - Key_Comma = 0x2c, - Key_Minus = 0x2d, - Key_Period = 0x2e, - Key_Slash = 0x2f, - Key_0 = 0x30, - Key_1 = 0x31, - Key_2 = 0x32, - Key_3 = 0x33, - Key_4 = 0x34, - Key_5 = 0x35, - Key_6 = 0x36, - Key_7 = 0x37, - Key_8 = 0x38, - Key_9 = 0x39, - Key_Colon = 0x3a, - Key_Semicolon = 0x3b, - Key_Less = 0x3c, - Key_Equal = 0x3d, - Key_Greater = 0x3e, - Key_Question = 0x3f, - Key_At = 0x40, - Key_A = 0x41, - Key_B = 0x42, - Key_C = 0x43, - Key_D = 0x44, - Key_E = 0x45, - Key_F = 0x46, - Key_G = 0x47, - Key_H = 0x48, - Key_I = 0x49, - Key_J = 0x4a, - Key_K = 0x4b, - Key_L = 0x4c, - Key_M = 0x4d, - Key_N = 0x4e, - Key_O = 0x4f, - Key_P = 0x50, - Key_Q = 0x51, - Key_R = 0x52, - Key_S = 0x53, - Key_T = 0x54, - Key_U = 0x55, - Key_V = 0x56, - Key_W = 0x57, - Key_X = 0x58, - Key_Y = 0x59, - Key_Z = 0x5a, - Key_BracketLeft = 0x5b, - Key_Backslash = 0x5c, - Key_BracketRight = 0x5d, - Key_AsciiCircum = 0x5e, - Key_Underscore = 0x5f, - Key_QuoteLeft = 0x60, - Key_BraceLeft = 0x7b, - Key_Bar = 0x7c, - Key_BraceRight = 0x7d, - Key_AsciiTilde = 0x7e, - - // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06 - // - // This is mainly for compatibility - applications and input - // methods should not use the TQt keycodes between 128 and 255, - // but should rather use the TQKeyEvent::text(). See - // TQETWidget::translateKeyEventInternal() for more details. - - Key_nobreakspace = 0x0a0, - Key_exclamdown = 0x0a1, - Key_cent = 0x0a2, - Key_sterling = 0x0a3, - Key_currency = 0x0a4, - Key_yen = 0x0a5, - Key_brokenbar = 0x0a6, - Key_section = 0x0a7, - Key_diaeresis = 0x0a8, - Key_copyright = 0x0a9, - Key_ordfeminine = 0x0aa, - Key_guillemotleft = 0x0ab, // left angle quotation mark - Key_notsign = 0x0ac, - Key_hyphen = 0x0ad, - Key_registered = 0x0ae, - Key_macron = 0x0af, - Key_degree = 0x0b0, - Key_plusminus = 0x0b1, - Key_twosuperior = 0x0b2, - Key_threesuperior = 0x0b3, - Key_acute = 0x0b4, - Key_mu = 0x0b5, - Key_paragraph = 0x0b6, - Key_periodcentered = 0x0b7, - Key_cedilla = 0x0b8, - Key_onesuperior = 0x0b9, - Key_masculine = 0x0ba, - Key_guillemotright = 0x0bb, // right angle quotation mark - Key_onequarter = 0x0bc, - Key_onehalf = 0x0bd, - Key_threequarters = 0x0be, - Key_questiondown = 0x0bf, - Key_Agrave = 0x0c0, - Key_Aacute = 0x0c1, - Key_Acircumflex = 0x0c2, - Key_Atilde = 0x0c3, - Key_Adiaeresis = 0x0c4, - Key_Aring = 0x0c5, - Key_AE = 0x0c6, - Key_Ccedilla = 0x0c7, - Key_Egrave = 0x0c8, - Key_Eacute = 0x0c9, - Key_Ecircumflex = 0x0ca, - Key_Ediaeresis = 0x0cb, - Key_Igrave = 0x0cc, - Key_Iacute = 0x0cd, - Key_Icircumflex = 0x0ce, - Key_Idiaeresis = 0x0cf, - Key_ETH = 0x0d0, - Key_Ntilde = 0x0d1, - Key_Ograve = 0x0d2, - Key_Oacute = 0x0d3, - Key_Ocircumflex = 0x0d4, - Key_Otilde = 0x0d5, - Key_Odiaeresis = 0x0d6, - Key_multiply = 0x0d7, - Key_Ooblique = 0x0d8, - Key_Ugrave = 0x0d9, - Key_Uacute = 0x0da, - Key_Ucircumflex = 0x0db, - Key_Udiaeresis = 0x0dc, - Key_Yacute = 0x0dd, - Key_THORN = 0x0de, - Key_ssharp = 0x0df, - Key_agrave = 0x0e0, - Key_aacute = 0x0e1, - Key_acircumflex = 0x0e2, - Key_atilde = 0x0e3, - Key_adiaeresis = 0x0e4, - Key_aring = 0x0e5, - Key_ae = 0x0e6, - Key_ccedilla = 0x0e7, - Key_egrave = 0x0e8, - Key_eacute = 0x0e9, - Key_ecircumflex = 0x0ea, - Key_ediaeresis = 0x0eb, - Key_igrave = 0x0ec, - Key_iacute = 0x0ed, - Key_icircumflex = 0x0ee, - Key_idiaeresis = 0x0ef, - Key_eth = 0x0f0, - Key_ntilde = 0x0f1, - Key_ograve = 0x0f2, - Key_oacute = 0x0f3, - Key_ocircumflex = 0x0f4, - Key_otilde = 0x0f5, - Key_odiaeresis = 0x0f6, - Key_division = 0x0f7, - Key_oslash = 0x0f8, - Key_ugrave = 0x0f9, - Key_uacute = 0x0fa, - Key_ucircumflex = 0x0fb, - Key_udiaeresis = 0x0fc, - Key_yacute = 0x0fd, - Key_thorn = 0x0fe, - Key_ydiaeresis = 0x0ff, - - // multimedia/internet keys - ignored by default - see TQKeyEvent c'tor - - Key_Back = 0x1061, - Key_Forward = 0x1062, - Key_Stop = 0x1063, - Key_Refresh = 0x1064, - - Key_VolumeDown = 0x1070, - Key_VolumeMute = 0x1071, - Key_VolumeUp = 0x1072, - Key_BassBoost = 0x1073, - Key_BassUp = 0x1074, - Key_BassDown = 0x1075, - Key_TrebleUp = 0x1076, - Key_TrebleDown = 0x1077, - - Key_MediaPlay = 0x1080, - Key_MediaStop = 0x1081, - Key_MediaPrev = 0x1082, - Key_MediaNext = 0x1083, - Key_MediaRecord = 0x1084, - - Key_HomePage = 0x1090, - Key_Favorites = 0x1091, - Key_Search = 0x1092, - Key_Standby = 0x1093, - Key_OpenUrl = 0x1094, - - Key_LaunchMail = 0x10a0, - Key_LaunchMedia = 0x10a1, - Key_Launch0 = 0x10a2, - Key_Launch1 = 0x10a3, - Key_Launch2 = 0x10a4, - Key_Launch3 = 0x10a5, - Key_Launch4 = 0x10a6, - Key_Launch5 = 0x10a7, - Key_Launch6 = 0x10a8, - Key_Launch7 = 0x10a9, - Key_Launch8 = 0x10aa, - Key_Launch9 = 0x10ab, - Key_LaunchA = 0x10ac, - Key_LaunchB = 0x10ad, - Key_LaunchC = 0x10ae, - Key_LaunchD = 0x10af, - Key_LaunchE = 0x10b0, - Key_LaunchF = 0x10b1, - Key_MonBrightnessUp = 0x010b2, - Key_MonBrightnessDown = 0x010b3, - Key_KeyboardLightOnOff = 0x010b4, - Key_KeyboardBrightnessUp = 0x010b5, - Key_KeyboardBrightnessDown = 0x010b6, - - Key_MediaLast = 0x1fff, - - Key_unknown = 0xffff - }; - - // documented in tqcommonstyle.cpp - enum ArrowType { - UpArrow, - DownArrow, - LeftArrow, - RightArrow - }; - - // documented in tqpainter.cpp - enum RasterOp { // raster op mode - CopyROP, - OrROP, - XorROP, - NotAndROP, EraseROP=NotAndROP, - NotCopyROP, - NotOrROP, - NotXorROP, - AndROP, NotEraseROP=AndROP, - NotROP, - ClearROP, - SetROP, - NopROP, - AndNotROP, - OrNotROP, - NandROP, - NorROP, LastROP=NorROP - }; - - // documented in tqpainter.cpp - enum PenStyle { // pen style - NoPen, - SolidLine, - DashLine, - DotLine, - DashDotLine, - DashDotDotLine, - FineDotLine, - MPenStyle = 0x0f - }; - - // documented in tqpainter.cpp - enum PenCapStyle { // line endcap style - FlatCap = 0x00, - SquareCap = 0x10, - RoundCap = 0x20, - MPenCapStyle = 0x30 - }; - - // documented in tqpainter.cpp - enum PenJoinStyle { // line join style - MiterJoin = 0x00, - BevelJoin = 0x40, - RoundJoin = 0x80, - MPenJoinStyle = 0xc0 - }; - - // documented in tqpainter.cpp - enum BrushStyle { // brush style - NoBrush, - SolidPattern, - Dense1Pattern, - Dense2Pattern, - Dense3Pattern, - Dense4Pattern, - Dense5Pattern, - Dense6Pattern, - Dense7Pattern, - HorPattern, - VerPattern, - CrossPattern, - BDiagPattern, - FDiagPattern, - DiagCrossPattern, - CustomPattern=24 - }; - - // documented in qapplication_mac.cpp - enum MacintoshVersion { - //Unknown - MV_Unknown = 0x0000, - - //Version numbers - MV_9 = 0x0001, - MV_10_DOT_0 = 0x0002, - MV_10_DOT_1 = 0x0003, - MV_10_DOT_2 = 0x0004, - MV_10_DOT_3 = 0x0005, - MV_10_DOT_4 = 0x0006, - - //Code names - MV_CHEETAH = MV_10_DOT_0, - MV_PUMA = MV_10_DOT_1, - MV_JAGUAR = MV_10_DOT_2, - MV_PANTHER = MV_10_DOT_3, - MV_TIGER = MV_10_DOT_4 - }; - - // documented in qapplication_win.cpp - enum WindowsVersion { - WV_32s = 0x0001, - WV_95 = 0x0002, - WV_98 = 0x0003, - WV_Me = 0x0004, - WV_DOS_based = 0x000f, - - WV_NT = 0x0010, - WV_2000 = 0x0020, - WV_XP = 0x0030, - WV_2003 = 0x0040, - WV_VISTA = 0x0080, - WV_NT_based = 0x00f0, - - WV_CE = 0x0100, - WV_CENET = 0x0200, - WV_CE_based = 0x0f00 - }; - - // documented in tqstyle.cpp - enum UIEffect { - UI_General, - UI_AnimateMenu, - UI_FadeMenu, - UI_AnimateCombo, - UI_AnimateTooltip, - UI_FadeTooltip, - UI_AnimateToolBox - }; - - // documented in tqcursor.cpp - enum CursorShape { - ArrowCursor, - UpArrowCursor, - CrossCursor, - WaitCursor, - IbeamCursor, - SizeVerCursor, - SizeHorCursor, - SizeBDiagCursor, - SizeFDiagCursor, - SizeAllCursor, - BlankCursor, - SplitVCursor, - SplitHCursor, - PointingHandCursor, - ForbiddenCursor, - WhatsThisCursor, - BusyCursor, - LastCursor = BusyCursor, - BitmapCursor = 24 - }; - - // Global cursors - - static const TQCursor & arrowCursor; // standard arrow cursor - static const TQCursor & upArrowCursor; // upwards arrow - static const TQCursor & crossCursor; // crosshair - static const TQCursor & waitCursor; // hourglass/watch - static const TQCursor & ibeamCursor; // ibeam/text entry - static const TQCursor & sizeVerCursor; // vertical resize - static const TQCursor & sizeHorCursor; // horizontal resize - static const TQCursor & sizeBDiagCursor; // diagonal resize (/) - static const TQCursor & sizeFDiagCursor; // diagonal resize (\) - static const TQCursor & sizeAllCursor; // all directions resize - static const TQCursor & blankCursor; // blank/invisible cursor - static const TQCursor & splitVCursor; // vertical bar with left-right - // arrows - static const TQCursor & splitHCursor; // horizontal bar with up-down - // arrows - static const TQCursor & pointingHandCursor; // pointing hand - static const TQCursor & forbiddenCursor; // forbidden cursor (slashed circle) - static const TQCursor & whatsThisCursor; // arrow with a question mark - static const TQCursor & busyCursor; // arrow with hourglass - - - enum TextFormat { - PlainText, - RichText, - AutoText, - LogText - }; - - // Documented in tqtextedit.cpp - enum AnchorAttribute { - AnchorName, - AnchorHref - }; - - // Documented in tqmainwindow.cpp - enum Dock { - DockUnmanaged, - DockTornOff, - DockTop, - DockBottom, - DockRight, - DockLeft, - DockMinimized -#ifndef TQT_NO_COMPAT - , - Unmanaged = DockUnmanaged, - TornOff = DockTornOff, - Top = DockTop, - Bottom = DockBottom, - Right = DockRight, - Left = DockLeft, - Minimized = DockMinimized -#endif - }; - // compatibility - typedef Dock ToolBarDock; - - // documented in tqdatetime.cpp - enum DateFormat { - TextDate, // default TQt - ISODate, // ISO 8601 - LocalDate // locale dependent - }; - - // documented in tqdatetime.cpp - enum TimeSpec { - LocalTime, - UTC - }; - - // documented in tqwidget.cpp - enum BackgroundMode { - FixedColor, - FixedPixmap, - NoBackground, - PaletteForeground, - PaletteButton, - PaletteLight, - PaletteMidlight, - PaletteDark, - PaletteMid, - PaletteText, - PaletteBrightText, - PaletteBase, - PaletteBackground, - PaletteShadow, - PaletteHighlight, - PaletteHighlightedText, - PaletteButtonText, - PaletteLink, - PaletteLinkVisited, - X11ParentRelative - }; - - typedef uint ComparisonFlags; - - // Documented in tqstring.cpp - enum StringComparisonMode { - CaseSensitive = 0x00001, // 0 0001 - BeginsWith = 0x00002, // 0 0010 - EndsWith = 0x00004, // 0 0100 - Contains = 0x00008, // 0 1000 - ExactMatch = 0x00010 // 1 0000 - }; - - // Documented in tqtabwidget.cpp - enum Corner { - TopLeft = 0x00000, - TopRight = 0x00001, - BottomLeft = 0x00002, - BottomRight = 0x00003 - }; - - // "handle" type for system objects. Documented as \internal in - // qapplication.cpp -#if defined(TQ_WS_MAC) - typedef void * HANDLE; -#elif defined(TQ_WS_WIN) - typedef void *HANDLE; -#elif defined(TQ_WS_X11) - typedef unsigned long HANDLE; -#endif -}; - - -class TQ_EXPORT TQInternal { -public: - enum PaintDeviceFlags { - UndefinedDevice = 0x00, - Widget = 0x01, - Pixmap = 0x02, - Printer = 0x03, - Picture = 0x04, - System = 0x05, - DeviceTypeMask = 0x0f, - ExternalDevice = 0x10, - // used to emulate some of the behaviour different between TQt2 and TQt3 (mainly for printing) - CompatibilityMode = 0x20 - }; -}; - -#endif // TQNAMESPACE_H diff --git a/src/kernel/ntqpolygonscanner.h b/src/kernel/ntqpolygonscanner.h deleted file mode 100644 index 2ab2c8e37..000000000 --- a/src/kernel/ntqpolygonscanner.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPolygonScanner class -** -** Created : 000120 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPOLYGONSCANNER_H -#define TQPOLYGONSCANNER_H - -#ifndef QT_H -#include "tqglobal.h" -#endif // QT_H - -class TQPointArray; -class TQPoint; - -class TQ_EXPORT TQPolygonScanner { -public: - // BIC: fix for 3.0 - void scan( const TQPointArray& pa, bool winding, int index=0, int npoints=-1 ); - void scan( const TQPointArray& pa, bool winding, int index, int npoints, bool stitchable ); - enum Edge { Left=1, Right=2, Top=4, Bottom=8 }; - void scan( const TQPointArray& pa, bool winding, int index, int npoints, Edge edges ); - virtual void processSpans( int n, TQPoint* point, int* width )=0; -}; - -#endif // TQPOLYGONSCANNER_H diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index 0a1ffc22b..7032b7383 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -21,7 +21,7 @@ #include "tqptrcollection.h" #include "tqglist.h" #include "tqobjectdefs.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqgarray.h" #include "tqmemarray.h" #include "tqcstring.h" @@ -93,7 +93,7 @@ #include #include "tqgplugin.h" #include -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #include "tqbuttongroup.h" #include #include "tqgvector.h" @@ -129,8 +129,8 @@ #include "tqbitmap.h" #include "ntqvariant.h" #include "tqsignal.h" -#include -#include "ntqmetaobject.h" +#include +#include "tqmetaobject.h" #include "tqheader.h" #include #include @@ -157,9 +157,9 @@ #include #include #include -#include +#include #include "tqpopupmenu.h" -#include +#include #include #include #include "tqprogressbar.h" @@ -312,7 +312,7 @@ #ifdef TQ_WS_MAC #include -#include +#include #endif // TQ_WS_MAC #ifdef TQ_WS_WIN diff --git a/src/kernel/ntqwindowdefs.h b/src/kernel/ntqwindowdefs.h index 812bf6f6c..166cc0638 100644 --- a/src/kernel/ntqwindowdefs.h +++ b/src/kernel/ntqwindowdefs.h @@ -45,7 +45,7 @@ #ifndef QT_H #include "tqobjectdefs.h" #include "tqstring.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #endif // QT_H // Class forward definitions diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 8f04514cf..8ad7f5a55 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -57,7 +57,7 @@ #include "tqstyle.h" #include "tqstylefactory.h" #include "tqfile.h" -#include "ntqmessagebox.h" +#include "tqmessagebox.h" #include "tqdir.h" #include "tqfileinfo.h" #ifdef TQ_WS_WIN @@ -281,7 +281,7 @@ TQApplication. This can be useful if you wish to share code between a non-GUI server and a GUI client. - \headerfile ntqnamespace.h + \headerfile tqnamespace.h \headerfile ntqwindowdefs.h \headerfile tqglobal.h */ diff --git a/src/kernel/qinternal_p.h b/src/kernel/qinternal_p.h index 8992497e6..d8c29cc67 100644 --- a/src/kernel/qinternal_p.h +++ b/src/kernel/qinternal_p.h @@ -53,7 +53,7 @@ // // #ifndef QT_H -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqrect.h" #include "tqptrlist.h" #include "tqcstring.h" diff --git a/src/kernel/qmetaobject.cpp b/src/kernel/qmetaobject.cpp deleted file mode 100644 index ae74503c3..000000000 --- a/src/kernel/qmetaobject.cpp +++ /dev/null @@ -1,1251 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQMetaObject class -** -** Created : 930419 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqmetaobject.h" -#include "tqasciidict.h" - -#ifdef TQT_THREAD_SUPPORT -#include -#endif // TQT_THREAD_SUPPORT - -/*! - \class TQMetaData ntqmetaobject.h - \reentrant - - \brief The TQMetaData class provides information about a member function that is known to the meta object system. - - \internal - - The struct consists of three members, \e name, \e method and \e access: - - \code - const char *name; // - member name - const TQUMethod* method; // - detailed method description - enum Access { Private, Protected, Public }; - Access access; // - access permission - \endcode - */ - -/*! - \class TQClassInfo ntqmetaobject.h - - \brief The TQClassInfo class provides a struct that stores some basic information about a single class. - - \internal - - The class information is a simple \e name - \e value pair: - - \code - const char* name; - const char* value; - \endcode - - */ - - -/*! - \class TQMetaObject ntqmetaobject.h - \brief The TQMetaObject class contains meta information about TQt objects. - - \ingroup objectmodel - - The Meta Object System in TQt is responsible for the signals and - slots inter-object communication mechanism, runtime type - information and the property system. All meta information in TQt is - kept in a single instance of TQMetaObject per class. - - This class is not normally required for application programming. - But if you write meta applications, such as scripting engines or - GUI builders, you might find these functions useful: - \list - \i className() to get the name of a class. - \i superClassName() to get the name of the superclass. - \i inherits(), the function called by TQObject::inherits(). - \i superClass() to access the superclass's meta object. - \i numSlots(), numSignals(), slotNames(), and signalNames() to get - information about a class's signals and slots. - \i property() and propertyNames() to obtain information about a - class's properties. - \endlist - - Classes may have a list of name-value pairs of class information. - The number of pairs is returned by numClassInfo(), and values are - returned by classInfo(). - - \sa \link moc.html moc (Meta Object Compiler)\endlink - -*/ - - -/***************************************************************************** - The private object. - *****************************************************************************/ - -// extra flags from moc.y -enum Flags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - EnumOrSet = 0x00000004, - UnresolvedEnum = 0x00000008, - StdSet = 0x00000100, - Override = 0x00000200, - NotDesignable = 0x00001000, - DesignableOverride = 0x00002000, - NotScriptable = 0x00004000, - ScriptableOverride = 0x00008000, - NotStored = 0x00010000, - StoredOverride = 0x00020000 -}; - -static TQAsciiDict *qt_metaobjects = 0; -static int qt_metaobjects_count = 0; - -class TQMetaObjectPrivate -{ -public: - TQMetaObjectPrivate() : -#ifndef TQT_NO_PROPERTIES - enumData(0), numEnumData(0), - propData(0),numPropData(0), - tqt_static_property(0), -#endif - classInfo(0), numClassInfo(0) {} -#ifndef TQT_NO_PROPERTIES - const TQMetaEnum *enumData; - int numEnumData; - const TQMetaProperty *propData; - int numPropData; - bool (*tqt_static_property)(TQObject*, int, int, TQVariant*); -#endif - const TQClassInfo *classInfo; - int numClassInfo; -}; - - -/***************************************************************************** - Internal dictionary for fast access to class members - *****************************************************************************/ - -#if defined(Q_CANNOT_DELETE_CONSTANT) -typedef TQMetaData TQConstMetaData; -#else -typedef const TQMetaData TQConstMetaData; -#endif - -class TQ_EXPORT TQMemberDict : public TQAsciiDict -{ -public: - TQMemberDict( int size = 17, bool cs = TRUE, bool ck = TRUE ) : - TQAsciiDict(size,cs,ck) {} - TQMemberDict( const TQMemberDict &dict ) : TQAsciiDict(dict) {} - ~TQMemberDict() { clear(); } - TQMemberDict &operator=(const TQMemberDict &dict) - { return (TQMemberDict&)TQAsciiDict::operator=(dict); } -}; - - -/* - Calculate optimal dictionary size for n entries using prime numbers, - and assuming there are no more than 40 entries. -*/ - -static int optDictSize( int n ) -{ - if ( n < 6 ) - n = 5; - else if ( n < 10 ) - n = 11; - else if ( n < 14 ) - n = 17; - else - n = 23; - return n; -} - - -/***************************************************************************** - TQMetaObject member functions - *****************************************************************************/ - -/*!\internal - */ -TQMetaObject::TQMetaObject( const char *const class_name, TQMetaObject *super_class, - const TQMetaData *const slot_data, int n_slots, - const TQMetaData *const signal_data, int n_signals, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, -#endif - const TQClassInfo *const class_info, int n_info ) -{ - classname = class_name; // set meta data - superclass = super_class; - superclassname = superclass ? superclass->className() : 0; - slotDict = init( slotData = slot_data, n_slots ); - signalDict = init( signalData = signal_data, n_signals ); - - d = new TQMetaObjectPrivate; - reserved = 0; - -#ifndef TQT_NO_PROPERTIES - d->propData = prop_data; - d->numPropData = n_props; - d->enumData = enum_data; - d->numEnumData = n_enums; -#endif - d->classInfo = class_info; - d->numClassInfo = n_info; - - signaloffset = superclass ? ( superclass->signalOffset() + superclass->numSignals() ) : 0; - slotoffset = superclass ? ( superclass->slotOffset() + superclass->numSlots() ) : 0; -#ifndef TQT_NO_PROPERTIES - propertyoffset = superclass ? ( superclass->propertyOffset() + superclass->numProperties() ) : 0; -#endif -} - -#ifndef TQT_NO_PROPERTIES -/*!\internal - */ -TQMetaObject::TQMetaObject( const char *const class_name, TQMetaObject *super_class, - const TQMetaData *const slot_data, int n_slots, - const TQMetaData *const signal_data, int n_signals, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo *const class_info, int n_info ) -{ - classname = class_name; // set meta data - superclass = super_class; - superclassname = superclass ? superclass->className() : 0; - slotDict = init( slotData = slot_data, n_slots ); - signalDict = init( signalData = signal_data, n_signals ); - - d = new TQMetaObjectPrivate; - reserved = 0; - - d->propData = prop_data; - d->numPropData = n_props; - d->enumData = enum_data; - d->numEnumData = n_enums; - d->tqt_static_property = tqt_static_property; - d->classInfo = class_info; - d->numClassInfo = n_info; - - signaloffset = superclass ? ( superclass->signalOffset() + superclass->numSignals() ) : 0; - slotoffset = superclass ? ( superclass->slotOffset() + superclass->numSlots() ) : 0; - propertyoffset = superclass ? ( superclass->propertyOffset() + superclass->numProperties() ) : 0; -} -#endif - -/*!\internal - */ -TQMetaObject::~TQMetaObject() -{ - delete slotDict; // delete dicts - delete signalDict; - delete d; -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - if ( qt_metaobjects ) { - qt_metaobjects->remove( classname ); - if ( qt_metaobjects->isEmpty() ) { - delete qt_metaobjects; - qt_metaobjects = 0; - } - } - - // delete reserved; // Unused void* -} - - -/*! - \fn const char *TQMetaObject::className() const - - Returns the class name. - - \sa TQObject::className(), superClassName() -*/ - -/*! - \fn const char *TQMetaObject::superClassName() const - - Returns the class name of the superclass or 0 if there is no - superclass in the TQObject hierachy. - - \sa className() -*/ - -/*! - \fn TQMetaObject *TQMetaObject::superClass() const - - Returns the meta object of the super class or 0 if there is no - such object. -*/ - -/*! - Returns the number of slots for this class. - - If \a super is TRUE, inherited slots are included. - - \sa slotNames() -*/ -int TQMetaObject::numSlots( bool super ) const // number of slots -{ - int n = slotDict ? slotDict->count() : 0; - if ( !super || !superclass ) - return n; - return n + superclass->numSlots( super ); -} - -/*! - Returns the number of signals for this class. - - If \a super is TRUE, inherited signals are included. - - \sa signalNames() -*/ -int TQMetaObject::numSignals( bool super ) const // number of signals -{ - int n = signalDict ? signalDict->count() : 0; - if ( !super || !superclass ) - return n; - return n + superclass->numSignals( super ); -} - - -/*! \internal - - Returns the meta data of the slot with the name \a n or 0 if no - such slot exists. - - If \a super is TRUE, inherited slots are included. - */ -const TQMetaData* TQMetaObject::slot( int index, bool super ) const -{ - int idx = index - ( super ? slotOffset() : 0 ); - if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { - return slotData + idx; - } - if ( !super || !superclass ) - return 0; - return superclass->slot( index, super ); -} - -/*! \internal - - Returns the meta data of the signal with the name \a n or 0 if no - such signal exists. - - If \a super is TRUE, inherited signals are included. - */ -const TQMetaData* TQMetaObject::signal( int index, bool super ) const -{ - int idx = index - ( super ? signalOffset() : 0 ); - if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { - return signalData + idx; - } - if ( !super || !superclass ) - return 0; - return superclass->signal( index, super ); -} - - -/*! - \fn int TQMetaObject::signalOffset() const - - \internal - - Returns the signal offset for this metaobject. - -*/ - -/*! - \fn int TQMetaObject::propertyOffset() const - - \internal - - Returns the property offset for this metaobject. - -*/ - -/*! \internal - Returns the index of the signal with name \n or -1 if no such signal exists. - - If \a super is TRUE, inherited signals are included. -*/ -int TQMetaObject::findSignal( const char* n, bool super ) const -{ - const TQMetaObject *mo = this; - int offset = -1; - - do { - const TQMetaData *md = mo->signalDict ? mo->signalDict->find( n ) : 0; - if ( md ) { -#if defined(QT_CHECK_RANGE) - if ( offset != -1 ) { - tqWarning( "TQMetaObject::findSignal:%s: Conflict with %s::%s", - className(), mo->className(), n ); - return offset; - } -#endif - offset = mo->signalOffset() + ( md - mo->signalData ); -#if !defined(QT_CHECK_RANGE) - return offset; -#endif - } - } while ( super && (mo = mo->superclass) ); - - return offset; -} - -/*! - \fn int TQMetaObject::slotOffset() const - - \internal - - Returns the slot offset for this metaobject. - -*/ - -/*! \internal - Returns the index of the slot with name \n or -1 if no such slot exists. - - If \a super is TRUE, inherited slots are included. - */ -int TQMetaObject::findSlot( const char* n, bool super ) const -{ - const TQMetaData *md = slotDict ? slotDict->find( n ) : 0; - if ( md ) - return slotOffset() + ( md - slotData ); - if ( !super || !superclass) - return -1; - return superclass->findSlot( n, super ); -} - -/*!\internal - */ -TQMetaObject *TQMetaObject::new_metaobject( const char *classname, - TQMetaObject *superclassobject, - const TQMetaData * const slot_data, int n_slots, - const TQMetaData * const signal_data, int n_signals, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty * const prop_data, int n_props, - const TQMetaEnum * const enum_data, int n_enums, -#endif - const TQClassInfo * const class_info, int n_info ) -{ - return new TQMetaObject( classname, superclassobject, slot_data, n_slots, - signal_data, n_signals, -#ifndef TQT_NO_PROPERTIES - prop_data, n_props, - enum_data, n_enums, -#endif - class_info, n_info ); -} - -#ifndef TQT_NO_PROPERTIES -/*!\internal - */ -TQMetaObject *TQMetaObject::new_metaobject( const char *classname, - TQMetaObject *superclassobject, - const TQMetaData * const slot_data, int n_slots, - const TQMetaData * const signal_data, int n_signals, - const TQMetaProperty * const prop_data, int n_props, - const TQMetaEnum * const enum_data, int n_enums, - bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo * const class_info, int n_info ) -{ - return new TQMetaObject( classname, superclassobject, slot_data, n_slots, - signal_data, n_signals, - prop_data, n_props, - enum_data, n_enums, - tqt_static_property, - class_info, n_info ); -} -#endif - -/*!\internal - */ -TQMemberDict *TQMetaObject::init( const TQMetaData * data, int n ) -{ - if ( n == 0 ) // nothing, then make no dict - return 0; - TQMemberDict *dict = new TQMemberDict( optDictSize(n), TRUE, FALSE ); - TQ_CHECK_PTR( dict ); - while ( n-- ) { // put all members into dict - dict->insert( data->name, data ); - data++; - } - return dict; -} - -/*! - Returns the number of items of class information available for - this class. - - If \a super is TRUE, inherited class information is included. -*/ -int TQMetaObject::numClassInfo( bool super ) const -{ - return d->numClassInfo + ((super && superclass)?superclass->numClassInfo(super):0); -} - -/*! - Returns the class information with index \a index or 0 if no such - information exists. - - If \a super is TRUE, inherited class information is included. -*/ -const TQClassInfo* TQMetaObject::classInfo( int index, bool super ) const -{ - if ( index < 0 ) - return 0; - if ( index < d->numClassInfo ) - return &(d->classInfo[ index ]); - if ( !super || !superclass ) - return 0; - return superclass->classInfo( index - d->numClassInfo, super ); -} - -/*! - \overload - Returns the class information with name \a name or 0 if no such - information exists. - - If \a super is TRUE, inherited class information is included. -*/ -const char* TQMetaObject::classInfo( const char* name, bool super ) const -{ - for( int i = 0; i < d->numClassInfo; ++i ) { - if ( qstrcmp( d->classInfo[i].name, name ) == 0 ) - return d->classInfo[i].value; - } - if ( !super || !superclass ) - return 0; - return superclass->classInfo( name, super ); -} - -#ifndef TQT_NO_PROPERTIES - -/*! - Returns the number of properties for this class. - - If \a super is TRUE, inherited properties are included. - - \sa propertyNames() - */ -int TQMetaObject::numProperties( bool super ) const // number of signals -{ - int n = d->numPropData; - if ( !super || !superclass ) - return n; - return n + superclass->numProperties( super ); -} - -/*! - Returns the property meta data for the property at index \a index - or 0 if no such property exists. - - If \a super is TRUE, inherited properties are included. - - \sa propertyNames() - */ -const TQMetaProperty* TQMetaObject::property( int index, bool super ) const -{ - int idx = index - ( super ? propertyOffset() : 0 ); - if ( d->propData && idx >= 0 && idx < (int)d->numPropData ) - return d->propData + idx; - if ( !super || !superclass ) - return 0; - return superclass->property( index, super ); -} - - -/*! - Returns the index for the property with name \a name or -1 if no - such property exists. - - If \a super is TRUE, inherited properties are included. - - \sa property(), propertyNames() -*/ - -int TQMetaObject::findProperty( const char *name, bool super ) const -{ - for( int i = 0; i < d->numPropData; ++i ) { - if ( d->propData[i].isValid() && qstrcmp( d->propData[i].name(), name ) == 0 ) { - return ( super ? propertyOffset() : 0 ) + i; - } - } - if ( !super || !superclass ) - return -1; - return superclass->findProperty( name, super ); -} - -/*! \internal - - Returns the index for the property \a prop - or -1 if the property can not be found. - - If \a super is TRUE, inherited properties are included. - - \sa property(), propertyNames() -*/ - -int TQMetaObject::indexOfProperty( const TQMetaProperty* prop, bool super ) const -{ - if ( *prop->meta == this ) - return ( super ? propertyOffset() : 0 ) + ( prop - d->propData); - if ( !super || !superclass ) - return -1; - return superclass->indexOfProperty( prop, super ); -} - -/*!\internal - - Returns the parent property of property \a p or 0, if the property - cannot be resolved. - - \a p has to be contained in this meta object -*/ - -const TQMetaProperty* TQMetaObject::resolveProperty( const TQMetaProperty* p ) const -{ - if ( !superclass ) - return 0; - return superclass->property( superclass->findProperty( p->n, TRUE ), TRUE ); -} - -/*!\internal - - \overload - - The version of resolveProperty that is used by moc generated code -*/ - -int TQMetaObject::resolveProperty( int index ) const -{ - if ( !superclass ) - return -1; - const TQMetaProperty* p = d->propData + ( index - propertyOffset() ); - return superclass->findProperty( p->n, TRUE ); -} - - -/*! - Returns a list with the names of all this class's properties. - - If \a super is TRUE, inherited properties are included. - - \sa property() -*/ -TQStrList TQMetaObject::propertyNames( bool super ) const -{ - TQStrList l( FALSE ); - - if ( superclass && super ) { - TQStrList sl = superclass->propertyNames( super ); - for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) - l.append( slit.current() ); - } - - for( int i = 0; i < d->numPropData; ++i ) { - if ( d->propData[i].isValid() ) - l.append( d->propData[i].name() ); - } - - return l; -} - -/*! - Returns a list with the names of all this class's signals. - - If \a super is TRUE, inherited signals are included. -*/ -TQStrList TQMetaObject::signalNames( bool super ) const -{ - TQStrList l( FALSE ); - int n = numSignals( super ); - for( int i = 0; i < n; ++i ) { - l.append( signal(i, super)->name ); - } - return l; -} - -/*! - Returns a list with the names of all this class's slots. - - If \a super is TRUE, inherited slots are included. - - \sa numSlots() -*/ -TQStrList TQMetaObject::slotNames( bool super ) const -{ - TQStrList l( FALSE ); - int n = numSlots( super ); - for( int i = 0; i < n; ++i ) - l.append( slot( i, super)->name ); - return l; -} - -/*!\internal - - */ - -int TQMetaObject::numEnumerators( bool super ) const -{ - int n = 0; - if ( superclass && super ) - n += superclass->numEnumerators( super ); - return n + d->numEnumData; -} - -/*!\internal - - */ -TQStrList TQMetaObject::enumeratorNames( bool super ) const -{ - TQStrList l( FALSE ); - - if ( superclass && super ) { - TQStrList sl = superclass->enumeratorNames( super ); - for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) - l.append( slit.current() ); - } - - for( int i = 0; i < d->numEnumData; ++i ) { - if ( d->enumData[i].items ) - l.append( d->enumData[i].name ); - } - - return l; -} - -/*!\internal - */ -const TQMetaEnum* TQMetaObject::enumerator( const char* name, bool super ) const -{ - for( int i = 0; i < d->numEnumData; ++i ) - if ( qstrcmp( d->enumData[i].name, name ) == 0 ) - return &(d->enumData[i]); - if ( !super || !superclass ) - return 0; - return superclass->enumerator( name, super ); -} - -#endif // TQT_NO_PROPERTIES - - -/*! - Returns TRUE if this class inherits \a clname within the meta - object inheritance chain; otherwise returns FALSE. - - (A class is considered to inherit itself.) -*/ -bool TQMetaObject::inherits( const char* clname ) const -{ - const TQMetaObject *meta = this; - while ( meta ) { - if ( qstrcmp(clname, meta->className()) == 0 ) - return TRUE; - meta = meta->superclass; - } - return FALSE; -} - -/*! \internal */ - -TQMetaObject *TQMetaObject::metaObject( const char *class_name ) -{ - if ( !qt_metaobjects ) - return 0; -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - TQtStaticMetaObjectFunction func = (TQtStaticMetaObjectFunction)qt_metaobjects->find( class_name ); - if ( func ) - return func(); - return 0; -} - -/*! \internal */ -bool TQMetaObject::hasMetaObject( const char *class_name ) -{ - if ( !qt_metaobjects ) - return FALSE; -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - return !!qt_metaobjects->find( class_name ); -} - -#ifndef TQT_NO_PROPERTIES -/*! \internal - -### this functions will go away. It exists purely for the sake of meta -### object code generated with TQt 3.1.0 -*/ -bool TQMetaObject::tqt_static_property( TQObject* o, int id, int f, TQVariant* v) -{ - if ( d->tqt_static_property ) - return d->tqt_static_property( o, id, f, v ); - else if ( o ) // compatibility - return o->tqt_property( id, f, v ); - else if ( superclass ) - return superclass->tqt_static_property( o, id, f, v ); - switch ( f ) { - case 3: case 4: case 5: - return TRUE; - default: - return FALSE; - } -} - - -/*! - \class TQMetaProperty ntqmetaobject.h - - \brief The TQMetaProperty class stores meta data about a property. - - \ingroup objectmodel - - Property meta data includes type(), name(), and whether a property - is writable(), designable() and stored(). - - The functions isSetType(), isEnumType() and enumKeys() provide - further information about a property's type. The conversion - functions keyToValue(), valueToKey(), keysToValue() and - valueToKeys() allow conversion between the integer representation - of an enumeration or set value and its literal representation. - - Actual property values are set and received through TQObject's set - and get functions. See TQObject::setProperty() and - TQObject::property() for details. - - You receive meta property data through an object's meta object. - See TQMetaObject::property() and TQMetaObject::propertyNames() for - details. -*/ - -/*! - Returns the possible enumeration keys if this property is an - enumeration type (or a set type). - - \sa isEnumType() -*/ -TQStrList TQMetaProperty::enumKeys() const -{ - TQStrList l( FALSE ); - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return l; - if ( ed != 0 ) { - for( uint i = 0; i < ed->count; ++i ) { - uint j = 0; - while ( j < i && - ed->items[j].value != ed->items[i].value ) - ++j; - if ( i == j ) - l.append( ed->items[i].key ); - } - } - return l; -} - -/*! - Converts the enumeration key \a key to its integer value. - - For set types, use keysToValue(). - - \sa valueToKey(), isSetType(), keysToValue() -*/ -int TQMetaProperty::keyToValue( const char* key ) const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return -1; - for ( uint i = 0; i < ed->count; ++i ) { - if ( !qstrcmp( key, ed->items[i].key) ) - return ed->items[i].value; - } - return -1; -} - -/*! - Converts the enumeration value \a value to its literal key. - - For set types, use valueToKeys(). - - \sa valueToKey(), isSetType(), valueToKeys() -*/ -const char* TQMetaProperty::valueToKey( int value ) const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return 0; - for ( uint i = 0; i < ed->count; ++i ) { - if ( value == ed->items[i].value ) - return ed->items[i].key ; - } - return 0; -} - -/*! - Converts the list of keys \a keys to their combined (OR-ed) - integer value. - - \sa isSetType(), valueToKey(), keysToValue() -*/ -int TQMetaProperty::keysToValue( const TQStrList& keys ) const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return -1; - int value = 0; - for ( TQStrListIterator it( keys ); it.current(); ++it ) { - uint i; - for( i = ed->count; i > 0; --i ) { - if ( !qstrcmp( it.current(), ed->items[i-1].key) ) { - value |= ed->items[i-1].value; - break; - } - } - if ( i == 0 ) - value |= -1; - } - return value; -} - -/*! - Converts the set value \a value to a list of keys. - - \sa isSetType(), valueToKey(), valueToKeys() -*/ -TQStrList TQMetaProperty::valueToKeys( int value ) const -{ - TQStrList keys; - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - if ( !ed ) - return keys; - - int v = value; - for( uint i = ed->count; i > 0; --i ) { - int k = ed->items[i-1].value; - if ( ( k != 0 && (v & k) == k ) || ( k == value) ) { - v = v & ~k; - keys.append( ed->items[i-1].key ); - } - } - return keys; -} - -bool TQMetaProperty::writable() const -{ - if ( !testFlags( Override ) || testFlags( Writable ) ) - return testFlags( Writable ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->writable() : FALSE; -} - -/*!\internal - */ -bool TQMetaProperty::stdSet() const -{ - if ( !testFlags( Override ) || testFlags( Writable ) ) - return testFlags( StdSet ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->stdSet() : FALSE; -} - -/*!\internal - */ -int TQMetaProperty::id() const -{ - return _id < 0 ? (*meta)->indexOfProperty( this, TRUE ) : _id; -} - -/*! \internal -*/ -void TQMetaProperty::clear() -{ - t = n = 0; - meta = 0; - enumData = 0; - _id = -1; - flags = 0; -} - -bool TQMetaProperty::isValid() const -{ - if ( testFlags( UnresolvedEnum ) ) { - if ( !enumData && (!meta || !(*meta)->enumerator( t, TRUE ) ) ) - return FALSE; - } - if ( !testFlags( Override ) || testFlags( Readable ) ) - return testFlags( Readable ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->isValid() : FALSE; -} - -bool TQMetaProperty::isSetType() const -{ - const TQMetaEnum* ed = enumData; - if ( !enumData && meta ) - ed = (*meta)->enumerator( t, TRUE ); - return ( ed != 0 && ed->set ); -} - -bool TQMetaProperty::isEnumType() const -{ - return testFlags( EnumOrSet ); -} - - - -/*! - \fn const char* TQMetaProperty::type() const - - Returns the type of the property. -*/ - -/*! - \fn const char* TQMetaProperty::name() const - - Returns the name of the property. -*/ - -/*! - \fn bool TQMetaProperty::writable() const - - Returns TRUE if the property is writable; otherwise returns FALSE. - -*/ - -/*! \fn bool TQMetaProperty::isValid() const - - \internal - - Returns whether the property is valid. -*/ - -/*! - \fn bool TQMetaProperty::isEnumType() const - - Returns TRUE if the property's type is an enumeration value; - otherwise returns FALSE. - - \sa isSetType(), enumKeys() -*/ - -/*! - \fn bool TQMetaProperty::isSetType() const - - Returns TRUE if the property's type is an enumeration value that - is used as set, i.e. if the enumeration values can be OR-ed - together; otherwise returns FALSE. A set type is implicitly also - an enum type. - - \sa isEnumType(), enumKeys() -*/ - - -/*! Returns TRUE if the property is designable for object \a o; - otherwise returns FALSE. - - If no object \a o is given, the function returns a static - approximation. - */ -bool TQMetaProperty::designable( TQObject* o ) const -{ - if ( !isValid() || !writable() ) - return FALSE; - if ( o ) { - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - return idx >= 0 && o->tqt_property( idx, 3, 0 ); - } - if ( testFlags( DesignableOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->designable() : FALSE; - } - return !testFlags( NotDesignable ); -} - -/*! - Returns TRUE if the property is scriptable for object \a o; - otherwise returns FALSE. - - If no object \a o is given, the function returns a static - approximation. - */ -bool TQMetaProperty::scriptable( TQObject* o ) const -{ - if ( o ) { - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - return idx >= 0 && o->tqt_property( idx, 4, 0 ); - } - if ( testFlags( ScriptableOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->scriptable() : FALSE; - } - return !testFlags( NotScriptable ); -} - -/*! - Returns TRUE if the property shall be stored for object \a o; - otherwise returns FALSE. - - If no object \a o is given, the function returns a static - approximation. - */ -bool TQMetaProperty::stored( TQObject* o ) const -{ - if ( !isValid() || !writable() ) - return FALSE; - if ( o ) { - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - return idx >= 0 && o->tqt_property( idx, 5, 0 ); - } - if ( testFlags( StoredOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* parent = mo->resolveProperty( this ); - return parent ? parent->stored() : FALSE; - } - return !testFlags( NotStored ); -} - - -/*! - Tries to reset the property for object \a o with a reset method. - On success, returns TRUE; otherwise returns FALSE. - - Reset methods are optional, usually only a few properties support - them. -*/ -bool TQMetaProperty::reset( TQObject* o ) const -{ - if ( !o ) - return FALSE; - int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); - if ( idx < 0 ) - return 0; - return o->tqt_property( idx, 2, 0 ); -} - - -/*! \enum TQMetaProperty::Flags - - \internal -*/ - -#endif // TQT_NO_PROPERTIES - -/* - * TQMetaObjectCleanUp is used as static global object in the moc-generated cpp - * files and deletes the TQMetaObject provided with setMetaObject. It sets the - * TQObject reference to the metaObj to NULL when it is destroyed. - */ -TQMetaObjectCleanUp::TQMetaObjectCleanUp( const char *mo_name, TQtStaticMetaObjectFunction func ) - : metaObject( 0 ) -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - if ( !qt_metaobjects ) - qt_metaobjects = new TQAsciiDict( 257 ); - qt_metaobjects->insert( mo_name, (void*)func ); - - qt_metaobjects_count++; -} - -TQMetaObjectCleanUp::TQMetaObjectCleanUp() - : metaObject( 0 ) -{ -} - -/*! \fn bool TQMetaProperty::testFlags( uint f ) const - \internal -*/ - -TQMetaObjectCleanUp::~TQMetaObjectCleanUp() -{ -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker( tqt_global_mutexpool ? - tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); -#endif // TQT_THREAD_SUPPORT - if ( !--qt_metaobjects_count ) { - delete qt_metaobjects; - qt_metaobjects = 0; - } - if ( metaObject ) { - delete *metaObject; - *metaObject = 0; - metaObject = 0; - } -} - -void TQMetaObjectCleanUp::setMetaObject( TQMetaObject *&mo ) -{ -#if defined(QT_CHECK_RANGE) - if (metaObject && metaObject != &mo) - tqWarning( "TQMetaObjectCleanUp::setMetaObject: Double use of TQMetaObjectCleanUp!" ); -#endif - metaObject = &mo; -} diff --git a/src/kernel/qmngio.cpp b/src/kernel/qmngio.cpp deleted file mode 100644 index 3e1678c4e..000000000 --- a/src/kernel/qmngio.cpp +++ /dev/null @@ -1,460 +0,0 @@ -/**************************************************************************** -** -** Implementation of MNG TQImage IOHandler -** -** Created : 970521 -** -** Copyright (C) 1997-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "tqdatetime.h" - -#ifndef TQT_NO_IMAGEIO_MNG - -#include "tqimage.h" -#include "tqasyncimageio.h" -#include "tqiodevice.h" -#include "ntqmngio.h" - -// Define XMD_H prohibits the included headers of libmng.h to typedef INT32. -// This is needed for Borland with STL support, since in that case, INT32 is -// already defined by some Borland header. -#define XMD_H -#if defined(Q_OS_UNIXWARE) -# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this -#endif -#include -#include - - -#ifndef TQT_NO_ASYNC_IMAGE_IO - -class TQMNGFormat : public TQImageFormat { -public: - TQMNGFormat(); - virtual ~TQMNGFormat(); - - int decode(TQImage& img, TQImageConsumer* consumer, - const uchar* buffer, int length); - - bool openstream() - { - // ### We should figure out how many loops an MNG has, but for now always assume infinite. - if (consumer) - consumer->setLooping(0); - return TRUE; - } - bool closestream( ) - { - if (consumer) - consumer->end(); - return TRUE; - } - bool readdata( mng_ptr pBuf, mng_uint32 iBuflen, mng_uint32p pRead ) - { - uint m = ndata + nbuffer - ubuffer; - if ( iBuflen > m ) { - iBuflen = m; - } - *pRead = iBuflen; - uint n = nbuffer-ubuffer; - if ( iBuflen < n ) { - // enough in buffer - memcpy(pBuf, buffer+ubuffer, iBuflen); - ubuffer += iBuflen; - return TRUE; - } - if ( n ) { - // consume buffer - memcpy(pBuf, buffer+ubuffer, n ); - pBuf = (mng_ptr)((char*)pBuf + n); - iBuflen -= n; - ubuffer = nbuffer; - } - if ( iBuflen ) { - // fill from incoming data - memcpy(pBuf, data, iBuflen); - data += iBuflen; - ndata -= iBuflen; - } - return TRUE; - } - bool errorproc( mng_int32 iErrorcode, - mng_int8 /*iSeverity*/, - mng_chunkid iChunkname, - mng_uint32 /*iChunkseq*/, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext ) - { - tqWarning("MNG error %d: %s; chunk %c%c%c%c; subcode %d:%d", - iErrorcode, zErrortext ? zErrortext : "", - (iChunkname>>24)&0xff, - (iChunkname>>16)&0xff, - (iChunkname>>8)&0xff, - (iChunkname>>0)&0xff, - iExtra1,iExtra2); - return TRUE; - } - bool processheader( mng_uint32 iWidth, mng_uint32 iHeight ) - { - image->create(iWidth,iHeight,32); - image->setAlphaBuffer(TRUE); - memset(image->bits(),0,iWidth*iHeight*4); - consumer->setSize(iWidth,iHeight); - mng_set_canvasstyle(handle, - TQImage::systemByteOrder() == TQImage::LittleEndian - ? MNG_CANVAS_BGRA8 : MNG_CANVAS_ARGB8 ); - return TRUE; - } - mng_ptr getcanvasline( mng_uint32 iLinenr ) - { - return image->scanLine(iLinenr); - } - mng_bool refresh( mng_uint32 x, mng_uint32 y, mng_uint32 w, mng_uint32 h ) - { - TQRect r(x,y,w,h); - consumer->changed(r); - consumer->setFramePeriod(0); - consumer->frameDone(); - return TRUE; - } - mng_uint32 gettickcount( ) - { - return timer.elapsed() - losttime; - } - bool settimer( mng_uint32 iMsecs ) - { - consumer->setFramePeriod(iMsecs); - consumer->frameDone(); - state = Time; - losingtimer.start(); - losttime -= iMsecs; - return TRUE; - } - -private: - // Animation-level information - enum { MovieStart, Time, Data, Data2 } state; - - // Image-level information - mng_handle handle; - - // For storing unused data - uchar *buffer; - uint maxbuffer; - uint nbuffer; - - // Timing - TQTime timer; - TQTime losingtimer; - int losttime; - - void enlargeBuffer(uint n) - { - if ( n > maxbuffer ) { - maxbuffer = n; - buffer = (uchar*)realloc(buffer,n); - } - } - - // Temporary locals during single data-chunk processing - const uchar* data; - uint ndata; - uint ubuffer; - TQImageConsumer* consumer; - TQImage* image; -}; - -class TQMNGFormatType : public TQImageFormatType -{ - TQImageFormat* decoderFor(const uchar* buffer, int length); - const char* formatName() const; -}; - - -/* - \class TQMNGFormat ntqmngio.h - \brief Incremental image decoder for MNG image format. - - \ingroup images - \ingroup graphics - - This subclass of TQImageFormat decodes MNG format images, - including animated MNGs. - - Animated MNG images are standard MNG images. The MNG standard - defines two extension chunks that are useful for animations: - -
-
gIFg - GIF-like Graphic Control Extension -
Includes frame disposal, user input flag (we ignore this), - and inter-frame delay. -
gIFx - GIF-like Application Extension -
Multi-purpose, but we just use the Netscape extension - which specifies looping. -
- - The subimages usually contain a offset chunk (oFFs) but need not. - - The first image defines the "screen" size. Any subsequent image that - doesn't fit is clipped. - -TODO: decide on this point. gIFg gives disposal types, so it can be done. - All images paste (\e not composite, just place all-channel copying) - over the previous image to produce a subsequent frame. -*/ - -/* - \class TQMNGFormatType tqasyncimageio.h - \brief Incremental image decoder for MNG image format. - - \ingroup images - \ingroup graphics - \ingroup io - - This subclass of TQImageFormatType recognizes MNG - format images, creating a TQMNGFormat when required. An instance - of this class is created automatically before any other factories, - so you should have no need for such objects. -*/ - -TQImageFormat* TQMNGFormatType::decoderFor( const uchar* buffer, int length ) -{ - if (length < 8) return 0; - - if ((buffer[0]==138 // MNG signature - && buffer[1]=='M' - && buffer[2]=='N' - && buffer[3]=='G' - && buffer[4]==13 - && buffer[5]==10 - && buffer[6]==26 - && buffer[7]==10) - || (buffer[0]==139 // JNG signature - && buffer[1]=='J' - && buffer[2]=='N' - && buffer[3]=='G' - && buffer[4]==13 - && buffer[5]==10 - && buffer[6]==26 - && buffer[7]==10) -#ifdef TQT_NO_IMAGEIO_PNG // if we don't have native PNG support use libmng - || (buffer[0]==137 // PNG signature - && buffer[1]=='P' - && buffer[2]=='N' - && buffer[3]=='G' - && buffer[4]==13 - && buffer[5]==10 - && buffer[6]==26 - && buffer[7]==10) -#endif - ) - return new TQMNGFormat; - return 0; -} - -const char* TQMNGFormatType::formatName() const -{ - return "MNG"; -} - - -/*! - Constructs a TQMNGFormat. -*/ -TQMNGFormat::TQMNGFormat() -{ - state = MovieStart; - handle = 0; - nbuffer = 0; - maxbuffer = 0; - buffer = 0; - losttime = 0; -} - -/* - Destroys a TQMNGFormat. -*/ -TQMNGFormat::~TQMNGFormat() -{ - // We're setting the consumer to 0 since it may have been - // deleted by read_async_image in tqimage.cpp - consumer = 0; - if (handle) mng_cleanup(&handle); -} - - -// C-callback to C++-member-function conversion -// -static mng_bool openstream( mng_handle handle ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->openstream(); -} -static mng_bool closestream( mng_handle handle ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->closestream(); -} -static mng_bool readdata( mng_handle handle, mng_ptr pBuf, mng_uint32 iBuflen, mng_uint32p pRead ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->readdata(pBuf,iBuflen,pRead); -} -static mng_bool errorproc( mng_handle handle, - mng_int32 iErrorcode, - mng_int8 iSeverity, - mng_chunkid iChunkname, - mng_uint32 iChunkseq, - mng_int32 iExtra1, - mng_int32 iExtra2, - mng_pchar zErrortext ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->errorproc(iErrorcode, - iSeverity,iChunkname,iChunkseq,iExtra1,iExtra2,zErrortext); -} -static mng_bool processheader( mng_handle handle, - mng_uint32 iWidth, mng_uint32 iHeight ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->processheader(iWidth,iHeight); -} -static mng_ptr getcanvasline( mng_handle handle, mng_uint32 iLinenr ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->getcanvasline(iLinenr); -} -static mng_bool refresh( mng_handle handle, - mng_uint32 iTop, - mng_uint32 iLeft, - mng_uint32 iBottom, - mng_uint32 iRight ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->refresh(iTop,iLeft,iBottom,iRight); -} -static mng_uint32 gettickcount( mng_handle handle ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->gettickcount(); -} -static mng_bool settimer( mng_handle handle, mng_uint32 iMsecs ) -{ - return ((TQMNGFormat*)mng_get_userdata(handle))->settimer(iMsecs); -} - -static mng_ptr memalloc( mng_size_t iLen ) -{ - return calloc(1,iLen); -} -static void memfree( mng_ptr iPtr, mng_size_t /*iLen*/ ) -{ - free(iPtr); -} - -/*! - This function decodes some data into image changes. - - Returns the number of bytes consumed. -*/ -int TQMNGFormat::decode( TQImage& img, TQImageConsumer* cons, - const uchar* buf, int length ) -{ - consumer = cons; - image = &img; - - data = buf; - ndata = length; - ubuffer = 0; - - if ( state == MovieStart ) { - handle = mng_initialize( (mng_ptr)this, ::memalloc, ::memfree, 0 ); - mng_set_suspensionmode( handle, MNG_TRUE ); - mng_setcb_openstream( handle, ::openstream ); - mng_setcb_closestream( handle, ::closestream ); - mng_setcb_readdata( handle, ::readdata ); - mng_setcb_errorproc( handle, ::errorproc ); - mng_setcb_processheader( handle, ::processheader ); - mng_setcb_getcanvasline( handle, ::getcanvasline ); - mng_setcb_refresh( handle, ::refresh ); - mng_setcb_gettickcount( handle, ::gettickcount ); - mng_setcb_settimer( handle, ::settimer ); - state = Data; - mng_readdisplay(handle); - losingtimer.start(); - } - - losttime += losingtimer.elapsed(); - if ( ndata || !length ) - mng_display_resume(handle); - losingtimer.start(); - - image = 0; - - nbuffer -= ubuffer; - if ( nbuffer ) { - // Move back unused tail - memcpy(buffer,buffer+ubuffer,nbuffer); - } - if ( ndata ) { - // Not all used. - enlargeBuffer(nbuffer+ndata); - memcpy(buffer+nbuffer,data,ndata); - nbuffer += ndata; - } - - return length; -} - -static TQMNGFormatType* globalMngFormatTypeObject = 0; - -#endif // TQT_NO_ASYNC_IMAGE_IO - -#ifndef TQT_NO_ASYNC_IMAGE_IO -void qCleanupMngIO() -{ - if ( globalMngFormatTypeObject ) { - delete globalMngFormatTypeObject; - globalMngFormatTypeObject = 0; - } -} -#endif - -void qInitMngIO() -{ - static bool done = FALSE; - if ( !done ) { - done = TRUE; -#ifndef TQT_NO_ASYNC_IMAGE_IO - globalMngFormatTypeObject = new TQMNGFormatType; - tqAddPostRoutine( qCleanupMngIO ); -#endif - } -} - -#endif // TQT_NO_IMAGEIO_MNG diff --git a/src/kernel/qpolygonscanner.cpp b/src/kernel/qpolygonscanner.cpp deleted file mode 100644 index 44d59e7b8..000000000 --- a/src/kernel/qpolygonscanner.cpp +++ /dev/null @@ -1,937 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQPolygonScanner class -** -** Created : 000120 -** -** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqpolygonscanner.h" -#include "tqpointarray.h" -#include - - -// Based on Xserver code miFillGeneralPoly... -/* - * - * Written by Brian Kelleher; Oct. 1985 - * - * Routine to fill a polygon. Two fill rules are - * supported: frWINDING and frEVENODD. - * - * See fillpoly.h for a complete description of the algorithm. - */ - -/* - * These are the data structures needed to scan - * convert regions. Two different scan conversion - * methods are available -- the even-odd method, and - * the winding number method. - * The even-odd rule states that a point is inside - * the polygon if a ray drawn from that point in any - * direction will pass through an odd number of - * path segments. - * By the winding number rule, a point is decided - * to be inside the polygon if a ray drawn from that - * point in any direction passes through a different - * number of clockwise and counterclockwise path - * segments. - * - * These data structures are adapted somewhat from - * the algorithm in (Foley/Van Dam) for scan converting - * polygons. - * The basic algorithm is to start at the top (smallest y) - * of the polygon, stepping down to the bottom of - * the polygon by incrementing the y coordinate. We - * keep a list of edges which the current scanline crosses, - * sorted by x. This list is called the Active Edge Table (AET) - * As we change the y-coordinate, we update each entry in - * in the active edge table to reflect the edges new xcoord. - * This list must be sorted at each scanline in case - * two edges intersect. - * We also keep a data structure known as the Edge Table (ET), - * which keeps track of all the edges which the current - * scanline has not yet reached. The ET is basically a - * list of ScanLineList structures containing a list of - * edges which are entered at a given scanline. There is one - * ScanLineList per scanline at which an edge is entered. - * When we enter a new edge, we move it from the ET to the AET. - * - * From the AET, we can implement the even-odd rule as in - * (Foley/Van Dam). - * The winding number rule is a little trickier. We also - * keep the EdgeTableEntries in the AET linked by the - * nextWETE (winding EdgeTableEntry) link. This allows - * the edges to be linked just as before for updating - * purposes, but only uses the edges linked by the nextWETE - * link as edges representing spans of the polygon to - * drawn (as with the even-odd rule). - */ - -/* $XConsortium: miscanfill.h,v 1.5 94/04/17 20:27:50 dpw Exp $ */ -/* - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from the X Consortium. - -*/ - - -/* - * scanfill.h - * - * Written by Brian Kelleher; Jan 1985 - * - * This file contains a few macros to help track - * the edge of a filled object. The object is assumed - * to be filled in scanline order, and thus the - * algorithm used is an extension of Bresenham's line - * drawing algorithm which assumes that y is always the - * major axis. - * Since these pieces of code are the same for any filled shape, - * it is more convenient to gather the library in one - * place, but since these pieces of code are also in - * the inner loops of output primitives, procedure call - * overhead is out of the question. - * See the author for a derivation if needed. - */ - -/* - * In scan converting polygons, we want to choose those pixels - * which are inside the polygon. Thus, we add .5 to the starting - * x coordinate for both left and right edges. Now we choose the - * first pixel which is inside the pgon for the left edge and the - * first pixel which is outside the pgon for the right edge. - * Draw the left pixel, but not the right. - * - * How to add .5 to the starting x coordinate: - * If the edge is moving to the right, then subtract dy from the - * error term from the general form of the algorithm. - * If the edge is moving to the left, then add dy to the error term. - * - * The reason for the difference between edges moving to the left - * and edges moving to the right is simple: If an edge is moving - * to the right, then we want the algorithm to flip immediately. - * If it is moving to the left, then we don't want it to flip until - * we traverse an entire pixel. - */ -#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ - int dx; /* local storage */ \ -\ - /* \ - * if the edge is horizontal, then it is ignored \ - * and assumed not to be processed. Otherwise, do this stuff. \ - */ \ - if ((dy) != 0) { \ - xStart = (x1); \ - dx = (x2) - xStart; \ - if (dx < 0) { \ - m = dx / (dy); \ - m1 = m - 1; \ - incr1 = -2 * dx + 2 * (dy) * m1; \ - incr2 = -2 * dx + 2 * (dy) * m; \ - d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ - } else { \ - m = dx / (dy); \ - m1 = m + 1; \ - incr1 = 2 * dx - 2 * (dy) * m1; \ - incr2 = 2 * dx - 2 * (dy) * m; \ - d = -2 * m * (dy) + 2 * dx; \ - } \ - } \ -} - -#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ - if (m1 > 0) { \ - if (d > 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } else {\ - if (d >= 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } \ -} - - -/* - * This structure contains all of the information needed - * to run the bresenham algorithm. - * The variables may be hardcoded into the declarations - * instead of using this structure to make use of - * register declarations. - */ -typedef struct { - int minor; /* minor axis */ - int d; /* decision variable */ - int m, m1; /* slope and slope+1 */ - int incr1, incr2; /* error increments */ -} BRESINFO; - - -#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ - BRESINITPGON(dmaj, min1, min2, bres.minor, bres.d, \ - bres.m, bres.m1, bres.incr1, bres.incr2) - -#define BRESINCRPGONSTRUCT(bres) \ - BRESINCRPGON(bres.d, bres.minor, bres.m, bres.m1, bres.incr1, bres.incr2) - - -typedef struct _EdgeTableEntry { - int ymax; /* ycoord at which we exit this edge. */ - BRESINFO bres; /* Bresenham info to run the edge */ - struct _EdgeTableEntry *next; /* next in the list */ - struct _EdgeTableEntry *back; /* for insertion sort */ - struct _EdgeTableEntry *nextWETE; /* for winding num rule */ - int ClockWise; /* flag for winding number rule */ -} EdgeTableEntry; - - -typedef struct _ScanLineList{ - int scanline; /* the scanline represented */ - EdgeTableEntry *edgelist; /* header node */ - struct _ScanLineList *next; /* next in the list */ -} ScanLineList; - - -typedef struct { - int ymax; /* ymax for the polygon */ - int ymin; /* ymin for the polygon */ - ScanLineList scanlines; /* header node */ -} EdgeTable; - - -/* - * Here is a struct to help with storage allocation - * so we can allocate a big chunk at a time, and then take - * pieces from this heap when we need to. - */ -#define SLLSPERBLOCK 25 - -typedef struct _ScanLineListBlock { - ScanLineList SLLs[SLLSPERBLOCK]; - struct _ScanLineListBlock *next; -} ScanLineListBlock; - -/* - * number of points to buffer before sending them off - * to scanlines() : Must be an even number - */ -#define NUMPTSTOBUFFER 200 - -/* - * - * a few macros for the inner loops of the fill code where - * performance considerations don't allow a procedure call. - * - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The winding number rule is in effect, so we must notify - * the caller when the edge has been removed so he - * can reorder the Winding Active Edge Table. - */ -#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - fixWAET = 1; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres); \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} - - -/* - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The even-odd rule is in effect. - */ -#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres) \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} - -/*********************************************************** - -Copyright (c) 1987 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -#define MAXINT 0x7fffffff -#define MININT -MAXINT - -/* - * fillUtils.c - * - * Written by Brian Kelleher; Oct. 1985 - * - * This module contains all of the utility functions - * needed to scan convert a polygon. - * - */ -/* - * InsertEdgeInET - * - * Insert the given edge into the edge table. - * First we must find the correct bucket in the - * Edge table, then find the right slot in the - * bucket. Finally, we can insert it. - * - */ -static bool -miInsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, - int scanline, ScanLineListBlock **SLLBlock, int *iSLLBlock) -{ - EdgeTableEntry *start, *prev; - ScanLineList *pSLL, *pPrevSLL; - ScanLineListBlock *tmpSLLBlock; - - /* - * find the right bucket to put the edge into - */ - pPrevSLL = &ET->scanlines; - pSLL = pPrevSLL->next; - while (pSLL && (pSLL->scanline < scanline)) - { - pPrevSLL = pSLL; - pSLL = pSLL->next; - } - - /* - * reassign pSLL (pointer to ScanLineList) if necessary - */ - if ((!pSLL) || (pSLL->scanline > scanline)) - { - if (*iSLLBlock > SLLSPERBLOCK-1) - { - tmpSLLBlock = - (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); - if (!tmpSLLBlock) - return FALSE; - (*SLLBlock)->next = tmpSLLBlock; - tmpSLLBlock->next = 0; - *SLLBlock = tmpSLLBlock; - *iSLLBlock = 0; - } - pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); - - pSLL->next = pPrevSLL->next; - pSLL->edgelist = 0; - pPrevSLL->next = pSLL; - } - pSLL->scanline = scanline; - - /* - * now insert the edge in the right bucket - */ - prev = 0; - start = pSLL->edgelist; - while (start && (start->bres.minor < ETE->bres.minor)) - { - prev = start; - start = start->next; - } - ETE->next = start; - - if (prev) - prev->next = ETE; - else - pSLL->edgelist = ETE; - return TRUE; -} - -/* - * CreateEdgeTable - * - * This routine creates the edge table for - * scan converting polygons. - * The Edge Table (ET) looks like: - * - * EdgeTable - * -------- - * | ymax | ScanLineLists - * |scanline|-->------------>-------------->... - * -------- |scanline| |scanline| - * |edgelist| |edgelist| - * --------- --------- - * | | - * | | - * V V - * list of ETEs list of ETEs - * - * where ETE is an EdgeTableEntry data structure, - * and there is one ScanLineList per scanline at - * which an edge is initially entered. - * - */ - -typedef struct { -#if defined(Q_OS_MAC) - int y, x; -#else - int x, y; -#endif - -} DDXPointRec, *DDXPointPtr; - -/* - * Clean up our act. - */ -static void -miFreeStorage(ScanLineListBlock *pSLLBlock) -{ - ScanLineListBlock *tmpSLLBlock; - - while (pSLLBlock) - { - tmpSLLBlock = pSLLBlock->next; - free(pSLLBlock); - pSLLBlock = tmpSLLBlock; - } -} - -static bool -miCreateETandAET(int count, DDXPointPtr pts, EdgeTable *ET, - EdgeTableEntry *AET, EdgeTableEntry *pETEs, ScanLineListBlock *pSLLBlock) -{ - DDXPointPtr top, bottom; - DDXPointPtr PrevPt, CurrPt; - int iSLLBlock = 0; - - int dy; - - if (count < 2) return TRUE; - - /* - * initialize the Active Edge Table - */ - AET->next = 0; - AET->back = 0; - AET->nextWETE = 0; - AET->bres.minor = MININT; - - /* - * initialize the Edge Table. - */ - ET->scanlines.next = 0; - ET->ymax = MININT; - ET->ymin = MAXINT; - pSLLBlock->next = 0; - - PrevPt = &pts[count-1]; - - /* - * for each vertex in the array of points. - * In this loop we are dealing with two vertices at - * a time -- these make up one edge of the polygon. - */ - while (count--) - { - CurrPt = pts++; - - /* - * find out which point is above and which is below. - */ - if (PrevPt->y > CurrPt->y) - { - bottom = PrevPt, top = CurrPt; - pETEs->ClockWise = 0; - } - else - { - bottom = CurrPt, top = PrevPt; - pETEs->ClockWise = 1; - } - - /* - * don't add horizontal edges to the Edge table. - */ - if (bottom->y != top->y) - { - pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */ - - /* - * initialize integer edge algorithm - */ - dy = bottom->y - top->y; - BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres) - - if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) - { - miFreeStorage(pSLLBlock->next); - return FALSE; - } - - ET->ymax = TQMAX(ET->ymax, PrevPt->y); - ET->ymin = TQMIN(ET->ymin, PrevPt->y); - pETEs++; - } - - PrevPt = CurrPt; - } - return TRUE; -} - -/* - * loadAET - * - * This routine moves EdgeTableEntries from the - * EdgeTable into the Active Edge Table, - * leaving them sorted by smaller x coordinate. - * - */ - -static void -miloadAET(EdgeTableEntry *AET, EdgeTableEntry *ETEs) -{ - EdgeTableEntry *pPrevAET; - EdgeTableEntry *tmp; - - pPrevAET = AET; - AET = AET->next; - while (ETEs) - { - while (AET && (AET->bres.minor < ETEs->bres.minor)) - { - pPrevAET = AET; - AET = AET->next; - } - tmp = ETEs->next; - ETEs->next = AET; - if (AET) - AET->back = ETEs; - ETEs->back = pPrevAET; - pPrevAET->next = ETEs; - pPrevAET = ETEs; - - ETEs = tmp; - } -} - -/* - * computeWAET - * - * This routine links the AET by the - * nextWETE (winding EdgeTableEntry) link for - * use by the winding number rule. The final - * Active Edge Table (AET) might look something - * like: - * - * AET - * ---------- --------- --------- - * |ymax | |ymax | |ymax | - * | ... | |... | |... | - * |next |->|next |->|next |->... - * |nextWETE| |nextWETE| |nextWETE| - * --------- --------- ^-------- - * | | | - * V-------------------> V---> ... - * - */ -static void -micomputeWAET(EdgeTableEntry *AET) -{ - EdgeTableEntry *pWETE; - int inside = 1; - int isInside = 0; - - AET->nextWETE = 0; - pWETE = AET; - AET = AET->next; - while (AET) - { - if (AET->ClockWise) - isInside++; - else - isInside--; - - if ((!inside && !isInside) || - ( inside && isInside)) - { - pWETE->nextWETE = AET; - pWETE = AET; - inside = !inside; - } - AET = AET->next; - } - pWETE->nextWETE = 0; -} - -/* - * InsertionSort - * - * Just a simple insertion sort using - * pointers and back pointers to sort the Active - * Edge Table. - * - */ - -static int -miInsertionSort(EdgeTableEntry *AET) -{ - EdgeTableEntry *pETEchase; - EdgeTableEntry *pETEinsert; - EdgeTableEntry *pETEchaseBackTMP; - int changed = 0; - - AET = AET->next; - while (AET) - { - pETEinsert = AET; - pETEchase = AET; - while (pETEchase->back->bres.minor > AET->bres.minor) - pETEchase = pETEchase->back; - - AET = AET->next; - if (pETEchase != pETEinsert) - { - pETEchaseBackTMP = pETEchase->back; - pETEinsert->back->next = AET; - if (AET) - AET->back = pETEinsert->back; - pETEinsert->next = pETEchase; - pETEchase->back->next = pETEinsert; - pETEchase->back = pETEinsert; - pETEinsert->back = pETEchaseBackTMP; - changed = 1; - } - } - return(changed); -} - -/*! - \overload -*/ -void TQPolygonScanner::scan(const TQPointArray& pa, bool winding, int index, int npoints) -{ - scan( pa, winding, index, npoints, TRUE ); -} - -/*! - \overload - - If \a stitchable is FALSE, the right and bottom edges of the - polygon are included. This causes adjacent polygons to overlap. -*/ -void TQPolygonScanner::scan(const TQPointArray& pa, bool winding, int index, int npoints, bool stitchable) -{ - scan( pa, winding, index, npoints, - stitchable ? Edge(Left+Top) : Edge(Left+Right+Top+Bottom) ); -} - -/*! - Calls processSpans() for all scanlines of the polygon defined by - \a npoints starting at \a index in \a pa. - - If \a winding is TRUE, the Winding algorithm rather than the - Odd-Even rule is used. - - The \a edges is any bitwise combination of: - \list - \i \c TQPolygonScanner::Left - \i \c TQPolygonScanner::Right - \i \c TQPolygonScanner::Top - \i \c TQPolygonScanner::Bottom - \endlist - \a edges determines which edges are included. - - \warning The edges feature does not work properly. - -*/ -void TQPolygonScanner::scan( const TQPointArray& pa, bool winding, int index, int npoints, Edge edges ) -{ - - - DDXPointPtr ptsIn = (DDXPointPtr)pa.data(); - ptsIn += index; - EdgeTableEntry *pAET; /* the Active Edge Table */ - int y; /* the current scanline */ - int nPts = 0; /* number of pts in buffer */ - EdgeTableEntry *pWETE; /* Winding Edge Table */ - ScanLineList *pSLL; /* Current ScanLineList */ - DDXPointPtr ptsOut; /* ptr to output buffers */ - int *width; - DDXPointRec FirstPoint[NUMPTSTOBUFFER]; /* the output buffers */ - int FirstWidth[NUMPTSTOBUFFER]; - EdgeTableEntry *pPrevAET; /* previous AET entry */ - EdgeTable ET; /* Edge Table header node */ - EdgeTableEntry AET; /* Active ET header node */ - EdgeTableEntry *pETEs; /* Edge Table Entries buff */ - ScanLineListBlock SLLBlock; /* header for ScanLineList */ - int fixWAET = 0; - int edge_l = (edges & Left) ? 1 : 0; - int edge_r = (edges & Right) ? 1 : 0; - int edge_t = 1; //#### (edges & Top) ? 1 : 0; - int edge_b = (edges & Bottom) ? 1 : 0; - - if (npoints == -1) - npoints = pa.size(); - - if (npoints < 3) - return; - - if(!(pETEs = (EdgeTableEntry *) - malloc(sizeof(EdgeTableEntry) * npoints))) - return; - ptsOut = FirstPoint; - width = FirstWidth; - if (!miCreateETandAET(npoints, ptsIn, &ET, &AET, pETEs, &SLLBlock)) - { - free(pETEs); - return; - } - pSLL = ET.scanlines.next; - - if (!winding) - { - /* - * for each scanline - */ - for (y = ET.ymin+1-edge_t; y < ET.ymax+edge_b; y++) - { - /* - * Add a new edge to the active edge table when we - * get to the next edge. - */ - if (pSLL && y == pSLL->scanline) - { - miloadAET(&AET, pSLL->edgelist); - pSLL = pSLL->next; - } - pPrevAET = &AET; - pAET = AET.next; - - /* - * for each active edge - */ - while (pAET) - { - ptsOut->x = pAET->bres.minor + 1 - edge_l; - ptsOut++->y = y; - *width++ = pAET->next->bres.minor - pAET->bres.minor - - 1 + edge_l + edge_r; - nPts++; - - /* - * send out the buffer when its full - */ - if (nPts == NUMPTSTOBUFFER) - { - processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); - ptsOut = FirstPoint; - width = FirstWidth; - nPts = 0; - } - EVALUATEEDGEEVENODD(pAET, pPrevAET, y) - EVALUATEEDGEEVENODD(pAET, pPrevAET, y) - } - miInsertionSort(&AET); - } - } - else /* default to WindingNumber */ - { - /* - * for each scanline - */ - for (y = ET.ymin+1-edge_t; y < ET.ymax+edge_b; y++) - { - /* - * Add a new edge to the active edge table when we - * get to the next edge. - */ - if (pSLL && y == pSLL->scanline) - { - miloadAET(&AET, pSLL->edgelist); - micomputeWAET(&AET); - pSLL = pSLL->next; - } - pPrevAET = &AET; - pAET = AET.next; - pWETE = pAET; - - /* - * for each active edge - */ - while (pAET) - { - /* - * if the next edge in the active edge table is - * also the next edge in the winding active edge - * table. - */ - if (pWETE == pAET) - { - ptsOut->x = pAET->bres.minor + 1 - edge_l; - ptsOut++->y = y; - *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor - 1 + edge_l + edge_r; - nPts++; - - /* - * send out the buffer - */ - if (nPts == NUMPTSTOBUFFER) - { - processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); - ptsOut = FirstPoint; - width = FirstWidth; - nPts = 0; - } - - pWETE = pWETE->nextWETE; - while (pWETE != pAET) { - EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) - } - pWETE = pWETE->nextWETE; - } - EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) - } - - /* - * reevaluate the Winding active edge table if we - * just had to resort it or if we just exited an edge. - */ - if (miInsertionSort(&AET) || fixWAET) - { - micomputeWAET(&AET); - fixWAET = 0; - } - } - } - - /* - * Get any spans that we missed by buffering - */ - - - processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); - free(pETEs); - miFreeStorage(SLLBlock.next); -} -/***** END OF X11-based CODE *****/ - - diff --git a/src/kernel/qt_gfx.pri b/src/kernel/qt_gfx.pri index fadd1277f..a30d86f17 100644 --- a/src/kernel/qt_gfx.pri +++ b/src/kernel/qt_gfx.pri @@ -1,8 +1,8 @@ # TQt graphics #mng support -HEADERS += $$KERNEL_H/ntqmngio.h -SOURCES += $$KERNEL_CPP/qmngio.cpp +HEADERS += $$KERNEL_H/tqmngio.h +SOURCES += $$KERNEL_CPP/tqmngio.cpp mng { system-mng { win32:LIBS += libmng.lib diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri index 03904d262..d3e214b06 100644 --- a/src/kernel/qt_kernel.pri +++ b/src/kernel/qt_kernel.pri @@ -40,10 +40,10 @@ kernel { $$KERNEL_H/tqlayout.h \ $$KERNEL_P/tqlayoutengine_p.h \ $$KERNEL_H/tqtranslator.h \ - $$KERNEL_H/ntqmetaobject.h \ + $$KERNEL_H/tqmetaobject.h \ $$KERNEL_H/tqmime.h \ $$KERNEL_H/tqmovie.h \ - $$KERNEL_H/ntqnamespace.h \ + $$KERNEL_H/tqnamespace.h \ $$KERNEL_H/tqnetworkprotocol.h \ $$KERNEL_H/tqobject.h \ $$KERNEL_H/tqobjectcleanuphandler.h \ @@ -61,7 +61,7 @@ kernel { $$KERNEL_H/tqpixmapcache.h \ $$KERNEL_H/tqpointarray.h \ $$KERNEL_H/tqpoint.h \ - $$KERNEL_H/ntqpolygonscanner.h \ + $$KERNEL_H/tqpolygonscanner.h \ $$KERNEL_H/tqprinter.h \ $$KERNEL_H/tqprocess.h \ $$KERNEL_H/tqrect.h \ @@ -221,7 +221,7 @@ kernel { $$KERNEL_CPP/tqlayout.cpp \ $$KERNEL_CPP/tqlayoutengine.cpp \ $$KERNEL_CPP/tqtranslator.cpp \ - $$KERNEL_CPP/qmetaobject.cpp \ + $$KERNEL_CPP/tqmetaobject.cpp \ $$KERNEL_CPP/tqmime.cpp \ $$KERNEL_CPP/tqmovie.cpp \ $$KERNEL_CPP/tqnetworkprotocol.cpp \ @@ -235,7 +235,7 @@ kernel { $$KERNEL_CPP/tqpixmapcache.cpp \ $$KERNEL_CPP/tqpointarray.cpp \ $$KERNEL_CPP/tqpoint.cpp \ - $$KERNEL_CPP/qpolygonscanner.cpp \ + $$KERNEL_CPP/tqpolygonscanner.cpp \ $$KERNEL_CPP/tqprinter.cpp \ $$KERNEL_CPP/tqprocess.cpp \ $$KERNEL_CPP/tqrect.cpp \ diff --git a/src/kernel/qt_pch.h b/src/kernel/qt_pch.h index 982ea2946..690551eb6 100644 --- a/src/kernel/qt_pch.h +++ b/src/kernel/qt_pch.h @@ -29,7 +29,7 @@ #include #include #include -#include // All moc genereated code has this include +#include // All moc genereated code has this include #include #include #include diff --git a/src/kernel/tqaccel.cpp b/src/kernel/tqaccel.cpp index 39e0213f0..ef6b665e6 100644 --- a/src/kernel/tqaccel.cpp +++ b/src/kernel/tqaccel.cpp @@ -85,7 +85,7 @@ combined with modifiers (\c SHIFT, \c CTRL, \c ALT or \c UNICODE_ACCEL). For example, \c{CTRL + Key_P} could be a shortcut for printing a document. The key codes are listed in \c - ntqnamespace.h. As an alternative, use \c UNICODE_ACCEL with the + tqnamespace.h. As an alternative, use \c UNICODE_ACCEL with the unicode code point of the character. For example, \c{UNICODE_ACCEL + 'A'} gives the same accelerator as \c Key_A. diff --git a/src/kernel/tqaccessible.cpp b/src/kernel/tqaccessible.cpp index 243c4384c..6cbe717e6 100644 --- a/src/kernel/tqaccessible.cpp +++ b/src/kernel/tqaccessible.cpp @@ -41,7 +41,7 @@ #if defined(QT_ACCESSIBILITY_SUPPORT) #include "tqptrdict.h" -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include #include "ntqapplication.h" #include diff --git a/src/kernel/tqcolor.cpp b/src/kernel/tqcolor.cpp index 59f726694..142fb408a 100644 --- a/src/kernel/tqcolor.cpp +++ b/src/kernel/tqcolor.cpp @@ -39,7 +39,7 @@ **********************************************************************/ #include "tqcolor.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqdatastream.h" #include diff --git a/src/kernel/tqcursor_x11.cpp b/src/kernel/tqcursor_x11.cpp index fd2aea158..9facf093c 100644 --- a/src/kernel/tqcursor_x11.cpp +++ b/src/kernel/tqcursor_x11.cpp @@ -43,7 +43,7 @@ #include "tqimage.h" #include "ntqapplication.h" #include "tqdatastream.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "qt_x11_p.h" #include diff --git a/src/kernel/tqdrawutil.h b/src/kernel/tqdrawutil.h index d8e2703d2..113d6095f 100644 --- a/src/kernel/tqdrawutil.h +++ b/src/kernel/tqdrawutil.h @@ -42,7 +42,7 @@ #define TQDRAWUTIL_H #ifndef QT_H -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqstring.h" // char*->TQString conversion #endif // QT_H diff --git a/src/kernel/tqevent.h b/src/kernel/tqevent.h index f05fc2c94..fc229f9ab 100644 --- a/src/kernel/tqevent.h +++ b/src/kernel/tqevent.h @@ -44,7 +44,7 @@ #ifndef QT_H #include "ntqwindowdefs.h" #include "tqregion.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqmime.h" #include "tqpair.h" #endif // QT_H diff --git a/src/kernel/tqfont.cpp b/src/kernel/tqfont.cpp index fa050a234..a3e21c655 100644 --- a/src/kernel/tqfont.cpp +++ b/src/kernel/tqfont.cpp @@ -2435,7 +2435,7 @@ TQRect TQFontMetrics::boundingRect( TQChar ch ) const If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined. - These flags are defined in \c ntqnamespace.h. + These flags are defined in \c tqnamespace.h. If \c ExpandTabs is set in \a flgs, then: if \a tabarray is non-null, it specifies a 0-terminated sequence of pixel-positions @@ -2497,7 +2497,7 @@ TQRect TQFontMetrics::boundingRect( int x, int y, int w, int h, int flgs, \i \c WordBreak breaks the text to fit the rectangle. \endlist - These flags are defined in \c ntqnamespace.h. + These flags are defined in \c tqnamespace.h. If \c ExpandTabs is set in \a flgs, then: if \a tabarray is non-null, it specifies a 0-terminated sequence of pixel-positions diff --git a/src/kernel/tqimage.cpp b/src/kernel/tqimage.cpp index b71804321..0a2995ede 100644 --- a/src/kernel/tqimage.cpp +++ b/src/kernel/tqimage.cpp @@ -47,7 +47,7 @@ #include "tqptrlist.h" #include "tqasyncimageio.h" #include "tqpngio.h" -#include "ntqmngio.h" +#include "tqmngio.h" #include "tqjpegio.h" #include "tqmap.h" #include diff --git a/src/kernel/tqkeycode.h b/src/kernel/tqkeycode.h index bca9305ba..45aec20b6 100644 --- a/src/kernel/tqkeycode.h +++ b/src/kernel/tqkeycode.h @@ -42,7 +42,7 @@ #define TQKEYCODE_H #ifndef QT_H -#include "ntqnamespace.h" +#include "tqnamespace.h" #endif // QT_H // all key codes are now in the TQt namespace class diff --git a/src/kernel/tqkeysequence.cpp b/src/kernel/tqkeysequence.cpp index 94ba5cf53..88ea36bd5 100644 --- a/src/kernel/tqkeysequence.cpp +++ b/src/kernel/tqkeysequence.cpp @@ -67,7 +67,7 @@ optionally combined with modifiers, e.g. \c SHIFT, \c CTRL, \c ALT, \c META, or \c UNICODE_ACCEL. For example, \c{CTRL + Key_P} might be a sequence used as a shortcut for printing a document. - The key codes are listed in \c{ntqnamespace.h}. As an alternative, + The key codes are listed in \c{tqnamespace.h}. As an alternative, use \c UNICODE_ACCEL with the unicode code point of the character. For example, \c{UNICODE_ACCEL + 'A'} gives the same key sequence as \c Key_A. @@ -246,7 +246,7 @@ TQKeySequence::TQKeySequence( const TQString& key ) /*! Constructs a key sequence that has a single \a key. - The key codes are listed in \c{ntqnamespace.h} and can be + The key codes are listed in \c{tqnamespace.h} and can be combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c ALT, \c META or \c UNICODE_ACCEL. */ @@ -261,7 +261,7 @@ TQKeySequence::TQKeySequence( int key ) Constructs a key sequence with up to 4 keys \a k1, \a k2, \a k3 and \a k4. - The key codes are listed in \c{ntqnamespace.h} and can be + The key codes are listed in \c{tqnamespace.h} and can be combined with modifiers, e.g. with \c SHIFT, \c CTRL, \c ALT, \c META or \c UNICODE_ACCEL. */ diff --git a/src/kernel/tqkeysequence.h b/src/kernel/tqkeysequence.h index e4800839d..d4965fd5c 100644 --- a/src/kernel/tqkeysequence.h +++ b/src/kernel/tqkeysequence.h @@ -43,7 +43,7 @@ #ifndef QT_H #ifndef QT_H -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqstring.h" #endif // QT_H #endif diff --git a/src/kernel/tqmetaobject.cpp b/src/kernel/tqmetaobject.cpp new file mode 100644 index 000000000..06fd7c86f --- /dev/null +++ b/src/kernel/tqmetaobject.cpp @@ -0,0 +1,1251 @@ +/**************************************************************************** +** +** Implementation of TQMetaObject class +** +** Created : 930419 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqmetaobject.h" +#include "tqasciidict.h" + +#ifdef TQT_THREAD_SUPPORT +#include +#endif // TQT_THREAD_SUPPORT + +/*! + \class TQMetaData tqmetaobject.h + \reentrant + + \brief The TQMetaData class provides information about a member function that is known to the meta object system. + + \internal + + The struct consists of three members, \e name, \e method and \e access: + + \code + const char *name; // - member name + const TQUMethod* method; // - detailed method description + enum Access { Private, Protected, Public }; + Access access; // - access permission + \endcode + */ + +/*! + \class TQClassInfo tqmetaobject.h + + \brief The TQClassInfo class provides a struct that stores some basic information about a single class. + + \internal + + The class information is a simple \e name - \e value pair: + + \code + const char* name; + const char* value; + \endcode + + */ + + +/*! + \class TQMetaObject tqmetaobject.h + \brief The TQMetaObject class contains meta information about TQt objects. + + \ingroup objectmodel + + The Meta Object System in TQt is responsible for the signals and + slots inter-object communication mechanism, runtime type + information and the property system. All meta information in TQt is + kept in a single instance of TQMetaObject per class. + + This class is not normally required for application programming. + But if you write meta applications, such as scripting engines or + GUI builders, you might find these functions useful: + \list + \i className() to get the name of a class. + \i superClassName() to get the name of the superclass. + \i inherits(), the function called by TQObject::inherits(). + \i superClass() to access the superclass's meta object. + \i numSlots(), numSignals(), slotNames(), and signalNames() to get + information about a class's signals and slots. + \i property() and propertyNames() to obtain information about a + class's properties. + \endlist + + Classes may have a list of name-value pairs of class information. + The number of pairs is returned by numClassInfo(), and values are + returned by classInfo(). + + \sa \link moc.html moc (Meta Object Compiler)\endlink + +*/ + + +/***************************************************************************** + The private object. + *****************************************************************************/ + +// extra flags from moc.y +enum Flags { + Invalid = 0x00000000, + Readable = 0x00000001, + Writable = 0x00000002, + EnumOrSet = 0x00000004, + UnresolvedEnum = 0x00000008, + StdSet = 0x00000100, + Override = 0x00000200, + NotDesignable = 0x00001000, + DesignableOverride = 0x00002000, + NotScriptable = 0x00004000, + ScriptableOverride = 0x00008000, + NotStored = 0x00010000, + StoredOverride = 0x00020000 +}; + +static TQAsciiDict *qt_metaobjects = 0; +static int qt_metaobjects_count = 0; + +class TQMetaObjectPrivate +{ +public: + TQMetaObjectPrivate() : +#ifndef TQT_NO_PROPERTIES + enumData(0), numEnumData(0), + propData(0),numPropData(0), + tqt_static_property(0), +#endif + classInfo(0), numClassInfo(0) {} +#ifndef TQT_NO_PROPERTIES + const TQMetaEnum *enumData; + int numEnumData; + const TQMetaProperty *propData; + int numPropData; + bool (*tqt_static_property)(TQObject*, int, int, TQVariant*); +#endif + const TQClassInfo *classInfo; + int numClassInfo; +}; + + +/***************************************************************************** + Internal dictionary for fast access to class members + *****************************************************************************/ + +#if defined(Q_CANNOT_DELETE_CONSTANT) +typedef TQMetaData TQConstMetaData; +#else +typedef const TQMetaData TQConstMetaData; +#endif + +class TQ_EXPORT TQMemberDict : public TQAsciiDict +{ +public: + TQMemberDict( int size = 17, bool cs = TRUE, bool ck = TRUE ) : + TQAsciiDict(size,cs,ck) {} + TQMemberDict( const TQMemberDict &dict ) : TQAsciiDict(dict) {} + ~TQMemberDict() { clear(); } + TQMemberDict &operator=(const TQMemberDict &dict) + { return (TQMemberDict&)TQAsciiDict::operator=(dict); } +}; + + +/* + Calculate optimal dictionary size for n entries using prime numbers, + and assuming there are no more than 40 entries. +*/ + +static int optDictSize( int n ) +{ + if ( n < 6 ) + n = 5; + else if ( n < 10 ) + n = 11; + else if ( n < 14 ) + n = 17; + else + n = 23; + return n; +} + + +/***************************************************************************** + TQMetaObject member functions + *****************************************************************************/ + +/*!\internal + */ +TQMetaObject::TQMetaObject( const char *const class_name, TQMetaObject *super_class, + const TQMetaData *const slot_data, int n_slots, + const TQMetaData *const signal_data, int n_signals, +#ifndef TQT_NO_PROPERTIES + const TQMetaProperty *const prop_data, int n_props, + const TQMetaEnum *const enum_data, int n_enums, +#endif + const TQClassInfo *const class_info, int n_info ) +{ + classname = class_name; // set meta data + superclass = super_class; + superclassname = superclass ? superclass->className() : 0; + slotDict = init( slotData = slot_data, n_slots ); + signalDict = init( signalData = signal_data, n_signals ); + + d = new TQMetaObjectPrivate; + reserved = 0; + +#ifndef TQT_NO_PROPERTIES + d->propData = prop_data; + d->numPropData = n_props; + d->enumData = enum_data; + d->numEnumData = n_enums; +#endif + d->classInfo = class_info; + d->numClassInfo = n_info; + + signaloffset = superclass ? ( superclass->signalOffset() + superclass->numSignals() ) : 0; + slotoffset = superclass ? ( superclass->slotOffset() + superclass->numSlots() ) : 0; +#ifndef TQT_NO_PROPERTIES + propertyoffset = superclass ? ( superclass->propertyOffset() + superclass->numProperties() ) : 0; +#endif +} + +#ifndef TQT_NO_PROPERTIES +/*!\internal + */ +TQMetaObject::TQMetaObject( const char *const class_name, TQMetaObject *super_class, + const TQMetaData *const slot_data, int n_slots, + const TQMetaData *const signal_data, int n_signals, + const TQMetaProperty *const prop_data, int n_props, + const TQMetaEnum *const enum_data, int n_enums, + bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), + const TQClassInfo *const class_info, int n_info ) +{ + classname = class_name; // set meta data + superclass = super_class; + superclassname = superclass ? superclass->className() : 0; + slotDict = init( slotData = slot_data, n_slots ); + signalDict = init( signalData = signal_data, n_signals ); + + d = new TQMetaObjectPrivate; + reserved = 0; + + d->propData = prop_data; + d->numPropData = n_props; + d->enumData = enum_data; + d->numEnumData = n_enums; + d->tqt_static_property = tqt_static_property; + d->classInfo = class_info; + d->numClassInfo = n_info; + + signaloffset = superclass ? ( superclass->signalOffset() + superclass->numSignals() ) : 0; + slotoffset = superclass ? ( superclass->slotOffset() + superclass->numSlots() ) : 0; + propertyoffset = superclass ? ( superclass->propertyOffset() + superclass->numProperties() ) : 0; +} +#endif + +/*!\internal + */ +TQMetaObject::~TQMetaObject() +{ + delete slotDict; // delete dicts + delete signalDict; + delete d; +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); +#endif // TQT_THREAD_SUPPORT + if ( qt_metaobjects ) { + qt_metaobjects->remove( classname ); + if ( qt_metaobjects->isEmpty() ) { + delete qt_metaobjects; + qt_metaobjects = 0; + } + } + + // delete reserved; // Unused void* +} + + +/*! + \fn const char *TQMetaObject::className() const + + Returns the class name. + + \sa TQObject::className(), superClassName() +*/ + +/*! + \fn const char *TQMetaObject::superClassName() const + + Returns the class name of the superclass or 0 if there is no + superclass in the TQObject hierachy. + + \sa className() +*/ + +/*! + \fn TQMetaObject *TQMetaObject::superClass() const + + Returns the meta object of the super class or 0 if there is no + such object. +*/ + +/*! + Returns the number of slots for this class. + + If \a super is TRUE, inherited slots are included. + + \sa slotNames() +*/ +int TQMetaObject::numSlots( bool super ) const // number of slots +{ + int n = slotDict ? slotDict->count() : 0; + if ( !super || !superclass ) + return n; + return n + superclass->numSlots( super ); +} + +/*! + Returns the number of signals for this class. + + If \a super is TRUE, inherited signals are included. + + \sa signalNames() +*/ +int TQMetaObject::numSignals( bool super ) const // number of signals +{ + int n = signalDict ? signalDict->count() : 0; + if ( !super || !superclass ) + return n; + return n + superclass->numSignals( super ); +} + + +/*! \internal + + Returns the meta data of the slot with the name \a n or 0 if no + such slot exists. + + If \a super is TRUE, inherited slots are included. + */ +const TQMetaData* TQMetaObject::slot( int index, bool super ) const +{ + int idx = index - ( super ? slotOffset() : 0 ); + if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { + return slotData + idx; + } + if ( !super || !superclass ) + return 0; + return superclass->slot( index, super ); +} + +/*! \internal + + Returns the meta data of the signal with the name \a n or 0 if no + such signal exists. + + If \a super is TRUE, inherited signals are included. + */ +const TQMetaData* TQMetaObject::signal( int index, bool super ) const +{ + int idx = index - ( super ? signalOffset() : 0 ); + if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { + return signalData + idx; + } + if ( !super || !superclass ) + return 0; + return superclass->signal( index, super ); +} + + +/*! + \fn int TQMetaObject::signalOffset() const + + \internal + + Returns the signal offset for this metaobject. + +*/ + +/*! + \fn int TQMetaObject::propertyOffset() const + + \internal + + Returns the property offset for this metaobject. + +*/ + +/*! \internal + Returns the index of the signal with name \n or -1 if no such signal exists. + + If \a super is TRUE, inherited signals are included. +*/ +int TQMetaObject::findSignal( const char* n, bool super ) const +{ + const TQMetaObject *mo = this; + int offset = -1; + + do { + const TQMetaData *md = mo->signalDict ? mo->signalDict->find( n ) : 0; + if ( md ) { +#if defined(QT_CHECK_RANGE) + if ( offset != -1 ) { + tqWarning( "TQMetaObject::findSignal:%s: Conflict with %s::%s", + className(), mo->className(), n ); + return offset; + } +#endif + offset = mo->signalOffset() + ( md - mo->signalData ); +#if !defined(QT_CHECK_RANGE) + return offset; +#endif + } + } while ( super && (mo = mo->superclass) ); + + return offset; +} + +/*! + \fn int TQMetaObject::slotOffset() const + + \internal + + Returns the slot offset for this metaobject. + +*/ + +/*! \internal + Returns the index of the slot with name \n or -1 if no such slot exists. + + If \a super is TRUE, inherited slots are included. + */ +int TQMetaObject::findSlot( const char* n, bool super ) const +{ + const TQMetaData *md = slotDict ? slotDict->find( n ) : 0; + if ( md ) + return slotOffset() + ( md - slotData ); + if ( !super || !superclass) + return -1; + return superclass->findSlot( n, super ); +} + +/*!\internal + */ +TQMetaObject *TQMetaObject::new_metaobject( const char *classname, + TQMetaObject *superclassobject, + const TQMetaData * const slot_data, int n_slots, + const TQMetaData * const signal_data, int n_signals, +#ifndef TQT_NO_PROPERTIES + const TQMetaProperty * const prop_data, int n_props, + const TQMetaEnum * const enum_data, int n_enums, +#endif + const TQClassInfo * const class_info, int n_info ) +{ + return new TQMetaObject( classname, superclassobject, slot_data, n_slots, + signal_data, n_signals, +#ifndef TQT_NO_PROPERTIES + prop_data, n_props, + enum_data, n_enums, +#endif + class_info, n_info ); +} + +#ifndef TQT_NO_PROPERTIES +/*!\internal + */ +TQMetaObject *TQMetaObject::new_metaobject( const char *classname, + TQMetaObject *superclassobject, + const TQMetaData * const slot_data, int n_slots, + const TQMetaData * const signal_data, int n_signals, + const TQMetaProperty * const prop_data, int n_props, + const TQMetaEnum * const enum_data, int n_enums, + bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), + const TQClassInfo * const class_info, int n_info ) +{ + return new TQMetaObject( classname, superclassobject, slot_data, n_slots, + signal_data, n_signals, + prop_data, n_props, + enum_data, n_enums, + tqt_static_property, + class_info, n_info ); +} +#endif + +/*!\internal + */ +TQMemberDict *TQMetaObject::init( const TQMetaData * data, int n ) +{ + if ( n == 0 ) // nothing, then make no dict + return 0; + TQMemberDict *dict = new TQMemberDict( optDictSize(n), TRUE, FALSE ); + TQ_CHECK_PTR( dict ); + while ( n-- ) { // put all members into dict + dict->insert( data->name, data ); + data++; + } + return dict; +} + +/*! + Returns the number of items of class information available for + this class. + + If \a super is TRUE, inherited class information is included. +*/ +int TQMetaObject::numClassInfo( bool super ) const +{ + return d->numClassInfo + ((super && superclass)?superclass->numClassInfo(super):0); +} + +/*! + Returns the class information with index \a index or 0 if no such + information exists. + + If \a super is TRUE, inherited class information is included. +*/ +const TQClassInfo* TQMetaObject::classInfo( int index, bool super ) const +{ + if ( index < 0 ) + return 0; + if ( index < d->numClassInfo ) + return &(d->classInfo[ index ]); + if ( !super || !superclass ) + return 0; + return superclass->classInfo( index - d->numClassInfo, super ); +} + +/*! + \overload + Returns the class information with name \a name or 0 if no such + information exists. + + If \a super is TRUE, inherited class information is included. +*/ +const char* TQMetaObject::classInfo( const char* name, bool super ) const +{ + for( int i = 0; i < d->numClassInfo; ++i ) { + if ( qstrcmp( d->classInfo[i].name, name ) == 0 ) + return d->classInfo[i].value; + } + if ( !super || !superclass ) + return 0; + return superclass->classInfo( name, super ); +} + +#ifndef TQT_NO_PROPERTIES + +/*! + Returns the number of properties for this class. + + If \a super is TRUE, inherited properties are included. + + \sa propertyNames() + */ +int TQMetaObject::numProperties( bool super ) const // number of signals +{ + int n = d->numPropData; + if ( !super || !superclass ) + return n; + return n + superclass->numProperties( super ); +} + +/*! + Returns the property meta data for the property at index \a index + or 0 if no such property exists. + + If \a super is TRUE, inherited properties are included. + + \sa propertyNames() + */ +const TQMetaProperty* TQMetaObject::property( int index, bool super ) const +{ + int idx = index - ( super ? propertyOffset() : 0 ); + if ( d->propData && idx >= 0 && idx < (int)d->numPropData ) + return d->propData + idx; + if ( !super || !superclass ) + return 0; + return superclass->property( index, super ); +} + + +/*! + Returns the index for the property with name \a name or -1 if no + such property exists. + + If \a super is TRUE, inherited properties are included. + + \sa property(), propertyNames() +*/ + +int TQMetaObject::findProperty( const char *name, bool super ) const +{ + for( int i = 0; i < d->numPropData; ++i ) { + if ( d->propData[i].isValid() && qstrcmp( d->propData[i].name(), name ) == 0 ) { + return ( super ? propertyOffset() : 0 ) + i; + } + } + if ( !super || !superclass ) + return -1; + return superclass->findProperty( name, super ); +} + +/*! \internal + + Returns the index for the property \a prop + or -1 if the property can not be found. + + If \a super is TRUE, inherited properties are included. + + \sa property(), propertyNames() +*/ + +int TQMetaObject::indexOfProperty( const TQMetaProperty* prop, bool super ) const +{ + if ( *prop->meta == this ) + return ( super ? propertyOffset() : 0 ) + ( prop - d->propData); + if ( !super || !superclass ) + return -1; + return superclass->indexOfProperty( prop, super ); +} + +/*!\internal + + Returns the parent property of property \a p or 0, if the property + cannot be resolved. + + \a p has to be contained in this meta object +*/ + +const TQMetaProperty* TQMetaObject::resolveProperty( const TQMetaProperty* p ) const +{ + if ( !superclass ) + return 0; + return superclass->property( superclass->findProperty( p->n, TRUE ), TRUE ); +} + +/*!\internal + + \overload + + The version of resolveProperty that is used by moc generated code +*/ + +int TQMetaObject::resolveProperty( int index ) const +{ + if ( !superclass ) + return -1; + const TQMetaProperty* p = d->propData + ( index - propertyOffset() ); + return superclass->findProperty( p->n, TRUE ); +} + + +/*! + Returns a list with the names of all this class's properties. + + If \a super is TRUE, inherited properties are included. + + \sa property() +*/ +TQStrList TQMetaObject::propertyNames( bool super ) const +{ + TQStrList l( FALSE ); + + if ( superclass && super ) { + TQStrList sl = superclass->propertyNames( super ); + for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) + l.append( slit.current() ); + } + + for( int i = 0; i < d->numPropData; ++i ) { + if ( d->propData[i].isValid() ) + l.append( d->propData[i].name() ); + } + + return l; +} + +/*! + Returns a list with the names of all this class's signals. + + If \a super is TRUE, inherited signals are included. +*/ +TQStrList TQMetaObject::signalNames( bool super ) const +{ + TQStrList l( FALSE ); + int n = numSignals( super ); + for( int i = 0; i < n; ++i ) { + l.append( signal(i, super)->name ); + } + return l; +} + +/*! + Returns a list with the names of all this class's slots. + + If \a super is TRUE, inherited slots are included. + + \sa numSlots() +*/ +TQStrList TQMetaObject::slotNames( bool super ) const +{ + TQStrList l( FALSE ); + int n = numSlots( super ); + for( int i = 0; i < n; ++i ) + l.append( slot( i, super)->name ); + return l; +} + +/*!\internal + + */ + +int TQMetaObject::numEnumerators( bool super ) const +{ + int n = 0; + if ( superclass && super ) + n += superclass->numEnumerators( super ); + return n + d->numEnumData; +} + +/*!\internal + + */ +TQStrList TQMetaObject::enumeratorNames( bool super ) const +{ + TQStrList l( FALSE ); + + if ( superclass && super ) { + TQStrList sl = superclass->enumeratorNames( super ); + for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) + l.append( slit.current() ); + } + + for( int i = 0; i < d->numEnumData; ++i ) { + if ( d->enumData[i].items ) + l.append( d->enumData[i].name ); + } + + return l; +} + +/*!\internal + */ +const TQMetaEnum* TQMetaObject::enumerator( const char* name, bool super ) const +{ + for( int i = 0; i < d->numEnumData; ++i ) + if ( qstrcmp( d->enumData[i].name, name ) == 0 ) + return &(d->enumData[i]); + if ( !super || !superclass ) + return 0; + return superclass->enumerator( name, super ); +} + +#endif // TQT_NO_PROPERTIES + + +/*! + Returns TRUE if this class inherits \a clname within the meta + object inheritance chain; otherwise returns FALSE. + + (A class is considered to inherit itself.) +*/ +bool TQMetaObject::inherits( const char* clname ) const +{ + const TQMetaObject *meta = this; + while ( meta ) { + if ( qstrcmp(clname, meta->className()) == 0 ) + return TRUE; + meta = meta->superclass; + } + return FALSE; +} + +/*! \internal */ + +TQMetaObject *TQMetaObject::metaObject( const char *class_name ) +{ + if ( !qt_metaobjects ) + return 0; +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); +#endif // TQT_THREAD_SUPPORT + TQtStaticMetaObjectFunction func = (TQtStaticMetaObjectFunction)qt_metaobjects->find( class_name ); + if ( func ) + return func(); + return 0; +} + +/*! \internal */ +bool TQMetaObject::hasMetaObject( const char *class_name ) +{ + if ( !qt_metaobjects ) + return FALSE; +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); +#endif // TQT_THREAD_SUPPORT + return !!qt_metaobjects->find( class_name ); +} + +#ifndef TQT_NO_PROPERTIES +/*! \internal + +### this functions will go away. It exists purely for the sake of meta +### object code generated with TQt 3.1.0 +*/ +bool TQMetaObject::tqt_static_property( TQObject* o, int id, int f, TQVariant* v) +{ + if ( d->tqt_static_property ) + return d->tqt_static_property( o, id, f, v ); + else if ( o ) // compatibility + return o->tqt_property( id, f, v ); + else if ( superclass ) + return superclass->tqt_static_property( o, id, f, v ); + switch ( f ) { + case 3: case 4: case 5: + return TRUE; + default: + return FALSE; + } +} + + +/*! + \class TQMetaProperty tqmetaobject.h + + \brief The TQMetaProperty class stores meta data about a property. + + \ingroup objectmodel + + Property meta data includes type(), name(), and whether a property + is writable(), designable() and stored(). + + The functions isSetType(), isEnumType() and enumKeys() provide + further information about a property's type. The conversion + functions keyToValue(), valueToKey(), keysToValue() and + valueToKeys() allow conversion between the integer representation + of an enumeration or set value and its literal representation. + + Actual property values are set and received through TQObject's set + and get functions. See TQObject::setProperty() and + TQObject::property() for details. + + You receive meta property data through an object's meta object. + See TQMetaObject::property() and TQMetaObject::propertyNames() for + details. +*/ + +/*! + Returns the possible enumeration keys if this property is an + enumeration type (or a set type). + + \sa isEnumType() +*/ +TQStrList TQMetaProperty::enumKeys() const +{ + TQStrList l( FALSE ); + const TQMetaEnum* ed = enumData; + if ( !enumData && meta ) + ed = (*meta)->enumerator( t, TRUE ); + if ( !ed ) + return l; + if ( ed != 0 ) { + for( uint i = 0; i < ed->count; ++i ) { + uint j = 0; + while ( j < i && + ed->items[j].value != ed->items[i].value ) + ++j; + if ( i == j ) + l.append( ed->items[i].key ); + } + } + return l; +} + +/*! + Converts the enumeration key \a key to its integer value. + + For set types, use keysToValue(). + + \sa valueToKey(), isSetType(), keysToValue() +*/ +int TQMetaProperty::keyToValue( const char* key ) const +{ + const TQMetaEnum* ed = enumData; + if ( !enumData && meta ) + ed = (*meta)->enumerator( t, TRUE ); + if ( !ed ) + return -1; + for ( uint i = 0; i < ed->count; ++i ) { + if ( !qstrcmp( key, ed->items[i].key) ) + return ed->items[i].value; + } + return -1; +} + +/*! + Converts the enumeration value \a value to its literal key. + + For set types, use valueToKeys(). + + \sa valueToKey(), isSetType(), valueToKeys() +*/ +const char* TQMetaProperty::valueToKey( int value ) const +{ + const TQMetaEnum* ed = enumData; + if ( !enumData && meta ) + ed = (*meta)->enumerator( t, TRUE ); + if ( !ed ) + return 0; + for ( uint i = 0; i < ed->count; ++i ) { + if ( value == ed->items[i].value ) + return ed->items[i].key ; + } + return 0; +} + +/*! + Converts the list of keys \a keys to their combined (OR-ed) + integer value. + + \sa isSetType(), valueToKey(), keysToValue() +*/ +int TQMetaProperty::keysToValue( const TQStrList& keys ) const +{ + const TQMetaEnum* ed = enumData; + if ( !enumData && meta ) + ed = (*meta)->enumerator( t, TRUE ); + if ( !ed ) + return -1; + int value = 0; + for ( TQStrListIterator it( keys ); it.current(); ++it ) { + uint i; + for( i = ed->count; i > 0; --i ) { + if ( !qstrcmp( it.current(), ed->items[i-1].key) ) { + value |= ed->items[i-1].value; + break; + } + } + if ( i == 0 ) + value |= -1; + } + return value; +} + +/*! + Converts the set value \a value to a list of keys. + + \sa isSetType(), valueToKey(), valueToKeys() +*/ +TQStrList TQMetaProperty::valueToKeys( int value ) const +{ + TQStrList keys; + const TQMetaEnum* ed = enumData; + if ( !enumData && meta ) + ed = (*meta)->enumerator( t, TRUE ); + if ( !ed ) + return keys; + + int v = value; + for( uint i = ed->count; i > 0; --i ) { + int k = ed->items[i-1].value; + if ( ( k != 0 && (v & k) == k ) || ( k == value) ) { + v = v & ~k; + keys.append( ed->items[i-1].key ); + } + } + return keys; +} + +bool TQMetaProperty::writable() const +{ + if ( !testFlags( Override ) || testFlags( Writable ) ) + return testFlags( Writable ); + const TQMetaObject* mo = (*meta); + const TQMetaProperty* parent = mo->resolveProperty( this ); + return parent ? parent->writable() : FALSE; +} + +/*!\internal + */ +bool TQMetaProperty::stdSet() const +{ + if ( !testFlags( Override ) || testFlags( Writable ) ) + return testFlags( StdSet ); + const TQMetaObject* mo = (*meta); + const TQMetaProperty* parent = mo->resolveProperty( this ); + return parent ? parent->stdSet() : FALSE; +} + +/*!\internal + */ +int TQMetaProperty::id() const +{ + return _id < 0 ? (*meta)->indexOfProperty( this, TRUE ) : _id; +} + +/*! \internal +*/ +void TQMetaProperty::clear() +{ + t = n = 0; + meta = 0; + enumData = 0; + _id = -1; + flags = 0; +} + +bool TQMetaProperty::isValid() const +{ + if ( testFlags( UnresolvedEnum ) ) { + if ( !enumData && (!meta || !(*meta)->enumerator( t, TRUE ) ) ) + return FALSE; + } + if ( !testFlags( Override ) || testFlags( Readable ) ) + return testFlags( Readable ); + const TQMetaObject* mo = (*meta); + const TQMetaProperty* parent = mo->resolveProperty( this ); + return parent ? parent->isValid() : FALSE; +} + +bool TQMetaProperty::isSetType() const +{ + const TQMetaEnum* ed = enumData; + if ( !enumData && meta ) + ed = (*meta)->enumerator( t, TRUE ); + return ( ed != 0 && ed->set ); +} + +bool TQMetaProperty::isEnumType() const +{ + return testFlags( EnumOrSet ); +} + + + +/*! + \fn const char* TQMetaProperty::type() const + + Returns the type of the property. +*/ + +/*! + \fn const char* TQMetaProperty::name() const + + Returns the name of the property. +*/ + +/*! + \fn bool TQMetaProperty::writable() const + + Returns TRUE if the property is writable; otherwise returns FALSE. + +*/ + +/*! \fn bool TQMetaProperty::isValid() const + + \internal + + Returns whether the property is valid. +*/ + +/*! + \fn bool TQMetaProperty::isEnumType() const + + Returns TRUE if the property's type is an enumeration value; + otherwise returns FALSE. + + \sa isSetType(), enumKeys() +*/ + +/*! + \fn bool TQMetaProperty::isSetType() const + + Returns TRUE if the property's type is an enumeration value that + is used as set, i.e. if the enumeration values can be OR-ed + together; otherwise returns FALSE. A set type is implicitly also + an enum type. + + \sa isEnumType(), enumKeys() +*/ + + +/*! Returns TRUE if the property is designable for object \a o; + otherwise returns FALSE. + + If no object \a o is given, the function returns a static + approximation. + */ +bool TQMetaProperty::designable( TQObject* o ) const +{ + if ( !isValid() || !writable() ) + return FALSE; + if ( o ) { + int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); + return idx >= 0 && o->tqt_property( idx, 3, 0 ); + } + if ( testFlags( DesignableOverride ) ) { + const TQMetaObject* mo = (*meta); + const TQMetaProperty* parent = mo->resolveProperty( this ); + return parent ? parent->designable() : FALSE; + } + return !testFlags( NotDesignable ); +} + +/*! + Returns TRUE if the property is scriptable for object \a o; + otherwise returns FALSE. + + If no object \a o is given, the function returns a static + approximation. + */ +bool TQMetaProperty::scriptable( TQObject* o ) const +{ + if ( o ) { + int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); + return idx >= 0 && o->tqt_property( idx, 4, 0 ); + } + if ( testFlags( ScriptableOverride ) ) { + const TQMetaObject* mo = (*meta); + const TQMetaProperty* parent = mo->resolveProperty( this ); + return parent ? parent->scriptable() : FALSE; + } + return !testFlags( NotScriptable ); +} + +/*! + Returns TRUE if the property shall be stored for object \a o; + otherwise returns FALSE. + + If no object \a o is given, the function returns a static + approximation. + */ +bool TQMetaProperty::stored( TQObject* o ) const +{ + if ( !isValid() || !writable() ) + return FALSE; + if ( o ) { + int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); + return idx >= 0 && o->tqt_property( idx, 5, 0 ); + } + if ( testFlags( StoredOverride ) ) { + const TQMetaObject* mo = (*meta); + const TQMetaProperty* parent = mo->resolveProperty( this ); + return parent ? parent->stored() : FALSE; + } + return !testFlags( NotStored ); +} + + +/*! + Tries to reset the property for object \a o with a reset method. + On success, returns TRUE; otherwise returns FALSE. + + Reset methods are optional, usually only a few properties support + them. +*/ +bool TQMetaProperty::reset( TQObject* o ) const +{ + if ( !o ) + return FALSE; + int idx = _id >= 0 ? _id : (*meta)->indexOfProperty( this, TRUE ); + if ( idx < 0 ) + return 0; + return o->tqt_property( idx, 2, 0 ); +} + + +/*! \enum TQMetaProperty::Flags + + \internal +*/ + +#endif // TQT_NO_PROPERTIES + +/* + * TQMetaObjectCleanUp is used as static global object in the moc-generated cpp + * files and deletes the TQMetaObject provided with setMetaObject. It sets the + * TQObject reference to the metaObj to NULL when it is destroyed. + */ +TQMetaObjectCleanUp::TQMetaObjectCleanUp( const char *mo_name, TQtStaticMetaObjectFunction func ) + : metaObject( 0 ) +{ +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); +#endif // TQT_THREAD_SUPPORT + if ( !qt_metaobjects ) + qt_metaobjects = new TQAsciiDict( 257 ); + qt_metaobjects->insert( mo_name, (void*)func ); + + qt_metaobjects_count++; +} + +TQMetaObjectCleanUp::TQMetaObjectCleanUp() + : metaObject( 0 ) +{ +} + +/*! \fn bool TQMetaProperty::testFlags( uint f ) const + \internal +*/ + +TQMetaObjectCleanUp::~TQMetaObjectCleanUp() +{ +#ifdef TQT_THREAD_SUPPORT + TQMutexLocker( tqt_global_mutexpool ? + tqt_global_mutexpool->get( &qt_metaobjects ) : 0 ); +#endif // TQT_THREAD_SUPPORT + if ( !--qt_metaobjects_count ) { + delete qt_metaobjects; + qt_metaobjects = 0; + } + if ( metaObject ) { + delete *metaObject; + *metaObject = 0; + metaObject = 0; + } +} + +void TQMetaObjectCleanUp::setMetaObject( TQMetaObject *&mo ) +{ +#if defined(QT_CHECK_RANGE) + if (metaObject && metaObject != &mo) + tqWarning( "TQMetaObjectCleanUp::setMetaObject: Double use of TQMetaObjectCleanUp!" ); +#endif + metaObject = &mo; +} diff --git a/src/kernel/tqmetaobject.h b/src/kernel/tqmetaobject.h new file mode 100644 index 000000000..9db397f47 --- /dev/null +++ b/src/kernel/tqmetaobject.h @@ -0,0 +1,286 @@ +/**************************************************************************** +** +** Definition of TQMetaObject class +** +** Created : 930419 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMETAOBJECT_H +#define TQMETAOBJECT_H + +#ifndef QT_H +#include "tqconnection.h" +#include "tqstrlist.h" +#endif // QT_H + +#ifndef Q_MOC_OUTPUT_REVISION +#define Q_MOC_OUTPUT_REVISION 26 +#endif + +class TQObject; +struct TQUMethod; +class TQMetaObjectPrivate; + +struct TQMetaData // - member function meta data +{ // for signal and slots + const char *name; // - member name + const TQUMethod* method; // - detailed method description + enum Access { Private, Protected, Public }; + Access access; // - access permission +}; + +#ifndef TQT_NO_PROPERTIES +struct TQMetaEnum // enumerator meta data +{ // for properties + const char *name; // - enumerator name + uint count; // - number of values + struct Item // - a name/value pair + { + const char *key; + int value; + }; + const Item *items; // - the name/value pairs + bool set; // whether enum has to be treated as a set +}; +#endif + +#ifndef TQT_NO_PROPERTIES + +class TQ_EXPORT TQMetaProperty // property meta data +{ +public: + const char* type() const { return t; } // type of the property + const char* name() const { return n; } // name of the property + + bool writable() const; + bool isValid() const; + + bool isSetType() const; + bool isEnumType() const; + TQStrList enumKeys() const; // enumeration names + + int keyToValue( const char* key ) const; // enum and set conversion functions + const char* valueToKey( int value ) const; + int keysToValue( const TQStrList& keys ) const; + TQStrList valueToKeys( int value ) const; + + bool designable( TQObject* = 0 ) const; + bool scriptable( TQObject* = 0 ) const; + bool stored( TQObject* = 0 ) const; + + bool reset( TQObject* ) const; + + const char* t; // internal + const char* n; // internal + + enum Flags { + Invalid = 0x00000000, + Readable = 0x00000001, + Writable = 0x00000002, + EnumOrSet = 0x00000004, + UnresolvedEnum = 0x00000008, + StdSet = 0x00000100, + Override = 0x00000200 + }; + + uint flags; // internal + bool testFlags( uint f ) const; // internal + bool stdSet() const; // internal + int id() const; // internal + + TQMetaObject** meta; // internal + + const TQMetaEnum* enumData; // internal + int _id; // internal + void clear(); // internal +}; + +inline bool TQMetaProperty::testFlags( uint f ) const +{ return (flags & (uint)f) != (uint)0; } + +#endif // TQT_NO_PROPERTIES + +struct TQClassInfo // class info meta data +{ + const char* name; // - name of the info + const char* value; // - value of the info +}; + +class TQ_EXPORT TQMetaObject // meta object class +{ +public: + TQMetaObject( const char * const class_name, TQMetaObject *superclass, + const TQMetaData * const slot_data, int n_slots, + const TQMetaData * const signal_data, int n_signals, +#ifndef TQT_NO_PROPERTIES + const TQMetaProperty *const prop_data, int n_props, + const TQMetaEnum *const enum_data, int n_enums, +#endif + const TQClassInfo *const class_info, int n_info ); + +#ifndef TQT_NO_PROPERTIES + TQMetaObject( const char * const class_name, TQMetaObject *superclass, + const TQMetaData * const slot_data, int n_slots, + const TQMetaData * const signal_data, int n_signals, + const TQMetaProperty *const prop_data, int n_props, + const TQMetaEnum *const enum_data, int n_enums, + bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), + const TQClassInfo *const class_info, int n_info ); +#endif + + + virtual ~TQMetaObject(); + + const char *className() const { return classname; } + const char *superClassName() const { return superclassname; } + + TQMetaObject *superClass() const { return superclass; } + + bool inherits( const char* clname ) const; + + int numSlots( bool super = FALSE ) const; + int numSignals( bool super = FALSE ) const; + + int findSlot( const char *, bool super = FALSE ) const; + int findSignal( const char *, bool super = FALSE ) const; + + const TQMetaData *slot( int index, bool super = FALSE ) const; + const TQMetaData *signal( int index, bool super = FALSE ) const; + + TQStrList slotNames( bool super = FALSE ) const; + TQStrList signalNames( bool super = FALSE ) const; + + int slotOffset() const; + int signalOffset() const; + int propertyOffset() const; + + int numClassInfo( bool super = FALSE ) const; + const TQClassInfo *classInfo( int index, bool super = FALSE ) const; + const char *classInfo( const char* name, bool super = FALSE ) const; + +#ifndef TQT_NO_PROPERTIES + const TQMetaProperty *property( int index, bool super = FALSE ) const; + int findProperty( const char *name, bool super = FALSE ) const; + int indexOfProperty( const TQMetaProperty*, bool super = FALSE ) const; + const TQMetaProperty* resolveProperty( const TQMetaProperty* ) const; + int resolveProperty( int ) const; + TQStrList propertyNames( bool super = FALSE ) const; + int numProperties( bool super = FALSE ) const; +#endif + + // static wrappers around constructors, necessary to work around a + // Windows-DLL limitation: objects can only be deleted within a + // DLL if they were actually created within that DLL. + static TQMetaObject *new_metaobject( const char *, TQMetaObject *, + const TQMetaData *const, int, + const TQMetaData *const, int, +#ifndef TQT_NO_PROPERTIES + const TQMetaProperty *const prop_data, int n_props, + const TQMetaEnum *const enum_data, int n_enums, +#endif + const TQClassInfo *const class_info, int n_info ); +#ifndef TQT_NO_PROPERTIES + static TQMetaObject *new_metaobject( const char *, TQMetaObject *, + const TQMetaData *const, int, + const TQMetaData *const, int, + const TQMetaProperty *const prop_data, int n_props, + const TQMetaEnum *const enum_data, int n_enums, + bool (*tqt_static_property)(TQObject*, int, int, TQVariant*), + const TQClassInfo *const class_info, int n_info ); + TQStrList enumeratorNames( bool super = FALSE ) const; + int numEnumerators( bool super = FALSE ) const; + const TQMetaEnum *enumerator( const char* name, bool super = FALSE ) const; +#endif + + static TQMetaObject *metaObject( const char *class_name ); + static bool hasMetaObject( const char *class_name ); + +private: + TQMemberDict *init( const TQMetaData *, int ); + + const char *classname; // class name + const char *superclassname; // super class name + TQMetaObject *superclass; // super class meta object + TQMetaObjectPrivate *d; // private data for... + void *reserved; // ...binary compatibility + const TQMetaData *slotData; // slot meta data + TQMemberDict *slotDict; // slot dictionary + const TQMetaData *signalData; // signal meta data + TQMemberDict *signalDict; // signal dictionary + int signaloffset; + int slotoffset; +#ifndef TQT_NO_PROPERTIES + int propertyoffset; +public: + bool tqt_static_property( TQObject* o, int id, int f, TQVariant* v); +private: + friend class TQMetaProperty; +#endif + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQMetaObject( const TQMetaObject & ); + TQMetaObject &operator=( const TQMetaObject & ); +#endif +}; + +inline int TQMetaObject::slotOffset() const +{ return slotoffset; } + +inline int TQMetaObject::signalOffset() const +{ return signaloffset; } + +#ifndef TQT_NO_PROPERTIES +inline int TQMetaObject::propertyOffset() const +{ return propertyoffset; } +#endif + +typedef TQMetaObject *(*TQtStaticMetaObjectFunction)(); + +class TQ_EXPORT TQMetaObjectCleanUp +{ +public: + TQMetaObjectCleanUp( const char *mo_name, TQtStaticMetaObjectFunction ); + TQMetaObjectCleanUp(); + ~TQMetaObjectCleanUp(); + + void setMetaObject( TQMetaObject *&mo ); + +private: + TQMetaObject **metaObject; +}; + +#endif // TQMETAOBJECT_H diff --git a/src/kernel/tqmngio.cpp b/src/kernel/tqmngio.cpp new file mode 100644 index 000000000..0f257ae88 --- /dev/null +++ b/src/kernel/tqmngio.cpp @@ -0,0 +1,460 @@ +/**************************************************************************** +** +** Implementation of MNG TQImage IOHandler +** +** Created : 970521 +** +** Copyright (C) 1997-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqdatetime.h" + +#ifndef TQT_NO_IMAGEIO_MNG + +#include "tqimage.h" +#include "tqasyncimageio.h" +#include "tqiodevice.h" +#include "tqmngio.h" + +// Define XMD_H prohibits the included headers of libmng.h to typedef INT32. +// This is needed for Borland with STL support, since in that case, INT32 is +// already defined by some Borland header. +#define XMD_H +#if defined(Q_OS_UNIXWARE) +# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this +#endif +#include +#include + + +#ifndef TQT_NO_ASYNC_IMAGE_IO + +class TQMNGFormat : public TQImageFormat { +public: + TQMNGFormat(); + virtual ~TQMNGFormat(); + + int decode(TQImage& img, TQImageConsumer* consumer, + const uchar* buffer, int length); + + bool openstream() + { + // ### We should figure out how many loops an MNG has, but for now always assume infinite. + if (consumer) + consumer->setLooping(0); + return TRUE; + } + bool closestream( ) + { + if (consumer) + consumer->end(); + return TRUE; + } + bool readdata( mng_ptr pBuf, mng_uint32 iBuflen, mng_uint32p pRead ) + { + uint m = ndata + nbuffer - ubuffer; + if ( iBuflen > m ) { + iBuflen = m; + } + *pRead = iBuflen; + uint n = nbuffer-ubuffer; + if ( iBuflen < n ) { + // enough in buffer + memcpy(pBuf, buffer+ubuffer, iBuflen); + ubuffer += iBuflen; + return TRUE; + } + if ( n ) { + // consume buffer + memcpy(pBuf, buffer+ubuffer, n ); + pBuf = (mng_ptr)((char*)pBuf + n); + iBuflen -= n; + ubuffer = nbuffer; + } + if ( iBuflen ) { + // fill from incoming data + memcpy(pBuf, data, iBuflen); + data += iBuflen; + ndata -= iBuflen; + } + return TRUE; + } + bool errorproc( mng_int32 iErrorcode, + mng_int8 /*iSeverity*/, + mng_chunkid iChunkname, + mng_uint32 /*iChunkseq*/, + mng_int32 iExtra1, + mng_int32 iExtra2, + mng_pchar zErrortext ) + { + tqWarning("MNG error %d: %s; chunk %c%c%c%c; subcode %d:%d", + iErrorcode, zErrortext ? zErrortext : "", + (iChunkname>>24)&0xff, + (iChunkname>>16)&0xff, + (iChunkname>>8)&0xff, + (iChunkname>>0)&0xff, + iExtra1,iExtra2); + return TRUE; + } + bool processheader( mng_uint32 iWidth, mng_uint32 iHeight ) + { + image->create(iWidth,iHeight,32); + image->setAlphaBuffer(TRUE); + memset(image->bits(),0,iWidth*iHeight*4); + consumer->setSize(iWidth,iHeight); + mng_set_canvasstyle(handle, + TQImage::systemByteOrder() == TQImage::LittleEndian + ? MNG_CANVAS_BGRA8 : MNG_CANVAS_ARGB8 ); + return TRUE; + } + mng_ptr getcanvasline( mng_uint32 iLinenr ) + { + return image->scanLine(iLinenr); + } + mng_bool refresh( mng_uint32 x, mng_uint32 y, mng_uint32 w, mng_uint32 h ) + { + TQRect r(x,y,w,h); + consumer->changed(r); + consumer->setFramePeriod(0); + consumer->frameDone(); + return TRUE; + } + mng_uint32 gettickcount( ) + { + return timer.elapsed() - losttime; + } + bool settimer( mng_uint32 iMsecs ) + { + consumer->setFramePeriod(iMsecs); + consumer->frameDone(); + state = Time; + losingtimer.start(); + losttime -= iMsecs; + return TRUE; + } + +private: + // Animation-level information + enum { MovieStart, Time, Data, Data2 } state; + + // Image-level information + mng_handle handle; + + // For storing unused data + uchar *buffer; + uint maxbuffer; + uint nbuffer; + + // Timing + TQTime timer; + TQTime losingtimer; + int losttime; + + void enlargeBuffer(uint n) + { + if ( n > maxbuffer ) { + maxbuffer = n; + buffer = (uchar*)realloc(buffer,n); + } + } + + // Temporary locals during single data-chunk processing + const uchar* data; + uint ndata; + uint ubuffer; + TQImageConsumer* consumer; + TQImage* image; +}; + +class TQMNGFormatType : public TQImageFormatType +{ + TQImageFormat* decoderFor(const uchar* buffer, int length); + const char* formatName() const; +}; + + +/* + \class TQMNGFormat tqmngio.h + \brief Incremental image decoder for MNG image format. + + \ingroup images + \ingroup graphics + + This subclass of TQImageFormat decodes MNG format images, + including animated MNGs. + + Animated MNG images are standard MNG images. The MNG standard + defines two extension chunks that are useful for animations: + +
+
gIFg - GIF-like Graphic Control Extension +
Includes frame disposal, user input flag (we ignore this), + and inter-frame delay. +
gIFx - GIF-like Application Extension +
Multi-purpose, but we just use the Netscape extension + which specifies looping. +
+ + The subimages usually contain a offset chunk (oFFs) but need not. + + The first image defines the "screen" size. Any subsequent image that + doesn't fit is clipped. + +TODO: decide on this point. gIFg gives disposal types, so it can be done. + All images paste (\e not composite, just place all-channel copying) + over the previous image to produce a subsequent frame. +*/ + +/* + \class TQMNGFormatType tqasyncimageio.h + \brief Incremental image decoder for MNG image format. + + \ingroup images + \ingroup graphics + \ingroup io + + This subclass of TQImageFormatType recognizes MNG + format images, creating a TQMNGFormat when required. An instance + of this class is created automatically before any other factories, + so you should have no need for such objects. +*/ + +TQImageFormat* TQMNGFormatType::decoderFor( const uchar* buffer, int length ) +{ + if (length < 8) return 0; + + if ((buffer[0]==138 // MNG signature + && buffer[1]=='M' + && buffer[2]=='N' + && buffer[3]=='G' + && buffer[4]==13 + && buffer[5]==10 + && buffer[6]==26 + && buffer[7]==10) + || (buffer[0]==139 // JNG signature + && buffer[1]=='J' + && buffer[2]=='N' + && buffer[3]=='G' + && buffer[4]==13 + && buffer[5]==10 + && buffer[6]==26 + && buffer[7]==10) +#ifdef TQT_NO_IMAGEIO_PNG // if we don't have native PNG support use libmng + || (buffer[0]==137 // PNG signature + && buffer[1]=='P' + && buffer[2]=='N' + && buffer[3]=='G' + && buffer[4]==13 + && buffer[5]==10 + && buffer[6]==26 + && buffer[7]==10) +#endif + ) + return new TQMNGFormat; + return 0; +} + +const char* TQMNGFormatType::formatName() const +{ + return "MNG"; +} + + +/*! + Constructs a TQMNGFormat. +*/ +TQMNGFormat::TQMNGFormat() +{ + state = MovieStart; + handle = 0; + nbuffer = 0; + maxbuffer = 0; + buffer = 0; + losttime = 0; +} + +/* + Destroys a TQMNGFormat. +*/ +TQMNGFormat::~TQMNGFormat() +{ + // We're setting the consumer to 0 since it may have been + // deleted by read_async_image in tqimage.cpp + consumer = 0; + if (handle) mng_cleanup(&handle); +} + + +// C-callback to C++-member-function conversion +// +static mng_bool openstream( mng_handle handle ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->openstream(); +} +static mng_bool closestream( mng_handle handle ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->closestream(); +} +static mng_bool readdata( mng_handle handle, mng_ptr pBuf, mng_uint32 iBuflen, mng_uint32p pRead ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->readdata(pBuf,iBuflen,pRead); +} +static mng_bool errorproc( mng_handle handle, + mng_int32 iErrorcode, + mng_int8 iSeverity, + mng_chunkid iChunkname, + mng_uint32 iChunkseq, + mng_int32 iExtra1, + mng_int32 iExtra2, + mng_pchar zErrortext ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->errorproc(iErrorcode, + iSeverity,iChunkname,iChunkseq,iExtra1,iExtra2,zErrortext); +} +static mng_bool processheader( mng_handle handle, + mng_uint32 iWidth, mng_uint32 iHeight ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->processheader(iWidth,iHeight); +} +static mng_ptr getcanvasline( mng_handle handle, mng_uint32 iLinenr ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->getcanvasline(iLinenr); +} +static mng_bool refresh( mng_handle handle, + mng_uint32 iTop, + mng_uint32 iLeft, + mng_uint32 iBottom, + mng_uint32 iRight ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->refresh(iTop,iLeft,iBottom,iRight); +} +static mng_uint32 gettickcount( mng_handle handle ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->gettickcount(); +} +static mng_bool settimer( mng_handle handle, mng_uint32 iMsecs ) +{ + return ((TQMNGFormat*)mng_get_userdata(handle))->settimer(iMsecs); +} + +static mng_ptr memalloc( mng_size_t iLen ) +{ + return calloc(1,iLen); +} +static void memfree( mng_ptr iPtr, mng_size_t /*iLen*/ ) +{ + free(iPtr); +} + +/*! + This function decodes some data into image changes. + + Returns the number of bytes consumed. +*/ +int TQMNGFormat::decode( TQImage& img, TQImageConsumer* cons, + const uchar* buf, int length ) +{ + consumer = cons; + image = &img; + + data = buf; + ndata = length; + ubuffer = 0; + + if ( state == MovieStart ) { + handle = mng_initialize( (mng_ptr)this, ::memalloc, ::memfree, 0 ); + mng_set_suspensionmode( handle, MNG_TRUE ); + mng_setcb_openstream( handle, ::openstream ); + mng_setcb_closestream( handle, ::closestream ); + mng_setcb_readdata( handle, ::readdata ); + mng_setcb_errorproc( handle, ::errorproc ); + mng_setcb_processheader( handle, ::processheader ); + mng_setcb_getcanvasline( handle, ::getcanvasline ); + mng_setcb_refresh( handle, ::refresh ); + mng_setcb_gettickcount( handle, ::gettickcount ); + mng_setcb_settimer( handle, ::settimer ); + state = Data; + mng_readdisplay(handle); + losingtimer.start(); + } + + losttime += losingtimer.elapsed(); + if ( ndata || !length ) + mng_display_resume(handle); + losingtimer.start(); + + image = 0; + + nbuffer -= ubuffer; + if ( nbuffer ) { + // Move back unused tail + memcpy(buffer,buffer+ubuffer,nbuffer); + } + if ( ndata ) { + // Not all used. + enlargeBuffer(nbuffer+ndata); + memcpy(buffer+nbuffer,data,ndata); + nbuffer += ndata; + } + + return length; +} + +static TQMNGFormatType* globalMngFormatTypeObject = 0; + +#endif // TQT_NO_ASYNC_IMAGE_IO + +#ifndef TQT_NO_ASYNC_IMAGE_IO +void qCleanupMngIO() +{ + if ( globalMngFormatTypeObject ) { + delete globalMngFormatTypeObject; + globalMngFormatTypeObject = 0; + } +} +#endif + +void qInitMngIO() +{ + static bool done = FALSE; + if ( !done ) { + done = TRUE; +#ifndef TQT_NO_ASYNC_IMAGE_IO + globalMngFormatTypeObject = new TQMNGFormatType; + tqAddPostRoutine( qCleanupMngIO ); +#endif + } +} + +#endif // TQT_NO_IMAGEIO_MNG diff --git a/src/kernel/tqmngio.h b/src/kernel/tqmngio.h new file mode 100644 index 000000000..530a0aa1d --- /dev/null +++ b/src/kernel/tqmngio.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Definition of MNG TQImage IOHandler +** +** Created : 970521 +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMNGIO_H +#define TQMNGIO_H + +#ifndef QT_H +#endif // QT_H + +#ifndef TQT_NO_IMAGEIO_MNG + +void qInitMngIO(); + +#endif // TQT_NO_IMAGEIO_MNG + +#endif // TQMNGIO_H diff --git a/src/kernel/tqnamespace.h b/src/kernel/tqnamespace.h new file mode 100644 index 000000000..f5ec7dd1d --- /dev/null +++ b/src/kernel/tqnamespace.h @@ -0,0 +1,1035 @@ +/**************************************************************************** +** +** Definition of TQt namespace (as class for compiler compatibility) +** +** Created : 980927 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQNAMESPACE_H +#define TQNAMESPACE_H + +#ifndef QT_H +#include "tqglobal.h" +#endif // QT_H + + +class TQColor; +class TQCursor; + + +class TQ_EXPORT TQt { +public: + static const TQColor & color0; + static const TQColor & color1; + static const TQColor & black; + static const TQColor & white; + static const TQColor & darkGray; + static const TQColor & gray; + static const TQColor & lightGray; + static const TQColor & red; + static const TQColor & green; + static const TQColor & blue; + static const TQColor & cyan; + static const TQColor & magenta; + static const TQColor & yellow; + static const TQColor & darkRed; + static const TQColor & darkGreen; + static const TQColor & darkBlue; + static const TQColor & darkCyan; + static const TQColor & darkMagenta; + static const TQColor & darkYellow; + + // documented in tqevent.cpp + enum ButtonState { // mouse/keyboard state values + NoButton = 0x0000, + LeftButton = 0x0001, + RightButton = 0x0002, + MidButton = 0x0004, + HistoryBackButton = 0x0008, + HistoryForwardButton = 0x0010, + MouseButtonMask = 0x001f, + ShiftButton = 0x0100, + ControlButton = 0x0200, + AltButton = 0x0400, + MetaButton = 0x0800, + KeyButtonMask = 0x0f00, + Keypad = 0x4000 + }; + + // documented in tqobject.cpp + // ideally would start at 1, as in TQSizePolicy, but that breaks other things + enum Orientation { + Horizontal = 0, + Vertical + }; + + // documented in tqlistview.cpp + enum SortOrder { + Ascending, + Descending + }; + + // Text formatting flags for TQPainter::drawText and TQLabel + // the following four enums can be combined to one integer which + // is passed as textflag to drawText and qt_format_text. + + // documented in tqpainter.cpp + enum AlignmentFlags { + AlignAuto = 0x0000, // text alignment + AlignLeft = 0x0001, + AlignRight = 0x0002, + AlignHCenter = 0x0004, + AlignJustify = 0x0008, + AlignHorizontal_Mask = AlignLeft | AlignRight | AlignHCenter | AlignJustify, + AlignTop = 0x0010, + AlignBottom = 0x0020, + AlignVCenter = 0x0040, + AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter, + AlignCenter = AlignVCenter | AlignHCenter + }; + + // documented in tqpainter.cpp + enum TextFlags { + SingleLine = 0x0080, // misc. flags + DontClip = 0x0100, + ExpandTabs = 0x0200, + ShowPrefix = 0x0400, + WordBreak = 0x0800, + BreakAnywhere = 0x1000, +#ifndef Q_QDOC + DontPrint = 0x2000, + Underline = 0x01000000, + Overline = 0x02000000, + StrikeOut = 0x04000000, + IncludeTrailingSpaces = 0x08000000, +#endif + NoAccel = 0x4000 + }; + + // Widget flags; documented in tqwidget.cpp + typedef uint WState; + + // TQWidget state flags (internal, barely documented in tqwidget.cpp) + enum WidgetState { + WState_Created = 0x00000001, + WState_Disabled = 0x00000002, + WState_Visible = 0x00000004, + WState_ForceHide = 0x00000008, + WState_OwnCursor = 0x00000010, + WState_MouseTracking = 0x00000020, + WState_CompressKeys = 0x00000040, + WState_BlockUpdates = 0x00000080, + WState_InPaintEvent = 0x00000100, + WState_Reparented = 0x00000200, + WState_ConfigPending = 0x00000400, + WState_Resized = 0x00000800, + WState_AutoMask = 0x00001000, + WState_Polished = 0x00002000, + WState_DND = 0x00004000, + WState_Reserved0 = 0x00008000, + WState_FullScreen = 0x00010000, + WState_OwnSizePolicy = 0x00020000, + WState_CreatedHidden = 0x00040000, + WState_Maximized = 0x00080000, + WState_Minimized = 0x00100000, + WState_ForceDisabled = 0x00200000, + WState_Exposed = 0x00400000, + WState_HasMouse = 0x00800000 + }; + + // NetWM flags; documented in tqwidget.cpp + typedef uint NFlags; + + // documented in tqwidget.cpp + enum NETWMFlags { +#if defined(TQ_WS_X11) + WX11DisableMove = 0x00000001, + WX11DisableClose = 0x00000002, + WX11DisableResize = 0x00000004, + WX11DisableMinimize = 0x00000008, + WX11DisableMaximize = 0x00000010, + WX11DisableShade = 0x00000020 +#else + WX11DisableMove = 0x00000000, + WX11DisableClose = 0x00000000, + WX11DisableResize = 0x00000000, + WX11DisableMinimize = 0x00000000, + WX11DisableMaximize = 0x00000000, + WX11DisableShade = 0x00000000 +#endif + }; + + // Widget flags2; documented in tqwidget.cpp + typedef uint WFlags; + + // documented in tqwidget.cpp + enum WidgetFlags { + WType_TopLevel = 0x00000001, // widget type flags + WType_Dialog = 0x00000002, + WType_Popup = 0x00000004, + WType_Desktop = 0x00000008, + WType_Mask = 0x0000000f, + + WStyle_Customize = 0x00000010, // window style flags + WStyle_NormalBorder = 0x00000020, + WStyle_DialogBorder = 0x00000040, // MS-Windows only + WStyle_NoBorder = 0x00002000, + WStyle_Title = 0x00000080, + WStyle_SysMenu = 0x00000100, + WStyle_Minimize = 0x00000200, + WStyle_Maximize = 0x00000400, + WStyle_MinMax = WStyle_Minimize | WStyle_Maximize, + WStyle_Tool = 0x00000800, + WStyle_StaysOnTop = 0x00001000, + WStyle_ContextHelp = 0x00004000, + WStyle_Reserved = 0x00008000, + WStyle_Mask = 0x0000fff0, + + WDestructiveClose = 0x00010000, // misc flags + WPaintDesktop = 0x00020000, + WPaintUnclipped = 0x00040000, + WPaintClever = 0x00080000, + WResizeNoErase = 0x00100000, // OBSOLETE + WMouseNoMask = 0x00200000, + WStaticContents = 0x00400000, + WRepaintNoErase = 0x00800000, // OBSOLETE +#if defined(TQ_WS_X11) + WX11BypassWM = 0x01000000, + WWinOwnDC = 0x00000000, + WMacNoSheet = 0x00000000, + WMacDrawer = 0x00000000, +#elif defined(TQ_WS_MAC) + WX11BypassWM = 0x00000000, + WWinOwnDC = 0x00000000, + WMacNoSheet = 0x01000000, + WMacDrawer = 0x20000000, +#else + WX11BypassWM = 0x00000000, + WWinOwnDC = 0x01000000, + WMacNoSheet = 0x00000000, + WMacDrawer = 0x00000000, +#endif + WGroupLeader = 0x02000000, + WShowModal = 0x04000000, + WNoMousePropagation = 0x08000000, + WSubWindow = 0x10000000, +#if defined(TQ_WS_X11) + WStyle_Splash = 0x20000000, +#else + WStyle_Splash = WStyle_NoBorder | WMacNoSheet | WStyle_Tool | WWinOwnDC, +#endif + WNoAutoErase = WRepaintNoErase | WResizeNoErase +#ifndef TQT_NO_COMPAT + , + WNorthWestGravity = WStaticContents, + WType_Modal = WType_Dialog | WShowModal, + WStyle_Dialog = WType_Dialog, + WStyle_NoBorderEx = WStyle_NoBorder +#endif + }; + + enum WindowState { + WindowNoState = 0x00000000, + WindowMinimized = 0x00000001, + WindowMaximized = 0x00000002, + WindowFullScreen = 0x00000004, + WindowActive = 0x00000008 + }; + + + // Image conversion flags. The unusual ordering is caused by + // compatibility and default requirements. + // Documented in tqimage.cpp + + enum ImageConversionFlags { + ColorMode_Mask = 0x00000003, + AutoColor = 0x00000000, + ColorOnly = 0x00000003, + MonoOnly = 0x00000002, + // Reserved = 0x00000001, + + AlphaDither_Mask = 0x0000000c, + ThresholdAlphaDither = 0x00000000, + OrderedAlphaDither = 0x00000004, + DiffuseAlphaDither = 0x00000008, + NoAlpha = 0x0000000c, // Not supported + + Dither_Mask = 0x00000030, + DiffuseDither = 0x00000000, + OrderedDither = 0x00000010, + ThresholdDither = 0x00000020, + // ReservedDither= 0x00000030, + + DitherMode_Mask = 0x000000c0, + AutoDither = 0x00000000, + PreferDither = 0x00000040, + AvoidDither = 0x00000080 + }; + + // documented in tqpainter.cpp + enum BGMode { // background mode + TransparentMode, + OpaqueMode + }; + +#ifndef TQT_NO_COMPAT + // documented in tqpainter.cpp + enum PaintUnit { // paint unit + PixelUnit, + LoMetricUnit, // OBSOLETE + HiMetricUnit, // OBSOLETE + LoEnglishUnit, // OBSOLETE + HiEnglishUnit, // OBSOLETE + TwipsUnit // OBSOLETE + }; +#endif + + // documented in tqstyle.cpp +#ifdef TQT_NO_COMPAT + enum GUIStyle { + WindowsStyle = 1, // ### TQt 4.0: either remove the obsolete enums or clean up compat vs. + MotifStyle = 4, // ### TQT_NO_COMPAT by reordering or combination into one enum. + GtkStyle = 6 // Gtk compability mode + }; +#else + enum GUIStyle { + MacStyle, // OBSOLETE + WindowsStyle, + Win3Style, // OBSOLETE + PMStyle, // OBSOLETE + MotifStyle, + GtkStyle = 6 // Gtk compability mode + }; +#endif + + // documented in tqkeysequence.cpp + enum SequenceMatch { + NoMatch, + PartialMatch, + Identical + }; + + // documented in tqevent.cpp + enum Modifier { // accelerator modifiers + META = 0x00100000, + SHIFT = 0x00200000, + CTRL = 0x00400000, + ALT = 0x00800000, + MODIFIER_MASK = 0x00f00000, + UNICODE_ACCEL = 0x10000000, + + ASCII_ACCEL = UNICODE_ACCEL // 1.x compat + }; + + // documented in tqevent.cpp + enum Key { + Key_Escape = 0x1000, // misc keys + Key_Tab = 0x1001, + Key_Backtab = 0x1002, Key_BackTab = Key_Backtab, + Key_Backspace = 0x1003, Key_BackSpace = Key_Backspace, + Key_Return = 0x1004, + Key_Enter = 0x1005, + Key_Insert = 0x1006, + Key_Delete = 0x1007, + Key_Pause = 0x1008, + Key_Print = 0x1009, + Key_SysReq = 0x100a, + Key_Clear = 0x100b, + Key_Home = 0x1010, // cursor movement + Key_End = 0x1011, + Key_Left = 0x1012, + Key_Up = 0x1013, + Key_Right = 0x1014, + Key_Down = 0x1015, + Key_Prior = 0x1016, Key_PageUp = Key_Prior, + Key_Next = 0x1017, Key_PageDown = Key_Next, + Key_Shift = 0x1020, // modifiers + Key_Control = 0x1021, + Key_Meta = 0x1022, + Key_Alt = 0x1023, + Key_CapsLock = 0x1024, + Key_NumLock = 0x1025, + Key_ScrollLock = 0x1026, + Key_F1 = 0x1030, // function keys + Key_F2 = 0x1031, + Key_F3 = 0x1032, + Key_F4 = 0x1033, + Key_F5 = 0x1034, + Key_F6 = 0x1035, + Key_F7 = 0x1036, + Key_F8 = 0x1037, + Key_F9 = 0x1038, + Key_F10 = 0x1039, + Key_F11 = 0x103a, + Key_F12 = 0x103b, + Key_F13 = 0x103c, + Key_F14 = 0x103d, + Key_F15 = 0x103e, + Key_F16 = 0x103f, + Key_F17 = 0x1040, + Key_F18 = 0x1041, + Key_F19 = 0x1042, + Key_F20 = 0x1043, + Key_F21 = 0x1044, + Key_F22 = 0x1045, + Key_F23 = 0x1046, + Key_F24 = 0x1047, + Key_F25 = 0x1048, // F25 .. F35 only on X11 + Key_F26 = 0x1049, + Key_F27 = 0x104a, + Key_F28 = 0x104b, + Key_F29 = 0x104c, + Key_F30 = 0x104d, + Key_F31 = 0x104e, + Key_F32 = 0x104f, + Key_F33 = 0x1050, + Key_F34 = 0x1051, + Key_F35 = 0x1052, + Key_Super_L = 0x1053, // extra keys + Key_Super_R = 0x1054, + Key_Menu = 0x1055, + Key_Hyper_L = 0x1056, + Key_Hyper_R = 0x1057, + Key_Help = 0x1058, + Key_Direction_L = 0x1059, + Key_Direction_R = 0x1060, + + // International input method support (X keycode - 0xEE00). + // Only interesting if you are writing your own input method + + // International & multi-key character composition + Key_Multi_key = 0x1120, // Multi-key character compose + Key_Codeinput = 0x1137, + Key_SingleCandidate = 0x113c, + Key_MultipleCandidate = 0x113d, + Key_PreviousCandidate = 0x113e, + + // Misc Functions + Key_Mode_switch = 0x117e, // Character set switch + //Key_script_switch = 0x117e, // Alias for mode_switch + + // Japanese keyboard support + Key_Kanji = 0x1121, // Kanji, Kanji convert + Key_Muhenkan = 0x1122, // Cancel Conversion + //Key_Henkan_Mode = 0x1123, // Start/Stop Conversion + Key_Henkan = 0x1123, // Alias for Henkan_Mode + Key_Romaji = 0x1124, // to Romaji + Key_Hiragana = 0x1125, // to Hiragana + Key_Katakana = 0x1126, // to Katakana + Key_Hiragana_Katakana = 0x1127, // Hiragana/Katakana toggle + Key_Zenkaku = 0x1128, // to Zenkaku + Key_Hankaku = 0x1129, // to Hankaku + Key_Zenkaku_Hankaku = 0x112a, // Zenkaku/Hankaku toggle + Key_Touroku = 0x112b, // Add to Dictionary + Key_Massyo = 0x112c, // Delete from Dictionary + Key_Kana_Lock = 0x112d, // Kana Lock + Key_Kana_Shift = 0x112e, // Kana Shift + Key_Eisu_Shift = 0x112f, // Alphanumeric Shift + Key_Eisu_toggle = 0x1130, // Alphanumeric toggle + //Key_Kanji_Bangou = 0x1137, // Codeinput + //Key_Zen_Koho = 0x113d, // Multiple/All Candidate(s) + //Key_Mae_Koho = 0x113e, // Previous Candidate + + // Korean keyboard support + // + // In fact, many Korean users need only 2 keys, Key_Hangul and + // Key_Hangul_Hanja. But rest of the keys are good for future. + + Key_Hangul = 0x1131, // Hangul start/stop(toggle) + Key_Hangul_Start = 0x1132, // Hangul start + Key_Hangul_End = 0x1133, // Hangul end, English start + Key_Hangul_Hanja = 0x1134, // Start Hangul->Hanja Conversion + Key_Hangul_Jamo = 0x1135, // Hangul Jamo mode + Key_Hangul_Romaja = 0x1136, // Hangul Romaja mode + //Key_Hangul_Codeinput = 0x1137, // Hangul code input mode + Key_Hangul_Jeonja = 0x1138, // Jeonja mode + Key_Hangul_Banja = 0x1139, // Banja mode + Key_Hangul_PreHanja = 0x113a, // Pre Hanja conversion + Key_Hangul_PostHanja = 0x113b, // Post Hanja conversion + //Key_Hangul_SingleCandidate = 0x113c, // Single candidate + //Key_Hangul_MultipleCandidate = 0x113d, // Multiple candidate + //Key_Hangul_PreviousCandidate = 0x113e, // Previous candidate + Key_Hangul_Special = 0x113f, // Special symbols + //Key_Hangul_switch = 0x117e, // Alias for mode_switch + + // dead keys (X keycode - 0xED00 to avoid the conflict) + Key_Dead_Grave = 0x1250, + Key_Dead_Acute = 0x1251, + Key_Dead_Circumflex = 0x1252, + Key_Dead_Tilde = 0x1253, + Key_Dead_Macron = 0x1254, + Key_Dead_Breve = 0x1255, + Key_Dead_Abovedot = 0x1256, + Key_Dead_Diaeresis = 0x1257, + Key_Dead_Abovering = 0x1258, + Key_Dead_Doubleacute = 0x1259, + Key_Dead_Caron = 0x125a, + Key_Dead_Cedilla = 0x125b, + Key_Dead_Ogonek = 0x125c, + Key_Dead_Iota = 0x125d, + Key_Dead_Voiced_Sound = 0x125e, + Key_Dead_Semivoiced_Sound = 0x125f, + Key_Dead_Belowdot = 0x1260, + Key_Dead_Hook = 0x1261, + Key_Dead_Horn = 0x1262, + + Key_Space = 0x20, // 7 bit printable ASCII + Key_Any = Key_Space, + Key_Exclam = 0x21, + Key_QuoteDbl = 0x22, + Key_NumberSign = 0x23, + Key_Dollar = 0x24, + Key_Percent = 0x25, + Key_Ampersand = 0x26, + Key_Apostrophe = 0x27, + Key_ParenLeft = 0x28, + Key_ParenRight = 0x29, + Key_Asterisk = 0x2a, + Key_Plus = 0x2b, + Key_Comma = 0x2c, + Key_Minus = 0x2d, + Key_Period = 0x2e, + Key_Slash = 0x2f, + Key_0 = 0x30, + Key_1 = 0x31, + Key_2 = 0x32, + Key_3 = 0x33, + Key_4 = 0x34, + Key_5 = 0x35, + Key_6 = 0x36, + Key_7 = 0x37, + Key_8 = 0x38, + Key_9 = 0x39, + Key_Colon = 0x3a, + Key_Semicolon = 0x3b, + Key_Less = 0x3c, + Key_Equal = 0x3d, + Key_Greater = 0x3e, + Key_Question = 0x3f, + Key_At = 0x40, + Key_A = 0x41, + Key_B = 0x42, + Key_C = 0x43, + Key_D = 0x44, + Key_E = 0x45, + Key_F = 0x46, + Key_G = 0x47, + Key_H = 0x48, + Key_I = 0x49, + Key_J = 0x4a, + Key_K = 0x4b, + Key_L = 0x4c, + Key_M = 0x4d, + Key_N = 0x4e, + Key_O = 0x4f, + Key_P = 0x50, + Key_Q = 0x51, + Key_R = 0x52, + Key_S = 0x53, + Key_T = 0x54, + Key_U = 0x55, + Key_V = 0x56, + Key_W = 0x57, + Key_X = 0x58, + Key_Y = 0x59, + Key_Z = 0x5a, + Key_BracketLeft = 0x5b, + Key_Backslash = 0x5c, + Key_BracketRight = 0x5d, + Key_AsciiCircum = 0x5e, + Key_Underscore = 0x5f, + Key_QuoteLeft = 0x60, + Key_BraceLeft = 0x7b, + Key_Bar = 0x7c, + Key_BraceRight = 0x7d, + Key_AsciiTilde = 0x7e, + + // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06 + // + // This is mainly for compatibility - applications and input + // methods should not use the TQt keycodes between 128 and 255, + // but should rather use the TQKeyEvent::text(). See + // TQETWidget::translateKeyEventInternal() for more details. + + Key_nobreakspace = 0x0a0, + Key_exclamdown = 0x0a1, + Key_cent = 0x0a2, + Key_sterling = 0x0a3, + Key_currency = 0x0a4, + Key_yen = 0x0a5, + Key_brokenbar = 0x0a6, + Key_section = 0x0a7, + Key_diaeresis = 0x0a8, + Key_copyright = 0x0a9, + Key_ordfeminine = 0x0aa, + Key_guillemotleft = 0x0ab, // left angle quotation mark + Key_notsign = 0x0ac, + Key_hyphen = 0x0ad, + Key_registered = 0x0ae, + Key_macron = 0x0af, + Key_degree = 0x0b0, + Key_plusminus = 0x0b1, + Key_twosuperior = 0x0b2, + Key_threesuperior = 0x0b3, + Key_acute = 0x0b4, + Key_mu = 0x0b5, + Key_paragraph = 0x0b6, + Key_periodcentered = 0x0b7, + Key_cedilla = 0x0b8, + Key_onesuperior = 0x0b9, + Key_masculine = 0x0ba, + Key_guillemotright = 0x0bb, // right angle quotation mark + Key_onequarter = 0x0bc, + Key_onehalf = 0x0bd, + Key_threequarters = 0x0be, + Key_questiondown = 0x0bf, + Key_Agrave = 0x0c0, + Key_Aacute = 0x0c1, + Key_Acircumflex = 0x0c2, + Key_Atilde = 0x0c3, + Key_Adiaeresis = 0x0c4, + Key_Aring = 0x0c5, + Key_AE = 0x0c6, + Key_Ccedilla = 0x0c7, + Key_Egrave = 0x0c8, + Key_Eacute = 0x0c9, + Key_Ecircumflex = 0x0ca, + Key_Ediaeresis = 0x0cb, + Key_Igrave = 0x0cc, + Key_Iacute = 0x0cd, + Key_Icircumflex = 0x0ce, + Key_Idiaeresis = 0x0cf, + Key_ETH = 0x0d0, + Key_Ntilde = 0x0d1, + Key_Ograve = 0x0d2, + Key_Oacute = 0x0d3, + Key_Ocircumflex = 0x0d4, + Key_Otilde = 0x0d5, + Key_Odiaeresis = 0x0d6, + Key_multiply = 0x0d7, + Key_Ooblique = 0x0d8, + Key_Ugrave = 0x0d9, + Key_Uacute = 0x0da, + Key_Ucircumflex = 0x0db, + Key_Udiaeresis = 0x0dc, + Key_Yacute = 0x0dd, + Key_THORN = 0x0de, + Key_ssharp = 0x0df, + Key_agrave = 0x0e0, + Key_aacute = 0x0e1, + Key_acircumflex = 0x0e2, + Key_atilde = 0x0e3, + Key_adiaeresis = 0x0e4, + Key_aring = 0x0e5, + Key_ae = 0x0e6, + Key_ccedilla = 0x0e7, + Key_egrave = 0x0e8, + Key_eacute = 0x0e9, + Key_ecircumflex = 0x0ea, + Key_ediaeresis = 0x0eb, + Key_igrave = 0x0ec, + Key_iacute = 0x0ed, + Key_icircumflex = 0x0ee, + Key_idiaeresis = 0x0ef, + Key_eth = 0x0f0, + Key_ntilde = 0x0f1, + Key_ograve = 0x0f2, + Key_oacute = 0x0f3, + Key_ocircumflex = 0x0f4, + Key_otilde = 0x0f5, + Key_odiaeresis = 0x0f6, + Key_division = 0x0f7, + Key_oslash = 0x0f8, + Key_ugrave = 0x0f9, + Key_uacute = 0x0fa, + Key_ucircumflex = 0x0fb, + Key_udiaeresis = 0x0fc, + Key_yacute = 0x0fd, + Key_thorn = 0x0fe, + Key_ydiaeresis = 0x0ff, + + // multimedia/internet keys - ignored by default - see TQKeyEvent c'tor + + Key_Back = 0x1061, + Key_Forward = 0x1062, + Key_Stop = 0x1063, + Key_Refresh = 0x1064, + + Key_VolumeDown = 0x1070, + Key_VolumeMute = 0x1071, + Key_VolumeUp = 0x1072, + Key_BassBoost = 0x1073, + Key_BassUp = 0x1074, + Key_BassDown = 0x1075, + Key_TrebleUp = 0x1076, + Key_TrebleDown = 0x1077, + + Key_MediaPlay = 0x1080, + Key_MediaStop = 0x1081, + Key_MediaPrev = 0x1082, + Key_MediaNext = 0x1083, + Key_MediaRecord = 0x1084, + + Key_HomePage = 0x1090, + Key_Favorites = 0x1091, + Key_Search = 0x1092, + Key_Standby = 0x1093, + Key_OpenUrl = 0x1094, + + Key_LaunchMail = 0x10a0, + Key_LaunchMedia = 0x10a1, + Key_Launch0 = 0x10a2, + Key_Launch1 = 0x10a3, + Key_Launch2 = 0x10a4, + Key_Launch3 = 0x10a5, + Key_Launch4 = 0x10a6, + Key_Launch5 = 0x10a7, + Key_Launch6 = 0x10a8, + Key_Launch7 = 0x10a9, + Key_Launch8 = 0x10aa, + Key_Launch9 = 0x10ab, + Key_LaunchA = 0x10ac, + Key_LaunchB = 0x10ad, + Key_LaunchC = 0x10ae, + Key_LaunchD = 0x10af, + Key_LaunchE = 0x10b0, + Key_LaunchF = 0x10b1, + Key_MonBrightnessUp = 0x010b2, + Key_MonBrightnessDown = 0x010b3, + Key_KeyboardLightOnOff = 0x010b4, + Key_KeyboardBrightnessUp = 0x010b5, + Key_KeyboardBrightnessDown = 0x010b6, + + Key_MediaLast = 0x1fff, + + Key_unknown = 0xffff + }; + + // documented in tqcommonstyle.cpp + enum ArrowType { + UpArrow, + DownArrow, + LeftArrow, + RightArrow + }; + + // documented in tqpainter.cpp + enum RasterOp { // raster op mode + CopyROP, + OrROP, + XorROP, + NotAndROP, EraseROP=NotAndROP, + NotCopyROP, + NotOrROP, + NotXorROP, + AndROP, NotEraseROP=AndROP, + NotROP, + ClearROP, + SetROP, + NopROP, + AndNotROP, + OrNotROP, + NandROP, + NorROP, LastROP=NorROP + }; + + // documented in tqpainter.cpp + enum PenStyle { // pen style + NoPen, + SolidLine, + DashLine, + DotLine, + DashDotLine, + DashDotDotLine, + FineDotLine, + MPenStyle = 0x0f + }; + + // documented in tqpainter.cpp + enum PenCapStyle { // line endcap style + FlatCap = 0x00, + SquareCap = 0x10, + RoundCap = 0x20, + MPenCapStyle = 0x30 + }; + + // documented in tqpainter.cpp + enum PenJoinStyle { // line join style + MiterJoin = 0x00, + BevelJoin = 0x40, + RoundJoin = 0x80, + MPenJoinStyle = 0xc0 + }; + + // documented in tqpainter.cpp + enum BrushStyle { // brush style + NoBrush, + SolidPattern, + Dense1Pattern, + Dense2Pattern, + Dense3Pattern, + Dense4Pattern, + Dense5Pattern, + Dense6Pattern, + Dense7Pattern, + HorPattern, + VerPattern, + CrossPattern, + BDiagPattern, + FDiagPattern, + DiagCrossPattern, + CustomPattern=24 + }; + + // documented in qapplication_mac.cpp + enum MacintoshVersion { + //Unknown + MV_Unknown = 0x0000, + + //Version numbers + MV_9 = 0x0001, + MV_10_DOT_0 = 0x0002, + MV_10_DOT_1 = 0x0003, + MV_10_DOT_2 = 0x0004, + MV_10_DOT_3 = 0x0005, + MV_10_DOT_4 = 0x0006, + + //Code names + MV_CHEETAH = MV_10_DOT_0, + MV_PUMA = MV_10_DOT_1, + MV_JAGUAR = MV_10_DOT_2, + MV_PANTHER = MV_10_DOT_3, + MV_TIGER = MV_10_DOT_4 + }; + + // documented in qapplication_win.cpp + enum WindowsVersion { + WV_32s = 0x0001, + WV_95 = 0x0002, + WV_98 = 0x0003, + WV_Me = 0x0004, + WV_DOS_based = 0x000f, + + WV_NT = 0x0010, + WV_2000 = 0x0020, + WV_XP = 0x0030, + WV_2003 = 0x0040, + WV_VISTA = 0x0080, + WV_NT_based = 0x00f0, + + WV_CE = 0x0100, + WV_CENET = 0x0200, + WV_CE_based = 0x0f00 + }; + + // documented in tqstyle.cpp + enum UIEffect { + UI_General, + UI_AnimateMenu, + UI_FadeMenu, + UI_AnimateCombo, + UI_AnimateTooltip, + UI_FadeTooltip, + UI_AnimateToolBox + }; + + // documented in tqcursor.cpp + enum CursorShape { + ArrowCursor, + UpArrowCursor, + CrossCursor, + WaitCursor, + IbeamCursor, + SizeVerCursor, + SizeHorCursor, + SizeBDiagCursor, + SizeFDiagCursor, + SizeAllCursor, + BlankCursor, + SplitVCursor, + SplitHCursor, + PointingHandCursor, + ForbiddenCursor, + WhatsThisCursor, + BusyCursor, + LastCursor = BusyCursor, + BitmapCursor = 24 + }; + + // Global cursors + + static const TQCursor & arrowCursor; // standard arrow cursor + static const TQCursor & upArrowCursor; // upwards arrow + static const TQCursor & crossCursor; // crosshair + static const TQCursor & waitCursor; // hourglass/watch + static const TQCursor & ibeamCursor; // ibeam/text entry + static const TQCursor & sizeVerCursor; // vertical resize + static const TQCursor & sizeHorCursor; // horizontal resize + static const TQCursor & sizeBDiagCursor; // diagonal resize (/) + static const TQCursor & sizeFDiagCursor; // diagonal resize (\) + static const TQCursor & sizeAllCursor; // all directions resize + static const TQCursor & blankCursor; // blank/invisible cursor + static const TQCursor & splitVCursor; // vertical bar with left-right + // arrows + static const TQCursor & splitHCursor; // horizontal bar with up-down + // arrows + static const TQCursor & pointingHandCursor; // pointing hand + static const TQCursor & forbiddenCursor; // forbidden cursor (slashed circle) + static const TQCursor & whatsThisCursor; // arrow with a question mark + static const TQCursor & busyCursor; // arrow with hourglass + + + enum TextFormat { + PlainText, + RichText, + AutoText, + LogText + }; + + // Documented in tqtextedit.cpp + enum AnchorAttribute { + AnchorName, + AnchorHref + }; + + // Documented in tqmainwindow.cpp + enum Dock { + DockUnmanaged, + DockTornOff, + DockTop, + DockBottom, + DockRight, + DockLeft, + DockMinimized +#ifndef TQT_NO_COMPAT + , + Unmanaged = DockUnmanaged, + TornOff = DockTornOff, + Top = DockTop, + Bottom = DockBottom, + Right = DockRight, + Left = DockLeft, + Minimized = DockMinimized +#endif + }; + // compatibility + typedef Dock ToolBarDock; + + // documented in tqdatetime.cpp + enum DateFormat { + TextDate, // default TQt + ISODate, // ISO 8601 + LocalDate // locale dependent + }; + + // documented in tqdatetime.cpp + enum TimeSpec { + LocalTime, + UTC + }; + + // documented in tqwidget.cpp + enum BackgroundMode { + FixedColor, + FixedPixmap, + NoBackground, + PaletteForeground, + PaletteButton, + PaletteLight, + PaletteMidlight, + PaletteDark, + PaletteMid, + PaletteText, + PaletteBrightText, + PaletteBase, + PaletteBackground, + PaletteShadow, + PaletteHighlight, + PaletteHighlightedText, + PaletteButtonText, + PaletteLink, + PaletteLinkVisited, + X11ParentRelative + }; + + typedef uint ComparisonFlags; + + // Documented in tqstring.cpp + enum StringComparisonMode { + CaseSensitive = 0x00001, // 0 0001 + BeginsWith = 0x00002, // 0 0010 + EndsWith = 0x00004, // 0 0100 + Contains = 0x00008, // 0 1000 + ExactMatch = 0x00010 // 1 0000 + }; + + // Documented in tqtabwidget.cpp + enum Corner { + TopLeft = 0x00000, + TopRight = 0x00001, + BottomLeft = 0x00002, + BottomRight = 0x00003 + }; + + // "handle" type for system objects. Documented as \internal in + // qapplication.cpp +#if defined(TQ_WS_MAC) + typedef void * HANDLE; +#elif defined(TQ_WS_WIN) + typedef void *HANDLE; +#elif defined(TQ_WS_X11) + typedef unsigned long HANDLE; +#endif +}; + + +class TQ_EXPORT TQInternal { +public: + enum PaintDeviceFlags { + UndefinedDevice = 0x00, + Widget = 0x01, + Pixmap = 0x02, + Printer = 0x03, + Picture = 0x04, + System = 0x05, + DeviceTypeMask = 0x0f, + ExternalDevice = 0x10, + // used to emulate some of the behaviour different between TQt2 and TQt3 (mainly for printing) + CompatibilityMode = 0x20 + }; +}; + +#endif // TQNAMESPACE_H diff --git a/src/kernel/tqobject.cpp b/src/kernel/tqobject.cpp index 756117fff..cb1dfe7ab 100644 --- a/src/kernel/tqobject.cpp +++ b/src/kernel/tqobject.cpp @@ -44,7 +44,7 @@ #include "tqobjectlist.h" #include "tqsignalslotimp.h" #include "tqregexp.h" -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include #include "qucomextra_p.h" #include "tqptrvector.h" @@ -314,7 +314,7 @@ TQMetaCallEvent::~TQMetaCallEvent() { } /*! - \class TQt ntqnamespace.h + \class TQt tqnamespace.h \brief The TQt class is a namespace for miscellaneous identifiers that need to be global-like. diff --git a/src/kernel/tqobject.h b/src/kernel/tqobject.h index 3ee1c6c19..eb627831d 100644 --- a/src/kernel/tqobject.h +++ b/src/kernel/tqobject.h @@ -47,7 +47,7 @@ #include "tqstring.h" #include "tqevent.h" #include "tqmutex.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #endif // QT_H #include diff --git a/src/kernel/tqobjectdict.h b/src/kernel/tqobjectdict.h index 8ff8c31f4..c51123054 100644 --- a/src/kernel/tqobjectdict.h +++ b/src/kernel/tqobjectdict.h @@ -42,7 +42,7 @@ #define TQOBJECTDICT_H #ifndef QT_H -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include "tqasciidict.h" #endif // QT_H diff --git a/src/kernel/tqpixmap.h b/src/kernel/tqpixmap.h index 70609d4a7..1ab6dd0b9 100644 --- a/src/kernel/tqpixmap.h +++ b/src/kernel/tqpixmap.h @@ -45,7 +45,7 @@ #include "tqpaintdevice.h" #include "tqcolor.h" // char*->TQColor conversion #include "tqstring.h" // char*->TQString conversion -#include "ntqnamespace.h" +#include "tqnamespace.h" #endif // QT_H class TQPixmapPrivate; diff --git a/src/kernel/tqpolygonscanner.cpp b/src/kernel/tqpolygonscanner.cpp new file mode 100644 index 000000000..2df631730 --- /dev/null +++ b/src/kernel/tqpolygonscanner.cpp @@ -0,0 +1,937 @@ +/**************************************************************************** +** +** Implementation of TQPolygonScanner class +** +** Created : 000120 +** +** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqpolygonscanner.h" +#include "tqpointarray.h" +#include + + +// Based on Xserver code miFillGeneralPoly... +/* + * + * Written by Brian Kelleher; Oct. 1985 + * + * Routine to fill a polygon. Two fill rules are + * supported: frWINDING and frEVENODD. + * + * See fillpoly.h for a complete description of the algorithm. + */ + +/* + * These are the data structures needed to scan + * convert regions. Two different scan conversion + * methods are available -- the even-odd method, and + * the winding number method. + * The even-odd rule states that a point is inside + * the polygon if a ray drawn from that point in any + * direction will pass through an odd number of + * path segments. + * By the winding number rule, a point is decided + * to be inside the polygon if a ray drawn from that + * point in any direction passes through a different + * number of clockwise and counterclockwise path + * segments. + * + * These data structures are adapted somewhat from + * the algorithm in (Foley/Van Dam) for scan converting + * polygons. + * The basic algorithm is to start at the top (smallest y) + * of the polygon, stepping down to the bottom of + * the polygon by incrementing the y coordinate. We + * keep a list of edges which the current scanline crosses, + * sorted by x. This list is called the Active Edge Table (AET) + * As we change the y-coordinate, we update each entry in + * in the active edge table to reflect the edges new xcoord. + * This list must be sorted at each scanline in case + * two edges intersect. + * We also keep a data structure known as the Edge Table (ET), + * which keeps track of all the edges which the current + * scanline has not yet reached. The ET is basically a + * list of ScanLineList structures containing a list of + * edges which are entered at a given scanline. There is one + * ScanLineList per scanline at which an edge is entered. + * When we enter a new edge, we move it from the ET to the AET. + * + * From the AET, we can implement the even-odd rule as in + * (Foley/Van Dam). + * The winding number rule is a little trickier. We also + * keep the EdgeTableEntries in the AET linked by the + * nextWETE (winding EdgeTableEntry) link. This allows + * the edges to be linked just as before for updating + * purposes, but only uses the edges linked by the nextWETE + * link as edges representing spans of the polygon to + * drawn (as with the even-odd rule). + */ + +/* $XConsortium: miscanfill.h,v 1.5 94/04/17 20:27:50 dpw Exp $ */ +/* + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + + +/* + * scanfill.h + * + * Written by Brian Kelleher; Jan 1985 + * + * This file contains a few macros to help track + * the edge of a filled object. The object is assumed + * to be filled in scanline order, and thus the + * algorithm used is an extension of Bresenham's line + * drawing algorithm which assumes that y is always the + * major axis. + * Since these pieces of code are the same for any filled shape, + * it is more convenient to gather the library in one + * place, but since these pieces of code are also in + * the inner loops of output primitives, procedure call + * overhead is out of the question. + * See the author for a derivation if needed. + */ + +/* + * In scan converting polygons, we want to choose those pixels + * which are inside the polygon. Thus, we add .5 to the starting + * x coordinate for both left and right edges. Now we choose the + * first pixel which is inside the pgon for the left edge and the + * first pixel which is outside the pgon for the right edge. + * Draw the left pixel, but not the right. + * + * How to add .5 to the starting x coordinate: + * If the edge is moving to the right, then subtract dy from the + * error term from the general form of the algorithm. + * If the edge is moving to the left, then add dy to the error term. + * + * The reason for the difference between edges moving to the left + * and edges moving to the right is simple: If an edge is moving + * to the right, then we want the algorithm to flip immediately. + * If it is moving to the left, then we don't want it to flip until + * we traverse an entire pixel. + */ +#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ + int dx; /* local storage */ \ +\ + /* \ + * if the edge is horizontal, then it is ignored \ + * and assumed not to be processed. Otherwise, do this stuff. \ + */ \ + if ((dy) != 0) { \ + xStart = (x1); \ + dx = (x2) - xStart; \ + if (dx < 0) { \ + m = dx / (dy); \ + m1 = m - 1; \ + incr1 = -2 * dx + 2 * (dy) * m1; \ + incr2 = -2 * dx + 2 * (dy) * m; \ + d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ + } else { \ + m = dx / (dy); \ + m1 = m + 1; \ + incr1 = 2 * dx - 2 * (dy) * m1; \ + incr2 = 2 * dx - 2 * (dy) * m; \ + d = -2 * m * (dy) + 2 * dx; \ + } \ + } \ +} + +#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ + if (m1 > 0) { \ + if (d > 0) { \ + minval += m1; \ + d += incr1; \ + } \ + else { \ + minval += m; \ + d += incr2; \ + } \ + } else {\ + if (d >= 0) { \ + minval += m1; \ + d += incr1; \ + } \ + else { \ + minval += m; \ + d += incr2; \ + } \ + } \ +} + + +/* + * This structure contains all of the information needed + * to run the bresenham algorithm. + * The variables may be hardcoded into the declarations + * instead of using this structure to make use of + * register declarations. + */ +typedef struct { + int minor; /* minor axis */ + int d; /* decision variable */ + int m, m1; /* slope and slope+1 */ + int incr1, incr2; /* error increments */ +} BRESINFO; + + +#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ + BRESINITPGON(dmaj, min1, min2, bres.minor, bres.d, \ + bres.m, bres.m1, bres.incr1, bres.incr2) + +#define BRESINCRPGONSTRUCT(bres) \ + BRESINCRPGON(bres.d, bres.minor, bres.m, bres.m1, bres.incr1, bres.incr2) + + +typedef struct _EdgeTableEntry { + int ymax; /* ycoord at which we exit this edge. */ + BRESINFO bres; /* Bresenham info to run the edge */ + struct _EdgeTableEntry *next; /* next in the list */ + struct _EdgeTableEntry *back; /* for insertion sort */ + struct _EdgeTableEntry *nextWETE; /* for winding num rule */ + int ClockWise; /* flag for winding number rule */ +} EdgeTableEntry; + + +typedef struct _ScanLineList{ + int scanline; /* the scanline represented */ + EdgeTableEntry *edgelist; /* header node */ + struct _ScanLineList *next; /* next in the list */ +} ScanLineList; + + +typedef struct { + int ymax; /* ymax for the polygon */ + int ymin; /* ymin for the polygon */ + ScanLineList scanlines; /* header node */ +} EdgeTable; + + +/* + * Here is a struct to help with storage allocation + * so we can allocate a big chunk at a time, and then take + * pieces from this heap when we need to. + */ +#define SLLSPERBLOCK 25 + +typedef struct _ScanLineListBlock { + ScanLineList SLLs[SLLSPERBLOCK]; + struct _ScanLineListBlock *next; +} ScanLineListBlock; + +/* + * number of points to buffer before sending them off + * to scanlines() : Must be an even number + */ +#define NUMPTSTOBUFFER 200 + +/* + * + * a few macros for the inner loops of the fill code where + * performance considerations don't allow a procedure call. + * + * Evaluate the given edge at the given scanline. + * If the edge has expired, then we leave it and fix up + * the active edge table; otherwise, we increment the + * x value to be ready for the next scanline. + * The winding number rule is in effect, so we must notify + * the caller when the edge has been removed so he + * can reorder the Winding Active Edge Table. + */ +#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ + if (pAET->ymax == y) { /* leaving this edge */ \ + pPrevAET->next = pAET->next; \ + pAET = pPrevAET->next; \ + fixWAET = 1; \ + if (pAET) \ + pAET->back = pPrevAET; \ + } \ + else { \ + BRESINCRPGONSTRUCT(pAET->bres); \ + pPrevAET = pAET; \ + pAET = pAET->next; \ + } \ +} + + +/* + * Evaluate the given edge at the given scanline. + * If the edge has expired, then we leave it and fix up + * the active edge table; otherwise, we increment the + * x value to be ready for the next scanline. + * The even-odd rule is in effect. + */ +#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ + if (pAET->ymax == y) { /* leaving this edge */ \ + pPrevAET->next = pAET->next; \ + pAET = pPrevAET->next; \ + if (pAET) \ + pAET->back = pPrevAET; \ + } \ + else { \ + BRESINCRPGONSTRUCT(pAET->bres) \ + pPrevAET = pAET; \ + pAET = pAET->next; \ + } \ +} + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#define MAXINT 0x7fffffff +#define MININT -MAXINT + +/* + * fillUtils.c + * + * Written by Brian Kelleher; Oct. 1985 + * + * This module contains all of the utility functions + * needed to scan convert a polygon. + * + */ +/* + * InsertEdgeInET + * + * Insert the given edge into the edge table. + * First we must find the correct bucket in the + * Edge table, then find the right slot in the + * bucket. Finally, we can insert it. + * + */ +static bool +miInsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, + int scanline, ScanLineListBlock **SLLBlock, int *iSLLBlock) +{ + EdgeTableEntry *start, *prev; + ScanLineList *pSLL, *pPrevSLL; + ScanLineListBlock *tmpSLLBlock; + + /* + * find the right bucket to put the edge into + */ + pPrevSLL = &ET->scanlines; + pSLL = pPrevSLL->next; + while (pSLL && (pSLL->scanline < scanline)) + { + pPrevSLL = pSLL; + pSLL = pSLL->next; + } + + /* + * reassign pSLL (pointer to ScanLineList) if necessary + */ + if ((!pSLL) || (pSLL->scanline > scanline)) + { + if (*iSLLBlock > SLLSPERBLOCK-1) + { + tmpSLLBlock = + (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); + if (!tmpSLLBlock) + return FALSE; + (*SLLBlock)->next = tmpSLLBlock; + tmpSLLBlock->next = 0; + *SLLBlock = tmpSLLBlock; + *iSLLBlock = 0; + } + pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); + + pSLL->next = pPrevSLL->next; + pSLL->edgelist = 0; + pPrevSLL->next = pSLL; + } + pSLL->scanline = scanline; + + /* + * now insert the edge in the right bucket + */ + prev = 0; + start = pSLL->edgelist; + while (start && (start->bres.minor < ETE->bres.minor)) + { + prev = start; + start = start->next; + } + ETE->next = start; + + if (prev) + prev->next = ETE; + else + pSLL->edgelist = ETE; + return TRUE; +} + +/* + * CreateEdgeTable + * + * This routine creates the edge table for + * scan converting polygons. + * The Edge Table (ET) looks like: + * + * EdgeTable + * -------- + * | ymax | ScanLineLists + * |scanline|-->------------>-------------->... + * -------- |scanline| |scanline| + * |edgelist| |edgelist| + * --------- --------- + * | | + * | | + * V V + * list of ETEs list of ETEs + * + * where ETE is an EdgeTableEntry data structure, + * and there is one ScanLineList per scanline at + * which an edge is initially entered. + * + */ + +typedef struct { +#if defined(Q_OS_MAC) + int y, x; +#else + int x, y; +#endif + +} DDXPointRec, *DDXPointPtr; + +/* + * Clean up our act. + */ +static void +miFreeStorage(ScanLineListBlock *pSLLBlock) +{ + ScanLineListBlock *tmpSLLBlock; + + while (pSLLBlock) + { + tmpSLLBlock = pSLLBlock->next; + free(pSLLBlock); + pSLLBlock = tmpSLLBlock; + } +} + +static bool +miCreateETandAET(int count, DDXPointPtr pts, EdgeTable *ET, + EdgeTableEntry *AET, EdgeTableEntry *pETEs, ScanLineListBlock *pSLLBlock) +{ + DDXPointPtr top, bottom; + DDXPointPtr PrevPt, CurrPt; + int iSLLBlock = 0; + + int dy; + + if (count < 2) return TRUE; + + /* + * initialize the Active Edge Table + */ + AET->next = 0; + AET->back = 0; + AET->nextWETE = 0; + AET->bres.minor = MININT; + + /* + * initialize the Edge Table. + */ + ET->scanlines.next = 0; + ET->ymax = MININT; + ET->ymin = MAXINT; + pSLLBlock->next = 0; + + PrevPt = &pts[count-1]; + + /* + * for each vertex in the array of points. + * In this loop we are dealing with two vertices at + * a time -- these make up one edge of the polygon. + */ + while (count--) + { + CurrPt = pts++; + + /* + * find out which point is above and which is below. + */ + if (PrevPt->y > CurrPt->y) + { + bottom = PrevPt, top = CurrPt; + pETEs->ClockWise = 0; + } + else + { + bottom = CurrPt, top = PrevPt; + pETEs->ClockWise = 1; + } + + /* + * don't add horizontal edges to the Edge table. + */ + if (bottom->y != top->y) + { + pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */ + + /* + * initialize integer edge algorithm + */ + dy = bottom->y - top->y; + BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres) + + if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) + { + miFreeStorage(pSLLBlock->next); + return FALSE; + } + + ET->ymax = TQMAX(ET->ymax, PrevPt->y); + ET->ymin = TQMIN(ET->ymin, PrevPt->y); + pETEs++; + } + + PrevPt = CurrPt; + } + return TRUE; +} + +/* + * loadAET + * + * This routine moves EdgeTableEntries from the + * EdgeTable into the Active Edge Table, + * leaving them sorted by smaller x coordinate. + * + */ + +static void +miloadAET(EdgeTableEntry *AET, EdgeTableEntry *ETEs) +{ + EdgeTableEntry *pPrevAET; + EdgeTableEntry *tmp; + + pPrevAET = AET; + AET = AET->next; + while (ETEs) + { + while (AET && (AET->bres.minor < ETEs->bres.minor)) + { + pPrevAET = AET; + AET = AET->next; + } + tmp = ETEs->next; + ETEs->next = AET; + if (AET) + AET->back = ETEs; + ETEs->back = pPrevAET; + pPrevAET->next = ETEs; + pPrevAET = ETEs; + + ETEs = tmp; + } +} + +/* + * computeWAET + * + * This routine links the AET by the + * nextWETE (winding EdgeTableEntry) link for + * use by the winding number rule. The final + * Active Edge Table (AET) might look something + * like: + * + * AET + * ---------- --------- --------- + * |ymax | |ymax | |ymax | + * | ... | |... | |... | + * |next |->|next |->|next |->... + * |nextWETE| |nextWETE| |nextWETE| + * --------- --------- ^-------- + * | | | + * V-------------------> V---> ... + * + */ +static void +micomputeWAET(EdgeTableEntry *AET) +{ + EdgeTableEntry *pWETE; + int inside = 1; + int isInside = 0; + + AET->nextWETE = 0; + pWETE = AET; + AET = AET->next; + while (AET) + { + if (AET->ClockWise) + isInside++; + else + isInside--; + + if ((!inside && !isInside) || + ( inside && isInside)) + { + pWETE->nextWETE = AET; + pWETE = AET; + inside = !inside; + } + AET = AET->next; + } + pWETE->nextWETE = 0; +} + +/* + * InsertionSort + * + * Just a simple insertion sort using + * pointers and back pointers to sort the Active + * Edge Table. + * + */ + +static int +miInsertionSort(EdgeTableEntry *AET) +{ + EdgeTableEntry *pETEchase; + EdgeTableEntry *pETEinsert; + EdgeTableEntry *pETEchaseBackTMP; + int changed = 0; + + AET = AET->next; + while (AET) + { + pETEinsert = AET; + pETEchase = AET; + while (pETEchase->back->bres.minor > AET->bres.minor) + pETEchase = pETEchase->back; + + AET = AET->next; + if (pETEchase != pETEinsert) + { + pETEchaseBackTMP = pETEchase->back; + pETEinsert->back->next = AET; + if (AET) + AET->back = pETEinsert->back; + pETEinsert->next = pETEchase; + pETEchase->back->next = pETEinsert; + pETEchase->back = pETEinsert; + pETEinsert->back = pETEchaseBackTMP; + changed = 1; + } + } + return(changed); +} + +/*! + \overload +*/ +void TQPolygonScanner::scan(const TQPointArray& pa, bool winding, int index, int npoints) +{ + scan( pa, winding, index, npoints, TRUE ); +} + +/*! + \overload + + If \a stitchable is FALSE, the right and bottom edges of the + polygon are included. This causes adjacent polygons to overlap. +*/ +void TQPolygonScanner::scan(const TQPointArray& pa, bool winding, int index, int npoints, bool stitchable) +{ + scan( pa, winding, index, npoints, + stitchable ? Edge(Left+Top) : Edge(Left+Right+Top+Bottom) ); +} + +/*! + Calls processSpans() for all scanlines of the polygon defined by + \a npoints starting at \a index in \a pa. + + If \a winding is TRUE, the Winding algorithm rather than the + Odd-Even rule is used. + + The \a edges is any bitwise combination of: + \list + \i \c TQPolygonScanner::Left + \i \c TQPolygonScanner::Right + \i \c TQPolygonScanner::Top + \i \c TQPolygonScanner::Bottom + \endlist + \a edges determines which edges are included. + + \warning The edges feature does not work properly. + +*/ +void TQPolygonScanner::scan( const TQPointArray& pa, bool winding, int index, int npoints, Edge edges ) +{ + + + DDXPointPtr ptsIn = (DDXPointPtr)pa.data(); + ptsIn += index; + EdgeTableEntry *pAET; /* the Active Edge Table */ + int y; /* the current scanline */ + int nPts = 0; /* number of pts in buffer */ + EdgeTableEntry *pWETE; /* Winding Edge Table */ + ScanLineList *pSLL; /* Current ScanLineList */ + DDXPointPtr ptsOut; /* ptr to output buffers */ + int *width; + DDXPointRec FirstPoint[NUMPTSTOBUFFER]; /* the output buffers */ + int FirstWidth[NUMPTSTOBUFFER]; + EdgeTableEntry *pPrevAET; /* previous AET entry */ + EdgeTable ET; /* Edge Table header node */ + EdgeTableEntry AET; /* Active ET header node */ + EdgeTableEntry *pETEs; /* Edge Table Entries buff */ + ScanLineListBlock SLLBlock; /* header for ScanLineList */ + int fixWAET = 0; + int edge_l = (edges & Left) ? 1 : 0; + int edge_r = (edges & Right) ? 1 : 0; + int edge_t = 1; //#### (edges & Top) ? 1 : 0; + int edge_b = (edges & Bottom) ? 1 : 0; + + if (npoints == -1) + npoints = pa.size(); + + if (npoints < 3) + return; + + if(!(pETEs = (EdgeTableEntry *) + malloc(sizeof(EdgeTableEntry) * npoints))) + return; + ptsOut = FirstPoint; + width = FirstWidth; + if (!miCreateETandAET(npoints, ptsIn, &ET, &AET, pETEs, &SLLBlock)) + { + free(pETEs); + return; + } + pSLL = ET.scanlines.next; + + if (!winding) + { + /* + * for each scanline + */ + for (y = ET.ymin+1-edge_t; y < ET.ymax+edge_b; y++) + { + /* + * Add a new edge to the active edge table when we + * get to the next edge. + */ + if (pSLL && y == pSLL->scanline) + { + miloadAET(&AET, pSLL->edgelist); + pSLL = pSLL->next; + } + pPrevAET = &AET; + pAET = AET.next; + + /* + * for each active edge + */ + while (pAET) + { + ptsOut->x = pAET->bres.minor + 1 - edge_l; + ptsOut++->y = y; + *width++ = pAET->next->bres.minor - pAET->bres.minor + - 1 + edge_l + edge_r; + nPts++; + + /* + * send out the buffer when its full + */ + if (nPts == NUMPTSTOBUFFER) + { + processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); + ptsOut = FirstPoint; + width = FirstWidth; + nPts = 0; + } + EVALUATEEDGEEVENODD(pAET, pPrevAET, y) + EVALUATEEDGEEVENODD(pAET, pPrevAET, y) + } + miInsertionSort(&AET); + } + } + else /* default to WindingNumber */ + { + /* + * for each scanline + */ + for (y = ET.ymin+1-edge_t; y < ET.ymax+edge_b; y++) + { + /* + * Add a new edge to the active edge table when we + * get to the next edge. + */ + if (pSLL && y == pSLL->scanline) + { + miloadAET(&AET, pSLL->edgelist); + micomputeWAET(&AET); + pSLL = pSLL->next; + } + pPrevAET = &AET; + pAET = AET.next; + pWETE = pAET; + + /* + * for each active edge + */ + while (pAET) + { + /* + * if the next edge in the active edge table is + * also the next edge in the winding active edge + * table. + */ + if (pWETE == pAET) + { + ptsOut->x = pAET->bres.minor + 1 - edge_l; + ptsOut++->y = y; + *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor - 1 + edge_l + edge_r; + nPts++; + + /* + * send out the buffer + */ + if (nPts == NUMPTSTOBUFFER) + { + processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); + ptsOut = FirstPoint; + width = FirstWidth; + nPts = 0; + } + + pWETE = pWETE->nextWETE; + while (pWETE != pAET) { + EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) + } + pWETE = pWETE->nextWETE; + } + EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) + } + + /* + * reevaluate the Winding active edge table if we + * just had to resort it or if we just exited an edge. + */ + if (miInsertionSort(&AET) || fixWAET) + { + micomputeWAET(&AET); + fixWAET = 0; + } + } + } + + /* + * Get any spans that we missed by buffering + */ + + + processSpans( nPts, (TQPoint*)FirstPoint, FirstWidth ); + free(pETEs); + miFreeStorage(SLLBlock.next); +} +/***** END OF X11-based CODE *****/ + + diff --git a/src/kernel/tqpolygonscanner.h b/src/kernel/tqpolygonscanner.h new file mode 100644 index 000000000..2ab2c8e37 --- /dev/null +++ b/src/kernel/tqpolygonscanner.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Definition of TQPolygonScanner class +** +** Created : 000120 +** +** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPOLYGONSCANNER_H +#define TQPOLYGONSCANNER_H + +#ifndef QT_H +#include "tqglobal.h" +#endif // QT_H + +class TQPointArray; +class TQPoint; + +class TQ_EXPORT TQPolygonScanner { +public: + // BIC: fix for 3.0 + void scan( const TQPointArray& pa, bool winding, int index=0, int npoints=-1 ); + void scan( const TQPointArray& pa, bool winding, int index, int npoints, bool stitchable ); + enum Edge { Left=1, Right=2, Top=4, Bottom=8 }; + void scan( const TQPointArray& pa, bool winding, int index, int npoints, Edge edges ); + virtual void processSpans( int n, TQPoint* point, int* width )=0; +}; + +#endif // TQPOLYGONSCANNER_H diff --git a/src/kernel/tqprinter_unix.cpp b/src/kernel/tqprinter_unix.cpp index b5ae63926..06eeabbdd 100644 --- a/src/kernel/tqprinter_unix.cpp +++ b/src/kernel/tqprinter_unix.cpp @@ -53,7 +53,7 @@ static inline int qt_open(const char *pathname, int flags, mode_t mode) #include "tqpaintdevicemetrics.h" #include "qpsprinter_p.h" -#include "ntqprintdialog.h" +#include "tqprintdialog.h" #include "ntqapplication.h" #include "tqprinter_p.h" diff --git a/src/kernel/tqsignal.cpp b/src/kernel/tqsignal.cpp index 3be5bb960..073b61949 100644 --- a/src/kernel/tqsignal.cpp +++ b/src/kernel/tqsignal.cpp @@ -39,7 +39,7 @@ **********************************************************************/ #include "tqsignal.h" -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include "tqguardedptr.h" /*! diff --git a/src/kernel/tqsimplerichtext.h b/src/kernel/tqsimplerichtext.h index 8d3d9ad8b..45ddd6b10 100644 --- a/src/kernel/tqsimplerichtext.h +++ b/src/kernel/tqsimplerichtext.h @@ -42,7 +42,7 @@ #define TQSIMPLERICHTEXT_H #ifndef QT_H -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqstring.h" #include "tqregion.h" #endif // QT_H diff --git a/src/kernel/tqsize.h b/src/kernel/tqsize.h index 6bfb60865..a49dd25a9 100644 --- a/src/kernel/tqsize.h +++ b/src/kernel/tqsize.h @@ -49,7 +49,7 @@ class TQ_EXPORT TQSize // ### Make TQSize inherit TQt in TQt 4.0 { public: - // ### Move this enum to ntqnamespace.h in TQt 4.0 + // ### Move this enum to tqnamespace.h in TQt 4.0 enum ScaleMode { ScaleFree, ScaleMin, diff --git a/src/kernel/tqtextengine_p.h b/src/kernel/tqtextengine_p.h index d1a467f2b..d092a3e7d 100644 --- a/src/kernel/tqtextengine_p.h +++ b/src/kernel/tqtextengine_p.h @@ -40,7 +40,7 @@ #ifndef QT_H #include "tqglobal.h" #include "tqstring.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include #endif // QT_H diff --git a/src/kernel/tqtextlayout_p.h b/src/kernel/tqtextlayout_p.h index 58dced19b..a95f28e78 100644 --- a/src/kernel/tqtextlayout_p.h +++ b/src/kernel/tqtextlayout_p.h @@ -39,7 +39,7 @@ #ifndef QT_H #include "tqstring.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqrect.h" #endif // QT_H diff --git a/src/kernel/tqttdeintegration_x11.cpp b/src/kernel/tqttdeintegration_x11.cpp index 0b8e794c2..48aeb0dc9 100644 --- a/src/kernel/tqttdeintegration_x11.cpp +++ b/src/kernel/tqttdeintegration_x11.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include bool TQTDEIntegration::inited = false; diff --git a/src/kernel/tqwidget.cpp b/src/kernel/tqwidget.cpp index 4aa4a09ed..e2e6c44f8 100644 --- a/src/kernel/tqwidget.cpp +++ b/src/kernel/tqwidget.cpp @@ -54,7 +54,7 @@ #include "tqstylefactory.h" #include "tqcleanuphandler.h" #include "tqstyle.h" -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include "tqguardedptr.h" #if defined(TQT_THREAD_SUPPORT) #include "tqthread.h" diff --git a/src/kernel/tqwidget_x11.cpp b/src/kernel/tqwidget_x11.cpp index b7136818f..cc16871a7 100644 --- a/src/kernel/tqwidget_x11.cpp +++ b/src/kernel/tqwidget_x11.cpp @@ -40,7 +40,7 @@ #include "ntqapplication.h" #include "qapplication_p.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #include "tqpaintdevicemetrics.h" #include "tqpainter.h" #include "tqbitmap.h" diff --git a/src/moc/moc.y b/src/moc/moc.y index 1691c5805..a393aa868 100644 --- a/src/moc/moc.y +++ b/src/moc/moc.y @@ -646,10 +646,10 @@ int tmpYYStart; // Used to store the lexers current mode int tmpYYStart2; // Used to store the lexers current mode // (if tmpYYStart is already used) -// if the format revision changes, you MUST change it in ntqmetaobject.h too +// if the format revision changes, you MUST change it in tqmetaobject.h too const int formatRevision = 26; // moc output format revision -// if the flags change, you HAVE to change it in ntqmetaobject.h too +// if the flags change, you HAVE to change it in tqmetaobject.h too enum Flags { Invalid = 0x00000000, Readable = 0x00000001, @@ -2904,7 +2904,7 @@ void generateClass() // generate C++ source code for a class g->includeFiles.next(); } } - fprintf( out, "#include <%sntqmetaobject.h>\n", (const char*)g->qtPath ); + fprintf( out, "#include <%stqmetaobject.h>\n", (const char*)g->qtPath ); fprintf( out, "#include <%sntqapplication.h>\n\n", (const char*)g->qtPath ); fprintf( out, "#include <%sprivate/qucomextra_p.h>\n", (const char*)g->qtPath ); fprintf( out, "#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != %d)\n", formatRevision ); diff --git a/src/moc/moc_yacc.cpp b/src/moc/moc_yacc.cpp index dcf19ab2a..ae23163da 100644 --- a/src/moc/moc_yacc.cpp +++ b/src/moc/moc_yacc.cpp @@ -659,10 +659,10 @@ int tmpYYStart; // Used to store the lexers current mode int tmpYYStart2; // Used to store the lexers current mode // (if tmpYYStart is already used) -// if the format revision changes, you MUST change it in ntqmetaobject.h too +// if the format revision changes, you MUST change it in tqmetaobject.h too const int formatRevision = 26; // moc output format revision -// if the flags change, you HAVE to change it in ntqmetaobject.h too +// if the flags change, you HAVE to change it in tqmetaobject.h too enum Flags { Invalid = 0x00000000, Readable = 0x00000001, @@ -5779,7 +5779,7 @@ void generateClass() // generate C++ source code for a class g->includeFiles.next(); } } - fprintf( out, "#include <%sntqmetaobject.h>\n", (const char*)g->qtPath ); + fprintf( out, "#include <%stqmetaobject.h>\n", (const char*)g->qtPath ); fprintf( out, "#include <%sntqapplication.h>\n\n", (const char*)g->qtPath ); fprintf( out, "#include <%sprivate/qucomextra_p.h>\n", (const char*)g->qtPath ); fprintf( out, "#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != %d)\n", formatRevision ); diff --git a/src/sql/tqsqlerror.cpp b/src/sql/tqsqlerror.cpp index 1b9f69ca8..55d98202d 100644 --- a/src/sql/tqsqlerror.cpp +++ b/src/sql/tqsqlerror.cpp @@ -39,7 +39,7 @@ **********************************************************************/ #include "tqsqlerror.h" -#include +#include #ifndef TQT_NO_SQL diff --git a/src/sql/tqsqlmanager_p.cpp b/src/sql/tqsqlmanager_p.cpp index 4b9597319..754d572a9 100644 --- a/src/sql/tqsqlmanager_p.cpp +++ b/src/sql/tqsqlmanager_p.cpp @@ -48,7 +48,7 @@ #include "tqsqlform.h" #include "tqsqldriver.h" #include "tqstring.h" -#include "ntqmessagebox.h" +#include "tqmessagebox.h" #include "tqbitarray.h" //#define QT_DEBUG_DATAMANAGER diff --git a/src/sql/tqsqlpropertymap.cpp b/src/sql/tqsqlpropertymap.cpp index 81a0dd4a5..55a9f6843 100644 --- a/src/sql/tqsqlpropertymap.cpp +++ b/src/sql/tqsqlpropertymap.cpp @@ -44,7 +44,7 @@ #include "tqwidget.h" #include "tqcleanuphandler.h" -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include "tqmap.h" class TQSqlPropertyMapPrivate diff --git a/src/sql/tqsqlrecord.cpp b/src/sql/tqsqlrecord.cpp index dd4432aa1..9c567c126 100644 --- a/src/sql/tqsqlrecord.cpp +++ b/src/sql/tqsqlrecord.cpp @@ -45,7 +45,7 @@ #include "tqregexp.h" #include "tqvaluevector.h" #include "ntqshared.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" class TQSqlRecordPrivate { diff --git a/src/styles/qt_styles.pri b/src/styles/qt_styles.pri index b0daa8513..eedd54754 100644 --- a/src/styles/qt_styles.pri +++ b/src/styles/qt_styles.pri @@ -16,9 +16,9 @@ styles { x11|embedded|!macx-*:styles -= mac contains( styles, mac ) { - HEADERS +=$$STYLES_H/qmacstyle_mac.h \ - $$STYLES_H/qmacstylepixmaps_mac_p.h - SOURCES +=$$STYLES_CPP/qmacstyle_mac.cpp + HEADERS +=$$STYLES_H/tqmacstyle_mac.h \ + $$STYLES_H/tqmacstylepixmaps_mac_p.h + SOURCES +=$$STYLES_CPP/tqmacstyle_mac.cpp HEADERS *= $$STYLES_CPP/qaquastyle_p.h SOURCES *= $$STYLES_CPP/qaquastyle_p.cpp diff --git a/src/styles/tqcommonstyle.cpp b/src/styles/tqcommonstyle.cpp index 6158189d5..287bc5e8b 100644 --- a/src/styles/tqcommonstyle.cpp +++ b/src/styles/tqcommonstyle.cpp @@ -59,7 +59,7 @@ #include "tqdockarea.h" #include "tqheader.h" #include "tqspinbox.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #include "tqgroupbox.h" #include "tqslider.h" #include "tqlistview.h" @@ -170,7 +170,7 @@ static void tqt_style_control_element_data_null_cleanup() { TQStyleControlElementData_null =0; } -#include +#include // Keep in sync with duplicate definition in tqobject.cpp class TQStyleControlElementDataPrivate { diff --git a/src/styles/tqinterlacestyle.cpp b/src/styles/tqinterlacestyle.cpp index 8ddd55940..3c86f0638 100644 --- a/src/styles/tqinterlacestyle.cpp +++ b/src/styles/tqinterlacestyle.cpp @@ -52,7 +52,7 @@ #include "tqlabel.h" #include "tqpushbutton.h" #include "tqwidget.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #include "tqscrollbar.h" #include "tqlistbox.h" diff --git a/src/styles/tqstylefactory.cpp b/src/styles/tqstylefactory.cpp index 7a5706c64..29a3ad5ec 100644 --- a/src/styles/tqstylefactory.cpp +++ b/src/styles/tqstylefactory.cpp @@ -64,7 +64,7 @@ #if !defined( TQT_NO_STYLE_MAC ) && defined( TQ_WS_MAC ) TQString p2qstring(const unsigned char *c); //tqglobal.cpp #include "qt_mac.h" -#include "qmacstyle_mac.h" +#include "tqmacstyle_mac.h" #endif #include diff --git a/src/styles/tqwindowsstyle.cpp b/src/styles/tqwindowsstyle.cpp index 284da1617..03fc62dd5 100644 --- a/src/styles/tqwindowsstyle.cpp +++ b/src/styles/tqwindowsstyle.cpp @@ -54,7 +54,7 @@ #include "tqcombobox.h" #include "tqlistbox.h" #include "tqwidget.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #include "tqscrollbar.h" #include "tqslider.h" #include "tqtabwidget.h" diff --git a/src/tools/tqdatetime.h b/src/tools/tqdatetime.h index 545f1f56b..874246bf8 100644 --- a/src/tools/tqdatetime.h +++ b/src/tools/tqdatetime.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "tqstring.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #endif // QT_H #include diff --git a/src/tools/tqfeatures.txt b/src/tools/tqfeatures.txt index ef466fd36..d6a05abb4 100644 --- a/src/tools/tqfeatures.txt +++ b/src/tools/tqfeatures.txt @@ -988,7 +988,7 @@ SeeAlso: ??? Feature: MESSAGEBOX Section: Widgets Requires: DIALOG PUSHBUTTON LABEL -Name: QMessageBox +Name: TQMessageBox SeeAlso: ??? Feature: TABDIALOG @@ -1018,7 +1018,7 @@ SeeAlso: ??? Feature: PRINTDIALOG Section: Widgets Requires: DIALOG LISTVIEW PRINTER COMBOBOX LABEL BUTTONGROUP SPINBOX RADIOBUTTON PUSHBUTTON DIR -Name: QPrintDialog +Name: TQPrintDialog SeeAlso: ??? Feature: PROGRESSDIALOG diff --git a/src/tools/tqlocale.cpp b/src/tools/tqlocale.cpp index 57ddcfb3f..77f3cae19 100644 --- a/src/tools/tqlocale.cpp +++ b/src/tools/tqlocale.cpp @@ -45,7 +45,7 @@ #include "tqlocale.h" #include "tqlocale_p.h" -#include "ntqnamespace.h" +#include "tqnamespace.h" #ifdef QT_QLOCALE_USES_FCVT # include diff --git a/src/widgets/ntqrangecontrol.h b/src/widgets/ntqrangecontrol.h deleted file mode 100644 index 39f2e2abc..000000000 --- a/src/widgets/ntqrangecontrol.h +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** -** -** Definition of TQRangeControl class -** -** Created : 940427 -** -** 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 TQRANGECONTROL_H -#define TQRANGECONTROL_H - -#ifndef QT_H -#include "tqglobal.h" -#include "tqframe.h" -#endif // QT_H - -#ifndef TQT_NO_RANGECONTROL - - -class TQRangeControlPrivate; - - -class TQ_EXPORT TQRangeControl -{ -public: - TQRangeControl(); - TQRangeControl( int minValue, int maxValue, - int lineStep, int pageStep, int value ); - virtual ~TQRangeControl(); - int value() const; - void setValue( int ); - void addPage(); - void subtractPage(); - void addLine(); - void subtractLine(); - - int minValue() const; - int maxValue() const; - void setRange( int minValue, int maxValue ); - void setMinValue( int minVal ); - void setMaxValue( int minVal ); - - int lineStep() const; - int pageStep() const; - void setSteps( int line, int page ); - - int bound( int ) const; - -protected: - int positionFromValue( int val, int space ) const; - int valueFromPosition( int pos, int space ) const; - void directSetValue( int val ); - int prevValue() const; - - virtual void valueChange(); - virtual void rangeChange(); - virtual void stepChange(); - -private: - int minVal, maxVal; - int line, page; - int val, prevVal; - - TQRangeControlPrivate * d; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQRangeControl( const TQRangeControl & ); - TQRangeControl &operator=( const TQRangeControl & ); -#endif -}; - - -inline int TQRangeControl::value() const -{ return val; } - -inline int TQRangeControl::prevValue() const -{ return prevVal; } - -inline int TQRangeControl::minValue() const -{ return minVal; } - -inline int TQRangeControl::maxValue() const -{ return maxVal; } - -inline int TQRangeControl::lineStep() const -{ return line; } - -inline int TQRangeControl::pageStep() const -{ return page; } - - -#endif // TQT_NO_RANGECONTROL - -#ifndef TQT_NO_SPINWIDGET - -class TQSpinWidgetPrivate; -class TQ_EXPORT TQSpinWidget : public TQWidget -{ - TQ_OBJECT -public: - TQSpinWidget( TQWidget* parent=0, const char* name=0 ); - ~TQSpinWidget(); - - void setEditWidget( TQWidget * widget ); - TQWidget * editWidget(); - - TQRect upRect() const; - TQRect downRect() const; - - void setUpEnabled( bool on ); - void setDownEnabled( bool on ); - - bool isUpEnabled() const; - bool isDownEnabled() const; - - enum ButtonSymbols { UpDownArrows, PlusMinus }; - virtual void setButtonSymbols( ButtonSymbols bs ); - ButtonSymbols buttonSymbols() const; - - void arrange(); - -signals: - void stepUpPressed(); - void stepDownPressed(); - -public slots: - void stepUp(); - void stepDown(); - -protected: - void mousePressEvent( TQMouseEvent *e ); - void resizeEvent( TQResizeEvent* ev ); - void mouseReleaseEvent( TQMouseEvent *e ); - void mouseMoveEvent( TQMouseEvent *e ); -#ifndef TQT_NO_WHEELEVENT - void wheelEvent( TQWheelEvent * ); -#endif - void styleChange( TQStyle& ); - void paintEvent( TQPaintEvent * ); - void enableChanged( bool old ); - void windowActivationChange( bool ); - -private slots: - void timerDone(); - void timerDoneEx(); - -private: - TQSpinWidgetPrivate * d; - - void updateDisplay(); - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQSpinWidget( const TQSpinWidget& ); - TQSpinWidget& operator=( const TQSpinWidget& ); -#endif -}; - -#endif // TQT_NO_SPINWIDGET - -#endif // TQRANGECONTROL_H diff --git a/src/widgets/qeffects_p.h b/src/widgets/qeffects_p.h index d3beb3055..4d9845c01 100644 --- a/src/widgets/qeffects_p.h +++ b/src/widgets/qeffects_p.h @@ -56,7 +56,7 @@ // #ifndef QT_H -#include "ntqnamespace.h" +#include "tqnamespace.h" #endif // QT_H #ifndef TQT_NO_EFFECTS diff --git a/src/widgets/qrangecontrol.cpp b/src/widgets/qrangecontrol.cpp deleted file mode 100644 index 95056e578..000000000 --- a/src/widgets/qrangecontrol.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQRangeControl class -** -** Created : 940427 -** -** 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 "ntqrangecontrol.h" -#ifndef TQT_NO_RANGECONTROL -#include "tqglobal.h" -#include - -static bool sumOutOfRange(int current, int add); - - -/*! - \class TQRangeControl ntqrangecontrol.h - \brief The TQRangeControl class provides an integer value within a range. - - \ingroup misc - - Although originally designed for the TQScrollBar widget, the - TQRangeControl can also be used in conjunction with other widgets - such as TQSlider and TQSpinBox. Here are the five main concepts in - the class: - - \list 1 - - \i \e{Current value} The bounded integer that - TQRangeControl maintains. value() returns it, and several - functions, including setValue(), set it. - - \i \e{Minimum} The lowest value that value() can ever - return. Returned by minValue() and set by setRange() or one of the - constructors. - - \i \e{Maximum} The highest value that value() can ever - return. Returned by maxValue() and set by setRange() or one of the - constructors. - - \i \e{Line step} The smaller of two natural steps that - TQRangeControl provides and typically corresponds to the user - pressing an arrow key. The line step is returned by lineStep() - and set using setSteps(). The functions addLine() and - subtractLine() respectively increment and decrement the current - value by lineStep(). - - \i \e{Page step} The larger of two natural steps that - TQRangeControl provides and typically corresponds to the user - pressing PageUp or PageDown. The page step is returned by - pageStep() and set using setSteps(). The functions addPage() and - substractPage() respectively increment and decrement the current - value by pageStep(). - - \endlist - - Unity (1) may be viewed as a third step size. setValue() lets you - set the current value to any integer in the allowed range, not - just minValue() + \e n * lineStep() for integer values of \e n. - Some widgets may allow the user to set any value at all; others - may just provide multiples of lineStep() or pageStep(). - - TQRangeControl provides three virtual functions that are well - suited for updating the on-screen representation of range controls - and emitting signals: valueChange(), rangeChange() and - stepChange(). - - TQRangeControl also provides a function called bound() which lets - you force arbitrary integers to be within the allowed range of the - range control. - - We recommend that all widgets that inherit TQRangeControl provide - at least a signal called valueChanged(); many widgets will want to - provide addStep(), addPage(), substractStep() and substractPage() - as slots. - - Note that you must use multiple inheritance if you plan to - implement a widget using TQRangeControl because TQRangeControl is - not derived from TQWidget. -*/ - - -/*! - Constructs a range control with a minimum value of 0, maximum - value of 99, line step of 1, page step of 10 and initial value 0. -*/ - -TQRangeControl::TQRangeControl() -{ - minVal = 0; - maxVal = 99; - line = 1; - page = 10; - val = 0; - prevVal = -1; - d = 0; -} - -/*! - Constructs a range control whose value can never be smaller than - \a minValue or greater than \a maxValue, whose line step size is - \a lineStep and page step size is \a pageStep and whose value is - initially \a value (which is guaranteed to be in range using - bound()). -*/ - -TQRangeControl::TQRangeControl( int minValue, int maxValue, - int lineStep, int pageStep, - int value ) -{ - minVal = minValue; - maxVal = maxValue; - line = TQABS( lineStep ); - page = TQABS( pageStep ); - prevVal = minVal - 1; - val = bound( value ); - d = 0; -} - -/*! - Destroys the range control -*/ - -TQRangeControl::~TQRangeControl() -{ -} - - -/*! - \fn int TQRangeControl::value() const - - Returns the current range control value. This is guaranteed to be - within the range [minValue(), maxValue()]. - - \sa setValue() prevValue() -*/ - -/*! - \fn int TQRangeControl::prevValue() const - - Returns the previous value of the range control. "Previous value" - means the value before the last change occurred. Setting a new - range may affect the value, too, because the value is forced to be - inside the specified range. When the range control is initially - created, this is the same as value(). - - prevValue() can be outside the current legal range if a call to - setRange() causes the current value to change. For example, if the - range was [0, 1000] and the current value is 500, setRange(0, 400) - makes value() return 400 and prevValue() return 500. - - \sa value() setRange() -*/ - -/*! - Sets the range control's value to \a value and forces it to be - within the legal range. - - Calls the virtual valueChange() function if the new value is - different from the previous value. The old value can still be - retrieved using prevValue(). - - \sa value() -*/ - -void TQRangeControl::setValue( int value ) -{ - directSetValue( value ); - if ( prevVal != val ) - valueChange(); -} - -/*! - Sets the range control \a value directly without calling - valueChange(). - - Forces the new \a value to be within the legal range. - - You will rarely have to call this function. However, if you want - to change the range control's value inside the overloaded method - valueChange(), setValue() would call the function valueChange() - again. To avoid this recursion you must use directSetValue() - instead. - - \sa setValue() -*/ - -void TQRangeControl::directSetValue(int value) -{ - prevVal = val; - val = bound( value ); -} - -/*! - Equivalent to \c{setValue( value() + pageStep() )}. - - If the value is changed, then valueChange() is called. - - \sa subtractPage() addLine() setValue() -*/ - -void TQRangeControl::addPage() -{ - if (!sumOutOfRange(value(), pageStep())) - setValue(value() + pageStep()); -} - -/*! - Equivalent to \c{setValue( value() - pageStep() )}. - - If the value is changed, then valueChange() is called. - - \sa addPage() subtractLine() setValue() -*/ - -void TQRangeControl::subtractPage() -{ - if (!sumOutOfRange(value(), -pageStep())) - setValue(value() - pageStep()); -} - -/*! - Equivalent to \c{setValue( value() + lineStep() )}. - - If the value is changed, then valueChange() is called. - - \sa subtractLine() addPage() setValue() -*/ - -void TQRangeControl::addLine() -{ - if (!sumOutOfRange(value(), lineStep())) - setValue(value() + lineStep()); -} - -/*! - Equivalent to \c{setValue( value() - lineStep() )}. - - If the value is changed, then valueChange() is called. - - \sa addLine() subtractPage() setValue() -*/ - -void TQRangeControl::subtractLine() -{ - if (!sumOutOfRange(value(), -lineStep())) - setValue(value() - lineStep()); -} - - -/*! - \fn int TQRangeControl::minValue() const - - Returns the minimum value of the range. - - \sa setMinValue() setRange() maxValue() -*/ - -/*! - \fn int TQRangeControl::maxValue() const - - Returns the maximum value of the range. - - \sa setMaxValue() setRange() minValue() -*/ - -/*! - Sets the minimum value of the range to \a minVal. - - If necessary, the maxValue() is adjusted so that the range remains - valid. - - \sa minValue() setMaxValue() -*/ -void TQRangeControl::setMinValue( int minVal ) -{ - int maxVal = maxValue(); - if ( maxVal < minVal ) - maxVal = minVal; - setRange( minVal, maxVal ); -} - -/*! - Sets the minimum value of the range to \a maxVal. - - If necessary, the minValue() is adjusted so that the range remains - valid. - - \sa maxValue() setMinValue() -*/ -void TQRangeControl::setMaxValue( int maxVal ) -{ - int minVal = minValue(); - if ( minVal > maxVal ) - minVal = maxVal; - setRange( minVal, maxVal ); -} - -/*! - Sets the range control's minimum value to \a minValue and its - maximum value to \a maxValue. - - Calls the virtual rangeChange() function if one or both of the new - minimum and maximum values are different from the previous - setting. Calls the virtual valueChange() function if the current - value is adjusted because it was outside the new range. - - If \a maxValue is smaller than \a minValue, \a minValue becomes - the only legal value. - - \sa minValue() maxValue() -*/ - -void TQRangeControl::setRange( int minValue, int maxValue ) -{ - if ( minValue > maxValue ) { -#if defined(QT_CHECK_RANGE) - tqWarning( "TQRangeControl::setRange: minValue %d > maxValue %d", - minValue, maxValue ); -#endif - maxValue = minValue; - } - if ( minValue == minVal && maxValue == maxVal ) - return; - minVal = minValue; - maxVal = maxValue; - int tmp = bound( val ); - rangeChange(); - if ( tmp != val ) { - prevVal = val; - val = tmp; - valueChange(); - } -} - - -/*! - \fn int TQRangeControl::lineStep() const - - Returns the line step. - - \sa setSteps() pageStep() -*/ - -/*! - \fn int TQRangeControl::pageStep() const - - Returns the page step. - - \sa setSteps() lineStep() -*/ - -/*! - Sets the range's line step to \a lineStep and page step to \a - pageStep. - - Calls the virtual stepChange() function if the new line step - or page step are different from the previous settings. - - \sa lineStep() pageStep() setRange() -*/ - -void TQRangeControl::setSteps( int lineStep, int pageStep ) -{ - if ( lineStep != line || pageStep != page ) { - line = TQABS( lineStep ); - page = TQABS( pageStep ); - stepChange(); - } -} - - -/*! - This virtual function is called whenever the range control value - changes. You can reimplement it if you want to be notified when - the value changes. The default implementation does nothing. - - Note that this method is called after the value has changed. The - previous value can be retrieved using prevValue(). - - \sa setValue(), addPage(), subtractPage(), addLine(), - subtractLine() rangeChange(), stepChange() -*/ - -void TQRangeControl::valueChange() -{ -} - - -/*! - This virtual function is called whenever the range control's range - changes. You can reimplement it if you want to be notified when - the range changes. The default implementation does nothing. - - Note that this method is called after the range has changed. - - \sa setRange(), valueChange(), stepChange() -*/ - -void TQRangeControl::rangeChange() -{ -} - - -/*! - This virtual function is called whenever the range control's - line or page step settings change. You can reimplement it if you - want to be notified when the step changes. The default - implementation does nothing. - - Note that this method is called after a step setting has changed. - - \sa setSteps(), rangeChange(), valueChange() -*/ - -void TQRangeControl::stepChange() -{ -} - - -/*! - Forces the value \a v to be within the range from minValue() to - maxValue() inclusive, and returns the result. - - This function is provided so that you can easily force other - numbers than value() into the allowed range. You do not need to - call it in order to use TQRangeControl itself. - - \sa setValue() value() minValue() maxValue() -*/ - -int TQRangeControl::bound( int v ) const -{ - if ( v < minVal ) - return minVal; - if ( v > maxVal ) - return maxVal; - return v; -} - - -/*! - Converts \a logical_val to a pixel position. minValue() maps to 0, - maxValue() maps to \a span and other values are distributed evenly - in-between. - - This function can handle the entire integer range without - overflow, providing \a span is \<= 4096. - - Calling this method is useful when actually drawing a range - control such as a TQScrollBar on-screen. - - \sa valueFromPosition() -*/ - -int TQRangeControl::positionFromValue( int logical_val, int span ) const -{ - if ( span <= 0 || logical_val < minValue() || maxValue() <= minValue() ) - return 0; - if ( logical_val > maxValue() ) - return span; - - uint range = maxValue() - minValue(); - uint p = logical_val - minValue(); - - if ( range > (uint)INT_MAX/4096 ) { - const int scale = 4096*2; - return ( (p/scale) * span ) / (range/scale); - // ### the above line is probably not 100% correct - // ### but fixing it isn't worth the extreme pain... - } else if ( range > (uint)span ) { - return (2*p*span + range) / (2*range); - } else { - uint div = span / range; - uint mod = span % range; - return p*div + (2*p*mod + range) / (2*range); - } - //equiv. to (p*span)/range + 0.5 - // no overflow because of this implicit assumption: - // span <= 4096 -} - - -/*! - Converts the pixel position \a pos to a value. 0 maps to - minValue(), \a span maps to maxValue() and other values are - distributed evenly in-between. - - This function can handle the entire integer range without - overflow. - - Calling this method is useful if you actually implemented a range - control widget such as TQScrollBar and want to handle mouse press - events. This function then maps screen coordinates to the logical - values. - - \sa positionFromValue() -*/ - -int TQRangeControl::valueFromPosition( int pos, int span ) const -{ - if ( span <= 0 || pos <= 0 ) - return minValue(); - if ( pos >= span ) - return maxValue(); - - uint range = maxValue() - minValue(); - - if ( (uint)span > range ) - return minValue() + (2*pos*range + span) / (2*span); - else { - uint div = range / span; - uint mod = range % span; - return minValue() + pos*div + (2*pos*mod + span) / (2*span); - } - // equiv. to minValue() + (pos*range)/span + 0.5 - // no overflow because of this implicit assumption: - // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX) -} - -static bool sumOutOfRange(int current, int add) -{ - if (add > 0 && INT_MAX - add < current) { - return true; - } - if (add < 0 && INT_MIN - add > current) { - return true; - } - return false; -} - -#endif diff --git a/src/widgets/qt_widgets.pri b/src/widgets/qt_widgets.pri index 93acd0832..4d124e940 100644 --- a/src/widgets/qt_widgets.pri +++ b/src/widgets/qt_widgets.pri @@ -34,7 +34,7 @@ widgets { $$WIDGETS_H/tqprogressbar.h \ $$WIDGETS_H/tqpushbutton.h \ $$WIDGETS_H/tqradiobutton.h \ - $$WIDGETS_H/ntqrangecontrol.h \ + $$WIDGETS_H/tqrangecontrol.h \ $$WIDGETS_H/tqscrollbar.h \ $$WIDGETS_H/tqscrollview.h \ $$WIDGETS_H/tqslider.h \ @@ -96,7 +96,7 @@ widgets { $$WIDGETS_CPP/tqprogressbar.cpp \ $$WIDGETS_CPP/tqpushbutton.cpp \ $$WIDGETS_CPP/tqradiobutton.cpp \ - $$WIDGETS_CPP/qrangecontrol.cpp \ + $$WIDGETS_CPP/tqrangecontrol.cpp \ $$WIDGETS_CPP/tqscrollbar.cpp \ $$WIDGETS_CPP/tqscrollview.cpp \ $$WIDGETS_CPP/tqslider.cpp \ diff --git a/src/widgets/tqdatetimeedit.cpp b/src/widgets/tqdatetimeedit.cpp index 203d310de..6e32d3aaf 100644 --- a/src/widgets/tqdatetimeedit.cpp +++ b/src/widgets/tqdatetimeedit.cpp @@ -44,7 +44,7 @@ #include "../kernel/qinternal_p.h" #include "../kernel/qrichtext_p.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #include "ntqapplication.h" #include "tqpixmap.h" #include "ntqapplication.h" diff --git a/src/widgets/tqdial.h b/src/widgets/tqdial.h index 7baf98e53..ae3689705 100644 --- a/src/widgets/tqdial.h +++ b/src/widgets/tqdial.h @@ -44,7 +44,7 @@ #ifndef QT_H #include "tqwidget.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #endif // QT_H #ifndef TQT_NO_DIAL diff --git a/src/widgets/tqmenudata.cpp b/src/widgets/tqmenudata.cpp index 5a3872d31..148d79790 100644 --- a/src/widgets/tqmenudata.cpp +++ b/src/widgets/tqmenudata.cpp @@ -415,7 +415,7 @@ void TQMenuData::removePopup( TQPopupMenu *popup ) Returns the allocated menu identifier number (\a id if \a id >= 0). \sa removeItem(), changeItem(), setAccel(), connectItem(), TQAccel, - ntqnamespace.h + tqnamespace.h */ int TQMenuData::insertItem( const TQString &text, @@ -442,7 +442,7 @@ int TQMenuData::insertItem( const TQString &text, Returns the allocated menu identifier number (\a id if \a id >= 0). \sa removeItem(), changeItem(), setAccel(), connectItem(), TQAccel, - ntqnamespace.h + tqnamespace.h */ int TQMenuData::insertItem( const TQIconSet& icon, @@ -504,7 +504,7 @@ int TQMenuData::insertItem( const TQPixmap &pixmap, Returns the allocated menu identifier number (\a id if \a id >= 0). \sa removeItem(), changeItem(), setAccel(), connectItem(), TQAccel, - ntqnamespace.h + tqnamespace.h */ int TQMenuData::insertItem( const TQIconSet& icon, @@ -864,7 +864,7 @@ void TQMenuData::clear() item \a id, or 0 if it has no accelerator key or if there is no such menu item. - \sa setAccel(), TQAccel, ntqnamespace.h + \sa setAccel(), TQAccel, tqnamespace.h */ TQKeySequence TQMenuData::accel( int id ) const @@ -880,7 +880,7 @@ TQKeySequence TQMenuData::accel( int id ) const An accelerator key consists of a key code and a combination of the modifiers \c SHIFT, \c CTRL, \c ALT or \c UNICODE_ACCEL (OR'ed or - added). The header file \c ntqnamespace.h contains a list of key + added). The header file \c tqnamespace.h contains a list of key codes. Defining an accelerator key produces a text that is added to the diff --git a/src/widgets/tqrangecontrol.cpp b/src/widgets/tqrangecontrol.cpp new file mode 100644 index 000000000..03d9cecd0 --- /dev/null +++ b/src/widgets/tqrangecontrol.cpp @@ -0,0 +1,565 @@ +/**************************************************************************** +** +** Implementation of TQRangeControl class +** +** Created : 940427 +** +** 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 "tqrangecontrol.h" +#ifndef TQT_NO_RANGECONTROL +#include "tqglobal.h" +#include + +static bool sumOutOfRange(int current, int add); + + +/*! + \class TQRangeControl tqrangecontrol.h + \brief The TQRangeControl class provides an integer value within a range. + + \ingroup misc + + Although originally designed for the TQScrollBar widget, the + TQRangeControl can also be used in conjunction with other widgets + such as TQSlider and TQSpinBox. Here are the five main concepts in + the class: + + \list 1 + + \i \e{Current value} The bounded integer that + TQRangeControl maintains. value() returns it, and several + functions, including setValue(), set it. + + \i \e{Minimum} The lowest value that value() can ever + return. Returned by minValue() and set by setRange() or one of the + constructors. + + \i \e{Maximum} The highest value that value() can ever + return. Returned by maxValue() and set by setRange() or one of the + constructors. + + \i \e{Line step} The smaller of two natural steps that + TQRangeControl provides and typically corresponds to the user + pressing an arrow key. The line step is returned by lineStep() + and set using setSteps(). The functions addLine() and + subtractLine() respectively increment and decrement the current + value by lineStep(). + + \i \e{Page step} The larger of two natural steps that + TQRangeControl provides and typically corresponds to the user + pressing PageUp or PageDown. The page step is returned by + pageStep() and set using setSteps(). The functions addPage() and + substractPage() respectively increment and decrement the current + value by pageStep(). + + \endlist + + Unity (1) may be viewed as a third step size. setValue() lets you + set the current value to any integer in the allowed range, not + just minValue() + \e n * lineStep() for integer values of \e n. + Some widgets may allow the user to set any value at all; others + may just provide multiples of lineStep() or pageStep(). + + TQRangeControl provides three virtual functions that are well + suited for updating the on-screen representation of range controls + and emitting signals: valueChange(), rangeChange() and + stepChange(). + + TQRangeControl also provides a function called bound() which lets + you force arbitrary integers to be within the allowed range of the + range control. + + We recommend that all widgets that inherit TQRangeControl provide + at least a signal called valueChanged(); many widgets will want to + provide addStep(), addPage(), substractStep() and substractPage() + as slots. + + Note that you must use multiple inheritance if you plan to + implement a widget using TQRangeControl because TQRangeControl is + not derived from TQWidget. +*/ + + +/*! + Constructs a range control with a minimum value of 0, maximum + value of 99, line step of 1, page step of 10 and initial value 0. +*/ + +TQRangeControl::TQRangeControl() +{ + minVal = 0; + maxVal = 99; + line = 1; + page = 10; + val = 0; + prevVal = -1; + d = 0; +} + +/*! + Constructs a range control whose value can never be smaller than + \a minValue or greater than \a maxValue, whose line step size is + \a lineStep and page step size is \a pageStep and whose value is + initially \a value (which is guaranteed to be in range using + bound()). +*/ + +TQRangeControl::TQRangeControl( int minValue, int maxValue, + int lineStep, int pageStep, + int value ) +{ + minVal = minValue; + maxVal = maxValue; + line = TQABS( lineStep ); + page = TQABS( pageStep ); + prevVal = minVal - 1; + val = bound( value ); + d = 0; +} + +/*! + Destroys the range control +*/ + +TQRangeControl::~TQRangeControl() +{ +} + + +/*! + \fn int TQRangeControl::value() const + + Returns the current range control value. This is guaranteed to be + within the range [minValue(), maxValue()]. + + \sa setValue() prevValue() +*/ + +/*! + \fn int TQRangeControl::prevValue() const + + Returns the previous value of the range control. "Previous value" + means the value before the last change occurred. Setting a new + range may affect the value, too, because the value is forced to be + inside the specified range. When the range control is initially + created, this is the same as value(). + + prevValue() can be outside the current legal range if a call to + setRange() causes the current value to change. For example, if the + range was [0, 1000] and the current value is 500, setRange(0, 400) + makes value() return 400 and prevValue() return 500. + + \sa value() setRange() +*/ + +/*! + Sets the range control's value to \a value and forces it to be + within the legal range. + + Calls the virtual valueChange() function if the new value is + different from the previous value. The old value can still be + retrieved using prevValue(). + + \sa value() +*/ + +void TQRangeControl::setValue( int value ) +{ + directSetValue( value ); + if ( prevVal != val ) + valueChange(); +} + +/*! + Sets the range control \a value directly without calling + valueChange(). + + Forces the new \a value to be within the legal range. + + You will rarely have to call this function. However, if you want + to change the range control's value inside the overloaded method + valueChange(), setValue() would call the function valueChange() + again. To avoid this recursion you must use directSetValue() + instead. + + \sa setValue() +*/ + +void TQRangeControl::directSetValue(int value) +{ + prevVal = val; + val = bound( value ); +} + +/*! + Equivalent to \c{setValue( value() + pageStep() )}. + + If the value is changed, then valueChange() is called. + + \sa subtractPage() addLine() setValue() +*/ + +void TQRangeControl::addPage() +{ + if (!sumOutOfRange(value(), pageStep())) + setValue(value() + pageStep()); +} + +/*! + Equivalent to \c{setValue( value() - pageStep() )}. + + If the value is changed, then valueChange() is called. + + \sa addPage() subtractLine() setValue() +*/ + +void TQRangeControl::subtractPage() +{ + if (!sumOutOfRange(value(), -pageStep())) + setValue(value() - pageStep()); +} + +/*! + Equivalent to \c{setValue( value() + lineStep() )}. + + If the value is changed, then valueChange() is called. + + \sa subtractLine() addPage() setValue() +*/ + +void TQRangeControl::addLine() +{ + if (!sumOutOfRange(value(), lineStep())) + setValue(value() + lineStep()); +} + +/*! + Equivalent to \c{setValue( value() - lineStep() )}. + + If the value is changed, then valueChange() is called. + + \sa addLine() subtractPage() setValue() +*/ + +void TQRangeControl::subtractLine() +{ + if (!sumOutOfRange(value(), -lineStep())) + setValue(value() - lineStep()); +} + + +/*! + \fn int TQRangeControl::minValue() const + + Returns the minimum value of the range. + + \sa setMinValue() setRange() maxValue() +*/ + +/*! + \fn int TQRangeControl::maxValue() const + + Returns the maximum value of the range. + + \sa setMaxValue() setRange() minValue() +*/ + +/*! + Sets the minimum value of the range to \a minVal. + + If necessary, the maxValue() is adjusted so that the range remains + valid. + + \sa minValue() setMaxValue() +*/ +void TQRangeControl::setMinValue( int minVal ) +{ + int maxVal = maxValue(); + if ( maxVal < minVal ) + maxVal = minVal; + setRange( minVal, maxVal ); +} + +/*! + Sets the minimum value of the range to \a maxVal. + + If necessary, the minValue() is adjusted so that the range remains + valid. + + \sa maxValue() setMinValue() +*/ +void TQRangeControl::setMaxValue( int maxVal ) +{ + int minVal = minValue(); + if ( minVal > maxVal ) + minVal = maxVal; + setRange( minVal, maxVal ); +} + +/*! + Sets the range control's minimum value to \a minValue and its + maximum value to \a maxValue. + + Calls the virtual rangeChange() function if one or both of the new + minimum and maximum values are different from the previous + setting. Calls the virtual valueChange() function if the current + value is adjusted because it was outside the new range. + + If \a maxValue is smaller than \a minValue, \a minValue becomes + the only legal value. + + \sa minValue() maxValue() +*/ + +void TQRangeControl::setRange( int minValue, int maxValue ) +{ + if ( minValue > maxValue ) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQRangeControl::setRange: minValue %d > maxValue %d", + minValue, maxValue ); +#endif + maxValue = minValue; + } + if ( minValue == minVal && maxValue == maxVal ) + return; + minVal = minValue; + maxVal = maxValue; + int tmp = bound( val ); + rangeChange(); + if ( tmp != val ) { + prevVal = val; + val = tmp; + valueChange(); + } +} + + +/*! + \fn int TQRangeControl::lineStep() const + + Returns the line step. + + \sa setSteps() pageStep() +*/ + +/*! + \fn int TQRangeControl::pageStep() const + + Returns the page step. + + \sa setSteps() lineStep() +*/ + +/*! + Sets the range's line step to \a lineStep and page step to \a + pageStep. + + Calls the virtual stepChange() function if the new line step + or page step are different from the previous settings. + + \sa lineStep() pageStep() setRange() +*/ + +void TQRangeControl::setSteps( int lineStep, int pageStep ) +{ + if ( lineStep != line || pageStep != page ) { + line = TQABS( lineStep ); + page = TQABS( pageStep ); + stepChange(); + } +} + + +/*! + This virtual function is called whenever the range control value + changes. You can reimplement it if you want to be notified when + the value changes. The default implementation does nothing. + + Note that this method is called after the value has changed. The + previous value can be retrieved using prevValue(). + + \sa setValue(), addPage(), subtractPage(), addLine(), + subtractLine() rangeChange(), stepChange() +*/ + +void TQRangeControl::valueChange() +{ +} + + +/*! + This virtual function is called whenever the range control's range + changes. You can reimplement it if you want to be notified when + the range changes. The default implementation does nothing. + + Note that this method is called after the range has changed. + + \sa setRange(), valueChange(), stepChange() +*/ + +void TQRangeControl::rangeChange() +{ +} + + +/*! + This virtual function is called whenever the range control's + line or page step settings change. You can reimplement it if you + want to be notified when the step changes. The default + implementation does nothing. + + Note that this method is called after a step setting has changed. + + \sa setSteps(), rangeChange(), valueChange() +*/ + +void TQRangeControl::stepChange() +{ +} + + +/*! + Forces the value \a v to be within the range from minValue() to + maxValue() inclusive, and returns the result. + + This function is provided so that you can easily force other + numbers than value() into the allowed range. You do not need to + call it in order to use TQRangeControl itself. + + \sa setValue() value() minValue() maxValue() +*/ + +int TQRangeControl::bound( int v ) const +{ + if ( v < minVal ) + return minVal; + if ( v > maxVal ) + return maxVal; + return v; +} + + +/*! + Converts \a logical_val to a pixel position. minValue() maps to 0, + maxValue() maps to \a span and other values are distributed evenly + in-between. + + This function can handle the entire integer range without + overflow, providing \a span is \<= 4096. + + Calling this method is useful when actually drawing a range + control such as a TQScrollBar on-screen. + + \sa valueFromPosition() +*/ + +int TQRangeControl::positionFromValue( int logical_val, int span ) const +{ + if ( span <= 0 || logical_val < minValue() || maxValue() <= minValue() ) + return 0; + if ( logical_val > maxValue() ) + return span; + + uint range = maxValue() - minValue(); + uint p = logical_val - minValue(); + + if ( range > (uint)INT_MAX/4096 ) { + const int scale = 4096*2; + return ( (p/scale) * span ) / (range/scale); + // ### the above line is probably not 100% correct + // ### but fixing it isn't worth the extreme pain... + } else if ( range > (uint)span ) { + return (2*p*span + range) / (2*range); + } else { + uint div = span / range; + uint mod = span % range; + return p*div + (2*p*mod + range) / (2*range); + } + //equiv. to (p*span)/range + 0.5 + // no overflow because of this implicit assumption: + // span <= 4096 +} + + +/*! + Converts the pixel position \a pos to a value. 0 maps to + minValue(), \a span maps to maxValue() and other values are + distributed evenly in-between. + + This function can handle the entire integer range without + overflow. + + Calling this method is useful if you actually implemented a range + control widget such as TQScrollBar and want to handle mouse press + events. This function then maps screen coordinates to the logical + values. + + \sa positionFromValue() +*/ + +int TQRangeControl::valueFromPosition( int pos, int span ) const +{ + if ( span <= 0 || pos <= 0 ) + return minValue(); + if ( pos >= span ) + return maxValue(); + + uint range = maxValue() - minValue(); + + if ( (uint)span > range ) + return minValue() + (2*pos*range + span) / (2*span); + else { + uint div = range / span; + uint mod = range % span; + return minValue() + pos*div + (2*pos*mod + span) / (2*span); + } + // equiv. to minValue() + (pos*range)/span + 0.5 + // no overflow because of this implicit assumption: + // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX) +} + +static bool sumOutOfRange(int current, int add) +{ + if (add > 0 && INT_MAX - add < current) { + return true; + } + if (add < 0 && INT_MIN - add > current) { + return true; + } + return false; +} + +#endif diff --git a/src/widgets/tqrangecontrol.h b/src/widgets/tqrangecontrol.h new file mode 100644 index 000000000..39f2e2abc --- /dev/null +++ b/src/widgets/tqrangecontrol.h @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Definition of TQRangeControl class +** +** Created : 940427 +** +** 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 TQRANGECONTROL_H +#define TQRANGECONTROL_H + +#ifndef QT_H +#include "tqglobal.h" +#include "tqframe.h" +#endif // QT_H + +#ifndef TQT_NO_RANGECONTROL + + +class TQRangeControlPrivate; + + +class TQ_EXPORT TQRangeControl +{ +public: + TQRangeControl(); + TQRangeControl( int minValue, int maxValue, + int lineStep, int pageStep, int value ); + virtual ~TQRangeControl(); + int value() const; + void setValue( int ); + void addPage(); + void subtractPage(); + void addLine(); + void subtractLine(); + + int minValue() const; + int maxValue() const; + void setRange( int minValue, int maxValue ); + void setMinValue( int minVal ); + void setMaxValue( int minVal ); + + int lineStep() const; + int pageStep() const; + void setSteps( int line, int page ); + + int bound( int ) const; + +protected: + int positionFromValue( int val, int space ) const; + int valueFromPosition( int pos, int space ) const; + void directSetValue( int val ); + int prevValue() const; + + virtual void valueChange(); + virtual void rangeChange(); + virtual void stepChange(); + +private: + int minVal, maxVal; + int line, page; + int val, prevVal; + + TQRangeControlPrivate * d; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQRangeControl( const TQRangeControl & ); + TQRangeControl &operator=( const TQRangeControl & ); +#endif +}; + + +inline int TQRangeControl::value() const +{ return val; } + +inline int TQRangeControl::prevValue() const +{ return prevVal; } + +inline int TQRangeControl::minValue() const +{ return minVal; } + +inline int TQRangeControl::maxValue() const +{ return maxVal; } + +inline int TQRangeControl::lineStep() const +{ return line; } + +inline int TQRangeControl::pageStep() const +{ return page; } + + +#endif // TQT_NO_RANGECONTROL + +#ifndef TQT_NO_SPINWIDGET + +class TQSpinWidgetPrivate; +class TQ_EXPORT TQSpinWidget : public TQWidget +{ + TQ_OBJECT +public: + TQSpinWidget( TQWidget* parent=0, const char* name=0 ); + ~TQSpinWidget(); + + void setEditWidget( TQWidget * widget ); + TQWidget * editWidget(); + + TQRect upRect() const; + TQRect downRect() const; + + void setUpEnabled( bool on ); + void setDownEnabled( bool on ); + + bool isUpEnabled() const; + bool isDownEnabled() const; + + enum ButtonSymbols { UpDownArrows, PlusMinus }; + virtual void setButtonSymbols( ButtonSymbols bs ); + ButtonSymbols buttonSymbols() const; + + void arrange(); + +signals: + void stepUpPressed(); + void stepDownPressed(); + +public slots: + void stepUp(); + void stepDown(); + +protected: + void mousePressEvent( TQMouseEvent *e ); + void resizeEvent( TQResizeEvent* ev ); + void mouseReleaseEvent( TQMouseEvent *e ); + void mouseMoveEvent( TQMouseEvent *e ); +#ifndef TQT_NO_WHEELEVENT + void wheelEvent( TQWheelEvent * ); +#endif + void styleChange( TQStyle& ); + void paintEvent( TQPaintEvent * ); + void enableChanged( bool old ); + void windowActivationChange( bool ); + +private slots: + void timerDone(); + void timerDoneEx(); + +private: + TQSpinWidgetPrivate * d; + + void updateDisplay(); + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQSpinWidget( const TQSpinWidget& ); + TQSpinWidget& operator=( const TQSpinWidget& ); +#endif +}; + +#endif // TQT_NO_SPINWIDGET + +#endif // TQRANGECONTROL_H diff --git a/src/widgets/tqscrollbar.h b/src/widgets/tqscrollbar.h index 6a298c96f..d5cc1a502 100644 --- a/src/widgets/tqscrollbar.h +++ b/src/widgets/tqscrollbar.h @@ -45,7 +45,7 @@ class TQTimer; #ifndef QT_H #include "tqwidget.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #endif // QT_H #ifndef TQT_NO_SCROLLBAR diff --git a/src/widgets/tqslider.h b/src/widgets/tqslider.h index af60245e3..1ce9883ef 100644 --- a/src/widgets/tqslider.h +++ b/src/widgets/tqslider.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "tqwidget.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #endif // QT_H #ifndef TQT_NO_SLIDER diff --git a/src/widgets/tqspinbox.h b/src/widgets/tqspinbox.h index 345857c74..390c6bbd2 100644 --- a/src/widgets/tqspinbox.h +++ b/src/widgets/tqspinbox.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "tqwidget.h" -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #endif // QT_H #ifndef TQT_NO_SPINBOX diff --git a/src/widgets/tqspinwidget.cpp b/src/widgets/tqspinwidget.cpp index a66e90d1d..893fa0f0c 100644 --- a/src/widgets/tqspinwidget.cpp +++ b/src/widgets/tqspinwidget.cpp @@ -36,7 +36,7 @@ ** **********************************************************************/ -#include "ntqrangecontrol.h" +#include "tqrangecontrol.h" #ifndef TQT_NO_SPINWIDGET diff --git a/src/widgets/tqtabbar.cpp b/src/widgets/tqtabbar.cpp index 140473e6a..7c9ebb2c4 100644 --- a/src/widgets/tqtabbar.cpp +++ b/src/widgets/tqtabbar.cpp @@ -53,7 +53,7 @@ #endif #ifdef TQ_WS_MACX -#include +#include #endif diff --git a/src/widgets/tqtabwidget.cpp b/src/widgets/tqtabwidget.cpp index fdf857050..88ec8a06e 100644 --- a/src/widgets/tqtabwidget.cpp +++ b/src/widgets/tqtabwidget.cpp @@ -51,7 +51,7 @@ #include "tqtoolbutton.h" #ifdef Q_OS_MACX -#include +#include #endif /*! diff --git a/src/widgets/tqtextedit.cpp b/src/widgets/tqtextedit.cpp index 54dc1b2db..2c8bf3ba4 100644 --- a/src/widgets/tqtextedit.cpp +++ b/src/widgets/tqtextedit.cpp @@ -72,7 +72,7 @@ #include "tqregexp.h" #include "tqpopupmenu.h" #include "tqptrstack.h" -#include "ntqmetaobject.h" +#include "tqmetaobject.h" #include "tqtextbrowser.h" #include #include "private/tqsyntaxhighlighter_p.h" -- cgit v1.2.3