From be74b66794d3148c926f079eb2595ae0d78b6522 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 24 Jul 2011 03:10:43 -0500 Subject: [PATCH] Remove temporary files from source tree --- tqtinterface/qt4/include/tqtglobaldefines.h~ | 492 -- .../qt4/src/kernel/tqapplication.cpp~ | 5499 ----------------- tqtinterface/qt4/src/kernel/tqapplication.h~ | 724 --- tqtinterface/qt4/src/kernel/tqmetaobject.cpp~ | 1792 ------ tqtinterface/qt4/src/kernel/tqmetaobject.h~ | 403 -- tqtinterface/qt4/src/kernel/tqpainter.cpp~ | 5161 ---------------- tqtinterface/qt4/src/kernel/tqpainter.h~ | 993 --- tqtinterface/qt4/src/kernel/tqwmatrix.cpp~ | 1204 ---- tqtinterface/qt4/src/kernel/tqwmatrix.h~ | 193 - tqtinterface/qt4/src/tools/tqbuffer.h~ | 219 - tqtinterface/qt4/src/tools/tqiodevice.h~ | 310 - 11 files changed, 16990 deletions(-) delete mode 100644 tqtinterface/qt4/include/tqtglobaldefines.h~ delete mode 100644 tqtinterface/qt4/src/kernel/tqapplication.cpp~ delete mode 100644 tqtinterface/qt4/src/kernel/tqapplication.h~ delete mode 100644 tqtinterface/qt4/src/kernel/tqmetaobject.cpp~ delete mode 100644 tqtinterface/qt4/src/kernel/tqmetaobject.h~ delete mode 100644 tqtinterface/qt4/src/kernel/tqpainter.cpp~ delete mode 100644 tqtinterface/qt4/src/kernel/tqpainter.h~ delete mode 100644 tqtinterface/qt4/src/kernel/tqwmatrix.cpp~ delete mode 100644 tqtinterface/qt4/src/kernel/tqwmatrix.h~ delete mode 100644 tqtinterface/qt4/src/tools/tqbuffer.h~ delete mode 100644 tqtinterface/qt4/src/tools/tqiodevice.h~ diff --git a/tqtinterface/qt4/include/tqtglobaldefines.h~ b/tqtinterface/qt4/include/tqtglobaldefines.h~ deleted file mode 100644 index 6c023a8..0000000 --- a/tqtinterface/qt4/include/tqtglobaldefines.h~ +++ /dev/null @@ -1,492 +0,0 @@ -#ifndef TQTGLOBALDEFINES_H -#define TQTGLOBALDEFINES_H - -#include "tqtglobalsettings.h" - -// #ifdef USE_QT4 -// #define QT3_SUPPORT -// #endif -// -#ifdef USE_QT4 - -#include -#include -#include - -#ifdef QT_NO_TRANSLATION -#define TQT_NO_TRANSLATION -#endif // QT_NO_TRANSLATION - -#ifdef QT_THREAD_SUPPORT -#define TQT_THREAD_SUPPORT -#endif // QT_THREAD_SUPPORT - -// #define tqqt_cast qobject_cast - -// Mark certain Qt3 static variables squarely OFF LIMITS -#define qt_x_time "Usage of the qt_x_time static variable is strongly deprecated in TQt, and is unavailable in TQt for Qt4. Use GET_QT_X_TIME/SET_QT_X_TIME instead" -#define qt_x_user_time "Usage of the qt_x_time static variable is strongly deprecated in TQt, and is unavailable in TQt for Qt4. Use GET_QT_X_USER_TIME/SET_QT_X_USER_TIME instead" - -// #define TQT_TQOBJECT(x) (static_cast(static_cast(x))) -#define TQT_TQOBJECT(x) (convertFromTQT_BASE_OBJECT_NAMEPointer(x)) -#define TQT_TQWIDGET(x) TQWidget::tqt_ensure_valid_widget_painting(static_cast(static_cast(static_cast(x)))) -#define TQT_TQSIZEPOLICY(x) (static_cast(static_cast(x))) -#define TQT_TQLAYOUT(x) (static_cast(static_cast(x))) -#define TQT_TQGRIDLAYOUT(x) (static_cast(static_cast(x))) -#define TQT_TQPAINTER(x) (static_cast(static_cast(x))) -#define TQT_TQPAINTDEVICE(x) (static_cast(static_cast(x))) -#define TQT_TQLAYOUTITEM(x) (static_cast(static_cast(x))) -#define TQT_TQIODEVICE(x) (static_cast(static_cast(x))) -#define TQT_TQCOLOR(x) (static_cast(static_cast(x))) -#define TQT_TQCHAR(x) TQChar(x) -#define TQT_TQSTRING(x) TQString(x) -#define TQT_TQPOINT(x) (static_cast(static_cast(x))) -#define TQT_TQBUFFER(x) (static_cast(static_cast(x))) -#define TQT_TQWMATRIX(x) (static_cast(static_cast(x))) -#define TQT_TQFILE(x) (static_cast(static_cast(x))) -#define TQT_TQBYTEARRAY(x) (static_cast(static_cast(x))) -#define TQT_TQMIMESOURCE(x) (static_cast(static_cast(x))) -#define TQT_TQWEXTRA(x) (static_cast(static_cast(x))) -#define TQT_TQPIXMAP(x) (static_cast(static_cast(x))) -#define TQT_TQCLIPBOARD(x) (static_cast(static_cast(x))) -#define TQT_TQPRINTER(x) (static_cast(static_cast(x))) -#define TQT_TQVARIANT(x) (static_cast(static_cast(x))) -#define TQT_TQMETAOBJECT(x) (static_cast(static_cast(x))) -#define TQT_TQSTYLEOPTION(x) (static_cast(static_cast(x))) -#define TQT_TQEVENT(x) (static_cast(static_cast(x))) -#define TQT_TQKEYEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQSHOWEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQMOUSEEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQWHEELEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQFOCUSEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQPAINTEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQCHILDEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQCLOSEEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQTIMEREVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQRESIZEEVENT(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQCONTEXTMENUEVENT(x) (static_cast(static_cast(static_cast(x)))) - -#define TQT_TQOBJECT_OBJECT(x) (convertFromTQT_BASE_OBJECT_NAME(x)) -#define TQT_TQSIZEPOLICY_OBJECT(x) (convertFromQSizePolicy(x)) -#define TQT_TQLAYOUT_OBJECT(x) (convertFromQLayout(x)) -#define TQT_TQCOLOR_OBJECT(x) (convertFromQColor(x)) -#define TQT_TQSTRING_OBJECT(x) (convertFromQString(x)) -#define TQT_TQSTRLIST_OBJECT(x) (convertFromQStrList(x)) -#define TQT_TQSTRINGLIST_OBJECT(x) (TQStringList::convertFromQStringList(x)) -#define TQT_TQWMATRIX_OBJECT(x) (convertFromQMatrix(x)) -#define TQT_TQRECT_OBJECT(x) TQRect(x) -#define TQT_TQBYTEARRAY_OBJECT(x) (convertFromQByteArray(x)) -#define TQT_TQPIXMAP_OBJECT(x) (convertFromQPixmap(x)) -#define TQT_TQTIME_OBJECT(x) (TQTime::convertFromQTime(x)) -#define TQT_TQDATE_OBJECT(x) (TQDate::convertFromQDate(x)) -#define TQT_TQDATETIME_OBJECT(x) (TQDateTime::convertFromQDateTime(x)) -#define TQT_TQBRUSH_OBJECT(x) (convertFromQBrush(x)) -#define TQT_TQPALETTE_OBJECT(x) (convertFromQPalette(x)) -#define TQT_TQPOINT_OBJECT(x) (convertFromQPoint(x)) -#define TQT_TQREGION_OBJECT(x) (convertFromQRegion(x)) -#define TQT_TQIMAGE_OBJECT(x) (convertFromQImage(x)) -#define TQT_TQPAINTDEVICE_OBJECT(x) (convertFromQPaintDevice(x)) -#define TQT_TQVARIANT_OBJECT(x) (convertFromQVariant(x)) -#define TQT_TQIODEVICE_OBJECT(x) (convertFromQIODevice(x)) -#define TQT_TQSESSIONMANAGER_OBJECT(x) (convertFromQSessionManager(x)) -#define TQT_TQSTYLEOPTION_OBJECT(x) (TQStyleOption(x)) - -// #define TQT_TQOBJECT_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQOBJECT_CONST(x) (convertFromTQT_BASE_OBJECT_NAMEPointerConst(x)) -#define TQT_TQWIDGET_CONST(x) (static_cast(static_cast(static_cast(x)))) -#define TQT_TQMIMESOURCE_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQPOINT_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQBRUSH_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQPIXMAP_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQPAINTDEVICE_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQCOLOR_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQPRINTER_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQIODEVICE_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQVARIANT_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQMETAOBJECT_CONST(x) (static_cast(static_cast(x))) -#define TQT_TQSTYLEOPTION_CONST(x) (static_cast(static_cast(x))) - -#define TQPOINT_OBJECT_NAME_STRING "TQPoint" -#define TQBYTEARRAY_OBJECT_NAME_STRING "TQByteArray" -#define TQPIXMAP_OBJECT_NAME_STRING "TQPixmap" -#define TQSTRING_OBJECT_NAME_STRING "TQString" -#define TQSTRINGLIST_OBJECT_NAME_STRING "TQStringList" -#define TQLAYOUT_OBJECT_NAME_STRING "TQLayout" -#define TQBOXLAYOUT_OBJECT_NAME_STRING "TQBoxLayout" -#define TQHBOXLAYOUT_OBJECT_NAME_STRING "TQHBoxLayout" -#define TQVBOXLAYOUT_OBJECT_NAME_STRING "TQVBoxLayout" -#define TQGRIDLAYOUT_OBJECT_NAME_STRING "TQGridLayout" -#define TQHBOX_OBJECT_NAME_STRING "TQHBox" -#define TQVBOX_OBJECT_NAME_STRING "TQVBox" -#define TQGRID_OBJECT_NAME_STRING "TQGrid" -#define TQTABWIDGET_OBJECT_NAME_STRING "TQTabWidget" -#define TQCHECKBOX_OBJECT_NAME_STRING "TQCheckBox" -#define TQLINEEDIT_OBJECT_NAME_STRING "TQLineEdit" -#define TQTEXTEDIT_OBJECT_NAME_STRING "TQTextEdit" -#define TQOBJECT_OBJECT_NAME_STRING "TQObject" -#define TQWIDGET_OBJECT_NAME_STRING "TQWidget" -#define TQGLWIDGET_OBJECT_NAME_STRING "TQGLWidget" -#define TQLABEL_OBJECT_NAME_STRING "TQLabel" -#define TQTIMER_OBJECT_NAME_STRING "TQTimer" -#define TQFRAME_OBJECT_NAME_STRING "TQFrame" -#define TQACCEL_OBJECT_NAME_STRING "TQAccel" -#define TQDIALOG_OBJECT_NAME_STRING "TQDialog" -#define TQDIAL_OBJECT_NAME_STRING "TQDial" -#define TQACTION_OBJECT_NAME_STRING "TQAction" -#define TQACTIONGROUP_OBJECT_NAME_STRING "TQActionGroup" -#define TQLCDNUMBER_OBJECT_NAME_STRING "TQLCDNumber" -#define TQPROGRESSBAR_OBJECT_NAME_STRING "TQProgressBar" -#define TQTABDIALOG_OBJECT_NAME_STRING "TQTabDialog" -#define TQTABWIDGET_OBJECT_NAME_STRING "TQTabWidget" -#define TQDOCKWINDOW_OBJECT_NAME_STRING "TQDockWindow" -#define TQGROUPBOX_OBJECT_NAME_STRING "TQGroupBox" -#define TQCOMBOBOX_OBJECT_NAME_STRING "TQComboBox" -#define TQSPINBOX_OBJECT_NAME_STRING "TQSpinBox" -#define TQSPINWIDGET_OBJECT_NAME_STRING "TQSpinWidget" -#define TQLISTBOX_OBJECT_NAME_STRING "TQListBox" -#define TQTOOLBOX_OBJECT_NAME_STRING "TQToolBox" -#define TQTOOLBOXBUTTON_OBJECT_NAME_STRING "TQToolBoxButton" -#define TQVGROUPBOX_OBJECT_NAME_STRING "TQVGroupBox" -#define TQSPLITTER_OBJECT_NAME_STRING "TQSplitter" -#define TQSPLITTERHANDLE_OBJECT_NAME_STRING "TQSplitterHandle" -#define TQBUTTON_OBJECT_NAME_STRING "TQButton" -#define TQGRIDVIEW_OBJECT_NAME_STRING "TQGridView" -#define TQSLIDER_OBJECT_NAME_STRING "TQSlider" -#define TQPUSHBUTTON_OBJECT_NAME_STRING "TQPushButton" -#define TQTOOLBUTTON_OBJECT_NAME_STRING "TQToolButton" -#define TQRADIOBUTTON_OBJECT_NAME_STRING "TQRadioButton" -#define TQPOPUPMENU_OBJECT_NAME_STRING "TQPopupMenu" -#define TQTOOLBAR_OBJECT_NAME_STRING "TQToolBar" -#define TQMENUBAR_OBJECT_NAME_STRING "TQMenuBar" -#define TQTABBAR_OBJECT_NAME_STRING "TQTabBar" -#define TQLISTVIEW_OBJECT_NAME_STRING "TQListView" -#define TQSCROLLBAR_OBJECT_NAME_STRING "TQScrollBar" -#define TQSCROLLVIEW_OBJECT_NAME_STRING "TQScrollView" -#define TQRANGECONTROL_OBJECT_NAME_STRING "TQRangeControl" -#define TQCANVASITEM_OBJECT_NAME_STRING "TQCanvasItem" -#define TQICONVIEW_OBJECT_NAME_STRING "TQIconView" -#define TQMULTILINEEDIT_OBJECT_NAME_STRING "TQMultiLineEdit" -#define TQINTVALIDATOR_OBJECT_NAME_STRING "TQIntValidator" -#define TQDATEEDIT_OBJECT_NAME_STRING "TQDateEdit" -#define TQTIMEEDIT_OBJECT_NAME_STRING "TQTimeEdit" -#define TQDATETIMEEDIT_OBJECT_NAME_STRING "TQDateTimeEdit" -#define TQHEADER_OBJECT_NAME_STRING "TQHeader" -#define TQSIZEGRIP_OBJECT_NAME_STRING "TQSizeGrip" -#define TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING "TQDockWindowHandle" -#define TQHIDEDOCK_OBJECT_NAME_STRING "TQHideDock" -#define TQTABLE_OBJECT_NAME_STRING "TQTable" -#define TQWIZARD_OBJECT_NAME_STRING "TQWizard" -#define TQDATATABLE_OBJECT_NAME_STRING "TQDataTable" -#define TQDATABROWSER_OBJECT_NAME_STRING "TQDataBrowser" -#define TQDATAVIEW_OBJECT_NAME_STRING "TQDataView" -#define TQMAINWINDOW_OBJECT_NAME_STRING "TQMainWindow" -#define TQWIDGETSTACK_OBJECT_NAME_STRING "TQWidgetStack" -#define TQBUTTONGROUP_OBJECT_NAME_STRING "TQButtonGroup" -#define TQTEXTVIEW_OBJECT_NAME_STRING "TQTextView" -#define TQTEXTBROWSER_OBJECT_NAME_STRING "TQTextBrowser" -#define TQLAYOUTWIDGET_OBJECT_NAME_STRING "TQLayoutWidget" - -#define TQMOTIFPLUSSTYLE_OBJECT_NAME_STRING "TQMotifPlusStyle" - -// #define tqarrowCursor Qt::ArrowCursor -// #define tqupArrowCursor Qt::UpArrowCursor -// #define tqcrossCursor Qt::CrossCursor -// #define tqwaitCursor Qt::WaitCursor -// #define tqibeamCursor Qt::IBeamCursor -// #define tqsizeVerCursor Qt::SizeVerCursor -// #define tqsizeHorCursor Qt::SizeHorCursor -// #define tqsizeBDiagCursor Qt::SizeBDiagCursor -// #define tqsizeFDiagCursor Qt::SizeFDiagCursor -// #define tqsizeAllCursor Qt::SizeAllCursor -// #define tqblankCursor Qt::BlankCursor -// #define tqsplitVCursor Qt::SplitVCursor -// #define tqsplitHCursor Qt::SplitHCursor -// #define tqpointingHandCursor Qt::PointingHandCursor -// #define tqforbiddenCursor Qt::ForbiddenCursor -// #define tqwhatsThisCursor Qt::WhatsThisCursor -// #define tqbusyCursor Qt::BusyCursor - -#define tqarrowCursor TQt::arrowCursor -#define tqupArrowCursor TQt::upArrowCursor -#define tqcrossCursor TQt::crossCursor -#define tqwaitCursor TQt::waitCursor -#define tqibeamCursor TQt::ibeamCursor -#define tqsizeVerCursor TQt::sizeVerCursor -#define tqsizeHorCursor TQt::sizeHorCursor -#define tqsizeBDiagCursor TQt::sizeBDiagCursor -#define tqsizeFDiagCursor TQt::sizeFDiagCursor -#define tqsizeAllCursor TQt::sizeAllCursor -#define tqblankCursor TQt::blankCursor -#define tqsplitVCursor TQt::splitVCursor -#define tqsplitHCursor TQt::splitHCursor -#define tqpointingHandCursor TQt::pointingHandCursor -#define tqforbiddenCursor TQt::forbiddenCursor -#define tqwhatsThisCursor TQt::whatsThisCursor -#define tqbusyCursor TQt::busyCursor - -#define tqreadBlock readData -#define tqwriteBlock writeData -#define TQT_TQIO_LONG qint64 -#define TQT_TQIO_ULONG qint64 -#define TQ_WFlags WFlags - -#define SET_QT_X_TIME(x) QX11Info::setAppTime(x) -#define GET_QT_X_TIME(x) QX11Info::appTime() -#define SET_QT_X_USER_TIME(x) QX11Info::setAppUserTime(x) -#define GET_QT_X_USER_TIME(x) QX11Info::appUserTime() - -// // [FIXME] -// // This should try a dynamic cast first before resorting to conversion (which entails a create/copy/delete operation) -// // Also, is simply overwriting the origin pointer enough to make this work in all cases??? -// template -// U* tqt_convert_object(T* orig) -// { -// T* orig_ptr = orig; -// U* temp = new U(); -// *temp = *orig; -// orig_ptr = temp; -// delete orig; -// return temp; -// } -// -// #define TQT_TQPIXMAP(x) (tqt_convert_object(x)) -// #define TQT_TQPIXMAP_CONST(x) (tqt_convert_object(x)) - -// [NOTE] -// It is IMPOSSIBLE to downcast an abstract base class [ABC] to a derived type. Period. End of story. -// Think of it this way...is it ever possible to instantiate an ABC on its own (e.g. with new)? No! -// Therefore, it is also impossible to copy an ABC. -// static_cast won't work because an ABC has a completely different structure than a non abstract class. -// Specifically, you will get segmentation faults in typeinfo for the ABC at runtime. -// This is probably due to the complete absence of the abstract method implementations in the static_casted object. -// The only exception that I can think of MIGHT be if NO CHANGES are made to the abstracted methods, -// including addition, modification, or removal of said methods. Don't bet the farm on this however! - -// #define TQT_TQLAYOUTITEM_CONST(x) (static_cast(static_cast(x))) - -// // [FIXME] -// // This should try a dynamic cast first before resorting to conversion (which entails a create/copy/delete operation) -// // There is half a chance that this sort of nasty hackery is only required for abstract base classes, such as QStyle and QLayoutItem -// // For other class types a simple static_cast *might* suffice. [???] -// template -// U* tqt_convert_object(T* orig) -// { -// T* orig_ptr = orig; -// U* temp = new U(); -// *temp = *orig; -// orig_ptr = temp; -// delete orig; -// return temp; -// } -// -// #define TQT_TQLAYOUTITEM_CONST(x) (tqt_convert_object(x)) - -// TQT_BASE_OBJECT is here for equality operators, as pointers will only be considered equal if the top (base) classes are compared -// This is because all widget/extension/etc. classes will have one and only one TQT_BASE_OBJECT class instance in memory -// Thus casting both pointers to TQT_BASE_OBJECT and comparing will reveal if the objects being compared are truly the same -// For TQT 3 TQObject is the real base class, while in TQt 4 QObject is the real base class -#define TQT_BASE_OBJECT_NAME QObject -#define TQT_BASE_OBJECT(x) (static_cast(x)) -#define TQT_BASE_OBJECT_CONST(x) (static_cast(x)) - -// This can be used to change any object name within TQt -// x is a QString or TQString -#define TQT_OBJECT_NAME_HANDLER(x) TQString(x) - -// Safe casts -template -T tqt_dynamic_cast(TQT_BASE_OBJECT_NAME* a) { return dynamic_cast(a); } - -template -T tqt_dynamic_cast(const TQT_BASE_OBJECT_NAME* a) { return dynamic_cast(a); } - -// Interface defines -#define QABS(n) qAbs(n) -#define QMIN(x, y) qMin(x, y) -#define QMAX(x, y) qMax(x, y) - -#define tqt_mo_access access() - -// [FIXME] The underlying problem in uic creating the need for these defines should probably be fixed sometime in the future... -// See object.cpp e.g. line 571 -#define setTqmaximumSize setMaximumSize -#define setTqminimumSize setMinimumSize -#define setTqalignment tqsetAlignment -#define setTqgeometry setGeometry - -#define Q_UINT16 quint16 - -#define ttqqt_cast( x ) tqqt_cast(TQT_TQOBJECT(x)) - -// TQT for Qt3 compatibility defines -#define tqred red -#define tqgreen green -#define tqblue blue -#define tqcyan cyan -#define tqmagenta magenta -#define tqyellow yellow -#define tqdarkRed darkRed -#define tqdarkGreen darkGreen -#define tqdarkBlue darkBlue -#define tqdarkCyan darkCyan -#define tqdarkMagenta darkMagenta -#define tqdarkYellow darkYellow -#define tqwhite white -#define tqwhiteptr &TQt::white -#define tqlightGray lightGray -#define tqgray gray -#define tqdarkGray darkGray -#define tqblack black -#define tqblackptr &TQt::black -#define tqcolor0 color0 -#define tqcolor1 color1 - -// #define tqaccess access -// #define tqcolorTable colorTable -#define TQSO_Default Default -// #define tqqt_cast ::qt_cast -#define TQ_Alignment Qt::Alignment -#define TQ_Horizontal Horizontal -#define TQ_Vertical Vertical -#define TQImage_ScaleFree ScaleFree -#define TQ_Key_Shift Key_Shift -#define TQ_Key_Control Key_Control -#define TQ_Key_Alt Key_Alt -#define TQ_Key_Meta Key_Meta -#define TQ_Key_Super_L Key_Super_L -#define TQ_Key_Super_R Key_Super_R -#define TQ_Key_Hyper_L Key_Hyper_L -#define TQ_Key_Hyper_R Key_Hyper_R -#define TQ_ButtonState TQt::ButtonState -#define TQ_LeftButton Qt::LeftButton -#define TQ_MidButton Qt::MidButton -#define TQ_RightButton Qt::RightButton -#define TQ_ShiftButton ShiftButton -#define TQ_ControlButton ControlButton -#define TQ_AltButton AltButton -#define TQ_MetaButton MetaButton -#define TQ_ScaleFree ScaleFree -#define TQ_ScaleMin ScaleMin -#define TQ_ScaleMax ScaleMax -#define TQ_ScaleMode ScaleMode -#define TQ_StrongFocus Qt::StrongFocus -#define TQ_NoFocus Qt::NoFocus -#define TQ_WheelFocus Qt::WheelFocus -#define TQ_ClickFocus Qt::ClickFocus -#define TQ_TabFocus Qt::TabFocus -#define TQ_FocusPolicy Qt::FocusPolicy -#define TQ_SPExpandData Qt::Orientations -#define TQIODevice_OpenModeFlag QIODevice::OpenModeFlag -#define TQ_OpenMode OpenMode - -// #define Orientation Qt::Orientation - -// #define SubRect SubElement -// #define SR_PushButtonContents SE_PushButtonContents -// #define SR_PushButtonFocusRect SE_PushButtonFocusRect -// #define SR_CheckBoxIndicator SE_CheckBoxIndicator -// #define SR_CheckBoxContents SE_CheckBoxContents -// #define SR_CheckBoxFocusRect SE_CheckBoxFocusRect -// #define SR_RadioButtonIndicator SE_RadioButtonIndicator -// #define SR_RadioButtonContents SE_RadioButtonContents -// #define SR_RadioButtonFocusRect SE_RadioButtonFocusRect -// #define SR_ComboBoxFocusRect SE_ComboBoxFocusRect -// #define SR_SliderFocusRect SE_SliderFocusRect -// #define SR_DockWindowHandleRect SE_DockWindowHandleRect -// #define SR_ProgressBarGroove SE_ProgressBarGroove -// #define SR_ProgressBarContents SE_ProgressBarContents -// #define SR_ProgressBarLabel SE_ProgressBarLabel -// #define SR_ToolButtonContents SE_ToolButtonContents -// #define SR_DialogButtonAccept SE_DialogButtonAccept -// #define SR_DialogButtonReject SE_DialogButtonReject -// #define SR_DialogButtonApply SE_DialogButtonApply -// #define SR_DialogButtonHelp SE_DialogButtonHelp -// #define SR_DialogButtonAll SE_DialogButtonAll -// #define SR_DialogButtonAbort SE_DialogButtonAbort -// #define SR_DialogButtonIgnore SE_DialogButtonIgnore -// #define SR_DialogButtonRetry SE_DialogButtonRetry -// #define SR_DialogButtonCustom SE_DialogButtonCustom -// #define SR_ToolBoxTabContents SE_ToolBoxTabContents -// #define SR_CustomBase SE_CustomBase -// -// #define StylePixmap StandardPixmap -// // #define SP_TitleBarMinButton SC_TitleBarMinButton -// // #define SP_TitleBarMaxButton SC_TitleBarMaxButton -// // #define SP_TitleBarCloseButton SC_TitleBarCloseButton -// // #define SP_TitleBarNormalButton SC_TitleBarNormalButton -// // #define SP_TitleBarShadeButton SC_TitleBarShadeButton -// // #define SP_TitleBarUnshadeButton SC_TitleBarUnshadeButton -// #define SP_DockWindowCloseButton SP_DockWidgetCloseButton -// // #define SP_MessageBoxInformation SC_MessageBoxInformation -// // #define SP_MessageBoxWarning SC_MessageBoxWarning -// // #define SP_MessageBoxCritical SC_MessageBoxCritical -// // #define SP_MessageBoxQuestion SC_MessageBoxQuestion -// // #define SP_CustomBase SC_CustomBase -// -// #define StyleFlags StateFlags -// #define Style_Default QStyle::State_Default -// #define Style_Enabled QStyle::State_Enabled -// #define Style_Raised QStyle::State_Raised -// #define Style_Sunken QStyle::State_Sunken -// #define Style_Off QStyle::State_Off -// #define Style_NoChange QStyle::State_NoChange -// #define Style_On QStyle::State_On -// #define Style_Down QStyle::State_DownArrow -// #define Style_Horizontal QStyle::State_Horizontal -// #define Style_HasFocus QStyle::State_HasFocus -// #define Style_To QStyle::State_To -// #define Style_Bottom QStyle::State_Bottom -// #define Style_FocusAtBorder QStyle::State_FocusAtBorder -// #define Style_AutoRaise QStyle::State_AutoRaise -// #define Style_MouseOver QStyle::State_MouseOver -// #define Style_Up QStyle::State_UpArrow -// #define Style_Selected QStyle::State_Selected -// #define Style_Active QStyle::State_Active -// #define Style_ButtonDefault QStyle::State_ButtonDefault -// -// #define PE_ArrowDown PE_IndicatorArrowDown -// #define PE_ArrowUp PE_IndicatorArrowUp -// #define PE_ButtonTool PE_PanelButtonTool -// #define PE_DockWindowHandle PE_IndicatorToolBarHandle -// #define PE_DockWindowSeparator PE_Q3DockWindowSeparator -// // Verify this one -------------v -// #define PE_FocusRect PE_FrameFocusRect -// #define PE_Panel PE_Frame -// #define PE_RubberBand CE_RubberBand -// #define PE_ScrollBarAddLine CE_ScrollBarAddLine -// #define PE_ScrollBarAddPage CE_ScrollBarAddPage -// #define PE_ScrollBarFirst CE_ScrollBarFirst -// #define PE_ScrollBarLast CE_ScrollBarLast -// #define PE_ScrollBarSlider CE_ScrollBarSlider -// #define PE_ScrollBarSubLine CE_ScrollBarSubLine -// #define PE_ScrollBarSubPage CE_ScrollBarSubPage -// -// #define SC_ListView SC_Q3ListView -// #define SC_ListViewBranch SC_Q3ListViewBranch -// #define SC_ListViewExpand SC_Q3ListViewExpand -// -// #define CC_ListView CC_Q3ListView -// -// #define WState Qt::WidgetAttribute -// #define WState_Polished Qt::WA_WState_Polished -// //#define WState_ForceHide Qt::WA_WState_ForceHide -// #define WState_ForceHide Qt::WA_WState_Hidden -// -// #define SH_PopupMenu_Scrollable SH_Menu_Scrollable -// #define SH_PopupMenu_SloppySubMenus SH_Menu_SloppySubMenus -// #define SH_PopupMenu_SubMenuPopupDelay SH_Menu_SubMenuPopupDelay -// #define SH_PopupMenu_AllowActiveAndDisabled SH_Menu_AllowActiveAndDisabled -// #define SH_PopupMenu_MouseTracking SH_Menu_MouseTracking -// -// #define CE_PopupMenuScroller CE_MenuScroller -// -// #define PM_DockWindowHandleExtent PM_DockWidgetHandleExtent -// #define PM_MenuBarFrameWidth PM_ToolBarFrameWidth -// #define PM_DockWindowFrameWidth PM_DockWidgetFrameWidth -// #define PM_PopupMenuScrollerHeight PM_MenuScrollerHeight -// -// // #define WFlags Qt::WindowFlags - -#endif // USE_QT4 - -#endif // TQTGLOBALDEFINES_H diff --git a/tqtinterface/qt4/src/kernel/tqapplication.cpp~ b/tqtinterface/qt4/src/kernel/tqapplication.cpp~ deleted file mode 100644 index ff60776..0000000 --- a/tqtinterface/qt4/src/kernel/tqapplication.cpp~ +++ /dev/null @@ -1,5499 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQApplication class -** -** Created : 931107 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 "tqobjectlist.h" -#include "tqapplication.h" -#include "tqeventloop.h" -#include "tqeventloop_p.h" -#include "tqwidget.h" -#include "tqwidgetlist.h" -#include "tqwidgetintdict.h" -#include "tqptrdict.h" -#include "tqcleanuphandler.h" - -#include "tqtranslator.h" -#include "tqtextcodec.h" -#include "tqsessionmanager.h" -#include "tqdragobject.h" -#include "tqclipboard.h" -#include "tqcursor.h" -#include "tqstyle.h" -#include "tqstylefactory.h" -#include "tqfile.h" -#include "tqmessagebox.h" -#include "tqdir.h" -#include "tqfileinfo.h" -#ifdef TQ_WS_WIN -#include "tqinputcontext_p.h" -#endif -#include "tqfontdata_p.h" - -#if defined(TQT_THREAD_SUPPORT) -# include "tqmutex.h" -# include "tqthread.h" -#endif // TQT_THREAD_SUPPORT - -#include - -#ifdef truncate -# undef truncate -#endif - -#ifdef USE_QT4 - -TQApplication *tqAppReal; // global application object -TQStyle *TQApplication::app_style = 0; // default application style -bool qt_explicit_app_style = FALSE; // style explicitly set by programmer -QWidget* TQApplication::current_app_main_widget = 0; // current main widget - -int TQApplication::app_cspec = TQApplication::NormalColor; // color mode (obsolete) - -TQWidgetList * qt_modal_stack=0; // stack of modal widgets - -#ifndef TQT_NO_PALETTE -TQPalette *TQApplication::app_pal = 0; // default application palette -#endif -// TQFont *TQApplication::app_font = 0; // default application font -bool qt_app_has_font = FALSE; - -bool qt_is_gui_used; -bool TQ_EXPORT qt_resolve_symlinks = TRUE; -bool TQ_EXPORT qt_tab_all_widgets = TRUE; - -#if defined(TQ_WS_X11) -extern void qt_init( Display* dpy, TQt::HANDLE, TQt::HANDLE ); -#endif -extern void qt_init( int *argcptr, char **argv, TQApplication::Type ); - -#ifndef TQT_NO_CLIPBOARD -TQClipboard *tqt_clipboard = 0; // global clipboard object -#endif - -#ifdef TQT_THREAD_SUPPORT -TQMutex *TQApplication::qt_mutex = 0; -static TQMutex *postevent_mutex = 0; -static TQt::HANDLE qt_application_thread_id = 0; -TQ_EXPORT TQt::HANDLE qt_get_application_thread_id() -{ - return qt_application_thread_id; -} -#endif // TQT_THREAD_SUPPORT - - -#ifdef TQT_THREAD_SUPPORT - #define TQAPPLICATION_MUTEX_INIT \ - qt_mutex = new TQMutex( TRUE ); \ - postevent_mutex = new TQMutex( TRUE ); \ - qt_application_thread_id = TQThread::currentThread(); -#else // TQT_THREAD_SUPPORT - #define TQAPPLICATION_MUTEX_INIT -#endif // TQT_THREAD_SUPPORT - -TQWidgetList TQApplication::tqt_all_widgets_list; - -TQApplication::TQApplication( int &argc, char **argv ) : QApplication( argc, argv ) -{ - bool GUIenabled = true; - TQAPPLICATION_GUI_CONDITIONAL_VAR_INIT - TQAPPLICATION_XORG_CONDITIONAL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled ) : QApplication( argc, argv, GUIenabled ) -{ - TQAPPLICATION_GUI_CONDITIONAL_VAR_INIT - TQAPPLICATION_XORG_CONDITIONAL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -TQApplication::TQApplication( int &argc, char **argv, Type t ) : QApplication( argc, argv, t ) -{ - TQAPPLICATION_GUI_VAR_INIT - TQAPPLICATION_XORG_PARTIAL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -#if defined(TQ_WS_X11) -TQApplication::TQApplication( Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap ) : QApplication( dpy, visual, cmap ) -{ - TQAPPLICATION_GUI_VAR_INIT - TQAPPLICATION_XORG_FULL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -TQApplication::TQApplication( Display *dpy, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap ) : QApplication( dpy, argc, argv, visual, cmap ) -{ - TQAPPLICATION_GUI_VAR_INIT - TQAPPLICATION_XORG_FULL_INIT - TQAPPLICATION_MUTEX_INIT - TQAPPLICATION_REGISTER_TQ_DATATYPES -} -#endif - -// Qt4 session manager interconnect -void TQApplication::commitData( QSessionManager& sm ) { - commitData(TQT_TQSESSIONMANAGER_OBJECT(sm)); -} -void TQApplication::saveState( QSessionManager& sm ) { - saveState(TQT_TQSESSIONMANAGER_OBJECT(sm)); -} - -#ifndef TQT_NO_TRANSLATION - -bool qt_detectRTLLanguage() -{ - return TQApplication::tr( "TQT_LAYOUT_DIRECTION", - "Translate this string to the string 'LTR' in left-to-right" - " languages or to 'RTL' in right-to-left languages (such as Hebrew" - " and Arabic) to get proper widget tqlayout." ) == "RTL"; -} - -#endif // TQT_NO_TRANSLATION - -TQEventLoop* TQApplication::eventloop; -TQPtrList TQApplication::tqt_event_loop_stack; -int TQApplication::composedUnicode; -bool TQApplication::metaComposeUnicode; - -// static TQEventLoop eventLoop_private; // Will this actually work, or do I need to call exec or something? -// -// TQEventLoop *TQApplication::eventLoop() -// { -// return &eventLoop_private; -// } - -TQEventLoop *TQApplication::eventLoop() { - if ( !eventloop ) - (void) new TQEventLoop( TQT_TQOBJECT(tqApp), "default event loop" ); - return eventloop; -} - -/*! - - Wakes up the GUI thread. - - \sa guiThreadAwake() \link threads.html Thread Support in TQt\endlink -*/ -void TQApplication::wakeUpGuiThread() -{ - eventLoop()->wakeUp(); -} - -#ifdef TQT_THREAD_SUPPORT -void TQApplication::lock() { - qt_mutex->lock(); -} - -void TQApplication::unlock(bool wakeUpGui) { - qt_mutex->unlock(); - - if (wakeUpGui) - wakeUpGuiThread(); -} - -bool TQApplication::locked() { - return qt_mutex->locked(); -} - -bool TQApplication::tryLock() { - return qt_mutex->tryLock(); -} -#endif // TQT_THREAD_SUPPORT - -#ifndef TQT_NO_PALETTE -TQPalette *qt_std_pal = 0; - -void qt_create_std_palette() -{ - if ( qt_std_pal ) - delete qt_std_pal; - - TQColor standardLightGray( 192, 192, 192 ); - TQColor light( 255, 255, 255 ); - TQColor dark( standardLightGray.dark( 150 ) ); - TQColorGroup std_act( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - TQColorGroup std_dis( TQt::darkGray, standardLightGray, - light, dark, TQt::gray, - TQt::darkGray, std_act.background() ); - TQColorGroup std_inact( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - qt_std_pal = new TQPalette( std_act, std_dis, std_inact ); -} - -static void qt_fix_tooltips() -{ - // No resources for this yet (unlike on Windows). - TQColorGroup cg( TQt::black, TQColor(255,255,220), - TQColor(96,96,96), TQt::black, TQt::black, - TQt::black, TQColor(255,255,220) ); - TQPalette pal( cg, cg, cg ); - TQApplication::tqsetPalette( pal, TRUE, "TQTipLabel"); -} -#endif - -// [FIXME] This needs to somehow connect to the Qt4 style mechanism -// Possibly on calls to setStyle the Qt4 setStyle must also be called for the same style? - -static TQString *qt_style_override = 0; - -TQStyle& TQApplication::tqstyle() -{ -#ifndef TQT_NO_STYLE - if ( app_style ) - return *app_style; - if ( !qt_is_gui_used ) - qFatal( "No style available in non-gui applications!" ); - -#if defined(TQ_WS_X11) -// if(!qt_style_override) -// x11_initialize_style(); // run-time search for default style -#endif - if ( !app_style ) { -// // Compile-time search for default style -// // - TQString style; - if ( qt_style_override ) { - style = *qt_style_override; - delete qt_style_override; - qt_style_override = 0; - } else { -// # if defined(TQ_WS_WIN) && defined(TQ_OS_TEMP) -// style = "PocketPC"; -// #elif defined(TQ_WS_WIN) -// if ( qWinVersion() >= TQt::WV_XP && qWinVersion() < TQt::WV_NT_based ) -// style = "WindowsXP"; -// else -// style = "Windows"; // default styles for Windows -// #elif defined(TQ_WS_X11) && defined(TQ_OS_SOLARIS) -// style = "CDE"; // default style for X11 on Solaris -// #elif defined(TQ_WS_X11) && defined(TQ_OS_IRIX) -// style = "SGI"; // default style for X11 on IRIX -// #elif defined(TQ_WS_X11) - style = "Motif"; // default style for X11 -// #elif defined(TQ_WS_MAC) -// style = "Macintosh"; // default style for all Mac's -// #elif defined(TQ_WS_TQWS) -// style = "Compact"; // default style for small tqdevices -// #endif - } - app_style = TQStyleFactory::create( style ); - if ( !app_style && // platform default style not available, try alternatives - !(app_style = TQStyleFactory::create( "Windows" ) ) && - !(app_style = TQStyleFactory::create( "Platinum" ) ) && - !(app_style = TQStyleFactory::create( "MotifPlus" ) ) && - !(app_style = TQStyleFactory::create( "Motif" ) ) && - !(app_style = TQStyleFactory::create( "CDE" ) ) && - !(app_style = TQStyleFactory::create( "Aqua" ) ) && - !(app_style = TQStyleFactory::create( "SGI" ) ) && - !(app_style = TQStyleFactory::create( "Compact" ) ) -#ifndef TQT_NO_STRINGLIST - && !(app_style = TQStyleFactory::create( TQStyleFactory::keys()[0] ) ) -#endif - ) - qFatal( "No %s style available!", style.latin1() ); - } - -// TQPalette app_pal_copy ( *app_pal ); -// app_style->polish( *app_pal ); - -// if ( is_app_running && !is_app_closing && (*app_pal != app_pal_copy) ) { -// TQEvent e( TQEvent::ApplicationPaletteChange ); -// TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); -// register TQWidget *w; -// while ( (w=it.current()) ) { // for all widgets... -// ++it; -// sendEvent( w, &e ); -// } -// } - - app_style->polish( tqApp ); -#endif - return *app_style; -} - -/*! - Enters the main event loop and waits until exit() is called or the - main widget is destroyed, and returns the value that was set to - exit() (which is 0 if exit() is called via quit()). - - It is necessary to call this function to start event handling. The - main event loop receives events from the window system and - dispatches these to the application widgets. - - Generally speaking, no user interaction can take place before - calling exec(). As a special case, modal widgets like TQMessageBox - can be used before calling exec(), because modal widgets call - exec() to start a local event loop. - - To make your application perform idle processing, i.e. executing a - special function whenever there are no pending events, use a - TQTimer with 0 timeout. More advanced idle processing schemes can - be achieved using processEvents(). - - \sa quit(), exit(), processEvents(), setMainWidget() -*/ -int TQApplication::exec() -{ - return eventLoop()->exec(); -} - -/*! - Sets the application's GUI style to \a style. Ownership of the style - object is transferred to TQApplication, so TQApplication will delete - the style object on application exit or when a new style is set. - - Example usage: - \code - TQApplication::setStyle( new TQWindowsStyle ); - \endcode - - When switching application styles, the color palette is set back to - the initial colors or the system defaults. This is necessary since - certain styles have to adapt the color palette to be fully - style-guide compliant. - - \sa style(), TQStyle, setPalette(), desktopSettingsAware() -*/ -void TQApplication::setStyle( TQStyle *style ) -{ - TQStyle* old = app_style; - app_style = style; -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - delete old; - return; - } - - // clean up the old style - if (old) { -// if ( is_app_running && !is_app_closing ) { -// TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); -// register TQWidget *w; -// while ( (w=it.current()) ) { // for all widgets... -// ++it; -// if ( !w->testWFlags(WType_Desktop) && // except desktop -// w->testWState(WState_Polished) ) { // has been polished -// old->unPolish(w); -// } -// } -// } -// old->unPolish( tqApp ); - } - - // take care of possible palette requirements of certain gui - // styles. Do it before polishing the application since the style - // might call TQApplication::setStyle() itself - if ( !qt_std_pal ) - qt_create_std_palette(); - TQPalette tmpPal = *qt_std_pal; - tqsetPalette( tmpPal, TRUE ); - - // initialize the application with the new style - app_style->polish( tqApp ); - - // re-polish existing widgets if necessary - if (old) { -// if ( is_app_running && !is_app_closing ) { -// TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); -// register TQWidget *w; -// while ( (w=it.current()) ) { // for all widgets... -// ++it; -// if ( !w->testWFlags(WType_Desktop) ) { // except desktop -// if ( w->testWState(WState_Polished) ) -// app_style->polish(w); // repolish -// w->styleChange( *old ); -// if ( w->isVisible() ){ -// w->update(); -// } -// } -// } -// } - delete old; - } -} - -/*! - \overload - - Requests a TQStyle object for \a style from the TQStyleFactory. - - The string must be one of the TQStyleFactory::keys(), typically one - of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and - "compact". Depending on the platform, "windowsxp", "aqua" or - "macintosh" may be available. - - A later call to the TQApplication constructor will override the - requested style when a "-style" option is passed in as a commandline - parameter. - - Returns 0 if an unknown \a style is passed, otherwise the TQStyle object - returned is set as the application's GUI style. -*/ -TQStyle* TQApplication::setStyle( const TQString& style ) -{ -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - if(qt_style_override) - *qt_style_override = style; - else - qt_style_override = new TQString(style); - return 0; - } - TQStyle *s = TQStyleFactory::create( style ); - if ( !s ) - return 0; - - setStyle( s ); - return s; -} - -TQWidget *TQApplication::mainWidget() -{ - return TQT_TQWIDGET(current_app_main_widget); -} - -const char *TQApplication::tqname() const { - if (dynamic_cast(static_cast(static_cast(this)))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - printf("[WARNING] Attempted to call TQApplication::tqname() on an object without a constructed TQApplication object or base object. Returning \"\"\n\r"); - return ""; - } -} - -const char *TQApplication::name() const { - if (dynamic_cast(static_cast(static_cast(this)))) { - static_object_name = TQT_OBJECT_NAME_HANDLER(objectName()); - return static_object_name.ascii(); - } - else { - printf("[WARNING] Attempted to call TQApplication::name() on an object without a constructed TQApplication object or base object. Returning \"\"\n\r"); - return ""; - } -} - -/*!\internal - - Called from qapplication_.cpp, returns TRUE - if the widget should accept the event. - */ -TQ_EXPORT bool qt_tryModalHelper( TQWidget *widget, TQWidget **rettop ) { - TQWidget *modal=0, *top=TQT_TQWIDGET(TQApplication::activeModalWidget()); - if ( rettop ) *rettop = top; - - if ( tqApp->activePopupWidget() ) - return TRUE; - -#ifdef TQ_WS_MACX - top = qt_tryModalHelperMac( top ); - if ( rettop ) *rettop = top; -#endif - - TQWidget* groupLeader = widget; - widget = widget->tqtopLevelWidget(); - - if ( widget->testWFlags(TQt::WShowModal) ) // widget is modal - modal = widget; - if ( !top || modal == top ) // don't block event - return TRUE; - - TQWidget * p = widget->parentWidget(); // Check if the active modal widget is a tqparent of our widget - while ( p ) { - if ( p == top ) - return TRUE; - p = p->parentWidget(); - } - - while ( groupLeader && !groupLeader->testWFlags( TQt::WGroupLeader ) ) - groupLeader = groupLeader->parentWidget(); - -// [FIXME] -printf("[WARNING] bool qt_tryModalHelper partially implemented\n\r"); -// if ( groupLeader ) { -// // Does groupLeader have a child in qt_modal_stack? -// bool unrelated = TRUE; -// modal = qt_modal_stack->first(); -// while (modal && unrelated) { -// TQWidget* p = modal->parentWidget(); -// while ( p && p != groupLeader && !p->testWFlags( TQt::WGroupLeader) ) { -// p = p->parentWidget(); -// } -// modal = qt_modal_stack->next(); -// if ( p == groupLeader ) unrelated = FALSE; -// } -// -// if ( unrelated ) -// return TRUE; // don't block event -// } - - return FALSE; -} - -/*!\internal - - Creates the proper Enter/Leave event when widget \a enter is entered - and widget \a leave is left. - */ -TQ_EXPORT void qt_dispatchEnterLeave( TQWidget* enter, TQWidget* leave ) { -#if 0 - if ( leave ) { - TQEvent e( TQEvent::Leave ); - TQApplication::sendEvent( leave, & e ); - } - if ( enter ) { - TQEvent e( TQEvent::Enter ); - TQApplication::sendEvent( enter, & e ); - } - return; -#endif - - TQWidget* w ; - if ( !enter && !leave ) - return; - TQWidgetList leaveList; - TQWidgetList enterList; - - bool sameWindow = leave && enter && leave->tqtopLevelWidget() == enter->tqtopLevelWidget(); - if ( leave && !sameWindow ) { - w = leave; - do { - leaveList.append( w ); - } while ( (w = w->parentWidget( TRUE ) ) ); - } - if ( enter && !sameWindow ) { - w = enter; - do { - enterList.prepend( w ); - } while ( (w = w->parentWidget(TRUE) ) ); - } - if ( sameWindow ) { - int enterDepth = 0; - int leaveDepth = 0; - w = enter; - while ( ( w = w->parentWidget( TRUE ) ) ) - enterDepth++; - w = leave; - while ( ( w = w->parentWidget( TRUE ) ) ) - leaveDepth++; - TQWidget* wenter = enter; - TQWidget* wleave = leave; - while ( enterDepth > leaveDepth ) { - wenter = wenter->parentWidget(); - enterDepth--; - } - while ( leaveDepth > enterDepth ) { - wleave = wleave->parentWidget(); - leaveDepth--; - } - while ( !wenter->isTopLevel() && wenter != wleave ) { - wenter = wenter->parentWidget(); - wleave = wleave->parentWidget(); - } - - w = leave; - while ( w != wleave ) { - leaveList.append( w ); - w = w->parentWidget(); - } - w = enter; - while ( w != wenter ) { - enterList.prepend( w ); - w = w->parentWidget(); - } - } - - TQEvent leaveEvent( TQEvent::Leave ); - for ( w = leaveList.first(); w; w = leaveList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &leaveEvent ); - } - TQEvent enterEvent( TQEvent::Enter ); - for ( w = enterList.first(); w; w = enterList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &enterEvent ); - } -} - -#ifndef TQT_NO_CLIPBOARD -/*! - Returns a pointer to the application global clipboard. -*/ -TQClipboard *TQApplication::tqclipboard() -{ - if ( tqt_clipboard == 0 ) { - tqt_clipboard = new TQClipboard; - TQ_CHECK_PTR( tqt_clipboard ); - } - return tqt_clipboard; -} -#endif // TQT_NO_CLIPBOARD - -/*! - \fn void TQApplication::commitData( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the TQSessionManager wants the - application to commit all its data. - - Usually this means saving all open files, after getting - permission from the user. Furthermore you may want to provide a means - by which the user can cancel the shutdown. - - Note that you should not exit the application within this function. - Instead, the session manager may or may not do this afterwards, - depending on the context. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details and example - usage. - - The default implementation requests interaction and sends a close - event to all visible top level widgets. If any event was - rejected, the shutdown is canceled. - - \sa isSessionRestored(), sessionId(), saveState(), \link session.html the Session Management overview\endlink -*/ -#ifndef TQT_NO_SESSIONMANAGER -void TQApplication::commitData( TQSessionManager& sm ) -{ - - if ( sm.allowsInteraction() ) { - TQWidgetList done; - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - bool cancelled = FALSE; - TQWidget* w = list->first(); - while ( !cancelled && w ) { - if ( !w->isHidden() ) { - TQCloseEvent e; - sendEvent( w, &e ); - cancelled = !e.isAccepted(); - if ( !cancelled ) - done.append( w ); - delete list; // one never knows... - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - while ( w && done.tqcontainsRef( w ) ) - w = list->next(); - } - delete list; - if ( cancelled ) - sm.cancel(); - } -} - - -/*! - \fn void TQApplication::saveState( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the - \link TQSessionManager session manager \endlink wants the application - to preserve its state for a future session. - - For example, a text editor would create a temporary file that - includes the current contents of its edit buffers, the location of - the cursor and other aspects of the current editing session. - - Note that you should never exit the application within this - function. Instead, the session manager may or may not do this - afterwards, depending on the context. Futhermore, most session - managers will very likely request a saved state immediately after - the application has been started. This permits the session manager - to learn about the application's restart policy. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details. - - \sa isSessionRestored(), sessionId(), commitData(), \link session.html the Session Management overview\endlink -*/ - -void TQApplication::saveState( TQSessionManager& /* sm */ ) -{ -} -#endif //TQT_NO_SESSIONMANAGER - -#if 1 /* OBSOLETE */ - -TQApplication::ColorMode TQApplication::colorMode() -{ - return (TQApplication::ColorMode)app_cspec; -} - -void TQApplication::setColorMode( TQApplication::ColorMode mode ) -{ - printf("[WARNING] TQApplication::setColorMode() does nothing!\n\r"); - app_cspec = mode; -} -#endif - -/*! - Initialization of the appearance of the widget \a w \e before it is first - shown. - - Usually widgets call this automatically when they are polished. It - may be used to do some style-based central customization of widgets. - - Note that you are not limited to the public functions of TQWidget. - Instead, based on meta information like TQObject::className() you are - able to customize any kind of widget. - - \sa TQStyle::polish(), TQWidget::polish(), setPalette(), setFont() -*/ - -void TQApplication::polish( QWidget *w ) -{ -#ifndef TQT_NO_STYLE - TQT_TQWIDGET(w)->tqstyle().polish( w ); -#endif -} - -void TQApplication::exit_loop() { // Does not exit in Qt4 - printf("[WARNING] No runtime validation is performed within TQApplication::exit_loop; this may cause odd/obscure problems\n\r"); -// QThreadData *data = QThreadData::current(); -// if (!data->eventLoops.isEmpty()) -// data->eventLoops.top()->exit(); - QEventLoop* eventLoop = tqt_event_loop_stack.getLast(); - if (eventLoop) { - eventLoop->exit(); - } - else { - printf("[WARNING] An attempt was made to exit a nonexistant event loop!\n\r"); - } -} -int TQApplication::enter_loop() { // Does not exit in Qt4 - printf("[WARNING] No runtime validation is performed within TQApplication::enter_loop; this may cause odd/obscure problems\n\r"); - QEventLoop* eventLoop = new QEventLoop(); - tqt_event_loop_stack.append(eventLoop); - int returnCode = eventLoop->exec(); // This blocks until either QEventLoop::exit is called or the loop terminates normally - tqt_event_loop_stack.remove(eventLoop); - delete eventLoop; - return returnCode; -} - -TQMetaObject *TQApplication::tqmetaObject() const { - return TQT_TQOBJECT_CONST(this)->tqmetaObject(); -} - -void TQApplication::processOneEvent() { - processEvents(QEventLoop::WaitForMoreEvents); -} - -void TQApplication::tqprocessEvents() { - return processEvents(); -} - -void TQApplication::tqprocessEvents( int maxtime ) { - return processEvents(QEventLoop::AllEvents, maxtime); -} - -/*! - \obsolete - - Returns the current loop level. - - Use TQApplication::eventLoop()->loopLevel() instead. - -*/ -int TQApplication::loopLevel() const -{ - return eventLoop()->loopLevel(); -} - -bool TQApplication::hasGlobalMouseTracking() -{ - printf("[WARNING] TQApplication::hasGlobalMouseTracking unimplemented!\n\r"); - return true; -} - -void TQApplication::setGlobalMouseTracking( bool enable ) -{ - printf("[WARNING] TQApplication::setGlobalMouseTracking unimplemented!\n\r"); -} - -#if defined(TQ_WS_X11) -void TQApplication::create_xim() { - printf("[WARNING] static void TQApplication::create_xim() unimplemented\n\r"); // [FIXME] -} - -void TQApplication::close_xim() { - printf("[WARNING] static void TQApplication::close_xim() unimplemented\n\r"); // [FIXME] -} - -bool TQApplication::x11_apply_settings() { - printf("[WARNING] static bool TQApplication::x11_apply_settings() unimplemented\n\r"); - return false; // [FIXME] -} -#endif - -#ifndef TQT_NO_TEXTCODEC -void TQApplication::setDefaultCodec( TQTextCodec * ) { - printf("[WARNING] void TQApplication::setDefaultCodec( TQTextCodec * ) unimplemented\n\r"); // [FIXME] -} - -TQTextCodec* TQApplication::defaultCodec() const -{ -// return TQTextCodec::codecForTr(); - - printf("[WARNING] TQTextCodec* TQApplication::defaultCodec unimplemented\n\r"); // [FIXME] -// return TQTextCodec(); -} -#endif - -TQWidgetList *TQApplication::tqallWidgets() { - QWidgetList ql = allWidgets(); - tqt_all_widgets_list.clear(); - for (int i = 0; i < ql.size(); ++i) tqt_all_widgets_list.append(TQT_TQWIDGET(ql.at(i))); - return &tqt_all_widgets_list; -} - -TQStringList TQApplication::libraryPaths() { - return TQT_TQSTRINGLIST_OBJECT(QApplication::libraryPaths()); -} - -void TQApplication::tqsetLibraryPaths( const QStringList &qsl ) { - setLibraryPaths(qsl); -} - -TQWidgetList *TQApplication::tqtopLevelWidgets() { - // The end user of the list is expected to delete it, so create it with new... - TQWidgetList *tqwl = new TQWidgetList(); - foreach (QWidget *widget, QApplication::topLevelWidgets()) { - tqwl->append(static_cast(widget)); - } - return tqwl; - -} - -TQDesktopWidget *TQApplication::desktop() { - return static_cast(QApplication::desktop()); -} - -const QColor &TQApplication::winStyleHighlightColor() { - return palette().color(QPalette::Active, QPalette::Highlight); -} - -void TQApplication::setWinStyleHighlightColor( const QColor c ) { - TQPalette p( tqpalette() ); - p.setColor( TQColorGroup::Highlight, c ); - tqsetPalette( p, TRUE); -} - -void TQApplication::tqsetPalette(const QPalette &pal, bool, const char* className) { - setPalette(pal, className); -} - -void TQApplication::tqsetFont(const QFont &font, bool, const char* className) { - setFont(font, className); -} - -void TQApplication::setReverseLayout(bool b) { - setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); -} - -bool TQApplication::reverseLayout() { - return layoutDirection() == Qt::RightToLeft; -} - -TQPalette TQApplication::tqpalette( const TQWidget*w ) { - return palette( w ); -} - -#ifndef TQT_NO_CURSOR -//void TQApplication::setOverrideCursor( const QCursor &cur, bool tqreplace=FALSE ) { -// TQ_UNUSED(tqreplace); -// QApplication::setOverrideCursor( cur ); -// } - -void TQApplication::setOverrideCursor( const QCursor &cur, bool tqreplace ) { - TQ_UNUSED(tqreplace); - printf("[FIXME] TQApplication::setOverrideCursor( const QCursor &cur, bool tqreplace=FALSE ) unimplemented\n\r"); -} -#endif - -void TQApplication::sendPostedEvents( QObject *receiver, int event_type ) { - QApplication::sendPostedEvents(receiver, event_type); - if (event_type == TQEvent::LayoutHint) { - QApplication::sendPostedEvents(receiver, TQEvent::LayoutRequest);; // This one eats LayoutRequest/LayoutHint events for breakfast - } -} - -void TQApplication::sendPostedEvents() { - QApplication::sendPostedEvents(); -} - -TQWidget *TQApplication::tqfocusWidget() const { - return static_cast(focusWidget()); -} - -TQWidget *TQApplication::widgetAt( const TQPoint &p, bool child ) { - TQ_UNUSED(child); - return static_cast(QApplication::widgetAt( p )); -} - -TQWidget *TQApplication::widgetAt( int x, int y, bool child ) { - TQ_UNUSED(child); - return static_cast(QApplication::widgetAt( QPoint(x, y) )); -} - -int TQApplication::horizontalAlignment( int align ) { - return QStyle::visualAlignment(layoutDirection(), (Qt::Alignment)align); -} - -void TQApplication::flushX() { - flush(); -} - -const char *TQApplication::name(const char *defaultName) const { - TQString s = objectName(); - return s.isEmpty()?defaultName:s.latin1(); -} - -void TQApplication::setName(const char *aName) { - TQT_TQOBJECT(this)->setName(aName); -} - -/*! - Displays a simple message box about TQt. 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. - - This function is a convenience slot for TQMessageBox::aboutTQt(). -*/ -void TQApplication::aboutTQt() -{ -#ifndef TQT_NO_MESSAGEBOX - TQMessageBox::aboutTQt( mainWidget() ); -#endif // TQT_NO_MESSAGEBOX -} - -#else // USE_QT4 - -/*! - \class TQApplication tqapplication.h - \brief The TQApplication class manages the GUI application's control - flow and main settings. - - \ingroup application - \mainclass - - It tqcontains the main event loop, where all events from the window - system and other sources are processed and dispatched. It also - handles the application's initialization and finalization, and - provides session management. It also handles most system-wide and - application-wide settings. - - For any GUI application that uses TQt, there is precisely one - TQApplication object, no matter whether the application has 0, 1, 2 - or more windows at any time. - - The TQApplication object is accessible through the global pointer \c - tqApp. Its main areas of responsibility are: - \list - - \i It initializes the application with the user's desktop settings - such as palette(), font() and doubleClickInterval(). It keeps track - of these properties in case the user changes the desktop globally, for - example through some kind of control panel. - - \i It performs event handling, meaning that it receives events - from the underlying window system and dispatches them to the relevant - widgets. By using sendEvent() and postEvent() you can send your own - events to widgets. - - \i It parses common command line arguments and sets its internal - state accordingly. See the \link TQApplication::TQApplication() - constructor documentation\endlink below for more details about this. - - \i It defines the application's look and feel, which is - encapsulated in a TQStyle object. This can be changed at runtime - with setStyle(). - - \i It specifies how the application is to allocate colors. - See setColorSpec() for details. - - \i It provides localization of strings that are visible to the user - via translate(). - - \i It provides some magical objects like the desktop() and the - clipboard(). - - \i It knows about the application's windows. You can ask which - widget is at a certain position using widgetAt(), get a list of - tqtopLevelWidgets() and closeAllWindows(), etc. - - \i It manages the application's mouse cursor handling, - see setOverrideCursor() and setGlobalMouseTracking(). - - \i On the X window system, it provides functions to flush and sync - the communication stream, see flushX() and syncX(). - - \i It provides support for sophisticated \link - session.html session management \endlink. This makes it possible - for applications to terminate gracefully when the user logs out, to - cancel a shutdown process if termination isn't possible and even to - preserve the entire application's state for a future session. See - isSessionRestored(), sessionId() and commitData() and saveState() - for details. - - \endlist - - The Application walk-through - example tqcontains a typical complete main() that does the usual - things with TQApplication. - - Since the TQApplication object does so much initialization, it - must be created before any other objects related to the user - interface are created. - - Since it also deals with common command line arguments, it is - usually a good idea to create it \e before any interpretation or - modification of \c argv is done in the application itself. (Note - also that for X11, setMainWidget() may change the main widget - according to the \c -tqgeometry option. To preserve this - functionality, you must set your defaults before setMainWidget() and - any overrides after.) - - \table - \header \i21 Groups of functions - \row - \i System settings - \i - desktopSettingsAware(), - setDesktopSettingsAware(), - cursorFlashTime(), - setCursorFlashTime(), - doubleClickInterval(), - setDoubleClickInterval(), - wheelScrollLines(), - setWheelScrollLines(), - palette(), - setPalette(), - font(), - setFont(), - fontMetrics(). - - \row - \i Event handling - \i - exec(), - processEvents(), - enter_loop(), - exit_loop(), - exit(), - quit(). - sendEvent(), - postEvent(), - sendPostedEvents(), - removePostedEvents(), - hasPendingEvents(), - notify(), - macEventFilter(), - qwsEventFilter(), - x11EventFilter(), - x11ProcessEvent(), - winEventFilter(). - - \row - \i GUI Styles - \i - style(), - setStyle(), - polish(). - - \row - \i Color usage - \i - colorSpec(), - setColorSpec(), - qwsSetCustomColors(). - - \row - \i Text handling - \i - installTranslator(), - removeTranslator() - translate(). - - \row - \i Widgets - \i - mainWidget(), - setMainWidget(), - allWidgets(), - tqtopLevelWidgets(), - desktop(), - activePopupWidget(), - activeModalWidget(), - clipboard(), - tqfocusWidget(), - winFocus(), - activeWindow(), - widgetAt(). - - \row - \i Advanced cursor handling - \i - hasGlobalMouseTracking(), - setGlobalMouseTracking(), - overrideCursor(), - setOverrideCursor(), - restoreOverrideCursor(). - - \row - \i X Window System synchronization - \i - flushX(), - syncX(). - - \row - \i Session management - \i - isSessionRestored(), - sessionId(), - commitData(), - saveState(). - - \row - \i Threading - \i - lock(), unlock(), locked(), tryLock(), - wakeUpGuiThread() - - \row - \i Miscellaneous - \i - closeAllWindows(), - startingUp(), - closingDown(), - type(). - \endtable - - \e {Non-GUI programs:} While TQt is not optimized or - designed for writing non-GUI programs, it's possible to use - \link tools.html some of its classes \endlink without creating a - TQApplication. This can be useful if you wish to share code between - a non-GUI server and a GUI client. - - \headerfile tqnamespace.h - \headerfile tqwindowdefs.h - \headerfile tqglobal.h -*/ - -/*! \enum TQt::HANDLE - \internal -*/ - -/*! - \enum TQApplication::Type - - \value Tty a console application - \value GuiClient a GUI client application - \value GuiServer a GUI server application -*/ - -/*! - \enum TQApplication::ColorSpec - - \value NormalColor the default color allocation policy - \value CustomColor the same as NormalColor for X11; allocates colors - to a palette on demand under Windows - \value ManyColor the right choice for applications that use thousands of - colors - - See setColorSpec() for full details. -*/ - -/* - The qt_init() and qt_cleanup() functions are implemented in the - qapplication_xyz.cpp file. -*/ - -void qt_init( int *, char **, TQApplication::Type ); -void qt_cleanup(); -#if defined(TQ_WS_X11) -void qt_init( Display* dpy, TQt::HANDLE, TQt::HANDLE ); -#endif -TQ_EXPORT bool qt_tryModalHelper( TQWidget *widget, TQWidget **rettop ); - -TQApplication *tqApp = 0; // global application object - -TQStyle *TQApplication::app_style = 0; // default application style -bool qt_explicit_app_style = FALSE; // style explicitly set by programmer - -int TQApplication::app_cspec = TQApplication::NormalColor; -#ifndef TQT_NO_PALETTE -TQPalette *TQApplication::app_pal = 0; // default application palette -#endif -TQFont *TQApplication::app_font = 0; // default application font -bool qt_app_has_font = FALSE; -#ifndef TQT_NO_CURSOR -TQCursor *TQApplication::app_cursor = 0; // default application cursor -#endif -int TQApplication::app_tracking = 0; // global mouse tracking -bool TQApplication::is_app_running = FALSE; // app starting up if FALSE -bool TQApplication::is_app_closing = FALSE; // app closing down if TRUE -int TQApplication::loop_level = 0; // event loop level -TQWidget *TQApplication::main_widget = 0; // main application widget -TQWidget *TQApplication::focus_widget = 0; // has keyboard input focus -TQWidget *TQApplication::active_window = 0; // toplevel with keyboard focus -bool TQApplication::obey_desktop_settings = TRUE; // use winsys resources -int TQApplication::cursor_flash_time = 1000; // text caret flash time -int TQApplication::mouse_double_click_time = 400; // mouse dbl click limit -#ifndef TQT_NO_WHEELEVENT -int TQApplication::wheel_scroll_lines = 3; // number of lines to scroll -#endif -bool qt_is_gui_used; -bool TQ_EXPORT qt_resolve_symlinks = TRUE; -bool TQ_EXPORT qt_tab_all_widgets = TRUE; -TQRect qt_maxWindowRect; -static int drag_time = 500; -static int drag_distance = 4; -static bool reverse_tqlayout = FALSE; -TQSize TQApplication::app_strut = TQSize( 0,0 ); // no default application strut -bool TQApplication::animate_ui = TRUE; -bool TQApplication::animate_menu = FALSE; -bool TQApplication::fade_menu = FALSE; -bool TQApplication::animate_combo = FALSE; -bool TQApplication::animate_tooltip = FALSE; -bool TQApplication::fade_tooltip = FALSE; -bool TQApplication::animate_toolbox = FALSE; -bool TQApplication::widgetCount = FALSE; -TQApplication::Type qt_appType=TQApplication::Tty; -#ifndef TQT_NO_COMPONENT -TQStringList *TQApplication::app_libpaths = 0; -#endif -bool TQApplication::metaComposeUnicode = FALSE; -int TQApplication::composedUnicode = 0; - -#ifdef TQT_THREAD_SUPPORT -TQMutex *TQApplication::qt_mutex = 0; -static TQMutex *postevent_mutex = 0; -static TQt::HANDLE qt_application_thread_id = 0; -TQ_EXPORT TQt::HANDLE qt_get_application_thread_id() -{ - return qt_application_thread_id; -} -#endif // TQT_THREAD_SUPPORT - -TQEventLoop *TQApplication::eventloop = 0; // application event loop - -#ifndef TQT_NO_ACCEL -extern bool qt_dispatchAccelEvent( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp -extern bool qt_tryComposeUnicode( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp -#endif - -#if defined(TQT_TABLET_SUPPORT) -bool chokeMouse = FALSE; -#endif - -void qt_setMaxWindowRect(const TQRect& r) -{ - qt_maxWindowRect = r; - // Re-resize any maximized windows - TQWidgetList* l = TQApplication::tqtopLevelWidgets(); - if ( l ) { - TQWidget *w = l->first(); - while ( w ) { - if ( w->isVisible() && w->isMaximized() ) - { - w->showNormal(); //#### flicker - w->showMaximized(); - } - w = l->next(); - } - delete l; - } -} - -typedef void (*VFPTR)(); -typedef TQValueList TQVFuncList; -static TQVFuncList *postRList = 0; // list of post routines - -/*! - \relates TQApplication - - Adds a global routine that will be called from the TQApplication - destructor. This function is normally used to add cleanup routines - for program-wide functionality. - - The function given by \a p should take no arguments and return - nothing, like this: - \code - static int *global_ptr = 0; - - static void cleanup_ptr() - { - delete [] global_ptr; - global_ptr = 0; - } - - void init_ptr() - { - global_ptr = new int[100]; // allocate data - qAddPostRoutine( cleanup_ptr ); // delete later - } - \endcode - - Note that for an application- or module-wide cleanup, - qAddPostRoutine() is often not suitable. People have a tendency to - make such modules dynamically loaded, and then unload those modules - long before the TQApplication destructor is called, for example. - - For modules and libraries, using a reference-counted initialization - manager or TQt' tqparent-child delete mechanism may be better. Here is - an example of a private class which uses the tqparent-child mechanism - to call a cleanup function at the right time: - - \code - class MyPrivateInitStuff: public TQObject { - private: - MyPrivateInitStuff( TQObject * tqparent ): TQObject( tqparent) { - // initialization goes here - } - MyPrivateInitStuff * p; - - public: - static MyPrivateInitStuff * initStuff( TQObject * tqparent ) { - if ( !p ) - p = new MyPrivateInitStuff( tqparent ); - return p; - } - - ~MyPrivateInitStuff() { - // cleanup (the "post routine") goes here - } - } - \endcode - - By selecting the right tqparent widget/object, this can often be made - to clean up the module's data at the exact right moment. -*/ - -TQ_EXPORT void qAddPostRoutine( TQtCleanUpFunction p) -{ - if ( !postRList ) { - postRList = new TQVFuncList; - TQ_CHECK_PTR( postRList ); - } - postRList->prepend( p ); -} - - -TQ_EXPORT void qRemovePostRoutine( TQtCleanUpFunction p ) -{ - if ( !postRList ) return; - TQVFuncList::Iterator it = postRList->begin(); - while ( it != postRList->end() ) { - if ( *it == p ) { - postRList->remove( it ); - it = postRList->begin(); - } else { - ++it; - } - } -} - -// Default application palettes and fonts (per widget type) -TQAsciiDict *TQApplication::app_palettes = 0; -TQAsciiDict *TQApplication::app_fonts = 0; - -#ifndef TQT_NO_SESSIONMANAGER -TQString *TQApplication::session_key = 0; // ## session key. Should be a member in 4.0 -#endif -TQWidgetList *TQApplication::popupWidgets = 0; // has keyboard input focus - -TQDesktopWidget *qt_desktopWidget = 0; // root window widgets -#ifndef TQT_NO_CLIPBOARD -TQClipboard *qt_clipboard = 0; // global clipboard object -#endif -TQWidgetList * qt_modal_stack=0; // stack of modal widgets - -// Definitions for posted events -struct TQPostEvent { - TQPostEvent( TQObject *r, TQEvent *e ): receiver( r ), event( e ) {} - ~TQPostEvent() { delete event; } - TQObject *receiver; - TQEvent *event; -}; - -class TQ_EXPORT TQPostEventList : public TQPtrList -{ -public: - TQPostEventList() : TQPtrList() {} - TQPostEventList( const TQPostEventList &list ) : TQPtrList(list) {} - ~TQPostEventList() { clear(); } - TQPostEventList &operator=(const TQPostEventList &list) - { return (TQPostEventList&)TQPtrList::operator=(list); } -}; -class TQ_EXPORT TQPostEventListIt : public TQPtrListIterator -{ -public: - TQPostEventListIt( const TQPostEventList &l ) : TQPtrListIterator(l) {} - TQPostEventListIt &operator=(const TQPostEventListIt &i) -{ return (TQPostEventListIt&)TQPtrListIterator::operator=(i); } -}; - -static TQPostEventList *globalPostedEvents = 0; // list of posted events - -uint qGlobalPostedEventsCount() -{ - if (!globalPostedEvents) - return 0; - return globalPostedEvents->count(); -} - -static TQSingleCleanupHandler qapp_cleanup_events; - -#ifndef TQT_NO_PALETTE -TQPalette *qt_std_pal = 0; - -void qt_create_std_palette() -{ - if ( qt_std_pal ) - delete qt_std_pal; - - TQColor standardLightGray( 192, 192, 192 ); - TQColor light( 255, 255, 255 ); - TQColor dark( standardLightGray.dark( 150 ) ); - TQColorGroup std_act( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - TQColorGroup std_dis( TQt::darkGray, standardLightGray, - light, dark, TQt::gray, - TQt::darkGray, std_act.background() ); - TQColorGroup std_inact( TQt::black, standardLightGray, - light, dark, TQt::gray, - TQt::black, TQt::white ); - qt_std_pal = new TQPalette( std_act, std_dis, std_inact ); -} - -static void qt_fix_tooltips() -{ - // No resources for this yet (unlike on Windows). - TQColorGroup cg( TQt::black, TQColor(255,255,220), - TQColor(96,96,96), TQt::black, TQt::black, - TQt::black, TQColor(255,255,220) ); - TQPalette pal( cg, cg, cg ); - TQApplication::setPalette( pal, TRUE, "TQTipLabel"); -} -#endif - -void TQApplication::process_cmdline( int* argcptr, char ** argv ) -{ - // process platform-indep command line - if ( !qt_is_gui_used || !*argcptr) - return; - - int argc = *argcptr; - int i, j; - - j = 1; - for ( i=1; i= 0 ) { - if ( !session_key ) - session_key = new TQString; - *session_key = session_id.mid( p +1 ); - session_id = session_id.left( p ); - } - is_session_restored = TRUE; - } -#endif - } else if ( qstrcmp(arg, "-reverse") == 0 ) { - setReverseLayout( TRUE ); - } else if ( qstrcmp(arg, "-widgetcount") == 0 ) { - widgetCount = TRUE;; - } else { - argv[j++] = argv[i]; - } -#ifndef TQT_NO_STYLE - if ( !s.isEmpty() ) { - setStyle( s ); - } -#endif - } - - if(j < argc) { -#ifdef TQ_WS_MACX - static char* empty = "\0"; - argv[j] = empty; -#else - argv[j] = 0; -#endif - *argcptr = j; - } -} - -/*! - Initializes the window system and constructs an application object - with \a argc command line arguments in \a argv. - - The global \c tqApp pointer refers to this application object. Only - one application object should be created. - - This application object must be constructed before any \link - TQPaintDevice paint tqdevices\endlink (including widgets, pixmaps, bitmaps - etc.). - - Note that \a argc and \a argv might be changed. TQt removes command - line arguments that it recognizes. The modified \a argc and \a argv - can also be accessed later with \c tqApp->argc() and \c tqApp->argv(). - The documentation for argv() tqcontains a detailed description of how - to process command line arguments. - - TQt debugging options (not available if TQt was compiled with the - TQT_NO_DEBUG flag defined): - \list - \i -nograb, tells TQt that it must never grab the mouse or the keyboard. - \i -dograb (only under X11), running under a debugger can cause - an implicit -nograb, use -dograb to override. - \i -sync (only under X11), switches to synchronous mode for - debugging. - \endlist - - See \link debug.html Debugging Techniques \endlink for a more - detailed explanation. - - All TQt programs automatically support the following command line options: - \list - \i -reverse causes text to be formatted for right-to-left languages - rather than in the usual left-to-right direction. - \i -style= \e style, sets the application GUI style. Possible values - are \c motif, \c windows, and \c platinum. If you compiled TQt - with additional styles or have additional styles as plugins these - will be available to the \c -style command line option. - \i -style \e style, is the same as listed above. - \i -session= \e session, restores the application from an earlier - \link session.html session \endlink. - \i -session \e session, is the same as listed above. - \i -widgetcount, prints debug message at the end about number of widgets left - undestroyed and maximum number of widgets existed at the same time - \endlist - - The X11 version of TQt also supports some traditional X11 - command line options: - \list - \i -display \e display, sets the X display (default is $DISPLAY). - \i -tqgeometry \e tqgeometry, sets the client tqgeometry of the - \link setMainWidget() main widget\endlink. - \i -fn or \c -font \e font, defines the application font. The - font should be specified using an X logical font description. - \i -bg or \c -background \e color, sets the default background color - and an application palette (light and dark shades are calculated). - \i -fg or \c -foreground \e color, sets the default foreground color. - \i -btn or \c -button \e color, sets the default button color. - \i -name \e name, sets the application name. - \i -title \e title, sets the application title (caption). - \i -visual \c TrueColor, forces the application to use a TrueColor visual - on an 8-bit display. - \i -ncols \e count, limits the number of colors allocated in the - color cube on an 8-bit display, if the application is using the - \c TQApplication::ManyColor color specification. If \e count is - 216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, - and 6 of blue); for other values, a cube - approximately proportional to a 2x3x1 cube is used. - \i -cmap, causes the application to install a private color map - on an 8-bit display. - \endlist - - \sa argc(), argv() -*/ - -//######### BINARY COMPATIBILITY constructor -TQApplication::TQApplication( int &argc, char **argv ) -{ - construct( argc, argv, GuiClient ); -} - - -/*! - Constructs an application object with \a argc command line arguments - in \a argv. If \a GUIenabled is TRUE, a GUI application is - constructed, otherwise a non-GUI (console) application is created. - - Set \a GUIenabled to FALSE for programs without a graphical user - interface that should be able to run without a window system. - - On X11, the window system is initialized if \a GUIenabled is TRUE. - If \a GUIenabled is FALSE, the application does not connect to the - X-server. - On Windows and Macintosh, currently the window system is always - initialized, regardless of the value of GUIenabled. This may change in - future versions of TQt. - - The following example shows how to create an application that - uses a graphical interface when available. - \code - int main( int argc, char **argv ) - { -#ifdef TQ_WS_X11 - bool useGUI = getenv( "DISPLAY" ) != 0; -#else - bool useGUI = TRUE; -#endif - TQApplication app(argc, argv, useGUI); - - if ( useGUI ) { - //start GUI version - ... - } else { - //start non-GUI version - ... - } - return app.exec(); - } -\endcode -*/ - -TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled ) -{ - construct( argc, argv, GUIenabled ? GuiClient : Tty ); -} - -/*! - Constructs an application object with \a argc command line arguments - in \a argv. - - For TQt/Embedded, passing \c TQApplication::GuiServer for \a type - makes this application the server (equivalent to running with the - -qws option). -*/ -TQApplication::TQApplication( int &argc, char **argv, Type type ) -{ - construct( argc, argv, type ); -} - -TQ_EXPORT void qt_ucm_initialize( TQApplication *theApp ) -{ - if ( tqApp ) - return; - int argc = theApp->argc(); - char **argv = theApp->argv(); - theApp->construct( argc, argv, tqApp->type() ); - - TQ_ASSERT( tqApp == theApp ); -} - -void TQApplication::construct( int &argc, char **argv, Type type ) -{ - qt_appType = type; - qt_is_gui_used = (type != Tty); - init_precmdline(); - static const char *empty = ""; - if ( argc == 0 || argv == 0 ) { - argc = 0; - argv = (char **)∅ // ouch! careful with TQApplication::argv()! - } - app_argc = argc; - app_argv = argv; - - qt_init( &argc, argv, type ); // Must be called before initialize() - process_cmdline( &argc, argv ); - initialize( argc, argv ); - if ( qt_is_gui_used ) - qt_maxWindowRect = desktop()->rect(); - if ( eventloop ) - eventloop->appStartingUp(); -} - -/*! - Returns the type of application, Tty, GuiClient or GuiServer. -*/ - -TQApplication::Type TQApplication::type() const -{ - return qt_appType; -} - -#if defined(TQ_WS_X11) -/*! - Create an application, given an already open display \a dpy. If \a - visual and \a colormap are non-zero, the application will use those as - the default Visual and Colormap contexts. - - \warning TQt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This is available only on X11. -*/ - -TQApplication::TQApplication( Display* dpy, HANDLE visual, HANDLE colormap ) -{ - static int aargc = 1; - // ### a string literal is a cont char* - // ### using it as a char* is wrong and could lead to segfaults - // ### if aargv is modified someday - static char *aargv[] = { (char*)"unknown", 0 }; - - app_argc = aargc; - app_argv = aargv; - - qt_appType = GuiClient; - qt_is_gui_used = TRUE; - qt_appType = GuiClient; - init_precmdline(); - // ... no command line. - - if ( ! dpy ) { -#ifdef TQT_CHECK_STATE - qWarning( "TQApplication: invalid Display* argument." ); -#endif // TQT_CHECK_STATE - - qt_init( &aargc, aargv, GuiClient ); - } else { - qt_init( dpy, visual, colormap ); - } - - initialize( aargc, aargv ); - - if ( qt_is_gui_used ) - qt_maxWindowRect = desktop()->rect(); - if ( eventloop ) - eventloop->appStartingUp(); -} - -/*! - Create an application, given an already open display \a dpy and using - \a argc command line arguments in \a argv. If \a - visual and \a colormap are non-zero, the application will use those as - the default Visual and Colormap contexts. - - \warning TQt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This is available only on X11. - -*/ -TQApplication::TQApplication(Display *dpy, int argc, char **argv, - HANDLE visual, HANDLE colormap) -{ - qt_appType = GuiClient; - qt_is_gui_used = TRUE; - qt_appType = GuiClient; - init_precmdline(); - - app_argc = argc; - app_argv = argv; - - if ( ! dpy ) { -#ifdef TQT_CHECK_STATE - qWarning( "TQApplication: invalid Display* argument." ); -#endif // TQT_CHECK_STATE - - qt_init( &argc, argv, GuiClient ); - } else { - qt_init(dpy, visual, colormap); - } - - process_cmdline( &argc, argv ); - initialize(argc, argv); - - if ( qt_is_gui_used ) - qt_maxWindowRect = desktop()->rect(); - if ( eventloop ) - eventloop->appStartingUp(); -} - - -#endif // TQ_WS_X11 - - -void TQApplication::init_precmdline() -{ - translators = 0; - is_app_closing = FALSE; -#ifndef TQT_NO_SESSIONMANAGER - is_session_restored = FALSE; -#endif -#if defined(TQT_CHECK_STATE) - if ( tqApp ) - qWarning( "TQApplication: There should be max one application object" ); -#endif - tqApp = (TQApplication*)this; -} - -/*! - Initializes the TQApplication object, called from the constructors. -*/ - -void TQApplication::initialize( int argc, char **argv ) -{ -#ifdef TQT_THREAD_SUPPORT - qt_mutex = new TQMutex( TRUE ); - postevent_mutex = new TQMutex( TRUE ); - qt_application_thread_id = TQThread::currentThread(); -#endif // TQT_THREAD_SUPPORT - - app_argc = argc; - app_argv = argv; - quit_now = FALSE; - quit_code = 0; - TQWidget::createMapper(); // create widget mapper -#ifndef TQT_NO_PALETTE - (void) palette(); // trigger creation of application palette -#endif - is_app_running = TRUE; // no longer starting up - -#ifndef TQT_NO_SESSIONMANAGER - // connect to the session manager - if ( !session_key ) - session_key = new TQString; - session_manager = new TQSessionManager( tqApp, session_id, *session_key ); -#endif - -} - - -/***************************************************************************** - Functions returning the active popup and modal widgets. - *****************************************************************************/ - -/*! - Returns the active popup widget. - - A popup widget is a special top level widget that sets the \c - WType_Popup widget flag, e.g. the TQPopupMenu widget. When the - application opens a popup widget, all events are sent to the popup. - Normal widgets and modal widgets cannot be accessed before the popup - widget is closed. - - Only other popup widgets may be opened when a popup widget is shown. - The popup widgets are organized in a stack. This function returns - the active popup widget at the top of the stack. - - \sa activeModalWidget(), tqtopLevelWidgets() -*/ - -TQWidget *TQApplication::activePopupWidget() -{ - return popupWidgets ? popupWidgets->getLast() : 0; -} - - -/*! - Returns the active modal widget. - - A modal widget is a special top level widget which is a subclass of - TQDialog that specifies the modal parameter of the constructor as - TRUE. A modal widget must be closed before the user can continue - with other parts of the program. - - Modal widgets are organized in a stack. This function returns - the active modal widget at the top of the stack. - - \sa activePopupWidget(), tqtopLevelWidgets() -*/ - -TQWidget *TQApplication::activeModalWidget() -{ - return qt_modal_stack ? qt_modal_stack->getFirst() : 0; -} - -/*! - Cleans up any window system resources that were allocated by this - application. Sets the global variable \c tqApp to 0. -*/ - -TQApplication::~TQApplication() -{ -#ifndef TQT_NO_CLIPBOARD - // flush clipboard contents - if ( qt_clipboard ) { - TQCustomEvent event( TQEvent::Clipboard ); - TQApplication::sendEvent( qt_clipboard, &event ); - } -#endif - - if ( eventloop ) - eventloop->appClosingDown(); - if ( postRList ) { - TQVFuncList::Iterator it = postRList->begin(); - while ( it != postRList->end() ) { // call post routines - (**it)(); - postRList->remove( it ); - it = postRList->begin(); - } - delete postRList; - postRList = 0; - } - - TQObject *tipmanager = child( "toolTipManager", "TQTipManager", FALSE ); - delete tipmanager; - - delete qt_desktopWidget; - qt_desktopWidget = 0; - is_app_closing = TRUE; - -#ifndef TQT_NO_CLIPBOARD - delete qt_clipboard; - qt_clipboard = 0; -#endif - TQWidget::destroyMapper(); -#ifndef TQT_NO_PALETTE - delete qt_std_pal; - qt_std_pal = 0; - delete app_pal; - app_pal = 0; - delete app_palettes; - app_palettes = 0; -#endif - delete app_font; - app_font = 0; - delete app_fonts; - app_fonts = 0; -#ifndef TQT_NO_STYLE - delete app_style; - app_style = 0; -#endif -#ifndef TQT_NO_CURSOR - delete app_cursor; - app_cursor = 0; -#endif -#ifndef TQT_NO_TRANSLATION - delete translators; -#endif - -#ifndef TQT_NO_DRAGANDDROP - extern TQDragManager *qt_dnd_manager; - delete qt_dnd_manager; -#endif - - qt_cleanup(); - -#ifndef TQT_NO_COMPONENT - delete app_libpaths; - app_libpaths = 0; -#endif - -#ifdef TQT_THREAD_SUPPORT - delete qt_mutex; - qt_mutex = 0; - delete postevent_mutex; - postevent_mutex = 0; -#endif // TQT_THREAD_SUPPORT - - if( tqApp == this ) { - if ( postedEvents ) - removePostedEvents( this ); - tqApp = 0; - } - is_app_running = FALSE; - - if ( widgetCount ) { - qDebug( "Widgets left: %i Max widgets: %i \n", TQWidget::instanceCounter, TQWidget::maxInstances ); - } -#ifndef TQT_NO_SESSIONMANAGER - delete session_manager; - session_manager = 0; - delete session_key; - session_key = 0; -#endif //TQT_NO_SESSIONMANAGER - - qt_explicit_app_style = FALSE; - qt_app_has_font = FALSE; - app_tracking = 0; - obey_desktop_settings = TRUE; - cursor_flash_time = 1000; - mouse_double_click_time = 400; -#ifndef TQT_NO_WHEELEVENT - wheel_scroll_lines = 3; -#endif - drag_time = 500; - drag_distance = 4; - reverse_tqlayout = FALSE; - app_strut = TQSize( 0, 0 ); - animate_ui = TRUE; - animate_menu = FALSE; - fade_menu = FALSE; - animate_combo = FALSE; - animate_tooltip = FALSE; - fade_tooltip = FALSE; - widgetCount = FALSE; -} - - -/*! - \fn int TQApplication::argc() const - - Returns the number of command line arguments. - - The documentation for argv() describes how to process command line - arguments. - - \sa argv(), TQApplication::TQApplication() -*/ - -/*! - \fn char **TQApplication::argv() const - - Returns the command line argument vector. - - \c argv()[0] is the program name, \c argv()[1] is the first - argument and \c argv()[argc()-1] is the last argument. - - A TQApplication object is constructed by passing \e argc and \e - argv from the \c main() function. Some of the arguments may be - recognized as TQt options and removed from the argument vector. For - example, the X11 version of TQt knows about \c -display, \c -font - and a few more options. - - Example: - \code - // showargs.cpp - displays program arguments in a list box - - #include - #include - - int main( int argc, char **argv ) - { - TQApplication a( argc, argv ); - TQListBox b; - a.setMainWidget( &b ); - for ( int i = 0; i < a.argc(); i++ ) // a.argc() == argc - b.insertItem( a.argv()[i] ); // a.argv()[i] == argv[i] - b.show(); - return a.exec(); - } - \endcode - - If you run \c{showargs -display unix:0 -font 9x15bold hello world} - under X11, the list box tqcontains the three strings "showargs", - "hello" and "world". - - TQt provides a global pointer, \c tqApp, that points to the - TQApplication object, and through which you can access argc() and - argv() in functions other than main(). - - \sa argc(), TQApplication::TQApplication() -*/ - -/*! - \fn void TQApplication::setArgs( int argc, char **argv ) - \internal -*/ - - -#ifndef TQT_NO_STYLE - -static TQString *qt_style_override = 0; - -/*! - Returns the application's style object. - - \sa setStyle(), TQStyle -*/ -TQStyle& TQApplication::tqstyle() -{ -#ifndef TQT_NO_STYLE - if ( app_style ) - return *app_style; - if ( !qt_is_gui_used ) - qFatal( "No style available in non-gui applications!" ); - -#if defined(TQ_WS_X11) - if(!qt_style_override) - x11_initialize_style(); // run-time search for default style -#endif - if ( !app_style ) { - // Compile-time search for default style - // - TQString style; - if ( qt_style_override ) { - style = *qt_style_override; - delete qt_style_override; - qt_style_override = 0; - } else { -# if defined(TQ_WS_WIN) && defined(TQ_OS_TEMP) - style = "PocketPC"; -#elif defined(TQ_WS_WIN) - if ( qWinVersion() >= TQt::WV_XP && qWinVersion() < TQt::WV_NT_based ) - style = "WindowsXP"; - else - style = "Windows"; // default styles for Windows -#elif defined(TQ_WS_X11) && defined(TQ_OS_SOLARIS) - style = "CDE"; // default style for X11 on Solaris -#elif defined(TQ_WS_X11) && defined(TQ_OS_IRIX) - style = "SGI"; // default style for X11 on IRIX -#elif defined(TQ_WS_X11) - style = "Motif"; // default style for X11 -#elif defined(TQ_WS_MAC) - style = "Macintosh"; // default style for all Mac's -#elif defined(TQ_WS_TQWS) - style = "Compact"; // default style for small tqdevices -#endif - } - app_style = TQStyleFactory::create( style ); - if ( !app_style && // platform default style not available, try alternatives - !(app_style = TQStyleFactory::create( "Windows" ) ) && - !(app_style = TQStyleFactory::create( "Platinum" ) ) && - !(app_style = TQStyleFactory::create( "MotifPlus" ) ) && - !(app_style = TQStyleFactory::create( "Motif" ) ) && - !(app_style = TQStyleFactory::create( "CDE" ) ) && - !(app_style = TQStyleFactory::create( "Aqua" ) ) && - !(app_style = TQStyleFactory::create( "SGI" ) ) && - !(app_style = TQStyleFactory::create( "Compact" ) ) -#ifndef TQT_NO_STRINGLIST - && !(app_style = TQStyleFactory::create( TQStyleFactory::keys()[0] ) ) -#endif - ) - qFatal( "No %s style available!", style.latin1() ); - } - - TQPalette app_pal_copy ( *app_pal ); - app_style->polish( *app_pal ); - - if ( is_app_running && !is_app_closing && (*app_pal != app_pal_copy) ) { - TQEvent e( TQEvent::ApplicationPaletteChange ); - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - sendEvent( w, &e ); - } - } - - app_style->polish( tqApp ); -#endif - return *app_style; -} - -/*! - Sets the application's GUI style to \a style. Ownership of the style - object is transferred to TQApplication, so TQApplication will delete - the style object on application exit or when a new style is set. - - Example usage: - \code - TQApplication::setStyle( new TQWindowsStyle ); - \endcode - - When switching application styles, the color palette is set back to - the initial colors or the system defaults. This is necessary since - certain styles have to adapt the color palette to be fully - style-guide compliant. - - \sa style(), TQStyle, setPalette(), desktopSettingsAware() -*/ -void TQApplication::setStyle( TQStyle *style ) -{ - TQStyle* old = app_style; - app_style = style; -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - delete old; - return; - } - - // clean up the old style - if (old) { - if ( is_app_running && !is_app_closing ) { - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( !w->testWFlags(WType_Desktop) && // except desktop - w->testWState(WState_Polished) ) { // has been polished - old->unPolish(w); - } - } - } - old->unPolish( tqApp ); - } - - // take care of possible palette requirements of certain gui - // styles. Do it before polishing the application since the style - // might call TQApplication::setStyle() itself - if ( !qt_std_pal ) - qt_create_std_palette(); - TQPalette tmpPal = *qt_std_pal; - setPalette( tmpPal, TRUE ); - - // initialize the application with the new style - app_style->polish( tqApp ); - - // re-polish existing widgets if necessary - if (old) { - if ( is_app_running && !is_app_closing ) { - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( !w->testWFlags(WType_Desktop) ) { // except desktop - if ( w->testWState(WState_Polished) ) - app_style->polish(w); // repolish - w->styleChange( *old ); - if ( w->isVisible() ){ - w->update(); - } - } - } - } - delete old; - } -} - -/*! - \overload - - Requests a TQStyle object for \a style from the TQStyleFactory. - - The string must be one of the TQStyleFactory::keys(), typically one - of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and - "compact". Depending on the platform, "windowsxp", "aqua" or - "macintosh" may be available. - - A later call to the TQApplication constructor will override the - requested style when a "-style" option is passed in as a commandline - parameter. - - Returns 0 if an unknown \a style is passed, otherwise the TQStyle object - returned is set as the application's GUI style. -*/ -TQStyle* TQApplication::setStyle( const TQString& style ) -{ -#ifdef TQ_WS_X11 - qt_explicit_app_style = TRUE; -#endif // TQ_WS_X11 - - if ( startingUp() ) { - if(qt_style_override) - *qt_style_override = style; - else - qt_style_override = new TQString(style); - return 0; - } - TQStyle *s = TQStyleFactory::create( style ); - if ( !s ) - return 0; - - setStyle( s ); - return s; -} - -#endif - - -#if 1 /* OBSOLETE */ - -TQApplication::ColorMode TQApplication::colorMode() -{ - return (TQApplication::ColorMode)app_cspec; -} - -void TQApplication::setColorMode( TQApplication::ColorMode mode ) -{ - app_cspec = mode; -} -#endif - - -/*! - Returns the color specification. - \sa TQApplication::setColorSpec() - */ - -int TQApplication::colorSpec() -{ - return app_cspec; -} - -/*! - Sets the color specification for the application to \a spec. - - The color specification controls how the application allocates colors - when run on a display with a limited amount of colors, e.g. 8 bit / 256 - color displays. - - The color specification must be set before you create the TQApplication - object. - - The options are: - \list - \i TQApplication::NormalColor. - This is the default color allocation strategy. Use this option if - your application uses buttons, menus, texts and pixmaps with few - colors. With this option, the application uses system global - colors. This works fine for most applications under X11, but on - Windows machines it may cause dithering of non-standard colors. - \i TQApplication::CustomColor. - Use this option if your application needs a small number of custom - colors. On X11, this option is the same as NormalColor. On Windows, TQt - creates a Windows palette, and allocates colors to it on demand. - \i TQApplication::ManyColor. - Use this option if your application is very color hungry - (e.g. it requires thousands of colors). - Under X11 the effect is: - \list - \i For 256-color displays which have at best a 256 color true color - visual, the default visual is used, and colors are allocated - from a color cube. The color cube is the 6x6x6 (216 color) "Web - palette"*, but the number of colors can be changed - by the \e -ncols option. The user can force the application to - use the true color visual with the \link - TQApplication::TQApplication() -visual \endlink option. - \i For 256-color displays which have a true color visual with more - than 256 colors, use that visual. Silicon Graphics X servers - have this feature, for example. They provide an 8 bit visual - by default but can deliver true color when asked. - \endlist - On Windows, TQt creates a Windows palette, and fills it with a color cube. - \endlist - - Be aware that the CustomColor and ManyColor choices may lead to colormap - flashing: The foreground application gets (most) of the available - colors, while the background windows will look less attractive. - - Example: - \code - int main( int argc, char **argv ) - { - TQApplication::setColorSpec( TQApplication::ManyColor ); - TQApplication a( argc, argv ); - ... - } - \endcode - - TQColor provides more functionality for controlling color allocation and - freeing up certain colors. See TQColor::enterAllocContext() for more - information. - - To check what mode you end up with, call TQColor::numBitPlanes() once - the TQApplication object exists. A value greater than 8 (typically - 16, 24 or 32) means true color. - - * The color cube used by TQt has 216 colors whose red, - green, and blue components always have one of the following values: - 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF. - - \sa colorSpec(), TQColor::numBitPlanes(), TQColor::enterAllocContext() */ - -void TQApplication::setColorSpec( int spec ) -{ -#if defined(TQT_CHECK_STATE) - if ( tqApp ) { - qWarning( "TQApplication::setColorSpec: This function must be " - "called before the TQApplication object is created" ); - } -#endif - app_cspec = spec; -} - -/*! - \fn TQSize TQApplication::globalStrut() - - Returns the application's global strut. - - The strut is a size object whose dimensions are the minimum that any - GUI element that the user can interact with should have. For example - no button should be resized to be smaller than the global strut size. - - \sa setGlobalStrut() -*/ - -/*! - Sets the application's global strut to \a strut. - - The strut is a size object whose dimensions are the minimum that any - GUI element that the user can interact with should have. For example - no button should be resized to be smaller than the global strut size. - - The strut size should be considered when reimplementing GUI controls - that may be used on touch-screens or similar IO-tqdevices. - - Example: - \code - TQSize& WidgetClass::tqsizeHint() const - { - return TQSize( 80, 25 ).expandedTo( TQApplication::globalStrut() ); - } - \endcode - - \sa globalStrut() -*/ - -void TQApplication::setGlobalStrut( const TQSize& strut ) -{ - app_strut = strut; -} - -#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) -extern const char *tqAppFileName(); -#endif - -#ifndef TQT_NO_DIR -#ifndef TQ_WS_WIN -static TQString resolveSymlinks( const TQString& path, int depth = 0 ) -{ - bool foundLink = FALSE; - TQString linkTarget; - TQString part = path; - int slashPos = path.length(); - - // too deep; we give up - if ( depth == 128 ) - return TQString::null; - - do { - part = part.left( slashPos ); - TQFileInfo fileInfo( part ); - if ( fileInfo.isSymLink() ) { - foundLink = TRUE; - linkTarget = fileInfo.readLink(); - break; - } - } while ( (slashPos = part.tqfindRev('/')) != -1 ); - - if ( foundLink ) { - TQString path2; - if ( linkTarget[0] == '/' ) { - path2 = linkTarget; - if ( slashPos < (int) path.length() ) - path2 += "/" + path.right( path.length() - slashPos - 1 ); - } else { - TQString relPath; - relPath = part.left( part.tqfindRev('/') + 1 ) + linkTarget; - if ( slashPos < (int) path.length() ) { - if ( !linkTarget.endsWith( "/" ) ) - relPath += "/"; - relPath += path.right( path.length() - slashPos - 1 ); - } - path2 = TQDir::current().absFilePath( relPath ); - } - path2 = TQDir::cleanDirPath( path2 ); - return resolveSymlinks( path2, depth + 1 ); - } else { - return path; - } -} -#endif // TQ_WS_WIN - -/*! - Returns the directory that tqcontains the application executable. - - For example, if you have installed TQt in the \c{C:\Trolltech\TQt} - directory, and you run the \c{demo} example, this function will - return "C:/Trolltech/TQt/examples/demo". - - On Mac OS X this will point to the directory actually containing the - executable, which may be inside of an application bundle (if the - application is bundled). - - \warning On Unix, this function assumes that argv[0] tqcontains the file - name of the executable (which it normally does). It also assumes that - the current directory hasn't been changed by the application. - - \sa applicationFilePath() -*/ -TQString TQApplication::applicationDirPath() -{ - return TQFileInfo( applicationFilePath() ).dirPath(); -} - -/*! - Returns the file path of the application executable. - - For example, if you have installed TQt in the \c{C:\Trolltech\TQt} - directory, and you run the \c{demo} example, this function will - return "C:/Trolltech/TQt/examples/demo/demo.exe". - - \warning On Unix, this function assumes that argv[0] tqcontains the file - name of the executable (which it normally does). It also assumes that - the current directory hasn't been changed by the application. - - \sa applicationDirPath() -*/ -TQString TQApplication::applicationFilePath() -{ -#if defined( TQ_WS_WIN ) - TQFileInfo filePath; - TQT_WA({ - WCHAR module_name[256]; - GetModuleFileNameW(0, module_name, sizeof(module_name)); - filePath = TQString::fromUcs2((const unsigned short *)module_name); - }, { - char module_name[256]; - GetModuleFileNameA(0, module_name, sizeof(module_name)); - filePath = TQString::fromLocal8Bit(module_name); - }); - - return filePath.filePath(); -#elif defined( TQ_WS_MAC ) - return TQDir::cleanDirPath( TQFile::decodeName( tqAppFileName() ) ); -#else - TQString argv0 = TQFile::decodeName( argv()[0] ); - TQString absPath; - - if ( argv0[0] == '/' ) { - /* - If argv0 starts with a slash, it is already an absolute - file path. - */ - absPath = argv0; - } else if ( argv0.tqfind('/') != -1 ) { - /* - If argv0 tqcontains one or more slashes, it is a file path - relative to the current directory. - */ - absPath = TQDir::current().absFilePath( argv0 ); - } else { - /* - Otherwise, the file path has to be determined using the - PATH environment variable. - */ - char *pEnv = getenv( "PATH" ); - TQStringList paths( TQStringList::split(TQChar(':'), pEnv) ); - TQStringList::const_iterator p = paths.begin(); - while ( p != paths.end() ) { - TQString candidate = TQDir::current().absFilePath( *p + "/" + argv0 ); - if ( TQFile::exists(candidate) ) { - absPath = candidate; - break; - } - ++p; - } - } - - absPath = TQDir::cleanDirPath( absPath ); - if ( TQFile::exists(absPath) ) { - return resolveSymlinks( absPath ); - } else { - return TQString::null; - } -#endif -} -#endif // TQT_NO_DIR - -#ifndef TQT_NO_COMPONENT - -/*! - Returns a list of paths that the application will search when - dynamically loading libraries. - The installation directory for plugins is the only entry if no - paths have been set. The default installation directory for plugins - is \c INSTALL/plugins, where \c INSTALL is the directory where TQt was - installed. The directory of the application executable (NOT the - working directory) is also added to the plugin paths. - - If you want to iterate over the list, you should iterate over a - copy, e.g. - \code - TQStringList list = app.libraryPaths(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - See the \link plugins-howto.html plugins documentation\endlink for a - description of how the library paths are used. - - \sa tqsetLibraryPaths(), addLibraryPath(), removeLibraryPath(), TQLibrary -*/ -TQStringList TQApplication::libraryPaths() -{ - if ( !app_libpaths ) { - app_libpaths = new TQStringList; - TQString installPathPlugins = TQString::fromLocal8Bit(qInstallPathPlugins()); - if ( TQFile::exists(installPathPlugins) ) { -#ifdef TQ_WS_WIN - installPathPlugins.tqreplace('\\', '/'); -#endif - app_libpaths->append(installPathPlugins); - } - - TQString app_location; - if (tqApp) - app_location = tqApp->applicationFilePath(); -#ifdef TQ_WS_WIN - else { - app_location = TQString(tqAppFileName()); - app_location.tqreplace('\\', '/'); - } -#endif - if (!app_location.isEmpty()) { - app_location.truncate( app_location.tqfindRev( '/' ) ); - if ( app_location != qInstallPathPlugins() && TQFile::exists( app_location ) ) - app_libpaths->append( app_location ); - } - } - return *app_libpaths; -} - - -/*! - Sets the list of directories to search when loading libraries to \a paths. - All existing paths will be deleted and the path list will consist of the - paths given in \a paths. - - \sa libraryPaths(), addLibraryPath(), removeLibraryPath(), TQLibrary - */ -void TQApplication::tqsetLibraryPaths( const TQStringList &paths ) -{ - delete app_libpaths; - app_libpaths = new TQStringList( paths ); -} - -/*! - Append \a path to the end of the library path list. If \a path is - empty or already in the path list, the path list is not changed. - - The default path list consists of a single entry, the installation - directory for plugins. The default installation directory for plugins - is \c INSTALL/plugins, where \c INSTALL is the directory where TQt was - installed. - - \sa removeLibraryPath(), libraryPaths(), tqsetLibraryPaths() - */ -void TQApplication::addLibraryPath( const TQString &path ) -{ - if ( path.isEmpty() ) - return; - - // make sure that library paths is initialized - libraryPaths(); - - if ( !app_libpaths->tqcontains( path ) ) - app_libpaths->prepend( path ); -} - -/*! - Removes \a path from the library path list. If \a path is empty or not - in the path list, the list is not changed. - - \sa addLibraryPath(), libraryPaths(), tqsetLibraryPaths() -*/ -void TQApplication::removeLibraryPath( const TQString &path ) -{ - if ( path.isEmpty() ) - return; - - // make sure that library paths is initialized - libraryPaths(); - - if ( app_libpaths->tqcontains( path ) ) - app_libpaths->remove( path ); -} -#endif //TQT_NO_COMPONENT - -/*! - Returns the application palette. - - If a widget is passed in \a w, the default palette for the - widget's class is returned. This may or may not be the application - palette. In most cases there isn't a special palette for certain - types of widgets, but one notable exception is the popup menu under - Windows, if the user has defined a special background color for - menus in the display settings. - - \sa setPalette(), TQWidget::palette() -*/ -#ifndef TQT_NO_PALETTE -TQPalette TQApplication::palette(const TQWidget* w) -{ -#if defined(TQT_CHECK_STATE) - if ( !tqApp ) - qWarning( "TQApplication::palette: This function can only be " - "called after the TQApplication object has been created" ); -#endif - if ( !app_pal ) { - if ( !qt_std_pal ) - qt_create_std_palette(); - app_pal = new TQPalette( *qt_std_pal ); - qt_fix_tooltips(); - } - - if ( w && app_palettes ) { - TQPalette* wp = app_palettes->tqfind( w->className() ); - if ( wp ) - return *wp; - TQAsciiDictIterator it( *app_palettes ); - const char* name; - while ( (name=it.currentKey()) != 0 ) { - if ( w->inherits( name ) ) - return *it.current(); - ++it; - } - } - return *app_pal; -} - -/*! - Changes the default application palette to \a palette. If \a - informWidgets is TRUE, then existing widgets are informed about the - change and may adjust themselves to the new application - setting. If \a informWidgets is FALSE, the change only affects newly - created widgets. - - If \a className is passed, the change applies only to widgets that - inherit \a className (as reported by TQObject::inherits()). If - \a className is left 0, the change affects all widgets, thus overriding - any previously set class specific palettes. - - The palette may be changed according to the current GUI style in - TQStyle::polish(). - - \sa TQWidget::setPalette(), palette(), TQStyle::polish() -*/ - -void TQApplication::setPalette( const TQPalette &palette, bool informWidgets, - const char* className ) -{ - TQPalette pal = palette; - TQPalette *oldpal = 0; -#ifndef TQT_NO_STYLE - if ( !startingUp() ) // on startup this has been done already - tqApp->style().polish( pal ); // NB: non-const reference -#endif - bool all = FALSE; - if ( !className ) { - if ( !app_pal ) { - app_pal = new TQPalette( pal ); - TQ_CHECK_PTR( app_pal ); - } else { - *app_pal = pal; - } - all = app_palettes != 0; - delete app_palettes; - app_palettes = 0; - qt_fix_tooltips(); - } else { - if ( !app_palettes ) { - app_palettes = new TQAsciiDict; - TQ_CHECK_PTR( app_palettes ); - app_palettes->setAutoDelete( TRUE ); - } - oldpal = app_palettes->tqfind( className ); - app_palettes->insert( className, new TQPalette( pal ) ); - } - if ( informWidgets && is_app_running && !is_app_closing ) { - if ( !oldpal || ( *oldpal != pal ) ) { - TQEvent e( TQEvent::ApplicationPaletteChange ); - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( all || (!className && w->isTopLevel() ) || w->inherits(className) ) // matching class - sendEvent( w, &e ); - } - } - } -} - -#endif // TQT_NO_PALETTE - -/*! - Returns the default font for the widget \a w, or the default - application font if \a w is 0. - - \sa setFont(), fontMetrics(), TQWidget::font() -*/ - -TQFont TQApplication::font( const TQWidget *w ) -{ - if ( w && app_fonts ) { - TQFont* wf = app_fonts->tqfind( w->className() ); - if ( wf ) - return *wf; - TQAsciiDictIterator it( *app_fonts ); - const char* name; - while ( (name=it.currentKey()) != 0 ) { - if ( w->inherits( name ) ) - return *it.current(); - ++it; - } - } - if ( !app_font ) { - app_font = new TQFont( "Helvetica" ); - TQ_CHECK_PTR( app_font ); - } - return *app_font; -} - -/*! Changes the default application font to \a font. If \a - informWidgets is TRUE, then existing widgets are informed about the - change and may adjust themselves to the new application - setting. If \a informWidgets is FALSE, the change only affects newly - created widgets. If \a className is passed, the change applies only - to classes that inherit \a className (as reported by - TQObject::inherits()). - - On application start-up, the default font depends on the window - system. It can vary depending on both the window system version and - the locale. This function lets you override the default font; but - overriding may be a bad idea because, for example, some locales need - extra-large fonts to support their special characters. - - \sa font(), fontMetrics(), TQWidget::setFont() -*/ - -void TQApplication::setFont( const TQFont &font, bool informWidgets, - const char* className ) -{ - bool all = FALSE; - if ( !className ) { - qt_app_has_font = TRUE; - if ( !app_font ) { - app_font = new TQFont( font ); - TQ_CHECK_PTR( app_font ); - } else { - *app_font = font; - } - - // make sure the application font is complete - app_font->detach(); - app_font->d->tqmask = TQFontPrivate::Complete; - - all = app_fonts != 0; - delete app_fonts; - app_fonts = 0; - } else { - if (!app_fonts){ - app_fonts = new TQAsciiDict; - TQ_CHECK_PTR( app_fonts ); - app_fonts->setAutoDelete( TRUE ); - } - TQFont* fnt = new TQFont(font); - TQ_CHECK_PTR( fnt ); - app_fonts->insert(className, fnt); - } - if ( informWidgets && is_app_running && !is_app_closing ) { - TQEvent e( TQEvent::ApplicationFontChange ); - TQWidgetIntDictIt it( *((TQWidgetIntDict*)TQWidget::wmapper()) ); - register TQWidget *w; - while ( (w=it.current()) ) { // for all widgets... - ++it; - if ( all || (!className && w->isTopLevel() ) || w->inherits(className) ) // matching class - sendEvent( w, &e ); - } - } -} - - -/*! - Initialization of the appearance of the widget \a w \e before it is first - shown. - - Usually widgets call this automatically when they are polished. It - may be used to do some style-based central customization of widgets. - - Note that you are not limited to the public functions of TQWidget. - Instead, based on meta information like TQObject::className() you are - able to customize any kind of widget. - - \sa TQStyle::polish(), TQWidget::polish(), setPalette(), setFont() -*/ - -void TQApplication::polish( TQWidget *w ) -{ -#ifndef TQT_NO_STYLE - w->style().polish( w ); -#endif -} - - -/*! - Returns a list of the top level widgets in the application. - - The list is created using \c new and must be deleted by the caller. - - The list is empty (TQPtrList::isEmpty()) if there are no top level - widgets. - - Note that some of the top level widgets may be hidden, for example - the tooltip if no tooltip is currently shown. - - Example: - \code - // Show all hidden top level widgets. - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - TQWidgetListIt it( *list ); // iterate over the widgets - TQWidget * w; - while ( (w=it.current()) != 0 ) { // for each top level widget... - ++it; - if ( !w->isVisible() ) - w->show(); - } - delete list; // delete the list, not the widgets - \endcode - - \warning Delete the list as soon you have finished using it. - The widgets in the list may be deleted by someone else at any time. - - \sa allWidgets(), TQWidget::isTopLevel(), TQWidget::isVisible(), - TQPtrList::isEmpty() -*/ - -TQWidgetList *TQApplication::tqtopLevelWidgets() -{ - return TQWidget::tlwList(); -} - -/*! - Returns a list of all the widgets in the application. - - The list is created using \c new and must be deleted by the caller. - - The list is empty (TQPtrList::isEmpty()) if there are no widgets. - - Note that some of the widgets may be hidden. - - Example that updates all widgets: - \code - TQWidgetList *list = TQApplication::allWidgets(); - TQWidgetListIt it( *list ); // iterate over the widgets - TQWidget * w; - while ( (w=it.current()) != 0 ) { // for each widget... - ++it; - w->update(); - } - delete list; // delete the list, not the widgets - \endcode - - The TQWidgetList class is defined in the \c tqwidgetlist.h header - file. - - \warning Delete the list as soon as you have finished using it. - The widgets in the list may be deleted by someone else at any time. - - \sa tqtopLevelWidgets(), TQWidget::isVisible(), TQPtrList::isEmpty(), -*/ - -TQWidgetList *TQApplication::allWidgets() -{ - return TQWidget::wList(); -} - -/*! - \fn TQWidget *TQApplication::tqfocusWidget() const - - Returns the application widget that has the keyboard input focus, or - 0 if no widget in this application has the focus. - - \sa TQWidget::setFocus(), TQWidget::hasFocus(), activeWindow() -*/ - -/*! - \fn TQWidget *TQApplication::activeWindow() const - - Returns the application top-level window that has the keyboard input - focus, or 0 if no application window has the focus. Note that - there might be an activeWindow() even if there is no tqfocusWidget(), - for example if no widget in that window accepts key events. - - \sa TQWidget::setFocus(), TQWidget::hasFocus(), tqfocusWidget() -*/ - -/*! - Returns display (screen) font metrics for the application font. - - \sa font(), setFont(), TQWidget::fontMetrics(), TQPainter::fontMetrics() -*/ - -TQFontMetrics TQApplication::fontMetrics() -{ - return desktop()->fontMetrics(); -} - - - -/*! - Tells the application to exit with return code 0 (success). - Equivalent to calling TQApplication::exit( 0 ). - - It's common to connect the lastWindowClosed() signal to quit(), and - you also often connect e.g. TQButton::clicked() or Q_SIGNALS in - TQAction, TQPopupMenu or TQMenuBar to it. - - Example: - \code - TQPushButton *quitButton = new TQPushButton( "Quit" ); - connect( quitButton, TQT_SIGNAL(clicked()), tqApp, TQT_SLOT(quit()) ); - \endcode - - \sa exit() aboutToQuit() lastWindowClosed() TQAction -*/ - -void TQApplication::quit() -{ - TQApplication::exit( 0 ); -} - - -/*! - Closes all top-level windows. - - This function is particularly useful for applications with many - top-level windows. It could, for example, be connected to a "Quit" - entry in the file menu as shown in the following code example: - - \code - // the "Quit" menu entry should try to close all windows - TQPopupMenu* file = new TQPopupMenu( this ); - file->insertItem( "&Quit", tqApp, TQT_SLOT(closeAllWindows()), CTRL+Key_Q ); - - // when the last window is closed, the application should quit - connect( tqApp, TQT_SIGNAL( lastWindowClosed() ), tqApp, TQT_SLOT( quit() ) ); - \endcode - - The windows are closed in random order, until one window does not - accept the close event. - - \sa TQWidget::close(), TQWidget::closeEvent(), lastWindowClosed(), - quit(), tqtopLevelWidgets(), TQWidget::isTopLevel() - - */ -void TQApplication::closeAllWindows() -{ - bool did_close = TRUE; - TQWidget *w; - while((w = activeModalWidget()) && did_close) { - if(w->isHidden()) - break; - did_close = w->close(); - } - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - for ( w = list->first(); did_close && w; ) { - if ( !w->isHidden() ) { - did_close = w->close(); - delete list; - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - } - delete list; -} - -/*! - Displays a simple message box about TQt. 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. - - This function is a convenience slot for TQMessageBox::aboutTQt(). -*/ -void TQApplication::aboutTQt() -{ -#ifndef TQT_NO_MESSAGEBOX - TQMessageBox::aboutTQt( mainWidget() ); -#endif // TQT_NO_MESSAGEBOX -} - - -/*! - \fn void TQApplication::lastWindowClosed() - - This signal is emitted when the user has closed the last - top level window. - - The signal is very useful when your application has many top level - widgets but no main widget. You can then connect it to the quit() - slot. - - For convenience, this signal is \e not emitted for transient top level - widgets such as popup menus and dialogs. - - \sa mainWidget(), tqtopLevelWidgets(), TQWidget::isTopLevel(), TQWidget::close() -*/ - -/*! - \fn void TQApplication::aboutToQuit() - - This signal is emitted when the application is about to quit the - main event loop, e.g. when the event loop level drops to zero. - This may happen either after a call to quit() from inside the - application or when the users shuts down the entire desktop session. - - The signal is particularly useful if your application has to do some - last-second cleanup. Note that no user interaction is possible in - this state. - - \sa quit() -*/ - - -/*! - \fn void TQApplication::guiThreadAwake() - - This signal is emitted after the event loop returns from a function - that could block. - - \sa wakeUpGuiThread() -*/ - - -/*! - \fn bool TQApplication::sendEvent( TQObject *receiver, TQEvent *event ) - - Sends event \a event directly to receiver \a receiver, using the - notify() function. Returns the value that was returned from the event - handler. - - The event is \e not deleted when the event has been sent. The normal - approach is to create the event on the stack, e.g. - \code - TQMouseEvent me( TQEvent::MouseButtonPress, pos, 0, 0 ); - TQApplication::sendEvent( mainWindow, &me ); - \endcode - If you create the event on the heap you must delete it. - - \sa postEvent(), notify() -*/ - -/*! - Sends event \a e to \a receiver: \a {receiver}->event(\a e). - Returns the value that is returned from the receiver's event handler. - - For certain types of events (e.g. mouse and key events), - the event will be propagated to the receiver's tqparent and so on up to - the top-level object if the receiver is not interested in the event - (i.e., it returns FALSE). - - There are five different ways that events can be processed; - reimplementing this virtual function is just one of them. All five - approaches are listed below: - \list 1 - \i Reimplementing this function. This is very powerful, providing - complete control; but only one subclass can be tqApp. - - \i Installing an event filter on tqApp. Such an event filter is able - to process all events for all widgets, so it's just as powerful as - reimplementing notify(); furthermore, it's possible to have more - than one application-global event filter. Global event filters even - see mouse events for \link TQWidget::isEnabled() disabled - widgets, \endlink and if \link setGlobalMouseTracking() global mouse - tracking \endlink is enabled, as well as mouse move events for all - widgets. - - \i Reimplementing TQObject::event() (as TQWidget does). If you do - this you get Tab key presses, and you get to see the events before - any widget-specific event filters. - - \i Installing an event filter on the object. Such an event filter - gets all the events except Tab and Shift-Tab key presses. - - \i Reimplementing paintEvent(), mousePressEvent() and so - on. This is the commonest, easiest and least powerful way. - \endlist - - \sa TQObject::event(), installEventFilter() -*/ - -bool TQApplication::notify( TQObject *receiver, TQEvent *e ) -{ - // no events are delivered after ~TQApplication() has started - if ( is_app_closing ) - return FALSE; - - if ( receiver == 0 ) { // serious error -#if defined(TQT_CHECK_NULL) - qWarning( "TQApplication::notify: Unexpected null receiver" ); -#endif - return FALSE; - } - - if ( e->type() == TQEvent::ChildRemoved && receiver->postedEvents && globalPostedEvents) { - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - // the TQObject destructor calls TQObject::removeChild, which calls - // TQApplication::sendEvent() directly. this can happen while the event - // loop is in the middle of posting events, and when we get here, we may - // not have any more posted events for this object. - if ( receiver->postedEvents ) { - // if this is a child remove event and the child insert - // hasn't been dispatched yet, kill that insert - TQPostEventList * l = receiver->postedEvents; - TQObject * c = ((TQChildEvent*)e)->child(); - TQPostEvent * pe; - l->first(); - while( ( pe = l->current()) != 0 ) { - if ( pe->event && pe->receiver == receiver && - pe->event->type() == TQEvent::ChildInserted && - ((TQChildEvent*)pe->event)->child() == c ) { - pe->event->posted = FALSE; - delete pe->event; - pe->event = 0; - l->remove(); - continue; - } - l->next(); - } - } - } - - bool res = FALSE; - if ( !receiver->isWidgetType() ) - res = internalNotify( receiver, e ); - else switch ( e->type() ) { -#ifndef TQT_NO_ACCEL - case TQEvent::Accel: - { - TQKeyEvent* key = (TQKeyEvent*) e; - res = internalNotify( receiver, e ); - - if ( !res && !key->isAccepted() ) - res = qt_dispatchAccelEvent( (TQWidget*)receiver, key ); - - // next lines are for compatibility with TQt <= 3.0.x: old - // TQAccel was listening on toplevel widgets - if ( !res && !key->isAccepted() && !((TQWidget*)receiver)->isTopLevel() ) - res = internalNotify( ((TQWidget*)receiver)->tqtopLevelWidget(), e ); - } - break; -#endif //TQT_NO_ACCEL - case TQEvent::KeyPress: - case TQEvent::KeyRelease: - case TQEvent::AccelOverride: - { - TQWidget* w = (TQWidget*)receiver; - TQKeyEvent* key = (TQKeyEvent*) e; -#ifndef TQT_NO_ACCEL - if ( qt_tryComposeUnicode( w, key ) ) - break; -#endif - bool def = key->isAccepted(); - while ( w ) { - if ( def ) - key->accept(); - else - key->ignore(); - res = internalNotify( w, e ); - if ( res || key->isAccepted() ) - break; - w = w->parentWidget( TRUE ); - } - } - break; - case TQEvent::MouseButtonPress: - if ( e->spontaneous() ) { - TQWidget* fw = (TQWidget*)receiver; - while ( fw->focusProxy() ) - fw = fw->focusProxy(); - if ( fw->isEnabled() && fw->focusPolicy() & TQWidget::ClickFocus ) { - TQFocusEvent::setReason( TQFocusEvent::Mouse); - fw->setFocus(); - TQFocusEvent::resetReason(); - } - } - // fall through intended - case TQEvent::MouseButtonRelease: - case TQEvent::MouseButtonDblClick: - case TQEvent::MouseMove: - { - TQWidget* w = (TQWidget*)receiver; - TQMouseEvent* mouse = (TQMouseEvent*) e; - TQPoint relpos = mouse->pos(); - while ( w ) { - TQMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->state()); - me.spont = mouse->spontaneous(); - res = internalNotify( w, w == receiver ? mouse : &me ); - e->spont = FALSE; - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - mouse->accept(); - else - mouse->ignore(); - } - break; -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - { - if ( e->spontaneous() ) { - TQWidget* fw = (TQWidget*)receiver; - while ( fw->focusProxy() ) - fw = fw->focusProxy(); - if ( fw->isEnabled() && (fw->focusPolicy() & TQWidget::WheelFocus) == TQWidget::WheelFocus ) { - TQFocusEvent::setReason( TQFocusEvent::Mouse); - fw->setFocus(); - TQFocusEvent::resetReason(); - } - } - - TQWidget* w = (TQWidget*)receiver; - TQWheelEvent* wheel = (TQWheelEvent*) e; - TQPoint relpos = wheel->pos(); - while ( w ) { - TQWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->state(), wheel->orientation()); - we.spont = wheel->spontaneous(); - res = internalNotify( w, w == receiver ? wheel : &we ); - e->spont = FALSE; - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - wheel->accept(); - else - wheel->ignore(); - } - break; -#endif - case TQEvent::ContextMenu: - { - TQWidget* w = (TQWidget*)receiver; - TQContextMenuEvent *context = (TQContextMenuEvent*) e; - TQPoint relpos = context->pos(); - while ( w ) { - TQContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->state()); - ce.spont = e->spontaneous(); - res = internalNotify( w, w == receiver ? context : &ce ); - e->spont = FALSE; - - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - context->accept(); - else - context->ignore(); - } - break; -#if defined (TQT_TABLET_SUPPORT) - case TQEvent::TabletMove: - case TQEvent::TabletPress: - case TQEvent::TabletRelease: - { - TQWidget *w = (TQWidget*)receiver; - TQTabletEvent *tablet = (TQTabletEvent*)e; - TQPoint relpos = tablet->pos(); - while ( w ) { - TQTabletEvent te(tablet->pos(), tablet->globalPos(), tablet->tqdevice(), - tablet->pressure(), tablet->xTilt(), tablet->yTilt(), - tablet->uniqueId()); - te.spont = e->spontaneous(); - res = internalNotify( w, w == receiver ? tablet : &te ); - e->spont = FALSE; - if (res || w->isTopLevel() || w->testWFlags(WNoMousePropagation)) - break; - - relpos += w->pos(); - w = w->parentWidget(); - } - if ( res ) - tablet->accept(); - else - tablet->ignore(); - chokeMouse = tablet->isAccepted(); - } - break; -#endif - default: - res = internalNotify( receiver, e ); - break; - } - - return res; -} - -/*!\reimp - -*/ -bool TQApplication::event( TQEvent *e ) -{ - if(e->type() == TQEvent::Close) { - TQCloseEvent *ce = (TQCloseEvent*)e; - ce->accept(); - closeAllWindows(); - - TQWidgetList *list = tqtopLevelWidgets(); - for(TQWidget *w = list->first(); w; w = list->next()) { - if ( !w->isHidden() && !w->isDesktop() && !w->isPopup() && - (!w->isDialog() || !w->parentWidget())) { - ce->ignore(); - break; - } - } - if(ce->isAccepted()) - return TRUE; - } else if (e->type() == TQEvent::Quit) { - quit(); - return TRUE; - } - return TQObject::event(e); -} - -/*!\internal - - Helper function called by notify() - */ -bool TQApplication::internalNotify( TQObject *receiver, TQEvent * e) -{ - if ( eventFilters ) { - TQObjectListIt it( *eventFilters ); - register TQObject *obj; - while ( (obj=it.current()) != 0 ) { // send to all filters - ++it; // until one returns TRUE - if ( obj->eventFilter(receiver,e) ) - return TRUE; - } - } - - bool consumed = FALSE; - bool handled = FALSE; - if ( receiver->isWidgetType() ) { - TQWidget *widget = (TQWidget*)receiver; - - // toggle HasMouse widget state on enter and leave - if ( e->type() == TQEvent::Enter || e->type() == TQEvent::DragEnter ) - widget->setWState( WState_HasMouse ); - else if ( e->type() == TQEvent::Leave || e->type() == TQEvent::DragLeave ) - widget->clearWState( WState_HasMouse ); - - // throw away any mouse-tracking-only mouse events - if ( e->type() == TQEvent::MouseMove && - (((TQMouseEvent*)e)->state()&TQMouseEvent::MouseButtonMask) == 0 && - !widget->hasMouseTracking() ) { - handled = TRUE; - consumed = TRUE; - } else if ( !widget->isEnabled() ) { // throw away mouse events to disabled widgets - switch(e->type()) { - case TQEvent::MouseButtonPress: - case TQEvent::MouseButtonRelease: - case TQEvent::MouseButtonDblClick: - case TQEvent::MouseMove: - ( (TQMouseEvent*) e)->ignore(); - handled = TRUE; - consumed = TRUE; - break; -#ifndef TQT_NO_DRAGANDDROP - case TQEvent::DragEnter: - case TQEvent::DragMove: - ( (TQDragMoveEvent*) e)->ignore(); - handled = TRUE; - break; - - case TQEvent::DragLeave: - case TQEvent::DragResponse: - handled = TRUE; - break; - - case TQEvent::Drop: - ( (TQDropEvent*) e)->ignore(); - handled = TRUE; - break; -#endif -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - ( (TQWheelEvent*) e)->ignore(); - handled = TRUE; - break; -#endif - case TQEvent::ContextMenu: - ( (TQContextMenuEvent*) e)->ignore(); - handled = TRUE; - break; - default: - break; - } - } - - } - - if (!handled) - consumed = receiver->event( e ); - e->spont = FALSE; - return consumed; -} - -/*! - Returns TRUE if an application object has not been created yet; - otherwise returns FALSE. - - \sa closingDown() -*/ - -bool TQApplication::startingUp() -{ - return !is_app_running; -} - -/*! - Returns TRUE if the application objects are being destroyed; - otherwise returns FALSE. - - \sa startingUp() -*/ - -bool TQApplication::closingDown() -{ - return is_app_closing; -} - - -/*! - Processes pending events, for 3 seconds or until there are no more - events to process, whichever is shorter. - - You can call this function occasionally when your program is busy - performing a long operation (e.g. copying a file). - - \sa exec(), TQTimer, TQEventLoop::processEvents() -*/ - -void TQApplication::processEvents() -{ - processEvents( 3000 ); -} - -/*! - \overload - - Processes pending events for \a maxtime milliseconds or until - there are no more events to process, whichever is shorter. - - You can call this function occasionally when you program is busy - doing a long operation (e.g. copying a file). - - \sa exec(), TQTimer, TQEventLoop::processEvents() -*/ -void TQApplication::processEvents( int maxtime ) -{ - eventLoop()->processEvents( TQEventLoop::AllEvents, maxtime ); -} - -/*! \obsolete - Waits for an event to occur, processes it, then returns. - - This function is useful for adapting TQt to situations where the - event processing must be grafted onto existing program loops. - - Using this function in new applications may be an indication of design - problems. - - \sa processEvents(), exec(), TQTimer -*/ - -void TQApplication::processOneEvent() -{ - eventLoop()->processEvents( TQEventLoop::AllEvents | - TQEventLoop::WaitForMore ); -} - -/***************************************************************************** - Main event loop wrappers - *****************************************************************************/ - -/*! - Returns the application event loop. This function will return - zero if called during and after destroying TQApplication. - - To create your own instance of TQEventLoop or TQEventLoop subclass create - it before you create the TQApplication object. - - \sa TQEventLoop -*/ -TQEventLoop *TQApplication::eventLoop() -{ - if ( !eventloop && !is_app_closing ) - (void) new TQEventLoop( tqApp, "default event loop" ); - return eventloop; -} - - -/*! - Enters the main event loop and waits until exit() is called or the - main widget is destroyed, and returns the value that was set to - exit() (which is 0 if exit() is called via quit()). - - It is necessary to call this function to start event handling. The - main event loop receives events from the window system and - dispatches these to the application widgets. - - Generally speaking, no user interaction can take place before - calling exec(). As a special case, modal widgets like TQMessageBox - can be used before calling exec(), because modal widgets call - exec() to start a local event loop. - - To make your application perform idle processing, i.e. executing a - special function whenever there are no pending events, use a - TQTimer with 0 timeout. More advanced idle processing schemes can - be achieved using processEvents(). - - \sa quit(), exit(), processEvents(), setMainWidget() -*/ -int TQApplication::exec() -{ - return eventLoop()->exec(); -} - -/*! - Tells the application to exit with a return code. - - After this function has been called, the application leaves the main - event loop and returns from the call to exec(). The exec() function - returns \a retcode. - - By convention, a \a retcode of 0 means success, and any non-zero - value indicates an error. - - Note that unlike the C library function of the same name, this - function \e does return to the caller -- it is event processing that - stops. - - \sa quit(), exec() -*/ -void TQApplication::exit( int retcode ) -{ - tqApp->eventLoop()->exit( retcode ); -} - -/*! - \obsolete - - This function enters the main event loop (recursively). Do not call - it unless you really know what you are doing. - - Use TQApplication::eventLoop()->enterLoop() instead. - -*/ -int TQApplication::enter_loop() -{ - return eventLoop()->enterLoop(); -} - -/*! - \obsolete - - This function exits from a recursive call to the main event loop. - Do not call it unless you are an expert. - - Use TQApplication::eventLoop()->exitLoop() instead. - -*/ -void TQApplication::exit_loop() -{ - eventLoop()->exitLoop(); -} - -/*! - \obsolete - - Returns the current loop level. - - Use TQApplication::eventLoop()->loopLevel() instead. - -*/ -int TQApplication::loopLevel() const -{ - return eventLoop()->loopLevel(); -} - -/*! - - Wakes up the GUI thread. - - \sa guiThreadAwake() \link threads.html Thread Support in TQt\endlink -*/ -void TQApplication::wakeUpGuiThread() -{ - eventLoop()->wakeUp(); -} - -/*! - This function returns TRUE if there are pending events; otherwise - returns FALSE. Pending events can be either from the window system - or posted events using TQApplication::postEvent(). -*/ -bool TQApplication::hasPendingEvents() -{ - return eventLoop()->hasPendingEvents(); -} - -#if !defined(TQ_WS_X11) - -// The doc and X implementation of these functions is in qapplication_x11.cpp - -void TQApplication::flushX() {} // do nothing - -void TQApplication::syncX() {} // do nothing - -#endif - -/*! - \fn void TQApplication::setWinStyleHighlightColor( const TQColor & ) - \obsolete - - Sets the color used to mark selections in windows style for all widgets - in the application. Will tqrepaint all widgets if the color is changed. - - The default color is \c darkBlue. - \sa winStyleHighlightColor() -*/ - -/*! - \fn const TQColor& TQApplication::winStyleHighlightColor() - \obsolete - - Returns the color used to mark selections in windows style. - - \sa setWinStyleHighlightColor() -*/ - -/*! - Returns the version of the Windows operating system that is running: - - \list - \i TQt::WV_95 - Windows 95 - \i TQt::WV_98 - Windows 98 - \i TQt::WV_Me - Windows Me - \i TQt::WV_NT - Windows NT 4.x - \i TQt::WV_2000 - Windows 2000 (NT5) - \i TQt::WV_XP - Windows XP - \i TQt::WV_2003 - Windows Server 2003 family - \i TQt::WV_CE - Windows CE - \i TQt::WV_CENET - Windows CE.NET - \endlist - - Note that this function is implemented for the Windows version - of TQt only. -*/ - -#if defined(TQ_OS_CYGWIN) -TQt::WindowsVersion TQApplication::winVersion() -{ - return qt_winver; -} -#endif - -#ifndef TQT_NO_TRANSLATION - -bool qt_detectRTLLanguage() -{ - return TQApplication::tr( "TQT_LAYOUT_DIRECTION", - "Translate this string to the string 'LTR' in left-to-right" - " languages or to 'RTL' in right-to-left languages (such as Hebrew" - " and Arabic) to get proper widget tqlayout." ) == "RTL"; -} - -/*! - Adds the message file \a mf to the list of message files to be used - for translations. - - Multiple message files can be installed. Translations are searched - for in the last installed message file, then the one from last, and - so on, back to the first installed message file. The search stops as - soon as a matching translation is found. - - \sa removeTranslator() translate() TQTranslator::load() -*/ - -void TQApplication::installTranslator( TQTranslator * mf ) -{ - if ( !mf ) - return; - if ( !translators ) - translators = new TQValueList; - - translators->prepend( mf ); - -#ifndef TQT_NO_TRANSLATION_BUILDER - if ( mf->isEmpty() ) - return; -#endif - - // hook to set the tqlayout direction of dialogs - setReverseLayout( qt_detectRTLLanguage() ); - - TQWidgetList *list = tqtopLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget *w; - while ( ( w=it.current() ) != 0 ) { - ++it; - if (!w->isDesktop()) - postEvent( w, new TQEvent( TQEvent::LanguageChange ) ); - } - delete list; -} - -/*! - Removes the message file \a mf from the list of message files used by - this application. (It does not delete the message file from the file - system.) - - \sa installTranslator() translate(), TQObject::tr() -*/ - -void TQApplication::removeTranslator( TQTranslator * mf ) -{ - if ( !translators || !mf ) - return; - - if ( translators->remove( mf ) && ! tqApp->closingDown() ) { - setReverseLayout( qt_detectRTLLanguage() ); - - TQWidgetList *list = tqtopLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget *w; - while ( ( w=it.current() ) != 0 ) { - ++it; - postEvent( w, new TQEvent( TQEvent::LanguageChange ) ); - } - delete list; - } -} - -#ifndef TQT_NO_TEXTCODEC -/*! \obsolete - This is the same as TQTextCodec::setCodecForTr(). -*/ -void TQApplication::setDefaultCodec( TQTextCodec* codec ) -{ - TQTextCodec::setCodecForTr( codec ); -} - -/*! \obsolete - Returns TQTextCodec::codecForTr(). -*/ -TQTextCodec* TQApplication::defaultCodec() const -{ - return TQTextCodec::codecForTr(); -} -#endif //TQT_NO_TEXTCODEC - -/*! \enum TQApplication::Encoding - - This enum type defines the 8-bit encoding of character string - arguments to translate(): - - \value DefaultCodec - the encoding specified by - TQTextCodec::codecForTr() (Latin-1 if none has been set) - \value UnicodeUTF8 - UTF-8 - - \sa TQObject::tr(), TQObject::trUtf8(), TQString::fromUtf8() -*/ - -/*! \reentrant - Returns the translation text for \a sourceText, by querying the - installed messages files. The message files are searched from the most - recently installed message file back to the first installed message - file. - - TQObject::tr() and TQObject::trUtf8() provide this functionality more - conveniently. - - \a context is typically a class name (e.g., "MyDialog") and - \a sourceText is either English text or a short identifying text, if - the output text will be very long (as for help texts). - - \a comment is a disambiguating comment, for when the same \a - sourceText is used in different roles within the same context. By - default, it is null. \a encoding indicates the 8-bit encoding of - character stings - - See the \l TQTranslator documentation for more information about - contexts and comments. - - If none of the message files contain a translation for \a - sourceText in \a context, this function returns a TQString - equivalent of \a sourceText. The encoding of \a sourceText is - specified by \e encoding; it defaults to \c DefaultCodec. - - This function is not virtual. You can use alternative translation - techniques by subclassing \l TQTranslator. - - \warning This method is reentrant only if all translators are - installed \e before calling this method. Installing or removing - translators while performing translations is not supported. Doing - so will most likely result in crashes or other undesirable behavior. - - \sa TQObject::tr() installTranslator() defaultCodec() -*/ - -TQString TQApplication::translate( const char * context, const char * sourceText, - const char * comment, Encoding encoding ) const -{ - if ( !sourceText ) - return TQString::null; - - if ( translators ) { - TQValueList::iterator it; - TQTranslator * mf; - TQString result; - for ( it = translators->begin(); it != translators->end(); ++it ) { - mf = *it; - result = mf->tqfindMessage( context, sourceText, comment ).translation(); - if ( !result.isNull() ) - return result; - } - } -#ifndef TQT_NO_TEXTCODEC - if ( encoding == UnicodeUTF8 ) - return TQString::fromUtf8( sourceText ); - else if ( TQTextCodec::codecForTr() != 0 ) - return TQTextCodec::codecForTr()->toUnicode( sourceText ); - else -#endif - return TQString::tqfromLatin1( sourceText ); -} - -#endif - -/***************************************************************************** - TQApplication management of posted events - *****************************************************************************/ - -//see also notify(), which does the removal of ChildInserted when ChildRemoved. - -/*! - Adds the event \a event with the object \a receiver as the receiver of the - event, to an event queue and returns immediately. - - The event must be allocated on the heap since the post event queue - will take ownership of the event and delete it once it has been posted. - - When control returns to the main event loop, all events that are - stored in the queue will be sent using the notify() function. - - \threadsafe - - \sa sendEvent(), notify() -*/ - -void TQApplication::postEvent( TQObject *receiver, TQEvent *event ) -{ - if ( receiver == 0 ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQApplication::postEvent: Unexpected null receiver" ); -#endif - delete event; - return; - } - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - if ( !globalPostedEvents ) { // create list - globalPostedEvents = new TQPostEventList; - TQ_CHECK_PTR( globalPostedEvents ); - globalPostedEvents->setAutoDelete( TRUE ); - qapp_cleanup_events.set( &globalPostedEvents ); - } - - if ( !receiver->postedEvents ) - receiver->postedEvents = new TQPostEventList; - TQPostEventList * l = receiver->postedEvents; - - // if this is one of the compressible events, do compression - if ( event->type() == TQEvent::Paint || - event->type() == TQEvent::LayoutHint || - event->type() == TQEvent::Resize || - event->type() == TQEvent::Move || - event->type() == TQEvent::LanguageChange ) { - l->first(); - TQPostEvent * cur = 0; - for ( ;; ) { - while ( (cur=l->current()) != 0 && - ( cur->receiver != receiver || - cur->event == 0 || - cur->event->type() != event->type() ) ) - l->next(); - if ( l->current() != 0 ) { - if ( cur->event->type() == TQEvent::Paint ) { - TQPaintEvent * p = (TQPaintEvent*)(cur->event); - if ( p->erase != ((TQPaintEvent*)event)->erase ) { - l->next(); - continue; - } - p->reg = p->reg.unite( ((TQPaintEvent *)event)->reg ); - p->rec = p->rec.unite( ((TQPaintEvent *)event)->rec ); - delete event; - return; - } else if ( cur->event->type() == TQEvent::LayoutHint ) { - delete event; - return; - } else if ( cur->event->type() == TQEvent::Resize ) { - ((TQResizeEvent *)(cur->event))->s = ((TQResizeEvent *)event)->s; - delete event; - return; - } else if ( cur->event->type() == TQEvent::Move ) { - ((TQMoveEvent *)(cur->event))->p = ((TQMoveEvent *)event)->p; - delete event; - return; - } else if ( cur->event->type() == TQEvent::LanguageChange ) { - delete event; - return; - } - } - break; - }; - } - - // if no compression could be done, just append something - event->posted = TRUE; - TQPostEvent * pe = new TQPostEvent( receiver, event ); - l->append( pe ); - globalPostedEvents->append( pe ); - - if (eventloop) - eventloop->wakeUp(); -} - - -/*! \overload - - Dispatches all posted events, i.e. empties the event queue. -*/ -void TQApplication::sendPostedEvents() -{ - sendPostedEvents( 0, 0 ); -} - - - -/*! - Immediately dispatches all events which have been previously queued - with TQApplication::postEvent() and which are for the object \a receiver - and have the event type \a event_type. - - Note that events from the window system are \e not dispatched by this - function, but by processEvents(). - - If \a receiver is null, the events of \a event_type are sent for all - objects. If \a event_type is 0, all the events are sent for \a receiver. -*/ - -void TQApplication::sendPostedEvents( TQObject *receiver, int event_type ) -{ - // Make sure the object hierarchy is stable before processing events - // to avoid endless loops - if ( receiver == 0 && event_type == 0 ) - sendPostedEvents( 0, TQEvent::ChildInserted ); - - if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) - return; - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif - - bool sent = TRUE; - while ( sent ) { - sent = FALSE; - - if ( !globalPostedEvents || ( receiver && !receiver->postedEvents ) ) - return; - - // if we have a receiver, use the local list. Otherwise, use the - // global list - TQPostEventList * l = receiver ? receiver->postedEvents : globalPostedEvents; - - // okay. here is the tricky loop. be careful about optimizing - // this, it looks the way it does for good reasons. - TQPostEventListIt it( *l ); - TQPostEvent *pe; - while ( (pe=it.current()) != 0 ) { - ++it; - if ( pe->event // hasn't been sent yet - && ( receiver == 0 // we send to all tqreceivers - || receiver == pe->receiver ) // we send to THAT receiver - && ( event_type == 0 // we send all types - || event_type == pe->event->type() ) ) { // we send THAT type - // first, we diddle the event so that we can deliver - // it, and that noone will try to touch it later. - pe->event->posted = FALSE; - TQEvent * e = pe->event; - TQObject * r = pe->receiver; - pe->event = 0; - - // next, update the data structure so that we're ready - // for the next event. - - // look for the local list, and take whatever we're - // delivering out of it. r->postedEvents maybe *l - if ( r->postedEvents ) { - r->postedEvents->removeRef( pe ); - // if possible, get rid of that list. this is not - // ideal - we will create and delete a list for - // each update() call. it would be better if we'd - // leave the list empty here, and delete it - // somewhere else if it isn't being used. - if ( r->postedEvents->isEmpty() ) { - delete r->postedEvents; - r->postedEvents = 0; - } - } - -#ifdef TQT_THREAD_SUPPORT - if ( locker.mutex() ) locker.mutex()->unlock(); -#endif // TQT_THREAD_SUPPORT - // after all that work, it's time to deliver the event. - if ( e->type() == TQEvent::Paint && r->isWidgetType() ) { - TQWidget * w = (TQWidget*)r; - TQPaintEvent * p = (TQPaintEvent*)e; - if ( w->isVisible() ) - w->tqrepaint( p->reg, p->erase ); - } else { - sent = TRUE; - TQApplication::sendEvent( r, e ); - } -#ifdef TQT_THREAD_SUPPORT - if ( locker.mutex() ) locker.mutex()->lock(); -#endif // TQT_THREAD_SUPPORT - - delete e; - // careful when adding anything below this point - the - // sendEvent() call might tqinvalidate any invariants this - // function depends on. - } - } - - // clear the global list, i.e. remove everything that was - // delivered. - if ( l == globalPostedEvents ) { - globalPostedEvents->first(); - while( (pe=globalPostedEvents->current()) != 0 ) { - if ( pe->event ) - globalPostedEvents->next(); - else - globalPostedEvents->remove(); - } - } - } -} - -/*! - Removes all events posted using postEvent() for \a receiver. - - The events are \e not dispatched, instead they are removed from the - queue. You should never need to call this function. If you do call it, - be aware that killing events may cause \a receiver to break one or - more invariants. - - \threadsafe -*/ - -void TQApplication::removePostedEvents( TQObject *receiver ) -{ - if ( !receiver ) - return; - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - // the TQObject destructor calls this function directly. this can - // happen while the event loop is in the middle of posting events, - // and when we get here, we may not have any more posted events - // for this object. - if ( !receiver->postedEvents ) - return; - - // iterate over the object-specifc list and delete the events. - // leave the TQPostEvent objects; they'll be deleted by - // sendPostedEvents(). - TQPostEventList * l = receiver->postedEvents; - receiver->postedEvents = 0; - l->first(); - TQPostEvent * pe; - while( (pe=l->current()) != 0 ) { - if ( pe->event ) { - pe->event->posted = FALSE; - delete pe->event; - pe->event = 0; - } - l->remove(); - } - delete l; -} - - -/*! - Removes \a event from the queue of posted events, and emits a - warning message if appropriate. - - \warning This function can be \e really slow. Avoid using it, if - possible. - - \threadsafe -*/ - -void TQApplication::removePostedEvent( TQEvent * event ) -{ - if ( !event || !event->posted ) - return; - - if ( !globalPostedEvents ) { -#if defined(TQT_DEBUG) - qDebug( "TQApplication::removePostedEvent: %p %d is posted: impossible", - (void*)event, event->type() ); - return; -#endif - } - -#ifdef TQT_THREAD_SUPPORT - TQMutexLocker locker( postevent_mutex ); -#endif // TQT_THREAD_SUPPORT - - TQPostEventListIt it( *globalPostedEvents ); - TQPostEvent * pe; - while( (pe = it.current()) != 0 ) { - ++it; - if ( pe->event == event ) { -#if defined(TQT_DEBUG) - const char *n; - switch ( event->type() ) { - case TQEvent::Timer: - n = "Timer"; - break; - case TQEvent::MouseButtonPress: - n = "MouseButtonPress"; - break; - case TQEvent::MouseButtonRelease: - n = "MouseButtonRelease"; - break; - case TQEvent::MouseButtonDblClick: - n = "MouseButtonDblClick"; - break; - case TQEvent::MouseMove: - n = "MouseMove"; - break; -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - n = "Wheel"; - break; -#endif - case TQEvent::KeyPress: - n = "KeyPress"; - break; - case TQEvent::KeyRelease: - n = "KeyRelease"; - break; - case TQEvent::FocusIn: - n = "FocusIn"; - break; - case TQEvent::FocusOut: - n = "FocusOut"; - break; - case TQEvent::Enter: - n = "Enter"; - break; - case TQEvent::Leave: - n = "Leave"; - break; - case TQEvent::Paint: - n = "Paint"; - break; - case TQEvent::Move: - n = "Move"; - break; - case TQEvent::Resize: - n = "Resize"; - break; - case TQEvent::Create: - n = "Create"; - break; - case TQEvent::Destroy: - n = "Destroy"; - break; - case TQEvent::Close: - n = "Close"; - break; - case TQEvent::Quit: - n = "Quit"; - break; - default: - n = ""; - break; - } - qWarning("TQEvent: Warning: %s event deleted while posted to %s %s", - n, - pe->receiver ? pe->receiver->className() : "null", - pe->receiver ? pe->receiver->name() : "object" ); - // note the beautiful uglehack if !pe->receiver :) -#endif - event->posted = FALSE; - delete pe->event; - pe->event = 0; - return; - } - } -} - -/*!\internal - - Sets the active window in reaction to a system event. Call this - from the platform specific event handlers. - - It sets the activeWindow() and tqfocusWidget() attributes and sends - proper WindowActivate/WindowDeactivate and FocusIn/FocusOut events - to all appropriate widgets. - - \sa activeWindow() - */ -void TQApplication::setActiveWindow( TQWidget* act ) -{ - TQWidget* window = act?act->tqtopLevelWidget():0; - - if ( active_window == window ) - return; - - // first the activation/deactivation events - if ( active_window ) { - TQWidgetList deacts; -#ifndef TQT_NO_STYLE - if ( style().tqstyleHint(TQStyle::SH_Widget_ShareActivation, active_window ) ) { - TQWidgetList *list = tqtopLevelWidgets(); - if ( list ) { - for ( TQWidget *w = list->first(); w; w = list->next() ) { - if ( w->isVisible() && w->isActiveWindow() ) - deacts.append(w); - } - delete list; - } - } else -#endif - deacts.append(active_window); - active_window = 0; - TQEvent e( TQEvent::WindowDeactivate ); - for(TQWidget *w = deacts.first(); w; w = deacts.next()) - TQApplication::sendSpontaneousEvent( w, &e ); - } - - active_window = window; - if ( active_window ) { - TQEvent e( TQEvent::WindowActivate ); - TQWidgetList acts; -#ifndef TQT_NO_STYLE - if ( style().tqstyleHint(TQStyle::SH_Widget_ShareActivation, active_window ) ) { - TQWidgetList *list = tqtopLevelWidgets(); - if ( list ) { - for ( TQWidget *w = list->first(); w; w = list->next() ) { - if ( w->isVisible() && w->isActiveWindow() ) - acts.append(w); - } - delete list; - } - } else -#endif - acts.append(active_window); - for(TQWidget *w = acts.first(); w; w = acts.next()) - TQApplication::sendSpontaneousEvent( w, &e ); - } - - // then focus events - TQFocusEvent::setReason( TQFocusEvent::ActiveWindow ); - if ( !active_window && focus_widget ) { - TQFocusEvent out( TQEvent::FocusOut ); - TQWidget *tmp = focus_widget; - focus_widget = 0; -#ifdef TQ_WS_WIN - TQInputContext::accept( tmp ); -#endif - TQApplication::sendSpontaneousEvent( tmp, &out ); - } else if ( active_window ) { - TQWidget *w = active_window->tqfocusWidget(); - if ( w && w->focusPolicy() != TQWidget::NoFocus ) - w->setFocus(); - else - active_window->focusNextPrevChild( TRUE ); - } - TQFocusEvent::resetReason(); -} - - -/*!\internal - - Creates the proper Enter/Leave event when widget \a enter is entered - and widget \a leave is left. - */ -TQ_EXPORT void qt_dispatchEnterLeave( TQWidget* enter, TQWidget* leave ) { -#if 0 - if ( leave ) { - TQEvent e( TQEvent::Leave ); - TQApplication::sendEvent( leave, & e ); - } - if ( enter ) { - TQEvent e( TQEvent::Enter ); - TQApplication::sendEvent( enter, & e ); - } - return; -#endif - - TQWidget* w ; - if ( !enter && !leave ) - return; - TQWidgetList leaveList; - TQWidgetList enterList; - - bool sameWindow = leave && enter && leave->tqtopLevelWidget() == enter->tqtopLevelWidget(); - if ( leave && !sameWindow ) { - w = leave; - do { - leaveList.append( w ); - } while ( (w = w->parentWidget( TRUE ) ) ); - } - if ( enter && !sameWindow ) { - w = enter; - do { - enterList.prepend( w ); - } while ( (w = w->parentWidget(TRUE) ) ); - } - if ( sameWindow ) { - int enterDepth = 0; - int leaveDepth = 0; - w = enter; - while ( ( w = w->parentWidget( TRUE ) ) ) - enterDepth++; - w = leave; - while ( ( w = w->parentWidget( TRUE ) ) ) - leaveDepth++; - TQWidget* wenter = enter; - TQWidget* wleave = leave; - while ( enterDepth > leaveDepth ) { - wenter = wenter->parentWidget(); - enterDepth--; - } - while ( leaveDepth > enterDepth ) { - wleave = wleave->parentWidget(); - leaveDepth--; - } - while ( !wenter->isTopLevel() && wenter != wleave ) { - wenter = wenter->parentWidget(); - wleave = wleave->parentWidget(); - } - - w = leave; - while ( w != wleave ) { - leaveList.append( w ); - w = w->parentWidget(); - } - w = enter; - while ( w != wenter ) { - enterList.prepend( w ); - w = w->parentWidget(); - } - } - - TQEvent leaveEvent( TQEvent::Leave ); - for ( w = leaveList.first(); w; w = leaveList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &leaveEvent ); - } - TQEvent enterEvent( TQEvent::Enter ); - for ( w = enterList.first(); w; w = enterList.next() ) { - if ( !tqApp->activeModalWidget() || qt_tryModalHelper( w, 0 )) - TQApplication::sendEvent( w, &enterEvent ); - } -} - - -#ifdef TQ_WS_MACX -extern TQWidget *qt_tryModalHelperMac( TQWidget * top ); //qapplication_mac.cpp -#endif - - -/*!\internal - - Called from qapplication_.cpp, returns TRUE - if the widget should accept the event. - */ -TQ_EXPORT bool qt_tryModalHelper( TQWidget *widget, TQWidget **rettop ) { - TQWidget *modal=0, *top=TQApplication::activeModalWidget(); - if ( rettop ) *rettop = top; - - if ( tqApp->activePopupWidget() ) - return TRUE; - -#ifdef TQ_WS_MACX - top = qt_tryModalHelperMac( top ); - if ( rettop ) *rettop = top; -#endif - - TQWidget* groupLeader = widget; - widget = widget->tqtopLevelWidget(); - - if ( widget->testWFlags(TQt::WShowModal) ) // widget is modal - modal = widget; - if ( !top || modal == top ) // don't block event - return TRUE; - - TQWidget * p = widget->parentWidget(); // Check if the active modal widget is a tqparent of our widget - while ( p ) { - if ( p == top ) - return TRUE; - p = p->parentWidget(); - } - - while ( groupLeader && !groupLeader->testWFlags( TQt::WGroupLeader ) ) - groupLeader = groupLeader->parentWidget(); - - if ( groupLeader ) { - // Does groupLeader have a child in qt_modal_stack? - bool unrelated = TRUE; - modal = qt_modal_stack->first(); - while (modal && unrelated) { - TQWidget* p = modal->parentWidget(); - while ( p && p != groupLeader && !p->testWFlags( TQt::WGroupLeader) ) { - p = p->parentWidget(); - } - modal = qt_modal_stack->next(); - if ( p == groupLeader ) unrelated = FALSE; - } - - if ( unrelated ) - return TRUE; // don't block event - } - return FALSE; -} - - -/*! - Returns the desktop widget (also called the root window). - - The desktop widget is useful for obtaining the size of the screen. - It may also be possible to draw on the desktop. We recommend against - assuming that it's possible to draw on the desktop, since this does - not work on all operating systems. - - \code - TQDesktopWidget *d = TQApplication::desktop(); - int w = d->width(); // returns desktop width - int h = d->height(); // returns desktop height - \endcode -*/ - -TQDesktopWidget *TQApplication::desktop() -{ - if ( !qt_desktopWidget || // not created yet - !qt_desktopWidget->isDesktop() ) { // reparented away - qt_desktopWidget = new TQDesktopWidget(); - TQ_CHECK_PTR( qt_desktopWidget ); - } - return qt_desktopWidget; -} - -#ifndef TQT_NO_CLIPBOARD -/*! - Returns a pointer to the application global clipboard. -*/ -TQClipboard *TQApplication::clipboard() -{ - if ( qt_clipboard == 0 ) { - qt_clipboard = new TQClipboard; - TQ_CHECK_PTR( qt_clipboard ); - } - return qt_clipboard; -} -#endif // TQT_NO_CLIPBOARD - -/*! - By default, TQt will try to use the current standard colors, fonts - etc., from the underlying window system's desktop settings, - and use them for all relevant widgets. This behavior can be switched off - by calling this function with \a on set to FALSE. - - This static function must be called before creating the TQApplication - object, like this: - - \code - int main( int argc, char** argv ) { - TQApplication::setDesktopSettingsAware( FALSE ); // I know better than the user - TQApplication myApp( argc, argv ); // Use default fonts & colors - ... - } - \endcode - - \sa desktopSettingsAware() -*/ - -void TQApplication::setDesktopSettingsAware( bool on ) -{ - obey_desktop_settings = on; -} - -/*! - Returns the value set by setDesktopSettingsAware(); by default TRUE. - - \sa setDesktopSettingsAware() -*/ - -bool TQApplication::desktopSettingsAware() -{ - return obey_desktop_settings; -} - -/*! \fn void TQApplication::lock() - - Lock the TQt Library Mutex. If another thread has already locked the - mutex, the calling thread will block until the other thread has - unlocked the mutex. - - \sa unlock() locked() \link threads.html Thread Support in TQt\endlink -*/ - - -/*! \fn void TQApplication::unlock(bool wakeUpGui) - - Unlock the TQt Library Mutex. If \a wakeUpGui is TRUE (the default), - then the GUI thread will be woken with TQApplication::wakeUpGuiThread(). - - \sa lock(), locked() \link threads.html Thread Support in TQt\endlink -*/ - - -/*! \fn bool TQApplication::locked() - - Returns TRUE if the TQt Library Mutex is locked by a different thread; - otherwise returns FALSE. - - \warning Due to different implementations of recursive mutexes on - the supported platforms, calling this function from the same thread - that previously locked the mutex will give undefined results. - - \sa lock() unlock() \link threads.html Thread Support in TQt\endlink -*/ - -/*! \fn bool TQApplication::tryLock() - - Attempts to lock the TQt Library Mutex, and returns immediately. If - the lock was obtained, this function returns TRUE. If another thread - has locked the mutex, this function returns FALSE, instead of - waiting for the lock to become available. - - The mutex must be unlocked with unlock() before another thread can - successfully lock it. - - \sa lock(), unlock() \link threads.html Thread Support in TQt\endlink -*/ - -#if defined(TQT_THREAD_SUPPORT) -void TQApplication::lock() -{ - qt_mutex->lock(); -} - -void TQApplication::unlock(bool wakeUpGui) -{ - qt_mutex->unlock(); - - if (wakeUpGui) - wakeUpGuiThread(); -} - -bool TQApplication::locked() -{ - return qt_mutex->locked(); -} - -bool TQApplication::tryLock() -{ - return qt_mutex->tryLock(); -} -#endif - - -/*! - \fn bool TQApplication::isSessionRestored() const - - Returns TRUE if the application has been restored from an earlier - \link session.html session\endlink; otherwise returns FALSE. - - \sa sessionId(), commitData(), saveState() -*/ - - -/*! - \fn TQString TQApplication::sessionId() const - - Returns the current \link session.html session's\endlink identifier. - - If the application has been restored from an earlier session, this - identifier is the same as it was in that previous session. - - The session identifier is guaranteed to be unique both for different - applications and for different instances of the same application. - - \sa isSessionRestored(), sessionKey(), commitData(), saveState() - */ - -/*! - \fn TQString TQApplication::sessionKey() const - - Returns the session key in the current \link session.html - session\endlink. - - If the application has been restored from an earlier session, this - key is the same as it was when the previous session ended. - - The session key changes with every call of commitData() or - saveState(). - - \sa isSessionRestored(), sessionId(), commitData(), saveState() - */ - - -/*! - \fn void TQApplication::commitData( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the TQSessionManager wants the - application to commit all its data. - - Usually this means saving all open files, after getting - permission from the user. Furthermore you may want to provide a means - by which the user can cancel the shutdown. - - Note that you should not exit the application within this function. - Instead, the session manager may or may not do this afterwards, - depending on the context. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details and example - usage. - - The default implementation requests interaction and sends a close - event to all visible top level widgets. If any event was - rejected, the shutdown is canceled. - - \sa isSessionRestored(), sessionId(), saveState(), \link session.html the Session Management overview\endlink -*/ -#ifndef TQT_NO_SESSIONMANAGER -void TQApplication::commitData( TQSessionManager& sm ) -{ - - if ( sm.allowsInteraction() ) { - TQWidgetList done; - TQWidgetList *list = TQApplication::tqtopLevelWidgets(); - bool cancelled = FALSE; - TQWidget* w = list->first(); - while ( !cancelled && w ) { - if ( !w->isHidden() ) { - TQCloseEvent e; - sendEvent( w, &e ); - cancelled = !e.isAccepted(); - if ( !cancelled ) - done.append( w ); - delete list; // one never knows... - list = TQApplication::tqtopLevelWidgets(); - w = list->first(); - } else { - w = list->next(); - } - while ( w && done.tqcontainsRef( w ) ) - w = list->next(); - } - delete list; - if ( cancelled ) - sm.cancel(); - } -} - - -/*! - \fn void TQApplication::saveState( TQSessionManager& sm ) - - This function deals with \link session.html session - management\endlink. It is invoked when the - \link TQSessionManager session manager \endlink wants the application - to preserve its state for a future session. - - For example, a text editor would create a temporary file that - includes the current contents of its edit buffers, the location of - the cursor and other aspects of the current editing session. - - Note that you should never exit the application within this - function. Instead, the session manager may or may not do this - afterwards, depending on the context. Futhermore, most session - managers will very likely request a saved state immediately after - the application has been started. This permits the session manager - to learn about the application's restart policy. - - \warning Within this function, no user interaction is possible, \e - unless you ask the session manager \a sm for explicit permission. - See TQSessionManager::allowsInteraction() and - TQSessionManager::allowsErrorInteraction() for details. - - \sa isSessionRestored(), sessionId(), commitData(), \link session.html the Session Management overview\endlink -*/ - -void TQApplication::saveState( TQSessionManager& /* sm */ ) -{ -} -#endif //TQT_NO_SESSIONMANAGER -/*! - Sets the time after which a drag should start to \a ms ms. - - \sa startDragTime() -*/ - -void TQApplication::setStartDragTime( int ms ) -{ - drag_time = ms; -} - -/*! - If you support drag and drop in you application and a drag should - start after a mouse click and after a certain time elapsed, you - should use the value which this method returns as the delay (in ms). - - TQt also uses this delay internally, e.g. in TQTextEdit and TQLineEdit, - for starting a drag. - - The default value is 500 ms. - - \sa setStartDragTime(), startDragDistance() -*/ - -int TQApplication::startDragTime() -{ - return drag_time; -} - -/*! - Sets the distance after which a drag should start to \a l pixels. - - \sa startDragDistance() -*/ - -void TQApplication::setStartDragDistance( int l ) -{ - drag_distance = l; -} - -/*! - If you support drag and drop in you application and a drag should - start after a mouse click and after moving the mouse a certain - distance, you should use the value which this method returns as the - distance. - - For example, if the mouse position of the click is stored in \c - startPos and the current position (e.g. in the mouse move event) is - \c currPos, you can tqfind out if a drag should be started with code - like this: - \code - if ( ( startPos - currPos ).manhattanLength() > - TQApplication::startDragDistance() ) - startTheDrag(); - \endcode - - TQt uses this value internally, e.g. in TQFileDialog. - - The default value is 4 pixels. - - \sa setStartDragDistance(), startDragTime(), TQPoint::manhattanLength() -*/ - -int TQApplication::startDragDistance() -{ - return drag_distance; -} - -/*! - If \a b is TRUE, all dialogs and widgets will be laid out in a - mirrored fashion, as required by right to left languages such as - Arabic and Hebrew. If \a b is FALSE, dialogs and widgets are laid - out left to right. - - Changing this flag in runtime does not cause a retqlayout of already - instantiated widgets. - - \sa reverseLayout() -*/ -void TQApplication::setReverseLayout( bool b ) -{ - if ( reverse_tqlayout == b ) - return; - - reverse_tqlayout = b; - - TQWidgetList *list = tqtopLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget *w; - while ( ( w=it.current() ) != 0 ) { - ++it; - postEvent( w, new TQEvent( TQEvent::LayoutDirectionChange ) ); - } - delete list; -} - -/*! - Returns TRUE if all dialogs and widgets will be laid out in a - mirrored (right to left) fashion. Returns FALSE if dialogs and - widgets will be laid out left to right. - - \sa setReverseLayout() -*/ -bool TQApplication::reverseLayout() -{ - return reverse_tqlayout; -} - - -/*! - \class TQSessionManager tqsessionmanager.h - \brief The TQSessionManager class provides access to the session manager. - - \ingroup application - \ingroup environment - - The session manager is responsible for session management, most - importantly for interruption and resumption. A "session" is a kind - of record of the state of the system, e.g. which applications were - run at start up and which applications are currently running. The - session manager is used to save the session, e.g. when the machine - is shut down; and to restore a session, e.g. when the machine is - started up. Use TQSettings to save and restore an individual - application's settings, e.g. window positions, recently used files, - etc. - - TQSessionManager provides an interface between the application and - the session manager so that the program can work well with the - session manager. In TQt, session management requests for action - are handled by the two virtual functions TQApplication::commitData() - and TQApplication::saveState(). Both provide a reference to - a session manager object as argument, to allow the application - to communicate with the session manager. - - During a session management action (i.e. within commitData() and - saveState()), no user interaction is possible \e unless the - application got explicit permission from the session manager. You - ask for permission by calling allowsInteraction() or, if it's really - urgent, allowsErrorInteraction(). TQt does not enforce this, but the - session manager may. - - You can try to abort the shutdown process by calling cancel(). The - default commitData() function does this if some top-level window - rejected its closeEvent(). - - For sophisticated session managers provided on Unix/X11, TQSessionManager - offers further possibilites to fine-tune an application's session - management behavior: setRestartCommand(), setDiscardCommand(), - setRestartHint(), setProperty(), requestPhase2(). See the respective - function descriptions for further details. -*/ - -/*! \enum TQSessionManager::RestartHint - - This enum type defines the circumstances under which this - application wants to be restarted by the session manager. The - current values are - - \value RestartIfRunning if the application is still running when - the session is shut down, it wants to be restarted at the start of - the next session. - - \value RestartAnyway the application wants to be started at the - start of the next session, no matter what. (This is useful for - utilities that run just after startup and then quit.) - - \value RestartImmediately the application wants to be started - immediately whenever it is not running. - - \value RestartNever the application does not want to be restarted - automatically. - - The default hint is \c RestartIfRunning. -*/ - - -/*! - \fn TQString TQSessionManager::sessionId() const - - Returns the identifier of the current session. - - If the application has been restored from an earlier session, this - identifier is the same as it was in that earlier session. - - \sa sessionKey(), TQApplication::sessionId() - */ - -/*! - \fn TQString TQSessionManager::sessionKey() const - - Returns the session key in the current session. - - If the application has been restored from an earlier session, this - key is the same as it was when the previous session ended. - - The session key changes with every call of commitData() or - saveState(). - - \sa sessionId(), TQApplication::sessionKey() - */ - -// ### Note: This function is undocumented, since it is #ifdef'd. - -/*! - \fn void* TQSessionManager::handle() const - - X11 only: returns a handle to the current \c SmcConnection. -*/ - - -/*! - \fn bool TQSessionManager::allowsInteraction() - - Asks the session manager for permission to interact with the - user. Returns TRUE if interaction is permitted; otherwise - returns FALSE. - - The rationale behind this mechanism is to make it possible to - synchronize user interaction during a shutdown. Advanced session - managers may ask all applications simultaneously to commit their - data, resulting in a much faster shutdown. - - When the interaction is completed we strongly recommend releasing the - user interaction semaphore with a call to release(). This way, other - applications may get the chance to interact with the user while your - application is still busy saving data. (The semaphore is implicitly - released when the application exits.) - - If the user decides to cancel the shutdown process during the - interaction phase, you must tell the session manager that this has - happened by calling cancel(). - - Here's an example of how an application's TQApplication::commitData() - might be implemented: - -\code -void MyApplication::commitData( TQSessionManager& sm ) { - if ( sm.allowsInteraction() ) { - switch ( TQMessageBox::warning( - yourMainWindow, - tr("Application Name"), - tr("Save changes to document Foo?"), - tr("&Yes"), - tr("&No"), - tr("Cancel"), - 0, 2) ) { - case 0: // yes - sm.release(); - // save document here; if saving fails, call sm.cancel() - break; - case 1: // continue without saving - break; - default: // cancel - sm.cancel(); - break; - } - } else { - // we did not get permission to interact, then - // do something reasonable instead. - } -} -\endcode - - If an error occurred within the application while saving its data, - you may want to try allowsErrorInteraction() instead. - - \sa TQApplication::commitData(), release(), cancel() -*/ - - -/*! - \fn bool TQSessionManager::allowsErrorInteraction() - - This is similar to allowsInteraction(), but also tells the session - manager that an error occurred. Session managers may give error - interaction request higher priority, which means that it is more likely - that an error interaction is permitted. However, you are still not - guaranteed that the session manager will allow interaction. - - \sa allowsInteraction(), release(), cancel() -*/ - -/*! - \fn void TQSessionManager::release() - - Releases the session manager's interaction semaphore after an - interaction phase. - - \sa allowsInteraction(), allowsErrorInteraction() -*/ - -/*! - \fn void TQSessionManager::cancel() - - Tells the session manager to cancel the shutdown process. Applications - should not call this function without first asking the user. - - \sa allowsInteraction(), allowsErrorInteraction() - -*/ - -/*! - \fn void TQSessionManager::setRestartHint( RestartHint hint ) - - Sets the application's restart hint to \a hint. On application - startup the hint is set to \c RestartIfRunning. - - Note that these flags are only hints, a session manager may or may - not respect them. - - We recommend setting the restart hint in TQApplication::saveState() - because most session managers perform a checkpoint shortly after an - application's startup. - - \sa restartHint() -*/ - -/*! - \fn TQSessionManager::RestartHint TQSessionManager::restartHint() const - - Returns the application's current restart hint. The default is - \c RestartIfRunning. - - \sa setRestartHint() -*/ - -/*! - \fn void TQSessionManager::setRestartCommand( const TQStringList& command ) - - If the session manager is capable of restoring sessions it will - execute \a command in order to restore the application. The command - defaults to - - \code - appname -session id - \endcode - - The \c -session option is mandatory; otherwise TQApplication cannot - tell whether it has been restored or what the current session - identifier is. See TQApplication::isSessionRestored() and - TQApplication::sessionId() for details. - - If your application is very simple, it may be possible to store the - entire application state in additional command line options. This - is usually a very bad idea because command lines are often limited - to a few hundred bytes. Instead, use TQSettings, or temporary files - or a database for this purpose. By marking the data with the unique - sessionId(), you will be able to restore the application in a future - session. - - \sa restartCommand(), setDiscardCommand(), setRestartHint() -*/ - -/*! - \fn TQStringList TQSessionManager::restartCommand() const - - Returns the currently set restart command. - - Note that if you want to iterate over the list, you should - iterate over a copy, e.g. - \code - TQStringList list = mySession.restartCommand(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa setRestartCommand(), restartHint() -*/ - -/*! - \fn void TQSessionManager::setDiscardCommand( const TQStringList& ) - - \sa discardCommand(), setRestartCommand() -*/ - - -/*! - \fn TQStringList TQSessionManager::discardCommand() const - - Returns the currently set discard command. - - Note that if you want to iterate over the list, you should - iterate over a copy, e.g. - \code - TQStringList list = mySession.discardCommand(); - TQStringList::Iterator it = list.begin(); - while( it != list.end() ) { - myProcessing( *it ); - ++it; - } - \endcode - - \sa setDiscardCommand(), restartCommand(), setRestartCommand() -*/ - -/*! - \overload void TQSessionManager::setManagerProperty( const TQString& name, - const TQString& value ) - - Low-level write access to the application's identification and state - records are kept in the session manager. - - The property called \a name has its value set to the string \a value. -*/ - -/*! - \fn void TQSessionManager::setManagerProperty( const TQString& name, - const TQStringList& value ) - - Low-level write access to the application's identification and state - record are kept in the session manager. - - The property called \a name has its value set to the string list \a value. -*/ - -/*! - \fn bool TQSessionManager::isPhase2() const - - Returns TRUE if the session manager is currently performing a second - session management phase; otherwise returns FALSE. - - \sa requestPhase2() -*/ - -/*! - \fn void TQSessionManager::requestPhase2() - - Requests a second session management phase for the application. The - application may then return immediately from the - TQApplication::commitData() or TQApplication::saveState() function, - and they will be called again once most or all other applications have - finished their session management. - - The two phases are useful for applications such as the X11 window manager - that need to store information about another application's windows - and therefore have to wait until these applications have completed their - respective session management tasks. - - Note that if another application has requested a second phase it - may get called before, simultaneously with, or after your - application's second phase. - - \sa isPhase2() -*/ - -/*! - \fn int TQApplication::horizontalAlignment( int align ) - - Strips out vertical tqalignment flags and transforms an - tqalignment \a align of AlignAuto into AlignLeft or - AlignRight according to the language used. The other horizontal - tqalignment flags are left untouched. -*/ - - -/***************************************************************************** - Stubbed session management support - *****************************************************************************/ -#ifndef TQT_NO_SESSIONMANAGER -#if defined( TQT_NO_SM_SUPPORT ) || defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) || defined( TQ_WS_TQWS ) - -class TQSessionManagerData -{ -public: - TQStringList restartCommand; - TQStringList discardCommand; - TQString sessionId; - TQString sessionKey; - TQSessionManager::RestartHint restartHint; -}; - -TQSessionManager* qt_session_manager_self = 0; -TQSessionManager::TQSessionManager( TQApplication * app, TQString &id, TQString &key ) - : TQObject( app, "qt_sessionmanager" ) -{ - qt_session_manager_self = this; - d = new TQSessionManagerData; -#if defined(TQ_WS_WIN) && !defined(TQ_OS_TEMP) - wchar_t guidstr[40]; - GUID guid; - CoCreateGuid( &guid ); - StringFromGUID2(guid, guidstr, 40); - id = TQString::fromUcs2((ushort*)guidstr); - CoCreateGuid( &guid ); - StringFromGUID2(guid, guidstr, 40); - key = TQString::fromUcs2((ushort*)guidstr); -#endif - d->sessionId = id; - d->sessionKey = key; - d->restartHint = RestartIfRunning; -} - -TQSessionManager::~TQSessionManager() -{ - delete d; - qt_session_manager_self = 0; -} - -TQString TQSessionManager::sessionId() const -{ - return d->sessionId; -} - -TQString TQSessionManager::sessionKey() const -{ - return d->sessionKey; -} - - -#if defined(TQ_WS_X11) || defined(TQ_WS_MAC) -void* TQSessionManager::handle() const -{ - return 0; -} -#endif - -#if !defined(TQ_WS_WIN) -bool TQSessionManager::allowsInteraction() -{ - return TRUE; -} - -bool TQSessionManager::allowsErrorInteraction() -{ - return TRUE; -} -void TQSessionManager::release() -{ -} - -void TQSessionManager::cancel() -{ -} -#endif - - -void TQSessionManager::setRestartHint( TQSessionManager::RestartHint hint) -{ - d->restartHint = hint; -} - -TQSessionManager::RestartHint TQSessionManager::restartHint() const -{ - return d->restartHint; -} - -void TQSessionManager::setRestartCommand( const TQStringList& command) -{ - d->restartCommand = command; -} - -TQStringList TQSessionManager::restartCommand() const -{ - return d->restartCommand; -} - -void TQSessionManager::setDiscardCommand( const TQStringList& command) -{ - d->discardCommand = command; -} - -TQStringList TQSessionManager::discardCommand() const -{ - return d->discardCommand; -} - -void TQSessionManager::setManagerProperty( const TQString&, const TQString&) -{ -} - -void TQSessionManager::setManagerProperty( const TQString&, const TQStringList& ) -{ -} - -bool TQSessionManager::isPhase2() const -{ - return FALSE; -} - -void TQSessionManager::requestPhase2() -{ -} - -#endif // TQT_NO_SM_SUPPORT -#endif //TQT_NO_SESSIONMANAGER - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqapplication.h~ b/tqtinterface/qt4/src/kernel/tqapplication.h~ deleted file mode 100644 index 44acad5..0000000 --- a/tqtinterface/qt4/src/kernel/tqapplication.h~ +++ /dev/null @@ -1,724 +0,0 @@ -/**************************************************************************** -** -** Definition of TQApplication class -** -** Created : 931107 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 TQAPPLICATION_H -#define TQAPPLICATION_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqdesktopwidget.h" -#include "tqasciidict.h" -#include "tqpalette.h" -#include "tqtranslator.h" -#include "tqstrlist.h" -#include "tqstringlist.h" -#include "tqwidgetlist.h" -#include "tqclipboard.h" -#include "tqcursor.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include "private/qt4_qapplication_p.h" -#include -#include - -#endif // USE_QT4 - -class TQSessionManager; -class TQStyle; -class TQTranslator; -class TQEventLoop; -#if defined(TQ_WS_TQWS) -class TQWSDecoration; -#endif - -#ifdef TQT_THREAD_SUPPORT -class TQMutex; -#endif // TQT_THREAD_SUPPORT - -#ifdef USE_QT4 - -#define TQAPPLICATION_GUI_VAR_INIT if (( QApplication::type() != QApplication::GuiClient ) && ( QApplication::type() != QApplication::GuiServer )) { qt_is_gui_used = FALSE; } else { qt_is_gui_used = TRUE; } tqAppReal = static_cast(qApp); -#define TQAPPLICATION_GUI_CONDITIONAL_VAR_INIT if (GUIenabled == false) { qt_is_gui_used = FALSE; } else { qt_is_gui_used = TRUE; } tqAppReal = static_cast(qApp); -#define TQAPPLICATION_XORG_FULL_INIT if (qt_is_gui_used == true) { qt_init( dpy, visual, cmap ); } -#define TQAPPLICATION_XORG_PARTIAL_INIT qt_init( &argc, argv, t ); -#define TQAPPLICATION_XORG_CONDITIONAL_INIT if (GUIenabled == true) { qt_init( &argc, argv, QApplication::GuiClient ); } -#define TQAPPLICATION_REGISTER_TQ_DATATYPES qRegisterMetaType("TQChar"); \ - qRegisterMetaType("TQString"); \ - qRegisterMetaType("TQColor"); - -class TQApplication; -extern TQ_EXPORT TQApplication *tqAppReal; // global application object -#define tqApp tqAppReal - -class TQ_EXPORT TQApplication : public QApplication, virtual public TQt -{ - Q_OBJECT - TQ_OBJECT -public: - TQApplication( int &argc, char **argv ); - TQApplication( int &argc, char **argv, bool GUIenabled ); - TQApplication( int &argc, char **argv, Type t ); -#if defined(TQ_WS_X11) - TQApplication( Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 ); - TQApplication( Display *dpy, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0 ); -#endif - -#ifndef Q_QDOC - enum ColorMode { NormalColors, CustomColors }; - static ColorMode colorMode(); - static void setColorMode( TQApplication::ColorMode ); -#endif - - int exec(); - - const char *tqname() const; - const char *name() const; - const char *name(const char *defaultName) const; - void setName(const char *aName); - - virtual void commitData( TQSessionManager& sm ); - virtual void saveState( TQSessionManager& sm ); - - // Qt4 session manager interconnect - virtual void commitData( QSessionManager& sm ); - virtual void saveState( QSessionManager& sm ); - - static void exit_loop(); - static int enter_loop(); - static void processOneEvent(); - void tqprocessEvents(); - void tqprocessEvents( int maxtime ); - int loopLevel() const; - static void flushX(); - TQWidget *tqfocusWidget() const; - static TQWidget *widgetAt( const TQPoint &p, bool child=FALSE ); - static TQWidget *widgetAt( int x, int y, bool child=FALSE ); - static int horizontalAlignment( int align ); - - inline static void sendPostedEvents( QObject *receiver, int event_type ); - inline static void sendPostedEvents(); - -#ifndef TQT_NO_CURSOR -// static void setOverrideCursor( const QCursor &cur, bool tqreplace=FALSE ); - static void setOverrideCursor( const QCursor &cur, bool tqreplace=FALSE ); -#endif - - static void setReverseLayout(bool b); - static bool reverseLayout(); - - static TQPalette tqpalette( const TQWidget*w = 0 ); - - static TQWidgetList *tqtopLevelWidgets(); - - static TQEventLoop *eventLoop(); - - static TQStyle &tqstyle(); - static void setStyle( TQStyle* ); - static TQStyle* setStyle( const TQString& ); - - static TQDesktopWidget *desktop(); - static const QColor &winStyleHighlightColor(); - static void tqsetPalette(const QPalette &pal, bool informWidgets=FALSE, const char* className = 0); - static void tqsetFont(const QFont &font, bool informWidgets=FALSE, const char* className = 0); - static void setWinStyleHighlightColor( const QColor c ); -#ifndef TQT_NO_CLIPBOARD -// static inline TQClipboard *tqclipboard() { return TQT_TQCLIPBOARD(clipboard()); } - static TQClipboard *tqclipboard(); -#endif - - static TQStringList libraryPaths(); - static void tqsetLibraryPaths( const QStringList &qsl ); -// inline static void tqsetLibraryPaths( const TQStringList &tqsl ) { setLibraryPaths(static_cast(&tqsl)); } - - static TQWidgetList *tqallWidgets(); - - virtual void polish( QWidget * ); - - TQMetaObject *tqmetaObject() const; - - static bool hasGlobalMouseTracking(); - static void setGlobalMouseTracking( bool enable ); - -Q_SIGNALS: - void guiThreadAwake(); // Does not exist in Qt4; therefore will never be triggered - -public: - TQWidget *mainWidget(); - void setMainWidget(QWidget *); - - // [FIXME] -#if defined(TQ_WS_X11) - static void create_xim(); - static void close_xim(); - static bool x11_apply_settings(); -#endif -#ifndef TQT_NO_TRANSLATION -#ifndef TQT_NO_TEXTCODEC - void setDefaultCodec( TQTextCodec * ); - TQTextCodec* defaultCodec() const; -#endif -// void installTranslator( TQTranslator * ); -// void removeTranslator( TQTranslator * ); -#endif - - void wakeUpGuiThread(); -#ifdef TQT_THREAD_SUPPORT - void lock(); - void unlock(bool wakeUpGui = TRUE); - bool locked(); - bool tryLock(); -#endif - -public slots: - void aboutTQt(); - -private: - static TQEventLoop* eventloop; // Will this work as-is or do I need code behind it? - static int app_cspec; - static TQStyle *app_style; -#ifndef TQT_NO_PALETTE - static TQPalette *app_pal; -#endif - static TQPtrList tqt_event_loop_stack; - static TQWidgetList tqt_all_widgets_list; - static QWidget* current_app_main_widget; - mutable TQString static_object_name; - friend class TQWidget; - friend class TQETWidget; - friend class TQDialog; - friend class TQAccelManager; - friend class TQEvent; - friend class TQTranslator; - friend class TQEventLoop; - friend TQ_EXPORT void qt_ucm_initialize( TQApplication * ); -#if defined(TQ_WS_WIN) - friend bool qt_sendSpontaneousEvent( TQObject*, TQEvent* ); -#endif -#if defined(TQ_WS_TQWS) - friend class TQInputContext; -#endif - - friend void qt_init(int *, char **, TQApplication::Type); - -#ifdef TQT_THREAD_SUPPORT - static TQMutex *qt_mutex; -#endif // TQT_THREAD_SUPPORT - -public: - static int composedUnicode; // Value, meta-composed character - static bool metaComposeUnicode; - -protected: - inline bool event(QEvent *e) { TQT_TQOBJECT_CHILDEVENT_REQUIRED_HANDLER(e) return QApplication::event(e); } -}; - -#else // USE_QT4 - -class TQApplication; -extern TQ_EXPORT TQApplication *tqApp; // global application object - - -class TQ_EXPORT TQApplication : public TQObject -{ - Q_OBJECT - TQ_OBJECT -public: - TQApplication( int &argc, char **argv ); - TQApplication( int &argc, char **argv, bool GUIenabled ); - enum Type { Tty, GuiClient, GuiServer }; - TQApplication( int &argc, char **argv, Type ); -#if defined(TQ_WS_X11) - TQApplication( Display* dpy, HANDLE visual = 0, HANDLE cmap = 0 ); - TQApplication( Display *dpy, int argc, char **argv, - HANDLE visual = 0, HANDLE cmap= 0 ); -#endif - virtual ~TQApplication(); - - int argc() const; - char **argv() const; - - Type type() const; - -#ifndef TQT_NO_STYLE - static TQStyle &tqstyle(); - static void setStyle( TQStyle* ); - static TQStyle* setStyle( const TQString& ); -#endif -#ifndef TQ_TQDOC - enum ColorMode { NormalColors, CustomColors }; - static ColorMode colorMode(); - static void setColorMode( TQApplication::ColorMode ); -#endif - - enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; - static int colorSpec(); - static void setColorSpec( int ); -#ifndef TQT_NO_CURSOR - static TQCursor *overrideCursor(); - static void setOverrideCursor( const TQCursor &, bool tqreplace=FALSE ); - static void restoreOverrideCursor(); -#endif - static bool hasGlobalMouseTracking(); - static void setGlobalMouseTracking( bool enable ); -#ifndef TQT_NO_PALETTE - static TQPalette palette( const TQWidget* = 0 ); - static void setPalette( const TQPalette &, bool informWidgets=FALSE, - const char* className = 0 ); -#endif - static TQFont font( const TQWidget* = 0 ); - static void setFont( const TQFont &, bool informWidgets=FALSE, - const char* className = 0 ); - static TQFontMetrics fontMetrics(); - - TQWidget *mainWidget() const; - virtual void setMainWidget( TQWidget * ); - virtual void polish( TQWidget * ); - - static TQWidgetList *allWidgets(); - static TQWidgetList *tqtopLevelWidgets(); - - static TQDesktopWidget *desktop(); - - static TQWidget *activePopupWidget(); - static TQWidget *activeModalWidget(); -#ifndef TQT_NO_CLIPBOARD - static TQClipboard *clipboard(); -#endif - TQWidget *tqfocusWidget() const; - TQWidget *activeWindow() const; - - static TQWidget *widgetAt( int x, int y, bool child=FALSE ); - static TQWidget *widgetAt( const TQPoint &, bool child=FALSE ); - - static TQEventLoop *eventLoop(); - - int exec(); - void processEvents(); - void processEvents( int maxtime ); - void processOneEvent(); - bool hasPendingEvents(); - int enter_loop(); - void exit_loop(); - int loopLevel() const; - static void exit( int retcode=0 ); - - static bool sendEvent( TQObject *receiver, TQEvent *event ); - static void postEvent( TQObject *receiver, TQEvent *event ); - static void sendPostedEvents( TQObject *receiver, int event_type ); - static void sendPostedEvents(); - - static void removePostedEvents( TQObject *receiver ); - - virtual bool notify( TQObject *, TQEvent * ); - - static bool startingUp(); - static bool closingDown(); - - static void flushX(); - static void flush(); - static void syncX(); - - static void beep(); - -#ifndef TQT_NO_TRANSLATION -# ifndef TQT_NO_TEXTCODEC - void setDefaultCodec( TQTextCodec * ); - TQTextCodec* defaultCodec() const; -# endif - void installTranslator( TQTranslator * ); - void removeTranslator( TQTranslator * ); -#endif - enum Encoding { DefaultCodec, UnicodeUTF8 }; - TQString translate( const char * context, - const char * key, - const char * comment = 0, - Encoding encoding = DefaultCodec ) const; -#ifndef TQT_NO_DIR - TQString applicationDirPath(); - TQString applicationFilePath(); -#endif -#ifndef TQT_NO_PALETTE - // obsolete functions - static void setWinStyleHighlightColor( const TQColor &c ) { - TQPalette p( palette() ); - p.setColor( TQColorGroup::Highlight, c ); - setPalette( p, TRUE); - } - static const TQColor &winStyleHighlightColor() { - return palette().active().highlight(); - } -#endif - static void setDesktopSettingsAware( bool ); - static bool desktopSettingsAware(); - - static void setCursorFlashTime( int ); - static int cursorFlashTime(); - - static void setDoubleClickInterval( int ); - static int doubleClickInterval(); -#ifndef TQT_NO_WHEELEVENT - static void setWheelScrollLines( int ); - static int wheelScrollLines(); -#endif - static void setGlobalStrut( const TQSize & ); - static TQSize globalStrut(); - -#ifndef TQT_NO_COMPONENT - static void tqsetLibraryPaths( const TQStringList & ); - static TQStringList libraryPaths(); - static void addLibraryPath( const TQString & ); - static void removeLibraryPath( const TQString & ); -#endif // TQT_NO_COMPONENT - static void setStartDragTime( int ms ); - static int startDragTime(); - static void setStartDragDistance( int l ); - static int startDragDistance(); - - static void setReverseLayout( bool b ); - static bool reverseLayout(); - - static int horizontalAlignment( int align ); - - static bool isEffectEnabled( TQt::UIEffect ); - static void setEffectEnabled( TQt::UIEffect, bool enable = TRUE ); - -#if defined(TQ_WS_MAC) - virtual bool macEventFilter( EventHandlerCallRef, EventRef ); -#endif -#if defined(TQ_WS_WIN) - virtual bool winEventFilter( MSG * ); -#endif -#if defined(TQ_WS_X11) - virtual bool x11EventFilter( XEvent * ); - virtual int x11ClientMessage( TQWidget*, XEvent*, bool passive_only); - int x11ProcessEvent( XEvent* ); -#endif -#if defined(TQ_WS_TQWS) - virtual bool qwsEventFilter( TQWSEvent * ); - int qwsProcessEvent( TQWSEvent* ); - void qwsSetCustomColors( TQRgb *colortable, int start, int numColors ); -/*! - \internal - Returns true if the process is GUI server -*/ - bool qwsIsGUIServer(); -#ifndef TQT_NO_TQWS_MANAGER - static TQWSDecoration &qwsDecoration(); - static void qwsSetDecoration( TQWSDecoration *); -#endif -#endif - -#if defined(TQ_OS_WIN32) || defined(TQ_OS_CYGWIN) - static WindowsVersion winVersion(); -#elif defined(TQ_OS_MAC) - static MacintoshVersion macVersion(); -#endif -#if defined(TQ_WS_WIN) - void winFocus( TQWidget *, bool ); - static void winMouseButtonUp(); -#endif - -#ifndef TQT_NO_SESSIONMANAGER - // session management - bool isSessionRestored() const; - TQString sessionId() const; - TQString sessionKey() const; - virtual void commitData( TQSessionManager& sm ); - virtual void saveState( TQSessionManager& sm ); -#endif -#if defined(TQ_WS_X11) - static void create_xim(); - static void close_xim(); - static bool x11_apply_settings(); -#endif - void wakeUpGuiThread(); -#if defined(TQT_THREAD_SUPPORT) - void lock(); - void unlock(bool wakeUpGui = TRUE); - bool locked(); - bool tryLock(); -#endif - -Q_SIGNALS: - void lastWindowClosed(); - void aboutToQuit(); - void guiThreadAwake(); - -public Q_SLOTS: - void quit(); - void closeAllWindows(); - void aboutTQt(); - -#if defined(TQ_WS_TQWS) -protected: - void setArgs(int, char **); -#endif - -protected: - bool event(TQEvent *); - -private: - void construct( int &argc, char **argv, Type ); - void initialize( int, char ** ); - void init_precmdline(); - void process_cmdline( int* argcptr, char ** argv ); - bool internalNotify( TQObject *, TQEvent * ); -#if defined(TQ_WS_TQWS) - static TQWidget *tqfindChildWidget( const TQWidget *p, const TQPoint &pos ); - static TQWidget *tqfindWidget( const TQObjectList&, const TQPoint &, bool rec ); -#endif - -#if defined(TQ_WS_MAC) - bool do_mouse_down(Point *, bool *); - static TQMAC_PASCAL OStqStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *); - static TQMAC_PASCAL OStqStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long); - static TQMAC_PASCAL void qt_context_timer_callbk(EventLoopTimerRef, void *); - static TQMAC_PASCAL void qt_select_timer_callbk(EventLoopTimerRef, void *); - static bool qt_mac_apply_settings(); - friend class TQMacInputMethod; - friend TQMAC_PASCAL OStqStatus qt_window_event(EventHandlerCallRef, EventRef, void *); - friend void qt_mac_update_os_settings(); - friend bool qt_set_socket_handler( int, int, TQObject *, bool); - friend void qt_mac_destroy_widget(TQWidget *); - friend void qt_init(int *, char **, TQApplication::Type); -#endif - -#ifdef TQT_THREAD_SUPPORT - static TQMutex *qt_mutex; -#endif // TQT_THREAD_SUPPORT - - int app_argc; - char **app_argv; - bool quit_now; - int quit_code; - static TQStyle *app_style; - static int app_cspec; -#ifndef TQT_NO_PALETTE - static TQPalette *app_pal; -#endif - static TQFont *app_font; -#ifndef TQT_NO_CURSOR - static TQCursor *app_cursor; -#endif - static TQEventLoop* eventloop; - static int app_tracking; - static bool is_app_running; - static bool is_app_closing; - static bool app_exit_loop; - static int loop_level; - static TQWidget *main_widget; - static TQWidget *focus_widget; - static TQWidget *active_window; - static bool obey_desktop_settings; - static int cursor_flash_time; - static int mouse_double_click_time; - static int wheel_scroll_lines; - static int composedUnicode; // Value, meta-composed character - - static bool animate_ui; - static bool animate_menu; - static bool animate_tooltip; - static bool animate_combo; - static bool fade_menu; - static bool fade_tooltip; - static bool animate_toolbox; - static bool widgetCount; // Coupled with -widgetcount switch - static bool metaComposeUnicode; - - TQValueList *translators; -#ifndef TQT_NO_SESSIONMANAGER - TQSessionManager *session_manager; - TQString session_id; - static TQString* session_key; - bool is_session_restored; -#endif -#if defined(TQ_WS_X11) && !defined (TQT_NO_STYLE ) - static void x11_initialize_style(); -#endif - - static TQSize app_strut; -#ifndef TQT_NO_COMPONENT - static TQStringList *app_libpaths; -#endif - static TQAsciiDict *app_palettes; - static TQAsciiDict *app_fonts; - - static TQWidgetList *popupWidgets; - bool inPopupMode() const; - void closePopup( TQWidget *popup ); - void openPopup( TQWidget *popup ); - void setActiveWindow( TQWidget* act ); - - static bool sendSpontaneousEvent( TQObject *receiver, TQEvent *event ); - static void removePostedEvent( TQEvent * ); - - friend class TQWidget; - friend class TQETWidget; - friend class TQDialog; - friend class TQAccelManager; - friend class TQEvent; - friend class TQTranslator; - friend class TQEventLoop; - friend TQ_EXPORT void qt_ucm_initialize( TQApplication * ); -#if defined(TQ_WS_WIN) - friend bool qt_sendSpontaneousEvent( TQObject*, TQEvent* ); -#endif -#if defined(TQ_WS_TQWS) - friend class TQInputContext; -#endif -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQApplication( const TQApplication & ); - TQApplication &operator=( const TQApplication & ); -#endif -}; - -inline int TQApplication::argc() const -{ - return app_argc; -} - -inline char **TQApplication::argv() const -{ - return app_argv; -} - -#if defined(TQ_WS_TQWS) -inline void TQApplication::setArgs(int c, char **v) -{ - app_argc = c; - app_argv = v; -} -#endif - -#ifndef TQT_NO_CURSOR -inline TQCursor *TQApplication::overrideCursor() -{ - return app_cursor; -} -#endif -inline bool TQApplication::hasGlobalMouseTracking() -{ - return app_tracking > 0; -} - -inline TQWidget *TQApplication::mainWidget() const -{ - return main_widget; -} - -inline TQWidget *TQApplication::tqfocusWidget() const -{ - return focus_widget; -} - -inline TQWidget *TQApplication::activeWindow() const -{ - return active_window; -} - -inline TQWidget *TQApplication::widgetAt( const TQPoint &p, bool child ) -{ - return widgetAt( p.x(), p.y(), child ); -} - -inline bool TQApplication::inPopupMode() const -{ - return popupWidgets != 0; -} -#ifndef TQT_NO_SESSIONMANAGER -inline bool TQApplication::isSessionRestored() const -{ - return is_session_restored; -} - -inline TQString TQApplication::sessionId() const -{ - return session_id; -} - -inline TQString TQApplication::sessionKey() const -{ - return session_key ? *session_key : TQString::null; -} -#endif -inline TQSize TQApplication::globalStrut() -{ - return app_strut; -} - -inline bool TQApplication::sendEvent( TQObject *receiver, TQEvent *event ) -{ if ( event ) event->spont = FALSE; return tqApp ? tqApp->notify( receiver, event ) : FALSE; } - -inline bool TQApplication::sendSpontaneousEvent( TQObject *receiver, TQEvent *event ) -{ if ( event ) event->spont = TRUE; return tqApp ? tqApp->notify( receiver, event ) : FALSE; } - -#ifdef TQT_NO_TRANSLATION -// Simple versions -inline TQString TQApplication::translate( const char *, const char *sourceText, - const char *, Encoding encoding ) const -{ -#ifndef TQT_NO_TEXTCODEC - if ( encoding == UnicodeUTF8 ) - return TQString::fromUtf8( sourceText ); - else -#endif - return TQString::tqfromLatin1( sourceText ); -} -#endif - -inline int TQApplication::horizontalAlignment( int align ) -{ - align &= AlignHorizontal_Mask; - if ( align == AlignAuto ) { - if ( reverseLayout() ) - align = AlignRight; - else - align = AlignLeft; - } - return align; -} - -#endif // TQAPPLICATION_H - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqmetaobject.cpp~ b/tqtinterface/qt4/src/kernel/tqmetaobject.cpp~ deleted file mode 100644 index 09d8439..0000000 --- a/tqtinterface/qt4/src/kernel/tqmetaobject.cpp~ +++ /dev/null @@ -1,1792 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQMetaObject class -** -** Created : 930419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 - -#include - -#ifdef USE_QT4 - -// #include - -/*! - 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 ); - int n = numProperties( super ); - for( int i = 0; i < n; ++i ) { - if (property( i, super)) - l.append( property( i, super)->name() ); - else - l.append( "[TQt TQMetaObject::propertyNames was unable to find the Qt4 name for this property]" ); - } - return l; -} - -const char * TQMetaData::name() const { - return signature(); // Member name -} - -const TQUMethod* TQMetaData::method() const { - // FIXME - // Verify that this routine accurately fills internal_method_information! - printf("[WARNING] const TQUMethod* TQMetaData::method() partially implemented!\n\r"); - - if (!internal_method_information) { - internal_method_information = new TQUMethod; - internal_method_information->parameters = 0; - } - internal_method_information->name = QMetaMethod::signature(); - internal_method_information->count = QMetaMethod::parameterNames().count(); - if (internal_method_information->parameters) { - for (int i=0; icount; i++) { - if (internal_method_information->parameters[i].type) - delete internal_method_information->parameters[i].type; - } - delete [] internal_method_information->parameters; - } - internal_method_information->parameters = new TQUParameter[internal_method_information->count]; - for (int i=0; icount; i++) { - const_cast(internal_method_information->parameters[i]).name = QMetaMethod::parameterNames().at(i).data(); -// const_cast(internal_method_information->parameters[i]).type = new TQUType; -// const_cast(internal_method_information->parameters[i]).type.desc = QMetaMethod::parameterTypes().at(i).data(); - const_cast(internal_method_information->parameters[i]).typeExtra = 0; - const_cast(internal_method_information->parameters[i]).inOut = 3; - } - return internal_method_information; -} - -TQMetaEnum::TQMetaEnum() : QMetaEnum() { internal_item_list = 0; } - -uint TQMetaEnum::count() const { - return QMetaEnum::keyCount(); -} - -TQMetaEnum::Item* TQMetaEnum::items() const { - if (internal_item_list) - delete [] internal_item_list; - int internal_item_count = count(); - internal_item_list = new Item[internal_item_count]; - for (int i=0; iresolveProperty( this ); -// return tqparent ? tqparent->stdSet() : FALSE; - - // [FIXME] - printf("[WARNING] bool TQMetaProperty::stdSet() const unimplemented\n\r"); - return FALSE; -} - -TQMetaObject::TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, -#endif // TQT_NO_PROPERTIES - const TQClassInfo *const class_info, int n_info ) : QMetaObject() { - printf("[WARNING] TQMetaObject() constructor unimplemented\n\r"); // [FIXME] -} - -#ifndef TQT_NO_PROPERTIES -TQMetaObject::TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, bool (*qt_static_property)(TQObject*, int, int, TQVariant*), const TQClassInfo *const class_info, int n_info ) : QMetaObject() { - printf("[WARNING] TQMetaObject() constructor unimplemented\n\r"); // [FIXME] -} -#endif // TQT_NO_PROPERTIES - -TQStrList TQMetaObject::slotNames( bool super ) const { - printf("[WARNING] TQStrList slotNames( bool super = FALSE ) unimplemented\n\r"); - return TQStrList(); -} - -TQStrList TQMetaObject::signalNames( bool super ) const { - printf("[WARNING] TQStrList signalNames( bool super = FALSE ) const unimplemented\n\r"); - return TQStrList(); -} - -/*! - Returns the number of Q_SLOTS for this class. - - If \a super is TRUE, inherited Q_SLOTS are included. - - \sa slotNames() -*/ -int TQMetaObject::numSlots( bool super ) const // number of Q_SLOTS -{ - int i; - int n=0; - for (i=0;inumSlots( super ); -} - -/*! - 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 classInfoCount() + ((super && tqsuperClass())?tqsuperClass()->numClassInfo(super):0); -} - -/*! - Returns the number of Q_SIGNALS for this class. - - If \a super is TRUE, inherited Q_SIGNALS are included. - - \sa signalNames() -*/ -int TQMetaObject::numSignals( bool super ) const // number of Q_SIGNALS -{ - int i; - int n=0; - for (i=0;inumSignals( super ); -} - -#if 0 -/*! \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. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::slot( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { - if ( idx >= 0 && idx < numSlots(true) ) { -// return slotData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->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. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::signal( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { - if ( idx >= 0 && idx < numSignals(true) ) { -// return signalData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->signal( index, super ); -} -#endif - -/*! \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. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::slot( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( slotDict && idx >= 0 && idx < (int) slotDict->count() ) { - if ( idx >= 0 && idx < numSlots(true) ) { -// return slotData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->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. - - [FIXME]: Superclass handling is badly broken - */ -const TQMetaData* TQMetaObject::signal( int index, bool super ) const -{ - QMetaMethod mm; - const QMetaMethod *mr; - int idx = index - ( super ? methodOffset() : 0 ); -// if ( signalDict && idx >= 0 && idx < (int) signalDict->count() ) { - if ( idx >= 0 && idx < numSignals(true) ) { -// return signalData + idx; - mm = method(idx); - mr = &mm; - return static_cast(mr); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->signal( index, super ); -} - -/*! \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. - - [FIXME]: Superclass handling is badly broken - */ -int TQMetaObject::tqfindSlot( const char* n, bool super ) const -{ -// TQStrList l( FALSE ); -// int m = methodCount(); -// for( int i = 0; i < m; ++i ) { -// // if ( normalizedSignature(slot( i, super)->signature()) == QByteArray(n) ) { -// if ( normalizedSignature(method(i).signature()) == QByteArray(n) ) { -// if (method(i).methodType() == QMetaMethod::Slot) { -// return i; -// } -// } -// } -// return -1; - - if (super) printf("[WARNING] In TQMetaObject::tqfindSlot(), superclasses are not being searched for the slot\n\r"); - return indexOfSlot(normalizedSignature(n)); -} - -/*! \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. - - [FIXME]: Superclass handling is badly broken -*/ -int TQMetaObject::tqfindSignal( const char* n, bool super ) const -{ -// TQStrList l( FALSE ); -// int m = methodCount(); -// for( int i = 0; i < m; ++i ) { -// // if ( normalizedSignature(signal( i, super)->signature()) == QByteArray(n) ) { -// if ( normalizedSignature(method(i).signature()) == QByteArray(n) ) { -// if (method(i).methodType() == QMetaMethod::Signal) { -// return i; -// } -// } -// } -// return -1; - - if (super) printf("[WARNING] In TQMetaObject::tqfindSignal(), superclasses are not being searched for the signal\n\r"); - return indexOfSignal(normalizedSignature(n)); -} - -#ifndef QT_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 properties -{ - int i; - int n=0; - for (i=0;inumProperties( 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() - - [FIXME]: Superclass handling is badly broken - */ -static QMetaProperty tqmo_propmethod_curprop; -const TQMetaProperty* TQMetaObject::property( int index, bool super ) const -{ - QMetaProperty mp; - const QMetaProperty *pr; - int idx = index - ( super ? propertyOffset() : 0 ); -// if ( d->propData && idx >= 0 && idx < (int)d->numPropData ) - if ( idx >= 0 && idx < numProperties(true) ) - tqmo_propmethod_curprop = QMetaObject::property(idx); - return static_cast(&tqmo_propmethod_curprop); - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->property( index, super ); -} - -int TQMetaObject::tqfindProperty( const char *name, bool super ) const { - TQ_UNUSED(name); - return indexOfProperty(name); -} - -TQMetaObject * TQMetaObject::tqsuperClass() const { - return static_cast(const_cast(superClass())); -} - -const char * TQMetaObject::tqsuperClassName() const { - return static_cast(const_cast(superClass()))->className(); -} - -#endif // QT_NO_PROPERTIES - -/*! - 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 < QMetaObject::classInfoCount() ) - return static_cast(&(QMetaObject::classInfo(index))); - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->classInfo( index - QMetaObject::classInfoCount(), 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 < QMetaObject::classInfoCount(); ++i ) { - if ( qstrcmp( QMetaObject::classInfo(i).name(), name ) == 0 ) - return QMetaObject::classInfo(i).value(); - } - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->classInfo( name, super ); -} - -/*!\internal - - */ -TQStrList TQMetaObject::enumeratorNames( bool super ) const -{ - TQStrList l( FALSE ); - - if ( tqsuperClass() && super ) { - TQStrList sl = tqsuperClass()->enumeratorNames( super ); - for ( TQStrListIterator slit( sl ); slit.current(); ++slit ) - l.append( slit.current() ); - } - - for( int i = 0; i < QMetaObject::enumeratorCount(); ++i ) { -// if ( d->enumData[i].items ) - if (QMetaObject::enumerator(i).name() != "") - l.append( QMetaObject::enumerator(i).name() ); - } - - return l; -} - -/*!\internal - */ -const TQMetaEnum* TQMetaObject::enumerator( const char* name, bool super ) const -{ - for( int i = 0; i < QMetaObject::enumeratorCount(); ++i ) - if ( qstrcmp( QMetaObject::enumerator(i).name(), name ) == 0 ) - return static_cast(&(QMetaObject::enumerator(i))); - if ( !super || !superClass() ) - return 0; - return tqsuperClass()->enumerator( name, super ); -} - -#else // USE_QT4 - -/*! - \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 tqcontains meta information about TQt objects. - - \ingroup objectmodel - - The Meta Object System in TQt is responsible for the Q_SIGNALS and - Q_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 tqfind 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 Q_SIGNALS and Q_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 tqmoc.html tqmoc (Meta Object Compiler)\endlink - -*/ - - -/***************************************************************************** - The private object. - *****************************************************************************/ - -// extra flags from tqmoc.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), - qt_static_property(0), -#endif - classInfo(0), numClassInfo(0) {} -#ifndef TQT_NO_PROPERTIES - const TQMetaEnum *enumData; - int numEnumData; - const TQMetaProperty *propData; - int numPropData; - bool (*qt_static_property)(TQObject*, int, int, TQVariant*); -#endif - const TQClassInfo *classInfo; - int numClassInfo; -}; - - -/***************************************************************************** - Internal dictionary for fast access to class members - *****************************************************************************/ - -#if defined(TQ_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_Q_SLOTS, - const TQMetaData *const signal_data, int n_Q_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_Q_SLOTS ); - signalDict = init( signalData = signal_data, n_Q_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_Q_SLOTS, - const TQMetaData *const signal_data, int n_Q_SIGNALS, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*qt_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_Q_SLOTS ); - signalDict = init( signalData = signal_data, n_Q_SIGNALS ); - - d = new TQMetaObjectPrivate; - reserved = 0; - - d->propData = prop_data; - d->numPropData = n_props; - d->enumData = enum_data; - d->numEnumData = n_enums; - d->qt_static_property = qt_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 Q_SLOTS for this class. - - If \a super is TRUE, inherited Q_SLOTS are included. - - \sa slotNames() -*/ -int TQMetaObject::numSlots( bool super ) const // number of Q_SLOTS -{ - int n = slotDict ? slotDict->count() : 0; - if ( !super || !superclass ) - return n; - return n + superclass->numSlots( super ); -} - -/*! - Returns the number of Q_SIGNALS for this class. - - If \a super is TRUE, inherited Q_SIGNALS are included. - - \sa signalNames() -*/ -int TQMetaObject::numSignals( bool super ) const // number of Q_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 Q_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 Q_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 Q_SIGNALS are included. -*/ -int TQMetaObject::tqfindSignal( const char* n, bool super ) const -{ - const TQMetaObject *mo = this; - int offset = -1; - - do { - const TQMetaData *md = mo->signalDict ? mo->signalDict->tqfind( n ) : 0; - if ( md ) { -#if defined(TQT_CHECK_RANGE) - if ( offset != -1 ) { - qWarning( "TQMetaObject::tqfindSignal:%s: Conflict with %s::%s", - className(), mo->className(), n ); - return offset; - } -#endif - offset = mo->signalOffset() + ( md - mo->signalData ); -#if !defined(TQT_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 Q_SLOTS are included. - */ -int TQMetaObject::tqfindSlot( const char* n, bool super ) const -{ - const TQMetaData *md = slotDict ? slotDict->tqfind( n ) : 0; - if ( md ) - return slotOffset() + ( md - slotData ); - if ( !super || !superclass) - return -1; - return superclass->tqfindSlot( n, super ); -} - -/*!\internal - */ -TQMetaObject *TQMetaObject::new_metaobject( const char *classname, - TQMetaObject *superclassobject, - const TQMetaData * const slot_data, int n_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_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_Q_SLOTS, - signal_data, n_Q_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_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_SIGNALS, - const TQMetaProperty * const prop_data, int n_props, - const TQMetaEnum * const enum_data, int n_enums, - bool (*qt_static_property)(TQObject*, int, int, TQVariant*), - const TQClassInfo * const class_info, int n_info ) -{ - return new TQMetaObject( classname, superclassobject, slot_data, n_Q_SLOTS, - signal_data, n_Q_SIGNALS, - prop_data, n_props, - enum_data, n_enums, - qt_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 Q_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::tqfindProperty( 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->tqfindProperty( 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 tqparent 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->tqfindProperty( p->n, TRUE ), TRUE ); -} - -/*!\internal - - \overload - - The version of resolveProperty that is used by tqmoc generated code -*/ - -int TQMetaObject::resolveProperty( int index ) const -{ - if ( !superclass ) - return -1; - const TQMetaProperty* p = d->propData + ( index - propertyOffset() ); - return superclass->tqfindProperty( 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 Q_SIGNALS. - - If \a super is TRUE, inherited Q_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 Q_SLOTS. - - If \a super is TRUE, inherited Q_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::tqmetaObject( 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->tqfind( 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->tqfind( 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::qt_static_property( TQObject* o, int id, int f, TQVariant* v) -{ - if ( d->qt_static_property ) - return d->qt_static_property( o, id, f, v ); - else if ( o ) // compatibility - return o->qt_property( id, f, v ); - else if ( superclass ) - return superclass->qt_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* tqparent = mo->resolveProperty( this ); - return tqparent ? tqparent->writable() : FALSE; -} - -/*!\internal - */ -bool TQMetaProperty::stdSet() const -{ - if ( !testFlags( Override ) || testFlags( Writable ) ) - return testFlags( StdSet ); - const TQMetaObject* mo = (*meta); - const TQMetaProperty* tqparent = mo->resolveProperty( this ); - return tqparent ? tqparent->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* tqparent = mo->resolveProperty( this ); - return tqparent ? tqparent->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->qt_property( idx, 3, 0 ); - } - if ( testFlags( DesignableOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* tqparent = mo->resolveProperty( this ); - return tqparent ? tqparent->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->qt_property( idx, 4, 0 ); - } - if ( testFlags( ScriptableOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* tqparent = mo->resolveProperty( this ); - return tqparent ? tqparent->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->qt_property( idx, 5, 0 ); - } - if ( testFlags( StoredOverride ) ) { - const TQMetaObject* mo = (*meta); - const TQMetaProperty* tqparent = mo->resolveProperty( this ); - return tqparent ? tqparent->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->qt_property( idx, 2, 0 ); -} - - -/*! \enum TQMetaProperty::Flags - - \internal -*/ - -#endif // TQT_NO_PROPERTIES - -/* - * TQMetaObjectCleanUp is used as static global object in the tqmoc-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 ) - : tqmetaObject( 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() - : tqmetaObject( 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 ( tqmetaObject ) { - delete *tqmetaObject; - *tqmetaObject = 0; - tqmetaObject = 0; - } -} - -void TQMetaObjectCleanUp::setMetaObject( TQMetaObject *&mo ) -{ -#if defined(TQT_CHECK_RANGE) - if ( tqmetaObject ) - qWarning( "TQMetaObjectCleanUp::setMetaObject: Double use of TQMetaObjectCleanUp!" ); -#endif - tqmetaObject = &mo; -} - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqmetaobject.h~ b/tqtinterface/qt4/src/kernel/tqmetaobject.h~ deleted file mode 100644 index ecb6c23..0000000 --- a/tqtinterface/qt4/src/kernel/tqmetaobject.h~ +++ /dev/null @@ -1,403 +0,0 @@ -/**************************************************************************** -** -** Definition of TQMetaObject class -** -** Created : 930419 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqconnection.h" -#include "tqstrlist.h" -#endif // TQT_H - -#ifndef TQ_TQMOC_OUTPUT_REVISION -#define TQ_TQMOC_OUTPUT_REVISION 26 -#endif - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -struct TQUMethod; - -class TQ_EXPORT TQMetaEnum : public QMetaEnum, virtual public TQt -{ -public: - TQMetaEnum(); - - struct Item // - a name/value pair - { - const char *key; - int value; - }; - - uint count() const; - Item* items() const; - -private: - mutable Item* internal_item_list; -}; - -class TQ_EXPORT TQMetaData : public QMetaMethod, virtual public TQt -{ -public: - TQMetaData(); - - const char *name() const; - const TQUMethod* method() const; - - mutable TQUMethod* internal_method_information; -}; - -class TQ_EXPORT TQMetaProperty : public QMetaProperty, virtual public TQt -{ -public: - TQMetaProperty(); - - bool isSetType() const; - int keyToValue( const char* key ) const; - const char* valueToKey( int value ) const; - int keysToValue( const TQStrList& keys_in ) const; - TQStrList valueToKeys( int value ) const; - bool writable() const; - const char* type() const; - TQStrList enumKeys() const; - - bool designable( TQT_BASE_OBJECT_NAME *o = 0 ) const; - bool scriptable( TQT_BASE_OBJECT_NAME *o = 0 ) const; - bool stored( TQT_BASE_OBJECT_NAME *o = 0 ) const; - - bool stdSet() const; // internal - -// inline bool reset( TQT_BASE_OBJECT_NAME *o ) const { return isResettable(o); } -}; - -class TQ_EXPORT TQClassInfo : public QMetaClassInfo, virtual public TQt -{ -public: - TQClassInfo() : QMetaClassInfo() {} -}; - -class TQ_EXPORT TQMetaObject : public QMetaObject, virtual public TQt -{ -public: - TQMetaObject( const char * const class_name, TQMetaObject *superclass, const TQMetaData * const slot_data, int n_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, -#ifndef TQT_NO_PROPERTIES - const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, -#endif // TQT_NO_PROPERTIES - 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_Q_SLOTS, const TQMetaData * const signal_data, int n_Q_SIGNALS, const TQMetaProperty *const prop_data, int n_props, const TQMetaEnum *const enum_data, int n_enums, bool (*qt_static_property)(TQObject*, int, int, TQVariant*), const TQClassInfo *const class_info, int n_info ); -#endif // TQT_NO_PROPERTIES - - TQStrList slotNames( bool super = FALSE ) const; - TQStrList signalNames( bool super = FALSE ) const; - -#ifndef TQT_NO_PROPERTIES - int tqfindProperty( const char *name, bool super = FALSE ) const; - TQMetaObject *tqsuperClass() const; - const char *tqsuperClassName() const; - TQStrList propertyNames( bool super = FALSE ) const; - - int numSlots( bool super = FALSE ) const; - int numSignals( bool super = FALSE ) const; - int numClassInfo( bool super = FALSE ) const; - - const TQMetaData *slot( int index, bool super = FALSE ) const; - const TQMetaData *signal( int index, bool super = FALSE ) const; - - int tqfindSlot( const char *, bool super = FALSE ) const; - int tqfindSignal( const char *, bool super = FALSE ) const; - - int numProperties( bool super = FALSE ) const; - const TQMetaProperty *property( int index, bool super = FALSE ) const; - - const TQMetaEnum *enumerator( const char* name, bool super = FALSE ) const; - TQStrList enumeratorNames( bool super = FALSE ) const; -#endif // TQT_NO_PROPERTIES - - const TQClassInfo *classInfo( int index, bool super = FALSE ) const; - const char *classInfo( const char* name, bool super = FALSE ) const; -}; - -#else // USE_QT4 - -class TQObject; -struct TQUMethod; -class TQMetaObjectPrivate; - -struct TQMetaData // - member function meta data -{ // for signal and Q_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_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_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_Q_SLOTS, - const TQMetaData * const signal_data, int n_Q_SIGNALS, - const TQMetaProperty *const prop_data, int n_props, - const TQMetaEnum *const enum_data, int n_enums, - bool (*qt_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 tqfindSlot( const char *, bool super = FALSE ) const; - int tqfindSignal( 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 tqfindProperty( 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 (*qt_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 *tqmetaObject( 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 qt_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 **tqmetaObject; -}; - -#endif // USE_QT4 - -#endif // TQMETAOBJECT_H diff --git a/tqtinterface/qt4/src/kernel/tqpainter.cpp~ b/tqtinterface/qt4/src/kernel/tqpainter.cpp~ deleted file mode 100644 index 44e7577..0000000 --- a/tqtinterface/qt4/src/kernel/tqpainter.cpp~ +++ /dev/null @@ -1,5161 +0,0 @@ -#include "tqpainter.h" - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqpainter.h" -#include "tqimage.h" -#include "Qt/qpaintengine.h" - -// #include - -QT_BEGIN_NAMESPACE - -// TAKEN FROM QT4 qbrush.cpp -// THIS BLOCK MAY NEED TO BE UPDATED FROM TIME TO TIME -// BEGIN BLOCK -struct QTexturedBrushData : public QBrushData -{ - QTexturedBrushData() { - m_has_pixmap_texture = false; - m_pixmap = 0; - } - ~QTexturedBrushData() { - delete m_pixmap; - } - - void setPixmap(const QPixmap &pm) { - delete m_pixmap; - - if (pm.isNull()) { - m_pixmap = 0; - m_has_pixmap_texture = false; - } else { - m_pixmap = new QPixmap(pm); - m_has_pixmap_texture = true; - } - - m_image = QImage(); - } - - void setImage(const QImage &image) { - m_image = image; - delete m_pixmap; - m_pixmap = 0; - m_has_pixmap_texture = false; - } - - QPixmap &pixmap() { - if (!m_pixmap) { - m_pixmap = new QPixmap(QPixmap::fromImage(m_image)); - } - return *m_pixmap; - } - - QImage &image() { - if (m_image.isNull() && m_pixmap) - m_image = m_pixmap->toImage(); - return m_image; - } - - QPixmap *m_pixmap; - QImage m_image; - bool m_has_pixmap_texture; -}; -// END BLOCK - -/*! - \class TQPainter - \brief The TQPainter class is a Qt 3 compatibility wrapper for QPainter. - - \compat - - Prior to Qt 4, QPainter specialized the pen drawing for rectangle - based functions (in particular: drawRect, drawEllipse, - drawRoundRect, drawArc, drawChord and drawPie). When stroking a - rectangle of width 10, the pen would draw a rectangle of width 10. - Drawing a polygon defined by the corner points of the same - rectangle the stroke would have a width of 11. - - The reason for this is best explained using the picture below: - - \img q3painter_rationale.png - - As we can see, stroking the rectangle so it gets a width of 10, - means the pen is drawn on a rectangle on width 9. The polygon, - however follows a consistent model. - - In Qt 4, all rectangle based functions have changed to follow the - polygon approach, which means that the rectangle defines the size of - the fill, and the pen follows the edges of the shape. For pen widths - of 0 and 1 this means that the stroke will be inside the shape on the - left and the top and outside on the bottom and right. - - The reason for the change in Qt 4 is so that we provide consistency - for all drawing functions even with complex transformations. -*/ - -TQPainter::TQPainter() : QPainter(), has_qwidget(FALSE), current_penpos(0,0) { -} - -TQPainter::TQPainter( const QWidget *pdev, bool unclipped) : QPainter((QWidget*)pdev), has_qwidget(TRUE), current_penpos(0,0) { - qwidget_ptr = (QWidget*)pdev; - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -TQPainter::TQPainter( QPaintDevice *pdev, bool unclipped) : QPainter(pdev), has_qwidget(FALSE), current_penpos(0,0) { - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -TQPainter::TQPainter( QWidget *pdev, const QWidget *w, bool unclipped) : QPainter(pdev), has_qwidget(TRUE), current_penpos(0,0) { - qwidget_ptr = pdev; - initFrom(w); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -TQPainter::TQPainter( QPaintDevice *pdev, const QWidget *w, bool unclipped ) : QPainter(pdev), has_qwidget(FALSE), current_penpos(0,0) { - initFrom(w); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } -} - -// [FIXME] -void TQPainter::flush() { - printf("[WARNING] void TQPainter::flush() unimplemented\n\r"); -} - -// [FIXME] -void TQPainter::flush( const TQRegion ®ion, TQPainter::CoordinateMode cm ) { - printf("[WARNING] void TQPainter::flush( const TQRegion ®ion, CoordinateMode cm = CoordDevice ) unimplemented\n\r"); -} - -void TQPainter::setBrush(const QBrush &brush) { - return QPainter::setBrush(brush); -} - -void TQPainter::setBrush(Qt::BrushStyle style) { - return QPainter::setBrush(style); -} - -void TQPainter::setBrush(TQt::BrushStyle style) { - this->QPainter::setBrush((Qt::BrushStyle)style); -} - -TQPoint TQPainter::pos() const { - return current_penpos; -} - -bool TQPainter::tqbegin( QPaintDevice *pdev, bool unclipped ) { - bool ret = begin(pdev); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } - return ret; -} - -bool TQPainter::tqbegin( QPaintDevice *pdev, const QWidget *init, bool unclipped ) { - bool ret = begin(pdev); - initFrom(init); - if (unclipped) { - printf("[WARNING] Qt4 does not support drawing under child widgets in TQPainter via the unclipped==TRUE flag in any form! Blame Nokia and change your code...\n\r"); - fflush(stdout); - } - return ret; -} - -QRectF TQPainter::boundingRect(const QRectF &rect, int flags, const QString &text) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRectF tqbr = QPainter::boundingRect(rect, flags, text); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -QRect TQPainter::boundingRect(const QRect &rect, int flags, const QString &text) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRect tqbr = QPainter::boundingRect(rect, flags, text); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -QRect TQPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRect tqbr = QPainter::boundingRect(x, y, w, h, flags, text); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -QRectF TQPainter::boundingRect(const QRectF &rect, const QString &text, const QTextOption &o) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - QRectF tqbr = QPainter::boundingRect(rect, text, o); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -TQRect TQPainter::boundingRect(const QRect &rect, int flags, const QString &text, int len) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - TQRect tqbr = QPainter::boundingRect(rect, flags, text.left(len)); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -TQRect TQPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len) { - TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - TQRect tqbr = QPainter::boundingRect(QRect(x, y, w, h), flags, text.left(len)); - TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL - return tqbr; -} - -void TQPainter::drawText(const QPointF &p, const QString &s) { - QPainter::drawText(p, s); -} - -void TQPainter::drawText(const QPoint &p, const QString &s) { - QPainter::drawText(p, s); -} - -void TQPainter::drawText(int x, int y, const QString &s) { - QPainter::drawText(x, y, s); -} - -void TQPainter::drawText(const QPointF &p, const QString &str, int tf, int justificationPadding) { - QPainter::drawText(p, str, tf, justificationPadding); -} - -void TQPainter::drawText(const QRectF &r, int flags, const QString &text, QRectF *br) { - QPainter::drawText(r, flags, text, br); -} - -void TQPainter::drawText(const QRect &r, int flags, const QString &text, QRect *br) { - QPainter::drawText(r, flags, text, br); -} - -void TQPainter::drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br) { - QPainter::drawText(x, y, w, h, flags, text, br); -} - -void TQPainter::drawText(const QRectF &r, const QString &text, const QTextOption &o) { - QPainter::drawText(r, text, o); -} - -void TQPainter::drawText( int x, int y, const TQString &s, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(x, y, s.left(len)); - setLayoutDirection(old); -} -void TQPainter::drawText( const TQPoint &p, const TQString &s, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(p, s.left(len)); - setLayoutDirection(old); -} -void TQPainter::drawText( int x, int y, const TQString &s, int pos, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(x, y, s.mid(pos, len)); - setLayoutDirection(old); -} -void TQPainter::drawText( const TQPoint &p, const TQString &s, int pos, int len, TextDirection dir ) { - Qt::LayoutDirection old = layoutDirection(); - if (dir == RTL) - setLayoutDirection(Qt::RightToLeft); - else if (dir == LTR) - setLayoutDirection(Qt::LeftToRight); - QPainter::drawText(p, s.mid(pos, len)); - setLayoutDirection(old); -} - -void TQPainter::drawText(int x, int y, const QString &s, int pos, int len) { - drawText(x, y, s.mid(pos, len)); -} - -void TQPainter::drawText(const QPoint &p, const QString &s, int pos, int len) { - drawText(p, s.mid(pos, len)); -} - -void TQPainter::drawText(int x, int y, const QString &s, int len) { - drawText(x, y, s.left(len)); -} - -void TQPainter::drawText(const QPoint &p, const QString &s, int len) { - drawText(p, s.left(len)); -} - -void TQPainter::drawText(const QRect &r, int flags, const QString &str, int len, QRect *br) { - drawText(r, flags, str.left(len), br); -} - -void TQPainter::drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br) { - drawText(QRect(x, y, w, h), flags, text.left(len), br); -} - -int *TQPainter::tabArray() const -{ - printf("[WARNING] TQPainter::tabArray unimplemented!\n\r"); -} - -void TQPainter::setTabArray( int *ta ) -{ - printf("[WARNING] TQPainter::setTabArray unimplemented!\n\r"); - -// #if defined(TQT_CHECK_STATE) -// if ( !isActive() ) -// qWarning( "TQPainter::setTabArray: Will be reset by begin()" ); -// #endif -// if ( ta != tabarray ) { -// tabarraylen = 0; -// if ( tabarray ) // Avoid purify complaint -// delete [] tabarray; // delete old array -// if ( ta ) { // tabarray = copy of 'ta' -// while ( ta[tabarraylen] ) -// tabarraylen++; -// tabarraylen++; // and 0 terminator -// tabarray = new int[tabarraylen]; // duplicate ta -// memcpy( tabarray, ta, sizeof(int)*tabarraylen ); -// } else { -// tabarray = 0; -// } -// } -// if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice -// TQPDevCmdParam param[2]; -// param[0].ival = tabarraylen; -// param[1].ivec = tabarray; -// pdev->cmd( TQPaintDevice::PdcSetTabArray, this, param ); -// } -} - -void TQPainter::drawImage( int x, int y, const TQImage image, int sx, int sy, int sw, int sh, int conversionFlags ) { - QPainter::drawImage(x, y, image, sx, sy, sw, sh, (Qt::ImageConversionFlags)conversionFlags); -} - -void TQPainter::drawImage( const TQPoint p, const TQImage image, const TQRect sr, int conversionFlags ) { - QPainter::drawImage(p, image, sr, (Qt::ImageConversionFlags)conversionFlags); -} - -void TQPainter::drawImage( const TQPoint p, const TQImage image, int conversion_flags ) { - TQ_UNUSED(conversion_flags); - QPainter::drawImage(p, image); -} - -void TQPainter::drawImage( const TQRect r, const TQImage image ) { - QPainter::drawImage(r, image); -} - -void TQPainter::resetXForm() { - resetTransform(); -} - -// [FIXME] The drawWinFocusRect methods below probably need tweaking to exactly match the old Qt3 behaviour -void TQPainter::drawWinFocusRect( int x, int y, int w, int h ) { - drawWinFocusRect( x, y, w, h, TRUE, TQt::color0 ); -} - -void TQPainter::drawWinFocusRect( int x, int y, int w, int h, const TQColor &bgColor ) { - drawWinFocusRect( x, y, w, h, FALSE, bgColor ); -} - -void TQPainter::drawWinFocusRect( const TQRect &tqr ) { - drawWinFocusRect( tqr.x(), tqr.y(), tqr.width(), tqr.height() ); -} - -void TQPainter::drawWinFocusRect( const TQRect &tqr, const TQColor &bgColor ) { - drawWinFocusRect( tqr.x(), tqr.y(), tqr.width(), tqr.height(), bgColor ); -} - -void TQPainter::setBackgroundColor(const QColor &color) { - setBackground(color); -} - -const QColor &TQPainter::backgroundColor() const { - return background().color(); -} - -void TQPainter::setClipRect(const QRectF &qrf, Qt::ClipOperation op) { - QPainter::setClipRect(qrf, op); -} - -void TQPainter::setClipRect(const QRect &qr, Qt::ClipOperation op) { - QPainter::setClipRect(qr, op); -} - -void TQPainter::setClipRect( int x, int y, int w, int h, TQPainter::CoordinateMode cm ) { - TQRect r(x, y, w, h); - setClipRect(r, cm); -} - -void TQPainter::redirect(QPaintDevice *pdev, QPaintDevice *replacement) { - if (replacement == 0) { - restoreRedirected(pdev); - } - else { - setRedirected(pdev, replacement); - } -} - -TQPaintDevice *TQPainter::redirect(QPaintDevice *pdev) { - return static_cast(const_cast(redirected(pdev))); -} - -void TQPainter::setWorldXForm(bool enabled) { - setMatrixEnabled(enabled); -} - -bool TQPainter::hasWorldXForm() const { - return matrixEnabled(); -} - -void TQPainter::setViewXForm(bool enabled) { - setViewTransformEnabled(enabled); -} - -bool TQPainter::hasViewXForm() const { - return viewTransformEnabled(); -} - -// [FIXME] -void TQPainter::initialize() { - printf("[WARNING] TQColor static void initialize() not implemented\n\r"); -} - -// [FIXME] -void TQPainter::cleanup() { - printf("[WARNING] TQColor static void cleanup() not implemented\n\r"); -} - -void TQPainter::moveTo( const TQPoint &p ) -{ - moveTo( p.x(), p.y() ); -} - -void TQPainter::lineTo( const TQPoint &p ) -{ - lineTo( p.x(), p.y() ); -} - -void TQPainter::drawRect(const QRect &r) -{ - QPainter::drawRect(adjustedRectangle(r)); -} - -void TQPainter::drawEllipse(const QRect &r) -{ - QPainter::drawEllipse(adjustedRectangle(r)); -} - -void TQPainter::drawRoundRect(const QRect &r, int xrnd, int yrnd) -{ - QPainter::drawRoundRect(adjustedRectangle(r), xrnd, yrnd); -} - -void TQPainter::drawArc(const QRect &r, int angle, int arcLength) -{ - QPainter::drawArc(adjustedRectangle(r), angle, arcLength); -} - -void TQPainter::drawPie(const QRect &r, int angle, int arcLength) -{ - QPainter::drawPie(adjustedRectangle(r), angle, arcLength); -} - -void TQPainter::drawChord(const QRect &r, int angle, int arcLength) -{ - QPainter::drawChord(adjustedRectangle(r), angle, arcLength); -} - -void TQPainter::tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags ) -{ - tqdrawTextItem( p.x(), p.y(), ti, textflags ); -} - -// [FIXME] -// Verify these mappings... -// They will need to be kept in sync with the code inside tqpainter_x11.cpp -TQt::RasterOp TQPainter::rasterOp() const -{ - TQt::RasterOp cm; - switch (rop) { - case QPainter::CompositionMode_SourceOver: - cm=CopyROP; - break; - case QPainter::RasterOp_SourceOrDestination: - cm=OrROP; - break; - case QPainter::RasterOp_SourceXorDestination: - cm=XorROP; - break; - case QPainter::RasterOp_NotSourceAndDestination: - cm=NotAndROP; - break; - case QPainter::RasterOp_NotSource: - cm=NotCopyROP; - break; - case QPainter::RasterOp_NotSourceXorDestination: - cm=NotXorROP; - break; - case QPainter::RasterOp_SourceAndDestination: - cm=AndROP; - break; - case QPainter::CompositionMode_Clear: - cm=ClearROP; - break; - case QPainter::CompositionMode_Destination: - cm=NopROP; - break; - case QPainter::RasterOp_SourceAndNotDestination: - cm=AndNotROP; - break; - case QPainter::RasterOp_NotSourceOrNotDestination: - cm=NandROP; - break; - case QPainter::RasterOp_NotSourceAndNotDestination: - cm=NorROP; - break; - default: - cm=CopyROP; - break; - } - return cm; -} - -/*! - \fn TQPainter::TQPainter() - - Constructs a TQPainter. -*/ - -/*! - \fn TQPainter::TQPainter(QPaintDevice *pdev) - - Constructs a TQPainter that operates on tqdevice \a pdev. -*/ - -/*! - \internal -*/ - -int TQPainter::rectSubtraction() const { - return pen().style() != Qt::NoPen && pen().width() == 0 ? 1 : 0; -} - -/*! - \internal -*/ -QRect TQPainter::adjustedRectangle(const QRect &r) -{ - QRect rect = r.normalized(); - int subtract = rectSubtraction(); - if (subtract != 0) - rect.setSize(QSize(rect.width() - subtract, rect.height() - subtract)); - return rect; -} - - -/*! - \fn void TQPainter::drawRect(int x, int y, int w, int h) - - \overload - - Draws the rectangle that fits inside the bounds specified by \a x, - \a y, \a w and \a h using the current pen and brush. -*/ - -/*! - \fn void TQPainter::drawRect(const QRect &r) - - Draws a rectangle that fits inside the rectangle \a r using the - current pen and brush. - -*/ - - - -/*! - \fn TQPainter::drawEllipse(const QRect &r) - - Draws the ellipse that fits inside the bounds \a r using the - current pen and brush. - -*/ - -/*! - \fn TQPainter::drawEllipse(int x, int y, int width, int height) - - \overload - - Draws an ellipse that fits inside the bounds specified by \a x, - \a y, \a width and \a height using the current pen and brush. - -*/ - -/*! - \fn void TQPainter::drawPie(int x, int y, int w, int h, int - startAngle, int spanAngle) - - \overload - - Draws a pie segment that fits inside the bounds (\a{x}, \a{y}, - \a{w}, \a{h}) with the given \a startAngle and \a spanAngle. -*/ - -/*! - \fn void TQPainter::drawPie(const QRect &r, int a, int alen) - - Draws a pie defined by the rectangle \a r, the start angle \a a - and the arc length \a alen. - - The pie is filled with the current brush(). - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - \sa drawArc(), drawChord() -*/ - -/*! - \fn void TQPainter::drawArc(int x, int y, int w, int h, int - startAngle, int spanAngle) - - \overload - - Draws the arc that fits inside the rectangle (\a{x}, \a{y}, \a{w}, - \a{h}), with the given \a startAngle and \a spanAngle. -*/ - -/*! - \fn void TQPainter::drawArc(const QRect &r, int a, int alen) - - Draws an arc defined by the rectangle \a r, the start angle \a a - and the arc length \a alen. - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - Example: - \snippet doc/src/snippets/code/src_qt3support_painting_q3painter.cpp 0 - - \sa drawPie(), drawChord() -*/ - -/*! - \fn void TQPainter::drawChord(int x, int y, int w, int h, int - startAngle, int spanAngle) - - \overload - - Draws a chord that fits inside the rectangle (\a{x}, \a{y}, \a{w}, - \a{h}) with the given \a startAngle and \a spanAngle. -*/ - - -/*! - \fn void TQPainter::drawChord(const QRect &r, int a, int alen) - - Draws a chord defined by the rectangle \a r, the start angle \a a - and the arc length \a alen. - - The chord is filled with the current brush(). - - The angles \a a and \a alen are 1/16th of a degree, i.e. a full - circle equals 5760 (16*360). Positive values of \a a and \a alen - mean counter-clockwise while negative values mean the clockwise - direction. Zero degrees is at the 3 o'clock position. - - \sa drawArc(), drawPie() -*/ - -/*! - \fn void TQPainter::drawRoundRect(const QRect &r, int xrnd, int yrnd) - - Draws a rounded rect that fits into the bounds \a r using the current - pen and brush. The parameters \a xrnd and \a yrnd specifies the roundness - in x and y direction. -*/ - -/*! - \fn void TQPainter::drawRoundRect(int x, int y, int w, int h, int xrnd, int yrnd) - - \overload - - Draws a rounded rect that fits into the bounds \a x, \a y, \a w - and \a h using the current pen and brush. The parameters \a xrnd - and \a yrnd specifies the roundness in x and y direction. -*/ - -/*! - \fn void QPainter::drawLineSegments(const QPolygon &polygon, int - index, int count) - - Draws \a count separate lines from points defined by the \a - polygon, starting at \a{polygon}\e{[index]} (\a index defaults to - 0). If \a count is -1 (the default) all points until the end of - the array are used. - - Use drawLines() combined with QPolygon::constData() instead. - - \oldcode - QPainter painter(this); - painter.drawLineSegments(polygon, index, count); - \newcode - int lineCount = (count == -1) ? (polygon.size() - index) / 2 : count; - - QPainter painter(this); - painter.drawLines(polygon.constData() + index * 2, lineCount); - \endcode -*/ - -void TQPainter::drawLineSegments(const QPolygon &polygon, int index, int count) -{ - int lineCount = (count == -1) ? (polygon.size() - index) / 2 : count; - - drawLines(polygon.constData() + index * 2, lineCount); -} - -/*! - \obsolete - - Use the worldTransform() combined with QTransform::dx() instead. - - \oldcode - QPainter painter(this); - qreal x = painter.translationX(); - \newcode - QPainter painter(this); - qreal x = painter.worldTransform().dx(); - \endcode -*/ -qreal TQPainter::translationX() const -{ - return worldTransform().dx(); -} - -/*! - \obsolete - - Use the worldTransform() combined with QTransform::dy() instead. - - \oldcode - QPainter painter(this); - qreal y = painter.translationY(); - \newcode - QPainter painter(this); - qreal y = painter.worldTransform().dy(); - \endcode -*/ -qreal TQPainter::translationY() const -{ - return worldTransform().dy(); -} - -/*! - \fn void TQPainter::map(int x, int y, int *rx, int *ry) const - - \internal - - Sets (\a{rx}, \a{ry}) to the point that results from applying the - painter's current transformation on the point (\a{x}, \a{y}). -*/ -void TQPainter::map(int x, int y, int *rx, int *ry) const -{ - QPoint p(x, y); - p = p * combinedMatrix(); - *rx = p.x(); - *ry = p.y(); -} - -/*! - \internal - Maps a rectangle from logical coordinates to device coordinates. - This internal function does not handle rotation and/or shear. -*/ - -void TQPainter::map( int x, int y, int w, int h, int *rx, int *ry, int *rw, int *rh ) const -{ - TQRect qr(x, y, w, h); - QTransform dtrans = combinedTransform(); - TQRect tqr = dtrans.mapRect(qr); - *rx = tqr.x(); - *ry = tqr.y(); - *rw = tqr.width(); - *rh = tqr.height(); -} - -/*! - \fn TQPoint TQPainter::xForm(const QPoint &point) const - - Use combinedTransform() instead. -*/ - -TQPoint TQPainter::xForm(const QPoint &p) const -{ - if (combinedTransform().type() == QTransform::TxNone) - return p; - return p * combinedMatrix(); -} - - -/*! - \fn TQRect TQPainter::xForm(const QRect &rectangle) const - \overload - - Use combinedTransform() instead of this function and call - mapRect() on the result to obtain a QRect. -*/ - -TQRect TQPainter::xForm(const QRect &r) const -{ - if (combinedTransform().type() == QTransform::TxNone) - return r; - return combinedMatrix().mapRect(r); -} - -bool TQPainter::testf( uint b ) const { -// printf("[WARNING] QPainter::testf() disabled\n\r"); -// return 0; - - // Map to Qt4 flags and functions... - if ((b&IsActive)!=0) { - if (QPainter::isActive()) return TRUE; - } -// if ((b&ExtDev)!=0) { -// printf("[WARNING] Assuming ExtDev==false in QPainter::testf()\n\r"); -// } -// if ((b&IsStartingUp)!=0) { -// } -// if ((b&NoCache)!=0) { -// } - if ((b&VxF)!=0) { - if (QPainter::viewTransformEnabled()) return TRUE; - } - if ((b&WxF)!=0) { - if (QPainter::worldMatrixEnabled()) return TRUE; - } - if ((b&ClipOn)!=0) { - if (QPainter::hasClipping()) return TRUE; - } - - printf("[WARNING] Assuming test flag 0x%x == false in QPainter::testf()\n\r", b); - return 0; -} - -/*! - \fn TQPolygon TQPainter::xForm(const QPolygon &polygon) const - \overload - - Use combinedTransform() instead. -*/ - -// TQPolygon TQPainter::xForm(const QPolygon &a) const -// { -// Q_D(const QPainter); -// if (!d->engine) { -// qWarning("QPainter::xForm: Painter not active"); -// return QPolygon(); -// } -// if (d->state->matrix.type() == QTransform::TxNone) -// return a; -// return a * combinedMatrix(); -// } - -/*! - \fn TQPolygon TQPainter::xForm(const QPolygon &polygon, int index, int count) const - \overload - - Use combinedTransform() combined with QPolygon::mid() instead. - - \oldcode - QPainter painter(this); - QPolygon transformed = painter.xForm(polygon, index, count) - \newcode - QPainter painter(this); - QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform(); - \endcode -*/ - -// TQPolygon TQPainter::xForm(const QPolygon &av, int index, int npoints) const -// { -// int lastPoint = npoints < 0 ? av.size() : index+npoints; -// QPolygon a(lastPoint-index); -// memcpy(a.data(), av.data()+index, (lastPoint-index)*sizeof(QPoint)); -// return a * combinedMatrix(); -// } - -/*! - \fn TQPoint TQPainter::xFormDev(const QPoint &point) const - \overload - \obsolete - - Use combinedTransform() combined with QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QPoint transformed = painter.xFormDev(point); - \newcode - QPainter painter(this); - QPoint transformed = point * painter.combinedTransform().inverted(); - \endcode -*/ - -TQPoint TQPainter::xFormDev(const QPoint &p) const -{ - if(combinedTransform().type() == QTransform::TxNone) - return p; - return p * combinedMatrix().inverted(); -} - -/*! - \fn TQRect TQPainter::xFormDev(const QRect &rectangle) const - \overload - \obsolete - - Use combinedTransform() combined with QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QRect transformed = painter.xFormDev(rectangle); - \newcode - QPainter painter(this); - QRegion region = QRegion(rectangle) * painter.combinedTransform().inverted(); - QRect transformed = region.boundingRect(); - \endcode -*/ - -TQRect TQPainter::xFormDev(const QRect &r) const -{ - if (combinedTransform().type() == QTransform::TxNone) - return r; - return combinedMatrix().inverted().mapRect(r); -} - -/*! - \overload - - \fn TQPoint TQPainter::xFormDev(const QPolygon &polygon) const - \obsolete - - Use combinedTransform() combined with QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QPolygon transformed = painter.xFormDev(rectangle); - \newcode - QPainter painter(this); - QPolygon transformed = polygon * painter.combinedTransform().inverted(); - \endcode -*/ - -// TQPolygon TQPainter::xFormDev(const QPolygon &a) const -// { -// Q_D(const QPainter); -// if (!d->engine) { -// qWarning("QPainter::xFormDev: Painter not active"); -// return QPolygon(); -// } -// if (d->state->matrix.type() == QTransform::TxNone) -// return a; -// return a * combinedMatrix().inverted(); -// } - -/*! - \fn TQPolygon TQPainter::xFormDev(const QPolygon &polygon, int index, int count) const - \overload - \obsolete - - Use combinedTransform() combined with QPolygon::mid() and QTransform::inverted() instead. - - \oldcode - QPainter painter(this); - QPolygon transformed = painter.xFormDev(polygon, index, count); - \newcode - QPainter painter(this); - QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform().inverted(); - \endcode -*/ - -// TQPolygon TQPainter::xFormDev(const QPolygon &ad, int index, int npoints) const -// { -// Q_D(const QPainter); -// int lastPoint = npoints < 0 ? ad.size() : index+npoints; -// QPolygon a(lastPoint-index); -// memcpy(a.data(), ad.data()+index, (lastPoint-index)*sizeof(QPoint)); -// if (d->state->matrix.type() == QTransform::TxNone) -// return a; -// return a * combinedMatrix().inverted(); -// } - -/*! \obsolete - Sets the current pen position to \a (x, y) - - \sa lineTo(), pos() -*/ - -void TQPainter::moveTo( int x, int y ) -{ - QPainterPath path; - path.moveTo(x, y); - drawPath(path); - current_penpos = QPoint(x, y); -} - -/*! \obsolete - Use drawLine() instead. - - Draws a line from the current pen position to \a (x, y) and sets - \a (x, y) to be the new current pen position. - - \sa TQPen moveTo(), drawLine(), pos() -*/ - -void TQPainter::lineTo( int x, int y ) -{ - QPainterPath path; - path.moveTo(current_penpos.x(), current_penpos.y()); - path.lineTo(x, y); - drawPath(path); - current_penpos = QPoint(x, y); -} - -static void bitBlt_helper(QPaintDevice *dst, const QPoint &dp, - const QPaintDevice *src, const QRect &sr, bool) -{ - Q_ASSERT(dst); - Q_ASSERT(src); - - if (src->devType() == QInternal::Pixmap) { - const QPixmap *pixmap = static_cast(src); - QPainter pt(dst); - pt.drawPixmap(dp, *pixmap, sr); - - } else { - qWarning("QPainter: bitBlt only works when source is of type pixmap"); - } -} - -void bitBlt(QPaintDevice *dst, int dx, int dy, - const QPaintDevice *src, int sx, int sy, int sw, int sh, - bool ignoreMask ) -{ - bitBlt_helper(dst, QPoint(dx, dy), src, QRect(sx, sy, sw, sh), ignoreMask); -} - -void bitBlt(QPaintDevice *dst, const QPoint &dp, const QPaintDevice *src, const QRect &sr, bool ignoreMask) -{ - bitBlt_helper(dst, dp, src, sr, ignoreMask); -} - -void bitBlt(QPaintDevice *dst, int dx, int dy, - const QImage *src, int sx, int sy, int sw, int sh, int fl) -{ - Qt::ImageConversionFlags flags(fl); - QPixmap srcPixmap = QPixmap::fromImage(*src, flags); - bitBlt_helper(dst, QPoint(dx, dy), &srcPixmap, QRect(sx, sy, sw, sh), false); -} - -const TQWMatrix &TQPainter::tqworldMatrix() const { - return (*(static_cast(&worldMatrix()))); -} - -/*! - \fn void TQPainter::tqdrawTextItem(const TQPoint &, const TQTextItem &, int) - \internal -*/ - -static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - if ( *w < 0 ) { - *w = -*w + 2; - *x -= *w - 1; - } - if ( *h < 0 ) { - *h = -*h + 2; - *y -= *h - 1; - } -} -void TQPainter::fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - ::fix_neg_rect(x,y,w,h); -} - -TQRegion TQPainter::clipRegion( CoordinateMode cm ) const { - QRegion qr = QPainter::clipRegion(); - QRegion tqr = qr; - if (cm == CoordDevice) { - // Convert to device coordinates - QTransform dtrans = combinedTransform(); - tqr = dtrans.map(qr); - } - return tqr; -} - -void TQPainter::setClipRegion( const QRegion &qr, CoordinateMode cm ) { - QRegion tqr = qr; - - if (cm == CoordDevice) { - // Convert from device coordinates - QTransform itrans = combinedTransform().inverted(); - tqr = itrans.map(qr); - - QPainter::setClipRegion( tqr, Qt::ReplaceClip ); - } - else { - QPainter::setClipRegion( tqr, Qt::ReplaceClip ); - } -} - -void TQPainter::setClipRect( const TQRect &qr, CoordinateMode cm ) { - QRect tqr = qr; - - if (cm == CoordDevice) { - // Convert from device coordinates - QTransform itrans = combinedTransform().inverted(); - tqr = itrans.mapRect(qr); - - QPainter::setClipRect( tqr, Qt::ReplaceClip ); - } - else { - QPainter::setClipRect( tqr, Qt::ReplaceClip ); - } -} - -QT_END_NAMESPACE - -#else // USE_QT4 - -/**************************************************************************** -** -** Implementation of TQPainter, TQPen and TQBrush classes -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 "tqpainter_p.h" -#include "tqbitmap.h" -#include "tqptrstack.h" -#include "tqptrdict.h" -#include "tqdatastream.h" -#include "tqwidget.h" -#include "tqimage.h" -#include "tqpaintdevicemetrics.h" -#include "tqapplication.h" -#include "tqrichtext_p.h" -#include "tqregexp.h" -#include "tqcleanuphandler.h" -#ifdef TQ_WS_TQWS -#include "tqgfx_qws.h" -#endif -#include - -#include "tqtextlayout_p.h" -#include "tqfontengine_p.h" - -#ifndef TQT_NO_TRANSFORMATIONS -typedef TQPtrStack TQWMatrixStack; -#endif - -// POSIX Large File Support redefines truncate -> truncate64 -#if defined(truncate) -# undef truncate -#endif - -/*! - \class TQPainter tqpainter.h - \brief The TQPainter class does low-level painting e.g. on widgets. - - \ingroup graphics - \ingroup images - \mainclass - - The painter provides highly optimized functions to do most of the - drawing GUI programs require. TQPainter can draw everything from - simple lines to complex tqshapes like pies and chords. It can also - draw aligned text and pixmaps. Normally, it draws in a "natural" - coordinate system, but it can also do view and world - transformation. - - The typical use of a painter is: - - \list - \i Construct a painter. - \i Set a pen, a brush etc. - \i Draw. - \i Destroy the painter. - \endlist - - Mostly, all this is done inside a paint event. (In fact, 99% of - all TQPainter use is in a reimplementation of - TQWidget::paintEvent(), and the painter is heavily optimized for - such use.) Here's one very simple example: - - \code - void SimpleExampleWidget::paintEvent() - { - TQPainter paint( this ); - paint.setPen( TQt::blue ); - paint.drawText( rect(), AlignCenter, "The Text" ); - } - \endcode - - Usage is simple, and there are many settings you can use: - - \list - - \i font() is the currently set font. If you set a font that isn't - available, TQt tqfinds a close match. In fact font() returns what - you set using setFont() and fontInfo() returns the font actually - being used (which may be the same). - - \i brush() is the currently set brush; the color or pattern that's - used for filling e.g. circles. - - \i pen() is the currently set pen; the color or stipple that's - used for drawing lines or boundaries. - - \i backgroundMode() is \c Opaque or \c Transtqparent, i.e. whether - backgroundColor() is used or not. - - \i backgroundColor() only applies when backgroundMode() is Opaque - and pen() is a stipple. In that case, it describes the color of - the background pixels in the stipple. - - \i rasterOp() is how pixels drawn interact with the pixels already - there. - - \i brushOrigin() is the origin of the tiled brushes, normally the - origin of the window. - - \i viewport(), window(), tqworldMatrix() and many more make up the - painter's coordinate transformation system. See \link - coordsys.html The Coordinate System \endlink for an explanation of - this, or see below for a very brief overview of the functions. - - \i hasClipping() is whether the painter clips at all. (The paint - tqdevice clips, too.) If the painter clips, it clips to clipRegion(). - - \i pos() is the current position, set by moveTo() and used by - lineTo(). - - \endlist - - Note that some of these settings mirror settings in some paint - tqdevices, e.g. TQWidget::font(). TQPainter::begin() (or the TQPainter - constructor) copies these attributes from the paint tqdevice. - Calling, for example, TQWidget::setFont() doesn't take effect until - the next time a painter begins painting on it. - - save() saves all of these settings on an internal stack, restore() - pops them back. - - The core functionality of TQPainter is drawing, and there are - functions to draw most primitives: drawPoint(), drawPoints(), - drawLine(), drawRect(), drawWinFocusRect(), drawRoundRect(), - drawEllipse(), drawArc(), drawPie(), drawChord(), - drawLineSegments(), drawPolyline(), drawPolygon(), - drawConvexPolygon() and drawCubicBezier(). All of these functions - take integer coordinates; there are no floating-point versions - since we want drawing to be as fast as possible. - - There are functions to draw pixmaps/images, namely drawPixmap(), - drawImage() and drawTiledPixmap(). drawPixmap() and drawImage() - produce the same result, except that drawPixmap() is faster - on-screen and drawImage() faster and sometimes better on TQPrinter - and TQPicture. - - Text drawing is done using drawText(), and when you need - fine-grained positioning, boundingRect() tells you where a given - drawText() command would draw. - - There is a drawPicture() function that draws the contents of an - entire TQPicture using this painter. drawPicture() is the only - function that disregards all the painter's settings: the TQPicture - has its own settings. - - Normally, the TQPainter operates on the tqdevice's own coordinate - system (usually pixels), but TQPainter has good support for - coordinate transformation. See \link coordsys.html The Coordinate - System \endlink for a more general overview and a simple example. - - The most common functions used are scale(), rotate(), translate() - and shear(), all of which operate on the tqworldMatrix(). - setWorldMatrix() can tqreplace or add to the currently set - tqworldMatrix(). - - setViewport() sets the rectangle on which TQPainter operates. The - default is the entire tqdevice, which is usually fine, except on - printers. setWindow() sets the coordinate system, that is, the - rectangle that maps to viewport(). What's drawn inside the - window() ends up being inside the viewport(). The window's - default is the same as the viewport, and if you don't use the - transformations, they are optimized away, gaining another little - bit of speed. - - After all the coordinate transformation is done, TQPainter can clip - the drawing to an arbitrary rectangle or region. hasClipping() is - TRUE if TQPainter clips, and clipRegion() returns the clip region. - You can set it using either setClipRegion() or setClipRect(). - Note that the clipping can be slow. It's all system-dependent, - but as a rule of thumb, you can assume that drawing speed is - inversely proportional to the number of rectangles in the clip - region. - - After TQPainter's clipping, the paint tqdevice may also clip. For - example, most widgets clip away the pixels used by child widgets, - and most printers clip away an area near the edges of the paper. - This additional clipping is not reflected by the return value of - clipRegion() or hasClipping(). - - TQPainter also includes some less-used functions that are very - useful on those occasions when they're needed. - - isActive() indicates whether the painter is active. begin() (and - the most usual constructor) makes it active. end() (and the - destructor) deactivates it. If the painter is active, tqdevice() - returns the paint tqdevice on which the painter paints. - - Sometimes it is desirable to make someone else paint on an unusual - TQPaintDevice. TQPainter supports a static function to do this, - redirect(). We recommend not using it, but for some hacks it's - perfect. - - setTabStops() and setTabArray() can change where the tab stops - are, but these are very seldomly used. - - \warning Note that TQPainter does not attempt to work around - coordinate limitations in the underlying window system. Some - platforms may behave incorrectly with coordinates as small as - +/-4000. - - \headerfile tqdrawutil.h - - \sa TQPaintDevice TQWidget TQPixmap TQPrinter TQPicture - \link simple-application.html Application Walkthrough \endlink - \link coordsys.html Coordinate System Overview \endlink -*/ - -/*! - \fn TQGfx * TQPainter::internalGfx() - - \internal -*/ - -/*! - \enum TQPainter::CoordinateMode - \value CoordDevice - \value CoordPainter - - \sa clipRegion() -*/ -/*! - \enum TQPainter::TextDirection - \value Auto - \value RTL right to left - \value LTR left to right - - \sa drawText() -*/ - -/*! - \enum TQt::PaintUnit - \value PixelUnit - \value LoMetricUnit \e obsolete - \value HiMetricUnit \e obsolete - \value LoEnglishUnit \e obsolete - \value HiEnglishUnit \e obsolete - \value TwipsUnit \e obsolete -*/ - -/*! - \enum TQt::BrushStyle - - \value NoBrush - \value SolidPattern - \value Dense1Pattern - \value Dense2Pattern - \value Dense3Pattern - \value Dense4Pattern - \value Dense5Pattern - \value Dense6Pattern - \value Dense7Pattern - \value HorPattern - \value VerPattern - \value CrossPattern - \value BDiagPattern - \value FDiagPattern - \value DiagCrossPattern - \value CustomPattern - - \img brush-styles.png Brush Styles - -*/ - -/*! - \enum TQt::RasterOp - - This enum type is used to describe the way things are written to - the paint tqdevice. Each bit of the \e src (what you write) - interacts with the corresponding bit of the \e dst pixel. - - \value CopyROP dst = src - \value OrROP dst = src OR dst - \value XorROP dst = src XOR dst - \value NotAndROP dst = (NOT src) AND dst - \value EraseROP an alias for \c NotAndROP - \value NotCopyROP dst = NOT src - \value NotOrROP dst = (NOT src) OR dst - \value NotXorROP dst = (NOT src) XOR dst - \value AndROP dst = src AND dst - \value NotEraseROP an alias for \c AndROP - \value NotROP dst = NOT dst - \value ClearROP dst = 0 - \value SetROP dst = 1 - \value NopROP dst = dst - \value AndNotROP dst = src AND (NOT dst) - \value OrNotROP dst = src OR (NOT dst) - \value NandROP dst = NOT (src AND dst) - \value NorROP dst = NOT (src OR dst) - - By far the most useful ones are \c CopyROP and \c XorROP. - - On TQt/Embedded, only \c CopyROP, \c XorROP, and \c NotROP are supported. -*/ - -/*! - \enum TQt::AlignmentFlags - - This enum type is used to describe tqalignment. It tqcontains - horizontal and vertical flags. - - The horizontal flags are: - - \value AlignAuto Aligns according to the language. Left for most, - right for Arabic and Hebrew. - \value AlignLeft Aligns with the left edge. - \value AlignRight Aligns with the right edge. - \value AlignHCenter Centers horizontally in the available space. - \value AlignJustify Justifies the text in the available space. - Does not work for everything and may be interpreted as - AlignAuto in some cases. - - The vertical flags are: - - \value AlignTop Aligns with the top. - \value AlignBottom Aligns with the bottom. - \value AlignVCenter Centers vertically in the available space. - - You can use only one of the horizontal flags at a time. There is - one two-dimensional flag: - - \value AlignCenter Centers in both dimensions. - - You can use at most one horizontal and one vertical flag at a time. \c - AlignCenter counts as both horizontal and vertical. - - Masks: - - \value AlignHorizontal_Mask - \value AlignVertical_Mask - - Conflicting combinations of flags have undefined meanings. -*/ - -/*! - \enum TQt::TextFlags - - This enum type is used to define some modifier flags. Some of - these flags only make sense in the context of printing: - - \value SingleLine Treats all whitespace as spaces and prints just - one line. - \value DontClip If it's impossible to stay within the given bounds, - it prints outside. - \value ExpandTabs Makes the U+0009 (ASCII tab) character move to - the next tab stop. - \value ShowPrefix Displays the string "\&P" as P - (see TQButton for an example). For an ampersand, use "\&\&". - \value WordBreak Breaks lines at appropriate points, e.g. at word - boundaries. - \value BreakAnywhere Breaks lines anywhere, even within words. - \value NoAccel Same as ShowPrefix but doesn't draw the underlines. - - You can use as many modifier flags as you want, except that \c - SingleLine and \c WordBreak cannot be combined. - - Flags that are inappropriate for a given use (e.g. ShowPrefix to - TQGridLayout::addWidget()) are generally ignored. - -*/ - -/*! - \enum TQt::PenStyle - - This enum type defines the pen styles that can be drawn using - TQPainter. The styles are - - \value NoPen no line at all. For example, TQPainter::drawRect() - fills but does not draw any boundary line. - - \value SolidLine a simple line. - - \value DashLine dashes separated by a few pixels. - - \value DotLine dots separated by a few pixels. - - \value DashDotLine alternate dots and dashes. - - \value DashDotDotLine one dash, two dots, one dash, two dots. - - \value MPenStyle tqmask of the pen styles. - - \img pen-styles.png Pen Styles -*/ - -/*! - \enum TQt::PenCapStyle - - This enum type defines the pen cap styles supported by TQt, i.e. - the line end caps that can be drawn using TQPainter. - - \value FlatCap a square line end that does not cover the end - point of the line. - \value SquareCap a square line end that covers the end point and - extends beyond it with half the line width. - \value RoundCap a rounded line end. - \value MPenCapStyle tqmask of the pen cap styles. - - \img pen-cap-styles.png Pen Cap Styles -*/ - -/*! - \enum TQt::PenJoinStyle - - This enum type defines the pen join styles supported by TQt, i.e. - which joins between two connected lines can be drawn using - TQPainter. - - \value MiterJoin The outer edges of the lines are extended to - meet at an angle, and this area is filled. - \value BevelJoin The triangular notch between the two lines is filled. - \value RoundJoin A circular arc between the two lines is filled. - \value MPenJoinStyle tqmask of the pen join styles. - - \img pen-join-styles.png Pen Join Styles -*/ - -/*! - \enum TQt::BGMode - - Background mode - - \value TransparentMode - \value OpaqueMode -*/ - -/*! - Constructs a painter. - - Notice that all painter settings (setPen, setBrush etc.) are reset - to default values when begin() is called. - - \sa begin(), end() -*/ - -TQPainter::TQPainter() -{ - init(); -} - - -/*! - Constructs a painter that begins painting the paint tqdevice \a pd - immediately. Depending on the underlying graphic system the - painter will paint over tqchildren of the painttqdevice if \a - unclipped is TRUE. - - This constructor is convenient for short-lived painters, e.g. in a - \link TQWidget::paintEvent() paint event\endlink and should be used - only once. The constructor calls begin() for you and the TQPainter - destructor automatically calls end(). - - Here's an example using begin() and end(): - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p; - p.begin( this ); - p.drawLine( ... ); // drawing code - p.end(); - } - \endcode - - The same example using this constructor: - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p( this ); - p.drawLine( ... ); // drawing code - } - \endcode - - Since the constructor cannot provide feedback when the initialization - of the painter failed you should rather use begin() and end() to paint - on external tqdevices, e.g. printers. - - \sa begin(), end() -*/ - -TQPainter::TQPainter( const TQPaintDevice *pd, bool unclipped ) -{ - init(); - if ( begin( pd, unclipped ) ) - flags |= CtorBegin; -} - - -/*! - Constructs a painter that begins painting the paint tqdevice \a pd - immediately, with the default arguments taken from \a - copyAttributes. The painter will paint over tqchildren of the paint - tqdevice if \a unclipped is TRUE (although this is not supported on - all platforms). - - \sa begin() -*/ - -TQPainter::TQPainter( const TQPaintDevice *pd, - const TQWidget *copyAttributes, bool unclipped ) -{ - init(); - if ( begin( pd, copyAttributes, unclipped ) ) - flags |= CtorBegin; -} - - -/*! - Destroys the painter. -*/ - -TQPainter::~TQPainter() -{ - if ( isActive() ) - end(); - else - killPStack(); - if ( tabarray ) // delete tab array - delete [] tabarray; -#ifndef TQT_NO_TRANSFORMATIONS - if ( wm_stack ) - delete (TQWMatrixStack *)wm_stack; -#endif - destroy(); -} - - -/*! - \overload bool TQPainter::begin( const TQPaintDevice *pd, const TQWidget *copyAttributes, bool unclipped ) - - This version opens the painter on a paint tqdevice \a pd and sets - the initial pen, background color and font from \a copyAttributes, - painting over the paint tqdevice's tqchildren when \a unclipped is - TRUE. This is equivalent to: - - \code - TQPainter p; - p.begin( pd ); - p.setPen( copyAttributes->foregroundColor() ); - p.setBackgroundColor( copyAttributes->backgroundColor() ); - p.setFont( copyAttributes->font() ); - \endcode - - This begin function is convenient for double buffering. When you - draw in a pixmap instead of directly in a widget (to later bitBlt - the pixmap into the widget) you will need to set the widget's - font etc. This function does exactly that. - - Example: - \code - void MyWidget::paintEvent( TQPaintEvent * ) - { - TQPixmap pm(size()); - TQPainter p; - p.begin(&pm, this); - // ... potentially flickering paint operation ... - p.end(); - bitBlt(this, 0, 0, &pm); - } - \endcode - - \sa end() -*/ - -bool TQPainter::begin( const TQPaintDevice *pd, const TQWidget *copyAttributes, bool unclipped ) -{ - if ( copyAttributes == 0 ) { -#if defined(TQT_CHECK_NULL) - qWarning( "TQPainter::begin: The widget to copy attributes from cannot " - "be null" ); -#endif - return FALSE; - } - if ( begin( pd, unclipped ) ) { - setPen( copyAttributes->foregroundColor() ); - setBackgroundColor( copyAttributes->backgroundColor() ); - setFont( copyAttributes->font() ); - return TRUE; - } - return FALSE; -} - - -/*! - \internal - Sets or clears a pointer flag. -*/ - -void TQPainter::setf( uint b, bool v ) -{ - if ( v ) - setf( b ); - else - clearf( b ); -} - - -/*! - \fn bool TQPainter::isActive() const - - Returns TRUE if the painter is active painting, i.e. begin() has - been called and end() has not yet been called; otherwise returns - FALSE. - - \sa TQPaintDevice::paintingActive() -*/ - -/*! - \fn TQPaintDevice *TQPainter::tqdevice() const - - Returns the paint tqdevice on which this painter is currently - painting, or 0 if the painter is not active. - - \sa TQPaintDevice::paintingActive() -*/ - - -struct TQPState { // painter state - TQFont font; - TQPen pen; - TQPoint curPt; - TQBrush brush; - TQColor bgc; - uchar bgm; - uchar rop; - TQPoint bro; - TQRect wr, vr; -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix wm; -#else - int xlatex; - int xlatey; -#endif - bool vxf; - bool wxf; - TQRegion rgn; - bool clip; - int ts; - int *ta; - void* wm_stack; -}; - -//TODO lose the worldmatrix stack - -typedef TQPtrStack TQPStateStack; - - -void TQPainter::killPStack() -{ -#if defined(TQT_CHECK_STATE) - if ( ps_stack && !((TQPStateStack *)ps_stack)->isEmpty() ) - qWarning( "TQPainter::killPStack: non-empty save/restore stack when " - "end() was called" ); -#endif - delete (TQPStateStack *)ps_stack; - ps_stack = 0; -} - -/*! - Saves the current painter state (pushes the state onto a stack). A - save() must be followed by a corresponding restore(). end() - unwinds the stack. - - \sa restore() -*/ - -void TQPainter::save() -{ - if ( testf(ExtDev) ) { - if ( testf(DirtyFont) ) - updateFont(); - if ( testf(DirtyPen) ) - updatePen(); - if ( testf(DirtyBrush) ) - updateBrush(); - pdev->cmd( TQPaintDevice::PdcSave, this, 0 ); - } - TQPStateStack *pss = (TQPStateStack *)ps_stack; - if ( pss == 0 ) { - pss = new TQPtrStack; - TQ_CHECK_PTR( pss ); - pss->setAutoDelete( TRUE ); - ps_stack = pss; - } - TQPState *ps = new TQPState; - TQ_CHECK_PTR( ps ); - ps->font = cfont; - ps->pen = cpen; - ps->curPt = pos(); - ps->brush = cbrush; - ps->bgc = bg_col; - ps->bgm = bg_mode; - ps->rop = rop; - ps->bro = bro; -#ifndef TQT_NO_TRANSFORMATIONS - ps->wr = TQRect( wx, wy, ww, wh ); - ps->vr = TQRect( vx, vy, vw, vh ); - ps->wm = wxmat; - ps->vxf = testf(VxF); - ps->wxf = testf(WxF); -#else - ps->xlatex = xlatex; - ps->xlatey = xlatey; -#endif - ps->rgn = crgn; - ps->clip = testf(ClipOn); - ps->ts = tabstops; - ps->ta = tabarray; - ps->wm_stack = wm_stack; - wm_stack = 0; - pss->push( ps ); -} - -/*! - Restores the current painter state (pops a saved state off the - stack). - - \sa save() -*/ - -void TQPainter::restore() -{ - if ( testf(ExtDev) ) { - pdev->cmd( TQPaintDevice::PdcRestore, this, 0 ); - if ( pdev->devType() == TQInternal::Picture ) - block_ext = TRUE; - } - TQPStateStack *pss = (TQPStateStack *)ps_stack; - if ( pss == 0 || pss->isEmpty() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::restore: Empty stack error" ); -#endif - return; - } - TQPState *ps = pss->pop(); - bool hardRestore = testf(VolatileDC); - - if ( ps->font != cfont || hardRestore ) - setFont( ps->font ); - if ( ps->pen != cpen || hardRestore ) - setPen( ps->pen ); - if ( ps->brush != cbrush || hardRestore ) - setBrush( ps->brush ); - if ( ps->bgc != bg_col || hardRestore ) - setBackgroundColor( ps->bgc ); - if ( ps->bgm != bg_mode || hardRestore ) - setBackgroundMode( (BGMode)ps->bgm ); - if ( ps->rop != rop || hardRestore ) - setRasterOp( (RasterOp)ps->rop ); - if ( ps->bro != bro || hardRestore ) - setBrushOrigin( ps->bro ); -#ifndef TQT_NO_TRANSFORMATIONS - TQRect wr( wx, wy, ww, wh ); - TQRect vr( vx, vy, vw, vh ); - if ( ps->wr != wr || hardRestore ) - setWindow( ps->wr ); - if ( ps->vr != vr || hardRestore ) - setViewport( ps->vr ); - if ( ps->wm != wxmat || hardRestore ) - setWorldMatrix( ps->wm ); - if ( ps->vxf != testf(VxF) || hardRestore ) - setViewXForm( ps->vxf ); - if ( ps->wxf != testf(WxF) || hardRestore ) - setWorldXForm( ps->wxf ); -#else - xlatex = ps->xlatex; - xlatey = ps->xlatey; - setf( VxF, xlatex || xlatey ); -#endif - if ( ps->curPt != pos() || hardRestore ) - moveTo( ps->curPt ); - if ( ps->rgn != crgn || hardRestore ) - setClipRegion( ps->rgn ); - if ( ps->clip != testf(ClipOn) || hardRestore ) - setClipping( ps->clip ); - tabstops = ps->ts; - tabarray = ps->ta; - -#ifndef TQT_NO_TRANSFORMATIONS - if ( wm_stack ) - delete (TQWMatrixStack *)wm_stack; - wm_stack = ps->wm_stack; -#endif - delete ps; - block_ext = FALSE; -} - -typedef TQPtrDict TQPaintDeviceDict; -static TQPaintDeviceDict *pdev_dict = 0; - -/*! - Redirects all paint commands for a paint tqdevice, \a pdev, to - another paint tqdevice, \a tqreplacement, unless \a tqreplacement is 0. - If \a tqreplacement is 0, the redirection for \a pdev is removed. - - In general, you'll probably tqfind calling TQPixmap::grabWidget() or - TQPixmap::grabWindow() is an easier solution. -*/ - -void TQPainter::redirect( TQPaintDevice *pdev, TQPaintDevice *tqreplacement ) -{ - if ( pdev_dict == 0 ) { - if ( tqreplacement == 0 ) - return; - pdev_dict = new TQPaintDeviceDict; - TQ_CHECK_PTR( pdev_dict ); - } -#if defined(TQT_CHECK_NULL) - if ( pdev == 0 ) - qWarning( "TQPainter::redirect: The pdev argument cannot be 0" ); -#endif - if ( tqreplacement ) { - pdev_dict->insert( pdev, tqreplacement ); - } else { - pdev_dict->remove( pdev ); - if ( pdev_dict->count() == 0 ) { - delete pdev_dict; - pdev_dict = 0; - } - } -} - -/*! - \internal - Returns the tqreplacement for \a pdev, or 0 if there is no tqreplacement. -*/ -TQPaintDevice *TQPainter::redirect( TQPaintDevice *pdev ) -{ - return pdev_dict ? pdev_dict->tqfind( pdev ) : 0; -} - -/*! - Returns the font metrics for the painter, if the painter is - active. It is not possible to obtain metrics for an inactive - painter, so the return value is undefined if the painter is not - active. - - \sa fontInfo(), isActive() -*/ - -TQFontMetrics TQPainter::fontMetrics() const -{ - if ( pdev && pdev->devType() == TQInternal::Picture ) - return TQFontMetrics( cfont ); - - return TQFontMetrics(this); -} - -/*! - Returns the font info for the painter, if the painter is active. - It is not possible to obtain font information for an inactive - painter, so the return value is undefined if the painter is not - active. - - \sa fontMetrics(), isActive() -*/ - -TQFontInfo TQPainter::fontInfo() const -{ - if ( pdev && pdev->devType() == TQInternal::Picture ) - return TQFontInfo( cfont ); - - return TQFontInfo(this); -} - - -/*! - \fn const TQPen &TQPainter::pen() const - - Returns the painter's current pen. - - \sa setPen() -*/ - -/*! - Sets a new painter pen. - - The \a pen defines how to draw lines and outlines, and it also - defines the text color. - - \sa pen() -*/ - -void TQPainter::setPen( const TQPen &pen ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setPen: Will be reset by begin()" ); -#endif - if ( cpen == pen ) - return; - cpen = pen; - updatePen(); -} - -/*! - \overload - - Sets the painter's pen to have style \a style, width 0 and black - color. - - \sa pen(), TQPen -*/ - -void TQPainter::setPen( PenStyle style ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setPen: Will be reset by begin()" ); -#endif - TQPen::TQPenData *d = cpen.data; // low level access - if ( d->style == style && d->linest == style && !d->width && d->color == TQt::black ) - return; - if ( d->count != 1 ) { - cpen.detach(); - d = cpen.data; - } - d->style = style; - d->width = 0; - d->color = TQt::black; - d->linest = style; - updatePen(); -} - -/*! - \overload - - Sets the painter's pen to have style \c SolidLine, width 0 and the - specified \a color. - - \sa pen(), TQPen -*/ - -void TQPainter::setPen( const TQColor &color ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setPen: Will be reset by begin()" ); -#endif - TQPen::TQPenData *d = cpen.data; // low level access - if ( d->color == color && !d->width && d->style == SolidLine && d->linest == SolidLine ) - return; - if ( d->count != 1 ) { - cpen.detach(); - d = cpen.data; - } - d->style = SolidLine; - d->width = 0; - d->color = color; - d->linest = SolidLine; - updatePen(); -} - -/*! - \fn const TQBrush &TQPainter::brush() const - - Returns the painter's current brush. - - \sa TQPainter::setBrush() -*/ - -/*! - \overload - - Sets the painter's brush to \a brush. - - The \a brush defines how tqshapes are filled. - - \sa brush() -*/ - -void TQPainter::setBrush( const TQBrush &brush ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setBrush: Will be reset by begin()" ); -#endif - if ( cbrush == brush ) - return; - cbrush = brush; - updateBrush(); -} - -/*! - Sets the painter's brush to black color and the specified \a - style. - - \sa brush(), TQBrush -*/ - -void TQPainter::setBrush( BrushStyle style ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setBrush: Will be reset by begin()" ); -#endif - TQBrush::TQBrushData *d = cbrush.data; // low level access - if ( d->style == style && d->color == TQt::black && !d->pixmap ) - return; - if ( d->count != 1 ) { - cbrush.detach(); - d = cbrush.data; - } - d->style = style; - d->color = TQt::black; - if ( d->pixmap ) { - delete d->pixmap; - d->pixmap = 0; - } - updateBrush(); -} - -/*! - \overload - - Sets the painter's brush to have style \c SolidPattern and the - specified \a color. - - \sa brush(), TQBrush -*/ - -void TQPainter::setBrush( const TQColor &color ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setBrush: Will be reset by begin()" ); -#endif - TQBrush::TQBrushData *d = cbrush.data; // low level access - if ( d->color == color && d->style == SolidPattern && !d->pixmap ) - return; - if ( d->count != 1 ) { - cbrush.detach(); - d = cbrush.data; - } - d->style = SolidPattern; - d->color = color; - if ( d->pixmap ) { - delete d->pixmap; - d->pixmap = 0; - } - updateBrush(); -} - - -/*! - \fn const TQColor &TQPainter::backgroundColor() const - - Returns the current background color. - - \sa setBackgroundColor() TQColor -*/ - -/*! - \fn BGMode TQPainter::backgroundMode() const - - Returns the current background mode. - - \sa setBackgroundMode() BGMode -*/ - -/*! - \fn RasterOp TQPainter::rasterOp() const - - Returns the current \link TQt::RasterOp raster operation \endlink. - - \sa setRasterOp() RasterOp -*/ - -/*! - \fn const TQPoint &TQPainter::brushOrigin() const - - Returns the brush origin currently set. - - \sa setBrushOrigin() -*/ - - -/*! - \fn int TQPainter::tabStops() const - - Returns the tab stop setting. - - \sa setTabStops() -*/ - -/*! - Set the tab stop width to \a ts, i.e. locates tab stops at \a ts, - 2*\a ts, 3*\a ts and so on. - - Tab stops are used when drawing formatted text with \c ExpandTabs - set. This fixed tab stop value is used only if no tab array is set - (which is the default case). - - A value of 0 (the default) implies a tabstop setting of 8 times the width of the - character 'x' in the font currently set on the painter. - - \sa tabStops(), setTabArray(), drawText(), fontMetrics() -*/ - -void TQPainter::setTabStops( int ts ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setTabStops: Will be reset by begin()" ); -#endif - tabstops = ts; - if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice - TQPDevCmdParam param[1]; - param[0].ival = ts; - pdev->cmd( TQPaintDevice::PdcSetTabStops, this, param ); - } -} - -/*! - \fn int *TQPainter::tabArray() const - - Returns the currently set tab stop array. - - \sa setTabArray() -*/ - -/*! - Sets the tab stop array to \a ta. This puts tab stops at \a ta[0], - \a ta[1] and so on. The array is null-terminated. - - If both a tab array and a tab top size is set, the tab array wins. - - \sa tabArray(), setTabStops(), drawText(), fontMetrics() -*/ - -void TQPainter::setTabArray( int *ta ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setTabArray: Will be reset by begin()" ); -#endif - if ( ta != tabarray ) { - tabarraylen = 0; - if ( tabarray ) // Avoid purify complaint - delete [] tabarray; // delete old array - if ( ta ) { // tabarray = copy of 'ta' - while ( ta[tabarraylen] ) - tabarraylen++; - tabarraylen++; // and 0 terminator - tabarray = new int[tabarraylen]; // duplicate ta - memcpy( tabarray, ta, sizeof(int)*tabarraylen ); - } else { - tabarray = 0; - } - } - if ( isActive() && testf(ExtDev) ) { // tell extended tqdevice - TQPDevCmdParam param[2]; - param[0].ival = tabarraylen; - param[1].ivec = tabarray; - pdev->cmd( TQPaintDevice::PdcSetTabArray, this, param ); - } -} - - -/*! - \fn HANDLE TQPainter::handle() const - - Returns the platform-dependent handle used for drawing. Using this - function is not portable. -*/ - - -/***************************************************************************** - TQPainter xform settings - *****************************************************************************/ - -#ifndef TQT_NO_TRANSFORMATIONS - -/*! - Enables view transformations if \a enable is TRUE, or disables - view transformations if \a enable is FALSE. - - \sa hasViewXForm(), setWindow(), setViewport(), setWorldMatrix(), - setWorldXForm(), xForm() -*/ - -void TQPainter::setViewXForm( bool enable ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setViewXForm: Will be reset by begin()" ); -#endif - if ( !isActive() || enable == testf(VxF) ) - return; - setf( VxF, enable ); - if ( testf(ExtDev) ) { - TQPDevCmdParam param[1]; - param[0].ival = enable; - pdev->cmd( TQPaintDevice::PdcSetVXform, this, param ); - } - updateXForm(); -} - -/*! - \fn bool TQPainter::hasViewXForm() const - - Returns TRUE if view transformation is enabled; otherwise returns - FALSE. - - \sa setViewXForm(), xForm() -*/ - -/*! - Returns the window rectangle. - - \sa setWindow(), setViewXForm() -*/ - -TQRect TQPainter::window() const -{ - return TQRect( wx, wy, ww, wh ); -} - -/*! - Sets the window rectangle view transformation for the painter and - enables view transformation. - - The window rectangle is part of the view transformation. The - window specifies the logical coordinate system and is specified by - the \a x, \a y, \a w width and \a h height parameters. Its sister, - the viewport(), specifies the tqdevice coordinate system. - - The default window rectangle is the same as the tqdevice's - rectangle. See the \link coordsys.html Coordinate System Overview - \endlink for an overview of coordinate transformation. - - \sa window(), setViewport(), setViewXForm(), setWorldMatrix(), - setWorldXForm() -*/ - -void TQPainter::setWindow( int x, int y, int w, int h ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setWindow: Will be reset by begin()" ); -#endif - wx = x; - wy = y; - ww = w; - wh = h; - if ( testf(ExtDev) ) { - TQRect r( x, y, w, h ); - TQPDevCmdParam param[1]; - param[0].rect = (TQRect*)&r; - pdev->cmd( TQPaintDevice::PdcSetWindow, this, param ); - } - if ( testf(VxF) ) - updateXForm(); - else - setViewXForm( TRUE ); -} - -/*! - Returns the viewport rectangle. - - \sa setViewport(), setViewXForm() -*/ - -TQRect TQPainter::viewport() const // get viewport -{ - return TQRect( vx, vy, vw, vh ); -} - -/*! - Sets the viewport rectangle view transformation for the painter - and enables view transformation. - - The viewport rectangle is part of the view transformation. The - viewport specifies the tqdevice coordinate system and is specified - by the \a x, \a y, \a w width and \a h height parameters. Its - sister, the window(), specifies the logical coordinate system. - - The default viewport rectangle is the same as the tqdevice's - rectangle. See the \link coordsys.html Coordinate System Overview - \endlink for an overview of coordinate transformation. - - \sa viewport(), setWindow(), setViewXForm(), setWorldMatrix(), - setWorldXForm(), xForm() -*/ - -void TQPainter::setViewport( int x, int y, int w, int h ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setViewport: Will be reset by begin()" ); -#endif - vx = x; - vy = y; - vw = w; - vh = h; - if ( testf(ExtDev) ) { - TQRect r( x, y, w, h ); - TQPDevCmdParam param[1]; - param[0].rect = (TQRect*)&r; - pdev->cmd( TQPaintDevice::PdcSetViewport, this, param ); - } - if ( testf(VxF) ) - updateXForm(); - else - setViewXForm( TRUE ); -} - - -/*! - Enables world transformations if \a enable is TRUE, or disables - world transformations if \a enable is FALSE. The world - transformation matrix is not changed. - - \sa setWorldMatrix(), setWindow(), setViewport(), setViewXForm(), - xForm() -*/ - -void TQPainter::setWorldXForm( bool enable ) -{ -#if defined(TQT_CHECK_STATE) - if ( !isActive() ) - qWarning( "TQPainter::setWorldXForm: Will be reset by begin()" ); -#endif - if ( !isActive() || enable == testf(WxF) ) - return; - setf( WxF, enable ); - if ( testf(ExtDev) && !block_ext ) { - TQPDevCmdParam param[1]; - param[0].ival = enable; - pdev->cmd( TQPaintDevice::PdcSetWXform, this, param ); - } - updateXForm(); -} - -/*! - \fn bool TQPainter::hasWorldXForm() const - - Returns TRUE if world transformation is enabled; otherwise returns - FALSE. - - \sa setWorldXForm() -*/ - -/*! - Returns the world transformation matrix. - - \sa setWorldMatrix() -*/ - -const TQWMatrix &TQPainter::tqworldMatrix() const -{ - return wxmat; -} - -/*! - Sets the world transformation matrix to \a m and enables world - transformation. - - If \a combine is TRUE, then \a m is combined with the current - transformation matrix, otherwise \a m tqreplaces the current - transformation matrix. - - If \a m is the identity matrix and \a combine is FALSE, this - function calls setWorldXForm(FALSE). (The identity matrix is the - matrix where TQWMatrix::m11() and TQWMatrix::m22() are 1.0 and the - rest are 0.0.) - - World transformations are applied after the view transformations - (i.e. \link setWindow() window\endlink and \link setViewport() - viewport\endlink). - - The following functions can transform the coordinate system without using - a TQWMatrix: - \list - \i translate() - \i scale() - \i shear() - \i rotate() - \endlist - - They operate on the painter's tqworldMatrix() and are implemented like this: - - \code - void TQPainter::rotate( double a ) - { - TQWMatrix m; - m.rotate( a ); - setWorldMatrix( m, TRUE ); - } - \endcode - - Note that you should always use \a combine when you are drawing - into a TQPicture. Otherwise it may not be possible to replay the - picture with additional transformations. Using translate(), - scale(), etc., is safe. - - For a brief overview of coordinate transformation, see the \link - coordsys.html Coordinate System Overview. \endlink - - \sa tqworldMatrix() setWorldXForm() setWindow() setViewport() - setViewXForm() xForm() TQWMatrix -*/ - -void TQPainter::setWorldMatrix( const TQWMatrix &m, bool combine ) -{ - if ( !isActive() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::setWorldMatrix: Will be reset by begin()" ); -#endif - return; - } - if ( combine ) - wxmat = m * wxmat; // combines - else - wxmat = m; // set new matrix - bool identity = wxmat.m11() == 1.0F && wxmat.m22() == 1.0F && - wxmat.m12() == 0.0F && wxmat.m21() == 0.0F && - wxmat.dx() == 0.0F && wxmat.dy() == 0.0F; - if ( testf(ExtDev) && !block_ext ) { - TQPDevCmdParam param[2]; - param[0].matrix = &m; - param[1].ival = combine; - pdev->cmd( TQPaintDevice::PdcSetWMatrix, this, param ); - } - if ( identity && pdev->devType() != TQInternal::Picture ) - setWorldXForm( FALSE ); - else if ( !testf(WxF) ) - setWorldXForm( TRUE ); - else - updateXForm(); -} - -/*! \obsolete - - We recommend using save() instead. -*/ - -void TQPainter::saveWorldMatrix() -{ - TQWMatrixStack *stack = (TQWMatrixStack *)wm_stack; - if ( stack == 0 ) { - stack = new TQPtrStack; - TQ_CHECK_PTR( stack ); - stack->setAutoDelete( TRUE ); - wm_stack = stack; - } - - stack->push( new TQWMatrix( wxmat ) ); - -} - -/*! \obsolete - We recommend using restore() instead. -*/ - -void TQPainter::restoreWorldMatrix() -{ - TQWMatrixStack *stack = (TQWMatrixStack *)wm_stack; - if ( stack == 0 || stack->isEmpty() ) { -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::restoreWorldMatrix: Empty stack error" ); -#endif - return; - } - TQWMatrix* m = stack->pop(); - setWorldMatrix( *m ); - delete m; -} - -#endif // TQT_NO_TRANSFORMATIONS - -/*! - Translates the coordinate system by \a (dx, dy). After this call, - \a (dx, dy) is added to points. - - For example, the following code draws the same point twice: - \code - void MyWidget::paintEvent() - { - TQPainter paint( this ); - - paint.drawPoint( 0, 0 ); - - paint.translate( 100.0, 40.0 ); - paint.drawPoint( -100, -40 ); - } - \endcode - - \sa scale(), shear(), rotate(), resetXForm(), setWorldMatrix(), xForm() -*/ - -void TQPainter::translate( double dx, double dy ) -{ -#ifndef TQT_NO_TRANSFORMATIONS - TQWMatrix m; - m.translate( dx, dy ); - setWorldMatrix( m, TRUE ); -#else - xlatex += (int)dx; - xlatey += (int)dy; - setf( VxF, xlatex || xlatey ); -#endif -} - - -#ifndef TQT_NO_TRANSFORMATIONS -/*! - Scales the coordinate system by \a (sx, sy). - - \sa translate(), shear(), rotate(), resetXForm(), setWorldMatrix(), - xForm() -*/ - -void TQPainter::scale( double sx, double sy ) -{ - TQWMatrix m; - m.scale( sx, sy ); - setWorldMatrix( m, TRUE ); -} - -/*! - Shears the coordinate system by \a (sh, sv). - - \sa translate(), scale(), rotate(), resetXForm(), setWorldMatrix(), - xForm() -*/ - -void TQPainter::shear( double sh, double sv ) -{ - TQWMatrix m; - m.shear( sv, sh ); - setWorldMatrix( m, TRUE ); -} - -/*! - Rotates the coordinate system \a a degrees counterclockwise. - - \sa translate(), scale(), shear(), resetXForm(), setWorldMatrix(), - xForm() -*/ - -void TQPainter::rotate( double a ) -{ - TQWMatrix m; - m.rotate( a ); - setWorldMatrix( m, TRUE ); -} - - -/*! - Resets any transformations that were made using translate(), scale(), - shear(), rotate(), setWorldMatrix(), setViewport() and - setWindow(). - - \sa tqworldMatrix(), viewport(), window() -*/ - -void TQPainter::resetXForm() -{ - if ( !isActive() ) - return; - wx = wy = vx = vy = 0; // default view origins - ww = vw = pdev->metric( TQPaintDeviceMetrics::PdmWidth ); - wh = vh = pdev->metric( TQPaintDeviceMetrics::PdmHeight ); - wxmat = TQWMatrix(); - setWorldXForm( FALSE ); - setViewXForm( FALSE ); -} - -/*! - \internal - Updates an internal integer transformation matrix. -*/ - -void TQPainter::updateXForm() -{ - TQWMatrix m; - if ( testf(VxF) ) { - double scaleW = (double)vw/(double)ww; - double scaleH = (double)vh/(double)wh; - m.setMatrix( scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH ); - } - if ( testf(WxF) ) { - if ( testf(VxF) ) - m = wxmat * m; - else - m = wxmat; - } - xmat = m; - - txinv = FALSE; // no inverted matrix - txop = TxNone; - if ( m12()==0.0 && m21()==0.0 && m11() >= 0.0 && m22() >= 0.0 ) { - if ( m11()==1.0 && m22()==1.0 ) { - if ( dx()!=0.0 || dy()!=0.0 ) - txop = TxTranslate; - } else { - txop = TxScale; -#if defined(TQ_WS_WIN) - setf(DirtyFont); -#endif - } - } else { - txop = TxRotShear; -#if defined(TQ_WS_WIN) - setf(DirtyFont); -#endif - } -} - - -/*! - \internal - Updates an internal integer inverse transformation matrix. -*/ - -void TQPainter::updateInvXForm() -{ -#if defined(TQT_CHECK_STATE) - TQ_ASSERT( txinv == FALSE ); -#endif - txinv = TRUE; // creating inverted matrix - bool invertible; - TQWMatrix m; - if ( testf(VxF) ) { - m.translate( vx, vy ); - m.scale( 1.0*vw/ww, 1.0*vh/wh ); - m.translate( -wx, -wy ); - } - if ( testf(WxF) ) { - if ( testf(VxF) ) - m = wxmat * m; - else - m = wxmat; - } - ixmat = m.invert( &invertible ); // invert matrix -} - -#else -void TQPainter::resetXForm() -{ - xlatex = 0; - xlatey = 0; - clearf( VxF ); -} -#endif // TQT_NO_TRANSFORMATIONS - - -extern bool qt_old_transformations; - -/*! - \internal - Maps a point from logical coordinates to tqdevice coordinates. -*/ - -void TQPainter::map( int x, int y, int *rx, int *ry ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( qt_old_transformations ) { - switch ( txop ) { - case TxNone: - *rx = x; *ry = y; - break; - case TxTranslate: - // #### "Why no rounding here?", Warwick asked of Haavard. - *rx = int(x + dx()); - *ry = int(y + dy()); - break; - case TxScale: { - double tx = m11()*x + dx(); - double ty = m22()*y + dy(); - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - } break; - default: { - double tx = m11()*x + m21()*y+dx(); - double ty = m12()*x + m22()*y+dy(); - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - } break; - } - } else { - switch ( txop ) { - case TxNone: - *rx = x; - *ry = y; - break; - case TxTranslate: - *rx = tqRound( x + dx() ); - *ry = tqRound( y + dy() ); - break; - case TxScale: - *rx = tqRound( m11()*x + dx() ); - *ry = tqRound( m22()*y + dy() ); - break; - default: - *rx = tqRound( m11()*x + m21()*y+dx() ); - *ry = tqRound( m12()*x + m22()*y+dy() ); - break; - } - } -#else - *rx = x + xlatex; - *ry = y + xlatey; -#endif -} - -/*! - \internal - Maps a rectangle from logical coordinates to tqdevice coordinates. - This internal function does not handle rotation and/or shear. -*/ - -void TQPainter::map( int x, int y, int w, int h, - int *rx, int *ry, int *rw, int *rh ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( qt_old_transformations ) { - switch ( txop ) { - case TxNone: - *rx = x; *ry = y; - *rw = w; *rh = h; - break; - case TxTranslate: - // #### "Why no rounding here?", Warwick asked of Haavard. - *rx = int(x + dx()); - *ry = int(y + dy()); - *rw = w; *rh = h; - break; - case TxScale: { - double tx1 = m11()*x + dx(); - double ty1 = m22()*y + dy(); - double tx2 = m11()*(x + w - 1) + dx(); - double ty2 = m22()*(y + h - 1) + dy(); - *rx = tqRound( tx1 ); - *ry = tqRound( ty1 ); - *rw = tqRound( tx2 ) - *rx + 1; - *rh = tqRound( ty2 ) - *ry + 1; - } break; - default: -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::map: Internal error" ); -#endif - break; - } - } else { - switch ( txop ) { - case TxNone: - *rx = x; *ry = y; - *rw = w; *rh = h; - break; - case TxTranslate: - *rx = tqRound(x + dx() ); - *ry = tqRound(y + dy() ); - *rw = w; *rh = h; - break; - case TxScale: - *rx = tqRound( m11()*x + dx() ); - *ry = tqRound( m22()*y + dy() ); - *rw = tqRound( m11()*w ); - *rh = tqRound( m22()*h ); - break; - default: -#if defined(TQT_CHECK_STATE) - qWarning( "TQPainter::map: Internal error" ); -#endif - break; - } - } -#else - *rx = x + xlatex; - *ry = y + xlatey; - *rw = w; *rh = h; -#endif -} - -/*! - \internal - Maps a point from tqdevice coordinates to logical coordinates. -*/ - -void TQPainter::mapInv( int x, int y, int *rx, int *ry ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS -#if defined(TQT_CHECK_STATE) - if ( !txinv ) - qWarning( "TQPainter::mapInv: Internal error" ); -#endif - if ( qt_old_transformations ) { - double tx = im11()*x + im21()*y+idx(); - double ty = im12()*x + im22()*y+idy(); - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - } else { - *rx = tqRound( im11()*x + im21()*y + idx() ); - *ry = tqRound( im12()*x + im22()*y + idy() ); - } -#else - *rx = x - xlatex; - *ry = y - xlatey; -#endif -} - -/*! - \internal - Maps a rectangle from tqdevice coordinates to logical coordinates. - Cannot handle rotation and/or shear. -*/ - -void TQPainter::mapInv( int x, int y, int w, int h, - int *rx, int *ry, int *rw, int *rh ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS -#if defined(TQT_CHECK_STATE) - if ( !txinv || txop == TxRotShear ) - qWarning( "TQPainter::mapInv: Internal error" ); -#endif - if ( qt_old_transformations ) { - double tx = im11()*x + idx(); - double ty = im22()*y + idy(); - double tw = im11()*w; - double th = im22()*h; - *rx = tx >= 0 ? int(tx + 0.5) : int(tx - 0.5); - *ry = ty >= 0 ? int(ty + 0.5) : int(ty - 0.5); - *rw = tw >= 0 ? int(tw + 0.5) : int(tw - 0.5); - *rh = th >= 0 ? int(th + 0.5) : int(th - 0.5); - } else { - *rx = tqRound( im11()*x + idx() ); - *ry = tqRound( im22()*y + idy() ); - *rw = tqRound( im11()*w ); - *rh = tqRound( im22()*h ); - } -#else - *rx = x - xlatex; - *ry = y - xlatey; - *rw = w; - *rh = h; -#endif -} - - -/*! - Returns the point \a pv transformed from model coordinates to - tqdevice coordinates. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPoint TQPainter::xForm( const TQPoint &pv ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return pv; - int x=pv.x(), y=pv.y(); - map( x, y, &x, &y ); - return TQPoint( x, y ); -#else - return TQPoint( pv.x()+xlatex, pv.y()+xlatey ); -#endif -} - -/*! - \overload - - Returns the rectangle \a rv transformed from model coordinates to - tqdevice coordinates. - - If world transformation is enabled and rotation or shearing has - been specified, then the bounding rectangle is returned. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQRect TQPainter::xForm( const TQRect &rv ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return rv; - if ( txop == TxRotShear ) { // rotation/shear - return xmat.mapRect( rv ); - } - // Just translation/scale - int x, y, w, h; - rv.rect( &x, &y, &w, &h ); - map( x, y, w, h, &x, &y, &w, &h ); - return TQRect( x, y, w, h ); -#else - return TQRect( rv.x()+xlatex, rv.y()+xlatey, rv.width(), rv.height() ); -#endif -} - -/*! - \overload - - Returns the point array \a av transformed from model coordinates - to tqdevice coordinates. - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xForm( const TQPointArray &av ) const -{ - TQPointArray a = av; -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop != TxNone ) - { - return xmat * av; - } -#else - a.translate( xlatex, xlatey ); -#endif - return a; -} - -/*! - \overload - - Returns the point array \a av transformed from model coordinates - to tqdevice coordinates. The \a index is the first point in the - array and \a npoints denotes the number of points to be - transformed. If \a npoints is negative, all points from \a - av[index] until the last point in the array are transformed. - - The returned point array consists of the number of points that - were transformed. - - Example: - \code - TQPointArray a(10); - TQPointArray b; - b = painter.xForm(a, 2, 4); // b.size() == 4 - b = painter.xForm(a, 2, -1); // b.size() == 8 - \endcode - - \sa xFormDev(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xForm( const TQPointArray &av, int index, - int npoints ) const -{ - int lastPoint = npoints < 0 ? av.size() : index+npoints; - TQPointArray a( lastPoint-index ); - memcpy( a.data(), av.data()+index, (lastPoint-index)*sizeof( TQPoint ) ); -#ifndef TQT_NO_TRANSFORMATIONS - return xmat*a; -#else - a.translate( xlatex, xlatey ); - return a; -#endif -} - -/*! - \overload - - Returns the point \a pd transformed from tqdevice coordinates to - model coordinates. - - \sa xForm(), TQWMatrix::map() -*/ - -TQPoint TQPainter::xFormDev( const TQPoint &pd ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return pd; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } -#endif - int x=pd.x(), y=pd.y(); - mapInv( x, y, &x, &y ); - return TQPoint( x, y ); -} - -/*! - Returns the rectangle \a rd transformed from tqdevice coordinates to - model coordinates. - - If world transformation is enabled and rotation or shearing is - used, then the bounding rectangle is returned. - - \sa xForm(), TQWMatrix::map() -*/ - -TQRect TQPainter::xFormDev( const TQRect &rd ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return rd; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - if ( txop == TxRotShear ) { // rotation/shear - return ixmat.mapRect( rd ); - } -#endif - // Just translation/scale - int x, y, w, h; - rd.rect( &x, &y, &w, &h ); - mapInv( x, y, w, h, &x, &y, &w, &h ); - return TQRect( x, y, w, h ); -} - -/*! - \overload - - Returns the point array \a ad transformed from tqdevice coordinates - to model coordinates. - - \sa xForm(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xFormDev( const TQPointArray &ad ) const -{ -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return ad; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - return ixmat * ad; -#else - // ### - return ad; -#endif -} - -/*! - \overload - - Returns the point array \a ad transformed from tqdevice coordinates - to model coordinates. The \a index is the first point in the array - and \a npoints denotes the number of points to be transformed. If - \a npoints is negative, all points from \a ad[index] until the - last point in the array are transformed. - - The returned point array consists of the number of points that - were transformed. - - Example: - \code - TQPointArray a(10); - TQPointArray b; - b = painter.xFormDev(a, 1, 3); // b.size() == 3 - b = painter.xFormDev(a, 1, -1); // b.size() == 9 - \endcode - - \sa xForm(), TQWMatrix::map() -*/ - -TQPointArray TQPainter::xFormDev( const TQPointArray &ad, int index, - int npoints ) const -{ - int lastPoint = npoints < 0 ? ad.size() : index+npoints; - TQPointArray a( lastPoint-index ); - memcpy( a.data(), ad.data()+index, (lastPoint-index)*sizeof( TQPoint ) ); -#ifndef TQT_NO_TRANSFORMATIONS - if ( txop == TxNone ) - return a; - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - return ixmat * a; -#else - // ### - return a; -#endif -} - - -/*! - Fills the rectangle \a (x, y, w, h) with the \a brush. - - You can specify a TQColor as \a brush, since there is a TQBrush - constructor that takes a TQColor argument and creates a solid - pattern brush. - - \sa drawRect() -*/ - -void TQPainter::fillRect( int x, int y, int w, int h, const TQBrush &brush ) -{ - TQPen oldPen = pen(); // save pen - TQBrush oldBrush = this->brush(); // save brush - setPen( NoPen ); - setBrush( brush ); - drawRect( x, y, w, h ); // draw filled rect - setBrush( oldBrush ); // restore brush - setPen( oldPen ); // restore pen -} - - -/*! - \overload void TQPainter::setBrushOrigin( const TQPoint &p ) - - Sets the brush origin to point \a p. -*/ - -/*! - \overload void TQPainter::setWindow( const TQRect &r ) - - Sets the painter's window to rectangle \a r. -*/ - - -/*! - \overload void TQPainter::setViewport( const TQRect &r ) - - Sets the painter's viewport to rectangle \a r. -*/ - - -/*! - \fn bool TQPainter::hasClipping() const - - Returns TRUE if clipping has been set; otherwise returns FALSE. - - \sa setClipping() -*/ - -/*! - Returns the currently set clip region. Note that the clip region - is given in physical tqdevice coordinates and \e not subject to any - \link coordsys.html coordinate transformation \endlink if \a m is - equal to \c CoordDevice (the default). If \a m equals \c - CoordPainter the returned region is in model coordinates. - - \sa setClipRegion(), setClipRect(), setClipping() TQPainter::CoordinateMode -*/ -TQRegion TQPainter::clipRegion( CoordinateMode m ) const -{ - // ### FIXME in 4.0: - // If the transformation mode is CoordPainter, we should transform the - // clip region with painter transformations. - -#ifndef TQT_NO_TRANSFORMATIONS - TQRegion r; - if ( m == CoordDevice ) { - r = crgn; - } else { - if ( !txinv ) { - TQPainter *that = (TQPainter*)this; // mutable - that->updateInvXForm(); - } - - r = ixmat * crgn; - } - return r; -#else - return crgn; -#endif -} - -/*! - \fn void TQPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m) - - Sets the clip region to the rectangle \a x, \a y, \a w, \a h and - enables clipping. The clip mode is set to \a m. - - If \a m is \c CoordDevice (the default), the coordinates given for - the clip region are taken to be physical tqdevice coordinates and - are \e not subject to any \link coordsys.html coordinate - transformations\endlink. If \a m is \c CoordPainter, the - coordinates given for the clip region are taken to be model - coordinates. - - \sa setClipRegion(), clipRegion(), setClipping() TQPainter::CoordinateMode -*/ - -/*! - \overload void TQPainter::drawPoint( const TQPoint &p ) - - Draws the point \a p. -*/ - - -/*! - \overload void TQPainter::moveTo( const TQPoint &p ) - - Moves to the point \a p. -*/ - -/*! - \overload void TQPainter::lineTo( const TQPoint &p ) - - Draws a line to the point \a p. -*/ - -/*! - \overload void TQPainter::drawLine( const TQPoint &p1, const TQPoint &p2 ) - - Draws a line from point \a p1 to point \a p2. -*/ - -/*! - \overload void TQPainter::drawRect( const TQRect &r ) - - Draws the rectangle \a r. -*/ - -/*! - \overload void TQPainter::drawWinFocusRect( const TQRect &r ) - - Draws rectangle \a r as a window focus rectangle. -*/ - -/*! - \overload void TQPainter::drawWinFocusRect( const TQRect &r, const TQColor &bgColor ) - - Draws rectangle \a r as a window focus rectangle using background - color \a bgColor. -*/ - - -#if !defined(TQ_WS_X11) && !defined(TQ_WS_TQWS) && !defined(TQ_WS_MAC) -// The doc and X implementation of this functions is in qpainter_x11.cpp -void TQPainter::drawWinFocusRect( int, int, int, int, - bool, const TQColor & ) -{ - // do nothing, only called from X11 specific functions -} -#endif - - -/*! - \overload void TQPainter::drawRoundRect( const TQRect &r, int xRnd, int yRnd ) - - Draws a rounded rectangle \a r, rounding to the x position \a xRnd - and the y position \a yRnd on each corner. -*/ - -/*! - \overload void TQPainter::drawEllipse( const TQRect &r ) - - Draws the ellipse that fits inside rectangle \a r. -*/ - -/*! - \overload void TQPainter::drawArc( const TQRect &r, int a, int alen ) - - Draws the arc that fits inside the rectangle \a r with start angle - \a a and arc length \a alen. -*/ - -/*! - \overload void TQPainter::drawPie( const TQRect &r, int a, int alen ) - - Draws a pie segment that fits inside the rectangle \a r with start - angle \a a and arc length \a alen. -*/ - -/*! - \overload void TQPainter::drawChord( const TQRect &r, int a, int alen ) - - Draws a chord that fits inside the rectangle \a r with start angle - \a a and arc length \a alen. -*/ - -/*! - \overload void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm, const TQRect &sr ) - - Draws the rectangle \a sr of pixmap \a pm with its origin at point - \a p. -*/ - -/*! - \overload void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm ) - - Draws the pixmap \a pm with its origin at point \a p. -*/ - -void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm ) -{ - drawPixmap( p.x(), p.y(), pm, 0, 0, pm.width(), pm.height() ); -} - -#if !defined(TQT_NO_IMAGE_SMOOTHSCALE) || !defined(TQT_NO_PIXMAP_TRANSFORMATION) - -/*! - \overload - - Draws the pixmap \a pm into the rectangle \a r. The pixmap is - scaled to fit the rectangle, if image and rectangle size disagree. -*/ -void TQPainter::drawPixmap( const TQRect &r, const TQPixmap &pm ) -{ - int rw = r.width(); - int rh = r.height(); - int iw= pm.width(); - int ih = pm.height(); - if ( rw <= 0 || rh <= 0 || iw <= 0 || ih <= 0 ) - return; - bool scale = ( rw != iw || rh != ih ); - float scaleX = (float)rw/(float)iw; - float scaleY = (float)rh/(float)ih; - bool smooth = ( scaleX < 1.5 || scaleY < 1.5 ); - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - param[0].rect = &r; - param[1].pixmap = ± -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ) || !hdc ) - return; -#elif defined(TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ); - return; -#elif defined(TQ_WS_MAC) - if ( !pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ) || !pdev->handle()) - return; -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawPixmap, this, param ) || !hd ) - return; -#endif - } - - TQPixmap pixmap = pm; - - if ( scale ) { -#ifndef TQT_NO_IMAGE_SMOOTHSCALE -# ifndef TQT_NO_PIXMAP_TRANSFORMATION - if ( smooth ) -# endif - { - TQImage i = pm.convertToImage(); - pixmap = TQPixmap( i.smoothScale( rw, rh ) ); - } -# ifndef TQT_NO_PIXMAP_TRANSFORMATION - else -# endif -#endif -#ifndef TQT_NO_PIXMAP_TRANSFORMATION - { - pixmap = pm.xForm( TQWMatrix( scaleX, 0, 0, scaleY, 0, 0 ) ); - } -#endif - } - drawPixmap( r.x(), r.y(), pixmap ); -} - -#endif - -/*! - \overload void TQPainter::drawImage( const TQPoint &, const TQImage &, const TQRect &sr, int conversionFlags = 0 ); - - Draws the rectangle \a sr from the image at the given point. -*/ - -/* - Draws at point \a p the \sr rect from image \a pm, using \a - conversionFlags if the image needs to be converted to a pixmap. - The default value for \a conversionFlags is 0; see - convertFromImage() for information about what other values do. - - This function may convert \a image to a pixmap and then draw it, if - tqdevice() is a TQPixmap or a TQWidget, or else draw it directly, if - tqdevice() is a TQPrinter or TQPicture. -*/ - -/*! - Draws at (\a x, \a y) the \a sw by \a sh area of pixels from (\a - sx, \a sy) in \a image, using \a conversionFlags if the image - needs to be converted to a pixmap. The default value for \a - conversionFlags is 0; see convertFromImage() for information about - what other values do. - - This function may convert \a image to a pixmap and then draw it, - if tqdevice() is a TQPixmap or a TQWidget, or else draw it directly, - if tqdevice() is a TQPrinter or TQPicture. - - Currently alpha masks of the image are ignored when painting on a TQPrinter. - - \sa drawPixmap() TQPixmap::convertFromImage() -*/ -void TQPainter::drawImage( int x, int y, const TQImage & image, - int sx, int sy, int sw, int sh, - int conversionFlags ) -{ -#ifdef TQ_WS_TQWS - //### Hackish -# ifndef TQT_NO_TRANSFORMATIONS - if ( !image.isNull() && gfx && - (txop==TxNone||txop==TxTranslate) && !testf(ExtDev) ) -# else - if ( !image.isNull() && gfx && !testf(ExtDev) ) -# endif - { - if(sw<0) - sw=image.width(); - if(sh<0) - sh=image.height(); - - TQImage image2 = qt_screen->mapToDevice( image ); - - // This is a bit dubious - if(image2.depth()==1) { - image2.setNumColors( 2 ); - image2.setColor( 0, tqRgb(255,255,255) ); - image2.setColor( 1, tqRgb(0,0,0) ); - } - if ( image2.hasAlphaBuffer() ) - gfx->setAlphaType(TQGfx::InlineAlpha); - else - gfx->setAlphaType(TQGfx::IgnoreAlpha); - gfx->setSource(&image2); - if ( testf(VxF|WxF) ) { - map( x, y, &x, &y ); - } - gfx->blt(x,y,sw,sh,sx,sy); - return; - } -#endif - - if ( !isActive() || image.isNull() ) - return; - - // right/bottom - if ( sw < 0 ) - sw = image.width() - sx; - if ( sh < 0 ) - sh = image.height() - sy; - - // Sanity-check clipping - if ( sx < 0 ) { - x -= sx; - sw += sx; - sx = 0; - } - if ( sw + sx > image.width() ) - sw = image.width() - sx; - if ( sy < 0 ) { - y -= sy; - sh += sy; - sy = 0; - } - if ( sh + sy > image.height() ) - sh = image.height() - sy; - - if ( sw <= 0 || sh <= 0 ) - return; - - bool all = image.rect().intersect(TQRect(sx,sy,sw,sh)) == image.rect(); - TQImage subimage = all ? image : image.copy(sx,sy,sw,sh); - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - TQRect r( x, y, subimage.width(), subimage.height() ); - param[0].rect = &r; - param[1].image = &subimage; -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hdc ) - return; -#elif defined (TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ); - return; -#elif defined(TQ_WS_MAC) - if(!pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !pdev->handle() ) - return; -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hd ) - return; -#endif - } - - TQPixmap pm; - pm.convertFromImage( subimage, conversionFlags ); - drawPixmap( x, y, pm ); -} - -/*! - \overload void TQPainter::drawImage( const TQPoint &p, const TQImage &i, int conversion_flags ) - - Draws the image \a i at point \a p. - - If the image needs to be modified to fit in a lower-resolution - result (e.g. converting from 32-bit to 8-bit), use the \a - conversion_flags to specify how you'd prefer this to happen. - - \sa TQt::ImageConversionFlags -*/ -void TQPainter::drawImage( const TQPoint & p, const TQImage & i, - int conversion_flags ) -{ - drawImage(p, i, i.rect(), conversion_flags); -} - -#if !defined(TQT_NO_IMAGE_TRANSFORMATION) || !defined(TQT_NO_IMAGE_SMOOTHSCALE) - -/*! - \overload - - Draws the image \a i into the rectangle \a r. The image will be - scaled to fit the rectangle if image and rectangle dimensions - differ. -*/ -void TQPainter::drawImage( const TQRect &r, const TQImage &i ) -{ - int rw = r.width(); - int rh = r.height(); - int iw= i.width(); - int ih = i.height(); - if ( rw <= 0 || rh <= 0 || iw <= 0 || ih <= 0 ) - return; - - if ( testf(ExtDev) ) { - TQPDevCmdParam param[2]; - param[0].rect = &r; - param[1].image = &i; -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hdc ) - return; -#elif defined(TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ); - return; -#elif defined(TQ_WS_MAC) - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !pdev->handle() ) - return; -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawImage, this, param ) || !hd ) - return; -#endif - } - - - bool scale = ( rw != iw || rh != ih ); - float scaleX = (float)rw/(float)iw; - float scaleY = (float)rh/(float)ih; - bool smooth = ( scaleX < 1.5 || scaleY < 1.5 ); - - TQImage img = scale - ? ( -#if defined(TQT_NO_IMAGE_TRANSFORMATION) - i.smoothScale( rw, rh ) -#elif defined(TQT_NO_IMAGE_SMOOTHSCALE) - i.scale( rw, rh ) -#else - smooth ? i.smoothScale( rw, rh ) : i.scale( rw, rh ) -#endif - ) - : i; - - drawImage( r.x(), r.y(), img ); -} - -#endif - - -void bitBlt( TQPaintDevice *dst, int dx, int dy, - const TQImage *src, int sx, int sy, int sw, int sh, - int conversion_flags ) -{ - TQPixmap tmp; - if ( sx == 0 && sy == 0 - && (sw<0 || sw==src->width()) && (sh<0 || sh==src->height()) ) - { - tmp.convertFromImage( *src, conversion_flags ); - } else { - tmp.convertFromImage( src->copy( sx, sy, sw, sh, conversion_flags), - conversion_flags ); - } - bitBlt( dst, dx, dy, &tmp ); -} - - -/*! - \overload void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm, const TQPoint &sp ) - - Draws a tiled pixmap, \a pm, inside rectangle \a r with its origin - at point \a sp. -*/ - -/*! - \overload void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm ) - - Draws a tiled pixmap, \a pm, inside rectangle \a r. -*/ - -/*! - \overload void TQPainter::fillRect( const TQRect &r, const TQBrush &brush ) - - Fills the rectangle \a r using brush \a brush. -*/ - -/*! - \fn void TQPainter::eraseRect( int x, int y, int w, int h ) - - Erases the area inside \a x, \a y, \a w, \a h. Equivalent to - \c{fillRect( x, y, w, h, backgroundColor() )}. -*/ - -/*! - \overload void TQPainter::eraseRect( const TQRect &r ) - - Erases the area inside the rectangle \a r. -*/ - -/*! - \fn TQPainter::drawText( int x, int y, const TQString &, int len = -1, TextDirection dir = Auto ) - - \overload - - Draws the given text at position \a x, \a y. If \a len is -1 (the - default) all the text is drawn, otherwise the first \a len - characters are drawn. The text's direction is given by \a dir. - - \sa TQPainter::TextDirection -*/ - -/*! - \fn void TQPainter::drawText( int x, int y, int w, int h, int flags, - const TQString&, int len = -1, TQRect *br=0, - TQTextParag **internal=0 ) - - \overload - - Draws the given text within the rectangle starting at \a x, \a y, - with width \a w and height \a h. If \a len is -1 (the default) all - the text is drawn, otherwise the first \a len characters are - drawn. The text's flags that are given in the \a flags parameter - are \l{TQt::AlignmentFlags} and \l{TQt::TextFlags} OR'd together. \a - br (if not null) is set to the actual bounding rectangle of the - output. The \a internal parameter is for internal use only. -*/ - -/*! - \fn void TQPainter::drawText( const TQPoint &, const TQString &, int len = -1, TextDirection dir = Auto ); - - \overload - - Draws the text at the given point. - - \sa TQPainter::TextDirection -*/ - -/* - Draws the text in \a s at point \a p. If \a len is -1 the entire - string is drawn, otherwise just the first \a len characters. The - text's direction is specified by \a dir. -*/ - - -/*! - \fn void TQPainter::drawText( int x, int y, const TQString &, int pos, int len, TextDirection dir = Auto ); - - \overload - - Draws the text from position \a pos, at point \a (x, y). If \a len is - -1 the entire string is drawn, otherwise just the first \a len - characters. The text's direction is specified by \a dir. -*/ - -/*! - \fn void TQPainter::drawText( const TQPoint &p, const TQString &, int pos, int len, TextDirection dir = Auto ); - - Draws the text from position \a pos, at point \a p. If \a len is - -1 the entire string is drawn, otherwise just the first \a len - characters. The text's direction is specified by \a dir. - - Note that the meaning of \e y is not the same for the two - drawText() varieties. For overloads that take a simple \e x, \e y - pair (or a point), the \e y value is the text's baseline; for - overloads that take a rectangle, \e rect.y() is the top of the - rectangle and the text is aligned within that rectangle in - accordance with the tqalignment flags. - - \sa TQPainter::TextDirection -*/ - -/*! - \fn void TQPainter::tqdrawTextItem(const TQPoint &, const TQTextItem &, int) - \internal -*/ - -static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - if ( *w < 0 ) { - *w = -*w + 2; - *x -= *w - 1; - } - if ( *h < 0 ) { - *h = -*h + 2; - *y -= *h - 1; - } -} -void TQPainter::fix_neg_rect( int *x, int *y, int *w, int *h ) -{ - ::fix_neg_rect(x,y,w,h); -} - -// -// The drawText function takes two special parameters; 'internal' and 'brect'. -// -// The 'internal' parameter tqcontains a pointer to an array of encoded -// information that keeps internal tqgeometry data. -// If the drawText function is called repeatedly to display the same text, -// it makes sense to calculate text width and linebreaks the first time, -// and use these parameters later to print the text because we save a lot of -// CPU time. -// The 'internal' parameter will not be used if it is a null pointer. -// The 'internal' parameter will be generated if it is not null, but points -// to a null pointer, i.e. internal != 0 && *internal == 0. -// The 'internal' parameter will be used if it tqcontains a non-null pointer. -// -// If the 'brect parameter is a non-null pointer, then the bounding rectangle -// of the text will be returned in 'brect'. -// - -/*! - \overload - - Draws at most \a len characters from \a str in the rectangle \a r. - - This function draws formatted text. The \a tf text format is - really of type \l TQt::AlignmentFlags and \l TQt::TextFlags OR'd - together. - - Horizontal tqalignment defaults to AlignAuto and vertical tqalignment - defaults to AlignTop. - - \a brect (if not null) is set to the actual bounding rectangle of - the output. \a internal is, yes, internal. - - \sa boundingRect() -*/ - -void TQPainter::drawText( const TQRect &r, int tf, - const TQString& str, int len, TQRect *brect, - TQTextParag **internal ) -{ - if ( !isActive() ) - return; - if ( len < 0 ) - len = str.length(); - if ( len == 0 ) // empty string - return; - - if ( testf(DirtyFont|ExtDev) ) { - if ( testf(DirtyFont) ) - updateFont(); - if ( testf(ExtDev) && (tf & DontPrint) == 0 ) { - TQPDevCmdParam param[3]; - TQString newstr = str; - newstr.truncate( len ); - param[0].rect = &r; - param[1].ival = tf; - param[2].str = &newstr; - if ( pdev->devType() != TQInternal::Printer ) { -#if defined(TQ_WS_WIN) - if ( !pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, - this, param) || - !hdc ) - return; // TQPrinter wants PdcDrawText2 -#elif defined(TQ_WS_TQWS) - pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, this, param); - return; -#elif defined(TQ_WS_MAC) - if ( !pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, this, param) || - !pdev->handle()) - return; // TQPrinter wants PdcDrawText2 -#else - if ( !pdev->cmd( TQPaintDevice::PdcDrawText2Formatted, - this, param) || - !hd ) - return; // TQPrinter wants PdcDrawText2 -#endif - } - } - } - - qt_format_text(font(), r, tf, str, len, brect, - tabstops, tabarray, tabarraylen, internal, this); -} - -//#define TQT_FORMAT_TEXT_DEBUG - -#define TQChar_linesep TQChar(0x2028U) - -void qt_format_text( const TQFont& font, const TQRect &_r, - int tf, const TQString& str, int len, TQRect *brect, - int tabstops, int* tabarray, int tabarraylen, - TQTextParag **, TQPainter* painter ) -{ - // we need to copy r here to protect against the case (&r == brect). - TQRect r( _r ); - - bool dontclip = (tf & TQt::DontClip) == TQt::DontClip; - bool wordbreak = (tf & TQt::WordBreak) == TQt::WordBreak; - bool singleline = (tf & TQt::SingleLine) == TQt::SingleLine; - bool showprefix = (tf & TQt::ShowPrefix) == TQt::ShowPrefix; - bool noaccel = ( tf & TQt::NoAccel ) == TQt::NoAccel; - - bool isRightToLeft = str.isRightToLeft(); - if ( ( tf & TQt::AlignHorizontal_Mask ) == TQt::AlignAuto ) - tf |= isRightToLeft ? TQt::AlignRight : TQt::AlignLeft; - - bool expandtabs = ( (tf & TQt::ExpandTabs) && - ( ( (tf & TQt::AlignLeft) && !isRightToLeft ) || - ( (tf & TQt::AlignRight) && isRightToLeft ) ) ); - - if ( !painter ) - tf |= TQt::DontPrint; - - int maxUnderlines = 0; - int numUnderlines = 0; - int underlinePositionStack[32]; - int *underlinePositions = underlinePositionStack; - - TQFont fnt(painter ? (painter->pfont ? *painter->pfont : painter->cfont) : font); - TQFontMetrics fm( fnt ); - - TQString text = str; - // str.setLength() always does a deep copy, so the tqreplacement - // code below is safe. - text.setLength( len ); - // compatible behaviour to the old implementation. Replace - // tabs by spaces - TQChar *chr = (TQChar*)text.tqunicode(); - const TQChar *end = chr + len; - bool haveLineSep = FALSE; - while ( chr != end ) { - if ( *chr == '\r' || ( singleline && *chr == '\n' ) ) { - *chr = ' '; - } else if ( *chr == '\n' ) { - *chr = TQChar_linesep; - haveLineSep = TRUE; - } else if ( *chr == '&' ) { - ++maxUnderlines; - } - ++chr; - } - if ( !expandtabs ) { - chr = (TQChar*)text.tqunicode(); - while ( chr != end ) { - if ( *chr == '\t' ) - *chr = ' '; - ++chr; - } - } else if (!tabarraylen && !tabstops) { - tabstops = fm.width('x')*8; - } - - if ( noaccel || showprefix ) { - if ( maxUnderlines > 32 ) - underlinePositions = new int[maxUnderlines]; - TQChar *cout = (TQChar*)text.tqunicode(); - TQChar *cin = cout; - int l = len; - while ( l ) { - if ( *cin == '&' ) { - ++cin; - --l; - if ( !l ) - break; - if ( *cin != '&' ) - underlinePositions[numUnderlines++] = cout - text.tqunicode(); - } - *cout = *cin; - ++cout; - ++cin; - --l; - } - uint newlen = cout - text.tqunicode(); - if ( newlen != text.length()) - text.setLength( newlen ); - } - - // no need to do extra work for underlines if we don't paint - if ( tf & TQt::DontPrint ) - numUnderlines = 0; - - int height = 0; - int left = r.width(); - int right = 0; - - TQTextLayout textLayout( text, fnt ); - int rb = TQMAX( 0, -fm.minRightBearing() ); - int lb = TQMAX( 0, -fm.minLeftBearing() ); - - if ( text.isEmpty() ) { - height = fm.height(); - left = right = 0; - tf |= TQPainter::DontPrint; - } else { - textLayout.beginLayout((haveLineSep || expandtabs || wordbreak) ? - TQTextLayout::MultiLine : - (tf & TQt::DontPrint) ? TQTextLayout::NoBidi : TQTextLayout::SingleLine ); - - // break underline chars into items of their own - for( int i = 0; i < numUnderlines; i++ ) { - textLayout.setBoundary( underlinePositions[i] ); - textLayout.setBoundary( underlinePositions[i]+1 ); - } - - int lineWidth = wordbreak ? TQMAX(0, r.width()-rb-lb) : INT_MAX; - if(!wordbreak) - tf |= TQt::IncludeTrailingSpaces; - - int leading = fm.leading(); - int asc = fm.ascent(); - int desc = fm.descent(); - height = -leading; - - //qDebug("\n\nbeginLayout: lw = %d, rectwidth=%d", lineWidth , r.width()); - while ( !textLayout.atEnd() ) { - height += leading; - textLayout.beginLine( lineWidth == INT_MAX ? lineWidth : lineWidth ); - //qDebug("-----beginLine( %d )-----", lineWidth ); - bool linesep = FALSE; - while ( 1 ) { - TQTextItem ti = textLayout.currentItem(); - //qDebug("item: from=%d, ch=%x", ti.from(), text.tqunicode()[ti.from()].tqunicode() ); - if ( expandtabs && ti.isTab() ) { - int tw = 0; - int x = textLayout.widthUsed(); - if ( tabarraylen ) { -// qDebug("tabarraylen=%d", tabarraylen ); - int tab = 0; - while ( tab < tabarraylen ) { - if ( tabarray[tab] > x ) { - tw = tabarray[tab] - x; - break; - } - ++tab; - } - } else { - tw = tabstops - (x % tabstops); - } - //qDebug("tw = %d", tw ); - if ( tw ) - ti.setWidth( tw ); - } - if ( ti.isObject() && text.tqunicode()[ti.from()] == TQChar_linesep ) - linesep = TRUE; - - if ( linesep || textLayout.addCurrentItem() != TQTextLayout::Ok || textLayout.atEnd() ) - break; - } - - int ascent = asc, descent = desc, lineLeft, lineRight; - textLayout.setLineWidth( r.width()-rb-lb ); - textLayout.endLine( 0, height, tf, &ascent, &descent, - &lineLeft, &lineRight ); - //qDebug("finalizing line: lw=%d ascent = %d, descent=%d lineleft=%d lineright=%d", lineWidth, ascent, descent,lineLeft, lineRight ); - left = TQMIN( left, lineLeft ); - right = TQMAX( right, lineRight ); - height += ascent + descent + 1; - if ( linesep ) - textLayout.nextItem(); - } - } - - int yoff = 0; - if ( tf & TQt::AlignBottom ) - yoff = r.height() - height; - else if ( tf & TQt::AlignVCenter ) - yoff = (r.height() - height)/2; - - if ( brect ) { - *brect = TQRect( r.x() + left, r.y() + yoff, right-left + lb+rb, height ); - //qDebug("br = %d %d %d/%d, left=%d, right=%d", brect->x(), brect->y(), brect->width(), brect->height(), left, right); - } - - if (!(tf & TQPainter::DontPrint)) { - bool restoreClipping = FALSE; - bool painterHasClip = FALSE; - TQRegion painterClipRegion; - if ( !dontclip ) { -#ifndef TQT_NO_TRANSFORMATIONS - TQRegion reg = painter->xmat * r; -#else - TQRegion reg = r; - reg.translate( painter->xlatex, painter->xlatey ); -#endif - if ( painter->hasClipping() ) - reg &= painter->clipRegion(); - - painterHasClip = painter->hasClipping(); - painterClipRegion = painter->clipRegion(); - restoreClipping = TRUE; - painter->setClipRegion( reg ); - } else { - if ( painter->hasClipping() ){ - painterHasClip = painter->hasClipping(); - painterClipRegion = painter->clipRegion(); - restoreClipping = TRUE; - painter->setClipping( FALSE ); - } - } - - int cUlChar = 0; - int _tf = 0; - if (fnt.underline()) _tf |= TQt::Underline; - if (fnt.overline()) _tf |= TQt::Overline; - if (fnt.strikeOut()) _tf |= TQt::StrikeOut; - - //qDebug("have %d items",textLayout.numItems()); - for ( int i = 0; i < textLayout.numItems(); i++ ) { - TQTextItem ti = textLayout.itemAt( i ); - //qDebug("Item %d: from=%d, length=%d, space=%d x=%d", i, ti.from(), ti.length(), ti.isSpace(), ti.x() ); - if ( ti.isTab() || ti.isObject() ) - continue; - int textFlags = _tf; - if ( !noaccel && numUnderlines > cUlChar && ti.from() == underlinePositions[cUlChar] ) { - textFlags |= TQt::Underline; - cUlChar++; - } -#if defined(TQ_WS_X11) || defined(TQ_WS_TQWS) - if ( painter->bg_mode == TQt::OpaqueMode ) { - int h = ti.ascent() + ti.descent() + 1; - if (ti.y() + h < height) - // don't add leading to last line - h += fm.leading(); - qt_draw_background( painter, r.x()+lb + ti.x(), r.y() + yoff + ti.y() - ti.ascent(), - ti.width(), h); - } -#endif - painter->tqdrawTextItem( r.x()+lb, r.y() + yoff, ti, textFlags ); - } - - if ( restoreClipping ) { - painter->setClipRegion( painterClipRegion ); - painter->setClipping( painterHasClip ); - } - } - - if ( underlinePositions != underlinePositionStack ) - delete [] underlinePositions; -} - -/*! - \overload - - Returns the bounding rectangle of the aligned text that would be - printed with the corresponding drawText() function using the first - \a len characters from \a str if \a len is > -1, or the whole of - \a str if \a len is -1. The drawing, and hence the bounding - rectangle, is constrained to the rectangle \a r, or to the - rectangle required to draw the text, whichever is the larger. - - The \a internal parameter should not be used. - - \sa drawText(), fontMetrics(), TQFontMetrics::boundingRect(), TQt::TextFlags -*/ - -TQRect TQPainter::boundingRect( const TQRect &r, int flags, - const TQString& str, int len, TQTextParag **internal ) -{ - TQRect brect; - if ( str.isEmpty() ) - brect.setRect( r.x(),r.y(), 0,0 ); - else - drawText( r, flags | DontPrint, str, len, &brect, internal ); - return brect; -} - -/*! - \fn TQRect TQPainter::boundingRect( int x, int y, int w, int h, int flags, const TQString&, int len = -1, TQTextParag **intern=0 ); - - Returns the bounding rectangle of the aligned text that would be - printed with the corresponding drawText() function using the first - \a len characters of the string if \a len is > -1, or the whole of - the string if \a len is -1. The drawing, and hence the bounding - rectangle, is constrained to the rectangle that begins at point \a - (x, y) with width \a w and hight \a h, or to the - rectangle required to draw the text, whichever is the larger. - - The \a flags argument is - the bitwise OR of the following flags: - \table - \header \i Flag \i Meaning - \row \i \c AlignAuto \i aligns according to the language, usually left. - \row \i \c AlignLeft \i aligns to the left border. - \row \i \c AlignRight \i aligns to the right border. - \row \i \c AlignHCenter \i aligns horizontally centered. - \row \i \c AlignTop \i aligns to the top border. - \row \i \c AlignBottom \i aligns to the bottom border. - \row \i \c AlignVCenter \i aligns vertically centered. - \row \i \c AlignCenter \i (== \c AlignHCenter | \c AlignVCenter). - \row \i \c SingleLine \i ignores newline characters in the text. - \row \i \c ExpandTabs \i expands tabs. - \row \i \c ShowPrefix \i interprets "&x" as "x". - \row \i \c WordBreak \i breaks the text to fit the rectangle. - \endtable - - Horizontal tqalignment defaults to \c AlignLeft and vertical - tqalignment defaults to \c AlignTop. - - If several of the horizontal or several of the vertical tqalignment flags - are set, the resulting tqalignment is undefined. - - The \a intern parameter should not be used. - - \sa TQt::TextFlags -*/ - - - -/***************************************************************************** - TQPen member functions - *****************************************************************************/ - -/*! - \class TQPen tqpen.h - \brief The TQPen class defines how a TQPainter should draw lines and outlines - of tqshapes. - - \ingroup graphics - \ingroup images - \ingroup shared - \mainclass - - A pen has a style, width, color, cap style and join style. - - The pen style defines the line type. The default pen style is \c - TQt::SolidLine. Setting the style to \c NoPen tells the painter to - not draw lines or outlines. - - When drawing 1 pixel wide diagonal lines you can either use a very - fast algorithm (specified by a line width of 0, which is the - default), or a slower but more accurate algorithm (specified by a - line width of 1). For horizontal and vertical lines a line width - of 0 is the same as a line width of 1. The cap and join style have - no effect on 0-width lines. - - The pen color defines the color of lines and text. The default - line color is black. The TQColor documentation lists predefined - colors. - - The cap style defines how the end points of lines are drawn. The - join style defines how the joins between two lines are drawn when - multiple connected lines are drawn (TQPainter::drawPolyline() - etc.). The cap and join styles only apply to wide lines, i.e. when - the width is 1 or greater. - - Use the TQBrush class to specify fill styles. - - Example: - \code - TQPainter painter; - TQPen pen( red, 2 ); // red solid line, 2 pixels wide - painter.begin( &anyPaintDevice ); // paint something - painter.setPen( pen ); // set the red, wide pen - painter.drawRect( 40,30, 200,100 ); // draw a rectangle - painter.setPen( blue ); // set blue pen, 0 pixel width - painter.drawLine( 40,30, 240,130 ); // draw a diagonal in rectangle - painter.end(); // painting done - \endcode - - See the \l TQt::PenStyle enum type for a complete list of pen - styles. - - With reference to the end points of lines, for wide (non-0-width) - pens it depends on the cap style whether the end point is drawn or - not. TQPainter will try to make sure that the end point is drawn - for 0-width pens, but this cannot be absolutely guaranteed because - the underlying drawing engine is free to use any (typically - accelerated) algorithm for drawing 0-width lines. On all tested - systems, however, the end point of at least all non-diagonal lines - are drawn. - - A pen's color(), width(), style(), capStyle() and joinStyle() can - be set in the constructor or later with setColor(), setWidth(), - setStyle(), setCapStyle() and setJoinStyle(). Pens may also be - compared and streamed. - - \img pen-styles.png Pen styles - - \sa TQPainter, TQPainter::setPen() -*/ - - -/*! - \internal - Initializes the pen. -*/ - -void TQPen::init( const TQColor &color, uint width, uint linestyle ) -{ - data = new TQPenData; - TQ_CHECK_PTR( data ); - data->style = (PenStyle)(linestyle & MPenStyle); - data->width = width; - data->color = color; - data->linest = linestyle; -} - -/*! - Constructs a default black solid line pen with 0 width, which - renders lines 1 pixel wide (fast diagonals). -*/ - -TQPen::TQPen() -{ - init( TQt::black, 0, SolidLine ); // default pen -} - -/*! - Constructs a black pen with 0 width (fast diagonals) and style \a - style. - - \sa setStyle() -*/ - -TQPen::TQPen( PenStyle style ) -{ - init( TQt::black, 0, style ); -} - -/*! - Constructs a pen with the specified \a color, \a width and \a - style. - - \sa setWidth(), setStyle(), setColor() -*/ - -TQPen::TQPen( const TQColor &color, uint width, PenStyle style ) -{ - init( color, width, style ); -} - -/*! - Constructs a pen with the specified color \a cl and width \a w. - The pen style is set to \a s, the pen cap style to \a c and the - pen join style to \a j. - - A line width of 0 will produce a 1 pixel wide line using a fast - algorithm for diagonals. A line width of 1 will also produce a 1 - pixel wide line, but uses a slower more accurate algorithm for - diagonals. For horizontal and vertical lines a line width of 0 is - the same as a line width of 1. The cap and join style have no - effect on 0-width lines. - - \sa setWidth(), setStyle(), setColor() -*/ - -TQPen::TQPen( const TQColor &cl, uint w, PenStyle s, PenCapStyle c, - PenJoinStyle j ) -{ - init( cl, w, s | c | j ); -} - -/*! - Constructs a pen that is a copy of \a p. -*/ - -TQPen::TQPen( const TQPen &p ) -{ - data = p.data; - data->ref(); -} - -/*! - Destroys the pen. -*/ - -TQPen::~TQPen() -{ - if ( data->deref() ) - delete data; -} - - -/*! - Detaches from shared pen data to make sure that this pen is the - only one referring the data. - - If multiple pens share common data, this pen dereferences the data - and gets a copy of the data. Nothing is done if there is just a - single reference. -*/ - -void TQPen::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - - -/*! - Assigns \a p to this pen and returns a reference to this pen. -*/ - -TQPen &TQPen::operator=( const TQPen &p ) -{ - p.data->ref(); - if ( data->deref() ) - delete data; - data = p.data; - return *this; -} - - -/*! - Returns a \link shclass.html deep copy\endlink of the pen. -*/ - -TQPen TQPen::copy() const -{ - TQPen p( data->color, data->width, data->style, capStyle(), joinStyle() ); - return p; -} - - -/*! - \fn PenStyle TQPen::style() const - - Returns the pen style. - - \sa setStyle() -*/ - -/*! - Sets the pen style to \a s. - - See the \l TQt::PenStyle documentation for a list of all the - styles. - - \warning On Mac OS X the style setting (other than \c NoPen and \c - SolidLine) have no effect as they are not implemented by the - underlying system. - - \warning On Windows 95/98, the style setting (other than \c NoPen - and \c SolidLine) has no effect for lines with width greater than - 1. - - \sa style() -*/ - -void TQPen::setStyle( PenStyle s ) -{ - if ( data->style == s ) - return; - detach(); - data->style = s; - data->linest = (data->linest & ~MPenStyle) | s; -} - - -/*! - \fn uint TQPen::width() const - - Returns the pen width. - - \sa setWidth() -*/ - -/*! - Sets the pen width to \a w. - - A line width of 0 will produce a 1 pixel wide line using a fast - algorithm for diagonals. A line width of 1 will also produce a 1 - pixel wide line, but uses a slower more accurate algorithm for - diagonals. For horizontal and vertical lines a line width of 0 is - the same as a line width of 1. The cap and join style have no - effect on 0-width lines. - - \sa width() -*/ - -void TQPen::setWidth( uint w ) -{ - if ( data->width == w ) - return; - detach(); - data->width = w; -} - - -/*! - Returns the pen's cap style. - - \sa setCapStyle() -*/ -TQt::PenCapStyle TQPen::capStyle() const -{ - return (PenCapStyle)(data->linest & MPenCapStyle); -} - -/*! - Sets the pen's cap style to \a c. - - The default value is \c FlatCap. The cap style has no effect on - 0-width pens. - - \img pen-cap-styles.png Pen Cap Styles - - \warning On Windows 95/98 and Macintosh, the cap style setting has - no effect. Wide lines are rendered as if the cap style was \c - SquareCap. - - \sa capStyle() -*/ - -void TQPen::setCapStyle( PenCapStyle c ) -{ - if ( (data->linest & MPenCapStyle) == c ) - return; - detach(); - data->linest = (data->linest & ~MPenCapStyle) | c; -} - -/*! - Returns the pen's join style. - - \sa setJoinStyle() -*/ -TQt::PenJoinStyle TQPen::joinStyle() const -{ - return (PenJoinStyle)(data->linest & MPenJoinStyle); -} - -/*! - Sets the pen's join style to \a j. - - The default value is \c MiterJoin. The join style has no effect on - 0-width pens. - - \img pen-join-styles.png Pen Join Styles - - \warning On Windows 95/98 and Macintosh, the join style setting - has no effect. Wide lines are rendered as if the join style was \c - BevelJoin. - - \sa joinStyle() -*/ - -void TQPen::setJoinStyle( PenJoinStyle j ) -{ - if ( (data->linest & MPenJoinStyle) == j ) - return; - detach(); - data->linest = (data->linest & ~MPenJoinStyle) | j; -} - -/*! - \fn const TQColor &TQPen::color() const - - Returns the pen color. - - \sa setColor() -*/ - -/*! - Sets the pen color to \a c. - - \sa color() -*/ - -void TQPen::setColor( const TQColor &c ) -{ - detach(); - data->color = c; -} - - -/*! - \fn bool TQPen::operator!=( const TQPen &p ) const - - Returns TRUE if the pen is different from \a p; otherwise returns - FALSE. - - Two pens are different if they have different styles, widths or - colors. - - \sa operator==() -*/ - -/*! - Returns TRUE if the pen is equal to \a p; otherwise returns FALSE. - - Two pens are equal if they have equal styles, widths and colors. - - \sa operator!=() -*/ - -bool TQPen::operator==( const TQPen &p ) const -{ - return (p.data == data) || (p.data->linest == data->linest && - p.data->width == data->width && p.data->color == data->color); -} - - -/***************************************************************************** - TQPen stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQPen - - Writes the pen \a p to the stream \a s and returns a reference to - the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQPen &p ) -{ - // ### width() should not be restricted to 8-bit values - if ( s.version() < 3 ) - return s << (TQ_UINT8)p.style() << (TQ_UINT8)p.width() << p.color(); - else - return s << (TQ_UINT8)( p.style() | p.capStyle() | p.joinStyle() ) - << (TQ_UINT8)p.width() << p.color(); -} - -/*! - \relates TQPen - - Reads a pen from the stream \a s into \a p and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQPen &p ) -{ - TQ_UINT8 style, width; - TQColor color; - s >> style; - s >> width; - s >> color; - p = TQPen( color, (uint)width, (TQt::PenStyle)style ); // owl - return s; -} -#endif //TQT_NO_DATASTREAM - -/***************************************************************************** - TQBrush member functions - *****************************************************************************/ - -/*! - \class TQBrush tqbrush.h - - \brief The TQBrush class defines the fill pattern of tqshapes drawn by a TQPainter. - - \ingroup graphics - \ingroup images - \ingroup shared - - A brush has a style and a color. One of the brush styles is a - custom pattern, which is defined by a TQPixmap. - - The brush style defines the fill pattern. The default brush style - is \c NoBrush (depending on how you construct a brush). This style - tells the painter to not fill tqshapes. The standard style for - filling is \c SolidPattern. - - The brush color defines the color of the fill pattern. The TQColor - documentation lists the predefined colors. - - Use the TQPen class for specifying line/outline styles. - - Example: - \code - TQPainter painter; - TQBrush brush( yellow ); // yellow solid pattern - painter.begin( &anyPaintDevice ); // paint something - painter.setBrush( brush ); // set the yellow brush - painter.setPen( NoPen ); // do not draw outline - painter.drawRect( 40,30, 200,100 ); // draw filled rectangle - painter.setBrush( NoBrush ); // do not fill - painter.setPen( black ); // set black pen, 0 pixel width - painter.drawRect( 10,10, 30,20 ); // draw rectangle outline - painter.end(); // painting done - \endcode - - See the setStyle() function for a complete list of brush styles. - - \img brush-styles.png Brush Styles - - \sa TQPainter, TQPainter::setBrush(), TQPainter::setBrushOrigin() -*/ - -inline TQPixmap *TQBrush::pixmap() const { - if (style() != Qt::TexturePattern) - return 0; - QTexturedBrushData *data = static_cast(d.data()); - QPixmap &pixmap = data->pixmap(); - return pixmap.isNull() ? 0 : &pixmap; -} - -/*! - \internal - Initializes the brush. -*/ - -void TQBrush::init( const TQColor &color, BrushStyle style ) -{ - data = new TQBrushData; - TQ_CHECK_PTR( data ); - data->style = style; - data->color = color; - data->pixmap = 0; -} - -/*! - Constructs a default black brush with the style \c NoBrush (will - not fill tqshapes). -*/ - -TQBrush::TQBrush() -{ - static TQBrushData* defBrushData = 0; - if ( !defBrushData ) { - static TQSharedCleanupHandler defBrushCleanup; - defBrushData = new TQBrushData; - defBrushData->style = NoBrush; - defBrushData->color = TQt::black; - defBrushData->pixmap = 0; - defBrushCleanup.set( &defBrushData ); - } - data = defBrushData; - data->ref(); -} - -/*! - Constructs a black brush with the style \a style. - - \sa setStyle() -*/ - -TQBrush::TQBrush( BrushStyle style ) -{ - init( TQt::black, style ); -} - -/*! - Constructs a brush with the color \a color and the style \a style. - - \sa setColor(), setStyle() -*/ - -TQBrush::TQBrush( const TQColor &color, BrushStyle style ) -{ - init( color, style ); -} - -/*! - Constructs a brush with the color \a color and a custom pattern - stored in \a pixmap. - - The color will only have an effect for monochrome pixmaps, i.e. - for TQPixmap::depth() == 1. - - Pixmap brushes are currently not supported when printing on X11. - - \sa setColor(), setPixmap() -*/ - -TQBrush::TQBrush( const TQColor &color, const TQPixmap &pixmap ) -{ - init( color, CustomPattern ); - setPixmap( pixmap ); -} - -/*! - Constructs a brush that is a \link shclass.html shallow - copy\endlink of \a b. -*/ - -TQBrush::TQBrush( const TQBrush &b ) -{ - data = b.data; - data->ref(); -} - -/*! - Destroys the brush. -*/ - -TQBrush::~TQBrush() -{ - if ( data->deref() ) { - delete data->pixmap; - delete data; - } -} - - -/*! - Detaches from shared brush data to make sure that this brush is - the only one referring the data. - - If multiple brushes share common data, this brush dereferences the - data and gets a copy of the data. Nothing is done if there is just - a single reference. -*/ - -void TQBrush::detach() -{ - if ( data->count != 1 ) - *this = copy(); -} - - -/*! - Assigns \a b to this brush and returns a reference to this brush. -*/ - -TQBrush &TQBrush::operator=( const TQBrush &b ) -{ - b.data->ref(); // beware of b = b - if ( data->deref() ) { - delete data->pixmap; - delete data; - } - data = b.data; - return *this; -} - - -/*! - Returns a \link shclass.html deep copy\endlink of the brush. -*/ - -TQBrush TQBrush::copy() const -{ - if ( data->style == CustomPattern ) { // brush has pixmap - TQBrush b( data->color, *data->pixmap ); - return b; - } else { // brush has std pattern - TQBrush b( data->color, data->style ); - return b; - } -} - - -/*! - \fn BrushStyle TQBrush::style() const - - Returns the brush style. - - \sa setStyle() -*/ - -/*! - Sets the brush style to \a s. - - The brush styles are: - \table - \header \i Pattern \i Meaning - \row \i NoBrush \i will not fill tqshapes (default). - \row \i SolidPattern \i solid (100%) fill pattern. - \row \i Dense1Pattern \i11 94% fill pattern. - \row \i Dense2Pattern \i11 88% fill pattern. - \row \i Dense3Pattern \i11 63% fill pattern. - \row \i Dense4Pattern \i11 50% fill pattern. - \row \i Dense5Pattern \i11 37% fill pattern. - \row \i Dense6Pattern \i11 12% fill pattern. - \row \i Dense7Pattern \i11 6% fill pattern. - \row \i HorPattern \i horizontal lines pattern. - \row \i VerPattern \i vertical lines pattern. - \row \i CrossPattern \i crossing lines pattern. - \row \i BDiagPattern \i diagonal lines (directed /) pattern. - \row \i FDiagPattern \i diagonal lines (directed \) pattern. - \row \i DiagCrossPattern \i diagonal crossing lines pattern. - \row \i CustomPattern \i set when a pixmap pattern is being used. - \endtable - - On Windows, dense and custom patterns cannot be transtqparent. - - See the \link #details Detailed Description\endlink for a picture - of all the styles. - - \sa style() -*/ - -void TQBrush::setStyle( BrushStyle s ) // set brush style -{ - if ( data->style == s ) - return; -#if defined(TQT_CHECK_RANGE) - if ( s == CustomPattern ) - qWarning( "TQBrush::setStyle: CustomPattern is for internal use" ); -#endif - detach(); - data->style = s; -} - - -/*! - \fn const TQColor &TQBrush::color() const - - Returns the brush color. - - \sa setColor() -*/ - -/*! - Sets the brush color to \a c. - - \sa color(), setStyle() -*/ - -void TQBrush::setColor( const TQColor &c ) -{ - detach(); - data->color = c; -} - - -/*! - \fn TQPixmap *TQBrush::pixmap() const - - Returns a pointer to the custom brush pattern, or 0 if no custom - brush pattern has been set. - - \sa setPixmap() -*/ - -/*! - Sets the brush pixmap to \a pixmap. The style is set to \c - CustomPattern. - - The current brush color will only have an effect for monochrome - pixmaps, i.e. for TQPixmap::depth() == 1. - - Pixmap brushes are currently not supported when printing on X11. - - \sa pixmap(), color() -*/ - -void TQBrush::setPixmap( const TQPixmap &pixmap ) -{ - detach(); - if ( data->pixmap ) - delete data->pixmap; - if ( pixmap.isNull() ) { - data->style = NoBrush; - data->pixmap = 0; - } else { - data->style = CustomPattern; - data->pixmap = new TQPixmap( pixmap ); - if ( data->pixmap->optimization() == TQPixmap::MemoryOptim ) - data->pixmap->setOptimization( TQPixmap::NormalOptim ); - } -} - - -/*! - \fn bool TQBrush::operator!=( const TQBrush &b ) const - - Returns TRUE if the brush is different from \a b; otherwise - returns FALSE. - - Two brushes are different if they have different styles, colors or - pixmaps. - - \sa operator==() -*/ - -/*! - Returns TRUE if the brush is equal to \a b; otherwise returns - FALSE. - - Two brushes are equal if they have equal styles, colors and - pixmaps. - - \sa operator!=() -*/ - -bool TQBrush::operator==( const TQBrush &b ) const -{ - return (b.data == data) || (b.data->style == data->style && - b.data->color == data->color && - b.data->pixmap == data->pixmap); -} - - -/*! - \fn inline double TQPainter::translationX() const - \internal -*/ - -/*! - \fn inline double TQPainter::translationY() const - \internal -*/ - - -/***************************************************************************** - TQBrush stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQBrush - - Writes the brush \a b to the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQBrush &b ) -{ - s << (TQ_UINT8)b.style() << b.color(); - if ( b.style() == TQt::CustomPattern ) -#ifndef TQT_NO_IMAGEIO - s << *b.pixmap(); -#else - qWarning("No Image Brush I/O"); -#endif - return s; -} - -/*! - \relates TQBrush - - Reads the brush \a b from the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQBrush &b ) -{ - TQ_UINT8 style; - TQColor color; - s >> style; - s >> color; - if ( style == TQt::CustomPattern ) { -#ifndef TQT_NO_IMAGEIO - TQPixmap pm; - s >> pm; - b = TQBrush( color, pm ); -#else - qWarning("No Image Brush I/O"); -#endif - } - else - b = TQBrush( color, (TQt::BrushStyle)style ); - return s; -} -#endif // TQT_NO_DATASTREAM - -#endif // USE_QT4 diff --git a/tqtinterface/qt4/src/kernel/tqpainter.h~ b/tqtinterface/qt4/src/kernel/tqpainter.h~ deleted file mode 100644 index f391c79..0000000 --- a/tqtinterface/qt4/src/kernel/tqpainter.h~ +++ /dev/null @@ -1,993 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPainter class -** -** Created : 940112 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 TQPAINTER_H -#define TQPAINTER_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqcolor.h" -#include "tqfontmetrics.h" -#include "tqfontinfo.h" -#include "tqregion.h" -#include "tqpen.h" -#include "tqbrush.h" -#include "tqpointarray.h" -#include "tqwmatrix.h" -#endif // TQT_H - -#ifdef USE_QT4 - -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt3Support module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tqwidget.h" -#include "tqpaintdevice.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_COMPAT_EXPORT TQPainter : public QPainter, virtual public TQt -{ -public: - enum TextDirection { - Auto, - RTL, - LTR - }; - - enum CoordinateMode { CoordDevice, CoordPainter }; - - TQPainter(); - TQPainter( const QWidget *pdev, bool unclipped = FALSE); - TQPainter( QPaintDevice *pdev, bool unclipped = FALSE); - TQPainter( QWidget *pdev, const QWidget *w, bool unclipped = FALSE ); - TQPainter( QPaintDevice *pdev, const QWidget *w, bool unclipped = FALSE ); - - void flush(); - void flush( const TQRegion ®ion, CoordinateMode cm = CoordDevice ); - - void drawRect(const QRect &rect); - inline void drawRect(int x1, int y1, int w, int h) - { drawRect(QRect(x1, y1, w, h)); } - - void drawRoundRect(const QRect &r, int xround = 25, int yround = 25); - inline void drawRoundRect(int x, int y, int w, int h, int xround = 25, int yround = 25) - { drawRoundRect(QRect(x, y, w, h), xround, yround); } - - void drawEllipse(const QRect &r); - inline void drawEllipse(int x, int y, int w, int h) - { drawEllipse(QRect(x, y, w, h)); } - - void drawArc(const QRect &r, int a, int alen); - inline void drawArc(int x, int y, int w, int h, int a, int alen) - { drawArc(QRect(x, y, w, h), a, alen); } - - void drawPie(const QRect &r, int a, int alen); - inline void drawPie(int x, int y, int w, int h, int a, int alen) - { drawPie(QRect(x, y, w, h), a, alen); } - - void drawChord(const QRect &r, int a, int alen); - inline void drawChord(int x, int y, int w, int h, int a, int alen) - { drawChord(QRect(x, y, w, h), a, alen); } - - void drawImage( int x, int y, const TQImage image, int sx = 0, int sy = 0, int sw = -1, int sh = -1, int conversionFlags = 0 ); - void drawImage( const TQPoint &p, const TQImage image, const TQRect &sr, int conversionFlags = 0 ); - void drawImage( const TQPoint &p, const TQImage image, int conversion_flags = 0 ); - void drawImage( const TQRect &r, const TQImage image ); - - void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1); - - void setBrush(const QBrush &brush); - void setBrush(Qt::BrushStyle style); - void setBrush(TQt::BrushStyle style); - - inline void tqdrawPixmap( int x, int y, const TQPixmap &tqpm, int sx=0, int sy=0, int sw=-1, int sh=-1 ) { drawPixmap(x, y, tqpm, sx, sy, sw, sh); } - - TQPoint pos() const; - - // Qt4 requires the QPainter to have a valid QPaintDevice (engine) for boundingRect() to work - // So, we create one off-screen! - #define TQT_INITIALIZE_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL \ - bool neededEngine = FALSE; \ - if (QPainter::isActive() == 0) { \ - printf("[WARNING] Painter was inactive when TQPainter::boundingRect was called; this indicates a likely problem in painting within your application (check Qt::WA_PaintOutsidePaintEvent == true)\n\r"); \ - QImage image(1,1,QImage::Format_RGB32); \ - neededEngine = TRUE; \ - QPainter::begin(&image); \ - } - - #define TQT_DESTROY_QPAINTER_TEMPORARY_ENGINE_CONDITIONAL \ - if (neededEngine == TRUE) { \ - QPainter::end(); \ - } - - QRectF boundingRect(const QRectF &rect, int flags, const QString &text); - QRect boundingRect(const QRect &rect, int flags, const QString &text); - QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text); - QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption()); - - TQRect boundingRect(const QRect &rect, int flags, const QString &text, int len); - TQRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len); - - void drawText(const QPointF &p, const QString &s); - void drawText(const QPoint &p, const QString &s); - void drawText(int x, int y, const QString &s); - void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding); - void drawText(const QRectF &r, int flags, const QString &text, QRectF *br=0); - void drawText(const QRect &r, int flags, const QString &text, QRect *br=0); - void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br=0); - void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption()); - - void drawText( int x, int y, const TQString &s, int len = -1, TextDirection dir = Auto ); - void drawText( const TQPoint &p, const TQString &s, int len = -1, TextDirection dir = Auto ); - void drawText( int x, int y, const TQString &s, int pos, int len, TextDirection dir = Auto ); - void drawText( const TQPoint &p, const TQString &s, int pos, int len, TextDirection dir = Auto ); - - void drawText(int x, int y, const QString &s, int pos, int len); - void drawText(const QPoint &p, const QString &s, int pos, int len); - void drawText(int x, int y, const QString &s, int len); - void drawText(const QPoint &p, const QString &s, int len); - void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0); - void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0); - - void map(int x, int y, int *rx, int *ry) const; - void map( int, int, int, int, int *, int *, int *, int * ) const; - TQPoint xForm(const QPoint &) const; // map virtual -> deviceb - TQRect xForm(const QRect &) const; -// TQPolygon xForm(const QPolygon &) const; -// TQPolygon xForm(const QPolygon &, int index, int npoints) const; - TQPoint xFormDev(const QPoint &) const; // map device -> virtual - TQRect xFormDev(const QRect &) const; -// TQPolygon xFormDev(const QPolygon &) const; -// TQPolygon xFormDev(const QPolygon &, int index, int npoints) const; - qreal translationX() const; - qreal translationY() const; - - void resetXForm(); - - // [FIXME] The drawWinFocusRect methods below probably need tweaking to exactly match the old Qt3 behaviour - void drawWinFocusRect( int x, int y, int w, int h ); - void drawWinFocusRect( int x, int y, int w, int h, const TQColor &bgColor ); - void drawWinFocusRect( const TQRect &tqr ); - void drawWinFocusRect( const TQRect &tqr, const TQColor &bgColor ); - -// inline const TQWMatrix &tqworldMatrix() const { return (*(static_cast(&worldMatrix()))); } - const TQWMatrix &tqworldMatrix() const; - - inline TQPaintDevice *tqdevice() const { return static_cast(device()); } - - TQRegion clipRegion( CoordinateMode cm = CoordDevice ) const; - - void setClipRegion( const QRegion &qr, CoordinateMode cm = CoordDevice ); - - void setBackgroundColor(const QColor &color); - const QColor &backgroundColor() const; - - void setClipRect(const QRectF &qrf, Qt::ClipOperation op = Qt::ReplaceClip); - void setClipRect(const QRect &qr, Qt::ClipOperation op = Qt::ReplaceClip); - void setClipRect( const TQRect &qr, CoordinateMode cm = CoordDevice ); - void setClipRect( int x, int y, int w, int h, CoordinateMode cm = CoordDevice ); - - inline double m11() const { return deviceTransform().m11(); } - inline double m12() const { return deviceTransform().m12(); } - inline double m21() const { return deviceTransform().m21(); } - inline double m22() const { return deviceTransform().m22(); } - inline double dx() const { return deviceTransform().dx(); } - inline double dy() const { return deviceTransform().dy(); } - inline double im11() const { return deviceTransform().inverted().m11(); } - inline double im12() const { return deviceTransform().inverted().m12(); } - inline double im21() const { return deviceTransform().inverted().m21(); } - inline double im22() const { return deviceTransform().inverted().m22(); } - inline double idx() const { return deviceTransform().inverted().dx(); } - inline double idy() const { return deviceTransform().inverted().dy(); } - - void moveTo( int x, int y ); - void moveTo( const TQPoint & ); - void lineTo( int x, int y ); - void lineTo( const TQPoint & ); - - void tqdrawTextItem( int x, int y, const TQTextItem &ti, int textflags = 0 ); - void tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags = 0 ); - - static void redirect(QPaintDevice *pdev, QPaintDevice *replacement); - static TQPaintDevice *redirect(QPaintDevice *pdev); - - TQt::RasterOp rasterOp() const; - void setRasterOp( TQt::RasterOp ); - - bool tqbegin( QPaintDevice *pdev, bool unclipped = FALSE ); - bool tqbegin( QPaintDevice *pdev, const QWidget *init, bool unclipped = FALSE ); - - inline void tqdrawPolyline(const QPolygon &pa, int index, int npoints = -1) { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); } - inline void tqdrawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1) { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints, winding ? Qt::WindingFill : Qt::OddEvenFill); } - inline void tqdrawPolygon(const QPolygonF &polygon, bool winding, int index = 0, int npoints = -1) { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints, winding ? Qt::WindingFill : Qt::OddEvenFill); } - inline void tqdrawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1) { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); } - inline void tqdrawConvexPolygon(const QPolygon &pa, int index, int npoints = -1) { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); } -// static inline void redirect(QPaintDevice *pdev, QPaintDevice *replacement) { setRedirected(pdev, replacement); } -// static inline TQPaintDevice *redirect(QPaintDevice *pdev) { return const_cast(redirected(pdev)); } - void setWorldXForm(bool enabled); - bool hasWorldXForm() const; -// inline void resetXForm() { resetTransform(); } - void setViewXForm(bool enabled); - bool hasViewXForm() const; - - // [FIXME] - static void initialize(); - static void cleanup(); - - bool has_qwidget; - mutable QWidget* qwidget_ptr; - -private: - QRect adjustedRectangle(const QRect &r); - int rectSubtraction() const; - uchar rop; - enum { IsActive=0x01, ExtDev=0x02, IsStartingUp=0x04, NoCache=0x08, - VxF=0x10, WxF=0x20, ClipOn=0x40, SafePolygon=0x80, MonoDev=0x100, - DirtyFont=0x200, DirtyPen=0x400, DirtyBrush=0x800, - RGBColor=0x1000, FontMet=0x2000, FontInf=0x4000, CtorBegin=0x8000, - UsePrivateCx = 0x10000, VolatileDC = 0x20000, TQt2Compat = 0x40000 }; -// uint flags; -// bool testf( uint b ) const { return (flags&b)!=0; } - bool testf( uint b ) const; - void drawWinFocusRect( int x, int y, int w, int h, bool xorPaint, const QColor &penColor ); - void fix_neg_rect( int *x, int *y, int *w, int *h ); - - TQPoint current_penpos; - - Q_DISABLE_COPY(TQPainter) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#else // USE_QT4 - -class TQGfx; -class TQTextCodec; -class TQTextParag; -class TQPaintDevice; -class TQTextItem; -#if defined( TQ_WS_MAC ) -class TQMacSavedPortInfo; -#endif -class TQPainterPrivate; - -#if defined(TQ_WS_TQWS) -class TQScreen; -#endif - -class TQ_EXPORT TQPainter : public TQt -{ -public: - enum CoordinateMode { CoordDevice, CoordPainter }; - - TQPainter(); - TQPainter( const TQPaintDevice *, bool unclipped = FALSE ); - TQPainter( const TQPaintDevice *, const TQWidget *, bool unclipped = FALSE ); - ~TQPainter(); - - bool begin( const TQPaintDevice *, bool unclipped = FALSE ); - bool begin( const TQPaintDevice *, const TQWidget *, bool unclipped = FALSE ); - bool end(); - TQPaintDevice *tqdevice() const; - -#ifdef TQ_WS_TQWS - TQGfx * internalGfx(); -#ifdef TQT_TQWS_EXPERIMENTAL_SCREENPAINTER - bool begin(TQScreen *screen); -#endif -#endif - - static void redirect( TQPaintDevice *pdev, TQPaintDevice *tqreplacement ); - static TQPaintDevice *redirect( TQPaintDevice *pdev ); - - bool isActive() const; - - void flush( const TQRegion ®ion, CoordinateMode cm = CoordDevice ); - void flush(); - void save(); - void restore(); - - // Drawing tools - - TQFontMetrics fontMetrics() const; - TQFontInfo fontInfo() const; - - const TQFont &font() const; - void setFont( const TQFont & ); - const TQPen &pen() const; - void setPen( const TQPen & ); - void setPen( PenStyle ); - void setPen( const TQColor & ); - const TQBrush &brush() const; - void setBrush( const TQBrush & ); - void setBrush( BrushStyle ); - void setBrush( const TQColor & ); - TQPoint pos() const; - - // Drawing attributes/modes - - const TQColor &backgroundColor() const; - void setBackgroundColor( const TQColor & ); - BGMode backgroundMode() const; - void setBackgroundMode( BGMode ); - RasterOp rasterOp() const; - void setRasterOp( RasterOp ); - const TQPoint &brushOrigin() const; - void setBrushOrigin( int x, int y ); - void setBrushOrigin( const TQPoint & ); - - // Scaling and transformations - -// PaintUnit unit() const; // get set painter unit -// void setUnit( PaintUnit ); // NOT IMPLEMENTED!!! - - bool hasViewXForm() const; - bool hasWorldXForm() const; - -#ifndef TQT_NO_TRANSFORMATIONS - void setViewXForm( bool ); // set xform on/off - TQRect window() const; // get window - void setWindow( const TQRect & ); // set window - void setWindow( int x, int y, int w, int h ); - TQRect viewport() const; // get viewport - void setViewport( const TQRect & ); // set viewport - void setViewport( int x, int y, int w, int h ); - - void setWorldXForm( bool ); // set world xform on/off - const TQWMatrix &tqworldMatrix() const; // get/set world xform matrix - void setWorldMatrix( const TQWMatrix &, bool combine=FALSE ); - - void saveWorldMatrix(); - void restoreWorldMatrix(); - - void scale( double sx, double sy ); - void shear( double sh, double sv ); - void rotate( double a ); -#endif - void translate( double dx, double dy ); - void resetXForm(); - double translationX() const; - double translationY() const; - - TQPoint xForm( const TQPoint & ) const; // map virtual -> tqdevice - TQRect xForm( const TQRect & ) const; - TQPointArray xForm( const TQPointArray & ) const; - TQPointArray xForm( const TQPointArray &, int index, int npoints ) const; - TQPoint xFormDev( const TQPoint & ) const; // map tqdevice -> virtual - TQRect xFormDev( const TQRect & ) const; - TQPointArray xFormDev( const TQPointArray & ) const; - TQPointArray xFormDev( const TQPointArray &, int index, int npoints ) const; - - // Clipping - - void setClipping( bool ); // set clipping on/off - bool hasClipping() const; - TQRegion clipRegion( CoordinateMode = CoordDevice ) const; - void setClipRect( const TQRect &, CoordinateMode = CoordDevice ); // set clip rectangle - void setClipRect( int x, int y, int w, int h, CoordinateMode = CoordDevice ); - void setClipRegion( const TQRegion &, CoordinateMode = CoordDevice );// set clip region - - // Graphics drawing functions - - void drawPoint( int x, int y ); - void drawPoint( const TQPoint & ); - void drawPoints( const TQPointArray& a, - int index=0, int npoints=-1 ); - void moveTo( int x, int y ); - void moveTo( const TQPoint & ); - void lineTo( int x, int y ); - void lineTo( const TQPoint & ); - void drawLine( int x1, int y1, int x2, int y2 ); - void drawLine( const TQPoint &, const TQPoint & ); - void drawRect( int x, int y, int w, int h ); - void drawRect( const TQRect & ); - void drawWinFocusRect( int x, int y, int w, int h ); - void drawWinFocusRect( int x, int y, int w, int h, - const TQColor &bgColor ); - void drawWinFocusRect( const TQRect & ); - void drawWinFocusRect( const TQRect &, - const TQColor &bgColor ); - void drawRoundRect( int x, int y, int w, int h, int = 25, int = 25 ); - void drawRoundRect( const TQRect &, int = 25, int = 25 ); - void drawEllipse( int x, int y, int w, int h ); - void drawEllipse( const TQRect & ); - void drawArc( int x, int y, int w, int h, int a, int alen ); - void drawArc( const TQRect &, int a, int alen ); - void drawPie( int x, int y, int w, int h, int a, int alen ); - void drawPie( const TQRect &, int a, int alen ); - void drawChord( int x, int y, int w, int h, int a, int alen ); - void drawChord( const TQRect &, int a, int alen ); - void drawLineSegments( const TQPointArray &, - int index=0, int nlines=-1 ); - void drawPolyline( const TQPointArray &, - int index=0, int npoints=-1 ); - void drawPolygon( const TQPointArray &, bool winding=FALSE, - int index=0, int npoints=-1 ); - void drawConvexPolygon( const TQPointArray &, - int index=0, int npoints=-1 ); -#ifndef TQT_NO_BEZIER - void drawCubicBezier( const TQPointArray &, int index=0 ); -#endif - void drawPixmap( int x, int y, const TQPixmap &, - int sx=0, int sy=0, int sw=-1, int sh=-1 ); - void drawPixmap( const TQPoint &, const TQPixmap &, - const TQRect &sr ); - void drawPixmap( const TQPoint &, const TQPixmap & ); - void drawPixmap( const TQRect &, const TQPixmap & ); - void drawImage( int x, int y, const TQImage &, - int sx = 0, int sy = 0, int sw = -1, int sh = -1, - int conversionFlags = 0 ); - void drawImage( const TQPoint &, const TQImage &, - const TQRect &sr, int conversionFlags = 0 ); - void drawImage( const TQPoint &, const TQImage &, - int conversion_flags = 0 ); - void drawImage( const TQRect &, const TQImage & ); - void drawTiledPixmap( int x, int y, int w, int h, const TQPixmap &, - int sx=0, int sy=0 ); - void drawTiledPixmap( const TQRect &, const TQPixmap &, - const TQPoint & ); - void drawTiledPixmap( const TQRect &, const TQPixmap & ); -#ifndef TQT_NO_PICTURE - void drawPicture( const TQPicture & ); - void drawPicture( int x, int y, const TQPicture & ); - void drawPicture( const TQPoint &, const TQPicture & ); -#endif - - void fillRect( int x, int y, int w, int h, const TQBrush & ); - void fillRect( const TQRect &, const TQBrush & ); - void eraseRect( int x, int y, int w, int h ); - void eraseRect( const TQRect & ); - - // Text drawing functions - - enum TextDirection { - Auto, - RTL, - LTR - }; - - void drawText( int x, int y, const TQString &, int len = -1, TextDirection dir = Auto ); - void drawText( const TQPoint &, const TQString &, int len = -1, TextDirection dir = Auto ); - - void drawText( int x, int y, const TQString &, int pos, int len, TextDirection dir = Auto ); - void drawText( const TQPoint &p, const TQString &, int pos, int len, TextDirection dir = Auto ); - - void drawText( int x, int y, int w, int h, int flags, - const TQString&, int len = -1, TQRect *br=0, - TQTextParag **intern=0 ); - void drawText( const TQRect &, int flags, - const TQString&, int len = -1, TQRect *br=0, - TQTextParag **intern=0 ); - - void tqdrawTextItem( int x, int y, const TQTextItem &ti, int textflags = 0 ); - void tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags = 0 ); - - TQRect boundingRect( int x, int y, int w, int h, int flags, - const TQString&, int len = -1, TQTextParag **intern=0 ); - TQRect boundingRect( const TQRect &, int flags, - const TQString&, int len = -1, TQTextParag **intern=0 ); - - int tabStops() const; - void setTabStops( int ); - int *tabArray() const; - void setTabArray( int * ); - - // Other functions - -#if defined(TQ_WS_WIN) - HDC handle() const; -#elif defined(TQ_WS_X11) || defined(TQ_WS_MAC) - HANDLE handle() const; -#endif - - - static void initialize(); - static void cleanup(); - -private: - void init(); - void destroy(); - void updateFont(); - void updatePen(); - void updateBrush(); -#ifndef TQT_NO_TRANSFORMATIONS - void updateXForm(); - void updateInvXForm(); -#endif - void map( int, int, int *rx, int *ry ) const; - void map( int, int, int, int, int *, int *, int *, int * ) const; - void mapInv( int, int, int *, int * ) const; - void mapInv( int, int, int, int, int *, int *, int *, int * ) const; - void drawPolyInternal( const TQPointArray &, bool close=TRUE ); - void drawWinFocusRect( int x, int y, int w, int h, bool xorPaint, - const TQColor &penColor ); - - enum { IsActive=0x01, ExtDev=0x02, IsStartingUp=0x04, NoCache=0x08, - VxF=0x10, WxF=0x20, ClipOn=0x40, SafePolygon=0x80, MonoDev=0x100, - DirtyFont=0x200, DirtyPen=0x400, DirtyBrush=0x800, - RGBColor=0x1000, FontMet=0x2000, FontInf=0x4000, CtorBegin=0x8000, - UsePrivateCx = 0x10000, VolatileDC = 0x20000, TQt2Compat = 0x40000 }; - uint flags; - bool testf( uint b ) const { return (flags&b)!=0; } - void setf( uint b ) { flags |= b; } - void setf( uint b, bool v ); - void clearf( uint b ) { flags &= (uint)(~b); } - void fix_neg_rect( int *x, int *y, int *w, int *h ); - - TQPainterPrivate *d; - TQPaintDevice *pdev; - TQColor bg_col; - uchar bg_mode; - uchar rop; - uchar pu; - TQPoint bro; - TQFont cfont; - TQFont *pfont; // font used for metrics (might be different for printers) - TQPen cpen; - TQBrush cbrush; - TQRegion crgn; - int tabstops; - int *tabarray; - int tabarraylen; - bool block_ext; // for temporary blocking of external tqdevices - - // Transformations -#ifndef TQT_NO_TRANSFORMATIONS - TQCOORD wx, wy, ww, wh; - TQCOORD vx, vy, vw, vh; - TQWMatrix wxmat; - - // Cached composition (and inverse) of transformations - TQWMatrix xmat; - TQWMatrix ixmat; - - - - double m11() const { return xmat.m11(); } - double m12() const { return xmat.m12(); } - double m21() const { return xmat.m21(); } - double m22() const { return xmat.m22(); } - double dx() const { return xmat.dx(); } - double dy() const { return xmat.dy(); } - double im11() const { return ixmat.m11(); } - double im12() const { return ixmat.m12(); } - double im21() const { return ixmat.m21(); } - double im22() const { return ixmat.m22(); } - double idx() const { return ixmat.dx(); } - double idy() const { return ixmat.dy(); } - - int txop; - bool txinv; - -#else - // even without transformations we still have translations - int xlatex; - int xlatey; -#endif - - void *penRef; // pen cache ref - void *brushRef; // brush cache ref - void *ps_stack; - void *wm_stack; - void killPStack(); - -protected: -#ifdef TQ_OS_TEMP - TQPoint internalCurrentPos; - uint old_pix; // ### All win platforms in 4.0 -#endif -#if defined(TQ_WS_WIN) - friend class TQFontEngineWin; - friend class TQFontEngineBox; - TQT_WIN_PAINTER_MEMBERS -#elif defined(TQ_WS_X11) - friend class TQFontEngineXLFD; - friend class TQFontEngineXft; - friend class TQFontEngineBox; - Display *dpy; // current display - int scrn; // current screen - TQt::HANDLE hd; // handle to drawable - TQt::HANDLE rendhd; // handle to Xft draw - GC gc; // graphics context (standard) - GC gc_brush; // graphics contect for brush - TQPoint curPt; // current point - uint clip_serial; // clipping serial number -#elif defined(TQ_WS_MAC) - TQt::HANDLE hd; // handle to drawable - void initPaintDevice(bool force=FALSE, TQPoint *off=NULL, TQRegion *rgn=NULL); - friend const TQRegion &qt_mac_update_painter(TQPainter *, bool); - friend class TQFontEngineMac; - friend class TQMacPainter; -#elif defined(TQ_WS_TQWS) - friend class TQFontEngine; - TQGfx * gfx; - friend void qwsUpdateActivePainters(); -#endif - friend class TQFontMetrics; - friend class TQFontInfo; - friend class TQTextLayout; - friend void qt_format_text( const TQFont &, const TQRect &r, - int tf, const TQString& str, int len, TQRect *brect, - int tabstops, int* tabarray, int tabarraylen, - TQTextParag **internal, TQPainter* painter ); - friend void qt_draw_background( TQPainter *p, int x, int y, int w, int h ); - friend void qt_draw_transformed_rect( TQPainter *p, int x, int y, int w, int h, bool fill ); - friend class TQPrinter; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQPainter( const TQPainter & ); - TQPainter &operator=( const TQPainter & ); -#endif - - enum TransformationCodes { - TxNone = 0, // transformation codes - TxTranslate = 1, // copy in qpainter_*.cpp - TxScale = 2, - TxRotShear = 3 - }; -}; - - -/***************************************************************************** - TQPainter member functions - *****************************************************************************/ - -inline TQPaintDevice *TQPainter::tqdevice() const -{ - return pdev; -} - -inline bool TQPainter::isActive() const -{ - return testf(IsActive); -} - -inline const TQFont &TQPainter::font() const -{ - return cfont; -} - -inline const TQPen &TQPainter::pen() const -{ - return cpen; -} - -inline const TQBrush &TQPainter::brush() const -{ - return cbrush; -} - -/* -inline PaintUnit TQPainter::unit() const -{ - return (PaintUnit)pu; -} -*/ - -inline const TQColor &TQPainter::backgroundColor() const -{ - return bg_col; -} - -inline TQt::BGMode TQPainter::backgroundMode() const -{ - return (BGMode)bg_mode; -} - -inline TQt::RasterOp TQPainter::rasterOp() const -{ - return (RasterOp)rop; -} - -inline const TQPoint &TQPainter::brushOrigin() const -{ - return bro; -} - -inline bool TQPainter::hasViewXForm() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return testf(VxF); -#else - return xlatex || xlatey; -#endif -} - -inline bool TQPainter::hasWorldXForm() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return testf(WxF); -#else - return xlatex || xlatey; -#endif -} - -inline double TQPainter::translationX() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return tqworldMatrix().dx(); -#else - return xlatex; -#endif -} - -inline double TQPainter::translationY() const -{ -#ifndef TQT_NO_TRANSFORMATIONS - return tqworldMatrix().dy(); -#else - return xlatey; -#endif -} - - -inline bool TQPainter::hasClipping() const -{ - return testf(ClipOn); -} - -inline int TQPainter::tabStops() const -{ - return tabstops; -} - -inline int *TQPainter::tabArray() const -{ - return tabarray; -} - -#if defined(TQ_WS_WIN) -inline HDC TQPainter::handle() const -{ - return hdc; -} -#elif defined(TQ_WS_X11) || defined(TQ_WS_MAC) -inline TQt::HANDLE TQPainter::handle() const -{ - return hd; -} -#endif - -inline void TQPainter::setBrushOrigin( const TQPoint &p ) -{ - setBrushOrigin( p.x(), p.y() ); -} - -#ifndef TQT_NO_TRANSFORMATIONS -inline void TQPainter::setWindow( const TQRect &r ) -{ - setWindow( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::setViewport( const TQRect &r ) -{ - setViewport( r.x(), r.y(), r.width(), r.height() ); -} -#endif - -inline void TQPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m ) -{ - setClipRect( TQRect(x,y,w,h), m ); -} - -inline void TQPainter::drawPoint( const TQPoint &p ) -{ - drawPoint( p.x(), p.y() ); -} - -inline void TQPainter::moveTo( const TQPoint &p ) -{ - moveTo( p.x(), p.y() ); -} - -inline void TQPainter::lineTo( const TQPoint &p ) -{ - lineTo( p.x(), p.y() ); -} - -inline void TQPainter::drawLine( const TQPoint &p1, const TQPoint &p2 ) -{ - drawLine( p1.x(), p1.y(), p2.x(), p2.y() ); -} - -inline void TQPainter::drawRect( const TQRect &r ) -{ - drawRect( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::drawWinFocusRect( const TQRect &r ) -{ - drawWinFocusRect( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::drawWinFocusRect( const TQRect &r,const TQColor &penColor ) -{ - drawWinFocusRect( r.x(), r.y(), r.width(), r.height(), penColor ); -} - -inline void TQPainter::drawRoundRect( const TQRect &r, int xRnd, int yRnd ) -{ - drawRoundRect( r.x(), r.y(), r.width(), r.height(), xRnd, yRnd ); -} - -inline void TQPainter::drawEllipse( const TQRect &r ) -{ - drawEllipse( r.x(), r.y(), r.width(), r.height() ); -} - -inline void TQPainter::drawArc( const TQRect &r, int a, int alen ) -{ - drawArc( r.x(), r.y(), r.width(), r.height(), a, alen ); -} - -inline void TQPainter::drawPie( const TQRect &r, int a, int alen ) -{ - drawPie( r.x(), r.y(), r.width(), r.height(), a, alen ); -} - -inline void TQPainter::drawChord( const TQRect &r, int a, int alen ) -{ - drawChord( r.x(), r.y(), r.width(), r.height(), a, alen ); -} - -inline void TQPainter::drawPixmap( const TQPoint &p, const TQPixmap &pm, - const TQRect &sr ) -{ - drawPixmap( p.x(), p.y(), pm, sr.x(), sr.y(), sr.width(), sr.height() ); -} - -inline void TQPainter::drawImage( const TQPoint &p, const TQImage &pm, - const TQRect &sr, int conversionFlags ) -{ - drawImage( p.x(), p.y(), pm, - sr.x(), sr.y(), sr.width(), sr.height(), conversionFlags ); -} - -inline void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm, - const TQPoint &sp ) -{ - drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, sp.x(), sp.y() ); -} - -inline void TQPainter::drawTiledPixmap( const TQRect &r, const TQPixmap &pm ) -{ - drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, 0, 0 ); -} - -inline void TQPainter::fillRect( const TQRect &r, const TQBrush &brush ) -{ - fillRect( r.x(), r.y(), r.width(), r.height(), brush ); -} - -inline void TQPainter::eraseRect( int x, int y, int w, int h ) -{ - fillRect( x, y, w, h, backgroundColor() ); -} - -inline void TQPainter::eraseRect( const TQRect &r ) -{ - fillRect( r.x(), r.y(), r.width(), r.height(), backgroundColor() ); -} - -inline void TQPainter::drawText( const TQPoint &p, const TQString &s, int len, TextDirection dir ) -{ - drawText( p.x(), p.y(), s, 0, len, dir ); -} - -inline void TQPainter::drawText( const TQPoint &p, const TQString &s, int pos, int len, TextDirection dir ) -{ - drawText( p.x(), p.y(), s, pos, len, dir ); -} - -inline void TQPainter::drawText( int x, int y, int w, int h, int tf, - const TQString& str, int len, TQRect *br, TQTextParag **i ) -{ - TQRect r(x, y, w, h); - drawText( r, tf, str, len, br, i ); -} - -inline void TQPainter::tqdrawTextItem( const TQPoint& p, const TQTextItem &ti, int textflags ) -{ - tqdrawTextItem( p.x(), p.y(), ti, textflags ); -} - -inline TQRect TQPainter::boundingRect( int x, int y, int w, int h, int tf, - const TQString& str, int len, TQTextParag **i ) -{ - TQRect r(x, y, w, h); - return boundingRect( r, tf, str, len, i ); -} - -#if defined(TQ_WS_TQWS) -inline TQGfx * TQPainter::internalGfx() -{ - return gfx; -} -#endif - -#endif // USE_QT4 - -#endif // TQPAINTER_H diff --git a/tqtinterface/qt4/src/kernel/tqwmatrix.cpp~ b/tqtinterface/qt4/src/kernel/tqwmatrix.cpp~ deleted file mode 100644 index f95b660..0000000 --- a/tqtinterface/qt4/src/kernel/tqwmatrix.cpp~ +++ /dev/null @@ -1,1204 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQWMatrix class -** -** Created : 941020 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 "tqwmatrix.h" -#include "tqdatastream.h" -#include "tqregion.h" -#if defined(TQ_WS_X11) -double qsincos( double, bool calcCos ); // defined in qpainter_x11.cpp -#else -#include -#endif - -#include - -#ifndef TQT_NO_WMATRIX - -#ifdef USE_QT4 - -// some defines to inline some code -#define MAPDOUBLE( x, y, nx, ny ) \ -{ \ - double fx = x; \ - double fy = y; \ - nx = m11()*fx + m21()*fy + dx(); \ - ny = m12()*fx + m22()*fy + dy(); \ -} - -#define MAPINT( x, y, nx, ny ) \ -{ \ - double fx = x; \ - double fy = y; \ - nx = tqRound(m11()*fx + m21()*fy + dx()); \ - ny = tqRound(m12()*fx + m22()*fy + dy()); \ -} - -struct TQWMDoublePoint { - double x; - double y; -}; - -bool qt_old_transformations = TRUE; - -// TQWMatrix TQWMatrix::invert(bool *invertible=0) { -// return convertFromQMatrix(inverted(invertible)); -// } - -/*! - Sets the transformation mode that TQWMatrix and painter - transformations use to \a m. - - \sa TQWMatrix::TransformationMode -*/ -void TQWMatrix::setTransformationMode( TQWMatrix::TransformationMode m ) -{ - printf("[WARNING] TQWMatrix::setTransformationMode has no effect!\n\r"); - - if ( m == TQWMatrix::Points ) - qt_old_transformations = TRUE; - else - qt_old_transformations = FALSE; -} - - -/*! - Returns the current transformation mode. - - \sa TQWMatrix::TransformationMode -*/ -TQWMatrix::TransformationMode TQWMatrix::transformationMode() -{ - return (qt_old_transformations ? TQWMatrix::Points : TQWMatrix::Areas ); -} - -/*! - \internal -*/ -TQPointArray TQWMatrix::operator *( const TQPointArray &a ) const -{ - if( qt_old_transformations ) { - TQPointArray result = a.copy(); - int x, y; - for ( int i=0; i<(int)result.size(); i++ ) { - result.point( i, &x, &y ); - MAPINT( x, y, x, y ); - result.setPoint( i, x, y ); - } - return result; - } else { - int size = a.size(); - int i; - TQMemArray p( size ); - TQPoint *da = TQT_TQPOINT_CONST(a.data()); - TQWMDoublePoint *dp = p.data(); - double xmin = INT_MAX; - double ymin = xmin; - double xmax = INT_MIN; - double ymax = xmax; - int xminp = 0; - int yminp = 0; - for( i = 0; i < size; i++ ) { - dp[i].x = da[i].x(); - dp[i].y = da[i].y(); - if ( dp[i].x < xmin ) { - xmin = dp[i].x; - xminp = i; - } - if ( dp[i].y < ymin ) { - ymin = dp[i].y; - yminp = i; - } - xmax = TQMAX( xmax, dp[i].x ); - ymax = TQMAX( ymax, dp[i].y ); - } - double w = TQMAX( xmax - xmin, 1 ); - double h = TQMAX( ymax - ymin, 1 ); - for( i = 0; i < size; i++ ) { - dp[i].x += (dp[i].x - xmin)/w; - dp[i].y += (dp[i].y - ymin)/h; - MAPDOUBLE( dp[i].x, dp[i].y, dp[i].x, dp[i].y ); - } - - // now apply correction back for transformed values... - xmin = INT_MAX; - ymin = xmin; - xmax = INT_MIN; - ymax = xmax; - for( i = 0; i < size; i++ ) { - xmin = TQMIN( xmin, dp[i].x ); - ymin = TQMIN( ymin, dp[i].y ); - xmax = TQMAX( xmax, dp[i].x ); - ymax = TQMAX( ymax, dp[i].y ); - } - w = TQMAX( xmax - xmin, 1 ); - h = TQMAX( ymax - ymin, 1 ); - - TQPointArray result( size ); - TQPoint *dr = TQT_TQPOINT(result.data()); - for( i = 0; i < size; i++ ) { - dr[i].setX( tqRound( dp[i].x - (dp[i].x - dp[xminp].x)/w ) ); - dr[i].setY( tqRound( dp[i].y - (dp[i].y - dp[yminp].y)/h ) ); - } - return result; - } -} - -/*! - Returns the result of multiplying this matrix by matrix \a m. -*/ - -TQWMatrix &TQWMatrix::operator*=( const TQWMatrix &m ) -{ - double tm11 = m11()*m.m11() + m12()*m.m21(); - double tm12 = m11()*m.m12() + m12()*m.m22(); - double tm21 = m21()*m.m11() + m22()*m.m21(); - double tm22 = m21()*m.m12() + m22()*m.m22(); - - double tdx = dx()*m.m11() + dy()*m.m21() + m.dx(); - double tdy = dx()*m.m12() + dy()*m.m22() + m.dy(); - - *this = TQWMatrix(tm11, tm12, tm21, tm22, tdx, tdy); - - return *this; -} - -/*! - \overload - \relates TQWMatrix - Returns the product of \a m1 * \a m2. - - Note that matrix multiplication is not commutative, i.e. a*b != - b*a. -*/ - -TQWMatrix operator*( const TQWMatrix &m1, const TQWMatrix &m2 ) -{ - TQWMatrix result = m1; - result *= m2; - return result; -} - -#else // USE_QT4 - -/*! - \class TQWMatrix tqwmatrix.h - \brief The TQWMatrix class specifies 2D transformations of a - coordinate system. - - \ingroup graphics - \ingroup images - - The standard coordinate system of a \link TQPaintDevice paint - tqdevice\endlink has the origin located at the top-left position. X - values increase to the right; Y values increase downward. - - This coordinate system is the default for the TQPainter, which - renders graphics in a paint tqdevice. A user-defined coordinate - system can be specified by setting a TQWMatrix for the painter. - - Example: - \code - MyWidget::paintEvent( TQPaintEvent * ) - { - TQPainter p; // our painter - TQWMatrix m; // our transformation matrix - m.rotate( 22.5 ); // rotated coordinate system - p.begin( this ); // start painting - p.setWorldMatrix( m ); // use rotated coordinate system - p.drawText( 30,20, "detator" ); // draw rotated text at 30,20 - p.end(); // painting done - } - \endcode - - A matrix specifies how to translate, scale, shear or rotate the - graphics; the actual transformation is performed by the drawing - routines in TQPainter and by TQPixmap::xForm(). - - The TQWMatrix class tqcontains a 3x3 matrix of the form: - - - - -
m11m12 0
m21m22 0
dx dy  1
- - A matrix transforms a point in the plane to another point: - \code - x' = m11*x + m21*y + dx - y' = m22*y + m12*x + dy - \endcode - - The point \e (x, y) is the original point, and \e (x', y') is the - transformed point. \e (x', y') can be transformed back to \e (x, - y) by performing the same operation on the \link - TQWMatrix::invert() inverted matrix\endlink. - - The elements \e dx and \e dy specify horizontal and vertical - translation. The elements \e m11 and \e m22 specify horizontal and - vertical scaling. The elements \e m12 and \e m21 specify - horizontal and vertical shearing. - - The identity matrix has \e m11 and \e m22 set to 1; all others are - set to 0. This matrix maps a point to itself. - - Translation is the simplest transformation. Setting \e dx and \e - dy will move the coordinate system \e dx units along the X axis - and \e dy units along the Y axis. - - Scaling can be done by setting \e m11 and \e m22. For example, - setting \e m11 to 2 and \e m22 to 1.5 will double the height and - increase the width by 50%. - - Shearing is controlled by \e m12 and \e m21. Setting these - elements to values different from zero will twist the coordinate - system. - - Rotation is achieved by carefully setting both the shearing - factors and the scaling factors. The TQWMatrix also has a function - that sets \link rotate() rotation \endlink directly. - - TQWMatrix lets you combine transformations like this: - \code - TQWMatrix m; // identity matrix - m.translate(10, -20); // first translate (10,-20) - m.rotate(25); // then rotate 25 degrees - m.scale(1.2, 0.7); // finally scale it - \endcode - - Here's the same example using basic matrix operations: - \code - double a = pi/180 * 25; // convert 25 to radians - double sina = sin(a); - double cosa = cos(a); - TQWMatrix m1(1, 0, 0, 1, 10, -20); // translation matrix - TQWMatrix m2( cosa, sina, // rotation matrix - -sina, cosa, 0, 0 ); - TQWMatrix m3(1.2, 0, 0, 0.7, 0, 0); // scaling matrix - TQWMatrix m; - m = m3 * m2 * m1; // combine all transformations - \endcode - - \l TQPainter has functions to translate, scale, shear and rotate the - coordinate system without using a TQWMatrix. Although these - functions are very convenient, it can be more efficient to build a - TQWMatrix and call TQPainter::setWorldMatrix() if you want to perform - more than a single transform operation. - - \sa TQPainter::setWorldMatrix(), TQPixmap::xForm() -*/ - -bool qt_old_transformations = TRUE; - -/*! - \enum TQWMatrix::TransformationMode - - \keyword transformation matrix - - TQWMatrix offers two transformation modes. Calculations can either - be done in terms of points (Points mode, the default), or in - terms of area (Area mode). - - In Points mode the transformation is applied to the points that - mark out the tqshape's bounding line. In Areas mode the - transformation is applied in such a way that the area of the - contained region is correctly transformed under the matrix. - - \value Points transformations are applied to the tqshape's points. - \value Areas transformations are applied (e.g. to the width and - height) so that the area is transformed. - - Example: - - Suppose we have a rectangle, - \c{TQRect( 10, 20, 30, 40 )} and a transformation matrix - \c{TQWMatrix( 2, 0, 0, 2, 0, 0 )} to double the rectangle's size. - - In Points mode, the matrix will transform the top-left (10,20) and - the bottom-right (39,59) points producing a rectangle with its - top-left point at (20,40) and its bottom-right point at (78,118), - i.e. with a width of 59 and a height of 79. - - In Areas mode, the matrix will transform the top-left point in - the same way as in Points mode to (20/40), and double the width - and height, so the bottom-right will become (69,99), i.e. a width - of 60 and a height of 80. - - Because integer arithmetic is used (for speed), rounding - differences mean that the modes will produce slightly different - results given the same tqshape and the same transformation, - especially when scaling up. This also means that some operations - are not commutative. - - Under Points mode, \c{matrix * ( region1 | region2 )} is not equal to - \c{matrix * region1 | matrix * region2}. Under Area mode, \c{matrix * - (pointarray[i])} is not neccesarily equal to - \c{(matrix * pointarry)[i]}. - - \img xform.png Comparison of Points and Areas TransformationModes -*/ - -/*! - Sets the transformation mode that TQWMatrix and painter - transformations use to \a m. - - \sa TQWMatrix::TransformationMode -*/ -void TQWMatrix::setTransformationMode( TQWMatrix::TransformationMode m ) -{ - if ( m == TQWMatrix::Points ) - qt_old_transformations = TRUE; - else - qt_old_transformations = FALSE; -} - - -/*! - Returns the current transformation mode. - - \sa TQWMatrix::TransformationMode -*/ -TQWMatrix::TransformationMode TQWMatrix::transformationMode() -{ - return (qt_old_transformations ? TQWMatrix::Points : TQWMatrix::Areas ); -} - - -// some defines to inline some code -#define MAPDOUBLE( x, y, nx, ny ) \ -{ \ - double fx = x; \ - double fy = y; \ - nx = _m11*fx + _m21*fy + _dx; \ - ny = _m12*fx + _m22*fy + _dy; \ -} - -#define MAPINT( x, y, nx, ny ) \ -{ \ - double fx = x; \ - double fy = y; \ - nx = tqRound(_m11*fx + _m21*fy + _dx); \ - ny = tqRound(_m12*fx + _m22*fy + _dy); \ -} - -/***************************************************************************** - TQWMatrix member functions - *****************************************************************************/ - -/*! - Constructs an identity matrix. All elements are set to zero except - \e m11 and \e m22 (scaling), which are set to 1. -*/ - -TQWMatrix::TQWMatrix() -{ - _m11 = _m22 = 1.0; - _m12 = _m21 = _dx = _dy = 0.0; -} - -/*! - Constructs a matrix with the elements, \a m11, \a m12, \a m21, \a - m22, \a dx and \a dy. -*/ - -TQWMatrix::TQWMatrix( double m11, double m12, double m21, double m22, - double dx, double dy ) -{ - _m11 = m11; _m12 = m12; - _m21 = m21; _m22 = m22; - _dx = dx; _dy = dy; -} - - -/*! - Sets the matrix elements to the specified values, \a m11, \a m12, - \a m21, \a m22, \a dx and \a dy. -*/ - -void TQWMatrix::setMatrix( double m11, double m12, double m21, double m22, - double dx, double dy ) -{ - _m11 = m11; _m12 = m12; - _m21 = m21; _m22 = m22; - _dx = dx; _dy = dy; -} - - -/*! - \fn double TQWMatrix::m11() const - - Returns the X scaling factor. -*/ - -/*! - \fn double TQWMatrix::m12() const - - Returns the vertical shearing factor. -*/ - -/*! - \fn double TQWMatrix::m21() const - - Returns the horizontal shearing factor. -*/ - -/*! - \fn double TQWMatrix::m22() const - - Returns the Y scaling factor. -*/ - -/*! - \fn double TQWMatrix::dx() const - - Returns the horizontal translation. -*/ - -/*! - \fn double TQWMatrix::dy() const - - Returns the vertical translation. -*/ - - -/*! - \overload - - Transforms ( \a x, \a y ) to ( \a *tx, \a *ty ) using the - following formulae: - - \code - *tx = m11*x + m21*y + dx - *ty = m22*y + m12*x + dy - \endcode -*/ - -void TQWMatrix::map( double x, double y, double *tx, double *ty ) const -{ - MAPDOUBLE( x, y, *tx, *ty ); -} - -/*! - Transforms ( \a x, \a y ) to ( \a *tx, \a *ty ) using the formulae: - - \code - *tx = m11*x + m21*y + dx (rounded to the nearest integer) - *ty = m22*y + m12*x + dy (rounded to the nearest integer) - \endcode -*/ - -void TQWMatrix::map( int x, int y, int *tx, int *ty ) const -{ - MAPINT( x, y, *tx, *ty ); -} - -/*! - \fn TQPoint TQWMatrix::map( const TQPoint &p ) const - - \overload - - Transforms \a p to using the formulae: - - \code - retx = m11*px + m21*py + dx (rounded to the nearest integer) - rety = m22*py + m12*px + dy (rounded to the nearest integer) - \endcode -*/ - -/*! - \fn TQRect TQWMatrix::map( const TQRect &r ) const - - \obsolete - - Please use \l TQWMatrix::mapRect() instead. - - Note that this method does return the bounding rectangle of the \a r, when - shearing or rotations are used. -*/ - -/*! - \fn TQPointArray TQWMatrix::map( const TQPointArray &a ) const - - \overload - - Returns the point array \a a transformed by calling map for each point. -*/ - - -/*! - \fn TQRegion TQWMatrix::map( const TQRegion &r ) const - - \overload - - Transforms the region \a r. - - Calling this method can be rather expensive, if rotations or - shearing are used. -*/ - -/*! - \fn TQRegion TQWMatrix::mapToRegion( const TQRect &rect ) const - - Returns the transformed rectangle \a rect. - - A rectangle which has been rotated or sheared may result in a - non-rectangular region being returned. - - Calling this method can be expensive, if rotations or shearing are - used. If you just need to know the bounding rectangle of the - returned region, use mapRect() which is a lot faster than this - function. - - \sa TQWMatrix::mapRect() -*/ - - -/*! - Returns the transformed rectangle \a rect. - - The bounding rectangle is returned if rotation or shearing has - been specified. - - If you need to know the exact region \a rect maps to use \l - operator*(). - - \sa operator*() -*/ - -TQRect TQWMatrix::mapRect( const TQRect &rect ) const -{ - TQRect result; - if( qt_old_transformations ) { - if ( _m12 == 0.0F && _m21 == 0.0F ) { - result = TQRect( map(rect.topLeft()), map(rect.bottomRight()) ).normalize(); - } else { - TQPointArray a( rect ); - a = map( a ); - result = a.boundingRect(); - } - } else { - if ( _m12 == 0.0F && _m21 == 0.0F ) { - int x = tqRound( _m11*rect.x() + _dx ); - int y = tqRound( _m22*rect.y() + _dy ); - int w = tqRound( _m11*rect.width() ); - int h = tqRound( _m22*rect.height() ); - if ( w < 0 ) { - w = -w; - x -= w-1; - } - if ( h < 0 ) { - h = -h; - y -= h-1; - } - result = TQRect( x, y, w, h ); - } else { - - // see mapToPolygon for explanations of the algorithm. - double x0, y0; - double x, y; - MAPDOUBLE( rect.left(), rect.top(), x0, y0 ); - double xmin = x0; - double ymin = y0; - double xmax = x0; - double ymax = y0; - MAPDOUBLE( rect.right() + 1, rect.top(), x, y ); - xmin = TQMIN( xmin, x ); - ymin = TQMIN( ymin, y ); - xmax = TQMAX( xmax, x ); - ymax = TQMAX( ymax, y ); - MAPDOUBLE( rect.right() + 1, rect.bottom() + 1, x, y ); - xmin = TQMIN( xmin, x ); - ymin = TQMIN( ymin, y ); - xmax = TQMAX( xmax, x ); - ymax = TQMAX( ymax, y ); - MAPDOUBLE( rect.left(), rect.bottom() + 1, x, y ); - xmin = TQMIN( xmin, x ); - ymin = TQMIN( ymin, y ); - xmax = TQMAX( xmax, x ); - ymax = TQMAX( ymax, y ); - double w = xmax - xmin; - double h = ymax - ymin; - xmin -= ( xmin - x0 ) / w; - ymin -= ( ymin - y0 ) / h; - xmax -= ( xmax - x0 ) / w; - ymax -= ( ymax - y0 ) / h; - result = TQRect( tqRound(xmin), tqRound(ymin), tqRound(xmax)-tqRound(xmin)+1, tqRound(ymax)-tqRound(ymin)+1 ); - } - } - return result; -} - - -/*! - \internal -*/ -TQPoint TQWMatrix::operator *( const TQPoint &p ) const -{ - double fx = p.x(); - double fy = p.y(); - return TQPoint( tqRound(_m11*fx + _m21*fy + _dx), - tqRound(_m12*fx + _m22*fy + _dy) ); -} - - -struct TQWMDoublePoint { - double x; - double y; -}; - -/*! - \internal -*/ -TQPointArray TQWMatrix::operator *( const TQPointArray &a ) const -{ - if( qt_old_transformations ) { - TQPointArray result = a.copy(); - int x, y; - for ( int i=0; i<(int)result.size(); i++ ) { - result.point( i, &x, &y ); - MAPINT( x, y, x, y ); - result.setPoint( i, x, y ); - } - return result; - } else { - int size = a.size(); - int i; - TQMemArray p( size ); - TQPoint *da = a.data(); - TQWMDoublePoint *dp = p.data(); - double xmin = INT_MAX; - double ymin = xmin; - double xmax = INT_MIN; - double ymax = xmax; - int xminp = 0; - int yminp = 0; - for( i = 0; i < size; i++ ) { - dp[i].x = da[i].x(); - dp[i].y = da[i].y(); - if ( dp[i].x < xmin ) { - xmin = dp[i].x; - xminp = i; - } - if ( dp[i].y < ymin ) { - ymin = dp[i].y; - yminp = i; - } - xmax = TQMAX( xmax, dp[i].x ); - ymax = TQMAX( ymax, dp[i].y ); - } - double w = TQMAX( xmax - xmin, 1 ); - double h = TQMAX( ymax - ymin, 1 ); - for( i = 0; i < size; i++ ) { - dp[i].x += (dp[i].x - xmin)/w; - dp[i].y += (dp[i].y - ymin)/h; - MAPDOUBLE( dp[i].x, dp[i].y, dp[i].x, dp[i].y ); - } - - // now apply correction back for transformed values... - xmin = INT_MAX; - ymin = xmin; - xmax = INT_MIN; - ymax = xmax; - for( i = 0; i < size; i++ ) { - xmin = TQMIN( xmin, dp[i].x ); - ymin = TQMIN( ymin, dp[i].y ); - xmax = TQMAX( xmax, dp[i].x ); - ymax = TQMAX( ymax, dp[i].y ); - } - w = TQMAX( xmax - xmin, 1 ); - h = TQMAX( ymax - ymin, 1 ); - - TQPointArray result( size ); - TQPoint *dr = result.data(); - for( i = 0; i < size; i++ ) { - dr[i].setX( tqRound( dp[i].x - (dp[i].x - dp[xminp].x)/w ) ); - dr[i].setY( tqRound( dp[i].y - (dp[i].y - dp[yminp].y)/h ) ); - } - return result; - } -} - -/*! -\internal -*/ -TQRegion TQWMatrix::operator * (const TQRect &rect ) const -{ - TQRegion result; - if ( isIdentity() ) { - result = rect; - } else if ( _m12 == 0.0F && _m21 == 0.0F ) { - if( qt_old_transformations ) { - result = TQRect( map(rect.topLeft()), map(rect.bottomRight()) ).normalize(); - } else { - int x = tqRound( _m11*rect.x() + _dx ); - int y = tqRound( _m22*rect.y() + _dy ); - int w = tqRound( _m11*rect.width() ); - int h = tqRound( _m22*rect.height() ); - if ( w < 0 ) { - w = -w; - x -= w - 1; - } - if ( h < 0 ) { - h = -h; - y -= h - 1; - } - result = TQRect( x, y, w, h ); - } - } else { - result = TQRegion( mapToPolygon( rect ) ); - } - return result; - -} - -/*! - Returns the transformed rectangle \a rect as a polygon. - - Polygons and rectangles behave slightly differently - when transformed (due to integer rounding), so - \c{matrix.map( TQPointArray( rect ) )} is not always the same as - \c{matrix.mapToPolygon( rect )}. -*/ -TQPointArray TQWMatrix::mapToPolygon( const TQRect &rect ) const -{ - TQPointArray a( 4 ); - if ( qt_old_transformations ) { - a = TQPointArray( rect ); - return operator *( a ); - } - double x[4], y[4]; - if ( _m12 == 0.0F && _m21 == 0.0F ) { - x[0] = tqRound( _m11*rect.x() + _dx ); - y[0] = tqRound( _m22*rect.y() + _dy ); - double w = tqRound( _m11*rect.width() ); - double h = tqRound( _m22*rect.height() ); - if ( w < 0 ) { - w = -w; - x[0] -= w - 1.; - } - if ( h < 0 ) { - h = -h; - y[0] -= h - 1.; - } - x[1] = x[0]+w-1; - x[2] = x[1]; - x[3] = x[0]; - y[1] = y[0]; - y[2] = y[0]+h-1; - y[3] = y[2]; - } else { - MAPINT( rect.left(), rect.top(), x[0], y[0] ); - MAPINT( rect.right() + 1, rect.top(), x[1], y[1] ); - MAPINT( rect.right() + 1, rect.bottom() + 1, x[2], y[2] ); - MAPINT( rect.left(), rect.bottom() + 1, x[3], y[3] ); - - /* - Including rectangles as we have are evil. - - We now have a rectangle that is one pixel to wide and one to - high. the tranformed position of the top-left corner is - correct. All other points need some adjustments. - - Doing this mathematically exact would force us to calculate some square roots, - something we don't want for the sake of speed. - - Instead we use an approximation, that converts to the correct - answer when m12 -> 0 and m21 -> 0, and accept smaller - errors in the general transformation case. - - The solution is to calculate the width and height of the - bounding rect, and scale the points 1/2/3 by (xp-x0)/xw pixel direction - to point 0. - */ - - double xmin = x[0]; - double ymin = y[0]; - double xmax = x[0]; - double ymax = y[0]; - int i; - for( i = 1; i< 4; i++ ) { - xmin = TQMIN( xmin, x[i] ); - ymin = TQMIN( ymin, y[i] ); - xmax = TQMAX( xmax, x[i] ); - ymax = TQMAX( ymax, y[i] ); - } - double w = xmax - xmin; - double h = ymax - ymin; - - for( i = 1; i < 4; i++ ) { - x[i] -= (x[i] - x[0])/w; - y[i] -= (y[i] - y[0])/h; - } - } -#if 0 - int i; - for( i = 0; i< 4; i++ ) - qDebug("coords(%d) = (%f/%f) (%d/%d)", i, x[i], y[i], tqRound(x[i]), tqRound(y[i]) ); - qDebug( "width=%f, height=%f", sqrt( (x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]) ), - sqrt( (x[0]-x[3])*(x[0]-x[3]) + (y[0]-y[3])*(y[0]-y[3]) ) ); -#endif - // all coordinates are correctly, tranform to a pointarray - // (rounding to the next integer) - a.setPoints( 4, tqRound( x[0] ), tqRound( y[0] ), - tqRound( x[1] ), tqRound( y[1] ), - tqRound( x[2] ), tqRound( y[2] ), - tqRound( x[3] ), tqRound( y[3] ) ); - return a; -} - -/*! -\internal -*/ -TQRegion TQWMatrix::operator * (const TQRegion &r ) const -{ - if ( isIdentity() ) - return r; - TQMemArray rects = r.rects(); - TQRegion result; - register TQRect *rect = rects.data(); - register int i = rects.size(); - if ( _m12 == 0.0F && _m21 == 0.0F && _m11 > 1.0F && _m22 > 1.0F ) { - // simple case, no rotation - while ( i ) { - int x = tqRound( _m11*rect->x() + _dx ); - int y = tqRound( _m22*rect->y() + _dy ); - int w = tqRound( _m11*rect->width() ); - int h = tqRound( _m22*rect->height() ); - if ( w < 0 ) { - w = -w; - x -= w-1; - } - if ( h < 0 ) { - h = -h; - y -= h-1; - } - *rect = TQRect( x, y, w, h ); - rect++; - i--; - } - result.setRects( rects.data(), rects.size() ); - } else { - while ( i ) { - result |= operator *( *rect ); - rect++; - i--; - } - } - return result; -} - -/*! - Resets the matrix to an identity matrix. - - All elements are set to zero, except \e m11 and \e m22 (scaling) - which are set to 1. - - \sa isIdentity() -*/ - -void TQWMatrix::reset() -{ - _m11 = _m22 = 1.0; - _m12 = _m21 = _dx = _dy = 0.0; -} - -/*! - Returns TRUE if the matrix is the identity matrix; otherwise returns FALSE. - - \sa reset() -*/ -bool TQWMatrix::isIdentity() const -{ - return _m11 == 1.0 && _m22 == 1.0 && _m12 == 0.0 && _m21 == 0.0 - && _dx == 0.0 && _dy == 0.0; -} - -/*! - Moves the coordinate system \a dx along the X-axis and \a dy along - the Y-axis. - - Returns a reference to the matrix. - - \sa scale(), shear(), rotate() -*/ - -TQWMatrix &TQWMatrix::translate( double dx, double dy ) -{ - _dx += dx*_m11 + dy*_m21; - _dy += dy*_m22 + dx*_m12; - return *this; -} - -/*! - Scales the coordinate system unit by \a sx horizontally and \a sy - vertically. - - Returns a reference to the matrix. - - \sa translate(), shear(), rotate() -*/ - -TQWMatrix &TQWMatrix::scale( double sx, double sy ) -{ - _m11 *= sx; - _m12 *= sx; - _m21 *= sy; - _m22 *= sy; - return *this; -} - -/*! - Shears the coordinate system by \a sh horizontally and \a sv - vertically. - - Returns a reference to the matrix. - - \sa translate(), scale(), rotate() -*/ - -TQWMatrix &TQWMatrix::shear( double sh, double sv ) -{ - double tm11 = sv*_m21; - double tm12 = sv*_m22; - double tm21 = sh*_m11; - double tm22 = sh*_m12; - _m11 += tm11; - _m12 += tm12; - _m21 += tm21; - _m22 += tm22; - return *this; -} - -const double deg2rad = 0.017453292519943295769; // pi/180 - -/*! - Rotates the coordinate system \a a degrees counterclockwise. - - Returns a reference to the matrix. - - \sa translate(), scale(), shear() -*/ - -TQWMatrix &TQWMatrix::rotate( double a ) -{ - double b = deg2rad*a; // convert to radians -#if defined(TQ_WS_X11) - double sina = qsincos(b,FALSE); // fast and convenient - double cosa = qsincos(b,TRUE); -#else - double sina = sin(b); - double cosa = cos(b); -#endif - double tm11 = cosa*_m11 + sina*_m21; - double tm12 = cosa*_m12 + sina*_m22; - double tm21 = -sina*_m11 + cosa*_m21; - double tm22 = -sina*_m12 + cosa*_m22; - _m11 = tm11; _m12 = tm12; - _m21 = tm21; _m22 = tm22; - return *this; -} - -/*! - \fn bool TQWMatrix::isInvertible() const - - Returns TRUE if the matrix is invertible; otherwise returns FALSE. - - \sa invert() -*/ - -/*! - \fn double TQWMatrix::det() const - - Returns the matrix's determinant. -*/ - - -/*! - Returns the inverted matrix. - - If the matrix is singular (not invertible), the identity matrix is - returned. - - If \a invertible is not 0: the value of \a *invertible is set - to TRUE if the matrix is invertible; otherwise \a *invertible is - set to FALSE. - - \sa isInvertible() -*/ - -TQWMatrix TQWMatrix::invert( bool *invertible ) const -{ - double determinant = det(); - if ( determinant == 0.0 ) { - if ( invertible ) - *invertible = FALSE; // singular matrix - TQWMatrix defaultMatrix; - return defaultMatrix; - } - else { // invertible matrix - if ( invertible ) - *invertible = TRUE; - double dinv = 1.0/determinant; - TQWMatrix imatrix( (_m22*dinv), (-_m12*dinv), - (-_m21*dinv), ( _m11*dinv), - ((_m21*_dy - _m22*_dx)*dinv), - ((_m12*_dx - _m11*_dy)*dinv) ); - return imatrix; - } -} - - -/*! - Returns TRUE if this matrix is equal to \a m; otherwise returns FALSE. -*/ - -bool TQWMatrix::operator==( const TQWMatrix &m ) const -{ - return _m11 == m._m11 && - _m12 == m._m12 && - _m21 == m._m21 && - _m22 == m._m22 && - _dx == m._dx && - _dy == m._dy; -} - -/*! - Returns TRUE if this matrix is not equal to \a m; otherwise returns FALSE. -*/ - -bool TQWMatrix::operator!=( const TQWMatrix &m ) const -{ - return _m11 != m._m11 || - _m12 != m._m12 || - _m21 != m._m21 || - _m22 != m._m22 || - _dx != m._dx || - _dy != m._dy; -} - -/*! - Returns the result of multiplying this matrix by matrix \a m. -*/ - -TQWMatrix &TQWMatrix::operator*=( const TQWMatrix &m ) -{ - double tm11 = _m11*m._m11 + _m12*m._m21; - double tm12 = _m11*m._m12 + _m12*m._m22; - double tm21 = _m21*m._m11 + _m22*m._m21; - double tm22 = _m21*m._m12 + _m22*m._m22; - - double tdx = _dx*m._m11 + _dy*m._m21 + m._dx; - double tdy = _dx*m._m12 + _dy*m._m22 + m._dy; - - _m11 = tm11; _m12 = tm12; - _m21 = tm21; _m22 = tm22; - _dx = tdx; _dy = tdy; - return *this; -} - -/*! - \overload - \relates TQWMatrix - Returns the product of \a m1 * \a m2. - - Note that matrix multiplication is not commutative, i.e. a*b != - b*a. -*/ - -TQWMatrix operator*( const TQWMatrix &m1, const TQWMatrix &m2 ) -{ - TQWMatrix result = m1; - result *= m2; - return result; -} - -/***************************************************************************** - TQWMatrix stream functions - *****************************************************************************/ -#ifndef TQT_NO_DATASTREAM -/*! - \relates TQWMatrix - - Writes the matrix \a m to the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator<<( TQDataStream &s, const TQWMatrix &m ) -{ - if ( s.version() == 1 ) - s << (float)m.m11() << (float)m.m12() << (float)m.m21() - << (float)m.m22() << (float)m.dx() << (float)m.dy(); - else - s << m.m11() << m.m12() << m.m21() << m.m22() - << m.dx() << m.dy(); - return s; -} - -/*! - \relates TQWMatrix - - Reads the matrix \a m from the stream \a s and returns a reference - to the stream. - - \sa \link datastreamformat.html Format of the TQDataStream operators \endlink -*/ - -TQDataStream &operator>>( TQDataStream &s, TQWMatrix &m ) -{ - if ( s.version() == 1 ) { - float m11, m12, m21, m22, dx, dy; - s >> m11; s >> m12; s >> m21; s >> m22; - s >> dx; s >> dy; - m.setMatrix( m11, m12, m21, m22, dx, dy ); - } - else { - double m11, m12, m21, m22, dx, dy; - s >> m11; s >> m12; s >> m21; s >> m22; - s >> dx; s >> dy; - m.setMatrix( m11, m12, m21, m22, dx, dy ); - } - return s; -} -#endif // TQT_NO_DATASTREAM - -#endif // USE_QT4 - -#endif // TQT_NO_WMATRIX - diff --git a/tqtinterface/qt4/src/kernel/tqwmatrix.h~ b/tqtinterface/qt4/src/kernel/tqwmatrix.h~ deleted file mode 100644 index 0ce4085..0000000 --- a/tqtinterface/qt4/src/kernel/tqwmatrix.h~ +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Definition of TQWMatrix class -** -** Created : 941020 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** 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 TQWMATRIX_H -#define TQWMATRIX_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqwindowdefs.h" -#include "tqpointarray.h" -#include "tqrect.h" -#include "tqregion.h" -#endif // TQT_H - -#ifndef TQT_NO_WMATRIX - -#ifdef USE_QT4 - -#include -#include - -// #include "tqimage.h" - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQWMatrix : public QMatrix, virtual public TQt -{ -public: - TQWMatrix() : QMatrix() {} - TQWMatrix( double m11, double m12, double m21, double m22, double dx, double dy ) : QMatrix( m11, m12, m21, m22, dx, dy ) {} - - //TQWMatrix invert(bool *invertible=0); - inline TQWMatrix invert(bool *invertible=0) const { const QMatrix &ref = inverted(invertible); return (*static_cast(&ref)); } - - inline TQRect map(const QRect &r) const { return mapRect(r); } - - inline void map( int x, int y, int *tx, int *ty ) const { return QMatrix::map(x, y, tx, ty); } - inline void map( double x, double y, double *tx, double *ty ) const { return QMatrix::map(x, y, tx, ty); } - inline TQPoint map( const QPoint &p ) const { return QMatrix::map(p); } - inline TQRegion map( const QRegion &r ) const { return QMatrix::map(r); } - TQPointArray map( const TQPointArray &a ) const; - - TQRegion mapToRegion(const QRect &r) const; - - enum TransformationMode { - Points, Areas - }; - static void setTransformationMode( TQWMatrix::TransformationMode m ); - static TransformationMode transformationMode(); - - TQPointArray operator * ( const TQPointArray &a ) const; - - TQWMatrix &operator*=( const TQWMatrix & ); - - // Interoperability - inline TQWMatrix &operator=( const QMatrix &qm ) { return *this = qm; } - -// TQWMatrix(QMatrix a) { -// setMatrix(a.m11(), a.m12() -// } - -// inline operator QMatrix() const { return *this; } - - // Interoperability - static const TQWMatrix& convertFromQMatrix( QMatrix& qs ); -}; - -// Interoperability -inline static const TQWMatrix& convertFromQMatrix( const QMatrix& qs ) { - return (*static_cast(&qs)); -} - -TQ_EXPORT TQWMatrix operator*( const TQWMatrix &, const TQWMatrix & ); - -#else // USE_QT4 - -class TQ_EXPORT TQWMatrix // 2D transform matrix -{ -public: - TQWMatrix(); - TQWMatrix( double m11, double m12, double m21, double m22, - double dx, double dy ); - - void setMatrix( double m11, double m12, double m21, double m22, - double dx, double dy ); - - double m11() const { return _m11; } - double m12() const { return _m12; } - double m21() const { return _m21; } - double m22() const { return _m22; } - double dx() const { return _dx; } - double dy() const { return _dy; } - - void map( int x, int y, int *tx, int *ty ) const; - void map( double x, double y, double *tx, double *ty ) const; - TQRect mapRect( const TQRect & ) const; - - TQPoint map( const TQPoint &p ) const { return operator *( p ); } - TQRect map( const TQRect &r ) const { return mapRect ( r ); } - TQPointArray map( const TQPointArray &a ) const { return operator * ( a ); } - TQRegion map( const TQRegion &r ) const { return operator *( r ); } - TQRegion mapToRegion( const TQRect &r ) const { return operator *( r ); } - TQPointArray mapToPolygon( const TQRect &r ) const; - - void reset(); - bool isIdentity() const; - - TQWMatrix &translate( double dx, double dy ); - TQWMatrix &scale( double sx, double sy ); - TQWMatrix &shear( double sh, double sv ); - TQWMatrix &rotate( double a ); - - bool isInvertible() const { return (_m11*_m22 - _m12*_m21) != 0; } - double det() const { return _m11*_m22 - _m12*_m21; } - - TQWMatrix invert( bool * = 0 ) const; - - bool operator==( const TQWMatrix & ) const; - bool operator!=( const TQWMatrix & ) const; - TQWMatrix &operator*=( const TQWMatrix & ); - - /* we use matrix multiplication semantics here */ - TQPoint operator * (const TQPoint & ) const; - TQRegion operator * (const TQRect & ) const; - TQRegion operator * (const TQRegion & ) const; - TQPointArray operator * ( const TQPointArray &a ) const; - - enum TransformationMode { - Points, Areas - }; - static void setTransformationMode( TQWMatrix::TransformationMode m ); - static TransformationMode transformationMode(); -private: - double _m11, _m12; - double _m21, _m22; - double _dx, _dy; -}; - -TQ_EXPORT TQWMatrix operator*( const TQWMatrix &, const TQWMatrix & ); - - -/***************************************************************************** - TQWMatrix stream functions - *****************************************************************************/ - -TQ_EXPORT TQDataStream &operator<<( TQDataStream &, const TQWMatrix & ); -TQ_EXPORT TQDataStream &operator>>( TQDataStream &, TQWMatrix & ); - -#endif // USE_QT4 - -#endif // TQT_NO_WMATRIX - -#endif // TQWMATRIX_H diff --git a/tqtinterface/qt4/src/tools/tqbuffer.h~ b/tqtinterface/qt4/src/tools/tqbuffer.h~ deleted file mode 100644 index c939e50..0000000 --- a/tqtinterface/qt4/src/tools/tqbuffer.h~ +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Definition of TQBuffer class -** -** Created : 930812 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQBUFFER_H -#define TQBUFFER_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqiodevice.h" -#include "tqstring.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -class TQ_EXPORT TQBuffer : public QBuffer -{ -public: -#if defined(TQT_ABI_QT4) - typedef TQ_LLONG Offset; -#else - typedef TQ_ULONG Offset; -#endif - - #warning Please remember that TQByteArray is no longer explicitly shared. If you get weird crashes while using TQt stream objects please see tqbuffer.h line 69 - // NOTE: - // QByteArray was explicitly shared in Qt3 - // This is no longer the case in Qt4 - // If you get weird crashes inside TQBuffer, it probably means you did something like this: - // - // main() { - // aFunction(); - // otherFunction(); - // } - // - // aFunction() { - // TQBuffer m_Buffer(QByteArray()); - // } - // - // otherFunction() { - // m_Buffer.putch('H'); - // } - // - // The QByteArray object was created within aFunction, but as it went out of scope it was destroyed before otherFunction was called - // Therefore, the TQBuffer's internal reference to the TQByteArray was invalid at the time putch() was called - // You could do this instead: - // - // aFunction() { - // TQBuffer m_Buffer(); - // m_Buffer.tqsetBufferFromCopy(QByteArray()); - // } - - TQBuffer() : QBuffer() {} - TQBuffer( TQByteArray &ba ) : QBuffer( &ba, 0 ) {} - TQBuffer( const TQByteArray &ba ) : QBuffer( const_cast(&ba), 0 ) {} -// TQBuffer( TQByteArray ba ) : QBuffer(), internal_ba_copy(ba) { QBuffer::setBuffer(&internal_ba_copy); } // Make a copy of ba - - inline int state() const { return isOpen() ? 0x1000 : 0; } - inline int mode() const { return (int) openMode(); } - inline int flags() const { return (int) openMode(); } - inline bool tqopen( int mode ) { return open((OpenModeFlag)mode); } - - inline Offset at() const { return pos(); } - inline bool at(Offset offset) { return seek(offset); } - inline Offset tqat() const { return pos(); } - inline bool tqat(Offset offset) { return seek(offset); } - -// virtual inline qint64 readBlock(char *data, quint64 maxlen) { return read(data, maxlen); } -// virtual inline qint64 writeBlock(const char *data, quint64 len) { return write(data, len); } -// virtual inline qint64 writeBlock(const QByteArray &data) { return write(data); } - inline qint64 readBlock(char *data, quint64 maxlen) { return read(data, maxlen); } - inline qint64 writeBlock(const char *data, quint64 len) { return write(data, len); } - inline qint64 writeBlock(const QByteArray &data) { return write(data); } - -// virtual inline qint64 readData ( char * data, qint64 maxSize ) { return readBlock(data, maxSize); } -// virtual inline qint64 writeData ( const char * data, qint64 maxSize ) { return writeBlock(data, maxSize); } - - inline int getch() { char c; return getChar(&c) ? int(uchar(c)) : -1; } - inline int putch(int c) { return putChar(char(c)) ? int(uchar(c)) : -1; } - inline int ungetch(int c) { ungetChar(uchar(c)); return c; } - - inline bool isDirectAccess() const { return !isSequential(); } - inline bool isSequentialAccess() const { return isSequential(); } - inline bool isCombinedAccess() const { return false; } - inline bool isBuffered() const { return true; } - inline bool isRaw() const { return false; } - inline bool isSynchronous() const { return true; } - inline bool isAsynchronous() const { return false; } - inline bool isTranslated() const { return (openMode() & Text) != 0; } - inline bool isInactive() const { return !isOpen(); } - - inline TQByteArray &buffer() { return static_cast(QBuffer::buffer()); } - inline bool setBuffer( TQByteArray &tqba ) { if (isOpen() == TRUE) return FALSE; QBuffer::setBuffer(&tqba); return TRUE; } - inline bool tqsetBufferFromCopy( TQByteArray tqba ) { if (isOpen() == TRUE) return FALSE; internal_ba_copy = tqba; QBuffer::setBuffer(&internal_ba_copy); return TRUE; } -// inline bool setBuffer( TQByteArray tqba ) { if (isOpen() == TRUE) return FALSE; internal_ba_copy = tqba; QBuffer::setBuffer(&internal_ba_copy); return TRUE; } - -public: - typedef int Status; - Status status() const { -#if !defined(QT_NO_QOBJECT) - const QFile *f = qobject_cast(this); - if (f) return (int) f->error(); -#endif - return isOpen() ? 0 /* IO_Ok */ : 8 /* IO_UnspecifiedError */; - } - void resetStatus() { -#if !defined(QT_NO_QOBJECT) - QFile *f = qobject_cast(this); - if (f) f->unsetError(); -#endif - } - - void setqStatus( int ) { std::cout << "[WARNING] TQBuffer::setqStatus() UNIMPLEMENTED\n\r"; } - void resetqStatus() { resetStatus(); } - -private: - TQByteArray internal_ba_copy; -}; - -#else // USE_QT4 - -class TQ_EXPORT TQBuffer : public TQIODevice -{ -public: - TQBuffer(); - TQBuffer( TQByteArray ); - ~TQBuffer(); - - TQByteArray buffer() const; - bool setBuffer( TQByteArray ); - - bool open( int ); - void close(); - void flush(); - - Offset size() const; - Offset at() const; - bool at( Offset ); - - TQ_LONG readBlock( char *p, TQ_ULONG ); - TQ_LONG writeBlock( const char *p, TQ_ULONG ); - TQ_LONG writeBlock( const TQByteArray& data ) - { return TQIODevice::writeBlock(data); } - TQ_LONG readLine( char *p, TQ_ULONG ); - - int getch(); - int putch( int ); - int ungetch( int ); - -protected: - TQByteArray a; - -private: - uint a_len; - uint a_inc; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQBuffer( const TQBuffer & ); - TQBuffer &operator=( const TQBuffer & ); -#endif -}; - - -inline TQByteArray TQBuffer::buffer() const -{ return a; } - -inline TQIODevice::Offset TQBuffer::size() const -{ return (Offset)a.size(); } - -inline TQIODevice::Offset TQBuffer::at() const -{ return ioIndex; } - -#endif // USE_QT4 - -#endif // TQBUFFER_H diff --git a/tqtinterface/qt4/src/tools/tqiodevice.h~ b/tqtinterface/qt4/src/tools/tqiodevice.h~ deleted file mode 100644 index e34b65d..0000000 --- a/tqtinterface/qt4/src/tools/tqiodevice.h~ +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************** -** -** Definition of TQIODevice class -** -** Created : 940913 -** -** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQIODEVICE_H -#define TQIODEVICE_H - -#include "tqtglobaldefines.h" - -#ifndef TQT_H -#include "tqglobal.h" -#include "tqcstring.h" -#endif // TQT_H - -#ifdef USE_QT4 - -#include -#include -#include - -#endif // USE_QT4 - -#ifdef USE_QT4 - -#define IO_Direct 0x0100 // direct access tqdevice -#define IO_Sequential 0x0200 // sequential access tqdevice -#define IO_Combined 0x0300 // combined direct/sequential -#define IO_TypeMask 0x0f00 - -// IO handling modes - -#define IO_Raw 0x0040 // raw access (not buffered) -#define IO_Async 0x0080 // asynchronous mode - -// IO tqdevice open modes - -#define IO_ReadOnly (QIODevice::OpenModeFlag)0x0001 // readable tqdevice -#define IO_WriteOnly (QIODevice::OpenModeFlag)0x0002 // writable tqdevice -#define IO_ReadWrite (QIODevice::OpenModeFlag)0x0003 // read+write tqdevice -#define IO_Append (QIODevice::OpenModeFlag)0x0004 // append -#define IO_Truncate (QIODevice::OpenModeFlag)0x0008 // truncate tqdevice -#define IO_Translate (QIODevice::OpenModeFlag)0x0010 // translate CR+LF -#define IO_ModeMask (QIODevice::OpenModeFlag)0x00ff - -// IO tqdevice state - -#define IO_Open 0x1000 // tqdevice is open -#define IO_StateMask 0xf000 - -// IO tqdevice status - -#define IO_Ok 0 -#define IO_ReadError 1 // read error -#define IO_WriteError 2 // write error -#define IO_FatalError 3 // fatal unrecoverable error -#define IO_ResourceError 4 // resource limitation -#define IO_OpenError 5 // cannot open tqdevice -#define IO_ConnectError 5 // cannot connect to tqdevice -#define IO_AbortError 6 // abort error -#define IO_TimeOutError 7 // time out -#define IO_UnspecifiedError 8 // unspecified error - -class TQ_EXPORT TQIODevice : public QIODevice -{ -public: -#if defined(TQT_ABI_QT4) - typedef TQ_LLONG Offset; -#else - typedef TQ_ULONG Offset; -#endif - - TQIODevice() : QIODevice() {} - - inline int state() const { return isOpen() ? 0x1000 : 0; } - inline int mode() const { return (int) openMode(); } - inline int flags() const { return (int) openMode(); } - inline bool tqopen( int mode ) { return open((OpenModeFlag)mode); } - - inline Offset at() const { return pos(); } - inline bool at(Offset offset) { return seek(offset); } - inline Offset tqat() const { return pos(); } - inline bool tqat(Offset offset) { return seek(offset); } - -// virtual inline qint64 readBlock(char *data, quint64 maxlen) { return read(data, maxlen); } -// virtual inline qint64 writeBlock(const char *data, quint64 len) { return write(data, len); } -// virtual inline qint64 writeBlock(const QByteArray &data) { return write(data); } - inline qint64 readBlock(char *data, quint64 maxlen) { return read(data, maxlen); } - inline qint64 writeBlock(const char *data, quint64 len) { return write(data, len); } - inline qint64 writeBlock(const QByteArray &data) { return write(data); } - -// virtual inline qint64 readData ( char * data, qint64 maxSize ) { return readBlock(data, maxSize); } -// virtual inline qint64 writeData ( const char * data, qint64 maxSize ) { return writeBlock(data, maxSize); } - - inline int getch() { char c; return getChar(&c) ? int(uchar(c)) : -1; } - inline int putch(int c) { return putChar(char(c)) ? int(uchar(c)) : -1; } - inline int ungetch(int c) { ungetChar(uchar(c)); return c; } - virtual void flush() = 0; - - inline bool isDirectAccess() const { return !isSequential(); } - inline bool isSequentialAccess() const { return isSequential(); } - inline bool isCombinedAccess() const { return false; } - inline bool isBuffered() const { return true; } - inline bool isRaw() const { return false; } - inline bool isSynchronous() const { return true; } - inline bool isAsynchronous() const { return false; } - inline bool isTranslated() const { return (openMode() & Text) != 0; } - inline bool isInactive() const { return !isOpen(); } - -// inline bool open( int mode ) = 0; - -protected: - void setFlags( int f ) { setOpenMode((QIODevice::OpenModeFlag)f); } - void setType( int ) { printf("[WARNING] TQIODevice::setType() unimplemented\n\r"); } - void setMode( int f ) { setOpenMode((QIODevice::OpenModeFlag)f); } - void setState( int state ) { - switch (state) { - case (IO_Open): - QIODevice::open(openMode()); - break; - } - } - -public: - typedef int Status; - Status status() const { -#if !defined(QT_NO_QOBJECT) - const QFile *f = qobject_cast(this); - if (f) return (int) f->error(); -#endif - return isOpen() ? 0 /* IO_Ok */ : 8 /* IO_UnspecifiedError */; - } - void resetStatus() { -#if !defined(QT_NO_QOBJECT) - QFile *f = qobject_cast(this); - if (f) f->unsetError(); -#endif - } - -protected: - void setqStatus( int ) { std::cout << "[WARNING] TQIODevice::setqStatus() UNIMPLEMENTED\n\r"; } - void resetqStatus() { resetStatus(); } - - friend class TQFile; - friend class TQIODeviceSource; - friend class TQImageIO; - -public: - // Interoperability - static TQIODevice& convertFromQIODevice( QIODevice& qiod ); -}; - -// Interoperability -inline static TQIODevice& convertFromQIODevice( QIODevice& qiod ) { - return (*static_cast(&qiod)); -} - -#else // USE_QT4 - -// IO tqdevice access types - -#define IO_Direct 0x0100 // direct access tqdevice -#define IO_Sequential 0x0200 // sequential access tqdevice -#define IO_Combined 0x0300 // combined direct/sequential -#define IO_TypeMask 0x0f00 - -// IO handling modes - -#define IO_Raw 0x0040 // raw access (not buffered) -#define IO_Async 0x0080 // asynchronous mode - -// IO tqdevice open modes - -#define IO_ReadOnly 0x0001 // readable tqdevice -#define IO_WriteOnly 0x0002 // writable tqdevice -#define IO_ReadWrite 0x0003 // read+write tqdevice -#define IO_Append 0x0004 // append -#define IO_Truncate 0x0008 // truncate tqdevice -#define IO_Translate 0x0010 // translate CR+LF -#define IO_ModeMask 0x00ff - -// IO tqdevice state - -#define IO_Open 0x1000 // tqdevice is open -#define IO_StateMask 0xf000 - -// IO tqdevice status - -#define IO_Ok 0 -#define IO_ReadError 1 // read error -#define IO_WriteError 2 // write error -#define IO_FatalError 3 // fatal unrecoverable error -#define IO_ResourceError 4 // resource limitation -#define IO_OpenError 5 // cannot open tqdevice -#define IO_ConnectError 5 // cannot connect to tqdevice -#define IO_AbortError 6 // abort error -#define IO_TimeOutError 7 // time out -#define IO_UnspecifiedError 8 // unspecified error - - -class TQ_EXPORT TQIODevice -{ -public: -#if defined(TQT_ABI_QT4) - typedef TQ_LLONG Offset; -#else - typedef TQ_ULONG Offset; -#endif - - TQIODevice(); - virtual ~TQIODevice(); - - int flags() const { return ioMode; } - int mode() const { return ioMode & IO_ModeMask; } - int state() const { return ioMode & IO_StateMask; } - - bool isDirectAccess() const { return ((ioMode & IO_Direct) == IO_Direct); } - bool isSequentialAccess() const { return ((ioMode & IO_Sequential) == IO_Sequential); } - bool isCombinedAccess() const { return ((ioMode & IO_Combined) == IO_Combined); } - bool isBuffered() const { return ((ioMode & IO_Raw) != IO_Raw); } - bool isRaw() const { return ((ioMode & IO_Raw) == IO_Raw); } - bool isSynchronous() const { return ((ioMode & IO_Async) != IO_Async); } - bool isAsynchronous() const { return ((ioMode & IO_Async) == IO_Async); } - bool isTranslated() const { return ((ioMode & IO_Translate) == IO_Translate); } - bool isReadable() const { return ((ioMode & IO_ReadOnly) == IO_ReadOnly); } - bool isWritable() const { return ((ioMode & IO_WriteOnly) == IO_WriteOnly); } - bool isReadWrite() const { return ((ioMode & IO_ReadWrite) == IO_ReadWrite); } - bool isInactive() const { return state() == 0; } - bool isOpen() const { return state() == IO_Open; } - - int status() const { return ioSt; } - void resetqStatus() { ioSt = IO_Ok; } - - virtual bool open( int mode ) = 0; - virtual void close() = 0; - virtual void flush() = 0; - - virtual Offset size() const = 0; - virtual Offset at() const; - virtual bool at( Offset ); - virtual bool atEnd() const; - bool reset() { return at(0); } - - virtual TQ_LONG readBlock( char *data, TQ_ULONG maxlen ) = 0; - virtual TQ_LONG writeBlock( const char *data, TQ_ULONG len ) = 0; - virtual TQ_LONG readLine( char *data, TQ_ULONG maxlen ); - TQ_LONG writeBlock( const TQByteArray& data ); - virtual TQByteArray readAll(); - - virtual int getch() = 0; - virtual int putch( int ) = 0; - virtual int ungetch( int ) = 0; - -protected: - void setFlags( int f ) { ioMode = f; } - void setType( int ); - void setMode( int ); - void setState( int ); - void setqStatus( int ); - Offset ioIndex; - -private: - int ioMode; - int ioSt; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQIODevice( const TQIODevice & ); - TQIODevice &operator=( const TQIODevice & ); -#endif -}; - -#endif // USE_QT4 - -#endif // TQIODEVICE_H