Пример #1
0
void Canvas::draw_zoom_rectangle( wxDC *dc )
{
    wxRect drawn_rect = get_rect_by_corners( drag_start, drag_end );
    wxRect max_rect( 
        wxSize( contents->GetWidth(), contents->GetHeight() )
            * zoom_in_level / zoom_out_level );
    if ( drawn_rect.Intersects( max_rect ) )
        draw_rectangle( drawn_rect.Intersect( max_rect ), dc );
}
Пример #2
0
QSize Header::sizeHint() const
{
	QRectF max_rect(-Padding, 0, Padding, 0);
	const vector<shared_ptr<TraceTreeItem>> items(
		view_.list_by_type<TraceTreeItem>());
	for (auto &i : items)
		if (i->enabled())
			max_rect = max_rect.united(i->label_rect(QRect()));
	return QSize(max_rect.width() + Padding + BaselineOffset, 0);
}
Пример #3
0
int main()
{
    int M[R][C] = {{1, 2, -1, -4, -20},
                       {-8, -3, 4, 2, 1},
                       {3, 8, 10, 1, 3},
                       {-4, -1, 1, 7, -6}
                      };
 
    max_rect(M);
 
    return 0;
}
Пример #4
0
QPixmap EC_ChatBubble::GetChatBubblePixmap()
{
    if (renderer_.expired())
        return 0;

///\todo    Resize the chat bubble and font size according to the render window size and distance
///         avatar's distance from the camera.
//    const int minWidth =
//    const int minHeight =
//    Ogre::Viewport* viewport = renderer_.lock()->GetViewport();
//    const int max_width = viewport->getActualWidth()/4;
//    int max_height = viewport->getActualHeight()/10;

    const int max_width = 1500;
    int max_height = 800;
    QRect max_rect(0, 0, max_width, max_height);

    const QString &filename("./media/textures/Transparent.png");
    assert(QFile::exists(filename));
    if (!QFile::exists(filename))
        return 0;

    // Create pixmap
    QPixmap pixmap;//(max_rect.size());
//    pixmap.fill(QColor(0,0,0,0));
    pixmap.load(filename);
    pixmap = pixmap.scaled(max_rect.size());

    // Gather chat log and calculate the bounding rect size.
    QStringListIterator it(messages_);
    QString fullChatLog;
    while(it.hasNext())
    {
        fullChatLog.append(it.next());
        if (it.hasNext())
            fullChatLog.append('\n');
    }

    QPainter painter(&pixmap);
    painter.setFont(font_);

    // Set padding for text.
    // Make the font size temporarily bigger when calculating bounding rect
    // so we get padding without need to modify the rect itself.
    QFont origFont = painter.font();
    painter.setFont(QFont(origFont.family(), origFont.pointSize()+12));
    QRect rect = painter.boundingRect(max_rect, Qt::AlignCenter | Qt::TextWordWrap, fullChatLog);
    painter.setFont(origFont);
    // could also try this:
    // QFontMetrics metric(any_qfont); int width = metric.width(mytext) + padding;

    rect.setHeight(rect.height() - 10);
//    rect.setX(rect.x() - 40);
//    rect.setY(rect.y() + 20);

//    painter.end();
//    pixmap = pixmap.scaled(rect.size());
//    painter.begin(&pixmap);

    // Draw rounded rect.
    QBrush brush(bubbleColor_, Qt::SolidPattern);
    painter.setBrush(brush);
    painter.drawRoundedRect(rect, 20.0, 20.0);

    // Draw text
    painter.setPen(textColor_);
    painter.drawText(rect, Qt::AlignCenter | Qt::TextWordWrap, fullChatLog);

    return pixmap;
}