Source Code (Use browser search to find items of interest.)

Class Index

qt'QComboBox (./qt-2.1.0/src/widgets/qcombobox.h:42)

class Q_EXPORT QComboBox : public QWidget
{
    Q_OBJECT
    Q_ENUMS( Policy )
    Q_PROPERTY( int count READ count )
    Q_PROPERTY( QString currentText READ currentText )
    Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem )
    Q_PROPERTY( bool autoResize READ autoResize WRITE setAutoResize )
    Q_PROPERTY( int sizeLimit READ sizeLimit WRITE setSizeLimit )
    Q_PROPERTY( int maxCount READ maxCount WRITE setMaxCount )
    Q_PROPERTY( Policy insertionPolicy READ insertionPolicy WRITE setInsertionPolicy )
    Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
    Q_PROPERTY( bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled )

public:
    QComboBox( QWidget *parent=0, const char *name=0 );
    QComboBox( bool rw, QWidget *parent=0, const char *name=0 );
   ~QComboBox();

    int		count() const;

    void	insertStringList( const QStringList &, int index=-1 );
    void	insertStrList( const QStrList &, int index=-1 );
    void	insertStrList( const QStrList *, int index=-1 );
    void	insertStrList( const char **, int numStrings=-1, int index=-1);

    void	insertItem( const QString &text, int index=-1 );
    void	insertItem( const QPixmap &pixmap, int index=-1 );
    void	insertItem( const QPixmap &pixmap, const QString &text, int index=-1 );

    void	removeItem( int index );
    void	clear();

    QString currentText() const;
    QString text( int index ) const;
    const QPixmap *pixmap( int index ) const;

    void	changeItem( const QString &text, int index );
    void	changeItem( const QPixmap &pixmap, int index );
    void	changeItem( const QPixmap &pixmap, const QString &text, int index );

    int		currentItem() const;
    virtual void	setCurrentItem( int index );

    bool	autoResize()	const;
    virtual void	setAutoResize( bool );
    QSize	sizeHint() const;
    virtual QSizePolicy sizePolicy() const;

    virtual void	setBackgroundColor( const QColor & );
    virtual void	setPalette( const QPalette & );
    virtual void	setFont( const QFont & );
    virtual void	setEnabled( bool );

    virtual void	setSizeLimit( int );
    int		sizeLimit() const;

    virtual void	setMaxCount( int );
    int		maxCount() const;

    enum Policy { NoInsertion, AtTop, AtCurrent, AtBottom,
		  AfterCurrent, BeforeCurrent };

    virtual void	setInsertionPolicy( Policy policy );
    Policy 	insertionPolicy() const;

    virtual void	setValidator( const QValidator * );
    const QValidator * validator() const;

    virtual void	setListBox( QListBox * );
    QListBox * 	listBox() const;
    
    QLineEdit*	lineEdit() const;

    virtual void	setAutoCompletion( bool );
    bool	autoCompletion() const;

    bool	eventFilter( QObject *object, QEvent *event );

    void 	setDuplicatesEnabled( bool enable );
    bool 	duplicatesEnabled() const;

public slots:
    void	clearValidator();
    void	clearEdit();
    virtual void	setEditText( const QString &);

signals:
    void	activated( int index );
    void	highlighted( int index );
    void	activated( const QString &);
    void	highlighted( const QString &);
    void	textChanged( const QString &);

private slots:
    void	internalActivate( int );
    void	internalHighlight( int );
    void	internalClickTimeout();
    void	returnPressed();
    void	showMore();
    
protected:
    void	paintEvent( QPaintEvent * );
    void	resizeEvent( QResizeEvent * );
    void	mousePressEvent( QMouseEvent * );
    void	mouseMoveEvent( QMouseEvent * );
    void	mouseReleaseEvent( QMouseEvent * );
    void	mouseDoubleClickEvent( QMouseEvent * );
    void	keyPressEvent( QKeyEvent *e );
    void	focusInEvent( QFocusEvent *e );
    void     styleChange( QStyle& );

    void	popup();
    void updateMask();

private:
    void	popDownListBox();
    void	reIndex();
    void	currentChanged();
    QRect	arrowRect() const;
    bool	getMetrics( int *dist, int *buttonW, int *buttonH ) const;

    QComboData	*d;

private:	// Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
    QComboBox( const QComboBox & );
    QComboBox &operator=( const QComboBox & );
#endif
};


qt'QComboBox::getMetrics() (./qt-2.1.0/src/widgets/qcombobox.cpp:265)

bool QComboBox::getMetrics( int *dist, int *buttonW, int *buttonH ) const
{
    if ( d->usingListBox() && style() == WindowsStyle ) {
	QRect r  = arrowRect();
	*buttonW = r.width();
	*buttonH = r.height();
	*dist    = 4;
    } else if ( d->usingListBox() ) {
	*dist = 6;
	*buttonW = 16;
	*buttonH = 18;
    } else {
	*dist     = 8;
	*buttonH  = 7;
	*buttonW  = 11;
    }
    return TRUE;
}



qt'QComboBox::QComboBox() (./qt-2.1.0/src/widgets/qcombobox.cpp:327)

QComboBox::QComboBox( QWidget *parent, const char *name )
    : QWidget( parent, name, WResizeNoErase )
{
    if ( style() == WindowsStyle ) {
	d = new QComboData( this );
	d->setListBox( new QListBox( 0, "in-combo", WType_Popup ) );
	d->listBox()->setAutoScrollBar( FALSE );
	d->listBox()->setBottomScrollBar( FALSE );
	d->listBox()->setAutoBottomScrollBar( FALSE );
	d->listBox()->setFrameStyle( QFrame::Box | QFrame::Plain );
	d->listBox()->setLineWidth( 1 );
	d->listBox()->resize( 100, 10 );

	connect( d->listBox(), SIGNAL(selected(int)),
			     SLOT(internalActivate(int)) );
	connect( d->listBox(), SIGNAL(highlighted(int)),
			     SLOT(internalHighlight(int)));
	d->showTimer = new QTimer( this );
	connect( d->showTimer, SIGNAL( timeout() ),
		 this, SLOT( showMore() ) );
    } else {
	d = new QComboData( this );
	d->setPopupMenu( new QComboBoxPopup );
	connect( d->popup(), SIGNAL(activated(int)),
			     SLOT(internalActivate(int)) );
	connect( d->popup(), SIGNAL(highlighted(int)),
			     SLOT(internalHighlight(int)) );
    }
    d->ed                    = 0;
    d->current               = 0;
    d->maxCount              = INT_MAX;
    d->sizeLimit	     = 10;
    d->p                    =  AtBottom;
    d->autoresize            = FALSE;
    d->poppedUp              = FALSE;
    d->arrowDown             = FALSE;
    d->discardNextMousePress = FALSE;
    d->shortClick            = FALSE;
    d->useCompletion = FALSE;

    setFocusPolicy( TabFocus );
    setPalettePropagation( AllChildren );
    setFontPropagation( AllChildren );
}


/*!
  Constructs a combo box with a maximum size and either Motif 2.0 or
  Windows look and feel.

  The input field can be edited if \a rw is TRUE, otherwise the user
  may only choose one of the items in the combo box.
*/



qt'QComboBox::QComboBox() (./qt-2.1.0/src/widgets/qcombobox.cpp:382)

QComboBox::QComboBox( bool rw, QWidget *parent, const char *name )
    : QWidget( parent, name, WResizeNoErase )
{
    d = new QComboData( this );
    d->setListBox( new QListBox( 0, "in-combo", WType_Popup ) );
    d->listBox()->setAutoScrollBar( FALSE );
    d->listBox()->setBottomScrollBar( FALSE );
    d->listBox()->setAutoBottomScrollBar( FALSE );
    d->listBox()->setFrameStyle( QFrame::Box | QFrame::Plain );
    d->listBox()->setLineWidth( 1 );
    d->listBox()->resize( 100, 10 );

    connect( d->listBox(), SIGNAL(selected(int)),
	     SLOT(internalActivate(int)) );
    connect( d->listBox(), SIGNAL(highlighted(int)),
	     SLOT(internalHighlight(int)));

    d->current = 0;
    d->maxCount = INT_MAX;
    setSizeLimit(10);
    d->p = AtBottom;
    d->autoresize = FALSE;
    d->poppedUp = FALSE;
    d->arrowDown = FALSE;
    d->discardNextMousePress = FALSE;
    d->shortClick = FALSE;
    d->useCompletion = FALSE;

    d->showTimer = new QTimer( this );
    connect( d->showTimer, SIGNAL( timeout() ),
	     this, SLOT( showMore() ) );

    setFocusPolicy( StrongFocus );

    if ( rw ) {
	d->ed = new QLineEdit( this, "combo edit" );
	connect (d->ed, SIGNAL( textChanged( const QString& ) ),
		 this, SIGNAL( textChanged( const QString& ) ) );
	d->ed->setFrame( FALSE );
	d->updateLinedGeometry();//ed->setGeometry(style().comboButtonRect( 0, 0, width(), height() ));
	d->ed->installEventFilter( this );
	setFocusProxy( d->ed );

	connect( d->ed, SIGNAL(returnPressed()), SLOT(returnPressed()) );
    } else {
	d->ed = 0;
    }
    setBackgroundMode( PaletteButton );
    setPalettePropagation( AllChildren );
    setFontPropagation( AllChildren );
}



/*!
  Destructs the combo box.
*/


qt'QComboBox::~QComboBox() (./qt-2.1.0/src/widgets/qcombobox.cpp:440)

QComboBox::~QComboBox()
{
    delete d;
}


/*!
  If the combobox is editable and the user enters some text in
  the lineedit of the combox and presses return (and the insertionPolicy()
  is different from \c NoInsertion), the entered text is inserted into the
  list of this combobox. Now, if you set \a enable to TRUE here,
  this new text is always inserted, else it's only inserted if it
  doesn't already exist in the list. If you set \a enable to FALSE
  and the text exists already in the list, the item which contains
  the same text like which should be inserted, this item
  gets the new current item.

  This setting only applies when the user want's to insert a text
  with pressing the return key. It does \em not affect methods like
  insertItem() and similar.
*/


qt'QComboBox::setDuplicatesEnabled() (./qt-2.1.0/src/widgets/qcombobox.cpp:462)

void QComboBox::setDuplicatesEnabled( bool enable )
{
   d->duplicatesEnabled = enable;
}

/*!
  Returns TRUE if the same text can be inserted multiple times
  into the list of the combobox, else FALSE.

  \sa setDuplicatesEnabled();
*/


qt'QComboBox::duplicatesEnabled() (./qt-2.1.0/src/widgets/qcombobox.cpp:474)

bool QComboBox::duplicatesEnabled() const
{
    return d->duplicatesEnabled;
}


/*!
  Returns the number of items in the combo box.
*/


qt'QComboBox::count() (./qt-2.1.0/src/widgets/qcombobox.cpp:484)

int QComboBox::count() const
{
    if ( d->usingListBox() )
	return d->listBox()->count();
    else
	return d->popup()->count();
}


/*!
  \overload
*/


qt'QComboBox::insertStrList() (./qt-2.1.0/src/widgets/qcombobox.cpp:497)

void QComboBox::insertStrList( const QStrList &list, int index )
{
    insertStrList( &list, index );
}

/*!
  Inserts the list of strings at the index \e index in the combo box.

  This is only for compatibility, as it does not support Unicode
  strings.  See insertStringList().
*/


qt'QComboBox::insertStrList() (./qt-2.1.0/src/widgets/qcombobox.cpp:509)

void QComboBox::insertStrList( const QStrList *list, int index )
{
    if ( !list ) {
#if defined(CHECK_NULL)
	ASSERT( list != 0 );
#endif
	return;
    }
    QStrListIterator it( *list );
    const char* tmp;
    if ( index < 0 )
	index = count();
    while ( (tmp=it.current()) ) {
	++it;
	if ( d->usingListBox() )
	    d->listBox()->insertItem( QString::fromLatin1(tmp), index );
	else
	    d->popup()->insertItem( QString::fromLatin1(tmp), index, index );
	if ( index++ == d->current && d->current < count() ) {
	    if ( d->ed ) {
		d->ed->setText( text( d->current ) );
		d->updateLinedGeometry();
	    } else
		update();
	    currentChanged();
	}
    }
    if ( index != count() )
	reIndex();
}

/*!
  Inserts the list of strings at the index \e index in the combo box.
*/


qt'QComboBox::insertStringList() (./qt-2.1.0/src/widgets/qcombobox.cpp:544)

void QComboBox::insertStringList( const QStringList &list, int index )
{
    QStringList::ConstIterator it = list.begin();
    if ( index < 0 )
	index = count();
    while ( it != list.end() ) {
	if ( d->usingListBox() )
	    d->listBox()->insertItem( *it, index );
	else
	    d->popup()->insertItem( *it, index, index );
	if ( index++ == d->current && d->current < count() ) {
	    if ( d->ed ) {
		d->ed->setText( text( d->current ) );
		d->updateLinedGeometry();
	    } else
		update();
	    currentChanged();
	}
	++it;
    }
    if ( index != count() )
	reIndex();
}

/*!
  Inserts the array of ASCII strings at the index \e index in the combo box.

  The \e numStrings argument is the number of strings.
  If \e numStrings is -1 (default), the \e strs array must be
  terminated with 0.

  Example:
  \code
    static const char* items[] = { "red", "green", "blue", 0 };
    combo->insertStrList( items );
  \endcode
*/


qt'QComboBox::insertStrList() (./qt-2.1.0/src/widgets/qcombobox.cpp:582)

void QComboBox::insertStrList( const char **strings, int numStrings, int index)
{
    if ( !strings ) {
#if defined(CHECK_NULL)
	ASSERT( strings != 0 );
#endif
	return;
    }
    if ( index < 0 )
	index = count();
    int i = 0;
    while ( (numStrings<0 && strings[i]!=0) || i<numStrings ) {
	if ( d->usingListBox() )
	    d->listBox()->insertItem( QString::fromLatin1(strings[i]), index );
	else
	    d->popup()->insertItem( QString::fromLatin1(strings[i]), index, index );
	i++;
	if ( index++ == d->current && d->current < count()  ) {
	    if ( d->ed ) {
		d->ed->setText( text( d->current ) );
		d->updateLinedGeometry();
	    } else
		update();
	    currentChanged();
	}
    }
    if ( index != count() )
	reIndex();
}


/*!
  Inserts a text item at position \e index. The item will be appended if
  \e index is negative.
*/


qt'QComboBox::insertItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:618)

void QComboBox::insertItem( const QString &t, int index )
{
    int cnt = count();
    if ( !checkInsertIndex( "insertItem", name(), cnt, &index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->insertItem( t, index );
    else
	d->popup()->insertItem( t, index, index );
    if ( index != cnt )
	reIndex();
    if ( index == d->current && d->current < count()  ) {
	if ( d->ed ) {
	    d->ed->setText( text( d->current ) );
	    d->updateLinedGeometry();
	} else
	    update();
    }
    if ( index == d->current )
	currentChanged();
}

/*!
  Inserts a pixmap item at position \e index. The item will be appended if
  \e index is negative.
*/


qt'QComboBox::insertItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:645)

void QComboBox::insertItem( const QPixmap &pixmap, int index )
{
    int cnt = count();
    if ( !checkInsertIndex( "insertItem", name(), cnt, &index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->insertItem( pixmap, index );
    else
	d->popup()->insertItem( pixmap, index, index );
    if ( index != cnt )
	reIndex();
    if ( index == d->current && d->current < count()  ) {
	if ( d->ed ) {
	    d->ed->setText( text( d->current ) );
	    d->updateLinedGeometry();
	} else
	    update();
    }
    if ( index == d->current )
	currentChanged();
}

/*!
  Inserts a pixmap item with additional text \a text at position \e
  index. The item will be appended if \e index is negative.
*/


qt'QComboBox::insertItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:672)

void QComboBox::insertItem( const QPixmap &pixmap, const QString& text, int index )
{
    int cnt = count();
    if ( !checkInsertIndex( "insertItem", name(), cnt, &index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->insertItem( pixmap, text, index );
    else
	d->popup()->insertItem( pixmap, text, index, index );
    if ( index != cnt )
	reIndex();
    if ( index == d->current && d->current < count()  ) {
	if ( d->ed ) {
	    d->ed->setText( this->text( d->current ) );
	    d->updateLinedGeometry();
	} else
	    update();
    }
    if ( index == d->current )
	currentChanged();
}


/*!
  Removes the item at position \e index.
*/


qt'QComboBox::removeItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:699)

void QComboBox::removeItem( int index )
{
    int cnt = count();
    if ( !checkIndex( "removeItem", name(), cnt, index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->removeItem( index );
    else
	d->popup()->removeItemAt( index );
    if ( index != cnt-1 )
	reIndex();
    if ( index == d->current ) {
	if ( d->ed ) {
	    QString s = QString::fromLatin1("");
	    if (d->current < cnt - 1)
		s = text( d->current );
	    d->ed->setText( s );
	    d->updateLinedGeometry();
	}
	else {
	    if ( d->usingListBox() )
		d->current = d->listBox()->currentItem();
	    else {
		if (d->current > count()-1 && d->current > 0)
		    d->current--;
	    }
	    update();
	}
	currentChanged();
    }
}


/*!
  Removes all combo box items.
*/


qt'QComboBox::clear() (./qt-2.1.0/src/widgets/qcombobox.cpp:736)

void QComboBox::clear()
{
    if ( d->usingListBox() )
	d->listBox()->clear();
    else
	d->popup()->clear();

    d->current = 0;
    if ( d->ed ) {
	d->ed->setText( QString::fromLatin1("") );
	d->updateLinedGeometry();
    }
    currentChanged();
}


/*!
  Returns the text item being edited, or the current text item if the combo
  box is not editable.
  \sa text()
*/


qt'QComboBox::currentText() (./qt-2.1.0/src/widgets/qcombobox.cpp:758)

QString QComboBox::currentText() const
{
    if ( d->ed )
	return d->ed->text();
    else if ( d->current < count() )
	return text( currentItem() );
    else
	return QString::null;
}


/*!
  Returns the text item at a given index, or
  \link QString::operator!() null string\endlink
  if the item is not a string.
  \sa currentText()
*/


qt'QComboBox::text() (./qt-2.1.0/src/widgets/qcombobox.cpp:776)

QString QComboBox::text( int index ) const
{
    if ( !checkIndex( "text", name(), count(), index ) )
	return QString::null;
    if ( d->usingListBox() )
	return d->listBox()->text( index );
    else
	return d->popup()->text( index );
}

/*!
  Returns the pixmap item at a given index, or 0 if the item is not a pixmap.
*/


qt'QComboBox::pixmap() (./qt-2.1.0/src/widgets/qcombobox.cpp:790)

const QPixmap *QComboBox::pixmap( int index ) const
{
    if ( !checkIndex( "pixmap", name(), count(), index ) )
	return 0;
    if ( d->usingListBox() )
	return d->listBox()->pixmap( index );
    else
	return d->popup()->pixmap( index );
}

/*!
  Replaces the item at position \e index with a text.
*/


qt'QComboBox::changeItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:804)

void QComboBox::changeItem( const QString &t, int index )
{
    if ( !checkIndex( "changeItem", name(), count(), index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->changeItem( t, index );
    else
	d->popup()->changeItem( t, index );
    if ( index == d->current && d->ed ) {
	d->ed->setText( text( d->current ) );
	d->updateLinedGeometry();
    }
}

/*!
  Replaces the item at position \e index with a pixmap, unless the
  combo box is writable.

  \sa insertItem()
*/


qt'QComboBox::changeItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:825)

void QComboBox::changeItem( const QPixmap &im, int index )
{
    if ( d->ed != 0 || !checkIndex( "changeItem", name(), count(), index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->changeItem( im, index );
    else
	d->popup()->changeItem( im, index );
}

/*!
  Replaces the item at position \e index with a pixmap plus text.
  If the combo box is writable, the pixmap is ignored.

  \sa insertItem()
*/


qt'QComboBox::changeItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:842)

void QComboBox::changeItem( const QPixmap &im, const QString &t, int index )
{
    if ( d->ed != 0 ) {
	changeItem( t, index );
	return;
    }
    if ( !checkIndex( "changeItem", name(), count(), index ) )
	return;
    if ( d->usingListBox() )
	d->listBox()->changeItem( im, t, index );
    else
	d->popup()->changeItem( im, t, index );
}


/*!
  Returns the index of the current combo box item.
  \sa setCurrentItem()
*/


qt'QComboBox::currentItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:862)

int QComboBox::currentItem() const
{
    return d->current;
}

/*!
  Sets the current combo box item.
  This is the item to be displayed on the combo box button.
  \sa currentItem()
*/


qt'QComboBox::setCurrentItem() (./qt-2.1.0/src/widgets/qcombobox.cpp:873)

void QComboBox::setCurrentItem( int index )
{
    if ( index == d->current && !d->ed ) {
	    return;
    }
    if ( !checkIndex( "setCurrentItem", name(), count(), index ) ) {
	return;
    }
    d->current = index;
    if ( d->ed ) {
	d->ed->setText( text( index ) );
	d->updateLinedGeometry();
    }
    if ( d->poppedUp ) {
	if ( d->usingListBox() && d->listBox() )
	    d->listBox()->setCurrentItem( index );
	else if ( d->popup() )
	    // the popup will soon send an override, but for the
	    // moment this is correct
	    internalHighlight( index );
    }
    currentChanged();
}


/*! \obsolete
  Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing is
  disabled.

  Auto-resizing is disabled by default.

  \sa setAutoResize()
*/


qt'QComboBox::autoResize() (./qt-2.1.0/src/widgets/qcombobox.cpp:907)

bool QComboBox::autoResize() const
{
    return d->autoresize;
}

/*! \obsolete
  Enables auto-resizing if \e enable is TRUE, or disables it if \e enable is
  FALSE.

  When auto-resizing is enabled, the combo box button will resize itself
  whenever the current combo box item change.

  \sa autoResize(), adjustSize()
*/


qt'QComboBox::setAutoResize() (./qt-2.1.0/src/widgets/qcombobox.cpp:922)

void QComboBox::setAutoResize( bool enable )
{
    if ( (bool)d->autoresize != enable ) {
	d->autoresize = enable;
	if ( enable )
	    adjustSize();
    }
}


/*!\reimp
*/

qt'QComboBox::sizeHint() (./qt-2.1.0/src/widgets/qcombobox.cpp:934)

QSize QComboBox::sizeHint() const
{
    constPolish();
    int i, w, h;
    QString tmp;
    QFontMetrics fm = fontMetrics();

    int maxW = count() ? 18 : 7 * fm.width(QChar('x')) + 18;
    int maxH = QMAX( fm.lineSpacing() + 2, 12 );

    for( i = 0; i < count(); i++ ) {
	if ( d->usingListBox() ) {
	    w = d->listBox()->item( i )->width( d->listBox() );
	    h = d->listBox()->item( i )->height( d->listBox() );
	}
	else {
	    h = d->popup()->itemHeight( i );
	    w = d->popup()->sizeHint().width() - 2* d->popup()->frameWidth();
	}
	if ( w > maxW )
	    maxW = w;
	if ( h > maxH )
	    maxH = h;
    }
    if ( maxH <= 17 && style() == WindowsStyle || parentWidget() &&
	 ( parentWidget()->inherits( "QToolBar" ) ||
	   parentWidget()->inherits( "QDialog" ) && d->ed ) )
	maxH = 12;

    int sw, sh;
    if ( d->usingListBox() ) {
	sw = 4 + 4 + maxW;
	sh = 5 + 5 + maxH;
	QRect cr = style().comboButtonRect( 0, 0, sw, sh );
	sw += sw - cr.width();
    } else {
	//hardcoded values for motif 1.x style
	int extraW = 20+5;
	sw = 4 + 4 + maxW + extraW;
	sh = 5 + 5 + maxH;
    }

    return QSize( sw, sh );
}


/*!\reimp
*/

qt'QComboBox::sizePolicy() (./qt-2.1.0/src/widgets/qcombobox.cpp:982)

QSizePolicy QComboBox::sizePolicy() const
{
    return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
}


/*!
  \internal
  Receives activated signals from an internal popup list and emits
  the activated() signal.
*/


qt'QComboBox::internalActivate() (./qt-2.1.0/src/widgets/qcombobox.cpp:994)

void QComboBox::internalActivate( int index )
{
    if ( d->current != index ) {
	d->current = index;
	currentChanged();
    }
    if ( d->usingListBox() )
	popDownListBox();
    else
	d->popup()->removeEventFilter( this );
    d->poppedUp = FALSE;

    QString t( text( index ) );
    if ( d->ed ) {
	d->ed->setText( t );
	d->updateLinedGeometry();
    }
    emit activated( index );
    emit activated( t );
}

/*!
  \internal
  Receives highlighted signals from an internal popup list and emits
  the highlighted() signal.
*/


qt'QComboBox::internalHighlight() (./qt-2.1.0/src/widgets/qcombobox.cpp:1021)

void QComboBox::internalHighlight( int index )
{
    emit highlighted( index );
    QString t = text( index );
    if ( !t.isNull() )
	emit highlighted( t );
}

/*!
  \internal
  Receives timeouts after a click. Used to decide if a Motif style
  popup should stay up or not after a click.
*/

qt'QComboBox::internalClickTimeout() (./qt-2.1.0/src/widgets/qcombobox.cpp:1034)

void QComboBox::internalClickTimeout()
{
    d->shortClick = FALSE;
}


/*!
  Reimplements QWidget::setBackgroundColor().

  Sets the background color for both the combo box button and the
  combo box popup list.
*/


qt'QComboBox::setBackgroundColor() (./qt-2.1.0/src/widgets/qcombobox.cpp:1047)

void QComboBox::setBackgroundColor( const QColor &color )
{
    QWidget::setBackgroundColor( color );
    if ( !d->usingListBox() )
	d->popup()->setBackgroundColor( color );
}

/*!
  Reimplements QWidget::setPalette().

  Sets the palette for both the combo box button and the
  combo box popup list.
*/


qt'QComboBox::setPalette() (./qt-2.1.0/src/widgets/qcombobox.cpp:1061)

void QComboBox::setPalette( const QPalette &palette )
{
    QWidget::setPalette( palette );
    if ( d->usingListBox() )
	d->listBox()->setPalette( palette );
    else
	d->popup()->setPalette( palette );
}

/*!
  Reimplements QWidget::setFont().

  Sets the font for both the combo box button and the
  combo box popup list.
*/


qt'QComboBox::setFont() (./qt-2.1.0/src/widgets/qcombobox.cpp:1077)

void QComboBox::setFont( const QFont &font )
{
    QWidget::setFont( font );
    if ( d->usingListBox() )
	d->listBox()->setFont( font );
    else
	d->popup()->setFont( font );
    if (d->ed)
	d->ed->setFont( font );
    if ( d->autoresize )
	adjustSize();
}


/*!\reimp
*/


qt'QComboBox::resizeEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1094)

void QComboBox::resizeEvent( QResizeEvent * e )
{
    if ( d->ed ) {
	d->updateLinedGeometry();
	//d->ed->setGeometry(style().comboButtonRect( 0, 0, width(), height() ));
    }
    QWidget::resizeEvent( e );
}

/*!\reimp
*/


qt'QComboBox::paintEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1106)

void QComboBox::paintEvent( QPaintEvent * )
{
    QPainter p( this );
    const QColorGroup & g = colorGroup();

    if ( width() < 5 || height() < 5 ) {
	qDrawShadePanel( &p, rect(), g, FALSE, 2,
			 &g.brush( QColorGroup::Button ) );
	return;
    }

    if ( !d->usingListBox() ) {			// motif 1.x style
	int dist, buttonH, buttonW;
	getMetrics( &dist, &buttonW, &buttonH );
	int xPos = width() - dist - buttonW - 1;
	qDrawShadePanel( &p, rect(), g, FALSE, style().defaultFrameWidth(),
			 &g.brush( QColorGroup::Button ) );
	qDrawShadePanel( &p, xPos, (height() - buttonH)/2,
			 buttonW, buttonH, g, FALSE, style().defaultFrameWidth() );
	QRect clip( 4, 2, xPos - 2 - 4 - 5, height() - 4 );
	QString str = d->popup()->text( this->d->current );
	if ( !str.isNull() ) {
	    p.drawText( clip, AlignCenter | SingleLine, str );
	} else {
	    QPixmap *pix = d->popup()->pixmap( this->d->current );
	    if ( pix ) {
		p.setClipRect( clip );
		p.drawPixmap( 4, (height()-pix->height())/2, *pix );
		p.setClipping( FALSE );
	    }
	}

	if ( hasFocus() )
	    p.drawRect( xPos - 5, 4, width() - xPos + 1 , height() - 8 );

    } else if ( style() == MotifStyle ) {	// motif 2.0 style
	style().drawComboButton( &p, 0, 0, width(), height(),
				 g, d->arrowDown, d->ed != 0 );
       	if ( hasFocus() ) {
	    style().drawFocusRect(&p, style().
				  comboButtonFocusRect(0,0,width(),height()),
				  g, &g.button());
	}
	if ( !d->ed ) {
	    QRect clip = style().comboButtonRect( 0, 0, width(), height() );
	    QString str = d->listBox()->text( d->current );
	    p.setPen( g.foreground() );
	    p.setClipRect( clip );
	    p.setPen( g.foreground() );
	    QListBoxItem * item = d->listBox()->item( d->current );
	    if ( item ) {
		int itemh = item->height( d->listBox() );
		p.translate( clip.x(), clip.y() + (clip.height() - itemh)/2  );
		item->paint( &p );
	    }
	} else if ( d->listBox() && d->listBox()->item( d->current ) ) {
	    QRect r( style().comboButtonRect( 0, 0, width(), height() ) );
	    QListBoxItem * item = d->listBox()->item( d->current );
	    const QPixmap *pix = item->pixmap();
	    if ( pix ) {
		p.fillRect( r.x(), r.y(), pix->width() + 4, r.height(), colorGroup().brush( QColorGroup::Base ) );
		p.drawPixmap( r.x() + 2, r.y() + ( r.height() - pix->height() ) / 2, *pix );
	    }
	}
	p.setClipping( FALSE );
    } else {					// windows 95 style
	style().drawComboButton(&p, 0, 0, width(), height(), g, d->arrowDown, d->ed != 0);

	QRect tmpR = style().comboButtonRect(0,0,width(),height());
	QRect textR(tmpR.x()+1, tmpR.y()+1, tmpR.width()-2, tmpR.height()-2);

	if ( hasFocus()) {
	    if (!d->ed) {
		p.fillRect( textR.x(), textR.y(),
			    textR.width(), textR.height(),
			    g.brush( QColorGroup::Highlight ) );

	    }
	    style().drawFocusRect(&p, style().comboButtonFocusRect(0,0,width(),height()), g, &g.highlight());
	}

	textR.setRect(tmpR.x()+2, tmpR.y()+1, tmpR.width()-4, tmpR.height()-2);
	p.setClipRect( textR );

	if ( hasFocus() ) {
	    p.setPen( g.highlightedText() );
	    p.setBackgroundColor( g.highlight() );
	} else {
	    p.setPen( g.text() );
	    p.setBackgroundColor( g.background() );
	}
	if ( !d->ed ) {
	    QListBoxItem * item = d->listBox()->item( d->current );
	    if ( item ) {
		int itemh = item->height( d->listBox() );
		p.translate( textR.x(), textR.y() + (textR.height() - itemh)/2  );
		item->paint( &p );
	    }
	} else if ( d->listBox() && d->listBox()->item( d->current ) ) {
	    p.setClipping( FALSE );
	    QRect r( style().comboButtonRect( 0, 0, width(), height() ) );
	    QListBoxItem * item = d->listBox()->item( d->current );
	    const QPixmap *pix = item->pixmap();
	    if ( pix ) {
		p.fillRect( r.x(), r.y(), pix->width() + 4, r.height(), colorGroup().brush( QColorGroup::Base ) );
		p.drawPixmap( r.x() + 2, r.y() + ( r.height() - pix->height() ) / 2, *pix );
	    }
	}
	p.setClipping( FALSE );
    }
}


/*!
  \internal
  Returns the button arrow rectangle for windows style combo boxes.
*/

qt'QComboBox::arrowRect() (./qt-2.1.0/src/widgets/qcombobox.cpp:1223)

QRect QComboBox::arrowRect() const
{
    return QRect( width() - 2 - 16, 2, 16, height() - 4 );
}


/*!\reimp
*/


qt'QComboBox::mousePressEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1232)

void QComboBox::mousePressEvent( QMouseEvent *e )
{
    if ( d->discardNextMousePress ) {
	d->discardNextMousePress = FALSE;
	return;
    }
    if ( count() ) {
	d->arrowPressed = FALSE;
	if ( style() == WindowsStyle ) {
	    popup();
	    if ( arrowRect().contains( e->pos() ) ) {
		d->arrowPressed = TRUE;
		d->arrowDown    = TRUE;
		repaint( FALSE );
	    }
	} else if ( d->usingListBox() ) {
	    popup();
	    QTimer::singleShot( 200, this, SLOT(internalClickTimeout()));
	    d->shortClick = TRUE;
	} else {
	    popup();
	    QTimer::singleShot( 200, this, SLOT(internalClickTimeout()));
	    d->shortClick = TRUE;
	}
    }
}

/*!\reimp
*/


qt'QComboBox::mouseMoveEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1262)

void QComboBox::mouseMoveEvent( QMouseEvent * )
{
}

/*!\reimp
*/


qt'QComboBox::mouseReleaseEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1269)

void QComboBox::mouseReleaseEvent( QMouseEvent * )
{
}

/*!\reimp
*/


qt'QComboBox::mouseDoubleClickEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1276)

void QComboBox::mouseDoubleClickEvent( QMouseEvent *e )
{
    mousePressEvent( e );
}


/*!\reimp
*/


qt'QComboBox::keyPressEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1285)

void QComboBox::keyPressEvent( QKeyEvent *e )
{
    int c;
    if ( ( e->key() == Key_F4 && e->state() == 0 ) ||
	 ( e->key() == Key_Down && (e->state() & AltButton) ) ||
	 ( !d->ed && e->key() == Key_Space ) ) {
	if ( count() ) {
	    if ( !d->usingListBox() )
		d->popup()->setActiveItem( this->d->current );
	    popup();
	}
	return;
    } else if ( d->usingListBox() && e->key() == Key_Up ) {
	c = currentItem();
	if ( c > 0 )
	    setCurrentItem( c-1 );
	else
	    setCurrentItem( count()-1 );
    } else if ( d->usingListBox() && e->key() == Key_Down ) {
	c = currentItem();
	if ( ++c < count() )
	    setCurrentItem( c );
	else
	    setCurrentItem( 0 );
    } else {
	e->ignore();
	return;
    }

    c = currentItem();
    if ( !text( c ).isNull() )
	emit activated( text( c ) );
    emit highlighted( c );
    emit activated( c );
}


/*!\reimp
*/


qt'QComboBox::focusInEvent() (./qt-2.1.0/src/widgets/qcombobox.cpp:1325)

void QComboBox::focusInEvent( QFocusEvent * e )
{
    QWidget::focusInEvent( e );
}

/*!
  \internal
   Calculates the listbox height needed to contain all items, or as
   many as the list box is supposed to contain.
*/

qt'QComboBox::popup() (./qt-2.1.0/src/widgets/qcombobox.cpp:1350)

void QComboBox::popup()
{
    if ( !count() )
	return;

    if ( d->usingListBox() ) {
			// Send all listbox events to eventFilter():
	d->listBox()->installEventFilter( this );
	d->listBox()->viewport()->installEventFilter( this );
	d->mouseWasInsidePopup = FALSE;
	d->listBox()->resize( width(),
			    listHeight( d->listBox(), d->sizeLimit ) + 2 );
	QWidget *desktop = QApplication::desktop();
	int sw = desktop->width();			// screen width
	int sh = desktop->height();			// screen height
	QPoint pos = mapToGlobal( QPoint(0,height()) );

	// ### Similar code is in QPopupMenu
	int x = pos.x();
	int y = pos.y();
	int w = d->listBox()->width();
	int h = d->listBox()->height();

	// the complete widget must be visible
	if ( x + w > sw )
	    x = sw - w;
	else if ( x < 0 )
	    x = 0;
	if (y + h > sh && y - h - height() >= 0 )
	    y = y - h - height();

	d->listBox()->move( x,y );
	d->listBox()->raise();
	d->listBox()->blockSignals( TRUE );
	d->listBox()->setCurrentItem( d->listBox()->item( d->current ) );
	d->listBox()->blockSignals( FALSE );
	d->listBox()->setAutoScrollBar( TRUE );
#ifdef ANIMATED_COMBO
	d->fullHeight = d->listBox()->height();
	d->currHeight = 0;
	d->listBox()->resize( d->listBox()->width(), 0 );
	d->listBox()->show();
	d->listBox()->setVScrollBarMode( QScrollView::AlwaysOff );
	d->showTimer->start( 2 );
#else
	d->listBox()->show();
#endif
    } else {
	d->popup()->installEventFilter( this );
	d->popup()->popup( mapToGlobal( QPoint(0,0) ), this->d->current );
    }
    d->poppedUp = TRUE;
}


/*!
  \reimp
*/

qt'QComboBox::updateMask() (./qt-2.1.0/src/widgets/qcombobox.cpp:1408)

void QComboBox::updateMask()
{
    QBitmap bm( size() );
    bm.fill( color0 );

    {
	QPainter p( &bm, this );
	p.setPen( color1 );
	p.setBrush( color1 );
	style().drawComboButtonMask(&p, 0, 0, width(), height() );
    }
    setMask( bm );
}

/*!
  \internal
  Pops down (removes) the combo box popup list box.
*/

qt'QComboBox::popDownListBox() (./qt-2.1.0/src/widgets/qcombobox.cpp:1426)

void QComboBox::popDownListBox()
{
    ASSERT( d->usingListBox() );
    d->listBox()->removeEventFilter( this );
    d->listBox()->viewport()->removeEventFilter( this );
    d->listBox()->hide();
    d->listBox()->setCurrentItem( d->current );
    if ( d->arrowDown ) {
	d->arrowDown = FALSE;
	repaint( FALSE );
    }
    d->poppedUp = FALSE;
}


/*!
  \internal
  Re-indexes the identifiers in the popup list.
*/


qt'QComboBox::reIndex() (./qt-2.1.0/src/widgets/qcombobox.cpp:1446)

void QComboBox::reIndex()
{
    if ( !d->usingListBox() ) {
	int cnt = count();
	while ( cnt-- )
	    d->popup()->setId( cnt, cnt );
    }
}

/*!
  \internal
  Repaints the combo box.
*/


qt'QComboBox::currentChanged() (./qt-2.1.0/src/widgets/qcombobox.cpp:1460)

void QComboBox::currentChanged()
{
    if ( d->autoresize )
	adjustSize();
    update();
}

/*! \reimp

  \internal

  The event filter steals events from the popup or listbox when they
  are popped up. It makes the popup stay up after a short click in
  motif style. In windows style it toggles the arrow button of the
  combo box field, and activates an item and takes down the listbox
  when the mouse button is released.
*/


qt'QComboBox::eventFilter() (./qt-2.1.0/src/widgets/qcombobox.cpp:1478)

bool QComboBox::eventFilter( QObject *object, QEvent *event )
{
    if ( !event )
	return TRUE;
    else if ( object == d->ed ) {
	if ( event->type() == QEvent::KeyPress ) {
	    keyPressEvent( (QKeyEvent *)event );
	    if ( ((QKeyEvent *)event)->isAccepted() ) {
		d->completeNow = FALSE;
		return TRUE;
	    } else if ( ((QKeyEvent *)event)->key() != Key_End ) {
		d->completeNow = TRUE;
		d->completeAt = d->ed->cursorPosition();
	    }
	} else if ( event->type() == QEvent::KeyRelease ) {
	    d->completeNow = FALSE;
	    keyReleaseEvent( (QKeyEvent *)event );
	    return ((QKeyEvent *)event)->isAccepted();
	} else if ( (event->type() == QEvent::FocusIn ||
		     event->type() == QEvent::FocusOut ) ) {
	    d->completeNow = FALSE;
	    // to get the focus indication right
	    update();
	} else if ( d->useCompletion && d->completeNow ) {
	    if ( !d->ed->text().isNull() &&
		 d->ed->cursorPosition() > d->completeAt &&
		 d->ed->cursorPosition() == (int)d->ed->text().length() ) {
		d->completeNow = FALSE;
		QString ct( d->ed->text() );
		QString it;
		int i =0;
		int foundAt = -1;
		int foundLength = 100000; // lots
		while( i<count() ) {
		    it = text( i );
		    if ( it.length() >= ct.length() ) {
			it.truncate( ct.length() );
			int itlen = text( i ).length();
			if ( it == ct && itlen < foundLength ) {
			    foundAt = i;
			    foundLength = text( i ).length();
			}
		    }
		    i++;
		}
		if ( foundAt > -1 ) {
		    it = text( foundAt );
		    d->ed->validateAndSet( it, ct.length(),
					   ct.length(), it.length() );
		}
	    }
	}
    } else if ( d->usingListBox() && ( object == d->listBox() ||
				       object == d->listBox()->viewport() )) {
	QMouseEvent *e = (QMouseEvent*)event;
	switch( event->type() ) {
	case QEvent::MouseMove:
	    if ( !d->mouseWasInsidePopup  ) {
		QPoint pos = e->pos();
		if ( d->listBox()->rect().contains( pos ) )
		    d->mouseWasInsidePopup = TRUE;
		// Check if arrow button should toggle
		// this applies only to windows style
		if ( d->arrowPressed ) {
		    QPoint comboPos;
		    comboPos = mapFromGlobal( d->listBox()->mapToGlobal(pos) );
		    if ( arrowRect().contains( comboPos ) ) {
			if ( !d->arrowDown  ) {
			    d->arrowDown = TRUE;
			    repaint( FALSE );
			}
		    } else {
			if ( d->arrowDown  ) {
			    d->arrowDown = FALSE;
			    repaint( FALSE );
			}
		    }
		}
	    } else if ((e->state() & ( RightButton | LeftButton | MidButton ) )
		       == 0 && style() == WindowsStyle ){
		QWidget *mouseW = QApplication::widgetAt( e->globalPos(), TRUE );
		if ( mouseW == d->listBox()->viewport() ) { //###
		    QMouseEvent m( QEvent::MouseMove, e->pos(), e->globalPos(),
				   0, LeftButton );
		    QApplication::sendEvent( object, &m ); //### Evil
		    return TRUE;
		}
	    }

	    break;
	case QEvent::MouseButtonRelease:
	    if ( d->listBox()->rect().contains( e->pos() ) ) {
		QMouseEvent tmp( QEvent::MouseButtonDblClick,
				 e->pos(), e->button(), e->state() ) ;
		// will hide popup
		QApplication::sendEvent( object, &tmp );
		return TRUE;
	    } else {
		if ( d->mouseWasInsidePopup ) {
		    popDownListBox();
		} else {
		    d->arrowPressed = FALSE;
		    if ( d->arrowDown  ) {
			d->arrowDown = FALSE;
			repaint( FALSE );
		    }
		}
	    }
	    break;
	case QEvent::MouseButtonDblClick:
	case QEvent::MouseButtonPress:
	    if ( !d->listBox()->rect().contains( e->pos() ) ) {
		QPoint globalPos = d->listBox()->mapToGlobal(e->pos());
		if ( QApplication::widgetAt( globalPos, TRUE ) == this ) {
		    d->discardNextMousePress = TRUE;
		    // avoid popping up again
		}
		popDownListBox();
		return TRUE;
	    }
	    break;
	case QEvent::KeyPress:
	    switch( ((QKeyEvent *)event)->key() ) {
	    case Key_Up:
	    case Key_Down:
		if ( !(((QKeyEvent *)event)->state() & AltButton) )
		    break;
	    case Key_F4:
	    case Key_Escape:
		if ( d->poppedUp ) {
		    popDownListBox();
		    return TRUE;
		}
		break;
	    case Key_Enter:
	    case Key_Return:
		// work around QDialog's enter handling
		return FALSE;
	    default:
		break;
	    }
	default:
	    break;
	}
    } else if ( !d->usingListBox() && object == d->popup() ) {
	QMouseEvent *e = (QMouseEvent*)event;
	switch ( event->type() ) {
	case QEvent::MouseButtonRelease:
	    if ( d->shortClick ) {
		QMouseEvent tmp( QEvent::MouseMove,
				 e->pos(), e->button(), e->state() ) ;
		// highlight item, but don't pop down:
		QApplication::sendEvent( object, &tmp );
		return TRUE;
	    }
	    break;
	case QEvent::MouseButtonDblClick:
	case QEvent::MouseButtonPress:
	    if ( !d->popup()->rect().contains( e->pos() ) ) {
		// remove filter, event will take down popup:
		d->popup()->removeEventFilter( this );
		// ### uglehack!
		// call internalHighlight so the highlighed signal
		// will be emitted at least as often as necessary.
		// it may be called more often than necessary
		internalHighlight( d->current );
	    }
	    break;
	default:
	    break;
	}
    }
    return QWidget::eventFilter( object, event );
}


/*!
  Returns the current maximum on-screen size of the combo box.  The
  default is ten lines.

  \sa setSizeLimit() count() maxCount()
*/


qt'QComboBox::sizeLimit() (./qt-2.1.0/src/widgets/qcombobox.cpp:1661)

int QComboBox::sizeLimit() const
{
    return d ? d->sizeLimit : INT_MAX;
}


/*!

  Sets the maximum on-screen size of the combo box to \a lines.  This
  is disregarded in Motif 1.x style.  The default limit is ten lines.

  If the number of items in the combo box is/grows larger than
  \c lines, a list box is added.

  \sa sizeLimit() count() setMaxCount()
*/


qt'QComboBox::setSizeLimit() (./qt-2.1.0/src/widgets/qcombobox.cpp:1678)

void QComboBox::setSizeLimit( int lines )
{
    d->sizeLimit = lines;
}



/*!
  Returns the current maximum size of the combo box.  By default,
  there is no limit, so this function returns INT_MAX.

  \sa setMaxCount() count()
*/


qt'QComboBox::maxCount() (./qt-2.1.0/src/widgets/qcombobox.cpp:1692)

int QComboBox::maxCount() const
{
    return d ? d->maxCount : INT_MAX;
}


/*!
  Sets the maximum number of items the combo box can hold to \a count.

  If \a count is smaller than the current number of items, the list is
  truncated at the end.  There is no limit by default.

  \sa maxCount() count()
*/


qt'QComboBox::setMaxCount() (./qt-2.1.0/src/widgets/qcombobox.cpp:1707)

void QComboBox::setMaxCount( int count )
{
    int l = this->count();
    while( --l > count )
	removeItem( l );
    d->maxCount = count;
}

/*!
  Returns the current insertion policy of the combo box.

  \sa setInsertionPolicy()
*/

QComboBox::Policy QComboBox::insertionPolicy() const
{
    return d->p;
}


/*!
  Sets the insertion policy of the combo box to \a policy.

  The insertion policy governs where items typed in by the user are
  inserted in the list.  The possible values are <ul> <li> \c
  NoInsertion: Strings typed by the user aren't inserted anywhere <li>
  \c AtTop: Strings typed by the user are inserted above the top item
  in the list <li> AtCurrent: Strings typed by the user replace the
  last selected item <li> AtBottom: Strings typed by the user are
  inserted at the bottom of the list. </ul>

  The default insertion policy is \c AtBottom.

  \sa insertionPolicy()
*/


qt'QComboBox::setInsertionPolicy() (./qt-2.1.0/src/widgets/qcombobox.cpp:1743)

void QComboBox::setInsertionPolicy( Policy policy )
{
    d->p = policy;
}



/*!
  Internal slot to keep the line editor up to date.
*/


qt'QComboBox::returnPressed() (./qt-2.1.0/src/widgets/qcombobox.cpp:1754)

void QComboBox::returnPressed()
{
    QString s( d->ed->text() );
    int c = 0;
    switch ( insertionPolicy() ) {
    case AtCurrent:
	if ( s != text( currentItem() ) )
	    changeItem( s, currentItem() );
	emit activated( currentItem() );
	emit activated( s );
	return;
    case NoInsertion:
	emit activated( s );
	return;
    case AtTop:
	c = 0;
	break;
    case AtBottom:
	c = count();
	break;
    case BeforeCurrent:
	c = currentItem();
	break;
    case AfterCurrent:
	c = currentItem() + 1;
	break;
    }
    if ( count() == d->maxCount )
	removeItem( count() - 1 );

    bool doInsert = TRUE;
    if ( !d->duplicatesEnabled ) {
	for ( int i = 0; i < count(); ++i ) {
	    if ( s == text( i ) ) {
		doInsert = FALSE;
		c = i;
		break;
	    }
	}
    }

    if ( doInsert )
	insertItem( s, c );
    setCurrentItem( c );
    emit activated( c );
    emit activated( s );
}


/*! \reimp
*/


qt'QComboBox::setEnabled() (./qt-2.1.0/src/widgets/qcombobox.cpp:1806)

void QComboBox::setEnabled( bool enable )
{
    QWidget::setEnabled( enable );
}



/*!  Sets this combo box to be editable only as allowed by \a v.

  This function does nothing if the combo is not editable.

  \sa validator() clearValidator() QValidator
*/


qt'QComboBox::setValidator() (./qt-2.1.0/src/widgets/qcombobox.cpp:1820)

void QComboBox::setValidator( const QValidator * v )
{
    if ( d && d->ed )
	d->ed->setValidator( v );
}


/*!  Returns the validator which constrains editing for this combo
  box if there is any, or else 0.

  \sa setValidator() clearValidator() QValidator
*/


qt'QComboBox::validator() (./qt-2.1.0/src/widgets/qcombobox.cpp:1833)

const QValidator * QComboBox::validator() const
{
    return d && d->ed ? d->ed->validator() : 0;
}


/*!  This slot is equivalent to setValidator( 0 ). */


qt'QComboBox::clearValidator() (./qt-2.1.0/src/widgets/qcombobox.cpp:1841)

void QComboBox::clearValidator()
{
    if ( d && d->ed )
	d->ed->setValidator( 0 );
}


/*!  Sets the combo box to use \a newListBox instead of the current
  list box or popup.  As a site effect, clears the combo box of its
  current contents.

  \warning QComboBox assumes that newListBox->text(n) returns
  non-null for 0 \<= n \< newListbox->count().  This assumption is
  necessary because of the line edit in QComboBox.
*/


qt'QComboBox::setListBox() (./qt-2.1.0/src/widgets/qcombobox.cpp:1857)

void QComboBox::setListBox( QListBox * newListBox )
{
    clear();

    if ( d->usingListBox() )
	delete d->listBox();
    else
	delete d->popup();

    newListBox->reparent( 0, WType_Popup, QPoint(0,0), FALSE );
    d->setListBox( newListBox );

    d->listBox()->setAutoScrollBar( FALSE );
    d->listBox()->setBottomScrollBar( FALSE );
    d->listBox()->setAutoBottomScrollBar( FALSE );
    d->listBox()->setFrameStyle( QFrame::Box | QFrame::Plain );
    d->listBox()->setLineWidth( 1 );
    d->listBox()->resize( 100, 10 );

    connect( d->listBox(), SIGNAL(selected(int)),
	     SLOT(internalActivate(int)) );
    connect( d->listBox(), SIGNAL(highlighted(int)),
	     SLOT(internalHighlight(int)));
}


/*!  Returns the current list box, or 0 if there is no list box
  currently.  (QComboBox can use QPopupMenu instead of QListBox.)
  Provided to match setListBox().

  \sa setListBox()
*/


qt'QComboBox::listBox() (./qt-2.1.0/src/widgets/qcombobox.cpp:1890)

QListBox * QComboBox::listBox() const
{
    return d && d->usingListBox() ? d->listBox() : 0;
}

/*!
  Returns the line editor, or 0 if there is no line editor currently.

  Only editable listboxes have a line editor.
 */

qt'QComboBox::lineEdit() (./qt-2.1.0/src/widgets/qcombobox.cpp:1900)

QLineEdit* QComboBox::lineEdit() const
{
    return d->ed;
}



/*!  Clears the line edit without changing the combo's contents.  Does
  nothing if the combo isn't editable.

  This is particularly handy when using a combo box as a line edit
  with history.  For example you can connect the combo's activated()
  signal to clearEdit() in order to present the user with a new, empty
  line as soon as return is pressed.

  \sa setEditText()
*/


qt'QComboBox::clearEdit() (./qt-2.1.0/src/widgets/qcombobox.cpp:1918)

void QComboBox::clearEdit()
{
    if ( d && d->ed )
	d->ed->clear();
}


/*!  Sets the text in the embedded line edit to \a newText without
  changing the combo's contents.  Does nothing if the combo isn't
  editable.

  This is useful e.g. for providing a good starting point for the
  user's editing and entering the change in the combo only when the
  user presses enter.

  \sa clearEdit() insertItem()
*/


qt'QComboBox::setEditText() (./qt-2.1.0/src/widgets/qcombobox.cpp:1936)

void QComboBox::setEditText( const QString &newText )
{
    if ( d && d->ed ) {
	d->updateLinedGeometry();
	d->ed->setText( newText );
    }
}


/*!  Sets this combo box to offer auto-completion while the user is
  editing if \a enable is TRUE, or not to offer auto-completion of \a
  enable is FALSE (the default).

  The combo box uses the list of items as candidates for completion.

  \sa autoCompletion() setEditText()
*/


qt'QComboBox::setAutoCompletion() (./qt-2.1.0/src/widgets/qcombobox.cpp:1954)

void QComboBox::setAutoCompletion( bool enable )
{
    d->useCompletion = enable && (d->ed != 0);
    d->completeNow = FALSE;
}


/*!  Returns TRUE if this combo box is in auto-completion mode.

  \sa setAutoCompletion()
*/


qt'QComboBox::autoCompletion() (./qt-2.1.0/src/widgets/qcombobox.cpp:1966)

bool QComboBox::autoCompletion() const
{
    return d->useCompletion;
}

/*!\reimp
 */

qt'QComboBox::styleChange() (./qt-2.1.0/src/widgets/qcombobox.cpp:1973)

void QComboBox::styleChange( QStyle& s )
{
    if ( d->ed )
	d->updateLinedGeometry();
    //d->ed->setGeometry(style().comboButtonRect( 0, 0, width(), height() ));
    QWidget::styleChange( s );
}

/*!
  \internal
*/


qt'QComboBox::showMore() (./qt-2.1.0/src/widgets/qcombobox.cpp:1985)

void QComboBox::showMore()
{
    if ( !d->listBox() )
	return;
    d->currHeight += 10;
    if ( d->currHeight > d->fullHeight )
	d->currHeight = d->fullHeight;
    d->listBox()->resize( d->listBox()->width(), d->currHeight );
    if ( d->currHeight == d->fullHeight ) {
	d->listBox()->setVScrollBarMode( QScrollView::Auto );
	d->showTimer->stop();
    }
}