Example #1
0
void TExportZone::DrawInMarker(BRect updateRect)
{
	// Set up environment
	PushState();
		
	BPoint drawPt;
	
	// Draw left marker
	if (updateRect.Intersects(m_InRect) )
	{
		// Draw indicator in new location
		drawPt.Set(m_InRect.left, m_InRect.top);
		DrawBitmap(m_InMarker, drawPt);
	}

	// Draw right marker
	if (updateRect.Intersects(m_OutRect) )
	{
		// Draw indicator in new location
		drawPt.Set(m_OutRect.left, m_OutRect.top);
		DrawBitmap(m_OutMarker, drawPt);
	}
		
	// Restore environment
	PopState();
}
Example #2
0
void BWebPage::scroll(int xOffset, int yOffset, const BRect& rectToScroll,
	const BRect& clipRect)
{
    if (!fWebView->LockLooper())
        return;
    BBitmap* bitmap = fWebView->OffscreenBitmap();
    BView* offscreenView = fWebView->OffscreenView();

    // Lock the offscreen bitmap while we still have the
    // window locked. This cannot deadlock and makes sure
    // the window is not deleting the offscreen view right
    // after we unlock it and before locking the bitmap.
    if (!bitmap->Lock()) {
    	fWebView->UnlockLooper();
    	return;
    }
    fWebView->UnlockLooper();

	BRect clip = offscreenView->Bounds();
	if (clipRect.IsValid())
		clip = clip & clipRect;
	BRect rectAtSrc = rectToScroll;
	BRect rectAtDst = rectAtSrc.OffsetByCopy(xOffset, yOffset);
	BRegion repaintRegion(rectAtSrc);
	if (clip.Intersects(rectAtSrc) && clip.Intersects(rectAtDst)) {
		// clip source rect
		rectAtSrc = rectAtSrc & clip;
		// clip dest rect
		rectAtDst = rectAtDst & clip;
		// move dest back over source and clip source to dest
		rectAtDst.OffsetBy(-xOffset, -yOffset);
		rectAtSrc = rectAtSrc & rectAtDst;
		// remember the part that will be clean
		rectAtDst.OffsetBy(xOffset, yOffset);
		repaintRegion.Exclude(rectAtDst);

		offscreenView->CopyBits(rectAtSrc, rectAtDst);
	}

	if (repaintRegion.Frame().IsValid()) {
        WebCore::Frame* frame = fMainFrame->Frame();
        WebCore::FrameView* view = frame->view();
        // Make sure the view is layouted, since it will refuse to paint
        // otherwise.
        fLayoutingView = true;
        view->layout(true);
        fLayoutingView = false;

		internalPaint(offscreenView, view, &repaintRegion);
	}

    bitmap->Unlock();

    // Notify the view that it can now pull the bitmap in its own thread
    fWebView->SetOffscreenViewClean(rectToScroll, false);
}
Example #3
0
void
TabDecorator::_DrawButtons(Decorator::Tab* tab, const BRect& invalid)
{
	STRACE(("TabDecorator: _DrawButtons\n"));

	// Draw the buttons if we're supposed to
	if (!(tab->flags & B_NOT_CLOSABLE) && invalid.Intersects(tab->closeRect))
		_DrawClose(tab, false, tab->closeRect);
	if (!(tab->flags & B_NOT_ZOOMABLE) && invalid.Intersects(tab->zoomRect))
		_DrawZoom(tab, false, tab->zoomRect);
}
Example #4
0
void
PieView::_DrawPieChart(BRect updateRect)
{
	BRect pieRect = Bounds();
	if (!updateRect.Intersects(pieRect))
		return;

	pieRect.InsetBy(kPieOuterMargin, kPieOuterMargin);

	SetHighColor(kPieBGColor);
	FillRect(updateRect);

	// constraint proportions
	if (pieRect.Width() > pieRect.Height()) {
		float moveBy = (pieRect.Width() - pieRect.Height()) / 2;
		pieRect.left += moveBy;
		pieRect.right -= moveBy;
	} else {
		float moveBy = (pieRect.Height() - pieRect.Width()) / 2;
		pieRect.top -= moveBy;
		pieRect.bottom += moveBy;
	}
	int colorIdx = 0;
	FileInfo* currentDir = fScanner->CurrentDir();
	FileInfo* parent = currentDir;
	while (parent != NULL) {
		parent = parent->parent;
		colorIdx++;
	}
	_DrawDirectory(pieRect, currentDir, 0.0, 0.0,
		colorIdx % kBasePieColorCount, 0);
}
Example #5
0
void
WinDecorator::_DrawButtons(Decorator::Tab* tab, const BRect& invalid)
{
	if ((tab->flags & B_NOT_MINIMIZABLE) == 0
		&& invalid.Intersects(tab->minimizeRect)) {
		_DrawMinimize(tab, false, tab->minimizeRect);
	}
	if ((tab->flags & B_NOT_ZOOMABLE) == 0
		&& invalid.Intersects(tab->zoomRect)) {
		_DrawZoom(tab, false, tab->zoomRect);
	}
	if ((tab->flags & B_NOT_CLOSABLE) == 0
		&& invalid.Intersects(tab->closeRect)) {
		_DrawClose(tab, false, tab->closeRect);
	}
}
Example #6
0
/**
	Lays out items one after another.
*/
void AlbumView::Arrange(bool invalidate)
{
	// scale back the page relative to zoom ratio
	BRect bounds = Bounds();
	bounds.left /= fZoom;
	bounds.top /= fZoom;
	bounds.right /= fZoom;
	bounds.bottom /= fZoom;
	FlowLayout layout(bounds.OffsetToCopy(0,0), fColumns);
	layout.SetSpacing(1,1);
	// The entire set must be examined.
	float width = 0;
	float height = 0;
	AlbumItem *item;
	for (int32 i = 0; (item = ItemAt(i)); i++) {
		if (!IsItemVisible(item))
			continue;
		BRect frame0 = item->Frame();
		// separator
		uint32 hint = item->Flags() & ALBUMITEM_SEPARATOR ? LAYOUT_HINT_BREAK : 0;
		BRect frame = layout.Next(frame0, hint);
		if (hint == LAYOUT_HINT_BREAK) {
			// shift the last frame, so we get a gap in the layout
			layout.Last().OffsetBy(0,fSeparatorHeight);
			frame = layout.Last();
		}
		if (frame != frame0) {
			// rects outside the bounds are new
			if (invalidate && bounds.Intersects(frame0) && frame0.left >= 0) {
				// clear the old rect
				Invalidate(Adjust(frame0));				
			}
			// reposition to the new location
			item->SetFrame(frame);
			if (invalidate && bounds.Intersects(frame))  {
				// show on the new location
				Invalidate(Adjust(frame));
			}
		}
		if (frame.right > width)
			width = frame.right;
		if (frame.bottom > height)
			height = frame.bottom;
	}
	SetPageBounds(BRect(0,0,width,height));
}
Example #7
0
/**
	Renders all visible items.
*/
void AlbumView::DrawOffscreen(BView *view, BRect update)
{
	view->SetScale(fZoom);
	AlbumItem *item;
	for (int i = 0; (item = ItemAt(i)); i++) {
 			if (IsItemVisible(item) && update.Intersects(Adjust(item->Frame()))) {
				item->DrawItem(view);
 			}
	}
}
Example #8
0
void
LeftView::Draw(BRect updateRect)
{
	float right = Bounds().Width() - kSmallHMargin;
	BRect iconRect(right - 31.0, kSmallVMargin, right, kSmallVMargin + 31.0);
	if (updateRect.Intersects(iconRect)) {
		SetDrawingMode(B_OP_OVER);
		DrawBitmap(fIcon, iconRect);
	}
}
Example #9
0
void
WinDecorator::_DrawTab(BRect invalid)
{
	// If a window has a tab, this will draw it and any buttons which are
	// in it.
	if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect) || fLook==B_NO_BORDER_WINDOW_LOOK)
		return;

	fDrawingEngine->FillRect(fTabRect,tab_highcol);

	_DrawTitle(fTabRect);

	// Draw the buttons if we're supposed to	
	// TODO : we should still draw the buttons if they are disabled, but grey them out
	if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect))
		_DrawClose(fCloseRect);
	if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect))
		_DrawZoom(fZoomRect);
}
Example #10
0
void
TTimeWindow::_AlignWindow()
{
	BPoint pt = TimeSettings().LeftTop();
	MoveTo(pt);

	BRect frame = Frame();
	BRect screen = BScreen().Frame();
	if (!frame.Intersects(screen.InsetByCopy(50.0, 50.0))) {
		BRect bounds(Bounds());
		BPoint leftTop((screen.Width() - bounds.Width()) / 2.0,
			(screen.Height() - bounds.Height()) / 2.0);

		MoveTo(leftTop);
	}
}
Example #11
0
void Slider::Draw (BRect rect)
{
	BRect label = BRect (0, 0, sep, height);
	if (rect.Intersects (label))	// Label needs to be redrawn
	{
		SetLowColor (LightGrey);
		SetHighColor (Black);
		FillRect (label, B_SOLID_LOW);
		DrawString (name, BPoint (0, label.bottom - 5));
	}
	offslid->Lock ();
	offview->SetHighColor (Grey21);
	offview->FillRect (bounds);
	offview->SetHighColor (Grey30);
	offview->StrokeLine (bounds.RightTop (), bounds.RightBottom ());
	offview->StrokeLine (bounds.LeftBottom ());
	offview->SetHighColor (Grey14);
	offview->StrokeLine (bounds.LeftTop ());
	offview->StrokeLine (bounds.RightTop ());
	knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1);
	knob = BRect (knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2);
	offview->SetHighColor (Grey27);
	offview->FillRect (knob);
	offview->SetHighColor (Black);
	offview->SetLowColor (Grey27);
	offview->SetFont (be_plain_font);
	char val[KNOBVAL];
	sprintf (val, fmt, value);
	offview->DrawString (val, BPoint (knobpos.x + (knobsize - StringWidth (val))/2 + 1, knobpos.y + 12));
	offview->SetHighColor (Grey30);
	offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y), BPoint (knobpos.x + 1, knobpos.y));
	offview->StrokeLine (BPoint (knobpos.x + 1, knobpos.y + height - 2));
	offview->SetHighColor (Grey13);
	offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y + height - 2));
	offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y));
	if (IsFocus())
	{
		// printf ("%s focused!\n", Name());
		BRect k (knobpos.x, knobpos.y - 1, knobpos.x + knobsize - 1, knobpos.y + height - 2);
		k.InsetBy (1, 1);
		offview->SetHighColor (ui_color (B_KEYBOARD_NAVIGATION_COLOR));
		offview->StrokeRect (k);
	}
	offview->Sync ();
	offslid->Unlock ();
	DrawBitmapAsync (offslid, BPoint (sep, 0));
}
Example #12
0
status_t
MainWindow::RestoreSettings(BMessage* archive)
{
	BRect frame;
	if (archive->FindRect("window frame", &frame) == B_OK) {
		BScreen screen(this);
		if (frame.Intersects(screen.Frame())) {
			MoveTo(frame.LeftTop());
			ResizeTo(frame.Width(), frame.Height());
		}
	}

	BMessage columnSettings;
	if (archive->FindMessage("column settings", &columnSettings) == B_OK)
		fListView->LoadState(&columnSettings);

	return B_OK;
}
Example #13
0
/**
	Draws all spliters.	
*/
void SplitView::Draw(BRect update)
{
	BView *child;	
	for (int i = 0; i < CountChildren() -1; i++) {
		child = ChildAt(i);
		BRect frame = child->Frame();
		if (fLayout.Mode() == B_HORIZONTAL) {
			frame.left = frame.right+1;
			frame.right = frame.left + fLayout.Spacing().x-2;
		}
		else {
			frame.top = frame.bottom+1;
			frame.bottom = frame.top + fLayout.Spacing().y-2;
		}
		if (frame.Intersects(update))
			DrawSplitter(frame, child == fSelected && fDragged);		
	}
}
Example #14
0
/*!	\brief Actually draws the tab

	This function is called when the tab itself needs drawn. Other items,
	like the window title or buttons, should not be drawn here.

	\param tab The \a tab to update.
	\param rect The area of the \a tab to update.
*/
void
WinDecorator::_DrawTab(Decorator::Tab* tab, BRect rect)
{
	const BRect& tabRect = tab->tabRect;

	// If a window has a tab, this will draw it and any buttons in it.
	if (!tabRect.IsValid() || !rect.Intersects(tabRect)
		|| fTopTab->look == B_NO_BORDER_WINDOW_LOOK) {
		return;
	}

	fDrawingEngine->FillRect(tabRect & rect, fTabColor);

	_DrawTitle(tab, tabRect);

	// Draw the buttons if we're supposed to
	// TODO : we should still draw the buttons if they are disabled, but grey them out
	_DrawButtons(tab, rect);
}
Example #15
0
void
BAbstractSpinner::_DrawTextView(BRect updateRect)
{
	BRect rect = fTextView->Frame();
	rect.InsetBy(-kFrameMargin, -kFrameMargin);
	if (!rect.IsValid() || !rect.Intersects(updateRect))
		return;

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	uint32 flags = 0;
	if (!IsEnabled())
		flags |= BControlLook::B_DISABLED;

	if (fTextView->IsFocus() && Window()->IsActive())
		flags |= BControlLook::B_FOCUSED;

	be_control_look->DrawTextControlBorder(this, rect, updateRect, base,
		flags);
}
Example #16
0
void TElementsSorter::Draw(BRect updateRect)
{
	PushState();

	//  Draw dummy header to the right of our rightmost TSorter
	TSorterContainer* sorter = static_cast<TSorterContainer*>(fSorterList->ItemAt( fSorterList->CountItems()-1) );
	if (sorter) {
		BRect bounds    = Bounds();
		bounds.bottom   = bounds.top + kSorterHeight;
		bounds.left     = sorter->Frame().right;

		if (updateRect.Intersects(bounds) ) {
			// Fill background
			SetHighColor(kBeGrey);
			FillRect(bounds);

			// Frame it
			BPoint endPt;
			SetHighColor(kWhite);
			MovePenTo(bounds.left, bounds.top+1);
			endPt.Set( bounds.right, bounds.top+1 );
			StrokeLine(endPt);

			SetHighColor(kMediumGrey);
			MovePenTo(bounds.left, bounds.bottom-1);
			endPt.Set( bounds.right, bounds.bottom-1 );
			StrokeLine(endPt);

			SetHighColor(kBlack);
			MovePenTo(bounds.left, bounds.top);
			endPt.Set( bounds.right, bounds.top );
			StrokeLine(endPt);
			MovePenTo(bounds.left, bounds.bottom);
			endPt.Set( bounds.right, bounds.bottom );
			StrokeLine(endPt);
		}
	}

	PopState();

}
Example #17
0
void TextEntryAlertBackgroundView::Draw(BRect update_rect)
{
	if(update_rect.Intersects(m_entry_text_rect))
	{
		SetHighColor(m_dark_1_color);
		StrokeLine(BPoint(m_entry_text_rect.left,m_entry_text_rect.top),
			BPoint(m_entry_text_rect.right,m_entry_text_rect.top));
		StrokeLine(BPoint(m_entry_text_rect.left,m_entry_text_rect.top+1),
			BPoint(m_entry_text_rect.left,m_entry_text_rect.bottom));
		SetHighColor( ui_color(B_SHINE_COLOR));
		StrokeLine(BPoint(m_entry_text_rect.right,m_entry_text_rect.top+1),
			BPoint(m_entry_text_rect.right,m_entry_text_rect.bottom-1));
		StrokeLine(BPoint(m_entry_text_rect.left+1,m_entry_text_rect.bottom),
			BPoint(m_entry_text_rect.right,m_entry_text_rect.bottom));
		SetHighColor( BmWeakenColor(B_SHADOW_COLOR, BeShadowMod));
		StrokeLine(BPoint(m_entry_text_rect.left+1,m_entry_text_rect.top+1),
			BPoint(m_entry_text_rect.right-1,m_entry_text_rect.top+1));
		StrokeLine(BPoint(m_entry_text_rect.left+1,m_entry_text_rect.top+2),
			BPoint(m_entry_text_rect.left+1,m_entry_text_rect.bottom-1));
	}
}
Example #18
0
void
RouteWindow::_constrainToScreen()
{
	D_INTERNAL(("RouteWindow::_constrainToScreen()\n"));

	BScreen screen(this);
	BRect screenRect = screen.Frame();
	BRect windowRect = Frame();

	// if the window is outside the screen rect
	// move it to the default position
	if (!screenRect.Intersects(windowRect)) {
		windowRect.OffsetTo(screenRect.LeftTop());
		MoveTo(windowRect.LeftTop());
		windowRect = Frame();
	}

	// if the window is larger than the screen rect
	// resize it to fit at each side
	if (!screenRect.Contains(windowRect)) {
		if (windowRect.left < screenRect.left) {
			windowRect.left = screenRect.left + 5.0;
			MoveTo(windowRect.LeftTop());
			windowRect = Frame();
		}
		if (windowRect.top < screenRect.top) {
			windowRect.top = screenRect.top + 5.0;
			MoveTo(windowRect.LeftTop());
			windowRect = Frame();
		}
		if (windowRect.right > screenRect.right) {
			windowRect.right = screenRect.right - 5.0;
		}
		if (windowRect.bottom > screenRect.bottom) {
			windowRect.bottom = screenRect.bottom - 5.0;
		}
		ResizeTo(windowRect.Width(), windowRect.Height());
	}
}
Example #19
0
void MultiBoxView::Draw(BRect urect)
{
	UpdateProperties();

	BRect rect;
	int32 element;
	for (int32 i=0; i<numcols; i++) {
		for (int32 j=0; j<numrows; j++) {
//_sPrintf("i: %d, j: %d\n", i, j);
			element = GetElementAt(j, i);
			GetRectAt(element, &rect);
			if (urect.Intersects(rect))
			{
				DrawContentBox(element);
			}
		}
	}
	// clear bottom area of view
	rect = Bounds();
	rect.top = numrows * rowheight + 1;
	SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	FillRect(rect);
}
Example #20
0
void MovieLooperUI::PositionIndicator::Draw(BRect update)
{
	BRect rect = Bounds();
	
	// draw the focus indicator
	if (IsFocus())
	{
		SetHighColor(navigationColor);
		StrokeRect(rect);
	}
	else // or not
	{
		// how bout a nice bevel?
		SetHighColor(255,255,255,255);
		StrokeLine(rect.RightTop(), rect.RightBottom());
		StrokeLine(rect.LeftBottom(), rect.RightBottom());
		SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		StrokeLine(rect.LeftTop(), rect.RightTop());
		StrokeLine(rect.LeftTop(), rect.LeftBottom());
	}
	
	// the non-focus-indicating part of the view
	rect.InsetBy(1.0,1.0);
	
	// everything but the knobs
	if (startCoord == 3.0 && endCoord == rect.right-2.0)
	{
		// green
		SetHighColor(clipColor);
		// don't draw where the knobs draw
		rect.left += 5.0;
		rect.right -= 5.0;
		// draw
		FillRect(rect & update);
	}
	else
	{
		BRect left(rect.left, rect.top, startCoord-3.0, rect.bottom),
				right(endCoord+3.0, rect.top, rect.right, rect.bottom),
				middle(startCoord+3.0, rect.top, endCoord-3.0, rect.bottom);
		
		SetHighColor(clipColor);
		FillRect(middle & update);
		SetHighColor(unClipColor);
		FillRect(left & update);
		FillRect(right & update);
	}
	
	// the position indicator
	if (update.left < playCoord && update.right > playCoord)
	{
		if (playCoord >= (startCoord+3.0) && playCoord <= (endCoord-3.0))
		{
			SetHighColor(0,0,0,255);
			StrokeLine(BPoint(playCoord, 1.0), BPoint(playCoord, Bounds().bottom-1.0));
		}
	}
	// and the knobs
	rect.Set(startCoord-2.0, 1.0, startCoord+2.0, Bounds().bottom-1.0);
	if (update.Intersects(rect))
		DrawKnob(startCoord);
	
	rect.Set(endCoord-2.0, 1.0, endCoord+2.0, Bounds().bottom-1.0);
	if (update.Intersects(rect))
		DrawKnob(endCoord);
}
Example #21
0
void
CalcView::Draw(BRect updateRect)
{
	bool drawBackground = true;
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// CalcView is embedded somewhere, most likely the Tracker Desktop
		// shelf.
		drawBackground = false;
	}

	SetHighColor(fBaseColor);
	BRect expressionRect(_ExpressionRect());
	if (updateRect.Intersects(expressionRect)) {
		if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT
			&& expressionRect.Height() >= fCalcIcon->Bounds().Height()) {
			// render calc icon
			expressionRect.left = fExpressionTextView->Frame().right + 2;
			if (drawBackground) {
				SetHighColor(fBaseColor);
				FillRect(updateRect & expressionRect);
			}

			if (fCalcIcon->ColorSpace() == B_RGBA32) {
				SetDrawingMode(B_OP_ALPHA);
				SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
			} else {
				SetDrawingMode(B_OP_OVER);
			}

			BPoint iconPos;
			iconPos.x = expressionRect.right - (expressionRect.Width()
				+ fCalcIcon->Bounds().Width()) / 2.0;
			iconPos.y = expressionRect.top + (expressionRect.Height()
				- fCalcIcon->Bounds().Height()) / 2.0;
			DrawBitmap(fCalcIcon, iconPos);

			SetDrawingMode(B_OP_COPY);
		}

		// render border around expression text view
		expressionRect = fExpressionTextView->Frame();
		expressionRect.InsetBy(-2, -2);
		if (fOptions->keypad_mode != KEYPAD_MODE_COMPACT && drawBackground) {
			expressionRect.InsetBy(-2, -2);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
		}

		if (be_control_look != NULL) {
			uint32 flags = 0;
			if (!drawBackground)
				flags |= BControlLook::B_BLEND_FRAME;
			be_control_look->DrawTextControlBorder(this, expressionRect,
				updateRect, fBaseColor, flags);
		} else {
			BeginLineArray(8);

			rgb_color lightShadow = tint_color(fBaseColor, B_DARKEN_1_TINT);
			rgb_color darkShadow = tint_color(fBaseColor, B_DARKEN_3_TINT);

			AddLine(BPoint(expressionRect.left, expressionRect.bottom),
					BPoint(expressionRect.left, expressionRect.top),
					lightShadow);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.top),
					BPoint(expressionRect.right, expressionRect.top),
					lightShadow);
			AddLine(BPoint(expressionRect.right, expressionRect.top + 1),
					BPoint(expressionRect.right, expressionRect.bottom),
					fLightColor);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.bottom),
					BPoint(expressionRect.right - 1, expressionRect.bottom),
					fLightColor);

			expressionRect.InsetBy(1, 1);
			AddLine(BPoint(expressionRect.left, expressionRect.bottom),
					BPoint(expressionRect.left, expressionRect.top),
					darkShadow);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.top),
					BPoint(expressionRect.right, expressionRect.top),
					darkShadow);
			AddLine(BPoint(expressionRect.right, expressionRect.top + 1),
					BPoint(expressionRect.right, expressionRect.bottom),
					fBaseColor);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.bottom),
					BPoint(expressionRect.right - 1, expressionRect.bottom),
					fBaseColor);

			EndLineArray();
		}
	}

	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT)
		return;

	// calculate grid sizes
	BRect keypadRect(_KeypadRect());

	if (be_control_look != NULL) {
		if (drawBackground)
			StrokeRect(keypadRect);
		keypadRect.InsetBy(1, 1);
	}

	float sizeDisp = keypadRect.top;
	float sizeCol = (keypadRect.Width() + 1) / (float)fColumns;
	float sizeRow = (keypadRect.Height() + 1) / (float)fRows;

	if (!updateRect.Intersects(keypadRect))
		return;

	SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));

	if (be_control_look != NULL) {
		CalcKey* key = fKeypad;
		for (int row = 0; row < fRows; row++) {
			for (int col = 0; col < fColumns; col++) {
				BRect frame;
				frame.left = keypadRect.left + col * sizeCol;
				frame.right = keypadRect.left + (col + 1) * sizeCol - 1;
				frame.top = sizeDisp + row * sizeRow;
				frame.bottom = sizeDisp + (row + 1) * sizeRow - 1;

				if (drawBackground) {
					SetHighColor(fBaseColor);
					StrokeRect(frame);
				}
				frame.InsetBy(1, 1);

				uint32 flags = 0;
				if (!drawBackground)
					flags |= BControlLook::B_BLEND_FRAME;
				if (key->flags != 0)
					flags |= BControlLook::B_ACTIVATED;
				flags |= BControlLook::B_IGNORE_OUTLINE;

				be_control_look->DrawButtonFrame(this, frame, updateRect,
					fBaseColor, fBaseColor, flags);

				be_control_look->DrawButtonBackground(this, frame, updateRect,
					fBaseColor, flags);

				be_control_look->DrawLabel(this, key->label, frame, updateRect,
					fBaseColor, flags, BAlignment(B_ALIGN_HORIZONTAL_CENTER,
						B_ALIGN_VERTICAL_CENTER));

				key++;
			}
		}
		return;
	}

	// TODO: support pressed keys

	// paint keypad b/g
	SetHighColor(fBaseColor);
	FillRect(updateRect & keypadRect);

	// render key main grid
	BeginLineArray(((fColumns + fRows) << 1) + 1);

	// render cols
	AddLine(BPoint(0.0, sizeDisp),
			BPoint(0.0, fHeight),
			fLightColor);
	for (int col = 1; col < fColumns; col++) {
		AddLine(BPoint(col * sizeCol - 1.0, sizeDisp),
				BPoint(col * sizeCol - 1.0, fHeight),
				fDarkColor);
		AddLine(BPoint(col * sizeCol, sizeDisp),
				BPoint(col * sizeCol, fHeight),
				fLightColor);
	}
	AddLine(BPoint(fColumns * sizeCol, sizeDisp),
			BPoint(fColumns * sizeCol, fHeight),
			fDarkColor);

	// render rows
	for (int row = 0; row < fRows; row++) {
		AddLine(BPoint(0.0, sizeDisp + row * sizeRow - 1.0),
				BPoint(fWidth, sizeDisp + row * sizeRow - 1.0),
				fDarkColor);
		AddLine(BPoint(0.0, sizeDisp + row * sizeRow),
				BPoint(fWidth, sizeDisp + row * sizeRow),
				fLightColor);
	}
	AddLine(BPoint(0.0, sizeDisp + fRows * sizeRow),
			BPoint(fWidth, sizeDisp + fRows * sizeRow),
			fDarkColor);

	// main grid complete
	EndLineArray();

	// render key symbols
	float halfSizeCol = sizeCol * 0.5f;
	SetHighColor(fButtonTextColor);
	SetLowColor(fBaseColor);
	SetDrawingMode(B_OP_COPY);

	float baselineOffset = ((fHeight - sizeDisp) / (float)fRows)
							* (1.0 - kFontScaleY) * 0.5;
	CalcKey* key = fKeypad;
	for (int row = 0; row < fRows; row++) {
		for (int col = 0; col < fColumns; col++) {
			float halfSymbolWidth = StringWidth(key->label) * 0.5f;
			DrawString(key->label,
				BPoint(col * sizeCol + halfSizeCol - halfSymbolWidth,
				sizeDisp + (row + 1) * sizeRow - baselineOffset));
			key++;
		}
	}
}
Example #22
0
void
BStatusBar::Draw(BRect updateRect)
{
    rgb_color backgroundColor = LowColor();

    font_height fontHeight;
    GetFontHeight(&fontHeight);
    BRect barFrame = _BarFrame(&fontHeight);
    BRect outerFrame = barFrame.InsetByCopy(-2, -2);

    BRegion background(updateRect);
    background.Exclude(outerFrame);
    FillRegion(&background, B_SOLID_LOW);

    // Draw labels/texts

    BRect rect = outerFrame;
    rect.top = 0;
    rect.bottom = outerFrame.top - 1;

    if (updateRect.Intersects(rect)) {
        // update labels
        BString leftText;
        leftText << fLabel << fText;

        BString rightText;
        rightText << fTrailingText << fTrailingLabel;

        float baseLine = ceilf(fontHeight.ascent) + 1;
        fTextDivider = rect.right;

        BFont font;
        GetFont(&font);

        if (rightText.Length()) {
            font.TruncateString(&rightText, B_TRUNCATE_BEGINNING,
                                rect.Width());
            fTextDivider -= StringWidth(rightText.String());
        }

        if (leftText.Length()) {
            float width = max_c(0.0, fTextDivider - rect.left);
            font.TruncateString(&leftText, B_TRUNCATE_END, width);
        }

        rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);

        if (backgroundColor != ui_color(B_PANEL_BACKGROUND_COLOR)) {
            if (backgroundColor.Brightness() > 100)
                textColor = make_color(0, 0, 0, 255);
            else
                textColor = make_color(255, 255, 255, 255);
        }

        SetHighColor(textColor);

        if (leftText.Length())
            DrawString(leftText.String(), BPoint(rect.left, baseLine));

        if (rightText.Length())
            DrawString(rightText.String(), BPoint(fTextDivider, baseLine));
    }

    // Draw bar

    if (!updateRect.Intersects(outerFrame))
        return;

    rect = outerFrame;

    if (be_control_look != NULL) {
        be_control_look->DrawStatusBar(this, rect, updateRect,
                                       backgroundColor, fBarColor, _BarPosition(barFrame));
        return;
    }

    // First bevel
    SetHighColor(tint_color(backgroundColor, B_DARKEN_1_TINT));
    StrokeLine(rect.LeftBottom(), rect.LeftTop());
    StrokeLine(rect.RightTop());

    SetHighColor(tint_color(backgroundColor, B_LIGHTEN_2_TINT));
    StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom());
    StrokeLine(BPoint(rect.right, rect.top + 1));

    rect.InsetBy(1, 1);

    // Second bevel
    SetHighColor(tint_color(backgroundColor, B_DARKEN_4_TINT));
    StrokeLine(rect.LeftBottom(), rect.LeftTop());
    StrokeLine(rect.RightTop());

    SetHighColor(backgroundColor);
    StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom());
    StrokeLine(BPoint(rect.right, rect.top + 1));

    rect = barFrame;
    rect.right = _BarPosition(barFrame);

    // draw bar itself

    if (rect.right >= rect.left) {
        // Bevel
        SetHighColor(tint_color(fBarColor, B_LIGHTEN_2_TINT));
        StrokeLine(rect.LeftBottom(), rect.LeftTop());
        StrokeLine(rect.RightTop());

        SetHighColor(tint_color(fBarColor, B_DARKEN_2_TINT));
        StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom());
        StrokeLine(BPoint(rect.right, rect.top + 1));

        // filling
        SetHighColor(fBarColor);
        FillRect(rect.InsetByCopy(1, 1));
    }

    if (rect.right < barFrame.right) {
        // empty space
        rect.left = rect.right + 1;
        rect.right = barFrame.right;
        SetHighColor(tint_color(backgroundColor, B_LIGHTEN_MAX_TINT));
        FillRect(rect);
    }
}
Example #23
0
void
MacDecorator::_DrawTab(BRect invalid)
{
    // If a window has a tab, this will draw it and any buttons which are
    // in it.
    if (!fTabRect.IsValid() || !invalid.Intersects(fTabRect))
        return;

    BRect rect(fTabRect);
    fDrawingEngine->SetHighColor(RGBColor(frame_midcol));
    fDrawingEngine->FillRect(rect,frame_midcol);

    if (IsFocus()) {
        fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowercol);
        fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowercol);
        fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowercol);

        rect.InsetBy(1,1);
        rect.bottom++;

        fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_highcol);
        fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_highcol);
        fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);

        // Draw the neat little lines on either side of the title if there's room
        if (fTabRect.left + textoffset > fCloseRect.right + 5) {
            // Left side

            BPoint offset(fCloseRect.right+5,fCloseRect.top),
                   pt2(fTabRect.left+textoffset-5,fCloseRect.top);
            fDrawState.SetHighColor(RGBColor(frame_highcol));
            for (int32 i = 0; i < 6; i++) {
                fDrawingEngine->StrokeLine(offset,pt2,fDrawState.HighColor());
                offset.y+=2;
                pt2.y+=2;
            }

            offset.Set(fCloseRect.right+6,fCloseRect.top+1),
                       pt2.Set(fTabRect.left+textoffset-4,fCloseRect.top+1);
            fDrawState.SetHighColor(RGBColor(frame_lowcol));
            for (int32 i = 0; i < 6; i++) {
                fDrawingEngine->StrokeLine(offset, pt2, fDrawState.HighColor());
                offset.y += 2;
                pt2.y += 2;
            }

            // Right side

            offset.Set(fTabRect.left + textoffset + titlepixelwidth + 6,
                       fZoomRect.top), pt2.Set(fZoomRect.left - 6, fZoomRect.top);
            if (offset.x < pt2.x) {
                fDrawState.SetHighColor(RGBColor(frame_highcol));
                for (int32 i = 0; i < 6; i++) {
                    fDrawingEngine->StrokeLine(offset, pt2,
                                               fDrawState.HighColor());
                    offset.y += 2;
                    pt2.y += 2;
                }
                offset.Set(fTabRect.left+textoffset + titlepixelwidth + 7,
                           fZoomRect.top + 1), pt2.Set(fZoomRect.left - 5,
                                                       fZoomRect.top + 1);
                fDrawState.SetHighColor(frame_lowcol);
                for(int32 i = 0; i < 6; i++) {
                    fDrawingEngine->StrokeLine(offset, pt2,
                                               fDrawState.HighColor());
                    offset.y += 2;
                    pt2.y += 2;
                }
            }
        }

        // Draw the buttons if we're supposed to
        if (!(fFlags & B_NOT_CLOSABLE))
            _DrawClose(fCloseRect);
        if (!(fFlags & B_NOT_ZOOMABLE))
            _DrawZoom(fZoomRect);
    } else {
        // Not focused - Just draw a plain light grey area with the title in the middle
        fDrawingEngine->StrokeLine(rect.LeftTop(),rect.RightTop(),frame_lowcol);
        fDrawingEngine->StrokeLine(rect.LeftTop(),rect.LeftBottom(),frame_lowcol);
        fDrawingEngine->StrokeLine(rect.RightBottom(),rect.RightTop(),frame_lowcol);
    }

    _DrawTitle(fTabRect);
}
Example #24
0
void
BTextControl::Draw(BRect updateRect)
{
	bool enabled = IsEnabled();
	bool active = fText->IsFocus() && Window()->IsActive();

	BRect rect = fText->Frame();
	rect.InsetBy(-2, -2);

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = 0;
		if (!enabled)
			flags |= BControlLook::B_DISABLED;
		if (active)
			flags |= BControlLook::B_FOCUSED;
		be_control_look->DrawTextControlBorder(this, rect, updateRect, base,
			flags);

		rect = Bounds();
		rect.right = fDivider - kLabelInputSpacing;
//		rect.right = fText->Frame().left - 2;
//		rect.right -= 3;//be_control_look->DefaultLabelSpacing();
		be_control_look->DrawLabel(this, Label(), rect, updateRect,
			base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE));

		return;
	}

	// outer bevel

	rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT);
	rgb_color lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT);
	rgb_color lightenMax = tint_color(noTint, B_LIGHTEN_MAX_TINT);
	rgb_color darken1 = tint_color(noTint, B_DARKEN_1_TINT);
	rgb_color darken2 = tint_color(noTint, B_DARKEN_2_TINT);
	rgb_color darken4 = tint_color(noTint, B_DARKEN_4_TINT);
	rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);

	if (enabled)
		SetHighColor(darken1);
	else
		SetHighColor(noTint);

	StrokeLine(rect.LeftBottom(), rect.LeftTop());
	StrokeLine(rect.RightTop());

	if (enabled)
		SetHighColor(lighten2);
	else
		SetHighColor(lighten1);

	StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
	StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom());

	// inner bevel

	rect.InsetBy(1.0f, 1.0f);

	if (active) {
		SetHighColor(navigationColor);
		StrokeRect(rect);
	} else {
		if (enabled)
			SetHighColor(darken4);
		else
			SetHighColor(darken2);

		StrokeLine(rect.LeftTop(), rect.LeftBottom());
		StrokeLine(rect.LeftTop(), rect.RightTop());

		SetHighColor(noTint);
		StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
		StrokeLine(BPoint(rect.right, rect.top + 1.0f));
	}

	// label

	if (Label()) {
		_ValidateLayoutData();
		font_height& fontHeight = fLayoutData->font_info;

		float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent
			- fontHeight.descent) / 2 + fontHeight.ascent;
		float x;

		float labelWidth = StringWidth(Label());
		switch (fLabelAlign) {
			case B_ALIGN_RIGHT:
				x = fDivider - labelWidth - kLabelInputSpacing;
				break;

			case B_ALIGN_CENTER:
				x = fDivider - labelWidth / 2.0;
				break;

			default:
				x = 0.0;
				break;
		}

		BRect labelArea(x, Bounds().top, x + labelWidth, Bounds().bottom);
		if (x < fDivider && updateRect.Intersects(labelArea)) {
			labelArea.right = fText->Frame().left - kLabelInputSpacing;

			BRegion clipRegion(labelArea);
			ConstrainClippingRegion(&clipRegion);
			SetHighColor(IsEnabled() ? ui_color(B_CONTROL_TEXT_COLOR)
				: tint_color(noTint, B_DISABLED_LABEL_TINT));
			DrawString(Label(), BPoint(x, y));
		}
	}
}
Example #25
0
void THeaderView::Draw(BRect where)
{
	BRect	r;

	r = Window()->Bounds();
	if (!fWidth)
		fWidth = r.Width();

	r.OffsetTo(0, 0);
	if (fIncoming)
		r.bottom = MIN_HEADER_HEIGHT;
	else
		r.bottom = HEADER_HEIGHT;
	SetHighColor(255, 255, 255);
	StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top));
	StrokeLine(BPoint(r.left, r.top), BPoint(r.left, r.bottom - 1));
	SetHighColor(120, 120, 120);
	StrokeLine(BPoint(r.left, r.bottom - 1), BPoint(r.right, r.bottom - 1));
	StrokeLine(BPoint(r.right, r.bottom - 1), BPoint(r.right, r.top + 1));
	SetHighColor(64, 64, 64);
	StrokeLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom));

	SetHighColor(255, 255, 255);
	r = ((BTextView *)(fSubject->ChildAt(0)))->Frame();
	fSubject->ConvertToParent(&r);
	r.left -= 3;
	r.right += 3;
	r.top -= 3;
	if (r.Intersects(where)) {
		StrokeLine(BPoint(r.left, r.bottom + 2),
				   BPoint(r.right, r.bottom + 2));
		StrokeLine(BPoint(r.right, r.bottom + 1),
				   BPoint(r.right, r.top));
	}

	r = ((BTextView *)(fTo->ChildAt(0)))->Frame();
	fTo->ConvertToParent(&r);
	r.left -= 3;
	r.right += 3;
	r.top -= 3;
	if (r.Intersects(where)) {
		StrokeLine(BPoint(r.left, r.bottom + 2),
				   BPoint(r.right, r.bottom + 2));
		StrokeLine(BPoint(r.right, r.bottom + 1),
				   BPoint(r.right, r.top));
	}

	if (!fIncoming) {
		r = ((BTextView *)(fCc->ChildAt(0)))->Frame();
		fCc->ConvertToParent(&r);
		r.left -= 3;
		r.right += 3;
		r.top -= 3;
		if (r.Intersects(where)) {
			StrokeLine(BPoint(r.left, r.bottom + 2),
					   BPoint(r.right, r.bottom + 2));
			StrokeLine(BPoint(r.right, r.bottom + 1),
					   BPoint(r.right, r.top));
		}

		r = ((BTextView *)(fBcc->ChildAt(0)))->Frame();
		fBcc->ConvertToParent(&r);
		r.left -= 3;
		r.right += 3;
		r.top -= 3;
		if (r.Intersects(where)) {
			StrokeLine(BPoint(r.left, r.bottom + 2),
					   BPoint(r.right, r.bottom + 2));
			StrokeLine(BPoint(r.right, r.bottom + 1),
					   BPoint(r.right, r.top));
		}
	}
}
Example #26
0
void
CalcView::Draw(BRect updateRect)
{
	bool drawBackground = !_IsEmbedded();

	SetHighColor(fBaseColor);
	BRect expressionRect(_ExpressionRect());
	if (updateRect.Intersects(expressionRect)) {
		if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT
			&& expressionRect.Height() >= fCalcIcon->Bounds().Height()) {
			// render calc icon
			expressionRect.left = fExpressionTextView->Frame().right + 2;
			if (drawBackground) {
				SetHighColor(fBaseColor);
				FillRect(updateRect & expressionRect);
			}

			if (fCalcIcon->ColorSpace() == B_RGBA32) {
				SetDrawingMode(B_OP_ALPHA);
				SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
			} else {
				SetDrawingMode(B_OP_OVER);
			}

			BPoint iconPos;
			iconPos.x = expressionRect.right - (expressionRect.Width()
				+ fCalcIcon->Bounds().Width()) / 2.0;
			iconPos.y = expressionRect.top + (expressionRect.Height()
				- fCalcIcon->Bounds().Height()) / 2.0;
			DrawBitmap(fCalcIcon, iconPos);

			SetDrawingMode(B_OP_COPY);
		}

		// render border around expression text view
		expressionRect = fExpressionTextView->Frame();
		expressionRect.InsetBy(-2, -2);
		if (fOptions->keypad_mode != KEYPAD_MODE_COMPACT && drawBackground) {
			expressionRect.InsetBy(-2, -2);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
		}

		uint32 flags = 0;
		if (!drawBackground)
			flags |= BControlLook::B_BLEND_FRAME;
		be_control_look->DrawTextControlBorder(this, expressionRect,
			updateRect, fBaseColor, flags);
	}

	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT)
		return;

	// calculate grid sizes
	BRect keypadRect(_KeypadRect());

	if (be_control_look != NULL) {
		if (drawBackground)
			StrokeRect(keypadRect);
		keypadRect.InsetBy(1, 1);
	}

	float sizeDisp = keypadRect.top;
	float sizeCol = (keypadRect.Width() + 1) / (float)fColumns;
	float sizeRow = (keypadRect.Height() + 1) / (float)fRows;

	if (!updateRect.Intersects(keypadRect))
		return;

	SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));

	CalcKey* key = fKeypad;
	for (int row = 0; row < fRows; row++) {
		for (int col = 0; col < fColumns; col++) {
			BRect frame;
			frame.left = keypadRect.left + col * sizeCol;
			frame.right = keypadRect.left + (col + 1) * sizeCol - 1;
			frame.top = sizeDisp + row * sizeRow;
			frame.bottom = sizeDisp + (row + 1) * sizeRow - 1;

			if (drawBackground) {
				SetHighColor(fBaseColor);
				StrokeRect(frame);
			}
			frame.InsetBy(1, 1);

			uint32 flags = 0;
			if (!drawBackground)
				flags |= BControlLook::B_BLEND_FRAME;
			if (key->flags != 0)
				flags |= BControlLook::B_ACTIVATED;
			flags |= BControlLook::B_IGNORE_OUTLINE;

			be_control_look->DrawButtonFrame(this, frame, updateRect,
				fBaseColor, fBaseColor, flags);

			be_control_look->DrawButtonBackground(this, frame, updateRect,
				fBaseColor, flags);

			be_control_look->DrawLabel(this, key->label, frame, updateRect,
				fBaseColor, flags, BAlignment(B_ALIGN_HORIZONTAL_CENTER,
					B_ALIGN_VERTICAL_CENTER), &fButtonTextColor);

			key++;
		}
	}
}
Example #27
0
// _DrawBitmap32
void
Painter::_DrawBitmap32(const agg::rendering_buffer& srcBuffer,
					   BRect actualBitmapRect, BRect bitmapRect, BRect viewRect) const
{
typedef agg::span_allocator<agg::rgba8> span_alloc_type;
typedef agg::span_interpolator_linear<> interpolator_type;
typedef agg::span_image_filter_rgba32_nn<agg::order_bgra32,
										 interpolator_type> span_gen_type;
typedef agg::renderer_scanline_aa<renderer_base, span_gen_type> image_renderer_type;

	if (bitmapRect.IsValid() && bitmapRect.Intersects(actualBitmapRect)
		&& viewRect.IsValid()) {

		// compensate for the lefttop offset the actualBitmapRect might have
// NOTE: I have no clue why enabling the next call gives a wrong result!
// According to the BeBook, bitmapRect is supposed to be in native
// bitmap space!
//		bitmapRect.OffsetBy(-actualBitmapRect.left, -actualBitmapRect.top);
		actualBitmapRect.OffsetBy(-actualBitmapRect.left, -actualBitmapRect.top);

		// calculate the scaling
		double xScale = (viewRect.Width() + 1) / (bitmapRect.Width() + 1);
		double yScale = (viewRect.Height() + 1) / (bitmapRect.Height() + 1);

		// constrain rect to passed bitmap bounds
		// and transfer the changes to the viewRect
		if (bitmapRect.left < actualBitmapRect.left) {
			float diff = actualBitmapRect.left - bitmapRect.left;
			viewRect.left += diff * xScale;
			bitmapRect.left = actualBitmapRect.left;
		}
		if (bitmapRect.top < actualBitmapRect.top) {
			float diff = actualBitmapRect.top - bitmapRect.top;
			viewRect.top += diff;
			bitmapRect.top = actualBitmapRect.top;
		}
		if (bitmapRect.right > actualBitmapRect.right) {
			float diff = bitmapRect.right - actualBitmapRect.right;
			viewRect.right -= diff;
			bitmapRect.right = actualBitmapRect.right;
		}
		if (bitmapRect.bottom > actualBitmapRect.bottom) {
			float diff = bitmapRect.right - actualBitmapRect.bottom;
			viewRect.bottom -= diff;
			bitmapRect.bottom = actualBitmapRect.bottom;
		}

		float xOffset = viewRect.left - (bitmapRect.left * xScale);
		float yOffset = viewRect.top - (bitmapRect.top * yScale);

		agg::trans_affine srcMatrix;
//		srcMatrix *= agg::trans_affine_translation(-actualBitmapRect.left, -actualBitmapRect.top);
		srcMatrix *= agg::trans_affine_scaling(fScale, fScale);
		srcMatrix *= agg::trans_affine_translation(fOrigin.x, fOrigin.y);

		agg::trans_affine imgMatrix;
		imgMatrix *= agg::trans_affine_scaling(xScale, yScale);
		imgMatrix *= agg::trans_affine_translation(xOffset, yOffset);
		imgMatrix *= agg::trans_affine_scaling(fScale, fScale);
		imgMatrix *= agg::trans_affine_translation(fOrigin.x, fOrigin.y);
		imgMatrix.invert();
		
		span_alloc_type sa;
		interpolator_type interpolator(imgMatrix);

		span_gen_type sg(sa, srcBuffer, agg::rgba(0, 0, 0, 0), interpolator);

		image_renderer_type ri(*fBaseRenderer, sg);

		agg::rasterizer_scanline_aa<> pf;
		agg::scanline_u8 sl;

		// path encloses image
		agg::path_storage path;
		path.move_to(viewRect.left, viewRect.top);
		path.line_to(viewRect.right + 1, viewRect.top);
		path.line_to(viewRect.right + 1, viewRect.bottom + 1);
		path.line_to(viewRect.left, viewRect.bottom + 1);
		path.close_polygon();

		agg::conv_transform<agg::path_storage> tr(path, srcMatrix);

		pf.add_path(tr);
		agg::render_scanlines(pf, sl, ri);
	}
}
void
SATGroup::_EnsureGroupIsOnScreen(SATGroup* group)
{
	STRACE_SAT("SATGroup::_EnsureGroupIsOnScreen\n");
	if (!group)
		return;

	if (group->CountItems() < 1)
		return;

	SATWindow* window = group->WindowAt(0);
	Desktop* desktop = window->GetWindow()->Desktop();
	if (!desktop)
		return;

	const float kBigDistance = 1E+10;

	float minLeftDistance = kBigDistance;
	BRect leftRect;
	float minTopDistance = kBigDistance;
	BRect topRect;
	float minRightDistance = kBigDistance;
	BRect rightRect;
	float minBottomDistance = kBigDistance;
	BRect bottomRect;

	BRect screen = window->GetWindow()->Screen()->Frame();
	BRect reducedScreen = screen;
	reducedScreen.InsetBy(kMinOverlap, kMinOverlap);

	for (int i = 0; i < group->CountItems(); i++) {
		SATWindow* window = group->WindowAt(i);
		BRect frame = window->CompleteWindowFrame();
		if (reducedScreen.Intersects(frame))
			return;

		if (frame.right < screen.left + kMinOverlap) {
			float dist = fabs(screen.left - frame.right);
			if (dist < minLeftDistance) {
				minLeftDistance = dist;
				leftRect = frame;
			}
			else if (dist == minLeftDistance)
				leftRect = leftRect | frame;
		}
		if (frame.top > screen.bottom - kMinOverlap) {
			float dist = fabs(frame.top - screen.bottom);
			if (dist < minBottomDistance) {
				minBottomDistance = dist;
				bottomRect = frame;
			}
			else if (dist == minBottomDistance)
				bottomRect = bottomRect | frame;
		}
		if (frame.left > screen.right - kMinOverlap) {
			float dist = fabs(frame.left - screen.right);
			if (dist < minRightDistance) {
				minRightDistance = dist;
				rightRect = frame;
			}
			else if (dist == minRightDistance)
				rightRect = rightRect | frame;
		}
		if (frame.bottom < screen.top + kMinOverlap) {
			float dist = fabs(frame.bottom - screen.top);
			if (dist < minTopDistance) {
				minTopDistance = dist;
				topRect = frame;
			}
			else if (dist == minTopDistance)
				topRect = topRect | frame;
		}
	}

	BPoint offset;
	if (minLeftDistance < kBigDistance) {
		offset.x = screen.left - leftRect.right + kMoveToScreen;
		_CallculateYOffset(offset, leftRect, screen);
	}
	else if (minTopDistance < kBigDistance) {
		offset.y = screen.top - topRect.bottom + kMoveToScreen;
		_CallculateXOffset(offset, topRect, screen);
	}
	else if (minRightDistance < kBigDistance) {
		offset.x = screen.right - rightRect.left - kMoveToScreen;
		_CallculateYOffset(offset, rightRect, screen);
	}
	else if (minBottomDistance < kBigDistance) {
		offset.y = screen.bottom - bottomRect.top - kMoveToScreen;
		_CallculateXOffset(offset, bottomRect, screen);
	}

	if (offset.x == 0. && offset.y == 0.)
		return;
	STRACE_SAT("move group back to screen: offset x: %f offset y: %f\n",
		offset.x, offset.y);

	desktop->MoveWindowBy(window->GetWindow(), offset.x, offset.y);
	window->DoGroupLayout();
}
Example #29
0
void
WebSafeSelector::Draw(BRect updateRect)
{
	ColorSelector::Draw(updateRect);

	if (fIsHidden) {
		SetHighColor(ViewColor());
		FillRect(updateRect);
		return;
	}

	if (updateRect.Intersects(INDICATOR_RECT)) {
		rgb_color black = (rgb_color){ 0, 0, 0 };
		rgb_color light;
		rgb_color medium;
		rgb_color dark;

		if (fMouseOver) {
			light  = (rgb_color){ 0, 255, 0, 255 };
			medium = (rgb_color){ 255, 0, 0, 255 };
			dark   = (rgb_color){ 0, 0, 255, 255 };
		} else {
			light  = tint_color(black, B_LIGHTEN_MAX_TINT);
			medium = tint_color(black, B_LIGHTEN_2_TINT);
			dark   = tint_color(black, B_LIGHTEN_1_TINT);
		}

		BRect bounds = INDICATOR_RECT;

		BPoint pointList[4];
		pointList[0] = bounds.LeftTop() + BPoint(0, 3);
		pointList[1] = bounds.LeftTop() + BPoint(0, 9);
		pointList[2] = bounds.LeftTop() + BPoint(5, 12);
		pointList[3] = bounds.LeftTop() + BPoint(5, 6);

		BPolygon* rhombus1 = new BPolygon(pointList, 4);
		SetHighColor(dark);
		FillPolygon(rhombus1);
		SetHighColor(black);
		StrokePolygon(rhombus1);
		delete rhombus1;

		pointList[0] = bounds.LeftTop() + BPoint(5, 6);
		pointList[1] = bounds.LeftTop() + BPoint(5, 12);
		pointList[2] = bounds.LeftTop() + BPoint(10, 9);
		pointList[3] = bounds.LeftTop() + BPoint(10, 3);

		BPolygon* rhombus2 = new BPolygon(pointList, 4);
		SetHighColor(light);
		FillPolygon(rhombus2);
		SetHighColor(black);
		StrokePolygon(rhombus2);
		delete rhombus2;

		pointList[0] = bounds.LeftTop() + BPoint(0, 3);
		pointList[1] = bounds.LeftTop() + BPoint(5, 6);
		pointList[2] = bounds.LeftTop() + BPoint(10, 3);
		pointList[3] = bounds.LeftTop() + BPoint(5, 0);

		BPolygon* rhombus3 = new BPolygon(pointList, 4);
		SetHighColor(medium);
		FillPolygon(rhombus3);
		SetHighColor(black);
		StrokePolygon(rhombus3);
		delete rhombus3;
	}
}
Example #30
0
void TExportZone::Draw(BRect updateRect)
{
	BPoint startPt, endPt;

	const BRect bounds = Bounds();
	
	// Save environment
	PushState();
			
	//
	//	Draw zone and Start and End indicators
	//
	
	// Draw export zone
	SetHighColor(kTaupe);
	FillRect(updateRect);
	
	//	Draw top highlight
	SetHighColor(kLightTaupe);
	startPt.Set(updateRect.left, bounds.top);
	endPt.Set(updateRect.right, bounds.top);
	StrokeLine(startPt, endPt);		
	
	//	Draw top shadow
	SetHighColor(kDarkTaupe);
	startPt.Set(updateRect.left, bounds.top-1);
	endPt.Set(updateRect.right, bounds.top-1);
	StrokeLine(startPt, endPt);		
	
	//	Draw bottom highlight
	SetHighColor(kLightTaupe);
	startPt.Set(updateRect.left, bounds.bottom-1);
	endPt.Set(updateRect.right, bounds.bottom-1);
	StrokeLine(startPt, endPt);		

	//	Draw bottom border line
	SetHighColor(kBlack);
	startPt.Set(updateRect.left, bounds.bottom);
	endPt.Set(updateRect.right, bounds.bottom);
	StrokeLine(startPt, endPt);		

	//	Crop 1 pixel from bottom of channel height
	BRect channelRect = m_ExportChannel;
	channelRect.bottom--;

	// Draw export channel
	if (updateRect.Intersects(channelRect) )
	{		
		BRect fillRect = updateRect & channelRect;
		
		//	Fill
		SetHighColor(kKhaki);
		FillRect(fillRect);
		
		//	Highlight
		BPoint startPt, endPt;
		SetHighColor(kLightKhaki);
		startPt.Set(fillRect.left, m_ExportChannel.top);
		endPt.Set(fillRect.right, m_ExportChannel.top);
		StrokeLine(startPt, endPt);
		
		//	Shadow
		SetHighColor(kDarkKhaki);
		startPt.Set(fillRect.left, m_ExportChannel.bottom);
		endPt.Set(fillRect.right, m_ExportChannel.bottom);
		StrokeLine(startPt, endPt);
	}
				
	// Draw ExportStart and ExportEnd markers
	DrawInMarker(updateRect);
	DrawOutMarker(updateRect);
	
	// Restore environment
	PopState();	
}