From 8ac0e970e4464d9f8f73c0fb34a178ff135be8c3 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 2 Jun 2024 23:07:22 +0900 Subject: Rename ntqwidget* related files to equivalent tqwidget* Signed-off-by: Michele Calgaro --- src/kernel/ntqdesktopwidget.h | 2 +- src/kernel/ntqfocusdata.h | 2 +- src/kernel/ntqlayout.h | 2 +- src/kernel/ntqnamespace.h | 14 +- src/kernel/ntqsizegrip.h | 2 +- src/kernel/ntqt.h | 14 +- src/kernel/ntqwidget.h | 1096 ------- src/kernel/ntqwidgetintdict.h | 75 - src/kernel/ntqwidgetlist.h | 67 - src/kernel/ntqwindowdefs.h | 2 +- src/kernel/qaccel.cpp | 2 +- src/kernel/qapplication.cpp | 8 +- src/kernel/qapplication_p.h | 2 +- src/kernel/qapplication_x11.cpp | 10 +- src/kernel/qdesktopwidget_x11.cpp | 2 +- src/kernel/qdnd_x11.cpp | 2 +- src/kernel/qdragobject.cpp | 2 +- src/kernel/qdropsite.cpp | 2 +- src/kernel/qfontengine_x11.cpp | 2 +- src/kernel/qinputcontext.cpp | 2 +- src/kernel/qinputcontext_x11.cpp | 2 +- src/kernel/qinternal.cpp | 2 +- src/kernel/qlayout.cpp | 2 +- src/kernel/qmotifdnd_x11.cpp | 2 +- src/kernel/qpaintdevice_x11.cpp | 2 +- src/kernel/qpainter.cpp | 2 +- src/kernel/qpainter_x11.cpp | 2 +- src/kernel/qpixmap.cpp | 2 +- src/kernel/qsizegrip.cpp | 2 +- src/kernel/qstyle.cpp | 2 +- src/kernel/qt_kernel.pri | 16 +- src/kernel/qt_pch.h | 2 +- src/kernel/qtranslator.cpp | 2 +- src/kernel/qwidget.cpp | 6122 ------------------------------------- src/kernel/qwidget_p.h | 64 - src/kernel/qwidget_x11.cpp | 3172 ------------------- src/kernel/qwidgetcreate_x11.cpp | 74 - src/kernel/tqwidget.cpp | 6122 +++++++++++++++++++++++++++++++++++++ src/kernel/tqwidget.h | 1096 +++++++ src/kernel/tqwidget_p.h | 64 + src/kernel/tqwidget_x11.cpp | 3172 +++++++++++++++++++ src/kernel/tqwidgetcreate_x11.cpp | 74 + src/kernel/tqwidgetintdict.h | 75 + src/kernel/tqwidgetlist.h | 67 + 44 files changed, 10726 insertions(+), 10726 deletions(-) delete mode 100644 src/kernel/ntqwidget.h delete mode 100644 src/kernel/ntqwidgetintdict.h delete mode 100644 src/kernel/ntqwidgetlist.h delete mode 100644 src/kernel/qwidget.cpp delete mode 100644 src/kernel/qwidget_p.h delete mode 100644 src/kernel/qwidget_x11.cpp delete mode 100644 src/kernel/qwidgetcreate_x11.cpp create mode 100644 src/kernel/tqwidget.cpp create mode 100644 src/kernel/tqwidget.h create mode 100644 src/kernel/tqwidget_p.h create mode 100644 src/kernel/tqwidget_x11.cpp create mode 100644 src/kernel/tqwidgetcreate_x11.cpp create mode 100644 src/kernel/tqwidgetintdict.h create mode 100644 src/kernel/tqwidgetlist.h (limited to 'src/kernel') diff --git a/src/kernel/ntqdesktopwidget.h b/src/kernel/ntqdesktopwidget.h index de199f31e..a017b8aca 100644 --- a/src/kernel/ntqdesktopwidget.h +++ b/src/kernel/ntqdesktopwidget.h @@ -40,7 +40,7 @@ #define TQDESKTOPWIDGET_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H class TQApplication; diff --git a/src/kernel/ntqfocusdata.h b/src/kernel/ntqfocusdata.h index 29c804c20..f6eb57fe3 100644 --- a/src/kernel/ntqfocusdata.h +++ b/src/kernel/ntqfocusdata.h @@ -42,7 +42,7 @@ #define TQFOCUSDATA_H #ifndef QT_H -#include "ntqwidgetlist.h" +#include "tqwidgetlist.h" #endif // QT_H diff --git a/src/kernel/ntqlayout.h b/src/kernel/ntqlayout.h index 9ff6615a9..9465e2788 100644 --- a/src/kernel/ntqlayout.h +++ b/src/kernel/ntqlayout.h @@ -44,7 +44,7 @@ #ifndef QT_H #include "tqobject.h" #include "ntqsizepolicy.h" -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #include diff --git a/src/kernel/ntqnamespace.h b/src/kernel/ntqnamespace.h index 5ce38f835..abc3bfb8b 100644 --- a/src/kernel/ntqnamespace.h +++ b/src/kernel/ntqnamespace.h @@ -139,10 +139,10 @@ public: NoAccel = 0x4000 }; - // Widget flags; documented in qwidget.cpp + // Widget flags; documented in tqwidget.cpp typedef uint WState; - // TQWidget state flags (internal, barely documented in qwidget.cpp) + // TQWidget state flags (internal, barely documented in tqwidget.cpp) enum WidgetState { WState_Created = 0x00000001, WState_Disabled = 0x00000002, @@ -170,10 +170,10 @@ public: WState_HasMouse = 0x00800000 }; - // NetWM flags; documented in qwidget.cpp + // NetWM flags; documented in tqwidget.cpp typedef uint NFlags; - // documented in qwidget.cpp + // documented in tqwidget.cpp enum NETWMFlags { #if defined(TQ_WS_X11) WX11DisableMove = 0x00000001, @@ -192,10 +192,10 @@ public: #endif }; - // Widget flags2; documented in qwidget.cpp + // Widget flags2; documented in tqwidget.cpp typedef uint WFlags; - // documented in qwidget.cpp + // documented in tqwidget.cpp enum WidgetFlags { WType_TopLevel = 0x00000001, // widget type flags WType_Dialog = 0x00000002, @@ -962,7 +962,7 @@ public: UTC }; - // documented in qwidget.cpp + // documented in tqwidget.cpp enum BackgroundMode { FixedColor, FixedPixmap, diff --git a/src/kernel/ntqsizegrip.h b/src/kernel/ntqsizegrip.h index 93e95aade..624fb6498 100644 --- a/src/kernel/ntqsizegrip.h +++ b/src/kernel/ntqsizegrip.h @@ -42,7 +42,7 @@ #define TQSIZEGRIP_H #ifndef QT_H -#include "ntqwidget.h" +#include "tqwidget.h" #endif // QT_H #ifndef TQT_NO_SIZEGRIP diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index 78ff48a19..d6671bee8 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -63,7 +63,7 @@ #include #include "ntqbrush.h" #include "ntqpalette.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqjpunicode.h" #include "ntqtextcodec.h" #include "ntqpixmap.h" @@ -76,7 +76,7 @@ #include "ntqfile.h" #include "ntqfileinfo.h" #include "ntqurlinfo.h" -#include "ntqwidgetlist.h" +#include "tqwidgetlist.h" #include #include "ntqgroupbox.h" #include "ntqdialog.h" @@ -261,10 +261,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include #include @@ -305,8 +305,8 @@ #include "private/qsettings_p.h" #include "private/tqsqlextension_p.h" #include "private/qdialogbuttons_p.h" -#include "private/qwidgetinterface_p.h" -#include "private/qwidgetresizehandler_p.h" +#include "private/tqwidgetinterface_p.h" +#include "private/tqwidgetresizehandler_p.h" #include "private/qlibrary_p.h" #endif // Private headers diff --git a/src/kernel/ntqwidget.h b/src/kernel/ntqwidget.h deleted file mode 100644 index d328dd95d..000000000 --- a/src/kernel/ntqwidget.h +++ /dev/null @@ -1,1096 +0,0 @@ -/**************************************************************************** -** -** Definition of TQWidget class -** -** Created : 931029 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQWIDGET_H -#define TQWIDGET_H - -#ifndef QT_H -#include "ntqwindowdefs.h" -#include "tqobject.h" -#include "ntqpaintdevice.h" -#include "ntqpalette.h" -#include "ntqfont.h" -#include "ntqfontmetrics.h" -#include "ntqfontinfo.h" -#include "ntqsizepolicy.h" -#endif // QT_H - -#if defined(TQ_WS_X11) -class TQInputContext; -#endif - -class TQLayout; -struct TQWExtra; -struct TQTLWExtra; -class TQFocusData; -class TQCursor; -class TQWSRegionManager; -class TQStyle; -class TQStyleControlElementData; - -class TQ_EXPORT TQWidget : public TQObject, public TQPaintDevice -{ - TQ_OBJECT - TQ_ENUMS( BackgroundMode FocusPolicy BackgroundOrigin ) - TQ_PROPERTY( bool isTopLevel READ isTopLevel ) - TQ_PROPERTY( bool isDialog READ isDialog ) - TQ_PROPERTY( bool isModal READ isModal ) - TQ_PROPERTY( bool isPopup READ isPopup ) - TQ_PROPERTY( bool isDesktop READ isDesktop ) - TQ_PROPERTY( bool enabled READ isEnabled WRITE setEnabled ) - TQ_PROPERTY( TQRect geometry READ geometry WRITE setGeometry ) - TQ_PROPERTY( TQRect frameGeometry READ frameGeometry ) - TQ_PROPERTY( int x READ x ) - TQ_PROPERTY( int y READ y ) - TQ_PROPERTY( TQPoint pos READ pos WRITE move DESIGNABLE false STORED false ) - TQ_PROPERTY( TQSize frameSize READ frameSize ) - TQ_PROPERTY( TQSize size READ size WRITE resize DESIGNABLE false STORED false ) - TQ_PROPERTY( int width READ width ) - TQ_PROPERTY( int height READ height ) - TQ_PROPERTY( TQRect rect READ rect ) - TQ_PROPERTY( TQRect childrenRect READ childrenRect ) - TQ_PROPERTY( TQRegion childrenRegion READ childrenRegion ) - TQ_PROPERTY( TQSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy ) - TQ_PROPERTY( TQSize minimumSize READ minimumSize WRITE setMinimumSize ) - TQ_PROPERTY( TQSize maximumSize READ maximumSize WRITE setMaximumSize ) - TQ_PROPERTY( int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false ) - TQ_PROPERTY( int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false ) - TQ_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false ) - TQ_PROPERTY( int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false ) - TQ_PROPERTY( TQSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement ) - TQ_PROPERTY( TQSize baseSize READ baseSize WRITE setBaseSize ) - TQ_PROPERTY( BackgroundMode backgroundMode READ backgroundMode WRITE setBackgroundMode DESIGNABLE false ) - TQ_PROPERTY( TQColor paletteForegroundColor READ paletteForegroundColor WRITE setPaletteForegroundColor RESET unsetPalette ) - TQ_PROPERTY( TQColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor RESET unsetPalette ) - TQ_PROPERTY( TQPixmap paletteBackgroundPixmap READ paletteBackgroundPixmap WRITE setPaletteBackgroundPixmap RESET unsetPalette ) - TQ_PROPERTY( TQBrush backgroundBrush READ backgroundBrush ) - TQ_PROPERTY( TQColorGroup colorGroup READ colorGroup ) - TQ_PROPERTY( TQPalette palette READ palette WRITE setPalette RESET unsetPalette STORED ownPalette ) - TQ_PROPERTY( BackgroundOrigin backgroundOrigin READ backgroundOrigin WRITE setBackgroundOrigin ) - TQ_PROPERTY( bool ownPalette READ ownPalette ) - TQ_PROPERTY( TQFont font READ font WRITE setFont RESET unsetFont STORED ownFont ) - TQ_PROPERTY( bool ownFont READ ownFont ) -#ifndef TQT_NO_CURSOR - TQ_PROPERTY( TQCursor cursor READ cursor WRITE setCursor RESET unsetCursor STORED ownCursor ) - TQ_PROPERTY( bool ownCursor READ ownCursor ) -#endif -#ifndef TQT_NO_WIDGET_TOPEXTRA - TQ_PROPERTY( TQString caption READ caption WRITE setCaption ) - TQ_PROPERTY( TQPixmap icon READ icon WRITE setIcon ) - TQ_PROPERTY( TQString iconText READ iconText WRITE setIconText ) -#endif - TQ_PROPERTY( bool mouseTracking READ hasMouseTracking WRITE setMouseTracking ) - TQ_PROPERTY( bool underMouse READ hasMouse ) - TQ_PROPERTY( bool isActiveWindow READ isActiveWindow ) - TQ_PROPERTY( bool focusEnabled READ isFocusEnabled ) - TQ_PROPERTY( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy ) - TQ_PROPERTY( bool focus READ hasFocus ) - TQ_PROPERTY( bool updatesEnabled READ isUpdatesEnabled WRITE setUpdatesEnabled DESIGNABLE false ) - TQ_PROPERTY( bool visible READ isVisible ) - TQ_PROPERTY( TQRect visibleRect READ visibleRect ) // obsolete - TQ_PROPERTY( bool hidden READ isHidden WRITE setHidden DESIGNABLE false SCRIPTABLE false ) - TQ_PROPERTY( bool shown READ isShown WRITE setShown DESIGNABLE false SCRIPTABLE false ) - TQ_PROPERTY( bool minimized READ isMinimized ) - TQ_PROPERTY( bool maximized READ isMaximized ) - TQ_PROPERTY( bool fullScreen READ isFullScreen ) - TQ_PROPERTY( TQSize sizeHint READ sizeHint ) - TQ_PROPERTY( TQSize minimumSizeHint READ minimumSizeHint ) - TQ_PROPERTY( TQRect microFocusHint READ microFocusHint ) - TQ_PROPERTY( bool acceptDrops READ acceptDrops WRITE setAcceptDrops ) - TQ_PROPERTY( bool autoMask READ autoMask WRITE setAutoMask DESIGNABLE false SCRIPTABLE false ) - TQ_PROPERTY( bool customWhatsThis READ customWhatsThis ) - TQ_PROPERTY( bool inputMethodEnabled READ isInputMethodEnabled WRITE setInputMethodEnabled DESIGNABLE false SCRIPTABLE false ) - TQ_PROPERTY( double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE false ) - -public: - Q_EXPLICIT TQWidget( TQWidget* parent=0, const char* name=0, WFlags f=0, NFlags n=0 ); - ~TQWidget(); - - WId winId() const; - void setName( const char *name ); -#ifndef TQT_NO_STYLE - // GUI style setting - - TQStyle &style() const; - void setStyle( TQStyle * ); - TQStyle* setStyle( const TQString& ); -#endif - // Widget types and states - - bool isTopLevel() const; - bool isDialog() const; - bool isPopup() const; - bool isDesktop() const; - bool isModal() const; - - bool isEnabled() const; - bool isEnabledTo(TQWidget*) const; - bool isEnabledToTLW() const; - -public slots: - virtual void setEnabled( bool ); - void setDisabled( bool ); - - // Widget coordinates - -public: - TQRect frameGeometry() const; - const TQRect &geometry() const; - int x() const; - int y() const; - TQPoint pos() const; - TQSize frameSize() const; - TQSize size() const; - int width() const; - int height() const; - TQRect rect() const; - TQRect childrenRect() const; - TQRegion childrenRegion() const; - - TQSize minimumSize() const; - TQSize maximumSize() const; - int minimumWidth() const; - int minimumHeight() const; - int maximumWidth() const; - int maximumHeight() const; - void setMinimumSize( const TQSize & ); - virtual void setMinimumSize( int minw, int minh ); - void setMaximumSize( const TQSize & ); - virtual void setMaximumSize( int maxw, int maxh ); - void setMinimumWidth( int minw ); - void setMinimumHeight( int minh ); - void setMaximumWidth( int maxw ); - void setMaximumHeight( int maxh ); - - TQSize sizeIncrement() const; - void setSizeIncrement( const TQSize & ); - virtual void setSizeIncrement( int w, int h ); - TQSize baseSize() const; - void setBaseSize( const TQSize & ); - void setBaseSize( int basew, int baseh ); - - void setFixedSize( const TQSize & ); - void setFixedSize( int w, int h ); - void setFixedWidth( int w ); - void setFixedHeight( int h ); - - // Widget coordinate mapping - - TQPoint mapToGlobal( const TQPoint & ) const; - TQPoint mapFromGlobal( const TQPoint & ) const; - TQPoint mapToParent( const TQPoint & ) const; - TQPoint mapFromParent( const TQPoint & ) const; - TQPoint mapTo( TQWidget *, const TQPoint & ) const; - TQPoint mapFrom( TQWidget *, const TQPoint & ) const; - - TQWidget *topLevelWidget() const; - - // Widget attribute functions - - BackgroundMode backgroundMode() const; - virtual void setBackgroundMode( BackgroundMode ); - void setBackgroundMode( BackgroundMode, BackgroundMode ); - - const TQColor & foregroundColor() const; - - const TQColor & eraseColor() const; - virtual void setEraseColor( const TQColor & ); - - const TQPixmap * erasePixmap() const; - virtual void setErasePixmap( const TQPixmap & ); - -#ifndef TQT_NO_PALETTE - const TQColorGroup & colorGroup() const; - const TQPalette & palette() const; - bool ownPalette() const; - virtual void setPalette( const TQPalette & ); - void unsetPalette(); -#endif - - const TQColor & paletteForegroundColor() const; - void setPaletteForegroundColor( const TQColor & ); - - const TQColor & paletteBackgroundColor() const; - virtual void setPaletteBackgroundColor( const TQColor & ); - - const TQPixmap * paletteBackgroundPixmap() const; - virtual void setPaletteBackgroundPixmap( const TQPixmap & ); - - const TQBrush& backgroundBrush() const; - - TQFont font() const; - bool ownFont() const; - virtual void setFont( const TQFont & ); - void unsetFont(); - TQFontMetrics fontMetrics() const; - TQFontInfo fontInfo() const; - -#ifndef TQT_NO_CURSOR - const TQCursor &cursor() const; - bool ownCursor() const; - virtual void setCursor( const TQCursor & ); - virtual void unsetCursor(); -#endif -#ifndef TQT_NO_WIDGET_TOPEXTRA - TQString caption() const; - const TQPixmap *icon() const; - TQString iconText() const; -#endif - bool hasMouseTracking() const; - bool hasMouse() const; - - virtual void setMask( const TQBitmap & ); - virtual void setMask( const TQRegion & ); - void clearMask(); - - const TQColor & backgroundColor() const; // obsolete, use eraseColor() - virtual void setBackgroundColor( const TQColor & ); // obsolete, use setEraseColor() - const TQPixmap * backgroundPixmap() const; // obsolete, use erasePixmap() - virtual void setBackgroundPixmap( const TQPixmap & ); // obsolete, use setErasePixmap() - -public slots: -#ifndef TQT_NO_WIDGET_TOPEXTRA - virtual void setCaption( const TQString &); - virtual void setIcon( const TQPixmap & ); - virtual void setIconText( const TQString &); -#endif - virtual void setMouseTracking( bool enable ); - - // Keyboard input focus functions - - virtual void setFocus(); - void clearFocus(); - -public: - enum FocusPolicy { - NoFocus = 0, - TabFocus = 0x1, - ClickFocus = 0x2, - StrongFocus = TabFocus | ClickFocus | 0x8, - WheelFocus = StrongFocus | 0x4 - }; - - bool isActiveWindow() const; - virtual void setActiveWindow(); - bool isFocusEnabled() const; - - FocusPolicy focusPolicy() const; - virtual void setFocusPolicy( FocusPolicy ); - bool hasFocus() const; - static void setTabOrder( TQWidget *, TQWidget * ); - virtual void setFocusProxy( TQWidget * ); - TQWidget * focusProxy() const; - - void setInputMethodEnabled( bool b ); - bool isInputMethodEnabled() const; - // Grab functions - - void grabMouse(); -#ifndef TQT_NO_CURSOR - void grabMouse( const TQCursor & ); -#endif - void releaseMouse(); - void grabKeyboard(); - void releaseKeyboard(); - static TQWidget * mouseGrabber(); - static TQWidget * keyboardGrabber(); - - // Update/refresh functions - - bool isUpdatesEnabled() const; - -#if 0 //def TQ_WS_QWS - void repaintUnclipped( const TQRegion &, bool erase = TRUE ); -#endif -public slots: - virtual void setUpdatesEnabled( bool enable ); - void update(); - void update( int x, int y, int w, int h ); - void update( const TQRect& ); - void repaint(); - void repaint( bool erase ); - void repaint( int x, int y, int w, int h, bool erase=TRUE ); - void repaint( const TQRect &, bool erase = TRUE ); - void repaint( const TQRegion &, bool erase = TRUE ); - - // Widget management functions - - virtual void show(); - virtual void hide(); - void setShown( bool show ); - void setHidden( bool hide ); -#ifndef TQT_NO_COMPAT - void iconify() { showMinimized(); } -#endif - virtual void showMinimized(); - virtual void showMaximized(); - void showFullScreen(); - virtual void showNormal(); - virtual void polish(); - void constPolish() const; - bool close(); - - void raise(); - void lower(); - void stackUnder( TQWidget* ); - virtual void move( int x, int y ); - void move( const TQPoint & ); - virtual void resize( int w, int h ); - void resize( const TQSize & ); - virtual void setGeometry( int x, int y, int w, int h ); - virtual void setGeometry( const TQRect & ); // ### make non virtual in TQt 4? - -public: - virtual bool close( bool alsoDelete ); - bool isVisible() const; - bool isVisibleTo(TQWidget*) const; - bool isVisibleToTLW() const; // obsolete - TQRect visibleRect() const; // obsolete - bool isHidden() const; - bool isShown() const; - bool isMinimized() const; - bool isMaximized() const; - bool isFullScreen() const; - - uint windowState() const; - void setWindowState(uint windowState); - - virtual TQSize sizeHint() const; - virtual TQSize minimumSizeHint() const; - virtual TQSizePolicy sizePolicy() const; - virtual void setSizePolicy( TQSizePolicy ); - void setSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw = FALSE ); - virtual int heightForWidth(int) const; - - TQRegion clipRegion() const; - -// ### move together with other slots in TQt 4.0 -public slots: - virtual void adjustSize(); - -public: -#ifndef TQT_NO_LAYOUT - TQLayout * layout() const { return lay_out; } -#endif - void updateGeometry(); - virtual void reparent( TQWidget *parent, WFlags, const TQPoint &, - bool showIt=FALSE ); - void reparent( TQWidget *parent, const TQPoint &, - bool showIt=FALSE ); -#ifndef TQT_NO_COMPAT - void recreate( TQWidget *parent, WFlags f, const TQPoint & p, - bool showIt=FALSE ) { reparent(parent,f,p,showIt); } -#endif - - void erase(); - void erase( int x, int y, int w, int h ); - void erase( const TQRect & ); - void erase( const TQRegion & ); - void scroll( int dx, int dy ); - void scroll( int dx, int dy, const TQRect& ); - - void drawText( int x, int y, const TQString &); - void drawText( const TQPoint &, const TQString &); - - // Misc. functions - - TQWidget * focusWidget() const; - TQRect microFocusHint() const; - - // drag and drop - - bool acceptDrops() const; - virtual void setAcceptDrops( bool on ); - - // transparency and pseudo transparency - - virtual void setAutoMask(bool); - bool autoMask() const; - - enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin }; - - virtual void setBackgroundOrigin( BackgroundOrigin ); - BackgroundOrigin backgroundOrigin() const; - TQPoint backgroundOffset() const; - - // whats this help - virtual bool customWhatsThis() const; - - TQWidget * parentWidget( bool sameWindow = FALSE ) const; - WState testWState( WState s ) const; - WFlags testWFlags( WFlags f ) const; - NFlags testNFlags( NFlags f ) const; - uint getWState() const; - WFlags getWFlags() const; - NFlags getNFlags() const; - static TQWidget * find( WId ); - static TQWidgetMapper *wmapper(); - - TQWidget *childAt( int x, int y, bool includeThis = FALSE ) const; - TQWidget *childAt( const TQPoint &, bool includeThis = FALSE ) const; - -#if defined(TQ_WS_QWS) - virtual TQGfx * graphicsContext(bool clip_children=TRUE) const; -#endif -#if defined(TQ_WS_MAC) - TQRegion clippedRegion(bool do_children=TRUE); - uint clippedSerial(bool do_children=TRUE); -#ifndef TQMAC_NO_QUARTZ - CGContextRef macCGContext(bool clipped=TRUE) const; -#endif -#endif -#if defined(TQ_WS_X11) - enum X11WindowType { - X11WindowTypeSelect, - X11WindowTypeCombo, - X11WindowTypeDND, - X11WindowTypeTooltip, - X11WindowTypeMenu, // torn-off - X11WindowTypeDropdown, - X11WindowTypePopup - }; - void x11SetWindowType( X11WindowType type = X11WindowTypeSelect ); - void x11SetWindowTransient( TQWidget* parent ); -#endif - void setWindowOpacity(double level); - double windowOpacity() const; - -protected: - // Event handlers - bool event( TQEvent * ); - virtual void mousePressEvent( TQMouseEvent * ); - virtual void mouseReleaseEvent( TQMouseEvent * ); - virtual void mouseDoubleClickEvent( TQMouseEvent * ); - virtual void mouseMoveEvent( TQMouseEvent * ); -#ifndef TQT_NO_WHEELEVENT - virtual void wheelEvent( TQWheelEvent * ); -#endif - virtual void keyPressEvent( TQKeyEvent * ); - virtual void keyReleaseEvent( TQKeyEvent * ); - virtual void focusInEvent( TQFocusEvent * ); - virtual void focusOutEvent( TQFocusEvent * ); - virtual void enterEvent( TQEvent * ); - virtual void leaveEvent( TQEvent * ); - virtual void paintEvent( TQPaintEvent * ); - virtual void moveEvent( TQMoveEvent * ); - virtual void resizeEvent( TQResizeEvent * ); - virtual void closeEvent( TQCloseEvent * ); - virtual void contextMenuEvent( TQContextMenuEvent * ); - virtual void imStartEvent( TQIMEvent * ); - virtual void imComposeEvent( TQIMEvent * ); - virtual void imEndEvent( TQIMEvent * ); - virtual void tabletEvent( TQTabletEvent * ); - -#ifndef TQT_NO_DRAGANDDROP - virtual void dragEnterEvent( TQDragEnterEvent * ); - virtual void dragMoveEvent( TQDragMoveEvent * ); - virtual void dragLeaveEvent( TQDragLeaveEvent * ); - virtual void dropEvent( TQDropEvent * ); -#endif - - virtual void showEvent( TQShowEvent * ); - virtual void hideEvent( TQHideEvent * ); - -#if defined(TQ_WS_MAC) - virtual bool macEvent( MSG * ); -#endif -#if defined(TQ_WS_WIN) - virtual bool winEvent( MSG * ); -#endif -#if defined(TQ_WS_X11) - virtual bool x11Event( XEvent * ); -#endif -#if defined(TQ_WS_QWS) - virtual bool qwsEvent( TQWSEvent * ); - virtual unsigned char *scanLine( int ) const; - virtual int bytesPerLine() const; -#endif - - virtual void updateMask(); - - // Misc. protected functions - -#ifndef TQT_NO_STYLE - virtual void styleChange( TQStyle& ); -#endif - virtual void enabledChange( bool oldEnabled ); -#ifndef TQT_NO_PALETTE - virtual void paletteChange( const TQPalette & ); -#endif - virtual void fontChange( const TQFont & ); - virtual void windowActivationChange( bool oldActive ); - - int metric( int ) const; - -#if defined(TQ_WS_X11) -#if !defined(TQT_NO_IM_EXTENSIONS) - virtual TQWidget *icHolderWidget(); -#else - TQWidget *icHolderWidget(); -#endif - TQInputContext *getInputContext(); - void changeInputContext( const TQString & ); - void sendMouseEventToInputContext( int x, TQEvent::Type type, - TQt::ButtonState button, - TQt::ButtonState state ); -#endif - void resetInputContext(); - - virtual void create( WId = 0, bool initializeWindow = TRUE, - bool destroyOldWindow = TRUE ); - virtual void destroy( bool destroyWindow = TRUE, - bool destroySubWindows = TRUE ); - virtual void setWState( uint ); - void clearWState( uint n ); - virtual void setWFlags( WFlags ); - void clearWFlags( WFlags n ); - virtual void setNFlags( NFlags ); - void clearNFlags( NFlags n ); - - virtual bool focusNextPrevChild( bool next ); - - TQWExtra *extraData(); - TQTLWExtra *topData(); - TQFocusData *focusData(); - - virtual void setKeyCompression(bool); - virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, TQFont *f = 0); - -#if defined(TQ_WS_MAC) - void dirtyClippedRegion(bool); - bool isClippedRegionDirty(); - virtual void setRegionDirty(bool); - virtual void macWidgetChangedWindow(); -#endif - -private slots: - void focusProxyDestroyed(); -#if defined(TQ_WS_X11) - void destroyInputContext(); -#endif - -private: - void setFontSys( TQFont *f = 0 ); -#if defined(TQ_WS_X11) - void createInputContext(); - void focusInputContext(); - void unfocusInputContext(); - void checkChildrenDnd(); - -#ifndef TQT_NO_XSYNC - void createSyncCounter(); - void destroySyncCounter(); - void incrementSyncCounter(); - void handleSyncRequest( void* ev ); -#endif - -#elif defined(TQ_WS_MAC) - uint own_id : 1, macDropEnabled : 1; - EventHandlerRef window_event; - //mac event functions - void propagateUpdates(bool update_rgn=TRUE); - void update( const TQRegion& ); - //friends, way too many - fix this immediately! - friend void qt_clean_root_win(); - friend bool qt_recreate_root_win(); - friend TQPoint posInWindow(TQWidget *); - friend bool qt_mac_update_sizer(TQWidget *, int); - friend TQWidget *qt_recursive_match(TQWidget *widg, int x, int y); - friend bool qt_paint_children(TQWidget *,TQRegion &, uchar ops); - friend TQMAC_PASCAL OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *); - friend void qt_event_request_updates(TQWidget *, const TQRegion &, bool subtract); - friend bool qt_window_rgn(WId, short, RgnHandle, bool); - friend class TQDragManager; -#endif - -#ifndef TQT_NO_LAYOUT - void setLayout( TQLayout *l ); -#endif - void setWinId( WId ); - void showWindow(); - void hideWindow(); - void showChildren( bool spontaneous ); - void hideChildren( bool spontaneous ); - void reparentSys( TQWidget *parent, WFlags, const TQPoint &, bool showIt); - void createTLExtra(); - void createExtra(); - void deleteExtra(); - void createSysExtra(); - void deleteSysExtra(); - void createTLSysExtra(); - void deleteTLSysExtra(); - void deactivateWidgetCleanup(); - void internalSetGeometry( int, int, int, int, bool ); - void reparentFocusWidgets( TQWidget * ); - TQFocusData *focusData( bool create ); - void setBackgroundFromMode(); - void setBackgroundColorDirect( const TQColor & ); - void setBackgroundPixmapDirect( const TQPixmap & ); - void setBackgroundModeDirect( BackgroundMode ); - void setBackgroundEmpty(); - void updateFrameStrut() const; -#if defined(TQ_WS_X11) - void setBackgroundX11Relative(); -#endif - - WId winid; - uint widget_state; - uint widget_flags; - uint netwm_flags; - uint reserved_1; - uint reserved_2; - uint reserved_3; - uint reserved_4; - uint focus_policy : 4; - uint own_font :1; - uint own_palette :1; - uint sizehint_forced :1; - uint is_closing :1; - uint in_show : 1; - uint in_show_maximized : 1; - uint fstrut_dirty : 1; - uint im_enabled : 1; - TQRect crect; - TQColor bg_col; -#ifndef TQT_NO_PALETTE - TQPalette pal; -#endif - TQFont fnt; -#ifndef TQT_NO_LAYOUT - TQLayout *lay_out; -#endif -#if defined(TQ_WS_X11) && !defined(TQT_NO_IM) && !defined(TQT_NO_IM_EXTENSIONS) - TQInputContext *ic; // Input Context -#endif - TQWExtra *extra; -#if defined(TQ_WS_QWS) - TQRegion req_region; // Requested region - mutable TQRegion paintable_region; // Paintable region - mutable bool paintable_region_dirty;// needs to be recalculated - mutable TQRegion alloc_region; // Allocated region - mutable bool alloc_region_dirty; // needs to be recalculated - mutable int overlapping_children; // Handle overlapping children - - int alloc_region_index; - int alloc_region_revision; - - void updateOverlappingChildren() const; - void setChildrenAllocatedDirty(); - void setChildrenAllocatedDirty( const TQRegion &r, const TQWidget *dirty=0 ); - bool isAllocatedRegionDirty() const; - void updateRequestedRegion( const TQPoint &gpos ); - TQRegion requestedRegion() const; - TQRegion allocatedRegion() const; - TQRegion paintableRegion() const; - - void updateGraphicsContext( TQGfx *qgfx_qws, bool clip_children ) const; -#ifndef TQT_NO_CURSOR - void updateCursor( const TQRegion &r ) const; -#endif - - // used to accumulate dirty region when children moved/resized. - TQRegion dirtyChildren; - bool isSettingGeometry; - friend class TQWSManager; -#endif - static int instanceCounter; // Current number of widget instances - static int maxInstances; // Maximum number of widget instances - - static void createMapper(); - static void destroyMapper(); - static TQWidgetList *wList(); - static TQWidgetList *tlwList(); - static TQWidgetMapper *mapper; - friend class TQApplication; - friend class TQBaseApplication; - friend class TQPainter; - friend class TQFontMetrics; - friend class TQFontInfo; - friend class TQETWidget; - friend class TQLayout; - -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQWidget( const TQWidget & ); - TQWidget &operator=( const TQWidget & ); -#endif - -public: // obsolete functions to dissappear or to become inline in 3.0 -#ifndef TQT_NO_PALETTE - void setPalette( const TQPalette &p, bool ) { setPalette( p ); } -#endif - void setFont( const TQFont &f, bool ) { setFont( f ); } -}; - - -inline TQt::WState TQWidget::testWState( WState s ) const -{ return (widget_state & s); } - -inline TQt::WFlags TQWidget::testWFlags( WFlags f ) const -{ return (widget_flags & f); } - -inline TQt::NFlags TQWidget::testNFlags( NFlags f ) const -{ return (netwm_flags & f); } - -inline WId TQWidget::winId() const -{ return winid; } - -inline bool TQWidget::isTopLevel() const -{ return testWFlags(WType_TopLevel); } - -inline bool TQWidget::isDialog() const -{ return testWFlags(WType_Dialog); } - -inline bool TQWidget::isPopup() const -{ return testWFlags(WType_Popup); } - -inline bool TQWidget::isDesktop() const -{ return testWFlags(WType_Desktop); } - -inline bool TQWidget::isEnabled() const -{ return !testWState(WState_Disabled); } - -inline bool TQWidget::isModal() const -{ return testWFlags(WShowModal); } - -inline bool TQWidget::isEnabledToTLW() const -{ return isEnabled(); } - -inline const TQRect &TQWidget::geometry() const -{ return crect; } - -inline TQSize TQWidget::size() const -{ return crect.size(); } - -inline int TQWidget::width() const -{ return crect.width(); } - -inline int TQWidget::height() const -{ return crect.height(); } - -inline TQRect TQWidget::rect() const -{ return TQRect(0,0,crect.width(),crect.height()); } - -inline int TQWidget::minimumWidth() const -{ return minimumSize().width(); } - -inline int TQWidget::minimumHeight() const -{ return minimumSize().height(); } - -inline int TQWidget::maximumWidth() const -{ return maximumSize().width(); } - -inline int TQWidget::maximumHeight() const -{ return maximumSize().height(); } - -inline void TQWidget::setMinimumSize( const TQSize &s ) -{ setMinimumSize(s.width(),s.height()); } - -inline void TQWidget::setMaximumSize( const TQSize &s ) -{ setMaximumSize(s.width(),s.height()); } - -inline void TQWidget::setSizeIncrement( const TQSize &s ) -{ setSizeIncrement(s.width(),s.height()); } - -inline void TQWidget::setBaseSize( const TQSize &s ) -{ setBaseSize(s.width(),s.height()); } - -inline const TQColor &TQWidget::eraseColor() const -{ return bg_col; } - -#ifndef TQT_NO_PALETTE -inline const TQPalette &TQWidget::palette() const -{ return pal; } -#endif - -inline TQFont TQWidget::font() const -{ return fnt; } - -inline TQFontMetrics TQWidget::fontMetrics() const -{ return TQFontMetrics(font()); } - -inline TQFontInfo TQWidget::fontInfo() const -{ return TQFontInfo(font()); } - -inline bool TQWidget::hasMouseTracking() const -{ return testWState(WState_MouseTracking); } - -inline bool TQWidget::hasMouse() const -{ return testWState(WState_HasMouse); } - -inline bool TQWidget::isFocusEnabled() const -{ return (FocusPolicy)focus_policy != NoFocus; } - -inline TQWidget::FocusPolicy TQWidget::focusPolicy() const -{ return (FocusPolicy)focus_policy; } - -inline bool TQWidget::isUpdatesEnabled() const -{ return !testWState(WState_BlockUpdates); } - -inline void TQWidget::update( const TQRect &r ) -{ update( r.x(), r.y(), r.width(), r.height() ); } - -inline void TQWidget::repaint() -{ repaint( TRUE ); } - -inline void TQWidget::repaint( const TQRect &r, bool erase ) -{ repaint( r.x(), r.y(), r.width(), r.height(), erase ); } - -inline void TQWidget::erase() -{ erase( 0, 0, crect.width(), crect.height() ); } - -inline void TQWidget::erase( const TQRect &r ) -{ erase( r.x(), r.y(), r.width(), r.height() ); } - -inline bool TQWidget::close() -{ return close( FALSE ); } - -inline bool TQWidget::isVisible() const -{ return testWState(WState_Visible); } - -inline bool TQWidget::isVisibleToTLW() const // obsolete -{ return isVisible(); } - -inline bool TQWidget::isHidden() const -{ return testWState(WState_ForceHide); } - -inline bool TQWidget::isShown() const -{ return !testWState(WState_ForceHide); } - -inline void TQWidget::move( const TQPoint &p ) -{ move( p.x(), p.y() ); } - -inline void TQWidget::resize( const TQSize &s ) -{ resize( s.width(), s.height()); } - -inline void TQWidget::setGeometry( const TQRect &r ) -{ setGeometry( r.left(), r.top(), r.width(), r.height() ); } - -inline void TQWidget::drawText( const TQPoint &p, const TQString &s ) -{ drawText( p.x(), p.y(), s ); } - -inline TQWidget *TQWidget::parentWidget( bool sameWindow ) const -{ - if ( sameWindow ) - return isTopLevel() ? 0 : (TQWidget *)TQObject::parent(); - return (TQWidget *)TQObject::parent(); -} - -inline TQWidgetMapper *TQWidget::wmapper() -{ return mapper; } - -inline uint TQWidget::getWState() const -{ return widget_state; } - -inline void TQWidget::setWState( uint f ) -{ widget_state |= f; } - -inline void TQWidget::clearWState( uint f ) -{ widget_state &= ~f; } - -inline TQt::WFlags TQWidget::getWFlags() const -{ return widget_flags; } - -inline TQt::NFlags TQWidget::getNFlags() const -{ return netwm_flags; } - -inline void TQWidget::setWFlags( WFlags f ) -{ widget_flags |= f; } - -inline void TQWidget::setNFlags( NFlags f ) -{ netwm_flags |= f; } - -inline void TQWidget::clearWFlags( WFlags f ) -{ widget_flags &= ~f; } - -inline void TQWidget::clearNFlags( NFlags f ) -{ netwm_flags &= ~f; } - -inline void TQWidget::constPolish() const -{ - if ( !testWState(WState_Polished) ) { - TQWidget* that = (TQWidget*) this; - that->polish(); - that->setWState(WState_Polished); // be on the safe side... - } -} -#ifndef TQT_NO_CURSOR -inline bool TQWidget::ownCursor() const -{ - return testWState( WState_OwnCursor ); -} -#endif -inline bool TQWidget::ownFont() const -{ - return own_font; -} -#ifndef TQT_NO_PALETTE -inline bool TQWidget::ownPalette() const -{ - return own_palette; -} -#endif - -inline void TQWidget::setSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw ) -{ - setSizePolicy( TQSizePolicy( hor, ver, hfw) ); -} - -inline bool TQWidget::isInputMethodEnabled() const -{ - return (bool)im_enabled; -} - -// Extra TQWidget data -// - to minimize memory usage for members that are seldom used. -// - top-level widgets have extra extra data to reduce cost further - -class TQFocusData; -class TQWSManager; -#if defined(TQ_WS_WIN) -class TQOleDropTarget; -#endif -#if defined(TQ_WS_MAC) -class TQMacDndExtra; -#endif - -struct TQ_EXPORT TQTLWExtra { -#ifndef TQT_NO_WIDGET_TOPEXTRA - TQString caption; // widget caption - TQString iconText; // widget icon text - TQPixmap *icon; // widget icon -#endif - TQFocusData *focusData; // focus data (for TLW) - short incw, inch; // size increments - // frame strut - ulong fleft, fright, ftop, fbottom; - uint unused : 8; // not used at this point... -#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) - uint opacity : 8; // Stores opacity level on Windows/Mac OS X. -#endif - uint savedFlags; // Save widgetflags while showing fullscreen - short basew, baseh; // base sizes -#if defined(TQ_WS_X11) - WId parentWinId; // parent window Id (valid after reparenting) - uint embedded : 1; // window is embedded in another TQt application - uint spont_unmapped: 1; // window was spontaneously unmapped - uint reserved: 1; // reserved - uint dnd : 1; // DND properties installed - uint uspos : 1; // User defined position - uint ussize : 1; // User defined size -#if defined(TQT_NO_IM_EXTENSIONS) - void *xic; // Input Context -#endif -#ifndef TQT_NO_XSYNC - ulong syncCounter; - uint syncRequestValue[2]; -#endif -#endif -#if defined(TQ_WS_MAC) - WindowGroupRef group; - uint is_moved: 1; - uint resizer : 4; -#endif -#if defined(TQ_WS_QWS) && !defined ( TQT_NO_QWS_MANAGER ) - TQRegion decor_allocated_region; // decoration allocated region - TQWSManager *qwsManager; -#endif -#if defined(TQ_WS_WIN) - HICON winIcon; // internal Windows icon -#endif - TQRect normalGeometry; // used by showMin/maximized/FullScreen -#ifdef TQ_WS_WIN - uint style, exstyle; -#endif -}; - - -#define TQWIDGETSIZE_MAX 32767 - -// dear user: you can see this struct, but it is internal. do not touch. - -struct TQ_EXPORT TQWExtra { - TQ_INT16 minw, minh; // minimum size - TQ_INT16 maxw, maxh; // maximum size - TQPixmap *bg_pix; // background pixmap - TQWidget *focus_proxy; -#ifndef TQT_NO_CURSOR - TQCursor *curs; -#endif - TQTLWExtra *topextra; // only useful for TLWs -#if defined(TQ_WS_WIN) - TQOleDropTarget *dropTarget; // drop target -#endif -#if defined(TQ_WS_X11) - WId xDndProxy; // XDND forwarding to embedded windows -#endif -#if defined(TQ_WS_MAC) - TQRegion clip_saved, clip_sibs, clip_children; - TQMacDndExtra *macDndExtra; - TQRegion dirty_area; - uint clip_dirty : 1, clip_serial : 15; - uint child_dirty : 1, child_serial : 15; -#ifndef TQMAC_NO_QUARTZ - uint ctx_children_clipped:1; -#endif // TQMAC_NO_QUARTZ - uint has_dirty_area:1; -#endif // TQ_WS_MAC - uint bg_origin : 2; -#if defined(TQ_WS_X11) - uint children_use_dnd : 1; - uint compress_events : 1; -#endif -#if defined(TQ_WS_QWS) || defined(TQ_WS_MAC) - TQRegion mask; // widget mask -#endif - char bg_mode; // background mode - char bg_mode_visual; // visual background mode -#ifndef TQT_NO_STYLE - TQStyle* style; -#endif - TQRect micro_focus_hint; // micro focus hint - TQSizePolicy size_policy; - TQStyleControlElementData* m_ceData; -}; - -#define Q_DEFINED_QWIDGET -#include "ntqwinexport.h" - -#endif // TQWIDGET_H diff --git a/src/kernel/ntqwidgetintdict.h b/src/kernel/ntqwidgetintdict.h deleted file mode 100644 index f5c924b23..000000000 --- a/src/kernel/ntqwidgetintdict.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Definition of TQWidgetIntDict -** -** Created : 950116 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQWIDGETINTDICT_H -#define TQWIDGETINTDICT_H - -#ifndef QT_H -#include "ntqwidget.h" -#include "ntqintdict.h" -#endif // QT_H - - -#if defined(Q_TEMPLATEDLL) -//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQIntDict; -//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQIntDictIterator; -#endif - - -class TQ_EXPORT TQWidgetIntDict : public TQIntDict -{ -public: - TQWidgetIntDict(int size=17) : TQIntDict(size) {} - TQWidgetIntDict( const TQWidgetIntDict &dict ) : TQIntDict(dict) {} - ~TQWidgetIntDict() { clear(); } - TQWidgetIntDict &operator=(const TQWidgetIntDict &dict) - { return (TQWidgetIntDict&)TQIntDict::operator=(dict); } -}; - -class TQ_EXPORT TQWidgetIntDictIt : public TQIntDictIterator -{ -public: - TQWidgetIntDictIt( const TQWidgetIntDict &d ) : TQIntDictIterator(d) {} - TQWidgetIntDictIt &operator=(const TQWidgetIntDictIt &i) - { return (TQWidgetIntDictIt&)TQIntDictIterator::operator=(i); } -}; - - -#endif diff --git a/src/kernel/ntqwidgetlist.h b/src/kernel/ntqwidgetlist.h deleted file mode 100644 index af912f812..000000000 --- a/src/kernel/ntqwidgetlist.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Definition of TQWidgetList -** -** Created : 950116 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQWIDGETLIST_H -#define TQWIDGETLIST_H - -#ifndef QT_H -#include "ntqwidget.h" -#include "ntqptrlist.h" -#endif // QT_H - -class TQ_EXPORT TQWidgetList : public TQPtrList -{ -public: - TQWidgetList() : TQPtrList() {} - TQWidgetList( const TQWidgetList &list ) : TQPtrList(list) {} - ~TQWidgetList() { clear(); } - TQWidgetList &operator=(const TQWidgetList &list) - { return (TQWidgetList&)TQPtrList::operator=(list); } -}; - -class TQ_EXPORT TQWidgetListIt : public TQPtrListIterator -{ -public: - TQWidgetListIt( const TQWidgetList &l ) : TQPtrListIterator(l) {} - TQWidgetListIt &operator=(const TQWidgetListIt &i) - { return (TQWidgetListIt&)TQPtrListIterator::operator=(i); } -}; - -#endif // TQWIDGETLIST_H diff --git a/src/kernel/ntqwindowdefs.h b/src/kernel/ntqwindowdefs.h index ae28caace..17593a715 100644 --- a/src/kernel/ntqwindowdefs.h +++ b/src/kernel/ntqwindowdefs.h @@ -84,7 +84,7 @@ class TQTime; class TQClipboard; -// Widget list (defined in ntqwidgetlist.h) +// Widget list (defined in tqwidgetlist.h) class TQWidgetList; class TQWidgetListIt; diff --git a/src/kernel/qaccel.cpp b/src/kernel/qaccel.cpp index c52f090fd..beb504052 100644 --- a/src/kernel/qaccel.cpp +++ b/src/kernel/qaccel.cpp @@ -44,7 +44,7 @@ #include "ntqsignal.h" #include "ntqapplication.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqptrlist.h" #include "ntqwhatsthis.h" #include "ntqguardedptr.h" diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 31bd5ecc4..39f8abc5a 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -42,9 +42,9 @@ #include "ntqapplication.h" #include "ntqeventloop.h" #include "qeventloop_p.h" -#include "ntqwidget.h" -#include "ntqwidgetlist.h" -#include "ntqwidgetintdict.h" +#include "tqwidget.h" +#include "tqwidgetlist.h" +#include "tqwidgetintdict.h" #include "ntqptrdict.h" #include "ntqcleanuphandler.h" @@ -2284,7 +2284,7 @@ TQWidgetList *TQApplication::topLevelWidgets() delete list; // delete the list, not the widgets \endcode - The TQWidgetList class is defined in the \c ntqwidgetlist.h header + The TQWidgetList class is defined in the \c tqwidgetlist.h header file. \warning Delete the list as soon as you have finished using it. diff --git a/src/kernel/qapplication_p.h b/src/kernel/qapplication_p.h index 5093dcfc7..7f6fbf9f9 100644 --- a/src/kernel/qapplication_p.h +++ b/src/kernel/qapplication_p.h @@ -47,7 +47,7 @@ // ------------- // // This file is not part of the TQt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp +// of qapplication_*.cpp, tqwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp // and many other. This header file may change from version to version // without notice, or even be removed. // diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 125f1fa21..56ba9aefa 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -65,11 +65,11 @@ #include "qapplication_p.h" #include "qcolor_p.h" #include "ntqcursor.h" -#include "ntqwidget.h" -#include "qwidget_p.h" +#include "tqwidget.h" +#include "tqwidget_p.h" #include "tqobjectlist.h" -#include "ntqwidgetlist.h" -#include "ntqwidgetintdict.h" +#include "tqwidgetlist.h" +#include "tqwidgetintdict.h" #include "ntqbitarray.h" #include "ntqpainter.h" #include "ntqpixmapcache.h" @@ -5952,7 +5952,7 @@ static Bool qt_net_wm_sync_request_scanner(Display*, XEvent* event, XPointer arg bool TQETWidget::translateConfigEvent( const XEvent *event ) { - // config pending is only set on resize, see qwidget_x11.cpp, internalSetGeometry() + // config pending is only set on resize, see tqwidget_x11.cpp, internalSetGeometry() bool was_resize = testWState( WState_ConfigPending ); clearWState(WState_ConfigPending); diff --git a/src/kernel/qdesktopwidget_x11.cpp b/src/kernel/qdesktopwidget_x11.cpp index bb301e522..db3763530 100644 --- a/src/kernel/qdesktopwidget_x11.cpp +++ b/src/kernel/qdesktopwidget_x11.cpp @@ -42,7 +42,7 @@ #include "qt_x11_p.h" #include -// defined in qwidget_x11.cpp +// defined in tqwidget_x11.cpp extern int qt_x11_create_desktop_on_screen; // defined in qapplication_x11.cpp diff --git a/src/kernel/qdnd_x11.cpp b/src/kernel/qdnd_x11.cpp index a50f23319..859a3c1a6 100644 --- a/src/kernel/qdnd_x11.cpp +++ b/src/kernel/qdnd_x11.cpp @@ -44,7 +44,7 @@ #ifndef TQT_NO_DRAGANDDROP -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqintdict.h" #include "ntqdatetime.h" #include "ntqdict.h" diff --git a/src/kernel/qdragobject.cpp b/src/kernel/qdragobject.cpp index c9d4e8f1b..5e6a0dab9 100644 --- a/src/kernel/qdragobject.cpp +++ b/src/kernel/qdragobject.cpp @@ -49,7 +49,7 @@ #include "ntqtextcodec.h" #include "ntqapplication.h" #include "ntqpoint.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqbuffer.h" #include "ntqgif.h" #include "ntqregexp.h" diff --git a/src/kernel/qdropsite.cpp b/src/kernel/qdropsite.cpp index 8dd44a2cc..a8d3a8728 100644 --- a/src/kernel/qdropsite.cpp +++ b/src/kernel/qdropsite.cpp @@ -40,7 +40,7 @@ #ifndef TQT_NO_DRAGANDDROP -#include "ntqwidget.h" +#include "tqwidget.h" // NOT REVISED diff --git a/src/kernel/qfontengine_x11.cpp b/src/kernel/qfontengine_x11.cpp index 65ab15811..96f011927 100644 --- a/src/kernel/qfontengine_x11.cpp +++ b/src/kernel/qfontengine_x11.cpp @@ -40,7 +40,7 @@ // #define FONTENGINE_DEBUG -#include +#include #include #include diff --git a/src/kernel/qinputcontext.cpp b/src/kernel/qinputcontext.cpp index 0149304ef..7f9760c46 100644 --- a/src/kernel/qinputcontext.cpp +++ b/src/kernel/qinputcontext.cpp @@ -42,7 +42,7 @@ #include "qplatformdefs.h" #include "ntqapplication.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqpopupmenu.h" #include diff --git a/src/kernel/qinputcontext_x11.cpp b/src/kernel/qinputcontext_x11.cpp index e4d36af6b..0a314dfbb 100644 --- a/src/kernel/qinputcontext_x11.cpp +++ b/src/kernel/qinputcontext_x11.cpp @@ -43,7 +43,7 @@ #include "qplatformdefs.h" #include "ntqapplication.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "qt_x11_p.h" diff --git a/src/kernel/qinternal.cpp b/src/kernel/qinternal.cpp index e99c95f79..87cf5694e 100644 --- a/src/kernel/qinternal.cpp +++ b/src/kernel/qinternal.cpp @@ -39,7 +39,7 @@ **********************************************************************/ #include "private/qinternal_p.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqpixmap.h" #include "ntqpainter.h" #include "ntqcleanuphandler.h" diff --git a/src/kernel/qlayout.cpp b/src/kernel/qlayout.cpp index a23a44a8f..229a9ed7d 100644 --- a/src/kernel/qlayout.cpp +++ b/src/kernel/qlayout.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_LAYOUT #include "ntqapplication.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqptrlist.h" #include "ntqsizepolicy.h" diff --git a/src/kernel/qmotifdnd_x11.cpp b/src/kernel/qmotifdnd_x11.cpp index d11065835..548310dab 100644 --- a/src/kernel/qmotifdnd_x11.cpp +++ b/src/kernel/qmotifdnd_x11.cpp @@ -72,7 +72,7 @@ in doc/dnd.doc, where the documentation system can see it. */ #ifndef TQT_NO_DRAGANDDROP -#include "ntqwidget.h" +#include "tqwidget.h" #include "qt_x11_p.h" #include diff --git a/src/kernel/qpaintdevice_x11.cpp b/src/kernel/qpaintdevice_x11.cpp index c64b3e90e..1a01803aa 100644 --- a/src/kernel/qpaintdevice_x11.cpp +++ b/src/kernel/qpaintdevice_x11.cpp @@ -41,7 +41,7 @@ #include "ntqpaintdevice.h" #include "ntqpaintdevicemetrics.h" #include "ntqpainter.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqbitmap.h" #include "ntqapplication.h" #include "qt_x11_p.h" diff --git a/src/kernel/qpainter.cpp b/src/kernel/qpainter.cpp index 4868ffb00..3e3574dff 100644 --- a/src/kernel/qpainter.cpp +++ b/src/kernel/qpainter.cpp @@ -44,7 +44,7 @@ #include "ntqptrstack.h" #include "ntqptrdict.h" #include "ntqdatastream.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqimage.h" #include "ntqpaintdevicemetrics.h" #include "ntqapplication.h" diff --git a/src/kernel/qpainter_x11.cpp b/src/kernel/qpainter_x11.cpp index 657965c42..a4f71fc00 100644 --- a/src/kernel/qpainter_x11.cpp +++ b/src/kernel/qpainter_x11.cpp @@ -42,7 +42,7 @@ #include "ntqfont.h" #include "ntqpainter.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqbitmap.h" #include "ntqpixmapcache.h" #include "ntqtextcodec.h" diff --git a/src/kernel/qpixmap.cpp b/src/kernel/qpixmap.cpp index 4f05adc02..9c93632c1 100644 --- a/src/kernel/qpixmap.cpp +++ b/src/kernel/qpixmap.cpp @@ -42,7 +42,7 @@ #include "ntqbitmap.h" #include "ntqimage.h" -#include "ntqwidget.h" +#include "tqwidget.h" #include "ntqpainter.h" #include "ntqdatastream.h" #include "ntqbuffer.h" diff --git a/src/kernel/qsizegrip.cpp b/src/kernel/qsizegrip.cpp index d27e0b534..a6629ecf6 100644 --- a/src/kernel/qsizegrip.cpp +++ b/src/kernel/qsizegrip.cpp @@ -53,7 +53,7 @@ extern Atom qt_sizegrip; // defined in qapplication_x11.cpp #include "tqobjectlist.h" #include "qt_windows.h" #elif defined(TQ_WS_MAC) -bool qt_mac_update_sizer(TQWidget *, int); //qwidget_mac.cpp +bool qt_mac_update_sizer(TQWidget *, int); //tqwidget_mac.cpp #endif diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 67b42e70f..d45540bb8 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -50,7 +50,7 @@ #include "ntqpopupmenu.h" #include "ntqpushbutton.h" #include "tqobjectlist.h" -#include "ntqwidgetlist.h" +#include "tqwidgetlist.h" #include diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri index 6baa0c732..f21fbfd17 100644 --- a/src/kernel/qt_kernel.pri +++ b/src/kernel/qt_kernel.pri @@ -83,9 +83,9 @@ kernel { $$KERNEL_H/ntqlocalfs.h \ $$KERNEL_H/ntqurloperator.h \ $$KERNEL_H/ntqurlinfo.h \ - $$KERNEL_H/ntqwidget.h \ - $$KERNEL_H/ntqwidgetintdict.h \ - $$KERNEL_H/ntqwidgetlist.h \ + $$KERNEL_H/tqwidget.h \ + $$KERNEL_H/tqwidgetintdict.h \ + $$KERNEL_H/tqwidgetlist.h \ $$KERNEL_H/ntqwindowdefs.h \ $$KERNEL_H/ntqwmatrix.h \ $$KERNEL_H/ntqvariant.h \ @@ -128,7 +128,7 @@ kernel { $$KERNEL_CPP/qregion_win.cpp \ $$KERNEL_CPP/qsound_win.cpp \ $$KERNEL_CPP/qthread_win.cpp \ - $$KERNEL_CPP/qwidget_win.cpp \ + $$KERNEL_CPP/tqwidget_win.cpp \ $$KERNEL_CPP/qole_win.c \ $$KERNEL_CPP/qfontengine_win.cpp @@ -148,8 +148,8 @@ kernel { $$KERNEL_CPP/qpainter_x11.cpp \ $$KERNEL_CPP/qregion_x11.cpp \ $$KERNEL_CPP/qsound_x11.cpp \ - $$KERNEL_CPP/qwidget_x11.cpp \ - $$KERNEL_CPP/qwidgetcreate_x11.cpp \ + $$KERNEL_CPP/tqwidget_x11.cpp \ + $$KERNEL_CPP/tqwidgetcreate_x11.cpp \ $$KERNEL_CPP/qfontengine_x11.cpp glibmainloop { SOURCES += $$KERNEL_CPP/qeventloop_x11_glib.cpp @@ -176,7 +176,7 @@ kernel { $$KERNEL_CPP/qpaintdevice_mac.cpp \ $$KERNEL_CPP/qpainter_mac.cpp \ $$KERNEL_CPP/qregion_mac.cpp \ - $$KERNEL_CPP/qwidget_mac.cpp \ + $$KERNEL_CPP/tqwidget_mac.cpp \ $$KERNEL_CPP/qeventloop_mac.cpp \ $$KERNEL_CPP/qfont_mac.cpp \ $$KERNEL_CPP/qfontengine_mac.cpp @@ -255,7 +255,7 @@ kernel { $$KERNEL_CPP/qlocalfs.cpp \ $$KERNEL_CPP/qurloperator.cpp \ $$KERNEL_CPP/qurlinfo.cpp \ - $$KERNEL_CPP/qwidget.cpp \ + $$KERNEL_CPP/tqwidget.cpp \ $$KERNEL_CPP/qwmatrix.cpp \ $$KERNEL_CPP/qvariant.cpp \ $$KERNEL_CPP/qrichtext.cpp \ diff --git a/src/kernel/qt_pch.h b/src/kernel/qt_pch.h index 1aef6f4a8..5295f8134 100644 --- a/src/kernel/qt_pch.h +++ b/src/kernel/qt_pch.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/kernel/qtranslator.cpp b/src/kernel/qtranslator.cpp index 99d475859..e3d1c5b98 100644 --- a/src/kernel/qtranslator.cpp +++ b/src/kernel/qtranslator.cpp @@ -57,7 +57,7 @@ static inline int qt_open(const char *pathname, int flags, mode_t mode) #ifndef TQT_NO_TRANSLATION #include "ntqfileinfo.h" -#include "ntqwidgetlist.h" +#include "tqwidgetlist.h" #include "ntqintdict.h" #include "ntqstring.h" #include "ntqapplication.h" diff --git a/src/kernel/qwidget.cpp b/src/kernel/qwidget.cpp deleted file mode 100644 index e855e7448..000000000 --- a/src/kernel/qwidget.cpp +++ /dev/null @@ -1,6122 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQWidget class -** -** Created : 931031 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - - -#include "tqobjectlist.h" -#include "ntqwidget.h" -#include "ntqwidgetlist.h" -#include "ntqwidgetintdict.h" -#include "ntqptrdict.h" -#include "ntqfocusdata.h" -#include "ntqcursor.h" -#include "ntqpixmap.h" -#include "ntqapplication.h" -#include "qapplication_p.h" -#include "ntqbrush.h" -#include "ntqlayout.h" -#include "ntqstylefactory.h" -#include "ntqcleanuphandler.h" -#include "ntqstyle.h" -#include "ntqmetaobject.h" -#include "ntqguardedptr.h" -#if defined(TQT_THREAD_SUPPORT) -#include "ntqthread.h" -#endif -#if defined(QT_ACCESSIBILITY_SUPPORT) -#include "ntqaccessible.h" -#endif -#if defined(TQ_WS_WIN) -#include "qt_windows.h" -#include "qinputcontext_p.h" -#endif -#if defined(TQ_WS_QWS) -#include "qwsmanager_qws.h" -#endif -#include "qfontdata_p.h" - - -/*! - \class TQWidget ntqwidget.h - \brief The TQWidget class is the base class of all user interface objects. - - \ingroup abstractwidgets - \mainclass - - The widget is the atom of the user interface: it receives mouse, - keyboard and other events from the window system, and paints a - representation of itself on the screen. Every widget is - rectangular, and they are sorted in a Z-order. A widget is - clipped by its parent and by the widgets in front of it. - - A widget that isn't embedded in a parent widget is called a - top-level widget. Usually, top-level widgets are windows with a - frame and a title bar (although it is also possible to create - top-level widgets without such decoration if suitable widget flags - are used). In TQt, TQMainWindow and the various subclasses of - TQDialog are the most common top-level windows. - - A widget without a parent widget is always a top-level widget. - - Non-top-level widgets are child widgets. These are child windows - in their parent widgets. You cannot usually distinguish a child - widget from its parent visually. Most other widgets in TQt are - useful only as child widgets. (It is possible to make, say, a - button into a top-level widget, but most people prefer to put - their buttons inside other widgets, e.g. TQDialog.) - - If you want to use a TQWidget to hold child widgets you will - probably want to add a layout to the parent TQWidget. (See \link - layout.html Layouts\endlink.) - - TQWidget has many member functions, but some of them have little - direct functionality: for example, TQWidget has a font property, - but never uses this itself. There are many subclasses which - provide real functionality, such as TQPushButton, TQListBox and - TQTabDialog, etc. - - \section1 Groups of functions: - - \table - \header \i Context \i Functions - - \row \i Window functions \i - show(), - hide(), - raise(), - lower(), - close(). - - \row \i Top level windows \i - caption(), - setCaption(), - icon(), - setIcon(), - iconText(), - setIconText(), - isActiveWindow(), - setActiveWindow(), - showMinimized(). - showMaximized(), - showFullScreen(), - showNormal(). - - \row \i Window contents \i - update(), - repaint(), - erase(), - scroll(), - updateMask(). - - \row \i Geometry \i - pos(), - size(), - rect(), - x(), - y(), - width(), - height(), - sizePolicy(), - setSizePolicy(), - sizeHint(), - updateGeometry(), - layout(), - move(), - resize(), - setGeometry(), - frameGeometry(), - geometry(), - childrenRect(), - adjustSize(), - mapFromGlobal(), - mapFromParent() - mapToGlobal(), - mapToParent(), - maximumSize(), - minimumSize(), - sizeIncrement(), - setMaximumSize(), - setMinimumSize(), - setSizeIncrement(), - setBaseSize(), - setFixedSize() - - \row \i Mode \i - isVisible(), - isVisibleTo(), - isMinimized(), - isDesktop(), - isEnabled(), - isEnabledTo(), - isModal(), - isPopup(), - isTopLevel(), - setEnabled(), - hasMouseTracking(), - setMouseTracking(), - isUpdatesEnabled(), - setUpdatesEnabled(), - clipRegion(). - - \row \i Look and feel \i - style(), - setStyle(), - cursor(), - setCursor() - font(), - setFont(), - palette(), - setPalette(), - backgroundMode(), - setBackgroundMode(), - colorGroup(), - fontMetrics(), - fontInfo(). - - \row \i Keyboard focus
functions \i - isFocusEnabled(), - setFocusPolicy(), - focusPolicy(), - hasFocus(), - setFocus(), - clearFocus(), - setTabOrder(), - setFocusProxy(). - - \row \i Mouse and
keyboard grabbing \i - grabMouse(), - releaseMouse(), - grabKeyboard(), - releaseKeyboard(), - mouseGrabber(), - keyboardGrabber(). - - \row \i Event handlers \i - event(), - mousePressEvent(), - mouseReleaseEvent(), - mouseDoubleClickEvent(), - mouseMoveEvent(), - keyPressEvent(), - keyReleaseEvent(), - focusInEvent(), - focusOutEvent(), - wheelEvent(), - enterEvent(), - leaveEvent(), - paintEvent(), - moveEvent(), - resizeEvent(), - closeEvent(), - dragEnterEvent(), - dragMoveEvent(), - dragLeaveEvent(), - dropEvent(), - childEvent(), - showEvent(), - hideEvent(), - customEvent(). - - \row \i Change handlers \i - enabledChange(), - fontChange(), - paletteChange(), - styleChange(), - windowActivationChange(). - - \row \i System functions \i - parentWidget(), - topLevelWidget(), - reparent(), - polish(), - winId(), - find(), - metric(). - - \row \i What's this help \i - customWhatsThis() - - \row \i Internal kernel
functions \i - focusNextPrevChild(), - wmapper(), - clearWFlags(), - getWFlags(), - setWFlags(), - testWFlags(). - - \endtable - - Every widget's constructor accepts two or three standard arguments: - \list 1 - \i \c{TQWidget *parent = 0} is the parent of the new widget. - If it is 0 (the default), the new widget will be a top-level window. - If not, it will be a child of \e parent, and be constrained by \e - parent's geometry (unless you specify \c WType_TopLevel as - widget flag). - \i \c{const char *name = 0} is the widget name of the new - widget. You can access it using name(). The widget name is little - used by programmers but is quite useful with GUI builders such as - \e{TQt Designer} (you can name a widget in \e{TQt Designer}, and - connect() to it using the name in your code). The dumpObjectTree() - debugging function also uses it. - \i \c{WFlags f = 0} (where available) sets the widget flags; the - default is suitable for almost all widgets, but to get, for - example, a top-level widget without a window system frame, you - must use special flags. - \endlist - - The tictac/tictac.cpp example program is good example of a simple - widget. It contains a few event handlers (as all widgets must), a - few custom routines that are specific to it (as all useful widgets - do), and has a few children and connections. Everything it does - is done in response to an event: this is by far the most common way - to design GUI applications. - - You will need to supply the content for your widgets yourself, but - here is a brief run-down of the events, starting with the most common - ones: - - \list - - \i paintEvent() - called whenever the widget needs to be - repainted. Every widget which displays output must implement it, - and it is wise \e not to paint on the screen outside - paintEvent(). - - \i resizeEvent() - called when the widget has been resized. - - \i mousePressEvent() - called when a mouse button is pressed. - There are six mouse-related events, but the mouse press and mouse - release events are by far the most important. A widget receives - mouse press events when the mouse is inside it, or when it has - grabbed the mouse using grabMouse(). - - \i mouseReleaseEvent() - called when a mouse button is released. - A widget receives mouse release events when it has received the - corresponding mouse press event. This means that if the user - presses the mouse inside \e your widget, then drags the mouse to - somewhere else, then releases, \e your widget receives the release - event. There is one exception: if a popup menu appears while the - mouse button is held down, this popup immediately steals the mouse - events. - - \i mouseDoubleClickEvent() - not quite as obvious as it might seem. - If the user double-clicks, the widget receives a mouse press event - (perhaps a mouse move event or two if they don't hold the mouse - quite steady), a mouse release event and finally this event. It is - \e{not possible} to distinguish a click from a double click until you've - seen whether the second click arrives. (This is one reason why most GUI - books recommend that double clicks be an extension of single clicks, - rather than trigger a different action.) - - \endlist - - If your widget only contains child widgets, you probably do not need to - implement any event handlers. If you want to detect a mouse click in - a child widget call the child's hasMouse() function inside the - parent widget's mousePressEvent(). - - Widgets that accept keyboard input need to reimplement a few more - event handlers: - - \list - - \i keyPressEvent() - called whenever a key is pressed, and again - when a key has been held down long enough for it to auto-repeat. - Note that the Tab and Shift+Tab keys are only passed to the widget - if they are not used by the focus-change mechanisms. To force those - keys to be processed by your widget, you must reimplement - TQWidget::event(). - - \i focusInEvent() - called when the widget gains keyboard focus - (assuming you have called setFocusPolicy()). Well written widgets - indicate that they own the keyboard focus in a clear but discreet - way. - - \i focusOutEvent() - called when the widget loses keyboard focus. - - \endlist - - Some widgets will also need to reimplement some of the less common - event handlers: - - \list - - \i mouseMoveEvent() - called whenever the mouse moves while a - button is held down. This is useful for, for example, dragging. If - you call setMouseTracking(TRUE), you get mouse move events even - when no buttons are held down. (Note that applications which make - use of mouse tracking are often not very useful on low-bandwidth X - connections.) (See also the \link dnd.html drag and drop\endlink - information.) - - \i keyReleaseEvent() - called whenever a key is released, and also - while it is held down if the key is auto-repeating. In that case - the widget receives a key release event and immediately a key press - event for every repeat. Note that the Tab and Shift+Tab keys are - only passed to the widget if they are not used by the focus-change - mechanisms. To force those keys to be processed by your widget, you - must reimplement TQWidget::event(). - - \i wheelEvent() -- called whenever the user turns the mouse wheel - while the widget has the focus. - - \i enterEvent() - called when the mouse enters the widget's screen - space. (This excludes screen space owned by any children of the - widget.) - - \i leaveEvent() - called when the mouse leaves the widget's screen - space. - - \i moveEvent() - called when the widget has been moved relative to its - parent. - - \i closeEvent() - called when the user closes the widget (or when - close() is called). - - \endlist - - There are also some rather obscure events. They are listed in - \c ntqevent.h and you need to reimplement event() to handle them. - The default implementation of event() handles Tab and Shift+Tab - (to move the keyboard focus), and passes on most other events to - one of the more specialized handlers above. - - When implementing a widget, there are a few more things to - consider. - - \list - - \i In the constructor, be sure to set up your member variables - early on, before there's any chance that you might receive an event. - - \i It is almost always useful to reimplement sizeHint() and to set - the correct size policy with setSizePolicy(), so users of your class - can set up layout management more easily. A size policy lets you - supply good defaults for the layout management handling, so that - other widgets can contain and manage yours easily. sizeHint() - indicates a "good" size for the widget. - - \i If your widget is a top-level window, setCaption() and setIcon() set - the title bar and icon respectively. - - \endlist - - \sa TQEvent, TQPainter, TQGridLayout, TQBoxLayout -*/ - - -/***************************************************************************** - Internal TQWidgetMapper class - - The purpose of this class is to map widget identifiers to TQWidget objects. - All TQWidget objects register themselves in the TQWidgetMapper when they - get an identifier. Widgets unregister themselves when they change ident- - ifier or when they are destroyed. A widget identifier is really a window - handle. - - The widget mapper is created and destroyed by the main application routines - in the file qapp_xxx.cpp. - *****************************************************************************/ - -#if defined(TQ_WS_QWS) || defined(Q_OS_TEMP) -static const int WDictSize = 163; // plenty for small devices -#else -static const int WDictSize = 1123; // plenty for 5 big complex windows -#endif - -class TQWidgetMapper : public TQWidgetIntDict -{ // maps ids -> widgets -public: - TQWidgetMapper(); - ~TQWidgetMapper(); - TQWidget *find( WId id ); // find widget - void insert( const TQWidget * ); // insert widget - bool remove( WId id ); // remove widget -private: - WId cur_id; - TQWidget *cur_widget; -}; - -TQWidgetMapper *TQWidget::mapper = 0; // app global widget mapper - - -TQWidgetMapper::TQWidgetMapper() : TQWidgetIntDict(WDictSize) -{ - cur_id = 0; - cur_widget = 0; -} - -TQWidgetMapper::~TQWidgetMapper() -{ - clear(); -} - -inline TQWidget *TQWidgetMapper::find( WId id ) -{ - if ( id != cur_id ) { // need to lookup - cur_widget = TQWidgetIntDict::find((long)id); - if ( cur_widget ) - cur_id = id; - else - cur_id = 0; - } - return cur_widget; -} - -inline void TQWidgetMapper::insert( const TQWidget *widget ) -{ - TQWidgetIntDict::insert((long)widget->winId(),widget); -} - -inline bool TQWidgetMapper::remove( WId id ) -{ - if ( cur_id == id ) { // reset current widget - cur_id = 0; - cur_widget = 0; - } - return TQWidgetIntDict::remove((long)id); -} - - -/***************************************************************************** - TQWidget utility functions - *****************************************************************************/ - -static TQFont qt_naturalWidgetFont( TQWidget* w ) { - TQFont naturalfont = TQApplication::font( w ); - if ( ! w->isTopLevel() ) { - if ( ! naturalfont.isCopyOf( TQApplication::font() ) ) - naturalfont = naturalfont.resolve( w->parentWidget()->font() ); - else - naturalfont = w->parentWidget()->font(); - } - return naturalfont; -} - -#ifndef TQT_NO_PALETTE -static TQPalette qt_naturalWidgetPalette( TQWidget* w ) { - TQPalette naturalpalette = TQApplication::palette( w ); - if ( !w->isTopLevel() && naturalpalette.isCopyOf( TQApplication::palette() ) ) - naturalpalette = w->parentWidget()->palette(); - return naturalpalette; -} -#endif - -TQSize qt_naturalWidgetSize( TQWidget *w ) { - TQSize s = w->sizeHint(); - TQSizePolicy::ExpandData exp; -#ifndef TQT_NO_LAYOUT - if ( w->layout() ) { - if ( w->layout()->hasHeightForWidth() ) - s.setHeight( w->layout()->totalHeightForWidth( s.width() ) ); - exp = w->layout()->expanding(); - } else -#endif - { - if ( w->sizePolicy().hasHeightForWidth() ) - s.setHeight( w->heightForWidth( s.width() ) ); - exp = w->sizePolicy().expanding(); - } - if ( exp & TQSizePolicy::Horizontally ) - s.setWidth( TQMAX( s.width(), 200 ) ); - if ( exp & TQSizePolicy::Vertically ) - s.setHeight( TQMAX( s.height(), 150 ) ); -#if defined(TQ_WS_X11) - TQRect screen = TQApplication::desktop()->screenGeometry( w->x11Screen() ); -#else // all others - TQRect screen = TQApplication::desktop()->screenGeometry( w->pos() ); -#endif - s.setWidth( TQMIN( s.width(), screen.width()*2/3 ) ); - s.setHeight( TQMIN( s.height(), screen.height()*2/3 ) ); - return s; -} - -/***************************************************************************** - TQWidget member functions - *****************************************************************************/ - -/* - Widget state flags: - \list - \i WState_Created The widget has a valid winId(). - \i WState_Disabled The widget does not receive any mouse or keyboard - events. - \i WState_ForceDisabled The widget is explicitly disabled, i.e. it - will remain disabled even when all its ancestors are set to the enabled - state. This implies WState_Disabled. - \i WState_Visible The widget is currently visible. - \i WState_ForceHide The widget is explicitly hidden, i.e. it won't - become visible unless you call show() on it. WState_ForceHide - implies !WState_Visible. - \i WState_OwnCursor A cursor has been set for this widget. - \i WState_MouseTracking Mouse tracking is enabled. - \i WState_CompressKeys Compress keyboard events. - \i WState_BlockUpdates Repaints and updates are disabled. - \i WState_InPaintEvent Currently processing a paint event. - \i WState_Reparented The widget has been reparented. - \i WState_ConfigPending A configuration (resize/move) event is pending. - \i WState_Resized The widget has been resized. - \i WState_AutoMask The widget has an automatic mask, see setAutoMask(). - \i WState_Polished The widget has been "polished" (i.e. late - initialization) by a TQStyle. - \i WState_DND The widget supports drag and drop, see setAcceptDrops(). - \i WState_Exposed the widget was finally exposed (X11 only, - helps avoid paint event doubling). - \i WState_HasMouse The widget is under the mouse cursor. - \endlist -*/ - -/*! \enum TQt::WFlags - \internal */ -/*! \enum TQt::WState - \internal */ - -/*! - \enum TQt::WidgetFlags - - \keyword widget flag - - This enum type is used to specify various window-system properties - for the widget. They are fairly unusual but necessary in a few - cases. Some of these flags depend on whether the underlying window - manager supports them. (See the \link toplevel-example.html - toplevel example\endlink for an explanation and example of their - use.) - - The main types are - - \value WType_TopLevel indicates that this widget is a top-level - widget, usually with a window-system frame and so on. - - \value WType_Dialog indicates that this widget is a top-level - window that should be decorated as a dialog (i.e. typically no - maximize or minimize buttons in the title bar). If you want to use - it as a modal dialog it should be launched from another window, or - have a parent and this flag should be combined with \c WShowModal. - If you make it modal, the dialog will prevent other top-level - windows in the application from getting any input. \c WType_Dialog - implies \c WType_TopLevel. We refer to a top-level window that has - a parent as a \e secondary window. (See also \c WGroupLeader.) - - \value WType_Popup indicates that this widget is a popup - top-level window, i.e. that it is modal, but has a window system - frame appropriate for popup menus. \c WType_Popup implies - WType_TopLevel. - - \value WType_Desktop indicates that this widget is the desktop. - See also \c WPaintDesktop below. \c WType_Desktop implies \c - WType_TopLevel. - - There are also a number of flags which you can use to customize - the appearance of top-level windows. These have no effect on other - windows: - - \value WStyle_Customize indicates that the \c WStyle_* flags - should be used to build the window instead of the default flags. - - \value WStyle_NormalBorder gives the window a normal border. - This cannot be combined with \c WStyle_DialogBorder or \c - WStyle_NoBorder. - - \value WStyle_DialogBorder gives the window a thin dialog border. - This cannot be combined with \c WStyle_NormalBorder or \c - WStyle_NoBorder. - - \value WStyle_NoBorder produces a borderless window. Note that - the user cannot move or resize a borderless window via the window - system. This cannot be combined with \c WStyle_NormalBorder or \c - WStyle_DialogBorder. On Windows, the flag works fine. On X11, the - result of the flag is dependent on the window manager and its - ability to understand MOTIF and/or NETWM hints: most existing - modern window managers can handle this. With \c WX11BypassWM, you - can bypass the window manager completely. This results in a - borderless window that is not managed at all (i.e. no keyboard - input unless you call setActiveWindow() manually). - - \value WStyle_NoBorderEx this value is obsolete. It has the same - effect as using \c WStyle_NoBorder. - - \value WStyle_Title gives the window a title bar. - - \value WStyle_SysMenu adds a window system menu. - - \value WStyle_Minimize adds a minimize button. Note that on - Windows this has to be combined with \c WStyle_SysMenu for it to - work. - - \value WStyle_Maximize adds a maximize button. Note that on - Windows this has to be combined with \c WStyle_SysMenu for it to work. - - \value WStyle_MinMax is equal to \c - WStyle_Minimize|WStyle_Maximize. Note that on Windows this has to - be combined with \c WStyle_SysMenu to work. - - \value WStyle_ContextHelp adds a context help button to dialogs. - - \value WStyle_Tool makes the window a tool window. A tool window - is often a small window with a smaller than usual title bar and - decoration, typically used for collections of tool buttons. It - there is a parent, the tool window will always be kept on top of - it. If there isn't a parent, you may consider passing \c - WStyle_StaysOnTop as well. If the window system supports it, a - tool window can be decorated with a somewhat lighter frame. It can - also be combined with \c WStyle_NoBorder. - - \value WStyle_StaysOnTop informs the window system that the - window should stay on top of all other windows. Note that on some - window managers on X11 you also have to pass \c WX11BypassWM for - this flag to work correctly. - - \value WStyle_Dialog indicates that the window is a logical - subwindow of its parent (i.e. a dialog). The window will not get - its own taskbar entry and will be kept on top of its parent by the - window system. Usually it will also be minimized when the parent - is minimized. If not customized, the window is decorated with a - slightly simpler title bar. This is the flag TQDialog uses. - - \value WStyle_Splash indicates that the window is a splash screen. - On X11, we try to follow NETWM standard for a splash screen window if the - window manager supports is otherwise it is equivalent to \c WX11BypassWM. On - other platforms, it is equivalent to \c WStyle_NoBorder \c | \c WMacNoSheet \c | - \c WStyle_Tool \c | \c WWinOwnDC - - Modifier flags: - - \value WDestructiveClose makes TQt delete this widget when the - widget has accepted closeEvent(), or when the widget tried to - ignore closeEvent() but could not. - - \value WPaintDesktop gives this widget paint events for the - desktop. - - \value WPaintUnclipped makes all painters operating on this - widget unclipped. Children of this widget or other widgets in - front of it do not clip the area the painter can paint on. - - \value WPaintClever indicates that TQt should \e not try to - optimize repainting for the widget, but instead pass on window - system repaint events directly. (This tends to produce more events - and smaller repaint regions.) - - \value WMouseNoMask indicates that even if the widget has a mask, - it wants mouse events for its entire rectangle. - - \value WStaticContents indicates that the widget contents are - north-west aligned and static. On resize, such a widget will - receive paint events only for the newly visible part of itself. - - \value WNoAutoErase indicates that the widget paints all its - pixels. Updating, resizing, scrolling and focus changes should - therefore not erase the widget. This allows smart-repainting to - avoid flicker. - - \value WResizeNoErase this value is obsolete; use WNoAutoErase instead. - \value WRepaintNoErase this value is obsolete; use WNoAutoErase instead. - \value WGroupLeader makes this window a group leader. A group - leader should \e not have a parent (i.e. it should be a top-level - window). Any decendant windows (direct or indirect) of a group - leader are in its group; other windows are not. If you show a - secondary window from the group (i.e. show a window whose top-most - parent is a group leader), that window will be modal with respect - to the other windows in the group, but modeless with respect to - windows in other groups. - - Miscellaneous flags - - \value WShowModal see WType_Dialog - - Internal flags. - - \value WNoMousePropagation - \value WStaticContents - \value WStyle_Reserved - \value WSubWindow - \value WType_Modal - \value WWinOwnDC - \value WX11BypassWM - \value WMacNoSheet - \value WMacDrawer - \value WStyle_Mask - \value WType_Mask - -*/ - -/*! - \enum TQt::NETWMFlags - - \keyword NETWM flag - - This enum type is used to specify various NETWM properties - under X11 and similar systems. - - The main types are - - \value WX11DisableMove - \value WX11DisableClose - \value WX11DisableResize - \value WX11DisableMinimize - \value WX11DisableMaximize - \value WX11DisableShade - -*/ - -/*! - \enum TQt::WidgetState - - Internal flags. - - \value WState_Created - \value WState_Disabled - \value WState_Visible - \value WState_ForceHide - \value WState_OwnCursor - \value WState_MouseTracking - \value WState_CompressKeys - \value WState_BlockUpdates - \value WState_InPaintEvent - \value WState_Reparented - \value WState_ConfigPending - \value WState_Resized - \value WState_AutoMask - \value WState_Polished - \value WState_DND - \value WState_Reserved0 \e internal - \value WState_CreatedHidden - \value WState_Maximized - \value WState_Minimized - \value WState_ForceDisabled - \value WState_Exposed - \value WState_HasMouse - \value WState_CreatedHidden - \value WState_OwnSizePolicy - \value WState_FullScreen -*/ - - -/*! - \enum TQt::WindowState - - \keyword window state - - This enum type is used to specify the current state of a top-level - window. - - The states are - - \value WindowNoState The window has no state set (in normal state). - \value WindowMinimized The window is minimized (i.e. iconified). - \value WindowMaximized The window is maximized with a frame around it. - \value WindowFullScreen The window fills the entire screen without any frame around it. - \value WindowActive The window is the active window, i.e. it has keyboard focus. - -*/ - -/*! - Constructs a widget which is a child of \a parent, with the name - \a name, widget flags set to \a f, and NETWM flags set to \a n. - - If \a parent is 0, the new widget becomes a top-level window. If - \a parent is another widget, this widget becomes a child window - inside \a parent. The new widget is deleted when its \a parent is - deleted. - - The \a name is sent to the TQObject constructor. - - The widget flags argument, \a f, is normally 0, but it can be set - to customize the window frame of a top-level widget (i.e. \a - parent must be 0). To customize the frame, set the \c - WStyle_Customize flag OR'ed with any of the \l TQt::WidgetFlags. - - If you add a child widget to an already visible widget you must - explicitly show the child to make it visible. - - Note that the X11 version of TQt may not be able to deliver all - combinations of style flags on all systems. This is because on - X11, TQt can only ask the window manager, and the window manager - can override the application's settings. On Windows, TQt can set - whatever flags you want. - - Example: - \code - TQLabel *splashScreen = new TQLabel( 0, "mySplashScreen", - WStyle_Customize | WStyle_Splash ); - \endcode -*/ - -TQWidget::TQWidget( TQWidget *parent, const char *name, WFlags f, NFlags n ) - : TQObject( parent, name ), TQPaintDevice( TQInternal::Widget ) -{ -#if defined(QT_CHECK_STATE) && !defined(TQ_WS_WIN) - if ( tqApp->type() == TQApplication::Tty ) { - tqWarning( "TQWidget: Cannot create a TQWidget when no GUI " - "is being used" ); - } -#endif - -#if defined(TQT_THREAD_SUPPORT) && defined(QT_CHECK_STATE) - if (TQThread::currentThreadObject() != TQApplication::guiThread()) { - tqFatal( "TQWidget: Cannot create a TQWidget outside of the main GUI thread" ); - } -#endif - - fstrut_dirty = 1; - - isWidget = TRUE; // is a widget - winid = 0; // default attributes - widget_state = 0; - widget_flags = f; - netwm_flags = n; - focus_policy = 0; - own_font = 0; - own_palette = 0; - sizehint_forced = 0; - is_closing = 0; - in_show = 0; - in_show_maximized = 0; - im_enabled = FALSE; -#ifndef TQT_NO_LAYOUT - lay_out = 0; -#endif - extra = 0; // no extra widget info -#ifndef TQT_NO_PALETTE - bg_col = pal.active().background(); // default background color -#endif - create(); // platform-dependent init -#ifndef TQT_NO_PALETTE - pal = isTopLevel() ? TQApplication::palette() : parentWidget()->palette(); -#endif - if ( ! isTopLevel() ) - fnt = parentWidget()->font(); -#if defined(TQ_WS_X11) - fnt.x11SetScreen( x11Screen() ); -#endif // TQ_WS_X11 - - if ( !isDesktop() ) - setBackgroundFromMode(); //### parts of this are done in create but not all (see reparent(...) ) - // make sure move/resize events are sent to all widgets - TQApplication::postEvent( this, new TQMoveEvent( crect.topLeft(), - crect.topLeft() ) ); - TQApplication::postEvent( this, new TQResizeEvent(crect.size(), - crect.size()) ); - if ( isTopLevel() ) { - setWState( WState_ForceHide | WState_CreatedHidden ); - TQFocusData *fd = focusData( TRUE ); - if ( fd->focusWidgets.findRef(this) < 0 ) - fd->focusWidgets.append( this ); - } else { - // propagate enabled state - if ( !parentWidget()->isEnabled() ) - setWState( WState_Disabled ); - // new widgets do not show up in already visible parents - if ( parentWidget()->isVisible() ) - setWState( WState_ForceHide | WState_CreatedHidden ); - } - if ( ++instanceCounter > maxInstances ) - maxInstances = instanceCounter; -} - -/*! - Destroys the widget. - - All this widget's children are deleted first. The application - exits if this widget is the main widget. -*/ - -TQWidget::~TQWidget() -{ -#if defined (QT_CHECK_STATE) - if ( paintingActive() ) - tqWarning( "%s (%s): deleted while being painted", className(), name() ); -#endif - - // Remove myself and all children from the can-take-focus list - TQFocusData *f = focusData( FALSE ); - if ( f ) { - TQPtrListIterator it(f->focusWidgets); - TQWidget *w; - while ( (w = it.current()) ) { - ++it; - TQWidget * p = w; - while( p && p != this ) - p = p->parentWidget(); - if ( p ) // my descendant - f->focusWidgets.removeRef( w ); - } - } - --instanceCounter; - - if ( TQApplication::main_widget == this ) { // reset main widget - TQApplication::main_widget = 0; - if (tqApp) - tqApp->quit(); - } - - if ( hasFocus() ) - clearFocus(); - - if ( isTopLevel() && isShown() && winId() ) - hide(); - - // A parent widget must destroy all its children before destroying itself - if ( childObjects ) { // delete children objects - TQObjectListIt it(*childObjects); - TQObject *obj; - while ( (obj=it.current()) ) { - ++it; - obj->parentObj = 0; - childObjects->removeRef( obj ); - delete obj; - } - delete childObjects; - childObjects = 0; - } - - TQApplication::removePostedEvents( this ); - - destroy(); // platform-dependent cleanup - if ( extra ) - deleteExtra(); -} - -int TQWidget::instanceCounter = 0; // Current number of widget instances -int TQWidget::maxInstances = 0; // Maximum number of widget instances - -/*! - \internal - Creates the global widget mapper. - The widget mapper converts window handles to widget pointers. - \sa destroyMapper() -*/ - -void TQWidget::createMapper() -{ - mapper = new TQWidgetMapper; - TQ_CHECK_PTR( mapper ); -} - -/*! - \internal - Destroys the global widget mapper. - \sa createMapper() -*/ - -void TQWidget::destroyMapper() -{ - if ( !mapper ) // already gone - return; - TQWidgetIntDictIt it( *((TQWidgetIntDict*)mapper) ); - TQWidgetMapper * myMapper = mapper; - mapper = 0; - TQWidget *w; - while ( (w=it.current()) ) { // remove parents widgets - ++it; - if ( !w->parentObj ) // widget is a parent - w->destroy( TRUE, TRUE ); - } - delete myMapper; -} - - -static TQWidgetList *wListInternal( TQWidgetMapper *mapper, bool onlyTopLevel ) -{ - TQWidgetList *list = new TQWidgetList; - TQ_CHECK_PTR( list ); - if ( mapper ) { - TQWidget *w; - TQWidgetIntDictIt it( *((TQWidgetIntDict*)mapper) ); - while ( (w=it.current()) ) { - ++it; - if ( !onlyTopLevel || w->isTopLevel() ) - list->append( w ); - } - } - return list; -} - -/*! - \internal - Returns a list of all widgets. - \sa tlwList(), TQApplication::allWidgets() -*/ - -TQWidgetList *TQWidget::wList() -{ - return wListInternal( mapper, FALSE ); -} - -/*! - \internal - Returns a list of all top level widgets. - \sa wList(), TQApplication::topLevelWidgets() -*/ - -TQWidgetList *TQWidget::tlwList() -{ - return wListInternal( mapper, TRUE ); -} - - -void TQWidget::setWinId( WId id ) // set widget identifier -{ - if ( !mapper ) // mapper destroyed - return; - if ( winid ) - mapper->remove( winid ); - winid = id; -#if defined(TQ_WS_X11) - hd = id; // X11: hd == ident -#endif - if ( id ) - mapper->insert( this ); -} - - -/*! - \internal - Returns a pointer to the block of extra widget data. -*/ - -TQWExtra *TQWidget::extraData() -{ - return extra; -} - - -/*! - \internal - Returns a pointer to the block of extra top level widget data. - - This data is guaranteed to exist for top level widgets. -*/ - -TQTLWExtra *TQWidget::topData() -{ - createTLExtra(); - return extra->topextra; -} - - -void TQWidget::createTLExtra() -{ - if ( !extra ) - createExtra(); - if ( !extra->topextra ) { - TQTLWExtra* x = extra->topextra = new TQTLWExtra; -#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) - x->opacity = 255; -#endif -#ifndef TQT_NO_WIDGET_TOPEXTRA - x->icon = 0; -#endif - x->focusData = 0; - x->fleft = x->fright = x->ftop = x->fbottom = 0; - x->incw = x->inch = 0; - x->basew = x->baseh = 0; - x->normalGeometry = TQRect(0,0,-1,-1); -#if defined(TQ_WS_X11) - x->embedded = 0; - x->parentWinId = 0; - x->spont_unmapped = 0; - x->dnd = 0; - x->uspos = 0; - x->ussize = 0; -#endif - x->savedFlags = 0; -#if defined(TQ_WS_QWS) && !defined(TQT_NO_QWS_MANAGER) - x->decor_allocated_region = TQRegion(); - x->qwsManager = 0; -#endif - createTLSysExtra(); - } -} - -/*! - \internal - Creates the widget extra data. -*/ - -void TQWidget::createExtra() -{ - if ( !extra ) { // if not exists - extra = new TQWExtra; - TQ_CHECK_PTR( extra ); - extra->minw = extra->minh = 0; - extra->maxw = extra->maxh = TQWIDGETSIZE_MAX; - extra->bg_pix = 0; - extra->focus_proxy = 0; -#ifndef TQT_NO_CURSOR - extra->curs = 0; -#endif - extra->topextra = 0; - extra->bg_mode = PaletteBackground; - extra->bg_mode_visual = PaletteBackground; - extra->bg_origin = WidgetOrigin; -#ifndef TQT_NO_STYLE - extra->style = 0; -#endif - extra->size_policy = TQSizePolicy( TQSizePolicy::Preferred, - TQSizePolicy::Preferred ); - - extra->m_ceData = NULL; - - createSysExtra(); - } -} - - -/*! - \internal - Deletes the widget extra data. -*/ - -void TQWidget::deleteExtra() -{ - if ( extra ) { // if exists - delete extra->m_ceData; - delete extra->bg_pix; -#ifndef TQT_NO_CURSOR - delete extra->curs; -#endif - deleteSysExtra(); - if ( extra->topextra ) { - deleteTLSysExtra(); -#ifndef TQT_NO_WIDGET_TOPEXTRA - delete extra->topextra->icon; -#endif - delete extra->topextra->focusData; -#if defined(TQ_WS_QWS) && !defined(TQT_NO_QWS_MANAGER) - delete extra->topextra->qwsManager; -#endif - delete extra->topextra; - } - delete extra; - // extra->xic destroyed in TQWidget::destroy() - extra = 0; - } -} - - -/*! - \internal - This function is called when a widget is hidden or destroyed. - It resets some application global pointers that should only refer active, - visible widgets. -*/ - -void TQWidget::deactivateWidgetCleanup() -{ - // If this was the active application window, reset it - if ( this == TQApplication::active_window ) - tqApp->setActiveWindow( 0 ); - // If the is the active mouse press widget, reset it -#ifdef TQ_WS_MAC - extern TQGuardedPtr qt_button_down; -#else - extern TQWidget *qt_button_down; -#endif - if ( this == (TQWidget *)qt_button_down ) - qt_button_down = 0; -} - - -/*! - Returns a pointer to the widget with window identifer/handle \a - id. - - The window identifier type depends on the underlying window - system, see \c ntqwindowdefs.h for the actual definition. If there - is no widget with this identifier, 0 is returned. -*/ - -TQWidget *TQWidget::find( WId id ) -{ - return mapper ? mapper->find( id ) : 0; -} - -/*! - \fn TQWidgetMapper *TQWidget::wmapper() - \internal - Returns a pointer to the widget mapper. - - The widget mapper is an internal dictionary that is used to map from - window identifiers/handles to widget pointers. - \sa find(), id() -*/ - -/*! - \fn WFlags TQWidget::getWFlags() const - - Returns the widget flags for this this widget. - - Widget flags are a combination of \l{TQt::WidgetFlags}. - - \sa testWFlags(), setWFlags(), clearWFlags() -*/ - -/*! - \fn void TQWidget::setWFlags( WFlags f ) - - Sets the widget flags \a f. - - Widget flags are a combination of \l{TQt::WidgetFlags}. - - \sa testWFlags(), getWFlags(), clearWFlags() -*/ - -/*! - \fn void TQWidget::clearWFlags( WFlags f ) - - Clears the widget flags \a f. - - Widget flags are a combination of \l{TQt::WidgetFlags}. - - \sa testWFlags(), getWFlags(), setWFlags() -*/ - - - -/*! - \fn WId TQWidget::winId() const - - Returns the window system identifier of the widget. - - Portable in principle, but if you use it you are probably about to - do something non-portable. Be careful. - - \sa find() -*/ - -#ifndef TQT_NO_STYLE -/*! - Returns the GUI style for this widget - - \sa TQWidget::setStyle(), TQApplication::setStyle(), TQApplication::style() -*/ - -TQStyle& TQWidget::style() const -{ - if ( extra && extra->style ) - return *extra->style; - TQStyle &ret = tqApp->style(); - return ret; -} - -/*! - Sets the widget's GUI style to \a style. Ownership of the style - object is not transferred. - - If no style is set, the widget uses the application's style, - TQApplication::style() instead. - - Setting a widget's style has no effect on existing or future child - widgets. - - \warning This function is particularly useful for demonstration - purposes, where you want to show TQt's styling capabilities. Real - applications should avoid it and use one consistent GUI style - instead. - - \sa style(), TQStyle, TQApplication::style(), TQApplication::setStyle() -*/ - -void TQWidget::setStyle( TQStyle *style ) -{ - TQStyle& old = TQWidget::style(); - createExtra(); - extra->style = style; - if ( !testWFlags(WType_Desktop) // (except desktop) - && testWState(WState_Polished)) { // (and have been polished) - old.unPolish( this ); - TQWidget::style().polish( this ); - } - styleChange( old ); -} - -/*! - \overload - - Sets the widget's GUI style to \a style using the TQStyleFactory. -*/ -TQStyle* TQWidget::setStyle( const TQString &style ) -{ - TQStyle *s = TQStyleFactory::create( style ); - setStyle( s ); - return s; -} - -/*! - This virtual function is called when the style of the widgets - changes. \a oldStyle is the previous GUI style; you can get the - new style from style(). - - Reimplement this function if your widget needs to know when its - GUI style changes. You will almost certainly need to update the - widget using update(). - - The default implementation updates the widget including its - geometry. - - \sa TQApplication::setStyle(), style(), update(), updateGeometry() -*/ - -void TQWidget::styleChange( TQStyle& /* oldStyle */ ) -{ - update(); - updateGeometry(); -} - -#endif - -/*! - \property TQWidget::isTopLevel - \brief whether the widget is a top-level widget - - A top-level widget is a widget which usually has a frame and a - \link TQWidget::caption caption (title)\endlink. \link - TQWidget::isPopup() Popup\endlink and \link TQWidget::isDesktop() - desktop\endlink widgets are also top-level widgets. - - A top-level widget can have a \link TQWidget::parentWidget() parent - widget\endlink. It will then be grouped with its parent and deleted - when the parent is deleted, minimized when the parent is minimized - etc. If supported by the window manager, it will also have a - common taskbar entry with its parent. - - TQDialog and TQMainWindow widgets are by default top-level, even if - a parent widget is specified in the constructor. This behavior is - specified by the \c WType_TopLevel widget flag. - - \sa topLevelWidget(), isDialog(), isModal(), isPopup(), isDesktop(), parentWidget() -*/ - -/*! - \property TQWidget::isDialog - \brief whether the widget is a dialog widget - - A dialog widget is a secondary top-level widget, i.e. a top-level - widget with a parent. - - \sa isTopLevel(), TQDialog -*/ - -/*! - \property TQWidget::isPopup - \brief whether the widget is a popup widget - - A popup widget is created by specifying the widget flag \c - WType_Popup to the widget constructor. A popup widget is also a - top-level widget. - - \sa isTopLevel() -*/ - -/*! - \property TQWidget::isDesktop - \brief whether the widget is a desktop widget, i.e. represents the desktop - - A desktop widget is also a top-level widget. - - \sa isTopLevel(), TQApplication::desktop() -*/ - -/*! - \property TQWidget::isModal - \brief whether the widget is a modal widget - - This property only makes sense for top-level widgets. A modal - widget prevents widgets in all other top-level widgets from - getting any input. - - \sa isTopLevel(), isDialog(), TQDialog -*/ - -/*! - \property TQWidget::underMouse - \brief whether the widget is under the mouse cursor - - This value is not updated properly during drag and drop - operations. - - \sa TQEvent::Enter, TQEvent::Leave -*/ - -/*! - \property TQWidget::minimized - \brief whether this widget is minimized (iconified) - - This property is only relevant for top-level widgets. - - \sa showMinimized(), visible, show(), hide(), showNormal(), maximized -*/ -bool TQWidget::isMinimized() const -{ return testWState(WState_Minimized); } - -/*! - Shows the widget minimized, as an icon. - - Calling this function only affects \link isTopLevel() top-level - widgets\endlink. - - \sa showNormal(), showMaximized(), show(), hide(), isVisible(), - isMinimized() -*/ -void TQWidget::showMinimized() -{ - bool isMin = isMinimized(); - if (isMin && isVisible()) return; - - if (!isMin) - setWindowState((windowState() & ~WindowActive) | WindowMinimized); - show(); - if (!isTopLevel()) - TQApplication::sendPostedEvents(this, TQEvent::ShowMinimized); -} - -/*! - \property TQWidget::maximized - \brief whether this widget is maximized - - This property is only relevant for top-level widgets. - - Note that due to limitations in some window-systems, this does not - always report the expected results (e.g. if the user on X11 - maximizes the window via the window manager, TQt has no way of - distinguishing this from any other resize). This is expected to - improve as window manager protocols evolve. - - \sa windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized -*/ -bool TQWidget::isMaximized() const -{ return testWState(WState_Maximized); } - - - -/*! Returns the current window state. The window state is a OR'ed - combination of TQt::WindowState: \c WindowMinimized, \c - WindowMaximized, \c WindowFullScreen and \c WindowActive. - - \sa TQt::WindowState setWindowState() - */ -uint TQWidget::windowState() const -{ - uint state = 0; - if (testWState(WState_Minimized)) - state |= WindowMinimized; - if (testWState(WState_Maximized)) - state |= WindowMaximized; - if (testWState(WState_FullScreen)) - state |= WindowFullScreen; - if (isActiveWindow()) - state |= WindowActive; - return state; -} - -/*! - \fn void TQWidget::setWindowState(uint windowState) - - Sets the window state to \a windowState. The window state is a OR'ed - combination of TQt::WindowState: \c WindowMinimized, \c - WindowMaximized, \c WindowFullScreen and \c WindowActive. - - If the window is not visible (i.e. isVisible() returns FALSE), the - window state will take effect when show() is called. For visible - windows, the change is immediate. For example, to toggle between - full-screen and mormal mode, use the following code: - - \code - w->setWindowState(w->windowState() ^ WindowFullScreen); - \endcode - - In order to restore and activate a minimized window (while - preserving its maximized and/or full-screen state), use the following: - - \code - w->setWindowState(w->windowState() & ~WindowMinimized | WindowActive); - \endcode - - Note: On some window systems \c WindowActive is not immediate, and may be - ignored in certain cases. - - \sa TQt::WindowState windowState() -*/ - -/*! - \property TQWidget::fullScreen - \brief whether the widget is full screen - - \sa windowState(), minimized, maximized -*/ -bool TQWidget::isFullScreen() const -{ return testWState(WState_FullScreen); } - -/*! - Shows the widget in full-screen mode. - - Calling this function only affects top-level widgets. - - To return from full-screen mode, call showNormal(). - - Full-screen mode works fine under Windows, but has certain - problems under X. These problems are due to limitations of the - ICCCM protocol that specifies the communication between X11 - clients and the window manager. ICCCM simply does not understand - the concept of non-decorated full-screen windows. Therefore, the - best we can do is to request a borderless window and place and - resize it to fill the entire screen. Depending on the window - manager, this may or may not work. The borderless window is - requested using MOTIF hints, which are at least partially - supported by virtually all modern window managers. - - An alternative would be to bypass the window manager entirely and - create a window with the WX11BypassWM flag. This has other severe - problems though, like totally broken keyboard focus and very - strange effects on desktop changes or when the user raises other - windows. - - X11 window managers that follow modern post-ICCCM specifications - support full-screen mode properly. - - \sa showNormal(), showMaximized(), show(), hide(), isVisible() -*/ -void TQWidget::showFullScreen() -{ - bool isFull = isFullScreen(); - if (isFull && isVisible()) - return; - - if (!isFull) - setWindowState(windowState() | WindowFullScreen); - show(); - if (!isTopLevel()) - TQApplication::sendPostedEvents(this, TQEvent::ShowFullScreen); - setActiveWindow(); -} - -/*! - Shows the widget maximized. - - Calling this function only affects \link isTopLevel() top-level - widgets\endlink. - - On X11, this function may not work properly with certain window - managers. See the \link geometry.html Window Geometry - documentation\endlink for an explanation. - - \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible() -*/ -void TQWidget::showMaximized() -{ - if (isMaximized() && isVisible() && !isMinimized()) - return; - - setWindowState((windowState() & ~WindowMinimized) | WindowMaximized); - show(); - if (!isTopLevel()) - TQApplication::sendPostedEvents(this, TQEvent::ShowMaximized); -} - -/*! - Restores the widget after it has been maximized or minimized. - - Calling this function only affects \link isTopLevel() top-level - widgets\endlink. - - \sa setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible() -*/ -void TQWidget::showNormal() -{ - setWindowState(WindowNoState); - show(); - if (!isTopLevel()) - TQApplication::sendPostedEvents(this, TQEvent::ShowNormal); -} - -/*! - Returns TRUE if this widget would become enabled if \a ancestor is - enabled; otherwise returns FALSE. - - This is the case if neither the widget itself nor every parent up - to but excluding \a ancestor has been explicitly disabled. - - isEnabledTo(0) is equivalent to isEnabled(). - - \sa setEnabled() enabled -*/ - -bool TQWidget::isEnabledTo( TQWidget* ancestor ) const -{ - const TQWidget * w = this; - while ( w && !w->testWState(WState_ForceDisabled) - && !w->isTopLevel() - && w->parentWidget() - && w->parentWidget() != ancestor ) - w = w->parentWidget(); - return !w->testWState( WState_ForceDisabled ); -} - - -/*! - \fn bool TQWidget::isEnabledToTLW() const - \obsolete - - This function is deprecated. It is equivalent to isEnabled() -*/ - -/*! - \property TQWidget::enabled - \brief whether the widget is enabled - - An enabled widget receives keyboard and mouse events; a disabled - widget does not. In fact, an enabled widget only receives keyboard - events when it is in focus. - - Some widgets display themselves differently when they are - disabled. For example a button might draw its label grayed out. If - your widget needs to know when it becomes enabled or disabled, you - can reimplement the enabledChange() function. - - Disabling a widget implicitly disables all its children. Enabling - respectively enables all child widgets unless they have been - explicitly disabled. - - \sa isEnabled(), isEnabledTo(), TQKeyEvent, TQMouseEvent, enabledChange() -*/ -void TQWidget::setEnabled( bool enable ) -{ - if ( enable ) - clearWState( WState_ForceDisabled ); - else - setWState( WState_ForceDisabled ); - - if ( !isTopLevel() && parentWidget() && - !parentWidget()->isEnabled() && enable ) - return; // nothing we can do - - if ( enable ) { - if ( testWState(WState_Disabled) ) { - clearWState( WState_Disabled ); - setBackgroundFromMode(); - enabledChange( !enable ); - if ( children() ) { - TQObjectListIt it( *children() ); - TQWidget *w; - while( (w = (TQWidget *)it.current()) != 0 ) { - ++it; - if ( w->isWidgetType() && - !w->testWState( WState_ForceDisabled ) ) - w->setEnabled( TRUE ); - } - } - } - } else { - if ( !testWState(WState_Disabled) ) { - if (focusWidget() == this) { - bool parentIsEnabled = (!parentWidget() || parentWidget()->isEnabled()); - if (!parentIsEnabled || !focusNextPrevChild(TRUE)) - clearFocus(); - } - setWState( WState_Disabled ); - setBackgroundFromMode(); - enabledChange( !enable ); - if ( children() ) { - TQObjectListIt it( *children() ); - TQWidget *w; - while( (w = (TQWidget *)it.current()) != 0 ) { - ++it; - if ( w->isWidgetType() && w->isEnabled() ) { - w->setEnabled( FALSE ); - w->clearWState( WState_ForceDisabled ); - } - } - } - } - } -#if defined(TQ_WS_X11) - if ( testWState( WState_OwnCursor ) ) { - // enforce the windows behavior of clearing the cursor on - // disabled widgets - - extern void tqt_x11_enforce_cursor( TQWidget * w ); // defined in qwidget_x11.cpp - tqt_x11_enforce_cursor( this ); - } -#endif -#ifdef TQ_WS_WIN - TQInputContext::enable( this, im_enabled & !((bool)testWState(WState_Disabled)) ); -#endif -} - -/*! - Disables widget input events if \a disable is TRUE; otherwise - enables input events. - - See the \l enabled documentation for more information. - - \sa isEnabledTo(), TQKeyEvent, TQMouseEvent, enabledChange() -*/ -void TQWidget::setDisabled( bool disable ) -{ - setEnabled( !disable ); -} - -/*! - \fn void TQWidget::enabledChange( bool oldEnabled ) - - This virtual function is called from setEnabled(). \a oldEnabled - is the previous setting; you can get the new setting from - isEnabled(). - - Reimplement this function if your widget needs to know when it - becomes enabled or disabled. You will almost certainly need to - update the widget using update(). - - The default implementation repaints the visible part of the - widget. - - \sa setEnabled(), isEnabled(), repaint(), update(), clipRegion() -*/ - -void TQWidget::enabledChange( bool ) -{ - update(); -#if defined(QT_ACCESSIBILITY_SUPPORT) - TQAccessible::updateAccessibility( this, 0, TQAccessible::StateChanged ); -#endif -} - -/*! - \fn void TQWidget::windowActivationChange( bool oldActive ) - - This virtual function is called for a widget when its window is - activated or deactivated by the window system. \a oldActive is the - previous state; you can get the new setting from isActiveWindow(). - - Reimplement this function if your widget needs to know when its - window becomes activated or deactivated. - - The default implementation updates the visible part of the widget - if the inactive and the active colorgroup are different for colors - other than the highlight and link colors. - - \sa setActiveWindow(), isActiveWindow(), update(), palette() -*/ - -void TQWidget::windowActivationChange( bool ) -{ -#ifndef TQT_NO_PALETTE - if ( !isVisible() ) - return; - - const TQColorGroup &acg = palette().active(); - const TQColorGroup &icg = palette().inactive(); - - if ( acg != icg ) { - BackgroundMode bm = backgroundMode(); - TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode(bm); - if ( bm > NoBackground && acg.brush(role) != icg.brush(role) ) - setBackgroundFromMode(); - else if ( acg.background() == icg.background() && - acg.base() == icg.base() && - acg.text() == icg.text() && - acg.foreground() == icg.foreground() && - acg.button() == icg.button() && - acg.buttonText() == icg.buttonText() && - acg.brightText() == icg.brightText() && - acg.dark() == icg.dark() && - acg.light() == icg.light() && - acg.mid() == icg.mid() && - acg.midlight() == icg.midlight() && - acg.shadow() == icg.shadow() ) - return; - update(); - } -#endif -} - -/*! - \property TQWidget::frameGeometry - \brief geometry of the widget relative to its parent including any - window frame - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of geometry issues with top-level widgets. - - \sa geometry() x() y() pos() -*/ -TQRect TQWidget::frameGeometry() const -{ - if (isTopLevel() && ! isPopup()) { - if (fstrut_dirty) - updateFrameStrut(); - TQWidget *that = (TQWidget *) this; - TQTLWExtra *top = that->topData(); - return TQRect(crect.x() - top->fleft, - crect.y() - top->ftop, - crect.width() + top->fleft + top->fright, - crect.height() + top->ftop + top->fbottom); - } - return crect; -} - -/*! \property TQWidget::x - \brief the x coordinate of the widget relative to its parent including - any window frame - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa frameGeometry, y, pos -*/ -int TQWidget::x() const -{ - if (isTopLevel() && ! isPopup()) { - if (fstrut_dirty) - updateFrameStrut(); - TQWidget *that = (TQWidget *) this; - return crect.x() - that->topData()->fleft; - } - return crect.x(); -} - -/*! - \property TQWidget::y - \brief the y coordinate of the widget relative to its parent and - including any window frame - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa frameGeometry, x, pos -*/ -int TQWidget::y() const -{ - if (isTopLevel() && ! isPopup()) { - if (fstrut_dirty) - updateFrameStrut(); - TQWidget *that = (TQWidget *) this; - return crect.y() - that->topData()->ftop; - } - return crect.y(); -} - -/*! - \property TQWidget::pos - \brief the position of the widget within its parent widget - - If the widget is a top-level widget, the position is that of the - widget on the desktop, including its frame. - - When changing the position, the widget, if visible, receives a - move event (moveEvent()) immediately. If the widget is not - currently visible, it is guaranteed to receive an event before it - is shown. - - move() is virtual, and all other overloaded move() implementations - in TQt call it. - - \warning Calling move() or setGeometry() inside moveEvent() can - lead to infinite recursion. - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa frameGeometry, size x(), y() -*/ -TQPoint TQWidget::pos() const -{ - if (isTopLevel() && ! isPopup()) { - if (fstrut_dirty) - updateFrameStrut(); - TQWidget *that = (TQWidget *) this; - TQTLWExtra *top = that->topData(); - return TQPoint(crect.x() - top->fleft, crect.y() - top->ftop); - } - return crect.topLeft(); -} - -/*! - \property TQWidget::geometry - \brief the geometry of the widget relative to its parent and - excluding the window frame - - When changing the geometry, the widget, if visible, receives a - move event (moveEvent()) and/or a resize event (resizeEvent()) - immediately. If the widget is not currently visible, it is - guaranteed to receive appropriate events before it is shown. - - The size component is adjusted if it lies outside the range - defined by minimumSize() and maximumSize(). - - setGeometry() is virtual, and all other overloaded setGeometry() - implementations in TQt call it. - - \warning Calling setGeometry() inside resizeEvent() or moveEvent() - can lead to infinite recursion. - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa frameGeometry(), rect(), move(), resize(), moveEvent(), - resizeEvent(), minimumSize(), maximumSize() -*/ - -/*! - \property TQWidget::size - \brief the size of the widget excluding any window frame - - When resizing, the widget, if visible, receives a resize event - (resizeEvent()) immediately. If the widget is not currently - visible, it is guaranteed to receive an event before it is shown. - - The size is adjusted if it lies outside the range defined by - minimumSize() and maximumSize(). Furthermore, the size is always - at least TQSize(1, 1). For toplevel widgets, the minimum size - might be larger, depending on the window manager. - - If you want a top-level window to have a fixed size, call - setResizeMode( TQLayout::FreeResize ) on its layout. - - resize() is virtual, and all other overloaded resize() - implementations in TQt call it. - - \warning Calling resize() or setGeometry() inside resizeEvent() can - lead to infinite recursion. - - \sa pos, geometry, minimumSize, maximumSize, resizeEvent() -*/ - -/*! - \property TQWidget::width - \brief the width of the widget excluding any window frame - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa geometry, height, size -*/ - -/*! - \property TQWidget::height - \brief the height of the widget excluding any window frame - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa geometry, width, size -*/ - -/*! - \property TQWidget::rect - \brief the internal geometry of the widget excluding any window - frame - - The rect property equals TQRect(0, 0, width(), height()). - - See the \link geometry.html Window Geometry documentation\endlink - for an overview of top-level widget geometry. - - \sa size -*/ - -/*! - \property TQWidget::childrenRect - \brief the bounding rectangle of the widget's children - - Hidden children are excluded. - - \sa childrenRegion() geometry() -*/ - -TQRect TQWidget::childrenRect() const -{ - TQRect r( 0, 0, 0, 0 ); - if ( !children() ) - return r; - TQObjectListIt it( *children() ); - TQObject *obj; - while ( (obj = it.current()) ) { - ++it; - if ( obj->isWidgetType() && !((TQWidget*)obj)->isHidden() && !((TQWidget*)obj)->isTopLevel()) - r = r.unite( ((TQWidget*)obj)->geometry() ); - } - return r; -} - -/*! - \property TQWidget::childrenRegion - \brief the combined region occupied by the widget's children - - Hidden children are excluded. - - \sa childrenRect() geometry() -*/ - -TQRegion TQWidget::childrenRegion() const -{ - TQRegion r; - if ( !children() ) - return r; - TQObjectListIt it( *children() ); // iterate over all children - TQObject *obj; - while ( (obj=it.current()) ) { - ++it; - if ( obj->isWidgetType() && !((TQWidget*)obj)->isHidden() && !((TQWidget*)obj)->isTopLevel()) - r = r.unite( ((TQWidget*)obj)->geometry() ); - } - return r; -} - - -/*! - \property TQWidget::minimumSize - \brief the widget's minimum size - - The widget cannot be resized to a smaller size than the minimum - widget size. The widget's size is forced to the minimum size if - the current size is smaller. - - If you use a layout inside the widget, the minimum size will be - set by the layout and not by setMinimumSize(), unless you set the - layout's resize mode to TQLayout::FreeResize. - - \sa minimumWidth, minimumHeight, maximumSize, sizeIncrement - TQLayout::setResizeMode() -*/ - -TQSize TQWidget::minimumSize() const -{ - return extra ? TQSize( extra->minw, extra->minh ) : TQSize( 0, 0 ); -} - -/*! - \property TQWidget::maximumSize - \brief the widget's maximum size - - The widget cannot be resized to a larger size than the maximum - widget size. - - \sa maximumWidth(), maximumHeight(), setMaximumSize(), - minimumSize(), sizeIncrement() -*/ - -TQSize TQWidget::maximumSize() const -{ - return extra ? TQSize( extra->maxw, extra->maxh ) - : TQSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX ); -} - - -/*! - \property TQWidget::minimumWidth - \brief the widget's minimum width - - This property corresponds to minimumSize().width(). - - \sa minimumSize, minimumHeight -*/ - -/*! - \property TQWidget::minimumHeight - \brief the widget's minimum height - - This property corresponds to minimumSize().height(). - - \sa minimumSize, minimumWidth -*/ - -/*! - \property TQWidget::maximumWidth - \brief the widget's maximum width - - This property corresponds to maximumSize().width(). - - \sa maximumSize, maximumHeight -*/ - -/*! - \property TQWidget::maximumHeight - \brief the widget's maximum height - - This property corresponds to maximumSize().height(). - - \sa maximumSize, maximumWidth -*/ - -/*! - \property TQWidget::sizeIncrement - \brief the size increment of the widget - - When the user resizes the window, the size will move in steps of - sizeIncrement().width() pixels horizontally and - sizeIncrement.height() pixels vertically, with baseSize() as the - basis. Preferred widget sizes are for non-negative integers \e i - and \e j: - \code - width = baseSize().width() + i * sizeIncrement().width(); - height = baseSize().height() + j * sizeIncrement().height(); - \endcode - - Note that while you can set the size increment for all widgets, it - only affects top-level widgets. - - \warning The size increment has no effect under Windows, and may - be disregarded by the window manager on X. - - \sa size, minimumSize, maximumSize -*/ -TQSize TQWidget::sizeIncrement() const -{ - return ( extra && extra->topextra ) - ? TQSize( extra->topextra->incw, extra->topextra->inch ) - : TQSize( 0, 0 ); -} - -/*! - \property TQWidget::baseSize - \brief the base size of the widget - - The base size is used to calculate a proper widget size if the - widget defines sizeIncrement(). - - \sa setSizeIncrement() -*/ - -TQSize TQWidget::baseSize() const -{ - return ( extra != 0 && extra->topextra != 0 ) - ? TQSize( extra->topextra->basew, extra->topextra->baseh ) - : TQSize( 0, 0 ); -} - -/*! - Sets both the minimum and maximum sizes of the widget to \a s, - thereby preventing it from ever growing or shrinking. - - \sa setMaximumSize() setMinimumSize() -*/ - -void TQWidget::setFixedSize( const TQSize & s) -{ - setMinimumSize( s ); - setMaximumSize( s ); - resize( s ); -} - - -/*! - \overload void TQWidget::setFixedSize( int w, int h ) - - Sets the width of the widget to \a w and the height to \a h. -*/ - -void TQWidget::setFixedSize( int w, int h ) -{ - setMinimumSize( w, h ); - setMaximumSize( w, h ); - resize( w, h ); -} - -void TQWidget::setMinimumWidth( int w ) -{ - setMinimumSize( w, minimumSize().height() ); -} - -void TQWidget::setMinimumHeight( int h ) -{ - setMinimumSize( minimumSize().width(), h ); -} - -void TQWidget::setMaximumWidth( int w ) -{ - setMaximumSize( w, maximumSize().height() ); -} - -void TQWidget::setMaximumHeight( int h ) -{ - setMaximumSize( maximumSize().width(), h ); -} - -/*! - Sets both the minimum and maximum width of the widget to \a w - without changing the heights. Provided for convenience. - - \sa sizeHint() minimumSize() maximumSize() setFixedSize() -*/ - -void TQWidget::setFixedWidth( int w ) -{ - setMinimumSize( w, minimumSize().height() ); - setMaximumSize( w, maximumSize().height() ); -} - - -/*! - Sets both the minimum and maximum heights of the widget to \a h - without changing the widths. Provided for convenience. - - \sa sizeHint() minimumSize() maximumSize() setFixedSize() -*/ - -void TQWidget::setFixedHeight( int h ) -{ - setMinimumSize( minimumSize().width(), h ); - setMaximumSize( maximumSize().width(), h ); -} - - -/*! - Translates the widget coordinate \a pos to the coordinate system - of \a parent. The \a parent must not be 0 and must be a parent - of the calling widget. - - \sa mapFrom() mapToParent() mapToGlobal() hasMouse() -*/ - -TQPoint TQWidget::mapTo( TQWidget * parent, const TQPoint & pos ) const -{ - TQPoint p = pos; - if ( parent ) { - const TQWidget * w = this; - while ( w != parent ) { - p = w->mapToParent( p ); - w = w->parentWidget(); - } - } - return p; -} - - -/*! - Translates the widget coordinate \a pos from the coordinate system - of \a parent to this widget's coordinate system. The \a parent - must not be 0 and must be a parent of the calling widget. - - \sa mapTo() mapFromParent() mapFromGlobal() hasMouse() -*/ - -TQPoint TQWidget::mapFrom( TQWidget * parent, const TQPoint & pos ) const -{ - TQPoint p( pos ); - if ( parent ) { - const TQWidget * w = this; - while ( w != parent ) { - p = w->mapFromParent( p ); - w = w->parentWidget(); - } - } - return p; -} - - -/*! - Translates the widget coordinate \a pos to a coordinate in the - parent widget. - - Same as mapToGlobal() if the widget has no parent. - - \sa mapFromParent() mapTo() mapToGlobal() hasMouse() -*/ - -TQPoint TQWidget::mapToParent( const TQPoint &pos ) const -{ - return pos + crect.topLeft(); -} - -/*! - Translates the parent widget coordinate \a pos to widget - coordinates. - - Same as mapFromGlobal() if the widget has no parent. - - \sa mapToParent() mapFrom() mapFromGlobal() hasMouse() -*/ - -TQPoint TQWidget::mapFromParent( const TQPoint &pos ) const -{ - return pos - crect.topLeft(); -} - - -/*! - Returns the top-level widget for this widget, i.e. the next - ancestor widget that has (or could have) a window-system frame. - - If the widget is a top-level, the widget itself is returned. - - Typical usage is changing the window caption: - - \code - aWidget->topLevelWidget()->setCaption( "New Caption" ); - \endcode - - \sa isTopLevel() -*/ - -TQWidget *TQWidget::topLevelWidget() const -{ - TQWidget *w = (TQWidget *)this; - TQWidget *p = w->parentWidget(); - while ( !w->testWFlags(WType_TopLevel) && p ) { - w = p; - p = p->parentWidget(); - } - return w; -} - - -/*! - \property TQWidget::paletteForegroundColor - \brief the foreground color of the widget - - setPaletteForegroundColor() is a convenience function that creates - and sets a modified TQPalette with setPalette(). The palette is - modified according to the widget's \e {background mode}. For - example, if the background mode is \c PaletteButton the palette entry - \c TQColorGroup::ButtonText is set to color. - - \sa setPalette() TQApplication::setPalette() backgroundMode() - foregroundColor() setBackgroundMode() setEraseColor() -*/ -const TQColor &TQWidget::paletteForegroundColor() const -{ -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - return colorGroup().color( TQPalette::foregroundRoleFromMode(mode) ); -#else - return TQt::black; -#endif -} - -void TQWidget::setPaletteForegroundColor( const TQColor & color ) -{ -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - TQPalette pal = palette(); - TQColorGroup::ColorRole role = TQPalette::foregroundRoleFromMode( mode ); - pal.setColor( TQPalette::Active, role, color ); - pal.setColor( TQPalette::Inactive, role, color ); - pal.setColor( TQPalette::Disabled, role, color ); - setPalette( pal ); -#endif -} - - -/*! - Same as paletteForegroundColor() - */ -const TQColor &TQWidget::foregroundColor() const -{ - return paletteForegroundColor(); -} - - -/*! - \fn const TQColor& TQWidget::eraseColor() const - - Returns the erase color of the widget. - - \sa setEraseColor() setErasePixmap() backgroundColor() -*/ - -/*! - Sets the erase color of the widget to \a color. - - The erase color is the color the widget is to be cleared to before - paintEvent() is called. If there is an erase pixmap (set using - setErasePixmap()), then this property has an indeterminate value. - - \sa erasePixmap(), backgroundColor(), backgroundMode(), palette() -*/ -void TQWidget::setEraseColor( const TQColor & color ) -{ - setBackgroundModeDirect( FixedColor ); - setBackgroundColorDirect( color ); - update(); -} - -/*! - Returns the widget's erase pixmap. - - \sa setErasePixmap() eraseColor() -*/ -const TQPixmap *TQWidget::erasePixmap() const -{ - return ( extra && extra->bg_pix ) ? extra->bg_pix : 0; -} - -/*! - Sets the widget's erase pixmap to \a pixmap. - - This pixmap is used to clear the widget before paintEvent() is - called. -*/ -void TQWidget::setErasePixmap( const TQPixmap &pixmap ) -{ - // This function is called with a null pixmap by setBackgroundEmpty(). - setBackgroundPixmapDirect( pixmap ); - setBackgroundModeDirect( FixedPixmap ); - update(); -} - -void TQWidget::setBackgroundFromMode() -{ -#ifndef TQT_NO_PALETTE - TQColorGroup::ColorRole r = TQColorGroup::Background; - if ( extra ) { - int i = (BackgroundMode)extra->bg_mode; - if ( i == FixedColor || i == FixedPixmap || i == NoBackground ) { - // Mode is for fixed color, not one based on palette, - // so nothing to do. - return; - } - switch( i ) { - case PaletteForeground: - r = TQColorGroup::Foreground; - break; - case PaletteButton: - r = TQColorGroup::Button; - break; - case PaletteLight: - r = TQColorGroup::Light; - break; - case PaletteMidlight: - r = TQColorGroup::Midlight; - break; - case PaletteDark: - r = TQColorGroup::Dark; - break; - case PaletteMid: - r = TQColorGroup::Mid; - break; - case PaletteText: - r = TQColorGroup::Text; - break; - case PaletteBrightText: - r = TQColorGroup::BrightText; - break; - case PaletteBase: - r = TQColorGroup::Base; - break; - case PaletteBackground: - r = TQColorGroup::Background; - break; - case PaletteShadow: - r = TQColorGroup::Shadow; - break; - case PaletteHighlight: - r = TQColorGroup::Highlight; - break; - case PaletteHighlightedText: - r = TQColorGroup::HighlightedText; - break; - case PaletteButtonText: - r = TQColorGroup::ButtonText; - break; - case X11ParentRelative: -#if defined(TQ_WS_X11) - setBackgroundX11Relative(); -#endif - return; - } - } - const TQColorGroup &cg = colorGroup(); - TQPixmap * p = cg.brush( r ).pixmap(); - if ( p ) - setBackgroundPixmapDirect( *p ); - else - setBackgroundColorDirect( cg.color( r ) ); -#endif -} - -/*! - \enum TQt::BackgroundMode - - This enum describes how the background of a widget changes, as the - widget's palette changes. - - The background is what the widget contains when \link - TQWidget::paintEvent() paintEvent()\endlink is called. To minimize - flicker, this should be the most common color or pixmap in the - widget. For \c PaletteBackground, use colorGroup().brush( \c - TQColorGroup::Background ), and so on. - - \value PaletteForeground - \value PaletteBackground - \value PaletteButton - \value PaletteLight - \value PaletteMidlight - \value PaletteDark - \value PaletteMid - \value PaletteText - \value PaletteBrightText - \value PaletteButtonText - \value PaletteBase - \value PaletteShadow - \value PaletteHighlight - \value PaletteHighlightedText - \value PaletteLink - \value PaletteLinkVisited - \value X11ParentRelative (internal use only) - - The final three values have special meaning: - - \value NoBackground the widget is not cleared before paintEvent(). - If the widget's paint event always draws on all the pixels, using - this mode can be both fast and flicker-free. - \value FixedColor the widget is cleared to a fixed color, normally - different from all the ones in the palette(). Set using \link - TQWidget::setPaletteBackgroundColor() - setPaletteBackgroundColor()\endlink. - \value FixedPixmap the widget is cleared to a fixed pixmap, - normally different from all the ones in the palette(). Set using - \link TQWidget::setPaletteBackgroundPixmap() - setPaletteBackgroundPixmap()\endlink. - - Although \c FixedColor and \c FixedPixmap are sometimes just - right, if you use them, make sure that you test your application - when the desktop color scheme has been changed. (On X11, a quick - way to test this is e.g. "./myapp -bg paleblue". On Windows, you - must use the control panel.) - - \sa TQWidget::setBackgroundMode() TQWidget::backgroundMode() - TQWidget::setBackgroundPixmap() TQWidget::setPaletteBackgroundColor() -*/ - -/*! - \property TQWidget::backgroundMode - \brief the color role used for painting the background of the widget - - setPaletteBackgroundColor() reads this property to determine which - entry of the \link TQWidget::palette palette\endlink to set. - - For most widgets the default suffices (\c PaletteBackground, - typically gray), but some need to use \c PaletteBase (the - background color for text output, typically white) or another - role. - - TQListBox, which is "sunken" and uses the base color to contrast - with its environment, does this in its constructor: - - \code - setBackgroundMode( PaletteBase ); - \endcode - - You will never need to set the background mode of a built-in - widget in TQt, but you might consider setting it in your custom - widgets, so that setPaletteBackgroundColor() works as expected. - - Note that two of the BackgroundMode values make no sense for - setBackgroundMode(), namely \c FixedPixmap and \c FixedColor. You - must call setBackgroundPixmap() and setPaletteBackgroundColor() - instead. -*/ -TQt::BackgroundMode TQWidget::backgroundMode() const -{ - return extra ? (BackgroundMode) extra->bg_mode : PaletteBackground; -} - -void TQWidget::setBackgroundMode( BackgroundMode m ) -{ - setBackgroundMode( m, m ); - if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == - WState_Visible ) - update(); -} - - -/*! - \overload - - Sets the widget's own background mode to \a m and the visual - background mode to \a visual. The visual background mode is used - with the designable properties \c backgroundColor, \c - foregroundColor and \c backgroundPixmap. - - For complex controls, the logical background mode sometimes - differs from a widget's own background mode. A spinbox for example - has \c PaletteBackground as background mode (typically dark gray), - while it's embedded lineedit control uses \c PaletteBase - (typically white). Since the lineedit covers most of the visual - area of a spinbox, it defines \c PaletteBase to be its \a visual - background mode. Changing the \c backgroundColor property thus - changes the lineedit control's background, which is exactly what - the user expects in \e{TQt Designer}. -*/ -void TQWidget::setBackgroundMode( BackgroundMode m, BackgroundMode visual ) -{ - if ( m == NoBackground ) { - setBackgroundEmpty(); - } else if ( m == FixedColor || m == FixedPixmap ) { -#if defined(QT_DEBUG) - tqWarning( "TQWidget::setBackgroundMode: FixedColor or FixedPixmap makes" - " no sense" ); -#endif - return; - } - setBackgroundModeDirect(m); - if ( m != visual && !extra ) - createExtra(); - if ( extra ) - extra->bg_mode_visual = visual; -} - - -/*! - \internal -*/ -void TQWidget::setBackgroundModeDirect( BackgroundMode m ) -{ - if ( m == PaletteBackground && !extra ) - return; - - createExtra(); - if ( (BackgroundMode)extra->bg_mode != m ) { - extra->bg_mode = m; - extra->bg_mode_visual = m; - setBackgroundFromMode(); - } -} - -/*! - \property TQWidget::paletteBackgroundColor - \brief the background color of the widget - - The palette background color is usually set implicitly by - setBackgroundMode(), although it can also be set explicitly by - setPaletteBackgroundColor(). setPaletteBackgroundColor() is a - convenience function that creates and sets a modified TQPalette - with setPalette(). The palette is modified according to the - widget's background mode. For example, if the background mode is - \c PaletteButton the color used for the palette's \c - TQColorGroup::Button color entry is set. - - If there is a background pixmap (set using - setPaletteBackgroundPixmap()), then the return value of this - function is indeterminate. - - \sa paletteBackgroundPixmap, paletteForegroundColor, palette, colorGroup() -*/ -const TQColor & TQWidget::paletteBackgroundColor() const -{ -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - switch( mode ) { - case FixedColor: - case FixedPixmap : - case NoBackground: - case X11ParentRelative: - return eraseColor(); - default: - TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); - return colorGroup().color( role ); - } -#else - return eraseColor(); -#endif -} - -void TQWidget::setPaletteBackgroundColor( const TQColor &color ) -{ -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - switch( mode ) { - case FixedColor: - case FixedPixmap : - case NoBackground: - case X11ParentRelative: - setEraseColor( color ); - break; - default: - TQPalette pal = palette(); - TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); - pal.setColor( TQPalette::Active, role, color ); - pal.setColor( TQPalette::Inactive, role, color ); - pal.setColor( TQPalette::Disabled, role, color ); - setPalette( pal ); - break; - } -#else - setEraseColor( color ); -#endif -} - - -/*! - \property TQWidget::paletteBackgroundPixmap - \brief the background pixmap of the widget - - The palette background pixmap is usually set implicitly by - setBackgroundMode(), although it can also be set explicitly by - setPaletteBackgroundPixmap(). setPaletteBackgroundPixmap() is a - convenience function that creates and sets a modified TQPalette - with setPalette(). The palette is modified according to the - widget's background mode. For example, if the background mode is - \c PaletteButton the pixmap used for the palette's - \c TQColorGroup::Button color entry is set. - - If there is a plain background color (set using - setPaletteBackgroundColor()), then this function returns 0. - - \sa paletteBackgroundColor, paletteForegroundColor, palette, colorGroup() -*/ -const TQPixmap *TQWidget::paletteBackgroundPixmap() const -{ -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - switch( mode ) { - case FixedColor: - case FixedPixmap : - case NoBackground: - case X11ParentRelative: - return erasePixmap(); - default: - TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); - return palette().brush( TQPalette::Active, role ).pixmap(); - } -#else - return erasePixmap(); -#endif -} - -void TQWidget::setPaletteBackgroundPixmap( const TQPixmap &pixmap ) -{ -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - switch( mode ) { - case FixedColor: - case FixedPixmap : - case NoBackground: - case X11ParentRelative: - setErasePixmap( pixmap ); - break; - default: - TQPalette pal = palette(); - TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); - pal.setBrush( TQPalette::Active, role, TQBrush( pal.color( TQPalette::Active, role ), pixmap ) ); - pal.setBrush( TQPalette::Inactive, role, TQBrush( pal.color( TQPalette::Inactive, role ), pixmap ) ); - pal.setBrush( TQPalette::Disabled, role, TQBrush( pal.color( TQPalette::Disabled, role ), pixmap ) ); - setPalette( pal ); - break; - } -#else - setErasePixmap( pixmap ); -#endif -} - - -/*! - \property TQWidget::backgroundBrush - \brief the widget's background brush - - The background brush depends on a widget's palette and its - background mode. - - \sa backgroundColor(), backgroundPixmap(), eraseColor(), palette, - TQApplication::setPalette() -*/ -const TQBrush& TQWidget::backgroundBrush() const -{ - static TQBrush noBrush; -#ifndef TQT_NO_PALETTE - BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; - switch( mode ) { - case FixedColor: - case FixedPixmap : - case NoBackground: - case X11ParentRelative: - return noBrush; - default: - TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); - return colorGroup().brush( role ); - } -#else - return noBrush; -#endif -} - - -/*! - \property TQWidget::colorGroup - \brief the current color group of the widget palette - - The color group is determined by the state of the widget. A - disabled widget has the TQPalette::disabled() color group, a widget - with keyboard focus has the TQPalette::active() color group, and an - inactive widget has the TQPalette::inactive() color group. - - \sa palette -*/ -#ifndef TQT_NO_PALETTE -const TQColorGroup &TQWidget::colorGroup() const -{ - if ( !isEnabled() ) - return palette().disabled(); - else if ( !isVisible() || isActiveWindow() ) - return palette().active(); - else - return palette().inactive(); -} -#endif - -/*! - \property TQWidget::palette - \brief the widget's palette - - As long as no special palette has been set, or after unsetPalette() - has been called, this is either a special palette for the widget - class, the parent's palette or (if this widget is a top level - widget), the default application palette. - - Instead of defining an entirely new palette, you can also use the - \link TQWidget::paletteBackgroundColor paletteBackgroundColor\endlink, - \link TQWidget::paletteBackgroundPixmap paletteBackgroundPixmap\endlink and - \link TQWidget::paletteForegroundColor paletteForegroundColor\endlink - convenience properties to change a widget's - background and foreground appearance only. - - \sa ownPalette, colorGroup(), TQApplication::palette() -*/ - -#ifndef TQT_NO_PALETTE -void TQWidget::setPalette( const TQPalette &palette ) -{ - own_palette = TRUE; - if ( pal == palette ) - return; - TQPalette old = pal; - pal = palette; - setBackgroundFromMode(); - TQEvent ev( TQEvent::PaletteChange ); - TQApplication::sendEvent( this, &ev ); - if ( children() ) { - TQEvent e( TQEvent::ParentPaletteChange ); - TQObjectListIt it( *children() ); - TQWidget *w; - while( (w=(TQWidget *)it.current()) != 0 ) { - ++it; - if ( w->isWidgetType() ) - TQApplication::sendEvent( w, &e ); - } - } - paletteChange( old ); - update(); -} - -void TQWidget::unsetPalette() -{ - // reset the palette - setPalette( qt_naturalWidgetPalette( this ) ); - own_palette = FALSE; -} - -/*! - \fn void TQWidget::setPalette( const TQPalette&, bool ) - \obsolete - - Use setPalette( const TQPalette& p ) instead. -*/ - -/*! - \fn void TQWidget::paletteChange( const TQPalette &oldPalette ) - - This virtual function is called from setPalette(). \a oldPalette - is the previous palette; you can get the new palette from - palette(). - - Reimplement this function if your widget needs to know when its - palette changes. - - \sa setPalette(), palette() -*/ - -void TQWidget::paletteChange( const TQPalette & ) -{ -} -#endif // TQT_NO_PALETTE - -/*! - \property TQWidget::font - \brief the font currently set for the widget - - The fontInfo() function reports the actual font that is being used - by the widget. - - As long as no special font has been set, or after unsetFont() is - called, this is either a special font for the widget class, the - parent's font or (if this widget is a top level widget), the - default application font. - - This code fragment sets a 12 point helvetica bold font: - \code - TQFont f( "Helvetica", 12, TQFont::Bold ); - setFont( f ); - \endcode - - In addition to setting the font, setFont() informs all children - about the change. - - \sa fontChange() fontInfo() fontMetrics() ownFont() -*/ -void TQWidget::setFont( const TQFont &font ) -{ - own_font = TRUE; - if ( fnt == font && fnt.d->mask == font.d->mask ) - return; - TQFont old = fnt; - fnt = font.resolve( qt_naturalWidgetFont( this ) ); -#if defined(TQ_WS_X11) - // make sure the font set on this widget is associated with the correct screen - fnt.x11SetScreen( x11Screen() ); -#endif - if ( children() ) { - TQEvent e( TQEvent::ParentFontChange ); - TQObjectListIt it( *children() ); - TQWidget *w; - while( (w=(TQWidget *)it.current()) != 0 ) { - ++it; - if ( w->isWidgetType() ) - TQApplication::sendEvent( w, &e ); - } - } - if ( hasFocus() ) - setFontSys(); - fontChange( old ); -} - -void TQWidget::unsetFont() -{ - // reset the font - setFont( qt_naturalWidgetFont( this ) ); - own_font = FALSE; -} - -/*! - \fn void TQWidget::setFont( const TQFont&, bool ) - \obsolete - - Use setFont(const TQFont& font) instead. -*/ - -/*! - \fn void TQWidget::fontChange( const TQFont &oldFont ) - - This virtual function is called from setFont(). \a oldFont is the - previous font; you can get the new font from font(). - - Reimplement this function if your widget needs to know when its - font changes. You will almost certainly need to update the widget - using update(). - - The default implementation updates the widget including its - geometry. - - \sa setFont(), font(), update(), updateGeometry() -*/ - -void TQWidget::fontChange( const TQFont & ) -{ - update(); - updateGeometry(); -} - - -/*! - \fn TQFontMetrics TQWidget::fontMetrics() const - - Returns the font metrics for the widget's current font. - Equivalent to TQFontMetrics(widget->font()). - - \sa font(), fontInfo(), setFont() -*/ - -/*! - \fn TQFontInfo TQWidget::fontInfo() const - - Returns the font info for the widget's current font. - Equivalent to TQFontInto(widget->font()). - - \sa font(), fontMetrics(), setFont() -*/ - - -/*! - \property TQWidget::cursor - \brief the cursor shape for this widget - - The mouse cursor will assume this shape when it's over this - widget. See the \link TQt::CursorShape list of predefined cursor - objects\endlink for a range of useful shapes. - - An editor widget might use an I-beam cursor: - \code - setCursor( IbeamCursor ); - \endcode - - If no cursor has been set, or after a call to unsetCursor(), the - parent's cursor is used. The function unsetCursor() has no effect - on top-level widgets. - - \sa TQApplication::setOverrideCursor() -*/ - -#ifndef TQT_NO_CURSOR -const TQCursor &TQWidget::cursor() const -{ - if ( testWState(WState_OwnCursor) ) - return (extra && extra->curs) - ? *extra->curs - : arrowCursor; - else - return (isTopLevel() || !parentWidget()) ? arrowCursor : parentWidget()->cursor(); -} -#endif -#ifndef TQT_NO_WIDGET_TOPEXTRA -/*! - \property TQWidget::caption - \brief the window caption (title) - - This property only makes sense for top-level widgets. If no - caption has been set, the caption is TQString::null. - - \sa icon() iconText() -*/ -TQString TQWidget::caption() const -{ - return extra && extra->topextra - ? extra->topextra->caption - : TQString::null; -} - -/*! - \property TQWidget::icon - \brief the widget's icon - - This property only makes sense for top-level widgets. If no icon - has been set, icon() returns 0. - - \sa iconText, caption, - \link appicon.html Setting the Application Icon\endlink -*/ -const TQPixmap *TQWidget::icon() const -{ - return ( extra && extra->topextra ) ? extra->topextra->icon : 0; -} - -/*! - \property TQWidget::iconText - \brief the widget's icon text - - This property only makes sense for top-level widgets. If no icon - text has been set, this functions returns TQString::null. - - \sa icon, caption -*/ - -TQString TQWidget::iconText() const -{ - return ( extra && extra->topextra ) ? extra->topextra->iconText - : TQString::null; -} -#endif //TQT_NO_WIDGET_TOPEXTRA - -/*! - \property TQWidget::mouseTracking - \brief whether mouse tracking is enabled for the widget - - If mouse tracking is disabled (the default), the widget only - receives mouse move events when at least one mouse button is - pressed while the mouse is being moved. - - If mouse tracking is enabled, the widget receives mouse move - events even if no buttons are pressed. - - \sa mouseMoveEvent(), TQApplication::setGlobalMouseTracking() -*/ - - -/*! - Sets the widget's focus proxy to widget \a w. If \a w is 0, the - function resets this widget to have no focus proxy. - - Some widgets, such as TQComboBox, can "have focus", but create a - child widget to actually handle the focus. TQComboBox, for example, - creates a TQLineEdit which handles the focus. - - setFocusProxy() sets the widget which will actually get focus when - "this widget" gets it. If there is a focus proxy, focusPolicy(), - setFocusPolicy(), setFocus() and hasFocus() all operate on the - focus proxy. - - \sa focusProxy() -*/ - -void TQWidget::setFocusProxy( TQWidget * w ) -{ - if ( !w && !extra ) - return; - - for ( TQWidget* fp = w; fp; fp = fp->focusProxy() ) { - if ( fp == this ) { -#if defined (QT_CHECK_STATE) - tqWarning( "%s (%s): already in focus proxy chain", className(), name() ); -#endif - return; - } - } - - createExtra(); - - if ( extra->focus_proxy ) { - disconnect( extra->focus_proxy, TQ_SIGNAL(destroyed()), - this, TQ_SLOT(focusProxyDestroyed()) ); - extra->focus_proxy = 0; - } - - if ( w ) { - setFocusPolicy( w->focusPolicy() ); - connect( w, TQ_SIGNAL(destroyed()), - this, TQ_SLOT(focusProxyDestroyed()) ); - } - extra->focus_proxy = w; -} - - -/*! - Returns the focus proxy, or 0 if there is no focus proxy. - - \sa setFocusProxy() -*/ - -TQWidget * TQWidget::focusProxy() const -{ - return extra ? extra->focus_proxy : 0; -} - - -/*! - \internal - - Internal slot used to clean up if the focus proxy is destroyed. - - \sa setFocusProxy() -*/ - -void TQWidget::focusProxyDestroyed() -{ - if ( extra ) - extra->focus_proxy = 0; - setFocusPolicy( NoFocus ); -} - -/*! - \property TQWidget::focus - \brief whether this widget (or its focus proxy) has the keyboard - input focus - - Effectively equivalent to \c {tqApp->focusWidget() == this}. - - \sa setFocus(), clearFocus(), setFocusPolicy(), TQApplication::focusWidget() -*/ -bool TQWidget::hasFocus() const -{ - const TQWidget* w = this; - while ( w->focusProxy() ) - w = w->focusProxy(); - return tqApp->focusWidget() == w; -} - -/*! - Gives the keyboard input focus to this widget (or its focus - proxy) if this widget or one of its parents is the \link - isActiveWindow() active window\endlink. - - First, a focus out event is sent to the focus widget (if any) to - tell it that it is about to lose the focus. Then a focus in event - is sent to this widget to tell it that it just received the focus. - (Nothing happens if the focus in and focus out widgets are the - same.) - - setFocus() gives focus to a widget regardless of its focus policy, - but does not clear any keyboard grab (see grabKeyboard()). - - Be aware that if the widget is hidden, it will not accept focus. - - \warning If you call setFocus() in a function which may itself be - called from focusOutEvent() or focusInEvent(), you may get an - infinite recursion. - - \sa hasFocus() clearFocus() focusInEvent() focusOutEvent() - setFocusPolicy() TQApplication::focusWidget() grabKeyboard() - grabMouse() -*/ - -void TQWidget::setFocus() -{ - if ( !isEnabled() ) - return; - - if ( focusProxy() ) { - focusProxy()->setFocus(); - return; - } - - TQFocusData * f = focusData( TRUE ); - if ( f->it.current() == this && tqApp->focusWidget() == this -#if defined(TQ_WS_WIN) - && GetFocus() == winId() -#endif - ) - return; - - f->it.toFirst(); - while ( f->it.current() != this && !f->it.atLast() ) - ++f->it; - // at this point, the iterator should point to 'this'. if it - // does not, 'this' must not be in the list - an error, but - // perhaps possible. fix it. - if ( f->it.current() != this ) { - f->focusWidgets.append( this ); - f->it.toLast(); - } - - if ( isActiveWindow() ) { - TQWidget * prev = tqApp->focus_widget; - if ( prev ) { - // This part is never executed when TQ_WS_X11? Preceding XFocusOut - // had already reset focus_widget when received XFocusIn - - // Don't reset input context explicitly here. Whether reset or not - // when focusing out is a responsibility of input methods. For - // example, Japanese input context should not be reset here. The - // context sometimes contains a whole paragraph and has minutes of - // lifetime different to ephemeral one in other languages. The - // input context should be survived until focused again. So we - // delegate the responsibility to input context via - // unfocusInputContext(). - if ( prev != this && prev->isInputMethodEnabled() ) { -#if 0 - prev->resetInputContext(); -#else - prev->unfocusInputContext(); -#endif - } - } -#if defined(TQ_WS_WIN) - else { - TQInputContext::endComposition(); - } -#endif - tqApp->focus_widget = this; - if( isInputMethodEnabled() ) - focusInputContext(); - -#if defined(TQ_WS_WIN) - if ( !topLevelWidget()->isPopup() ) - SetFocus( winId() ); - else { -#endif -#if defined(QT_ACCESSIBILITY_SUPPORT) - TQAccessible::updateAccessibility( this, 0, TQAccessible::Focus ); -#endif -#if defined(TQ_WS_WIN) - } -#endif - - if ( prev != this ) { - if ( prev ) { - TQFocusEvent out( TQEvent::FocusOut ); - TQApplication::sendEvent( prev, &out ); - } - - if ( tqApp->focus_widget == this ) { - TQFocusEvent in( TQEvent::FocusIn ); - TQApplication::sendEvent( this, &in ); - } - } - } -} - -/*! - Takes keyboard input focus from the widget. - - If the widget has active focus, a \link focusOutEvent() focus out - event\endlink is sent to this widget to tell it that it is about - to lose the focus. - - This widget must enable focus setting in order to get the keyboard - input focus, i.e. it must call setFocusPolicy(). - - \sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), - setFocusPolicy(), TQApplication::focusWidget() -*/ - -void TQWidget::clearFocus() -{ - if ( focusProxy() ) { - focusProxy()->clearFocus(); - return; - } else if ( hasFocus() ) { -#if !defined(TQ_WS_X11) - resetInputContext(); -#else - unfocusInputContext(); -#endif - TQWidget* w = tqApp->focusWidget(); - // clear active focus - tqApp->focus_widget = 0; - TQFocusEvent out( TQEvent::FocusOut ); - TQApplication::sendEvent( w, &out ); -#if defined(TQ_WS_WIN) - if ( !isPopup() && GetFocus() == winId() ) - SetFocus( 0 ); - else { -#endif -#if defined(QT_ACCESSIBILITY_SUPPORT) - TQAccessible::updateAccessibility( this, 0, TQAccessible::Focus ); -#endif -#if defined(TQ_WS_WIN) - } -#endif - } -} - - -/*! - Finds a new widget to give the keyboard focus to, as appropriate - for Tab and Shift+Tab, and returns TRUE if is can find a new - widget and FALSE if it can't, - - If \a next is TRUE, this function searches "forwards", if \a next - is FALSE, it searches "backwards". - - Sometimes, you will want to reimplement this function. For - example, a web browser might reimplement it to move its "current - active link" forwards or backwards, and call - TQWidget::focusNextPrevChild() only when it reaches the last or - first link on the "page". - - Child widgets call focusNextPrevChild() on their parent widgets, - but only the top-level widget decides where to redirect focus. By - overriding this method for an object, you thus gain control of - focus traversal for all child widgets. - - \warning TQScrollView uses it own logic for this function, which - does the right thing in most cases. But if you are using a - TQScrollView and want complete control of the focus chain you'll - need to override TQScrollView::focusNextPrevChild() and your - top-level widgets' focusNextPrevChild() functions. - - \sa focusData() -*/ - -bool TQWidget::focusNextPrevChild( bool next ) -{ - TQWidget* p = parentWidget(); - if ( !isTopLevel() && p ) - return p->focusNextPrevChild(next); - - TQFocusData *f = focusData( TRUE ); - - TQWidget *startingPoint = f->it.current(); - TQWidget *candidate = 0; - TQWidget *w = next ? f->focusWidgets.last() : f->focusWidgets.first(); - extern bool tqt_tab_all_widgets; - uint focus_flag = tqt_tab_all_widgets ? TabFocus : StrongFocus; - do { - if ( w && w != startingPoint && - ( ( w->focusPolicy() & focus_flag ) == focus_flag ) - && !w->focusProxy() && w->isVisibleTo(this) && w->isEnabled()) - candidate = w; - w = next ? f->focusWidgets.prev() : f->focusWidgets.next(); - } while( w && !(candidate && w==startingPoint) ); - - if ( !candidate ) - return FALSE; - - candidate->setFocus(); - return TRUE; -} - -/*! - Returns the focus widget in this widget's window. This is not the - same as TQApplication::focusWidget(), which returns the focus - widget in the currently active window. -*/ - -TQWidget *TQWidget::focusWidget() const -{ - TQWidget *that = (TQWidget *)this; // mutable - TQFocusData *f = that->focusData( FALSE ); - if ( f && f->focusWidgets.count() && f->it.current() == 0 ) - f->it.toFirst(); - return ( f && f->it.current() ) ? f->it.current() : 0; -} - - -/*! - Returns the focus data for this widget's top-level widget. - - Focus data always belongs to the top-level widget. The focus data - list contains all the widgets in this top-level widget that can - accept focus, in tab order. An iterator points to the current - focus widget (focusWidget() returns a pointer to this widget). - - This information is useful for implementing advanced versions of - focusNextPrevChild(). -*/ -TQFocusData * TQWidget::focusData() -{ - return focusData( TRUE ); -} - -/*! - \internal - - Internal function which lets us ask for the focus data, creating - it if it doesn't exist and \a create is TRUE. -*/ -TQFocusData * TQWidget::focusData( bool create ) -{ - TQWidget * tlw = topLevelWidget(); - TQWExtra * ed = tlw->extraData(); - if ( !ed || !ed->topextra ) { - if ( !create ) - return 0; - tlw->createTLExtra(); - ed = tlw->extraData(); - } - if ( create && !ed->topextra->focusData ) - ed->topextra->focusData = new TQFocusData; - - return ed->topextra->focusData; -} - -/*! - \property TQWidget::inputMethodEnabled - \brief enables or disables the use of input methods for this widget. - - Most Widgets (as eg. buttons) that do not handle text input should have - the input method disabled if they have focus. This is the default. - - If a widget handles text input it should set this property to TRUE. -*/ - -void TQWidget::setInputMethodEnabled( bool b ) -{ - im_enabled = b; -#ifdef TQ_WS_WIN - TQInputContext::enable( this, im_enabled & !((bool)testWState(WState_Disabled)) ); -#endif -} - - -/*! - Enables key event compression, if \a compress is TRUE, and - disables it if \a compress is FALSE. - - Key compression is off by default (except for TQLineEdit and - TQTextEdit), so widgets receive one key press event for each key - press (or more, since autorepeat is usually on). If you turn it on - and your program doesn't keep up with key input, TQt may try to - compress key events so that more than one character can be - processed in each event. - - For example, a word processor widget might receive 2, 3 or more - characters in each TQKeyEvent::text(), if the layout recalculation - takes too long for the CPU. - - If a widget supports multiple character unicode input, it is - always safe to turn the compression on. - - TQt performs key event compression only for printable characters. - Modifier keys, cursor movement keys, function keys and - miscellaneous action keys (e.g. Escape, Enter, Backspace, - PrintScreen) will stop key event compression, even if there are - more compressible key events available. - - Not all platforms support this compression, in which case turning - it on will have no effect. - - \sa TQKeyEvent::text(); -*/ - -void TQWidget::setKeyCompression(bool compress) -{ - if ( compress ) - setWState( WState_CompressKeys ); - else - clearWState( WState_CompressKeys ); -} - -/*! - \property TQWidget::isActiveWindow - \brief whether this widget is the active window - - The active window is the window that contains the widget - that has keyboard focus. - - When popup windows are visible, this property is TRUE for both the - active window \e and for the popup. - - \sa setActiveWindow(), TQApplication::activeWindow() -*/ -bool TQWidget::isActiveWindow() const -{ - TQWidget *tlw = topLevelWidget(); - if(testWFlags(WSubWindow) && parentWidget()) - tlw = parentWidget()->topLevelWidget(); - if(tlw == tqApp->activeWindow() || ( isVisible() && tlw->isPopup() )) - return TRUE; -#ifndef TQT_NO_STYLE - const_cast(this)->createExtra(); - if (!extra->m_ceData) { - const_cast(this)->extra->m_ceData = new TQStyleControlElementData(); - } - //extra->m_ceData->widgetObjectTypes = getObjectTypeListForObject(this); - extra->m_ceData->widgetObjectTypes.clear(); - extra->m_ceData->allDataPopulated = false; - //if(style().styleHint(TQStyle::SH_Widget_ShareActivation, *extra->m_ceData, getControlElementFlagsForObject(this, extra->m_ceData->widgetObjectTypes, TQStyleOption(), false), TQStyleOption(), NULL, this)) { - if(style().styleHint(TQStyle::SH_Widget_ShareActivation, *extra->m_ceData, TQStyle::CEF_None, TQStyleOption(), NULL, this)) { - if((tlw->isDialog() || (tlw->testWFlags(TQt::WStyle_Tool) && !tlw->isPopup())) && - !tlw->testWFlags(TQt::WShowModal) && - (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow())) - return TRUE; - TQWidget *w = tqApp->activeWindow(); - if( !testWFlags(WSubWindow) && w && w->testWFlags(WSubWindow) && - w->parentWidget()->topLevelWidget() == tlw) - return TRUE; - while(w && (tlw->isDialog() || tlw->testWFlags(TQt::WStyle_Tool)) && - !w->testWFlags(TQt::WShowModal) && w->parentWidget()) { - w = w->parentWidget()->topLevelWidget(); - if( w == tlw ) - return TRUE; - } - } -#endif -#if defined(TQ_WS_WIN32) - HWND parent = tlw->winId(); - HWND topparent = GetActiveWindow(); - while ( parent ) { - parent = ::GetParent( parent ); - if ( parent && parent == topparent ) - return TRUE; - } -#endif - - return FALSE; -} - -/*! - Moves the \a second widget around the ring of focus widgets so - that keyboard focus moves from the \a first widget to the \a - second widget when the Tab key is pressed. - - Note that since the tab order of the \a second widget is changed, - you should order a chain like this: - - \code - setTabOrder( a, b ); // a to b - setTabOrder( b, c ); // a to b to c - setTabOrder( c, d ); // a to b to c to d - \endcode - - \e not like this: - - \code - setTabOrder( c, d ); // c to d WRONG - setTabOrder( a, b ); // a to b AND c to d - setTabOrder( b, c ); // a to b to c, but not c to d - \endcode - - If \a first or \a second has a focus proxy, setTabOrder() - correctly substitutes the proxy. - - \sa setFocusPolicy(), setFocusProxy() -*/ -void TQWidget::setTabOrder( TQWidget* first, TQWidget *second ) -{ - if ( !first || !second || - first->focusPolicy() == NoFocus || second->focusPolicy() == NoFocus ) - return; - - // If first is redirected, set first to the last child of first - // that can take keyboard focus so that second is inserted after - // that last child, and the focus order within first is (more - // likely to be) preserved. - if ( first->focusProxy() ) { - TQObjectList *l = first->queryList( "TQWidget" ); - if ( l && l->count() ) { - TQObjectListIt it(*l); - it.toLast(); - while (it.current()) { - if (((TQWidget*)it.current())->topLevelWidget() == first->topLevelWidget()) { - first = (TQWidget*)it.current(); - if (first->focusPolicy() != NoFocus) - break; - } - --it; - } - } - delete l; - } - while ( first->focusProxy() ) - first = first->focusProxy(); - while ( second->focusProxy() ) - second = second->focusProxy(); - - TQFocusData *f = first->focusData( TRUE ); - bool focusThere = (f->it.current() == second ); - f->focusWidgets.removeRef( second ); - if ( f->focusWidgets.findRef( first ) >= 0 ) - f->focusWidgets.insert( f->focusWidgets.at() + 1, second ); - else - f->focusWidgets.append( second ); - if ( focusThere ) { // reset iterator so tab will work appropriately - f->it.toFirst(); - while( f->it.current() && f->it.current() != second ) - ++f->it; - } -} - -/*!\internal - - Moves the relevant subwidgets of this widget from the \a oldtlw's - tab chain to that of the new parent, if there's anything to move and - we're really moving - - This function is called from TQWidget::reparent() *after* the widget - has been reparented. - - \sa reparent() -*/ - -void TQWidget::reparentFocusWidgets( TQWidget * oldtlw ) -{ - if ( oldtlw == topLevelWidget() ) - return; // nothing to do - - TQFocusData * from = oldtlw ? oldtlw->topData()->focusData : 0; - TQFocusData * to; - to = focusData(); - - if ( from ) { - from->focusWidgets.first(); - do { - TQWidget * pw = from->focusWidgets.current(); - while( pw && pw != this ) - pw = pw->parentWidget(); - if ( pw == this ) { - TQWidget * w = from->focusWidgets.take(); - if ( w == from->it.current() ) - // probably best to clear keyboard focus, or - // the user might become rather confused - w->clearFocus(); - if ( !isTopLevel() ) - to->focusWidgets.append( w ); - } else { - from->focusWidgets.next(); - } - } while( from->focusWidgets.current() ); - } - - if ( to->focusWidgets.findRef(this) < 0 ) - to->focusWidgets.append( this ); - - if ( !isTopLevel() && extra && extra->topextra && extra->topextra->focusData ) { - // this widget is no longer a top-level widget, so get rid - // of old focus data - delete extra->topextra->focusData; - extra->topextra->focusData = 0; - } -} - -/*! - \fn void TQWidget::recreate( TQWidget *parent, WFlags f, const TQPoint & p, bool showIt ) - - \obsolete - - This method is provided to aid porting from TQt 1.0 to 2.0. It has - been renamed reparent() in TQt 2.0. -*/ - -/*! - \property TQWidget::frameSize - \brief the size of the widget including any window frame -*/ -TQSize TQWidget::frameSize() const -{ - if ( isTopLevel() && !isPopup() ) { - if ( fstrut_dirty ) - updateFrameStrut(); - TQWidget *that = (TQWidget *) this; - TQTLWExtra *top = that->topData(); - return TQSize( crect.width() + top->fleft + top->fright, - crect.height() + top->ftop + top->fbottom ); - } - return crect.size(); -} - -/*! - \internal - - Recursive function that updates \a widget and all its children, - if they have some parent background origin. -*/ -static void qt_update_bg_recursive( TQWidget *widget ) -{ - if ( !widget || widget->isHidden() || widget->backgroundOrigin() == TQWidget::WidgetOrigin || !widget->backgroundPixmap() ) - return; - - const TQObjectList *lst = widget->children(); - - if ( lst ) { - TQObjectListIterator it( *lst ); - TQWidget *widget; - while ( (widget = (TQWidget*)it.current()) ) { - ++it; - if ( widget->isWidgetType() && !widget->isHidden() && !widget->isTopLevel() && !widget->testWFlags(TQt::WSubWindow) ) - qt_update_bg_recursive( widget ); - } - } - TQApplication::postEvent( widget, new TQPaintEvent( widget->clipRegion(), !widget->testWFlags(TQt::WRepaintNoErase) ) ); -} - -/*! - \overload - - This corresponds to move( TQPoint(\a x, \a y) ). -*/ - -void TQWidget::move( int x, int y ) -{ - TQPoint oldp(pos()); - internalSetGeometry( x + geometry().x() - TQWidget::x(), - y + geometry().y() - TQWidget::y(), - width(), height(), TRUE ); - if ( isVisible() && oldp != pos() ) - qt_update_bg_recursive( this ); -} - -/*! - \overload - - This corresponds to resize( TQSize(\a w, \a h) ). -*/ -void TQWidget::resize( int w, int h ) -{ - internalSetGeometry( geometry().x(), geometry().y(), w, h, FALSE ); - setWState( WState_Resized ); -} - -/*! - \overload - - This corresponds to setGeometry( TQRect(\a x, \a y, \a w, \a h) ). -*/ -void TQWidget::setGeometry( int x, int y, int w, int h ) -{ - TQPoint oldp( pos( )); - internalSetGeometry( x, y, w, h, TRUE ); - setWState( WState_Resized ); - if ( isVisible() && oldp != pos() ) - qt_update_bg_recursive( this ); -} - -/*! - \property TQWidget::focusEnabled - \brief whether the widget accepts keyboard focus - - Keyboard focus is initially disabled (i.e. focusPolicy() == - \c TQWidget::NoFocus). - - You must enable keyboard focus for a widget if it processes - keyboard events. This is normally done from the widget's - constructor. For instance, the TQLineEdit constructor calls - setFocusPolicy(TQWidget::StrongFocus). - - \sa setFocusPolicy(), focusInEvent(), focusOutEvent(), keyPressEvent(), - keyReleaseEvent(), isEnabled() -*/ - -/*! - \enum TQWidget::FocusPolicy - - This enum type defines the various policies a widget can have with - respect to acquiring keyboard focus. - - \value TabFocus the widget accepts focus by tabbing. - \value ClickFocus the widget accepts focus by clicking. - \value StrongFocus the widget accepts focus by both tabbing - and clicking. On Mac OS X this will also - be indicate that the widget accepts tab focus - when in 'Text/List focus mode'. - \value WheelFocus like StrongFocus plus the widget accepts - focus by using the mouse wheel. - \value NoFocus the widget does not accept focus. - -*/ - -/*! - \property TQWidget::focusPolicy - \brief the way the widget accepts keyboard focus - - The policy is \c TQWidget::TabFocus if the widget accepts keyboard - focus by tabbing, \c TQWidget::ClickFocus if the widget accepts - focus by clicking, \c TQWidget::StrongFocus if it accepts both, and - \c TQWidget::NoFocus (the default) if it does not accept focus at - all. - - You must enable keyboard focus for a widget if it processes - keyboard events. This is normally done from the widget's - constructor. For instance, the TQLineEdit constructor calls - setFocusPolicy(TQWidget::StrongFocus). - - \sa focusEnabled, focusInEvent(), focusOutEvent(), keyPressEvent(), - keyReleaseEvent(), enabled -*/ - -void TQWidget::setFocusPolicy( FocusPolicy policy ) -{ - if ( focusProxy() ) - focusProxy()->setFocusPolicy( policy ); - if ( policy != NoFocus ) { - TQFocusData * f = focusData( TRUE ); - if ( f->focusWidgets.findRef( this ) < 0 ) - f->focusWidgets.append( this ); - } - focus_policy = (uint) policy; -} - -/*! - \property TQWidget::updatesEnabled - \brief whether updates are enabled - - Calling update() and repaint() has no effect if updates are - disabled. Paint events from the window system are processed - normally even if updates are disabled. - - setUpdatesEnabled() is normally used to disable updates for a - short period of time, for instance to avoid screen flicker during - large changes. - - Example: - \code - setUpdatesEnabled( FALSE ); - bigVisualChanges(); - setUpdatesEnabled( TRUE ); - repaint(); - \endcode - - \sa update(), repaint(), paintEvent() -*/ -void TQWidget::setUpdatesEnabled( bool enable ) -{ - if ( enable ) - clearWState( WState_BlockUpdates ); - else - setWState( WState_BlockUpdates ); -} - -/*! - Shows the widget and its child widgets. - - If its size or position has changed, TQt guarantees that a widget - gets move and resize events just before it is shown. - - You almost never have to reimplement this function. If you need to - change some settings before a widget is shown, use showEvent() - instead. If you need to do some delayed initialization use - polish(). - - \sa showEvent(), hide(), showMinimized(), showMaximized(), - showNormal(), isVisible(), polish() -*/ - -void TQWidget::show() -{ - if ( testWState(WState_Visible) ) - return; - - bool wasHidden = isHidden(); - bool postLayoutHint = !isTopLevel() && wasHidden; - clearWState( WState_ForceHide | WState_CreatedHidden ); - - if ( !isTopLevel() && !parentWidget()->isVisible() ) { - // we should become visible, but one of our ancestors is - // explicitly hidden. Since we cleared the ForceHide flag, our - // immediate parent will call show() on us again during its - // own processing of show(). - if ( wasHidden ) { - TQEvent showToParentEvent( TQEvent::ShowToParent ); - TQApplication::sendEvent( this, &showToParentEvent ); - } - if ( postLayoutHint ) - TQApplication::postEvent( parentWidget(), - new TQEvent(TQEvent::LayoutHint) ); - return; - } - - in_show = TRUE; // set qws recursion watch - - TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); - - uint state = isTopLevel() ? windowState() : 0; -#ifndef Q_OS_TEMP - if ( isTopLevel() && !testWState( WState_Resized ) ) { - // do this before sending the posted resize events. Otherwise - // the layout would catch the resize event and may expand the - // minimum size. - TQSize s = qt_naturalWidgetSize( this ); - if ( !s.isEmpty() ) - resize( s ); - } -#endif // Q_OS_TEMP - - TQApplication::sendPostedEvents( this, TQEvent::Move ); - TQApplication::sendPostedEvents( this, TQEvent::Resize ); - - // the resizing and layouting might have changed the window state - if (isTopLevel() && windowState() != state) - setWindowState(state); - - setWState( WState_Visible ); - - if ( parentWidget() ) - TQApplication::sendPostedEvents( parentWidget(), - TQEvent::ChildInserted ); - - if ( extra ) { - int w = crect.width(); - int h = crect.height(); - if ( w < extra->minw || h < extra->minh || - w > extra->maxw || h > extra->maxh ) { - w = TQMAX( extra->minw, TQMIN( w, extra->maxw )); - h = TQMAX( extra->minh, TQMIN( h, extra->maxh )); - resize( w, h ); // deferred resize - } - } - - if ( testWFlags(WStyle_Tool) || isPopup() ) { - raise(); - } else if ( testWFlags(WType_TopLevel) ) { - while ( TQApplication::activePopupWidget() ) { - if ( !TQApplication::activePopupWidget()->close() ) - break; - } - } - - if ( !testWState(WState_Polished) ) - polish(); - - showChildren( FALSE ); - - if ( postLayoutHint ) - TQApplication::postEvent( parentWidget(), - new TQEvent(TQEvent::LayoutHint) ); - - // Required for Mac, not sure whether we should always do that - if( isTopLevel() ) - TQApplication::sendPostedEvents(0, TQEvent::LayoutHint); - - // On Windows, show the popup now so that our own focus handling - // stores the correct old focus widget even if it's stolen in the showevent -#if defined(TQ_WS_WIN) - if ( testWFlags(WType_Popup) ) - tqApp->openPopup( this ); -#endif - - TQShowEvent showEvent; - TQApplication::sendEvent( this, &showEvent ); - - if ( testWFlags(WShowModal) ) { - // tqt_enter_modal *before* show, otherwise the initial - // stacking might be wrong - tqt_enter_modal( this ); - } - - // do not show the window directly, but post a show-window request - // to reduce flicker with widgets in layouts - if ( postLayoutHint ) - TQApplication::postEvent( this, new TQEvent( TQEvent::ShowWindowRequest ) ); - else - showWindow(); - -#if !defined(TQ_WS_WIN) - if ( testWFlags(WType_Popup) ) - tqApp->openPopup( this ); -#endif - -#if defined(QT_ACCESSIBILITY_SUPPORT) - TQAccessible::updateAccessibility( this, 0, TQAccessible::ObjectShow ); -#endif - - in_show = FALSE; // reset qws recursion watch -} - -/*! \fn void TQWidget::iconify() - \obsolete -*/ - -/*! - Hides the widget. - - You almost never have to reimplement this function. If you need to - do something after a widget is hidden, use hideEvent() instead. - - \sa hideEvent(), isHidden(), show(), showMinimized(), isVisible(), close() -*/ - -void TQWidget::hide() -{ - clearWState( WState_CreatedHidden ); - if ( testWState(WState_ForceHide) ) - return; - - setWState( WState_ForceHide ); - - if ( testWFlags(WType_Popup) ) - tqApp->closePopup( this ); - - // Move test modal here. Otherwise, a modal dialog could get - // destroyed and we lose all access to its parent because we haven't - // left modality. (Eg. modal Progress Dialog) - if ( testWFlags(WShowModal) ) - tqt_leave_modal( this ); - -#if defined(TQ_WS_WIN) - if ( isTopLevel() && !isPopup() && parentWidget() && isActiveWindow() ) - parentWidget()->setActiveWindow(); // Activate parent -#endif - - hideWindow(); - - if ( testWState(WState_Visible) ) { - clearWState( WState_Visible ); - - // next bit tries to move the focus if the focus widget is now - // hidden. - if ( tqApp && tqApp->focusWidget() == this ) - focusNextPrevChild( TRUE ); - TQHideEvent hideEvent; - TQApplication::sendEvent( this, &hideEvent ); - hideChildren( FALSE ); - -#if defined(QT_ACCESSIBILITY_SUPPORT) - TQAccessible::updateAccessibility( this, 0, TQAccessible::ObjectHide ); -#endif - } else { - TQEvent hideToParentEvent( TQEvent::HideToParent ); - TQApplication::sendEvent( this, &hideToParentEvent ); - } - - // post layout hint for non toplevels. The parent widget check is - // necessary since the function is called in the destructor - if ( !isTopLevel() && parentWidget() ) - TQApplication::postEvent( parentWidget(), - new TQEvent( TQEvent::LayoutHint) ); -} - -void TQWidget::setShown( bool show ) -{ - if ( show ) - this->show(); - else - hide(); -} - -void TQWidget::setHidden( bool hide ) -{ - if ( hide ) - this->hide(); - else - show(); -} - -void TQWidget::showChildren( bool spontaneous ) -{ - if ( children() ) { - TQObjectListIt it(*children()); - TQObject *object; - TQWidget *widget; - while ( it ) { - object = it.current(); - ++it; - if ( object->isWidgetType() ) { - widget = (TQWidget*)object; - if ( !widget->isTopLevel() && widget->isShown() ) { - if ( spontaneous ) { - widget->showChildren( spontaneous ); - TQShowEvent e; - TQApplication::sendSpontaneousEvent( widget, &e ); - } else { - widget->show(); - } - } - } - } - } -} - -void TQWidget::hideChildren( bool spontaneous ) -{ - if ( children() ) { - TQObjectListIt it(*children()); - TQObject *object; - TQWidget *widget; - while ( it ) { - object = it.current(); - ++it; - if ( object->isWidgetType() ) { - widget = (TQWidget*)object; - if ( !widget->isTopLevel() && widget->isShown() ) { - if ( !spontaneous ) - widget->clearWState( WState_Visible ); - widget->hideChildren( spontaneous ); - TQHideEvent e; - if ( spontaneous ) - TQApplication::sendSpontaneousEvent( widget, &e ); - else - TQApplication::sendEvent( widget, &e ); - } - } - } - } -} - - -/*! - Delayed initialization of a widget. - - This function will be called \e after a widget has been fully - created and \e before it is shown the very first time. - - Polishing is useful for final initialization which depends on - having an instantiated widget. This is something a constructor - cannot guarantee since the initialization of the subclasses might - not be finished. - - After this function, the widget has a proper font and palette and - TQApplication::polish() has been called. - - Remember to call TQWidget's implementation first when reimplementing this - function to ensure that your program does not end up in infinite recursion. - - \sa constPolish(), TQApplication::polish() -*/ - -void TQWidget::polish() -{ -#ifndef TQT_NO_WIDGET_TOPEXTRA - if ( isTopLevel() ) { - const TQPixmap *pm = icon(); - if ( !pm || pm->isNull() ) { - TQWidget *mw = (TQWidget *)parent(); - pm = mw ? mw->icon() : 0; - if ( pm && !pm->isNull() ) - setIcon( *pm ); - else { - mw = mw ? mw->topLevelWidget() : 0; - pm = mw ? mw->icon() : 0; - if ( pm && !pm->isNull() ) - setIcon( *pm ); - else { - mw = tqApp ? tqApp->mainWidget() : 0; - pm = mw ? mw->icon() : 0; - if ( pm && !pm->isNull() ) - setIcon( *pm ); - } - } - } - } -#endif - if ( !testWState(WState_Polished) ) { - if ( ! own_font && - ! TQApplication::font( this ).isCopyOf( TQApplication::font() ) ) - unsetFont(); -#ifndef TQT_NO_PALETTE - if ( ! own_palette && - ! TQApplication::palette( this ).isCopyOf( TQApplication::palette() ) ) - unsetPalette(); -#endif - setWState(WState_Polished); - tqApp->polish( this ); - TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); - } -} - - -/*! - \fn void TQWidget::constPolish() const - - Ensures that the widget is properly initialized by calling - polish(). - - Call constPolish() from functions like sizeHint() that depends on - the widget being initialized, and that may be called before - show(). - - \warning Do not call constPolish() on a widget from inside that - widget's constructor. - - \sa polish() -*/ - -/*! - \overload - - Closes this widget. Returns TRUE if the widget was closed; - otherwise returns FALSE. - - If \a alsoDelete is TRUE or the widget has the \c - WDestructiveClose widget flag, the widget is also deleted. The - widget can prevent itself from being closed by rejecting the - \l TQCloseEvent it gets. A close events is delivered to the widget - no matter if the widget is visible or not. - - The TQApplication::lastWindowClosed() signal is emitted when the - last visible top level widget is closed. - - Note that closing the \l TQApplication::mainWidget() terminates the - application. - - \sa closeEvent(), TQCloseEvent, hide(), TQApplication::quit(), - TQApplication::setMainWidget(), TQApplication::lastWindowClosed() -*/ - -bool TQWidget::close( bool alsoDelete ) -{ - if ( is_closing ) - return TRUE; - is_closing = 1; - WId id = winId(); - bool isMain = tqApp->mainWidget() == this; - bool checkLastWindowClosed = isTopLevel() && !isPopup(); - bool deleted = FALSE; - TQCloseEvent e; - TQApplication::sendEvent( this, &e ); - deleted = !TQWidget::find(id); - if ( !deleted && !e.isAccepted() ) { - is_closing = 0; - return FALSE; - } - if ( !deleted && !isHidden() ) - hide(); - if ( checkLastWindowClosed - && tqApp->receivers(TQ_SIGNAL(lastWindowClosed())) ) { - /* if there is no non-withdrawn top level window left (except - the desktop, popups, or dialogs with parents), we emit the - lastWindowClosed signal */ - TQWidgetList *list = tqApp->topLevelWidgets(); - TQWidget *widget = list->first(); - while ( widget ) { - if ( !widget->isHidden() - && !widget->isDesktop() - && !widget->isPopup() - && (!widget->isDialog() || !widget->parentWidget())) - break; - widget = list->next(); - } - delete list; - if ( widget == 0 ) - emit tqApp->lastWindowClosed(); - } - if ( isMain ) - tqApp->quit(); - if ( deleted ) - return TRUE; - is_closing = 0; - if ( alsoDelete ) - delete this; - else if ( testWFlags(WDestructiveClose) ) { - clearWFlags(WDestructiveClose); - deleteLater(); - } - return TRUE; -} - - -/*! - \fn bool TQWidget::close() - - Closes this widget. Returns TRUE if the widget was closed; - otherwise returns FALSE. - - First it sends the widget a TQCloseEvent. The widget is \link - hide() hidden\endlink if it \link TQCloseEvent::accept() - accepts\endlink the close event. The default implementation of - TQWidget::closeEvent() accepts the close event. - - The \l TQApplication::lastWindowClosed() signal is emitted when the - last visible top level widget is closed. - -*/ - -/*! - \property TQWidget::visible - \brief whether the widget is visible - - Calling show() sets the widget to visible status if all its parent - widgets up to the top-level widget are visible. If an ancestor is - not visible, the widget won't become visible until all its - ancestors are shown. - - Calling hide() hides a widget explicitly. An explicitly hidden - widget will never become visible, even if all its ancestors become - visible, unless you show it. - - A widget receives show and hide events when its visibility status - changes. Between a hide and a show event, there is no need to - waste CPU cycles preparing or displaying information to the user. - A video application, for example, might simply stop generating new - frames. - - A widget that happens to be obscured by other windows on the - screen is considered to be visible. The same applies to iconified - top-level widgets and windows that exist on another virtual - desktop (on platforms that support this concept). A widget - receives spontaneous show and hide events when its mapping status - is changed by the window system, e.g. a spontaneous hide event - when the user minimizes the window, and a spontaneous show event - when the window is restored again. - - \sa show(), hide(), isHidden(), isVisibleTo(), isMinimized(), - showEvent(), hideEvent() -*/ - - -/*! - Returns TRUE if this widget would become visible if \a ancestor is - shown; otherwise returns FALSE. - - The TRUE case occurs if neither the widget itself nor any parent - up to but excluding \a ancestor has been explicitly hidden. - - This function will still return TRUE if the widget is obscured by - other windows on the screen, but could be physically visible if it - or they were to be moved. - - isVisibleTo(0) is identical to isVisible(). - - \sa show() hide() isVisible() -*/ - -bool TQWidget::isVisibleTo(TQWidget* ancestor) const -{ - if ( !ancestor ) - return isVisible(); - const TQWidget * w = this; - while ( w - && w->isShown() - && !w->isTopLevel() - && w->parentWidget() - && w->parentWidget() != ancestor ) - w = w->parentWidget(); - return w->isShown(); -} - - -/*! - \fn bool TQWidget::isVisibleToTLW() const - \obsolete - - This function is deprecated. It is equivalent to isVisible() -*/ - -/*! - \property TQWidget::hidden - \brief whether the widget is explicitly hidden - - If FALSE, the widget is visible or would become visible if all its - ancestors became visible. - - \sa hide(), show(), isVisible(), isVisibleTo(), shown -*/ - -/*! - \property TQWidget::shown - \brief whether the widget is shown - - If TRUE, the widget is visible or would become visible if all its - ancestors became visible. - - \sa hide(), show(), isVisible(), isVisibleTo(), hidden -*/ - -/*! - \property TQWidget::visibleRect - \brief the visible rectangle - - \obsolete - - No longer necessary, you can simply call repaint(). If you do not - need the rectangle for repaint(), use clipRegion() instead. -*/ -TQRect TQWidget::visibleRect() const -{ - TQRect r = rect(); - const TQWidget * w = this; - int ox = 0; - int oy = 0; - while ( w - && w->isVisible() - && !w->isTopLevel() - && w->parentWidget() ) { - ox -= w->x(); - oy -= w->y(); - w = w->parentWidget(); - r = r.intersect( TQRect( ox, oy, w->width(), w->height() ) ); - } - if ( !w->isVisible() ) - return TQRect(); - return r; -} - -/*! - Returns the unobscured region where paint events can occur. - - For visible widgets, this is an approximation of the area not - covered by other widgets; otherwise, this is an empty region. - - The repaint() function calls this function if necessary, so in - general you do not need to call it. - -*/ -TQRegion TQWidget::clipRegion() const -{ - return visibleRect(); -} - - -/*! - Adjusts the size of the widget to fit the contents. - - Uses sizeHint() if valid (i.e if the size hint's width and height - are \>= 0), otherwise sets the size to the children rectangle (the - union of all child widget geometries). - - \sa sizeHint(), childrenRect() -*/ - -void TQWidget::adjustSize() -{ - TQApplication::sendPostedEvents( 0, TQEvent::ChildInserted ); - TQApplication::sendPostedEvents( 0, TQEvent::LayoutHint ); - if ( !testWState(WState_Polished) ) - polish(); - TQSize s = sizeHint(); - - if ( isTopLevel() ) { - -#if defined(TQ_WS_X11) - TQRect screen = TQApplication::desktop()->screenGeometry( x11Screen() ); -#else // all others - TQRect screen = TQApplication::desktop()->screenGeometry( pos() ); -#endif - -#ifndef TQT_NO_LAYOUT - if ( layout() ) { - if ( layout()->hasHeightForWidth() ) { - s = s.boundedTo( screen.size() ); - s.setHeight( layout()->totalHeightForWidth( s.width() ) ); - } - } else -#endif - { - if ( sizePolicy().hasHeightForWidth() ) { - s = s.boundedTo( screen.size() ); - s.setHeight( heightForWidth( s.width() ) ); - } - } - } - if ( s.isValid() ) { - resize( s ); - return; - } - TQRect r = childrenRect(); // get children rectangle - if ( r.isNull() ) // probably no widgets - return; - resize( r.width() + 2 * r.x(), r.height() + 2 * r.y() ); -} - - -/*! - \property TQWidget::sizeHint - \brief the recommended size for the widget - - If the value of this property is an invalid size, no size is - recommended. - - The default implementation of sizeHint() returns an invalid size - if there is no layout for this widget, and returns the layout's - preferred size otherwise. - - \sa TQSize::isValid(), minimumSizeHint(), sizePolicy(), - setMinimumSize(), updateGeometry() -*/ - -TQSize TQWidget::sizeHint() const -{ -#ifndef TQT_NO_LAYOUT - if ( layout() ) - return layout()->totalSizeHint(); -#endif - return TQSize( -1, -1 ); -} - -/*! - \property TQWidget::minimumSizeHint - \brief the recommended minimum size for the widget - - If the value of this property is an invalid size, no minimum size - is recommended. - - The default implementation of minimumSizeHint() returns an invalid - size if there is no layout for this widget, and returns the - layout's minimum size otherwise. Most built-in widgets reimplement - minimumSizeHint(). - - \l TQLayout will never resize a widget to a size smaller than - minimumSizeHint. - - \sa TQSize::isValid(), resize(), setMinimumSize(), sizePolicy() -*/ -TQSize TQWidget::minimumSizeHint() const -{ -#ifndef TQT_NO_LAYOUT - if ( layout() ) - return layout()->totalMinimumSize(); -#endif - return TQSize( -1, -1 ); -} - - -/*! - \fn TQWidget *TQWidget::parentWidget( bool sameWindow ) const - - Returns the parent of this widget, or 0 if it does not have any - parent widget. If \a sameWindow is TRUE and the widget is top - level returns 0; otherwise returns the widget's parent. -*/ - -/*! - \fn WFlags TQWidget::testWFlags( WFlags f ) const - - Returns the bitwise AND of the widget flags and \a f. - - Widget flags are a combination of \l{TQt::WidgetFlags}. - - If you want to test for the presence of multiple flags (or - composite flags such as \c WStyle_Splash), test the - return value for equality against the argument. For example: - - \code - int flags = WStyle_Tool | WStyle_NoBorder; - if ( testWFlags(flags) ) - ... // WStyle_Tool or WStyle_NoBorder or both are set - if ( testWFlags(flags) == flags ) - ... // both WStyle_Tool and WStyle_NoBorder are set - \endcode - - \sa getWFlags(), setWFlags(), clearWFlags() -*/ - -/*! - \fn WState TQWidget::testWState( WState s ) const - \internal - - Returns the bitwise AND of the widget states and \a s. -*/ - -/*! - \fn uint TQWidget::getWState() const - - \internal - - Returns the current widget state. -*/ -/*! - \fn void TQWidget::clearWState( uint n ) - - \internal - - Clears the widgets states \a n. -*/ -/*! - \fn void TQWidget::setWState( uint n ) - - \internal - - Sets the widgets states \a n. -*/ - - - -/***************************************************************************** - TQWidget event handling - *****************************************************************************/ - -/*! - This is the main event handler; it handles event \a e. You can - reimplement this function in a subclass, but we recommend using - one of the specialized event handlers instead. - - The main event handler first passes an event through all \link - TQObject::installEventFilter() event filters\endlink that have been - installed. If none of the filters intercept the event, it calls - one of the specialized event handlers. - - Key press and release events are treated differently from other - events. event() checks for Tab and Shift+Tab and tries to move the - focus appropriately. If there is no widget to move the focus to - (or the key press is not Tab or Shift+Tab), event() calls - keyPressEvent(). - - This function returns TRUE if it is able to pass the event over to - someone (i.e. someone wanted the event); otherwise returns FALSE. - - \sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), - keyPressEvent(), keyReleaseEvent(), leaveEvent(), - mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), - mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), - TQObject::event(), TQObject::timerEvent() -*/ - -bool TQWidget::event( TQEvent *e ) -{ - if ( TQObject::event( e ) ) - return TRUE; - - switch ( e->type() ) { - case TQEvent::MouseMove: - mouseMoveEvent( (TQMouseEvent*)e ); - if ( ! ((TQMouseEvent*)e)->isAccepted() ) - return FALSE; - break; - - case TQEvent::MouseButtonPress: - // Don't reset input context here. Whether reset or not is - // a responsibility of input method. reset() will be - // called by mouseHandler() of input method if necessary - // via mousePressEvent() of text widgets. -#if 0 - resetInputContext(); -#endif - mousePressEvent( (TQMouseEvent*)e ); - if ( ! ((TQMouseEvent*)e)->isAccepted() ) - return FALSE; - break; - - case TQEvent::MouseButtonRelease: - mouseReleaseEvent( (TQMouseEvent*)e ); - if ( ! ((TQMouseEvent*)e)->isAccepted() ) - return FALSE; - break; - - case TQEvent::MouseButtonDblClick: - mouseDoubleClickEvent( (TQMouseEvent*)e ); - if ( ! ((TQMouseEvent*)e)->isAccepted() ) - return FALSE; - break; -#ifndef TQT_NO_WHEELEVENT - case TQEvent::Wheel: - wheelEvent( (TQWheelEvent*)e ); - if ( ! ((TQWheelEvent*)e)->isAccepted() ) - return FALSE; - break; -#endif - case TQEvent::TabletMove: - case TQEvent::TabletPress: - case TQEvent::TabletRelease: - tabletEvent( (TQTabletEvent*)e ); - if ( ! ((TQTabletEvent*)e)->isAccepted() ) - return FALSE; - break; - case TQEvent::Accel: - ((TQKeyEvent*)e)->ignore(); - return FALSE; - case TQEvent::KeyPress: { - TQKeyEvent *k = (TQKeyEvent *)e; - bool res = FALSE; - if ( !(k->state() & ControlButton || k->state() & AltButton) ) { - if ( k->key() == Key_Backtab || - (k->key() == Key_Tab && - (k->state() & ShiftButton)) ) { - TQFocusEvent::setReason( TQFocusEvent::Backtab ); - res = focusNextPrevChild( FALSE ); - TQFocusEvent::resetReason(); - - } else if ( k->key() == Key_Tab ) { - TQFocusEvent::setReason( TQFocusEvent::Tab ); - res = focusNextPrevChild( TRUE ); - TQFocusEvent::resetReason(); - } - if ( res ) - break; - } - keyPressEvent( k ); - if ( !k->isAccepted() ) - return FALSE; - } - break; - - case TQEvent::KeyRelease: - keyReleaseEvent( (TQKeyEvent*)e ); - if ( ! ((TQKeyEvent*)e)->isAccepted() ) - return FALSE; - break; - - case TQEvent::IMStart: { - TQIMEvent *i = (TQIMEvent *) e; - imStartEvent(i); - if (! i->isAccepted()) - return FALSE; - } - break; - - case TQEvent::IMCompose: { - TQIMEvent *i = (TQIMEvent *) e; - imComposeEvent(i); - if (! i->isAccepted()) - return FALSE; - } - break; - - case TQEvent::IMEnd: { - TQIMEvent *i = (TQIMEvent *) e; - imEndEvent(i); - if (! i->isAccepted()) - return FALSE; - } - break; - - case TQEvent::FocusIn: - focusInEvent( (TQFocusEvent*)e ); - setFontSys(); - break; - - case TQEvent::FocusOut: - focusOutEvent( (TQFocusEvent*)e ); - break; - - case TQEvent::Enter: - enterEvent( e ); - break; - - case TQEvent::Leave: - leaveEvent( e ); - break; - - case TQEvent::Paint: - // At this point the event has to be delivered, regardless - // whether the widget isVisible() or not because it - // already went through the filters - paintEvent( (TQPaintEvent*)e ); - break; - - case TQEvent::Move: - moveEvent( (TQMoveEvent*)e ); - break; - - case TQEvent::Resize: - resizeEvent( (TQResizeEvent*)e ); - break; - - case TQEvent::Close: { - TQCloseEvent *c = (TQCloseEvent *)e; - closeEvent( c ); - if ( !c->isAccepted() ) - return FALSE; - } - break; - - case TQEvent::ContextMenu: { - TQContextMenuEvent *c = (TQContextMenuEvent *)e; - contextMenuEvent( c ); - if ( !c->isAccepted() ) - return FALSE; - } - break; - -#ifndef TQT_NO_DRAGANDDROP - case TQEvent::Drop: - dropEvent( (TQDropEvent*) e); - break; - - case TQEvent::DragEnter: - dragEnterEvent( (TQDragEnterEvent*) e); - break; - - case TQEvent::DragMove: - dragMoveEvent( (TQDragMoveEvent*) e); - break; - - case TQEvent::DragLeave: - dragLeaveEvent( (TQDragLeaveEvent*) e); - break; -#endif - - case TQEvent::Show: - showEvent( (TQShowEvent*) e); - break; - - case TQEvent::Hide: - hideEvent( (TQHideEvent*) e); - break; - - case TQEvent::ShowWindowRequest: - if ( isShown() ) - showWindow(); - break; - - case TQEvent::ParentFontChange: - if ( isTopLevel() ) - break; - // fall through - case TQEvent::ApplicationFontChange: - if ( own_font ) - setFont( fnt.resolve( qt_naturalWidgetFont( this ) ) ); - else - unsetFont(); - break; - -#ifndef TQT_NO_PALETTE - case TQEvent::ParentPaletteChange: - if ( isTopLevel() ) - break; - // fall through - case TQEvent::ApplicationPaletteChange: - if ( !own_palette && !isDesktop() ) - unsetPalette(); -# if defined(TQ_WS_QWS) && !defined (TQT_NO_QWS_MANAGER) - if ( isTopLevel() && topData()->qwsManager ) { - TQRegion r( topData()->qwsManager->region() ); - TQApplication::postEvent(topData()->qwsManager, new TQPaintEvent(r, FALSE) ); - } -# endif - break; -#endif - - case TQEvent::WindowActivate: - case TQEvent::WindowDeactivate: - windowActivationChange( e->type() != TQEvent::WindowActivate ); - if ( children() ) { - TQObjectListIt it( *children() ); - TQObject *o; - while( ( o = it.current() ) != 0 ) { - ++it; - if ( o->isWidgetType() && - ((TQWidget*)o)->isVisible() && - !((TQWidget*)o)->isTopLevel() ) - TQApplication::sendEvent( o, e ); - } - } - break; - - case TQEvent::LanguageChange: - case TQEvent::LocaleChange: - if ( children() ) { - TQObjectListIt it( *children() ); - TQObject *o; - while( ( o = it.current() ) != 0 ) { - ++it; - TQApplication::sendEvent( o, e ); - } - } - if ( e->type() == TQEvent::LanguageChange ) { - int index = metaObject()->findSlot( "languageChange()", TRUE ); - if ( index >= 0 ) - tqt_invoke( index, 0 ); - } - update(); - break; -#ifndef TQT_NO_LAYOUT - case TQEvent::LayoutDirectionChange: - if ( layout() ) { - layout()->activate(); - } else { - TQObjectList* llist = queryList( "TQLayout", 0, TRUE, TRUE ); - TQObjectListIt lit( *llist ); - TQLayout *lay; - while ( ( lay = (TQLayout*)lit.current() ) != 0 ) { - ++lit; - lay->activate(); - } - delete llist; - } - update(); - break; -#endif - - case TQEvent::WindowStateChange: - { - TQEvent::Type type; - if (isMinimized()) - type = TQEvent::ShowMinimized; - else if (isFullScreen()) - type = TQEvent::ShowFullScreen; - else if (isMaximized()) - type = TQEvent::ShowMaximized; - else - type = TQEvent::ShowNormal; - - TQApplication::postEvent(this, new TQEvent(type)); - break; - } - - case TQEvent::WindowBlocked: - case TQEvent::WindowUnblocked: - if ( children() ) { - TQObjectListIt it( *children() ); - TQObject *o; - while( ( o = it.current() ) != 0 ) { - ++it; - TQWidget *w = ::tqt_cast(o); - if (w && !w->testWFlags(TQt::WShowModal)) - TQApplication::sendEvent( o, e ); - } - } - break; - - default: - return FALSE; - } - return TRUE; -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse move events for the widget. - - If mouse tracking is switched off, mouse move events only occur if - a mouse button is pressed while the mouse is being moved. If mouse - tracking is switched on, mouse move events occur even if no mouse - button is pressed. - - TQMouseEvent::pos() reports the position of the mouse cursor, - relative to this widget. For press and release events, the - position is usually the same as the position of the last mouse - move event, but it might be different if the user's hand shakes. - This is a feature of the underlying window system, not TQt. - - \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), - mouseDoubleClickEvent(), event(), TQMouseEvent -*/ - -void TQWidget::mouseMoveEvent( TQMouseEvent * e) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse press events for the widget. - - If you create new widgets in the mousePressEvent() the - mouseReleaseEvent() may not end up where you expect, depending on - the underlying window system (or X11 window manager), the widgets' - location and maybe more. - - The default implementation implements the closing of popup widgets - when you click outside the window. For other widget types it does - nothing. - - \sa mouseReleaseEvent(), mouseDoubleClickEvent(), - mouseMoveEvent(), event(), TQMouseEvent -*/ - -void TQWidget::mousePressEvent( TQMouseEvent *e ) -{ - e->ignore(); - if ( isPopup() ) { - e->accept(); - TQWidget* w; - while ( (w = tqApp->activePopupWidget() ) && w != this ){ - w->close(); - if (tqApp->activePopupWidget() == w) // widget does not want to dissappear - w->hide(); // hide at least - } - if (!rect().contains(e->pos()) ){ - close(); - } - } -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse release events for the widget. - - \sa mouseReleaseEvent(), mouseDoubleClickEvent(), - mouseMoveEvent(), event(), TQMouseEvent -*/ - -void TQWidget::mouseReleaseEvent( TQMouseEvent * e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive mouse double click events for the widget. - - The default implementation generates a normal mouse press event. - - Note that the widgets gets a mousePressEvent() and a - mouseReleaseEvent() before the mouseDoubleClickEvent(). - - \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), - event(), TQMouseEvent -*/ - -void TQWidget::mouseDoubleClickEvent( TQMouseEvent *e ) -{ - mousePressEvent( e ); // try mouse press event -} - -#ifndef TQT_NO_WHEELEVENT -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive wheel events for the widget. - - If you reimplement this handler, it is very important that you - \link TQWheelEvent ignore()\endlink the event if you do not handle - it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa TQWheelEvent::ignore(), TQWheelEvent::accept(), event(), - TQWheelEvent -*/ - -void TQWidget::wheelEvent( TQWheelEvent *e ) -{ - e->ignore(); -} -#endif - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive tablet events for the widget. - - If you reimplement this handler, it is very important that you - \link TQTabletEvent ignore()\endlink the event if you do not handle - it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa TQTabletEvent::ignore(), TQTabletEvent::accept(), event(), - TQTabletEvent -*/ - -void TQWidget::tabletEvent( TQTabletEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive key press events for the widget. - - A widget must call setFocusPolicy() to accept focus initially and - have focus in order to receive a key press event. - - If you reimplement this handler, it is very important that you - explicitly \link TQKeyEvent::ignore() ignore\endlink the event - if you do not understand it, so that the widget's parent can - interpret it; otherwise, the event will be implicitly accepted. - Although top-level widgets are able to choose whether to accept - or ignore unknown events because they have no parent widgets that - could otherwise handle them, it is good practice to explicitly - ignore events to make widgets as reusable as possible. - - The default implementation closes popup widgets if the user - presses Esc. Otherwise the event is ignored. - - \sa keyReleaseEvent(), TQKeyEvent::ignore(), setFocusPolicy(), - focusInEvent(), focusOutEvent(), event(), TQKeyEvent -*/ - -void TQWidget::keyPressEvent( TQKeyEvent *e ) -{ - if ( isPopup() && e->key() == Key_Escape ) { - e->accept(); - close(); - } else { - e->ignore(); - } -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive key release events for the widget. - - A widget must \link setFocusPolicy() accept focus\endlink - initially and \link hasFocus() have focus\endlink in order to - receive a key release event. - - If you reimplement this handler, it is very important that you - \link TQKeyEvent ignore()\endlink the release if you do not - understand it, so that the widget's parent can interpret it. - - The default implementation ignores the event. - - \sa keyPressEvent(), TQKeyEvent::ignore(), setFocusPolicy(), - focusInEvent(), focusOutEvent(), event(), TQKeyEvent -*/ - -void TQWidget::keyReleaseEvent( TQKeyEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler can be reimplemented in a subclass to receive - keyboard focus events (focus received) for the widget. - - A widget normally must setFocusPolicy() to something other than - \c NoFocus in order to receive focus events. (Note that the - application programmer can call setFocus() on any widget, even - those that do not normally accept focus.) - - The default implementation updates the widget (except for toplevel - widgets that do not specify a focusPolicy() ). It also calls - setMicroFocusHint(), hinting any system-specific input tools about - the focus of the user's attention. - - \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(), - keyReleaseEvent(), event(), TQFocusEvent -*/ - -void TQWidget::focusInEvent( TQFocusEvent * ) -{ - if ( focusPolicy() != NoFocus || !isTopLevel() ) { - update(); - if ( testWState(WState_AutoMask) ) - updateMask(); - setMicroFocusHint(width()/2, 0, 1, height(), FALSE); - } -} - -/*! - This event handler can be reimplemented in a subclass to receive - keyboard focus events (focus lost) for the widget. - - A widget normally must setFocusPolicy() to something other than - \c NoFocus in order to receive focus events. (Note that the - application programmer can call setFocus() on any widget, even - those that do not normally accept focus.) - - The default implementation updates the widget (except for toplevel - widgets that do not specify a focusPolicy() ). It also calls - setMicroFocusHint(), hinting any system-specific input tools about - the focus of the user's attention. - - \sa focusInEvent(), setFocusPolicy(), keyPressEvent(), - keyReleaseEvent(), event(), TQFocusEvent -*/ - -void TQWidget::focusOutEvent( TQFocusEvent * ) -{ - if ( focusPolicy() != NoFocus || !isTopLevel() ){ - update(); - if ( testWState(WState_AutoMask) ) - updateMask(); - } -} - -/*! - \property TQWidget::microFocusHint - \brief the currently set micro focus hint for this widget. - - See the documentation of setMicroFocusHint() for more information. -*/ -TQRect TQWidget::microFocusHint() const -{ - if ( !extra || extra->micro_focus_hint.isEmpty() ) - return TQRect(width()/2, 0, 1, height() ); - else - return extra->micro_focus_hint; -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget enter events. - - An event is sent to the widget when the mouse cursor enters the - widget. - - \sa leaveEvent(), mouseMoveEvent(), event() -*/ - -void TQWidget::enterEvent( TQEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget leave events. - - A leave event is sent to the widget when the mouse cursor leaves - the widget. - - \sa enterEvent(), mouseMoveEvent(), event() -*/ - -void TQWidget::leaveEvent( TQEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - paint events. - - A paint event is a request to repaint all or part of the widget. - It can happen as a result of repaint() or update(), or because the - widget was obscured and has now been uncovered, or for many other - reasons. - - Many widgets can simply repaint their entire surface when asked - to, but some slow widgets need to optimize by painting only the - requested region: TQPaintEvent::region(). This speed optimization - does not change the result, as painting is clipped to that region - during event processing. TQListView and TQCanvas do this, for - example. - - TQt also tries to speed up painting by merging multiple paint - events into one. When update() is called several times or the - window system sends several paint events, TQt merges these events - into one event with a larger region (see TQRegion::unite()). - repaint() does not permit this optimization, so we suggest using - update() when possible. - - When the paint event occurs, the update region has normally been - erased, so that you're painting on the widget's background. There - are a couple of exceptions and TQPaintEvent::erased() tells you - whether the widget has been erased or not. - - The background can be set using setBackgroundMode(), - setPaletteBackgroundColor() or setBackgroundPixmap(). The - documentation for setBackgroundMode() elaborates on the - background; we recommend reading it. - - \sa event(), repaint(), update(), TQPainter, TQPixmap, TQPaintEvent -*/ - -void TQWidget::paintEvent( TQPaintEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - widget move events. When the widget receives this event, it is - already at the new position. - - The old position is accessible through TQMoveEvent::oldPos(). - - \sa resizeEvent(), event(), move(), TQMoveEvent -*/ - -void TQWidget::moveEvent( TQMoveEvent * ) -{ -} - - -/*! - This event handler can be reimplemented in a subclass to receive - widget resize events. When resizeEvent() is called, the widget - already has its new geometry. The old size is accessible through - TQResizeEvent::oldSize(). - - The widget will be erased and receive a paint event immediately - after processing the resize event. No drawing need be (or should - be) done inside this handler. - - Widgets that have been created with the \c WNoAutoErase flag - will not be erased. Nevertheless, they will receive a paint event - for their entire area afterwards. Again, no drawing needs to be - done inside this handler. - - The default implementation calls updateMask() if the widget has - \link TQWidget::setAutoMask() automatic masking\endlink enabled. - - \sa moveEvent(), event(), resize(), TQResizeEvent, paintEvent() -*/ - -void TQWidget::resizeEvent( TQResizeEvent * ) -{ - if ( testWState(WState_AutoMask) ) - updateMask(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive widget close events. - - The default implementation calls e->accept(), which hides this - widget. See the \l TQCloseEvent documentation for more details. - - \sa event(), hide(), close(), TQCloseEvent -*/ - -void TQWidget::closeEvent( TQCloseEvent *e ) -{ - e->accept(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive widget context menu events. - - The default implementation calls e->ignore(), which rejects the - context event. See the \l TQContextMenuEvent documentation for - more details. - - \sa event(), TQContextMenuEvent -*/ - -void TQWidget::contextMenuEvent( TQContextMenuEvent *e ) -{ - e->ignore(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user begins entering text using an Input Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQWidget::imStartEvent( TQIMEvent *e ) -{ - e->ignore(); -} - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user has entered some text using an Input Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQWidget::imComposeEvent( TQIMEvent *e ) -{ - e->ignore(); -} - - -/*! - This event handler, for event \a e, can be reimplemented in a - subclass to receive Input Method composition events. This handler - is called when the user has finished inputting text via an Input - Method. - - The default implementation calls e->ignore(), which rejects the - Input Method event. See the \l TQIMEvent documentation for more - details. - - \sa event(), TQIMEvent -*/ -void TQWidget::imEndEvent( TQIMEvent *e ) -{ - e->ignore(); -} - - -#ifndef TQT_NO_DRAGANDDROP - -/*! - This event handler is called when a drag is in progress and the - mouse enters this widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragEnterEvent -*/ -void TQWidget::dragEnterEvent( TQDragEnterEvent * ) -{ -} - -/*! - This event handler is called when a drag is in progress and the - mouse enters this widget, and whenever it moves within the widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragMoveEvent -*/ -void TQWidget::dragMoveEvent( TQDragMoveEvent * ) -{ -} - -/*! - This event handler is called when a drag is in progress and the - mouse leaves this widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDragLeaveEvent -*/ -void TQWidget::dragLeaveEvent( TQDragLeaveEvent * ) -{ -} - -/*! - This event handler is called when the drag is dropped on this - widget. - - See the \link dnd.html Drag-and-drop documentation\endlink for an - overview of how to provide drag-and-drop in your application. - - \sa TQTextDrag, TQImageDrag, TQDropEvent -*/ -void TQWidget::dropEvent( TQDropEvent * ) -{ -} - -#endif // TQT_NO_DRAGANDDROP - -/*! - This event handler can be reimplemented in a subclass to receive - widget show events. - - Non-spontaneous show events are sent to widgets immediately before - they are shown. The spontaneous show events of top-level widgets - are delivered afterwards. - - \sa event(), TQShowEvent -*/ -void TQWidget::showEvent( TQShowEvent * ) -{ -} - -/*! - This event handler can be reimplemented in a subclass to receive - widget hide events. - - Hide events are sent to widgets immediately after they have been - hidden. - - \sa event(), TQHideEvent -*/ -void TQWidget::hideEvent( TQHideEvent * ) -{ -} - -/* - \fn TQWidget::x11Event( MSG * ) - - This special event handler can be reimplemented in a subclass to - receive native X11 events. - - In your reimplementation of this function, if you want to stop the - event being handled by TQt, return TRUE. If you return FALSE, this - native event is passed back to TQt, which translates the event into - a TQt event and sends it to the widget. - - \warning This function is not portable. - - \sa TQApplication::x11EventFilter() -*/ - - -#if defined(TQ_WS_MAC) - -/*! - This special event handler can be reimplemented in a subclass to - receive native Macintosh events. - - In your reimplementation of this function, if you want to stop the - event being handled by TQt, return TRUE. If you return FALSE, this - native event is passed back to TQt, which translates the event into - a TQt event and sends it to the widget. - - \warning This function is not portable. - - \sa TQApplication::macEventFilter() -*/ - -bool TQWidget::macEvent( MSG * ) -{ - return FALSE; -} - -#endif -#if defined(TQ_WS_WIN) - -/*! - This special event handler can be reimplemented in a subclass to - receive native Windows events. - - In your reimplementation of this function, if you want to stop the - event being handled by TQt, return TRUE. If you return FALSE, this - native event is passed back to TQt, which translates the event into - a TQt event and sends it to the widget. - - \warning This function is not portable. - - \sa TQApplication::winEventFilter() -*/ -bool TQWidget::winEvent( MSG * ) -{ - return FALSE; -} - -#endif -#if defined(TQ_WS_X11) - -/*! - This special event handler can be reimplemented in a subclass to - receive native X11 events. - - In your reimplementation of this function, if you want to stop the - event being handled by TQt, return TRUE. If you return FALSE, this - native event is passed back to TQt, which translates the event into - a TQt event and sends it to the widget. - - \warning This function is not portable. - - \sa TQApplication::x11EventFilter() -*/ -bool TQWidget::x11Event( XEvent * ) -{ - return FALSE; -} - -#endif -#if defined(TQ_WS_QWS) - -/*! - This special event handler can be reimplemented in a subclass to - receive native TQt/Embedded events. - - In your reimplementation of this function, if you want to stop the - event being handled by TQt, return TRUE. If you return FALSE, this - native event is passed back to TQt, which translates the event into - a TQt event and sends it to the widget. - - \warning This function is not portable. - - \sa TQApplication::qwsEventFilter() -*/ -bool TQWidget::qwsEvent( TQWSEvent * ) -{ - return FALSE; -} - -#endif - -/*! - \property TQWidget::autoMask - \brief whether the auto mask feature is enabled for the widget - - Transparent widgets use a mask to define their visible region. - TQWidget has some built-in support to make the task of - recalculating the mask easier. When setting auto mask to TRUE, - updateMask() will be called whenever the widget is resized or - changes its focus state. Note that you must reimplement - updateMask() (which should include a call to setMask()) or nothing - will happen. - - Note: when you re-implement resizeEvent(), focusInEvent() or - focusOutEvent() in your custom widgets and still want to ensure - that the auto mask calculation works, you should add: - - \code - if ( autoMask() ) - updateMask(); - \endcode - - at the end of your event handlers. This is true for all member - functions that change the appearance of the widget in a way that - requires a recalculation of the mask. - - While being a technically appealing concept, masks have a big - drawback: when using complex masks that cannot be expressed easily - with relatively simple regions, they can be very slow on some - window systems. The classic example is a transparent label. The - complex shape of its contents makes it necessary to represent its - mask by a bitmap, which consumes both memory and time. If all you - want is to blend the background of several neighboring widgets - together seamlessly, you will probably want to use - setBackgroundOrigin() rather than a mask. - - \sa autoMask() updateMask() setMask() clearMask() setBackgroundOrigin() -*/ - -bool TQWidget::autoMask() const -{ - return testWState(WState_AutoMask); -} - -void TQWidget::setAutoMask( bool enable ) -{ - if ( enable == autoMask() ) - return; - - if ( enable ) { - setWState(WState_AutoMask); - updateMask(); - } else { - clearWState(WState_AutoMask); - clearMask(); - } -} - -/*! - \enum TQWidget::BackgroundOrigin - - This enum defines the origin used to draw a widget's background - pixmap. - - The pixmap is drawn using the: - \value WidgetOrigin widget's coordinate system. - \value ParentOrigin parent's coordinate system. - \value WindowOrigin top-level window's coordinate system. - \value AncestorOrigin same origin as the parent uses. -*/ - -/*! - \property TQWidget::backgroundOrigin - \brief the origin of the widget's background - - The origin is either WidgetOrigin (the default), ParentOrigin, - WindowOrigin or AncestorOrigin. - - This only makes a difference if the widget has a background - pixmap, in which case positioning matters. Using \c WindowOrigin - for several neighboring widgets makes the background blend - together seamlessly. \c AncestorOrigin allows blending backgrounds - seamlessly when an ancestor of the widget has an origin other than - \c WindowOrigin. - - \sa backgroundPixmap(), setBackgroundMode() -*/ -TQWidget::BackgroundOrigin TQWidget::backgroundOrigin() const -{ - return extra ? (BackgroundOrigin)extra->bg_origin : WidgetOrigin; -} - -void TQWidget::setBackgroundOrigin( BackgroundOrigin origin ) -{ - if ( origin == backgroundOrigin() ) - return; - createExtra(); - extra->bg_origin = origin; - update(); -} - -/*! - This function can be reimplemented in a subclass to support - transparent widgets. It should be called whenever a widget changes - state in a way that means that the shape mask must be recalculated. - - \sa setAutoMask(), updateMask(), setMask(), clearMask() -*/ -void TQWidget::updateMask() -{ -} - -/*! - \internal - Returns the offset of the widget from the backgroundOrigin. - - \sa setBackgroundMode(), backgroundMode(), -*/ -TQPoint TQWidget::backgroundOffset() const -{ - if (!isTopLevel()) { - switch(backgroundOrigin()) { - case WidgetOrigin: - break; - case ParentOrigin: - return pos(); - case WindowOrigin: - { - const TQWidget *topl = this; - while(topl && !topl->isTopLevel() && !topl->testWFlags(TQt::WSubWindow)) - topl = topl->parentWidget(TRUE); - return mapTo((TQWidget *)topl, TQPoint(0, 0) ); - } - case AncestorOrigin: - { - const TQWidget *topl = this; - bool ancestorIsWindowOrigin = FALSE; - while(topl && !topl->isTopLevel() && !topl->testWFlags(TQt::WSubWindow)) - { - if (!ancestorIsWindowOrigin) { - if (topl->backgroundOrigin() == TQWidget::WidgetOrigin) - break; - if (topl->backgroundOrigin() == TQWidget::ParentOrigin) - { - topl = topl->parentWidget(TRUE); - break; - } - if (topl->backgroundOrigin() == TQWidget::WindowOrigin) - ancestorIsWindowOrigin = TRUE; - } - topl = topl->parentWidget(TRUE); - } - - return mapTo((TQWidget *) topl, TQPoint(0,0) ); - } - } - } - // fall back - return TQPoint(0,0); -} - -/*! - \fn TQLayout* TQWidget::layout () const - - Returns the layout engine that manages the geometry of this - widget's children. - - If the widget does not have a layout, layout() returns 0. - - \sa sizePolicy() -*/ - - -/* Sets this widget to use layout \a l to manage the geometry of its - children. - - If the widget already had a layout, the old layout is - forgotten. (Note that it is not deleted.) - - \sa layout() TQLayout sizePolicy() -*/ -#ifndef TQT_NO_LAYOUT -void TQWidget::setLayout( TQLayout *l ) -{ - lay_out = l; -} -#endif - -/*! - \property TQWidget::sizePolicy - \brief the default layout behavior of the widget - - If there is a TQLayout that manages this widget's children, the - size policy specified by that layout is used. If there is no such - TQLayout, the result of this function is used. - - The default policy is Preferred/Preferred, which means that the - widget can be freely resized, but prefers to be the size - sizeHint() returns. Button-like widgets set the size policy to - specify that they may stretch horizontally, but are fixed - vertically. The same applies to lineedit controls (such as - TQLineEdit, TQSpinBox or an editable TQComboBox) and other - horizontally orientated widgets (such as TQProgressBar). - TQToolButton's are normally square, so they allow growth in both - directions. Widgets that support different directions (such as - TQSlider, TQScrollBar or TQHeader) specify stretching in the - respective direction only. Widgets that can provide scrollbars - (usually subclasses of TQScrollView) tend to specify that they can - use additional space, and that they can make do with less than - sizeHint(). - - \sa sizeHint() TQLayout TQSizePolicy updateGeometry() -*/ -TQSizePolicy TQWidget::sizePolicy() const -{ - return extra ? extra->size_policy - : TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ); -} - -void TQWidget::setSizePolicy( TQSizePolicy policy ) -{ - setWState( WState_OwnSizePolicy ); - if ( policy == sizePolicy() ) - return; - createExtra(); - extra->size_policy = policy; - updateGeometry(); -} - -/*! - \overload void TQWidget::setSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw ) - - Sets the size policy of the widget to \a hor, \a ver and \a hfw - (height for width). - - \sa TQSizePolicy::TQSizePolicy() -*/ - -/*! - Returns the preferred height for this widget, given the width \a - w. The default implementation returns 0, indicating that the - preferred height does not depend on the width. - - \warning Does not look at the widget's layout. -*/ - -int TQWidget::heightForWidth( int w ) const -{ - (void)w; - return 0; -} - -/*! - \property TQWidget::customWhatsThis - \brief whether the widget wants to handle What's This help manually - - The default implementation of customWhatsThis() returns FALSE, - which means the widget will not receive any events in Whats This - mode. - - The widget may leave What's This mode by calling - TQWhatsThis::leaveWhatsThisMode(), with or without actually - displaying any help text. - - You can also reimplement customWhatsThis() if your widget is a - "passive interactor" supposed to work under all circumstances. - Simply don't call TQWhatsThis::leaveWhatsThisMode() in that case. - - \sa TQWhatsThis::inWhatsThisMode() TQWhatsThis::leaveWhatsThisMode() -*/ -bool TQWidget::customWhatsThis() const -{ - return FALSE; -} - -/*! - Returns the visible child widget at pixel position \a (x, y) in - the widget's own coordinate system. - - If \a includeThis is TRUE, and there is no child visible at \a (x, - y), the widget itself is returned. -*/ -TQWidget *TQWidget::childAt( int x, int y, bool includeThis ) const -{ - if ( !rect().contains( x, y ) ) - return 0; - if ( children() ) { - TQObjectListIt it( *children() ); - it.toLast(); - TQWidget *w, *t; - while( (w=(TQWidget *)it.current()) != 0 ) { - --it; - if ( w->isWidgetType() && !w->isTopLevel() && !w->isHidden() ) { - if ( ( t = w->childAt( x - w->x(), y - w->y(), TRUE ) ) ) - return t; - } - } - } - if ( includeThis ) - return (TQWidget*)this; - return 0; -} - -/*! - \overload - - Returns the visible child widget at point \a p in the widget's own - coordinate system. - - If \a includeThis is TRUE, and there is no child visible at \a p, - the widget itself is returned. - -*/ -TQWidget *TQWidget::childAt( const TQPoint & p, bool includeThis ) const -{ - return childAt( p.x(), p.y(), includeThis ); -} - - -/*! - Notifies the layout system that this widget has changed and may - need to change geometry. - - Call this function if the sizeHint() or sizePolicy() have changed. - - For explicitly hidden widgets, updateGeometry() is a no-op. The - layout system will be notified as soon as the widget is shown. -*/ - -void TQWidget::updateGeometry() -{ - TQWidget *parent = parentWidget(); - if (parent && !isTopLevel() && isShown()) - TQApplication::postEvent(parent, new TQEvent(TQEvent::LayoutHint)); -} - - -/*! - Reparents the widget. The widget gets a new \a parent, new widget - flags (\a f, but as usual, use 0) at a new position in its new - parent (\a p). - - If \a showIt is TRUE, show() is called once the widget has been - reparented. - - If the new parent widget is in a different top-level widget, the - reparented widget and its children are appended to the end of the - \link setFocusPolicy() tab chain \endlink of the new parent - widget, in the same internal order as before. If one of the moved - widgets had keyboard focus, reparent() calls clearFocus() for that - widget. - - If the new parent widget is in the same top-level widget as the - old parent, reparent doesn't change the tab order or keyboard - focus. - - \warning It is extremely unlikely that you will ever need this - function. If you have a widget that changes its content - dynamically, it is far easier to use \l TQWidgetStack or \l - TQWizard. - - \sa getWFlags() -*/ - -void TQWidget::reparent( TQWidget *parent, WFlags f, const TQPoint &p, - bool showIt ) -{ - reparentSys( parent, f, p, showIt ); - TQEvent e( TQEvent::Reparent ); - TQApplication::sendEvent( this, &e ); - if (!own_font) - unsetFont(); - else - setFont( fnt.resolve( qt_naturalWidgetFont( this ) ) ); -#ifndef TQT_NO_PALETTE - if (!own_palette) - unsetPalette(); -#endif -} - -/*! - \overload - - A convenience version of reparent that does not take widget flags - as argument. - - Calls reparent(\a parent, getWFlags() \& ~\l WType_Mask, \a p, \a - showIt). -*/ -void TQWidget::reparent( TQWidget *parent, const TQPoint & p, - bool showIt ) -{ - reparent( parent, getWFlags() & ~WType_Mask, p, showIt ); -} - -/*! - \property TQWidget::ownCursor - \brief whether the widget uses its own cursor - - If FALSE, the widget uses its parent widget's cursor. - - \sa cursor -*/ - -/*! - \property TQWidget::ownFont - \brief whether the widget uses its own font - - If FALSE, the widget uses its parent widget's font. - - \sa font -*/ - -/*! - \property TQWidget::ownPalette - \brief whether the widget uses its own palette - - If FALSE, the widget uses its parent widget's palette. - - \sa palette -*/ - - -void TQWidget::repaint( bool erase ) -{ - repaint( visibleRect(), erase ); -} - - - - -/*!\obsolete Use paletteBackgroundColor() or eraseColor() instead. */ -const TQColor & TQWidget::backgroundColor() const { return eraseColor(); } -/*!\obsolete Use setPaletteBackgroundColor() or setEraseColor() instead. */ -void TQWidget::setBackgroundColor( const TQColor &c ) { setEraseColor( c ); } -/*!\obsolete Use paletteBackgroundPixmap() or erasePixmap() instead. */ -const TQPixmap *TQWidget::backgroundPixmap() const { return erasePixmap(); } -/*!\obsolete Use setPaletteBackgroundPixmap() or setErasePixmap() instead. */ -void TQWidget::setBackgroundPixmap( const TQPixmap &pm ) { setErasePixmap( pm ); } - - -// documentation in qdesktopwidget_win.cpp -void TQDesktopWidget::insertChild( TQObject *obj ) -{ - if ( obj->isWidgetType() ) - return; - TQWidget::insertChild( obj ); -} - -/*! - \property TQWidget::windowOpacity - - \brief The level of opacity for the window. - - The valid range of opacity is from 1.0 (completely opaque) to - 0.0 (completely transparent). - - By default the value of this property is 1.0. - - This feature is only present on Mac OS X and Windows 2000 and up. - - \warning Changing this property from opaque to transparent might issue a - paint event that needs to be processed before the window is displayed - correctly. This affects mainly the use of TQPixmap::grabWindow(). Also note - that semi-transparent windows update and resize significantely slower than - opaque windows. -*/ diff --git a/src/kernel/qwidget_p.h b/src/kernel/qwidget_p.h deleted file mode 100644 index b56b4960c..000000000 --- a/src/kernel/qwidget_p.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Definition of some TQt private functions. -** -** Created : 000903 -** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQWIDGET_P_H -#define TQWIDGET_P_H - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the TQt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// -// - -#ifndef QT_H -#endif // QT_H - -#if defined (TQ_WS_X11) || defined (TQ_WS_QWS) -extern int qt_widget_tlw_gravity; -#endif - -#endif diff --git a/src/kernel/qwidget_x11.cpp b/src/kernel/qwidget_x11.cpp deleted file mode 100644 index db3500cfe..000000000 --- a/src/kernel/qwidget_x11.cpp +++ /dev/null @@ -1,3172 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQWidget and TQWindow classes for X11 -** -** Created : 931031 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqapplication.h" -#include "qapplication_p.h" -#include "ntqnamespace.h" -#include "ntqpaintdevicemetrics.h" -#include "ntqpainter.h" -#include "ntqbitmap.h" -#include "ntqimage.h" -#include "tqobjectlist.h" -#include "ntqlayout.h" -#include "ntqtextcodec.h" -#include "ntqdatetime.h" -#include "ntqcursor.h" -#include "qt_x11_p.h" -#include - -// NOT REVISED - -// defined in qapplication_x11.cpp -extern Window qt_x11_wm_client_leader; -extern void qt_x11_create_wm_client_leader(); - -// defined in qapplication_x11.cpp -void qt_insert_sip( TQWidget*, int, int ); -int qt_sip_count( TQWidget* ); -bool qt_wstate_iconified( WId ); -void qt_updated_rootinfo(); - -#ifndef TQT_NO_IM -#include "ntqinputcontext.h" -#include "ntqinputcontextfactory.h" -#endif - -// Paint event clipping magic -extern void qt_set_paintevent_clipping( TQPaintDevice* dev, const TQRegion& region); -extern void qt_clear_paintevent_clipping(); - -extern bool qt_dnd_enable( TQWidget* w, bool on ); -extern bool qt_nograb(); - -// defined in qapplication_x11.cpp -extern void qt_deferred_map_add( TQWidget* ); -extern void qt_deferred_map_take( TQWidget* ); -extern bool qt_deferred_map_contains(TQWidget *); - -static TQWidget *mouseGrb = 0; -static TQWidget *keyboardGrb = 0; - -// defined in qapplication_x11.cpp -extern Time tqt_x_time; -extern Time tqt_x_user_time; - -#ifndef TQT_NO_XSYNC -extern Atom qt_net_wm_sync_request_counter; -extern Atom qt_net_wm_sync_request; -extern bool qt_use_xsync; -#endif - -// defined in qfont_x11.cpp -extern bool tqt_has_xft; - -int qt_x11_create_desktop_on_screen = -1; - -/***************************************************************************** - TQWidget member functions - *****************************************************************************/ - -// defined in qapplication_x11.cpp -extern Atom tqt_wm_state; -extern Atom qt_wm_change_state; -extern Atom tqt_wm_delete_window; -extern Atom tqt_wm_take_focus; -extern Atom qt_wm_client_leader; -extern Atom tqt_window_role; -extern Atom tqt_sm_client_id; -extern Atom qt_utf8_string; -extern Atom qt_net_wm_context_help; -extern Atom qt_net_wm_ping; -extern Atom qt_xa_motif_wm_hints; -extern Atom qt_net_wm_name; -extern Atom qt_net_wm_icon_name; -extern Atom qt_net_wm_state; -extern Atom qt_net_wm_state_modal; -extern Atom qt_net_wm_state_max_v; -extern Atom qt_net_wm_state_max_h; -extern Atom qt_net_wm_state_fullscreen; -extern Atom qt_net_wm_state_above; -extern Atom qt_net_wm_state_stays_on_top; -extern Atom qt_net_wm_action; -extern Atom qt_net_wm_action_move; -extern Atom qt_net_wm_action_resize; -extern Atom qt_net_wm_action_minimize; -extern Atom qt_net_wm_action_shade; -extern Atom qt_net_wm_action_stick; -extern Atom qt_net_wm_action_max_h; -extern Atom qt_net_wm_action_max_v; -extern Atom qt_net_wm_action_fullscreen; -extern Atom qt_net_wm_action_change_desktop; -extern Atom qt_net_wm_action_close; -extern Atom qt_net_wm_action_above; -extern Atom qt_net_wm_action_below; -extern Atom qt_net_wm_window_type; -extern Atom qt_net_wm_window_type_normal; -extern Atom qt_net_wm_window_type_dialog; -extern Atom qt_net_wm_window_type_toolbar; -extern Atom qt_net_wm_window_type_menu; -extern Atom qt_net_wm_window_type_utility; -extern Atom qt_net_wm_window_type_splash; -extern Atom qt_net_wm_window_type_override; -extern Atom qt_net_wm_window_type_dropdown_menu; -extern Atom qt_net_wm_window_type_popup_menu; -extern Atom qt_net_wm_window_type_combo; -extern Atom qt_net_wm_window_type_dnd; -extern Atom qt_net_wm_window_type_tooltip; -extern Atom qt_net_wm_pid; -extern Atom qt_net_wm_user_time; -extern Atom qt_enlightenment_desktop; -extern Atom qt_net_virtual_roots; -extern bool qt_broken_wm; - -// defined in qapplication_x11.cpp -extern bool qt_net_supports(Atom); -extern unsigned long *qt_net_virtual_root_list; - -#if defined (QT_TABLET_SUPPORT) -extern XDevice *devStylus; -extern XDevice *devEraser; -extern XEventClass event_list_stylus[7]; -extern XEventClass event_list_eraser[7]; -extern int qt_curr_events_stylus; -extern int qt_curr_events_eraser; -#endif - -const uint stdWidgetEventMask = // X event mask - (uint)( - KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | - KeymapStateMask | - ButtonMotionMask | - EnterWindowMask | LeaveWindowMask | - FocusChangeMask | - ExposureMask | - PropertyChangeMask | - StructureNotifyMask - ); - -const uint stdDesktopEventMask = // X event mask - (uint)( - KeymapStateMask | - EnterWindowMask | LeaveWindowMask | - PropertyChangeMask - ); - - -/* - The qt_ functions below are implemented in qwidgetcreate_x11.cpp. -*/ - -Window qt_XCreateWindow( const TQWidget *creator, - Display *display, Window parent, - int x, int y, uint w, uint h, - int borderwidth, int depth, - uint windowclass, Visual *visual, - ulong valuemask, XSetWindowAttributes *attributes ); -Window qt_XCreateSimpleWindow( const TQWidget *creator, - Display *display, Window parent, - int x, int y, uint w, uint h, int borderwidth, - ulong border, ulong background ); -void qt_XDestroyWindow( const TQWidget *destroyer, - Display *display, Window window ); - -TQ_EXPORT void tqt_x11_enforce_cursor( TQWidget * w ) -{ - if ( w->testWState( TQt::WState_OwnCursor ) ) { - TQCursor * oc = TQApplication::overrideCursor(); - if ( oc ) { - XDefineCursor( w->x11Display(), w->winId(), oc->handle() ); - } else if ( w->isEnabled() ) { - XDefineCursor( w->x11Display(), w->winId(), w->cursor().handle() ); - } else { - // enforce the windows behavior of clearing the cursor on - // disabled widgets - XDefineCursor( w->x11Display(), w->winId(), None ); - } - } else { - XDefineCursor( w->x11Display(), w->winId(), None ); - } -} - -TQ_EXPORT void tqt_wait_for_window_manager( TQWidget* w ) -{ - TQApplication::flushX(); - XEvent ev; - TQTime t; - t.start(); - while ( !XCheckTypedWindowEvent( w->x11Display(), w->winId(), ReparentNotify, &ev ) ) { - if ( XCheckTypedWindowEvent( w->x11Display(), w->winId(), MapNotify, &ev ) ) - break; - if ( t.elapsed() > 500 ) - return; // give up, no event available - tqApp->syncX(); // non-busy wait - } - tqApp->x11ProcessEvent( &ev ); - if ( XCheckTypedWindowEvent( w->x11Display(), w->winId(), ConfigureNotify, &ev ) ) - tqApp->x11ProcessEvent( &ev ); -} - -static void qt_net_change_wm_state(const TQWidget* w, bool set, Atom one, Atom two = 0) -{ - if (w->isShown()) { - // managed by WM - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = qt_net_wm_state; - e.xclient.display = w->x11Display(); - e.xclient.window = w->winId(); - e.xclient.format = 32; - e.xclient.data.l[ 0 ] = set ? 1 : 0; - e.xclient.data.l[ 1 ] = one; - e.xclient.data.l[ 2 ] = two; - e.xclient.data.l[ 3 ] = 0; - e.xclient.data.l[ 4 ] = 0; - XSendEvent(w->x11Display(), RootWindow(w->x11Display(), w->x11Screen()), - False, (SubstructureNotifyMask|SubstructureRedirectMask), &e); - } else { - Atom ret; - int format = 0, status; - unsigned char *data = 0; - unsigned long nitems = 0, after = 0; - Atom *old_states = 0; - status = XGetWindowProperty(w->x11Display(), w->winId(), - qt_net_wm_state, 0, 1024, False, - XA_ATOM, &ret, &format, &nitems, - &after, &data); - if (status == Success && ret == XA_ATOM && format == 32 && nitems > 0) - old_states = (Atom *) data; - else - nitems = 0; - - Atom *new_states = new Atom[nitems + 2]; - int i, j = 0; - for (i = 0; i < (int)nitems; ++i) { - if (old_states[i] && old_states[i] != one && old_states[i] != two) - new_states[j++] = old_states[i]; - } - - if (set) { - if (one) new_states[j++] = one; - if (two) new_states[j++] = two; - } - - if (j) - XChangeProperty(w->x11Display(), w->winId(), qt_net_wm_state, XA_ATOM, 32, - PropModeReplace, (uchar *) new_states, j); - else - XDeleteProperty(w->x11Display(), w->winId(), qt_net_wm_state); - - delete [] new_states; - if (data) XFree(data); - } -} - -/*! - Creates a new widget window if \a window is 0, otherwise sets the - widget's window to \a window. - - Initializes the window (sets the geometry etc.) if \a - initializeWindow is TRUE. If \a initializeWindow is FALSE, no - initialization is performed. This parameter only makes sense if \a - window is a valid window. - - Destroys the old window if \a destroyOldWindow is TRUE. If \a - destroyOldWindow is FALSE, you are responsible for destroying the - window yourself (using platform native code). - - The TQWidget constructor calls create(0,TRUE,TRUE) to create a - window for this widget. -*/ - -void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) -{ - if ( testWState(WState_Created) && window == 0 ) - return; - - // set created flag - setWState( WState_Created ); - - bool popup = testWFlags(WType_Popup); - bool dialog = testWFlags(WType_Dialog); - bool desktop = testWFlags(WType_Desktop); - - // top-level widget - if ( !parentWidget() || parentWidget()->isDesktop() ) - setWFlags( WType_TopLevel ); - - // these are top-level, too - if ( dialog || popup || desktop || testWFlags(WStyle_Splash)) - setWFlags( WType_TopLevel ); - - // a popup stays on top - if ( popup ) - setWFlags(WStyle_StaysOnTop); - - bool topLevel = testWFlags(WType_TopLevel); - Window parentw, destroyw = 0; - WId id; - - // always initialize - if ( !window ) - initializeWindow = TRUE; - - if ( desktop && - qt_x11_create_desktop_on_screen >= 0 && - qt_x11_create_desktop_on_screen != x11Screen() ) { - // desktop on a certain screen other than the default requested - TQPaintDeviceX11Data* xd = getX11Data( TRUE ); - xd->x_screen = qt_x11_create_desktop_on_screen; - xd->x_depth = TQPaintDevice::x11AppDepth( xd->x_screen ); - xd->x_cells = TQPaintDevice::x11AppCells( xd->x_screen ); - xd->x_colormap = TQPaintDevice::x11AppColormap( xd->x_screen ); - xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( xd->x_screen ); - xd->x_visual = TQPaintDevice::x11AppVisual( xd->x_screen ); - xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( xd->x_screen ); - setX11Data( xd ); - } else if ( parentWidget() && parentWidget()->x11Screen() != x11Screen() ) { - // if we have a parent widget, move to its screen if necessary - TQPaintDeviceX11Data* xd = getX11Data( TRUE ); - xd->x_screen = parentWidget()->x11Screen(); - xd->x_depth = TQPaintDevice::x11AppDepth( xd->x_screen ); - xd->x_cells = TQPaintDevice::x11AppCells( xd->x_screen ); - xd->x_colormap = TQPaintDevice::x11AppColormap( xd->x_screen ); - xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( xd->x_screen ); - xd->x_visual = TQPaintDevice::x11AppVisual( xd->x_screen ); - xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( xd->x_screen ); - setX11Data( xd ); - } - - //get display, screen number, root window and desktop geometry for - //the current screen - Display *dpy = x11Display(); - int scr = x11Screen(); - Window root_win = RootWindow( dpy, scr ); - int sw = DisplayWidth(dpy,scr); - int sh = DisplayHeight(dpy,scr); - - if ( desktop ) { // desktop widget - dialog = popup = FALSE; // force these flags off - crect.setRect( 0, 0, sw, sh ); - } else if ( topLevel ) { // calc pos/size from screen - crect.setRect( sw/4, 3*sh/10, sw/2, 4*sh/10 ); - } else { // child widget - crect.setRect( 0, 0, 100, 30 ); - } - - parentw = topLevel ? root_win : parentWidget()->winId(); - - XSetWindowAttributes wsa; - - if ( window ) { // override the old window - if ( destroyOldWindow ) - destroyw = winid; - id = window; - setWinId( window ); - XWindowAttributes a; - XGetWindowAttributes( dpy, window, &a ); - crect.setRect( a.x, a.y, a.width, a.height ); - - if ( a.map_state == IsUnmapped ) - clearWState( WState_Visible ); - else - setWState( WState_Visible ); - - TQPaintDeviceX11Data* xd = getX11Data( TRUE ); - - // find which screen the window is on... - xd->x_screen = TQPaintDevice::x11AppScreen(); // by default, use the default :) - int i; - for ( i = 0; i < ScreenCount( dpy ); i++ ) { - if ( RootWindow( dpy, i ) == a.root ) { - xd->x_screen = i; - break; - } - } - - xd->x_depth = a.depth; - xd->x_cells = DisplayCells( dpy, xd->x_screen ); - xd->x_visual = a.visual; - xd->x_defvisual = ( XVisualIDFromVisual( a.visual ) == - XVisualIDFromVisual( (Visual*)x11AppVisual(x11Screen()) ) ); - xd->x_colormap = a.colormap; - xd->x_defcolormap = ( a.colormap == x11AppColormap( x11Screen() ) ); - setX11Data( xd ); - } else if ( desktop ) { // desktop widget - id = (WId)parentw; // id = root window - TQWidget *otherDesktop = find( id ); // is there another desktop? - if ( otherDesktop && otherDesktop->testWFlags(WPaintDesktop) ) { - otherDesktop->setWinId( 0 ); // remove id from widget mapper - setWinId( id ); // make sure otherDesktop is - otherDesktop->setWinId( id ); // found first - } else { - setWinId( id ); - } - } else { - if ( x11DefaultVisual() && x11DefaultColormap() ) { - id = (WId)qt_XCreateSimpleWindow( this, dpy, parentw, - crect.left(), crect.top(), - crect.width(), crect.height(), - 0, - black.pixel(x11Screen()), - bg_col.pixel(x11Screen()) ); - } else { - wsa.background_pixel = bg_col.pixel(x11Screen()); - wsa.border_pixel = black.pixel(x11Screen()); - wsa.colormap = (Colormap)x11Colormap(); - id = (WId)qt_XCreateWindow( this, dpy, parentw, - crect.left(), crect.top(), - crect.width(), crect.height(), - 0, x11Depth(), InputOutput, - (Visual*)x11Visual(), - CWBackPixel|CWBorderPixel|CWColormap, - &wsa ); - } - - setWinId( id ); // set widget id/handle + hd - } - -#ifndef TQT_NO_XFTFREETYPE - if (rendhd) { - XftDrawDestroy( (XftDraw *) rendhd ); - rendhd = 0; - } - - if ( tqt_has_xft ) - rendhd = (HANDLE) XftDrawCreate( dpy, id, (Visual *) x11Visual(), - x11Colormap() ); -#endif // TQT_NO_XFTFREETYPE - - // NET window states - long net_winstates[6] = { 0, 0, 0, 0, 0, 0 }; - long net_winactions[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - int curr_winstate = 0; - int curr_winaction = 0; - - // Add all default actions that cannot be turned off - net_winactions[curr_winaction++] = qt_net_wm_action_stick; - net_winactions[curr_winaction++] = qt_net_wm_action_fullscreen; - net_winactions[curr_winaction++] = qt_net_wm_action_change_desktop; - net_winactions[curr_winaction++] = qt_net_wm_action_above; - net_winactions[curr_winaction++] = qt_net_wm_action_below; - - struct { - ulong flags, functions, decorations; - long input_mode; - ulong status; - } mwmhints; - - mwmhints.flags = mwmhints.functions = 0L; - mwmhints.decorations = (1L << 0); // MWM_DECOR_ALL - mwmhints.input_mode = 0L; - mwmhints.status = 0L; - - if ( testNFlags(WX11DisableResize) ) { - mwmhints.functions |= (1L << 1); // MWM_FUNC_RESIZE - mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL - mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS - } - else { - net_winactions[curr_winaction++] = qt_net_wm_action_resize; - } - - if ( testNFlags(WX11DisableMove) ) { - mwmhints.functions |= (1L << 2); // MWM_FUNC_MOVE - mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL - mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS - } - else { - net_winactions[curr_winaction++] = qt_net_wm_action_move; - } - - if ( testNFlags(WX11DisableMinimize) ) { - mwmhints.functions |= (1L << 3); // MWM_FUNC_MINIMIZE - mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL - mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS - } - else { - net_winactions[curr_winaction++] = qt_net_wm_action_minimize; - } - - if ( testNFlags(WX11DisableMaximize) ) { - mwmhints.functions |= (1L << 4); // MWM_FUNC_MAXIMIZE - mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL - mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS - } - else { - net_winactions[curr_winaction++] = qt_net_wm_action_max_h; - net_winactions[curr_winaction++] = qt_net_wm_action_max_v; - } - - if ( testNFlags(WX11DisableClose) ) { - mwmhints.functions |= (1L << 5); // MWM_FUNC_CLOSE - mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL - mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS - } - else { - net_winactions[curr_winaction++] = qt_net_wm_action_close; - } - - if ( ! testNFlags(WX11DisableShade) ) { - net_winactions[curr_winaction++] = qt_net_wm_action_shade; - } - - if (topLevel && ! (desktop || popup)) { - ulong wsa_mask = 0; - - if ( testWFlags(WStyle_Splash) ) { - if (qt_net_supports(qt_net_wm_window_type_splash)) { - clearWFlags( WX11BypassWM ); - } else { - setWFlags( WX11BypassWM | WStyle_Tool | WStyle_NoBorder ); - } - } - if (testWFlags(WStyle_Customize)) { - mwmhints.decorations = 0L; - mwmhints.flags |= (1L << 1); // MWM_HINTS_DECORATIONS - - if ( testWFlags( WStyle_NormalBorder | WStyle_DialogBorder ) ) { - mwmhints.decorations |= (1L << 1); // MWM_DECOR_BORDER - mwmhints.decorations |= (1L << 2); // MWM_DECOR_RESIZEH - } - - if ( testWFlags( WStyle_Title ) ) - mwmhints.decorations |= (1L << 3); // MWM_DECOR_TITLE - - if ( testWFlags( WStyle_SysMenu ) ) - mwmhints.decorations |= (1L << 4); // MWM_DECOR_MENU - - if ( testWFlags( WStyle_Minimize ) ) - mwmhints.decorations |= (1L << 5); // MWM_DECOR_MINIMIZE - - if ( testWFlags( WStyle_Maximize ) ) - mwmhints.decorations |= (1L << 6); // MWM_DECOR_MAXIMIZE - - if (testWFlags(WStyle_Tool)) { - wsa.save_under = True; - wsa_mask |= CWSaveUnder; - } - } else if (testWFlags(WType_Dialog)) { - setWFlags(WStyle_NormalBorder | WStyle_Title | - WStyle_SysMenu | WStyle_ContextHelp); - } else { - setWFlags(WStyle_NormalBorder | WStyle_Title | - WStyle_MinMax | WStyle_SysMenu); - - // maximized netwm state - if (testWFlags(WState_Maximized)) { - net_winstates[curr_winstate++] = qt_net_wm_state_max_v; - net_winstates[curr_winstate++] = qt_net_wm_state_max_h; - } - } - - // stays on top - if (testWFlags(WStyle_StaysOnTop)) { - net_winstates[curr_winstate++] = qt_net_wm_state_above; - net_winstates[curr_winstate++] = qt_net_wm_state_stays_on_top; - } - - if (testWFlags(WShowModal)) { - mwmhints.input_mode = 3L; // MWM_INPUT_FULL_APPLICATION_MODAL - mwmhints.flags |= (1L << 2); // MWM_HINTS_INPUT_MODE - - net_winstates[curr_winstate++] = qt_net_wm_state_modal; - } - - if ( testWFlags( WX11BypassWM ) ) { - wsa.override_redirect = True; - wsa_mask |= CWOverrideRedirect; - } - - if ( wsa_mask && initializeWindow ) - XChangeWindowAttributes( dpy, id, wsa_mask, &wsa ); - } else { - if (! testWFlags(WStyle_Customize)) - setWFlags(WStyle_NormalBorder | WStyle_Title | - WStyle_MinMax | WStyle_SysMenu); - } - - - if ( !initializeWindow ) { - // do no initialization - } else if ( popup ) { // popup widget - wsa.override_redirect = True; - wsa.save_under = True; - XChangeWindowAttributes( dpy, id, CWOverrideRedirect | CWSaveUnder, - &wsa ); - XClassHint class_hint; - class_hint.res_name = (char *) tqAppName(); // application name - class_hint.res_class = (char *) tqAppClass(); // application class - XSetClassHint( dpy, id, &class_hint ); - } else if ( topLevel && !desktop ) { // top-level widget - TQWidget *p = parentWidget(); // real parent - if (p) - p = p->topLevelWidget(); - - if (dialog || testWFlags(WStyle_DialogBorder) || testWFlags(WStyle_Tool)) { - if ( p ) - XSetTransientForHint( dpy, id, p->winId() ); - else // application-modal - XSetTransientForHint( dpy, id, root_win ); - } - - // find the real client leader, i.e. a toplevel without parent - while ( p && p->parentWidget()) - p = p->parentWidget()->topLevelWidget(); - - XSizeHints size_hints; - size_hints.flags = USSize | PSize | PWinGravity; - size_hints.x = crect.left(); - size_hints.y = crect.top(); - size_hints.width = crect.width(); - size_hints.height = crect.height(); - size_hints.win_gravity = - TQApplication::reverseLayout() ? NorthEastGravity : NorthWestGravity; - - XWMHints wm_hints; // window manager hints - wm_hints.input = True; - wm_hints.initial_state = NormalState; - wm_hints.flags = InputHint | StateHint; - if ( !qt_x11_wm_client_leader ) - qt_x11_create_wm_client_leader(); - - wm_hints.window_group = qt_x11_wm_client_leader; - wm_hints.flags |= WindowGroupHint; - - XClassHint class_hint; - class_hint.res_name = (char *) tqAppName(); // application name - class_hint.res_class = (char *) tqAppClass(); // application class - - XSetWMProperties( dpy, id, 0, 0, 0, 0, &size_hints, &wm_hints, &class_hint ); - - XResizeWindow( dpy, id, crect.width(), crect.height() ); - XStoreName( dpy, id, tqAppName() ); - Atom protocols[5]; - int n = 0; - protocols[n++] = tqt_wm_delete_window; // support del window protocol - protocols[n++] = tqt_wm_take_focus; // support take focus window protocol - protocols[n++] = qt_net_wm_ping; // support _NET_WM_PING protocol -#ifndef TQT_NO_XSYNC - protocols[n++] = qt_net_wm_sync_request;// support the _NET_WM_SYNC_REQUEST protocol -#endif - if ( testWFlags( WStyle_ContextHelp ) ) - protocols[n++] = qt_net_wm_context_help; - XSetWMProtocols( dpy, id, protocols, n ); - - // set mwm hints - if ( mwmhints.flags != 0l ) - XChangeProperty(dpy, id, qt_xa_motif_wm_hints, qt_xa_motif_wm_hints, 32, - PropModeReplace, (unsigned char *) &mwmhints, 5); - else - XDeleteProperty(dpy, id, qt_xa_motif_wm_hints); - - // set _NET_WM_WINDOW_STATE - if (curr_winstate > 0) - XChangeProperty(dpy, id, qt_net_wm_state, XA_ATOM, 32, PropModeReplace, - (unsigned char *) net_winstates, curr_winstate); - else - XDeleteProperty(dpy, id, qt_net_wm_state); - - // set _NET_WM_ALLOWED_ACTIONS - if (curr_winaction > 0) - XChangeProperty(dpy, id, qt_net_wm_action, XA_ATOM, 32, PropModeReplace, - (unsigned char *) net_winactions, curr_winaction); - else - XDeleteProperty(dpy, id, qt_net_wm_action); - -#ifndef TQT_NO_XSYNC - // set _NET_WM_SYNC_COUNTER - createSyncCounter(); - long counterVal = topData()->syncCounter; - XChangeProperty( dpy, id, qt_net_wm_sync_request_counter, XA_CARDINAL, 32, PropModeReplace, - (unsigned char*) &counterVal, 1); -#endif - - // when we create a toplevel widget, the frame strut should be dirty - fstrut_dirty = 1; - - } else { - // non-toplevel widgets don't have a frame, so no need to - // update the strut - fstrut_dirty = 0; - } - - if (initializeWindow && (popup || (topLevel && !desktop))) { // properties set on all toplevel windows - x11SetWindowType(); - - // set _NET_WM_PID - long curr_pid = getpid(); - XChangeProperty(dpy, id, qt_net_wm_pid, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *) &curr_pid, 1); - - // declare the widget's object name as window role - XChangeProperty( dpy, id, - tqt_window_role, XA_STRING, 8, PropModeReplace, - (unsigned char *)name(), tqstrlen( name() ) ); - - // set client leader property - if ( !qt_x11_wm_client_leader ) - qt_x11_create_wm_client_leader(); - XChangeProperty( dpy, id, qt_wm_client_leader, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&qt_x11_wm_client_leader, 1 ); - } - - if ( initializeWindow ) { - // don't erase when resizing - wsa.bit_gravity = - TQApplication::reverseLayout() ? NorthEastGravity : NorthWestGravity; - XChangeWindowAttributes( dpy, id, CWBitGravity, &wsa ); - } - - setWState( WState_MouseTracking ); - setMouseTracking( FALSE ); // also sets event mask - if ( desktop ) { - setWState( WState_Visible ); - } else if ( topLevel ) { // set X cursor - setWState( WState_OwnCursor ); - if ( initializeWindow ) - tqt_x11_enforce_cursor( this ); - } - - if ( destroyw ) - qt_XDestroyWindow( this, dpy, destroyw ); - -#if !defined(TQT_NO_IM_EXTENSIONS) - ic = 0; -#endif -} - - -/*! - Frees up window system resources. Destroys the widget window if \a - destroyWindow is TRUE. - - destroy() calls itself recursively for all the child widgets, - passing \a destroySubWindows for the \a destroyWindow parameter. - To have more control over destruction of subwidgets, destroy - subwidgets selectively first. - - This function is usually called from the TQWidget destructor. -*/ - -void TQWidget::destroy( bool destroyWindow, bool destroySubWindows ) -{ - deactivateWidgetCleanup(); - if ( testWState(WState_Created) ) { - clearWState( WState_Created ); - if ( children() ) { - TQObjectListIt it(*children()); - TQObject *obj; - while ( (obj=it.current()) ) { // destroy all widget children - ++it; - if ( obj->isWidgetType() ) - ((TQWidget*)obj)->destroy(destroySubWindows, - destroySubWindows); - } - } - if ( mouseGrb == this ) - releaseMouse(); - if ( keyboardGrb == this ) - releaseKeyboard(); - if ( isTopLevel() ) - qt_deferred_map_take( this ); - if ( testWFlags(WShowModal) ) // just be sure we leave modal - tqt_leave_modal( this ); - else if ( testWFlags(WType_Popup) ) - tqApp->closePopup( this ); - -#ifndef TQT_NO_XFTFREETYPE - if ( rendhd) { - if ( destroyWindow ) - XftDrawDestroy( (XftDraw *) rendhd ); - else - free( (void*) rendhd ); - rendhd = 0; - } -#endif // TQT_NO_XFTFREETYPE - - if ( testWFlags(WType_Desktop) ) { - if ( acceptDrops() ) - qt_dnd_enable( this, FALSE ); - } else { - if ( destroyWindow ) - qt_XDestroyWindow( this, x11Display(), winid ); - } -#ifndef TQT_NO_XSYNC - destroySyncCounter(); -#endif - setWinId( 0 ); - - extern void qPRCleanup( TQWidget *widget ); // from qapplication_x11.cpp - if ( testWState(WState_Reparented) ) - qPRCleanup(this); - - if( this == icHolderWidget() ) { - destroyInputContext(); - } else { -#ifndef TQT_NO_IM - // release previous focus information participating with - // preedit preservation of qic - TQInputContext *qic = getInputContext(); - if ( qic ) - qic->releaseComposingWidget( this ); -#endif // TQT_NO_IM - } - } -} - -void TQWidget::reparentSys( TQWidget *parent, WFlags f, const TQPoint &p, bool showIt ) -{ - extern void qPRCreate( const TQWidget *, Window ); - - Display *dpy = x11Display(); - TQCursor oldcurs; - bool setcurs = testWState(WState_OwnCursor); - if ( setcurs ) { - oldcurs = cursor(); - unsetCursor(); - } - - // dnd unregister (we will register again below) - bool accept_drops = acceptDrops(); - setAcceptDrops( FALSE ); - - // clear mouse tracking, re-enabled below - bool mouse_tracking = hasMouseTracking(); - clearWState(WState_MouseTracking); - - TQWidget* oldtlw = topLevelWidget(); - TQWidget *oldparent = parentWidget(); - WId old_winid = winid; - if ( testWFlags(WType_Desktop) ) - old_winid = 0; - setWinId( 0 ); - - // hide and reparent our own window away. Otherwise we might get - // destroyed when emitting the child remove event below. See TQWorkspace. - XUnmapWindow( x11Display(), old_winid ); - XReparentWindow( x11Display(), old_winid, - RootWindow( x11Display(), x11Screen() ), 0, 0 ); - - if ( this == icHolderWidget() ) { - // input contexts are sometimes associated with toplevel widgets, so - // we need destroy the context here. if we are reparenting back to - // toplevel, then we may have another context created, otherwise we - // will use our new ic holder's context - destroyInputContext(); - } - -#ifndef TQT_NO_XSYNC - destroySyncCounter(); -#endif - - if ( isTopLevel() || !parent ) // we are toplevel, or reparenting to toplevel - topData()->parentWinId = 0; - - if ( parent != parentObj ) { - if ( parentObj ) // remove from parent - parentObj->removeChild( this ); - if ( parent ) // insert into new parent - parent->insertChild( this ); - } - bool enable = isEnabled(); // remember status - FocusPolicy fp = focusPolicy(); - TQSize s = size(); - TQPixmap *bgp = (TQPixmap *)backgroundPixmap(); - TQColor bgc = bg_col; // save colors - TQString capt= caption(); - widget_flags = f; - clearWState( WState_Created | WState_Visible | WState_ForceHide ); - create(); - if ( isTopLevel() || (!parent || parent->isVisible() ) ) - setWState( WState_ForceHide ); // new widgets do not show up in already visible parents - - const TQObjectList *chlist = children(); - if ( chlist ) { // reparent children - TQObjectList childList(*chlist); - TQObjectListIt it(childList); // iterate over copy - TQObject *obj; - while ( (obj=it.current()) ) { - if ( obj->isWidgetType() ) { - TQWidget *w = (TQWidget *)obj; - if ( !w->isTopLevel() ) { - XReparentWindow( x11Display(), w->winId(), winId(), - w->geometry().x(), w->geometry().y() ); - } else if ( w->isPopup() - || w->testWFlags(WStyle_DialogBorder) - || w->testWFlags(WType_Dialog) - || w->testWFlags(WStyle_Tool) ) { - /* - when reparenting toplevel windows with toplevel-transient children, - we need to make sure that the window manager gets the updated - WM_TRANSIENT_FOR information... unfortunately, some window managers - don't handle changing WM_TRANSIENT_FOR before the toplevel window is - visible, so we unmap and remap all toplevel-transient children *after* - the toplevel parent has been mapped. thankfully, this is easy in TQt :) - */ - XUnmapWindow(w->x11Display(), w->winId()); - XSetTransientForHint(w->x11Display(), w->winId(), winId()); - TQApplication::postEvent(w, new TQEvent(TQEvent::ShowWindowRequest)); - } - } - ++it; - } - } - qPRCreate( this, old_winid ); - if ( bgp ) - XSetWindowBackgroundPixmap( dpy, winid, bgp->handle() ); - else - XSetWindowBackground( dpy, winid, bgc.pixel(x11Screen()) ); - - if (isTopLevel()) { - // preserve maximized/fullscreen flags and the normal geometry - uint save_state = widget_state & (WState_Maximized | WState_FullScreen); - const TQRect r = topData()->normalGeometry; - setGeometry(p.x(), p.y(), s.width(), s.height()); - widget_state |= save_state; - topData()->normalGeometry = r; - } else { - setGeometry(p.x(), p.y(), s.width(), s.height()); - } - - setEnabled( enable ); - setFocusPolicy( fp ); - if ( !capt.isNull() ) { - extra->topextra->caption = TQString::null; - setCaption( capt ); - } - if ( showIt ) - show(); - if ( old_winid ) - qt_XDestroyWindow( this, dpy, old_winid ); - if ( setcurs ) - setCursor(oldcurs); - - reparentFocusWidgets( oldtlw ); - - // re-register dnd - if (oldparent) - oldparent->checkChildrenDnd(); - - if ( accept_drops ) - setAcceptDrops( TRUE ); - else { - checkChildrenDnd(); - topData()->dnd = 0; - qt_dnd_enable(this, (extra && extra->children_use_dnd)); - } - - // re-enable mouse tracking - if (mouse_tracking) - setMouseTracking(mouse_tracking); -} - -// Sets the EWMH (netwm) window type. Needed as a separate function -// because create() may be too soon in some cases. -void TQWidget::x11SetWindowType( X11WindowType type ) -{ - // NET window types - long net_wintypes[7] = { 0, 0, 0, 0, 0, 0, 0 }; - int curr_wintype = 0; - if( testWFlags(WType_Desktop)) - return; - if( type == X11WindowTypeSelect ) { - if ( testWFlags(WStyle_Splash)) { - if (qt_net_supports(qt_net_wm_window_type_splash)) { - net_wintypes[curr_wintype++] = qt_net_wm_window_type_splash; - } - } else if (inherits("TQToolBar")) { - // toolbar netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_toolbar; - } else if (testWFlags(WStyle_Customize) && testWFlags(WStyle_Tool)) { - // utility netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_utility; - } else if (testWFlags(WType_Dialog)) { - // dialog netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_dialog; - } - } else if( type == X11WindowTypeCombo ) { - // combo netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_combo; - } else if( type == X11WindowTypeDND ) { - // dnd netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_dnd; - } else if( type == X11WindowTypeDropdown ) { - // dropdown netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_dropdown_menu; - } else if( type == X11WindowTypePopup ) { - // popup netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_popup_menu; - } else if( type == X11WindowTypeMenu ) { - // menu netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_menu; - } else if( type == X11WindowTypeTooltip ) { - // tooltip netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_tooltip; - } - - // normal netwm type - default - net_wintypes[curr_wintype++] = qt_net_wm_window_type_normal; - // set _NET_WM_WINDOW_TYPE - if (curr_wintype > 0) - XChangeProperty(x11Display(), winId(), qt_net_wm_window_type, XA_ATOM, 32, PropModeReplace, - (unsigned char *) net_wintypes, curr_wintype); - else - XDeleteProperty(x11Display(), winId(), qt_net_wm_window_type); -} - -void TQWidget::x11SetWindowTransient( TQWidget* parent ) -{ - XSetTransientForHint( x11Display(), winId(), parent->winId()); -} - -/*! - Translates the widget coordinate \a pos to global screen - coordinates. For example, \c{mapToGlobal(TQPoint(0,0))} would give - the global coordinates of the top-left pixel of the widget. - - \sa mapFromGlobal() mapTo() mapToParent() -*/ - -TQPoint TQWidget::mapToGlobal( const TQPoint &pos ) const -{ - int x, y; - Window child; - XTranslateCoordinates( x11Display(), winId(), - TQApplication::desktop()->screen(x11Screen())->winId(), - pos.x(), pos.y(), &x, &y, &child ); - return TQPoint( x, y ); -} - -/*! - Translates the global screen coordinate \a pos to widget - coordinates. - - \sa mapToGlobal() mapFrom() mapFromParent() -*/ - -TQPoint TQWidget::mapFromGlobal( const TQPoint &pos ) const -{ - int x, y; - Window child; - XTranslateCoordinates( x11Display(), - TQApplication::desktop()->screen(x11Screen())->winId(), - winId(), pos.x(), pos.y(), &x, &y, &child ); - return TQPoint( x, y ); -} - -/*! - When a widget gets focus, it should call setMicroFocusHint() with - some appropriate position and size, \a x, \a y, \a width and \a - height. This has no \e visual effect, it just provides hints to - any system-specific input handling tools. - - The \a text argument should be TRUE if this is a position for text - input. - - In the Windows version of TQt, this method sets the system caret, - which is used for user Accessibility focus handling. If \a text - is TRUE, it also sets the IME composition window in Far East Asian - language input systems. - - In the X11 version of TQt, if \a text is TRUE, this method sets the - input method focus point in the preedit (XIM "spot" point) for - complex language input handling. - - The font \a f is a rendering hint to the currently active input method. - If \a f is 0 the widget's font is used. - - \sa microFocusHint() -*/ -void TQWidget::setMicroFocusHint(int x, int y, int width, int height, - bool text, TQFont *f ) -{ -#ifndef TQT_NO_IM - if ( text ) { - // trigger input context creation if it hasn't happened already - createInputContext(); - - TQInputContext *qic = getInputContext(); - if(qic) { - TQPoint gp = mapToGlobal( TQPoint( x, y ) ); - qic->setMicroFocus(gp.x(), gp.y(), width, height, f); - } - } -#endif - - if ( TQRect( x, y, width, height ) != microFocusHint() ) { - createExtra(); - extraData()->micro_focus_hint.setRect( x, y, width, height ); - } -} - - -void TQWidget::setFontSys( TQFont * ) -{ - // Nothing -} - - -void TQWidget::setBackgroundColorDirect( const TQColor &color ) -{ - bg_col = color; - if ( extra && extra->bg_pix ) { // kill the background pixmap - delete extra->bg_pix; - extra->bg_pix = 0; - } - XSetWindowBackground( x11Display(), winId(), bg_col.pixel(x11Screen()) ); -} - -static int allow_null_pixmaps = 0; - - -void TQWidget::setBackgroundPixmapDirect( const TQPixmap &pixmap ) -{ - TQPixmap old; - if ( extra && extra->bg_pix ) - old = *extra->bg_pix; - if ( !allow_null_pixmaps && pixmap.isNull() ) { - XSetWindowBackground( x11Display(), winId(), bg_col.pixel(x11Screen()) ); - if ( extra && extra->bg_pix ) { - delete extra->bg_pix; - extra->bg_pix = 0; - } - } else { - TQPixmap pm = pixmap; - if (!pm.isNull()) { - if ( pm.depth() == 1 && TQPixmap::defaultDepth() > 1 ) { - pm = TQPixmap( pixmap.size() ); - bitBlt( &pm, 0, 0, &pixmap, 0, 0, pm.width(), pm.height() ); - } - } - if ( extra && extra->bg_pix ) - delete extra->bg_pix; - else - createExtra(); - extra->bg_pix = new TQPixmap( pm ); - TQ_CHECK_PTR( extra->bg_pix ); - extra->bg_pix->x11SetScreen( x11Screen() ); - XSetWindowBackgroundPixmap( x11Display(), winId(), extra->bg_pix->handle() ); - if ( testWFlags(WType_Desktop) ) // save rootinfo later - qt_updated_rootinfo(); - } -} - - -/*! - Sets the window-system background of the widget to nothing. - - Note that "nothing" is actually a pixmap that isNull(), thus you - can check for an empty background by checking backgroundPixmap(). - - \sa setBackgroundPixmap(), setBackgroundColor() -*/ -void TQWidget::setBackgroundEmpty() -{ - allow_null_pixmaps++; - setErasePixmap(TQPixmap()); - allow_null_pixmaps--; -} - - -void TQWidget::setBackgroundX11Relative() -{ - XSetWindowBackgroundPixmap( x11Display(), winId(), ParentRelative ); -} - -void TQWidget::setCursor( const TQCursor &cursor ) -{ - if ( cursor.handle() != arrowCursor.handle() - || (extra && extra->curs) ) { - createExtra(); - delete extra->curs; - extra->curs = new TQCursor(cursor); - } - setWState( WState_OwnCursor ); - tqt_x11_enforce_cursor( this ); - XFlush( x11Display() ); -} - -void TQWidget::unsetCursor() -{ - if ( extra ) { - delete extra->curs; - extra->curs = 0; - } - if ( !isTopLevel() ) - clearWState( WState_OwnCursor ); - tqt_x11_enforce_cursor( this ); - XFlush( x11Display() ); -} - -static XTextProperty* -qstring_to_xtp( const TQString& s ) -{ - static XTextProperty tp = { 0, 0, 0, 0 }; - static bool free_prop = TRUE; // we can't free tp.value in case it references - // the data of the static TQCString below. - if ( tp.value ) { - if ( free_prop ) - XFree( tp.value ); - tp.value = 0; - free_prop = TRUE; - } - - static const TQTextCodec* mapper = TQTextCodec::codecForLocale(); - int errCode = 0; - if ( mapper ) { - TQCString mapped = mapper->fromUnicode(s); - char* tl[2]; - tl[0] = mapped.data(); - tl[1] = 0; - errCode = XmbTextListToTextProperty( TQPaintDevice::x11AppDisplay(), - tl, 1, XStdICCTextStyle, &tp ); -#if defined(QT_DEBUG) - if ( errCode < 0 ) - tqDebug( "qstring_to_xtp result code %d", errCode ); -#endif - } - if ( !mapper || errCode < 0 ) { - static TQCString qcs; - qcs = s.ascii(); - tp.value = (uchar*)qcs.data(); - tp.encoding = XA_STRING; - tp.format = 8; - tp.nitems = qcs.length(); - free_prop = FALSE; - } - - // ### If we knew WM could understand unicode, we could use - // ### a much simpler, cheaper encoding... - /* - tp.value = (XChar2b*)s.unicode(); - tp.encoding = XA_UNICODE; // wish - tp.format = 16; - tp.nitems = s.length(); - */ - - return &tp; -} - -void TQWidget::setCaption( const TQString &caption ) -{ - if ( TQWidget::caption() == caption ) - return; - - topData()->caption = caption; - XSetWMName( x11Display(), winId(), qstring_to_xtp(caption) ); - - TQCString net_wm_name = caption.utf8(); - XChangeProperty(x11Display(), winId(), qt_net_wm_name, qt_utf8_string, 8, - PropModeReplace, (unsigned char *)net_wm_name.data(), - net_wm_name.length()); - - TQEvent e( TQEvent::CaptionChange ); - TQApplication::sendEvent( this, &e ); -} - -void TQWidget::setIcon( const TQPixmap &pixmap ) -{ - if ( extra && extra->topextra ) { - delete extra->topextra->icon; - extra->topextra->icon = 0; - } else { - createTLExtra(); - } - Pixmap icon_pixmap = 0; - Pixmap mask_pixmap = 0; - TQPixmap* pm = NULL; - if ( !pixmap.isNull() ) { - if (pixmap.depth() == 24) { - pm = new TQPixmap( pixmap ); - } - else { - // With most window managers, only 24-bit icon pixmaps are allowed in the WM hints, otherwise corrupt icons will be displayed - // Convert provided pixmaps to 24-bit here - int w = pixmap.width(); - int h = pixmap.height(); - pm = new TQPixmap( pixmap.width(), pixmap.height(), 24 ); - TQImage iconImage = pixmap.convertToImage(); - - // Load the new 24-bit RGB pixmap with data - GC gc; - pm->detach(); - TQt::HANDLE pmHandle = pm->handle(); - gc = XCreateGC(x11Display(), pmHandle, 0, 0); - for (int y = 0; y < h; ++y) { - TQRgb *ls = (TQRgb *)iconImage.scanLine( y ); - for (int x = 0; x < w; ++x) { - TQRgb l = ls[x]; - int r = int( tqRed( l ) ); - int g = int( tqGreen( l ) ); - int b = int( tqBlue( l ) ); - XSetForeground(x11Display(), gc, (r << 16) | (g << 8) | b ); - XDrawPoint(x11Display(), pmHandle, gc, x, y); - } - } - XFreeGC(x11Display(), gc); - } - - extra->topextra->icon = pm; - if ( !pm->mask() ) { - pm->setMask( pm->createHeuristicMask() ); // may do detach() - } - icon_pixmap = pm->handle(); - if ( pm->mask() ) { - mask_pixmap = pm->mask()->handle(); - } - } - XWMHints *h = XGetWMHints( x11Display(), winId() ); - XWMHints wm_hints; - bool got_hints = h != 0; - if ( !got_hints ) { - h = &wm_hints; - h->flags = 0; - } - h->icon_pixmap = icon_pixmap; - h->icon_mask = mask_pixmap; - h->flags |= IconPixmapHint | IconMaskHint; - XSetWMHints( x11Display(), winId(), h ); - if ( got_hints ) - XFree( (char *)h ); - TQEvent e( TQEvent::IconChange ); - TQApplication::sendEvent( this, &e ); -} - -void TQWidget::setIconText( const TQString &iconText ) -{ - if (TQWidget::iconText() == iconText) - return; - - topData()->iconText = iconText; - XSetWMIconName( x11Display(), winId(), qstring_to_xtp(iconText) ); - - TQCString net_wm_icon_name = iconText.utf8(); - XChangeProperty(x11Display(), winId(), qt_net_wm_icon_name, qt_utf8_string, 8, PropModeReplace, - (unsigned char *) net_wm_icon_name.data(), net_wm_icon_name.length()); -} - -void TQWidget::setMouseTracking( bool enable ) -{ - bool gmt = TQApplication::hasGlobalMouseTracking(); - if ( !enable == !testWState(WState_MouseTracking) && !gmt ) - return; - uint m = (enable || gmt) ? (uint)PointerMotionMask : 0; - if ( enable ) - setWState( WState_MouseTracking ); - else - clearWState( WState_MouseTracking ); - if ( testWFlags(WType_Desktop) ) { // desktop widget? - TQWidget* main_desktop = find( winId() ); - if ( main_desktop->testWFlags(WPaintDesktop) ) - XSelectInput( x11Display(), winId(), - stdDesktopEventMask | ExposureMask ); - else - XSelectInput( x11Display(), winId(), stdDesktopEventMask ); - } else { - XSelectInput( x11Display(), winId(), - m | stdWidgetEventMask ); -#if defined (QT_TABLET_SUPPORT) - if ( devStylus != NULL ) { - XSelectExtensionEvent( x11Display(), winId(), event_list_stylus, - qt_curr_events_stylus ); - } - if ( devEraser != NULL ) { - XSelectExtensionEvent( x11Display(), winId(), event_list_eraser, - qt_curr_events_eraser ); - } -#endif - } -} - - -/*! - Grabs the mouse input. - - This widget receives all mouse events until releaseMouse() is - called; other widgets get no mouse events at all. Keyboard - events are not affected. Use grabKeyboard() if you want to grab - that. - - \warning Bugs in mouse-grabbing applications very often lock the - terminal. Use this function with extreme caution, and consider - using the \c -nograb command line option while debugging. - - It is almost never necessary to grab the mouse when using TQt, as - TQt grabs and releases it sensibly. In particular, TQt grabs the - mouse when a mouse button is pressed and keeps it until the last - button is released. - - Note that only visible widgets can grab mouse input. If - isVisible() returns FALSE for a widget, that widget cannot call - grabMouse(). - - \sa releaseMouse() grabKeyboard() releaseKeyboard() grabKeyboard() - focusWidget() -*/ - -void TQWidget::grabMouse() -{ - if ( isVisible() && !qt_nograb() ) { - if ( mouseGrb ) - mouseGrb->releaseMouse(); -#if defined(QT_CHECK_STATE) - int status = -#endif - XGrabPointer( x11Display(), winId(), False, - (uint)( ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | EnterWindowMask | - LeaveWindowMask ), - GrabModeAsync, GrabModeAsync, - None, None, tqt_x_time ); -#if defined(QT_CHECK_STATE) - if ( status ) { - const char *s = - status == GrabNotViewable ? "\"GrabNotViewable\"" : - status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" : - status == GrabFrozen ? "\"GrabFrozen\"" : - status == GrabInvalidTime ? "\"GrabInvalidTime\"" : - ""; - tqWarning( "Grabbing the mouse failed with %s", s ); - } -#endif - mouseGrb = this; - } -} - -/*! - \overload - - Grabs the mouse input and changes the cursor shape. - - The cursor will assume shape \a cursor (for as long as the mouse - focus is grabbed) and this widget will be the only one to receive - mouse events until releaseMouse() is called(). - - \warning Grabbing the mouse might lock the terminal. - - \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() -*/ - -void TQWidget::grabMouse( const TQCursor &cursor ) -{ - if ( !qt_nograb() ) { - if ( mouseGrb != this ) { - if ( mouseGrb ) { - mouseGrb->releaseMouse(); - } -#if defined(QT_CHECK_STATE) - int status = -#endif - XGrabPointer( x11Display(), winId(), False, - (uint)(ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | EnterWindowMask | LeaveWindowMask), - GrabModeAsync, GrabModeAsync, - None, cursor.handle(), tqt_x_time ); -#if defined(QT_CHECK_STATE) - if ( status ) { - const char *s = - status == GrabNotViewable ? "\"GrabNotViewable\"" : - status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" : - status == GrabFrozen ? "\"GrabFrozen\"" : - status == GrabInvalidTime ? "\"GrabInvalidTime\"" : - ""; - tqWarning( "Grabbing the mouse failed with %s", s ); - } -#endif - mouseGrb = this; - } - } -} - -/*! - Releases the mouse grab. - - \sa grabMouse(), grabKeyboard(), releaseKeyboard() -*/ - -void TQWidget::releaseMouse() -{ - if ( !qt_nograb() && mouseGrb == this ) { - XUngrabPointer( x11Display(), tqt_x_time ); - XFlush( x11Display() ); - mouseGrb = 0; - } -} - -/*! - Grabs the keyboard input. - - This widget reveives all keyboard events until releaseKeyboard() - is called; other widgets get no keyboard events at all. Mouse - events are not affected. Use grabMouse() if you want to grab that. - - The focus widget is not affected, except that it doesn't receive - any keyboard events. setFocus() moves the focus as usual, but the - new focus widget receives keyboard events only after - releaseKeyboard() is called. - - If a different widget is currently grabbing keyboard input, that - widget's grab is released first. - - \sa releaseKeyboard() grabMouse() releaseMouse() focusWidget() -*/ - -void TQWidget::grabKeyboard() -{ - if ( !qt_nograb() ) { - if ( keyboardGrb != this ) { - if ( keyboardGrb ) { - keyboardGrb->releaseKeyboard(); - } - XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, tqt_x_time ); - keyboardGrb = this; - } - } -} - -/*! - Releases the keyboard grab. - - \sa grabKeyboard(), grabMouse(), releaseMouse() -*/ - -void TQWidget::releaseKeyboard() -{ - if ( !qt_nograb() && keyboardGrb == this ) { - XUngrabKeyboard( x11Display(), tqt_x_time ); - keyboardGrb = 0; - } -} - - -/*! - Returns the widget that is currently grabbing the mouse input. - - If no widget in this application is currently grabbing the mouse, - 0 is returned. - - \sa grabMouse(), keyboardGrabber() -*/ - -TQWidget *TQWidget::mouseGrabber() -{ - return mouseGrb; -} - -/*! - Returns the widget that is currently grabbing the keyboard input. - - If no widget in this application is currently grabbing the - keyboard, 0 is returned. - - \sa grabMouse(), mouseGrabber() -*/ - -TQWidget *TQWidget::keyboardGrabber() -{ - return keyboardGrb; -} - -/*! - Sets the top-level widget containing this widget to be the active - window. - - An active window is a visible top-level window that has the - keyboard input focus. - - This function performs the same operation as clicking the mouse on - the title bar of a top-level window. On X11, the result depends on - the Window Manager. If you want to ensure that the window is - stacked on top as well you should also call raise(). Note that the - window must be visible, otherwise setActiveWindow() has no effect. - - On Windows, if you are calling this when the application is not - currently the active one then it will not make it the active - window. It will flash the task bar entry blue to indicate that - the window has done something. This is because Microsoft do not - allow an application to interrupt what the user is currently doing - in another application. - - \sa isActiveWindow(), topLevelWidget(), show() -*/ - -void TQWidget::setActiveWindow() -{ - TQWidget *tlw = topLevelWidget(); - if ( tlw->isVisible() && !tlw->topData()->embedded && !qt_deferred_map_contains(tlw) ) { - XSetInputFocus( x11Display(), tlw->winId(), RevertToNone, tqt_x_time); - focusInputContext(); - } -} - - -/*! - Updates the widget unless updates are disabled or the widget is - hidden. - - This function does not cause an immediate repaint; instead it - schedules a paint event for processing when TQt returns to the main - event loop. This permits TQt to optimize for more speed and less - flicker than a call to repaint() does. - - Calling update() several times normally results in just one - paintEvent() call. - - TQt normally erases the widget's area before the paintEvent() call. - If the \c WRepaintNoErase widget flag is set, the widget is - responsible for painting all its pixels itself. - - \sa repaint(), paintEvent(), setUpdatesEnabled(), erase(), - setWFlags() -*/ - -void TQWidget::update() -{ - if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == - WState_Visible ) - TQApplication::postEvent( this, new TQPaintEvent( clipRegion(), !testWFlags(WRepaintNoErase) ) ); -} - -/*! - \overload - - Updates a rectangle (\a x, \a y, \a w, \a h) inside the widget - unless updates are disabled or the widget is hidden. - - This function does not cause an immediate repaint; instead it - schedules a paint event for processing when TQt returns to the main - event loop. This permits TQt to optimize for more speed and less - flicker and a call to repaint() does. - - Calling update() several times normally results in just one - paintEvent() call. - - If \a w is negative, it is replaced with \c{width() - x}. If \a h - is negative, it is replaced width \c{height() - y}. - - TQt normally erases the specified area before the paintEvent() - call. If the \c WRepaintNoErase widget flag is set, the widget is - responsible for painting all its pixels itself. - - \sa repaint(), paintEvent(), setUpdatesEnabled(), erase() -*/ - -void TQWidget::update( int x, int y, int w, int h ) -{ - if ( w && h && - (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) { - if ( w < 0 ) - w = crect.width() - x; - if ( h < 0 ) - h = crect.height() - y; - if ( w != 0 && h != 0 ) - TQApplication::postEvent( this, - new TQPaintEvent( clipRegion().intersect(TQRect(x,y,w,h)), - !testWFlags( WRepaintNoErase ) ) ); - } -} - -/*! - \overload void TQWidget::update( const TQRect &r ) - - Updates a rectangle \a r inside the widget unless updates are - disabled or the widget is hidden. - - This function does not cause an immediate repaint; instead it - schedules a paint event for processing when TQt returns to the main - event loop. This permits TQt to optimize for more speed and less - flicker and a call to repaint() does. - - Calling update() several times normally results in just one - paintEvent() call. -*/ - -/*! - \overload void TQWidget::repaint( bool erase ) - - This version repaints the entire widget. -*/ - -/*! - \overload void TQWidget::repaint() - - This version erases and repaints the entire widget. -*/ - -/*! - Repaints the widget directly by calling paintEvent() immediately, - unless updates are disabled or the widget is hidden. - - If \a erase is TRUE, TQt erases the area \a (x, y, w, h) before the - paintEvent() call. - - If \a w is negative, it is replaced with \c{width() - x}, and if - \a h is negative, it is replaced width \c{height() - y}. - - We suggest only using repaint() if you need an immediate repaint, - for example during animation. In almost all circumstances update() - is better, as it permits TQt to optimize for speed and minimize - flicker. - - \warning If you call repaint() in a function which may itself be - called from paintEvent(), you may get infinite recursion. The - update() function never causes recursion. - - \sa update(), paintEvent(), setUpdatesEnabled(), erase() -*/ - -void TQWidget::repaint( int x, int y, int w, int h, bool erase ) -{ - if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) { - if ( x > crect.width() || y > crect.height() ) - return; - if ( w < 0 ) - w = crect.width() - x; - if ( h < 0 ) - h = crect.height() - y; - TQRect r(x,y,w,h); - if ( r.isEmpty() ) - return; // nothing to do - TQPaintEvent e( r, erase ); - if ( r != rect() ) - qt_set_paintevent_clipping( this, r ); - if ( erase && w != 0 && h != 0 ) { - if ( backgroundOrigin() == WidgetOrigin ) - XClearArea( x11Display(), winId(), x, y, w, h, False ); - else - this->erase( x, y, w, h); - } - TQApplication::sendEvent( this, &e ); - qt_clear_paintevent_clipping(); - } -} - -/*! - \overload - - Repaints the widget directly by calling paintEvent() directly, - unless updates are disabled or the widget is hidden. - - Erases the widget region \a reg if \a erase is TRUE. - - Only use repaint if your widget needs to be repainted immediately, - for example when doing some animation. In all other cases, use - update(). Calling update() many times in a row will generate a - single paint event. - - \warning If you call repaint() in a function which may itself be - called from paintEvent(), you may get infinite recursion. The - update() function never causes recursion. - - \sa update(), paintEvent(), setUpdatesEnabled(), erase() -*/ - -void TQWidget::repaint( const TQRegion& reg, bool erase ) -{ - if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) { - TQPaintEvent e( reg, erase ); - qt_set_paintevent_clipping( this, reg ); - if ( erase ) - this->erase(reg); - TQApplication::sendEvent( this, &e ); - qt_clear_paintevent_clipping(); - } -} - -/*! - \overload void TQWidget::repaint( const TQRect &r, bool erase ) - - Repaints the widget directly by calling paintEvent() directly, - unless updates are disabled or the widget is hidden. - - Erases the widget region \a r if \a erase is TRUE. -*/ - -void TQWidget::setWindowState(uint newstate) -{ - bool needShow = FALSE; - uint oldstate = windowState(); - if (isTopLevel()) { - TQTLWExtra *top = topData(); - - if ((oldstate & WindowMaximized) != (newstate & WindowMaximized)) { - if (qt_net_supports(qt_net_wm_state_max_h) && qt_net_supports(qt_net_wm_state_max_v)) { - qt_net_change_wm_state(this, (newstate & WindowMaximized), - qt_net_wm_state_max_h, qt_net_wm_state_max_v); - } else if (! (newstate & WindowFullScreen)) { - if (newstate & WindowMaximized) { - // save original geometry - const TQRect normalGeometry = geometry(); - - if (isVisible()) { - updateFrameStrut(); - const TQRect maxRect = TQApplication::desktop()->availableGeometry(this); - const TQRect r = top->normalGeometry; - setGeometry(maxRect.x() + top->fleft, - maxRect.y() + top->ftop, - maxRect.width() - top->fleft - top->fright, - maxRect.height() - top->ftop - top->fbottom); - top->normalGeometry = r; - } - - if (top->normalGeometry.width() < 0) - top->normalGeometry = normalGeometry; - } else { - // restore original geometry - setGeometry(top->normalGeometry); - } - } - } - - if ((oldstate & WindowFullScreen) != (newstate & WindowFullScreen)) { - if (qt_net_supports(qt_net_wm_state_fullscreen)) { - qt_net_change_wm_state(this, (newstate & WindowFullScreen), - qt_net_wm_state_fullscreen); - } else { - needShow = isVisible(); - - if (newstate & WindowFullScreen) { - const TQRect normalGeometry = TQRect(pos(), size()); - - top->savedFlags = getWFlags(); - reparent(0, WType_TopLevel | WStyle_Customize | WStyle_NoBorder | - // preserve some widget flags - (getWFlags() & 0xffff0000), - mapToGlobal(TQPoint(0, 0))); - const TQRect r = top->normalGeometry; - setGeometry(tqApp->desktop()->screenGeometry(this)); - top->normalGeometry = r; - - if ( top->normalGeometry.width() < 0 ) - top->normalGeometry = normalGeometry; - } else { - reparent( 0, top->savedFlags, mapToGlobal(TQPoint(0, 0)) ); - - if (newstate & WindowMaximized) { - // from fullscreen to maximized - updateFrameStrut(); - const TQRect maxRect = TQApplication::desktop()->availableGeometry(this); - const TQRect r = top->normalGeometry; - setGeometry(maxRect.x() + top->fleft, - maxRect.y() + top->ftop, - maxRect.width() - top->fleft - top->fright, - maxRect.height() - top->ftop - top->fbottom); - top->normalGeometry = r; - } else { - // restore original geometry - setGeometry(top->normalGeometry); - } - } - } - } - - if ((oldstate & WindowMinimized) != (newstate & WindowMinimized)) { - if (isVisible()) { - if (newstate & WindowMinimized) { - XEvent e; - e.xclient.type = ClientMessage; - e.xclient.message_type = qt_wm_change_state; - e.xclient.display = x11Display(); - e.xclient.window = winid; - e.xclient.format = 32; - e.xclient.data.l[0] = IconicState; - e.xclient.data.l[1] = 0; - e.xclient.data.l[2] = 0; - e.xclient.data.l[3] = 0; - e.xclient.data.l[4] = 0; - XSendEvent(x11Display(), RootWindow(x11Display(), x11Screen()), - False, (SubstructureNotifyMask|SubstructureRedirectMask), &e); - } else { - XMapWindow(x11Display(), winId()); - } - } - - needShow = FALSE; - } - } - - widget_state &= ~(WState_Minimized | WState_Maximized | WState_FullScreen); - if (newstate & WindowMinimized) - widget_state |= WState_Minimized; - if (newstate & WindowMaximized) - widget_state |= WState_Maximized; - if (newstate & WindowFullScreen) - widget_state |= WState_FullScreen; - - if (needShow) - show(); - - if (newstate & WindowActive) - setActiveWindow(); - - TQEvent e(TQEvent::WindowStateChange); - TQApplication::sendEvent(this, &e); -} - -/*! - \internal - Platform-specific part of TQWidget::show(). -*/ - -void TQWidget::showWindow() -{ - if ( isTopLevel() ) { - XWMHints *h = XGetWMHints( x11Display(), winId() ); - XWMHints wm_hints; - bool got_hints = h != 0; - if ( !got_hints ) { - h = &wm_hints; - h->flags = 0; - } - h->initial_state = testWState(WState_Minimized) ? IconicState : NormalState; - h->flags |= StateHint; - XSetWMHints( x11Display(), winId(), h ); - if ( got_hints ) - XFree( (char *)h ); - - if (tqt_x_user_time != CurrentTime) { - XChangeProperty(x11Display(), winId(), qt_net_wm_user_time, XA_CARDINAL, - 32, PropModeReplace, (unsigned char *) &tqt_x_user_time, 1); - } - - if (!topData()->embedded && - topData()->parentWinId && - topData()->parentWinId != TQPaintDevice::x11AppRootWindow(x11Screen()) && - !isMinimized() ) { - qt_deferred_map_add( this ); - return; - } - - if (isMaximized() && !isFullScreen() - && !(qt_net_supports(qt_net_wm_state_max_h) - && qt_net_supports(qt_net_wm_state_max_v))) { - XMapWindow( x11Display(), winId() ); - tqt_wait_for_window_manager(this); - - // if the wm was not smart enough to adjust our size, do that manually - updateFrameStrut(); - TQRect maxRect = TQApplication::desktop()->availableGeometry(this); - - TQTLWExtra *top = topData(); - TQRect normalRect = top->normalGeometry; - - setGeometry(maxRect.x() + top->fleft, - maxRect.y() + top->ftop, - maxRect.width() - top->fleft - top->fright, - maxRect.height() - top->ftop - top->fbottom); - - // restore the original normalGeometry - top->normalGeometry = normalRect; - // internalSetGeometry() clears the maximized flag... make sure we set it back - setWState(WState_Maximized); - - return; - } - - if (isFullScreen() && !qt_net_supports(qt_net_wm_state_fullscreen)) { - XMapWindow(x11Display(), winId()); - tqt_wait_for_window_manager(this); - return; - } - } - XMapWindow( x11Display(), winId() ); -} - - -/*! - \internal - Platform-specific part of TQWidget::hide(). -*/ - -void TQWidget::hideWindow() -{ - clearWState( WState_Exposed ); - deactivateWidgetCleanup(); - if ( isTopLevel() ) { - qt_deferred_map_take( this ); - if ( winId() ) // in nsplugin, may be 0 - XWithdrawWindow( x11Display(), winId(), x11Screen() ); - - TQTLWExtra *top = topData(); - crect.moveTopLeft( TQPoint(crect.x() - top->fleft, crect.y() - top->ftop ) ); - - // zero the frame strut and mark it dirty - top->fleft = top->fright = top->ftop = top->fbottom = 0; - fstrut_dirty = TRUE; - - XFlush( x11Display() ); - } else { - if ( winId() ) // in nsplugin, may be 0 - XUnmapWindow( x11Display(), winId() ); - } -} - -/*! - Raises this widget to the top of the parent widget's stack. - - After this call the widget will be visually in front of any - overlapping sibling widgets. - - \sa lower(), stackUnder() -*/ - -void TQWidget::raise() -{ - TQWidget *p = parentWidget(); - if ( p && p->childObjects && p->childObjects->findRef(this) >= 0 ) - p->childObjects->append( p->childObjects->take() ); - XRaiseWindow( x11Display(), winId() ); -} - -/*! - Lowers the widget to the bottom of the parent widget's stack. - - After this call the widget will be visually behind (and therefore - obscured by) any overlapping sibling widgets. - - \sa raise(), stackUnder() -*/ - -void TQWidget::lower() -{ - TQWidget *p = parentWidget(); - if ( p && p->childObjects && p->childObjects->findRef(this) >= 0 ) - p->childObjects->insert( 0, p->childObjects->take() ); - XLowerWindow( x11Display(), winId() ); -} - - -/*! - Places the widget under \a w in the parent widget's stack. - - To make this work, the widget itself and \a w must be siblings. - - \sa raise(), lower() -*/ -void TQWidget::stackUnder( TQWidget* w) -{ - TQWidget *p = parentWidget(); - if ( !w || isTopLevel() || p != w->parentWidget() || this == w ) - return; - if ( p && p->childObjects && p->childObjects->findRef(w) >= 0 && p->childObjects->findRef(this) >= 0 ) { - p->childObjects->take(); - p->childObjects->insert( p->childObjects->findRef(w), this ); - } - Window stack[2]; - stack[0] = w->winId();; - stack[1] = winId(); - XRestackWindows( x11Display(), stack, 2 ); -} - - - -/* - The global variable qt_widget_tlw_gravity defines the window gravity of - the next top level window to be created. We do this when setting the - main widget's geometry and the "-geometry" command line option contains - a negative position. -*/ - -int qt_widget_tlw_gravity = NorthWestGravity; - -static void do_size_hints( TQWidget* widget, TQWExtra *x ) -{ - XSizeHints s; - s.flags = 0; - if ( x ) { - s.x = widget->x(); - s.y = widget->y(); - s.width = widget->width(); - s.height = widget->height(); - if ( x->minw > 0 || x->minh > 0 ) { // add minimum size hints - s.flags |= PMinSize; - s.min_width = x->minw; - s.min_height = x->minh; - } - if ( x->maxw < TQWIDGETSIZE_MAX || x->maxh < TQWIDGETSIZE_MAX ) { - s.flags |= PMaxSize; // add maximum size hints - s.max_width = x->maxw; - s.max_height = x->maxh; - } - if ( x->topextra && - (x->topextra->incw > 0 || x->topextra->inch > 0) ) - { // add resize increment hints - s.flags |= PResizeInc | PBaseSize; - s.width_inc = x->topextra->incw; - s.height_inc = x->topextra->inch; - s.base_width = x->topextra->basew; - s.base_height = x->topextra->baseh; - } - - if ( x->topextra && x->topextra->uspos) { - s.flags |= USPosition; - s.flags |= PPosition; - } - if ( x->topextra && x->topextra->ussize) { - s.flags |= USSize; - s.flags |= PSize; - } - } - s.flags |= PWinGravity; - s.win_gravity = qt_widget_tlw_gravity; // usually NorthWest - // reset in case it was set - qt_widget_tlw_gravity = - TQApplication::reverseLayout() ? NorthEastGravity : NorthWestGravity; - XSetWMNormalHints( widget->x11Display(), widget->winId(), &s ); -} - - -void TQWidget::internalSetGeometry( int x, int y, int w, int h, bool isMove ) -{ - Display *dpy = x11Display(); - - if ( testWFlags(WType_Desktop) ) - return; - if (isTopLevel()) { - if (!qt_net_supports(qt_net_wm_state_max_h) - && !qt_net_supports(qt_net_wm_state_max_v)) - clearWState(WState_Maximized); - if (!qt_net_supports(qt_net_wm_state_fullscreen)) - clearWState(WState_FullScreen); - topData()->normalGeometry = TQRect(0, 0, -1, -1); - } else { - // for TQWorkspace - clearWState(WState_Maximized); - clearWState(WState_FullScreen); - } - if ( extra ) { // any size restrictions? - w = TQMIN(w,extra->maxw); - h = TQMIN(h,extra->maxh); - w = TQMAX(w,extra->minw); - h = TQMAX(h,extra->minh); - } - if ( w < 1 ) // invalid size - w = 1; - if ( h < 1 ) - h = 1; - TQPoint oldPos( pos() ); - TQSize oldSize( size() ); - TQRect oldGeom( crect ); - TQRect r( x, y, w, h ); - - // We only care about stuff that changes the geometry, or may - // cause the window manager to change its state - if ( !isTopLevel() && oldGeom == r ) - return; - - crect = r; - bool isResize = size() != oldSize; - - if ( isTopLevel() ) { - if ( isMove ) - topData()->uspos = 1; - if ( isResize ) - topData()->ussize = 1; - do_size_hints( this, extra ); - } - - if ( isMove ) { - if (! qt_broken_wm) - // pos() is right according to ICCCM 4.1.5 - XMoveResizeWindow( dpy, winid, pos().x(), pos().y(), w, h ); - else - // work around 4Dwm's incompliance with ICCCM 4.1.5 - XMoveResizeWindow( dpy, winid, x, y, w, h ); - } else if ( isResize ) - XResizeWindow( dpy, winid, w, h ); - - if ( isVisible() ) { - if ( isMove && pos() != oldPos ) { - if ( ! qt_broken_wm ) { - // pos() is right according to ICCCM 4.1.5 - TQMoveEvent e( pos(), oldPos ); - TQApplication::sendEvent( this, &e ); - } else { - // work around 4Dwm's incompliance with ICCCM 4.1.5 - TQMoveEvent e( crect.topLeft(), oldGeom.topLeft() ); - TQApplication::sendEvent( this, &e ); - } - } - if ( isResize ) { - - // set config pending only on resize, see qapplication_x11.cpp, translateConfigEvent() - setWState( WState_ConfigPending ); - - TQResizeEvent e( size(), oldSize ); - TQApplication::sendEvent( this, &e ); - } - } else { - if ( isMove && pos() != oldPos ) { - if ( ! qt_broken_wm ) - // pos() is right according to ICCCM 4.1.5 - TQApplication::postEvent( this, new TQMoveEvent( pos(), oldPos ) ); - else - // work around 4Dwm's incompliance with ICCCM 4.1.5 - TQApplication::postEvent( this, new TQMoveEvent( crect.topLeft(), - oldGeom.topLeft() ) ); - } - if ( isResize ) - TQApplication::postEvent( this, - new TQResizeEvent( size(), oldSize ) ); - } -} - - -/*! - \overload - - This function corresponds to setMinimumSize( TQSize(minw, minh) ). - Sets the minimum width to \a minw and the minimum height to \a - minh. -*/ - -void TQWidget::setMinimumSize( int minw, int minh ) -{ -#if defined(QT_CHECK_RANGE) - if ( minw < 0 || minh < 0 ) - tqWarning("TQWidget::setMinimumSize: minw=%d, minh=%d. The smallest allowed size is (0,0)", minw, minh); -#endif - createExtra(); - if ( extra->minw == minw && extra->minh == minh ) - return; - extra->minw = minw; - extra->minh = minh; - if ( minw > width() || minh > height() ) { - bool resized = testWState( WState_Resized ); - resize( TQMAX(minw,width()), TQMAX(minh,height()) ); - if ( !resized ) - clearWState( WState_Resized ); // not a user resize - } - if ( testWFlags(WType_TopLevel) ) - do_size_hints( this, extra ); - updateGeometry(); -} - -/*! - \overload - - This function corresponds to setMaximumSize( TQSize(\a maxw, \a - maxh) ). Sets the maximum width to \a maxw and the maximum height - to \a maxh. -*/ -void TQWidget::setMaximumSize( int maxw, int maxh ) -{ -#if defined(QT_CHECK_RANGE) - if ( maxw > TQWIDGETSIZE_MAX || maxh > TQWIDGETSIZE_MAX ) { - tqWarning("TQWidget::setMaximumSize: (%s/%s) " - "The largest allowed size is (%d,%d)", - name( "unnamed" ), className(), TQWIDGETSIZE_MAX, - TQWIDGETSIZE_MAX ); - maxw = TQMIN( maxw, TQWIDGETSIZE_MAX ); - maxh = TQMIN( maxh, TQWIDGETSIZE_MAX ); - } - if ( maxw < 0 || maxh < 0 ) { - tqWarning("TQWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " - "are not possible", - name( "unnamed" ), className(), maxw, maxh ); - maxw = TQMAX( maxw, 0 ); - maxh = TQMAX( maxh, 0 ); - } -#endif - createExtra(); - if ( extra->maxw == maxw && extra->maxh == maxh ) - return; - extra->maxw = maxw; - extra->maxh = maxh; - if ( maxw < width() || maxh < height() ) { - bool resized = testWState( WState_Resized ); - resize( TQMIN(maxw,width()), TQMIN(maxh,height()) ); - if ( !resized ) - clearWState( WState_Resized ); // not a user resize - } - if ( testWFlags(WType_TopLevel) ) - do_size_hints( this, extra ); - updateGeometry(); -} - -/*! - \overload - - Sets the x (width) size increment to \a w and the y (height) size - increment to \a h. -*/ -void TQWidget::setSizeIncrement( int w, int h ) -{ - TQTLWExtra* x = topData(); - if ( x->incw == w && x->inch == h ) - return; - x->incw = w; - x->inch = h; - if ( testWFlags(WType_TopLevel) ) - do_size_hints( this, extra ); -} - -/*! - \overload - - This corresponds to setBaseSize( TQSize(\a basew, \a baseh) ). Sets - the widgets base size to width \a basew and height \a baseh. -*/ -void TQWidget::setBaseSize( int basew, int baseh ) -{ - createTLExtra(); - TQTLWExtra* x = topData(); - if ( x->basew == basew && x->baseh == baseh ) - return; - x->basew = basew; - x->baseh = baseh; - if ( testWFlags(WType_TopLevel) ) - do_size_hints( this, extra ); -} - -/*! - \overload void TQWidget::erase() - - This version erases the entire widget. -*/ - -/*! - \overload void TQWidget::erase( const TQRect &r ) - - Erases the specified area \a r in the widget without generating a - \link paintEvent() paint event\endlink. -*/ - -/*! - Erases the specified area \a (x, y, w, h) in the widget without - generating a \link paintEvent() paint event\endlink. - - If \a w is negative, it is replaced with \c{width() - x}. If \a h - is negative, it is replaced width \c{height() - y}. - - Child widgets are not affected. - - \sa repaint() -*/ - -void TQWidget::erase( int x, int y, int w, int h ) -{ - extern void qt_erase_rect( TQWidget*, const TQRect& ); // in qpainer_x11.cpp - if ( w < 0 ) - w = crect.width() - x; - if ( h < 0 ) - h = crect.height() - y; - if ( w != 0 && h != 0 ) - qt_erase_rect( this, TQRect(x, y, w, h ) ); -} - -/*! - \overload - - Erases the area defined by \a reg, without generating a \link - paintEvent() paint event\endlink. - - Child widgets are not affected. -*/ - -void TQWidget::erase( const TQRegion& reg ) -{ - extern void qt_erase_region( TQWidget*, const TQRegion& ); // in qpainer_x11.cpp - qt_erase_region( this, reg ); -} - -/*! - Scrolls the widget including its children \a dx pixels to the - right and \a dy downwards. Both \a dx and \a dy may be negative. - - After scrolling, scroll() sends a paint event for the the part - that is read but not written. For example, when scrolling 10 - pixels rightwards, the leftmost ten pixels of the widget need - repainting. The paint event may be delivered immediately or later, - depending on some heuristics (note that you might have to force - processing of paint events using TQApplication::sendPostedEvents() - when using scroll() and move() in combination). - - \sa TQScrollView erase() bitBlt() -*/ - -void TQWidget::scroll( int dx, int dy ) -{ - scroll( dx, dy, TQRect() ); -} - -/*! - \overload - - This version only scrolls \a r and does not move the children of - the widget. - - If \a r is empty or invalid, the result is undefined. - - \sa TQScrollView erase() bitBlt() -*/ -void TQWidget::scroll( int dx, int dy, const TQRect& r ) -{ - if ( testWState( WState_BlockUpdates ) && !children() ) - return; - bool valid_rect = r.isValid(); - bool just_update = TQABS( dx ) > width() || TQABS( dy ) > height(); - if ( just_update ) - update(); - TQRect sr = valid_rect?r:clipRegion().boundingRect(); - int x1, y1, x2, y2, w=sr.width(), h=sr.height(); - if ( dx > 0 ) { - x1 = sr.x(); - x2 = x1+dx; - w -= dx; - } else { - x2 = sr.x(); - x1 = x2-dx; - w += dx; - } - if ( dy > 0 ) { - y1 = sr.y(); - y2 = y1+dy; - h -= dy; - } else { - y2 = sr.y(); - y1 = y2-dy; - h += dy; - } - - if ( dx == 0 && dy == 0 ) - return; - - Display *dpy = x11Display(); - GC gc = tqt_xget_readonly_gc( x11Screen(), FALSE ); - // Want expose events - if ( w > 0 && h > 0 && !just_update ) { - XSetGraphicsExposures( dpy, gc, True ); - XCopyArea( dpy, winId(), winId(), gc, x1, y1, w, h, x2, y2); - XSetGraphicsExposures( dpy, gc, False ); - } - - if ( !valid_rect && children() ) { // scroll children - TQPoint pd( dx, dy ); - TQObjectListIt it(*children()); - TQObject *object; - while ( it ) { // move all children - object = it.current(); - if ( object->isWidgetType() ) { - TQWidget *w = (TQWidget *)object; - w->move( w->pos() + pd ); - } - ++it; - } - } - - if ( just_update ) - return; - - // Don't let the server be bogged-down with repaint events - bool repaint_immediately = qt_sip_count( this ) < 3; - - if ( dx ) { - int x = x2 == sr.x() ? sr.x()+w : sr.x(); - if ( repaint_immediately ) - repaint( x, sr.y(), TQABS(dx), sr.height(), !testWFlags(WRepaintNoErase) ); - else - XClearArea( dpy, winid, x, sr.y(), TQABS(dx), sr.height(), True ); - } - if ( dy ) { - int y = y2 == sr.y() ? sr.y()+h : sr.y(); - if ( repaint_immediately ) - repaint( sr.x(), y, sr.width(), TQABS(dy), !testWFlags(WRepaintNoErase) ); - else - XClearArea( dpy, winid, sr.x(), y, sr.width(), TQABS(dy), True ); - } - - qt_insert_sip( this, dx, dy ); // #### ignores r -} - - -/*! - \overload void TQWidget::drawText( const TQPoint &pos, const TQString& str ) - - Draws the string \a str at position \a pos. -*/ - -/*! - Draws the string \a str at position \a(x, y). - - The \a y position is the base line position of the text. The text - is drawn using the default font and the default foreground color. - - This function is provided for convenience. You will generally get - more flexible results and often higher speed by using a a \link - TQPainter painter\endlink instead. - - \sa setFont(), foregroundColor(), TQPainter::drawText() -*/ - -void TQWidget::drawText( int x, int y, const TQString &str ) -{ - if ( testWState(WState_Visible) ) { - TQPainter paint; - paint.begin( this ); - paint.drawText( x, y, str ); - paint.end(); - } -} - - -/*! - Internal implementation of the virtual TQPaintDevice::metric() - function. - - Use the TQPaintDeviceMetrics class instead. - - \a m is the metric to get. -*/ - -int TQWidget::metric( int m ) const -{ - int val; - if ( m == TQPaintDeviceMetrics::PdmWidth ) { - val = crect.width(); - } else if ( m == TQPaintDeviceMetrics::PdmHeight ) { - val = crect.height(); - } else { - Display *dpy = x11Display(); - int scr = x11Screen(); - switch ( m ) { - case TQPaintDeviceMetrics::PdmDpiX: - case TQPaintDeviceMetrics::PdmPhysicalDpiX: - val = TQPaintDevice::x11AppDpiX( scr ); - break; - case TQPaintDeviceMetrics::PdmDpiY: - case TQPaintDeviceMetrics::PdmPhysicalDpiY: - val = TQPaintDevice::x11AppDpiY( scr ); - break; - case TQPaintDeviceMetrics::PdmWidthMM: - val = (DisplayWidthMM(dpy,scr)*crect.width())/ - DisplayWidth(dpy,scr); - break; - case TQPaintDeviceMetrics::PdmHeightMM: - val = (DisplayHeightMM(dpy,scr)*crect.height())/ - DisplayHeight(dpy,scr); - break; - case TQPaintDeviceMetrics::PdmNumColors: - val = x11Cells(); - break; - case TQPaintDeviceMetrics::PdmDepth: - val = x11Depth(); - break; - default: - val = 0; -#if defined(QT_CHECK_RANGE) - tqWarning( "TQWidget::metric: Invalid metric command" ); -#endif - } - } - return val; -} - -void TQWidget::createSysExtra() -{ - extra->xDndProxy = 0; - extra->children_use_dnd = FALSE; - extra->compress_events = TRUE; -} - -void TQWidget::deleteSysExtra() -{ -} - -void TQWidget::createTLSysExtra() -{ -#if defined(TQT_NO_IM_EXTENSIONS) - // created lazily - extra->topextra->xic = 0; -#endif -#ifndef TQT_NO_XSYNC - extra->topextra->syncCounter = 0; - extra->topextra->syncRequestValue[0] = 0; - extra->topextra->syncRequestValue[1] = 0; -#endif -} - -void TQWidget::deleteTLSysExtra() -{ - // don't destroy input context here. it will be destroyed in - // TQWidget::destroy() destroyInputContext(); -} - -/* - examine the children of our parent up the tree and set the - children_use_dnd extra data appropriately... this is used to keep DND enabled - for widgets that are reparented and don't have DND enabled, BUT *DO* have - children (or children of children ...) with DND enabled... -*/ -void TQWidget::checkChildrenDnd() -{ - TQWidget *widget = this; - const TQObjectList *children; - const TQObject *object; - const TQWidget *child; - while (widget && ! widget->isDesktop()) { - // note: this isn't done for the desktop widget - - bool children_use_dnd = FALSE; - children = widget->children(); - if ( children ) { - TQObjectListIt it(*children); - while ( (object = it.current()) ) { - ++it; - if ( object->isWidgetType() ) { - child = (const TQWidget *) object; - children_use_dnd = (children_use_dnd || - child->acceptDrops() || - (child->extra && - child->extra->children_use_dnd)); - } - } - } - - widget->createExtra(); - widget->extra->children_use_dnd = children_use_dnd; - - widget = widget->parentWidget(); - } -} - - -#ifndef TQT_NO_XSYNC -// create a window's XSyncCounter -void TQWidget::createSyncCounter() -{ - if( !qt_use_xsync || !isTopLevel() || topData()->syncCounter ) - return; - XSyncValue zero; - XSyncIntToValue( &zero, 0 ); - topData()->syncCounter = XSyncCreateCounter( x11Display(), zero ); -} - -// destroy a window's XSyncCounter -void TQWidget::destroySyncCounter() -{ - if( !qt_use_xsync || !extra || !extra->topextra - || !extra->topextra->syncCounter ) - return; - XSyncDestroyCounter( x11Display(), extra->topextra->syncCounter ); - extra->topextra->syncCounter = 0; -} - -// increment a window's XSyncCounter -void TQWidget::incrementSyncCounter() -{ - if( qt_use_xsync && topData()->syncCounter && - !(topData()->syncRequestValue[0] == 0 && - topData()->syncRequestValue[1] == 0) ) { - XSyncValue val; - XSyncIntsToValue( &val, topData()->syncRequestValue[ 0 ], topData()->syncRequestValue[ 1 ] ); - XSyncSetCounter( x11Display(), topData()->syncCounter, val ); - topData()->syncRequestValue[0] = topData()->syncRequestValue[1] = 0; - } -} - -// handle _NET_WM_SYNC_REQUEST -void TQWidget::handleSyncRequest( void* ev ) -{ - XEvent* xev = (XEvent*)ev; - topData()->syncRequestValue[ 0 ] = xev->xclient.data.l[ 2 ]; - topData()->syncRequestValue[ 1 ] = xev->xclient.data.l[ 3 ]; -} -#endif // TQT_NO_XSYNC - - -/*! - \property TQWidget::acceptDrops - \brief whether drop events are enabled for this widget - - Setting this property to TRUE announces to the system that this - widget \e may be able to accept drop events. - - If the widget is the desktop (TQWidget::isDesktop()), this may - fail if another application is using the desktop; you can call - acceptDrops() to test if this occurs. - - \warning - Do not modify this property in a Drag&Drop event handler. -*/ -bool TQWidget::acceptDrops() const -{ - return testWState( WState_DND ); -} - -void TQWidget::setAcceptDrops( bool on ) -{ - if ( testWState(WState_DND) != on ) { - if ( qt_dnd_enable( this, on ) ) { - if ( on ) - setWState( WState_DND ); - else - clearWState( WState_DND ); - } - - checkChildrenDnd(); - } -} - -/*! - \overload - - Causes only the parts of the widget which overlap \a region to be - visible. If the region includes pixels outside the rect() of the - widget, window system controls in that area may or may not be - visible, depending on the platform. - - Note that this effect can be slow if the region is particularly - complex. - - \sa setMask(), clearMask() -*/ - -void TQWidget::setMask( const TQRegion& region ) -{ - XShapeCombineRegion( x11Display(), winId(), ShapeBounding, 0, 0, - region.handle(), ShapeSet ); -} - -/*! - Causes only the pixels of the widget for which \a bitmap has a - corresponding 1 bit to be visible. Use TQt::color0 to draw - transparent regions and TQt::color1 to draw opaque regions of the - bitmap. - - If the region includes pixels outside the rect() of the widget, - window system controls in that area may or may not be visible, - depending on the platform. - - Note that this effect can be slow if the region is particularly - complex. - - See \c examples/tux for an example of masking for transparency. - - \sa setMask(), clearMask() -*/ - -void TQWidget::setMask( const TQBitmap &bitmap ) -{ - TQBitmap bm = bitmap; - if ( bm.x11Screen() != x11Screen() ) - bm.x11SetScreen( x11Screen() ); - XShapeCombineMask( x11Display(), winId(), ShapeBounding, 0, 0, - bm.handle(), ShapeSet ); -} - -/*! - Removes any mask set by setMask(). - - \sa setMask() -*/ - -void TQWidget::clearMask() -{ - XShapeCombineMask( x11Display(), winId(), ShapeBounding, 0, 0, - None, ShapeSet ); -} - -/*!\reimp - */ -void TQWidget::setName( const char *name ) -{ - TQObject::setName( name ); - if ( isTopLevel() ) { - XChangeProperty( x11Display(), winId(), - tqt_window_role, XA_STRING, 8, PropModeReplace, - (unsigned char *)name, tqstrlen( name ) ); - } -} - - -/*! - \internal - - Computes the frame rectangle when needed. This is an internal function, you - should never call this. -*/ - -void TQWidget::updateFrameStrut() const -{ - TQWidget *that = (TQWidget *) this; - - if (! isVisible() || isDesktop()) { - that->fstrut_dirty = (! isVisible()); - return; - } - - Atom type_ret; - Window l = winId(), w = winId(), p, r; // target window, it's parent, root - Window *c; - int i_unused; - unsigned int nc; - unsigned char *data_ret; - unsigned long l_unused; - - while (XQueryTree(TQPaintDevice::x11AppDisplay(), w, &r, &p, &c, &nc)) { - if (c && nc > 0) - XFree(c); - - if (! p) { - tqWarning("TQWidget::updateFrameStrut(): ERROR - no parent"); - return; - } - - // if the parent window is the root window, an Enlightenment virtual root or - // a NET WM virtual root window, stop here - data_ret = 0; - if (p == r || - (XGetWindowProperty(TQPaintDevice::x11AppDisplay(), p, - qt_enlightenment_desktop, 0, 1, False, XA_CARDINAL, - &type_ret, &i_unused, &l_unused, &l_unused, - &data_ret) == Success && - type_ret == XA_CARDINAL)) { - if (data_ret) - XFree(data_ret); - - break; - } else if (qt_net_supports(qt_net_virtual_roots) && qt_net_virtual_root_list) { - int i = 0; - while (qt_net_virtual_root_list[i] != 0) { - if (qt_net_virtual_root_list[i++] == p) - break; - } - } - - l = w; - w = p; - } - - // we have our window - int transx, transy; - XWindowAttributes wattr; - if (XTranslateCoordinates(TQPaintDevice::x11AppDisplay(), l, w, - 0, 0, &transx, &transy, &p) && - XGetWindowAttributes(TQPaintDevice::x11AppDisplay(), w, &wattr)) { - TQTLWExtra *top = that->topData(); - top->fleft = transx; - top->ftop = transy; - top->fright = wattr.width - crect.width() - top->fleft; - top->fbottom = wattr.height - crect.height() - top->ftop; - - // add the border_width for the window managers frame... some window managers - // do not use a border_width of zero for their frames, and if we the left and - // top strut, we ensure that pos() is absolutely correct. frameGeometry() - // will still be incorrect though... perhaps i should have foffset as well, to - // indicate the frame offset (equal to the border_width on X). - // - Brad - top->fleft += wattr.border_width; - top->fright += wattr.border_width; - top->ftop += wattr.border_width; - top->fbottom += wattr.border_width; - } - - that->fstrut_dirty = 0; -} - - -/*! - This function returns the widget holding the TQInputContext - instance for this widget. The instance is used for text input to - this widget, switching input method, etc. - - By default, this function delegates the role of returning input - context holder widget to TQApplication::locateICHolderWidget(). - - This definition enables application developer to change the - mapping of widgets to TQInputContext instance simply by overriding - TQApplication::locateICHolderWidget(). - - \sa TQApplication::locateICHolderWidget() -*/ -TQWidget *TQWidget::icHolderWidget() -{ - return tqApp->locateICHolderWidget(this); -} - - -/*! - This function returns the TQInputContext instance for this widget. - This instance is used for text input to this widget, etc. - It is simply the accessor function. -*/ -TQInputContext *TQWidget::getInputContext() -{ - TQInputContext *qic = 0; - -#ifndef TQT_NO_IM -// #if !defined(TQT_NO_IM_EXTENSIONS) - if ( isInputMethodEnabled() ) { -#if !defined(TQT_NO_IM_EXTENSIONS) - qic = icHolderWidget()->ic; -#else -// { - // icHolderWidget is always topLevelWidget - TQTLWExtra *topdata = icHolderWidget()->topData(); - qic = (TQInputContext *)topdata->xic; -#endif - } -#endif // TQT_NO_IM - - return qic; -} - - -/*! - This function replaces the TQInputContext instance used for text - input to this widget. The \a identifierName is the identifier name - of newly choosed input method. -*/ -void TQWidget::changeInputContext( const TQString& identifierName ) -{ -#ifndef TQT_NO_IM - TQWidget *icWidget = icHolderWidget(); -#if !defined(TQT_NO_IM_EXTENSIONS) - TQInputContext **qicp = &icWidget->ic; -#else - TQInputContext **qicp = (TQInputContext **)&icWidget->topData()->xic; -#endif - - if( *qicp ) - delete *qicp; - // an input context that has the identifierName is generated. - TQInputContext *qic = TQInputContextFactory::create( identifierName, icWidget ); - *qicp = qic; - if ( qic ) { - TQObject::connect( qic, TQ_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)), - tqApp, TQ_SLOT(postIMEvent(TQObject *,TQIMEvent *)) ); - TQObject::connect( qic, TQ_SIGNAL(deletionRequested()), - icWidget, TQ_SLOT(destroyInputContext()) ); - } -#else - (void) identifierName; /* unused */ -#endif // TQT_NO_IM -} - - -/*! - \internal - This is an internal function, you should never call this. - - This function is called to generate an input context - according to a configuration for default input method - - When TQT_NO_IM_EXTENSIONS is not set, input context is - generated only when isInputMethodEnabled() returns TRUE. -*/ -void TQWidget::createInputContext() -{ -// #if !defined(TQT_NO_IM_EXTENSIONS) - if( !isInputMethodEnabled() || TQApplication::closingDown() ) - return; -// #endif - - TQWidget *icWidget = icHolderWidget(); -#ifndef TQT_NO_IM -#if !defined(TQT_NO_IM_EXTENSIONS) - TQInputContext **qicp = &icWidget->ic; -#else - TQInputContext **qicp = (TQInputContext **)&icWidget->topData()->xic; -#endif - - if ( ! *qicp ) { - // an input context of the default input method is generated. - TQInputContext *qic = TQInputContextFactory::create( TQApplication::defaultInputMethod(), icWidget ); - - *qicp = qic; - if ( qic ) { - TQObject::connect( qic, TQ_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)), - tqApp, TQ_SLOT(postIMEvent(TQObject *,TQIMEvent *)) ); - TQObject::connect( qic, TQ_SIGNAL(deletionRequested()), - icWidget, TQ_SLOT(destroyInputContext()) ); - } - } -#endif // TQT_NO_IM -} - - -/*! - \internal - - This slot is used to destroy the input context that belonging - to the widget itself, so icHolderWidget()->ic is not fetched. - - \sa TQInputContext::deletionRequested() -*/ -void TQWidget::destroyInputContext() -{ -#ifndef TQT_NO_IM -#if !defined(TQT_NO_IM_EXTENSIONS) - TQInputContext **qicp = ⁣ -#else - if ( ! extra || ! extra->topextra ) - return; - - TQInputContext **qicp = (TQInputContext **)&extra->topextra->xic; -#endif - - if( *qicp ) - delete *qicp; - - *qicp = 0; -#endif // TQT_NO_IM -} - - -/*! - This function is called when text widgets need to be neutral state to - execute text operations properly. See qlineedit.cpp and qtextedit.cpp as - example. - - Ordinary reset that along with changing focus to another widget, - moving the cursor, etc, is implicitly handled via - unfocusInputContext() because whether reset or not when such - situation is a responsibility of input methods. So we delegate the - responsibility to the input context via unfocusInputContext(). See - 'Preedit preservation' section of the class description of - TQInputContext for further information. - - \sa TQInputContext, unfocusInputContext(), TQInputContext::unsetFocus() -*/ -void TQWidget::resetInputContext() -{ -#ifndef TQT_NO_IM - // trigger input context creation if it hasn't happened already - createInputContext(); - - TQInputContext *qic = getInputContext(); - if( qic ) - qic->reset(); -#endif // TQT_NO_IM -} - - -/*! - \internal - This is an internal function, you should never call this. - - This function is called to focus associated input context. The - code intends to eliminate duplicate focus for the context even if - the context is shared between widgets - - \sa TQInputContext::setFocus() - */ -void TQWidget::focusInputContext() -{ -#ifndef TQT_NO_IM - TQWidget* tlw = topLevelWidget(); - - if (!tlw->isPopup() || isInputMethodEnabled()) { - // trigger input context creation if it hasn't happened already - createInputContext(); - - TQInputContext *qic = getInputContext(); - if ( qic ) { - if( qic->focusWidget() != this ) { - qic->setFocusWidget( this ); - qic->setFocus(); - } - } - } -#endif // TQT_NO_IM -} - - -/*! - \internal - This is an internal function, you should never call this. - - This function is called to remove focus from associated input - context. - - \sa TQInputContext::unsetFocus() - */ -void TQWidget::unfocusInputContext() -{ -#ifndef TQT_NO_IM - // trigger input context creation if it hasn't happened already - createInputContext(); - - TQInputContext *qic = getInputContext(); - if ( qic ) { - // may be caused reset() in some input methods - qic->unsetFocus(); - qic->setFocusWidget( 0 ); - } -#endif // TQT_NO_IM -} - - -/*! - This function is called to send mouse event to associated input - context by derived text widgets. A derived text widget must be - calculate \a x as character offset at the mouse cursor in the - preedit. - - \sa TQInputContext::mouseHandler() - */ -void TQWidget::sendMouseEventToInputContext( int x, TQEvent::Type type, - TQt::ButtonState button, - TQt::ButtonState state ) -{ -#ifndef TQT_NO_IM - // trigger input context creation if it hasn't happened already - createInputContext(); - - TQInputContext *qic = getInputContext(); - if ( qic ) { - // may be causing reset() in some input methods - qic->mouseHandler( x, type, button, state ); - } -#endif // TQT_NO_IM -} - - -void TQWidget::setWindowOpacity(double) -{ -} - -double TQWidget::windowOpacity() const -{ - return 1.0; -} diff --git a/src/kernel/qwidgetcreate_x11.cpp b/src/kernel/qwidgetcreate_x11.cpp deleted file mode 100644 index 25a17ccb1..000000000 --- a/src/kernel/qwidgetcreate_x11.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQt calls to X11 -** -** Created : 970529 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqwidget.h" -#include "qt_x11_p.h" - - -/* - Internal TQt functions to create X windows. We have put them in - separate functions to allow the programmer to reimplement them by - custom versions. -*/ - -Window qt_XCreateWindow( const TQWidget*, Display *display, Window parent, - int x, int y, uint w, uint h, - int borderwidth, int depth, - uint windowclass, Visual *visual, - ulong valuemask, XSetWindowAttributes *attributes ) -{ - return XCreateWindow( display, parent, x, y, w, h, borderwidth, depth, - windowclass, visual, valuemask, attributes ); -} - - -Window qt_XCreateSimpleWindow( const TQWidget*, Display *display, Window parent, - int x, int y, uint w, uint h, int borderwidth, - ulong border, ulong background ) -{ - return XCreateSimpleWindow( display, parent, x, y, w, h, borderwidth, - border, background ); -} - - -void qt_XDestroyWindow( const TQWidget*, Display *display, Window window ) -{ - XDestroyWindow( display, window ); -} diff --git a/src/kernel/tqwidget.cpp b/src/kernel/tqwidget.cpp new file mode 100644 index 000000000..9345c31e4 --- /dev/null +++ b/src/kernel/tqwidget.cpp @@ -0,0 +1,6122 @@ +/**************************************************************************** +** +** Implementation of TQWidget class +** +** Created : 931031 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + + +#include "tqobjectlist.h" +#include "tqwidget.h" +#include "tqwidgetlist.h" +#include "tqwidgetintdict.h" +#include "ntqptrdict.h" +#include "ntqfocusdata.h" +#include "ntqcursor.h" +#include "ntqpixmap.h" +#include "ntqapplication.h" +#include "qapplication_p.h" +#include "ntqbrush.h" +#include "ntqlayout.h" +#include "ntqstylefactory.h" +#include "ntqcleanuphandler.h" +#include "ntqstyle.h" +#include "ntqmetaobject.h" +#include "ntqguardedptr.h" +#if defined(TQT_THREAD_SUPPORT) +#include "ntqthread.h" +#endif +#if defined(QT_ACCESSIBILITY_SUPPORT) +#include "ntqaccessible.h" +#endif +#if defined(TQ_WS_WIN) +#include "qt_windows.h" +#include "qinputcontext_p.h" +#endif +#if defined(TQ_WS_QWS) +#include "qwsmanager_qws.h" +#endif +#include "qfontdata_p.h" + + +/*! + \class TQWidget tqwidget.h + \brief The TQWidget class is the base class of all user interface objects. + + \ingroup abstractwidgets + \mainclass + + The widget is the atom of the user interface: it receives mouse, + keyboard and other events from the window system, and paints a + representation of itself on the screen. Every widget is + rectangular, and they are sorted in a Z-order. A widget is + clipped by its parent and by the widgets in front of it. + + A widget that isn't embedded in a parent widget is called a + top-level widget. Usually, top-level widgets are windows with a + frame and a title bar (although it is also possible to create + top-level widgets without such decoration if suitable widget flags + are used). In TQt, TQMainWindow and the various subclasses of + TQDialog are the most common top-level windows. + + A widget without a parent widget is always a top-level widget. + + Non-top-level widgets are child widgets. These are child windows + in their parent widgets. You cannot usually distinguish a child + widget from its parent visually. Most other widgets in TQt are + useful only as child widgets. (It is possible to make, say, a + button into a top-level widget, but most people prefer to put + their buttons inside other widgets, e.g. TQDialog.) + + If you want to use a TQWidget to hold child widgets you will + probably want to add a layout to the parent TQWidget. (See \link + layout.html Layouts\endlink.) + + TQWidget has many member functions, but some of them have little + direct functionality: for example, TQWidget has a font property, + but never uses this itself. There are many subclasses which + provide real functionality, such as TQPushButton, TQListBox and + TQTabDialog, etc. + + \section1 Groups of functions: + + \table + \header \i Context \i Functions + + \row \i Window functions \i + show(), + hide(), + raise(), + lower(), + close(). + + \row \i Top level windows \i + caption(), + setCaption(), + icon(), + setIcon(), + iconText(), + setIconText(), + isActiveWindow(), + setActiveWindow(), + showMinimized(). + showMaximized(), + showFullScreen(), + showNormal(). + + \row \i Window contents \i + update(), + repaint(), + erase(), + scroll(), + updateMask(). + + \row \i Geometry \i + pos(), + size(), + rect(), + x(), + y(), + width(), + height(), + sizePolicy(), + setSizePolicy(), + sizeHint(), + updateGeometry(), + layout(), + move(), + resize(), + setGeometry(), + frameGeometry(), + geometry(), + childrenRect(), + adjustSize(), + mapFromGlobal(), + mapFromParent() + mapToGlobal(), + mapToParent(), + maximumSize(), + minimumSize(), + sizeIncrement(), + setMaximumSize(), + setMinimumSize(), + setSizeIncrement(), + setBaseSize(), + setFixedSize() + + \row \i Mode \i + isVisible(), + isVisibleTo(), + isMinimized(), + isDesktop(), + isEnabled(), + isEnabledTo(), + isModal(), + isPopup(), + isTopLevel(), + setEnabled(), + hasMouseTracking(), + setMouseTracking(), + isUpdatesEnabled(), + setUpdatesEnabled(), + clipRegion(). + + \row \i Look and feel \i + style(), + setStyle(), + cursor(), + setCursor() + font(), + setFont(), + palette(), + setPalette(), + backgroundMode(), + setBackgroundMode(), + colorGroup(), + fontMetrics(), + fontInfo(). + + \row \i Keyboard focus
functions \i + isFocusEnabled(), + setFocusPolicy(), + focusPolicy(), + hasFocus(), + setFocus(), + clearFocus(), + setTabOrder(), + setFocusProxy(). + + \row \i Mouse and
keyboard grabbing \i + grabMouse(), + releaseMouse(), + grabKeyboard(), + releaseKeyboard(), + mouseGrabber(), + keyboardGrabber(). + + \row \i Event handlers \i + event(), + mousePressEvent(), + mouseReleaseEvent(), + mouseDoubleClickEvent(), + mouseMoveEvent(), + keyPressEvent(), + keyReleaseEvent(), + focusInEvent(), + focusOutEvent(), + wheelEvent(), + enterEvent(), + leaveEvent(), + paintEvent(), + moveEvent(), + resizeEvent(), + closeEvent(), + dragEnterEvent(), + dragMoveEvent(), + dragLeaveEvent(), + dropEvent(), + childEvent(), + showEvent(), + hideEvent(), + customEvent(). + + \row \i Change handlers \i + enabledChange(), + fontChange(), + paletteChange(), + styleChange(), + windowActivationChange(). + + \row \i System functions \i + parentWidget(), + topLevelWidget(), + reparent(), + polish(), + winId(), + find(), + metric(). + + \row \i What's this help \i + customWhatsThis() + + \row \i Internal kernel
functions \i + focusNextPrevChild(), + wmapper(), + clearWFlags(), + getWFlags(), + setWFlags(), + testWFlags(). + + \endtable + + Every widget's constructor accepts two or three standard arguments: + \list 1 + \i \c{TQWidget *parent = 0} is the parent of the new widget. + If it is 0 (the default), the new widget will be a top-level window. + If not, it will be a child of \e parent, and be constrained by \e + parent's geometry (unless you specify \c WType_TopLevel as + widget flag). + \i \c{const char *name = 0} is the widget name of the new + widget. You can access it using name(). The widget name is little + used by programmers but is quite useful with GUI builders such as + \e{TQt Designer} (you can name a widget in \e{TQt Designer}, and + connect() to it using the name in your code). The dumpObjectTree() + debugging function also uses it. + \i \c{WFlags f = 0} (where available) sets the widget flags; the + default is suitable for almost all widgets, but to get, for + example, a top-level widget without a window system frame, you + must use special flags. + \endlist + + The tictac/tictac.cpp example program is good example of a simple + widget. It contains a few event handlers (as all widgets must), a + few custom routines that are specific to it (as all useful widgets + do), and has a few children and connections. Everything it does + is done in response to an event: this is by far the most common way + to design GUI applications. + + You will need to supply the content for your widgets yourself, but + here is a brief run-down of the events, starting with the most common + ones: + + \list + + \i paintEvent() - called whenever the widget needs to be + repainted. Every widget which displays output must implement it, + and it is wise \e not to paint on the screen outside + paintEvent(). + + \i resizeEvent() - called when the widget has been resized. + + \i mousePressEvent() - called when a mouse button is pressed. + There are six mouse-related events, but the mouse press and mouse + release events are by far the most important. A widget receives + mouse press events when the mouse is inside it, or when it has + grabbed the mouse using grabMouse(). + + \i mouseReleaseEvent() - called when a mouse button is released. + A widget receives mouse release events when it has received the + corresponding mouse press event. This means that if the user + presses the mouse inside \e your widget, then drags the mouse to + somewhere else, then releases, \e your widget receives the release + event. There is one exception: if a popup menu appears while the + mouse button is held down, this popup immediately steals the mouse + events. + + \i mouseDoubleClickEvent() - not quite as obvious as it might seem. + If the user double-clicks, the widget receives a mouse press event + (perhaps a mouse move event or two if they don't hold the mouse + quite steady), a mouse release event and finally this event. It is + \e{not possible} to distinguish a click from a double click until you've + seen whether the second click arrives. (This is one reason why most GUI + books recommend that double clicks be an extension of single clicks, + rather than trigger a different action.) + + \endlist + + If your widget only contains child widgets, you probably do not need to + implement any event handlers. If you want to detect a mouse click in + a child widget call the child's hasMouse() function inside the + parent widget's mousePressEvent(). + + Widgets that accept keyboard input need to reimplement a few more + event handlers: + + \list + + \i keyPressEvent() - called whenever a key is pressed, and again + when a key has been held down long enough for it to auto-repeat. + Note that the Tab and Shift+Tab keys are only passed to the widget + if they are not used by the focus-change mechanisms. To force those + keys to be processed by your widget, you must reimplement + TQWidget::event(). + + \i focusInEvent() - called when the widget gains keyboard focus + (assuming you have called setFocusPolicy()). Well written widgets + indicate that they own the keyboard focus in a clear but discreet + way. + + \i focusOutEvent() - called when the widget loses keyboard focus. + + \endlist + + Some widgets will also need to reimplement some of the less common + event handlers: + + \list + + \i mouseMoveEvent() - called whenever the mouse moves while a + button is held down. This is useful for, for example, dragging. If + you call setMouseTracking(TRUE), you get mouse move events even + when no buttons are held down. (Note that applications which make + use of mouse tracking are often not very useful on low-bandwidth X + connections.) (See also the \link dnd.html drag and drop\endlink + information.) + + \i keyReleaseEvent() - called whenever a key is released, and also + while it is held down if the key is auto-repeating. In that case + the widget receives a key release event and immediately a key press + event for every repeat. Note that the Tab and Shift+Tab keys are + only passed to the widget if they are not used by the focus-change + mechanisms. To force those keys to be processed by your widget, you + must reimplement TQWidget::event(). + + \i wheelEvent() -- called whenever the user turns the mouse wheel + while the widget has the focus. + + \i enterEvent() - called when the mouse enters the widget's screen + space. (This excludes screen space owned by any children of the + widget.) + + \i leaveEvent() - called when the mouse leaves the widget's screen + space. + + \i moveEvent() - called when the widget has been moved relative to its + parent. + + \i closeEvent() - called when the user closes the widget (or when + close() is called). + + \endlist + + There are also some rather obscure events. They are listed in + \c ntqevent.h and you need to reimplement event() to handle them. + The default implementation of event() handles Tab and Shift+Tab + (to move the keyboard focus), and passes on most other events to + one of the more specialized handlers above. + + When implementing a widget, there are a few more things to + consider. + + \list + + \i In the constructor, be sure to set up your member variables + early on, before there's any chance that you might receive an event. + + \i It is almost always useful to reimplement sizeHint() and to set + the correct size policy with setSizePolicy(), so users of your class + can set up layout management more easily. A size policy lets you + supply good defaults for the layout management handling, so that + other widgets can contain and manage yours easily. sizeHint() + indicates a "good" size for the widget. + + \i If your widget is a top-level window, setCaption() and setIcon() set + the title bar and icon respectively. + + \endlist + + \sa TQEvent, TQPainter, TQGridLayout, TQBoxLayout +*/ + + +/***************************************************************************** + Internal TQWidgetMapper class + + The purpose of this class is to map widget identifiers to TQWidget objects. + All TQWidget objects register themselves in the TQWidgetMapper when they + get an identifier. Widgets unregister themselves when they change ident- + ifier or when they are destroyed. A widget identifier is really a window + handle. + + The widget mapper is created and destroyed by the main application routines + in the file qapp_xxx.cpp. + *****************************************************************************/ + +#if defined(TQ_WS_QWS) || defined(Q_OS_TEMP) +static const int WDictSize = 163; // plenty for small devices +#else +static const int WDictSize = 1123; // plenty for 5 big complex windows +#endif + +class TQWidgetMapper : public TQWidgetIntDict +{ // maps ids -> widgets +public: + TQWidgetMapper(); + ~TQWidgetMapper(); + TQWidget *find( WId id ); // find widget + void insert( const TQWidget * ); // insert widget + bool remove( WId id ); // remove widget +private: + WId cur_id; + TQWidget *cur_widget; +}; + +TQWidgetMapper *TQWidget::mapper = 0; // app global widget mapper + + +TQWidgetMapper::TQWidgetMapper() : TQWidgetIntDict(WDictSize) +{ + cur_id = 0; + cur_widget = 0; +} + +TQWidgetMapper::~TQWidgetMapper() +{ + clear(); +} + +inline TQWidget *TQWidgetMapper::find( WId id ) +{ + if ( id != cur_id ) { // need to lookup + cur_widget = TQWidgetIntDict::find((long)id); + if ( cur_widget ) + cur_id = id; + else + cur_id = 0; + } + return cur_widget; +} + +inline void TQWidgetMapper::insert( const TQWidget *widget ) +{ + TQWidgetIntDict::insert((long)widget->winId(),widget); +} + +inline bool TQWidgetMapper::remove( WId id ) +{ + if ( cur_id == id ) { // reset current widget + cur_id = 0; + cur_widget = 0; + } + return TQWidgetIntDict::remove((long)id); +} + + +/***************************************************************************** + TQWidget utility functions + *****************************************************************************/ + +static TQFont qt_naturalWidgetFont( TQWidget* w ) { + TQFont naturalfont = TQApplication::font( w ); + if ( ! w->isTopLevel() ) { + if ( ! naturalfont.isCopyOf( TQApplication::font() ) ) + naturalfont = naturalfont.resolve( w->parentWidget()->font() ); + else + naturalfont = w->parentWidget()->font(); + } + return naturalfont; +} + +#ifndef TQT_NO_PALETTE +static TQPalette qt_naturalWidgetPalette( TQWidget* w ) { + TQPalette naturalpalette = TQApplication::palette( w ); + if ( !w->isTopLevel() && naturalpalette.isCopyOf( TQApplication::palette() ) ) + naturalpalette = w->parentWidget()->palette(); + return naturalpalette; +} +#endif + +TQSize qt_naturalWidgetSize( TQWidget *w ) { + TQSize s = w->sizeHint(); + TQSizePolicy::ExpandData exp; +#ifndef TQT_NO_LAYOUT + if ( w->layout() ) { + if ( w->layout()->hasHeightForWidth() ) + s.setHeight( w->layout()->totalHeightForWidth( s.width() ) ); + exp = w->layout()->expanding(); + } else +#endif + { + if ( w->sizePolicy().hasHeightForWidth() ) + s.setHeight( w->heightForWidth( s.width() ) ); + exp = w->sizePolicy().expanding(); + } + if ( exp & TQSizePolicy::Horizontally ) + s.setWidth( TQMAX( s.width(), 200 ) ); + if ( exp & TQSizePolicy::Vertically ) + s.setHeight( TQMAX( s.height(), 150 ) ); +#if defined(TQ_WS_X11) + TQRect screen = TQApplication::desktop()->screenGeometry( w->x11Screen() ); +#else // all others + TQRect screen = TQApplication::desktop()->screenGeometry( w->pos() ); +#endif + s.setWidth( TQMIN( s.width(), screen.width()*2/3 ) ); + s.setHeight( TQMIN( s.height(), screen.height()*2/3 ) ); + return s; +} + +/***************************************************************************** + TQWidget member functions + *****************************************************************************/ + +/* + Widget state flags: + \list + \i WState_Created The widget has a valid winId(). + \i WState_Disabled The widget does not receive any mouse or keyboard + events. + \i WState_ForceDisabled The widget is explicitly disabled, i.e. it + will remain disabled even when all its ancestors are set to the enabled + state. This implies WState_Disabled. + \i WState_Visible The widget is currently visible. + \i WState_ForceHide The widget is explicitly hidden, i.e. it won't + become visible unless you call show() on it. WState_ForceHide + implies !WState_Visible. + \i WState_OwnCursor A cursor has been set for this widget. + \i WState_MouseTracking Mouse tracking is enabled. + \i WState_CompressKeys Compress keyboard events. + \i WState_BlockUpdates Repaints and updates are disabled. + \i WState_InPaintEvent Currently processing a paint event. + \i WState_Reparented The widget has been reparented. + \i WState_ConfigPending A configuration (resize/move) event is pending. + \i WState_Resized The widget has been resized. + \i WState_AutoMask The widget has an automatic mask, see setAutoMask(). + \i WState_Polished The widget has been "polished" (i.e. late + initialization) by a TQStyle. + \i WState_DND The widget supports drag and drop, see setAcceptDrops(). + \i WState_Exposed the widget was finally exposed (X11 only, + helps avoid paint event doubling). + \i WState_HasMouse The widget is under the mouse cursor. + \endlist +*/ + +/*! \enum TQt::WFlags + \internal */ +/*! \enum TQt::WState + \internal */ + +/*! + \enum TQt::WidgetFlags + + \keyword widget flag + + This enum type is used to specify various window-system properties + for the widget. They are fairly unusual but necessary in a few + cases. Some of these flags depend on whether the underlying window + manager supports them. (See the \link toplevel-example.html + toplevel example\endlink for an explanation and example of their + use.) + + The main types are + + \value WType_TopLevel indicates that this widget is a top-level + widget, usually with a window-system frame and so on. + + \value WType_Dialog indicates that this widget is a top-level + window that should be decorated as a dialog (i.e. typically no + maximize or minimize buttons in the title bar). If you want to use + it as a modal dialog it should be launched from another window, or + have a parent and this flag should be combined with \c WShowModal. + If you make it modal, the dialog will prevent other top-level + windows in the application from getting any input. \c WType_Dialog + implies \c WType_TopLevel. We refer to a top-level window that has + a parent as a \e secondary window. (See also \c WGroupLeader.) + + \value WType_Popup indicates that this widget is a popup + top-level window, i.e. that it is modal, but has a window system + frame appropriate for popup menus. \c WType_Popup implies + WType_TopLevel. + + \value WType_Desktop indicates that this widget is the desktop. + See also \c WPaintDesktop below. \c WType_Desktop implies \c + WType_TopLevel. + + There are also a number of flags which you can use to customize + the appearance of top-level windows. These have no effect on other + windows: + + \value WStyle_Customize indicates that the \c WStyle_* flags + should be used to build the window instead of the default flags. + + \value WStyle_NormalBorder gives the window a normal border. + This cannot be combined with \c WStyle_DialogBorder or \c + WStyle_NoBorder. + + \value WStyle_DialogBorder gives the window a thin dialog border. + This cannot be combined with \c WStyle_NormalBorder or \c + WStyle_NoBorder. + + \value WStyle_NoBorder produces a borderless window. Note that + the user cannot move or resize a borderless window via the window + system. This cannot be combined with \c WStyle_NormalBorder or \c + WStyle_DialogBorder. On Windows, the flag works fine. On X11, the + result of the flag is dependent on the window manager and its + ability to understand MOTIF and/or NETWM hints: most existing + modern window managers can handle this. With \c WX11BypassWM, you + can bypass the window manager completely. This results in a + borderless window that is not managed at all (i.e. no keyboard + input unless you call setActiveWindow() manually). + + \value WStyle_NoBorderEx this value is obsolete. It has the same + effect as using \c WStyle_NoBorder. + + \value WStyle_Title gives the window a title bar. + + \value WStyle_SysMenu adds a window system menu. + + \value WStyle_Minimize adds a minimize button. Note that on + Windows this has to be combined with \c WStyle_SysMenu for it to + work. + + \value WStyle_Maximize adds a maximize button. Note that on + Windows this has to be combined with \c WStyle_SysMenu for it to work. + + \value WStyle_MinMax is equal to \c + WStyle_Minimize|WStyle_Maximize. Note that on Windows this has to + be combined with \c WStyle_SysMenu to work. + + \value WStyle_ContextHelp adds a context help button to dialogs. + + \value WStyle_Tool makes the window a tool window. A tool window + is often a small window with a smaller than usual title bar and + decoration, typically used for collections of tool buttons. It + there is a parent, the tool window will always be kept on top of + it. If there isn't a parent, you may consider passing \c + WStyle_StaysOnTop as well. If the window system supports it, a + tool window can be decorated with a somewhat lighter frame. It can + also be combined with \c WStyle_NoBorder. + + \value WStyle_StaysOnTop informs the window system that the + window should stay on top of all other windows. Note that on some + window managers on X11 you also have to pass \c WX11BypassWM for + this flag to work correctly. + + \value WStyle_Dialog indicates that the window is a logical + subwindow of its parent (i.e. a dialog). The window will not get + its own taskbar entry and will be kept on top of its parent by the + window system. Usually it will also be minimized when the parent + is minimized. If not customized, the window is decorated with a + slightly simpler title bar. This is the flag TQDialog uses. + + \value WStyle_Splash indicates that the window is a splash screen. + On X11, we try to follow NETWM standard for a splash screen window if the + window manager supports is otherwise it is equivalent to \c WX11BypassWM. On + other platforms, it is equivalent to \c WStyle_NoBorder \c | \c WMacNoSheet \c | + \c WStyle_Tool \c | \c WWinOwnDC + + Modifier flags: + + \value WDestructiveClose makes TQt delete this widget when the + widget has accepted closeEvent(), or when the widget tried to + ignore closeEvent() but could not. + + \value WPaintDesktop gives this widget paint events for the + desktop. + + \value WPaintUnclipped makes all painters operating on this + widget unclipped. Children of this widget or other widgets in + front of it do not clip the area the painter can paint on. + + \value WPaintClever indicates that TQt should \e not try to + optimize repainting for the widget, but instead pass on window + system repaint events directly. (This tends to produce more events + and smaller repaint regions.) + + \value WMouseNoMask indicates that even if the widget has a mask, + it wants mouse events for its entire rectangle. + + \value WStaticContents indicates that the widget contents are + north-west aligned and static. On resize, such a widget will + receive paint events only for the newly visible part of itself. + + \value WNoAutoErase indicates that the widget paints all its + pixels. Updating, resizing, scrolling and focus changes should + therefore not erase the widget. This allows smart-repainting to + avoid flicker. + + \value WResizeNoErase this value is obsolete; use WNoAutoErase instead. + \value WRepaintNoErase this value is obsolete; use WNoAutoErase instead. + \value WGroupLeader makes this window a group leader. A group + leader should \e not have a parent (i.e. it should be a top-level + window). Any decendant windows (direct or indirect) of a group + leader are in its group; other windows are not. If you show a + secondary window from the group (i.e. show a window whose top-most + parent is a group leader), that window will be modal with respect + to the other windows in the group, but modeless with respect to + windows in other groups. + + Miscellaneous flags + + \value WShowModal see WType_Dialog + + Internal flags. + + \value WNoMousePropagation + \value WStaticContents + \value WStyle_Reserved + \value WSubWindow + \value WType_Modal + \value WWinOwnDC + \value WX11BypassWM + \value WMacNoSheet + \value WMacDrawer + \value WStyle_Mask + \value WType_Mask + +*/ + +/*! + \enum TQt::NETWMFlags + + \keyword NETWM flag + + This enum type is used to specify various NETWM properties + under X11 and similar systems. + + The main types are + + \value WX11DisableMove + \value WX11DisableClose + \value WX11DisableResize + \value WX11DisableMinimize + \value WX11DisableMaximize + \value WX11DisableShade + +*/ + +/*! + \enum TQt::WidgetState + + Internal flags. + + \value WState_Created + \value WState_Disabled + \value WState_Visible + \value WState_ForceHide + \value WState_OwnCursor + \value WState_MouseTracking + \value WState_CompressKeys + \value WState_BlockUpdates + \value WState_InPaintEvent + \value WState_Reparented + \value WState_ConfigPending + \value WState_Resized + \value WState_AutoMask + \value WState_Polished + \value WState_DND + \value WState_Reserved0 \e internal + \value WState_CreatedHidden + \value WState_Maximized + \value WState_Minimized + \value WState_ForceDisabled + \value WState_Exposed + \value WState_HasMouse + \value WState_CreatedHidden + \value WState_OwnSizePolicy + \value WState_FullScreen +*/ + + +/*! + \enum TQt::WindowState + + \keyword window state + + This enum type is used to specify the current state of a top-level + window. + + The states are + + \value WindowNoState The window has no state set (in normal state). + \value WindowMinimized The window is minimized (i.e. iconified). + \value WindowMaximized The window is maximized with a frame around it. + \value WindowFullScreen The window fills the entire screen without any frame around it. + \value WindowActive The window is the active window, i.e. it has keyboard focus. + +*/ + +/*! + Constructs a widget which is a child of \a parent, with the name + \a name, widget flags set to \a f, and NETWM flags set to \a n. + + If \a parent is 0, the new widget becomes a top-level window. If + \a parent is another widget, this widget becomes a child window + inside \a parent. The new widget is deleted when its \a parent is + deleted. + + The \a name is sent to the TQObject constructor. + + The widget flags argument, \a f, is normally 0, but it can be set + to customize the window frame of a top-level widget (i.e. \a + parent must be 0). To customize the frame, set the \c + WStyle_Customize flag OR'ed with any of the \l TQt::WidgetFlags. + + If you add a child widget to an already visible widget you must + explicitly show the child to make it visible. + + Note that the X11 version of TQt may not be able to deliver all + combinations of style flags on all systems. This is because on + X11, TQt can only ask the window manager, and the window manager + can override the application's settings. On Windows, TQt can set + whatever flags you want. + + Example: + \code + TQLabel *splashScreen = new TQLabel( 0, "mySplashScreen", + WStyle_Customize | WStyle_Splash ); + \endcode +*/ + +TQWidget::TQWidget( TQWidget *parent, const char *name, WFlags f, NFlags n ) + : TQObject( parent, name ), TQPaintDevice( TQInternal::Widget ) +{ +#if defined(QT_CHECK_STATE) && !defined(TQ_WS_WIN) + if ( tqApp->type() == TQApplication::Tty ) { + tqWarning( "TQWidget: Cannot create a TQWidget when no GUI " + "is being used" ); + } +#endif + +#if defined(TQT_THREAD_SUPPORT) && defined(QT_CHECK_STATE) + if (TQThread::currentThreadObject() != TQApplication::guiThread()) { + tqFatal( "TQWidget: Cannot create a TQWidget outside of the main GUI thread" ); + } +#endif + + fstrut_dirty = 1; + + isWidget = TRUE; // is a widget + winid = 0; // default attributes + widget_state = 0; + widget_flags = f; + netwm_flags = n; + focus_policy = 0; + own_font = 0; + own_palette = 0; + sizehint_forced = 0; + is_closing = 0; + in_show = 0; + in_show_maximized = 0; + im_enabled = FALSE; +#ifndef TQT_NO_LAYOUT + lay_out = 0; +#endif + extra = 0; // no extra widget info +#ifndef TQT_NO_PALETTE + bg_col = pal.active().background(); // default background color +#endif + create(); // platform-dependent init +#ifndef TQT_NO_PALETTE + pal = isTopLevel() ? TQApplication::palette() : parentWidget()->palette(); +#endif + if ( ! isTopLevel() ) + fnt = parentWidget()->font(); +#if defined(TQ_WS_X11) + fnt.x11SetScreen( x11Screen() ); +#endif // TQ_WS_X11 + + if ( !isDesktop() ) + setBackgroundFromMode(); //### parts of this are done in create but not all (see reparent(...) ) + // make sure move/resize events are sent to all widgets + TQApplication::postEvent( this, new TQMoveEvent( crect.topLeft(), + crect.topLeft() ) ); + TQApplication::postEvent( this, new TQResizeEvent(crect.size(), + crect.size()) ); + if ( isTopLevel() ) { + setWState( WState_ForceHide | WState_CreatedHidden ); + TQFocusData *fd = focusData( TRUE ); + if ( fd->focusWidgets.findRef(this) < 0 ) + fd->focusWidgets.append( this ); + } else { + // propagate enabled state + if ( !parentWidget()->isEnabled() ) + setWState( WState_Disabled ); + // new widgets do not show up in already visible parents + if ( parentWidget()->isVisible() ) + setWState( WState_ForceHide | WState_CreatedHidden ); + } + if ( ++instanceCounter > maxInstances ) + maxInstances = instanceCounter; +} + +/*! + Destroys the widget. + + All this widget's children are deleted first. The application + exits if this widget is the main widget. +*/ + +TQWidget::~TQWidget() +{ +#if defined (QT_CHECK_STATE) + if ( paintingActive() ) + tqWarning( "%s (%s): deleted while being painted", className(), name() ); +#endif + + // Remove myself and all children from the can-take-focus list + TQFocusData *f = focusData( FALSE ); + if ( f ) { + TQPtrListIterator it(f->focusWidgets); + TQWidget *w; + while ( (w = it.current()) ) { + ++it; + TQWidget * p = w; + while( p && p != this ) + p = p->parentWidget(); + if ( p ) // my descendant + f->focusWidgets.removeRef( w ); + } + } + --instanceCounter; + + if ( TQApplication::main_widget == this ) { // reset main widget + TQApplication::main_widget = 0; + if (tqApp) + tqApp->quit(); + } + + if ( hasFocus() ) + clearFocus(); + + if ( isTopLevel() && isShown() && winId() ) + hide(); + + // A parent widget must destroy all its children before destroying itself + if ( childObjects ) { // delete children objects + TQObjectListIt it(*childObjects); + TQObject *obj; + while ( (obj=it.current()) ) { + ++it; + obj->parentObj = 0; + childObjects->removeRef( obj ); + delete obj; + } + delete childObjects; + childObjects = 0; + } + + TQApplication::removePostedEvents( this ); + + destroy(); // platform-dependent cleanup + if ( extra ) + deleteExtra(); +} + +int TQWidget::instanceCounter = 0; // Current number of widget instances +int TQWidget::maxInstances = 0; // Maximum number of widget instances + +/*! + \internal + Creates the global widget mapper. + The widget mapper converts window handles to widget pointers. + \sa destroyMapper() +*/ + +void TQWidget::createMapper() +{ + mapper = new TQWidgetMapper; + TQ_CHECK_PTR( mapper ); +} + +/*! + \internal + Destroys the global widget mapper. + \sa createMapper() +*/ + +void TQWidget::destroyMapper() +{ + if ( !mapper ) // already gone + return; + TQWidgetIntDictIt it( *((TQWidgetIntDict*)mapper) ); + TQWidgetMapper * myMapper = mapper; + mapper = 0; + TQWidget *w; + while ( (w=it.current()) ) { // remove parents widgets + ++it; + if ( !w->parentObj ) // widget is a parent + w->destroy( TRUE, TRUE ); + } + delete myMapper; +} + + +static TQWidgetList *wListInternal( TQWidgetMapper *mapper, bool onlyTopLevel ) +{ + TQWidgetList *list = new TQWidgetList; + TQ_CHECK_PTR( list ); + if ( mapper ) { + TQWidget *w; + TQWidgetIntDictIt it( *((TQWidgetIntDict*)mapper) ); + while ( (w=it.current()) ) { + ++it; + if ( !onlyTopLevel || w->isTopLevel() ) + list->append( w ); + } + } + return list; +} + +/*! + \internal + Returns a list of all widgets. + \sa tlwList(), TQApplication::allWidgets() +*/ + +TQWidgetList *TQWidget::wList() +{ + return wListInternal( mapper, FALSE ); +} + +/*! + \internal + Returns a list of all top level widgets. + \sa wList(), TQApplication::topLevelWidgets() +*/ + +TQWidgetList *TQWidget::tlwList() +{ + return wListInternal( mapper, TRUE ); +} + + +void TQWidget::setWinId( WId id ) // set widget identifier +{ + if ( !mapper ) // mapper destroyed + return; + if ( winid ) + mapper->remove( winid ); + winid = id; +#if defined(TQ_WS_X11) + hd = id; // X11: hd == ident +#endif + if ( id ) + mapper->insert( this ); +} + + +/*! + \internal + Returns a pointer to the block of extra widget data. +*/ + +TQWExtra *TQWidget::extraData() +{ + return extra; +} + + +/*! + \internal + Returns a pointer to the block of extra top level widget data. + + This data is guaranteed to exist for top level widgets. +*/ + +TQTLWExtra *TQWidget::topData() +{ + createTLExtra(); + return extra->topextra; +} + + +void TQWidget::createTLExtra() +{ + if ( !extra ) + createExtra(); + if ( !extra->topextra ) { + TQTLWExtra* x = extra->topextra = new TQTLWExtra; +#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) + x->opacity = 255; +#endif +#ifndef TQT_NO_WIDGET_TOPEXTRA + x->icon = 0; +#endif + x->focusData = 0; + x->fleft = x->fright = x->ftop = x->fbottom = 0; + x->incw = x->inch = 0; + x->basew = x->baseh = 0; + x->normalGeometry = TQRect(0,0,-1,-1); +#if defined(TQ_WS_X11) + x->embedded = 0; + x->parentWinId = 0; + x->spont_unmapped = 0; + x->dnd = 0; + x->uspos = 0; + x->ussize = 0; +#endif + x->savedFlags = 0; +#if defined(TQ_WS_QWS) && !defined(TQT_NO_QWS_MANAGER) + x->decor_allocated_region = TQRegion(); + x->qwsManager = 0; +#endif + createTLSysExtra(); + } +} + +/*! + \internal + Creates the widget extra data. +*/ + +void TQWidget::createExtra() +{ + if ( !extra ) { // if not exists + extra = new TQWExtra; + TQ_CHECK_PTR( extra ); + extra->minw = extra->minh = 0; + extra->maxw = extra->maxh = TQWIDGETSIZE_MAX; + extra->bg_pix = 0; + extra->focus_proxy = 0; +#ifndef TQT_NO_CURSOR + extra->curs = 0; +#endif + extra->topextra = 0; + extra->bg_mode = PaletteBackground; + extra->bg_mode_visual = PaletteBackground; + extra->bg_origin = WidgetOrigin; +#ifndef TQT_NO_STYLE + extra->style = 0; +#endif + extra->size_policy = TQSizePolicy( TQSizePolicy::Preferred, + TQSizePolicy::Preferred ); + + extra->m_ceData = NULL; + + createSysExtra(); + } +} + + +/*! + \internal + Deletes the widget extra data. +*/ + +void TQWidget::deleteExtra() +{ + if ( extra ) { // if exists + delete extra->m_ceData; + delete extra->bg_pix; +#ifndef TQT_NO_CURSOR + delete extra->curs; +#endif + deleteSysExtra(); + if ( extra->topextra ) { + deleteTLSysExtra(); +#ifndef TQT_NO_WIDGET_TOPEXTRA + delete extra->topextra->icon; +#endif + delete extra->topextra->focusData; +#if defined(TQ_WS_QWS) && !defined(TQT_NO_QWS_MANAGER) + delete extra->topextra->qwsManager; +#endif + delete extra->topextra; + } + delete extra; + // extra->xic destroyed in TQWidget::destroy() + extra = 0; + } +} + + +/*! + \internal + This function is called when a widget is hidden or destroyed. + It resets some application global pointers that should only refer active, + visible widgets. +*/ + +void TQWidget::deactivateWidgetCleanup() +{ + // If this was the active application window, reset it + if ( this == TQApplication::active_window ) + tqApp->setActiveWindow( 0 ); + // If the is the active mouse press widget, reset it +#ifdef TQ_WS_MAC + extern TQGuardedPtr qt_button_down; +#else + extern TQWidget *qt_button_down; +#endif + if ( this == (TQWidget *)qt_button_down ) + qt_button_down = 0; +} + + +/*! + Returns a pointer to the widget with window identifer/handle \a + id. + + The window identifier type depends on the underlying window + system, see \c ntqwindowdefs.h for the actual definition. If there + is no widget with this identifier, 0 is returned. +*/ + +TQWidget *TQWidget::find( WId id ) +{ + return mapper ? mapper->find( id ) : 0; +} + +/*! + \fn TQWidgetMapper *TQWidget::wmapper() + \internal + Returns a pointer to the widget mapper. + + The widget mapper is an internal dictionary that is used to map from + window identifiers/handles to widget pointers. + \sa find(), id() +*/ + +/*! + \fn WFlags TQWidget::getWFlags() const + + Returns the widget flags for this this widget. + + Widget flags are a combination of \l{TQt::WidgetFlags}. + + \sa testWFlags(), setWFlags(), clearWFlags() +*/ + +/*! + \fn void TQWidget::setWFlags( WFlags f ) + + Sets the widget flags \a f. + + Widget flags are a combination of \l{TQt::WidgetFlags}. + + \sa testWFlags(), getWFlags(), clearWFlags() +*/ + +/*! + \fn void TQWidget::clearWFlags( WFlags f ) + + Clears the widget flags \a f. + + Widget flags are a combination of \l{TQt::WidgetFlags}. + + \sa testWFlags(), getWFlags(), setWFlags() +*/ + + + +/*! + \fn WId TQWidget::winId() const + + Returns the window system identifier of the widget. + + Portable in principle, but if you use it you are probably about to + do something non-portable. Be careful. + + \sa find() +*/ + +#ifndef TQT_NO_STYLE +/*! + Returns the GUI style for this widget + + \sa TQWidget::setStyle(), TQApplication::setStyle(), TQApplication::style() +*/ + +TQStyle& TQWidget::style() const +{ + if ( extra && extra->style ) + return *extra->style; + TQStyle &ret = tqApp->style(); + return ret; +} + +/*! + Sets the widget's GUI style to \a style. Ownership of the style + object is not transferred. + + If no style is set, the widget uses the application's style, + TQApplication::style() instead. + + Setting a widget's style has no effect on existing or future child + widgets. + + \warning This function is particularly useful for demonstration + purposes, where you want to show TQt's styling capabilities. Real + applications should avoid it and use one consistent GUI style + instead. + + \sa style(), TQStyle, TQApplication::style(), TQApplication::setStyle() +*/ + +void TQWidget::setStyle( TQStyle *style ) +{ + TQStyle& old = TQWidget::style(); + createExtra(); + extra->style = style; + if ( !testWFlags(WType_Desktop) // (except desktop) + && testWState(WState_Polished)) { // (and have been polished) + old.unPolish( this ); + TQWidget::style().polish( this ); + } + styleChange( old ); +} + +/*! + \overload + + Sets the widget's GUI style to \a style using the TQStyleFactory. +*/ +TQStyle* TQWidget::setStyle( const TQString &style ) +{ + TQStyle *s = TQStyleFactory::create( style ); + setStyle( s ); + return s; +} + +/*! + This virtual function is called when the style of the widgets + changes. \a oldStyle is the previous GUI style; you can get the + new style from style(). + + Reimplement this function if your widget needs to know when its + GUI style changes. You will almost certainly need to update the + widget using update(). + + The default implementation updates the widget including its + geometry. + + \sa TQApplication::setStyle(), style(), update(), updateGeometry() +*/ + +void TQWidget::styleChange( TQStyle& /* oldStyle */ ) +{ + update(); + updateGeometry(); +} + +#endif + +/*! + \property TQWidget::isTopLevel + \brief whether the widget is a top-level widget + + A top-level widget is a widget which usually has a frame and a + \link TQWidget::caption caption (title)\endlink. \link + TQWidget::isPopup() Popup\endlink and \link TQWidget::isDesktop() + desktop\endlink widgets are also top-level widgets. + + A top-level widget can have a \link TQWidget::parentWidget() parent + widget\endlink. It will then be grouped with its parent and deleted + when the parent is deleted, minimized when the parent is minimized + etc. If supported by the window manager, it will also have a + common taskbar entry with its parent. + + TQDialog and TQMainWindow widgets are by default top-level, even if + a parent widget is specified in the constructor. This behavior is + specified by the \c WType_TopLevel widget flag. + + \sa topLevelWidget(), isDialog(), isModal(), isPopup(), isDesktop(), parentWidget() +*/ + +/*! + \property TQWidget::isDialog + \brief whether the widget is a dialog widget + + A dialog widget is a secondary top-level widget, i.e. a top-level + widget with a parent. + + \sa isTopLevel(), TQDialog +*/ + +/*! + \property TQWidget::isPopup + \brief whether the widget is a popup widget + + A popup widget is created by specifying the widget flag \c + WType_Popup to the widget constructor. A popup widget is also a + top-level widget. + + \sa isTopLevel() +*/ + +/*! + \property TQWidget::isDesktop + \brief whether the widget is a desktop widget, i.e. represents the desktop + + A desktop widget is also a top-level widget. + + \sa isTopLevel(), TQApplication::desktop() +*/ + +/*! + \property TQWidget::isModal + \brief whether the widget is a modal widget + + This property only makes sense for top-level widgets. A modal + widget prevents widgets in all other top-level widgets from + getting any input. + + \sa isTopLevel(), isDialog(), TQDialog +*/ + +/*! + \property TQWidget::underMouse + \brief whether the widget is under the mouse cursor + + This value is not updated properly during drag and drop + operations. + + \sa TQEvent::Enter, TQEvent::Leave +*/ + +/*! + \property TQWidget::minimized + \brief whether this widget is minimized (iconified) + + This property is only relevant for top-level widgets. + + \sa showMinimized(), visible, show(), hide(), showNormal(), maximized +*/ +bool TQWidget::isMinimized() const +{ return testWState(WState_Minimized); } + +/*! + Shows the widget minimized, as an icon. + + Calling this function only affects \link isTopLevel() top-level + widgets\endlink. + + \sa showNormal(), showMaximized(), show(), hide(), isVisible(), + isMinimized() +*/ +void TQWidget::showMinimized() +{ + bool isMin = isMinimized(); + if (isMin && isVisible()) return; + + if (!isMin) + setWindowState((windowState() & ~WindowActive) | WindowMinimized); + show(); + if (!isTopLevel()) + TQApplication::sendPostedEvents(this, TQEvent::ShowMinimized); +} + +/*! + \property TQWidget::maximized + \brief whether this widget is maximized + + This property is only relevant for top-level widgets. + + Note that due to limitations in some window-systems, this does not + always report the expected results (e.g. if the user on X11 + maximizes the window via the window manager, TQt has no way of + distinguishing this from any other resize). This is expected to + improve as window manager protocols evolve. + + \sa windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized +*/ +bool TQWidget::isMaximized() const +{ return testWState(WState_Maximized); } + + + +/*! Returns the current window state. The window state is a OR'ed + combination of TQt::WindowState: \c WindowMinimized, \c + WindowMaximized, \c WindowFullScreen and \c WindowActive. + + \sa TQt::WindowState setWindowState() + */ +uint TQWidget::windowState() const +{ + uint state = 0; + if (testWState(WState_Minimized)) + state |= WindowMinimized; + if (testWState(WState_Maximized)) + state |= WindowMaximized; + if (testWState(WState_FullScreen)) + state |= WindowFullScreen; + if (isActiveWindow()) + state |= WindowActive; + return state; +} + +/*! + \fn void TQWidget::setWindowState(uint windowState) + + Sets the window state to \a windowState. The window state is a OR'ed + combination of TQt::WindowState: \c WindowMinimized, \c + WindowMaximized, \c WindowFullScreen and \c WindowActive. + + If the window is not visible (i.e. isVisible() returns FALSE), the + window state will take effect when show() is called. For visible + windows, the change is immediate. For example, to toggle between + full-screen and mormal mode, use the following code: + + \code + w->setWindowState(w->windowState() ^ WindowFullScreen); + \endcode + + In order to restore and activate a minimized window (while + preserving its maximized and/or full-screen state), use the following: + + \code + w->setWindowState(w->windowState() & ~WindowMinimized | WindowActive); + \endcode + + Note: On some window systems \c WindowActive is not immediate, and may be + ignored in certain cases. + + \sa TQt::WindowState windowState() +*/ + +/*! + \property TQWidget::fullScreen + \brief whether the widget is full screen + + \sa windowState(), minimized, maximized +*/ +bool TQWidget::isFullScreen() const +{ return testWState(WState_FullScreen); } + +/*! + Shows the widget in full-screen mode. + + Calling this function only affects top-level widgets. + + To return from full-screen mode, call showNormal(). + + Full-screen mode works fine under Windows, but has certain + problems under X. These problems are due to limitations of the + ICCCM protocol that specifies the communication between X11 + clients and the window manager. ICCCM simply does not understand + the concept of non-decorated full-screen windows. Therefore, the + best we can do is to request a borderless window and place and + resize it to fill the entire screen. Depending on the window + manager, this may or may not work. The borderless window is + requested using MOTIF hints, which are at least partially + supported by virtually all modern window managers. + + An alternative would be to bypass the window manager entirely and + create a window with the WX11BypassWM flag. This has other severe + problems though, like totally broken keyboard focus and very + strange effects on desktop changes or when the user raises other + windows. + + X11 window managers that follow modern post-ICCCM specifications + support full-screen mode properly. + + \sa showNormal(), showMaximized(), show(), hide(), isVisible() +*/ +void TQWidget::showFullScreen() +{ + bool isFull = isFullScreen(); + if (isFull && isVisible()) + return; + + if (!isFull) + setWindowState(windowState() | WindowFullScreen); + show(); + if (!isTopLevel()) + TQApplication::sendPostedEvents(this, TQEvent::ShowFullScreen); + setActiveWindow(); +} + +/*! + Shows the widget maximized. + + Calling this function only affects \link isTopLevel() top-level + widgets\endlink. + + On X11, this function may not work properly with certain window + managers. See the \link geometry.html Window Geometry + documentation\endlink for an explanation. + + \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible() +*/ +void TQWidget::showMaximized() +{ + if (isMaximized() && isVisible() && !isMinimized()) + return; + + setWindowState((windowState() & ~WindowMinimized) | WindowMaximized); + show(); + if (!isTopLevel()) + TQApplication::sendPostedEvents(this, TQEvent::ShowMaximized); +} + +/*! + Restores the widget after it has been maximized or minimized. + + Calling this function only affects \link isTopLevel() top-level + widgets\endlink. + + \sa setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible() +*/ +void TQWidget::showNormal() +{ + setWindowState(WindowNoState); + show(); + if (!isTopLevel()) + TQApplication::sendPostedEvents(this, TQEvent::ShowNormal); +} + +/*! + Returns TRUE if this widget would become enabled if \a ancestor is + enabled; otherwise returns FALSE. + + This is the case if neither the widget itself nor every parent up + to but excluding \a ancestor has been explicitly disabled. + + isEnabledTo(0) is equivalent to isEnabled(). + + \sa setEnabled() enabled +*/ + +bool TQWidget::isEnabledTo( TQWidget* ancestor ) const +{ + const TQWidget * w = this; + while ( w && !w->testWState(WState_ForceDisabled) + && !w->isTopLevel() + && w->parentWidget() + && w->parentWidget() != ancestor ) + w = w->parentWidget(); + return !w->testWState( WState_ForceDisabled ); +} + + +/*! + \fn bool TQWidget::isEnabledToTLW() const + \obsolete + + This function is deprecated. It is equivalent to isEnabled() +*/ + +/*! + \property TQWidget::enabled + \brief whether the widget is enabled + + An enabled widget receives keyboard and mouse events; a disabled + widget does not. In fact, an enabled widget only receives keyboard + events when it is in focus. + + Some widgets display themselves differently when they are + disabled. For example a button might draw its label grayed out. If + your widget needs to know when it becomes enabled or disabled, you + can reimplement the enabledChange() function. + + Disabling a widget implicitly disables all its children. Enabling + respectively enables all child widgets unless they have been + explicitly disabled. + + \sa isEnabled(), isEnabledTo(), TQKeyEvent, TQMouseEvent, enabledChange() +*/ +void TQWidget::setEnabled( bool enable ) +{ + if ( enable ) + clearWState( WState_ForceDisabled ); + else + setWState( WState_ForceDisabled ); + + if ( !isTopLevel() && parentWidget() && + !parentWidget()->isEnabled() && enable ) + return; // nothing we can do + + if ( enable ) { + if ( testWState(WState_Disabled) ) { + clearWState( WState_Disabled ); + setBackgroundFromMode(); + enabledChange( !enable ); + if ( children() ) { + TQObjectListIt it( *children() ); + TQWidget *w; + while( (w = (TQWidget *)it.current()) != 0 ) { + ++it; + if ( w->isWidgetType() && + !w->testWState( WState_ForceDisabled ) ) + w->setEnabled( TRUE ); + } + } + } + } else { + if ( !testWState(WState_Disabled) ) { + if (focusWidget() == this) { + bool parentIsEnabled = (!parentWidget() || parentWidget()->isEnabled()); + if (!parentIsEnabled || !focusNextPrevChild(TRUE)) + clearFocus(); + } + setWState( WState_Disabled ); + setBackgroundFromMode(); + enabledChange( !enable ); + if ( children() ) { + TQObjectListIt it( *children() ); + TQWidget *w; + while( (w = (TQWidget *)it.current()) != 0 ) { + ++it; + if ( w->isWidgetType() && w->isEnabled() ) { + w->setEnabled( FALSE ); + w->clearWState( WState_ForceDisabled ); + } + } + } + } + } +#if defined(TQ_WS_X11) + if ( testWState( WState_OwnCursor ) ) { + // enforce the windows behavior of clearing the cursor on + // disabled widgets + + extern void tqt_x11_enforce_cursor( TQWidget * w ); // defined in tqwidget_x11.cpp + tqt_x11_enforce_cursor( this ); + } +#endif +#ifdef TQ_WS_WIN + TQInputContext::enable( this, im_enabled & !((bool)testWState(WState_Disabled)) ); +#endif +} + +/*! + Disables widget input events if \a disable is TRUE; otherwise + enables input events. + + See the \l enabled documentation for more information. + + \sa isEnabledTo(), TQKeyEvent, TQMouseEvent, enabledChange() +*/ +void TQWidget::setDisabled( bool disable ) +{ + setEnabled( !disable ); +} + +/*! + \fn void TQWidget::enabledChange( bool oldEnabled ) + + This virtual function is called from setEnabled(). \a oldEnabled + is the previous setting; you can get the new setting from + isEnabled(). + + Reimplement this function if your widget needs to know when it + becomes enabled or disabled. You will almost certainly need to + update the widget using update(). + + The default implementation repaints the visible part of the + widget. + + \sa setEnabled(), isEnabled(), repaint(), update(), clipRegion() +*/ + +void TQWidget::enabledChange( bool ) +{ + update(); +#if defined(QT_ACCESSIBILITY_SUPPORT) + TQAccessible::updateAccessibility( this, 0, TQAccessible::StateChanged ); +#endif +} + +/*! + \fn void TQWidget::windowActivationChange( bool oldActive ) + + This virtual function is called for a widget when its window is + activated or deactivated by the window system. \a oldActive is the + previous state; you can get the new setting from isActiveWindow(). + + Reimplement this function if your widget needs to know when its + window becomes activated or deactivated. + + The default implementation updates the visible part of the widget + if the inactive and the active colorgroup are different for colors + other than the highlight and link colors. + + \sa setActiveWindow(), isActiveWindow(), update(), palette() +*/ + +void TQWidget::windowActivationChange( bool ) +{ +#ifndef TQT_NO_PALETTE + if ( !isVisible() ) + return; + + const TQColorGroup &acg = palette().active(); + const TQColorGroup &icg = palette().inactive(); + + if ( acg != icg ) { + BackgroundMode bm = backgroundMode(); + TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode(bm); + if ( bm > NoBackground && acg.brush(role) != icg.brush(role) ) + setBackgroundFromMode(); + else if ( acg.background() == icg.background() && + acg.base() == icg.base() && + acg.text() == icg.text() && + acg.foreground() == icg.foreground() && + acg.button() == icg.button() && + acg.buttonText() == icg.buttonText() && + acg.brightText() == icg.brightText() && + acg.dark() == icg.dark() && + acg.light() == icg.light() && + acg.mid() == icg.mid() && + acg.midlight() == icg.midlight() && + acg.shadow() == icg.shadow() ) + return; + update(); + } +#endif +} + +/*! + \property TQWidget::frameGeometry + \brief geometry of the widget relative to its parent including any + window frame + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of geometry issues with top-level widgets. + + \sa geometry() x() y() pos() +*/ +TQRect TQWidget::frameGeometry() const +{ + if (isTopLevel() && ! isPopup()) { + if (fstrut_dirty) + updateFrameStrut(); + TQWidget *that = (TQWidget *) this; + TQTLWExtra *top = that->topData(); + return TQRect(crect.x() - top->fleft, + crect.y() - top->ftop, + crect.width() + top->fleft + top->fright, + crect.height() + top->ftop + top->fbottom); + } + return crect; +} + +/*! \property TQWidget::x + \brief the x coordinate of the widget relative to its parent including + any window frame + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa frameGeometry, y, pos +*/ +int TQWidget::x() const +{ + if (isTopLevel() && ! isPopup()) { + if (fstrut_dirty) + updateFrameStrut(); + TQWidget *that = (TQWidget *) this; + return crect.x() - that->topData()->fleft; + } + return crect.x(); +} + +/*! + \property TQWidget::y + \brief the y coordinate of the widget relative to its parent and + including any window frame + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa frameGeometry, x, pos +*/ +int TQWidget::y() const +{ + if (isTopLevel() && ! isPopup()) { + if (fstrut_dirty) + updateFrameStrut(); + TQWidget *that = (TQWidget *) this; + return crect.y() - that->topData()->ftop; + } + return crect.y(); +} + +/*! + \property TQWidget::pos + \brief the position of the widget within its parent widget + + If the widget is a top-level widget, the position is that of the + widget on the desktop, including its frame. + + When changing the position, the widget, if visible, receives a + move event (moveEvent()) immediately. If the widget is not + currently visible, it is guaranteed to receive an event before it + is shown. + + move() is virtual, and all other overloaded move() implementations + in TQt call it. + + \warning Calling move() or setGeometry() inside moveEvent() can + lead to infinite recursion. + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa frameGeometry, size x(), y() +*/ +TQPoint TQWidget::pos() const +{ + if (isTopLevel() && ! isPopup()) { + if (fstrut_dirty) + updateFrameStrut(); + TQWidget *that = (TQWidget *) this; + TQTLWExtra *top = that->topData(); + return TQPoint(crect.x() - top->fleft, crect.y() - top->ftop); + } + return crect.topLeft(); +} + +/*! + \property TQWidget::geometry + \brief the geometry of the widget relative to its parent and + excluding the window frame + + When changing the geometry, the widget, if visible, receives a + move event (moveEvent()) and/or a resize event (resizeEvent()) + immediately. If the widget is not currently visible, it is + guaranteed to receive appropriate events before it is shown. + + The size component is adjusted if it lies outside the range + defined by minimumSize() and maximumSize(). + + setGeometry() is virtual, and all other overloaded setGeometry() + implementations in TQt call it. + + \warning Calling setGeometry() inside resizeEvent() or moveEvent() + can lead to infinite recursion. + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa frameGeometry(), rect(), move(), resize(), moveEvent(), + resizeEvent(), minimumSize(), maximumSize() +*/ + +/*! + \property TQWidget::size + \brief the size of the widget excluding any window frame + + When resizing, the widget, if visible, receives a resize event + (resizeEvent()) immediately. If the widget is not currently + visible, it is guaranteed to receive an event before it is shown. + + The size is adjusted if it lies outside the range defined by + minimumSize() and maximumSize(). Furthermore, the size is always + at least TQSize(1, 1). For toplevel widgets, the minimum size + might be larger, depending on the window manager. + + If you want a top-level window to have a fixed size, call + setResizeMode( TQLayout::FreeResize ) on its layout. + + resize() is virtual, and all other overloaded resize() + implementations in TQt call it. + + \warning Calling resize() or setGeometry() inside resizeEvent() can + lead to infinite recursion. + + \sa pos, geometry, minimumSize, maximumSize, resizeEvent() +*/ + +/*! + \property TQWidget::width + \brief the width of the widget excluding any window frame + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa geometry, height, size +*/ + +/*! + \property TQWidget::height + \brief the height of the widget excluding any window frame + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa geometry, width, size +*/ + +/*! + \property TQWidget::rect + \brief the internal geometry of the widget excluding any window + frame + + The rect property equals TQRect(0, 0, width(), height()). + + See the \link geometry.html Window Geometry documentation\endlink + for an overview of top-level widget geometry. + + \sa size +*/ + +/*! + \property TQWidget::childrenRect + \brief the bounding rectangle of the widget's children + + Hidden children are excluded. + + \sa childrenRegion() geometry() +*/ + +TQRect TQWidget::childrenRect() const +{ + TQRect r( 0, 0, 0, 0 ); + if ( !children() ) + return r; + TQObjectListIt it( *children() ); + TQObject *obj; + while ( (obj = it.current()) ) { + ++it; + if ( obj->isWidgetType() && !((TQWidget*)obj)->isHidden() && !((TQWidget*)obj)->isTopLevel()) + r = r.unite( ((TQWidget*)obj)->geometry() ); + } + return r; +} + +/*! + \property TQWidget::childrenRegion + \brief the combined region occupied by the widget's children + + Hidden children are excluded. + + \sa childrenRect() geometry() +*/ + +TQRegion TQWidget::childrenRegion() const +{ + TQRegion r; + if ( !children() ) + return r; + TQObjectListIt it( *children() ); // iterate over all children + TQObject *obj; + while ( (obj=it.current()) ) { + ++it; + if ( obj->isWidgetType() && !((TQWidget*)obj)->isHidden() && !((TQWidget*)obj)->isTopLevel()) + r = r.unite( ((TQWidget*)obj)->geometry() ); + } + return r; +} + + +/*! + \property TQWidget::minimumSize + \brief the widget's minimum size + + The widget cannot be resized to a smaller size than the minimum + widget size. The widget's size is forced to the minimum size if + the current size is smaller. + + If you use a layout inside the widget, the minimum size will be + set by the layout and not by setMinimumSize(), unless you set the + layout's resize mode to TQLayout::FreeResize. + + \sa minimumWidth, minimumHeight, maximumSize, sizeIncrement + TQLayout::setResizeMode() +*/ + +TQSize TQWidget::minimumSize() const +{ + return extra ? TQSize( extra->minw, extra->minh ) : TQSize( 0, 0 ); +} + +/*! + \property TQWidget::maximumSize + \brief the widget's maximum size + + The widget cannot be resized to a larger size than the maximum + widget size. + + \sa maximumWidth(), maximumHeight(), setMaximumSize(), + minimumSize(), sizeIncrement() +*/ + +TQSize TQWidget::maximumSize() const +{ + return extra ? TQSize( extra->maxw, extra->maxh ) + : TQSize( TQWIDGETSIZE_MAX, TQWIDGETSIZE_MAX ); +} + + +/*! + \property TQWidget::minimumWidth + \brief the widget's minimum width + + This property corresponds to minimumSize().width(). + + \sa minimumSize, minimumHeight +*/ + +/*! + \property TQWidget::minimumHeight + \brief the widget's minimum height + + This property corresponds to minimumSize().height(). + + \sa minimumSize, minimumWidth +*/ + +/*! + \property TQWidget::maximumWidth + \brief the widget's maximum width + + This property corresponds to maximumSize().width(). + + \sa maximumSize, maximumHeight +*/ + +/*! + \property TQWidget::maximumHeight + \brief the widget's maximum height + + This property corresponds to maximumSize().height(). + + \sa maximumSize, maximumWidth +*/ + +/*! + \property TQWidget::sizeIncrement + \brief the size increment of the widget + + When the user resizes the window, the size will move in steps of + sizeIncrement().width() pixels horizontally and + sizeIncrement.height() pixels vertically, with baseSize() as the + basis. Preferred widget sizes are for non-negative integers \e i + and \e j: + \code + width = baseSize().width() + i * sizeIncrement().width(); + height = baseSize().height() + j * sizeIncrement().height(); + \endcode + + Note that while you can set the size increment for all widgets, it + only affects top-level widgets. + + \warning The size increment has no effect under Windows, and may + be disregarded by the window manager on X. + + \sa size, minimumSize, maximumSize +*/ +TQSize TQWidget::sizeIncrement() const +{ + return ( extra && extra->topextra ) + ? TQSize( extra->topextra->incw, extra->topextra->inch ) + : TQSize( 0, 0 ); +} + +/*! + \property TQWidget::baseSize + \brief the base size of the widget + + The base size is used to calculate a proper widget size if the + widget defines sizeIncrement(). + + \sa setSizeIncrement() +*/ + +TQSize TQWidget::baseSize() const +{ + return ( extra != 0 && extra->topextra != 0 ) + ? TQSize( extra->topextra->basew, extra->topextra->baseh ) + : TQSize( 0, 0 ); +} + +/*! + Sets both the minimum and maximum sizes of the widget to \a s, + thereby preventing it from ever growing or shrinking. + + \sa setMaximumSize() setMinimumSize() +*/ + +void TQWidget::setFixedSize( const TQSize & s) +{ + setMinimumSize( s ); + setMaximumSize( s ); + resize( s ); +} + + +/*! + \overload void TQWidget::setFixedSize( int w, int h ) + + Sets the width of the widget to \a w and the height to \a h. +*/ + +void TQWidget::setFixedSize( int w, int h ) +{ + setMinimumSize( w, h ); + setMaximumSize( w, h ); + resize( w, h ); +} + +void TQWidget::setMinimumWidth( int w ) +{ + setMinimumSize( w, minimumSize().height() ); +} + +void TQWidget::setMinimumHeight( int h ) +{ + setMinimumSize( minimumSize().width(), h ); +} + +void TQWidget::setMaximumWidth( int w ) +{ + setMaximumSize( w, maximumSize().height() ); +} + +void TQWidget::setMaximumHeight( int h ) +{ + setMaximumSize( maximumSize().width(), h ); +} + +/*! + Sets both the minimum and maximum width of the widget to \a w + without changing the heights. Provided for convenience. + + \sa sizeHint() minimumSize() maximumSize() setFixedSize() +*/ + +void TQWidget::setFixedWidth( int w ) +{ + setMinimumSize( w, minimumSize().height() ); + setMaximumSize( w, maximumSize().height() ); +} + + +/*! + Sets both the minimum and maximum heights of the widget to \a h + without changing the widths. Provided for convenience. + + \sa sizeHint() minimumSize() maximumSize() setFixedSize() +*/ + +void TQWidget::setFixedHeight( int h ) +{ + setMinimumSize( minimumSize().width(), h ); + setMaximumSize( maximumSize().width(), h ); +} + + +/*! + Translates the widget coordinate \a pos to the coordinate system + of \a parent. The \a parent must not be 0 and must be a parent + of the calling widget. + + \sa mapFrom() mapToParent() mapToGlobal() hasMouse() +*/ + +TQPoint TQWidget::mapTo( TQWidget * parent, const TQPoint & pos ) const +{ + TQPoint p = pos; + if ( parent ) { + const TQWidget * w = this; + while ( w != parent ) { + p = w->mapToParent( p ); + w = w->parentWidget(); + } + } + return p; +} + + +/*! + Translates the widget coordinate \a pos from the coordinate system + of \a parent to this widget's coordinate system. The \a parent + must not be 0 and must be a parent of the calling widget. + + \sa mapTo() mapFromParent() mapFromGlobal() hasMouse() +*/ + +TQPoint TQWidget::mapFrom( TQWidget * parent, const TQPoint & pos ) const +{ + TQPoint p( pos ); + if ( parent ) { + const TQWidget * w = this; + while ( w != parent ) { + p = w->mapFromParent( p ); + w = w->parentWidget(); + } + } + return p; +} + + +/*! + Translates the widget coordinate \a pos to a coordinate in the + parent widget. + + Same as mapToGlobal() if the widget has no parent. + + \sa mapFromParent() mapTo() mapToGlobal() hasMouse() +*/ + +TQPoint TQWidget::mapToParent( const TQPoint &pos ) const +{ + return pos + crect.topLeft(); +} + +/*! + Translates the parent widget coordinate \a pos to widget + coordinates. + + Same as mapFromGlobal() if the widget has no parent. + + \sa mapToParent() mapFrom() mapFromGlobal() hasMouse() +*/ + +TQPoint TQWidget::mapFromParent( const TQPoint &pos ) const +{ + return pos - crect.topLeft(); +} + + +/*! + Returns the top-level widget for this widget, i.e. the next + ancestor widget that has (or could have) a window-system frame. + + If the widget is a top-level, the widget itself is returned. + + Typical usage is changing the window caption: + + \code + aWidget->topLevelWidget()->setCaption( "New Caption" ); + \endcode + + \sa isTopLevel() +*/ + +TQWidget *TQWidget::topLevelWidget() const +{ + TQWidget *w = (TQWidget *)this; + TQWidget *p = w->parentWidget(); + while ( !w->testWFlags(WType_TopLevel) && p ) { + w = p; + p = p->parentWidget(); + } + return w; +} + + +/*! + \property TQWidget::paletteForegroundColor + \brief the foreground color of the widget + + setPaletteForegroundColor() is a convenience function that creates + and sets a modified TQPalette with setPalette(). The palette is + modified according to the widget's \e {background mode}. For + example, if the background mode is \c PaletteButton the palette entry + \c TQColorGroup::ButtonText is set to color. + + \sa setPalette() TQApplication::setPalette() backgroundMode() + foregroundColor() setBackgroundMode() setEraseColor() +*/ +const TQColor &TQWidget::paletteForegroundColor() const +{ +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + return colorGroup().color( TQPalette::foregroundRoleFromMode(mode) ); +#else + return TQt::black; +#endif +} + +void TQWidget::setPaletteForegroundColor( const TQColor & color ) +{ +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + TQPalette pal = palette(); + TQColorGroup::ColorRole role = TQPalette::foregroundRoleFromMode( mode ); + pal.setColor( TQPalette::Active, role, color ); + pal.setColor( TQPalette::Inactive, role, color ); + pal.setColor( TQPalette::Disabled, role, color ); + setPalette( pal ); +#endif +} + + +/*! + Same as paletteForegroundColor() + */ +const TQColor &TQWidget::foregroundColor() const +{ + return paletteForegroundColor(); +} + + +/*! + \fn const TQColor& TQWidget::eraseColor() const + + Returns the erase color of the widget. + + \sa setEraseColor() setErasePixmap() backgroundColor() +*/ + +/*! + Sets the erase color of the widget to \a color. + + The erase color is the color the widget is to be cleared to before + paintEvent() is called. If there is an erase pixmap (set using + setErasePixmap()), then this property has an indeterminate value. + + \sa erasePixmap(), backgroundColor(), backgroundMode(), palette() +*/ +void TQWidget::setEraseColor( const TQColor & color ) +{ + setBackgroundModeDirect( FixedColor ); + setBackgroundColorDirect( color ); + update(); +} + +/*! + Returns the widget's erase pixmap. + + \sa setErasePixmap() eraseColor() +*/ +const TQPixmap *TQWidget::erasePixmap() const +{ + return ( extra && extra->bg_pix ) ? extra->bg_pix : 0; +} + +/*! + Sets the widget's erase pixmap to \a pixmap. + + This pixmap is used to clear the widget before paintEvent() is + called. +*/ +void TQWidget::setErasePixmap( const TQPixmap &pixmap ) +{ + // This function is called with a null pixmap by setBackgroundEmpty(). + setBackgroundPixmapDirect( pixmap ); + setBackgroundModeDirect( FixedPixmap ); + update(); +} + +void TQWidget::setBackgroundFromMode() +{ +#ifndef TQT_NO_PALETTE + TQColorGroup::ColorRole r = TQColorGroup::Background; + if ( extra ) { + int i = (BackgroundMode)extra->bg_mode; + if ( i == FixedColor || i == FixedPixmap || i == NoBackground ) { + // Mode is for fixed color, not one based on palette, + // so nothing to do. + return; + } + switch( i ) { + case PaletteForeground: + r = TQColorGroup::Foreground; + break; + case PaletteButton: + r = TQColorGroup::Button; + break; + case PaletteLight: + r = TQColorGroup::Light; + break; + case PaletteMidlight: + r = TQColorGroup::Midlight; + break; + case PaletteDark: + r = TQColorGroup::Dark; + break; + case PaletteMid: + r = TQColorGroup::Mid; + break; + case PaletteText: + r = TQColorGroup::Text; + break; + case PaletteBrightText: + r = TQColorGroup::BrightText; + break; + case PaletteBase: + r = TQColorGroup::Base; + break; + case PaletteBackground: + r = TQColorGroup::Background; + break; + case PaletteShadow: + r = TQColorGroup::Shadow; + break; + case PaletteHighlight: + r = TQColorGroup::Highlight; + break; + case PaletteHighlightedText: + r = TQColorGroup::HighlightedText; + break; + case PaletteButtonText: + r = TQColorGroup::ButtonText; + break; + case X11ParentRelative: +#if defined(TQ_WS_X11) + setBackgroundX11Relative(); +#endif + return; + } + } + const TQColorGroup &cg = colorGroup(); + TQPixmap * p = cg.brush( r ).pixmap(); + if ( p ) + setBackgroundPixmapDirect( *p ); + else + setBackgroundColorDirect( cg.color( r ) ); +#endif +} + +/*! + \enum TQt::BackgroundMode + + This enum describes how the background of a widget changes, as the + widget's palette changes. + + The background is what the widget contains when \link + TQWidget::paintEvent() paintEvent()\endlink is called. To minimize + flicker, this should be the most common color or pixmap in the + widget. For \c PaletteBackground, use colorGroup().brush( \c + TQColorGroup::Background ), and so on. + + \value PaletteForeground + \value PaletteBackground + \value PaletteButton + \value PaletteLight + \value PaletteMidlight + \value PaletteDark + \value PaletteMid + \value PaletteText + \value PaletteBrightText + \value PaletteButtonText + \value PaletteBase + \value PaletteShadow + \value PaletteHighlight + \value PaletteHighlightedText + \value PaletteLink + \value PaletteLinkVisited + \value X11ParentRelative (internal use only) + + The final three values have special meaning: + + \value NoBackground the widget is not cleared before paintEvent(). + If the widget's paint event always draws on all the pixels, using + this mode can be both fast and flicker-free. + \value FixedColor the widget is cleared to a fixed color, normally + different from all the ones in the palette(). Set using \link + TQWidget::setPaletteBackgroundColor() + setPaletteBackgroundColor()\endlink. + \value FixedPixmap the widget is cleared to a fixed pixmap, + normally different from all the ones in the palette(). Set using + \link TQWidget::setPaletteBackgroundPixmap() + setPaletteBackgroundPixmap()\endlink. + + Although \c FixedColor and \c FixedPixmap are sometimes just + right, if you use them, make sure that you test your application + when the desktop color scheme has been changed. (On X11, a quick + way to test this is e.g. "./myapp -bg paleblue". On Windows, you + must use the control panel.) + + \sa TQWidget::setBackgroundMode() TQWidget::backgroundMode() + TQWidget::setBackgroundPixmap() TQWidget::setPaletteBackgroundColor() +*/ + +/*! + \property TQWidget::backgroundMode + \brief the color role used for painting the background of the widget + + setPaletteBackgroundColor() reads this property to determine which + entry of the \link TQWidget::palette palette\endlink to set. + + For most widgets the default suffices (\c PaletteBackground, + typically gray), but some need to use \c PaletteBase (the + background color for text output, typically white) or another + role. + + TQListBox, which is "sunken" and uses the base color to contrast + with its environment, does this in its constructor: + + \code + setBackgroundMode( PaletteBase ); + \endcode + + You will never need to set the background mode of a built-in + widget in TQt, but you might consider setting it in your custom + widgets, so that setPaletteBackgroundColor() works as expected. + + Note that two of the BackgroundMode values make no sense for + setBackgroundMode(), namely \c FixedPixmap and \c FixedColor. You + must call setBackgroundPixmap() and setPaletteBackgroundColor() + instead. +*/ +TQt::BackgroundMode TQWidget::backgroundMode() const +{ + return extra ? (BackgroundMode) extra->bg_mode : PaletteBackground; +} + +void TQWidget::setBackgroundMode( BackgroundMode m ) +{ + setBackgroundMode( m, m ); + if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == + WState_Visible ) + update(); +} + + +/*! + \overload + + Sets the widget's own background mode to \a m and the visual + background mode to \a visual. The visual background mode is used + with the designable properties \c backgroundColor, \c + foregroundColor and \c backgroundPixmap. + + For complex controls, the logical background mode sometimes + differs from a widget's own background mode. A spinbox for example + has \c PaletteBackground as background mode (typically dark gray), + while it's embedded lineedit control uses \c PaletteBase + (typically white). Since the lineedit covers most of the visual + area of a spinbox, it defines \c PaletteBase to be its \a visual + background mode. Changing the \c backgroundColor property thus + changes the lineedit control's background, which is exactly what + the user expects in \e{TQt Designer}. +*/ +void TQWidget::setBackgroundMode( BackgroundMode m, BackgroundMode visual ) +{ + if ( m == NoBackground ) { + setBackgroundEmpty(); + } else if ( m == FixedColor || m == FixedPixmap ) { +#if defined(QT_DEBUG) + tqWarning( "TQWidget::setBackgroundMode: FixedColor or FixedPixmap makes" + " no sense" ); +#endif + return; + } + setBackgroundModeDirect(m); + if ( m != visual && !extra ) + createExtra(); + if ( extra ) + extra->bg_mode_visual = visual; +} + + +/*! + \internal +*/ +void TQWidget::setBackgroundModeDirect( BackgroundMode m ) +{ + if ( m == PaletteBackground && !extra ) + return; + + createExtra(); + if ( (BackgroundMode)extra->bg_mode != m ) { + extra->bg_mode = m; + extra->bg_mode_visual = m; + setBackgroundFromMode(); + } +} + +/*! + \property TQWidget::paletteBackgroundColor + \brief the background color of the widget + + The palette background color is usually set implicitly by + setBackgroundMode(), although it can also be set explicitly by + setPaletteBackgroundColor(). setPaletteBackgroundColor() is a + convenience function that creates and sets a modified TQPalette + with setPalette(). The palette is modified according to the + widget's background mode. For example, if the background mode is + \c PaletteButton the color used for the palette's \c + TQColorGroup::Button color entry is set. + + If there is a background pixmap (set using + setPaletteBackgroundPixmap()), then the return value of this + function is indeterminate. + + \sa paletteBackgroundPixmap, paletteForegroundColor, palette, colorGroup() +*/ +const TQColor & TQWidget::paletteBackgroundColor() const +{ +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + switch( mode ) { + case FixedColor: + case FixedPixmap : + case NoBackground: + case X11ParentRelative: + return eraseColor(); + default: + TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); + return colorGroup().color( role ); + } +#else + return eraseColor(); +#endif +} + +void TQWidget::setPaletteBackgroundColor( const TQColor &color ) +{ +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + switch( mode ) { + case FixedColor: + case FixedPixmap : + case NoBackground: + case X11ParentRelative: + setEraseColor( color ); + break; + default: + TQPalette pal = palette(); + TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); + pal.setColor( TQPalette::Active, role, color ); + pal.setColor( TQPalette::Inactive, role, color ); + pal.setColor( TQPalette::Disabled, role, color ); + setPalette( pal ); + break; + } +#else + setEraseColor( color ); +#endif +} + + +/*! + \property TQWidget::paletteBackgroundPixmap + \brief the background pixmap of the widget + + The palette background pixmap is usually set implicitly by + setBackgroundMode(), although it can also be set explicitly by + setPaletteBackgroundPixmap(). setPaletteBackgroundPixmap() is a + convenience function that creates and sets a modified TQPalette + with setPalette(). The palette is modified according to the + widget's background mode. For example, if the background mode is + \c PaletteButton the pixmap used for the palette's + \c TQColorGroup::Button color entry is set. + + If there is a plain background color (set using + setPaletteBackgroundColor()), then this function returns 0. + + \sa paletteBackgroundColor, paletteForegroundColor, palette, colorGroup() +*/ +const TQPixmap *TQWidget::paletteBackgroundPixmap() const +{ +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + switch( mode ) { + case FixedColor: + case FixedPixmap : + case NoBackground: + case X11ParentRelative: + return erasePixmap(); + default: + TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); + return palette().brush( TQPalette::Active, role ).pixmap(); + } +#else + return erasePixmap(); +#endif +} + +void TQWidget::setPaletteBackgroundPixmap( const TQPixmap &pixmap ) +{ +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + switch( mode ) { + case FixedColor: + case FixedPixmap : + case NoBackground: + case X11ParentRelative: + setErasePixmap( pixmap ); + break; + default: + TQPalette pal = palette(); + TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); + pal.setBrush( TQPalette::Active, role, TQBrush( pal.color( TQPalette::Active, role ), pixmap ) ); + pal.setBrush( TQPalette::Inactive, role, TQBrush( pal.color( TQPalette::Inactive, role ), pixmap ) ); + pal.setBrush( TQPalette::Disabled, role, TQBrush( pal.color( TQPalette::Disabled, role ), pixmap ) ); + setPalette( pal ); + break; + } +#else + setErasePixmap( pixmap ); +#endif +} + + +/*! + \property TQWidget::backgroundBrush + \brief the widget's background brush + + The background brush depends on a widget's palette and its + background mode. + + \sa backgroundColor(), backgroundPixmap(), eraseColor(), palette, + TQApplication::setPalette() +*/ +const TQBrush& TQWidget::backgroundBrush() const +{ + static TQBrush noBrush; +#ifndef TQT_NO_PALETTE + BackgroundMode mode = extra ? (BackgroundMode) extra->bg_mode_visual : PaletteBackground; + switch( mode ) { + case FixedColor: + case FixedPixmap : + case NoBackground: + case X11ParentRelative: + return noBrush; + default: + TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode ); + return colorGroup().brush( role ); + } +#else + return noBrush; +#endif +} + + +/*! + \property TQWidget::colorGroup + \brief the current color group of the widget palette + + The color group is determined by the state of the widget. A + disabled widget has the TQPalette::disabled() color group, a widget + with keyboard focus has the TQPalette::active() color group, and an + inactive widget has the TQPalette::inactive() color group. + + \sa palette +*/ +#ifndef TQT_NO_PALETTE +const TQColorGroup &TQWidget::colorGroup() const +{ + if ( !isEnabled() ) + return palette().disabled(); + else if ( !isVisible() || isActiveWindow() ) + return palette().active(); + else + return palette().inactive(); +} +#endif + +/*! + \property TQWidget::palette + \brief the widget's palette + + As long as no special palette has been set, or after unsetPalette() + has been called, this is either a special palette for the widget + class, the parent's palette or (if this widget is a top level + widget), the default application palette. + + Instead of defining an entirely new palette, you can also use the + \link TQWidget::paletteBackgroundColor paletteBackgroundColor\endlink, + \link TQWidget::paletteBackgroundPixmap paletteBackgroundPixmap\endlink and + \link TQWidget::paletteForegroundColor paletteForegroundColor\endlink + convenience properties to change a widget's + background and foreground appearance only. + + \sa ownPalette, colorGroup(), TQApplication::palette() +*/ + +#ifndef TQT_NO_PALETTE +void TQWidget::setPalette( const TQPalette &palette ) +{ + own_palette = TRUE; + if ( pal == palette ) + return; + TQPalette old = pal; + pal = palette; + setBackgroundFromMode(); + TQEvent ev( TQEvent::PaletteChange ); + TQApplication::sendEvent( this, &ev ); + if ( children() ) { + TQEvent e( TQEvent::ParentPaletteChange ); + TQObjectListIt it( *children() ); + TQWidget *w; + while( (w=(TQWidget *)it.current()) != 0 ) { + ++it; + if ( w->isWidgetType() ) + TQApplication::sendEvent( w, &e ); + } + } + paletteChange( old ); + update(); +} + +void TQWidget::unsetPalette() +{ + // reset the palette + setPalette( qt_naturalWidgetPalette( this ) ); + own_palette = FALSE; +} + +/*! + \fn void TQWidget::setPalette( const TQPalette&, bool ) + \obsolete + + Use setPalette( const TQPalette& p ) instead. +*/ + +/*! + \fn void TQWidget::paletteChange( const TQPalette &oldPalette ) + + This virtual function is called from setPalette(). \a oldPalette + is the previous palette; you can get the new palette from + palette(). + + Reimplement this function if your widget needs to know when its + palette changes. + + \sa setPalette(), palette() +*/ + +void TQWidget::paletteChange( const TQPalette & ) +{ +} +#endif // TQT_NO_PALETTE + +/*! + \property TQWidget::font + \brief the font currently set for the widget + + The fontInfo() function reports the actual font that is being used + by the widget. + + As long as no special font has been set, or after unsetFont() is + called, this is either a special font for the widget class, the + parent's font or (if this widget is a top level widget), the + default application font. + + This code fragment sets a 12 point helvetica bold font: + \code + TQFont f( "Helvetica", 12, TQFont::Bold ); + setFont( f ); + \endcode + + In addition to setting the font, setFont() informs all children + about the change. + + \sa fontChange() fontInfo() fontMetrics() ownFont() +*/ +void TQWidget::setFont( const TQFont &font ) +{ + own_font = TRUE; + if ( fnt == font && fnt.d->mask == font.d->mask ) + return; + TQFont old = fnt; + fnt = font.resolve( qt_naturalWidgetFont( this ) ); +#if defined(TQ_WS_X11) + // make sure the font set on this widget is associated with the correct screen + fnt.x11SetScreen( x11Screen() ); +#endif + if ( children() ) { + TQEvent e( TQEvent::ParentFontChange ); + TQObjectListIt it( *children() ); + TQWidget *w; + while( (w=(TQWidget *)it.current()) != 0 ) { + ++it; + if ( w->isWidgetType() ) + TQApplication::sendEvent( w, &e ); + } + } + if ( hasFocus() ) + setFontSys(); + fontChange( old ); +} + +void TQWidget::unsetFont() +{ + // reset the font + setFont( qt_naturalWidgetFont( this ) ); + own_font = FALSE; +} + +/*! + \fn void TQWidget::setFont( const TQFont&, bool ) + \obsolete + + Use setFont(const TQFont& font) instead. +*/ + +/*! + \fn void TQWidget::fontChange( const TQFont &oldFont ) + + This virtual function is called from setFont(). \a oldFont is the + previous font; you can get the new font from font(). + + Reimplement this function if your widget needs to know when its + font changes. You will almost certainly need to update the widget + using update(). + + The default implementation updates the widget including its + geometry. + + \sa setFont(), font(), update(), updateGeometry() +*/ + +void TQWidget::fontChange( const TQFont & ) +{ + update(); + updateGeometry(); +} + + +/*! + \fn TQFontMetrics TQWidget::fontMetrics() const + + Returns the font metrics for the widget's current font. + Equivalent to TQFontMetrics(widget->font()). + + \sa font(), fontInfo(), setFont() +*/ + +/*! + \fn TQFontInfo TQWidget::fontInfo() const + + Returns the font info for the widget's current font. + Equivalent to TQFontInto(widget->font()). + + \sa font(), fontMetrics(), setFont() +*/ + + +/*! + \property TQWidget::cursor + \brief the cursor shape for this widget + + The mouse cursor will assume this shape when it's over this + widget. See the \link TQt::CursorShape list of predefined cursor + objects\endlink for a range of useful shapes. + + An editor widget might use an I-beam cursor: + \code + setCursor( IbeamCursor ); + \endcode + + If no cursor has been set, or after a call to unsetCursor(), the + parent's cursor is used. The function unsetCursor() has no effect + on top-level widgets. + + \sa TQApplication::setOverrideCursor() +*/ + +#ifndef TQT_NO_CURSOR +const TQCursor &TQWidget::cursor() const +{ + if ( testWState(WState_OwnCursor) ) + return (extra && extra->curs) + ? *extra->curs + : arrowCursor; + else + return (isTopLevel() || !parentWidget()) ? arrowCursor : parentWidget()->cursor(); +} +#endif +#ifndef TQT_NO_WIDGET_TOPEXTRA +/*! + \property TQWidget::caption + \brief the window caption (title) + + This property only makes sense for top-level widgets. If no + caption has been set, the caption is TQString::null. + + \sa icon() iconText() +*/ +TQString TQWidget::caption() const +{ + return extra && extra->topextra + ? extra->topextra->caption + : TQString::null; +} + +/*! + \property TQWidget::icon + \brief the widget's icon + + This property only makes sense for top-level widgets. If no icon + has been set, icon() returns 0. + + \sa iconText, caption, + \link appicon.html Setting the Application Icon\endlink +*/ +const TQPixmap *TQWidget::icon() const +{ + return ( extra && extra->topextra ) ? extra->topextra->icon : 0; +} + +/*! + \property TQWidget::iconText + \brief the widget's icon text + + This property only makes sense for top-level widgets. If no icon + text has been set, this functions returns TQString::null. + + \sa icon, caption +*/ + +TQString TQWidget::iconText() const +{ + return ( extra && extra->topextra ) ? extra->topextra->iconText + : TQString::null; +} +#endif //TQT_NO_WIDGET_TOPEXTRA + +/*! + \property TQWidget::mouseTracking + \brief whether mouse tracking is enabled for the widget + + If mouse tracking is disabled (the default), the widget only + receives mouse move events when at least one mouse button is + pressed while the mouse is being moved. + + If mouse tracking is enabled, the widget receives mouse move + events even if no buttons are pressed. + + \sa mouseMoveEvent(), TQApplication::setGlobalMouseTracking() +*/ + + +/*! + Sets the widget's focus proxy to widget \a w. If \a w is 0, the + function resets this widget to have no focus proxy. + + Some widgets, such as TQComboBox, can "have focus", but create a + child widget to actually handle the focus. TQComboBox, for example, + creates a TQLineEdit which handles the focus. + + setFocusProxy() sets the widget which will actually get focus when + "this widget" gets it. If there is a focus proxy, focusPolicy(), + setFocusPolicy(), setFocus() and hasFocus() all operate on the + focus proxy. + + \sa focusProxy() +*/ + +void TQWidget::setFocusProxy( TQWidget * w ) +{ + if ( !w && !extra ) + return; + + for ( TQWidget* fp = w; fp; fp = fp->focusProxy() ) { + if ( fp == this ) { +#if defined (QT_CHECK_STATE) + tqWarning( "%s (%s): already in focus proxy chain", className(), name() ); +#endif + return; + } + } + + createExtra(); + + if ( extra->focus_proxy ) { + disconnect( extra->focus_proxy, TQ_SIGNAL(destroyed()), + this, TQ_SLOT(focusProxyDestroyed()) ); + extra->focus_proxy = 0; + } + + if ( w ) { + setFocusPolicy( w->focusPolicy() ); + connect( w, TQ_SIGNAL(destroyed()), + this, TQ_SLOT(focusProxyDestroyed()) ); + } + extra->focus_proxy = w; +} + + +/*! + Returns the focus proxy, or 0 if there is no focus proxy. + + \sa setFocusProxy() +*/ + +TQWidget * TQWidget::focusProxy() const +{ + return extra ? extra->focus_proxy : 0; +} + + +/*! + \internal + + Internal slot used to clean up if the focus proxy is destroyed. + + \sa setFocusProxy() +*/ + +void TQWidget::focusProxyDestroyed() +{ + if ( extra ) + extra->focus_proxy = 0; + setFocusPolicy( NoFocus ); +} + +/*! + \property TQWidget::focus + \brief whether this widget (or its focus proxy) has the keyboard + input focus + + Effectively equivalent to \c {tqApp->focusWidget() == this}. + + \sa setFocus(), clearFocus(), setFocusPolicy(), TQApplication::focusWidget() +*/ +bool TQWidget::hasFocus() const +{ + const TQWidget* w = this; + while ( w->focusProxy() ) + w = w->focusProxy(); + return tqApp->focusWidget() == w; +} + +/*! + Gives the keyboard input focus to this widget (or its focus + proxy) if this widget or one of its parents is the \link + isActiveWindow() active window\endlink. + + First, a focus out event is sent to the focus widget (if any) to + tell it that it is about to lose the focus. Then a focus in event + is sent to this widget to tell it that it just received the focus. + (Nothing happens if the focus in and focus out widgets are the + same.) + + setFocus() gives focus to a widget regardless of its focus policy, + but does not clear any keyboard grab (see grabKeyboard()). + + Be aware that if the widget is hidden, it will not accept focus. + + \warning If you call setFocus() in a function which may itself be + called from focusOutEvent() or focusInEvent(), you may get an + infinite recursion. + + \sa hasFocus() clearFocus() focusInEvent() focusOutEvent() + setFocusPolicy() TQApplication::focusWidget() grabKeyboard() + grabMouse() +*/ + +void TQWidget::setFocus() +{ + if ( !isEnabled() ) + return; + + if ( focusProxy() ) { + focusProxy()->setFocus(); + return; + } + + TQFocusData * f = focusData( TRUE ); + if ( f->it.current() == this && tqApp->focusWidget() == this +#if defined(TQ_WS_WIN) + && GetFocus() == winId() +#endif + ) + return; + + f->it.toFirst(); + while ( f->it.current() != this && !f->it.atLast() ) + ++f->it; + // at this point, the iterator should point to 'this'. if it + // does not, 'this' must not be in the list - an error, but + // perhaps possible. fix it. + if ( f->it.current() != this ) { + f->focusWidgets.append( this ); + f->it.toLast(); + } + + if ( isActiveWindow() ) { + TQWidget * prev = tqApp->focus_widget; + if ( prev ) { + // This part is never executed when TQ_WS_X11? Preceding XFocusOut + // had already reset focus_widget when received XFocusIn + + // Don't reset input context explicitly here. Whether reset or not + // when focusing out is a responsibility of input methods. For + // example, Japanese input context should not be reset here. The + // context sometimes contains a whole paragraph and has minutes of + // lifetime different to ephemeral one in other languages. The + // input context should be survived until focused again. So we + // delegate the responsibility to input context via + // unfocusInputContext(). + if ( prev != this && prev->isInputMethodEnabled() ) { +#if 0 + prev->resetInputContext(); +#else + prev->unfocusInputContext(); +#endif + } + } +#if defined(TQ_WS_WIN) + else { + TQInputContext::endComposition(); + } +#endif + tqApp->focus_widget = this; + if( isInputMethodEnabled() ) + focusInputContext(); + +#if defined(TQ_WS_WIN) + if ( !topLevelWidget()->isPopup() ) + SetFocus( winId() ); + else { +#endif +#if defined(QT_ACCESSIBILITY_SUPPORT) + TQAccessible::updateAccessibility( this, 0, TQAccessible::Focus ); +#endif +#if defined(TQ_WS_WIN) + } +#endif + + if ( prev != this ) { + if ( prev ) { + TQFocusEvent out( TQEvent::FocusOut ); + TQApplication::sendEvent( prev, &out ); + } + + if ( tqApp->focus_widget == this ) { + TQFocusEvent in( TQEvent::FocusIn ); + TQApplication::sendEvent( this, &in ); + } + } + } +} + +/*! + Takes keyboard input focus from the widget. + + If the widget has active focus, a \link focusOutEvent() focus out + event\endlink is sent to this widget to tell it that it is about + to lose the focus. + + This widget must enable focus setting in order to get the keyboard + input focus, i.e. it must call setFocusPolicy(). + + \sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), + setFocusPolicy(), TQApplication::focusWidget() +*/ + +void TQWidget::clearFocus() +{ + if ( focusProxy() ) { + focusProxy()->clearFocus(); + return; + } else if ( hasFocus() ) { +#if !defined(TQ_WS_X11) + resetInputContext(); +#else + unfocusInputContext(); +#endif + TQWidget* w = tqApp->focusWidget(); + // clear active focus + tqApp->focus_widget = 0; + TQFocusEvent out( TQEvent::FocusOut ); + TQApplication::sendEvent( w, &out ); +#if defined(TQ_WS_WIN) + if ( !isPopup() && GetFocus() == winId() ) + SetFocus( 0 ); + else { +#endif +#if defined(QT_ACCESSIBILITY_SUPPORT) + TQAccessible::updateAccessibility( this, 0, TQAccessible::Focus ); +#endif +#if defined(TQ_WS_WIN) + } +#endif + } +} + + +/*! + Finds a new widget to give the keyboard focus to, as appropriate + for Tab and Shift+Tab, and returns TRUE if is can find a new + widget and FALSE if it can't, + + If \a next is TRUE, this function searches "forwards", if \a next + is FALSE, it searches "backwards". + + Sometimes, you will want to reimplement this function. For + example, a web browser might reimplement it to move its "current + active link" forwards or backwards, and call + TQWidget::focusNextPrevChild() only when it reaches the last or + first link on the "page". + + Child widgets call focusNextPrevChild() on their parent widgets, + but only the top-level widget decides where to redirect focus. By + overriding this method for an object, you thus gain control of + focus traversal for all child widgets. + + \warning TQScrollView uses it own logic for this function, which + does the right thing in most cases. But if you are using a + TQScrollView and want complete control of the focus chain you'll + need to override TQScrollView::focusNextPrevChild() and your + top-level widgets' focusNextPrevChild() functions. + + \sa focusData() +*/ + +bool TQWidget::focusNextPrevChild( bool next ) +{ + TQWidget* p = parentWidget(); + if ( !isTopLevel() && p ) + return p->focusNextPrevChild(next); + + TQFocusData *f = focusData( TRUE ); + + TQWidget *startingPoint = f->it.current(); + TQWidget *candidate = 0; + TQWidget *w = next ? f->focusWidgets.last() : f->focusWidgets.first(); + extern bool tqt_tab_all_widgets; + uint focus_flag = tqt_tab_all_widgets ? TabFocus : StrongFocus; + do { + if ( w && w != startingPoint && + ( ( w->focusPolicy() & focus_flag ) == focus_flag ) + && !w->focusProxy() && w->isVisibleTo(this) && w->isEnabled()) + candidate = w; + w = next ? f->focusWidgets.prev() : f->focusWidgets.next(); + } while( w && !(candidate && w==startingPoint) ); + + if ( !candidate ) + return FALSE; + + candidate->setFocus(); + return TRUE; +} + +/*! + Returns the focus widget in this widget's window. This is not the + same as TQApplication::focusWidget(), which returns the focus + widget in the currently active window. +*/ + +TQWidget *TQWidget::focusWidget() const +{ + TQWidget *that = (TQWidget *)this; // mutable + TQFocusData *f = that->focusData( FALSE ); + if ( f && f->focusWidgets.count() && f->it.current() == 0 ) + f->it.toFirst(); + return ( f && f->it.current() ) ? f->it.current() : 0; +} + + +/*! + Returns the focus data for this widget's top-level widget. + + Focus data always belongs to the top-level widget. The focus data + list contains all the widgets in this top-level widget that can + accept focus, in tab order. An iterator points to the current + focus widget (focusWidget() returns a pointer to this widget). + + This information is useful for implementing advanced versions of + focusNextPrevChild(). +*/ +TQFocusData * TQWidget::focusData() +{ + return focusData( TRUE ); +} + +/*! + \internal + + Internal function which lets us ask for the focus data, creating + it if it doesn't exist and \a create is TRUE. +*/ +TQFocusData * TQWidget::focusData( bool create ) +{ + TQWidget * tlw = topLevelWidget(); + TQWExtra * ed = tlw->extraData(); + if ( !ed || !ed->topextra ) { + if ( !create ) + return 0; + tlw->createTLExtra(); + ed = tlw->extraData(); + } + if ( create && !ed->topextra->focusData ) + ed->topextra->focusData = new TQFocusData; + + return ed->topextra->focusData; +} + +/*! + \property TQWidget::inputMethodEnabled + \brief enables or disables the use of input methods for this widget. + + Most Widgets (as eg. buttons) that do not handle text input should have + the input method disabled if they have focus. This is the default. + + If a widget handles text input it should set this property to TRUE. +*/ + +void TQWidget::setInputMethodEnabled( bool b ) +{ + im_enabled = b; +#ifdef TQ_WS_WIN + TQInputContext::enable( this, im_enabled & !((bool)testWState(WState_Disabled)) ); +#endif +} + + +/*! + Enables key event compression, if \a compress is TRUE, and + disables it if \a compress is FALSE. + + Key compression is off by default (except for TQLineEdit and + TQTextEdit), so widgets receive one key press event for each key + press (or more, since autorepeat is usually on). If you turn it on + and your program doesn't keep up with key input, TQt may try to + compress key events so that more than one character can be + processed in each event. + + For example, a word processor widget might receive 2, 3 or more + characters in each TQKeyEvent::text(), if the layout recalculation + takes too long for the CPU. + + If a widget supports multiple character unicode input, it is + always safe to turn the compression on. + + TQt performs key event compression only for printable characters. + Modifier keys, cursor movement keys, function keys and + miscellaneous action keys (e.g. Escape, Enter, Backspace, + PrintScreen) will stop key event compression, even if there are + more compressible key events available. + + Not all platforms support this compression, in which case turning + it on will have no effect. + + \sa TQKeyEvent::text(); +*/ + +void TQWidget::setKeyCompression(bool compress) +{ + if ( compress ) + setWState( WState_CompressKeys ); + else + clearWState( WState_CompressKeys ); +} + +/*! + \property TQWidget::isActiveWindow + \brief whether this widget is the active window + + The active window is the window that contains the widget + that has keyboard focus. + + When popup windows are visible, this property is TRUE for both the + active window \e and for the popup. + + \sa setActiveWindow(), TQApplication::activeWindow() +*/ +bool TQWidget::isActiveWindow() const +{ + TQWidget *tlw = topLevelWidget(); + if(testWFlags(WSubWindow) && parentWidget()) + tlw = parentWidget()->topLevelWidget(); + if(tlw == tqApp->activeWindow() || ( isVisible() && tlw->isPopup() )) + return TRUE; +#ifndef TQT_NO_STYLE + const_cast(this)->createExtra(); + if (!extra->m_ceData) { + const_cast(this)->extra->m_ceData = new TQStyleControlElementData(); + } + //extra->m_ceData->widgetObjectTypes = getObjectTypeListForObject(this); + extra->m_ceData->widgetObjectTypes.clear(); + extra->m_ceData->allDataPopulated = false; + //if(style().styleHint(TQStyle::SH_Widget_ShareActivation, *extra->m_ceData, getControlElementFlagsForObject(this, extra->m_ceData->widgetObjectTypes, TQStyleOption(), false), TQStyleOption(), NULL, this)) { + if(style().styleHint(TQStyle::SH_Widget_ShareActivation, *extra->m_ceData, TQStyle::CEF_None, TQStyleOption(), NULL, this)) { + if((tlw->isDialog() || (tlw->testWFlags(TQt::WStyle_Tool) && !tlw->isPopup())) && + !tlw->testWFlags(TQt::WShowModal) && + (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow())) + return TRUE; + TQWidget *w = tqApp->activeWindow(); + if( !testWFlags(WSubWindow) && w && w->testWFlags(WSubWindow) && + w->parentWidget()->topLevelWidget() == tlw) + return TRUE; + while(w && (tlw->isDialog() || tlw->testWFlags(TQt::WStyle_Tool)) && + !w->testWFlags(TQt::WShowModal) && w->parentWidget()) { + w = w->parentWidget()->topLevelWidget(); + if( w == tlw ) + return TRUE; + } + } +#endif +#if defined(TQ_WS_WIN32) + HWND parent = tlw->winId(); + HWND topparent = GetActiveWindow(); + while ( parent ) { + parent = ::GetParent( parent ); + if ( parent && parent == topparent ) + return TRUE; + } +#endif + + return FALSE; +} + +/*! + Moves the \a second widget around the ring of focus widgets so + that keyboard focus moves from the \a first widget to the \a + second widget when the Tab key is pressed. + + Note that since the tab order of the \a second widget is changed, + you should order a chain like this: + + \code + setTabOrder( a, b ); // a to b + setTabOrder( b, c ); // a to b to c + setTabOrder( c, d ); // a to b to c to d + \endcode + + \e not like this: + + \code + setTabOrder( c, d ); // c to d WRONG + setTabOrder( a, b ); // a to b AND c to d + setTabOrder( b, c ); // a to b to c, but not c to d + \endcode + + If \a first or \a second has a focus proxy, setTabOrder() + correctly substitutes the proxy. + + \sa setFocusPolicy(), setFocusProxy() +*/ +void TQWidget::setTabOrder( TQWidget* first, TQWidget *second ) +{ + if ( !first || !second || + first->focusPolicy() == NoFocus || second->focusPolicy() == NoFocus ) + return; + + // If first is redirected, set first to the last child of first + // that can take keyboard focus so that second is inserted after + // that last child, and the focus order within first is (more + // likely to be) preserved. + if ( first->focusProxy() ) { + TQObjectList *l = first->queryList( "TQWidget" ); + if ( l && l->count() ) { + TQObjectListIt it(*l); + it.toLast(); + while (it.current()) { + if (((TQWidget*)it.current())->topLevelWidget() == first->topLevelWidget()) { + first = (TQWidget*)it.current(); + if (first->focusPolicy() != NoFocus) + break; + } + --it; + } + } + delete l; + } + while ( first->focusProxy() ) + first = first->focusProxy(); + while ( second->focusProxy() ) + second = second->focusProxy(); + + TQFocusData *f = first->focusData( TRUE ); + bool focusThere = (f->it.current() == second ); + f->focusWidgets.removeRef( second ); + if ( f->focusWidgets.findRef( first ) >= 0 ) + f->focusWidgets.insert( f->focusWidgets.at() + 1, second ); + else + f->focusWidgets.append( second ); + if ( focusThere ) { // reset iterator so tab will work appropriately + f->it.toFirst(); + while( f->it.current() && f->it.current() != second ) + ++f->it; + } +} + +/*!\internal + + Moves the relevant subwidgets of this widget from the \a oldtlw's + tab chain to that of the new parent, if there's anything to move and + we're really moving + + This function is called from TQWidget::reparent() *after* the widget + has been reparented. + + \sa reparent() +*/ + +void TQWidget::reparentFocusWidgets( TQWidget * oldtlw ) +{ + if ( oldtlw == topLevelWidget() ) + return; // nothing to do + + TQFocusData * from = oldtlw ? oldtlw->topData()->focusData : 0; + TQFocusData * to; + to = focusData(); + + if ( from ) { + from->focusWidgets.first(); + do { + TQWidget * pw = from->focusWidgets.current(); + while( pw && pw != this ) + pw = pw->parentWidget(); + if ( pw == this ) { + TQWidget * w = from->focusWidgets.take(); + if ( w == from->it.current() ) + // probably best to clear keyboard focus, or + // the user might become rather confused + w->clearFocus(); + if ( !isTopLevel() ) + to->focusWidgets.append( w ); + } else { + from->focusWidgets.next(); + } + } while( from->focusWidgets.current() ); + } + + if ( to->focusWidgets.findRef(this) < 0 ) + to->focusWidgets.append( this ); + + if ( !isTopLevel() && extra && extra->topextra && extra->topextra->focusData ) { + // this widget is no longer a top-level widget, so get rid + // of old focus data + delete extra->topextra->focusData; + extra->topextra->focusData = 0; + } +} + +/*! + \fn void TQWidget::recreate( TQWidget *parent, WFlags f, const TQPoint & p, bool showIt ) + + \obsolete + + This method is provided to aid porting from TQt 1.0 to 2.0. It has + been renamed reparent() in TQt 2.0. +*/ + +/*! + \property TQWidget::frameSize + \brief the size of the widget including any window frame +*/ +TQSize TQWidget::frameSize() const +{ + if ( isTopLevel() && !isPopup() ) { + if ( fstrut_dirty ) + updateFrameStrut(); + TQWidget *that = (TQWidget *) this; + TQTLWExtra *top = that->topData(); + return TQSize( crect.width() + top->fleft + top->fright, + crect.height() + top->ftop + top->fbottom ); + } + return crect.size(); +} + +/*! + \internal + + Recursive function that updates \a widget and all its children, + if they have some parent background origin. +*/ +static void qt_update_bg_recursive( TQWidget *widget ) +{ + if ( !widget || widget->isHidden() || widget->backgroundOrigin() == TQWidget::WidgetOrigin || !widget->backgroundPixmap() ) + return; + + const TQObjectList *lst = widget->children(); + + if ( lst ) { + TQObjectListIterator it( *lst ); + TQWidget *widget; + while ( (widget = (TQWidget*)it.current()) ) { + ++it; + if ( widget->isWidgetType() && !widget->isHidden() && !widget->isTopLevel() && !widget->testWFlags(TQt::WSubWindow) ) + qt_update_bg_recursive( widget ); + } + } + TQApplication::postEvent( widget, new TQPaintEvent( widget->clipRegion(), !widget->testWFlags(TQt::WRepaintNoErase) ) ); +} + +/*! + \overload + + This corresponds to move( TQPoint(\a x, \a y) ). +*/ + +void TQWidget::move( int x, int y ) +{ + TQPoint oldp(pos()); + internalSetGeometry( x + geometry().x() - TQWidget::x(), + y + geometry().y() - TQWidget::y(), + width(), height(), TRUE ); + if ( isVisible() && oldp != pos() ) + qt_update_bg_recursive( this ); +} + +/*! + \overload + + This corresponds to resize( TQSize(\a w, \a h) ). +*/ +void TQWidget::resize( int w, int h ) +{ + internalSetGeometry( geometry().x(), geometry().y(), w, h, FALSE ); + setWState( WState_Resized ); +} + +/*! + \overload + + This corresponds to setGeometry( TQRect(\a x, \a y, \a w, \a h) ). +*/ +void TQWidget::setGeometry( int x, int y, int w, int h ) +{ + TQPoint oldp( pos( )); + internalSetGeometry( x, y, w, h, TRUE ); + setWState( WState_Resized ); + if ( isVisible() && oldp != pos() ) + qt_update_bg_recursive( this ); +} + +/*! + \property TQWidget::focusEnabled + \brief whether the widget accepts keyboard focus + + Keyboard focus is initially disabled (i.e. focusPolicy() == + \c TQWidget::NoFocus). + + You must enable keyboard focus for a widget if it processes + keyboard events. This is normally done from the widget's + constructor. For instance, the TQLineEdit constructor calls + setFocusPolicy(TQWidget::StrongFocus). + + \sa setFocusPolicy(), focusInEvent(), focusOutEvent(), keyPressEvent(), + keyReleaseEvent(), isEnabled() +*/ + +/*! + \enum TQWidget::FocusPolicy + + This enum type defines the various policies a widget can have with + respect to acquiring keyboard focus. + + \value TabFocus the widget accepts focus by tabbing. + \value ClickFocus the widget accepts focus by clicking. + \value StrongFocus the widget accepts focus by both tabbing + and clicking. On Mac OS X this will also + be indicate that the widget accepts tab focus + when in 'Text/List focus mode'. + \value WheelFocus like StrongFocus plus the widget accepts + focus by using the mouse wheel. + \value NoFocus the widget does not accept focus. + +*/ + +/*! + \property TQWidget::focusPolicy + \brief the way the widget accepts keyboard focus + + The policy is \c TQWidget::TabFocus if the widget accepts keyboard + focus by tabbing, \c TQWidget::ClickFocus if the widget accepts + focus by clicking, \c TQWidget::StrongFocus if it accepts both, and + \c TQWidget::NoFocus (the default) if it does not accept focus at + all. + + You must enable keyboard focus for a widget if it processes + keyboard events. This is normally done from the widget's + constructor. For instance, the TQLineEdit constructor calls + setFocusPolicy(TQWidget::StrongFocus). + + \sa focusEnabled, focusInEvent(), focusOutEvent(), keyPressEvent(), + keyReleaseEvent(), enabled +*/ + +void TQWidget::setFocusPolicy( FocusPolicy policy ) +{ + if ( focusProxy() ) + focusProxy()->setFocusPolicy( policy ); + if ( policy != NoFocus ) { + TQFocusData * f = focusData( TRUE ); + if ( f->focusWidgets.findRef( this ) < 0 ) + f->focusWidgets.append( this ); + } + focus_policy = (uint) policy; +} + +/*! + \property TQWidget::updatesEnabled + \brief whether updates are enabled + + Calling update() and repaint() has no effect if updates are + disabled. Paint events from the window system are processed + normally even if updates are disabled. + + setUpdatesEnabled() is normally used to disable updates for a + short period of time, for instance to avoid screen flicker during + large changes. + + Example: + \code + setUpdatesEnabled( FALSE ); + bigVisualChanges(); + setUpdatesEnabled( TRUE ); + repaint(); + \endcode + + \sa update(), repaint(), paintEvent() +*/ +void TQWidget::setUpdatesEnabled( bool enable ) +{ + if ( enable ) + clearWState( WState_BlockUpdates ); + else + setWState( WState_BlockUpdates ); +} + +/*! + Shows the widget and its child widgets. + + If its size or position has changed, TQt guarantees that a widget + gets move and resize events just before it is shown. + + You almost never have to reimplement this function. If you need to + change some settings before a widget is shown, use showEvent() + instead. If you need to do some delayed initialization use + polish(). + + \sa showEvent(), hide(), showMinimized(), showMaximized(), + showNormal(), isVisible(), polish() +*/ + +void TQWidget::show() +{ + if ( testWState(WState_Visible) ) + return; + + bool wasHidden = isHidden(); + bool postLayoutHint = !isTopLevel() && wasHidden; + clearWState( WState_ForceHide | WState_CreatedHidden ); + + if ( !isTopLevel() && !parentWidget()->isVisible() ) { + // we should become visible, but one of our ancestors is + // explicitly hidden. Since we cleared the ForceHide flag, our + // immediate parent will call show() on us again during its + // own processing of show(). + if ( wasHidden ) { + TQEvent showToParentEvent( TQEvent::ShowToParent ); + TQApplication::sendEvent( this, &showToParentEvent ); + } + if ( postLayoutHint ) + TQApplication::postEvent( parentWidget(), + new TQEvent(TQEvent::LayoutHint) ); + return; + } + + in_show = TRUE; // set qws recursion watch + + TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); + + uint state = isTopLevel() ? windowState() : 0; +#ifndef Q_OS_TEMP + if ( isTopLevel() && !testWState( WState_Resized ) ) { + // do this before sending the posted resize events. Otherwise + // the layout would catch the resize event and may expand the + // minimum size. + TQSize s = qt_naturalWidgetSize( this ); + if ( !s.isEmpty() ) + resize( s ); + } +#endif // Q_OS_TEMP + + TQApplication::sendPostedEvents( this, TQEvent::Move ); + TQApplication::sendPostedEvents( this, TQEvent::Resize ); + + // the resizing and layouting might have changed the window state + if (isTopLevel() && windowState() != state) + setWindowState(state); + + setWState( WState_Visible ); + + if ( parentWidget() ) + TQApplication::sendPostedEvents( parentWidget(), + TQEvent::ChildInserted ); + + if ( extra ) { + int w = crect.width(); + int h = crect.height(); + if ( w < extra->minw || h < extra->minh || + w > extra->maxw || h > extra->maxh ) { + w = TQMAX( extra->minw, TQMIN( w, extra->maxw )); + h = TQMAX( extra->minh, TQMIN( h, extra->maxh )); + resize( w, h ); // deferred resize + } + } + + if ( testWFlags(WStyle_Tool) || isPopup() ) { + raise(); + } else if ( testWFlags(WType_TopLevel) ) { + while ( TQApplication::activePopupWidget() ) { + if ( !TQApplication::activePopupWidget()->close() ) + break; + } + } + + if ( !testWState(WState_Polished) ) + polish(); + + showChildren( FALSE ); + + if ( postLayoutHint ) + TQApplication::postEvent( parentWidget(), + new TQEvent(TQEvent::LayoutHint) ); + + // Required for Mac, not sure whether we should always do that + if( isTopLevel() ) + TQApplication::sendPostedEvents(0, TQEvent::LayoutHint); + + // On Windows, show the popup now so that our own focus handling + // stores the correct old focus widget even if it's stolen in the showevent +#if defined(TQ_WS_WIN) + if ( testWFlags(WType_Popup) ) + tqApp->openPopup( this ); +#endif + + TQShowEvent showEvent; + TQApplication::sendEvent( this, &showEvent ); + + if ( testWFlags(WShowModal) ) { + // tqt_enter_modal *before* show, otherwise the initial + // stacking might be wrong + tqt_enter_modal( this ); + } + + // do not show the window directly, but post a show-window request + // to reduce flicker with widgets in layouts + if ( postLayoutHint ) + TQApplication::postEvent( this, new TQEvent( TQEvent::ShowWindowRequest ) ); + else + showWindow(); + +#if !defined(TQ_WS_WIN) + if ( testWFlags(WType_Popup) ) + tqApp->openPopup( this ); +#endif + +#if defined(QT_ACCESSIBILITY_SUPPORT) + TQAccessible::updateAccessibility( this, 0, TQAccessible::ObjectShow ); +#endif + + in_show = FALSE; // reset qws recursion watch +} + +/*! \fn void TQWidget::iconify() + \obsolete +*/ + +/*! + Hides the widget. + + You almost never have to reimplement this function. If you need to + do something after a widget is hidden, use hideEvent() instead. + + \sa hideEvent(), isHidden(), show(), showMinimized(), isVisible(), close() +*/ + +void TQWidget::hide() +{ + clearWState( WState_CreatedHidden ); + if ( testWState(WState_ForceHide) ) + return; + + setWState( WState_ForceHide ); + + if ( testWFlags(WType_Popup) ) + tqApp->closePopup( this ); + + // Move test modal here. Otherwise, a modal dialog could get + // destroyed and we lose all access to its parent because we haven't + // left modality. (Eg. modal Progress Dialog) + if ( testWFlags(WShowModal) ) + tqt_leave_modal( this ); + +#if defined(TQ_WS_WIN) + if ( isTopLevel() && !isPopup() && parentWidget() && isActiveWindow() ) + parentWidget()->setActiveWindow(); // Activate parent +#endif + + hideWindow(); + + if ( testWState(WState_Visible) ) { + clearWState( WState_Visible ); + + // next bit tries to move the focus if the focus widget is now + // hidden. + if ( tqApp && tqApp->focusWidget() == this ) + focusNextPrevChild( TRUE ); + TQHideEvent hideEvent; + TQApplication::sendEvent( this, &hideEvent ); + hideChildren( FALSE ); + +#if defined(QT_ACCESSIBILITY_SUPPORT) + TQAccessible::updateAccessibility( this, 0, TQAccessible::ObjectHide ); +#endif + } else { + TQEvent hideToParentEvent( TQEvent::HideToParent ); + TQApplication::sendEvent( this, &hideToParentEvent ); + } + + // post layout hint for non toplevels. The parent widget check is + // necessary since the function is called in the destructor + if ( !isTopLevel() && parentWidget() ) + TQApplication::postEvent( parentWidget(), + new TQEvent( TQEvent::LayoutHint) ); +} + +void TQWidget::setShown( bool show ) +{ + if ( show ) + this->show(); + else + hide(); +} + +void TQWidget::setHidden( bool hide ) +{ + if ( hide ) + this->hide(); + else + show(); +} + +void TQWidget::showChildren( bool spontaneous ) +{ + if ( children() ) { + TQObjectListIt it(*children()); + TQObject *object; + TQWidget *widget; + while ( it ) { + object = it.current(); + ++it; + if ( object->isWidgetType() ) { + widget = (TQWidget*)object; + if ( !widget->isTopLevel() && widget->isShown() ) { + if ( spontaneous ) { + widget->showChildren( spontaneous ); + TQShowEvent e; + TQApplication::sendSpontaneousEvent( widget, &e ); + } else { + widget->show(); + } + } + } + } + } +} + +void TQWidget::hideChildren( bool spontaneous ) +{ + if ( children() ) { + TQObjectListIt it(*children()); + TQObject *object; + TQWidget *widget; + while ( it ) { + object = it.current(); + ++it; + if ( object->isWidgetType() ) { + widget = (TQWidget*)object; + if ( !widget->isTopLevel() && widget->isShown() ) { + if ( !spontaneous ) + widget->clearWState( WState_Visible ); + widget->hideChildren( spontaneous ); + TQHideEvent e; + if ( spontaneous ) + TQApplication::sendSpontaneousEvent( widget, &e ); + else + TQApplication::sendEvent( widget, &e ); + } + } + } + } +} + + +/*! + Delayed initialization of a widget. + + This function will be called \e after a widget has been fully + created and \e before it is shown the very first time. + + Polishing is useful for final initialization which depends on + having an instantiated widget. This is something a constructor + cannot guarantee since the initialization of the subclasses might + not be finished. + + After this function, the widget has a proper font and palette and + TQApplication::polish() has been called. + + Remember to call TQWidget's implementation first when reimplementing this + function to ensure that your program does not end up in infinite recursion. + + \sa constPolish(), TQApplication::polish() +*/ + +void TQWidget::polish() +{ +#ifndef TQT_NO_WIDGET_TOPEXTRA + if ( isTopLevel() ) { + const TQPixmap *pm = icon(); + if ( !pm || pm->isNull() ) { + TQWidget *mw = (TQWidget *)parent(); + pm = mw ? mw->icon() : 0; + if ( pm && !pm->isNull() ) + setIcon( *pm ); + else { + mw = mw ? mw->topLevelWidget() : 0; + pm = mw ? mw->icon() : 0; + if ( pm && !pm->isNull() ) + setIcon( *pm ); + else { + mw = tqApp ? tqApp->mainWidget() : 0; + pm = mw ? mw->icon() : 0; + if ( pm && !pm->isNull() ) + setIcon( *pm ); + } + } + } + } +#endif + if ( !testWState(WState_Polished) ) { + if ( ! own_font && + ! TQApplication::font( this ).isCopyOf( TQApplication::font() ) ) + unsetFont(); +#ifndef TQT_NO_PALETTE + if ( ! own_palette && + ! TQApplication::palette( this ).isCopyOf( TQApplication::palette() ) ) + unsetPalette(); +#endif + setWState(WState_Polished); + tqApp->polish( this ); + TQApplication::sendPostedEvents( this, TQEvent::ChildInserted ); + } +} + + +/*! + \fn void TQWidget::constPolish() const + + Ensures that the widget is properly initialized by calling + polish(). + + Call constPolish() from functions like sizeHint() that depends on + the widget being initialized, and that may be called before + show(). + + \warning Do not call constPolish() on a widget from inside that + widget's constructor. + + \sa polish() +*/ + +/*! + \overload + + Closes this widget. Returns TRUE if the widget was closed; + otherwise returns FALSE. + + If \a alsoDelete is TRUE or the widget has the \c + WDestructiveClose widget flag, the widget is also deleted. The + widget can prevent itself from being closed by rejecting the + \l TQCloseEvent it gets. A close events is delivered to the widget + no matter if the widget is visible or not. + + The TQApplication::lastWindowClosed() signal is emitted when the + last visible top level widget is closed. + + Note that closing the \l TQApplication::mainWidget() terminates the + application. + + \sa closeEvent(), TQCloseEvent, hide(), TQApplication::quit(), + TQApplication::setMainWidget(), TQApplication::lastWindowClosed() +*/ + +bool TQWidget::close( bool alsoDelete ) +{ + if ( is_closing ) + return TRUE; + is_closing = 1; + WId id = winId(); + bool isMain = tqApp->mainWidget() == this; + bool checkLastWindowClosed = isTopLevel() && !isPopup(); + bool deleted = FALSE; + TQCloseEvent e; + TQApplication::sendEvent( this, &e ); + deleted = !TQWidget::find(id); + if ( !deleted && !e.isAccepted() ) { + is_closing = 0; + return FALSE; + } + if ( !deleted && !isHidden() ) + hide(); + if ( checkLastWindowClosed + && tqApp->receivers(TQ_SIGNAL(lastWindowClosed())) ) { + /* if there is no non-withdrawn top level window left (except + the desktop, popups, or dialogs with parents), we emit the + lastWindowClosed signal */ + TQWidgetList *list = tqApp->topLevelWidgets(); + TQWidget *widget = list->first(); + while ( widget ) { + if ( !widget->isHidden() + && !widget->isDesktop() + && !widget->isPopup() + && (!widget->isDialog() || !widget->parentWidget())) + break; + widget = list->next(); + } + delete list; + if ( widget == 0 ) + emit tqApp->lastWindowClosed(); + } + if ( isMain ) + tqApp->quit(); + if ( deleted ) + return TRUE; + is_closing = 0; + if ( alsoDelete ) + delete this; + else if ( testWFlags(WDestructiveClose) ) { + clearWFlags(WDestructiveClose); + deleteLater(); + } + return TRUE; +} + + +/*! + \fn bool TQWidget::close() + + Closes this widget. Returns TRUE if the widget was closed; + otherwise returns FALSE. + + First it sends the widget a TQCloseEvent. The widget is \link + hide() hidden\endlink if it \link TQCloseEvent::accept() + accepts\endlink the close event. The default implementation of + TQWidget::closeEvent() accepts the close event. + + The \l TQApplication::lastWindowClosed() signal is emitted when the + last visible top level widget is closed. + +*/ + +/*! + \property TQWidget::visible + \brief whether the widget is visible + + Calling show() sets the widget to visible status if all its parent + widgets up to the top-level widget are visible. If an ancestor is + not visible, the widget won't become visible until all its + ancestors are shown. + + Calling hide() hides a widget explicitly. An explicitly hidden + widget will never become visible, even if all its ancestors become + visible, unless you show it. + + A widget receives show and hide events when its visibility status + changes. Between a hide and a show event, there is no need to + waste CPU cycles preparing or displaying information to the user. + A video application, for example, might simply stop generating new + frames. + + A widget that happens to be obscured by other windows on the + screen is considered to be visible. The same applies to iconified + top-level widgets and windows that exist on another virtual + desktop (on platforms that support this concept). A widget + receives spontaneous show and hide events when its mapping status + is changed by the window system, e.g. a spontaneous hide event + when the user minimizes the window, and a spontaneous show event + when the window is restored again. + + \sa show(), hide(), isHidden(), isVisibleTo(), isMinimized(), + showEvent(), hideEvent() +*/ + + +/*! + Returns TRUE if this widget would become visible if \a ancestor is + shown; otherwise returns FALSE. + + The TRUE case occurs if neither the widget itself nor any parent + up to but excluding \a ancestor has been explicitly hidden. + + This function will still return TRUE if the widget is obscured by + other windows on the screen, but could be physically visible if it + or they were to be moved. + + isVisibleTo(0) is identical to isVisible(). + + \sa show() hide() isVisible() +*/ + +bool TQWidget::isVisibleTo(TQWidget* ancestor) const +{ + if ( !ancestor ) + return isVisible(); + const TQWidget * w = this; + while ( w + && w->isShown() + && !w->isTopLevel() + && w->parentWidget() + && w->parentWidget() != ancestor ) + w = w->parentWidget(); + return w->isShown(); +} + + +/*! + \fn bool TQWidget::isVisibleToTLW() const + \obsolete + + This function is deprecated. It is equivalent to isVisible() +*/ + +/*! + \property TQWidget::hidden + \brief whether the widget is explicitly hidden + + If FALSE, the widget is visible or would become visible if all its + ancestors became visible. + + \sa hide(), show(), isVisible(), isVisibleTo(), shown +*/ + +/*! + \property TQWidget::shown + \brief whether the widget is shown + + If TRUE, the widget is visible or would become visible if all its + ancestors became visible. + + \sa hide(), show(), isVisible(), isVisibleTo(), hidden +*/ + +/*! + \property TQWidget::visibleRect + \brief the visible rectangle + + \obsolete + + No longer necessary, you can simply call repaint(). If you do not + need the rectangle for repaint(), use clipRegion() instead. +*/ +TQRect TQWidget::visibleRect() const +{ + TQRect r = rect(); + const TQWidget * w = this; + int ox = 0; + int oy = 0; + while ( w + && w->isVisible() + && !w->isTopLevel() + && w->parentWidget() ) { + ox -= w->x(); + oy -= w->y(); + w = w->parentWidget(); + r = r.intersect( TQRect( ox, oy, w->width(), w->height() ) ); + } + if ( !w->isVisible() ) + return TQRect(); + return r; +} + +/*! + Returns the unobscured region where paint events can occur. + + For visible widgets, this is an approximation of the area not + covered by other widgets; otherwise, this is an empty region. + + The repaint() function calls this function if necessary, so in + general you do not need to call it. + +*/ +TQRegion TQWidget::clipRegion() const +{ + return visibleRect(); +} + + +/*! + Adjusts the size of the widget to fit the contents. + + Uses sizeHint() if valid (i.e if the size hint's width and height + are \>= 0), otherwise sets the size to the children rectangle (the + union of all child widget geometries). + + \sa sizeHint(), childrenRect() +*/ + +void TQWidget::adjustSize() +{ + TQApplication::sendPostedEvents( 0, TQEvent::ChildInserted ); + TQApplication::sendPostedEvents( 0, TQEvent::LayoutHint ); + if ( !testWState(WState_Polished) ) + polish(); + TQSize s = sizeHint(); + + if ( isTopLevel() ) { + +#if defined(TQ_WS_X11) + TQRect screen = TQApplication::desktop()->screenGeometry( x11Screen() ); +#else // all others + TQRect screen = TQApplication::desktop()->screenGeometry( pos() ); +#endif + +#ifndef TQT_NO_LAYOUT + if ( layout() ) { + if ( layout()->hasHeightForWidth() ) { + s = s.boundedTo( screen.size() ); + s.setHeight( layout()->totalHeightForWidth( s.width() ) ); + } + } else +#endif + { + if ( sizePolicy().hasHeightForWidth() ) { + s = s.boundedTo( screen.size() ); + s.setHeight( heightForWidth( s.width() ) ); + } + } + } + if ( s.isValid() ) { + resize( s ); + return; + } + TQRect r = childrenRect(); // get children rectangle + if ( r.isNull() ) // probably no widgets + return; + resize( r.width() + 2 * r.x(), r.height() + 2 * r.y() ); +} + + +/*! + \property TQWidget::sizeHint + \brief the recommended size for the widget + + If the value of this property is an invalid size, no size is + recommended. + + The default implementation of sizeHint() returns an invalid size + if there is no layout for this widget, and returns the layout's + preferred size otherwise. + + \sa TQSize::isValid(), minimumSizeHint(), sizePolicy(), + setMinimumSize(), updateGeometry() +*/ + +TQSize TQWidget::sizeHint() const +{ +#ifndef TQT_NO_LAYOUT + if ( layout() ) + return layout()->totalSizeHint(); +#endif + return TQSize( -1, -1 ); +} + +/*! + \property TQWidget::minimumSizeHint + \brief the recommended minimum size for the widget + + If the value of this property is an invalid size, no minimum size + is recommended. + + The default implementation of minimumSizeHint() returns an invalid + size if there is no layout for this widget, and returns the + layout's minimum size otherwise. Most built-in widgets reimplement + minimumSizeHint(). + + \l TQLayout will never resize a widget to a size smaller than + minimumSizeHint. + + \sa TQSize::isValid(), resize(), setMinimumSize(), sizePolicy() +*/ +TQSize TQWidget::minimumSizeHint() const +{ +#ifndef TQT_NO_LAYOUT + if ( layout() ) + return layout()->totalMinimumSize(); +#endif + return TQSize( -1, -1 ); +} + + +/*! + \fn TQWidget *TQWidget::parentWidget( bool sameWindow ) const + + Returns the parent of this widget, or 0 if it does not have any + parent widget. If \a sameWindow is TRUE and the widget is top + level returns 0; otherwise returns the widget's parent. +*/ + +/*! + \fn WFlags TQWidget::testWFlags( WFlags f ) const + + Returns the bitwise AND of the widget flags and \a f. + + Widget flags are a combination of \l{TQt::WidgetFlags}. + + If you want to test for the presence of multiple flags (or + composite flags such as \c WStyle_Splash), test the + return value for equality against the argument. For example: + + \code + int flags = WStyle_Tool | WStyle_NoBorder; + if ( testWFlags(flags) ) + ... // WStyle_Tool or WStyle_NoBorder or both are set + if ( testWFlags(flags) == flags ) + ... // both WStyle_Tool and WStyle_NoBorder are set + \endcode + + \sa getWFlags(), setWFlags(), clearWFlags() +*/ + +/*! + \fn WState TQWidget::testWState( WState s ) const + \internal + + Returns the bitwise AND of the widget states and \a s. +*/ + +/*! + \fn uint TQWidget::getWState() const + + \internal + + Returns the current widget state. +*/ +/*! + \fn void TQWidget::clearWState( uint n ) + + \internal + + Clears the widgets states \a n. +*/ +/*! + \fn void TQWidget::setWState( uint n ) + + \internal + + Sets the widgets states \a n. +*/ + + + +/***************************************************************************** + TQWidget event handling + *****************************************************************************/ + +/*! + This is the main event handler; it handles event \a e. You can + reimplement this function in a subclass, but we recommend using + one of the specialized event handlers instead. + + The main event handler first passes an event through all \link + TQObject::installEventFilter() event filters\endlink that have been + installed. If none of the filters intercept the event, it calls + one of the specialized event handlers. + + Key press and release events are treated differently from other + events. event() checks for Tab and Shift+Tab and tries to move the + focus appropriately. If there is no widget to move the focus to + (or the key press is not Tab or Shift+Tab), event() calls + keyPressEvent(). + + This function returns TRUE if it is able to pass the event over to + someone (i.e. someone wanted the event); otherwise returns FALSE. + + \sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), + keyPressEvent(), keyReleaseEvent(), leaveEvent(), + mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), + mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), + TQObject::event(), TQObject::timerEvent() +*/ + +bool TQWidget::event( TQEvent *e ) +{ + if ( TQObject::event( e ) ) + return TRUE; + + switch ( e->type() ) { + case TQEvent::MouseMove: + mouseMoveEvent( (TQMouseEvent*)e ); + if ( ! ((TQMouseEvent*)e)->isAccepted() ) + return FALSE; + break; + + case TQEvent::MouseButtonPress: + // Don't reset input context here. Whether reset or not is + // a responsibility of input method. reset() will be + // called by mouseHandler() of input method if necessary + // via mousePressEvent() of text widgets. +#if 0 + resetInputContext(); +#endif + mousePressEvent( (TQMouseEvent*)e ); + if ( ! ((TQMouseEvent*)e)->isAccepted() ) + return FALSE; + break; + + case TQEvent::MouseButtonRelease: + mouseReleaseEvent( (TQMouseEvent*)e ); + if ( ! ((TQMouseEvent*)e)->isAccepted() ) + return FALSE; + break; + + case TQEvent::MouseButtonDblClick: + mouseDoubleClickEvent( (TQMouseEvent*)e ); + if ( ! ((TQMouseEvent*)e)->isAccepted() ) + return FALSE; + break; +#ifndef TQT_NO_WHEELEVENT + case TQEvent::Wheel: + wheelEvent( (TQWheelEvent*)e ); + if ( ! ((TQWheelEvent*)e)->isAccepted() ) + return FALSE; + break; +#endif + case TQEvent::TabletMove: + case TQEvent::TabletPress: + case TQEvent::TabletRelease: + tabletEvent( (TQTabletEvent*)e ); + if ( ! ((TQTabletEvent*)e)->isAccepted() ) + return FALSE; + break; + case TQEvent::Accel: + ((TQKeyEvent*)e)->ignore(); + return FALSE; + case TQEvent::KeyPress: { + TQKeyEvent *k = (TQKeyEvent *)e; + bool res = FALSE; + if ( !(k->state() & ControlButton || k->state() & AltButton) ) { + if ( k->key() == Key_Backtab || + (k->key() == Key_Tab && + (k->state() & ShiftButton)) ) { + TQFocusEvent::setReason( TQFocusEvent::Backtab ); + res = focusNextPrevChild( FALSE ); + TQFocusEvent::resetReason(); + + } else if ( k->key() == Key_Tab ) { + TQFocusEvent::setReason( TQFocusEvent::Tab ); + res = focusNextPrevChild( TRUE ); + TQFocusEvent::resetReason(); + } + if ( res ) + break; + } + keyPressEvent( k ); + if ( !k->isAccepted() ) + return FALSE; + } + break; + + case TQEvent::KeyRelease: + keyReleaseEvent( (TQKeyEvent*)e ); + if ( ! ((TQKeyEvent*)e)->isAccepted() ) + return FALSE; + break; + + case TQEvent::IMStart: { + TQIMEvent *i = (TQIMEvent *) e; + imStartEvent(i); + if (! i->isAccepted()) + return FALSE; + } + break; + + case TQEvent::IMCompose: { + TQIMEvent *i = (TQIMEvent *) e; + imComposeEvent(i); + if (! i->isAccepted()) + return FALSE; + } + break; + + case TQEvent::IMEnd: { + TQIMEvent *i = (TQIMEvent *) e; + imEndEvent(i); + if (! i->isAccepted()) + return FALSE; + } + break; + + case TQEvent::FocusIn: + focusInEvent( (TQFocusEvent*)e ); + setFontSys(); + break; + + case TQEvent::FocusOut: + focusOutEvent( (TQFocusEvent*)e ); + break; + + case TQEvent::Enter: + enterEvent( e ); + break; + + case TQEvent::Leave: + leaveEvent( e ); + break; + + case TQEvent::Paint: + // At this point the event has to be delivered, regardless + // whether the widget isVisible() or not because it + // already went through the filters + paintEvent( (TQPaintEvent*)e ); + break; + + case TQEvent::Move: + moveEvent( (TQMoveEvent*)e ); + break; + + case TQEvent::Resize: + resizeEvent( (TQResizeEvent*)e ); + break; + + case TQEvent::Close: { + TQCloseEvent *c = (TQCloseEvent *)e; + closeEvent( c ); + if ( !c->isAccepted() ) + return FALSE; + } + break; + + case TQEvent::ContextMenu: { + TQContextMenuEvent *c = (TQContextMenuEvent *)e; + contextMenuEvent( c ); + if ( !c->isAccepted() ) + return FALSE; + } + break; + +#ifndef TQT_NO_DRAGANDDROP + case TQEvent::Drop: + dropEvent( (TQDropEvent*) e); + break; + + case TQEvent::DragEnter: + dragEnterEvent( (TQDragEnterEvent*) e); + break; + + case TQEvent::DragMove: + dragMoveEvent( (TQDragMoveEvent*) e); + break; + + case TQEvent::DragLeave: + dragLeaveEvent( (TQDragLeaveEvent*) e); + break; +#endif + + case TQEvent::Show: + showEvent( (TQShowEvent*) e); + break; + + case TQEvent::Hide: + hideEvent( (TQHideEvent*) e); + break; + + case TQEvent::ShowWindowRequest: + if ( isShown() ) + showWindow(); + break; + + case TQEvent::ParentFontChange: + if ( isTopLevel() ) + break; + // fall through + case TQEvent::ApplicationFontChange: + if ( own_font ) + setFont( fnt.resolve( qt_naturalWidgetFont( this ) ) ); + else + unsetFont(); + break; + +#ifndef TQT_NO_PALETTE + case TQEvent::ParentPaletteChange: + if ( isTopLevel() ) + break; + // fall through + case TQEvent::ApplicationPaletteChange: + if ( !own_palette && !isDesktop() ) + unsetPalette(); +# if defined(TQ_WS_QWS) && !defined (TQT_NO_QWS_MANAGER) + if ( isTopLevel() && topData()->qwsManager ) { + TQRegion r( topData()->qwsManager->region() ); + TQApplication::postEvent(topData()->qwsManager, new TQPaintEvent(r, FALSE) ); + } +# endif + break; +#endif + + case TQEvent::WindowActivate: + case TQEvent::WindowDeactivate: + windowActivationChange( e->type() != TQEvent::WindowActivate ); + if ( children() ) { + TQObjectListIt it( *children() ); + TQObject *o; + while( ( o = it.current() ) != 0 ) { + ++it; + if ( o->isWidgetType() && + ((TQWidget*)o)->isVisible() && + !((TQWidget*)o)->isTopLevel() ) + TQApplication::sendEvent( o, e ); + } + } + break; + + case TQEvent::LanguageChange: + case TQEvent::LocaleChange: + if ( children() ) { + TQObjectListIt it( *children() ); + TQObject *o; + while( ( o = it.current() ) != 0 ) { + ++it; + TQApplication::sendEvent( o, e ); + } + } + if ( e->type() == TQEvent::LanguageChange ) { + int index = metaObject()->findSlot( "languageChange()", TRUE ); + if ( index >= 0 ) + tqt_invoke( index, 0 ); + } + update(); + break; +#ifndef TQT_NO_LAYOUT + case TQEvent::LayoutDirectionChange: + if ( layout() ) { + layout()->activate(); + } else { + TQObjectList* llist = queryList( "TQLayout", 0, TRUE, TRUE ); + TQObjectListIt lit( *llist ); + TQLayout *lay; + while ( ( lay = (TQLayout*)lit.current() ) != 0 ) { + ++lit; + lay->activate(); + } + delete llist; + } + update(); + break; +#endif + + case TQEvent::WindowStateChange: + { + TQEvent::Type type; + if (isMinimized()) + type = TQEvent::ShowMinimized; + else if (isFullScreen()) + type = TQEvent::ShowFullScreen; + else if (isMaximized()) + type = TQEvent::ShowMaximized; + else + type = TQEvent::ShowNormal; + + TQApplication::postEvent(this, new TQEvent(type)); + break; + } + + case TQEvent::WindowBlocked: + case TQEvent::WindowUnblocked: + if ( children() ) { + TQObjectListIt it( *children() ); + TQObject *o; + while( ( o = it.current() ) != 0 ) { + ++it; + TQWidget *w = ::tqt_cast(o); + if (w && !w->testWFlags(TQt::WShowModal)) + TQApplication::sendEvent( o, e ); + } + } + break; + + default: + return FALSE; + } + return TRUE; +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive mouse move events for the widget. + + If mouse tracking is switched off, mouse move events only occur if + a mouse button is pressed while the mouse is being moved. If mouse + tracking is switched on, mouse move events occur even if no mouse + button is pressed. + + TQMouseEvent::pos() reports the position of the mouse cursor, + relative to this widget. For press and release events, the + position is usually the same as the position of the last mouse + move event, but it might be different if the user's hand shakes. + This is a feature of the underlying window system, not TQt. + + \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), + mouseDoubleClickEvent(), event(), TQMouseEvent +*/ + +void TQWidget::mouseMoveEvent( TQMouseEvent * e) +{ + e->ignore(); +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive mouse press events for the widget. + + If you create new widgets in the mousePressEvent() the + mouseReleaseEvent() may not end up where you expect, depending on + the underlying window system (or X11 window manager), the widgets' + location and maybe more. + + The default implementation implements the closing of popup widgets + when you click outside the window. For other widget types it does + nothing. + + \sa mouseReleaseEvent(), mouseDoubleClickEvent(), + mouseMoveEvent(), event(), TQMouseEvent +*/ + +void TQWidget::mousePressEvent( TQMouseEvent *e ) +{ + e->ignore(); + if ( isPopup() ) { + e->accept(); + TQWidget* w; + while ( (w = tqApp->activePopupWidget() ) && w != this ){ + w->close(); + if (tqApp->activePopupWidget() == w) // widget does not want to dissappear + w->hide(); // hide at least + } + if (!rect().contains(e->pos()) ){ + close(); + } + } +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive mouse release events for the widget. + + \sa mouseReleaseEvent(), mouseDoubleClickEvent(), + mouseMoveEvent(), event(), TQMouseEvent +*/ + +void TQWidget::mouseReleaseEvent( TQMouseEvent * e ) +{ + e->ignore(); +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive mouse double click events for the widget. + + The default implementation generates a normal mouse press event. + + Note that the widgets gets a mousePressEvent() and a + mouseReleaseEvent() before the mouseDoubleClickEvent(). + + \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), + event(), TQMouseEvent +*/ + +void TQWidget::mouseDoubleClickEvent( TQMouseEvent *e ) +{ + mousePressEvent( e ); // try mouse press event +} + +#ifndef TQT_NO_WHEELEVENT +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive wheel events for the widget. + + If you reimplement this handler, it is very important that you + \link TQWheelEvent ignore()\endlink the event if you do not handle + it, so that the widget's parent can interpret it. + + The default implementation ignores the event. + + \sa TQWheelEvent::ignore(), TQWheelEvent::accept(), event(), + TQWheelEvent +*/ + +void TQWidget::wheelEvent( TQWheelEvent *e ) +{ + e->ignore(); +} +#endif + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive tablet events for the widget. + + If you reimplement this handler, it is very important that you + \link TQTabletEvent ignore()\endlink the event if you do not handle + it, so that the widget's parent can interpret it. + + The default implementation ignores the event. + + \sa TQTabletEvent::ignore(), TQTabletEvent::accept(), event(), + TQTabletEvent +*/ + +void TQWidget::tabletEvent( TQTabletEvent *e ) +{ + e->ignore(); +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive key press events for the widget. + + A widget must call setFocusPolicy() to accept focus initially and + have focus in order to receive a key press event. + + If you reimplement this handler, it is very important that you + explicitly \link TQKeyEvent::ignore() ignore\endlink the event + if you do not understand it, so that the widget's parent can + interpret it; otherwise, the event will be implicitly accepted. + Although top-level widgets are able to choose whether to accept + or ignore unknown events because they have no parent widgets that + could otherwise handle them, it is good practice to explicitly + ignore events to make widgets as reusable as possible. + + The default implementation closes popup widgets if the user + presses Esc. Otherwise the event is ignored. + + \sa keyReleaseEvent(), TQKeyEvent::ignore(), setFocusPolicy(), + focusInEvent(), focusOutEvent(), event(), TQKeyEvent +*/ + +void TQWidget::keyPressEvent( TQKeyEvent *e ) +{ + if ( isPopup() && e->key() == Key_Escape ) { + e->accept(); + close(); + } else { + e->ignore(); + } +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive key release events for the widget. + + A widget must \link setFocusPolicy() accept focus\endlink + initially and \link hasFocus() have focus\endlink in order to + receive a key release event. + + If you reimplement this handler, it is very important that you + \link TQKeyEvent ignore()\endlink the release if you do not + understand it, so that the widget's parent can interpret it. + + The default implementation ignores the event. + + \sa keyPressEvent(), TQKeyEvent::ignore(), setFocusPolicy(), + focusInEvent(), focusOutEvent(), event(), TQKeyEvent +*/ + +void TQWidget::keyReleaseEvent( TQKeyEvent *e ) +{ + e->ignore(); +} + +/*! + This event handler can be reimplemented in a subclass to receive + keyboard focus events (focus received) for the widget. + + A widget normally must setFocusPolicy() to something other than + \c NoFocus in order to receive focus events. (Note that the + application programmer can call setFocus() on any widget, even + those that do not normally accept focus.) + + The default implementation updates the widget (except for toplevel + widgets that do not specify a focusPolicy() ). It also calls + setMicroFocusHint(), hinting any system-specific input tools about + the focus of the user's attention. + + \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(), + keyReleaseEvent(), event(), TQFocusEvent +*/ + +void TQWidget::focusInEvent( TQFocusEvent * ) +{ + if ( focusPolicy() != NoFocus || !isTopLevel() ) { + update(); + if ( testWState(WState_AutoMask) ) + updateMask(); + setMicroFocusHint(width()/2, 0, 1, height(), FALSE); + } +} + +/*! + This event handler can be reimplemented in a subclass to receive + keyboard focus events (focus lost) for the widget. + + A widget normally must setFocusPolicy() to something other than + \c NoFocus in order to receive focus events. (Note that the + application programmer can call setFocus() on any widget, even + those that do not normally accept focus.) + + The default implementation updates the widget (except for toplevel + widgets that do not specify a focusPolicy() ). It also calls + setMicroFocusHint(), hinting any system-specific input tools about + the focus of the user's attention. + + \sa focusInEvent(), setFocusPolicy(), keyPressEvent(), + keyReleaseEvent(), event(), TQFocusEvent +*/ + +void TQWidget::focusOutEvent( TQFocusEvent * ) +{ + if ( focusPolicy() != NoFocus || !isTopLevel() ){ + update(); + if ( testWState(WState_AutoMask) ) + updateMask(); + } +} + +/*! + \property TQWidget::microFocusHint + \brief the currently set micro focus hint for this widget. + + See the documentation of setMicroFocusHint() for more information. +*/ +TQRect TQWidget::microFocusHint() const +{ + if ( !extra || extra->micro_focus_hint.isEmpty() ) + return TQRect(width()/2, 0, 1, height() ); + else + return extra->micro_focus_hint; +} + +/*! + This event handler can be reimplemented in a subclass to receive + widget enter events. + + An event is sent to the widget when the mouse cursor enters the + widget. + + \sa leaveEvent(), mouseMoveEvent(), event() +*/ + +void TQWidget::enterEvent( TQEvent * ) +{ +} + +/*! + This event handler can be reimplemented in a subclass to receive + widget leave events. + + A leave event is sent to the widget when the mouse cursor leaves + the widget. + + \sa enterEvent(), mouseMoveEvent(), event() +*/ + +void TQWidget::leaveEvent( TQEvent * ) +{ +} + +/*! + This event handler can be reimplemented in a subclass to receive + paint events. + + A paint event is a request to repaint all or part of the widget. + It can happen as a result of repaint() or update(), or because the + widget was obscured and has now been uncovered, or for many other + reasons. + + Many widgets can simply repaint their entire surface when asked + to, but some slow widgets need to optimize by painting only the + requested region: TQPaintEvent::region(). This speed optimization + does not change the result, as painting is clipped to that region + during event processing. TQListView and TQCanvas do this, for + example. + + TQt also tries to speed up painting by merging multiple paint + events into one. When update() is called several times or the + window system sends several paint events, TQt merges these events + into one event with a larger region (see TQRegion::unite()). + repaint() does not permit this optimization, so we suggest using + update() when possible. + + When the paint event occurs, the update region has normally been + erased, so that you're painting on the widget's background. There + are a couple of exceptions and TQPaintEvent::erased() tells you + whether the widget has been erased or not. + + The background can be set using setBackgroundMode(), + setPaletteBackgroundColor() or setBackgroundPixmap(). The + documentation for setBackgroundMode() elaborates on the + background; we recommend reading it. + + \sa event(), repaint(), update(), TQPainter, TQPixmap, TQPaintEvent +*/ + +void TQWidget::paintEvent( TQPaintEvent * ) +{ +} + + +/*! + This event handler can be reimplemented in a subclass to receive + widget move events. When the widget receives this event, it is + already at the new position. + + The old position is accessible through TQMoveEvent::oldPos(). + + \sa resizeEvent(), event(), move(), TQMoveEvent +*/ + +void TQWidget::moveEvent( TQMoveEvent * ) +{ +} + + +/*! + This event handler can be reimplemented in a subclass to receive + widget resize events. When resizeEvent() is called, the widget + already has its new geometry. The old size is accessible through + TQResizeEvent::oldSize(). + + The widget will be erased and receive a paint event immediately + after processing the resize event. No drawing need be (or should + be) done inside this handler. + + Widgets that have been created with the \c WNoAutoErase flag + will not be erased. Nevertheless, they will receive a paint event + for their entire area afterwards. Again, no drawing needs to be + done inside this handler. + + The default implementation calls updateMask() if the widget has + \link TQWidget::setAutoMask() automatic masking\endlink enabled. + + \sa moveEvent(), event(), resize(), TQResizeEvent, paintEvent() +*/ + +void TQWidget::resizeEvent( TQResizeEvent * ) +{ + if ( testWState(WState_AutoMask) ) + updateMask(); +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive widget close events. + + The default implementation calls e->accept(), which hides this + widget. See the \l TQCloseEvent documentation for more details. + + \sa event(), hide(), close(), TQCloseEvent +*/ + +void TQWidget::closeEvent( TQCloseEvent *e ) +{ + e->accept(); +} + + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive widget context menu events. + + The default implementation calls e->ignore(), which rejects the + context event. See the \l TQContextMenuEvent documentation for + more details. + + \sa event(), TQContextMenuEvent +*/ + +void TQWidget::contextMenuEvent( TQContextMenuEvent *e ) +{ + e->ignore(); +} + + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive Input Method composition events. This handler + is called when the user begins entering text using an Input Method. + + The default implementation calls e->ignore(), which rejects the + Input Method event. See the \l TQIMEvent documentation for more + details. + + \sa event(), TQIMEvent +*/ +void TQWidget::imStartEvent( TQIMEvent *e ) +{ + e->ignore(); +} + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive Input Method composition events. This handler + is called when the user has entered some text using an Input Method. + + The default implementation calls e->ignore(), which rejects the + Input Method event. See the \l TQIMEvent documentation for more + details. + + \sa event(), TQIMEvent +*/ +void TQWidget::imComposeEvent( TQIMEvent *e ) +{ + e->ignore(); +} + + +/*! + This event handler, for event \a e, can be reimplemented in a + subclass to receive Input Method composition events. This handler + is called when the user has finished inputting text via an Input + Method. + + The default implementation calls e->ignore(), which rejects the + Input Method event. See the \l TQIMEvent documentation for more + details. + + \sa event(), TQIMEvent +*/ +void TQWidget::imEndEvent( TQIMEvent *e ) +{ + e->ignore(); +} + + +#ifndef TQT_NO_DRAGANDDROP + +/*! + This event handler is called when a drag is in progress and the + mouse enters this widget. + + See the \link dnd.html Drag-and-drop documentation\endlink for an + overview of how to provide drag-and-drop in your application. + + \sa TQTextDrag, TQImageDrag, TQDragEnterEvent +*/ +void TQWidget::dragEnterEvent( TQDragEnterEvent * ) +{ +} + +/*! + This event handler is called when a drag is in progress and the + mouse enters this widget, and whenever it moves within the widget. + + See the \link dnd.html Drag-and-drop documentation\endlink for an + overview of how to provide drag-and-drop in your application. + + \sa TQTextDrag, TQImageDrag, TQDragMoveEvent +*/ +void TQWidget::dragMoveEvent( TQDragMoveEvent * ) +{ +} + +/*! + This event handler is called when a drag is in progress and the + mouse leaves this widget. + + See the \link dnd.html Drag-and-drop documentation\endlink for an + overview of how to provide drag-and-drop in your application. + + \sa TQTextDrag, TQImageDrag, TQDragLeaveEvent +*/ +void TQWidget::dragLeaveEvent( TQDragLeaveEvent * ) +{ +} + +/*! + This event handler is called when the drag is dropped on this + widget. + + See the \link dnd.html Drag-and-drop documentation\endlink for an + overview of how to provide drag-and-drop in your application. + + \sa TQTextDrag, TQImageDrag, TQDropEvent +*/ +void TQWidget::dropEvent( TQDropEvent * ) +{ +} + +#endif // TQT_NO_DRAGANDDROP + +/*! + This event handler can be reimplemented in a subclass to receive + widget show events. + + Non-spontaneous show events are sent to widgets immediately before + they are shown. The spontaneous show events of top-level widgets + are delivered afterwards. + + \sa event(), TQShowEvent +*/ +void TQWidget::showEvent( TQShowEvent * ) +{ +} + +/*! + This event handler can be reimplemented in a subclass to receive + widget hide events. + + Hide events are sent to widgets immediately after they have been + hidden. + + \sa event(), TQHideEvent +*/ +void TQWidget::hideEvent( TQHideEvent * ) +{ +} + +/* + \fn TQWidget::x11Event( MSG * ) + + This special event handler can be reimplemented in a subclass to + receive native X11 events. + + In your reimplementation of this function, if you want to stop the + event being handled by TQt, return TRUE. If you return FALSE, this + native event is passed back to TQt, which translates the event into + a TQt event and sends it to the widget. + + \warning This function is not portable. + + \sa TQApplication::x11EventFilter() +*/ + + +#if defined(TQ_WS_MAC) + +/*! + This special event handler can be reimplemented in a subclass to + receive native Macintosh events. + + In your reimplementation of this function, if you want to stop the + event being handled by TQt, return TRUE. If you return FALSE, this + native event is passed back to TQt, which translates the event into + a TQt event and sends it to the widget. + + \warning This function is not portable. + + \sa TQApplication::macEventFilter() +*/ + +bool TQWidget::macEvent( MSG * ) +{ + return FALSE; +} + +#endif +#if defined(TQ_WS_WIN) + +/*! + This special event handler can be reimplemented in a subclass to + receive native Windows events. + + In your reimplementation of this function, if you want to stop the + event being handled by TQt, return TRUE. If you return FALSE, this + native event is passed back to TQt, which translates the event into + a TQt event and sends it to the widget. + + \warning This function is not portable. + + \sa TQApplication::winEventFilter() +*/ +bool TQWidget::winEvent( MSG * ) +{ + return FALSE; +} + +#endif +#if defined(TQ_WS_X11) + +/*! + This special event handler can be reimplemented in a subclass to + receive native X11 events. + + In your reimplementation of this function, if you want to stop the + event being handled by TQt, return TRUE. If you return FALSE, this + native event is passed back to TQt, which translates the event into + a TQt event and sends it to the widget. + + \warning This function is not portable. + + \sa TQApplication::x11EventFilter() +*/ +bool TQWidget::x11Event( XEvent * ) +{ + return FALSE; +} + +#endif +#if defined(TQ_WS_QWS) + +/*! + This special event handler can be reimplemented in a subclass to + receive native TQt/Embedded events. + + In your reimplementation of this function, if you want to stop the + event being handled by TQt, return TRUE. If you return FALSE, this + native event is passed back to TQt, which translates the event into + a TQt event and sends it to the widget. + + \warning This function is not portable. + + \sa TQApplication::qwsEventFilter() +*/ +bool TQWidget::qwsEvent( TQWSEvent * ) +{ + return FALSE; +} + +#endif + +/*! + \property TQWidget::autoMask + \brief whether the auto mask feature is enabled for the widget + + Transparent widgets use a mask to define their visible region. + TQWidget has some built-in support to make the task of + recalculating the mask easier. When setting auto mask to TRUE, + updateMask() will be called whenever the widget is resized or + changes its focus state. Note that you must reimplement + updateMask() (which should include a call to setMask()) or nothing + will happen. + + Note: when you re-implement resizeEvent(), focusInEvent() or + focusOutEvent() in your custom widgets and still want to ensure + that the auto mask calculation works, you should add: + + \code + if ( autoMask() ) + updateMask(); + \endcode + + at the end of your event handlers. This is true for all member + functions that change the appearance of the widget in a way that + requires a recalculation of the mask. + + While being a technically appealing concept, masks have a big + drawback: when using complex masks that cannot be expressed easily + with relatively simple regions, they can be very slow on some + window systems. The classic example is a transparent label. The + complex shape of its contents makes it necessary to represent its + mask by a bitmap, which consumes both memory and time. If all you + want is to blend the background of several neighboring widgets + together seamlessly, you will probably want to use + setBackgroundOrigin() rather than a mask. + + \sa autoMask() updateMask() setMask() clearMask() setBackgroundOrigin() +*/ + +bool TQWidget::autoMask() const +{ + return testWState(WState_AutoMask); +} + +void TQWidget::setAutoMask( bool enable ) +{ + if ( enable == autoMask() ) + return; + + if ( enable ) { + setWState(WState_AutoMask); + updateMask(); + } else { + clearWState(WState_AutoMask); + clearMask(); + } +} + +/*! + \enum TQWidget::BackgroundOrigin + + This enum defines the origin used to draw a widget's background + pixmap. + + The pixmap is drawn using the: + \value WidgetOrigin widget's coordinate system. + \value ParentOrigin parent's coordinate system. + \value WindowOrigin top-level window's coordinate system. + \value AncestorOrigin same origin as the parent uses. +*/ + +/*! + \property TQWidget::backgroundOrigin + \brief the origin of the widget's background + + The origin is either WidgetOrigin (the default), ParentOrigin, + WindowOrigin or AncestorOrigin. + + This only makes a difference if the widget has a background + pixmap, in which case positioning matters. Using \c WindowOrigin + for several neighboring widgets makes the background blend + together seamlessly. \c AncestorOrigin allows blending backgrounds + seamlessly when an ancestor of the widget has an origin other than + \c WindowOrigin. + + \sa backgroundPixmap(), setBackgroundMode() +*/ +TQWidget::BackgroundOrigin TQWidget::backgroundOrigin() const +{ + return extra ? (BackgroundOrigin)extra->bg_origin : WidgetOrigin; +} + +void TQWidget::setBackgroundOrigin( BackgroundOrigin origin ) +{ + if ( origin == backgroundOrigin() ) + return; + createExtra(); + extra->bg_origin = origin; + update(); +} + +/*! + This function can be reimplemented in a subclass to support + transparent widgets. It should be called whenever a widget changes + state in a way that means that the shape mask must be recalculated. + + \sa setAutoMask(), updateMask(), setMask(), clearMask() +*/ +void TQWidget::updateMask() +{ +} + +/*! + \internal + Returns the offset of the widget from the backgroundOrigin. + + \sa setBackgroundMode(), backgroundMode(), +*/ +TQPoint TQWidget::backgroundOffset() const +{ + if (!isTopLevel()) { + switch(backgroundOrigin()) { + case WidgetOrigin: + break; + case ParentOrigin: + return pos(); + case WindowOrigin: + { + const TQWidget *topl = this; + while(topl && !topl->isTopLevel() && !topl->testWFlags(TQt::WSubWindow)) + topl = topl->parentWidget(TRUE); + return mapTo((TQWidget *)topl, TQPoint(0, 0) ); + } + case AncestorOrigin: + { + const TQWidget *topl = this; + bool ancestorIsWindowOrigin = FALSE; + while(topl && !topl->isTopLevel() && !topl->testWFlags(TQt::WSubWindow)) + { + if (!ancestorIsWindowOrigin) { + if (topl->backgroundOrigin() == TQWidget::WidgetOrigin) + break; + if (topl->backgroundOrigin() == TQWidget::ParentOrigin) + { + topl = topl->parentWidget(TRUE); + break; + } + if (topl->backgroundOrigin() == TQWidget::WindowOrigin) + ancestorIsWindowOrigin = TRUE; + } + topl = topl->parentWidget(TRUE); + } + + return mapTo((TQWidget *) topl, TQPoint(0,0) ); + } + } + } + // fall back + return TQPoint(0,0); +} + +/*! + \fn TQLayout* TQWidget::layout () const + + Returns the layout engine that manages the geometry of this + widget's children. + + If the widget does not have a layout, layout() returns 0. + + \sa sizePolicy() +*/ + + +/* Sets this widget to use layout \a l to manage the geometry of its + children. + + If the widget already had a layout, the old layout is + forgotten. (Note that it is not deleted.) + + \sa layout() TQLayout sizePolicy() +*/ +#ifndef TQT_NO_LAYOUT +void TQWidget::setLayout( TQLayout *l ) +{ + lay_out = l; +} +#endif + +/*! + \property TQWidget::sizePolicy + \brief the default layout behavior of the widget + + If there is a TQLayout that manages this widget's children, the + size policy specified by that layout is used. If there is no such + TQLayout, the result of this function is used. + + The default policy is Preferred/Preferred, which means that the + widget can be freely resized, but prefers to be the size + sizeHint() returns. Button-like widgets set the size policy to + specify that they may stretch horizontally, but are fixed + vertically. The same applies to lineedit controls (such as + TQLineEdit, TQSpinBox or an editable TQComboBox) and other + horizontally orientated widgets (such as TQProgressBar). + TQToolButton's are normally square, so they allow growth in both + directions. Widgets that support different directions (such as + TQSlider, TQScrollBar or TQHeader) specify stretching in the + respective direction only. Widgets that can provide scrollbars + (usually subclasses of TQScrollView) tend to specify that they can + use additional space, and that they can make do with less than + sizeHint(). + + \sa sizeHint() TQLayout TQSizePolicy updateGeometry() +*/ +TQSizePolicy TQWidget::sizePolicy() const +{ + return extra ? extra->size_policy + : TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ); +} + +void TQWidget::setSizePolicy( TQSizePolicy policy ) +{ + setWState( WState_OwnSizePolicy ); + if ( policy == sizePolicy() ) + return; + createExtra(); + extra->size_policy = policy; + updateGeometry(); +} + +/*! + \overload void TQWidget::setSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw ) + + Sets the size policy of the widget to \a hor, \a ver and \a hfw + (height for width). + + \sa TQSizePolicy::TQSizePolicy() +*/ + +/*! + Returns the preferred height for this widget, given the width \a + w. The default implementation returns 0, indicating that the + preferred height does not depend on the width. + + \warning Does not look at the widget's layout. +*/ + +int TQWidget::heightForWidth( int w ) const +{ + (void)w; + return 0; +} + +/*! + \property TQWidget::customWhatsThis + \brief whether the widget wants to handle What's This help manually + + The default implementation of customWhatsThis() returns FALSE, + which means the widget will not receive any events in Whats This + mode. + + The widget may leave What's This mode by calling + TQWhatsThis::leaveWhatsThisMode(), with or without actually + displaying any help text. + + You can also reimplement customWhatsThis() if your widget is a + "passive interactor" supposed to work under all circumstances. + Simply don't call TQWhatsThis::leaveWhatsThisMode() in that case. + + \sa TQWhatsThis::inWhatsThisMode() TQWhatsThis::leaveWhatsThisMode() +*/ +bool TQWidget::customWhatsThis() const +{ + return FALSE; +} + +/*! + Returns the visible child widget at pixel position \a (x, y) in + the widget's own coordinate system. + + If \a includeThis is TRUE, and there is no child visible at \a (x, + y), the widget itself is returned. +*/ +TQWidget *TQWidget::childAt( int x, int y, bool includeThis ) const +{ + if ( !rect().contains( x, y ) ) + return 0; + if ( children() ) { + TQObjectListIt it( *children() ); + it.toLast(); + TQWidget *w, *t; + while( (w=(TQWidget *)it.current()) != 0 ) { + --it; + if ( w->isWidgetType() && !w->isTopLevel() && !w->isHidden() ) { + if ( ( t = w->childAt( x - w->x(), y - w->y(), TRUE ) ) ) + return t; + } + } + } + if ( includeThis ) + return (TQWidget*)this; + return 0; +} + +/*! + \overload + + Returns the visible child widget at point \a p in the widget's own + coordinate system. + + If \a includeThis is TRUE, and there is no child visible at \a p, + the widget itself is returned. + +*/ +TQWidget *TQWidget::childAt( const TQPoint & p, bool includeThis ) const +{ + return childAt( p.x(), p.y(), includeThis ); +} + + +/*! + Notifies the layout system that this widget has changed and may + need to change geometry. + + Call this function if the sizeHint() or sizePolicy() have changed. + + For explicitly hidden widgets, updateGeometry() is a no-op. The + layout system will be notified as soon as the widget is shown. +*/ + +void TQWidget::updateGeometry() +{ + TQWidget *parent = parentWidget(); + if (parent && !isTopLevel() && isShown()) + TQApplication::postEvent(parent, new TQEvent(TQEvent::LayoutHint)); +} + + +/*! + Reparents the widget. The widget gets a new \a parent, new widget + flags (\a f, but as usual, use 0) at a new position in its new + parent (\a p). + + If \a showIt is TRUE, show() is called once the widget has been + reparented. + + If the new parent widget is in a different top-level widget, the + reparented widget and its children are appended to the end of the + \link setFocusPolicy() tab chain \endlink of the new parent + widget, in the same internal order as before. If one of the moved + widgets had keyboard focus, reparent() calls clearFocus() for that + widget. + + If the new parent widget is in the same top-level widget as the + old parent, reparent doesn't change the tab order or keyboard + focus. + + \warning It is extremely unlikely that you will ever need this + function. If you have a widget that changes its content + dynamically, it is far easier to use \l TQWidgetStack or \l + TQWizard. + + \sa getWFlags() +*/ + +void TQWidget::reparent( TQWidget *parent, WFlags f, const TQPoint &p, + bool showIt ) +{ + reparentSys( parent, f, p, showIt ); + TQEvent e( TQEvent::Reparent ); + TQApplication::sendEvent( this, &e ); + if (!own_font) + unsetFont(); + else + setFont( fnt.resolve( qt_naturalWidgetFont( this ) ) ); +#ifndef TQT_NO_PALETTE + if (!own_palette) + unsetPalette(); +#endif +} + +/*! + \overload + + A convenience version of reparent that does not take widget flags + as argument. + + Calls reparent(\a parent, getWFlags() \& ~\l WType_Mask, \a p, \a + showIt). +*/ +void TQWidget::reparent( TQWidget *parent, const TQPoint & p, + bool showIt ) +{ + reparent( parent, getWFlags() & ~WType_Mask, p, showIt ); +} + +/*! + \property TQWidget::ownCursor + \brief whether the widget uses its own cursor + + If FALSE, the widget uses its parent widget's cursor. + + \sa cursor +*/ + +/*! + \property TQWidget::ownFont + \brief whether the widget uses its own font + + If FALSE, the widget uses its parent widget's font. + + \sa font +*/ + +/*! + \property TQWidget::ownPalette + \brief whether the widget uses its own palette + + If FALSE, the widget uses its parent widget's palette. + + \sa palette +*/ + + +void TQWidget::repaint( bool erase ) +{ + repaint( visibleRect(), erase ); +} + + + + +/*!\obsolete Use paletteBackgroundColor() or eraseColor() instead. */ +const TQColor & TQWidget::backgroundColor() const { return eraseColor(); } +/*!\obsolete Use setPaletteBackgroundColor() or setEraseColor() instead. */ +void TQWidget::setBackgroundColor( const TQColor &c ) { setEraseColor( c ); } +/*!\obsolete Use paletteBackgroundPixmap() or erasePixmap() instead. */ +const TQPixmap *TQWidget::backgroundPixmap() const { return erasePixmap(); } +/*!\obsolete Use setPaletteBackgroundPixmap() or setErasePixmap() instead. */ +void TQWidget::setBackgroundPixmap( const TQPixmap &pm ) { setErasePixmap( pm ); } + + +// documentation in qdesktopwidget_win.cpp +void TQDesktopWidget::insertChild( TQObject *obj ) +{ + if ( obj->isWidgetType() ) + return; + TQWidget::insertChild( obj ); +} + +/*! + \property TQWidget::windowOpacity + + \brief The level of opacity for the window. + + The valid range of opacity is from 1.0 (completely opaque) to + 0.0 (completely transparent). + + By default the value of this property is 1.0. + + This feature is only present on Mac OS X and Windows 2000 and up. + + \warning Changing this property from opaque to transparent might issue a + paint event that needs to be processed before the window is displayed + correctly. This affects mainly the use of TQPixmap::grabWindow(). Also note + that semi-transparent windows update and resize significantely slower than + opaque windows. +*/ diff --git a/src/kernel/tqwidget.h b/src/kernel/tqwidget.h new file mode 100644 index 000000000..d328dd95d --- /dev/null +++ b/src/kernel/tqwidget.h @@ -0,0 +1,1096 @@ +/**************************************************************************** +** +** Definition of TQWidget class +** +** Created : 931029 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQWIDGET_H +#define TQWIDGET_H + +#ifndef QT_H +#include "ntqwindowdefs.h" +#include "tqobject.h" +#include "ntqpaintdevice.h" +#include "ntqpalette.h" +#include "ntqfont.h" +#include "ntqfontmetrics.h" +#include "ntqfontinfo.h" +#include "ntqsizepolicy.h" +#endif // QT_H + +#if defined(TQ_WS_X11) +class TQInputContext; +#endif + +class TQLayout; +struct TQWExtra; +struct TQTLWExtra; +class TQFocusData; +class TQCursor; +class TQWSRegionManager; +class TQStyle; +class TQStyleControlElementData; + +class TQ_EXPORT TQWidget : public TQObject, public TQPaintDevice +{ + TQ_OBJECT + TQ_ENUMS( BackgroundMode FocusPolicy BackgroundOrigin ) + TQ_PROPERTY( bool isTopLevel READ isTopLevel ) + TQ_PROPERTY( bool isDialog READ isDialog ) + TQ_PROPERTY( bool isModal READ isModal ) + TQ_PROPERTY( bool isPopup READ isPopup ) + TQ_PROPERTY( bool isDesktop READ isDesktop ) + TQ_PROPERTY( bool enabled READ isEnabled WRITE setEnabled ) + TQ_PROPERTY( TQRect geometry READ geometry WRITE setGeometry ) + TQ_PROPERTY( TQRect frameGeometry READ frameGeometry ) + TQ_PROPERTY( int x READ x ) + TQ_PROPERTY( int y READ y ) + TQ_PROPERTY( TQPoint pos READ pos WRITE move DESIGNABLE false STORED false ) + TQ_PROPERTY( TQSize frameSize READ frameSize ) + TQ_PROPERTY( TQSize size READ size WRITE resize DESIGNABLE false STORED false ) + TQ_PROPERTY( int width READ width ) + TQ_PROPERTY( int height READ height ) + TQ_PROPERTY( TQRect rect READ rect ) + TQ_PROPERTY( TQRect childrenRect READ childrenRect ) + TQ_PROPERTY( TQRegion childrenRegion READ childrenRegion ) + TQ_PROPERTY( TQSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy ) + TQ_PROPERTY( TQSize minimumSize READ minimumSize WRITE setMinimumSize ) + TQ_PROPERTY( TQSize maximumSize READ maximumSize WRITE setMaximumSize ) + TQ_PROPERTY( int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false ) + TQ_PROPERTY( int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false ) + TQ_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false ) + TQ_PROPERTY( int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false ) + TQ_PROPERTY( TQSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement ) + TQ_PROPERTY( TQSize baseSize READ baseSize WRITE setBaseSize ) + TQ_PROPERTY( BackgroundMode backgroundMode READ backgroundMode WRITE setBackgroundMode DESIGNABLE false ) + TQ_PROPERTY( TQColor paletteForegroundColor READ paletteForegroundColor WRITE setPaletteForegroundColor RESET unsetPalette ) + TQ_PROPERTY( TQColor paletteBackgroundColor READ paletteBackgroundColor WRITE setPaletteBackgroundColor RESET unsetPalette ) + TQ_PROPERTY( TQPixmap paletteBackgroundPixmap READ paletteBackgroundPixmap WRITE setPaletteBackgroundPixmap RESET unsetPalette ) + TQ_PROPERTY( TQBrush backgroundBrush READ backgroundBrush ) + TQ_PROPERTY( TQColorGroup colorGroup READ colorGroup ) + TQ_PROPERTY( TQPalette palette READ palette WRITE setPalette RESET unsetPalette STORED ownPalette ) + TQ_PROPERTY( BackgroundOrigin backgroundOrigin READ backgroundOrigin WRITE setBackgroundOrigin ) + TQ_PROPERTY( bool ownPalette READ ownPalette ) + TQ_PROPERTY( TQFont font READ font WRITE setFont RESET unsetFont STORED ownFont ) + TQ_PROPERTY( bool ownFont READ ownFont ) +#ifndef TQT_NO_CURSOR + TQ_PROPERTY( TQCursor cursor READ cursor WRITE setCursor RESET unsetCursor STORED ownCursor ) + TQ_PROPERTY( bool ownCursor READ ownCursor ) +#endif +#ifndef TQT_NO_WIDGET_TOPEXTRA + TQ_PROPERTY( TQString caption READ caption WRITE setCaption ) + TQ_PROPERTY( TQPixmap icon READ icon WRITE setIcon ) + TQ_PROPERTY( TQString iconText READ iconText WRITE setIconText ) +#endif + TQ_PROPERTY( bool mouseTracking READ hasMouseTracking WRITE setMouseTracking ) + TQ_PROPERTY( bool underMouse READ hasMouse ) + TQ_PROPERTY( bool isActiveWindow READ isActiveWindow ) + TQ_PROPERTY( bool focusEnabled READ isFocusEnabled ) + TQ_PROPERTY( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy ) + TQ_PROPERTY( bool focus READ hasFocus ) + TQ_PROPERTY( bool updatesEnabled READ isUpdatesEnabled WRITE setUpdatesEnabled DESIGNABLE false ) + TQ_PROPERTY( bool visible READ isVisible ) + TQ_PROPERTY( TQRect visibleRect READ visibleRect ) // obsolete + TQ_PROPERTY( bool hidden READ isHidden WRITE setHidden DESIGNABLE false SCRIPTABLE false ) + TQ_PROPERTY( bool shown READ isShown WRITE setShown DESIGNABLE false SCRIPTABLE false ) + TQ_PROPERTY( bool minimized READ isMinimized ) + TQ_PROPERTY( bool maximized READ isMaximized ) + TQ_PROPERTY( bool fullScreen READ isFullScreen ) + TQ_PROPERTY( TQSize sizeHint READ sizeHint ) + TQ_PROPERTY( TQSize minimumSizeHint READ minimumSizeHint ) + TQ_PROPERTY( TQRect microFocusHint READ microFocusHint ) + TQ_PROPERTY( bool acceptDrops READ acceptDrops WRITE setAcceptDrops ) + TQ_PROPERTY( bool autoMask READ autoMask WRITE setAutoMask DESIGNABLE false SCRIPTABLE false ) + TQ_PROPERTY( bool customWhatsThis READ customWhatsThis ) + TQ_PROPERTY( bool inputMethodEnabled READ isInputMethodEnabled WRITE setInputMethodEnabled DESIGNABLE false SCRIPTABLE false ) + TQ_PROPERTY( double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE false ) + +public: + Q_EXPLICIT TQWidget( TQWidget* parent=0, const char* name=0, WFlags f=0, NFlags n=0 ); + ~TQWidget(); + + WId winId() const; + void setName( const char *name ); +#ifndef TQT_NO_STYLE + // GUI style setting + + TQStyle &style() const; + void setStyle( TQStyle * ); + TQStyle* setStyle( const TQString& ); +#endif + // Widget types and states + + bool isTopLevel() const; + bool isDialog() const; + bool isPopup() const; + bool isDesktop() const; + bool isModal() const; + + bool isEnabled() const; + bool isEnabledTo(TQWidget*) const; + bool isEnabledToTLW() const; + +public slots: + virtual void setEnabled( bool ); + void setDisabled( bool ); + + // Widget coordinates + +public: + TQRect frameGeometry() const; + const TQRect &geometry() const; + int x() const; + int y() const; + TQPoint pos() const; + TQSize frameSize() const; + TQSize size() const; + int width() const; + int height() const; + TQRect rect() const; + TQRect childrenRect() const; + TQRegion childrenRegion() const; + + TQSize minimumSize() const; + TQSize maximumSize() const; + int minimumWidth() const; + int minimumHeight() const; + int maximumWidth() const; + int maximumHeight() const; + void setMinimumSize( const TQSize & ); + virtual void setMinimumSize( int minw, int minh ); + void setMaximumSize( const TQSize & ); + virtual void setMaximumSize( int maxw, int maxh ); + void setMinimumWidth( int minw ); + void setMinimumHeight( int minh ); + void setMaximumWidth( int maxw ); + void setMaximumHeight( int maxh ); + + TQSize sizeIncrement() const; + void setSizeIncrement( const TQSize & ); + virtual void setSizeIncrement( int w, int h ); + TQSize baseSize() const; + void setBaseSize( const TQSize & ); + void setBaseSize( int basew, int baseh ); + + void setFixedSize( const TQSize & ); + void setFixedSize( int w, int h ); + void setFixedWidth( int w ); + void setFixedHeight( int h ); + + // Widget coordinate mapping + + TQPoint mapToGlobal( const TQPoint & ) const; + TQPoint mapFromGlobal( const TQPoint & ) const; + TQPoint mapToParent( const TQPoint & ) const; + TQPoint mapFromParent( const TQPoint & ) const; + TQPoint mapTo( TQWidget *, const TQPoint & ) const; + TQPoint mapFrom( TQWidget *, const TQPoint & ) const; + + TQWidget *topLevelWidget() const; + + // Widget attribute functions + + BackgroundMode backgroundMode() const; + virtual void setBackgroundMode( BackgroundMode ); + void setBackgroundMode( BackgroundMode, BackgroundMode ); + + const TQColor & foregroundColor() const; + + const TQColor & eraseColor() const; + virtual void setEraseColor( const TQColor & ); + + const TQPixmap * erasePixmap() const; + virtual void setErasePixmap( const TQPixmap & ); + +#ifndef TQT_NO_PALETTE + const TQColorGroup & colorGroup() const; + const TQPalette & palette() const; + bool ownPalette() const; + virtual void setPalette( const TQPalette & ); + void unsetPalette(); +#endif + + const TQColor & paletteForegroundColor() const; + void setPaletteForegroundColor( const TQColor & ); + + const TQColor & paletteBackgroundColor() const; + virtual void setPaletteBackgroundColor( const TQColor & ); + + const TQPixmap * paletteBackgroundPixmap() const; + virtual void setPaletteBackgroundPixmap( const TQPixmap & ); + + const TQBrush& backgroundBrush() const; + + TQFont font() const; + bool ownFont() const; + virtual void setFont( const TQFont & ); + void unsetFont(); + TQFontMetrics fontMetrics() const; + TQFontInfo fontInfo() const; + +#ifndef TQT_NO_CURSOR + const TQCursor &cursor() const; + bool ownCursor() const; + virtual void setCursor( const TQCursor & ); + virtual void unsetCursor(); +#endif +#ifndef TQT_NO_WIDGET_TOPEXTRA + TQString caption() const; + const TQPixmap *icon() const; + TQString iconText() const; +#endif + bool hasMouseTracking() const; + bool hasMouse() const; + + virtual void setMask( const TQBitmap & ); + virtual void setMask( const TQRegion & ); + void clearMask(); + + const TQColor & backgroundColor() const; // obsolete, use eraseColor() + virtual void setBackgroundColor( const TQColor & ); // obsolete, use setEraseColor() + const TQPixmap * backgroundPixmap() const; // obsolete, use erasePixmap() + virtual void setBackgroundPixmap( const TQPixmap & ); // obsolete, use setErasePixmap() + +public slots: +#ifndef TQT_NO_WIDGET_TOPEXTRA + virtual void setCaption( const TQString &); + virtual void setIcon( const TQPixmap & ); + virtual void setIconText( const TQString &); +#endif + virtual void setMouseTracking( bool enable ); + + // Keyboard input focus functions + + virtual void setFocus(); + void clearFocus(); + +public: + enum FocusPolicy { + NoFocus = 0, + TabFocus = 0x1, + ClickFocus = 0x2, + StrongFocus = TabFocus | ClickFocus | 0x8, + WheelFocus = StrongFocus | 0x4 + }; + + bool isActiveWindow() const; + virtual void setActiveWindow(); + bool isFocusEnabled() const; + + FocusPolicy focusPolicy() const; + virtual void setFocusPolicy( FocusPolicy ); + bool hasFocus() const; + static void setTabOrder( TQWidget *, TQWidget * ); + virtual void setFocusProxy( TQWidget * ); + TQWidget * focusProxy() const; + + void setInputMethodEnabled( bool b ); + bool isInputMethodEnabled() const; + // Grab functions + + void grabMouse(); +#ifndef TQT_NO_CURSOR + void grabMouse( const TQCursor & ); +#endif + void releaseMouse(); + void grabKeyboard(); + void releaseKeyboard(); + static TQWidget * mouseGrabber(); + static TQWidget * keyboardGrabber(); + + // Update/refresh functions + + bool isUpdatesEnabled() const; + +#if 0 //def TQ_WS_QWS + void repaintUnclipped( const TQRegion &, bool erase = TRUE ); +#endif +public slots: + virtual void setUpdatesEnabled( bool enable ); + void update(); + void update( int x, int y, int w, int h ); + void update( const TQRect& ); + void repaint(); + void repaint( bool erase ); + void repaint( int x, int y, int w, int h, bool erase=TRUE ); + void repaint( const TQRect &, bool erase = TRUE ); + void repaint( const TQRegion &, bool erase = TRUE ); + + // Widget management functions + + virtual void show(); + virtual void hide(); + void setShown( bool show ); + void setHidden( bool hide ); +#ifndef TQT_NO_COMPAT + void iconify() { showMinimized(); } +#endif + virtual void showMinimized(); + virtual void showMaximized(); + void showFullScreen(); + virtual void showNormal(); + virtual void polish(); + void constPolish() const; + bool close(); + + void raise(); + void lower(); + void stackUnder( TQWidget* ); + virtual void move( int x, int y ); + void move( const TQPoint & ); + virtual void resize( int w, int h ); + void resize( const TQSize & ); + virtual void setGeometry( int x, int y, int w, int h ); + virtual void setGeometry( const TQRect & ); // ### make non virtual in TQt 4? + +public: + virtual bool close( bool alsoDelete ); + bool isVisible() const; + bool isVisibleTo(TQWidget*) const; + bool isVisibleToTLW() const; // obsolete + TQRect visibleRect() const; // obsolete + bool isHidden() const; + bool isShown() const; + bool isMinimized() const; + bool isMaximized() const; + bool isFullScreen() const; + + uint windowState() const; + void setWindowState(uint windowState); + + virtual TQSize sizeHint() const; + virtual TQSize minimumSizeHint() const; + virtual TQSizePolicy sizePolicy() const; + virtual void setSizePolicy( TQSizePolicy ); + void setSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw = FALSE ); + virtual int heightForWidth(int) const; + + TQRegion clipRegion() const; + +// ### move together with other slots in TQt 4.0 +public slots: + virtual void adjustSize(); + +public: +#ifndef TQT_NO_LAYOUT + TQLayout * layout() const { return lay_out; } +#endif + void updateGeometry(); + virtual void reparent( TQWidget *parent, WFlags, const TQPoint &, + bool showIt=FALSE ); + void reparent( TQWidget *parent, const TQPoint &, + bool showIt=FALSE ); +#ifndef TQT_NO_COMPAT + void recreate( TQWidget *parent, WFlags f, const TQPoint & p, + bool showIt=FALSE ) { reparent(parent,f,p,showIt); } +#endif + + void erase(); + void erase( int x, int y, int w, int h ); + void erase( const TQRect & ); + void erase( const TQRegion & ); + void scroll( int dx, int dy ); + void scroll( int dx, int dy, const TQRect& ); + + void drawText( int x, int y, const TQString &); + void drawText( const TQPoint &, const TQString &); + + // Misc. functions + + TQWidget * focusWidget() const; + TQRect microFocusHint() const; + + // drag and drop + + bool acceptDrops() const; + virtual void setAcceptDrops( bool on ); + + // transparency and pseudo transparency + + virtual void setAutoMask(bool); + bool autoMask() const; + + enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin }; + + virtual void setBackgroundOrigin( BackgroundOrigin ); + BackgroundOrigin backgroundOrigin() const; + TQPoint backgroundOffset() const; + + // whats this help + virtual bool customWhatsThis() const; + + TQWidget * parentWidget( bool sameWindow = FALSE ) const; + WState testWState( WState s ) const; + WFlags testWFlags( WFlags f ) const; + NFlags testNFlags( NFlags f ) const; + uint getWState() const; + WFlags getWFlags() const; + NFlags getNFlags() const; + static TQWidget * find( WId ); + static TQWidgetMapper *wmapper(); + + TQWidget *childAt( int x, int y, bool includeThis = FALSE ) const; + TQWidget *childAt( const TQPoint &, bool includeThis = FALSE ) const; + +#if defined(TQ_WS_QWS) + virtual TQGfx * graphicsContext(bool clip_children=TRUE) const; +#endif +#if defined(TQ_WS_MAC) + TQRegion clippedRegion(bool do_children=TRUE); + uint clippedSerial(bool do_children=TRUE); +#ifndef TQMAC_NO_QUARTZ + CGContextRef macCGContext(bool clipped=TRUE) const; +#endif +#endif +#if defined(TQ_WS_X11) + enum X11WindowType { + X11WindowTypeSelect, + X11WindowTypeCombo, + X11WindowTypeDND, + X11WindowTypeTooltip, + X11WindowTypeMenu, // torn-off + X11WindowTypeDropdown, + X11WindowTypePopup + }; + void x11SetWindowType( X11WindowType type = X11WindowTypeSelect ); + void x11SetWindowTransient( TQWidget* parent ); +#endif + void setWindowOpacity(double level); + double windowOpacity() const; + +protected: + // Event handlers + bool event( TQEvent * ); + virtual void mousePressEvent( TQMouseEvent * ); + virtual void mouseReleaseEvent( TQMouseEvent * ); + virtual void mouseDoubleClickEvent( TQMouseEvent * ); + virtual void mouseMoveEvent( TQMouseEvent * ); +#ifndef TQT_NO_WHEELEVENT + virtual void wheelEvent( TQWheelEvent * ); +#endif + virtual void keyPressEvent( TQKeyEvent * ); + virtual void keyReleaseEvent( TQKeyEvent * ); + virtual void focusInEvent( TQFocusEvent * ); + virtual void focusOutEvent( TQFocusEvent * ); + virtual void enterEvent( TQEvent * ); + virtual void leaveEvent( TQEvent * ); + virtual void paintEvent( TQPaintEvent * ); + virtual void moveEvent( TQMoveEvent * ); + virtual void resizeEvent( TQResizeEvent * ); + virtual void closeEvent( TQCloseEvent * ); + virtual void contextMenuEvent( TQContextMenuEvent * ); + virtual void imStartEvent( TQIMEvent * ); + virtual void imComposeEvent( TQIMEvent * ); + virtual void imEndEvent( TQIMEvent * ); + virtual void tabletEvent( TQTabletEvent * ); + +#ifndef TQT_NO_DRAGANDDROP + virtual void dragEnterEvent( TQDragEnterEvent * ); + virtual void dragMoveEvent( TQDragMoveEvent * ); + virtual void dragLeaveEvent( TQDragLeaveEvent * ); + virtual void dropEvent( TQDropEvent * ); +#endif + + virtual void showEvent( TQShowEvent * ); + virtual void hideEvent( TQHideEvent * ); + +#if defined(TQ_WS_MAC) + virtual bool macEvent( MSG * ); +#endif +#if defined(TQ_WS_WIN) + virtual bool winEvent( MSG * ); +#endif +#if defined(TQ_WS_X11) + virtual bool x11Event( XEvent * ); +#endif +#if defined(TQ_WS_QWS) + virtual bool qwsEvent( TQWSEvent * ); + virtual unsigned char *scanLine( int ) const; + virtual int bytesPerLine() const; +#endif + + virtual void updateMask(); + + // Misc. protected functions + +#ifndef TQT_NO_STYLE + virtual void styleChange( TQStyle& ); +#endif + virtual void enabledChange( bool oldEnabled ); +#ifndef TQT_NO_PALETTE + virtual void paletteChange( const TQPalette & ); +#endif + virtual void fontChange( const TQFont & ); + virtual void windowActivationChange( bool oldActive ); + + int metric( int ) const; + +#if defined(TQ_WS_X11) +#if !defined(TQT_NO_IM_EXTENSIONS) + virtual TQWidget *icHolderWidget(); +#else + TQWidget *icHolderWidget(); +#endif + TQInputContext *getInputContext(); + void changeInputContext( const TQString & ); + void sendMouseEventToInputContext( int x, TQEvent::Type type, + TQt::ButtonState button, + TQt::ButtonState state ); +#endif + void resetInputContext(); + + virtual void create( WId = 0, bool initializeWindow = TRUE, + bool destroyOldWindow = TRUE ); + virtual void destroy( bool destroyWindow = TRUE, + bool destroySubWindows = TRUE ); + virtual void setWState( uint ); + void clearWState( uint n ); + virtual void setWFlags( WFlags ); + void clearWFlags( WFlags n ); + virtual void setNFlags( NFlags ); + void clearNFlags( NFlags n ); + + virtual bool focusNextPrevChild( bool next ); + + TQWExtra *extraData(); + TQTLWExtra *topData(); + TQFocusData *focusData(); + + virtual void setKeyCompression(bool); + virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE, TQFont *f = 0); + +#if defined(TQ_WS_MAC) + void dirtyClippedRegion(bool); + bool isClippedRegionDirty(); + virtual void setRegionDirty(bool); + virtual void macWidgetChangedWindow(); +#endif + +private slots: + void focusProxyDestroyed(); +#if defined(TQ_WS_X11) + void destroyInputContext(); +#endif + +private: + void setFontSys( TQFont *f = 0 ); +#if defined(TQ_WS_X11) + void createInputContext(); + void focusInputContext(); + void unfocusInputContext(); + void checkChildrenDnd(); + +#ifndef TQT_NO_XSYNC + void createSyncCounter(); + void destroySyncCounter(); + void incrementSyncCounter(); + void handleSyncRequest( void* ev ); +#endif + +#elif defined(TQ_WS_MAC) + uint own_id : 1, macDropEnabled : 1; + EventHandlerRef window_event; + //mac event functions + void propagateUpdates(bool update_rgn=TRUE); + void update( const TQRegion& ); + //friends, way too many - fix this immediately! + friend void qt_clean_root_win(); + friend bool qt_recreate_root_win(); + friend TQPoint posInWindow(TQWidget *); + friend bool qt_mac_update_sizer(TQWidget *, int); + friend TQWidget *qt_recursive_match(TQWidget *widg, int x, int y); + friend bool qt_paint_children(TQWidget *,TQRegion &, uchar ops); + friend TQMAC_PASCAL OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *); + friend void qt_event_request_updates(TQWidget *, const TQRegion &, bool subtract); + friend bool qt_window_rgn(WId, short, RgnHandle, bool); + friend class TQDragManager; +#endif + +#ifndef TQT_NO_LAYOUT + void setLayout( TQLayout *l ); +#endif + void setWinId( WId ); + void showWindow(); + void hideWindow(); + void showChildren( bool spontaneous ); + void hideChildren( bool spontaneous ); + void reparentSys( TQWidget *parent, WFlags, const TQPoint &, bool showIt); + void createTLExtra(); + void createExtra(); + void deleteExtra(); + void createSysExtra(); + void deleteSysExtra(); + void createTLSysExtra(); + void deleteTLSysExtra(); + void deactivateWidgetCleanup(); + void internalSetGeometry( int, int, int, int, bool ); + void reparentFocusWidgets( TQWidget * ); + TQFocusData *focusData( bool create ); + void setBackgroundFromMode(); + void setBackgroundColorDirect( const TQColor & ); + void setBackgroundPixmapDirect( const TQPixmap & ); + void setBackgroundModeDirect( BackgroundMode ); + void setBackgroundEmpty(); + void updateFrameStrut() const; +#if defined(TQ_WS_X11) + void setBackgroundX11Relative(); +#endif + + WId winid; + uint widget_state; + uint widget_flags; + uint netwm_flags; + uint reserved_1; + uint reserved_2; + uint reserved_3; + uint reserved_4; + uint focus_policy : 4; + uint own_font :1; + uint own_palette :1; + uint sizehint_forced :1; + uint is_closing :1; + uint in_show : 1; + uint in_show_maximized : 1; + uint fstrut_dirty : 1; + uint im_enabled : 1; + TQRect crect; + TQColor bg_col; +#ifndef TQT_NO_PALETTE + TQPalette pal; +#endif + TQFont fnt; +#ifndef TQT_NO_LAYOUT + TQLayout *lay_out; +#endif +#if defined(TQ_WS_X11) && !defined(TQT_NO_IM) && !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext *ic; // Input Context +#endif + TQWExtra *extra; +#if defined(TQ_WS_QWS) + TQRegion req_region; // Requested region + mutable TQRegion paintable_region; // Paintable region + mutable bool paintable_region_dirty;// needs to be recalculated + mutable TQRegion alloc_region; // Allocated region + mutable bool alloc_region_dirty; // needs to be recalculated + mutable int overlapping_children; // Handle overlapping children + + int alloc_region_index; + int alloc_region_revision; + + void updateOverlappingChildren() const; + void setChildrenAllocatedDirty(); + void setChildrenAllocatedDirty( const TQRegion &r, const TQWidget *dirty=0 ); + bool isAllocatedRegionDirty() const; + void updateRequestedRegion( const TQPoint &gpos ); + TQRegion requestedRegion() const; + TQRegion allocatedRegion() const; + TQRegion paintableRegion() const; + + void updateGraphicsContext( TQGfx *qgfx_qws, bool clip_children ) const; +#ifndef TQT_NO_CURSOR + void updateCursor( const TQRegion &r ) const; +#endif + + // used to accumulate dirty region when children moved/resized. + TQRegion dirtyChildren; + bool isSettingGeometry; + friend class TQWSManager; +#endif + static int instanceCounter; // Current number of widget instances + static int maxInstances; // Maximum number of widget instances + + static void createMapper(); + static void destroyMapper(); + static TQWidgetList *wList(); + static TQWidgetList *tlwList(); + static TQWidgetMapper *mapper; + friend class TQApplication; + friend class TQBaseApplication; + friend class TQPainter; + friend class TQFontMetrics; + friend class TQFontInfo; + friend class TQETWidget; + friend class TQLayout; + +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQWidget( const TQWidget & ); + TQWidget &operator=( const TQWidget & ); +#endif + +public: // obsolete functions to dissappear or to become inline in 3.0 +#ifndef TQT_NO_PALETTE + void setPalette( const TQPalette &p, bool ) { setPalette( p ); } +#endif + void setFont( const TQFont &f, bool ) { setFont( f ); } +}; + + +inline TQt::WState TQWidget::testWState( WState s ) const +{ return (widget_state & s); } + +inline TQt::WFlags TQWidget::testWFlags( WFlags f ) const +{ return (widget_flags & f); } + +inline TQt::NFlags TQWidget::testNFlags( NFlags f ) const +{ return (netwm_flags & f); } + +inline WId TQWidget::winId() const +{ return winid; } + +inline bool TQWidget::isTopLevel() const +{ return testWFlags(WType_TopLevel); } + +inline bool TQWidget::isDialog() const +{ return testWFlags(WType_Dialog); } + +inline bool TQWidget::isPopup() const +{ return testWFlags(WType_Popup); } + +inline bool TQWidget::isDesktop() const +{ return testWFlags(WType_Desktop); } + +inline bool TQWidget::isEnabled() const +{ return !testWState(WState_Disabled); } + +inline bool TQWidget::isModal() const +{ return testWFlags(WShowModal); } + +inline bool TQWidget::isEnabledToTLW() const +{ return isEnabled(); } + +inline const TQRect &TQWidget::geometry() const +{ return crect; } + +inline TQSize TQWidget::size() const +{ return crect.size(); } + +inline int TQWidget::width() const +{ return crect.width(); } + +inline int TQWidget::height() const +{ return crect.height(); } + +inline TQRect TQWidget::rect() const +{ return TQRect(0,0,crect.width(),crect.height()); } + +inline int TQWidget::minimumWidth() const +{ return minimumSize().width(); } + +inline int TQWidget::minimumHeight() const +{ return minimumSize().height(); } + +inline int TQWidget::maximumWidth() const +{ return maximumSize().width(); } + +inline int TQWidget::maximumHeight() const +{ return maximumSize().height(); } + +inline void TQWidget::setMinimumSize( const TQSize &s ) +{ setMinimumSize(s.width(),s.height()); } + +inline void TQWidget::setMaximumSize( const TQSize &s ) +{ setMaximumSize(s.width(),s.height()); } + +inline void TQWidget::setSizeIncrement( const TQSize &s ) +{ setSizeIncrement(s.width(),s.height()); } + +inline void TQWidget::setBaseSize( const TQSize &s ) +{ setBaseSize(s.width(),s.height()); } + +inline const TQColor &TQWidget::eraseColor() const +{ return bg_col; } + +#ifndef TQT_NO_PALETTE +inline const TQPalette &TQWidget::palette() const +{ return pal; } +#endif + +inline TQFont TQWidget::font() const +{ return fnt; } + +inline TQFontMetrics TQWidget::fontMetrics() const +{ return TQFontMetrics(font()); } + +inline TQFontInfo TQWidget::fontInfo() const +{ return TQFontInfo(font()); } + +inline bool TQWidget::hasMouseTracking() const +{ return testWState(WState_MouseTracking); } + +inline bool TQWidget::hasMouse() const +{ return testWState(WState_HasMouse); } + +inline bool TQWidget::isFocusEnabled() const +{ return (FocusPolicy)focus_policy != NoFocus; } + +inline TQWidget::FocusPolicy TQWidget::focusPolicy() const +{ return (FocusPolicy)focus_policy; } + +inline bool TQWidget::isUpdatesEnabled() const +{ return !testWState(WState_BlockUpdates); } + +inline void TQWidget::update( const TQRect &r ) +{ update( r.x(), r.y(), r.width(), r.height() ); } + +inline void TQWidget::repaint() +{ repaint( TRUE ); } + +inline void TQWidget::repaint( const TQRect &r, bool erase ) +{ repaint( r.x(), r.y(), r.width(), r.height(), erase ); } + +inline void TQWidget::erase() +{ erase( 0, 0, crect.width(), crect.height() ); } + +inline void TQWidget::erase( const TQRect &r ) +{ erase( r.x(), r.y(), r.width(), r.height() ); } + +inline bool TQWidget::close() +{ return close( FALSE ); } + +inline bool TQWidget::isVisible() const +{ return testWState(WState_Visible); } + +inline bool TQWidget::isVisibleToTLW() const // obsolete +{ return isVisible(); } + +inline bool TQWidget::isHidden() const +{ return testWState(WState_ForceHide); } + +inline bool TQWidget::isShown() const +{ return !testWState(WState_ForceHide); } + +inline void TQWidget::move( const TQPoint &p ) +{ move( p.x(), p.y() ); } + +inline void TQWidget::resize( const TQSize &s ) +{ resize( s.width(), s.height()); } + +inline void TQWidget::setGeometry( const TQRect &r ) +{ setGeometry( r.left(), r.top(), r.width(), r.height() ); } + +inline void TQWidget::drawText( const TQPoint &p, const TQString &s ) +{ drawText( p.x(), p.y(), s ); } + +inline TQWidget *TQWidget::parentWidget( bool sameWindow ) const +{ + if ( sameWindow ) + return isTopLevel() ? 0 : (TQWidget *)TQObject::parent(); + return (TQWidget *)TQObject::parent(); +} + +inline TQWidgetMapper *TQWidget::wmapper() +{ return mapper; } + +inline uint TQWidget::getWState() const +{ return widget_state; } + +inline void TQWidget::setWState( uint f ) +{ widget_state |= f; } + +inline void TQWidget::clearWState( uint f ) +{ widget_state &= ~f; } + +inline TQt::WFlags TQWidget::getWFlags() const +{ return widget_flags; } + +inline TQt::NFlags TQWidget::getNFlags() const +{ return netwm_flags; } + +inline void TQWidget::setWFlags( WFlags f ) +{ widget_flags |= f; } + +inline void TQWidget::setNFlags( NFlags f ) +{ netwm_flags |= f; } + +inline void TQWidget::clearWFlags( WFlags f ) +{ widget_flags &= ~f; } + +inline void TQWidget::clearNFlags( NFlags f ) +{ netwm_flags &= ~f; } + +inline void TQWidget::constPolish() const +{ + if ( !testWState(WState_Polished) ) { + TQWidget* that = (TQWidget*) this; + that->polish(); + that->setWState(WState_Polished); // be on the safe side... + } +} +#ifndef TQT_NO_CURSOR +inline bool TQWidget::ownCursor() const +{ + return testWState( WState_OwnCursor ); +} +#endif +inline bool TQWidget::ownFont() const +{ + return own_font; +} +#ifndef TQT_NO_PALETTE +inline bool TQWidget::ownPalette() const +{ + return own_palette; +} +#endif + +inline void TQWidget::setSizePolicy( TQSizePolicy::SizeType hor, TQSizePolicy::SizeType ver, bool hfw ) +{ + setSizePolicy( TQSizePolicy( hor, ver, hfw) ); +} + +inline bool TQWidget::isInputMethodEnabled() const +{ + return (bool)im_enabled; +} + +// Extra TQWidget data +// - to minimize memory usage for members that are seldom used. +// - top-level widgets have extra extra data to reduce cost further + +class TQFocusData; +class TQWSManager; +#if defined(TQ_WS_WIN) +class TQOleDropTarget; +#endif +#if defined(TQ_WS_MAC) +class TQMacDndExtra; +#endif + +struct TQ_EXPORT TQTLWExtra { +#ifndef TQT_NO_WIDGET_TOPEXTRA + TQString caption; // widget caption + TQString iconText; // widget icon text + TQPixmap *icon; // widget icon +#endif + TQFocusData *focusData; // focus data (for TLW) + short incw, inch; // size increments + // frame strut + ulong fleft, fright, ftop, fbottom; + uint unused : 8; // not used at this point... +#if defined( TQ_WS_WIN ) || defined( TQ_WS_MAC ) + uint opacity : 8; // Stores opacity level on Windows/Mac OS X. +#endif + uint savedFlags; // Save widgetflags while showing fullscreen + short basew, baseh; // base sizes +#if defined(TQ_WS_X11) + WId parentWinId; // parent window Id (valid after reparenting) + uint embedded : 1; // window is embedded in another TQt application + uint spont_unmapped: 1; // window was spontaneously unmapped + uint reserved: 1; // reserved + uint dnd : 1; // DND properties installed + uint uspos : 1; // User defined position + uint ussize : 1; // User defined size +#if defined(TQT_NO_IM_EXTENSIONS) + void *xic; // Input Context +#endif +#ifndef TQT_NO_XSYNC + ulong syncCounter; + uint syncRequestValue[2]; +#endif +#endif +#if defined(TQ_WS_MAC) + WindowGroupRef group; + uint is_moved: 1; + uint resizer : 4; +#endif +#if defined(TQ_WS_QWS) && !defined ( TQT_NO_QWS_MANAGER ) + TQRegion decor_allocated_region; // decoration allocated region + TQWSManager *qwsManager; +#endif +#if defined(TQ_WS_WIN) + HICON winIcon; // internal Windows icon +#endif + TQRect normalGeometry; // used by showMin/maximized/FullScreen +#ifdef TQ_WS_WIN + uint style, exstyle; +#endif +}; + + +#define TQWIDGETSIZE_MAX 32767 + +// dear user: you can see this struct, but it is internal. do not touch. + +struct TQ_EXPORT TQWExtra { + TQ_INT16 minw, minh; // minimum size + TQ_INT16 maxw, maxh; // maximum size + TQPixmap *bg_pix; // background pixmap + TQWidget *focus_proxy; +#ifndef TQT_NO_CURSOR + TQCursor *curs; +#endif + TQTLWExtra *topextra; // only useful for TLWs +#if defined(TQ_WS_WIN) + TQOleDropTarget *dropTarget; // drop target +#endif +#if defined(TQ_WS_X11) + WId xDndProxy; // XDND forwarding to embedded windows +#endif +#if defined(TQ_WS_MAC) + TQRegion clip_saved, clip_sibs, clip_children; + TQMacDndExtra *macDndExtra; + TQRegion dirty_area; + uint clip_dirty : 1, clip_serial : 15; + uint child_dirty : 1, child_serial : 15; +#ifndef TQMAC_NO_QUARTZ + uint ctx_children_clipped:1; +#endif // TQMAC_NO_QUARTZ + uint has_dirty_area:1; +#endif // TQ_WS_MAC + uint bg_origin : 2; +#if defined(TQ_WS_X11) + uint children_use_dnd : 1; + uint compress_events : 1; +#endif +#if defined(TQ_WS_QWS) || defined(TQ_WS_MAC) + TQRegion mask; // widget mask +#endif + char bg_mode; // background mode + char bg_mode_visual; // visual background mode +#ifndef TQT_NO_STYLE + TQStyle* style; +#endif + TQRect micro_focus_hint; // micro focus hint + TQSizePolicy size_policy; + TQStyleControlElementData* m_ceData; +}; + +#define Q_DEFINED_QWIDGET +#include "ntqwinexport.h" + +#endif // TQWIDGET_H diff --git a/src/kernel/tqwidget_p.h b/src/kernel/tqwidget_p.h new file mode 100644 index 000000000..3f8d68235 --- /dev/null +++ b/src/kernel/tqwidget_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Definition of some TQt private functions. +** +** Created : 000903 +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQWIDGET_P_H +#define TQWIDGET_P_H + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of qapplication_*.cpp, tqwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#endif // QT_H + +#if defined (TQ_WS_X11) || defined (TQ_WS_QWS) +extern int qt_widget_tlw_gravity; +#endif + +#endif diff --git a/src/kernel/tqwidget_x11.cpp b/src/kernel/tqwidget_x11.cpp new file mode 100644 index 000000000..88bed113c --- /dev/null +++ b/src/kernel/tqwidget_x11.cpp @@ -0,0 +1,3172 @@ +/**************************************************************************** +** +** Implementation of TQWidget and TQWindow classes for X11 +** +** Created : 931031 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "ntqapplication.h" +#include "qapplication_p.h" +#include "ntqnamespace.h" +#include "ntqpaintdevicemetrics.h" +#include "ntqpainter.h" +#include "ntqbitmap.h" +#include "ntqimage.h" +#include "tqobjectlist.h" +#include "ntqlayout.h" +#include "ntqtextcodec.h" +#include "ntqdatetime.h" +#include "ntqcursor.h" +#include "qt_x11_p.h" +#include + +// NOT REVISED + +// defined in qapplication_x11.cpp +extern Window qt_x11_wm_client_leader; +extern void qt_x11_create_wm_client_leader(); + +// defined in qapplication_x11.cpp +void qt_insert_sip( TQWidget*, int, int ); +int qt_sip_count( TQWidget* ); +bool qt_wstate_iconified( WId ); +void qt_updated_rootinfo(); + +#ifndef TQT_NO_IM +#include "ntqinputcontext.h" +#include "ntqinputcontextfactory.h" +#endif + +// Paint event clipping magic +extern void qt_set_paintevent_clipping( TQPaintDevice* dev, const TQRegion& region); +extern void qt_clear_paintevent_clipping(); + +extern bool qt_dnd_enable( TQWidget* w, bool on ); +extern bool qt_nograb(); + +// defined in qapplication_x11.cpp +extern void qt_deferred_map_add( TQWidget* ); +extern void qt_deferred_map_take( TQWidget* ); +extern bool qt_deferred_map_contains(TQWidget *); + +static TQWidget *mouseGrb = 0; +static TQWidget *keyboardGrb = 0; + +// defined in qapplication_x11.cpp +extern Time tqt_x_time; +extern Time tqt_x_user_time; + +#ifndef TQT_NO_XSYNC +extern Atom qt_net_wm_sync_request_counter; +extern Atom qt_net_wm_sync_request; +extern bool qt_use_xsync; +#endif + +// defined in qfont_x11.cpp +extern bool tqt_has_xft; + +int qt_x11_create_desktop_on_screen = -1; + +/***************************************************************************** + TQWidget member functions + *****************************************************************************/ + +// defined in qapplication_x11.cpp +extern Atom tqt_wm_state; +extern Atom qt_wm_change_state; +extern Atom tqt_wm_delete_window; +extern Atom tqt_wm_take_focus; +extern Atom qt_wm_client_leader; +extern Atom tqt_window_role; +extern Atom tqt_sm_client_id; +extern Atom qt_utf8_string; +extern Atom qt_net_wm_context_help; +extern Atom qt_net_wm_ping; +extern Atom qt_xa_motif_wm_hints; +extern Atom qt_net_wm_name; +extern Atom qt_net_wm_icon_name; +extern Atom qt_net_wm_state; +extern Atom qt_net_wm_state_modal; +extern Atom qt_net_wm_state_max_v; +extern Atom qt_net_wm_state_max_h; +extern Atom qt_net_wm_state_fullscreen; +extern Atom qt_net_wm_state_above; +extern Atom qt_net_wm_state_stays_on_top; +extern Atom qt_net_wm_action; +extern Atom qt_net_wm_action_move; +extern Atom qt_net_wm_action_resize; +extern Atom qt_net_wm_action_minimize; +extern Atom qt_net_wm_action_shade; +extern Atom qt_net_wm_action_stick; +extern Atom qt_net_wm_action_max_h; +extern Atom qt_net_wm_action_max_v; +extern Atom qt_net_wm_action_fullscreen; +extern Atom qt_net_wm_action_change_desktop; +extern Atom qt_net_wm_action_close; +extern Atom qt_net_wm_action_above; +extern Atom qt_net_wm_action_below; +extern Atom qt_net_wm_window_type; +extern Atom qt_net_wm_window_type_normal; +extern Atom qt_net_wm_window_type_dialog; +extern Atom qt_net_wm_window_type_toolbar; +extern Atom qt_net_wm_window_type_menu; +extern Atom qt_net_wm_window_type_utility; +extern Atom qt_net_wm_window_type_splash; +extern Atom qt_net_wm_window_type_override; +extern Atom qt_net_wm_window_type_dropdown_menu; +extern Atom qt_net_wm_window_type_popup_menu; +extern Atom qt_net_wm_window_type_combo; +extern Atom qt_net_wm_window_type_dnd; +extern Atom qt_net_wm_window_type_tooltip; +extern Atom qt_net_wm_pid; +extern Atom qt_net_wm_user_time; +extern Atom qt_enlightenment_desktop; +extern Atom qt_net_virtual_roots; +extern bool qt_broken_wm; + +// defined in qapplication_x11.cpp +extern bool qt_net_supports(Atom); +extern unsigned long *qt_net_virtual_root_list; + +#if defined (QT_TABLET_SUPPORT) +extern XDevice *devStylus; +extern XDevice *devEraser; +extern XEventClass event_list_stylus[7]; +extern XEventClass event_list_eraser[7]; +extern int qt_curr_events_stylus; +extern int qt_curr_events_eraser; +#endif + +const uint stdWidgetEventMask = // X event mask + (uint)( + KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask | + KeymapStateMask | + ButtonMotionMask | + EnterWindowMask | LeaveWindowMask | + FocusChangeMask | + ExposureMask | + PropertyChangeMask | + StructureNotifyMask + ); + +const uint stdDesktopEventMask = // X event mask + (uint)( + KeymapStateMask | + EnterWindowMask | LeaveWindowMask | + PropertyChangeMask + ); + + +/* + The qt_ functions below are implemented in tqwidgetcreate_x11.cpp. +*/ + +Window qt_XCreateWindow( const TQWidget *creator, + Display *display, Window parent, + int x, int y, uint w, uint h, + int borderwidth, int depth, + uint windowclass, Visual *visual, + ulong valuemask, XSetWindowAttributes *attributes ); +Window qt_XCreateSimpleWindow( const TQWidget *creator, + Display *display, Window parent, + int x, int y, uint w, uint h, int borderwidth, + ulong border, ulong background ); +void qt_XDestroyWindow( const TQWidget *destroyer, + Display *display, Window window ); + +TQ_EXPORT void tqt_x11_enforce_cursor( TQWidget * w ) +{ + if ( w->testWState( TQt::WState_OwnCursor ) ) { + TQCursor * oc = TQApplication::overrideCursor(); + if ( oc ) { + XDefineCursor( w->x11Display(), w->winId(), oc->handle() ); + } else if ( w->isEnabled() ) { + XDefineCursor( w->x11Display(), w->winId(), w->cursor().handle() ); + } else { + // enforce the windows behavior of clearing the cursor on + // disabled widgets + XDefineCursor( w->x11Display(), w->winId(), None ); + } + } else { + XDefineCursor( w->x11Display(), w->winId(), None ); + } +} + +TQ_EXPORT void tqt_wait_for_window_manager( TQWidget* w ) +{ + TQApplication::flushX(); + XEvent ev; + TQTime t; + t.start(); + while ( !XCheckTypedWindowEvent( w->x11Display(), w->winId(), ReparentNotify, &ev ) ) { + if ( XCheckTypedWindowEvent( w->x11Display(), w->winId(), MapNotify, &ev ) ) + break; + if ( t.elapsed() > 500 ) + return; // give up, no event available + tqApp->syncX(); // non-busy wait + } + tqApp->x11ProcessEvent( &ev ); + if ( XCheckTypedWindowEvent( w->x11Display(), w->winId(), ConfigureNotify, &ev ) ) + tqApp->x11ProcessEvent( &ev ); +} + +static void qt_net_change_wm_state(const TQWidget* w, bool set, Atom one, Atom two = 0) +{ + if (w->isShown()) { + // managed by WM + XEvent e; + e.xclient.type = ClientMessage; + e.xclient.message_type = qt_net_wm_state; + e.xclient.display = w->x11Display(); + e.xclient.window = w->winId(); + e.xclient.format = 32; + e.xclient.data.l[ 0 ] = set ? 1 : 0; + e.xclient.data.l[ 1 ] = one; + e.xclient.data.l[ 2 ] = two; + e.xclient.data.l[ 3 ] = 0; + e.xclient.data.l[ 4 ] = 0; + XSendEvent(w->x11Display(), RootWindow(w->x11Display(), w->x11Screen()), + False, (SubstructureNotifyMask|SubstructureRedirectMask), &e); + } else { + Atom ret; + int format = 0, status; + unsigned char *data = 0; + unsigned long nitems = 0, after = 0; + Atom *old_states = 0; + status = XGetWindowProperty(w->x11Display(), w->winId(), + qt_net_wm_state, 0, 1024, False, + XA_ATOM, &ret, &format, &nitems, + &after, &data); + if (status == Success && ret == XA_ATOM && format == 32 && nitems > 0) + old_states = (Atom *) data; + else + nitems = 0; + + Atom *new_states = new Atom[nitems + 2]; + int i, j = 0; + for (i = 0; i < (int)nitems; ++i) { + if (old_states[i] && old_states[i] != one && old_states[i] != two) + new_states[j++] = old_states[i]; + } + + if (set) { + if (one) new_states[j++] = one; + if (two) new_states[j++] = two; + } + + if (j) + XChangeProperty(w->x11Display(), w->winId(), qt_net_wm_state, XA_ATOM, 32, + PropModeReplace, (uchar *) new_states, j); + else + XDeleteProperty(w->x11Display(), w->winId(), qt_net_wm_state); + + delete [] new_states; + if (data) XFree(data); + } +} + +/*! + Creates a new widget window if \a window is 0, otherwise sets the + widget's window to \a window. + + Initializes the window (sets the geometry etc.) if \a + initializeWindow is TRUE. If \a initializeWindow is FALSE, no + initialization is performed. This parameter only makes sense if \a + window is a valid window. + + Destroys the old window if \a destroyOldWindow is TRUE. If \a + destroyOldWindow is FALSE, you are responsible for destroying the + window yourself (using platform native code). + + The TQWidget constructor calls create(0,TRUE,TRUE) to create a + window for this widget. +*/ + +void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) +{ + if ( testWState(WState_Created) && window == 0 ) + return; + + // set created flag + setWState( WState_Created ); + + bool popup = testWFlags(WType_Popup); + bool dialog = testWFlags(WType_Dialog); + bool desktop = testWFlags(WType_Desktop); + + // top-level widget + if ( !parentWidget() || parentWidget()->isDesktop() ) + setWFlags( WType_TopLevel ); + + // these are top-level, too + if ( dialog || popup || desktop || testWFlags(WStyle_Splash)) + setWFlags( WType_TopLevel ); + + // a popup stays on top + if ( popup ) + setWFlags(WStyle_StaysOnTop); + + bool topLevel = testWFlags(WType_TopLevel); + Window parentw, destroyw = 0; + WId id; + + // always initialize + if ( !window ) + initializeWindow = TRUE; + + if ( desktop && + qt_x11_create_desktop_on_screen >= 0 && + qt_x11_create_desktop_on_screen != x11Screen() ) { + // desktop on a certain screen other than the default requested + TQPaintDeviceX11Data* xd = getX11Data( TRUE ); + xd->x_screen = qt_x11_create_desktop_on_screen; + xd->x_depth = TQPaintDevice::x11AppDepth( xd->x_screen ); + xd->x_cells = TQPaintDevice::x11AppCells( xd->x_screen ); + xd->x_colormap = TQPaintDevice::x11AppColormap( xd->x_screen ); + xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( xd->x_screen ); + xd->x_visual = TQPaintDevice::x11AppVisual( xd->x_screen ); + xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( xd->x_screen ); + setX11Data( xd ); + } else if ( parentWidget() && parentWidget()->x11Screen() != x11Screen() ) { + // if we have a parent widget, move to its screen if necessary + TQPaintDeviceX11Data* xd = getX11Data( TRUE ); + xd->x_screen = parentWidget()->x11Screen(); + xd->x_depth = TQPaintDevice::x11AppDepth( xd->x_screen ); + xd->x_cells = TQPaintDevice::x11AppCells( xd->x_screen ); + xd->x_colormap = TQPaintDevice::x11AppColormap( xd->x_screen ); + xd->x_defcolormap = TQPaintDevice::x11AppDefaultColormap( xd->x_screen ); + xd->x_visual = TQPaintDevice::x11AppVisual( xd->x_screen ); + xd->x_defvisual = TQPaintDevice::x11AppDefaultVisual( xd->x_screen ); + setX11Data( xd ); + } + + //get display, screen number, root window and desktop geometry for + //the current screen + Display *dpy = x11Display(); + int scr = x11Screen(); + Window root_win = RootWindow( dpy, scr ); + int sw = DisplayWidth(dpy,scr); + int sh = DisplayHeight(dpy,scr); + + if ( desktop ) { // desktop widget + dialog = popup = FALSE; // force these flags off + crect.setRect( 0, 0, sw, sh ); + } else if ( topLevel ) { // calc pos/size from screen + crect.setRect( sw/4, 3*sh/10, sw/2, 4*sh/10 ); + } else { // child widget + crect.setRect( 0, 0, 100, 30 ); + } + + parentw = topLevel ? root_win : parentWidget()->winId(); + + XSetWindowAttributes wsa; + + if ( window ) { // override the old window + if ( destroyOldWindow ) + destroyw = winid; + id = window; + setWinId( window ); + XWindowAttributes a; + XGetWindowAttributes( dpy, window, &a ); + crect.setRect( a.x, a.y, a.width, a.height ); + + if ( a.map_state == IsUnmapped ) + clearWState( WState_Visible ); + else + setWState( WState_Visible ); + + TQPaintDeviceX11Data* xd = getX11Data( TRUE ); + + // find which screen the window is on... + xd->x_screen = TQPaintDevice::x11AppScreen(); // by default, use the default :) + int i; + for ( i = 0; i < ScreenCount( dpy ); i++ ) { + if ( RootWindow( dpy, i ) == a.root ) { + xd->x_screen = i; + break; + } + } + + xd->x_depth = a.depth; + xd->x_cells = DisplayCells( dpy, xd->x_screen ); + xd->x_visual = a.visual; + xd->x_defvisual = ( XVisualIDFromVisual( a.visual ) == + XVisualIDFromVisual( (Visual*)x11AppVisual(x11Screen()) ) ); + xd->x_colormap = a.colormap; + xd->x_defcolormap = ( a.colormap == x11AppColormap( x11Screen() ) ); + setX11Data( xd ); + } else if ( desktop ) { // desktop widget + id = (WId)parentw; // id = root window + TQWidget *otherDesktop = find( id ); // is there another desktop? + if ( otherDesktop && otherDesktop->testWFlags(WPaintDesktop) ) { + otherDesktop->setWinId( 0 ); // remove id from widget mapper + setWinId( id ); // make sure otherDesktop is + otherDesktop->setWinId( id ); // found first + } else { + setWinId( id ); + } + } else { + if ( x11DefaultVisual() && x11DefaultColormap() ) { + id = (WId)qt_XCreateSimpleWindow( this, dpy, parentw, + crect.left(), crect.top(), + crect.width(), crect.height(), + 0, + black.pixel(x11Screen()), + bg_col.pixel(x11Screen()) ); + } else { + wsa.background_pixel = bg_col.pixel(x11Screen()); + wsa.border_pixel = black.pixel(x11Screen()); + wsa.colormap = (Colormap)x11Colormap(); + id = (WId)qt_XCreateWindow( this, dpy, parentw, + crect.left(), crect.top(), + crect.width(), crect.height(), + 0, x11Depth(), InputOutput, + (Visual*)x11Visual(), + CWBackPixel|CWBorderPixel|CWColormap, + &wsa ); + } + + setWinId( id ); // set widget id/handle + hd + } + +#ifndef TQT_NO_XFTFREETYPE + if (rendhd) { + XftDrawDestroy( (XftDraw *) rendhd ); + rendhd = 0; + } + + if ( tqt_has_xft ) + rendhd = (HANDLE) XftDrawCreate( dpy, id, (Visual *) x11Visual(), + x11Colormap() ); +#endif // TQT_NO_XFTFREETYPE + + // NET window states + long net_winstates[6] = { 0, 0, 0, 0, 0, 0 }; + long net_winactions[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int curr_winstate = 0; + int curr_winaction = 0; + + // Add all default actions that cannot be turned off + net_winactions[curr_winaction++] = qt_net_wm_action_stick; + net_winactions[curr_winaction++] = qt_net_wm_action_fullscreen; + net_winactions[curr_winaction++] = qt_net_wm_action_change_desktop; + net_winactions[curr_winaction++] = qt_net_wm_action_above; + net_winactions[curr_winaction++] = qt_net_wm_action_below; + + struct { + ulong flags, functions, decorations; + long input_mode; + ulong status; + } mwmhints; + + mwmhints.flags = mwmhints.functions = 0L; + mwmhints.decorations = (1L << 0); // MWM_DECOR_ALL + mwmhints.input_mode = 0L; + mwmhints.status = 0L; + + if ( testNFlags(WX11DisableResize) ) { + mwmhints.functions |= (1L << 1); // MWM_FUNC_RESIZE + mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL + mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS + } + else { + net_winactions[curr_winaction++] = qt_net_wm_action_resize; + } + + if ( testNFlags(WX11DisableMove) ) { + mwmhints.functions |= (1L << 2); // MWM_FUNC_MOVE + mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL + mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS + } + else { + net_winactions[curr_winaction++] = qt_net_wm_action_move; + } + + if ( testNFlags(WX11DisableMinimize) ) { + mwmhints.functions |= (1L << 3); // MWM_FUNC_MINIMIZE + mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL + mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS + } + else { + net_winactions[curr_winaction++] = qt_net_wm_action_minimize; + } + + if ( testNFlags(WX11DisableMaximize) ) { + mwmhints.functions |= (1L << 4); // MWM_FUNC_MAXIMIZE + mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL + mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS + } + else { + net_winactions[curr_winaction++] = qt_net_wm_action_max_h; + net_winactions[curr_winaction++] = qt_net_wm_action_max_v; + } + + if ( testNFlags(WX11DisableClose) ) { + mwmhints.functions |= (1L << 5); // MWM_FUNC_CLOSE + mwmhints.functions |= (1L << 0); // MWM_FUNC_ALL + mwmhints.flags |= (1L << 0); // MWM_HINTS_FUNCTIONS + } + else { + net_winactions[curr_winaction++] = qt_net_wm_action_close; + } + + if ( ! testNFlags(WX11DisableShade) ) { + net_winactions[curr_winaction++] = qt_net_wm_action_shade; + } + + if (topLevel && ! (desktop || popup)) { + ulong wsa_mask = 0; + + if ( testWFlags(WStyle_Splash) ) { + if (qt_net_supports(qt_net_wm_window_type_splash)) { + clearWFlags( WX11BypassWM ); + } else { + setWFlags( WX11BypassWM | WStyle_Tool | WStyle_NoBorder ); + } + } + if (testWFlags(WStyle_Customize)) { + mwmhints.decorations = 0L; + mwmhints.flags |= (1L << 1); // MWM_HINTS_DECORATIONS + + if ( testWFlags( WStyle_NormalBorder | WStyle_DialogBorder ) ) { + mwmhints.decorations |= (1L << 1); // MWM_DECOR_BORDER + mwmhints.decorations |= (1L << 2); // MWM_DECOR_RESIZEH + } + + if ( testWFlags( WStyle_Title ) ) + mwmhints.decorations |= (1L << 3); // MWM_DECOR_TITLE + + if ( testWFlags( WStyle_SysMenu ) ) + mwmhints.decorations |= (1L << 4); // MWM_DECOR_MENU + + if ( testWFlags( WStyle_Minimize ) ) + mwmhints.decorations |= (1L << 5); // MWM_DECOR_MINIMIZE + + if ( testWFlags( WStyle_Maximize ) ) + mwmhints.decorations |= (1L << 6); // MWM_DECOR_MAXIMIZE + + if (testWFlags(WStyle_Tool)) { + wsa.save_under = True; + wsa_mask |= CWSaveUnder; + } + } else if (testWFlags(WType_Dialog)) { + setWFlags(WStyle_NormalBorder | WStyle_Title | + WStyle_SysMenu | WStyle_ContextHelp); + } else { + setWFlags(WStyle_NormalBorder | WStyle_Title | + WStyle_MinMax | WStyle_SysMenu); + + // maximized netwm state + if (testWFlags(WState_Maximized)) { + net_winstates[curr_winstate++] = qt_net_wm_state_max_v; + net_winstates[curr_winstate++] = qt_net_wm_state_max_h; + } + } + + // stays on top + if (testWFlags(WStyle_StaysOnTop)) { + net_winstates[curr_winstate++] = qt_net_wm_state_above; + net_winstates[curr_winstate++] = qt_net_wm_state_stays_on_top; + } + + if (testWFlags(WShowModal)) { + mwmhints.input_mode = 3L; // MWM_INPUT_FULL_APPLICATION_MODAL + mwmhints.flags |= (1L << 2); // MWM_HINTS_INPUT_MODE + + net_winstates[curr_winstate++] = qt_net_wm_state_modal; + } + + if ( testWFlags( WX11BypassWM ) ) { + wsa.override_redirect = True; + wsa_mask |= CWOverrideRedirect; + } + + if ( wsa_mask && initializeWindow ) + XChangeWindowAttributes( dpy, id, wsa_mask, &wsa ); + } else { + if (! testWFlags(WStyle_Customize)) + setWFlags(WStyle_NormalBorder | WStyle_Title | + WStyle_MinMax | WStyle_SysMenu); + } + + + if ( !initializeWindow ) { + // do no initialization + } else if ( popup ) { // popup widget + wsa.override_redirect = True; + wsa.save_under = True; + XChangeWindowAttributes( dpy, id, CWOverrideRedirect | CWSaveUnder, + &wsa ); + XClassHint class_hint; + class_hint.res_name = (char *) tqAppName(); // application name + class_hint.res_class = (char *) tqAppClass(); // application class + XSetClassHint( dpy, id, &class_hint ); + } else if ( topLevel && !desktop ) { // top-level widget + TQWidget *p = parentWidget(); // real parent + if (p) + p = p->topLevelWidget(); + + if (dialog || testWFlags(WStyle_DialogBorder) || testWFlags(WStyle_Tool)) { + if ( p ) + XSetTransientForHint( dpy, id, p->winId() ); + else // application-modal + XSetTransientForHint( dpy, id, root_win ); + } + + // find the real client leader, i.e. a toplevel without parent + while ( p && p->parentWidget()) + p = p->parentWidget()->topLevelWidget(); + + XSizeHints size_hints; + size_hints.flags = USSize | PSize | PWinGravity; + size_hints.x = crect.left(); + size_hints.y = crect.top(); + size_hints.width = crect.width(); + size_hints.height = crect.height(); + size_hints.win_gravity = + TQApplication::reverseLayout() ? NorthEastGravity : NorthWestGravity; + + XWMHints wm_hints; // window manager hints + wm_hints.input = True; + wm_hints.initial_state = NormalState; + wm_hints.flags = InputHint | StateHint; + if ( !qt_x11_wm_client_leader ) + qt_x11_create_wm_client_leader(); + + wm_hints.window_group = qt_x11_wm_client_leader; + wm_hints.flags |= WindowGroupHint; + + XClassHint class_hint; + class_hint.res_name = (char *) tqAppName(); // application name + class_hint.res_class = (char *) tqAppClass(); // application class + + XSetWMProperties( dpy, id, 0, 0, 0, 0, &size_hints, &wm_hints, &class_hint ); + + XResizeWindow( dpy, id, crect.width(), crect.height() ); + XStoreName( dpy, id, tqAppName() ); + Atom protocols[5]; + int n = 0; + protocols[n++] = tqt_wm_delete_window; // support del window protocol + protocols[n++] = tqt_wm_take_focus; // support take focus window protocol + protocols[n++] = qt_net_wm_ping; // support _NET_WM_PING protocol +#ifndef TQT_NO_XSYNC + protocols[n++] = qt_net_wm_sync_request;// support the _NET_WM_SYNC_REQUEST protocol +#endif + if ( testWFlags( WStyle_ContextHelp ) ) + protocols[n++] = qt_net_wm_context_help; + XSetWMProtocols( dpy, id, protocols, n ); + + // set mwm hints + if ( mwmhints.flags != 0l ) + XChangeProperty(dpy, id, qt_xa_motif_wm_hints, qt_xa_motif_wm_hints, 32, + PropModeReplace, (unsigned char *) &mwmhints, 5); + else + XDeleteProperty(dpy, id, qt_xa_motif_wm_hints); + + // set _NET_WM_WINDOW_STATE + if (curr_winstate > 0) + XChangeProperty(dpy, id, qt_net_wm_state, XA_ATOM, 32, PropModeReplace, + (unsigned char *) net_winstates, curr_winstate); + else + XDeleteProperty(dpy, id, qt_net_wm_state); + + // set _NET_WM_ALLOWED_ACTIONS + if (curr_winaction > 0) + XChangeProperty(dpy, id, qt_net_wm_action, XA_ATOM, 32, PropModeReplace, + (unsigned char *) net_winactions, curr_winaction); + else + XDeleteProperty(dpy, id, qt_net_wm_action); + +#ifndef TQT_NO_XSYNC + // set _NET_WM_SYNC_COUNTER + createSyncCounter(); + long counterVal = topData()->syncCounter; + XChangeProperty( dpy, id, qt_net_wm_sync_request_counter, XA_CARDINAL, 32, PropModeReplace, + (unsigned char*) &counterVal, 1); +#endif + + // when we create a toplevel widget, the frame strut should be dirty + fstrut_dirty = 1; + + } else { + // non-toplevel widgets don't have a frame, so no need to + // update the strut + fstrut_dirty = 0; + } + + if (initializeWindow && (popup || (topLevel && !desktop))) { // properties set on all toplevel windows + x11SetWindowType(); + + // set _NET_WM_PID + long curr_pid = getpid(); + XChangeProperty(dpy, id, qt_net_wm_pid, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &curr_pid, 1); + + // declare the widget's object name as window role + XChangeProperty( dpy, id, + tqt_window_role, XA_STRING, 8, PropModeReplace, + (unsigned char *)name(), tqstrlen( name() ) ); + + // set client leader property + if ( !qt_x11_wm_client_leader ) + qt_x11_create_wm_client_leader(); + XChangeProperty( dpy, id, qt_wm_client_leader, + XA_WINDOW, 32, PropModeReplace, + (unsigned char *)&qt_x11_wm_client_leader, 1 ); + } + + if ( initializeWindow ) { + // don't erase when resizing + wsa.bit_gravity = + TQApplication::reverseLayout() ? NorthEastGravity : NorthWestGravity; + XChangeWindowAttributes( dpy, id, CWBitGravity, &wsa ); + } + + setWState( WState_MouseTracking ); + setMouseTracking( FALSE ); // also sets event mask + if ( desktop ) { + setWState( WState_Visible ); + } else if ( topLevel ) { // set X cursor + setWState( WState_OwnCursor ); + if ( initializeWindow ) + tqt_x11_enforce_cursor( this ); + } + + if ( destroyw ) + qt_XDestroyWindow( this, dpy, destroyw ); + +#if !defined(TQT_NO_IM_EXTENSIONS) + ic = 0; +#endif +} + + +/*! + Frees up window system resources. Destroys the widget window if \a + destroyWindow is TRUE. + + destroy() calls itself recursively for all the child widgets, + passing \a destroySubWindows for the \a destroyWindow parameter. + To have more control over destruction of subwidgets, destroy + subwidgets selectively first. + + This function is usually called from the TQWidget destructor. +*/ + +void TQWidget::destroy( bool destroyWindow, bool destroySubWindows ) +{ + deactivateWidgetCleanup(); + if ( testWState(WState_Created) ) { + clearWState( WState_Created ); + if ( children() ) { + TQObjectListIt it(*children()); + TQObject *obj; + while ( (obj=it.current()) ) { // destroy all widget children + ++it; + if ( obj->isWidgetType() ) + ((TQWidget*)obj)->destroy(destroySubWindows, + destroySubWindows); + } + } + if ( mouseGrb == this ) + releaseMouse(); + if ( keyboardGrb == this ) + releaseKeyboard(); + if ( isTopLevel() ) + qt_deferred_map_take( this ); + if ( testWFlags(WShowModal) ) // just be sure we leave modal + tqt_leave_modal( this ); + else if ( testWFlags(WType_Popup) ) + tqApp->closePopup( this ); + +#ifndef TQT_NO_XFTFREETYPE + if ( rendhd) { + if ( destroyWindow ) + XftDrawDestroy( (XftDraw *) rendhd ); + else + free( (void*) rendhd ); + rendhd = 0; + } +#endif // TQT_NO_XFTFREETYPE + + if ( testWFlags(WType_Desktop) ) { + if ( acceptDrops() ) + qt_dnd_enable( this, FALSE ); + } else { + if ( destroyWindow ) + qt_XDestroyWindow( this, x11Display(), winid ); + } +#ifndef TQT_NO_XSYNC + destroySyncCounter(); +#endif + setWinId( 0 ); + + extern void qPRCleanup( TQWidget *widget ); // from qapplication_x11.cpp + if ( testWState(WState_Reparented) ) + qPRCleanup(this); + + if( this == icHolderWidget() ) { + destroyInputContext(); + } else { +#ifndef TQT_NO_IM + // release previous focus information participating with + // preedit preservation of qic + TQInputContext *qic = getInputContext(); + if ( qic ) + qic->releaseComposingWidget( this ); +#endif // TQT_NO_IM + } + } +} + +void TQWidget::reparentSys( TQWidget *parent, WFlags f, const TQPoint &p, bool showIt ) +{ + extern void qPRCreate( const TQWidget *, Window ); + + Display *dpy = x11Display(); + TQCursor oldcurs; + bool setcurs = testWState(WState_OwnCursor); + if ( setcurs ) { + oldcurs = cursor(); + unsetCursor(); + } + + // dnd unregister (we will register again below) + bool accept_drops = acceptDrops(); + setAcceptDrops( FALSE ); + + // clear mouse tracking, re-enabled below + bool mouse_tracking = hasMouseTracking(); + clearWState(WState_MouseTracking); + + TQWidget* oldtlw = topLevelWidget(); + TQWidget *oldparent = parentWidget(); + WId old_winid = winid; + if ( testWFlags(WType_Desktop) ) + old_winid = 0; + setWinId( 0 ); + + // hide and reparent our own window away. Otherwise we might get + // destroyed when emitting the child remove event below. See TQWorkspace. + XUnmapWindow( x11Display(), old_winid ); + XReparentWindow( x11Display(), old_winid, + RootWindow( x11Display(), x11Screen() ), 0, 0 ); + + if ( this == icHolderWidget() ) { + // input contexts are sometimes associated with toplevel widgets, so + // we need destroy the context here. if we are reparenting back to + // toplevel, then we may have another context created, otherwise we + // will use our new ic holder's context + destroyInputContext(); + } + +#ifndef TQT_NO_XSYNC + destroySyncCounter(); +#endif + + if ( isTopLevel() || !parent ) // we are toplevel, or reparenting to toplevel + topData()->parentWinId = 0; + + if ( parent != parentObj ) { + if ( parentObj ) // remove from parent + parentObj->removeChild( this ); + if ( parent ) // insert into new parent + parent->insertChild( this ); + } + bool enable = isEnabled(); // remember status + FocusPolicy fp = focusPolicy(); + TQSize s = size(); + TQPixmap *bgp = (TQPixmap *)backgroundPixmap(); + TQColor bgc = bg_col; // save colors + TQString capt= caption(); + widget_flags = f; + clearWState( WState_Created | WState_Visible | WState_ForceHide ); + create(); + if ( isTopLevel() || (!parent || parent->isVisible() ) ) + setWState( WState_ForceHide ); // new widgets do not show up in already visible parents + + const TQObjectList *chlist = children(); + if ( chlist ) { // reparent children + TQObjectList childList(*chlist); + TQObjectListIt it(childList); // iterate over copy + TQObject *obj; + while ( (obj=it.current()) ) { + if ( obj->isWidgetType() ) { + TQWidget *w = (TQWidget *)obj; + if ( !w->isTopLevel() ) { + XReparentWindow( x11Display(), w->winId(), winId(), + w->geometry().x(), w->geometry().y() ); + } else if ( w->isPopup() + || w->testWFlags(WStyle_DialogBorder) + || w->testWFlags(WType_Dialog) + || w->testWFlags(WStyle_Tool) ) { + /* + when reparenting toplevel windows with toplevel-transient children, + we need to make sure that the window manager gets the updated + WM_TRANSIENT_FOR information... unfortunately, some window managers + don't handle changing WM_TRANSIENT_FOR before the toplevel window is + visible, so we unmap and remap all toplevel-transient children *after* + the toplevel parent has been mapped. thankfully, this is easy in TQt :) + */ + XUnmapWindow(w->x11Display(), w->winId()); + XSetTransientForHint(w->x11Display(), w->winId(), winId()); + TQApplication::postEvent(w, new TQEvent(TQEvent::ShowWindowRequest)); + } + } + ++it; + } + } + qPRCreate( this, old_winid ); + if ( bgp ) + XSetWindowBackgroundPixmap( dpy, winid, bgp->handle() ); + else + XSetWindowBackground( dpy, winid, bgc.pixel(x11Screen()) ); + + if (isTopLevel()) { + // preserve maximized/fullscreen flags and the normal geometry + uint save_state = widget_state & (WState_Maximized | WState_FullScreen); + const TQRect r = topData()->normalGeometry; + setGeometry(p.x(), p.y(), s.width(), s.height()); + widget_state |= save_state; + topData()->normalGeometry = r; + } else { + setGeometry(p.x(), p.y(), s.width(), s.height()); + } + + setEnabled( enable ); + setFocusPolicy( fp ); + if ( !capt.isNull() ) { + extra->topextra->caption = TQString::null; + setCaption( capt ); + } + if ( showIt ) + show(); + if ( old_winid ) + qt_XDestroyWindow( this, dpy, old_winid ); + if ( setcurs ) + setCursor(oldcurs); + + reparentFocusWidgets( oldtlw ); + + // re-register dnd + if (oldparent) + oldparent->checkChildrenDnd(); + + if ( accept_drops ) + setAcceptDrops( TRUE ); + else { + checkChildrenDnd(); + topData()->dnd = 0; + qt_dnd_enable(this, (extra && extra->children_use_dnd)); + } + + // re-enable mouse tracking + if (mouse_tracking) + setMouseTracking(mouse_tracking); +} + +// Sets the EWMH (netwm) window type. Needed as a separate function +// because create() may be too soon in some cases. +void TQWidget::x11SetWindowType( X11WindowType type ) +{ + // NET window types + long net_wintypes[7] = { 0, 0, 0, 0, 0, 0, 0 }; + int curr_wintype = 0; + if( testWFlags(WType_Desktop)) + return; + if( type == X11WindowTypeSelect ) { + if ( testWFlags(WStyle_Splash)) { + if (qt_net_supports(qt_net_wm_window_type_splash)) { + net_wintypes[curr_wintype++] = qt_net_wm_window_type_splash; + } + } else if (inherits("TQToolBar")) { + // toolbar netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_toolbar; + } else if (testWFlags(WStyle_Customize) && testWFlags(WStyle_Tool)) { + // utility netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_utility; + } else if (testWFlags(WType_Dialog)) { + // dialog netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_dialog; + } + } else if( type == X11WindowTypeCombo ) { + // combo netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_combo; + } else if( type == X11WindowTypeDND ) { + // dnd netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_dnd; + } else if( type == X11WindowTypeDropdown ) { + // dropdown netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_dropdown_menu; + } else if( type == X11WindowTypePopup ) { + // popup netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_popup_menu; + } else if( type == X11WindowTypeMenu ) { + // menu netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_menu; + } else if( type == X11WindowTypeTooltip ) { + // tooltip netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_tooltip; + } + + // normal netwm type - default + net_wintypes[curr_wintype++] = qt_net_wm_window_type_normal; + // set _NET_WM_WINDOW_TYPE + if (curr_wintype > 0) + XChangeProperty(x11Display(), winId(), qt_net_wm_window_type, XA_ATOM, 32, PropModeReplace, + (unsigned char *) net_wintypes, curr_wintype); + else + XDeleteProperty(x11Display(), winId(), qt_net_wm_window_type); +} + +void TQWidget::x11SetWindowTransient( TQWidget* parent ) +{ + XSetTransientForHint( x11Display(), winId(), parent->winId()); +} + +/*! + Translates the widget coordinate \a pos to global screen + coordinates. For example, \c{mapToGlobal(TQPoint(0,0))} would give + the global coordinates of the top-left pixel of the widget. + + \sa mapFromGlobal() mapTo() mapToParent() +*/ + +TQPoint TQWidget::mapToGlobal( const TQPoint &pos ) const +{ + int x, y; + Window child; + XTranslateCoordinates( x11Display(), winId(), + TQApplication::desktop()->screen(x11Screen())->winId(), + pos.x(), pos.y(), &x, &y, &child ); + return TQPoint( x, y ); +} + +/*! + Translates the global screen coordinate \a pos to widget + coordinates. + + \sa mapToGlobal() mapFrom() mapFromParent() +*/ + +TQPoint TQWidget::mapFromGlobal( const TQPoint &pos ) const +{ + int x, y; + Window child; + XTranslateCoordinates( x11Display(), + TQApplication::desktop()->screen(x11Screen())->winId(), + winId(), pos.x(), pos.y(), &x, &y, &child ); + return TQPoint( x, y ); +} + +/*! + When a widget gets focus, it should call setMicroFocusHint() with + some appropriate position and size, \a x, \a y, \a width and \a + height. This has no \e visual effect, it just provides hints to + any system-specific input handling tools. + + The \a text argument should be TRUE if this is a position for text + input. + + In the Windows version of TQt, this method sets the system caret, + which is used for user Accessibility focus handling. If \a text + is TRUE, it also sets the IME composition window in Far East Asian + language input systems. + + In the X11 version of TQt, if \a text is TRUE, this method sets the + input method focus point in the preedit (XIM "spot" point) for + complex language input handling. + + The font \a f is a rendering hint to the currently active input method. + If \a f is 0 the widget's font is used. + + \sa microFocusHint() +*/ +void TQWidget::setMicroFocusHint(int x, int y, int width, int height, + bool text, TQFont *f ) +{ +#ifndef TQT_NO_IM + if ( text ) { + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if(qic) { + TQPoint gp = mapToGlobal( TQPoint( x, y ) ); + qic->setMicroFocus(gp.x(), gp.y(), width, height, f); + } + } +#endif + + if ( TQRect( x, y, width, height ) != microFocusHint() ) { + createExtra(); + extraData()->micro_focus_hint.setRect( x, y, width, height ); + } +} + + +void TQWidget::setFontSys( TQFont * ) +{ + // Nothing +} + + +void TQWidget::setBackgroundColorDirect( const TQColor &color ) +{ + bg_col = color; + if ( extra && extra->bg_pix ) { // kill the background pixmap + delete extra->bg_pix; + extra->bg_pix = 0; + } + XSetWindowBackground( x11Display(), winId(), bg_col.pixel(x11Screen()) ); +} + +static int allow_null_pixmaps = 0; + + +void TQWidget::setBackgroundPixmapDirect( const TQPixmap &pixmap ) +{ + TQPixmap old; + if ( extra && extra->bg_pix ) + old = *extra->bg_pix; + if ( !allow_null_pixmaps && pixmap.isNull() ) { + XSetWindowBackground( x11Display(), winId(), bg_col.pixel(x11Screen()) ); + if ( extra && extra->bg_pix ) { + delete extra->bg_pix; + extra->bg_pix = 0; + } + } else { + TQPixmap pm = pixmap; + if (!pm.isNull()) { + if ( pm.depth() == 1 && TQPixmap::defaultDepth() > 1 ) { + pm = TQPixmap( pixmap.size() ); + bitBlt( &pm, 0, 0, &pixmap, 0, 0, pm.width(), pm.height() ); + } + } + if ( extra && extra->bg_pix ) + delete extra->bg_pix; + else + createExtra(); + extra->bg_pix = new TQPixmap( pm ); + TQ_CHECK_PTR( extra->bg_pix ); + extra->bg_pix->x11SetScreen( x11Screen() ); + XSetWindowBackgroundPixmap( x11Display(), winId(), extra->bg_pix->handle() ); + if ( testWFlags(WType_Desktop) ) // save rootinfo later + qt_updated_rootinfo(); + } +} + + +/*! + Sets the window-system background of the widget to nothing. + + Note that "nothing" is actually a pixmap that isNull(), thus you + can check for an empty background by checking backgroundPixmap(). + + \sa setBackgroundPixmap(), setBackgroundColor() +*/ +void TQWidget::setBackgroundEmpty() +{ + allow_null_pixmaps++; + setErasePixmap(TQPixmap()); + allow_null_pixmaps--; +} + + +void TQWidget::setBackgroundX11Relative() +{ + XSetWindowBackgroundPixmap( x11Display(), winId(), ParentRelative ); +} + +void TQWidget::setCursor( const TQCursor &cursor ) +{ + if ( cursor.handle() != arrowCursor.handle() + || (extra && extra->curs) ) { + createExtra(); + delete extra->curs; + extra->curs = new TQCursor(cursor); + } + setWState( WState_OwnCursor ); + tqt_x11_enforce_cursor( this ); + XFlush( x11Display() ); +} + +void TQWidget::unsetCursor() +{ + if ( extra ) { + delete extra->curs; + extra->curs = 0; + } + if ( !isTopLevel() ) + clearWState( WState_OwnCursor ); + tqt_x11_enforce_cursor( this ); + XFlush( x11Display() ); +} + +static XTextProperty* +qstring_to_xtp( const TQString& s ) +{ + static XTextProperty tp = { 0, 0, 0, 0 }; + static bool free_prop = TRUE; // we can't free tp.value in case it references + // the data of the static TQCString below. + if ( tp.value ) { + if ( free_prop ) + XFree( tp.value ); + tp.value = 0; + free_prop = TRUE; + } + + static const TQTextCodec* mapper = TQTextCodec::codecForLocale(); + int errCode = 0; + if ( mapper ) { + TQCString mapped = mapper->fromUnicode(s); + char* tl[2]; + tl[0] = mapped.data(); + tl[1] = 0; + errCode = XmbTextListToTextProperty( TQPaintDevice::x11AppDisplay(), + tl, 1, XStdICCTextStyle, &tp ); +#if defined(QT_DEBUG) + if ( errCode < 0 ) + tqDebug( "qstring_to_xtp result code %d", errCode ); +#endif + } + if ( !mapper || errCode < 0 ) { + static TQCString qcs; + qcs = s.ascii(); + tp.value = (uchar*)qcs.data(); + tp.encoding = XA_STRING; + tp.format = 8; + tp.nitems = qcs.length(); + free_prop = FALSE; + } + + // ### If we knew WM could understand unicode, we could use + // ### a much simpler, cheaper encoding... + /* + tp.value = (XChar2b*)s.unicode(); + tp.encoding = XA_UNICODE; // wish + tp.format = 16; + tp.nitems = s.length(); + */ + + return &tp; +} + +void TQWidget::setCaption( const TQString &caption ) +{ + if ( TQWidget::caption() == caption ) + return; + + topData()->caption = caption; + XSetWMName( x11Display(), winId(), qstring_to_xtp(caption) ); + + TQCString net_wm_name = caption.utf8(); + XChangeProperty(x11Display(), winId(), qt_net_wm_name, qt_utf8_string, 8, + PropModeReplace, (unsigned char *)net_wm_name.data(), + net_wm_name.length()); + + TQEvent e( TQEvent::CaptionChange ); + TQApplication::sendEvent( this, &e ); +} + +void TQWidget::setIcon( const TQPixmap &pixmap ) +{ + if ( extra && extra->topextra ) { + delete extra->topextra->icon; + extra->topextra->icon = 0; + } else { + createTLExtra(); + } + Pixmap icon_pixmap = 0; + Pixmap mask_pixmap = 0; + TQPixmap* pm = NULL; + if ( !pixmap.isNull() ) { + if (pixmap.depth() == 24) { + pm = new TQPixmap( pixmap ); + } + else { + // With most window managers, only 24-bit icon pixmaps are allowed in the WM hints, otherwise corrupt icons will be displayed + // Convert provided pixmaps to 24-bit here + int w = pixmap.width(); + int h = pixmap.height(); + pm = new TQPixmap( pixmap.width(), pixmap.height(), 24 ); + TQImage iconImage = pixmap.convertToImage(); + + // Load the new 24-bit RGB pixmap with data + GC gc; + pm->detach(); + TQt::HANDLE pmHandle = pm->handle(); + gc = XCreateGC(x11Display(), pmHandle, 0, 0); + for (int y = 0; y < h; ++y) { + TQRgb *ls = (TQRgb *)iconImage.scanLine( y ); + for (int x = 0; x < w; ++x) { + TQRgb l = ls[x]; + int r = int( tqRed( l ) ); + int g = int( tqGreen( l ) ); + int b = int( tqBlue( l ) ); + XSetForeground(x11Display(), gc, (r << 16) | (g << 8) | b ); + XDrawPoint(x11Display(), pmHandle, gc, x, y); + } + } + XFreeGC(x11Display(), gc); + } + + extra->topextra->icon = pm; + if ( !pm->mask() ) { + pm->setMask( pm->createHeuristicMask() ); // may do detach() + } + icon_pixmap = pm->handle(); + if ( pm->mask() ) { + mask_pixmap = pm->mask()->handle(); + } + } + XWMHints *h = XGetWMHints( x11Display(), winId() ); + XWMHints wm_hints; + bool got_hints = h != 0; + if ( !got_hints ) { + h = &wm_hints; + h->flags = 0; + } + h->icon_pixmap = icon_pixmap; + h->icon_mask = mask_pixmap; + h->flags |= IconPixmapHint | IconMaskHint; + XSetWMHints( x11Display(), winId(), h ); + if ( got_hints ) + XFree( (char *)h ); + TQEvent e( TQEvent::IconChange ); + TQApplication::sendEvent( this, &e ); +} + +void TQWidget::setIconText( const TQString &iconText ) +{ + if (TQWidget::iconText() == iconText) + return; + + topData()->iconText = iconText; + XSetWMIconName( x11Display(), winId(), qstring_to_xtp(iconText) ); + + TQCString net_wm_icon_name = iconText.utf8(); + XChangeProperty(x11Display(), winId(), qt_net_wm_icon_name, qt_utf8_string, 8, PropModeReplace, + (unsigned char *) net_wm_icon_name.data(), net_wm_icon_name.length()); +} + +void TQWidget::setMouseTracking( bool enable ) +{ + bool gmt = TQApplication::hasGlobalMouseTracking(); + if ( !enable == !testWState(WState_MouseTracking) && !gmt ) + return; + uint m = (enable || gmt) ? (uint)PointerMotionMask : 0; + if ( enable ) + setWState( WState_MouseTracking ); + else + clearWState( WState_MouseTracking ); + if ( testWFlags(WType_Desktop) ) { // desktop widget? + TQWidget* main_desktop = find( winId() ); + if ( main_desktop->testWFlags(WPaintDesktop) ) + XSelectInput( x11Display(), winId(), + stdDesktopEventMask | ExposureMask ); + else + XSelectInput( x11Display(), winId(), stdDesktopEventMask ); + } else { + XSelectInput( x11Display(), winId(), + m | stdWidgetEventMask ); +#if defined (QT_TABLET_SUPPORT) + if ( devStylus != NULL ) { + XSelectExtensionEvent( x11Display(), winId(), event_list_stylus, + qt_curr_events_stylus ); + } + if ( devEraser != NULL ) { + XSelectExtensionEvent( x11Display(), winId(), event_list_eraser, + qt_curr_events_eraser ); + } +#endif + } +} + + +/*! + Grabs the mouse input. + + This widget receives all mouse events until releaseMouse() is + called; other widgets get no mouse events at all. Keyboard + events are not affected. Use grabKeyboard() if you want to grab + that. + + \warning Bugs in mouse-grabbing applications very often lock the + terminal. Use this function with extreme caution, and consider + using the \c -nograb command line option while debugging. + + It is almost never necessary to grab the mouse when using TQt, as + TQt grabs and releases it sensibly. In particular, TQt grabs the + mouse when a mouse button is pressed and keeps it until the last + button is released. + + Note that only visible widgets can grab mouse input. If + isVisible() returns FALSE for a widget, that widget cannot call + grabMouse(). + + \sa releaseMouse() grabKeyboard() releaseKeyboard() grabKeyboard() + focusWidget() +*/ + +void TQWidget::grabMouse() +{ + if ( isVisible() && !qt_nograb() ) { + if ( mouseGrb ) + mouseGrb->releaseMouse(); +#if defined(QT_CHECK_STATE) + int status = +#endif + XGrabPointer( x11Display(), winId(), False, + (uint)( ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | EnterWindowMask | + LeaveWindowMask ), + GrabModeAsync, GrabModeAsync, + None, None, tqt_x_time ); +#if defined(QT_CHECK_STATE) + if ( status ) { + const char *s = + status == GrabNotViewable ? "\"GrabNotViewable\"" : + status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" : + status == GrabFrozen ? "\"GrabFrozen\"" : + status == GrabInvalidTime ? "\"GrabInvalidTime\"" : + ""; + tqWarning( "Grabbing the mouse failed with %s", s ); + } +#endif + mouseGrb = this; + } +} + +/*! + \overload + + Grabs the mouse input and changes the cursor shape. + + The cursor will assume shape \a cursor (for as long as the mouse + focus is grabbed) and this widget will be the only one to receive + mouse events until releaseMouse() is called(). + + \warning Grabbing the mouse might lock the terminal. + + \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor() +*/ + +void TQWidget::grabMouse( const TQCursor &cursor ) +{ + if ( !qt_nograb() ) { + if ( mouseGrb != this ) { + if ( mouseGrb ) { + mouseGrb->releaseMouse(); + } +#if defined(QT_CHECK_STATE) + int status = +#endif + XGrabPointer( x11Display(), winId(), False, + (uint)(ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | EnterWindowMask | LeaveWindowMask), + GrabModeAsync, GrabModeAsync, + None, cursor.handle(), tqt_x_time ); +#if defined(QT_CHECK_STATE) + if ( status ) { + const char *s = + status == GrabNotViewable ? "\"GrabNotViewable\"" : + status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" : + status == GrabFrozen ? "\"GrabFrozen\"" : + status == GrabInvalidTime ? "\"GrabInvalidTime\"" : + ""; + tqWarning( "Grabbing the mouse failed with %s", s ); + } +#endif + mouseGrb = this; + } + } +} + +/*! + Releases the mouse grab. + + \sa grabMouse(), grabKeyboard(), releaseKeyboard() +*/ + +void TQWidget::releaseMouse() +{ + if ( !qt_nograb() && mouseGrb == this ) { + XUngrabPointer( x11Display(), tqt_x_time ); + XFlush( x11Display() ); + mouseGrb = 0; + } +} + +/*! + Grabs the keyboard input. + + This widget reveives all keyboard events until releaseKeyboard() + is called; other widgets get no keyboard events at all. Mouse + events are not affected. Use grabMouse() if you want to grab that. + + The focus widget is not affected, except that it doesn't receive + any keyboard events. setFocus() moves the focus as usual, but the + new focus widget receives keyboard events only after + releaseKeyboard() is called. + + If a different widget is currently grabbing keyboard input, that + widget's grab is released first. + + \sa releaseKeyboard() grabMouse() releaseMouse() focusWidget() +*/ + +void TQWidget::grabKeyboard() +{ + if ( !qt_nograb() ) { + if ( keyboardGrb != this ) { + if ( keyboardGrb ) { + keyboardGrb->releaseKeyboard(); + } + XGrabKeyboard( x11Display(), winid, False, GrabModeAsync, GrabModeAsync, tqt_x_time ); + keyboardGrb = this; + } + } +} + +/*! + Releases the keyboard grab. + + \sa grabKeyboard(), grabMouse(), releaseMouse() +*/ + +void TQWidget::releaseKeyboard() +{ + if ( !qt_nograb() && keyboardGrb == this ) { + XUngrabKeyboard( x11Display(), tqt_x_time ); + keyboardGrb = 0; + } +} + + +/*! + Returns the widget that is currently grabbing the mouse input. + + If no widget in this application is currently grabbing the mouse, + 0 is returned. + + \sa grabMouse(), keyboardGrabber() +*/ + +TQWidget *TQWidget::mouseGrabber() +{ + return mouseGrb; +} + +/*! + Returns the widget that is currently grabbing the keyboard input. + + If no widget in this application is currently grabbing the + keyboard, 0 is returned. + + \sa grabMouse(), mouseGrabber() +*/ + +TQWidget *TQWidget::keyboardGrabber() +{ + return keyboardGrb; +} + +/*! + Sets the top-level widget containing this widget to be the active + window. + + An active window is a visible top-level window that has the + keyboard input focus. + + This function performs the same operation as clicking the mouse on + the title bar of a top-level window. On X11, the result depends on + the Window Manager. If you want to ensure that the window is + stacked on top as well you should also call raise(). Note that the + window must be visible, otherwise setActiveWindow() has no effect. + + On Windows, if you are calling this when the application is not + currently the active one then it will not make it the active + window. It will flash the task bar entry blue to indicate that + the window has done something. This is because Microsoft do not + allow an application to interrupt what the user is currently doing + in another application. + + \sa isActiveWindow(), topLevelWidget(), show() +*/ + +void TQWidget::setActiveWindow() +{ + TQWidget *tlw = topLevelWidget(); + if ( tlw->isVisible() && !tlw->topData()->embedded && !qt_deferred_map_contains(tlw) ) { + XSetInputFocus( x11Display(), tlw->winId(), RevertToNone, tqt_x_time); + focusInputContext(); + } +} + + +/*! + Updates the widget unless updates are disabled or the widget is + hidden. + + This function does not cause an immediate repaint; instead it + schedules a paint event for processing when TQt returns to the main + event loop. This permits TQt to optimize for more speed and less + flicker than a call to repaint() does. + + Calling update() several times normally results in just one + paintEvent() call. + + TQt normally erases the widget's area before the paintEvent() call. + If the \c WRepaintNoErase widget flag is set, the widget is + responsible for painting all its pixels itself. + + \sa repaint(), paintEvent(), setUpdatesEnabled(), erase(), + setWFlags() +*/ + +void TQWidget::update() +{ + if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == + WState_Visible ) + TQApplication::postEvent( this, new TQPaintEvent( clipRegion(), !testWFlags(WRepaintNoErase) ) ); +} + +/*! + \overload + + Updates a rectangle (\a x, \a y, \a w, \a h) inside the widget + unless updates are disabled or the widget is hidden. + + This function does not cause an immediate repaint; instead it + schedules a paint event for processing when TQt returns to the main + event loop. This permits TQt to optimize for more speed and less + flicker and a call to repaint() does. + + Calling update() several times normally results in just one + paintEvent() call. + + If \a w is negative, it is replaced with \c{width() - x}. If \a h + is negative, it is replaced width \c{height() - y}. + + TQt normally erases the specified area before the paintEvent() + call. If the \c WRepaintNoErase widget flag is set, the widget is + responsible for painting all its pixels itself. + + \sa repaint(), paintEvent(), setUpdatesEnabled(), erase() +*/ + +void TQWidget::update( int x, int y, int w, int h ) +{ + if ( w && h && + (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) { + if ( w < 0 ) + w = crect.width() - x; + if ( h < 0 ) + h = crect.height() - y; + if ( w != 0 && h != 0 ) + TQApplication::postEvent( this, + new TQPaintEvent( clipRegion().intersect(TQRect(x,y,w,h)), + !testWFlags( WRepaintNoErase ) ) ); + } +} + +/*! + \overload void TQWidget::update( const TQRect &r ) + + Updates a rectangle \a r inside the widget unless updates are + disabled or the widget is hidden. + + This function does not cause an immediate repaint; instead it + schedules a paint event for processing when TQt returns to the main + event loop. This permits TQt to optimize for more speed and less + flicker and a call to repaint() does. + + Calling update() several times normally results in just one + paintEvent() call. +*/ + +/*! + \overload void TQWidget::repaint( bool erase ) + + This version repaints the entire widget. +*/ + +/*! + \overload void TQWidget::repaint() + + This version erases and repaints the entire widget. +*/ + +/*! + Repaints the widget directly by calling paintEvent() immediately, + unless updates are disabled or the widget is hidden. + + If \a erase is TRUE, TQt erases the area \a (x, y, w, h) before the + paintEvent() call. + + If \a w is negative, it is replaced with \c{width() - x}, and if + \a h is negative, it is replaced width \c{height() - y}. + + We suggest only using repaint() if you need an immediate repaint, + for example during animation. In almost all circumstances update() + is better, as it permits TQt to optimize for speed and minimize + flicker. + + \warning If you call repaint() in a function which may itself be + called from paintEvent(), you may get infinite recursion. The + update() function never causes recursion. + + \sa update(), paintEvent(), setUpdatesEnabled(), erase() +*/ + +void TQWidget::repaint( int x, int y, int w, int h, bool erase ) +{ + if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) { + if ( x > crect.width() || y > crect.height() ) + return; + if ( w < 0 ) + w = crect.width() - x; + if ( h < 0 ) + h = crect.height() - y; + TQRect r(x,y,w,h); + if ( r.isEmpty() ) + return; // nothing to do + TQPaintEvent e( r, erase ); + if ( r != rect() ) + qt_set_paintevent_clipping( this, r ); + if ( erase && w != 0 && h != 0 ) { + if ( backgroundOrigin() == WidgetOrigin ) + XClearArea( x11Display(), winId(), x, y, w, h, False ); + else + this->erase( x, y, w, h); + } + TQApplication::sendEvent( this, &e ); + qt_clear_paintevent_clipping(); + } +} + +/*! + \overload + + Repaints the widget directly by calling paintEvent() directly, + unless updates are disabled or the widget is hidden. + + Erases the widget region \a reg if \a erase is TRUE. + + Only use repaint if your widget needs to be repainted immediately, + for example when doing some animation. In all other cases, use + update(). Calling update() many times in a row will generate a + single paint event. + + \warning If you call repaint() in a function which may itself be + called from paintEvent(), you may get infinite recursion. The + update() function never causes recursion. + + \sa update(), paintEvent(), setUpdatesEnabled(), erase() +*/ + +void TQWidget::repaint( const TQRegion& reg, bool erase ) +{ + if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) { + TQPaintEvent e( reg, erase ); + qt_set_paintevent_clipping( this, reg ); + if ( erase ) + this->erase(reg); + TQApplication::sendEvent( this, &e ); + qt_clear_paintevent_clipping(); + } +} + +/*! + \overload void TQWidget::repaint( const TQRect &r, bool erase ) + + Repaints the widget directly by calling paintEvent() directly, + unless updates are disabled or the widget is hidden. + + Erases the widget region \a r if \a erase is TRUE. +*/ + +void TQWidget::setWindowState(uint newstate) +{ + bool needShow = FALSE; + uint oldstate = windowState(); + if (isTopLevel()) { + TQTLWExtra *top = topData(); + + if ((oldstate & WindowMaximized) != (newstate & WindowMaximized)) { + if (qt_net_supports(qt_net_wm_state_max_h) && qt_net_supports(qt_net_wm_state_max_v)) { + qt_net_change_wm_state(this, (newstate & WindowMaximized), + qt_net_wm_state_max_h, qt_net_wm_state_max_v); + } else if (! (newstate & WindowFullScreen)) { + if (newstate & WindowMaximized) { + // save original geometry + const TQRect normalGeometry = geometry(); + + if (isVisible()) { + updateFrameStrut(); + const TQRect maxRect = TQApplication::desktop()->availableGeometry(this); + const TQRect r = top->normalGeometry; + setGeometry(maxRect.x() + top->fleft, + maxRect.y() + top->ftop, + maxRect.width() - top->fleft - top->fright, + maxRect.height() - top->ftop - top->fbottom); + top->normalGeometry = r; + } + + if (top->normalGeometry.width() < 0) + top->normalGeometry = normalGeometry; + } else { + // restore original geometry + setGeometry(top->normalGeometry); + } + } + } + + if ((oldstate & WindowFullScreen) != (newstate & WindowFullScreen)) { + if (qt_net_supports(qt_net_wm_state_fullscreen)) { + qt_net_change_wm_state(this, (newstate & WindowFullScreen), + qt_net_wm_state_fullscreen); + } else { + needShow = isVisible(); + + if (newstate & WindowFullScreen) { + const TQRect normalGeometry = TQRect(pos(), size()); + + top->savedFlags = getWFlags(); + reparent(0, WType_TopLevel | WStyle_Customize | WStyle_NoBorder | + // preserve some widget flags + (getWFlags() & 0xffff0000), + mapToGlobal(TQPoint(0, 0))); + const TQRect r = top->normalGeometry; + setGeometry(tqApp->desktop()->screenGeometry(this)); + top->normalGeometry = r; + + if ( top->normalGeometry.width() < 0 ) + top->normalGeometry = normalGeometry; + } else { + reparent( 0, top->savedFlags, mapToGlobal(TQPoint(0, 0)) ); + + if (newstate & WindowMaximized) { + // from fullscreen to maximized + updateFrameStrut(); + const TQRect maxRect = TQApplication::desktop()->availableGeometry(this); + const TQRect r = top->normalGeometry; + setGeometry(maxRect.x() + top->fleft, + maxRect.y() + top->ftop, + maxRect.width() - top->fleft - top->fright, + maxRect.height() - top->ftop - top->fbottom); + top->normalGeometry = r; + } else { + // restore original geometry + setGeometry(top->normalGeometry); + } + } + } + } + + if ((oldstate & WindowMinimized) != (newstate & WindowMinimized)) { + if (isVisible()) { + if (newstate & WindowMinimized) { + XEvent e; + e.xclient.type = ClientMessage; + e.xclient.message_type = qt_wm_change_state; + e.xclient.display = x11Display(); + e.xclient.window = winid; + e.xclient.format = 32; + e.xclient.data.l[0] = IconicState; + e.xclient.data.l[1] = 0; + e.xclient.data.l[2] = 0; + e.xclient.data.l[3] = 0; + e.xclient.data.l[4] = 0; + XSendEvent(x11Display(), RootWindow(x11Display(), x11Screen()), + False, (SubstructureNotifyMask|SubstructureRedirectMask), &e); + } else { + XMapWindow(x11Display(), winId()); + } + } + + needShow = FALSE; + } + } + + widget_state &= ~(WState_Minimized | WState_Maximized | WState_FullScreen); + if (newstate & WindowMinimized) + widget_state |= WState_Minimized; + if (newstate & WindowMaximized) + widget_state |= WState_Maximized; + if (newstate & WindowFullScreen) + widget_state |= WState_FullScreen; + + if (needShow) + show(); + + if (newstate & WindowActive) + setActiveWindow(); + + TQEvent e(TQEvent::WindowStateChange); + TQApplication::sendEvent(this, &e); +} + +/*! + \internal + Platform-specific part of TQWidget::show(). +*/ + +void TQWidget::showWindow() +{ + if ( isTopLevel() ) { + XWMHints *h = XGetWMHints( x11Display(), winId() ); + XWMHints wm_hints; + bool got_hints = h != 0; + if ( !got_hints ) { + h = &wm_hints; + h->flags = 0; + } + h->initial_state = testWState(WState_Minimized) ? IconicState : NormalState; + h->flags |= StateHint; + XSetWMHints( x11Display(), winId(), h ); + if ( got_hints ) + XFree( (char *)h ); + + if (tqt_x_user_time != CurrentTime) { + XChangeProperty(x11Display(), winId(), qt_net_wm_user_time, XA_CARDINAL, + 32, PropModeReplace, (unsigned char *) &tqt_x_user_time, 1); + } + + if (!topData()->embedded && + topData()->parentWinId && + topData()->parentWinId != TQPaintDevice::x11AppRootWindow(x11Screen()) && + !isMinimized() ) { + qt_deferred_map_add( this ); + return; + } + + if (isMaximized() && !isFullScreen() + && !(qt_net_supports(qt_net_wm_state_max_h) + && qt_net_supports(qt_net_wm_state_max_v))) { + XMapWindow( x11Display(), winId() ); + tqt_wait_for_window_manager(this); + + // if the wm was not smart enough to adjust our size, do that manually + updateFrameStrut(); + TQRect maxRect = TQApplication::desktop()->availableGeometry(this); + + TQTLWExtra *top = topData(); + TQRect normalRect = top->normalGeometry; + + setGeometry(maxRect.x() + top->fleft, + maxRect.y() + top->ftop, + maxRect.width() - top->fleft - top->fright, + maxRect.height() - top->ftop - top->fbottom); + + // restore the original normalGeometry + top->normalGeometry = normalRect; + // internalSetGeometry() clears the maximized flag... make sure we set it back + setWState(WState_Maximized); + + return; + } + + if (isFullScreen() && !qt_net_supports(qt_net_wm_state_fullscreen)) { + XMapWindow(x11Display(), winId()); + tqt_wait_for_window_manager(this); + return; + } + } + XMapWindow( x11Display(), winId() ); +} + + +/*! + \internal + Platform-specific part of TQWidget::hide(). +*/ + +void TQWidget::hideWindow() +{ + clearWState( WState_Exposed ); + deactivateWidgetCleanup(); + if ( isTopLevel() ) { + qt_deferred_map_take( this ); + if ( winId() ) // in nsplugin, may be 0 + XWithdrawWindow( x11Display(), winId(), x11Screen() ); + + TQTLWExtra *top = topData(); + crect.moveTopLeft( TQPoint(crect.x() - top->fleft, crect.y() - top->ftop ) ); + + // zero the frame strut and mark it dirty + top->fleft = top->fright = top->ftop = top->fbottom = 0; + fstrut_dirty = TRUE; + + XFlush( x11Display() ); + } else { + if ( winId() ) // in nsplugin, may be 0 + XUnmapWindow( x11Display(), winId() ); + } +} + +/*! + Raises this widget to the top of the parent widget's stack. + + After this call the widget will be visually in front of any + overlapping sibling widgets. + + \sa lower(), stackUnder() +*/ + +void TQWidget::raise() +{ + TQWidget *p = parentWidget(); + if ( p && p->childObjects && p->childObjects->findRef(this) >= 0 ) + p->childObjects->append( p->childObjects->take() ); + XRaiseWindow( x11Display(), winId() ); +} + +/*! + Lowers the widget to the bottom of the parent widget's stack. + + After this call the widget will be visually behind (and therefore + obscured by) any overlapping sibling widgets. + + \sa raise(), stackUnder() +*/ + +void TQWidget::lower() +{ + TQWidget *p = parentWidget(); + if ( p && p->childObjects && p->childObjects->findRef(this) >= 0 ) + p->childObjects->insert( 0, p->childObjects->take() ); + XLowerWindow( x11Display(), winId() ); +} + + +/*! + Places the widget under \a w in the parent widget's stack. + + To make this work, the widget itself and \a w must be siblings. + + \sa raise(), lower() +*/ +void TQWidget::stackUnder( TQWidget* w) +{ + TQWidget *p = parentWidget(); + if ( !w || isTopLevel() || p != w->parentWidget() || this == w ) + return; + if ( p && p->childObjects && p->childObjects->findRef(w) >= 0 && p->childObjects->findRef(this) >= 0 ) { + p->childObjects->take(); + p->childObjects->insert( p->childObjects->findRef(w), this ); + } + Window stack[2]; + stack[0] = w->winId();; + stack[1] = winId(); + XRestackWindows( x11Display(), stack, 2 ); +} + + + +/* + The global variable qt_widget_tlw_gravity defines the window gravity of + the next top level window to be created. We do this when setting the + main widget's geometry and the "-geometry" command line option contains + a negative position. +*/ + +int qt_widget_tlw_gravity = NorthWestGravity; + +static void do_size_hints( TQWidget* widget, TQWExtra *x ) +{ + XSizeHints s; + s.flags = 0; + if ( x ) { + s.x = widget->x(); + s.y = widget->y(); + s.width = widget->width(); + s.height = widget->height(); + if ( x->minw > 0 || x->minh > 0 ) { // add minimum size hints + s.flags |= PMinSize; + s.min_width = x->minw; + s.min_height = x->minh; + } + if ( x->maxw < TQWIDGETSIZE_MAX || x->maxh < TQWIDGETSIZE_MAX ) { + s.flags |= PMaxSize; // add maximum size hints + s.max_width = x->maxw; + s.max_height = x->maxh; + } + if ( x->topextra && + (x->topextra->incw > 0 || x->topextra->inch > 0) ) + { // add resize increment hints + s.flags |= PResizeInc | PBaseSize; + s.width_inc = x->topextra->incw; + s.height_inc = x->topextra->inch; + s.base_width = x->topextra->basew; + s.base_height = x->topextra->baseh; + } + + if ( x->topextra && x->topextra->uspos) { + s.flags |= USPosition; + s.flags |= PPosition; + } + if ( x->topextra && x->topextra->ussize) { + s.flags |= USSize; + s.flags |= PSize; + } + } + s.flags |= PWinGravity; + s.win_gravity = qt_widget_tlw_gravity; // usually NorthWest + // reset in case it was set + qt_widget_tlw_gravity = + TQApplication::reverseLayout() ? NorthEastGravity : NorthWestGravity; + XSetWMNormalHints( widget->x11Display(), widget->winId(), &s ); +} + + +void TQWidget::internalSetGeometry( int x, int y, int w, int h, bool isMove ) +{ + Display *dpy = x11Display(); + + if ( testWFlags(WType_Desktop) ) + return; + if (isTopLevel()) { + if (!qt_net_supports(qt_net_wm_state_max_h) + && !qt_net_supports(qt_net_wm_state_max_v)) + clearWState(WState_Maximized); + if (!qt_net_supports(qt_net_wm_state_fullscreen)) + clearWState(WState_FullScreen); + topData()->normalGeometry = TQRect(0, 0, -1, -1); + } else { + // for TQWorkspace + clearWState(WState_Maximized); + clearWState(WState_FullScreen); + } + if ( extra ) { // any size restrictions? + w = TQMIN(w,extra->maxw); + h = TQMIN(h,extra->maxh); + w = TQMAX(w,extra->minw); + h = TQMAX(h,extra->minh); + } + if ( w < 1 ) // invalid size + w = 1; + if ( h < 1 ) + h = 1; + TQPoint oldPos( pos() ); + TQSize oldSize( size() ); + TQRect oldGeom( crect ); + TQRect r( x, y, w, h ); + + // We only care about stuff that changes the geometry, or may + // cause the window manager to change its state + if ( !isTopLevel() && oldGeom == r ) + return; + + crect = r; + bool isResize = size() != oldSize; + + if ( isTopLevel() ) { + if ( isMove ) + topData()->uspos = 1; + if ( isResize ) + topData()->ussize = 1; + do_size_hints( this, extra ); + } + + if ( isMove ) { + if (! qt_broken_wm) + // pos() is right according to ICCCM 4.1.5 + XMoveResizeWindow( dpy, winid, pos().x(), pos().y(), w, h ); + else + // work around 4Dwm's incompliance with ICCCM 4.1.5 + XMoveResizeWindow( dpy, winid, x, y, w, h ); + } else if ( isResize ) + XResizeWindow( dpy, winid, w, h ); + + if ( isVisible() ) { + if ( isMove && pos() != oldPos ) { + if ( ! qt_broken_wm ) { + // pos() is right according to ICCCM 4.1.5 + TQMoveEvent e( pos(), oldPos ); + TQApplication::sendEvent( this, &e ); + } else { + // work around 4Dwm's incompliance with ICCCM 4.1.5 + TQMoveEvent e( crect.topLeft(), oldGeom.topLeft() ); + TQApplication::sendEvent( this, &e ); + } + } + if ( isResize ) { + + // set config pending only on resize, see qapplication_x11.cpp, translateConfigEvent() + setWState( WState_ConfigPending ); + + TQResizeEvent e( size(), oldSize ); + TQApplication::sendEvent( this, &e ); + } + } else { + if ( isMove && pos() != oldPos ) { + if ( ! qt_broken_wm ) + // pos() is right according to ICCCM 4.1.5 + TQApplication::postEvent( this, new TQMoveEvent( pos(), oldPos ) ); + else + // work around 4Dwm's incompliance with ICCCM 4.1.5 + TQApplication::postEvent( this, new TQMoveEvent( crect.topLeft(), + oldGeom.topLeft() ) ); + } + if ( isResize ) + TQApplication::postEvent( this, + new TQResizeEvent( size(), oldSize ) ); + } +} + + +/*! + \overload + + This function corresponds to setMinimumSize( TQSize(minw, minh) ). + Sets the minimum width to \a minw and the minimum height to \a + minh. +*/ + +void TQWidget::setMinimumSize( int minw, int minh ) +{ +#if defined(QT_CHECK_RANGE) + if ( minw < 0 || minh < 0 ) + tqWarning("TQWidget::setMinimumSize: minw=%d, minh=%d. The smallest allowed size is (0,0)", minw, minh); +#endif + createExtra(); + if ( extra->minw == minw && extra->minh == minh ) + return; + extra->minw = minw; + extra->minh = minh; + if ( minw > width() || minh > height() ) { + bool resized = testWState( WState_Resized ); + resize( TQMAX(minw,width()), TQMAX(minh,height()) ); + if ( !resized ) + clearWState( WState_Resized ); // not a user resize + } + if ( testWFlags(WType_TopLevel) ) + do_size_hints( this, extra ); + updateGeometry(); +} + +/*! + \overload + + This function corresponds to setMaximumSize( TQSize(\a maxw, \a + maxh) ). Sets the maximum width to \a maxw and the maximum height + to \a maxh. +*/ +void TQWidget::setMaximumSize( int maxw, int maxh ) +{ +#if defined(QT_CHECK_RANGE) + if ( maxw > TQWIDGETSIZE_MAX || maxh > TQWIDGETSIZE_MAX ) { + tqWarning("TQWidget::setMaximumSize: (%s/%s) " + "The largest allowed size is (%d,%d)", + name( "unnamed" ), className(), TQWIDGETSIZE_MAX, + TQWIDGETSIZE_MAX ); + maxw = TQMIN( maxw, TQWIDGETSIZE_MAX ); + maxh = TQMIN( maxh, TQWIDGETSIZE_MAX ); + } + if ( maxw < 0 || maxh < 0 ) { + tqWarning("TQWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) " + "are not possible", + name( "unnamed" ), className(), maxw, maxh ); + maxw = TQMAX( maxw, 0 ); + maxh = TQMAX( maxh, 0 ); + } +#endif + createExtra(); + if ( extra->maxw == maxw && extra->maxh == maxh ) + return; + extra->maxw = maxw; + extra->maxh = maxh; + if ( maxw < width() || maxh < height() ) { + bool resized = testWState( WState_Resized ); + resize( TQMIN(maxw,width()), TQMIN(maxh,height()) ); + if ( !resized ) + clearWState( WState_Resized ); // not a user resize + } + if ( testWFlags(WType_TopLevel) ) + do_size_hints( this, extra ); + updateGeometry(); +} + +/*! + \overload + + Sets the x (width) size increment to \a w and the y (height) size + increment to \a h. +*/ +void TQWidget::setSizeIncrement( int w, int h ) +{ + TQTLWExtra* x = topData(); + if ( x->incw == w && x->inch == h ) + return; + x->incw = w; + x->inch = h; + if ( testWFlags(WType_TopLevel) ) + do_size_hints( this, extra ); +} + +/*! + \overload + + This corresponds to setBaseSize( TQSize(\a basew, \a baseh) ). Sets + the widgets base size to width \a basew and height \a baseh. +*/ +void TQWidget::setBaseSize( int basew, int baseh ) +{ + createTLExtra(); + TQTLWExtra* x = topData(); + if ( x->basew == basew && x->baseh == baseh ) + return; + x->basew = basew; + x->baseh = baseh; + if ( testWFlags(WType_TopLevel) ) + do_size_hints( this, extra ); +} + +/*! + \overload void TQWidget::erase() + + This version erases the entire widget. +*/ + +/*! + \overload void TQWidget::erase( const TQRect &r ) + + Erases the specified area \a r in the widget without generating a + \link paintEvent() paint event\endlink. +*/ + +/*! + Erases the specified area \a (x, y, w, h) in the widget without + generating a \link paintEvent() paint event\endlink. + + If \a w is negative, it is replaced with \c{width() - x}. If \a h + is negative, it is replaced width \c{height() - y}. + + Child widgets are not affected. + + \sa repaint() +*/ + +void TQWidget::erase( int x, int y, int w, int h ) +{ + extern void qt_erase_rect( TQWidget*, const TQRect& ); // in qpainer_x11.cpp + if ( w < 0 ) + w = crect.width() - x; + if ( h < 0 ) + h = crect.height() - y; + if ( w != 0 && h != 0 ) + qt_erase_rect( this, TQRect(x, y, w, h ) ); +} + +/*! + \overload + + Erases the area defined by \a reg, without generating a \link + paintEvent() paint event\endlink. + + Child widgets are not affected. +*/ + +void TQWidget::erase( const TQRegion& reg ) +{ + extern void qt_erase_region( TQWidget*, const TQRegion& ); // in qpainer_x11.cpp + qt_erase_region( this, reg ); +} + +/*! + Scrolls the widget including its children \a dx pixels to the + right and \a dy downwards. Both \a dx and \a dy may be negative. + + After scrolling, scroll() sends a paint event for the the part + that is read but not written. For example, when scrolling 10 + pixels rightwards, the leftmost ten pixels of the widget need + repainting. The paint event may be delivered immediately or later, + depending on some heuristics (note that you might have to force + processing of paint events using TQApplication::sendPostedEvents() + when using scroll() and move() in combination). + + \sa TQScrollView erase() bitBlt() +*/ + +void TQWidget::scroll( int dx, int dy ) +{ + scroll( dx, dy, TQRect() ); +} + +/*! + \overload + + This version only scrolls \a r and does not move the children of + the widget. + + If \a r is empty or invalid, the result is undefined. + + \sa TQScrollView erase() bitBlt() +*/ +void TQWidget::scroll( int dx, int dy, const TQRect& r ) +{ + if ( testWState( WState_BlockUpdates ) && !children() ) + return; + bool valid_rect = r.isValid(); + bool just_update = TQABS( dx ) > width() || TQABS( dy ) > height(); + if ( just_update ) + update(); + TQRect sr = valid_rect?r:clipRegion().boundingRect(); + int x1, y1, x2, y2, w=sr.width(), h=sr.height(); + if ( dx > 0 ) { + x1 = sr.x(); + x2 = x1+dx; + w -= dx; + } else { + x2 = sr.x(); + x1 = x2-dx; + w += dx; + } + if ( dy > 0 ) { + y1 = sr.y(); + y2 = y1+dy; + h -= dy; + } else { + y2 = sr.y(); + y1 = y2-dy; + h += dy; + } + + if ( dx == 0 && dy == 0 ) + return; + + Display *dpy = x11Display(); + GC gc = tqt_xget_readonly_gc( x11Screen(), FALSE ); + // Want expose events + if ( w > 0 && h > 0 && !just_update ) { + XSetGraphicsExposures( dpy, gc, True ); + XCopyArea( dpy, winId(), winId(), gc, x1, y1, w, h, x2, y2); + XSetGraphicsExposures( dpy, gc, False ); + } + + if ( !valid_rect && children() ) { // scroll children + TQPoint pd( dx, dy ); + TQObjectListIt it(*children()); + TQObject *object; + while ( it ) { // move all children + object = it.current(); + if ( object->isWidgetType() ) { + TQWidget *w = (TQWidget *)object; + w->move( w->pos() + pd ); + } + ++it; + } + } + + if ( just_update ) + return; + + // Don't let the server be bogged-down with repaint events + bool repaint_immediately = qt_sip_count( this ) < 3; + + if ( dx ) { + int x = x2 == sr.x() ? sr.x()+w : sr.x(); + if ( repaint_immediately ) + repaint( x, sr.y(), TQABS(dx), sr.height(), !testWFlags(WRepaintNoErase) ); + else + XClearArea( dpy, winid, x, sr.y(), TQABS(dx), sr.height(), True ); + } + if ( dy ) { + int y = y2 == sr.y() ? sr.y()+h : sr.y(); + if ( repaint_immediately ) + repaint( sr.x(), y, sr.width(), TQABS(dy), !testWFlags(WRepaintNoErase) ); + else + XClearArea( dpy, winid, sr.x(), y, sr.width(), TQABS(dy), True ); + } + + qt_insert_sip( this, dx, dy ); // #### ignores r +} + + +/*! + \overload void TQWidget::drawText( const TQPoint &pos, const TQString& str ) + + Draws the string \a str at position \a pos. +*/ + +/*! + Draws the string \a str at position \a(x, y). + + The \a y position is the base line position of the text. The text + is drawn using the default font and the default foreground color. + + This function is provided for convenience. You will generally get + more flexible results and often higher speed by using a a \link + TQPainter painter\endlink instead. + + \sa setFont(), foregroundColor(), TQPainter::drawText() +*/ + +void TQWidget::drawText( int x, int y, const TQString &str ) +{ + if ( testWState(WState_Visible) ) { + TQPainter paint; + paint.begin( this ); + paint.drawText( x, y, str ); + paint.end(); + } +} + + +/*! + Internal implementation of the virtual TQPaintDevice::metric() + function. + + Use the TQPaintDeviceMetrics class instead. + + \a m is the metric to get. +*/ + +int TQWidget::metric( int m ) const +{ + int val; + if ( m == TQPaintDeviceMetrics::PdmWidth ) { + val = crect.width(); + } else if ( m == TQPaintDeviceMetrics::PdmHeight ) { + val = crect.height(); + } else { + Display *dpy = x11Display(); + int scr = x11Screen(); + switch ( m ) { + case TQPaintDeviceMetrics::PdmDpiX: + case TQPaintDeviceMetrics::PdmPhysicalDpiX: + val = TQPaintDevice::x11AppDpiX( scr ); + break; + case TQPaintDeviceMetrics::PdmDpiY: + case TQPaintDeviceMetrics::PdmPhysicalDpiY: + val = TQPaintDevice::x11AppDpiY( scr ); + break; + case TQPaintDeviceMetrics::PdmWidthMM: + val = (DisplayWidthMM(dpy,scr)*crect.width())/ + DisplayWidth(dpy,scr); + break; + case TQPaintDeviceMetrics::PdmHeightMM: + val = (DisplayHeightMM(dpy,scr)*crect.height())/ + DisplayHeight(dpy,scr); + break; + case TQPaintDeviceMetrics::PdmNumColors: + val = x11Cells(); + break; + case TQPaintDeviceMetrics::PdmDepth: + val = x11Depth(); + break; + default: + val = 0; +#if defined(QT_CHECK_RANGE) + tqWarning( "TQWidget::metric: Invalid metric command" ); +#endif + } + } + return val; +} + +void TQWidget::createSysExtra() +{ + extra->xDndProxy = 0; + extra->children_use_dnd = FALSE; + extra->compress_events = TRUE; +} + +void TQWidget::deleteSysExtra() +{ +} + +void TQWidget::createTLSysExtra() +{ +#if defined(TQT_NO_IM_EXTENSIONS) + // created lazily + extra->topextra->xic = 0; +#endif +#ifndef TQT_NO_XSYNC + extra->topextra->syncCounter = 0; + extra->topextra->syncRequestValue[0] = 0; + extra->topextra->syncRequestValue[1] = 0; +#endif +} + +void TQWidget::deleteTLSysExtra() +{ + // don't destroy input context here. it will be destroyed in + // TQWidget::destroy() destroyInputContext(); +} + +/* + examine the children of our parent up the tree and set the + children_use_dnd extra data appropriately... this is used to keep DND enabled + for widgets that are reparented and don't have DND enabled, BUT *DO* have + children (or children of children ...) with DND enabled... +*/ +void TQWidget::checkChildrenDnd() +{ + TQWidget *widget = this; + const TQObjectList *children; + const TQObject *object; + const TQWidget *child; + while (widget && ! widget->isDesktop()) { + // note: this isn't done for the desktop widget + + bool children_use_dnd = FALSE; + children = widget->children(); + if ( children ) { + TQObjectListIt it(*children); + while ( (object = it.current()) ) { + ++it; + if ( object->isWidgetType() ) { + child = (const TQWidget *) object; + children_use_dnd = (children_use_dnd || + child->acceptDrops() || + (child->extra && + child->extra->children_use_dnd)); + } + } + } + + widget->createExtra(); + widget->extra->children_use_dnd = children_use_dnd; + + widget = widget->parentWidget(); + } +} + + +#ifndef TQT_NO_XSYNC +// create a window's XSyncCounter +void TQWidget::createSyncCounter() +{ + if( !qt_use_xsync || !isTopLevel() || topData()->syncCounter ) + return; + XSyncValue zero; + XSyncIntToValue( &zero, 0 ); + topData()->syncCounter = XSyncCreateCounter( x11Display(), zero ); +} + +// destroy a window's XSyncCounter +void TQWidget::destroySyncCounter() +{ + if( !qt_use_xsync || !extra || !extra->topextra + || !extra->topextra->syncCounter ) + return; + XSyncDestroyCounter( x11Display(), extra->topextra->syncCounter ); + extra->topextra->syncCounter = 0; +} + +// increment a window's XSyncCounter +void TQWidget::incrementSyncCounter() +{ + if( qt_use_xsync && topData()->syncCounter && + !(topData()->syncRequestValue[0] == 0 && + topData()->syncRequestValue[1] == 0) ) { + XSyncValue val; + XSyncIntsToValue( &val, topData()->syncRequestValue[ 0 ], topData()->syncRequestValue[ 1 ] ); + XSyncSetCounter( x11Display(), topData()->syncCounter, val ); + topData()->syncRequestValue[0] = topData()->syncRequestValue[1] = 0; + } +} + +// handle _NET_WM_SYNC_REQUEST +void TQWidget::handleSyncRequest( void* ev ) +{ + XEvent* xev = (XEvent*)ev; + topData()->syncRequestValue[ 0 ] = xev->xclient.data.l[ 2 ]; + topData()->syncRequestValue[ 1 ] = xev->xclient.data.l[ 3 ]; +} +#endif // TQT_NO_XSYNC + + +/*! + \property TQWidget::acceptDrops + \brief whether drop events are enabled for this widget + + Setting this property to TRUE announces to the system that this + widget \e may be able to accept drop events. + + If the widget is the desktop (TQWidget::isDesktop()), this may + fail if another application is using the desktop; you can call + acceptDrops() to test if this occurs. + + \warning + Do not modify this property in a Drag&Drop event handler. +*/ +bool TQWidget::acceptDrops() const +{ + return testWState( WState_DND ); +} + +void TQWidget::setAcceptDrops( bool on ) +{ + if ( testWState(WState_DND) != on ) { + if ( qt_dnd_enable( this, on ) ) { + if ( on ) + setWState( WState_DND ); + else + clearWState( WState_DND ); + } + + checkChildrenDnd(); + } +} + +/*! + \overload + + Causes only the parts of the widget which overlap \a region to be + visible. If the region includes pixels outside the rect() of the + widget, window system controls in that area may or may not be + visible, depending on the platform. + + Note that this effect can be slow if the region is particularly + complex. + + \sa setMask(), clearMask() +*/ + +void TQWidget::setMask( const TQRegion& region ) +{ + XShapeCombineRegion( x11Display(), winId(), ShapeBounding, 0, 0, + region.handle(), ShapeSet ); +} + +/*! + Causes only the pixels of the widget for which \a bitmap has a + corresponding 1 bit to be visible. Use TQt::color0 to draw + transparent regions and TQt::color1 to draw opaque regions of the + bitmap. + + If the region includes pixels outside the rect() of the widget, + window system controls in that area may or may not be visible, + depending on the platform. + + Note that this effect can be slow if the region is particularly + complex. + + See \c examples/tux for an example of masking for transparency. + + \sa setMask(), clearMask() +*/ + +void TQWidget::setMask( const TQBitmap &bitmap ) +{ + TQBitmap bm = bitmap; + if ( bm.x11Screen() != x11Screen() ) + bm.x11SetScreen( x11Screen() ); + XShapeCombineMask( x11Display(), winId(), ShapeBounding, 0, 0, + bm.handle(), ShapeSet ); +} + +/*! + Removes any mask set by setMask(). + + \sa setMask() +*/ + +void TQWidget::clearMask() +{ + XShapeCombineMask( x11Display(), winId(), ShapeBounding, 0, 0, + None, ShapeSet ); +} + +/*!\reimp + */ +void TQWidget::setName( const char *name ) +{ + TQObject::setName( name ); + if ( isTopLevel() ) { + XChangeProperty( x11Display(), winId(), + tqt_window_role, XA_STRING, 8, PropModeReplace, + (unsigned char *)name, tqstrlen( name ) ); + } +} + + +/*! + \internal + + Computes the frame rectangle when needed. This is an internal function, you + should never call this. +*/ + +void TQWidget::updateFrameStrut() const +{ + TQWidget *that = (TQWidget *) this; + + if (! isVisible() || isDesktop()) { + that->fstrut_dirty = (! isVisible()); + return; + } + + Atom type_ret; + Window l = winId(), w = winId(), p, r; // target window, it's parent, root + Window *c; + int i_unused; + unsigned int nc; + unsigned char *data_ret; + unsigned long l_unused; + + while (XQueryTree(TQPaintDevice::x11AppDisplay(), w, &r, &p, &c, &nc)) { + if (c && nc > 0) + XFree(c); + + if (! p) { + tqWarning("TQWidget::updateFrameStrut(): ERROR - no parent"); + return; + } + + // if the parent window is the root window, an Enlightenment virtual root or + // a NET WM virtual root window, stop here + data_ret = 0; + if (p == r || + (XGetWindowProperty(TQPaintDevice::x11AppDisplay(), p, + qt_enlightenment_desktop, 0, 1, False, XA_CARDINAL, + &type_ret, &i_unused, &l_unused, &l_unused, + &data_ret) == Success && + type_ret == XA_CARDINAL)) { + if (data_ret) + XFree(data_ret); + + break; + } else if (qt_net_supports(qt_net_virtual_roots) && qt_net_virtual_root_list) { + int i = 0; + while (qt_net_virtual_root_list[i] != 0) { + if (qt_net_virtual_root_list[i++] == p) + break; + } + } + + l = w; + w = p; + } + + // we have our window + int transx, transy; + XWindowAttributes wattr; + if (XTranslateCoordinates(TQPaintDevice::x11AppDisplay(), l, w, + 0, 0, &transx, &transy, &p) && + XGetWindowAttributes(TQPaintDevice::x11AppDisplay(), w, &wattr)) { + TQTLWExtra *top = that->topData(); + top->fleft = transx; + top->ftop = transy; + top->fright = wattr.width - crect.width() - top->fleft; + top->fbottom = wattr.height - crect.height() - top->ftop; + + // add the border_width for the window managers frame... some window managers + // do not use a border_width of zero for their frames, and if we the left and + // top strut, we ensure that pos() is absolutely correct. frameGeometry() + // will still be incorrect though... perhaps i should have foffset as well, to + // indicate the frame offset (equal to the border_width on X). + // - Brad + top->fleft += wattr.border_width; + top->fright += wattr.border_width; + top->ftop += wattr.border_width; + top->fbottom += wattr.border_width; + } + + that->fstrut_dirty = 0; +} + + +/*! + This function returns the widget holding the TQInputContext + instance for this widget. The instance is used for text input to + this widget, switching input method, etc. + + By default, this function delegates the role of returning input + context holder widget to TQApplication::locateICHolderWidget(). + + This definition enables application developer to change the + mapping of widgets to TQInputContext instance simply by overriding + TQApplication::locateICHolderWidget(). + + \sa TQApplication::locateICHolderWidget() +*/ +TQWidget *TQWidget::icHolderWidget() +{ + return tqApp->locateICHolderWidget(this); +} + + +/*! + This function returns the TQInputContext instance for this widget. + This instance is used for text input to this widget, etc. + It is simply the accessor function. +*/ +TQInputContext *TQWidget::getInputContext() +{ + TQInputContext *qic = 0; + +#ifndef TQT_NO_IM +// #if !defined(TQT_NO_IM_EXTENSIONS) + if ( isInputMethodEnabled() ) { +#if !defined(TQT_NO_IM_EXTENSIONS) + qic = icHolderWidget()->ic; +#else +// { + // icHolderWidget is always topLevelWidget + TQTLWExtra *topdata = icHolderWidget()->topData(); + qic = (TQInputContext *)topdata->xic; +#endif + } +#endif // TQT_NO_IM + + return qic; +} + + +/*! + This function replaces the TQInputContext instance used for text + input to this widget. The \a identifierName is the identifier name + of newly choosed input method. +*/ +void TQWidget::changeInputContext( const TQString& identifierName ) +{ +#ifndef TQT_NO_IM + TQWidget *icWidget = icHolderWidget(); +#if !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext **qicp = &icWidget->ic; +#else + TQInputContext **qicp = (TQInputContext **)&icWidget->topData()->xic; +#endif + + if( *qicp ) + delete *qicp; + // an input context that has the identifierName is generated. + TQInputContext *qic = TQInputContextFactory::create( identifierName, icWidget ); + *qicp = qic; + if ( qic ) { + TQObject::connect( qic, TQ_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)), + tqApp, TQ_SLOT(postIMEvent(TQObject *,TQIMEvent *)) ); + TQObject::connect( qic, TQ_SIGNAL(deletionRequested()), + icWidget, TQ_SLOT(destroyInputContext()) ); + } +#else + (void) identifierName; /* unused */ +#endif // TQT_NO_IM +} + + +/*! + \internal + This is an internal function, you should never call this. + + This function is called to generate an input context + according to a configuration for default input method + + When TQT_NO_IM_EXTENSIONS is not set, input context is + generated only when isInputMethodEnabled() returns TRUE. +*/ +void TQWidget::createInputContext() +{ +// #if !defined(TQT_NO_IM_EXTENSIONS) + if( !isInputMethodEnabled() || TQApplication::closingDown() ) + return; +// #endif + + TQWidget *icWidget = icHolderWidget(); +#ifndef TQT_NO_IM +#if !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext **qicp = &icWidget->ic; +#else + TQInputContext **qicp = (TQInputContext **)&icWidget->topData()->xic; +#endif + + if ( ! *qicp ) { + // an input context of the default input method is generated. + TQInputContext *qic = TQInputContextFactory::create( TQApplication::defaultInputMethod(), icWidget ); + + *qicp = qic; + if ( qic ) { + TQObject::connect( qic, TQ_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)), + tqApp, TQ_SLOT(postIMEvent(TQObject *,TQIMEvent *)) ); + TQObject::connect( qic, TQ_SIGNAL(deletionRequested()), + icWidget, TQ_SLOT(destroyInputContext()) ); + } + } +#endif // TQT_NO_IM +} + + +/*! + \internal + + This slot is used to destroy the input context that belonging + to the widget itself, so icHolderWidget()->ic is not fetched. + + \sa TQInputContext::deletionRequested() +*/ +void TQWidget::destroyInputContext() +{ +#ifndef TQT_NO_IM +#if !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext **qicp = ⁣ +#else + if ( ! extra || ! extra->topextra ) + return; + + TQInputContext **qicp = (TQInputContext **)&extra->topextra->xic; +#endif + + if( *qicp ) + delete *qicp; + + *qicp = 0; +#endif // TQT_NO_IM +} + + +/*! + This function is called when text widgets need to be neutral state to + execute text operations properly. See qlineedit.cpp and qtextedit.cpp as + example. + + Ordinary reset that along with changing focus to another widget, + moving the cursor, etc, is implicitly handled via + unfocusInputContext() because whether reset or not when such + situation is a responsibility of input methods. So we delegate the + responsibility to the input context via unfocusInputContext(). See + 'Preedit preservation' section of the class description of + TQInputContext for further information. + + \sa TQInputContext, unfocusInputContext(), TQInputContext::unsetFocus() +*/ +void TQWidget::resetInputContext() +{ +#ifndef TQT_NO_IM + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if( qic ) + qic->reset(); +#endif // TQT_NO_IM +} + + +/*! + \internal + This is an internal function, you should never call this. + + This function is called to focus associated input context. The + code intends to eliminate duplicate focus for the context even if + the context is shared between widgets + + \sa TQInputContext::setFocus() + */ +void TQWidget::focusInputContext() +{ +#ifndef TQT_NO_IM + TQWidget* tlw = topLevelWidget(); + + if (!tlw->isPopup() || isInputMethodEnabled()) { + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if ( qic ) { + if( qic->focusWidget() != this ) { + qic->setFocusWidget( this ); + qic->setFocus(); + } + } + } +#endif // TQT_NO_IM +} + + +/*! + \internal + This is an internal function, you should never call this. + + This function is called to remove focus from associated input + context. + + \sa TQInputContext::unsetFocus() + */ +void TQWidget::unfocusInputContext() +{ +#ifndef TQT_NO_IM + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if ( qic ) { + // may be caused reset() in some input methods + qic->unsetFocus(); + qic->setFocusWidget( 0 ); + } +#endif // TQT_NO_IM +} + + +/*! + This function is called to send mouse event to associated input + context by derived text widgets. A derived text widget must be + calculate \a x as character offset at the mouse cursor in the + preedit. + + \sa TQInputContext::mouseHandler() + */ +void TQWidget::sendMouseEventToInputContext( int x, TQEvent::Type type, + TQt::ButtonState button, + TQt::ButtonState state ) +{ +#ifndef TQT_NO_IM + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if ( qic ) { + // may be causing reset() in some input methods + qic->mouseHandler( x, type, button, state ); + } +#endif // TQT_NO_IM +} + + +void TQWidget::setWindowOpacity(double) +{ +} + +double TQWidget::windowOpacity() const +{ + return 1.0; +} diff --git a/src/kernel/tqwidgetcreate_x11.cpp b/src/kernel/tqwidgetcreate_x11.cpp new file mode 100644 index 000000000..b34fe9613 --- /dev/null +++ b/src/kernel/tqwidgetcreate_x11.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Implementation of TQt calls to X11 +** +** Created : 970529 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqwidget.h" +#include "qt_x11_p.h" + + +/* + Internal TQt functions to create X windows. We have put them in + separate functions to allow the programmer to reimplement them by + custom versions. +*/ + +Window qt_XCreateWindow( const TQWidget*, Display *display, Window parent, + int x, int y, uint w, uint h, + int borderwidth, int depth, + uint windowclass, Visual *visual, + ulong valuemask, XSetWindowAttributes *attributes ) +{ + return XCreateWindow( display, parent, x, y, w, h, borderwidth, depth, + windowclass, visual, valuemask, attributes ); +} + + +Window qt_XCreateSimpleWindow( const TQWidget*, Display *display, Window parent, + int x, int y, uint w, uint h, int borderwidth, + ulong border, ulong background ) +{ + return XCreateSimpleWindow( display, parent, x, y, w, h, borderwidth, + border, background ); +} + + +void qt_XDestroyWindow( const TQWidget*, Display *display, Window window ) +{ + XDestroyWindow( display, window ); +} diff --git a/src/kernel/tqwidgetintdict.h b/src/kernel/tqwidgetintdict.h new file mode 100644 index 000000000..8a4694804 --- /dev/null +++ b/src/kernel/tqwidgetintdict.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Definition of TQWidgetIntDict +** +** Created : 950116 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQWIDGETINTDICT_H +#define TQWIDGETINTDICT_H + +#ifndef QT_H +#include "tqwidget.h" +#include "ntqintdict.h" +#endif // QT_H + + +#if defined(Q_TEMPLATEDLL) +//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQIntDict; +//Q_TEMPLATE_EXTERN template class TQ_EXPORT TQIntDictIterator; +#endif + + +class TQ_EXPORT TQWidgetIntDict : public TQIntDict +{ +public: + TQWidgetIntDict(int size=17) : TQIntDict(size) {} + TQWidgetIntDict( const TQWidgetIntDict &dict ) : TQIntDict(dict) {} + ~TQWidgetIntDict() { clear(); } + TQWidgetIntDict &operator=(const TQWidgetIntDict &dict) + { return (TQWidgetIntDict&)TQIntDict::operator=(dict); } +}; + +class TQ_EXPORT TQWidgetIntDictIt : public TQIntDictIterator +{ +public: + TQWidgetIntDictIt( const TQWidgetIntDict &d ) : TQIntDictIterator(d) {} + TQWidgetIntDictIt &operator=(const TQWidgetIntDictIt &i) + { return (TQWidgetIntDictIt&)TQIntDictIterator::operator=(i); } +}; + + +#endif diff --git a/src/kernel/tqwidgetlist.h b/src/kernel/tqwidgetlist.h new file mode 100644 index 000000000..bcd7637cf --- /dev/null +++ b/src/kernel/tqwidgetlist.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Definition of TQWidgetList +** +** Created : 950116 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQWIDGETLIST_H +#define TQWIDGETLIST_H + +#ifndef QT_H +#include "tqwidget.h" +#include "ntqptrlist.h" +#endif // QT_H + +class TQ_EXPORT TQWidgetList : public TQPtrList +{ +public: + TQWidgetList() : TQPtrList() {} + TQWidgetList( const TQWidgetList &list ) : TQPtrList(list) {} + ~TQWidgetList() { clear(); } + TQWidgetList &operator=(const TQWidgetList &list) + { return (TQWidgetList&)TQPtrList::operator=(list); } +}; + +class TQ_EXPORT TQWidgetListIt : public TQPtrListIterator +{ +public: + TQWidgetListIt( const TQWidgetList &l ) : TQPtrListIterator(l) {} + TQWidgetListIt &operator=(const TQWidgetListIt &i) + { return (TQWidgetListIt&)TQPtrListIterator::operator=(i); } +}; + +#endif // TQWIDGETLIST_H -- cgit v1.2.3