summaryrefslogtreecommitdiff
path: root/libqtaux/qsplitter.cpp
Side-by-side diff
Diffstat (limited to 'libqtaux/qsplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/qsplitter.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/libqtaux/qsplitter.cpp b/libqtaux/qsplitter.cpp
index ab6e01b..39321f8 100644
--- a/libqtaux/qsplitter.cpp
+++ b/libqtaux/qsplitter.cpp
@@ -1,236 +1,232 @@
/****************************************************************************
** $Id$
**
** Splitter widget
**
** Created: 980105
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the widgets module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "qsplitter.h"
-#include "qpainter.h"
#include "qdrawutil.h"
-#include "qbitmap.h"
#include "qlayoutengine_p.h"
-#include "qlist.h"
-#include "qarray.h"
#include "qobjectlist.h"
#include "qapplication.h" //sendPostedEvents
class QSplitterHandle : public QWidget
{
public:
QSplitterHandle( Qt::Orientation o,
QSplitter *parent, const char* name=0 );
void setOrientation( Qt::Orientation o );
Qt::Orientation orientation() const { return orient; }
bool opaque() const { return s->opaqueResize(); }
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
int id() const { return myId; } // data->list.at(id())->wid == this
void setId( int i ) { myId = i; }
protected:
void paintEvent( QPaintEvent * );
void mouseMoveEvent( QMouseEvent * );
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
private:
Qt::Orientation orient;
bool opaq;
int myId;
QSplitter *s;
};
static int mouseOffset;
static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
QSplitterHandle::QSplitterHandle( Qt::Orientation o,
QSplitter *parent, const char * name )
: QWidget( parent, name )
{
s = parent;
setOrientation(o);
}
QSizePolicy QSplitterHandle::sizePolicy() const
{
//### removeme 3.0
return QWidget::sizePolicy();
}
QSize QSplitterHandle::sizeHint() const
{
int sw = style().splitterWidth();
return QSize(sw,sw).expandedTo( QApplication::globalStrut() );
}
void QSplitterHandle::setOrientation( Qt::Orientation o )
{
orient = o;
#ifndef QT_NO_CURSOR
if ( o == QSplitter::Horizontal )
setCursor( splitHCursor );
else
setCursor( splitVCursor );
#endif
}
void QSplitterHandle::mouseMoveEvent( QMouseEvent *e )
{
if ( !(e->state()&LeftButton) )
return;
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
- mouseOffset;
if ( opaque() ) {
s->moveSplitter( pos, id() );
} else {
int min = pos; int max = pos;
s->getRange( id(), &min, &max );
s->setRubberband( QMAX( min, QMIN(max, pos )));
}
}
void QSplitterHandle::mousePressEvent( QMouseEvent *e )
{
if ( e->button() == LeftButton )
mouseOffset = s->pick(e->pos());
}
void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
{
if ( !opaque() && e->button() == LeftButton ) {
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()));
s->setRubberband( -1 );
s->moveSplitter( pos, id() );
}
}
void QSplitterHandle::paintEvent( QPaintEvent * )
{
QPainter p( this );
s->drawSplitter( &p, 0, 0, width(), height() );
}
class QSplitterLayoutStruct
{
public:
QSplitter::ResizeMode mode;
QCOORD sizer;
bool isSplitter;
QWidget *wid;
};
class QSplitterData
{
public:
QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
QList<QSplitterLayoutStruct> list;
bool opaque;
bool firstShow;
};
// NOT REVISED
/*!
\class QSplitter qsplitter.h
\brief The QSplitter class implements a splitter widget.
\ingroup organizers
A splitter lets the user control the size of child widgets by
dragging the boundary between the children. Any number of widgets
may be controlled.
To show a QListBox, a QListView and a QMultiLineEdit side by side:
\code
QSplitter *split = new QSplitter( parent );
QListBox *lb = new QListBox( split );
QListView *lv = new QListView( split );
QMultiLineEdit *ed = new QMultiLineEdit( split );
\endcode
In QSplitter the boundary can be either horizontal or vertical. The
default is horizontal (the children are side by side) and you
can use setOrientation( QSplitter::Vertical ) to set it to vertical.
By default, all widgets can be as large or as small as the user
wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink.
You can naturally use setMinimumSize() and/or
setMaximumSize() on the children. Use setResizeMode() to specify that
a widget should keep its size when the splitter is resized.
QSplitter normally resizes the children only at the end of a
resize operation, but if you call setOpaqueResize( TRUE ), the
widgets are resized as often as possible.
The initial distribution of size between the widgets is determined
by the initial size of each widget. You can also use setSizes() to
set the sizes of all the widgets. The function sizes() returns the
sizes set by the user.
If you hide() a child, its space will be distributed among the other
children. When you show() it again, it will be reinstated.
<img src=qsplitter-m.png> <img src=qsplitter-w.png>
\sa QTabBar
*/
static QSize minSize( const QWidget *w )
{
QSize min = w->minimumSize();
QSize s;
if ( min.height() <= 0 || min.width() <= 0 )
s = w->minimumSizeHint();
if ( min.height() > 0 )
s.setHeight( min.height() );
if ( min.width() > 0 )
s.setWidth( min.width() );
return s.expandedTo(QSize(0,0));
}
/*!
Constructs a horizontal splitter.
*/