summaryrefslogtreecommitdiff
path: root/libqtaux
Side-by-side diff
Diffstat (limited to 'libqtaux') (more/less context) (show whitespace changes)
-rw-r--r--libqtaux/ocolorbutton.cpp3
-rw-r--r--libqtaux/ocolorpopupmenu.cpp1
-rw-r--r--libqtaux/qcolordialog.cpp2
-rw-r--r--libqtaux/qinputdialog.cpp1
-rw-r--r--libqtaux/qsplitter.cpp4
5 files changed, 0 insertions, 11 deletions
diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp
index d2ad873..fd3f963 100644
--- a/libqtaux/ocolorbutton.cpp
+++ b/libqtaux/ocolorbutton.cpp
@@ -1,150 +1,147 @@
/*
This file is part of the Opie Project
Copyright (C) Robert Griebl <sandman@handhelds.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "ocolorpopupmenu.h"
#include "ocolorbutton.h"
/* OPIE */
-#include <qpe/resource.h>
/* QT */
-#include <qcolor.h>
-#include <qpixmap.h>
#include <qimage.h>
using namespace Opie;
struct OColorButtonPrivate
{
QPopupMenu *m_menu;
QColor m_color;
};
/**
* This concstructs a Color Button with @param color as the start color
* It'll use a OColorPopupMenu internally
*
* @param parent The parent of the Color Button
* @param color The color from where to start on
* @param name @see QObject
*/
OColorButton::OColorButton ( QWidget *parent, const QColor &color, const char *name )
: QPushButton ( parent, name )
{
d = new OColorButtonPrivate;
d-> m_menu = new OColorPopupMenu ( color, 0, 0 );
setPopup ( d-> m_menu );
// setPopupDelay ( 0 );
connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & )));
updateColor ( color );
QSize s = sizeHint ( ) + QSize ( 12, 0 );
setMinimumSize ( s );
setMaximumSize ( s. width ( ) * 2, s. height ( ));
}
/**
* This destructs the object
*/
OColorButton::~OColorButton ( )
{
delete d;
}
/**
* @return Returns the current color of the button
*/
QColor OColorButton::color ( ) const
{
return d-> m_color;
}
/**
* This method sets the color of the button
* @param c The color to be set.
*/
void OColorButton::setColor ( const QColor &c )
{
updateColor ( c );
}
/**
* @internal
*/
void OColorButton::updateColor ( const QColor &c )
{
d-> m_color = c;
QImage img ( 16, 16, 32 );
img. fill ( 0 );
int r, g, b;
c. rgb ( &r, &g, &b );
int w = img. width ( );
int h = img. height ( );
int dx = w * 20 / 100; // 15%
int dy = h * 20 / 100;
for ( int y = 0; y < h; y++ )
{
for ( int x = 0; x < w; x++ )
{
double alpha = 1.0;
if ( x < dx )
alpha *= ( double ( x + 1 ) / dx );
else if ( x >= w - dx )
alpha *= ( double ( w - x ) / dx );
if ( y < dy )
alpha *= ( double ( y + 1 ) / dy );
else if ( y >= h - dy )
alpha *= ( double ( h - y ) / dy );
int a = int ( alpha * 255.0 );
if ( a < 0 )
a = 0;
if ( a > 255 )
a = 255;
img. setPixel ( x, y, qRgba ( r, g, b, a ));
}
}
img. setAlphaBuffer ( true );
QPixmap pix;
pix. convertFromImage ( img );
setPixmap ( pix );
emit colorSelected ( c );
}
diff --git a/libqtaux/ocolorpopupmenu.cpp b/libqtaux/ocolorpopupmenu.cpp
index 6c5f99c..c5b2b88 100644
--- a/libqtaux/ocolorpopupmenu.cpp
+++ b/libqtaux/ocolorpopupmenu.cpp
@@ -1,176 +1,175 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 S. Prud'homme <prudhomme@laposte.net>
              Dan Williams <williamsdr@acm.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "ocolorpopupmenu.h"
#include "qcolordialog.h"
/* QT */
-#include <qaction.h>
#include <qlayout.h>
#include <qpainter.h>
using namespace Opie;
OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, const char* name )
: QFrame( parent, name )
{
m_color = color;
setFixedSize( 16, 16 );
setActive( FALSE );
}
OColorPanelButton::~OColorPanelButton()
{
}
void OColorPanelButton::setActive( bool active )
{
m_active = active;
if ( m_active ) {
setFrameStyle( Panel | Sunken );
} else {
setFrameStyle( NoFrame );
}
}
void OColorPanelButton::enterEvent( QEvent* )
{
if ( !m_active ) {
setFrameStyle( Panel | Sunken );
}
}
void OColorPanelButton::leaveEvent( QEvent* )
{
if ( !m_active ) {
setFrameStyle( NoFrame );
}
}
void OColorPanelButton::paintEvent( QPaintEvent* e )
{
QFrame::paintEvent( e );
QPainter painter;
painter.begin( this );
painter.fillRect( 2, 2, 12, 12, m_color );
painter.setPen( Qt::black );
painter.drawRect( 2, 2, 12, 12 );
painter.end();
}
void OColorPanelButton::mouseReleaseEvent( QMouseEvent* )
{
emit selected( m_color );
}
OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
: QPopupMenu( parent, name )
{
m_color = color;
colorPanel = new QWidget( this );
colorLayout = new QGridLayout(colorPanel, 5, 6);
addColor(QColor(255, 255, 255), 0, 1);
addColor(QColor(192, 192, 192), 0, 2);
addColor(QColor(128, 128, 128), 0, 3);
addColor(QColor(64, 64, 64), 0, 4);
addColor(QColor(0, 0, 0), 0, 5);
addColor(QColor(255, 0, 0), 1, 0);
addColor(QColor(255, 128, 0), 1, 1);
addColor(QColor(255, 255, 0), 1, 2);
addColor(QColor(128, 255, 0), 1, 3);
addColor(QColor(0, 255, 0), 1, 4);
addColor(QColor(0, 255, 128), 1, 5);
addColor(QColor(128, 0, 0), 2, 0);
addColor(QColor(128, 64, 0), 2, 1);
addColor(QColor(128, 128, 0), 2, 2);
addColor(QColor(64, 128, 0), 2, 3);
addColor(QColor(0, 128, 0), 2, 4);
addColor(QColor(0, 128, 64), 2, 5);
addColor(QColor(0, 255, 255), 3, 0);
addColor(QColor(0, 128, 255), 3, 1);
addColor(QColor(0, 0, 255), 3, 2);
addColor(QColor(128, 0, 255), 3, 3);
addColor(QColor(255, 0, 255), 3, 4);
addColor(QColor(255, 0, 128), 3, 5);
addColor(QColor(0, 128, 128), 4, 0);
addColor(QColor(0, 64, 128), 4, 1);
addColor(QColor(0, 0, 128), 4, 2);
addColor(QColor(64, 0, 128), 4, 3);
addColor(QColor(128, 0, 128), 4, 4);
addColor(QColor(128, 0, 64), 4, 5);
insertItem( colorPanel );
insertSeparator();
insertItem(tr("More"),this,SLOT( moreColorClicked()));
/*
QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" );
connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) );
chooseColorAction->addTo( this );
*/
activateItemAt( 0 );
}
OColorPopupMenu::~OColorPopupMenu()
{
}
void OColorPopupMenu::addColor( const QColor& color, int row, int col )
{
OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel );
connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) );
colorLayout->addWidget( panelButton, row, col );
}
void OColorPopupMenu::buttonSelected( const QColor& color )
{
m_color = color;
emit colorSelected( color );
hide();
}
void OColorPopupMenu::moreColorClicked()
{
QColor color = QColorDialog::getColor( m_color );
m_color = color;
emit colorSelected( color );
hide();
}
diff --git a/libqtaux/qcolordialog.cpp b/libqtaux/qcolordialog.cpp
index b960b04..907c2aa 100644
--- a/libqtaux/qcolordialog.cpp
+++ b/libqtaux/qcolordialog.cpp
@@ -1,435 +1,433 @@
/****************************************************************************
** $Id$
**
** Implementation of QColorDialog class
**
** Created : 990222
**
** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
**
** This file is part of the dialogs 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 "qcolordialog.h"
#include "qpainter.h"
#include "qlayout.h"
#include "qlabel.h"
#include "qpushbutton.h"
#include "qlineedit.h"
#include "qimage.h"
#include "qpixmap.h"
#include "qdrawutil.h"
#include "qvalidator.h"
-#include "qdragobject.h"
#include "qapplication.h"
-#include "qdragobject.h"
//////////// QWellArray BEGIN
#include "qobjectdict.h"
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of qwellarray.cpp and qcolordialog.cpp.
// This header file may change from version to version without notice,
// or even be removed.
//
//
#include "qtableview.h"
struct QWellArrayData;
class QWellArray : public QTableView
{
Q_OBJECT
Q_PROPERTY( int numCols READ numCols )
Q_PROPERTY( int numRows READ numRows )
Q_PROPERTY( int selectedColumn READ selectedColumn )
Q_PROPERTY( int selectedRow READ selectedRow )
public:
QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE );
~QWellArray() {}
QString cellContent( int row, int col ) const;
// ### Paul !!! virtual void setCellContent( int row, int col, const QString &);
// ##### Obsolete since not const
int numCols() { return nCols; }
int numRows() { return nRows; }
int numCols() const { return nCols; }
int numRows() const { return nRows; }
// ##### Obsolete since not const
int selectedColumn() { return selCol; }
int selectedRow() { return selRow; }
int selectedColumn() const { return selCol; }
int selectedRow() const { return selRow; }
virtual void setSelected( int row, int col );
void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); }
QSize sizeHint() const;
virtual void setDimension( int rows, int cols );
virtual void setCellBrush( int row, int col, const QBrush & );
QBrush cellBrush( int row, int col );
signals:
void selected( int row, int col );
protected:
virtual void setCurrent( int row, int col );
virtual void drawContents( QPainter *, int row, int col, const QRect& );
void drawContents( QPainter * );
void paintCell( QPainter*, int row, int col );
void mousePressEvent( QMouseEvent* );
void mouseReleaseEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
void keyPressEvent( QKeyEvent* );
void focusInEvent( QFocusEvent* );
void focusOutEvent( QFocusEvent* );
private:
int curRow;
int curCol;
int selRow;
int selCol;
int nCols;
int nRows;
bool smallStyle;
QWellArrayData *d;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QWellArray( const QWellArray & );
QWellArray& operator=( const QWellArray & );
#endif
};
// non-interface ...
struct QWellArrayData {
QBrush *brush;
};
// NOT REVISED
/* WARNING, NOT
\class QWellArray qwellarray_p.h
\brief ....
....
\ingroup advanced
*/
QWellArray::QWellArray( QWidget *parent, const char * name, bool popup )
: QTableView( parent, name,
popup ? (WStyle_Customize|WStyle_Tool|WStyle_NoBorder) : 0 )
{
d = 0;
setFocusPolicy( StrongFocus );
setBackgroundMode( PaletteButton );
nCols = 7;
nRows = 7;
int w = 24; // cell width
int h = 21; // cell height
smallStyle = popup;
if ( popup ) {
w = h = 18;
if ( style() == WindowsStyle )
setFrameStyle( QFrame::WinPanel | QFrame::Raised );
else
setFrameStyle( QFrame::Panel | QFrame::Raised );
setMargin( 1 );
setLineWidth( 2 );
}
setNumCols( nCols );
setNumRows( nRows );
setCellWidth( w );
setCellHeight( h );
curCol = 0;
curRow = 0;
selCol = -1;
selRow = -1;
if ( smallStyle )
setMouseTracking( TRUE );
setOffset( 5 , 10 );
resize( sizeHint() );
}
QSize QWellArray::sizeHint() const
{
constPolish();
int f = frameWidth() * 2;
int w = nCols * cellWidth() + f;
int h = nRows * cellHeight() + f;
return QSize( w, h );
}
void QWellArray::paintCell( QPainter* p, int row, int col )
{
int w = cellWidth( col ); // width of cell in pixels
int h = cellHeight( row ); // height of cell in pixels
int b = 1;
if ( !smallStyle )
b = 3;
const QColorGroup & g = colorGroup();
p->setPen( QPen( black, 0, SolidLine ) );
if ( !smallStyle && row ==selRow && col == selCol &&
style() != MotifStyle ) {
int n = 2;
p->drawRect( n, n, w-2*n, h-2*n );
}
if ( style() == WindowsStyle ) {
qDrawWinPanel( p, b, b , w - 2*b, h - 2*b,
g, TRUE );
b += 2;
} else {
if ( smallStyle ) {
qDrawShadePanel( p, b, b , w - 2*b, h - 2*b,
g, TRUE, 2 );
b += 2;
} else {
int t = ( row == selRow && col == selCol ) ? 2 : 0;
b -= t;
qDrawShadePanel( p, b, b , w - 2*b, h - 2*b,
g, TRUE, 2 );
b += 2 + t;
}
}
if ( (row == curRow) && (col == curCol) ) {
if ( smallStyle ) {
p->setPen ( white );
p->drawRect( 1, 1, w-2, h-2 );
p->setPen ( black );
p->drawRect( 0, 0, w, h );
p->drawRect( 2, 2, w-4, h-4 );
b = 3;
} else if ( hasFocus() ) {
style().drawFocusRect(p, QRect(0,0,w,h), g );
}
}
drawContents( p, row, col, QRect(b, b, w - 2*b, h - 2*b) );
}
/*!
Pass-through to QTableView::drawContents() to avoid hiding.
*/
void QWellArray::drawContents( QPainter *p )
{
QTableView::drawContents(p);
}
/*!
Reimplement this function to change the contents of the well array.
*/
void QWellArray::drawContents( QPainter *p, int row, int col, const QRect &r )
{
if ( d ) {
p->fillRect( r, d->brush[row*nCols+col] );
} else {
p->fillRect( r, white );
p->setPen( black );
p->drawLine( r.topLeft(), r.bottomRight() );
p->drawLine( r.topRight(), r.bottomLeft() );
}
}
/*\reimp
*/
void QWellArray::mousePressEvent( QMouseEvent* e )
{
// The current cell marker is set to the cell the mouse is pressed
// in.
QPoint pos = e->pos();
setCurrent( findRow( pos.y() ), findCol( pos.x() ) );
}
/*\reimp
*/
void QWellArray::mouseReleaseEvent( QMouseEvent* )
{
// The current cell marker is set to the cell the mouse is clicked
// in.
setSelected( curRow, curCol );
}
/*\reimp
*/
void QWellArray::mouseMoveEvent( QMouseEvent* e )
{
// The current cell marker is set to the cell the mouse is
// clicked in.
if ( smallStyle ) {
QPoint pos = e->pos();
setCurrent( findRow( pos.y() ), findCol( pos.x() ) );
}
}
/*
Sets the cell currently having the focus. This is not necessarily
the same as the currently selected cell.
*/
void QWellArray::setCurrent( int row, int col )
{
if ( (curRow == row) && (curCol == col) )
return;
if ( row < 0 || col < 0 )
row = col = -1;
int oldRow = curRow;
int oldCol = curCol;
curRow = row;
curCol = col;
updateCell( oldRow, oldCol );
updateCell( curRow, curCol );
}
/*!
Sets the currently selected cell to \a row, \a col. If \a row or \a
col are less than zero, the current cell is unselected.
Does not set the position of the focus indicator.
*/
void QWellArray::setSelected( int row, int col )
{
if ( (selRow == row) && (selCol == col) )
return;
int oldRow = selRow;
int oldCol = selCol;
if ( row < 0 || col < 0 )
row = col = -1;
selCol = col;
selRow = row;
updateCell( oldRow, oldCol );
updateCell( selRow, selCol );
if ( row >= 0 )
emit selected( row, col );
if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") )
parentWidget()->close();
}
/*!\reimp
*/
void QWellArray::focusInEvent( QFocusEvent* )
{
updateCell( curRow, curCol );
}
/*!
Sets the size of the well array to be \c rows cells by \c cols.
Resets any brush info set by setCellBrush().
Must be called by reimplementors.
*/
void QWellArray::setDimension( int rows, int cols )
{
nRows = rows;
nCols = cols;
if ( d ) {
if ( d->brush )
delete[] d->brush;
delete d;
d = 0;
}
setNumCols( nCols );
setNumRows( nRows );
}
void QWellArray::setCellBrush( int row, int col, const QBrush &b )
{
if ( !d ) {
d = new QWellArrayData;
d->brush = new QBrush[nRows*nCols];
}
if ( row >= 0 && row < nRows && col >= 0 && col < nCols )
d->brush[row*nCols+col] = b;
#ifdef CHECK_RANGE
else
qWarning( "QWellArray::setCellBrush( %d, %d ) out of range", row, col );
#endif
}
/*!
Returns the brush set for the cell at \a row, \a col. If no brush is set,
\c NoBrush is returned.
*/
QBrush QWellArray::cellBrush( int row, int col )
{
if ( d && row >= 0 && row < nRows && col >= 0 && col < nCols )
diff --git a/libqtaux/qinputdialog.cpp b/libqtaux/qinputdialog.cpp
index 821c74d..43e243f 100644
--- a/libqtaux/qinputdialog.cpp
+++ b/libqtaux/qinputdialog.cpp
@@ -1,426 +1,425 @@
/****************************************************************************
** $Id$
**
** Implementation of QInputDialog class
**
** Created : 991212
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the dialogs 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 "qinputdialog.h"
#include <qlayout.h>
#include <qlabel.h>
-#include <qlineedit.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qwidgetstack.h>
#include <qvalidator.h>
#include <qapplication.h>
class QInputDialogPrivate
{
public:
friend class QInputDialog;
QLineEdit *lineEdit;
QSpinBox *spinBox;
QComboBox *comboBox, *editComboBox;
QPushButton *ok;
QWidgetStack *stack;
QInputDialog::Type type;
};
/*!
\class QInputDialog qinputdialog.h
\brief A convenience dialog to get a simple input from the user
\ingroup dialogs
The QInputDialog is a simple dialog which can be used if you
need a simple input from the user. This can be text, a number or
an item from a list. Also a label has to be set to tell the user
what he/she should input.
In this Qt version only the 4 static convenience functions
getText(), getInteger(), getDouble() and getItem() of QInputDialog
are available.
Use it like this:
\code
bool ok = FALSE;
QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed ok
else
;// user entered nothing or pressed cancel
\endcode
There are more static convenience methods!
\sa getText(), getInteger(), getDouble(), getItem()
*/
/*!
\enum QInputDialog::Type
This enum type specifies the type of the dialog
(which kind of input can be done):
<ul>
<li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or
(e.g. using a QValidator) a numerical input can be done. Using lineEdit()
the QLineEdit can be accessed.
<li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal
input can be done. Using spinBox() the QSpinBox can be accessed.
<li>\c ComboBox - A read-only QComboBox is used for taking the input,
so one item of a list can be chosen. Using comboBox() the QComboBox
can be accessed.
<li>\c EditableComboBox - An editable QComboBox is used for taking the input,
so either one item of a list can be chosen or a text can be entered. Using
editableComboBox() the QComboBox can be accessed.
</ul>
*/
/*!
Constructs the dialog. \a label is the text which is shown to the user (it should mention
to the user what he/she should input), \a parent the parent widget of the dialog, \a name
the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops
up modeless. With \a type you specify the type of the dialog.
\sa getText(), getInteger(), getDouble(), getItem()
*/
QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name,
bool modal, Type type)
: QDialog( parent, name, modal )
{
if ( parent && parent->icon() &&!parent->icon()->isNull() )
setIcon( *parent->icon() );
else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
QDialog::setIcon( *qApp->mainWidget()->icon() );
d = new QInputDialogPrivate;
d->lineEdit = 0;
d->spinBox = 0;
d->comboBox = 0;
QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
QLabel* l = new QLabel( label, this );
vbox->addWidget( l );
d->stack = new QWidgetStack( this );
vbox->addWidget( d->stack );
d->lineEdit = new QLineEdit( d->stack );
d->spinBox = new QSpinBox( d->stack );
d->comboBox = new QComboBox( FALSE, d->stack );
d->editComboBox = new QComboBox( TRUE, d->stack );
QHBoxLayout *hbox = new QHBoxLayout( 6 );
vbox->addLayout( hbox, AlignRight );
d->ok = new QPushButton( tr( "&OK" ), this );
d->ok->setDefault( TRUE );
QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
QSize bs( d->ok->sizeHint() );
if ( cancel->sizeHint().width() > bs.width() )
bs.setWidth( cancel->sizeHint().width() );
d->ok->setFixedSize( bs );
cancel->setFixedSize( bs );
hbox->addWidget( new QWidget( this ) );
hbox->addWidget( d->ok );
hbox->addWidget( cancel );
connect( d->lineEdit, SIGNAL( returnPressed() ),
this, SLOT( tryAccept() ) );
connect( d->lineEdit, SIGNAL( textChanged(const QString&) ),
this, SLOT( textChanged(const QString&) ) );
connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() );
setType( type );
}
/*!
Returns the line edit, which is used in the LineEdit mode
*/
QLineEdit *QInputDialog::lineEdit() const
{
return d->lineEdit;
}
/*!
Returns the spinbox, which is used in the SpinBox mode
*/
QSpinBox *QInputDialog::spinBox() const
{
return d->spinBox;
}
/*!
Returns the combobox, which is used in the ComboBox mode
*/
QComboBox *QInputDialog::comboBox() const
{
return d->comboBox;
}
/*!
Returns the combobox, which is used in the EditableComboBox mode
*/
QComboBox *QInputDialog::editableComboBox() const
{
return d->editComboBox;
}
/*!
Sets the input type of the dialog to \a t.
*/
void QInputDialog::setType( Type t )
{
switch ( t ) {
case LineEdit:
d->stack->raiseWidget( d->lineEdit );
d->lineEdit->setFocus();
break;
case SpinBox:
d->stack->raiseWidget( d->spinBox );
d->spinBox->setFocus();
break;
case ComboBox:
d->stack->raiseWidget( d->comboBox );
d->comboBox->setFocus();
break;
case EditableComboBox:
d->stack->raiseWidget( d->editComboBox );
d->editComboBox->setFocus();
break;
}
d->type = t;
}
/*!
Returns the input type of the dialog.
\sa setType()
*/
QInputDialog::Type QInputDialog::type() const
{
return d->type;
}
/*!
Destructor.
*/
QInputDialog::~QInputDialog()
{
delete d;
}
/*!
Static convenience function to get a textual input from the user. \a caption is the text
which is displayed in the title bar of the dialog. \a label is the text which
is shown to the user (it should mention to the user what he/she should input), \a text
the default text which will be initially set to the line edit, \a ok a pointer to
a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
user pressed cancel, \a parent the parent widget of the dialog and \a name
the name of it. The dialogs pops up modally!
This method returns the text which has been entered in the line edit.
You will use this static method like this:
\code
bool ok = FALSE;
QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed ok
else
;// user entered nothing or pressed cancel
\endcode
*/
QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text,
bool *ok, QWidget *parent, const char *name )
{
return getText( caption, label, QLineEdit::Normal, text, ok, parent, name );
}
/*!
Like above, but accepts an a \a mode which the line edit will use to display text.
\sa getText()
*/
QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode,
const QString &text, bool *ok, QWidget *parent, const char *name )
{
QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
dlg->setCaption( caption );
dlg->lineEdit()->setText( text );
dlg->lineEdit()->setEchoMode( mode );
if ( !text.isEmpty() )
dlg->lineEdit()->selectAll();
bool ok_ = FALSE;
QString result;
ok_ = dlg->exec() == QDialog::Accepted;
if ( ok )
*ok = ok_;
if ( ok_ )
result = dlg->lineEdit()->text();
delete dlg;
return result;
}
/*!
Static convenience function to get an integral input from the user. \a caption is the text
which is displayed in the title bar of the dialog. \a label is the text which
is shown to the user (it should mention to the user what he/she should input), \a num
the default number which will be initially set to the spinbox, \a from and \a to the
range in which the entered number has to be, \a step the step in which the number can
be increased/decreased by the spinbox, \a ok a pointer to
a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
user pressed cancel, \a parent the parent widget of the dialog and \a name
the name of it. The dialogs pops up modally!
This method returns the number which has been entered by the user.
You will use this static method like this:
\code
bool ok = FALSE;
int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
if ( ok )
;// user entered something and pressed ok
else
;// user pressed cancel
\endcode
*/
int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step,
bool *ok, QWidget *parent, const char *name )
{
QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox );
dlg->setCaption( caption );
dlg->spinBox()->setRange( from, to );
dlg->spinBox()->setSteps( step, 0 );
dlg->spinBox()->setValue( num );
bool ok_ = FALSE;
int result;
ok_ = dlg->exec() == QDialog::Accepted;
if ( ok )
*ok = ok_;
result = dlg->spinBox()->value();
delete dlg;
return result;
}
/*!
Static convenience function to get a decimal input from the user. \a caption is the text
which is displayed in the title bar of the dialog. \a label is the text which
is shown to the user (it should mention to the user what he/she should input), \a num
the default decimal number which will be initially set to the line edit, \a from and \a to the
range in which the entered number has to be, \a decimals the number of decimal which
the number may have, \a ok a pointer to
a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
user pressed cancel, \a parent the parent widget of the dialog and \a name
the name of it. The dialogs pops up modally!
This method returns the number which has been entered by the user.
You will use this static method like this:
\code
bool ok = FALSE;
double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this );
if ( ok )
;// user entered something and pressed ok
else
;// user pressed cancel
\endcode
*/
double QInputDialog::getDouble( const QString &caption, const QString &label, double num,
double from, double to, int decimals,
bool *ok, QWidget *parent, const char *name )
{
QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
dlg->setCaption( caption );
dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) );
dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) );
dlg->lineEdit()->selectAll();
bool accepted = ( dlg->exec() == QDialog::Accepted );
if ( ok )
*ok = accepted;
double result = dlg->lineEdit()->text().toDouble();
delete dlg;
return result;
}
/*!
Static convenience function to let the user select an item from a string list. \a caption is the text
which is displayed in the title bar of the dialog. \a label is the text which
is shown to the user (it should mention to the user what he/she should input), \a list the
string list which is inserted into the combobox, \a current the number of the item which should
be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE)
or read-only (if \a editable is FALSE), \a ok a pointer to
a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
user pressed cancel, \a parent the parent widget of the dialog and \a name
the name of it. The dialogs pops up modally!
This method returns the text of the current item, or if \a editable was TRUE, the current
text of the combobox.
You will use this static method like this:
\code
diff --git a/libqtaux/qsplitter.cpp b/libqtaux/qsplitter.cpp
index ab6e01b..39321f8 100644
--- a/libqtaux/qsplitter.cpp
+++ b/libqtaux/qsplitter.cpp
@@ -1,428 +1,424 @@
/****************************************************************************
** $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.
*/
QSplitter::QSplitter( QWidget *parent, const char *name )
:QFrame(parent,name,WPaintUnclipped)
{
orient = Horizontal;
init();
}
/*!
Constructs splitter with orientation \a o.
*/
QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name )
:QFrame(parent,name,WPaintUnclipped)
{
orient = o;
init();
}
/*!
Destructs the splitter.
*/
QSplitter::~QSplitter()
{
data->list.setAutoDelete( TRUE );
delete data;
}
void QSplitter::init()
{
data = new QSplitterData;
if ( orient == Horizontal )
setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) );
else
setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) );
}
/*!
\fn void QSplitter::refresh()
Updates the splitter state. You should not need to call this
function during normal use of the splitter.
*/
/*! Sets the orientation to \a o. By default the orientation is
horizontal (the widgets are side by side).
\sa orientation()
*/
void QSplitter::setOrientation( Orientation o )
{
if ( orient == o )
return;
orient = o;
if ( orient == Horizontal )
setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) );
else
setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
QSplitterLayoutStruct *s = data->list.first();
while ( s ) {
if ( s->isSplitter )
((QSplitterHandle*)s->wid)->setOrientation( o );
s = data->list.next(); // ### next at end of loop, no iterator
}
recalc( isVisible() );
}
/*!
\fn Orientation QSplitter::orientation() const
Returns the orientation (\c Horizontal or \c Vertical) of the splitter.
\sa setOrientation()
*/
/*!
\reimp
*/
void QSplitter::resizeEvent( QResizeEvent * )
{
doResize();
}
/*!
Inserts the widget \a w at the end, or at the beginning if \a first is TRUE
It is the responsibility of the caller of this function to make sure
that \a w is not already in the splitter, and to call recalcId if
needed. (If \a first is TRUE, then recalcId is very probably
needed.)
*/
QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first )
{
QSplitterLayoutStruct *s;
QSplitterHandle *newHandle = 0;
if ( data->list.count() > 0 ) {
s = new QSplitterLayoutStruct;
s->mode = KeepSize;
newHandle = new QSplitterHandle( orientation(), this );
s->wid = newHandle;
newHandle->setId(data->list.count());
s->isSplitter = TRUE;
s->sizer = pick( newHandle->sizeHint() );
if ( first )
data->list.insert( 0, s );
else
data->list.append( s );
}
s = new QSplitterLayoutStruct;
s->mode = Stretch;
s->wid = w;
if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
s->sizer = pick( w->sizeHint() );
else
s->sizer = pick( w->size() );
s->isSplitter = FALSE;
if ( first )
data->list.insert( 0, s );
else
data->list.append( s );
if ( newHandle && isVisible() )
newHandle->show(); //will trigger sending of post events
return s;
}
/*!
Tells the splitter that a child widget has been inserted/removed.
*/
void QSplitter::childEvent( QChildEvent *c )
{
if ( c->type() == QEvent::ChildInserted ) {
if ( !c->child()->isWidgetType() )
return;
if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
return;
QSplitterLayoutStruct *s = data->list.first();
while ( s ) {
if ( s->wid == c->child() )
return;
s = data->list.next();
}
addWidget( (QWidget*)c->child() );
recalc( isVisible() );
} else if ( c->type() == QEvent::ChildRemoved ) {
QSplitterLayoutStruct *p = 0;
if ( data->list.count() > 1 )
p = data->list.at(1); //remove handle _after_ first widget.
QSplitterLayoutStruct *s = data->list.first();
while ( s ) {
if ( s->wid == c->child() ) {
data->list.removeRef( s );
delete s;
if ( p && p->isSplitter ) {
data->list.removeRef( p );
delete p->wid; //will call childEvent
delete p;
}
recalcId();
doResize();
return;
}
p = s;
s = data->list.next();
}
}
}
/*!
Shows a rubber band at position \a p. If \a p is negative, the
rubber band is removed.
*/
void QSplitter::setRubberband( int p )
{
QPainter paint( this );
paint.setPen( gray );