summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/src/kernel/tqwidget.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
commitdda8474928bd7276e1fad8fb7a601e7c83ff2bc2 (patch)
tree7f83910598b33b12730035f086df20b5a53ab99c /tqtinterface/qt4/src/kernel/tqwidget.cpp
parent6260b6178868c03aab1644bf93b0ef043654bdb0 (diff)
downloadexperimental-dda8474928bd7276e1fad8fb7a601e7c83ff2bc2.tar.gz
experimental-dda8474928bd7276e1fad8fb7a601e7c83ff2bc2.zip
Added TQt4 HEAD
Diffstat (limited to 'tqtinterface/qt4/src/kernel/tqwidget.cpp')
-rw-r--r--tqtinterface/qt4/src/kernel/tqwidget.cpp8728
1 files changed, 8728 insertions, 0 deletions
diff --git a/tqtinterface/qt4/src/kernel/tqwidget.cpp b/tqtinterface/qt4/src/kernel/tqwidget.cpp
new file mode 100644
index 0000000..3bfdd86
--- /dev/null
+++ b/tqtinterface/qt4/src/kernel/tqwidget.cpp
@@ -0,0 +1,8728 @@
+/****************************************************************************
+**
+** Implementation of TQWidget class
+**
+** Created : 931031
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** This file is part of the kernel module of the TQt GUI Toolkit.
+**
+** This file may be used under the terms of the GNU General
+** Public License versions 2.0 or 3.0 as published by the Free
+** Software Foundation and appearing in the files LICENSE.GPL2
+** and LICENSE.GPL3 included in the packaging of this file.
+** Alternatively you may (at your option) use any later version
+** of the GNU General Public License if such license has been
+** publicly approved by Trolltech ASA (or its successors, if any)
+** and the KDE Free TQt Foundation.
+**
+** Please review the following information to ensure GNU General
+** Public Licensing requirements will be met:
+** http://trolltech.com/products/qt/licenses/licensing/opensource/.
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
+** or contact the sales department at sales@trolltech.com.
+**
+** This file may be used under the terms of the Q Public License as
+** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
+** included in the packaging of this file. Licensees holding valid TQt
+** Commercial licenses may use this file in accordance with the TQt
+** Commercial License Agreement provided with the Software.
+**
+** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
+** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
+** herein.
+**
+**********************************************************************/
+
+
+#include "tqobjectlist.h"
+#include "tqwidget.h"
+#include "tqwidgetlist.h"
+#include "tqwidgetintdict.h"
+#include "tqptrdict.h"
+#include "tqfocusdata.h"
+#include "tqcursor.h"
+#include "tqpixmap.h"
+#include "tqapplication.h"
+#include "tqapplication_p.h"
+#include "tqbrush.h"
+#include "tqlayout.h"
+#include "tqstylefactory.h"
+#include "tqcleanuphandler.h"
+#include "tqstyle.h"
+#include "tqmetaobject.h"
+#include "tqguardedptr.h"
+#if defined(TQT_ACCESSIBILITY_SUPPORT)
+#include "tqaccessible.h"
+#endif
+#if defined(TQ_WS_WIN)
+#include "tqt_windows.h"
+#include "tqinputcontext_p.h"
+#endif
+#if defined(TQ_WS_TQWS)
+#include "tqwsmanager_qws.h"
+#endif
+#include "tqfontdata_p.h"
+
+#ifdef USE_QT4
+
+TQObject* convertFromTQT_BASE_OBJECT_NAMEPointer( TQT_BASE_OBJECT_NAME* x ) {
+ return static_cast<TQObject*>(static_cast<TQT_BASE_OBJECT_NAME*>(x));
+}
+
+const TQObject* convertFromTQT_BASE_OBJECT_NAMEPointerConst( const TQT_BASE_OBJECT_NAME* x ) {
+ return static_cast<const TQObject*>(static_cast<const TQT_BASE_OBJECT_NAME*>(x));
+}
+
+void TQWidget::reparent(QWidget *parent, const QPoint &p, bool showIt) {
+ setParent(parent, windowFlags() & ~Qt::WindowType_Mask);
+ setGeometry(p.x(),p.y(),width(),height());
+ if (showIt) show();
+}
+
+bool TQWidget::close(bool alsoDelete) {
+ QPointer<QWidget> that = this;
+ bool accepted = QWidget::close();
+ if (alsoDelete && accepted && that)
+ deleteLater();
+ return accepted;
+}
+
+// void TQWidget::showEvent(QShowEvent *e) {
+// // if (!testAttribute(Qt::WA_Resized) && (isWindow() || !layout())) // Logic taken from Qt4 qwidget.cpp tqsetVisible...
+// // if (!testAttribute(Qt::WA_Resized))
+// // if (!isVisible())
+// // adjustSize(); // NOTE: Qt4 does not allow adjustSize to be overridden, therefore it must be called here
+// if (isVisible()) {
+// // setAttribute(Qt::WA_Resized, TRUE); //not a user resize
+// if (tqt_internal_show_called_event == FALSE) show(); // NOTE: Qt4 does not allow show to be overridden, therefore it must be called here
+// // if ( !isTopLevel() && parentWidget() ) QApplication::postEvent( parentWidget(), new TQEvent( TQEvent::LayoutHint) ); // Needed for layouts to work
+// tqt_internal_show_called_event = FALSE;
+// }
+// showEvent(static_cast<TQShowEvent*>(e));
+// }
+
+uint TQWidget::windowState() const {
+ return (uint)(QWidget::windowState());
+}
+
+void TQWidget::setWindowState(uint newstate) {
+ QWidget::setWindowState((Qt::WindowStates)newstate);
+}
+
+void TQWidget::showEvent(QShowEvent *e) {
+ if (isVisible()) {
+ // Spontaneous event
+ if (tqt_internal_show_called_event == FALSE) show(); // NOTE: Qt4 does not allow show to be overridden, therefore it must be called here
+ showEvent(static_cast<TQShowEvent*>(e));
+ }
+ else {
+ // Non-spontaneous event
+ showEvent(static_cast<TQShowEvent*>(e));
+ if (tqt_internal_show_called_event == FALSE) show(); // NOTE: Qt4 does not allow show to be overridden, therefore it must be called here
+ }
+ tqt_internal_show_called_event = FALSE;
+}
+
+void TQWidget::hideEvent(QHideEvent *e) {
+ hideEvent(static_cast<TQHideEvent*>(e));
+ if ( !isTopLevel() && parentWidget() ) QApplication::postEvent( parentWidget(), new TQEvent( TQEvent::LayoutHint) ); // Needed for layouts to work
+}
+
+void TQWidget::show() {
+ if ( testWState(WState_Visible) )
+ return;
+ tqt_internal_show_called_event = TRUE;
+ if ( !isTopLevel() && parentWidget() )
+ QApplication::postEvent( parentWidget(), new TQEvent( TQEvent::LayoutHint) ); // Needed for layouts to work
+ if (parentWidget()) {
+ if ( !isTopLevel() && !parentWidget()->isVisible() ) {
+ // return;
+ }
+ }
+ else {
+ QApplication::sendPostedEvents( this, TQEvent::ChildInserted );
+ if ( parentWidget() )
+ QApplication::sendPostedEvents( parentWidget(), TQEvent::ChildInserted );
+ // Required for Mac, not sure whether we should always do that [this? see tqwidget.cpp ::show() for Qt3.3]
+ if( isTopLevel() )
+ QApplication::sendPostedEvents(0, TQEvent::LayoutHint);
+ }
+ QWidget::show();
+}
+
+TQWidget* TQWidget::tqt_ensure_valid_widget_painting(TQWidget* w) {
+ if (w) w->setAttribute(Qt::WA_PaintOutsidePaintEvent, TRUE);
+ return w;
+}
+
+void TQWidget::showWindow() {
+ printf("[FIXME] TQWidget::showWindow unimplemented\n\r");
+}
+
+void TQWidget::hideWindow() {
+ printf("[FIXME] TQWidget::hideWindow unimplemented\n\r");
+}
+
+void TQWidget::timerEvent(QTimerEvent *e) {
+ timerEvent(static_cast<TQTimerEvent*>(e));
+}
+
+void TQWidget::childEvent(QChildEvent *e) {
+ TQT_TQOBJECT_CHILDEVENT_CONDITIONAL childEvent(static_cast<TQChildEvent*>(e));
+}
+
+void TQWidget::customEvent(QEvent *e) {
+ customEvent(static_cast<TQCustomEvent*>(e));
+}
+
+void TQWidget::tqrepaint() {
+ repaint();
+}
+
+void TQWidget::setFocus() {
+ setFocus(Qt::OtherFocusReason);
+}
+
+void TQWidget::polish() {
+ QApplication::sendPostedEvents( this, TQEvent::ChildInserted );
+ ensurePolished();
+}
+
+void TQWidget::mousePressEvent(QMouseEvent *e) {
+ TQT_TQWIDGET_FIX_BROKEN_POPUP_MOUSE_FOCUS mousePressEvent(static_cast<TQMouseEvent*>(e));
+}
+
+void TQWidget::mouseReleaseEvent(QMouseEvent *e) {
+ TQT_TQWIDGET_FIX_BROKEN_POPUP_MOUSE_FOCUS mouseReleaseEvent(static_cast<TQMouseEvent*>(e));
+}
+
+void TQWidget::mouseDoubleClickEvent(QMouseEvent *e) {
+ TQT_TQWIDGET_FIX_BROKEN_POPUP_MOUSE_FOCUS mouseDoubleClickEvent(static_cast<TQMouseEvent*>(e));
+}
+
+void TQWidget::mouseMoveEvent(QMouseEvent *e) {
+ TQT_TQWIDGET_FIX_BROKEN_POPUP_MOUSE_FOCUS mouseMoveEvent(static_cast<TQMouseEvent*>(e));
+}
+
+void TQWidget::createTLSysExtra( void ) {
+ printf("[TQT UNIMPLEMENTED CALL] createTLSysExtra()\n\r");
+}
+
+void TQWidget::destroyInputContext( void ) {
+ printf("[TQT UNIMPLEMENTED CALL] destroyInputContext()\n\r");
+}
+
+TQWidget::TQWidget( QWidget* tqparent, const char* name, WFlags f ) : QWidget( tqparent, (Qt::WindowFlags)(f&(~WTQtFlagMask)) ), TQtUpperWidgetFlags((WFlags)0) {
+ TQtUpperWidgetFlags = f & WTQtFlagMask;
+ TQT_TQWIDGET_REQUIRED_INITIALIZATION
+ static_cast<QWidget*>(this)->setObjectName(QString::fromAscii(name));
+ TQT_TQOBJECT_REQUIRED_INITIALIZATION(tqparent)
+}
+
+void TQWidget::setActiveWindow( void ) {
+ activateWindow();
+}
+
+Display * TQWidget::x11Display( void ) {
+ return this->x11Info().display();
+}
+
+int TQWidget::x11Screen( void ) {
+ return this->x11Info().screen();
+}
+
+TQWidget * TQWidget::parentWidget( bool sameWindow ) const {
+ TQ_UNUSED(sameWindow);
+ return static_cast<TQWidget*>(parentWidget());
+}
+
+TQCString TQWidget::normalizeSignalSlot( const char *signalSlot ) {
+ return TQObject::normalizeSignalSlot(signalSlot);
+}
+
+TQMetaObject *TQWidget::tqmetaObject() const {
+ return TQT_TQOBJECT_CONST(this)->tqmetaObject();
+}
+
+TQWidget * TQWidget::tqfind( WId w ) {
+ return static_cast<TQWidget*>(find(w));
+}
+
+bool TQWidget::isShown() const {
+ return !isHidden();
+}
+
+TQWidget *TQWidget::tqchildAt( int x, int y, bool includeThis ) const {
+ TQ_UNUSED(includeThis);
+ return static_cast<TQWidget*>(childAt(x, y));
+}
+
+TQWidget *TQWidget::tqchildAt( const TQPoint &p, bool includeThis ) const {
+ TQ_UNUSED(includeThis);
+ return static_cast<TQWidget*>(childAt(p));
+}
+
+TQWidget *TQWidget::tqtopLevelWidget() const {
+ return static_cast<TQWidget*>(topLevelWidget());
+}
+
+TQWExtra *TQWidget::extraData() {
+ return extra;
+}
+
+TQTLWExtra *TQWidget::topData() {
+ createTLExtra();
+ return extra->topextra;
+}
+
+void TQWidget::setName(const char *aName) {
+ TQT_TQOBJECT(this)->setName(aName);
+}
+
+TQWidget *TQWidget::parentWidget( bool sameWindow ) {
+ TQ_UNUSED(sameWindow);
+ return static_cast<TQWidget*>(this->parent());
+}
+
+bool TQWidget::isDialog() const {
+ return (windowType() == Qt::Dialog);
+}
+
+TQObject *TQWidget::child( const char *objName, const char *inheritsClass, bool recursiveSearch ) {
+ return TQT_TQOBJECT(this)->child( objName, inheritsClass, recursiveSearch );
+}
+
+const TQRect TQWidget::tqgeometry() const {
+ return TQT_TQRECT_OBJECT(geometry());
+}
+
+QSize TQWidget::sizeHint() const {
+ return tqsizeHint();
+}
+
+QSize TQWidget::minimumSizeHint() const {
+ return tqminimumSizeHint();
+}
+
+TQSize TQWidget::tqminimumSize() const {
+ return QWidget::minimumSize();
+}
+
+TQSize TQWidget::tqmaximumSize() const {
+ return QWidget::maximumSize();
+}
+
+TQColorGroup TQWidget::tqcolorGroup() const {
+ return TQColorGroup(palette());
+}
+
+void TQWidget::iconify() {
+ showMinimized();
+}
+
+void TQWidget::constPolish() const {
+ ensurePolished();
+}
+
+bool TQWidget::hasMouse() const {
+ return testAttribute(Qt::WA_UnderMouse);
+}
+
+bool TQWidget::ownCursor() const {
+ return testAttribute(Qt::WA_SetCursor);
+}
+
+bool TQWidget::ownFont() const {
+ return testAttribute(Qt::WA_SetFont);
+}
+
+const TQPixmap *TQWidget::backgroundPixmap() const {
+ return erasePixmap();
+}
+
+void TQWidget::tqsetSizePolicy(QSizePolicy qsp) {
+ setSizePolicy(qsp);
+}
+
+void TQWidget::tqsetSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) {
+ setSizePolicy(horizontal, vertical);
+}
+
+void TQWidget::tqsetSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw) {
+ QSizePolicy sp(hor, ver);
+ sp.setHeightForWidth(hfw);
+ setSizePolicy(sp);
+}
+
+void TQWidget::setInputMethodEnabled(bool b) {
+ setAttribute(Qt::WA_InputMethodEnabled, b);
+}
+
+bool TQWidget::isInputMethodEnabled() const {
+ return testAttribute(Qt::WA_InputMethodEnabled);
+}
+
+bool TQWidget::isPopup() const {
+ return windowType() == Qt::Popup;
+}
+
+TQString TQWidget::caption() const {
+ return windowTitle();
+}
+
+void TQWidget::setCaption(const QString &c) {
+ setWindowTitle(c);
+}
+
+TQRect TQWidget::tqchildrenRect() const {
+ return childrenRect();
+}
+
+TQRegion TQWidget::tqchildrenRegion() const {
+ return childrenRegion();
+}
+
+void TQWidget::unsetFont() {
+ setFont(QFont());
+}
+
+bool TQWidget::ownPalette() const {
+ return testAttribute(Qt::WA_SetPalette);
+}
+
+void TQWidget::unsetPalette() {
+ setPalette(QPalette());
+}
+
+const TQPalette &TQWidget::tqpalette() const {
+ return TQT_TQPALETTE_OBJECT(palette());
+}
+
+bool TQWidget::isUpdatesEnabled() const {
+ return updatesEnabled();
+}
+
+void TQWidget::tqrepaint(int x, int y, int w, int h) {
+ return repaint(x, y, w, h);
+}
+
+void TQWidget::tqrepaint(const QRect &r) {
+ return repaint(r);
+}
+
+void TQWidget::tqrepaint(const QRegion &r) {
+ return repaint(r);
+}
+
+void TQWidget::tqrepaint(bool eraseme) {
+ if (eraseme) erase();
+ repaint();
+}
+
+void TQWidget::tqrepaint(int x, int y, int w, int h, bool) {
+ repaint(x,y,w,h);
+}
+
+void TQWidget::tqrepaint(const QRect &r, bool) {
+ repaint(r);
+}
+
+void TQWidget::tqrepaint(const QRegion &rgn, bool) {
+ repaint(rgn);
+}
+
+TQSizePolicy TQWidget::tqsizePolicy() const {
+ return TQT_TQSIZEPOLICY_OBJECT(sizePolicy());
+}
+
+TQPoint TQWidget::backgroundOffset() const {
+ return TQPoint();
+}
+
+bool TQWidget::tqsignalsBlocked() const {
+ return signalsBlocked();
+}
+
+TQObjectList *TQWidget::queryList( const char *inheritsClass, const char *objName, bool regexpMatch, bool recursiveSearch ) const {
+ return TQT_TQOBJECT_CONST(this)->queryList(inheritsClass, objName, regexpMatch, recursiveSearch);
+}
+
+TQWidget *TQWidget::tqfocusWidget() const {
+ return TQT_TQWIDGET(focusWidget());
+}
+
+void TQWidget::setBackgroundOrigin(BackgroundOrigin) {
+}
+
+TQWidget::BackgroundOrigin TQWidget::backgroundOrigin() const {
+ return WindowOrigin;
+}
+
+void TQWidget::setIconText(const QString &it) {
+ setWindowIconText(it);
+}
+
+void TQWidget::insertChild( TQObject *object ) {
+ TQT_TQOBJECT(this)->insertChild(object);
+}
+
+void TQWidget::removeChild( TQObject *object ) {
+ TQT_TQOBJECT(this)->removeChild(object);
+}
+
+bool TQWidget::close() {
+ return QWidget::close();
+}
+
+void TQWidget::setFocus(Qt::FocusReason reason) {
+ return QWidget::setFocus(reason);
+}
+
+void TQWidget::setBackgroundMode( TQt::BackgroundMode tqbm ) {
+ setBackgroundMode(tqbm, TQt::PaletteBackground);
+}
+
+const QColor &TQWidget::paletteForegroundColor() const {
+ return palette().color(foregroundRole());
+}
+
+void TQWidget::setPaletteForegroundColor(const QColor &c) {
+ QPalette p = palette();
+ p.setColor(foregroundRole(), c);
+ setPalette(p);
+}
+
+const QColor &TQWidget::paletteBackgroundColor() const {
+ return palette().color(backgroundRole());
+}
+
+void TQWidget::setPaletteBackgroundColor(const QColor &c) {
+ QPalette p = palette();
+ p.setColor(backgroundRole(), c);
+ setPalette(p);
+}
+
+const TQPixmap *TQWidget::paletteBackgroundPixmap() const {
+ QPalette p = palette();
+ const QPixmap& pm = p.brush(backgroundRole()).texture();
+ if (pm.isNull())
+ return 0;
+ return TQT_TQPIXMAP_CONST(&pm);
+}
+
+void TQWidget::setPaletteBackgroundPixmap(const QPixmap &pm) {
+ QPalette p = palette();
+ p.setBrush(backgroundRole(), QBrush(pm));
+ setPalette(p);
+}
+
+const TQColor &TQWidget::backgroundColor() const {
+ return TQT_TQCOLOR_OBJECT(palette().color(backgroundRole()));
+}
+
+void TQWidget::setBackgroundColor(const QColor &c) {
+ QPalette p = palette();
+ p.setColor(backgroundRole(), c);
+ setPalette(p);
+}
+
+const TQColor &TQWidget::eraseColor() const {
+ return TQT_TQCOLOR_OBJECT(palette().color(backgroundRole()));
+}
+
+void TQWidget::setEraseColor(const QColor &c) {
+ QPalette p = palette();
+ p.setColor(backgroundRole(), c);
+ setPalette(p);
+}
+
+const TQPixmap *TQWidget::erasePixmap() const {
+ QPalette p = palette();
+ const QPixmap& pm = p.brush(backgroundRole()).texture();
+ if (pm.isNull())
+ return 0;
+ return TQT_TQPIXMAP_CONST(&pm);
+}
+
+void TQWidget::setErasePixmap(const QPixmap &pm) {
+ QPalette p = palette();
+ p.setBrush(backgroundRole(), QBrush(pm));
+ setPalette(p);
+}
+
+const TQColor &TQWidget::foregroundColor() const {
+ return TQT_TQCOLOR_OBJECT(palette().color(foregroundRole()));
+}
+
+void TQWidget::erase() {
+ erase_helper(0, 0, QWidget::width(), QWidget::height());
+}
+
+void TQWidget::erase(int x, int y, int w, int h) {
+ erase_helper(x, y, w, h);
+}
+
+void TQWidget::erase(const QRect &r) {
+ erase_helper(r.x(), r.y(), r.width(), r.height());
+}
+
+const char *TQWidget::name(const char *defaultName) const {
+ TQString s = objectName();
+ return s.isEmpty()?defaultName:s.latin1_helper();
+}
+
+void TQWidget::tqsetPalette( const TQPalette &p, bool ) {
+ setPalette( p );
+}
+
+bool TQWidget::isDesktop() const {
+ return testWFlags(WType_Desktop);
+}
+
+bool TQWidget::isFocusEnabled() const {
+ return focusPolicy() != Qt::NoFocus;
+}
+
+// Qt4 handler interface
+bool TQWidget::eventFilter( QObject *q, QEvent *e ) {
+ return eventFilter(static_cast<TQObject*>(q), static_cast<TQEvent*>(e));
+}
+
+bool TQWidget::event( QEvent *e ) {
+ return event(static_cast<TQEvent*>(e));
+}
+
+#ifndef QT_NO_WHEELEVENT
+void TQWidget::wheelEvent(QWheelEvent *e) {
+ wheelEvent(static_cast<TQWheelEvent*>(e));
+}
+#endif
+
+void TQWidget::keyPressEvent(QKeyEvent *e) {
+ keyPressEvent(static_cast<TQKeyEvent*>(e));
+}
+
+void TQWidget::keyReleaseEvent(QKeyEvent *e) {
+ keyReleaseEvent(static_cast<TQKeyEvent*>(e));
+}
+
+void TQWidget::focusInEvent(QFocusEvent *e) {
+ focusInEvent(static_cast<TQFocusEvent*>(e));
+}
+
+void TQWidget::focusOutEvent(QFocusEvent *e) {
+ focusOutEvent(static_cast<TQFocusEvent*>(e));
+}
+
+void TQWidget::enterEvent(QEvent *e) {
+ enterEvent(static_cast<TQEvent*>(e));
+}
+
+void TQWidget::leaveEvent(QEvent *e) {
+ leaveEvent(static_cast<TQEvent*>(e));
+}
+
+void TQWidget::paintEvent(QPaintEvent *e) {
+ paintEvent(static_cast<TQPaintEvent*>(e));
+}
+
+void TQWidget::moveEvent(QMoveEvent *e) {
+ moveEvent(static_cast<TQMoveEvent*>(e));
+}
+
+void TQWidget::resizeEvent(QResizeEvent *e) {
+ resizeEvent(static_cast<TQResizeEvent*>(e));
+}
+
+void TQWidget::closeEvent(QCloseEvent *e) {
+ closeEvent(static_cast<TQCloseEvent*>(e));
+}
+
+#ifndef QT_NO_CONTEXTMENU
+void TQWidget::contextMenuEvent(QContextMenuEvent *e) {
+ contextMenuEvent(static_cast<TQContextMenuEvent*>(e));
+}
+#endif
+
+#ifndef QT_NO_TABLETEVENT
+void TQWidget::tabletEvent(QTabletEvent *e) {
+ tabletEvent(static_cast<TQTabletEvent*>(e));
+}
+#endif
+
+TQConnectionList *TQWidget::tqreceivers( const char* signal ) const {
+ return TQT_TQOBJECT_CONST(this)->tqreceivers(signal);
+}
+
+TQConnectionList *TQWidget::tqreceivers( int signal ) const {
+ return TQT_TQOBJECT_CONST(this)->tqreceivers(signal);
+}
+
+void TQWidget::activate_signal( int signal ) {
+ TQT_TQOBJECT(this)->activate_signal(signal);
+}
+
+void TQWidget::activate_signal( TQConnectionList *clist, TQUObject *o ) {
+ TQT_TQOBJECT(this)->activate_signal(clist, o);
+}
+
+void TQWidget::tqt_handle_qt_destroyed(QObject* obj) {
+ emit destroyed(TQT_TQOBJECT(obj));
+}
+
+bool TQWidget::isVisibleToTLW() const {
+ return isVisible();
+}
+
+/*!
+ \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
+ TQt::BackgroundMode mode = extra ? (TQt::BackgroundMode) extra->bg_mode_visual : TQt::PaletteBackground;
+ switch( mode ) {
+ case TQt::FixedColor:
+ case TQt::FixedPixmap :
+ case TQt::NoBackground:
+ case TQt::X11ParentRelative:
+ return noBrush;
+ default:
+ TQColorGroup::ColorRole role = TQPalette::backgroundRoleFromMode( mode );
+ return tqcolorGroup().tqbrush( role );
+ }
+#else
+ return noBrush;
+#endif
+}
+
+/*!
+ \internal
+ Creates the widget extra data.
+*/
+
+// [FIXME] Fix the commented out lines
+
+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 = TQt::PaletteBackground;
+ extra->bg_mode_visual = TQt::PaletteBackground;
+// extra->bg_origin = TQt::WidgetOrigin;
+#ifndef TQT_NO_STYLE
+ extra->style = 0;
+#endif
+ extra->size_policy = TQSizePolicy( TQSizePolicy::Preferred,
+ TQSizePolicy::Preferred );
+// createSysExtra();
+ }
+}
+
+
+/*!
+ \internal
+ Deletes the widget extra data.
+*/
+
+// [FIXME] Fix the commented out lines
+
+void TQWidget::deleteExtra()
+{
+ if ( extra ) { // if exists
+ 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_TQWS) && !defined(TQT_NO_TQWS_MANAGER)
+ delete extra->topextra->qwsManager;
+#endif
+ delete extra->topextra;
+ }
+ delete extra;
+ // extra->xic destroyed in TQWidget::destroy()
+ extra = 0;
+ }
+}
+
+void TQWidget::setBackgroundPixmap(const QPixmap &pm) {
+ // Is this object really a TQWidget (or based on a TQWidget)? If so use the internal virtual function instead...
+ if (inherits("TQObject") == TRUE) {
+ tqsetBackgroundPixmap(pm);
+ }
+ else {
+ QPalette p = palette();
+ p.setBrush(backgroundRole(), QBrush(pm));
+ setPalette(p);
+ }
+}
+
+void TQWidget::tqsetBackgroundPixmap(const QPixmap &pm) {
+ QPalette p = palette();
+ p.setBrush(backgroundRole(), QBrush(pm));
+ setPalette(p);
+}
+
+void TQWidget::setWFlags( WFlags flags ) {
+ if (this->inherits("TQWidget"))
+ TQtUpperWidgetFlags = TQtUpperWidgetFlags | (flags & WTQtFlagMask);
+ overrideWindowFlags((Qt::WindowFlags) (windowFlags() | (flags&(~WTQtFlagMask))));
+ if (this->inherits("TQWidget"))
+ processUpperWidgetFlags();
+}
+
+void TQWidget::clearWFlags( WFlags flags ) {
+ unsigned long long upperflags = 0ULL;
+ if (this->inherits("TQWidget"))
+ upperflags = TQtUpperWidgetFlags;
+ unsigned long long oldFlags = windowFlags() | upperflags;
+ unsigned long long newFlags = (oldFlags &= (~flags));
+ if ( ((newFlags & (WType_Dialog & (~WType_TopLevel))) != 0)
+ || ((newFlags & (WType_Popup & (~WType_TopLevel))) != 0)
+ || ((newFlags & (WType_Desktop & (~WType_TopLevel))) != 0))
+ newFlags = newFlags | WType_TopLevel;
+ overrideWindowFlags((Qt::WindowFlags)(newFlags&(~WTQtFlagMask)));
+ if (this->inherits("TQWidget"))
+ processUpperWidgetFlags();
+}
+
+WFlags TQWidget::getWFlags() const {
+ unsigned long long upperflags = 0ULL;
+ if (this->inherits("TQWidget"))
+ upperflags = TQtUpperWidgetFlags;
+ return windowFlags() | upperflags;
+}
+
+WFlags TQWidget::testWFlags( WFlags f ) const {
+ unsigned long long upperflags = 0ULL;
+ if (this->inherits("TQWidget"))
+ upperflags = TQtUpperWidgetFlags;
+ return ((windowFlags() | upperflags) & f);
+}
+
+void TQWidget::reparent(QWidget *parent, WFlags f, const QPoint &p, bool showIt) {
+ if (this->inherits("TQWidget")) {
+ TQtUpperWidgetFlags = f & WTQtFlagMask;
+ processUpperWidgetFlags();
+ }
+ setParent(parent, (Qt::WindowFlags)(f&(~WTQtFlagMask)));
+ setGeometry(p.x(),p.y(),width(),height());
+ if (showIt) show();
+}
+
+void TQWidget::processUpperWidgetFlags() {
+ unsigned long long flags = TQtUpperWidgetFlags&WTQtFlagMask;
+
+ // Process each extended TQt window flag that was defined in tqnamespace.h
+ if (flags & WNoAutoErase)
+ setAutoFillBackground(false);
+ else
+ setAutoFillBackground(true);
+
+ if (flags & WMouseNoMask)
+ setAttribute(Qt::WA_MouseNoMask, true);
+ else
+ setAttribute(Qt::WA_MouseNoMask, false);
+
+ if ((flags & WPaintOnScreen) || (flags & WPaintUnclipped))
+ setAttribute(Qt::WA_PaintOnScreen, true);
+ else
+ setAttribute(Qt::WA_PaintOnScreen, false);
+
+ if (flags & WPaintUnclipped)
+ setAttribute(Qt::WA_PaintUnclipped, true);
+ else
+ setAttribute(Qt::WA_PaintUnclipped, false);
+}
+
+void TQWidget::setDefaultWidgetFlags() {
+ TQtUpperWidgetFlags = TQtUpperWidgetFlags | WPaintOnScreen;
+}
+
+/*!
+ 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 tqlayout recalculation
+ takes too long for the CPU.
+
+ If a widget supports multiple character tqunicode 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( TQt::WState_CompressKeys );
+ else
+ clearWState( TQt::WState_CompressKeys );
+}
+
+/*!
+ Returns the focus data for this widget's top-level widget.
+
+ Focus data always belongs to the top-level widget. The focus data
+ list tqcontains all the widgets in this top-level widget that can
+ accept focus, in tab order. An iterator points to the current
+ focus widget (tqfocusWidget() 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 = tqtopLevelWidget();
+ 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;
+
+ // [FIXME] What does this do and how can I do it in Qt4?
+ printf("[WARNING] TQWidget::focusData( bool create ) unimplemented\n\r");
+ return 0;
+}
+
+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_TQWS) && !defined(TQT_NO_TQWS_MANAGER)
+ x->decor_allocated_region = TQRegion();
+ x->qwsManager = 0;
+#endif
+ createTLSysExtra();
+ }
+}
+
+/*!
+ \property TQWidget::autoMask
+ \brief whether the auto tqmask feature is enabled for the widget
+
+ Transtqparent widgets use a tqmask to define their visible region.
+ TQWidget has some built-in support to make the task of
+ recalculating the tqmask easier. When setting auto tqmask 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 tqmask 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 tqmask.
+
+ 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 transtqparent label. The
+ complex tqshape of its contents makes it necessary to represent its
+ tqmask 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 tqmask.
+
+ \sa autoMask() updateMask() setMask() clearMask() setBackgroundOrigin()
+*/
+
+// [FIXME]
+// Verify that (WState)TQt::WState_AutoMask is a valid window state in Qt4, or at least
+// does not conflict with any Qt4 window states (i.e. can live alone without stomping on anything!)
+
+bool TQWidget::autoMask() const
+{
+ return testWState((WState)TQt::WState_AutoMask);
+}
+
+void TQWidget::setAutoMask( bool enable )
+{
+ if ( enable == autoMask() )
+ return;
+
+ if ( enable ) {
+ setWState((WState)TQt::WState_AutoMask);
+ updateMask();
+ } else {
+ clearWState((WState)TQt::WState_AutoMask);
+ clearMask();
+ }
+}
+
+void TQWidget::setFocus(TQFocusEvent::Reason reason)
+{
+ setFocus((Qt::FocusReason)reason);
+}
+
+TQObject *TQWidget::tqparent() const {
+ return TQT_TQOBJECT(parent());
+}
+
+// const TQObjectList *TQWidget::childrenListObject() const {
+// QObjectList qlr;
+// TQObjectList* tqt_tqobject_list = new TQObjectList();
+// qlr = this->children();
+// tqt_tqobject_list->clear();
+// for (int i = 0; i < qlr.size(); ++i) {
+// tqt_tqobject_list->append(static_cast<TQObject*>(qlr.at(i)));
+// }
+// return tqt_tqobject_list;
+// }
+
+TQObjectList TQWidget::childrenListObject() {
+ QObjectList qlr;
+ TQObjectList tqt_tqobject_list;
+ qlr = this->children();
+ tqt_tqobject_list.clear();
+ for (int i = 0; i < qlr.size(); ++i) {
+ tqt_tqobject_list.append(static_cast<TQObject*>(qlr.at(i)));
+ }
+ return tqt_tqobject_list;
+}
+
+const TQObjectList TQWidget::childrenListObject() const {
+ QObjectList qlr;
+ TQObjectList tqt_tqobject_list;
+ qlr = this->children();
+ tqt_tqobject_list.clear();
+ for (int i = 0; i < qlr.size(); ++i) {
+ tqt_tqobject_list.append(static_cast<TQObject*>(qlr.at(i)));
+ }
+ return tqt_tqobject_list;
+}
+
+const char *TQWidget::tqname() const {
+ if (dynamic_cast<const TQWidget*>(static_cast<const QWidget*>(static_cast<const QObject*>(this)))) {
+ static_object_name = TQT_OBJECT_NAME_HANDLER(objectName());
+ return static_object_name.ascii();
+ }
+ else {
+ printf("[WARNING] Attempted to call TQWidget::tqname() on an object without a constructed TQWidget object or base object. Returning \"\"\n\r");
+ return "";
+ }
+}
+
+const char *TQWidget::name() const {
+ if (dynamic_cast<const TQWidget*>(static_cast<const QWidget*>(static_cast<const QObject*>(this)))) {
+ static_object_name = TQT_OBJECT_NAME_HANDLER(objectName());
+ return static_object_name.ascii();
+ }
+ else {
+ printf("[WARNING] Attempted to call TQWidget::name() on an object without a constructed TQWidget object or base object. Returning \"\"\n\r");
+ return "";
+ }
+}
+
+TQLayout *TQWidget::tqlayout() const {
+ return TQT_TQLAYOUT(QWidget::layout());
+}
+
+/*!
+ Clear the rectangle at point (\a x, \a y) of width \a w and height
+ \a h.
+
+ \warning This is best done in a paintEvent().
+*/
+void TQWidget::erase_helper(int x, int y, int w, int h)
+{
+// if (testAttribute(Qt::WA_NoSystemBackground) || testAttribute(Qt::WA_UpdatesDisabled) || !testAttribute(Qt::WA_WState_Visible))
+// return;
+ if (w < 0)
+// w = data->crect.width() - x;
+ w = QWidget::x() - x;
+ if (h < 0)
+// h = data->crect.height() - y;
+ h = QWidget::y() - y;
+ if (w != 0 && h != 0) {
+// if (paintingActive()) {
+ if (paintingActive() && paintEngine()->isActive()) {
+ QPainter* p = paintEngine()->painter();
+ if (p) {
+ printf("[WARNING] A painter was aready active when TQWidget::erase(...) was called. Attempting to use existing painter for erasure...\n\r");
+ p->eraseRect(QRect(x, y, w, h));
+ }
+ else {
+ printf("[WARNING] A painter was aready active when TQWidget::erase(...) was called. Attempted to use existing painter for erasure but that FAILED!\n\r");
+ }
+ }
+ else {
+ QPainter p(this);
+ p.eraseRect(QRect(x, y, w, h));
+ }
+ }
+}
+
+/*!
+ \overload
+
+ Clear the given region, \a rgn.
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your erasing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+void TQWidget::erase(const QRegion& rgn)
+{
+ if (testAttribute(Qt::WA_NoSystemBackground) || testAttribute(Qt::WA_UpdatesDisabled) || !testAttribute(Qt::WA_WState_Visible))
+ return;
+
+ QPainter p(this);
+ p.setClipRegion(rgn);
+ p.eraseRect(rgn.boundingRect());
+}
+
+/*!
+ Returns the color role used for painting the widget's background.
+
+ Use QPalette(backgroundRole(()) instead.
+*/
+TQt::BackgroundMode TQWidget::backgroundMode() const
+{
+ if (testAttribute(Qt::WA_NoSystemBackground))
+ return TQt::NoBackground;
+ switch(backgroundRole()) {
+ case QPalette::WindowText:
+ return TQt::PaletteForeground;
+ case QPalette::Button:
+ return TQt::PaletteButton;
+ case QPalette::Light:
+ return TQt::PaletteLight;
+ case QPalette::Midlight:
+ return TQt::PaletteMidlight;
+ case QPalette::Dark:
+ return TQt::PaletteDark;
+ case QPalette::Mid:
+ return TQt::PaletteMid;
+ case QPalette::Text:
+ return TQt::PaletteText;
+ case QPalette::BrightText:
+ return TQt::PaletteBrightText;
+ case QPalette::Base:
+ return TQt::PaletteBase;
+ case QPalette::Window:
+ return TQt::PaletteBackground;
+ case QPalette::Shadow:
+ return TQt::PaletteShadow;
+ case QPalette::Highlight:
+ return TQt::PaletteHighlight;
+ case QPalette::HighlightedText:
+ return TQt::PaletteHighlightedText;
+ case QPalette::ButtonText:
+ return TQt::PaletteButtonText;
+ case QPalette::Link:
+ return TQt::PaletteLink;
+ case QPalette::LinkVisited:
+ return TQt::PaletteLinkVisited;
+ default:
+ break;
+ }
+ return TQt::NoBackground;
+}
+
+/*!
+ \fn void QWidget::setBackgroundMode(Qt::BackgroundMode
+ widgetBackground, Qt::BackgroundMode paletteBackground)
+
+ Sets the color role used for painting the widget's background to
+ background mode \a widgetBackground. The \a paletteBackground mode
+ parameter is ignored.
+*/
+void TQWidget::setBackgroundMode(TQt::BackgroundMode m, TQt::BackgroundMode)
+{
+ if(m == TQt::NoBackground) {
+ setAttribute(Qt::WA_NoSystemBackground, true);
+ return;
+ }
+ setAttribute(Qt::WA_NoSystemBackground, false);
+ setForegroundRole(QPalette::NoRole);
+ QPalette::ColorRole role = backgroundRole();
+ switch(m) {
+ case TQt::FixedColor:
+ case TQt::FixedPixmap:
+ break;
+ case TQt::PaletteForeground:
+ role = QPalette::WindowText;
+ break;
+ case TQt::PaletteButton:
+ role = QPalette::Button;
+ break;
+ case TQt::PaletteLight:
+ role = QPalette::Light;
+ break;
+ case TQt::PaletteMidlight:
+ role = QPalette::Midlight;
+ break;
+ case TQt::PaletteDark:
+ role = QPalette::Dark;
+ break;
+ case TQt::PaletteMid:
+ role = QPalette::Mid;
+ break;
+ case TQt::PaletteText:
+ role = QPalette::Text;
+ break;
+ case TQt::PaletteBrightText:
+ role = QPalette::BrightText;
+ break;
+ case TQt::PaletteBase:
+ role = QPalette::Base;
+ break;
+ case TQt::PaletteBackground:
+ role = QPalette::Window;
+ break;
+ case TQt::PaletteShadow:
+ role = QPalette::Shadow;
+ break;
+ case TQt::PaletteHighlight:
+ role = QPalette::Highlight;
+ break;
+ case TQt::PaletteHighlightedText:
+ role = QPalette::HighlightedText;
+ break;
+ case TQt::PaletteButtonText:
+ role = QPalette::ButtonText;
+ break;
+ case TQt::PaletteLink:
+ role = QPalette::Link;
+ break;
+ case TQt::PaletteLinkVisited:
+ role = QPalette::LinkVisited;
+ break;
+ case TQt::X11ParentRelative:
+ role = QPalette::NoRole;
+ setForegroundRole(role);
+ default:
+ break;
+ }
+ setBackgroundRole(role);
+}
+/*
+TQRect TQWidget::tqeffectiveRectFor(const QRect &rect) const
+{
+// #ifndef QT_NO_GRAPHICSEFFECT
+// if (graphicsEffect() && graphicsEffect()->isEnabled())
+// return graphicsEffect()->boundingRectFor(rect).toAlignedRect();
+// #endif //QT_NO_GRAPHICSEFFECT
+ return rect;
+}*/
+
+/*
+ Returns the widget's clipping rectangle.
+*/
+TQRect TQWidget::tqclipRect() const
+{
+// Q_Q(const QWidget);
+ const QWidget * w = this;
+ if (!w->isVisible())
+ return QRect();
+// QRect r = tqeffectiveRectFor(this->rect()); // [FIXME]
+ QRect r = this->rect();
+ int ox = 0;
+ int oy = 0;
+ while (w
+ && w->isVisible()
+ && !w->isWindow()
+ && w->parentWidget()) {
+ ox -= w->x();
+ oy -= w->y();
+ w = w->parentWidget();
+ r &= QRect(ox, oy, w->width(), w->height());
+ }
+ return r;
+}
+
+/*!
+ Use visibleRegion() instead.
+*/
+TQRect TQWidget::visibleRect() const
+{
+ return tqclipRect();
+}
+
+/*!
+ 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 tqrepaint() function calls this function if necessary, so in
+ general you do not need to call it.
+
+*/
+TQRegion TQWidget::clipRegion() const
+{
+ return visibleRect();
+}
+
+void TQWidget::setIcon(const QPixmap &i)
+{
+ setWindowIcon(i);
+}
+
+/*!
+ \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;
+}
+
+const TQPixmap *TQWidget::icon() const {
+ const_cast<TQWidget*>(this)->setProperty("TQT_WIDGET_ICON", TQPixmap(windowIcon().pixmap(QSize(14, 14)))); // [FIXME] Is there any way around hardcoding these sizes??
+ const QPixmap& ptrRef = property("TQT_WIDGET_ICON").value<QPixmap>();
+ return TQT_TQPIXMAP_CONST(&ptrRef);
+}
+
+const TQPixmap TQWidget::iconPixmap() const {
+ return TQPixmap(windowIcon().pixmap(QSize(14, 14))); // [FIXME] Is there any way around hardcoding these sizes??
+}
+
+/*!
+ This function can be reimplemented in a subclass to support
+ transtqparent widgets. It should be called whenever a widget changes
+ state in a way that means that the tqshape tqmask must be recalculated.
+
+ \sa setAutoMask(), updateMask(), setMask(), clearMask()
+*/
+void TQWidget::updateMask()
+{
+}
+
+/*!
+ Returns the GUI style for this widget
+
+ \sa TQWidget::setStyle(), TQApplication::setStyle(), TQApplication::style()
+*/
+
+TQStyle& TQWidget::tqstyle() const
+{
+// if ( extra && extra->style )
+// return *extra->style;
+ TQStyle &ret = tqApp->tqstyle();
+ 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 )
+{
+ QWidget::setStyle(style);
+}
+
+/*!
+ \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;
+}
+
+/*!
+ \property TQWidget::tqsizeHint
+ \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 tqsizeHint() returns an invalid size
+ if there is no tqlayout for this widget, and returns the tqlayout's
+ preferred size otherwise.
+
+ \sa TQSize::isValid(), tqminimumSizeHint(), sizePolicy(),
+ setMinimumSize(), updateGeometry()
+*/
+
+TQSize TQWidget::tqsizeHint() const
+{
+#ifndef TQT_NO_LAYOUT
+ if ( tqlayout() )
+ return tqlayout()->totalSizeHint();
+#endif
+ return TQSize( -1, -1 );
+}
+
+/*!
+ \property TQWidget::tqminimumSizeHint
+ \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 tqminimumSizeHint() returns an invalid
+ size if there is no tqlayout for this widget, and returns the
+ tqlayout's minimum size otherwise. Most built-in widgets reimplement
+ tqminimumSizeHint().
+
+ \l TQLayout will never resize a widget to a size smaller than
+ tqminimumSizeHint.
+
+ \sa TQSize::isValid(), resize(), setMinimumSize(), sizePolicy()
+*/
+TQSize TQWidget::tqminimumSizeHint() const
+{
+#ifndef TQT_NO_LAYOUT
+ if ( tqlayout() )
+ return tqlayout()->totalMinimumSize();
+#endif
+ return TQSize( -1, -1 );
+}
+
+/*!
+ \property TQWidget::updatesEnabled
+ \brief whether updates are enabled
+
+ Calling update() and tqrepaint() 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 );
+ tqrepaint();
+ \endcode
+
+ \sa update(), tqrepaint(), paintEvent()
+*/
+void TQWidget::tqsetUpdatesEnabled( bool enable )
+{
+// if ( enable )
+// clearWState( WState_BlockUpdates );
+// else
+// setWState( WState_BlockUpdates );
+
+ // Borrowed from Qt4
+ if (enable && !isWindow() && parentWidget() && !parentWidget()->updatesEnabled())
+ return; // nothing we can do
+
+ if (enable != testAttribute(Qt::WA_UpdatesDisabled))
+ return; // nothing to do
+
+ setAttribute(Qt::WA_UpdatesDisabled, !enable);
+// if (enable)
+// update();
+
+ Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled;
+ for (int i = 0; i < children().size(); ++i) {
+ TQWidget *w = TQT_TQWIDGET(qobject_cast<QWidget *>(children().at(i)));
+ if (w && !w->isWindow() && !w->testAttribute(attribute))
+ w->tqsetUpdatesEnabled(enable);
+ }
+}
+
+// USE_QT4
+
+// PRIVATE API FROM QT4
+// THIS MAY HAVE TO BE SYNCED WITH QT4 ON OCCASION
+/*!
+ \internal
+ \class QWidgetBackingStoreTracker
+ \brief Class which allows tracking of which widgets are using a given backing store
+
+ QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer,
+ which maintains a list of the QWidgets which are currently using the backing
+ store. This list is modified via the registerWidget and unregisterWidget functions.
+ */
+
+QWidgetBackingStoreTracker::QWidgetBackingStoreTracker()
+ : m_ptr(0)
+{
+
+}
+
+QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker()
+{
+ delete m_ptr;
+}
+
+#if 0
+
+/*!
+ \internal
+ Destroy the contained QWidgetBackingStore, if not null, and clear the list of
+ widgets using the backing store, then create a new QWidgetBackingStore, providing
+ the QWidget.
+ */
+void QWidgetBackingStoreTracker::create(QWidget *widget)
+{
+ destroy();
+ m_ptr = new QWidgetBackingStore(widget);
+}
+
+/*!
+ \internal
+ Destroy the contained QWidgetBackingStore, if not null, and clear the list of
+ widgets using the backing store.
+ */
+void QWidgetBackingStoreTracker::destroy()
+{
+ delete m_ptr;
+ m_ptr = 0;
+ m_widgets.clear();
+}
+
+/*!
+ \internal
+ Add the widget to the list of widgets currently using the backing store.
+ If the widget was already in the list, this function is a no-op.
+ */
+void QWidgetBackingStoreTracker::registerWidget(QWidget *w)
+{
+ Q_ASSERT(m_ptr);
+ Q_ASSERT(w->internalWinId());
+ Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr);
+ m_widgets.insert(w);
+}
+
+/*!
+ \internal
+ Remove the widget from the list of widgets currently using the backing store.
+ If the widget was in the list, and removing it causes the list to be empty,
+ the backing store is deleted.
+ If the widget was not in the list, this function is a no-op.
+ */
+void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w)
+{
+ if (m_widgets.remove(w) && m_widgets.isEmpty()) {
+ delete m_ptr;
+ m_ptr = 0;
+ }
+}
+
+#endif
+
+// END PRIVATE API
+
+// TQMetaObject *TQWidget::tqstaticMetaObject() {
+// return const_cast<TQMetaObject*>(static_cast<const TQMetaObject*>(&TQT_BASE_OBJECT_NAME::staticMetaObject));
+// }
+
+/*!
+ 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 )
+{
+ switch ( e->type() ) {
+// case TQEvent::MouseMove:
+// mouseMoveEvent( (TQMouseEvent*)e );
+// if ( ! ((TQMouseEvent*)e)->isAccepted() )
+// return FALSE;
+// break;
+//
+// case TQEvent::MouseButtonPress:
+// resetInputContext();
+// 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() & TQt::AltButton) ) {
+// if ( k->key() == Qt::Key_Backtab ||
+// (k->key() == Qt::Key_Tab &&
+// (k->state() & ShiftButton)) ) {
+// res = focusNextPrevChild( FALSE );
+//
+// } else if ( k->key() == Qt::Key_Tab ) {
+// res = focusNextPrevChild( TRUE );
+// }
+// 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_TQWS) && !defined (TQT_NO_TQWS_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 ( childrenListObject() ) {
+// TQObjectListIt it( *childrenListObject() );
+// 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 ( childrenListObject() ) {
+// // TQObjectListIt it( *childrenListObject() );
+// // TQObject *o;
+// // while( ( o = it.current() ) != 0 ) {
+// // ++it;
+// // TQApplication::sendEvent( o, e );
+// // }
+// // }
+// // if ( e->type() == TQEvent::LanguageChange ) {
+// // int index = tqmetaObject()->tqfindSlot( "languageChange()", TRUE );
+// // if ( index >= 0 )
+// // qt_invoke( index, 0 );
+// // }
+// // update();
+// // break;
+// // #ifndef TQT_NO_LAYOUT
+// // case TQEvent::LayoutDirectionChange:
+// // if ( tqlayout() ) {
+// // tqlayout()->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:
+ {
+ if (tqt_internal_ignore_next_windowstatechange_event == FALSE) {
+ 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));
+ }
+ else {
+ tqt_internal_ignore_next_windowstatechange_event = FALSE;
+ }
+ break;
+ }
+
+// case TQEvent::WindowBlocked:
+// case TQEvent::WindowUnblocked:
+// if ( childrenListObject() ) {
+// TQObjectListIt it( *childrenListObject() );
+// TQObject *o;
+// while( ( o = it.current() ) != 0 ) {
+// ++it;
+// TQWidget *w = ::tqqt_cast<TQWidget*>(o);
+// if (w && !w->testWFlags(TQt::WShowModal))
+// TQApplication::sendEvent( o, e );
+// }
+// }
+// break;
+
+ case TQEvent::ChildInserted:
+// case TQEvent::ChildRemoved: // Causes a recursion loop if uncommented
+ childEvent( (TQChildEvent*)e );
+ return TRUE;
+
+ default:
+ if ( TQT_TQOBJECT(this)->TQObject::event( e ) )
+ return TRUE;
+ return QWidget::event(e);
+ }
+
+ 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 = TQT_TQWIDGET(tqApp->activePopupWidget()) ) && w != this ){
+ w->close();
+ if (tqApp->activePopupWidget() == w) // widget does not want to dissappear
+ w->hide(); // hide at least
+ }
+ if (!TQT_TQRECT_OBJECT(rect()).tqcontains(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 tqparent 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 tqparent 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 tqparent 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 tqparent 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 <b>Esc</b>. 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 tqparent 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() != Qt::NoFocus || !isTopLevel() ) {
+ update();
+ if ( testWState(TQt::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() != Qt::NoFocus || !isTopLevel() ){
+ update();
+ if ( testWState(TQt::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 )
+ return TQRect(width()/2, 0, 1, height() );
+ else if ( 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 tqrepaint all or part of the widget.
+ It can happen as a result of tqrepaint() or update(), or because the
+ widget was obscured and has now been uncovered, or for many other
+ reasons.
+
+ Many widgets can simply tqrepaint 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()).
+ tqrepaint() 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(), tqrepaint(), update(), TQPainter, TQPixmap, TQPaintEvent
+*/
+
+void TQWidget::paintEvent( TQPaintEvent *e )
+{
+// // At least let Qt4 get a shot at painting it
+// QWidget::paintEvent(e);
+}
+
+
+/*!
+ 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 tqgeometry. 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(TQt::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_TQWS)
+
+/*!
+ 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
+
+void TQWidget::timerEvent( TQTimerEvent * )
+{
+}
+
+void TQWidget::childEvent( TQChildEvent * )
+{
+}
+
+void TQWidget::customEvent( TQCustomEvent * )
+{
+}
+
+bool TQWidget::eventFilter( TQObject * /* watched */, TQEvent * /* e */ )
+{
+ return FALSE;
+}
+
+int TQWidget::x11Depth() const {
+ const QX11Info *info = &x11Info();
+ if (info)
+ return info->depth();
+ return QX11Info::appDepth();
+}
+
+/*!
+ Adjusts the size of the widget to fit the contents.
+
+ Uses tqsizeHint() if valid (i.e if the size hint's width and height
+ are \>= 0), otherwise sets the size to the tqchildren rectangle (the
+ union of all child widget geometries).
+
+ \sa tqsizeHint(), tqchildrenRect()
+*/
+
+void TQWidget::adjustSize()
+{
+ TQApplication::sendPostedEvents( 0, TQEvent::ChildInserted );
+ TQApplication::sendPostedEvents( 0, TQEvent::LayoutHint );
+ if ( !testWState(WState_Polished) )
+ polish();
+ TQSize s = tqsizeHint();
+
+ 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 ( tqlayout() ) {
+ if ( tqlayout()->hasHeightForWidth() ) {
+ s = s.boundedTo( screen.size() );
+ s.setHeight( tqlayout()->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 = tqchildrenRect(); // get tqchildren rectangle
+ if ( r.isNull() ) // probably no widgets
+ return;
+ resize( r.width() + 2 * r.x(), r.height() + 2 * r.y() );
+}
+
+bool TQWidget::isA( const char *classname ) const
+{
+ if (tqstrcmp(classname, metaObject()->className()) == 0) return true;
+ else {
+ TQString cn = metaObject()->className();
+ if (cn[0] == 'T')
+ cn = cn.remove(0,1);
+ return (tqstrcmp(classname, cn.ascii()) == 0);
+ }
+}
+
+bool TQWidget::inherits( const char *classname ) const {
+ if (QWidget::inherits(classname)) return true;
+ else {
+ TQString cn = classname;
+ if (cn[0] != 'T')
+ cn = cn.prepend('T');
+ return QWidget::inherits(cn.ascii());
+ }
+}
+
+void TQWidget::setWState( uint state ) {
+ if (state == TQt::WState_OwnSizePolicy) setAttribute(Qt::WA_WState_OwnSizePolicy, true);
+ else if (state == TQt::WState_BlockUpdates) setAttribute(Qt::WA_ForceUpdatesDisabled, true);
+ else {
+ tqt_internal_ignore_next_windowstatechange_event = TRUE;
+ overrideWindowState((Qt::WindowState) (windowState() | state));
+ }
+}
+
+void TQWidget::clearWState( uint flags ) {
+ if (flags == TQt::WState_OwnSizePolicy)
+ setAttribute(Qt::WA_WState_OwnSizePolicy, false);
+ else if (flags == TQt::WState_BlockUpdates)
+ setAttribute(Qt::WA_ForceUpdatesDisabled, false);
+ else {
+ tqt_internal_ignore_next_windowstatechange_event = TRUE;
+ overrideWindowState((QWidget::windowState() &= (Qt::WindowState)(~flags)));
+ }
+}
+
+WState TQWidget::getWState() const {
+ return QWidget::windowState();
+}
+
+WState TQWidget::testWState( WState s ) const {
+ if (s == TQt::WState_OwnSizePolicy)
+ return (WState)(testAttribute(Qt::WA_WState_OwnSizePolicy) ? TQt::WState_OwnSizePolicy : 0);
+ else if (s == TQt::WState_BlockUpdates)
+ return (WState)(testAttribute(Qt::WA_ForceUpdatesDisabled) ? TQt::WState_BlockUpdates : 0);
+ else
+ return (QWidget::windowState() & s);
+}
+
+WState TQWidget::testWState( TQt::WidgetState s ) const {
+ if (s == TQt::WState_OwnSizePolicy)
+ return (WState)(testAttribute(Qt::WA_WState_OwnSizePolicy) ? TQt::WState_OwnSizePolicy : 0);
+ else if (s == TQt::WState_BlockUpdates)
+ return (WState)(testAttribute(Qt::WA_ForceUpdatesDisabled) ? TQt::WState_BlockUpdates : 0);
+ else
+ return (QWidget::windowState() & s);
+}
+
+#else // USE_QT4
+
+/*!
+ \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 tqparent and by the widgets in front of it.
+
+ A widget that isn't embedded in a tqparent 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 tqparent widget is always a top-level widget.
+
+ Non-top-level widgets are child widgets. These are child windows
+ in their tqparent widgets. You cannot usually distinguish a child
+ widget from its tqparent 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 tqlayout to the tqparent TQWidget. (See \link
+ tqlayout.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(),
+ tqrepaint(),
+ erase(),
+ scroll(),
+ updateMask().
+
+ \row \i Geometry \i
+ pos(),
+ size(),
+ rect(),
+ x(),
+ y(),
+ width(),
+ height(),
+ sizePolicy(),
+ tqsetSizePolicy(),
+ tqsizeHint(),
+ updateGeometry(),
+ tqlayout(),
+ move(),
+ resize(),
+ setGeometry(),
+ frameGeometry(),
+ tqgeometry(),
+ tqchildrenRect(),
+ adjustSize(),
+ mapFromGlobal(),
+ mapFromParent()
+ mapToGlobal(),
+ mapToParent(),
+ tqmaximumSize(),
+ tqminimumSize(),
+ 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(),
+ tqcolorGroup(),
+ fontMetrics(),
+ fontInfo().
+
+ \row \i Keyboard focus<br>functions \i
+ isFocusEnabled(),
+ setFocusPolicy(),
+ focusPolicy(),
+ hasFocus(),
+ setFocus(),
+ clearFocus(),
+ setTabOrder(),
+ setFocusProxy().
+
+ \row \i Mouse and<br>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(),
+ tqtopLevelWidget(),
+ reparent(),
+ polish(),
+ winId(),
+ tqfind(),
+ metric().
+
+ \row \i What's this help \i
+ customWhatsThis()
+
+ \row \i Internal kernel<br>functions \i
+ focusNextPrevChild(),
+ wmapper(),
+ clearWFlags(),
+ getWFlags(),
+ setWFlags(),
+ testWFlags().
+
+ \endtable
+
+ Every widget's constructor accepts two or three standard arguments:
+ \list 1
+ \i \c{TQWidget *tqparent = 0} is the tqparent 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 tqparent, and be constrained by \e
+ tqparent's tqgeometry (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 tqcontains 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 tqchildren 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 tqcontains 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
+ tqparent 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 tqchildren 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
+ tqparent.
+
+ \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 tqevent.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 tqsizeHint() and to set
+ the correct size policy with tqsetSizePolicy(), so users of your class
+ can set up tqlayout management more easily. A size policy lets you
+ supply good defaults for the tqlayout management handling, so that
+ other widgets can contain and manage yours easily. tqsizeHint()
+ 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_TQWS) || defined(TQ_OS_TEMP)
+static const int WDictSize = 163; // plenty for small tqdevices
+#else
+static const int WDictSize = 1123; // plenty for 5 big complex windows
+#endif
+
+class TQWidgetMapper : public TQWidgetIntDict
+{ // maps ids -> widgets
+public:
+ TQWidgetMapper();
+ ~TQWidgetMapper();
+ TQWidget *tqfind( WId id ); // tqfind widget
+ void insert( const TQWidget * ); // insert widget
+ bool remove( WId id ); // remove widget
+private:
+ WId cur_id;
+ TQWidget *cur_widget;
+};
+
+TQWidgetMapper *TQWidget::wmapper() = 0; // app global widget mapper
+
+
+TQWidgetMapper::TQWidgetMapper() : TQWidgetIntDict(WDictSize)
+{
+ cur_id = 0;
+ cur_widget = 0;
+}
+
+TQWidgetMapper::~TQWidgetMapper()
+{
+ clear();
+}
+
+inline TQWidget *TQWidgetMapper::tqfind( WId id )
+{
+ if ( id != cur_id ) { // need to lookup
+ cur_widget = TQWidgetIntDict::tqfind((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->tqsizeHint();
+ TQ_SPExpandData exp;
+#ifndef TQT_NO_LAYOUT
+ if ( w->tqlayout() ) {
+ if ( w->tqlayout()->hasHeightForWidth() )
+ s.setHeight( w->tqlayout()->totalHeightForWidth( s.width() ) );
+ exp = w->tqlayout()->expandingDirections();
+ } else
+#endif
+ {
+ if ( w->sizePolicy().hasHeightForWidth() )
+ s.setHeight( w->heightForWidth( s.width() ) );
+ exp = w->sizePolicy().expandingDirections();
+ }
+ 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 tqmask, 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 tqparent 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 tqparent 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 tqparent, the tool window will always be kept on top of
+ it. If there isn't a tqparent, 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 tqparent (i.e. a dialog). The window will not get
+ its own taskbar entry and will be kept on top of its tqparent by the
+ window system. Usually it will also be minimized when the tqparent
+ 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 tqrepaint events directly. (This tends to produce more events
+ and smaller tqrepaint regions.)
+
+ \value WMouseNoMask indicates that even if the widget has a tqmask,
+ 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 tqparent (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
+ tqparent 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::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 tqparent, with the name
+ \a name and widget flags set to \a f.
+
+ If \a tqparent is 0, the new widget becomes a top-level window. If
+ \a tqparent is another widget, this widget becomes a child window
+ inside \a tqparent. The new widget is deleted when its \a tqparent 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
+ tqparent 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 *tqparent, const char *name, WFlags f )
+ : TQObject( tqparent, name ), TQPaintDevice( TQInternal::Widget )
+{
+#if defined(TQT_CHECK_STATE) && !defined(TQ_WS_WIN)
+ if ( tqApp->type() == TQApplication::Tty ) {
+ qWarning( "TQWidget: Cannot create a TQWidget when no GUI "
+ "is being used" );
+ }
+#endif
+
+ fstrut_dirty = 1;
+
+ isWidget = TRUE; // is a widget
+ winid = 0; // default attributes
+ widget_state = 0;
+ widget_flags = f;
+ 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->tqfocusWidgets.tqfindRef(this) < 0 )
+ fd->tqfocusWidgets.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 tqchildren are deleted first. The application
+ exits if this widget is the main widget.
+*/
+
+TQWidget::~TQWidget()
+{
+#if defined (TQT_CHECK_STATE)
+ if ( paintingActive() )
+ qWarning( "%s (%s): deleted while being painted", className(), name() );
+#endif
+
+ // Remove myself and all tqchildren from the can-take-focus list
+ TQFocusData *f = focusData( FALSE );
+ if ( f ) {
+ TQPtrListIterator<TQWidget> it(f->tqfocusWidgets);
+ TQWidget *w;
+ while ( (w = it.current()) ) {
+ ++it;
+ TQWidget * p = w;
+ while( p && p != this )
+ p = p->parentWidget();
+ if ( p ) // my descendant
+ f->tqfocusWidgets.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 tqparent widget must destroy all its tqchildren before destroying itself
+ if ( childObjects ) { // delete tqchildren 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;
+ register TQWidget *w;
+ while ( (w=it.current()) ) { // remove parents widgets
+ ++it;
+ if ( !w->parentObj ) // widget is a tqparent
+ 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::tqtopLevelWidgets()
+*/
+
+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_TQWS) && !defined(TQT_NO_TQWS_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 );
+ createSysExtra();
+ }
+}
+
+
+/*!
+ \internal
+ Deletes the widget extra data.
+*/
+
+void TQWidget::deleteExtra()
+{
+ if ( extra ) { // if exists
+ 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_TQWS) && !defined(TQT_NO_TQWS_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<TQWidget> 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 tqwindowdefs.h for the actual definition. If there
+ is no widget with this identifier, 0 is returned.
+*/
+
+TQWidget *TQWidget::tqfind( WId id )
+{
+ return mapper ? mapper->tqfind( 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 tqfind(), 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 tqfind()
+*/
+
+#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
+ tqgeometry.
+
+ \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() tqparent
+ widget\endlink. It will then be grouped with its tqparent and deleted
+ when the tqparent is deleted, minimized when the tqparent is minimized
+ etc. If supported by the window manager, it will also have a
+ common taskbar entry with its tqparent.
+
+ TQDialog and TQMainWindow widgets are by default top-level, even if
+ a tqparent widget is specified in the constructor. This behavior is
+ specified by the \c WType_TopLevel widget flag.
+
+ \sa tqtopLevelWidget(), 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 tqparent.
+
+ \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 tqgeometry.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 tqparent 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 tqchildren. 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 ( childrenListObject() ) {
+ TQObjectListIt it( *childrenListObject() );
+ 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 (tqfocusWidget() == this) {
+ bool parentIsEnabled = (!parentWidget() || parentWidget()->isEnabled());
+ if (!parentIsEnabled || !focusNextPrevChild(TRUE))
+ clearFocus();
+ }
+ setWState( WState_Disabled );
+ setBackgroundFromMode();
+ enabledChange( !enable );
+ if ( childrenListObject() ) {
+ TQObjectListIt it( *childrenListObject() );
+ 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 qt_x11_enforce_cursor( TQWidget * w ); // defined in qwidget_x11.cpp
+ qt_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(), tqrepaint(), update(), clipRegion()
+*/
+
+void TQWidget::enabledChange( bool )
+{
+ update();
+#if defined(TQT_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 tqgeometry of the widget relative to its tqparent including any
+ window frame
+
+ See the \link tqgeometry.html Window Geometry documentation\endlink
+ for an overview of tqgeometry issues with top-level widgets.
+
+ \sa tqgeometry() 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 tqparent including
+ any window frame
+
+ See the \link tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \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 tqparent and
+ including any window frame
+
+ See the \link tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \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 tqparent 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 tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \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::tqgeometry
+ \brief the tqgeometry of the widget relative to its tqparent and
+ excluding the window frame
+
+ When changing the tqgeometry, 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 tqminimumSize() and tqmaximumSize().
+
+ 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 tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \sa frameGeometry(), rect(), move(), resize(), moveEvent(),
+ resizeEvent(), tqminimumSize(), tqmaximumSize()
+*/
+
+/*!
+ \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
+ tqminimumSize() and tqmaximumSize(). 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 tqlayout.
+
+ 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, tqgeometry, tqminimumSize, tqmaximumSize, resizeEvent()
+*/
+
+/*!
+ \property TQWidget::width
+ \brief the width of the widget excluding any window frame
+
+ See the \link tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \sa tqgeometry, height, size
+*/
+
+/*!
+ \property TQWidget::height
+ \brief the height of the widget excluding any window frame
+
+ See the \link tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \sa tqgeometry, width, size
+*/
+
+/*!
+ \property TQWidget::rect
+ \brief the internal tqgeometry of the widget excluding any window
+ frame
+
+ The rect property equals TQRect(0, 0, width(), height()).
+
+ See the \link tqgeometry.html Window Geometry documentation\endlink
+ for an overview of top-level widget tqgeometry.
+
+ \sa size
+*/
+
+/*!
+ \property TQWidget::tqchildrenRect
+ \brief the bounding rectangle of the widget's tqchildren
+
+ Hidden tqchildren are excluded.
+
+ \sa tqchildrenRegion() tqgeometry()
+*/
+
+TQRect TQWidget::tqchildrenRect() const
+{
+ TQRect r( 0, 0, 0, 0 );
+ if ( !childrenListObject() )
+ return r;
+ TQObjectListIt it( *childrenListObject() );
+ TQObject *obj;
+ while ( (obj = it.current()) ) {
+ ++it;
+ if ( obj->isWidgetType() && !((TQWidget*)obj)->isHidden() && !((TQWidget*)obj)->isTopLevel())
+ r = r.unite( ((TQWidget*)obj)->tqgeometry() );
+ }
+ return r;
+}
+
+/*!
+ \property TQWidget::tqchildrenRegion
+ \brief the combined region occupied by the widget's tqchildren
+
+ Hidden tqchildren are excluded.
+
+ \sa tqchildrenRect() tqgeometry()
+*/
+
+TQRegion TQWidget::tqchildrenRegion() const
+{
+ TQRegion r;
+ if ( !childrenListObject() )
+ return r;
+ TQObjectListIt it( *childrenListObject() ); // iterate over all tqchildren
+ TQObject *obj;
+ while ( (obj=it.current()) ) {
+ ++it;
+ if ( obj->isWidgetType() && !((TQWidget*)obj)->isHidden() && !((TQWidget*)obj)->isTopLevel())
+ r = r.unite( ((TQWidget*)obj)->tqgeometry() );
+ }
+ return r;
+}
+
+
+/*!
+ \property TQWidget::tqminimumSize
+ \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 tqlayout inside the widget, the minimum size will be
+ set by the tqlayout and not by setMinimumSize(), unless you set the
+ tqlayout's resize mode to TQLayout::FreeResize.
+
+ \sa minimumWidth, minimumHeight, tqmaximumSize, sizeIncrement
+ TQLayout::setResizeMode()
+*/
+
+TQSize TQWidget::tqminimumSize() const
+{
+ return extra ? TQSize( extra->minw, extra->minh ) : TQSize( 0, 0 );
+}
+
+/*!
+ \property TQWidget::tqmaximumSize
+ \brief the widget's maximum size
+
+ The widget cannot be resized to a larger size than the maximum
+ widget size.
+
+ \sa maximumWidth(), maximumHeight(), setMaximumSize(),
+ tqminimumSize(), sizeIncrement()
+*/
+
+TQSize TQWidget::tqmaximumSize() 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 tqminimumSize().width().
+
+ \sa tqminimumSize, minimumHeight
+*/
+
+/*!
+ \property TQWidget::minimumHeight
+ \brief the widget's minimum height
+
+ This property corresponds to tqminimumSize().height().
+
+ \sa tqminimumSize, minimumWidth
+*/
+
+/*!
+ \property TQWidget::maximumWidth
+ \brief the widget's maximum width
+
+ This property corresponds to tqmaximumSize().width().
+
+ \sa tqmaximumSize, maximumHeight
+*/
+
+/*!
+ \property TQWidget::maximumHeight
+ \brief the widget's maximum height
+
+ This property corresponds to tqmaximumSize().height().
+
+ \sa tqmaximumSize, 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, tqminimumSize, tqmaximumSize
+*/
+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, tqminimumSize().height() );
+}
+
+void TQWidget::setMinimumHeight( int h )
+{
+ setMinimumSize( tqminimumSize().width(), h );
+}
+
+void TQWidget::setMaximumWidth( int w )
+{
+ setMaximumSize( w, tqmaximumSize().height() );
+}
+
+void TQWidget::setMaximumHeight( int h )
+{
+ setMaximumSize( tqmaximumSize().width(), h );
+}
+
+/*!
+ Sets both the minimum and maximum width of the widget to \a w
+ without changing the heights. Provided for convenience.
+
+ \sa tqsizeHint() tqminimumSize() tqmaximumSize() setFixedSize()
+*/
+
+void TQWidget::setFixedWidth( int w )
+{
+ setMinimumSize( w, tqminimumSize().height() );
+ setMaximumSize( w, tqmaximumSize().height() );
+}
+
+
+/*!
+ Sets both the minimum and maximum heights of the widget to \a h
+ without changing the widths. Provided for convenience.
+
+ \sa tqsizeHint() tqminimumSize() tqmaximumSize() setFixedSize()
+*/
+
+void TQWidget::setFixedHeight( int h )
+{
+ setMinimumSize( tqminimumSize().width(), h );
+ setMaximumSize( tqmaximumSize().width(), h );
+}
+
+
+/*!
+ Translates the widget coordinate \a pos to the coordinate system
+ of \a tqparent. The \a tqparent must not be 0 and must be a tqparent
+ of the calling widget.
+
+ \sa mapFrom() mapToParent() mapToGlobal() hasMouse()
+*/
+
+TQPoint TQWidget::mapTo( TQWidget * tqparent, const TQPoint & pos ) const
+{
+ TQPoint p = pos;
+ if ( tqparent ) {
+ const TQWidget * w = this;
+ while ( w != tqparent ) {
+ p = w->mapToParent( p );
+ w = w->parentWidget();
+ }
+ }
+ return p;
+}
+
+
+/*!
+ Translates the widget coordinate \a pos from the coordinate system
+ of \a tqparent to this widget's coordinate system. The \a tqparent
+ must not be 0 and must be a tqparent of the calling widget.
+
+ \sa mapTo() mapFromParent() mapFromGlobal() hasMouse()
+*/
+
+TQPoint TQWidget::mapFrom( TQWidget * tqparent, const TQPoint & pos ) const
+{
+ TQPoint p( pos );
+ if ( tqparent ) {
+ const TQWidget * w = this;
+ while ( w != tqparent ) {
+ p = w->mapFromParent( p );
+ w = w->parentWidget();
+ }
+ }
+ return p;
+}
+
+
+/*!
+ Translates the widget coordinate \a pos to a coordinate in the
+ tqparent widget.
+
+ Same as mapToGlobal() if the widget has no tqparent.
+
+ \sa mapFromParent() mapTo() mapToGlobal() hasMouse()
+*/
+
+TQPoint TQWidget::mapToParent( const TQPoint &pos ) const
+{
+ return pos + crect.topLeft();
+}
+
+/*!
+ Translates the tqparent widget coordinate \a pos to widget
+ coordinates.
+
+ Same as mapFromGlobal() if the widget has no tqparent.
+
+ \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->tqtopLevelWidget()->setCaption( "New Caption" );
+ \endcode
+
+ \sa isTopLevel()
+*/
+
+TQWidget *TQWidget::tqtopLevelWidget() 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 tqcolorGroup().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 = tqcolorGroup();
+ 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 tqcontains 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 tqcolorGroup().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(TQT_DEBUG)
+ qWarning( "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, tqcolorGroup()
+*/
+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 tqcolorGroup().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, tqcolorGroup()
+*/
+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 tqcolorGroup().brush( role );
+ }
+#else
+ return noBrush;
+#endif
+}
+
+
+/*!
+ \property TQWidget::tqcolorGroup
+ \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::tqcolorGroup() 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 tqparent'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, tqcolorGroup(), 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 ( childrenListObject() ) {
+ TQEvent e( TQEvent::ParentPaletteChange );
+ TQObjectListIt it( *childrenListObject() );
+ 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
+ tqparent'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 tqchildren
+ about the change.
+
+ \sa fontChange() fontInfo() fontMetrics() ownFont()
+*/
+void TQWidget::setFont( const TQFont &font )
+{
+ own_font = TRUE;
+ if ( fnt == font && fnt.d->tqmask == font.d->tqmask )
+ 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 ( childrenListObject() ) {
+ TQEvent e( TQEvent::ParentFontChange );
+ TQObjectListIt it( *childrenListObject() );
+ 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
+ tqgeometry.
+
+ \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 tqshape for this widget
+
+ The mouse cursor will assume this tqshape when it's over this
+ widget. See the \link TQt::tqCursorShape list of predefined cursor
+ objects\endlink for a range of useful tqshapes.
+
+ 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
+ tqparent'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 (TQT_CHECK_STATE)
+ qWarning( "%s (%s): already in focus proxy chain", className(), name() );
+#endif
+ return;
+ }
+ }
+
+ createExtra();
+
+ if ( extra->focus_proxy ) {
+ disconnect( extra->focus_proxy, TQT_SIGNAL(destroyed()),
+ this, TQT_SLOT(focusProxyDestroyed()) );
+ extra->focus_proxy = 0;
+ }
+
+ if ( w ) {
+ setFocusPolicy( w->focusPolicy() );
+ connect( w, TQT_SIGNAL(destroyed()),
+ this, TQT_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->tqfocusWidget() == this}.
+
+ \sa setFocus(), clearFocus(), setFocusPolicy(), TQApplication::tqfocusWidget()
+*/
+bool TQWidget::hasFocus() const
+{
+ const TQWidget* w = this;
+ while ( w->focusProxy() )
+ w = w->focusProxy();
+ return tqApp->tqfocusWidget() == 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::tqfocusWidget() grabKeyboard()
+ grabMouse()
+*/
+
+void TQWidget::setFocus()
+{
+ if ( !isEnabled() )
+ return;
+
+ if ( focusProxy() ) {
+ focusProxy()->setFocus();
+ return;
+ }
+
+ TQFocusData * f = focusData( TRUE );
+ if ( f->it.current() == this && tqApp->tqfocusWidget() == 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->tqfocusWidgets.append( this );
+ f->it.toLast();
+ }
+
+ if ( isActiveWindow() ) {
+ TQWidget * prev = tqApp->focus_widget;
+ if ( prev ) {
+ if ( prev != this )
+ prev->resetInputContext();
+ }
+#if defined(TQ_WS_WIN)
+ else {
+ TQInputContext::endComposition();
+ }
+#endif
+ tqApp->focus_widget = this;
+#if defined(TQ_WS_X11)
+ focusInputContext();
+#endif
+
+#if defined(TQ_WS_WIN)
+ if ( !tqtopLevelWidget()->isPopup() )
+ SetFocus( winId() );
+ else {
+#endif
+#if defined(TQT_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::tqfocusWidget()
+*/
+
+void TQWidget::clearFocus()
+{
+ if ( focusProxy() ) {
+ focusProxy()->clearFocus();
+ return;
+ } else if ( hasFocus() ) {
+ resetInputContext();
+ TQWidget* w = tqApp->tqfocusWidget();
+ // 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(TQT_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 tqfind 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 tqparent 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->tqfocusWidgets.last() : f->tqfocusWidgets.first();
+ extern bool qt_tab_all_widgets;
+ uint focus_flag = qt_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->tqfocusWidgets.prev() : f->tqfocusWidgets.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::tqfocusWidget(), which returns the focus
+ widget in the currently active window.
+*/
+
+TQWidget *TQWidget::tqfocusWidget() const
+{
+ TQWidget *that = (TQWidget *)this; // mutable
+ TQFocusData *f = that->focusData( FALSE );
+ if ( f && f->tqfocusWidgets.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 tqcontains all the widgets in this top-level widget that can
+ accept focus, in tab order. An iterator points to the current
+ focus widget (tqfocusWidget() 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 = tqtopLevelWidget();
+ 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 tqlayout recalculation
+ takes too long for the CPU.
+
+ If a widget supports multiple character tqunicode 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 tqcontains 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 = tqtopLevelWidget();
+ if(testWFlags(WSubWindow) && parentWidget())
+ tlw = parentWidget()->tqtopLevelWidget();
+ if(tlw == tqApp->activeWindow() || ( isVisible() && tlw->isPopup() ))
+ return TRUE;
+#ifndef TQT_NO_STYLE
+ if(style().tqstyleHint(TQStyle::SH_Widget_ShareActivation, 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()->tqtopLevelWidget() == tlw)
+ return TRUE;
+ while(w && (tlw->isDialog() || tlw->testWFlags(TQt::WStyle_Tool)) &&
+ !w->testWFlags(TQt::WShowModal) && w->parentWidget()) {
+ w = w->parentWidget()->tqtopLevelWidget();
+ if( w == tlw )
+ return TRUE;
+ }
+ }
+#endif
+#if defined(TQ_WS_WIN32)
+ HWND tqparent = tlw->winId();
+ HWND toptqparent = GetActiveWindow();
+ while ( tqparent ) {
+ tqparent = ::GetParent( tqparent );
+ if ( tqparent && tqparent == toptqparent )
+ 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())->tqtopLevelWidget() == first->tqtopLevelWidget()) {
+ 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->tqfocusWidgets.removeRef( second );
+ if ( f->tqfocusWidgets.tqfindRef( first ) >= 0 )
+ f->tqfocusWidgets.insert( f->tqfocusWidgets.at() + 1, second );
+ else
+ f->tqfocusWidgets.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 tqparent, 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 == tqtopLevelWidget() )
+ return; // nothing to do
+
+ TQFocusData * from = oldtlw ? oldtlw->topData()->focusData : 0;
+ TQFocusData * to;
+ to = focusData();
+
+ if ( from ) {
+ from->tqfocusWidgets.first();
+ do {
+ TQWidget * pw = from->tqfocusWidgets.current();
+ while( pw && pw != this )
+ pw = pw->parentWidget();
+ if ( pw == this ) {
+ TQWidget * w = from->tqfocusWidgets.take();
+ if ( w == from->it.current() )
+ // probably best to clear keyboard focus, or
+ // the user might become rather confused
+ w->clearFocus();
+ if ( !isTopLevel() )
+ to->tqfocusWidgets.append( w );
+ } else {
+ from->tqfocusWidgets.next();
+ }
+ } while( from->tqfocusWidgets.current() );
+ }
+
+ if ( to->tqfocusWidgets.tqfindRef(this) < 0 )
+ to->tqfocusWidgets.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 *tqparent, 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 tqchildren,
+ if they have some tqparent 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->childrenListObject();
+
+ 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 + tqgeometry().x() - TQWidget::x(),
+ y + tqgeometry().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( tqgeometry().x(), tqgeometry().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->tqfocusWidgets.tqfindRef( this ) < 0 )
+ f->tqfocusWidgets.append( this );
+ }
+ focus_policy = (uint) policy;
+}
+
+/*!
+ \property TQWidget::updatesEnabled
+ \brief whether updates are enabled
+
+ Calling update() and tqrepaint() 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 );
+ tqrepaint();
+ \endcode
+
+ \sa update(), tqrepaint(), 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 tqparent 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 TQ_OS_TEMP
+ if ( isTopLevel() && !testWState( WState_Resized ) ) {
+ // do this before sending the posted resize events. Otherwise
+ // the tqlayout would catch the resize event and may expand the
+ // minimum size.
+ TQSize s = qt_naturalWidgetSize( this );
+ if ( !s.isEmpty() )
+ resize( s );
+ }
+#endif // TQ_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) ) {
+ // qt_enter_modal *before* show, otherwise the initial
+ // stacking might be wrong
+ qt_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(TQT_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 tqparent because we haven't
+ // left modality. (Eg. modal Progress Dialog)
+ if ( testWFlags(WShowModal) )
+ qt_leave_modal( this );
+
+#if defined(TQ_WS_WIN)
+ if ( isTopLevel() && !isPopup() && parentWidget() && isActiveWindow() )
+ parentWidget()->setActiveWindow(); // Activate tqparent
+#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->tqfocusWidget() == this )
+ focusNextPrevChild( TRUE );
+ TQHideEvent hideEvent;
+ TQApplication::sendEvent( this, &hideEvent );
+ hideChildren( FALSE );
+
+#if defined(TQT_ACCESSIBILITY_SUPPORT)
+ TQAccessible::updateAccessibility( this, 0, TQAccessible::ObjectHide );
+#endif
+ } else {
+ TQEvent hideToParentEvent( TQEvent::HideToParent );
+ TQApplication::sendEvent( this, &hideToParentEvent );
+ }
+
+ // post tqlayout hint for non toplevels. The tqparent 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 ( childrenListObject() ) {
+ TQObjectListIt it(*childrenListObject());
+ register 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 ( childrenListObject() ) {
+ TQObjectListIt it(*childrenListObject());
+ register 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 *)tqparent();
+ pm = mw ? mw->icon() : 0;
+ if ( pm && !pm->isNull() )
+ setIcon( *pm );
+ else {
+ mw = mw ? mw->tqtopLevelWidget() : 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 tqsizeHint() 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::tqfind(id);
+ if ( !deleted && !e.isAccepted() ) {
+ is_closing = 0;
+ return FALSE;
+ }
+ if ( !deleted && !isHidden() )
+ hide();
+ if ( checkLastWindowClosed
+ && tqApp->tqreceivers(TQT_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->tqtopLevelWidgets();
+ 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 tqparent
+ 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 tqparent
+ 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 tqrepaint(). If you do not
+ need the rectangle for tqrepaint(), 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 tqrepaint() 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 tqsizeHint() if valid (i.e if the size hint's width and height
+ are \>= 0), otherwise sets the size to the tqchildren rectangle (the
+ union of all child widget geometries).
+
+ \sa tqsizeHint(), tqchildrenRect()
+*/
+
+void TQWidget::adjustSize()
+{
+ TQApplication::sendPostedEvents( 0, TQEvent::ChildInserted );
+ TQApplication::sendPostedEvents( 0, TQEvent::LayoutHint );
+ if ( !testWState(WState_Polished) )
+ polish();
+ TQSize s = tqsizeHint();
+
+ 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 ( tqlayout() ) {
+ if ( tqlayout()->hasHeightForWidth() ) {
+ s = s.boundedTo( screen.size() );
+ s.setHeight( tqlayout()->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 = tqchildrenRect(); // get tqchildren rectangle
+ if ( r.isNull() ) // probably no widgets
+ return;
+ resize( r.width() + 2 * r.x(), r.height() + 2 * r.y() );
+}
+
+
+/*!
+ \property TQWidget::tqsizeHint
+ \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 tqsizeHint() returns an invalid size
+ if there is no tqlayout for this widget, and returns the tqlayout's
+ preferred size otherwise.
+
+ \sa TQSize::isValid(), tqminimumSizeHint(), sizePolicy(),
+ setMinimumSize(), updateGeometry()
+*/
+
+TQSize TQWidget::tqsizeHint() const
+{
+#ifndef TQT_NO_LAYOUT
+ if ( tqlayout() )
+ return tqlayout()->totalSizeHint();
+#endif
+ return TQSize( -1, -1 );
+}
+
+/*!
+ \property TQWidget::tqminimumSizeHint
+ \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 tqminimumSizeHint() returns an invalid
+ size if there is no tqlayout for this widget, and returns the
+ tqlayout's minimum size otherwise. Most built-in widgets reimplement
+ tqminimumSizeHint().
+
+ \l TQLayout will never resize a widget to a size smaller than
+ tqminimumSizeHint.
+
+ \sa TQSize::isValid(), resize(), setMinimumSize(), sizePolicy()
+*/
+TQSize TQWidget::tqminimumSizeHint() const
+{
+#ifndef TQT_NO_LAYOUT
+ if ( tqlayout() )
+ return tqlayout()->totalMinimumSize();
+#endif
+ return TQSize( -1, -1 );
+}
+
+
+/*!
+ \fn TQWidget *TQWidget::parentWidget( bool sameWindow ) const
+
+ Returns the tqparent of this widget, or 0 if it does not have any
+ tqparent widget. If \a sameWindow is TRUE and the widget is top
+ level returns 0; otherwise returns the widget's tqparent.
+*/
+
+/*!
+ \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:
+ resetInputContext();
+ 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_TQWS) && !defined (TQT_NO_TQWS_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 ( childrenListObject() ) {
+ TQObjectListIt it( *childrenListObject() );
+ 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 ( childrenListObject() ) {
+ TQObjectListIt it( *childrenListObject() );
+ TQObject *o;
+ while( ( o = it.current() ) != 0 ) {
+ ++it;
+ TQApplication::sendEvent( o, e );
+ }
+ }
+ if ( e->type() == TQEvent::LanguageChange ) {
+ int index = tqmetaObject()->tqfindSlot( "languageChange()", TRUE );
+ if ( index >= 0 )
+ qt_invoke( index, 0 );
+ }
+ update();
+ break;
+#ifndef TQT_NO_LAYOUT
+ case TQEvent::LayoutDirectionChange:
+ if ( tqlayout() ) {
+ tqlayout()->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 ( childrenListObject() ) {
+ TQObjectListIt it( *childrenListObject() );
+ TQObject *o;
+ while( ( o = it.current() ) != 0 ) {
+ ++it;
+ TQWidget *w = ::tqqt_cast<TQWidget*>(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().tqcontains(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 tqparent 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 tqparent 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 tqparent 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 tqparent 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 <b>Esc</b>. 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 tqparent 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 )
+ return TQRect(width()/2, 0, 1, height() );
+ else if ( 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 tqrepaint all or part of the widget.
+ It can happen as a result of tqrepaint() or update(), or because the
+ widget was obscured and has now been uncovered, or for many other
+ reasons.
+
+ Many widgets can simply tqrepaint 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()).
+ tqrepaint() 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(), tqrepaint(), 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 tqgeometry. 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_TQWS)
+
+/*!
+ 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 tqmask feature is enabled for the widget
+
+ Transtqparent widgets use a tqmask to define their visible region.
+ TQWidget has some built-in support to make the task of
+ recalculating the tqmask easier. When setting auto tqmask 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 tqmask 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 tqmask.
+
+ 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 transtqparent label. The
+ complex tqshape of its contents makes it necessary to represent its
+ tqmask 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 tqmask.
+
+ \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 tqparent's coordinate system.
+ \value WindowOrigin top-level window's coordinate system.
+ \value AncestorOrigin same origin as the tqparent 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
+ transtqparent widgets. It should be called whenever a widget changes
+ state in a way that means that the tqshape tqmask 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::tqlayout () const
+
+ Returns the tqlayout engine that manages the tqgeometry of this
+ widget's tqchildren.
+
+ If the widget does not have a tqlayout, tqlayout() returns 0.
+
+ \sa sizePolicy()
+*/
+
+
+/* Sets this widget to use tqlayout \a l to manage the tqgeometry of its
+ tqchildren.
+
+ If the widget already had a tqlayout, the old tqlayout is
+ forgotten. (Note that it is not deleted.)
+
+ \sa tqlayout() TQLayout sizePolicy()
+*/
+#ifndef TQT_NO_LAYOUT
+void TQWidget::setLayout( TQLayout *l )
+{
+ lay_out = l;
+}
+#endif
+
+/*!
+ \property TQWidget::sizePolicy
+ \brief the default tqlayout behavior of the widget
+
+ If there is a TQLayout that manages this widget's tqchildren, the
+ size policy specified by that tqlayout 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
+ tqsizeHint() 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
+ tqsizeHint().
+
+ \sa tqsizeHint() TQLayout TQSizePolicy updateGeometry()
+*/
+TQSizePolicy TQWidget::sizePolicy() const
+{
+ return extra ? extra->size_policy
+ : TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred );
+}
+
+void TQWidget::tqsetSizePolicy( TQSizePolicy policy )
+{
+ setWState( WState_OwnSizePolicy );
+ if ( policy == sizePolicy() )
+ return;
+ createExtra();
+ extra->size_policy = policy;
+ updateGeometry();
+}
+
+/*!
+ \overload void TQWidget::tqsetSizePolicy( 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 tqlayout.
+*/
+
+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::tqchildAt( int x, int y, bool includeThis ) const
+{
+ if ( !rect().tqcontains( x, y ) )
+ return 0;
+ if ( childrenListObject() ) {
+ TQObjectListIt it( *childrenListObject() );
+ it.toLast();
+ TQWidget *w, *t;
+ while( (w=(TQWidget *)it.current()) != 0 ) {
+ --it;
+ if ( w->isWidgetType() && !w->isTopLevel() && !w->isHidden() ) {
+ if ( ( t = w->tqchildAt( 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::tqchildAt( const TQPoint & p, bool includeThis ) const
+{
+ return tqchildAt( p.x(), p.y(), includeThis );
+}
+
+
+/*!
+ Notifies the tqlayout system that this widget has changed and may
+ need to change tqgeometry.
+
+ Call this function if the tqsizeHint() or sizePolicy() have changed.
+
+ For explicitly hidden widgets, updateGeometry() is a no-op. The
+ tqlayout system will be notified as soon as the widget is shown.
+*/
+
+void TQWidget::updateGeometry()
+{
+ if ( !isTopLevel() && isShown() )
+ TQApplication::postEvent( parentWidget(),
+ new TQEvent( TQEvent::LayoutHint ) );
+}
+
+
+/*!
+ Reparents the widget. The widget gets a new \a tqparent, new widget
+ flags (\a f, but as usual, use 0) at a new position in its new
+ tqparent (\a p).
+
+ If \a showIt is TRUE, show() is called once the widget has been
+ reparented.
+
+ If the new tqparent widget is in a different top-level widget, the
+ reparented widget and its tqchildren are appended to the end of the
+ \link setFocusPolicy() tab chain \endlink of the new tqparent
+ 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 tqparent widget is in the same top-level widget as the
+ old tqparent, 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 *tqparent, WFlags f, const TQPoint &p,
+ bool showIt )
+{
+ reparentSys( tqparent, f, p, showIt );
+ TQEvent e( TQEvent::Retqparent );
+ 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 tqparent, getWFlags() \& ~\l WType_Mask, \a p, \a
+ showIt).
+*/
+void TQWidget::reparent( TQWidget *tqparent, const TQPoint & p,
+ bool showIt )
+{
+ reparent( tqparent, getWFlags() & ~WType_Mask, p, showIt );
+}
+
+/*!
+ \property TQWidget::ownCursor
+ \brief whether the widget uses its own cursor
+
+ If FALSE, the widget uses its tqparent widget's cursor.
+
+ \sa cursor
+*/
+
+/*!
+ \property TQWidget::ownFont
+ \brief whether the widget uses its own font
+
+ If FALSE, the widget uses its tqparent widget's font.
+
+ \sa font
+*/
+
+/*!
+ \property TQWidget::ownPalette
+ \brief whether the widget uses its own palette
+
+ If FALSE, the widget uses its tqparent widget's palette.
+
+ \sa palette
+*/
+
+
+void TQWidget::tqrepaint( bool erase )
+{
+ tqrepaint( 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 transtqparent).
+
+ 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 transtqparent 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-transtqparent windows update and resize significantely slower than
+ opaque windows.
+*/
+
+#endif // USE_QT4