Q3DockWindowResizeHandle Class Reference

Inheritance diagram for Q3DockWindowResizeHandle:

Inheritance graph
[legend]
Collaboration diagram for Q3DockWindowResizeHandle:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 56 of file q3dockwindow.cpp.

Public Member Functions

 Q3DockWindowResizeHandle (Qt::Orientation o, QWidget *parent, Q3DockWindow *w, const char *=0)
void setOrientation (Qt::Orientation o)
Qt::Orientation orientation () const
QSize sizeHint () const

Protected Member Functions

void paintEvent (QPaintEvent *)
void mouseMoveEvent (QMouseEvent *)
void mousePressEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
bool event (QEvent *event)

Private Member Functions

void startLineDraw ()
void endLineDraw ()
void drawLine (const QPoint &globalPos)

Private Attributes

Qt::Orientation orient
bool mousePressed
QRubberBandrubberBand
QPoint lastPos
QPoint firstPos
Q3DockWindowdockWindow
bool mouseOver


Constructor & Destructor Documentation

Q3DockWindowResizeHandle::Q3DockWindowResizeHandle ( Qt::Orientation  o,
QWidget parent,
Q3DockWindow w,
const char *  = 0 
)

Definition at line 88 of file q3dockwindow.cpp.

References setOrientation().

00090     : QWidget(parent, "qt_dockwidget_internal"), mousePressed(false), rubberBand(0), dockWindow(w),
00091       mouseOver(false)
00092 {
00093     setOrientation(o);
00094 }

Here is the call graph for this function:


Member Function Documentation

void Q3DockWindowResizeHandle::setOrientation ( Qt::Orientation  o  ) 

Definition at line 110 of file q3dockwindow.cpp.

References QSizePolicy::Expanding, QSizePolicy::Fixed, Qt::Horizontal, orient, QWidget::setCursor(), and QWidget::setSizePolicy().

Referenced by Q3DockWindowResizeHandle().

00111 {
00112     orient = o;
00113     if (o == Qt::Horizontal) {
00114 #ifndef QT_NO_CURSOR
00115         setCursor(Qt::splitVCursor);
00116 #endif
00117         setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
00118     } else {
00119 #ifndef QT_NO_CURSOR
00120         setCursor(Qt::splitHCursor);
00121 #endif
00122         setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
00123     }
00124 }

Here is the call graph for this function:

Qt::Orientation Q3DockWindowResizeHandle::orientation (  )  const [inline]

Definition at line 63 of file q3dockwindow.cpp.

References orient.

Referenced by drawLine(), mouseMoveEvent(), mouseReleaseEvent(), and paintEvent().

00063 { return orient; }

QSize Q3DockWindowResizeHandle::sizeHint (  )  const [virtual]

Reimplemented from QWidget.

Definition at line 96 of file q3dockwindow.cpp.

References Q3DockWindow::area(), QStyleOptionQ3DockWindow::closeEnabled, QStyle::CT_Q3DockWindow, QStyleOptionQ3DockWindow::docked, dockWindow, QApplication::globalStrut(), Qt::Horizontal, QStyleOption::init(), Q3DockWindow::isCloseEnabled(), Q3DockArea::orientation(), QStyle::pixelMetric(), QStyle::PM_SplitterWidth, QStyleOption::rect, QWidget::rect(), QStyleOption::state, QStyle::State_Horizontal, and QWidget::style().

00097 {
00098     QStyleOptionQ3DockWindow opt;
00099     opt.init(this);
00100     if (!dockWindow->area() || dockWindow->area()->orientation() == Qt::Horizontal)
00101         opt.state |= QStyle::State_Horizontal;
00102 
00103     opt.rect = rect();
00104     opt.docked = dockWindow->area();
00105     opt.closeEnabled = dockWindow->isCloseEnabled();
00106     int sw = 2 * style()->pixelMetric(QStyle::PM_SplitterWidth, &opt, this) / 3;
00107     return (style()->sizeFromContents(QStyle::CT_Q3DockWindow, &opt, QSize(sw, sw), this).expandedTo(QApplication::globalStrut()));
00108 }

Here is the call graph for this function:

void Q3DockWindowResizeHandle::paintEvent ( QPaintEvent  )  [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 256 of file q3dockwindow.cpp.

References QStyle::drawPrimitive(), Qt::Horizontal, QStyleOption::init(), orientation(), p, QStyle::PE_IndicatorDockWidgetResizeHandle, QStyleOption::state, QStyle::State_Horizontal, and QWidget::style().

00257 {
00258     QPainter p(this);
00259     QStyleOption opt(0);
00260     opt.init(this);
00261     if (orientation() == Qt::Horizontal)
00262         opt.state |= QStyle::State_Horizontal;
00263     style()->drawPrimitive(QStyle::PE_IndicatorDockWidgetResizeHandle, &opt, &p, this);
00264 }

Here is the call graph for this function:

void Q3DockWindowResizeHandle::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 140 of file q3dockwindow.cpp.

References Q3DockWindow::area(), dockWindow, drawLine(), firstPos, QMouseEvent::globalPos(), QWidget::height(), Qt::Horizontal, lastPos, QWidget::mapToGlobal(), mousePressed, mouseReleaseEvent(), Q3DockWindow::opaqueMoving(), orientation(), Q3DockArea::orientation(), w, QWidget::width(), QWidget::window(), QPoint::x(), and QPoint::y().

00141 {
00142     if (!mousePressed)
00143         return;
00144     if (!dockWindow->opaqueMoving()) {
00145         if (orientation() != dockWindow->area()->orientation()) {
00146             if (orientation() == Qt::Horizontal) {
00147                 int minpos = dockWindow->area()->mapToGlobal(QPoint(0, 0)).y();
00148                 int maxpos = dockWindow->area()->mapToGlobal(QPoint(0, 0)).y() + dockWindow->area()->height();
00149                 if (e->globalPos().y() < minpos || e->globalPos().y() > maxpos)
00150                     return;
00151             } else {
00152                 int minpos = dockWindow->area()->mapToGlobal(QPoint(0, 0)).x();
00153                 int maxpos = dockWindow->area()->mapToGlobal(QPoint(0, 0)).x() + dockWindow->area()->width();
00154                 if (e->globalPos().x() < minpos || e->globalPos().x() > maxpos)
00155                     return;
00156             }
00157         } else {
00158             QWidget *w = dockWindow->area()->window();
00159             if (w) {
00160                 if (orientation() == Qt::Horizontal) {
00161                     int minpos = w->mapToGlobal(QPoint(0, 0)).y();
00162                     int maxpos = w->mapToGlobal(QPoint(0, 0)).y() + w->height();
00163                     if (e->globalPos().y() < minpos || e->globalPos().y() > maxpos)
00164                         return;
00165                 } else {
00166                     int minpos = w->mapToGlobal(QPoint(0, 0)).x();
00167                     int maxpos = w->mapToGlobal(QPoint(0, 0)).x() + w->width();
00168                     if (e->globalPos().x() < minpos || e->globalPos().x() > maxpos)
00169                         return;
00170                 }
00171             }
00172         }
00173     }
00174 
00175     if (!dockWindow->opaqueMoving())
00176         drawLine(lastPos);
00177     lastPos = e->globalPos();
00178     if (dockWindow->opaqueMoving()) {
00179         mouseReleaseEvent(e);
00180         mousePressed = true;
00181         firstPos = e->globalPos();
00182     }
00183     if (!dockWindow->opaqueMoving())
00184         drawLine(e->globalPos());
00185 }

Here is the call graph for this function:

void Q3DockWindowResizeHandle::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 126 of file q3dockwindow.cpp.

References QEvent::accept(), QMouseEvent::button(), dockWindow, drawLine(), firstPos, QMouseEvent::globalPos(), QEvent::ignore(), lastPos, Qt::LeftButton, mousePressed, Q3DockWindow::opaqueMoving(), and startLineDraw().

00127 {
00128     e->ignore();
00129     if (e->button() != Qt::LeftButton)
00130         return;
00131     e->accept();
00132     mousePressed = true;
00133     if (!dockWindow->opaqueMoving())
00134         startLineDraw();
00135     lastPos = firstPos = e->globalPos();
00136     if (!dockWindow->opaqueMoving())
00137         drawLine(e->globalPos());
00138 }

Here is the call graph for this function:

void Q3DockWindowResizeHandle::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 187 of file q3dockwindow.cpp.

References Q3DockWindow::area(), d, dockWindow, drawLine(), endLineDraw(), firstPos, QMouseEvent::globalPos(), Q3DockArea::handlePosition(), QWidget::height(), Qt::Horizontal, Q3DockArea::invalidNextOffset(), lastPos, Q3DockArea::maxSpace(), QWidget::minimumHeight(), QWidget::minimumWidth(), mousePressed, Q3DockArea::Normal, Q3DockWindow::opaqueMoving(), orientation(), Q3DockArea::orientation(), QCoreApplication::postEvent(), qMax(), qMin(), Q3DockArea::setFixedExtent(), Q3DockWindow::setFixedExtentHeight(), Q3DockWindow::setFixedExtentWidth(), QWidget::width(), QPoint::x(), and QPoint::y().

Referenced by mouseMoveEvent().

00188 {
00189     if (mousePressed) {
00190         if (!dockWindow->opaqueMoving()) {
00191             drawLine(lastPos);
00192             endLineDraw();
00193         }
00194         if (orientation() != dockWindow->area()->orientation())
00195             dockWindow->area()->invalidNextOffset(dockWindow);
00196         if (orientation() == Qt::Horizontal) {
00197             int dy;
00198             if (dockWindow->area()->handlePosition() == Q3DockArea::Normal || orientation() != dockWindow->area()->orientation())
00199                 dy = e->globalPos().y() - firstPos.y();
00200             else
00201                 dy =  firstPos.y() - e->globalPos().y();
00202             int d = dockWindow->height() + dy;
00203             if (orientation() != dockWindow->area()->orientation()) {
00204                 dockWindow->setFixedExtentHeight(-1);
00205                 d = qMax(d, dockWindow->minimumHeight());
00206                 int ms = dockWindow->area()->maxSpace(d, dockWindow);
00207                 d = qMin(d, ms);
00208                 dockWindow->setFixedExtentHeight(d);
00209             } else {
00210                 dockWindow->area()->setFixedExtent(d, dockWindow);
00211             }
00212         } else {
00213             int dx;
00214             if (dockWindow->area()->handlePosition() == Q3DockArea::Normal || orientation() != dockWindow->area()->orientation())
00215                 dx = e->globalPos().x() - firstPos.x();
00216             else
00217                 dx = firstPos.x() - e->globalPos().x();
00218             int d = dockWindow->width() + dx;
00219             if (orientation() != dockWindow->area()->orientation()) {
00220                 dockWindow->setFixedExtentWidth(-1);
00221                 d = qMax(d, dockWindow->minimumWidth());
00222                 int ms = dockWindow->area()->maxSpace(d, dockWindow);
00223                 d = qMin(d, ms);
00224                 dockWindow->setFixedExtentWidth(d);
00225             } else {
00226                 dockWindow->area()->setFixedExtent(d, dockWindow);
00227             }
00228         }
00229     }
00230 
00231     QApplication::postEvent(dockWindow->area(), new QEvent(QEvent::LayoutHint));
00232     mousePressed = false;
00233 }

Here is the call graph for this function:

bool Q3DockWindowResizeHandle::event ( QEvent event  )  [protected, virtual]

This is the main event handler; it handles event event. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

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().

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event() will call the specialized handlers such as mousePressEvent(); otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

See also:
closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event(), QObject::timerEvent()

Reimplemented from QWidget.

Definition at line 235 of file q3dockwindow.cpp.

References QWidget::event(), QEvent::HoverEnter, QEvent::HoverLeave, mouseOver, and QWidget::update().

00236 {
00237     switch (event->type()) {
00238     case QEvent::HoverEnter:
00239         if (!mouseOver) {
00240             mouseOver = true;
00241             update();
00242         }
00243         break;
00244     case QEvent::HoverLeave:
00245         if (mouseOver) {
00246             mouseOver = false;
00247             update();
00248         }
00249         break;
00250     default:
00251         break;
00252     }
00253     return QWidget::event(event);
00254 }

Here is the call graph for this function:

void Q3DockWindowResizeHandle::startLineDraw (  )  [private]

Definition at line 266 of file q3dockwindow.cpp.

References endLineDraw(), QRubberBand::Line, rubberBand, QRubberBand::setGeometry(), and QWidget::show().

Referenced by mousePressEvent().

00267 {
00268     if (rubberBand)
00269         endLineDraw();
00270     rubberBand = new QRubberBand(QRubberBand::Line);
00271     rubberBand->setGeometry(-1, -1, 1, 1);
00272     rubberBand->show();
00273 }

Here is the call graph for this function:

void Q3DockWindowResizeHandle::endLineDraw (  )  [private]

Definition at line 275 of file q3dockwindow.cpp.

References rubberBand.

Referenced by mouseReleaseEvent(), and startLineDraw().

00276 {
00277     delete rubberBand;
00278     rubberBand = 0;
00279 }

void Q3DockWindowResizeHandle::drawLine ( const QPoint globalPos  )  [private]

Definition at line 281 of file q3dockwindow.cpp.

References Q3DockWindow::area(), dockWindow, QWidget::height(), Qt::Horizontal, QWidget::mapToGlobal(), orientation(), Q3DockWindow::orientation(), rubberBand, QRubberBand::setGeometry(), start, QWidget::width(), QPoint::x(), and QPoint::y().

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

00282 {
00283     QPoint start = mapToGlobal(QPoint(0, 0));
00284     QPoint starta = dockWindow->area()->mapToGlobal(QPoint(0, 0));
00285     QPoint end = globalPos;
00286     if (orientation() == Qt::Horizontal) {
00287         if (orientation() == dockWindow->orientation())
00288             rubberBand->setGeometry(starta.x(), end.y(), dockWindow->area()->width(), height());
00289         else
00290             rubberBand->setGeometry(start.x(), end.y(), width(), height());
00291     } else {
00292         if (orientation() == dockWindow->orientation())
00293             rubberBand->setGeometry(end.x(), starta.y(), width(), dockWindow->area()->height());
00294         else
00295             rubberBand->setGeometry(end.x(), start.y(), width(), height());
00296     }
00297 }

Here is the call graph for this function:


Member Data Documentation

Qt::Orientation Q3DockWindowResizeHandle::orient [private]

Definition at line 80 of file q3dockwindow.cpp.

Referenced by orientation(), and setOrientation().

bool Q3DockWindowResizeHandle::mousePressed [private]

Definition at line 81 of file q3dockwindow.cpp.

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

QRubberBand* Q3DockWindowResizeHandle::rubberBand [private]

Definition at line 82 of file q3dockwindow.cpp.

Referenced by drawLine(), endLineDraw(), and startLineDraw().

QPoint Q3DockWindowResizeHandle::lastPos [private]

Definition at line 83 of file q3dockwindow.cpp.

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

QPoint Q3DockWindowResizeHandle::firstPos [private]

Definition at line 83 of file q3dockwindow.cpp.

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

Q3DockWindow* Q3DockWindowResizeHandle::dockWindow [private]

Definition at line 84 of file q3dockwindow.cpp.

Referenced by drawLine(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and sizeHint().

bool Q3DockWindowResizeHandle::mouseOver [private]

Definition at line 85 of file q3dockwindow.cpp.

Referenced by event().


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