Q3DockWindowHandle Class Reference

Inheritance diagram for Q3DockWindowHandle:

Inheritance graph
[legend]
Collaboration diagram for Q3DockWindowHandle:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 306 of file q3dockwindow.cpp.

Signals

void doubleClicked ()

Public Member Functions

 Q3DockWindowHandle (Q3DockWindow *dw)
void updateGui ()
QSize minimumSizeHint () const
QSize minimumSize () const
QSize sizeHint () const
void setOpaqueMoving (bool b)
QString windowTitle () const

Protected Member Functions

void paintEvent (QPaintEvent *e)
void resizeEvent (QResizeEvent *e)
void mousePressEvent (QMouseEvent *e)
void mouseMoveEvent (QMouseEvent *e)
void mouseReleaseEvent (QMouseEvent *e)
void mouseDoubleClickEvent (QMouseEvent *e)
void keyPressEvent (QKeyEvent *e)
void keyReleaseEvent (QKeyEvent *e)
void changeEvent (QEvent *)

Private Slots

void minimize ()

Private Attributes

Q3DockWindowdockWindow
QPoint offset
QToolButtoncloseButton
QTimertimer
uint opaque: 1
uint mousePressed: 1
uint hadDblClick: 1
uint ctrlDown: 1
QPointer< QWidgetoldFocus

Friends

class Q3DockWindow
class Q3DockWindowTitleBar


Constructor & Destructor Documentation

Q3DockWindowHandle::Q3DockWindowHandle ( Q3DockWindow dw  ) 

Definition at line 384 of file q3dockwindow.cpp.

References QObject::connect(), ctrlDown, minimize(), QWidget::setCursor(), SIGNAL, Qt::SizeAllCursor, SLOT, and timer.

00385     : QWidget(dw, "qt_dockwidget_internal"), dockWindow(dw),
00386       closeButton(0), opaque(default_opaque), mousePressed(false)
00387 {
00388     ctrlDown = false;
00389     timer = new QTimer(this);
00390     connect(timer, SIGNAL(timeout()), this, SLOT(minimize()));
00391 #ifdef Q_WS_WIN
00392     setCursor(Qt::SizeAllCursor);
00393 #endif
00394 }

Here is the call graph for this function:


Member Function Documentation

void Q3DockWindowHandle::updateGui (  ) 

Definition at line 503 of file q3dockwindow.cpp.

References Q3DockWindow::area(), Qt::ArrowCursor, closeButton, QObject::connect(), dockWindow, QWidget::height(), QWidget::hide(), Qt::Horizontal, QStyleOption::init(), Q3DockWindow::isCloseEnabled(), QWidget::move(), Q3DockArea::orientation(), QWidget::setCursor(), QWidget::setFixedSize(), QAbstractButton::setIcon(), QWidget::show(), SIGNAL, SLOT, QStyle::SP_DockWidgetCloseButton, QWidget::style(), QWidget::width(), and QWidget::x().

Referenced by resizeEvent(), Q3DockWindow::setCloseMode(), and Q3DockWindow::updateGui().

00504 {
00505     if (!closeButton) {
00506         closeButton = new QToolButton(this, "qt_close_button1");
00507 #ifndef QT_NO_CURSOR
00508         closeButton->setCursor(Qt::ArrowCursor);
00509 #endif
00510         QStyleOption opt(0);
00511         opt.init(closeButton);
00512         closeButton->setIcon(style()->standardPixmap(QStyle::SP_DockWidgetCloseButton, &opt,
00513                                                     closeButton));
00514         closeButton->setFixedSize(12, 12);
00515         connect(closeButton, SIGNAL(clicked()),
00516                  dockWindow, SLOT(hide()));
00517     }
00518 
00519     if (dockWindow->isCloseEnabled() && dockWindow->area())
00520         closeButton->show();
00521     else
00522         closeButton->hide();
00523 
00524     if (!dockWindow->area())
00525         return;
00526 
00527     if (dockWindow->area()->orientation() == Qt::Horizontal) {
00528         int off = (width() - closeButton->width() - 1) / 2;
00529         closeButton->move(off, 2);
00530     } else {
00531         int off = (height() - closeButton->height() - 1) / 2;
00532         int x = QApplication::reverseLayout() ? 2 : width() - closeButton->width() - 2;
00533         closeButton->move(x, off);
00534     }
00535 }

Here is the call graph for this function:

QSize Q3DockWindowHandle::minimumSizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 550 of file q3dockwindow.cpp.

References Q3DockWindow::dockArea, dockWindow, Qt::Horizontal, Q3DockWindow::isCloseEnabled(), Q3DockWindow::orientation(), QStyle::pixelMetric(), QStyle::PM_ToolBarHandleExtent, and QWidget::style().

Referenced by minimumSize().

00551 {
00552     if (!dockWindow->dockArea)
00553         return QSize(0, 0);
00554     int wh = dockWindow->isCloseEnabled() ? 17 : style()->pixelMetric(QStyle::PM_ToolBarHandleExtent, 0, this);
00555     if (dockWindow->orientation() == Qt::Horizontal)
00556         return QSize(wh, 0);
00557     return QSize(0, wh);
00558 }

Here is the call graph for this function:

QSize Q3DockWindowHandle::minimumSize (  )  const [inline]

Reimplemented from QWidget.

Definition at line 318 of file q3dockwindow.cpp.

References minimumSizeHint().

Referenced by sizeHint().

00318 { return minimumSizeHint(); }

Here is the call graph for this function:

QSize Q3DockWindowHandle::sizeHint (  )  const [inline, virtual]

Reimplemented from QWidget.

Definition at line 319 of file q3dockwindow.cpp.

References minimumSize().

00319 { return minimumSize(); }

Here is the call graph for this function:

void Q3DockWindowHandle::setOpaqueMoving ( bool  b  )  [inline]

Definition at line 320 of file q3dockwindow.cpp.

References opaque.

Referenced by Q3DockWindow::setOpaqueMoving().

00320 { opaque = b; }

QString Q3DockWindowHandle::windowTitle (  )  const [inline]

Reimplemented from QWidget.

Definition at line 322 of file q3dockwindow.cpp.

References dockWindow, and Q3DockWindow::windowTitle().

00322 { return dockWindow->windowTitle(); }

Here is the call graph for this function:

void Q3DockWindowHandle::doubleClicked (  )  [signal]

Referenced by mouseDoubleClickEvent().

void Q3DockWindowHandle::paintEvent ( QPaintEvent e  )  [protected, virtual]

This event handler can be reimplemented in a subclass to receive paint events which are passed in the event parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt 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, Qt merges these events into one event with a larger region (see QRegion::united()). repaint() does not permit this optimization, so we suggest using update() whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole() and setPalette().

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent() to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

See also:
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent, {Analog Clock Example}

Reimplemented from QWidget.

Definition at line 396 of file q3dockwindow.cpp.

References Q3DockWindow::area(), QStyleOptionQ3DockWindow::closeEnabled, QStyleOption::direction, Q3DockWindow::dockArea, QStyleOptionQ3DockWindow::docked, dockWindow, QStyle::drawPrimitive(), Qt::Horizontal, QStyleOption::init(), Q3DockWindow::isCloseEnabled(), opaque, Q3DockArea::orientation(), p, QWidget::paintEvent(), QStyle::PE_IndicatorToolBarHandle, QStyleOption::rect, QWidget::rect(), QStyle::SE_Q3DockWindowHandleRect, QStyleOption::state, QStyle::State_Horizontal, QWidget::style(), and QStyle::visualRect().

00397 {
00398     if (!dockWindow->dockArea && !opaque)
00399         return;
00400     QPainter p(this);
00401     QStyleOptionQ3DockWindow opt;
00402     opt.init(this);
00403     if (!dockWindow->area() || dockWindow->area()->orientation() == Qt::Horizontal)
00404         opt.state |= QStyle::State_Horizontal;
00405 
00406     opt.rect = rect();
00407     opt.docked = dockWindow->area();
00408     opt.closeEnabled = dockWindow->isCloseEnabled();
00409     opt.rect = QStyle::visualRect(opt.direction, opt.rect,
00410                                   style()->subElementRect(QStyle::SE_Q3DockWindowHandleRect, &opt, this));
00411     style()->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);
00412     QWidget::paintEvent(e);
00413 }

Here is the call graph for this function:

void Q3DockWindowHandle::resizeEvent ( QResizeEvent e  )  [protected, virtual]

This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::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.

See also:
moveEvent(), event(), resize(), QResizeEvent, paintEvent(), {Scribble Example}

Reimplemented from QWidget.

Definition at line 498 of file q3dockwindow.cpp.

References updateGui().

00499 {
00500     updateGui();
00501 }

Here is the call graph for this function:

void Q3DockWindowHandle::mousePressEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, 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.

See also:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 435 of file q3dockwindow.cpp.

References QEvent::accept(), QMouseEvent::button(), ctrlDown, Q3DockWindow::dockArea, dockWindow, hadDblClick, QEvent::ignore(), Qt::LeftButton, QWidget::mapToGlobal(), mousePressed, offset, oldFocus, opaque, QMouseEvent::pos(), qApp, QWidget::setFocus(), and Q3DockWindow::startRectDraw().

00436 {
00437     if (!dockWindow->dockArea)
00438         return;
00439     ctrlDown = (e->state() & Qt::ControlButton) == Qt::ControlButton;
00440     oldFocus = qApp->focusWidget();
00441     setFocus();
00442     e->ignore();
00443     if (e->button() != Qt::LeftButton)
00444         return;
00445     e->accept();
00446     hadDblClick = false;
00447     mousePressed = true;
00448     offset = e->pos();
00449     dockWindow->startRectDraw(mapToGlobal(e->pos()), !opaque);
00450     if (!opaque)
00451         qApp->installEventFilter(dockWindow);
00452 }

Here is the call graph for this function:

void Q3DockWindowHandle::mouseMoveEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, 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.

QMouseEvent::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 Qt.

See also:
setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 454 of file q3dockwindow.cpp.

References ctrlDown, dockWindow, QMouseEvent::globalPos(), Q3DockWindow::handleMove(), mousePressed, offset, opaque, QMouseEvent::pos(), and Q3DockWindow::updatePosition().

00455 {
00456     if (!mousePressed || e->pos() == offset)
00457         return;
00458     ctrlDown = (e->state() & Qt::ControlButton) == Qt::ControlButton;
00459     dockWindow->handleMove(e->pos() - offset, e->globalPos(), !opaque);
00460     if (opaque)
00461         dockWindow->updatePosition(e->globalPos());
00462 }

Here is the call graph for this function:

void Q3DockWindowHandle::mouseReleaseEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget.

See also:
mousePressEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}

Reimplemented from QWidget.

Definition at line 464 of file q3dockwindow.cpp.

References ctrlDown, dockWindow, QApplication::doubleClickInterval(), Q3DockWindow::endRectDraw(), QMouseEvent::globalPos(), hadDblClick, Q3DockWindowTitleBar::mousePressed, mousePressed, offset, oldFocus, opaque, QWidget::parentWidget(), QMouseEvent::pos(), QCoreApplication::postEvent(), qApp, QWidget::releaseMouse(), QTimer::start(), timer, Q3DockWindow::titleBar, and Q3DockWindow::updatePosition().

00465 {
00466     ctrlDown = false;
00467     qApp->removeEventFilter(dockWindow);
00468     if (oldFocus)
00469         oldFocus->setFocus();
00470     if (!mousePressed)
00471         return;
00472     dockWindow->endRectDraw(!opaque);
00473     mousePressed = false;
00474 #ifdef Q_WS_MAC
00475     releaseMouse();
00476 #endif
00477     if (!hadDblClick && offset == e->pos()) {
00478         timer->start(QApplication::doubleClickInterval(), true);
00479     } else if (!hadDblClick) {
00480         dockWindow->updatePosition(e->globalPos());
00481     }
00482     if (opaque)
00483         dockWindow->titleBar->mousePressed = false;
00484     if (dockWindow->parentWidget())
00485         QApplication::postEvent(dockWindow->parentWidget(), new QEvent(QEvent::LayoutHint));
00486 }

Here is the call graph for this function:

void Q3DockWindowHandle::mouseDoubleClickEvent ( QMouseEvent e  )  [protected, virtual]

This event handler, for event event, 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().

See also:
mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), event(), QMouseEvent

Reimplemented from QWidget.

Definition at line 560 of file q3dockwindow.cpp.

References QEvent::accept(), QMouseEvent::button(), dockWindow, doubleClicked(), emit, hadDblClick, QEvent::ignore(), Qt::LeftButton, QWidget::parentWidget(), QCoreApplication::postEvent(), QTimer::stop(), and timer.

00561 {
00562     e->ignore();
00563     if (e->button() != Qt::LeftButton)
00564         return;
00565     e->accept();
00566     timer->stop();
00567     emit doubleClicked();
00568     hadDblClick = true;
00569     if (dockWindow->parentWidget())
00570         QApplication::postEvent(dockWindow->parentWidget(), new QEvent(QEvent::LayoutHint));
00571 }

Here is the call graph for this function:

void Q3DockWindowHandle::keyPressEvent ( QKeyEvent e  )  [protected, virtual]

This event handler, for event event, 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 ignore() the event if you do not understand it, so that the widget's parent can interpret it.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

See also:
keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example}

Reimplemented from QWidget.

Definition at line 415 of file q3dockwindow.cpp.

References ctrlDown, dockWindow, Q3DockWindow::handleMove(), QKeyEvent::key(), Qt::Key_Control, QWidget::mapFromGlobal(), mousePressed, offset, opaque, and QCursor::pos().

00416 {
00417     if (!mousePressed)
00418         return;
00419     if (e->key() == Qt::Key_Control) {
00420         ctrlDown = true;
00421         dockWindow->handleMove(mapFromGlobal(QCursor::pos()) - offset, QCursor::pos(), !opaque);
00422     }
00423 }

Here is the call graph for this function:

void Q3DockWindowHandle::keyReleaseEvent ( QKeyEvent e  )  [protected, virtual]

This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget.

A widget must accept focus initially and have focus in order to receive a key release event.

If you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it.

The default implementation ignores the event.

See also:
keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent

Reimplemented from QWidget.

Definition at line 425 of file q3dockwindow.cpp.

References ctrlDown, dockWindow, Q3DockWindow::handleMove(), QKeyEvent::key(), Qt::Key_Control, QWidget::mapFromGlobal(), mousePressed, offset, opaque, and QCursor::pos().

00426 {
00427     if (!mousePressed)
00428         return;
00429     if (e->key() == Qt::Key_Control) {
00430         ctrlDown = false;
00431         dockWindow->handleMove(mapFromGlobal(QCursor::pos()) - offset, QCursor::pos(), !opaque);
00432     }
00433 }

Here is the call graph for this function:

void Q3DockWindowHandle::changeEvent ( QEvent ev  )  [protected, virtual]

This event handler can be reimplemented to handle state changes.

The state being changed in this event can be retrieved through event event.

Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEcvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.

Reimplemented from QWidget.

Definition at line 537 of file q3dockwindow.cpp.

References QWidget::changeEvent(), closeButton, QStyleOption::init(), QStyle::SP_DockWidgetCloseButton, QWidget::style(), QEvent::StyleChange, and QEvent::type().

00538 {
00539     if(ev->type() == QEvent::StyleChange) {
00540         if (closeButton) {
00541             QStyleOption opt(0);
00542             opt.init(closeButton);
00543             closeButton->setIcon(style()->standardPixmap(QStyle::SP_DockWidgetCloseButton,
00544                                                         &opt, closeButton));
00545         }
00546     }
00547     QWidget::changeEvent(ev);
00548 }

Here is the call graph for this function:

void Q3DockWindowHandle::minimize (  )  [private, slot]

Definition at line 488 of file q3dockwindow.cpp.

References Q3DockWindow::area(), dockWindow, Q3MainWindow::isDockEnabled(), Q3MainWindow::moveDockWindow(), and QWidget::parentWidget().

Referenced by Q3DockWindowHandle().

00489 {
00490     if (!dockWindow->area())
00491         return;
00492 
00493     Q3MainWindow *mw = qobject_cast<Q3MainWindow*>(dockWindow->area()->parentWidget());
00494     if (mw && mw->isDockEnabled(dockWindow, Qt::DockMinimized))
00495         mw->moveDockWindow(dockWindow, Qt::DockMinimized);
00496 }


Friends And Related Function Documentation

friend class Q3DockWindow [friend]

Definition at line 310 of file q3dockwindow.cpp.

friend class Q3DockWindowTitleBar [friend]

Definition at line 311 of file q3dockwindow.cpp.


Member Data Documentation

Q3DockWindow* Q3DockWindowHandle::dockWindow [private]

Definition at line 342 of file q3dockwindow.cpp.

Referenced by keyPressEvent(), keyReleaseEvent(), minimize(), minimumSizeHint(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), updateGui(), and windowTitle().

QPoint Q3DockWindowHandle::offset [private]

Definition at line 343 of file q3dockwindow.cpp.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

QToolButton* Q3DockWindowHandle::closeButton [private]

Definition at line 344 of file q3dockwindow.cpp.

Referenced by changeEvent(), and updateGui().

QTimer* Q3DockWindowHandle::timer [private]

Definition at line 345 of file q3dockwindow.cpp.

Referenced by mouseDoubleClickEvent(), mouseReleaseEvent(), and Q3DockWindowHandle().

uint Q3DockWindowHandle::opaque [private]

Definition at line 346 of file q3dockwindow.cpp.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), and setOpaqueMoving().

uint Q3DockWindowHandle::mousePressed [private]

Definition at line 347 of file q3dockwindow.cpp.

Referenced by Q3DockWindow::eventFilter(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), Q3DockWindowTitleBar::mouseReleaseEvent(), mouseReleaseEvent(), and Q3DockWindow::updateGui().

uint Q3DockWindowHandle::hadDblClick [private]

Definition at line 348 of file q3dockwindow.cpp.

Referenced by mouseDoubleClickEvent(), mousePressEvent(), and mouseReleaseEvent().

uint Q3DockWindowHandle::ctrlDown [private]

Definition at line 349 of file q3dockwindow.cpp.

Referenced by Q3DockWindow::handleMove(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and Q3DockWindowHandle().

QPointer<QWidget> Q3DockWindowHandle::oldFocus [private]

Definition at line 350 of file q3dockwindow.cpp.

Referenced by mousePressEvent(), and mouseReleaseEvent().


The documentation for this class was generated from the following file:
Generated on Thu Mar 15 15:53:39 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1