void displayInEditor(bool endflag, QString text, QString txtfont, QTextCursor cursor)
{
    //QTextCursor mycursor(activeEditor()->textCursor());
    if(endflag){
       cursor.insertText("\n");
    }//if

    QFont textFont("Courier");
    textFont.setPixelSize(12);
    QFont boldFont("Arial");
    boldFont.setPixelSize(12);

    if(txtfont == "bold"){
          QTextCharFormat boldFormat;
          boldFormat.setFont(boldFont);
          boldFormat.setFontWeight(QFont::Bold);
          cursor.insertText(text, boldFormat);
    }//if
    else if (txtfont == "normal"){
          QTextCharFormat textFormat;
          textFormat.setFont(textFont);
          textFormat.setFontWeight(QFont::Normal);
          cursor.insertText(text, textFormat);
    }//else if
    else if (txtfont == "underl"){
          QTextCharFormat textFormat;
          textFormat.setFont(textFont);
          textFormat.setFontWeight(QFont::Normal);
          textFormat.setFontUnderline(true);
          cursor.insertText(text, textFormat);
    }//else if
}
示例#2
0
void
DriveItem::Update(BView* owner, const BFont* font)
{
	fSizeWidth = font->StringWidth(fSize.String());

	BFont boldFont(font);
	boldFont.SetFace(B_BOLD_FACE);
	float width = 8 + boldFont.StringWidth(fPath.Path())
		+ be_control_look->DefaultItemSpacing() + fSizeWidth;
	float pathWidth = font->StringWidth(fPath.Path());
	if (width < pathWidth)
		width = pathWidth;

	SetWidth(width);

	font_height fheight;
	font->GetHeight(&fheight);

	float lineHeight = ceilf(fheight.ascent) + ceilf(fheight.descent)
		+ ceilf(fheight.leading);

	fBaselineOffset = 2 + ceilf(fheight.ascent + fheight.leading / 2);
	fSecondBaselineOffset = fBaselineOffset + lineHeight;

	SetHeight(2 * lineHeight + 4);
}
示例#3
0
QPixmap FoundCountIcon::foundCountPixmap(bool isLoading, int countFound, bool childrenAreLoading, int countChildsFound,
                                         const QFont &font, int height) const
{
    if (isLoading)
        return QPixmap();

    QFont boldFont(font);
    boldFont.setBold(true);

    QString text;
    if (childrenAreLoading) {
        if (countChildsFound > 0)
            text = i18n("%1+%2+", QString::number(countFound), QString::number(countChildsFound));
        else
            text = i18n("%1+", QString::number(countFound));
    } else {
        if (countChildsFound > 0)
            text = i18n("%1+%2", QString::number(countFound), QString::number(countChildsFound));
        else if (countFound > 0)
            text = QString::number(countFound);
        else
            return QPixmap();
    }

    return circledTextPixmap(text, height, boldFont, m_basketTree->palette().color(QPalette::HighlightedText));
}
示例#4
0
void
MimeTypeItem::DrawItem(BView* owner, BRect frame, bool complete)
{
	BFont font;

	if (IsSupertypeOnly()) {
		owner->GetFont(&font);
		BFont boldFont(font);
		boldFont.SetFace(B_BOLD_FACE);
		owner->SetFont(&boldFont);
	}

	BRect rect = frame;
	if (fFlat) {
		// This is where the latch would be - yet can freely consider this
		// as an ugly hack
		rect.left -= 11.0f;
	}

	if (fShowIcon) {
		rgb_color lowColor = owner->LowColor();

		if (IsSelected() || complete) {
			if (IsSelected())
				owner->SetLowColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));

			owner->FillRect(rect, B_SOLID_LOW);
		}

		BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32);
		BMimeType mimeType(fType.String());
		status_t status = icon_for_type(mimeType, bitmap, B_MINI_ICON);
		if (status < B_OK) {
			// get default generic/application icon
			BMimeType genericType(fApplicationMode
				? B_ELF_APP_MIME_TYPE : B_FILE_MIME_TYPE);
			status = icon_for_type(genericType, bitmap, B_MINI_ICON);
		}

		if (status == B_OK) {
			BPoint point(rect.left + 2.0f, 
				rect.top + (rect.Height() - B_MINI_ICON) / 2.0f);

			owner->SetDrawingMode(B_OP_ALPHA);
			owner->DrawBitmap(&bitmap, point);
		}

		owner->SetDrawingMode(B_OP_COPY);

		owner->MovePenTo(rect.left + B_MINI_ICON + 8.0f, frame.top + fBaselineOffset);
		owner->DrawString(Text());

		owner->SetLowColor(lowColor);
	} else
		BStringItem::DrawItem(owner, rect, complete);

	if (IsSupertypeOnly())
		owner->SetFont(&font);
}
QSize FancyTabBar::tabSizeHint(bool minimum) const
{
    QFont boldFont(font());

    boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    QFontMetrics fm(boldFont);
    int spacing    = 6;
    int width      = 90 + spacing + 2;

    int iconHeight = minimum ? 0 : iconSize;
    return QSize(width, iconHeight + spacing + fm.height());
}
QSize FancyTabBar::tabSizeHint(bool minimum) const
{
    QFont boldFont(font());
    boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    QFontMetrics fm(boldFont);
    int spacing = 8;
    int width = 60 + spacing + 2;
    int maxLabelwidth = 0;
    for (int tab=0 ; tab<count() ;++tab) {
        int width = fm.width(tabText(tab));
        if (width > maxLabelwidth)
            maxLabelwidth = width;
    }
    int iconHeight = minimum ? 0 : 32;
    return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height());
}
示例#7
0
文件: Headers.cpp 项目: KDE/koffice
void KCRowHeader::paintEvent(QPaintEvent* event)
{
    register KCSheet * const sheet = m_pView->activeSheet();
    if (!sheet)
        return;

//     KCElapsedTime et( "Painting vertical header", KCElapsedTime::PrintOnlyTime );

    // FIXME Stefan: Make use of clipping. Find the repaint call after the scrolling.
    // kDebug(36004) << event->rect();

    // painting rectangle
    const QRectF paintRect = m_pView->zoomHandler()->viewToDocument(event->rect());

    // the painter
    QPainter painter(this);
    painter.scale(m_pView->zoomHandler()->zoomedResolutionX(), m_pView->zoomHandler()->zoomedResolutionY());
    painter.setRenderHint(QPainter::TextAntialiasing);

    // fonts
    QFont normalFont(painter.font());
    QFont boldFont(normalFont);
    boldFont.setBold(true);

    // background brush/color
    const QBrush backgroundBrush(palette().window());
    const QColor backgroundColor(backgroundBrush.color());

    // selection brush/color
    QColor selectionColor(palette().highlight().color());
    selectionColor.setAlpha(127);
    const QBrush selectionBrush(selectionColor);

    painter.setClipRect(paintRect);

    double yPos;
    // Get the top row and the current y-position
    int y = sheet->topRow(paintRect.y() + m_pCanvas->yOffset(), yPos);
    // Align to the offset
    yPos = yPos - m_pCanvas->yOffset();

    const KViewConverter *converter = m_pCanvas->viewConverter();
    const double width = converter->viewToDocumentX(this->width() - 1);

    QSet<int> selectedRows;
    QSet<int> affectedRows;
    if (!m_pView->selection()->referenceSelectionMode() && m_cellToolIsActive) {
        selectedRows = m_pView->selection()->rowsSelected();
        affectedRows = m_pView->selection()->rowsAffected();
    }
    // Loop through the rows, until we are out of range
    while (yPos <= paintRect.bottom() && y <= KS_rowMax) {
        const bool selected = (selectedRows.contains(y));
        const bool highlighted = (!selected && affectedRows.contains(y));

        const KCRowFormat* rowFormat = sheet->rowFormat(y);
        if (rowFormat->isHiddenOrFiltered()) {
            ++y;
            continue;
        }
        const double height = rowFormat->height();

        if (selected || highlighted) {
            painter.setPen(selectionColor.dark(150));
            painter.setBrush(selectionBrush);
        } else {
            painter.setPen(backgroundColor.dark(150));
            painter.setBrush(backgroundBrush);
        }
        painter.drawRect(QRectF(0, yPos, width, height));

        QString rowText = QString::number(y);

        // Reset painter
        painter.setFont(normalFont);
        painter.setPen(palette().text().color());

        if (selected)
            painter.setPen(palette().highlightedText().color());
        else if (highlighted)
            painter.setFont(boldFont);

        const int ascent = painter.fontMetrics().ascent();
        if (height >= ascent - painter.fontMetrics().descent()) {
            const double len = painter.fontMetrics().width(rowText);
#if 0
            switch (y % 3) {
            case 0: rowText = QString::number(height) + 'h'; break;
            case 1: rowText = QString::number(painter.fontMetrics().ascent()) + 'a'; break;
            case 2: rowText = QString::number(painter.fontMetrics().descent()) + 'd'; break;
            }
            //kDebug() << "font height: " << painter.fontMetrics().ascent();
            painter.drawLine(1, yPos, 4, yPos + 3);
#endif
            drawText(painter,
                     normalFont,
                     QPointF((width - len) / 2,
                             yPos + (height - ascent) / 2),
//                            yPos + ( height - painter.fontMetrics().ascent() - painter.fontMetrics().descent() ) / 2 ),
                     rowText);
        }

        yPos += rowFormat->height();
        y++;
    }
}
示例#8
0
文件: Headers.cpp 项目: KDE/koffice
void KCColumnHeader::paintEvent(QPaintEvent* event)
{
    register KCSheet * const sheet = m_pView->activeSheet();
    if (!sheet)
        return;

//     KCElapsedTime et( "Painting horizontal header", KCElapsedTime::PrintOnlyTime );

    // FIXME Stefan: Make use of clipping. Find the repaint call after the scrolling.
    // kDebug(36004) << event->rect();

    // painting rectangle
    const QRectF paintRect = m_pView->zoomHandler()->viewToDocument(event->rect());

    // the painter
    QPainter painter(this);
    painter.scale(m_pView->zoomHandler()->zoomedResolutionX(), m_pView->zoomHandler()->zoomedResolutionY());
    painter.setRenderHint(QPainter::TextAntialiasing);

    // fonts
    QFont normalFont(painter.font());
    QFont boldFont(normalFont);
    boldFont.setBold(true);

    // background brush/color
    const QBrush backgroundBrush(palette().window());
    const QColor backgroundColor(backgroundBrush.color());

    // selection brush/color
    QColor selectionColor(palette().highlight().color());
    selectionColor.setAlpha(127);
    const QBrush selectionBrush(selectionColor);

    painter.setClipRect(paintRect);

    double xPos;
    int x;

    if (sheet->layoutDirection() == Qt::RightToLeft) {
        //Get the left column and the current x-position
        x = sheet->leftColumn(int(m_pView->zoomHandler()->unzoomItX(width()) - paintRect.x() + m_pCanvas->xOffset()), xPos);
        //Align to the offset
        xPos = m_pView->zoomHandler()->unzoomItX(width()) - xPos + m_pCanvas->xOffset();
    } else {
        //Get the left column and the current x-position
        x = sheet->leftColumn(int(paintRect.x() + m_pCanvas->xOffset()), xPos);
        //Align to the offset
        xPos = xPos - m_pCanvas->xOffset();
    }

    const KViewConverter *converter = m_pCanvas->viewConverter();
    const double height = converter->viewToDocumentY(this->height() - 1);

    if (sheet->layoutDirection() == Qt::RightToLeft) {
        if (x > KS_colMax)
            x = KS_colMax;

        xPos -= sheet->columnFormat(x)->width();

        QSet<int> selectedColumns;
        QSet<int> affectedColumns;
        if (!m_pView->selection()->referenceSelectionMode() && m_cellToolIsActive) {
            selectedColumns = m_pView->selection()->columnsSelected();
            affectedColumns = m_pView->selection()->columnsAffected();
        }
        //Loop through the columns, until we are out of range
        while (xPos <= paintRect.right() && x <= KS_colMax) {
            bool selected = (selectedColumns.contains(x));
            bool highlighted = (!selected && affectedColumns.contains(x));

            const KCColumnFormat* columnFormat = sheet->columnFormat(x);
            if (columnFormat->isHiddenOrFiltered()) {
                ++x;
                continue;
            }
            double width = columnFormat->width();

            if (selected || highlighted) {
                painter.setPen(selectionColor.dark(150));
                painter.setBrush(selectionBrush);
            } else {
                painter.setPen(backgroundColor.dark(150));
                painter.setBrush(backgroundBrush);
            }
            painter.drawRect(QRectF(xPos, 0, width, height));

            // Reset painter
            painter.setFont(normalFont);
            painter.setPen(palette().text().color());

            if (selected)
                painter.setPen(palette().highlightedText().color());
            else if (highlighted)
                painter.setFont(boldFont);

            QString colText = sheet->getShowColumnNumber() ? QString::number(x) : KCCell::columnName(x);
            double len = painter.fontMetrics().width(colText);
            if (width >= len) {
                drawText(painter,
                         normalFont,
                         QPointF(xPos + (width - len) / 2,
                                 (height - painter.fontMetrics().ascent() - painter.fontMetrics().descent()) / 2),
                         colText,
                         width);
            }
            xPos += columnFormat->width();
            --x;
        }
    } else { // if ( sheet->layoutDirection() == Qt::LeftToRight )
        QSet<int> selectedColumns;
        QSet<int> affectedColumns;
        if (!m_pView->selection()->referenceSelectionMode() && m_cellToolIsActive) {
            selectedColumns = m_pView->selection()->columnsSelected();
            affectedColumns = m_pView->selection()->columnsAffected();
        }
        //Loop through the columns, until we are out of range
        while (xPos <= paintRect.right() && x <= KS_colMax) {
            bool selected = (selectedColumns.contains(x));
            bool highlighted = (!selected && affectedColumns.contains(x));

            const KCColumnFormat *columnFormat = sheet->columnFormat(x);
            if (columnFormat->isHiddenOrFiltered()) {
                ++x;
                continue;
            }
            double width = columnFormat->width();

            QColor backgroundColor = palette().window().color();

            if (selected || highlighted) {
                painter.setPen(selectionColor.dark(150));
                painter.setBrush(selectionBrush);
            } else {
                painter.setPen(backgroundColor.dark(150));
                painter.setBrush(backgroundBrush);
            }
            painter.drawRect(QRectF(xPos, 0, width, height));

            // Reset painter
            painter.setFont(normalFont);
            painter.setPen(palette().text().color());

            if (selected)
                painter.setPen(palette().highlightedText().color());
            else if (highlighted)
                painter.setFont(boldFont);

            QString colText = sheet->getShowColumnNumber() ? QString::number(x) : KCCell::columnName(x);
            int len = painter.fontMetrics().width(colText);
            if (width >= len) {
#if 0
                switch (x % 3) {
                case 0: colText = QString::number(height) + 'h'; break;
                case 1: colText = QString::number(painter.fontMetrics().ascent()) + 'a'; break;
                case 2: colText = QString::number(painter.fontMetrics().descent()) + 'd'; break;
                }
#endif
                drawText(painter,
                         normalFont,
                         QPointF(xPos + (width - len) / 2,
                                 (height - painter.fontMetrics().ascent() - painter.fontMetrics().descent()) / 2),
                         colText,
                         width);
            }

            xPos += columnFormat->width();
            ++x;
        }
    }
}
示例#9
0
void CtrlDisAsmView::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	painter.setBrush(Qt::white);
	painter.setPen(Qt::white);
	painter.drawRect(rect());

	struct branch
	{
		int src,dst,srcAddr;
		bool conditional;
	};
	branch branches[256];
	int numBranches=0;

	int width = rect().width();
	int numRows=(rect().height()/rowHeight);

	QColor bgColor(0xFFFFFFFF);
	QPen nullPen(bgColor);
	QPen currentPen(QColor(0,0,0));
	QPen selPen(QColor(0xFF808080));
	QPen condPen(QColor(0xFFFF3020));

	QBrush lbr;
	lbr.setColor(bgColor);
	QBrush currentBrush(QColor(0xFFFFEfE8));
	QBrush pcBrush(QColor(0xFF70FF70));

	QFont normalFont("Arial", 10);
	QFont boldFont("Arial", 10);
	QFont alignedFont("Monospace", 10);
	alignedFont.setStyleHint(QFont::Monospace);
	boldFont.setBold(true);
	painter.setFont(normalFont);


	QImage breakPoint(":/resources/breakpoint.ico");
	int i;
	curAddress&=~(align-1);

	align=(debugger->getInstructionSize(0));
	for (i=0; i<=numRows; i++)
	{
		unsigned int address=curAddress + (i-(numRows/2))*align;

		int rowY1 = rect().top() + rowHeight*i;
		int rowY2 = rect().top() + rowHeight*i + rowHeight - 1;

		lbr.setColor((unsigned int)marker == address ? QColor(0xFFFFEEE0) : QColor(debugger->getColor(address)));
		QColor bg = lbr.color();
		painter.setBrush(currentBrush);
		painter.setPen(nullPen);
		painter.drawRect(0,rowY1,16-1,rowY2-rowY1);

		if (selecting && address == (unsigned int)selection)
			painter.setPen(selPen);
		else
		{
			if(i==numRows/2)
				painter.setPen(currentPen);
			else
				painter.setPen(bg);
		}
		painter.setBrush(QBrush(bg));

		if (address == debugger->getPC())
		{
			painter.setBrush(pcBrush);
		}

		painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);
		painter.setBrush(currentBrush);
		QPen textPen(QColor(halfAndHalf(bg.rgba(),0)));
		painter.setPen(textPen);
		painter.setFont(alignedFont);
		painter.drawText(17,rowY1-3+rowHeight,QString("%1").arg(address,8,16,QChar('0')));
		painter.setFont(normalFont);
		textPen.setColor(QColor(0xFF000000));
		painter.setPen(textPen);
		if (debugger->isAlive())
		{
			const char *dizz = debugger->disasm(address, align);
			char dis[512];
			strcpy(dis, dizz);
			char *dis2 = strchr(dis,'\t');
			char desc[256]="";
			if (dis2)
			{
				*dis2=0;
				dis2++;
				const char *mojs=strstr(dis2,"->$");
				if (mojs)
				{
					for (int i=0; i<8; i++)
					{
						bool found=false;
						for (int j=0; j<22; j++)
						{
							if (mojs[i+3]=="0123456789ABCDEFabcdef"[j])
								found=true;
						}
						if (!found)
						{
							mojs=0;
							break;
						}
					}
				}
				if (mojs)
				{
					int offs;
					sscanf(mojs+3,"%08x",&offs);
					branches[numBranches].src=rowY1 + rowHeight/2;
					branches[numBranches].srcAddr=address/align;
					branches[numBranches].dst=(int)(rowY1+((s64)offs-(s64)address)*rowHeight/align + rowHeight/2);
					branches[numBranches].conditional = (dis[1]!=0); //unconditional 'b' branch
					numBranches++;
					const char *t = debugger->getDescription(offs).c_str();
					if (memcmp(t,"z_",2)==0)
						t+=2;
					if (memcmp(t,"zz_",3)==0)
						t+=3;
					sprintf(desc,"-->%s", t);
					textPen.setColor(QColor(0xFF600060));
					painter.setPen(textPen);
				}
				else
				{
					textPen.setColor(QColor(0xFF000000));
					painter.setPen(textPen);
				}
				painter.drawText(149,rowY1-3+rowHeight,QString(dis2));
			}
			textPen.setColor(QColor(0xFF007000));
			painter.setPen(textPen);
			painter.setFont(boldFont);
			painter.drawText(84,rowY1-3+rowHeight,QString(dis));
			painter.setFont(normalFont);
			if (desc[0]==0)
			{
				const char *t = debugger->getDescription(address).c_str();
				if (memcmp(t,"z_",2)==0)
					t+=2;
				if (memcmp(t,"zz_",3)==0)
					t+=3;
				strcpy(desc,t);
			}
			if (memcmp(desc,"-->",3) == 0)
			{
				textPen.setColor(QColor(0xFF0000FF));
				painter.setPen(textPen);
			}
			else
			{
				textPen.setColor(halfAndHalf(halfAndHalf(bg.rgba(),0),bg.rgba()));
				painter.setPen(textPen);
			}
			if (strlen(desc))
				painter.drawText(std::max(280,width/3+190),rowY1-3+rowHeight,QString(desc));
			if (debugger->isBreakpoint(address))
			{
				painter.drawImage(2,rowY1+2,breakPoint);
			}
		}
	}
	for (i=0; i<numBranches; i++)
	{
		painter.setPen(branches[i].conditional ? condPen : currentPen);
		int x=280+(branches[i].srcAddr%9)*8;
		QPoint curPos(x-2,branches[i].src);

		if (branches[i].dst<rect().bottom()+200 && branches[i].dst>-200)
		{
			painter.drawLine(curPos, QPoint(x+2,branches[i].src));
			curPos = QPoint(x+2,branches[i].src);
			painter.drawLine(curPos, QPoint(x+2,branches[i].dst));
			curPos = QPoint(x+2,branches[i].dst);
			painter.drawLine(curPos, QPoint(x-4,branches[i].dst));

			curPos = QPoint(x,branches[i].dst-4);
			painter.drawLine(curPos, QPoint(x-4,branches[i].dst));
			curPos = QPoint(x-4,branches[i].dst);
			painter.drawLine(curPos, QPoint(x+1,branches[i].dst+5));
		}
		else
		{
			painter.drawLine(curPos, QPoint(x+4,branches[i].src));
		}
	}
}
/*!	\brief		Constructor for the ActivityWindow class.
 *		\param[in]	data			The data to be displayed.
 *		\param[in]	target		The process to be notified about user's choise.
 *		\param[in]	name			Name of the Event.
 *		\param[in]	category		Category of the Event.
 *		\param[in]	templateMessage		The message to be sent to the target.
 *										If \c NULL is passed, then a new message is constructed
 *										with \c kActivityWindowRepsonceMessage value in \c what.
 *		\param[in]	reminder		\c true if the window is constructed for a reminder, else
 *										\c false. Actually, it matters only for explanation to user.
 *										Default is \c false (it's not a reminder).
 *		\note			A note on memory management:
 *						\c data (the ActionData) belongs to the caller, but it's used only for
 *						initialization of this window. I. e., if the user makes changes to the
 *						data while an ActivityWindow is open, the changes won't be reflected.
 *						However, \c target and \c templateMessage belong to this object. User
 *						shouldn't free them or do anything else.
 */
ActivityWindow::ActivityWindow( ActivityData* data,
									 BMessenger* target,
									 BString		 name,
									 Category*	 category,
									 BMessage* templateMessage,
									 bool reminder )
	:
	BWindow( BRect( 0, 0, 400, 500 ),
				"Event occurred",
				B_FLOATING_WINDOW_LOOK,
				B_NORMAL_WINDOW_FEEL,
				B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS ),
	fTarget( target ),
	fData( data ),
	fTemplateMessage( templateMessage ),
	bIsReminder( reminder ),
	fLastError( B_OK ),
	fEventName( name ),
	fCategory( category ),
	fTitle( NULL ),
	fEventNameView( NULL ),
	fCategoryView( NULL ),
	fTextScroller( NULL ),
	fSnoozeTime( NULL ),
	fNoteText( NULL ),
	fSnooze( NULL ),
	fOk( NULL )
{
	BFont boldFont( be_bold_font );
	BFont plainFont( be_plain_font );
	BFont font;			// For various font-related activities
	font_height	fh;	// For setting the height of the Text View with notification text
	plainFont.GetHeight( &fh );
	int	numberOfColumnsInLayout = 2;
	
	// Sanity check
	if ( !data || !target ) {
		/* Panic! */
		fLastError = B_BAD_VALUE;
		return;
	}
	
	if ( ! fData->GetNotification( NULL ) &&
		  ! fData->GetSound( NULL ) &&
		  ! fData->GetProgram( NULL, NULL ) )
	{
		// Nothing to do! This is not an error!
		fLastError = B_NO_INIT;
		return;
	}
	BView*	background = new BView( Bounds(),
												"Background view",
												B_FOLLOW_ALL_SIDES,
												B_WILL_DRAW );
	if ( !background ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	this->AddChild( background );
	BGridLayout* gridLayout = new BGridLayout();
	if ( !gridLayout ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	background->SetLayout( gridLayout );
	background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	gridLayout->SetInsets( 5, 5, 5, 5 );
	
	/*-------------------------------------------------
	 * First line - explaining what's happening here
	 *------------------------------------------------*/
	BStringView* exp = new BStringView( BRect( 0, 0, 1, 1 ),
													"Explanation 1",
													( bIsReminder ? 
															"A Reminder has occured!" : 
															"An Event has occured!" ) );
	if ( ! exp ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;	
	}
	exp->SetFont( &boldFont );
	exp->ResizeToPreferred();
	BLayoutItem* layoutItem = gridLayout->AddView( exp, 0, 0, numberOfColumnsInLayout, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
	}
	
	/*-----------------------------------------------------------------
	 * Second line - event's name on category's color as background
	 *----------------------------------------------------------------*/
	 
	// Create background
	// Note: the pulse is requested for this Window to receive Pulse notifications.
	fBackground = new BView( BRect( 0, 0, 1, 1 ),
									 "Background",
									 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_V_CENTER | B_PULSE_NEEDED,
									 B_WILL_DRAW );
	if ( !fBackground ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fBackground->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	layoutItem = gridLayout->AddView( fBackground, 0, 1, numberOfColumnsInLayout, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
	}
	
	BGroupLayout* bgLayout = new BGroupLayout( B_VERTICAL );
	if ( !bgLayout ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fBackground->SetLayout( bgLayout	);
	bgLayout->SetInsets( 15, 10, 15, 10 );
	fBackground->SetViewColor( fCategory.categoryColor );
	BString sb = "Category:\n";
	sb << fCategory.categoryName;
	fBackground->SetToolTip( sb.String() );
	
	// Create Event's name view
	fTitle = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Event name",
									  fEventName.String(),
									  B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
	if ( !fTitle ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
		// Use big bold font for Event's name
	fTitle->SetFont( be_bold_font );
	fTitle->GetFont( &font );
	font.SetSize( font.Size() + 2 );
	fTitle->SetFont( &font, B_FONT_SIZE );
	
		// Add the title and set its tooltip
	fTitle->ResizeToPreferred();
	fTitle->SetToolTip( sb.String() );
	bgLayout->AddView( fTitle );
	fTitle->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	fTitle->SetToolTip( fEventName.String() );
	
	int	nextLineInLayout = 2;
	
	/*================================================================
	 * If the notification was set by the user, display it.
	 *================================================================*/

	BString 	tempString;
	BPath		path;
	float rectHeight = fh.leading + fh.ascent + fh.descent;
	float rectWidth = this->Bounds().Width() - 10;		// Layout insets
	BSize size( rectWidth, rectHeight );
	
	if ( fData->GetNotification( &tempString ) )
	{
		/*-----------------------------------------------------------------
	 	 * Line of explanation
	 	 *----------------------------------------------------------------*/
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Text view explanation",
									  "You set the following notification:" );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );

		/*-----------------------------------------------------------------
	 	 * Text view with notification text
	 	 *----------------------------------------------------------------*/
		BRect tempRect( BPoint( 0, 0 ), size );
		tempRect.right -= B_V_SCROLL_BAR_WIDTH;
		fNoteText = new BTextView( tempRect,
											"Notification text container",
											tempRect.InsetByCopy( 1, 1 ),
											B_FOLLOW_ALL_SIDES,
											B_WILL_DRAW );
		if ( !fNoteText ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		fNoteText->MakeEditable( false );
		fNoteText->SetText( tempString.String() );
		
		/*-----------------------------------------------------------------
	 	 * Scroll view to scroll the notification text
	 	 *----------------------------------------------------------------*/
		fTextScroller = new BScrollView( "Notification text scroller",
													fNoteText,
													B_FOLLOW_ALL_SIDES,
													0,
													false,
													true );
		if ( !fTextScroller ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		layoutItem = gridLayout->AddView( fTextScroller, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
//			layoutItem->SetExplicitMaxSize( size );
			layoutItem->SetExplicitMinSize( size );
			layoutItem->SetExplicitPreferredSize( size );
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
		}
	}	// <-- end of adding information about the notification
	
	/*================================================================
	 * If user wanted to play a sound file, notify him about it.
	 *================================================================*/
	if ( fData->GetSound( &path ) )
	{
		/*-----------------------------------------------------------------
	 	 * Line of explanation
	 	 *----------------------------------------------------------------*/
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Sound file explanation",
									  "You wanted to play the file:",
									  B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}

		/*-----------------------------------------------------------------
	 	 * Display sound file name
	 	 *----------------------------------------------------------------*/
	 	 
	 	// What should we display - full path or just the leaf?
	 	if ( ( size.width - 10 ) > plainFont.StringWidth( path.Path() ) )
	 	{
	 		tempString.SetTo( path.Path() );
	 	}
	 	else
	 	{
	 		tempString.SetTo( path.Leaf() );
	 	}
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Sound file name",
									  tempString.String() );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}
		
	}	// <-- end of displaying information about the sound file
	
	/*================================================================
	 * If user wanted to run a program, notify him about it.
	 *================================================================*/
	if ( fData->GetProgram( &path, &tempString ) )
	{
		/*-----------------------------------------------------------------
	 	 * Line of explanation
	 	 *----------------------------------------------------------------*/
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Program explanation",
									  "You wanted to run a program:" );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}

		/*-----------------------------------------------------------------
	 	 * Display path to program file
	 	 *----------------------------------------------------------------*/
	 	 
	 	// What should we display - full path or just the leaf?
	 	exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Program file name",
									  ( ( size.width - 10 ) > plainFont.StringWidth( path.Path() ) ) ?
									  		path.Path() :
									  		path.Leaf() );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}
		
		/*-----------------------------------------------------------------
	 	 * Explanation about the program options
	 	 *----------------------------------------------------------------*/
	 	 
	 	if ( tempString.Length() > 0 ) {
		 	exp = new BStringView( BRect( 0, 0, 1, 1 ),
										  "Program file options explanation",
										  "With the following parameters:" );
			if ( !exp ) {
				/* Panic! */
				fLastError = B_NO_MEMORY;
				return;
			}
			exp->ResizeToPreferred();
			layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
			if ( layoutItem ) {
				layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
			}
			
			/*-----------------------------------------------------------------
		 	 * Display the program options
		 	 *----------------------------------------------------------------*/
		 	 
		 	// What should we display - full path or just the leaf?
		 	exp = new BStringView( BRect( 0, 0, 1, 1 ),
										  "Program file options",
										  tempString.String() );
			if ( !exp ) {
				/* Panic! */
				fLastError = B_NO_MEMORY;
				return;
			}
			exp->ResizeToPreferred();
			layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
			if ( layoutItem ) {
				layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
			}
	 	}	// <-- end of diplaying CLI options		
	}	// <-- end of displaying information about the program to run
	
	/*================================================================
	 * Now it's time to display the Snooze time selector
	 *================================================================*/
	TimePreferences* prefs = pref_GetTimePreferences();
	if ( prefs ) {
		prefs->GetDefaultSnoozeTime( ( int* )&fSnoozeHours, ( int* )&fSnoozeMins );
	} else {
		fSnoozeHours = 0;
		fSnoozeMins = 10;
	}
	
	BMessage* toSend = new BMessage( kSnoozeTimeControlMessage );
	if ( ! toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnoozeTime = new GeneralHourMinControl( BRect( 0, 0, 1, 1 ),
														  "Snooze time selector",
														  "Snooze this Activtiy for:",
														  BString( "" ),	// No check box
														  toSend );
	if ( !fSnoozeTime ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnoozeTime->SetHoursLimit( 23 );	// Max reminder time delay is 23 hours 55 minutes
	fSnoozeTime->SetMinutesLimit( 55 );
	fSnoozeTime->SetCurrentTime( fSnoozeHours, fSnoozeMins );
	
	layoutItem = gridLayout->AddView( fSnoozeTime, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
	}
	

	/*================================================================
	 * Snooze button
	 *================================================================*/
	toSend = new BMessage( kSnoozeButtonPressed );
	if ( !toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnooze = new BButton( BRect( 0, 0, 1, 1 ),
								  "Snooze button",
								  "Snooze",
								  toSend,
								  B_FOLLOW_LEFT | B_FOLLOW_TOP );
	if ( !fSnooze ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnooze->ResizeToPreferred();
	layoutItem = gridLayout->AddView( fSnooze, 0, nextLineInLayout );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
	}

	/*================================================================
	 * Ok button
	 *================================================================*/
	toSend = new BMessage( kDismissButtonPressed );
	if ( !toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fOk = new BButton( BRect( 0, 0, 1, 1 ),
							  "Dismiss button",
							  "Dismiss",
							  toSend,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP );
	if ( !fOk ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnooze->ResizeToPreferred();
	layoutItem = gridLayout->AddView( fOk, 1, nextLineInLayout );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_TOP ) );
	}

	this->CenterOnScreen();	
}	// <-- end of constructor for ActivityWindow
示例#11
0
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
{
    if (!validIndex(tabIndex)) {
        qWarning("invalid index");
        return;
    }
    painter->save();

    QRect rect = tabRect(tabIndex);
    bool selected = (tabIndex == m_currentIndex);
    bool enabled = isTabEnabled(tabIndex);

    if (selected) {
        //jassuncao:if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
        if(true) {
          // background color of a fancy tab that is active
          painter->fillRect(rect.adjusted(0, 0, 0, -1), QColor(0x90,0x90,0x90,0xFF));
        } else {
            //background
            painter->save();
            QLinearGradient grad(rect.topLeft(), rect.topRight());
            grad.setColorAt(0, QColor(255, 255, 255, 140));
            grad.setColorAt(1, QColor(255, 255, 255, 210));
            painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
            painter->restore();

            //shadows
            painter->setPen(QColor(0, 0, 0, 110));
            painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1));
            painter->drawLine(rect.bottomLeft(), rect.bottomRight());
            painter->setPen(QColor(0, 0, 0, 40));
            painter->drawLine(rect.topLeft(), rect.bottomLeft());

            //highlights
            painter->setPen(QColor(255, 255, 255, 50));
            painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2));
            painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1));
            painter->setPen(QColor(255, 255, 255, 40));
            painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
            painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
            painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1));
        }
    }

    QString tabText(this->tabText(tabIndex));
    QRect tabTextRect(rect);
    const bool drawIcon = rect.height() > 36;
    QRect tabIconRect(tabTextRect);
    tabTextRect.translate(0, drawIcon ? -2 : 1);
    QFont boldFont(painter->font());
    //jassuncao boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
    boldFont.setPointSizeF(8);
    boldFont.setBold(true);
    painter->setFont(boldFont);
    painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
    const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;


#if defined(Q_OS_MAC)
    bool isMacHost = true;
#else
    bool isMacHost = false;
#endif

    if (!isMacHost && !selected && enabled) {
        painter->save();
        int fader = int(m_tabs[tabIndex]->fader());
        //jassuncaoif (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
        if(true) {
            //QColor c = creatorTheme()->color(Theme::BackgroundColorHover);
            QColor c(0x51,0x51,0x51,0xFF);
            c.setAlpha(int(255 * fader/40.0)); // FIXME: hardcoded end value 40
            painter->fillRect(rect, c);
        } else {
            QLinearGradient grad(rect.topLeft(), rect.topRight());
            grad.setColorAt(0, Qt::transparent);
            grad.setColorAt(0.5, QColor(255, 255, 255, fader));
            grad.setColorAt(1, Qt::transparent);
            painter->fillRect(rect, grad);
            painter->setPen(QPen(grad, 1.0));
            painter->drawLine(rect.topLeft(), rect.topRight());
            painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        }
        painter->restore();
    }

    if (!enabled)
        painter->setOpacity(0.7);

    if (drawIcon) {
        int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
        tabIconRect.adjust(0, 4, 0, -textHeight);
        //jassuncao StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
        drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
    }

    painter->setOpacity(1.0); //FIXME: was 0.7 before?
    /*jassuncao
    if (enabled) {
        painter->setPen(selected
          ? creatorTheme()->color(Theme::FancyTabWidgetEnabledSelectedTextColor)
          : creatorTheme()->color(Theme::FancyTabWidgetEnabledUnselectedTextColor));
    } else {
        painter->setPen(selected
          ? creatorTheme()->color(Theme::FancyTabWidgetDisabledSelectedTextColor)
          : creatorTheme()->color(Theme::FancyTabWidgetDisabledUnselectedTextColor));
    }
    */
    if (enabled) {
        painter->setPen(selected
          ? QColor(0x3C,0x3C,0x3C,0xFF)
          : QColor(0xFF,0xFF,0xFF,0xFF));
    } else {
        painter->setPen(selected
          ? QColor(0xFF,0xFF,0xFF,0xFF)
          : QColor(0xFF,0xFF,0xFF,0x78));
    }
    painter->translate(0, -1);
    painter->drawText(tabTextRect, textFlags, tabText);

    painter->restore();
}
示例#12
0
void wxCurlTransferDialog::CreateControls(const wxString &url, const wxString &msg, 
                                      const wxString &sizeLabel, const wxBitmap &bitmap)
{
    wxBoxSizer* main = new wxBoxSizer(wxVERTICAL);

    // message row
    if (!msg.IsEmpty())
    {
        wxStaticText *st = new wxStaticText( this, wxID_STATIC, msg );
        st->SetMinSize(wxSize(MINWIDTH, -1));
        main->Add(st, 0, wxLEFT|wxTOP|wxRIGHT|wxBOTTOM|wxGROW, OUTER_BORDER);
    }

    // URL row
    if (HasFlag(wxCTDS_URL))
    {
        wxBoxSizer* downloading = new wxBoxSizer(wxHORIZONTAL);

        wxStaticText *st = new wxStaticText( this, wxID_STATIC, _("URL:") );
        wxFont boldFont(st->GetFont());
        boldFont.SetWeight(wxFONTWEIGHT_BOLD);
        st->SetFont(boldFont);
        downloading->Add(st, 0, wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, BORDER);

        m_pURL = new wxStaticText( this, wxID_STATIC, url, wxDefaultPosition,
                                   wxSize(MINWIDTH, -1));//, wxST_ELLIPSIZE_MIDDLE);
        downloading->Add(m_pURL, 1, wxALIGN_CENTER_VERTICAL|wxTOP, BORDER);

        main->Add(downloading, 0, wxGROW|wxLEFT|wxRIGHT, OUTER_BORDER);
        main->AddSpacer(5);
    }


    wxSizer *leftcolumn = new wxBoxSizer(wxVERTICAL);

    // speed & size row
    if (HasFlag(wxCTDS_SPEED))
        m_pSpeed = AddSizerRow(leftcolumn, wxS("Speed:"));
    if (HasFlag(wxCTDS_SIZE))
        m_pSize = AddSizerRow(leftcolumn, sizeLabel);

    // a spacer
    leftcolumn->AddSpacer(5);

    // the time rows
    if (HasFlag(wxCTDS_ELAPSED_TIME))
        m_pElapsedTime = AddSizerRow(leftcolumn, wxS("Elapsed time:"));
    if (HasFlag(wxCTDS_ESTIMATED_TIME))
        m_pEstimatedTime = AddSizerRow(leftcolumn, wxS("Estimated total time:"));
    if (HasFlag(wxCTDS_REMAINING_TIME))
        m_pRemainingTime = AddSizerRow(leftcolumn, wxS("Estimated remaining time:"));

    if (bitmap.IsOk())
    {
        wxSizer *rightcolumn = new wxBoxSizer(wxVERTICAL);
        rightcolumn->Add( new wxStaticBitmap(this, wxID_ANY, bitmap),
                          0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, BORDER);

        wxSizer *both = new wxBoxSizer(wxHORIZONTAL);
        both->Add(leftcolumn);
        both->Add(rightcolumn, 1, wxGROW);
        main->Add(both, 0, wxGROW);
    }
    else
        main->Add(leftcolumn);


    // the gauge
    // VERY IMPORTANT: we set as range 101 so that when, because of some approximation,
    //                 the update event handler will SetValue(100), while the transfer
    //                 is not yet complete, the gauge will not appear completely filled.
    m_pGauge = new wxGauge( this, wxID_ANY, 101 );

    main->AddSpacer(5);
    main->Add(m_pGauge, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, OUTER_BORDER);

    // do we need to use wxCurlConnectionSettingsDialog?
    bool needsConnSettings = HasFlag(wxCTDS_CONN_SETTINGS_AUTH) ||
                             HasFlag(wxCTDS_CONN_SETTINGS_PORT) ||
                             HasFlag(wxCTDS_CONN_SETTINGS_PROXY);

    // an horizontal line of buttons
    if (HasFlag(wxCTDS_CAN_ABORT) || HasFlag(wxCTDS_CAN_PAUSE) || HasFlag(wxCTDS_CAN_START) ||
        needsConnSettings)
    {
        main->AddStretchSpacer(1);
        main->AddSpacer(BORDER*2);
        main->Add( new wxStaticLine(this), 0, wxGROW|wxLEFT|wxRIGHT, OUTER_BORDER);

        // the button row
        wxBoxSizer *btn = new wxBoxSizer(wxHORIZONTAL);

        if (HasFlag(wxCTDS_CAN_ABORT))
            btn->Add(new wxButton( this, AbortButtonId, _("Abort") ), 0, wxRIGHT, BORDER);
        if (needsConnSettings)
            btn->Add(new wxButton( this, ConnSettingsButtonId, _("Settings") ), 0);

        btn->AddStretchSpacer(1);

        if (HasFlag(wxCTDS_CAN_PAUSE))
            btn->Add(new wxButton( this, PauseResumeButtonId, _("Pause") ), 0);
        if (HasFlag(wxCTDS_CAN_START))
            btn->Add(new wxButton( this, StartButtonId, _("Start") ), 0, wxLEFT, BORDER);

        main->Add(btn, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, OUTER_BORDER);
    }

    this->SetSizerAndFit(main);
    main->SetSizeHints(this);
}
示例#13
0
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
{
    if (!validIndex(tabIndex)) {
        qWarning("invalid index");
        return;
    }
    painter->save();

    QRect rect = tabRect(tabIndex);
    bool selected = (tabIndex == m_currentIndex);
    bool enabled = isTabEnabled(tabIndex);

    if (selected) {
        //background
        painter->save();
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, QColor(255, 255, 255, 140));
        grad.setColorAt(1, QColor(255, 255, 255, 210));
        painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
        painter->restore();

        //shadows
        painter->setPen(QColor(0, 0, 0, 110));
        painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1));
        painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        painter->setPen(QColor(0, 0, 0, 40));
        painter->drawLine(rect.topLeft(), rect.bottomLeft());

        //highlights
        painter->setPen(QColor(255, 255, 255, 50));
        painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2));
        painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1));
        painter->setPen(QColor(255, 255, 255, 40));
        painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
        painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
        painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1));
    }

    QString tabText(this->tabText(tabIndex));
    QRect tabTextRect(tabRect(tabIndex));
    QRect tabIconRect(tabTextRect);
    tabTextRect.translate(0, -2);
    QFont boldFont(painter->font());
    boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    painter->setFont(boldFont);
    painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
    int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::TextWordWrap;
    if (enabled) {
        painter->drawText(tabTextRect, textFlags, tabText);
        painter->setPen(selected ? QColor(60, 60, 60) : StyleHelper::panelTextColor());
    } else {
        painter->setPen(selected ? StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
    }
#ifndef Q_WS_MAC
    if (!selected && enabled) {
        painter->save();
        int fader = int(m_tabs[tabIndex]->fader());
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, Qt::transparent);
        grad.setColorAt(0.5, QColor(255, 255, 255, fader));
        grad.setColorAt(1, Qt::transparent);
        painter->fillRect(rect, grad);
        painter->setPen(QPen(grad, 1.0));
        painter->drawLine(rect.topLeft(), rect.topRight());
        painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        painter->restore();
    }
#endif

    if (!enabled)
        painter->setOpacity(0.7);

    int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
    tabIconRect.adjust(0, 4, 0, -textHeight);
    StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);

    painter->translate(0, -1);
    painter->drawText(tabTextRect, textFlags, tabText);
    painter->restore();
}
示例#14
0
void ProgressBar::paintEvent(QPaintEvent *)
{
    // TODO move font into stylehelper
    // TODO use stylehelper white

    double range = maximum() - minimum();
    double percent = 0.50;
    if (range != 0)
        percent = (value() - minimum()) / range;
    if (percent > 1)
        percent = 1;
    else if (percent < 0)
        percent = 0;

    QPainter p(this);
    QFont boldFont(p.font());
    boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    p.setFont(boldFont);
    QFontMetrics fm(boldFont);

    // Draw separator
    int h = fm.height();
    p.setPen(QColor(0, 0, 0, 70));
    p.drawLine(0,0, size().width(), 0);

    p.setPen(QColor(255, 255, 255, 70));
    p.drawLine(0, 1, size().width(), 1);

    p.setPen(StyleHelper::panelTextColor());
    p.drawText(QPoint(7, h+1), m_title);

    m_progressHeight = h-4;
    m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
    // draw outer rect
    QRect rect(INDENT, h+6, size().width()-2*INDENT-m_progressHeight+1, m_progressHeight-1);
    p.setPen(StyleHelper::panelTextColor());
    p.drawRect(rect);

    // draw inner rect
    QColor c = StyleHelper::panelTextColor();
    c.setAlpha(180);
    p.setPen(Qt::NoPen);
    p.setBrush(c);
    QRect inner = rect.adjusted(2, 2, -1, -1);
    inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
    if (m_error) {
        // TODO this is not fancy enough
        QColor red(255, 0, 0, 180);
        p.setBrush(red);
        // avoid too small red bar
        if (inner.width() < 10)
            inner.adjust(0, 0, 10 - inner.width(), 0);
    } else if (value() == maximum()) {
        QColor green(140, 255, 140, 180);
        p.setBrush(green);
    }
    p.drawRect(inner);

    if (value() < maximum() && !m_error) {
        // draw cancel thingy
        // TODO this is quite ugly at the moment
        p.setPen(StyleHelper::panelTextColor());
        p.setBrush(QBrush(Qt::NoBrush));
        QRect cancelRect(size().width()-INDENT-m_progressHeight+3, h+6+1, m_progressHeight-3, m_progressHeight-3);
        p.drawRect(cancelRect);
        p.setPen(c);
        p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
        p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));
    }
}
示例#15
0
void ProgressBar::paintEvent(QPaintEvent *)
{
    // TODO move font into Utils::StyleHelper
    // TODO use Utils::StyleHelper white

    double range = maximum() - minimum();
    double percent = 0.50;
    if (range != 0)
        percent = (value() - minimum()) / range;
    if (percent > 1)
        percent = 1;
    else if (percent < 0)
        percent = 0;

    QPainter p(this);
    QFont boldFont(p.font());
    boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    p.setFont(boldFont);
    QFontMetrics fm(boldFont);

    // Draw separator
    int h = fm.height();
    p.setPen(QColor(0, 0, 0, 70));
    p.drawLine(0,0, size().width(), 0);

    p.setPen(QColor(255, 255, 255, 70));
    p.drawLine(0, 1, size().width(), 1);

    QRect textRect = rect().adjusted(0, 0, -1, 0);
    textRect.setHeight(h+5);

    p.setPen(QColor(30, 30, 30, 80));
    p.drawText(textRect, Qt::AlignHCenter | Qt::AlignBottom, m_title);
    p.translate(0, -1);
    p.setPen(Utils::StyleHelper::panelTextColor());
    p.drawText(textRect, Qt::AlignHCenter | Qt::AlignBottom, m_title);
    p.translate(0, 1);

    m_progressHeight = PROGRESSBAR_HEIGHT;
    m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
    // draw outer rect
    QRect rect(INDENT - 1, h+6, size().width()-2*INDENT, m_progressHeight-1);
    p.setPen(Utils::StyleHelper::panelTextColor());
    p.drawRect(rect);

    // draw inner rect
    QColor c = Utils::StyleHelper::panelTextColor();
    c.setAlpha(180);
    p.setPen(Qt::NoPen);

    QRect inner = rect.adjusted(2, 2, -1, -1);
    inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
    if (m_error) {
        QColor red(255, 60, 0, 210);
        c = red;
        // avoid too small red bar
        if (inner.width() < 10)
            inner.adjust(0, 0, 10 - inner.width(), 0);
    } else if (value() == maximum()) {
        c = QColor(120, 245, 90, 180);
    }

    QLinearGradient grad(inner.topLeft(), inner.bottomLeft());
    grad.setColorAt(0, c.lighter(114));
    grad.setColorAt(0.5, c.lighter(104));
    grad.setColorAt(0.51, c.darker(108));
    grad.setColorAt(1, c.darker(120));

    p.setBrush(grad);
    p.drawRect(inner);

    if (value() < maximum() && !m_error) {
        QColor cancelOutline = Utils::StyleHelper::panelTextColor();
        p.setPen(cancelOutline);
        QRect cancelRect(rect.right() - m_progressHeight + 2, rect.top(), m_progressHeight-1, rect.height());
        if (cancelRect.contains(mapFromGlobal(QCursor::pos())))
            p.setBrush(QColor(230, 90, 40, 190));
        else
            p.setBrush(Qt::NoBrush);

        p.drawRect(cancelRect);

        p.setPen(QPen(QColor(0, 0, 0, 70), 3));
        p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
        p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));

        p.setPen(Utils::StyleHelper::panelTextColor());
        p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
        p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));
    }
}