13#if QT_CONFIG(rubberband)
20#include "private/qlayoutengine_p.h"
21#include "private/qsplitter_p.h"
91 setOrientation(orientation);
137 return d->s->opaqueResize();
165 pos =
d->s->contentsRect().width() -
pos;
166 d->s->moveSplitter(
pos,
d->s->indexOf(
this));
182 int w =
s->contentsRect().width();
183 return w -
s->closestLegalPosition(
w -
pos,
s->indexOf(
this));
185 return s->closestLegalPosition(
pos,
s->indexOf(
this));
194 int hw =
d->s->handleWidth();
209 const int handleMargin = (5 -
d->s->handleWidth()) / 2;
215 const bool useTinyMode = handleMargin > 0;
237 switch(
event->type()) {
277 d->mouseOffset =
d->pick(
e->position().toPoint());
295 d->s->setRubberBand(-1);
331 const int presizer =
pick(
s, orient);
357 q->setSizePolicy(
sp);
370 bool allInvisible =
n != 0;
371 for (
int i = 0;
i <
n ; ++
i) {
374 if (allInvisible && !widgetHidden && !
s->collapsed)
375 allInvisible =
false;
376 s->handle->setHidden(
first || widgetHidden);
382 for (
int i = 0;
i <
n ; ++
i) {
384 if (!
s->widget->isHidden()) {
390 int fi = 2 *
q->frameWidth();
399 for (
int j = 0;
j <
n;
j++) {
402 if (!
s->widget->isHidden()) {
404 if (!
s->handle->isHidden()) {
406 maxl +=
s->getHandleSize(
orient);
415 maxt =
qMin(maxt, tm);
420 if (qobject_cast<QSplitter *>(
parent)) {
435 q->setMaximumSize(maxl, maxt);
437 q->setMinimumSize(minl,mint);
439 q->setMaximumSize(maxt, maxl);
441 q->setMinimumSize(mint,minl);
458 bool noStretchFactorsSet =
true;
459 for (
i = 0;
i <
n; ++
i) {
463 noStretchFactorsSet =
false;
469 for (
i = 0;
i <
n; ++
i) {
471#ifdef QSPLITTER_DEBUG
472 qDebug(
"widget %d hidden: %d collapsed: %d handle hidden: %d",
i,
s->widget->isHidden(),
473 s->collapsed,
s->handle->isHidden());
477 if (
s->handle->isHidden()) {
478 a[
j].maximumSize = 0;
480 a[
j].sizeHint =
a[
j].minimumSize =
a[
j].maximumSize =
s->getHandleSize(
orient);
486 if (
s->widget->isHidden() ||
s->collapsed) {
487 a[
j].maximumSize = 0;
493 bool stretch = noStretchFactorsSet;
501 a[
j].sizeHint =
a[
j].minimumSize;
502 a[
j].expansive =
true;
512#ifdef QSPLITTER_DEBUG
513 for (
i = 0;
i <
n*2; ++
i) {
514 qDebug(
"%*s%d: stretch %d, sh %d, minS %d, maxS %d, exp %d, emp %d -> %d, %d",
527 for (
i = 0;
i <
n; ++
i) {
544 if (!
s->widget->isHidden()) {
545 if (!
s->handle->isHidden()) {
546 *min +=
s->getHandleSize(
orient);
547 *max +=
s->getHandleSize(
orient);
549 if (mayCollapse || !
s->collapsed)
562 if (!
w->isHidden()) {
581 if (index <= 0 || index >=
n)
584 int collapsibleSizeBefore = 0;
587 int collapsibleSizeAfter = 0;
607 int smartMinBefore =
qMax(minBefore,
pick(
r.size()) - maxAfter);
608 int smartMaxBefore =
qMin(maxBefore,
pick(
r.size()) - minAfter);
610 minVal =
pick(
r.topLeft()) + smartMinBefore;
611 maxVal =
pick(
r.topLeft()) + smartMaxBefore;
614 if (minBefore - collapsibleSizeBefore >=
pick(
r.size()) - maxAfter)
615 farMinVal -= collapsibleSizeBefore;
617 if (
pick(
r.size()) - (minAfter - collapsibleSizeAfter) <= maxBefore)
618 farMaxVal += collapsibleSizeAfter;
632 const int Threshold = 40;
640 int delta =
pos - *max;
641 int width = *farMax - *max;
650 int delta = *min -
pos;
651 int width = *min - *farMin;
664 return (
bool)
s->collapsible;
685 if (clampNegativeSize &&
s->sizer < 0)
694 s->sizer = smartMinSize;
697 if (
s->sizer < smartMinSize)
698 s->sizer = smartMinSize;
734 sls->
collapsed = s <= 0 && minSize > 0 && !
w->isHidden();
739 r.moveTopLeft(
QPoint(-
r.width()-1, -
r.height()-1));
748 if (
q->isRightToLeft())
760 if (index < 0 || index >=
list.
size())
763#ifdef QSPLITTER_DEBUG
764 qDebug() <<
"QSplitterPrivate::doMove" << backwards << hPos <<
index << delta << mayCollapse;
775 int hs =
s->handle->isHidden() ? 0 :
s->getHandleSize(
orient);
777 int ws = backwards ? hPos -
pick(
s->rect.topLeft())
778 :
pick(
s->rect.bottomRight()) - hPos -hs + 1;
779 if (ws > 0 || (!
s->collapsed && !mayCollapse)) {
787 doMove(backwards, backwards ? hPos - ws - hs : hPos + hs + ws,
nextId, delta,
833 if (
s->widget ==
w) {
839 if (index < 0 || index > last)
946#if QT_CONFIG(rubberband)
947 delete d->rubberBand;
949 while (!
d->list.isEmpty())
950 delete d->list.takeFirst();
987 for (
int i = 0;
i <
d->list.size(); ++
i) {
1014 d->childrenCollapsible = collapse;
1020 return d->childrenCollapsible;
1040 if (
Q_UNLIKELY(index < 0 || index >=
d->list.size())) {
1041 qWarning(
"QSplitter::setCollapsible: Index %d out of range",
index);
1044 d->list.at(
index)->collapsible = collapse ? 1 : 0;
1053 if (
Q_UNLIKELY(index < 0 || index >=
d->list.size())) {
1054 qWarning(
"QSplitter::isCollapsible: Index %d out of range",
index);
1057 return d->list.at(
index)->collapsible;
1128 qWarning(
"QSplitter::replaceWidget: Widget can't be null");
1132 if (index < 0 || index >=
d->list.size()) {
1133 qWarning(
"QSplitter::replaceWidget: Index %d out of range",
index);
1140 qWarning(
"QSplitter::replaceWidget: Trying to replace a widget with itself");
1145 qWarning(
"QSplitter::replaceWidget: Trying to replace a widget with one of its siblings");
1152 const bool wasHidden = current->
isHidden();
1164 else if (
d->shouldShowWidget(
widget))
1183 for (
int i = 0;
i <
d->list.size(); ++
i) {
1218 if (index < 0 || index >=
d->list.size())
1220 return d->list.at(
index)->handle;
1232 if (index < 0 || index >=
d->list.size())
1234 return d->list.at(
index)->widget;
1245 return d->list.size();
1267 if (!
c->child()->isWidgetType()) {
1268 if (
Q_UNLIKELY(qobject_cast<QLayout *>(
c->child())))
1269 qWarning(
"Adding a QLayout to a QSplitter is not supported.");
1273 if (!
d->blockChildAdd && !
w->isWindow() && !
d->findWidget(
w))
1274 d->insertWidget_helper(
d->list.size(),
w,
false);
1275 }
else if (
c->polished()) {
1276 if (!
c->child()->isWidgetType())
1279 if (!
d->blockChildAdd && !
w->isWindow() &&
d->shouldShowWidget(
w))
1281 }
else if (
c->removed()) {
1283 for (
int i = 0;
i <
d->list.size(); ++
i) {
1285 if (
s->widget ==
child) {
1286 d->list.removeAt(
i);
1303#if QT_CONFIG(rubberband)
1307 d->rubberBand->deleteLater();
1311 const int rBord = 3;
1313 if (!
d->rubberBand) {
1317 d->rubberBand->setObjectName(
"qt_rubberband"_L1);
1322 d->rubberBand->setGeometry(newGeom);
1323 d->rubberBand->show();
1336 switch (
e->type()) {
1340 d->firstShow =
true;
1345 d->firstShow =
false;
1391#ifdef QSPLITTER_DEBUG
1395 pos =
d->adjustPos(
pos,
index, &farMin, &min, &max, &farMax);
1396 int oldP =
d->pick(
s->rect.topLeft());
1397#ifdef QSPLITTER_DEBUG
1398 qDebug() <<
"QSplitter::moveSplitter" << debugp <<
index <<
"adjusted" <<
pos <<
"oldP" << oldP;
1405 d->doMove(
false,
pos,
index, +1, (
d->collapsible(
s) && (
pos > max)), poss.
data(), ws.data());
1407 upLeft = (
pos < oldP);
1409 int wid, delta,
count =
d->list.size();
1417 for (; wid >= 0 && wid <
count; wid += delta) {
1420 d->setGeo(sls, poss[wid], ws[wid],
true);
1436 d->getRange(
index, min,
nullptr,
nullptr, max);
1482 d->opaqueResizeSet =
true;
1496 for (
int i = 0;
i <
d->list.size(); ++
i) {
1521 for (
int i = 0;
i <
d->list.size(); ++
i) {
1523 if (!
s || !
s->widget)
1525 if (
s->widget->isHidden())
1529 l +=
d->pick(widgetSize);
1530 t =
qMax(
t,
d->trans(widgetSize));
1532 if (!
s->handle ||
s->handle->isHidden())
1534 QSize splitterSize =
s->handle->sizeHint();
1536 l +=
d->pick(splitterSize);
1537 t =
qMax(
t,
d->trans(splitterSize));
1565 const int numSizes =
d->list.size();
1569 for (
int i = 0;
i < numSizes; ++
i) {
1600 d->setSizes_helper(
list,
true);
1617 if (
d->handleWidth >= 0) {
1618 return d->handleWidth;
1665 const int numSizes =
d->list.size();
1668 for (
int i = 0;
i < numSizes; ++
i) {
1716 d->setSizes_helper(
list,
false);
1754 if (index <= -1 || index >=
d->list.size())
1759 sp.setHorizontalStretch(stretch);
1760 sp.setVerticalStretch(stretch);
1766#include "moc_qsplitter.cpp"
\inmodule QtCore\reentrant
Type type() const
Returns the event type.
The QFrame class is the base class of widgets that can have a frame.
bool event(QEvent *e) override
\reimp
void changeEvent(QEvent *) override
\reimp
qsizetype size() const noexcept
iterator insert(qsizetype i, parameter_type t)
const_reference at(qsizetype i) const noexcept
void move(qsizetype from, qsizetype to)
void reserve(qsizetype size)
void append(parameter_type t)
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr QSize size() const noexcept
Returns the size of the rectangle.
The QRegion class specifies a clip region for a painter.
The QResizeEvent class contains event parameters for resize events.
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr int horizontalStretch() const noexcept
Returns the horizontal stretch factor of the size policy.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
The QSplitterHandle class provides handle functionality for the splitter.
void paintEvent(QPaintEvent *) override
\reimp
void mouseMoveEvent(QMouseEvent *) override
\reimp
bool event(QEvent *) override
\reimp
int closestLegalPosition(int p)
Returns the closest legal position to pos of the splitter handle.
void setOrientation(Qt::Orientation o)
Sets the orientation of the splitter handle to orientation.
void mousePressEvent(QMouseEvent *) override
\reimp
QSplitterHandle(Qt::Orientation o, QSplitter *parent)
Creates a QSplitter handle with the given orientation and parent.
void moveSplitter(int p)
Tells the splitter to move this handle to position pos, which is the distance from the left or top ed...
void mouseReleaseEvent(QMouseEvent *) override
\reimp
void resizeEvent(QResizeEvent *) override
\reimp
bool opaqueResize() const
Returns true if widgets are resized dynamically (opaquely) while interactively moving the splitter.
~QSplitterHandle()
Destructor.
QSize sizeHint() const override
\reimp
Qt::Orientation orientation() const
Returns the handle's orientation.
QSplitter * splitter() const
Returns the splitter associated with this splitter handle.
int getWidgetSize(Qt::Orientation orient)
int getHandleSize(Qt::Orientation orient)
int pick(const QSize &size, Qt::Orientation orient)
int trans(const QPoint &pos) const
int pick(const QPoint &pos) const
void getRange(int index, int *, int *, int *, int *) const
void recalc(bool update=false)
void doMove(bool backwards, int pos, int index, int delta, bool mayCollapse, int *positions, int *widths)
QSplitterLayoutStruct * findWidget(QWidget *) const
bool collapsible(QSplitterLayoutStruct *) const
bool shouldShowWidget(const QWidget *w) const
void addContribution(int, int *, int *, bool) const
QSplitterLayoutStruct * insertWidget(int index, QWidget *)
int adjustPos(int, int, int *, int *, int *, int *) const
QList< QSplitterLayoutStruct * > list
void setSizes_helper(const QList< int > &sizes, bool clampNegativeSize=false)
void insertWidget_helper(int index, QWidget *widget, bool show)
void setGeo(QSplitterLayoutStruct *s, int pos, int size, bool allowCollapse)
int findWidgetJustBeforeOrJustAfter(int index, int delta, int &collapsibleSize) const
The QSplitter class implements a splitter widget.
void refresh()
Updates the splitter's state.
int indexOf(QWidget *w) const
Returns the index in the splitter's layout of the specified widget, or -1 if widget is not found.
void resizeEvent(QResizeEvent *) override
\reimp
int closestLegalPosition(int, int)
Returns the closest legal position to pos of the widget at index.
int handleWidth
the width of the splitter handles
void setStretchFactor(int index, int stretch)
Updates the size policy of the widget at position index to have a stretch factor of stretch.
void setOrientation(Qt::Orientation)
void getRange(int index, int *, int *) const
Returns the valid range of the splitter at index in {min} and *{max} if min and max are not 0.
void setCollapsible(int index, bool)
Sets whether the child widget at index is collapsible to collapse.
void setOpaqueResize(bool opaque=true)
virtual QSplitterHandle * createHandle()
Returns a new splitter handle as a child widget of this splitter.
int count() const
Returns the number of widgets contained in the splitter's layout.
QSplitter(QWidget *parent=nullptr)
Constructs a horizontal splitter with the parent argument passed on to the QFrame constructor.
QSize minimumSizeHint() const override
\reimp
bool restoreState(const QByteArray &state)
Restores the splitter's layout to the state specified.
void setChildrenCollapsible(bool)
friend class QSplitterHandle
void changeEvent(QEvent *) override
\reimp
void setRubberBand(int position)
Displays a rubber band at position pos.
QByteArray saveState() const
Saves the state of the splitter's layout.
bool event(QEvent *) override
\reimp
void setSizes(const QList< int > &list)
Sets the child widgets' respective sizes to the values given in the list.
QSize sizeHint() const override
\reimp
void splitterMoved(int pos, int index)
This signal is emitted when the splitter handle at a particular index has been moved to position pos.
bool opaqueResize
Returns true if widgets are resized dynamically (opaquely) while interactively moving the splitter.
QSplitterHandle * handle(int index) const
Returns the handle to the left of (or above) the item in the splitter's layout at the given index,...
bool isCollapsible(int index) const
Returns true if the widget at index is collapsible, otherwise returns false.
QWidget * replaceWidget(int index, QWidget *widget)
Qt::Orientation orientation
the orientation of the splitter
void moveSplitter(int pos, int index)
Moves the left or top edge of the splitter handle at index as close as possible to position pos,...
void childEvent(QChildEvent *) override
\reimp
QList< int > sizes() const
Returns a list of the size parameters of all the widgets in this splitter.
QWidget * widget(int index) const
Returns the widget at the given index in the splitter's layout, or \nullptr if there is no such widge...
bool childrenCollapsible
whether child widgets can be resized down to size 0 by the user
void insertWidget(int index, QWidget *widget)
Inserts the widget specified into the splitter's layout at the given index.
~QSplitter()
Destroys the splitter.
void addWidget(QWidget *widget)
Adds the given widget to the splitter's layout after all the other items.
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_Splitter_OpaqueResize
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
Combined button and popup list for selecting options.
@ WA_WState_ExplicitShowHide
@ WA_WState_OwnSizePolicy
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
void qGeomCalc(QList< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy, Qt::Alignment align)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLdouble GLdouble GLdouble GLdouble q
static const qint32 SplitterMagic
static QT_BEGIN_NAMESPACE const uint Default
QFileInfo fi("c:/temp/foo")
[newstuff]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent