Exemplo n.º 1
0
    /**
     * @brief Entity::drawHeader
     * @param painter
     */
    void Entity::drawHeader(QPainter *painter)
    {
        painter->save();

        QColor color = typeColor();

        // Fill background
        QLinearGradient gradient(0, -height() / 2, 0, -height() / 2 + minimumHeight );
        gradient.setColorAt(0, color);
        gradient.setColorAt(1, Qt::white);
        QRectF headerRect(-width() / 2, -height() / 2, width(), minimumHeight);
        painter->fillRect(headerRect, QBrush(gradient));

        // Draw frame
        painter->setPen(color);
        painter->drawRect(headerRect);

        // Add element name
        painter->setPen(Qt::black);
        painter->setRenderHint(QPainter::TextAntialiasing);
        QString name(cutText(G_ASSERT(m_Type)->name(), painter->fontMetrics(), width()));
        painter->drawText(headerRect, Qt::AlignCenter, name);

        painter->restore();
    }
Exemplo n.º 2
0
bool Q3TitleBar::event(QEvent *e)
{
    Q_D(Q3TitleBar);
    if (d->inevent)
        return QWidget::event(e);
    d->inevent = true;
    if (e->type() == QEvent::ApplicationPaletteChange) {
        d->readColors();
        return true;
    } else if (e->type() == QEvent::WindowActivate) {
        setActive(d->act);
    } else if (e->type() == QEvent::WindowDeactivate) {
        bool wasActive = d->act;
        setActive(false);
        d->act = wasActive;
    } else if (e->type() == QEvent::WindowIconChange) {
        update();
    } else if (e->type() == QEvent::WindowTitleChange) {
        cutText();
        update();
    }

    d->inevent = false;
    return QWidget::event(e);
}
Exemplo n.º 3
0
void K3b::CutComboBox::setCurrentText( const QString& s )
{
    int i;
    for( i = 0; i < count(); i++ )
        if ( d->originalItems[i] == s )
            break;
    if ( i < count() ) {
        setCurrentIndex(i);
    }
    else if( !d->originalItems.isEmpty() ) {
        d->originalItems[currentIndex()] = s;
        cutText();
    }
}
Exemplo n.º 4
0
void K3b::CutComboBox::insertItem( const QPixmap& pixmap, const QString& text, int index )
{
    if( index != -1 )
        d->originalItems.insert( d->originalItems.at(index), text );
    else
        d->originalItems.append( text );

    if( !pixmap.isNull() )
        KComboBox::insertItem( index, pixmap, "xx" );
    else
        KComboBox::insertItem( index, "xx" );

    cutText();
}
Exemplo n.º 5
0
	void Label::calcStrSize() {
		mustCalcStrSize = false;
		Rect tempRect = Rect(0, 0, paddedBounds.width, paddedBounds.height);
		if(!font) {
			strSize = EXTENT(0,0);
		} else {
			if(autoSizeX)
				strSize = font->getStringDimensions(caption.c_str());
			else {
				if(multiLine) {	
					strSize = font->getBoundedStringDimensions(caption.c_str(), tempRect);
				} else {
					cutText(cuttedCaption, font, caption, tempRect);
					strSize = font->getStringDimensions(cuttedCaption.c_str());
				}
			}

		}
		strWidth  = EXTENT_X(strSize);
		strHeight = EXTENT_Y(strSize);

		if(autoSizeX) resize(strWidth + paddingLeft + paddingRight, bounds.height);
		if(autoSizeY) resize(bounds.width,  strHeight + paddingTop + paddingBottom);
	}
/**
 *	Processes key events, handling advanced editing commands. Advance editing
 *	commands are ignored if the advancedEditing flag is set to false. Bellow
 *	are the supported commands:
 *
 *	CTRL + <-		Go to beginning of word
 *	CTRL + ->		Go to end of word
 *	CTRL + A		Go to beginning of line (same as HOME)
 *	CTRL + E		Go to end word (same as END)
 *	CTRL + D		Delete character to the right (same as DELETE)
 *	CTRL + H		Delete character to the left (same as BACKSPACE)
 *	CTRL + K		Delete line to right of cursor (copies to clipboard)
 *	CTRL + U		Delete line to left of cursor (copies to clipboard)
 *	CTRL + [R|DEL]	Delete word to right of cursor (copies to clipboard)
 *	CTRL + [W|BS]	Delete word to left of cursor (copies to clipboard)
 *	CTRL + [Y|INS]	Paste clipboard contents
 */
bool LineEditor::processAdvanceEditKeys( KeyEvent event )
{
	if (!this->advancedEditing_) 
	{
		return false;
	}

	bool isHandled = false;
	if (event.isCtrlDown()) 
	{
		isHandled = true;
		switch (event.key())
		{
		case KeyEvent::KEY_LEFTARROW:
		case KeyEvent::KEY_JOY2:	// dpad left
			cx_ = curWordStart( cx_ );
			break;

		case KeyEvent::KEY_RIGHTARROW:
		case KeyEvent::KEY_JOY3:	// dpad right
			cx_ = curWordEnd( cx_ );
			break;

		case KeyEvent::KEY_A:
			cx_ = 0;
			break;

		case KeyEvent::KEY_E:
			cx_ = editString_.length();
			break;

		case KeyEvent::KEY_D:
			if ( cx_ < (int)editString_.length( ) )
			{
				deleteChar( cx_ );
			}
			break;

		case KeyEvent::KEY_H:
			if ( cx_ > 0 )
			{
				cx_--;
				deleteChar( cx_ );
			}
			break;

		case KeyEvent::KEY_K:
			clipBoard_ = cutText( cx_, editString_.length() );
			break;

		case KeyEvent::KEY_U:
			clipBoard_ = cutText( 0, cx_ );
			cx_ = 0;
			break;

		case KeyEvent::KEY_W:
		case KeyEvent::KEY_BACKSPACE:
		{
			int wordStart = curWordStart( cx_ );
			clipBoard_ = cutText( wordStart, cx_ );
			cx_ = wordStart;
			break;
		}

		case KeyEvent::KEY_R:
		case KeyEvent::KEY_DELETE:
		{
			clipBoard_ = cutText( cx_, curWordEnd( cx_ ) );
			break;
		}

		case KeyEvent::KEY_Y:
		case KeyEvent::KEY_INSERT:
			cx_ = pasteText( cx_, clipBoard_ );
			break;

		default:
			isHandled = false;
			break;
		}
	}	
	return isHandled;
}
Exemplo n.º 7
0
void Q3TitleBar::resizeEvent(QResizeEvent *r)
{
    QWidget::resizeEvent(r);
    cutText();
}
Exemplo n.º 8
0
void K3b::CutComboBox::setMethod( int m )
{
    d->method = m;
    cutText();
}
Exemplo n.º 9
0
void K3b::CutComboBox::resizeEvent( QResizeEvent* e )
{
    cutText();

    KComboBox::resizeEvent(e);
}
Exemplo n.º 10
0
void K3b::CutComboBox::changeItem( const QString& s, int i )
{
    d->originalItems[i] = s;
    cutText();
}