Beispiel #1
0
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = renderer().style(isFirstLineStyle());
    const Font& font = style->font();
    FloatPoint boxOrigin = locationIncludingFlipping();
    boxOrigin.moveBy(FloatPoint(paintOffset));
    if (!isHorizontal())
        boxOrigin.move(0, -virtualLogicalHeight());
    FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
    GraphicsContextStateSaver stateSaver(*context);
    if (!isHorizontal())
        context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
    FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());

    bool isPrinting = renderer().document().printing();
    bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && selectionState() != RenderObject::SelectionNone;

    if (haveSelection)
        paintSelection(context, boxOrigin, style, font);
    else if (paintInfo.phase == PaintPhaseSelection)
        return;

    TextPainter::Style textStyle = TextPainter::textPaintingStyle(renderer(), style, paintInfo.forceBlackText(), isPrinting);
    if (haveSelection)
        textStyle = TextPainter::selectionPaintingStyle(renderer(), true, paintInfo.forceBlackText(), isPrinting, textStyle);

    TextRun textRun = constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
    TextPainter textPainter(context, font, textRun, textOrigin, boxRect, isHorizontal());
    textPainter.paint(0, m_str.length(), m_str.length(), textStyle);

    paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
Beispiel #2
0
void FWRenderer::drawTransparentBox(int x, int y, int width, int height) {
	// Handle horizontally flipped boxes
	if (width < 0) {
		width = ABS(width);
		x -= width;
	}

	// Handle vertically flipped boxes
	if (height < 0) {
		height = ABS(height);
		y -= height;
	}

	// Clip the rectangle to screen dimensions
	Common::Rect boxRect(x, y, x + width, y + height);
	Common::Rect screenRect(320, 200);
	boxRect.clip(screenRect);

	byte *dest = _backBuffer + boxRect.top * 320 + boxRect.left;
	const int lineAdd = 320 - boxRect.width();
	for (int i = 0; i < boxRect.height(); ++i) {
		for (int j = 0; j < boxRect.width(); ++j, ++dest) {
			if (*dest < 16)
				*dest += 16;
		}
		dest += lineAdd;
	}
}
Beispiel #3
0
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = m_renderer->style(isFirstLineStyle());
    Color styleTextColor = style->visitedDependentColor(CSSPropertyWebkitTextFillColor);
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor, style->colorSpace());

    Color textColor = styleTextColor;
    const Font& font = style->font();
    if (selectionState() != RenderObject::SelectionNone) {
        paintSelection(context, paintOffset, style, font);

        // Select the correct color for painting the text.
        Color foreground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionForegroundColor();
        if (foreground.isValid() && foreground != styleTextColor)
            context->setFillColor(foreground, style->colorSpace());
    }

    const ShadowData* shadow = style->textShadow();
    bool hasShadow = shadow;
    if (hasShadow) {
        // FIXME: it would be better if we could get the shadows top-to-bottom from the style.
        Vector<const ShadowData*, 4> shadows;
        do {
            shadows.append(shadow);
        } while ((shadow = shadow->next()));

        DrawLooper drawLooper;
        drawLooper.addUnmodifiedContent();
        for (int i = shadows.size() - 1; i >= 0; i--) {
            shadow = shadows[i];
            int shadowX = isHorizontal() ? shadow->x() : shadow->y();
            int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
            FloatSize offset(shadowX, shadowY);
            drawLooper.addShadow(offset, shadow->blur(), shadow->color(),
                DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
        }
        context->setDrawLooper(drawLooper);
    }

    // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
    FloatPoint boxOrigin(paintOffset);
    boxOrigin.move(x(), y());
    FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight()));
    FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + style->fontMetrics().ascent());
    TextRun textRun = RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
    TextRunPaintInfo textRunPaintInfo(textRun);
    textRunPaintInfo.bounds = boxRect;
    context->drawText(font, textRunPaintInfo, textOrigin);

    // Restore the regular fill color.
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor, style->colorSpace());

    if (hasShadow)
        context->clearDrawLooper();

    paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
Beispiel #4
0
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = renderer().style(isFirstLineStyle());

    const Font& font = style->font();
    FloatPoint boxOrigin = locationIncludingFlipping();
    boxOrigin.moveBy(FloatPoint(paintOffset));
    if (!isHorizontal())
        boxOrigin.move(0, -virtualLogicalHeight());
    FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
    GraphicsContextStateSaver stateSaver(*context);
    if (!isHorizontal())
        context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
    FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());

    Color styleTextColor = renderer().resolveColor(style, CSSPropertyWebkitTextFillColor);
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor);

    if (selectionState() != RenderObject::SelectionNone) {
        paintSelection(context, boxOrigin, style, font);

        // Select the correct color for painting the text.
        Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
        if (foreground != styleTextColor)
            context->setFillColor(foreground);
    }

    // Text shadows are disabled when printing. http://crbug.com/258321
    const ShadowList* shadowList = context->printing() ? 0 : style->textShadow();
    bool hasShadow = shadowList;
    if (hasShadow) {
        OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
        for (size_t i = shadowList->shadows().size(); i--; ) {
            const ShadowData& shadow = shadowList->shadows()[i];
            float shadowX = isHorizontal() ? shadow.x() : shadow.y();
            float shadowY = isHorizontal() ? shadow.y() : -shadow.x();
            FloatSize offset(shadowX, shadowY);
            drawLooperBuilder->addShadow(offset, shadow.blur(), shadow.color(),
                DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::ShadowIgnoresAlpha);
        }
        drawLooperBuilder->addUnmodifiedContent();
        context->setDrawLooper(drawLooperBuilder.release());
    }

    TextRun textRun = RenderBlockFlow::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
    TextRunPaintInfo textRunPaintInfo(textRun);
    textRunPaintInfo.bounds = boxRect;
    context->drawText(font, textRunPaintInfo, textOrigin);

    // Restore the regular fill color.
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor);

    if (hasShadow)
        context->clearDrawLooper();

    paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
void
CheckBoxItem::DrawItem(BView* owner, BRect itemRect, bool drawEverything)
{
	BStringItem::DrawItem(owner, itemRect, drawEverything);

	if (!be_control_look)
		return;

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	uint32 flags = 0;
	if (fMouseDown)
		flags |= BControlLook::B_CLICKED;
	if (fChecked)
		flags |= BControlLook::B_ACTIVATED;
	font_height fontHeight;
	owner->GetFontHeight(&fontHeight);
	BRect boxRect(0.0f, 2.0f, ceilf(3.0f + fontHeight.ascent),
		ceilf(5.0f + fontHeight.ascent));

	fBoxRect.left = itemRect.right - boxRect.Width();
	fBoxRect.top = itemRect.top + (itemRect.Height() - boxRect.Height()) / 2;
	fBoxRect.right = itemRect.right;
	fBoxRect.bottom = itemRect.top + boxRect.Height();

	be_control_look->DrawCheckBox(owner, fBoxRect, fBoxRect, base, flags);
}
IntRect RenderInline::clippedOverflowRectForRepaint(RenderBox* repaintContainer)
{
    // Only run-ins are allowed in here during layout.
    ASSERT(!view() || !view()->layoutStateEnabled() || isRunIn());

    if (!firstLineBox() && !continuation())
        return IntRect();

    // Find our leftmost position.
    IntRect boundingBox(linesBoundingBox());
    int left = boundingBox.x();
    int top = boundingBox.y();

    // Now invalidate a rectangle.
    int ow = style() ? style()->outlineSize() : 0;
    
    // We need to add in the relative position offsets of any inlines (including us) up to our
    // containing block.
    RenderBlock* cb = containingBlock();
    for (RenderObject* inlineFlow = this; inlineFlow && inlineFlow->isRenderInline() && inlineFlow != cb; 
         inlineFlow = inlineFlow->parent()) {
         if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer())
            toRenderBox(inlineFlow)->layer()->relativePositionOffset(left, top);
    }

    IntRect r(-ow + left, -ow + top, boundingBox.width() + ow * 2, boundingBox.height() + ow * 2);
    if (cb->hasColumns())
        cb->adjustRectForColumns(r);

    if (cb->hasOverflowClip()) {
        // cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
        // layer's size instead.  Even if the layer's size is wrong, the layer itself will repaint
        // anyway if its size does change.
        int x = r.x();
        int y = r.y();
        IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
        cb->layer()->subtractScrolledContentOffset(x, y); // For overflow:auto/scroll/hidden.
        IntRect repaintRect(x, y, r.width(), r.height());
        r = intersection(repaintRect, boxRect);
    }
    ASSERT(repaintContainer != this);
    cb->computeRectForRepaint(r, repaintContainer);

    if (ow) {
        for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
            if (!curr->isText()) {
                IntRect childRect = curr->rectWithOutlineForRepaint(repaintContainer, ow);
                r.unite(childRect);
            }
        }

        if (continuation() && !continuation()->isInline()) {
            IntRect contRect = continuation()->rectWithOutlineForRepaint(repaintContainer, ow);
            r.unite(contRect);
        }
    }

    return r;
}
Beispiel #7
0
//
/// Returns the size of the maximize box rectangle.
//
TRect
TTinyCaption::GetMaxBoxRect()
{
    TRect boxRect(GetCaptionRect());
    boxRect.left = boxRect.right - CaptionHeight;
    boxRect.top -= 1;
    boxRect.right += 1;
    return boxRect;
}
Beispiel #8
0
//
/// Returns the size of the system box rectangle.
//
TRect
TTinyCaption::GetSysBoxRect()
{
    TRect boxRect(GetCaptionRect());
    boxRect.right = boxRect.left + CaptionHeight;
    boxRect.left -= 1;
    boxRect.top -= 1;
    return boxRect;
}
Beispiel #9
0
//
/// Returns the size of the minimize box rectangle.
//
TRect
TTinyCaption::GetMinBoxRect()
{
    // Far right on caption if no max box, else next to max box
    //
    TRect boxRect(GetMaxBoxRect());
    if (GetWindowLong(GWL_STYLE) & WS_MAXIMIZEBOX)
        boxRect.Offset(-CaptionHeight, 0);
    return boxRect;
}
Beispiel #10
0
bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth)
{
    // Non-replaced elements can always accommodate an ellipsis.
    if (!m_object || !m_object->isReplaced())
        return true;
    
    IntRect boxRect(m_x, 0, m_width, 10);
    IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsisWidth, 10);
    return !(boxRect.intersects(ellipsisRect));
}
Beispiel #11
0
bool InlineBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const
{
    // Non-replaced elements can always accommodate an ellipsis.
    if (!m_renderer || !m_renderer->isReplaced())
        return true;
    
    IntRect boxRect(left(), 0, m_logicalWidth, 10);
    IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsisWidth, 10);
    return !(boxRect.intersects(ellipsisRect));
}
Beispiel #12
0
//===========================PrefsWindow======================================
PrefsWindow::PrefsWindow(BRect frame, BMessenger *messenger) 
				:	BWindow(frame, "Preferences", B_FLOATING_WINDOW, B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_NOT_CLOSABLE|B_ASYNCHRONOUS_CONTROLS),
					m_msgr(messenger),
					m_colourPrefsChanged(false),
					m_fontSizeChanged(false),
					m_toolbarChanged(false)
{	
	SetFeel(B_NORMAL_WINDOW_FEEL);
	
	m_parent = new BView(Bounds(), "parent", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	m_parent->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(m_parent);
	
	prefsLock.Lock();	
	BFont font(be_fixed_font);
	float fontSize = 10.0f;
	if (preferences.FindFloat(K_FONT_SIZE, &fontSize) == B_OK)
		font.SetSize(fontSize);
	prefsLock.Unlock();
		
	float prefsListWidth = 80.0f;		
	BRect prefsListFrame(10.0f, 10.0f, 10.0f + prefsListWidth, Bounds().bottom - 10.0f);	
	PrefsListView *prefsListView = new PrefsListView(prefsListFrame, m_parent);
	BScrollView *prefsListScroll = new BScrollView("ScrollView", prefsListView, B_FOLLOW_LEFT | B_FOLLOW_TOP,B_WILL_DRAW,false,false);
	m_parent->AddChild(prefsListScroll);
		
	float 	bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f
			;
	
	BRect okButtonFrame(Bounds().right - bspacing - bwidth, Bounds().bottom - bspacing - bheight, Bounds().right - bspacing,Bounds().bottom - bspacing);
	BButton *okButton = new BButton(okButtonFrame, "okButton", "Ok", new BMessage(PrefsConstants::K_PREFS_VIEW_OK));
	m_parent->AddChild(okButton);
	okButton->MakeDefault(true);
	
	BRect cancelButtonFrame = okButtonFrame;
	cancelButtonFrame.OffsetBy(-(bwidth + 2.0f * bspacing), 0.0f);
	BButton *cancelButton = new BButton(cancelButtonFrame,"cancelButton","Cancel",new BMessage(PrefsConstants::K_PREFS_VIEW_CANCEL));
	m_parent->AddChild(cancelButton);
	
	float respiteWidth = 41.0f;
	BRect boxRect(10.0f + prefsListWidth + 10.0f , 2.0f, Bounds().right - 7.0f , Bounds().bottom - 10.0f - respiteWidth);	
	prefsListView->AddItem(new PrefsListItem(constructGeneralBox(boxRect), m_parent, "General"));
	prefsListView->AddItem(new PrefsListItem(constructCommandBox(boxRect), m_parent, "Commands"));
	prefsListView->AddItem(new PrefsListItem(constructColourBox(boxRect), m_parent, "TexView"));
	prefsListView->AddItem(new PrefsListItem(constructToolbarBox(boxRect), m_parent, "Toolbars"));	
	prefsListView->Select(0);
	prefsListView->MakeFocus(true);	
}
void PipelineFlowChart::mousePressEvent(QMouseEvent *e)
{
  if(e->button() == Qt::LeftButton)
  {
    const int num = numItems();
    for(int i = 0; i < numItems(); i++)
    {
      if(boxRect(i).contains(e->pos()))
      {
        setSelectedStage(i);
        break;
      }
    }
  }
}
Beispiel #14
0
void RenderSVGText::absoluteQuads(Vector<FloatQuad>& quads)
{
    RenderSVGRoot* root = findSVGRootObject(parent());
    if (!root)
        return;
 
    // Don't use objectBoundingBox here, as it's unites the selection rects. Makes it hard
    // to spot errors, if there are any using WebInspector. Individually feed them into 'rects'.
    for (InlineFlowBox* flow = firstLineBox(); flow; flow = flow->nextLineBox()) {
        for (InlineBox* box = flow->firstChild(); box; box = box->nextOnLine()) {
            FloatRect boxRect(box->x(), box->y(), box->width(), box->height());
            // FIXME: crawling up the parent chain to map each quad is very inefficient
            // we should compute the absoluteTransform outside this loop first.
            quads.append(localToAbsoluteQuad(boxRect));
        }
    }
}
void PipelineFlowChart::mouseMoveEvent(QMouseEvent *e)
{
  int old = m_HoverStage;
  m_HoverStage = -1;

  const int num = numItems();
  for(int i = 0; i < num; i++)
  {
    if(boxRect(i).contains(e->pos()))
    {
      m_HoverStage = i;
      break;
    }
  }

  if(m_HoverStage != old)
    update();
}
Beispiel #16
0
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
    GraphicsContext* context = paintInfo.context;
    RenderStyle* style = renderer().style(isFirstLineStyle());

    const Font& font = style->font();
    FloatPoint boxOrigin = locationIncludingFlipping();
    boxOrigin.moveBy(FloatPoint(paintOffset));
    FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
    GraphicsContextStateSaver stateSaver(*context);
    FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());

    Color styleTextColor = renderer().resolveColor(style, CSSPropertyWebkitTextFillColor);
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor);

    if (selectionState() != RenderObject::SelectionNone) {
        paintSelection(context, boxOrigin, style, font);

        // Select the correct color for painting the text.
        Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
        if (foreground != styleTextColor)
            context->setFillColor(foreground);
    }

    const ShadowList* shadowList = style->textShadow();
    bool hasShadow = shadowList;
    if (hasShadow)
        context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::ShadowIgnoresAlpha));

    TextRun textRun = constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
    TextRunPaintInfo textRunPaintInfo(textRun);
    textRunPaintInfo.bounds = boxRect;
    context->drawText(font, textRunPaintInfo, textOrigin);

    // Restore the regular fill color.
    if (styleTextColor != context->fillColor())
        context->setFillColor(styleTextColor);

    if (hasShadow)
        context->clearDrawLooper();

    paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
void RenderSVGText::absoluteRects(Vector<IntRect>& rects, int, int)
{
    RenderSVGRoot* root = findSVGRootObject(parent());
    if (!root)
        return;
 
    // Don't use objectBoundingBox here, as it's unites the selection rects. Makes it hard
    // to spot errors, if there are any using WebInspector. Individually feed them into 'rects'.
    for (InlineRunBox* runBox = firstLineBox(); runBox; runBox = runBox->nextLineBox()) {
        ASSERT(runBox->isInlineFlowBox());

        InlineFlowBox* flowBox = static_cast<InlineFlowBox*>(runBox);
        for (InlineBox* box = flowBox->firstChild(); box; box = box->nextOnLine()) {
            FloatRect boxRect(box->x(), box->y(), box->width(), box->height());
            // FIXME: crawling up the parent chain to map each rect is very inefficient
            // we should compute the absoluteTransform outside this loop first.
            rects.append(enclosingIntRect(localToAbsoluteQuad(boxRect).boundingBox()));
        }
    }
}
void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedStyle& style)
{
    bool haveSelection = !paintInfo.isPrinting() && paintInfo.phase != PaintPhaseTextClip && m_ellipsisBox.getSelectionState() != SelectionNone;

    LayoutRect paintRect(m_ellipsisBox.logicalFrameRect());
    if (haveSelection)
        paintRect.unite(LayoutRect(m_ellipsisBox.selectionRect()));
    m_ellipsisBox.logicalRectToPhysicalRect(paintRect);
    paintRect.moveBy(paintOffset);

    GraphicsContext& context = paintInfo.context;
    DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType(paintInfo.phase);
    if (DrawingRecorder::useCachedDrawingIfPossible(context, m_ellipsisBox, displayItemType))
        return;

    DrawingRecorder recorder(context, m_ellipsisBox, displayItemType, FloatRect(paintRect));

    LayoutPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping();
    boxOrigin.moveBy(paintOffset);
    LayoutRect boxRect(boxOrigin, LayoutSize(m_ellipsisBox.logicalWidth(), m_ellipsisBox.virtualLogicalHeight()));

    GraphicsContextStateSaver stateSaver(context);
    if (!m_ellipsisBox.isHorizontal())
        context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise));

    const Font& font = style.font();

    if (haveSelection)
        paintSelection(context, boxOrigin, style, font);
    else if (paintInfo.phase == PaintPhaseSelection)
        return;

    TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_ellipsisBox.getLineLayoutItem(), style, paintInfo);
    if (haveSelection)
        textStyle = TextPainter::selectionPaintingStyle(m_ellipsisBox.getLineLayoutItem(), true, paintInfo, textStyle);

    TextRun textRun = constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion);
    LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.getFontMetrics().ascent());
    TextPainter textPainter(context, font, textRun, textOrigin, boxRect, m_ellipsisBox.isHorizontal());
    textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), m_ellipsisBox.ellipsisStr().length(), textStyle);
}
Beispiel #19
0
void RenderSVGText::absoluteRects(Vector<IntRect>& rects, int, int, bool)
{
    RenderSVGRoot* root = findSVGRootObject(parent());
    if (!root)
        return;

    int x, y;
    absolutePosition(x, y);

    AffineTransform htmlParentCtm = root->RenderContainer::absoluteTransform();
 
    // Don't use relativeBBox here, as it's unites the selection rects. Makes it hard
    // to spot errors, if there are any using WebInspector. Individually feed them into 'rects'.
    for (InlineRunBox* runBox = firstLineBox(); runBox; runBox = runBox->nextLineBox()) {
        ASSERT(runBox->isInlineFlowBox());

        InlineFlowBox* flowBox = static_cast<InlineFlowBox*>(runBox);
        for (InlineBox* box = flowBox->firstChild(); box; box = box->nextOnLine()) {
            FloatRect boxRect(box->xPos(), box->yPos(), box->width(), box->height());
            boxRect.move(narrowPrecisionToFloat(x - htmlParentCtm.e()), narrowPrecisionToFloat(y - htmlParentCtm.f()));
            rects.append(enclosingIntRect(absoluteTransform().mapRect(boxRect)));
        }
    }
}
Beispiel #20
0
/**
 * Draw rectangle on screen
 * @param x Top left corner coordinate
 * @param y Top left corner coordinate
 * @param width Rectangle width (Negative values draw the box horizontally flipped)
 * @param height Rectangle height (Negative values draw the box vertically flipped)
 * @param color Fill color
 * @note An on-screen rectangle's drawn width is always at least one.
 * @note An on-screen rectangle's drawn height is always at least one.
 */
void FWRenderer::drawPlainBox(int x, int y, int width, int height, byte color) {
	// Make width's and height's absolute values at least one
	// which forces this function to always draw something if the
	// drawing position is inside screen bounds. This fixes at least
	// the showing of the oxygen gauge meter in Operation Stealth's
	// first arcade sequence where this function is called with a
	// height of zero.
	if (width == 0) {
		width = 1;
	}
	if (height == 0) {
		height = 1;
	}

	// Handle horizontally flipped boxes
	if (width < 0) {
		width = ABS(width);
		x -= width;
	}

	// Handle vertically flipped boxes
	if (height < 0) {
		height = ABS(height);
		y -= height;
	}

	// Clip the rectangle to screen dimensions
	Common::Rect boxRect(x, y, x + width, y + height);
	Common::Rect screenRect(320, 200);
	boxRect.clip(screenRect);

	byte *dest = _backBuffer + boxRect.top * 320 + boxRect.left;
	for (int i = 0; i < boxRect.height(); i++) {
		memset(dest + i * 320, color, boxRect.width());
	}
}
Beispiel #21
0
AutomountSettingsPanel::AutomountSettingsPanel(BRect frame, 
	BMessage *settings, AutoMounter *target)
	:	BBox(frame, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
			| B_NAVIGABLE_JUMP, B_PLAIN_BORDER),
		fTarget(target)
{
	SetViewColor(kLightGray);

	BRect checkBoxRect(Bounds());

	BRect boxRect(Bounds());
	boxRect.InsetBy(10, 15);
	boxRect.bottom = boxRect.top + 85;
	BBox *box = new BBox(boxRect, "autoMountBox", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED | B_NAVIGABLE_JUMP);
	box->SetLabel("Automatic Disk Mounting:");
	AddChild(box);

	checkBoxRect = box->Bounds();
	checkBoxRect.InsetBy(10, 18);
	
	checkBoxRect.bottom = checkBoxRect.top + 20;

	scanningDisabledCheck = new BRadioButton(checkBoxRect, "scanningOff",
		"Don't Automount", new BMessage(kAutomountSettingsChanged));
	box->AddChild(scanningDisabledCheck);

	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	autoMountAllBFSCheck = new BRadioButton(checkBoxRect, "autoBFS",
		"All BeOS Disks", new BMessage(kAutomountSettingsChanged));
	box->AddChild(autoMountAllBFSCheck);

	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	autoMountAllCheck = new BRadioButton(checkBoxRect, "autoAll",
		"All Disks", new BMessage(kAutomountSettingsChanged));
	box->AddChild(autoMountAllCheck);
	

	boxRect.OffsetTo(boxRect.left, boxRect.bottom + 15);
	boxRect.bottom = boxRect.top + 105;
	box = new BBox(boxRect, "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
			| B_PULSE_NEEDED | B_NAVIGABLE_JUMP);
	box->SetLabel("Disk Mounting During Boot:");
	AddChild(box);

	checkBoxRect = box->Bounds();
	checkBoxRect.InsetBy(10, 18);
	
	checkBoxRect.bottom = checkBoxRect.top + 20;
	initialDontMountCheck = new BRadioButton(checkBoxRect, "initialNone",
		"Only The Boot Disk", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialDontMountCheck);

	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	initialMountRestoreCheck = new BRadioButton(checkBoxRect, "initialRestore",
		"Previously Mounted Disks", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialMountRestoreCheck);
	
	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	initialMountAllBFSCheck = new BRadioButton(checkBoxRect, "initialBFS",
		"All BeOS Disks", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialMountAllBFSCheck);
	
	checkBoxRect.OffsetBy(0, kCheckBoxSpacing);
	initialMountAllCheck = new BRadioButton(checkBoxRect, "initialAll",
		"All Disks", new BMessage(kBootMountSettingsChanged));
	box->AddChild(initialMountAllCheck);

	
	BRect buttonRect(Bounds());
	buttonRect.InsetBy(15, 15);
	buttonRect.SetLeftTop(buttonRect.RightBottom() - kSmallButtonSize);
	fDone = new BButton(buttonRect, "done", "Done", new BMessage(kDone));

	buttonRect.OffsetTo(buttonRect.left - 15 - buttonRect.Width(), buttonRect.top);
	buttonRect.left = buttonRect.left - 60;
	fMountAllNow = new BButton(buttonRect, "mountAll", "Mount all disks now",
		new BMessage(kMountAllNow));

	AddChild(fMountAllNow);

	AddChild(fDone);
	fDone->MakeDefault(true);

	bool result;
	if (settings->FindBool("autoMountAll", &result) == B_OK && result)
		autoMountAllCheck->SetValue(1);
	else if (settings->FindBool("autoMountAllBFS", &result) == B_OK && result)
		autoMountAllBFSCheck->SetValue(1);
	else
		scanningDisabledCheck->SetValue(1);

	if (settings->FindBool("suspended", &result) == B_OK && result)
		scanningDisabledCheck->SetValue(1);
		
	if (settings->FindBool("initialMountAll", &result) == B_OK && result)
		initialMountAllCheck->SetValue(1);
	else if (settings->FindBool("initialMountRestore", &result) == B_OK && result)
		initialMountRestoreCheck->SetValue(1);
	else if (settings->FindBool("initialMountAllBFS", &result) == B_OK && result)
		initialMountAllBFSCheck->SetValue(1);
	else
		initialDontMountCheck->SetValue(1);
	
}
void PipelineFlowChart::paintEvent(QPaintEvent *e)
{
  if(m_StageNames.empty())
    return;

  QPainter p(this);

  p.fillRect(rect(), Qt::transparent);

  p.setRenderHint(QPainter::Antialiasing, true);

  const QRectF totalRect = totalAreaRect();
  const QRectF box0Rect = boxRect(0);

  const qreal radius = qMin(MaxBoxCornerRadius, box0Rect.height() * BoxCornerRadiusFraction);

  const qreal arrowY = totalRect.y() + totalRect.height() / 2;

  QColor base = palette().color(QPalette::Base);
  QColor baseText = palette().color(QPalette::Text);
  QColor inactiveWin = palette().color(QPalette::Inactive, QPalette::Dark);
  QColor inactiveWinText = palette().color(QPalette::Inactive, QPalette::WindowText);
  QColor tooltip = palette().color(QPalette::ToolTipBase);
  QColor tooltipText = palette().color(QPalette::ToolTipText);

  QPen pen(baseText);
  QPen selectedPen(Qt::red);

  int num = numGaps();
  for(int i = 0; i < num; i++)
  {
    if(!m_StageFlows[i] || !m_StageFlows[i + 1])
      continue;

    float right = totalRect.x() + (i + 1) * (box0Rect.width() + boxMargin());
    float left = right - boxMargin();

    p.setBrush(baseText);
    drawArrow(p, pen, ArrowHeadSize, arrowY, left, right);
  }

  num = numItems();
  for(int i = 0; i < num; i++)
  {
    QRectF boxrect = boxRect(i);

    QBrush backBrush(base);
    QPen textPen(baseText);
    QPen outlinePen = pen;

    if(!stageEnabled(i))
    {
      backBrush.setColor(inactiveWin);
      textPen.setColor(inactiveWinText);
    }

    if(i == m_HoverStage)
    {
      backBrush.setColor(tooltip);
      textPen.setColor(tooltipText);
    }

    if(i == m_SelectedStage)
    {
      outlinePen = selectedPen;
    }

    outlinePen.setWidthF(BoxBorderWidth);

    p.setPen(outlinePen);
    p.setBrush(backBrush);
    p.drawRoundedRect(boxrect, radius, radius);

    QTextOption opts(Qt::AlignCenter);
    opts.setWrapMode(QTextOption::NoWrap);

    QString s = m_StageNames[i];

    QRectF reqBox = p.boundingRect(QRectF(0, 0, 1, 1), m_StageNames[i], opts);

    if(reqBox.width() + BoxLabelMargin > (float)boxrect.width())
      s = m_StageAbbrevs[i];

    p.setPen(textPen);
    p.drawText(boxrect, s, opts);
  }
}