diff options
Diffstat (limited to 'src/widgets/tqcombobox.cpp')
| -rw-r--r-- | src/widgets/tqcombobox.cpp | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/src/widgets/tqcombobox.cpp b/src/widgets/tqcombobox.cpp index 278b555e6..b5c2593f0 100644 --- a/src/widgets/tqcombobox.cpp +++ b/src/widgets/tqcombobox.cpp @@ -89,8 +89,8 @@ The other constructor creates a new-style combobox in Motif style, and can create both read-only and editable comboboxes: \code - TQComboBox *c1 = new TQComboBox( FALSE, this, "read-only combobox" ); - TQComboBox *c2 = new TQComboBox( TRUE, this, "editable combobox" ); + TQComboBox *c1 = new TQComboBox( false, this, "read-only combobox" ); + TQComboBox *c2 = new TQComboBox( true, this, "editable combobox" ); \endcode New-style comboboxes use a list box in both Motif and Windows @@ -247,7 +247,7 @@ \brief whether auto-completion is enabled This property can only be set for editable comboboxes, for - non-editable comboboxes it has no effect. It is FALSE by default. + non-editable comboboxes it has no effect. It is false by default. */ /*! @@ -261,8 +261,8 @@ \brief whether auto resize is enabled \obsolete - If this property is set to TRUE then the combobox will resize itself - whenever its contents change. The default is FALSE. + If this property is set to true then the combobox will resize itself + whenever its contents change. The default is false. */ /*! @@ -293,9 +293,9 @@ is not \c NoInsertion), then what happens is this: \list \i If the text is not already in the list, the text is inserted. - \i If the text is in the list and this property is TRUE (the + \i If the text is in the list and this property is true (the default), the text is inserted. - \i If the text is in the list and this property is FALSE, the text + \i If the text is in the list and this property is false, the text is \e not inserted; instead the item which has matching text becomes the current item. \endlist @@ -309,8 +309,8 @@ \property TQComboBox::editable \brief whether the combobox is editable - This property's default is FALSE. Note that the combobox will be - cleared if this property is set to TRUE for a 1.x Motif style + This property's default is false. Note that the combobox will be + cleared if this property is set to true for a 1.x Motif style combobox. To avoid this, use setEditable() before inserting any items. Also note that the 1.x version of Motif didn't have any editable comboboxes, so the combobox will change it's appearance @@ -365,7 +365,7 @@ class TQComboBoxPopupItem : public TQCustomMenuItem TQSize sc; // Size cache optimization public: TQComboBoxPopupItem(TQListBoxItem *i) : TQCustomMenuItem(), li(i), sc(0, 0) { } - virtual bool fullSpan() const { return TRUE; } + virtual bool fullSpan() const { return true; } virtual void paint( TQPainter*, const TQColorGroup&, bool, bool, int, int, int, int); virtual TQSize sizeHint() { if (sc.isNull()) sc = TQSize(li->width(li->listBox()), TQMAX(25, li->height(li->listBox()))); return sc; } }; @@ -382,9 +382,9 @@ void TQComboBoxPopupItem::paint( TQPainter* p, const TQColorGroup&, bool, class TQComboBoxData { public: - TQComboBoxData( TQComboBox *cb ): ed( 0 ), usingLBox( FALSE ), pop( 0 ), lBox( 0 ), combo( cb ) + TQComboBoxData( TQComboBox *cb ): ed( 0 ), usingLBox( false ), pop( 0 ), lBox( 0 ), combo( cb ) { - duplicatesEnabled = TRUE; + duplicatesEnabled = true; cb->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ) ); } @@ -393,7 +393,7 @@ public: inline TQComboBoxPopup * popup() { return pop; } void updateLinedGeometry(); void setListBox( TQListBox *l ); - void setPopupMenu( TQComboBoxPopup * pm, bool isPopup=TRUE ); + void setPopupMenu( TQComboBoxPopup * pm, bool isPopup=true ); int current; int maxCount; @@ -442,8 +442,8 @@ void TQComboBoxData::updateLinedGeometry() void TQComboBoxData::setListBox( TQListBox *l ) { lBox = l; - usingLBox = TRUE; - l->setMouseTracking( TRUE ); + usingLBox = true; + l->setMouseTracking( true ); #ifdef TQ_WS_X11 l->x11SetWindowType( TQWidget::X11WindowTypeCombo ); l->x11SetWindowTransient( combo->topLevelWidget()); @@ -454,7 +454,7 @@ void TQComboBoxData::setPopupMenu( TQComboBoxPopup * pm, bool isPopup ) { pop = pm; if(isPopup) - usingLBox = FALSE; + usingLBox = false; #ifdef TQ_WS_X11 if( pm ) { pm->x11SetWindowType( TQWidget::X11WindowTypeCombo ); @@ -533,15 +533,15 @@ TQComboBox::TQComboBox( TQWidget *parent, const char *name ) d->maxCount = INT_MAX; d->sizeLimit = 10; d->p = AtBottom; - d->autoresize = FALSE; - d->poppedUp = FALSE; - d->arrowDown = FALSE; - d->arrowPressed = FALSE; - d->discardNextMousePress = FALSE; - d->shortClick = FALSE; - d->useCompletion = FALSE; + d->autoresize = false; + d->poppedUp = false; + d->arrowDown = false; + d->arrowPressed = false; + d->discardNextMousePress = false; + d->shortClick = false; + d->useCompletion = false; d->completeAt = 0; - d->completeNow = FALSE; + d->completeNow = false; d->completionTimer = new TQTimer( this ); setFocusPolicy( TabFocus ); @@ -553,7 +553,7 @@ TQComboBox::TQComboBox( TQWidget *parent, const char *name ) Constructs a combobox 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 + The input field can be edited if \a rw is true, otherwise the user may only choose one of the items in the combobox. The \a parent and \a name arguments are passed on to the TQWidget @@ -568,19 +568,19 @@ TQComboBox::TQComboBox( bool rw, TQWidget *parent, const char *name ) setUpListBox(); if(d->popup() && style().styleHint(TQStyle::SH_ComboBox_Popup, this)) - d->popup()->setItemChecked(d->current, FALSE); + d->popup()->setItemChecked(d->current, false); 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->autoresize = false; + d->poppedUp = false; + d->arrowDown = false; + d->discardNextMousePress = false; + d->shortClick = false; + d->useCompletion = false; d->completeAt = 0; - d->completeNow = FALSE; + d->completeNow = false; d->completionTimer = new TQTimer( this ); setFocusPolicy( StrongFocus ); @@ -905,7 +905,7 @@ void TQComboBox::clear() } if(d->popup() && style().styleHint(TQStyle::SH_ComboBox_Popup, this)) - d->popup()->setItemChecked(d->current, FALSE); + d->popup()->setItemChecked(d->current, false); d->current = 0; if ( d->ed ) { d->ed->setText( TQString::fromLatin1("") ); @@ -1057,7 +1057,7 @@ void TQComboBox::setCurrentItem( int index ) return; if(d->popup() && style().styleHint(TQStyle::SH_ComboBox_Popup, this)) - d->popup()->setItemChecked(d->current, FALSE); + d->popup()->setItemChecked(d->current, false); d->current = index; d->completeAt = 0; if ( d->ed ) { @@ -1140,7 +1140,7 @@ void TQComboBox::internalActivate( int index ) if ( d->current != index ) { if ( !d->usingListBox() || listBox()->item( index )->isSelectable() ) { if(d->popup() && style().styleHint(TQStyle::SH_ComboBox_Popup, this)) - d->popup()->setItemChecked(d->current, FALSE); + d->popup()->setItemChecked(d->current, false); d->current = index; currentChanged(); } @@ -1149,7 +1149,7 @@ void TQComboBox::internalActivate( int index ) popDownListBox(); else d->popup()->removeEventFilter( this ); - d->poppedUp = FALSE; + d->poppedUp = false; TQString t( text( index ) ); if ( d->ed ) { @@ -1181,7 +1181,7 @@ void TQComboBox::internalHighlight( int index ) */ void TQComboBox::internalClickTimeout() { - d->shortClick = FALSE; + d->shortClick = false; } /*! @@ -1248,7 +1248,7 @@ void TQComboBox::paintEvent( TQPaintEvent * ) flags |= TQStyle::Style_MouseOver; if ( width() < 5 || height() < 5 ) { - qDrawShadePanel( &p, rect(), g, FALSE, 2, + qDrawShadePanel( &p, rect(), g, false, 2, &g.brush( TQColorGroup::Button ) ); return; } @@ -1270,11 +1270,11 @@ void TQComboBox::paintEvent( TQPaintEvent * ) xPos = w; x0 = 4; } - qDrawShadePanel( &p, rect(), g, FALSE, + qDrawShadePanel( &p, rect(), g, false, style().pixelMetric(TQStyle::PM_DefaultFrameWidth, this), &g.brush( TQColorGroup::Button ) ); qDrawShadePanel( &p, xPos, (height() - buttonH)/2, - buttonW, buttonH, g, FALSE, + buttonW, buttonH, g, false, style().pixelMetric(TQStyle::PM_DefaultFrameWidth, this) ); TQRect clip( x0, 2, w - 2 - 4 - 5, height() - 4 ); TQString str = d->popup()->text( this->d->current ); @@ -1288,7 +1288,7 @@ void TQComboBox::paintEvent( TQPaintEvent * ) TQPixmap pm = ( pix ? *pix : iconSet->pixmap() ); p.setClipRect( clip ); p.drawPixmap( 4, (height()-pm.height())/2, pm ); - p.setClipping( FALSE ); + p.setClipping( false ); } if ( hasFocus() ) @@ -1352,7 +1352,7 @@ void TQComboBox::paintEvent( TQPaintEvent * ) ( re.height() - pix->height() ) / 2, *pix ); } } - p.setClipping( FALSE ); + p.setClipping( false ); } } @@ -1365,7 +1365,7 @@ void TQComboBox::mousePressEvent( TQMouseEvent *e ) if ( e->button() != LeftButton ) return; if ( d->discardNextMousePress ) { - d->discardNextMousePress = FALSE; + d->discardNextMousePress = false; return; } TQRect arrowRect = style().querySubControlMetrics( TQStyle::CC_ComboBox, this, @@ -1377,24 +1377,24 @@ void TQComboBox::mousePressEvent( TQMouseEvent *e ) arrowRect.setHeight( TQMAX( height() - (2 * arrowRect.y()), arrowRect.height() ) ); if ( count() && ( !editable() || arrowRect.contains( e->pos() ) ) ) { - d->arrowPressed = FALSE; + d->arrowPressed = false; if ( d->usingListBox() ) { - listBox()->blockSignals( TRUE ); + listBox()->blockSignals( true ); tqApp->sendEvent( listBox(), e ); // trigger the listbox's autoscroll listBox()->setCurrentItem(d->current); - listBox()->blockSignals( FALSE ); + listBox()->blockSignals( false ); popup(); if ( arrowRect.contains( e->pos() ) ) { - d->arrowPressed = TRUE; - d->arrowDown = TRUE; - repaint( FALSE ); + d->arrowPressed = true; + d->arrowDown = true; + repaint( false ); } } else { popup(); } TQTimer::singleShot( 200, this, TQ_SLOT(internalClickTimeout())); - d->shortClick = TRUE; + d->shortClick = true; } } @@ -1468,7 +1468,7 @@ void TQComboBox::keyPressEvent( TQKeyEvent *e ) d->completeAt = ct.length(); } } - d->completionTimer->start( 400, TRUE ); + d->completionTimer->start( 400, true ); } else { e->ignore(); return; @@ -1487,7 +1487,7 @@ void TQComboBox::keyPressEvent( TQKeyEvent *e ) void TQComboBox::focusInEvent( TQFocusEvent * e ) { TQWidget::focusInEvent( e ); - d->completeNow = FALSE; + d->completeNow = false; d->completeAt = 0; } @@ -1497,7 +1497,7 @@ void TQComboBox::focusInEvent( TQFocusEvent * e ) void TQComboBox::focusOutEvent( TQFocusEvent * e ) { TQWidget::focusOutEvent( e ); - d->completeNow = FALSE; + d->completeNow = false; d->completeAt = 0; } @@ -1560,7 +1560,7 @@ void TQComboBox::popup() if(d->usingListBox()) { if(!d->popup()) { TQComboBoxPopup *p = new TQComboBoxPopup( this, "in-combo" ); - d->setPopupMenu( p, FALSE ); + d->setPopupMenu( p, false ); p->setFont( font() ); connect( p, TQ_SIGNAL(activated(int)), TQ_SLOT(internalActivate(int)) ); connect( p, TQ_SIGNAL(highlighted(int)), TQ_SLOT(internalHighlight(int)) ); @@ -1582,15 +1582,15 @@ void TQComboBox::popup() } d->popup()->installEventFilter( this ); if(d->popup() && style().styleHint(TQStyle::SH_ComboBox_Popup, this)) - d->popup()->setItemChecked(this->d->current, TRUE); + d->popup()->setItemChecked(this->d->current, true); d->popup()->popup( mapToGlobal( TQPoint(0,0) ), this->d->current ); update(); } else { // Send all listbox events to eventFilter(): TQListBox* lb = d->listBox(); - lb->triggerUpdate( TRUE ); + lb->triggerUpdate( true ); lb->installEventFilter( this ); - d->mouseWasInsidePopup = FALSE; + d->mouseWasInsidePopup = false; int w = lb->variableWidth() ? lb->sizeHint().width() : width(); int h = listHeight( lb, d->sizeLimit ) + 2; TQRect screen = TQApplication::desktop()->availableGeometry( this ); @@ -1624,7 +1624,7 @@ void TQComboBox::popup() lb->raise(); bool block = lb->signalsBlocked(); - lb->blockSignals( TRUE ); + lb->blockSignals( true ); TQListBoxItem* currentLBItem = 0; if ( editable() && currentText() != text( currentItem() ) ) currentLBItem = lb->findItem( currentText() ); @@ -1637,7 +1637,7 @@ void TQComboBox::popup() // set the current item to also be the selected item if it isn't already if ( currentLBItem && currentLBItem->isSelectable() && !currentLBItem->isSelected() ) - lb->setSelected( currentLBItem, TRUE ); + lb->setSelected( currentLBItem, true ); lb->blockSignals( block ); lb->setVScrollBarMode(TQScrollView::Auto); @@ -1651,7 +1651,7 @@ void TQComboBox::popup() #endif lb->show(); } - d->poppedUp = TRUE; + d->poppedUp = true; } @@ -1683,10 +1683,10 @@ void TQComboBox::popDownListBox() d->listBox()->hide(); d->listBox()->setCurrentItem( d->current ); if ( d->arrowDown ) { - d->arrowDown = FALSE; - repaint( FALSE ); + d->arrowDown = false; + repaint( false ); } - d->poppedUp = FALSE; + d->poppedUp = false; update(); } @@ -1736,16 +1736,16 @@ void TQComboBox::currentChanged() bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) { if ( !event ) - return TRUE; + return true; else if ( object == d->ed ) { if ( event->type() == TQEvent::KeyPress ) { bool isAccepted = ( (TQKeyEvent*)event )->isAccepted(); keyPressEvent( (TQKeyEvent *)event ); if ( ((TQKeyEvent *)event)->isAccepted() ) { - d->completeNow = FALSE; - return TRUE; + d->completeNow = false; + return true; } else if ( ((TQKeyEvent *)event)->key() != Key_End ) { - d->completeNow = TRUE; + d->completeNow = true; d->completeAt = d->ed->cursorPosition(); } if ( isAccepted ) @@ -1760,7 +1760,7 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) } else if ( event->type() == TQEvent::FocusOut ) { focusOutEvent( (TQFocusEvent *)event ); } else if ( d->useCompletion && d->completeNow ) { - d->completeNow = FALSE; + d->completeNow = false; if ( !d->ed->text().isNull() && d->ed->cursorPosition() > d->completeAt && d->ed->cursorPosition() == (int)d->ed->text().length() ) { @@ -1786,7 +1786,7 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) if ( !d->mouseWasInsidePopup ) { TQPoint pos = e->pos(); if ( d->listBox()->rect().contains( pos ) ) - d->mouseWasInsidePopup = TRUE; + d->mouseWasInsidePopup = true; // Check if arrow button should toggle if ( d->arrowPressed ) { TQPoint comboPos; @@ -1797,24 +1797,24 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) arrowRect = TQStyle::visualRect(arrowRect, this); if ( arrowRect.contains( comboPos ) ) { if ( !d->arrowDown ) { - d->arrowDown = TRUE; - repaint( FALSE ); + d->arrowDown = true; + repaint( false ); } } else { if ( d->arrowDown ) { - d->arrowDown = FALSE; - repaint( FALSE ); + d->arrowDown = false; + repaint( false ); } } } } else if ((e->state() & ( RightButton | LeftButton | MidButton ) ) == 0 && style().styleHint(TQStyle::SH_ComboBox_ListMouseTracking, this)) { - TQWidget *mouseW = TQApplication::widgetAt( e->globalPos(), TRUE ); + TQWidget *mouseW = TQApplication::widgetAt( e->globalPos(), true ); if ( mouseW == d->listBox()->viewport() ) { //### TQMouseEvent m( TQEvent::MouseMove, e->pos(), e->globalPos(), LeftButton, LeftButton ); TQApplication::sendEvent( object, &m ); //### Evil - return TRUE; + return true; } } @@ -1825,15 +1825,15 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) e->pos(), e->button(), e->state() ) ; // will hide popup TQApplication::sendEvent( object, &tmp ); - return TRUE; + return true; } else { if ( d->mouseWasInsidePopup ) { popDownListBox(); } else { - d->arrowPressed = FALSE; + d->arrowPressed = false; if ( d->arrowDown ) { - d->arrowDown = FALSE; - repaint( FALSE ); + d->arrowDown = false; + repaint( false ); } } } @@ -1842,12 +1842,12 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) case TQEvent::MouseButtonPress: if ( !d->listBox()->rect().contains( e->pos() ) ) { TQPoint globalPos = d->listBox()->mapToGlobal(e->pos()); - if ( TQApplication::widgetAt( globalPos, TRUE ) == this ) { - d->discardNextMousePress = TRUE; + if ( TQApplication::widgetAt( globalPos, true ) == this ) { + d->discardNextMousePress = true; // avoid popping up again } popDownListBox(); - return TRUE; + return true; } break; case TQEvent::KeyPress: @@ -1860,13 +1860,13 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) case Key_Escape: if ( d->poppedUp ) { popDownListBox(); - return TRUE; + return true; } break; case Key_Enter: case Key_Return: // work around TQDialog's enter handling - return FALSE; + return false; default: break; } @@ -1887,14 +1887,14 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) e->pos(), e->button(), e->state() ) ; // highlight item, but don't pop down: TQApplication::sendEvent( object, &tmp ); - return TRUE; + return true; } break; case TQEvent::MouseButtonDblClick: case TQEvent::MouseButtonPress: if ( !d->popup()->rect().contains( e->pos() ) ) { - d->poppedUp = FALSE; - d->arrowDown = FALSE; + d->poppedUp = false; + d->arrowDown = false; // remove filter, event will take down popup: d->popup()->removeEventFilter( this ); // ### uglehack! @@ -1905,7 +1905,7 @@ bool TQComboBox::eventFilter( TQObject *object, TQEvent *event ) } break; case TQEvent::Hide: - d->poppedUp = FALSE; + d->poppedUp = false; break; default: break; @@ -1995,11 +1995,11 @@ void TQComboBox::returnPressed() return; int c = 0; - bool doInsert = TRUE; + bool doInsert = true; if ( !d->duplicatesEnabled ) { for ( int i = 0; i < count(); ++i ) { if ( s == text( i ) ) { - doInsert = FALSE; + doInsert = false; c = i; break; } @@ -2059,7 +2059,7 @@ void TQComboBox::setEnabled( bool enable ) } else { d->popup()->removeEventFilter( this ); d->popup()->close(); - d->poppedUp = FALSE; + d->poppedUp = false; } } TQWidget::setEnabled( enable ); @@ -2125,10 +2125,10 @@ void TQComboBox::setListBox( TQListBox * newListBox ) delete d->listBox(); } else { delete d->popup(); - d->setPopupMenu(0, FALSE); + d->setPopupMenu(0, false); } - newListBox->reparent( this, WType_Popup, TQPoint(0,0), FALSE ); + newListBox->reparent( this, WType_Popup, TQPoint(0,0), false ); d->setListBox( newListBox ); d->listBox()->setFont( font() ); d->listBox()->setPalette( palette() ); @@ -2211,7 +2211,7 @@ void TQComboBox::setEditText( const TQString &newText ) void TQComboBox::setAutoCompletion( bool enable ) { d->useCompletion = enable; - d->completeNow = FALSE; + d->completeNow = false; } @@ -2299,18 +2299,18 @@ void TQComboBox::setLineEdit( TQLineEdit *edit ) d->ed = edit; if ( edit->parent() != this ) - edit->reparent( this, TQPoint(0,0), FALSE ); + edit->reparent( this, TQPoint(0,0), false ); connect (edit, TQ_SIGNAL( textChanged(const TQString&) ), this, TQ_SIGNAL( textChanged(const TQString&) ) ); connect( edit, TQ_SIGNAL(returnPressed()), TQ_SLOT(returnPressed()) ); - edit->setFrame( FALSE ); + edit->setFrame( false ); d->updateLinedGeometry(); edit->installEventFilter( this ); setFocusProxy( edit ); setFocusPolicy( StrongFocus ); - setInputMethodEnabled( TRUE ); + setInputMethodEnabled( true ); if ( !d->usingListBox() ) setUpListBox(); |
