Exemple #1
0
void
BMenuField::_UpdateFrame()
{
	CALLED();

	if (fLayoutData->label_layout_item == NULL
		|| fLayoutData->menu_bar_layout_item == NULL) {
		return;
	}

	BRect labelFrame = fLayoutData->label_layout_item->Frame();
	BRect menuFrame = fLayoutData->menu_bar_layout_item->Frame();

	if (!labelFrame.IsValid() || !menuFrame.IsValid())
		return;

	// update divider
	fDivider = menuFrame.left - labelFrame.left;

	// update our frame
	MoveTo(labelFrame.left, labelFrame.top);
	BSize oldSize = Bounds().Size();
	ResizeTo(menuFrame.left + menuFrame.Width() - labelFrame.left,
		menuFrame.top + menuFrame.Height() - labelFrame.top);
	BSize newSize = Bounds().Size();

	// If the size changes, ResizeTo() will trigger a relayout, otherwise
	// we need to do that explicitly.
	if (newSize != oldSize)
		Relayout();
}
Exemple #2
0
void
BAbstractSpinner::_UpdateFrame()
{
	if (fLayoutData->label_layout_item == NULL
		|| fLayoutData->text_view_layout_item == NULL) {
		return;
	}

	BRect labelFrame = fLayoutData->label_layout_item->Frame();
	BRect textViewFrame = fLayoutData->text_view_layout_item->Frame();

	if (!labelFrame.IsValid() || !textViewFrame.IsValid())
		return;

	// update divider
	fDivider = textViewFrame.left - labelFrame.left;

	BRect frame = textViewFrame | labelFrame;
	MoveTo(frame.left, frame.top);
	BSize oldSize = Bounds().Size();
	ResizeTo(frame.Width(), frame.Height());
	BSize newSize = Bounds().Size();

	// If the size changes, ResizeTo() will trigger a relayout, otherwise
	// we need to do that explicitly.
	if (newSize != oldSize)
		Relayout();
}
BRect alpha_mixer_getOutputSize(je_mixer_plugin *cookie, BRect src1, BRect src2)
{
	alpha_mixer_private *self = (alpha_mixer_private *)cookie->data;
	BRect ret;
	
	// check rect validity first!!!
	// at least 1 is guaranteed to be valid
	if (src1.IsValid() && src2.IsValid())
	{
		if (src1.Width() > src2.Width())
		{
			// src1 is wider
			ret = src1;
			// set the scale for the mixer
			self->mix->SetScale(src2, src1);
		}
		else if (src1.Width() < src2.Width())
		{
			// src2 is wider
			ret = src2;
			// set the scale for the mixer
			self->mix->SetScale(src1, src2);
		}
		else if (src1.Height() > src2.Height())
		{
			// widths are equal, but src1 is taller
			ret = src1;
			// set the scale for the mixer
			self->mix->SetScale(src2, src1);
		}
		else
		{
			// widths are equal, src2 is taller or heights are equal
			ret = src2;
			// set the scale for the mixer
			self->mix->SetScale(src1, src2);
		}
	}
	else if (src1.IsValid())
	{
		// set the return value
		ret = src1;
		// set the scale for the mixer
		// 1.0 in this case (src == dst)
		self->mix->SetScale(ret, ret);
	}
	else // src2.IsValid()
	{
		// set the return value
		ret = src2;
		// set the scale for the mixer
		// 1.0 in this case (src == dst)
		self->mix->SetScale(ret, ret);
	}
	
	return ret;
}
Exemple #4
0
void BWebPage::paint(BRect rect, bool immediate)
{
	if (fLayoutingView || !rect.IsValid())
		return;
    // Block any drawing as long as the BWebView is hidden
    // (should be extended to when the containing BWebWindow is not
    // currently on screen either...)
    if (!fPageVisible) {
        fPageDirty = true;
        return;
    }

    // NOTE: fMainFrame can be 0 because init() eventually ends up calling
    // paint()! BWebFrame seems to cause an initial page to be loaded, maybe
    // this ought to be avoided also for start-up speed reasons!
    if (!fMainFrame)
        return;
    WebCore::Frame* frame = fMainFrame->Frame();
    WebCore::FrameView* view = frame->view();

    if (!view || !frame->contentRenderer())
        return;

	// Since calling layoutIfNeededRecursive can cycle back into paint(),
	// call this method before locking the window and before holding the
	// offscreen view lock.
	fLayoutingView = true;
	view->layout(true);
	fLayoutingView = false;

    if (!fWebView->LockLooper())
        return;
    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 (!offscreenView->LockLooper()) {
    	fWebView->UnlockLooper();
    	return;
    }
    fWebView->UnlockLooper();

    if (!rect.IsValid())
        rect = offscreenView->Bounds();
    BRegion region(rect);
    internalPaint(offscreenView, view, &region);

    offscreenView->UnlockLooper();

    fPageDirty = false;

    // Notify the window that it can now pull the bitmap in its own thread
    fWebView->SetOffscreenViewClean(rect, immediate);
}
void
LanguageListView::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	if (dragMessage != NULL && _AcceptsDragMessage(dragMessage)) {
		switch (transit) {
			case B_ENTERED_VIEW:
			case B_INSIDE_VIEW:
			{
				BRect highlightFrame;

				if (fGlobalDropTargetIndicator) {
					highlightFrame = Bounds();
					fDropIndex = 0;
				} else {
					// offset where by half of item height
					BRect r = ItemFrame(0);
					where.y += r.Height() / 2.0;

					int32 index = IndexOf(where);
					if (index < 0)
						index = CountItems();
					highlightFrame = ItemFrame(index);
					if (highlightFrame.IsValid())
						highlightFrame.bottom = highlightFrame.top;
					else {
						highlightFrame = ItemFrame(index - 1);
						if (highlightFrame.IsValid())
							highlightFrame.top = highlightFrame.bottom;
						else {
							// empty view, show indicator at top
							highlightFrame = Bounds();
							highlightFrame.bottom = highlightFrame.top;
						}
					}
					fDropIndex = index;
				}

				if (fDropTargetHighlightFrame != highlightFrame) {
					Invalidate(fDropTargetHighlightFrame);
					fDropTargetHighlightFrame = highlightFrame;
					Invalidate(fDropTargetHighlightFrame);
				}

				BOutlineListView::MouseMoved(where, transit, dragMessage);
				return;
			}
		}
	}

	if (fDropTargetHighlightFrame.IsValid()) {
		Invalidate(fDropTargetHighlightFrame);
		fDropTargetHighlightFrame = BRect();
	}
	BOutlineListView::MouseMoved(where, transit, dragMessage);
}
Exemple #6
0
// _InvalidateHighlightPoints
void
PathManipulator::_InvalidateHighlightPoints(int32 newIndex, uint32 newMode)
{
	BRect oldRect = _ControlPointRect(fCurrentPathPoint, fMode);
	BRect newRect = _ControlPointRect(newIndex, newMode);
	if (oldRect.IsValid())
		_InvalidateCanvas(oldRect);
	if (newRect.IsValid())
		_InvalidateCanvas(newRect);
}
Exemple #7
0
inline BRect rect_intersection(BRect r1, BRect r2)
{
	if (r1.IsValid() == false || r2.IsValid() == false) return BRect();

	BRect r3;
	r3.left = max_c(r1.left, r2.left);
	r3.top = max_c(r1.top, r2.top);
	r3.right = min_c(r1.right, r2.right);
	r3.bottom = min_c(r1.bottom, r2.bottom);

	return r3;
}
Exemple #8
0
void
BRadioButton::MouseDown(BPoint where)
{
	if (!IsEnabled() || !QueryCurrentMouse(true, B_PRIMARY_MOUSE_BUTTON)) return;

#if 0
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float sHeight = fontHeight.ascent + fontHeight.descent;

	BRect rect = Frame().OffsetToSelf(B_ORIGIN);
	rect.InsetBy(5, (rect.Height() - sHeight) / 2);
	if (rect.IsValid() == false) return;
	rect.right = rect.left + rect.Height();
	if (rect.Contains(where) == false) return;
#endif

	if ((Flags() &B_NAVIGABLE) && !IsFocus()) MakeFocus();

//	SetValue((Value() == B_CONTROL_ON) ?B_CONTROL_OFF :B_CONTROL_ON);

	if (Value() == B_CONTROL_ON) return;
	SetValue(B_CONTROL_ON);

	Invoke();
}
Exemple #9
0
void
BTextControl::_UpdateFrame()
{
	CALLED();

	if (fLayoutData->text_view_layout_item != NULL) {
		BRect textFrame = fLayoutData->text_view_layout_item->Frame();
		BRect labelFrame;
		if (fLayoutData->label_layout_item != NULL)
			labelFrame = fLayoutData->label_layout_item->Frame();

		BRect frame;
		if (labelFrame.IsValid()) {
			frame = textFrame | labelFrame;

			// update divider
			fDivider = fabs(textFrame.left - labelFrame.left);
		} else {
			frame = textFrame;
			fDivider = 0;
		}

		MoveTo(frame.left, frame.top);
		BSize oldSize = Bounds().Size();
		ResizeTo(frame.Width(), frame.Height());
		BSize newSize = Bounds().Size();

		// If the size changes, ResizeTo() will trigger a relayout, otherwise
		// we need to do that explicitly.
		if (newSize != oldSize)
			Relayout();
	}
}
Exemple #10
0
void
Utility::_MakeTabSpaceTransparent(BBitmap* screenshot, BRect frame) const
{
	if (!frame.IsValid() || screenshot->ColorSpace() != B_RGBA32)
		return;

	if (!frame.Contains(tabFrame))
		return;

	float tabHeight = tabFrame.bottom - tabFrame.top;

	BRegion tabSpace(frame);
	frame.OffsetBy(0, tabHeight);
	tabSpace.Exclude(frame);
	tabSpace.Exclude(tabFrame);
	frame.OffsetBy(0, -tabHeight);
	tabSpace.OffsetBy(-frame.left, -frame.top);
	BScreen screen;
	BRect screenFrame = screen.Frame();
	tabSpace.OffsetBy(-screenFrame.left, -screenFrame.top);

	BView view(screenshot->Bounds(), "bitmap", B_FOLLOW_ALL_SIDES, 0);
	screenshot->AddChild(&view);
	if (view.Looper() && view.Looper()->Lock()) {
		view.SetDrawingMode(B_OP_COPY);
		view.SetHighColor(B_TRANSPARENT_32_BIT);

		for (int i = 0; i < tabSpace.CountRects(); i++)
			view.FillRect(tabSpace.RectAt(i));

		view.Sync();
		view.Looper()->Unlock();
	}
	screenshot->RemoveChild(&view);
}
Exemple #11
0
// Draw
void
DragSortableListView::Draw( BRect updateRect )
{
	int32 firstIndex = IndexOf(updateRect.LeftTop());
	int32 lastIndex = IndexOf(updateRect.RightBottom());
	if (firstIndex >= 0) {
		if (lastIndex < firstIndex)
			lastIndex = CountItems() - 1;
		// update rect contains items
		BRect r = updateRect;
		for (int32 i = firstIndex; i <= lastIndex; i++) {
			r = ItemFrame(i);
			DrawListItem(this, i, r);
		}
		updateRect.top = r.bottom + 1.0;
		if (updateRect.IsValid()) {
			SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
			FillRect(updateRect, B_SOLID_LOW);
		}
	} else {
		SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
		FillRect(updateRect, B_SOLID_LOW);
	}
	// drop anticipation indication
	if (fDropRect.IsValid()) {
		SetHighColor(255, 0, 0, 255);
		StrokeRect(fDropRect);
	}
/*	// focus indication
	if (IsFocus()) {
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
		StrokeRect(Bounds());
	}*/
}
Exemple #12
0
// make_sure_frame_is_on_screen
bool
make_sure_frame_is_on_screen( BRect& frame )
{
    BScreen screen( B_MAIN_SCREEN_ID );
    if (frame.IsValid() && screen.IsValid()) {
        if (!screen.Frame().Contains(frame)) {
            // make sure frame fits in the screen
            if (frame.Width() > screen.Frame().Width())
                frame.right -= frame.Width() - screen.Frame().Width() + 10.0;
            if (frame.Height() > screen.Frame().Height())
                frame.bottom -= frame.Height() - screen.Frame().Height() + 30.0;
            // frame is now at the most the size of the screen
            if (frame.right > screen.Frame().right)
                frame.OffsetBy(-(frame.right - screen.Frame().right), 0.0);
            if (frame.bottom > screen.Frame().bottom)
                frame.OffsetBy(0.0, -(frame.bottom - screen.Frame().bottom));
            if (frame.left < screen.Frame().left)
                frame.OffsetBy((screen.Frame().left - frame.left), 0.0);
            if (frame.top < screen.Frame().top)
                frame.OffsetBy(0.0, (screen.Frame().top - frame.top));
        }
        return true;
    }
    return false;
}
Exemple #13
0
/*****************************************************************************
 * DragSortableListView::Draw
 *****************************************************************************/
void
DragSortableListView::Draw( BRect updateRect )
{
    int32 firstIndex = IndexOf( updateRect.LeftTop() );
    int32 lastIndex = IndexOf( updateRect.RightBottom() );
    if ( firstIndex >= 0 )
    {
        if ( lastIndex < firstIndex )
            lastIndex = CountItems() - 1;
        // update rect contains items
        BRect r( updateRect );
        for ( int32 i = firstIndex; i <= lastIndex; i++)
        {
            r = ItemFrame( i );
            DrawListItem( this, i, r );
        }
        updateRect.top = r.bottom + 1.0;
        if ( updateRect.IsValid() )
        {
            SetLowColor( 255, 255, 255, 255 );
            FillRect( updateRect, B_SOLID_LOW );
        }
    }
    else
    {
        SetLowColor( 255, 255, 255, 255 );
        FillRect( updateRect, B_SOLID_LOW );
    }
    // drop anticipation indication
    if ( fDropRect.IsValid() )
    {
        SetHighColor( 255, 0, 0, 255 );
        StrokeRect( fDropRect );
    }
}
Exemple #14
0
int RegionTestcase::GetPointsInRect(BRect theRect, BPoint **pointArrayPtr)
{
	*pointArrayPtr = pointArray;
	if (!theRect.IsValid()) {
		return(0);
	}
	
	float xIncrement = (theRect.Width() + 1.0) / (numPointsPerSide - 1);
	float yIncrement = (theRect.Height() + 1.0) / (numPointsPerSide - 1);
	
	int numPoints = 0;
	
	for(int i = 0; i < numPointsPerSide; i++) {
		float xCoord = theRect.left + (i * xIncrement);
		if (i == numPointsPerSide - 1) {
			xCoord = theRect.right;
		}
		for(int j = 0; j < numPointsPerSide; j++) {
			float yCoord = theRect.top + (j * yIncrement);
			if (j == numPointsPerSide - 1) {
				yCoord = theRect.bottom;
			}
			pointArray[numPoints].Set(floor(xCoord), floor(yCoord));
			assert(theRect.Contains(pointArray[numPoints]));
			numPoints++;
		}
	}
	return(numPoints); 
}
Exemple #15
0
void
BColorControl::_DrawColorRamp(BRect rect, BView* target,
	rgb_color baseColor, rgb_color compColor, int16 flag, bool focused,
	BRect updateRect)
{
	float width = rect.Width() + 1;
	rgb_color color;
	color.alpha = 255;

	updateRect = updateRect & rect;

	if (updateRect.IsValid() && updateRect.Width() >= 0) {
		target->BeginLineArray((int32)updateRect.Width() + 1);

		for (float i = (updateRect.left - rect.left);
				i <= (updateRect.right - rect.left) + 1; i++) {
			color.red = (uint8)(i * baseColor.red / width) + compColor.red;
			color.green = (uint8)(i * baseColor.green / width)
				+ compColor.green;
			color.blue = (uint8)(i * baseColor.blue / width) + compColor.blue;
			target->AddLine(BPoint(rect.left + i, rect.top),
				BPoint(rect.left + i, rect.bottom - 1), color);
		}

		target->EndLineArray();
	}
}
Exemple #16
0
bool
make_sure_frame_is_on_screen(BRect& frame, BWindow* window)
{
	BScreen* screen = window != NULL ? new BScreen(window)
		: new BScreen(B_MAIN_SCREEN_ID);

	bool success = false;
	if (frame.IsValid() && screen->IsValid()) {
		BRect screenFrame = screen->Frame();
		if (!screenFrame.Contains(frame)) {
			// make sure frame fits in the screen
			if (frame.Width() > screenFrame.Width())
				frame.right -= frame.Width() - screenFrame.Width() + 10.0;
			if (frame.Height() > screenFrame.Height())
				frame.bottom -= frame.Height() - screenFrame.Height() + 30.0;
			// frame is now at the most the size of the screen
			if (frame.right > screenFrame.right)
				frame.OffsetBy(-(frame.right - screenFrame.right), 0.0);
			if (frame.bottom > screenFrame.bottom)
				frame.OffsetBy(0.0, -(frame.bottom - screenFrame.bottom));
			if (frame.left < screenFrame.left)
				frame.OffsetBy((screenFrame.left - frame.left), 0.0);
			if (frame.top < screenFrame.top)
				frame.OffsetBy(0.0, (screenFrame.top - frame.top));
		}
		success = true;
	}
	delete screen;
	return success;
}
BMessage* Resize::Do(PDocument *doc, BMessage *settings)
{
	BMessage		*undoMessage		= new BMessage();
	BList			*selected			= doc->GetSelected();
	BList			*changed			= doc->GetChangedNodes();
	float			dx,dy;
	BRect			*newFrame			= new BRect(0,0,100,100);
	BRect			*oldFrame			= new BRect(0,0,100,100);
	BMessage		*node				= new BMessage();
	int32			i					= 0;
	if ( (settings->FindFloat("dx",&dx)==B_OK) && (settings->FindFloat("dy",&dy)==B_OK) )
	{
		for (i=0;i<selected->CountItems();i++)
		{
			node=(BMessage *)selected->ItemAt(i);
			node->FindRect("Node::frame",oldFrame);
			undoMessage->AddRect("oldFrame",*oldFrame);
			undoMessage->AddPointer("node",node);
			*newFrame			=	*oldFrame;
			newFrame->right		+=	dx;
			newFrame->bottom	+=	dy;
			if ( (newFrame->IsValid()) && (newFrame->Width()>20) && ((newFrame->Height()>20)) )
			{
				node->ReplaceRect("Node::frame",*newFrame);
				changed->AddItem(node);
			}
		}
	}
	doc->SetModified();
	settings->RemoveName("Resize::Undo");
	settings->AddMessage("Resize::Undo",undoMessage);
	settings= PCommand::Do(doc,settings);
	return settings;
}
Exemple #18
0
BRect
CanvasView::_LayoutCanvas()
{
	// size of zoomed bitmap
	BRect r(_CanvasRect());
	r.OffsetTo(B_ORIGIN);

	// ask current view state to extend size
	// TODO: Ask StateViewState to extend bounds...
	BRect stateBounds = r; //ViewStateBounds();

	// resize for empty area around bitmap
	// (the size we want, but might still be much smaller than view)
	r.InsetBy(-50, -50);

	// center data rect in bounds
	BRect bounds(Bounds());
	if (bounds.Width() > r.Width())
		r.InsetBy(-ceilf((bounds.Width() - r.Width()) / 2), 0);
	if (bounds.Height() > r.Height())
		r.InsetBy(0, -ceilf((bounds.Height() - r.Height()) / 2));

	if (stateBounds.IsValid()) {
		stateBounds.InsetBy(-20, -20);
		r = r | stateBounds;
	}

	return r;
}
Exemple #19
0
// _Clipped
BRect
Painter::_Clipped(const BRect& rect) const
{
	if (rect.IsValid() && fClippingRegion)
		return rect & _Transform(fClippingRegion->Frame());
	return rect;
}
Exemple #20
0
SettingsWindow::SettingsWindow(BRect frame, SettingsMessage* settings)
	:
	BWindow(frame, B_TRANSLATE("Settings"), B_TITLED_WINDOW_LOOK,
		B_NORMAL_WINDOW_FEEL, B_AUTO_UPDATE_SIZE_LIMITS
			| B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fSettings(settings)
{
	fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(MSG_APPLY));
	fCancelButton = new BButton(B_TRANSLATE("Cancel"),
		new BMessage(MSG_CANCEL));
	fRevertButton = new BButton(B_TRANSLATE("Revert"),
		new BMessage(MSG_REVERT));

	fOpenFilePanel = NULL;

	float spacing = be_control_look->DefaultItemSpacing();

	BTabView* tabView = new BTabView("settings pages", B_WIDTH_FROM_LABEL);
	tabView->SetBorder(B_NO_BORDER);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(0, B_USE_DEFAULT_SPACING, 0, B_USE_WINDOW_SPACING)
		.Add(tabView)
		.Add(new BSeparatorView(B_HORIZONTAL))
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_WINDOW_SPACING, 0)
			.Add(fRevertButton)
			.AddGlue()
			.Add(fCancelButton)
			.Add(fApplyButton);

	tabView->AddTab(_CreateGeneralPage(spacing));
	tabView->AddTab(_CreateFontsPage(spacing));
	tabView->AddTab(_CreateProxyPage(spacing));

	_SetupFontSelectionView(fStandardFontView,
		new BMessage(MSG_STANDARD_FONT_CHANGED));
	_SetupFontSelectionView(fSerifFontView,
		new BMessage(MSG_SERIF_FONT_CHANGED));
	_SetupFontSelectionView(fSansSerifFontView,
		new BMessage(MSG_SANS_SERIF_FONT_CHANGED));
	_SetupFontSelectionView(fFixedFontView,
		new BMessage(MSG_FIXED_FONT_CHANGED));

	fApplyButton->MakeDefault(true);

	if (!frame.IsValid())
		CenterOnScreen();

	// load settings from disk
	_RevertSettings();
	// apply to WebKit
	_ApplySettings();

	// Start hidden
	Hide();
	Show();
}
Exemple #21
0
void
OutputView::UpdatePreviewFromSettings()
{
	BRect rect = Settings().CaptureArea();
	if (!rect.IsValid())
		rect = BScreen().Frame();
	fRectView->Update(&rect);
}
Exemple #22
0
//------------------------------------------------------------------------------
bool
BRect::Intersects(BRect rect) const
{
	if (!IsValid() || !rect.IsValid())
		return false;

	return !(rect.left > right || rect.right < left
			|| rect.top > bottom || rect.bottom < top);	
}
Exemple #23
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);
}
Exemple #24
0
int32
Controller::CaptureThread()
{
	Settings settings;
	BScreen screen;
	BRect bounds = settings.CaptureArea();
	bigtime_t captureDelay = (bigtime_t)settings.CaptureFrameDelay() * 1000;
	
	// TODO: Validate captureDelay with some limits
	
	_DumpSettings();
	_TestWaitForRetrace();
	
	const int32 windowBorder = settings.WindowFrameBorderSize();
	int32 token = GetWindowTokenForFrame(bounds, windowBorder);
	bigtime_t waitTime = 0;
	status_t error = B_ERROR;
	while (!fKillThread) {
		if (!fPaused) {		
			if (token != -1) {
				BRect windowBounds = GetWindowFrameForToken(token, windowBorder);
				if (windowBounds.IsValid())
					bounds.OffsetTo(windowBounds.LeftTop());
			}
				
			_WaitForRetrace(captureDelay); // Wait for Vsync
			BBitmap *bitmap = new BBitmap(bounds, screen.ColorSpace());
			error = ReadBitmap(bitmap, true, bounds);
			bigtime_t currentTime = system_time();
			// Takes ownership of the bitmap
	    	if (error == B_OK && fFileList->AddItem(bitmap, currentTime))
				atomic_add(&fNumFrames, 1);
			else {
				delete bitmap;
				break;
			}
		} else
			snooze(500000);
	}
	
	fCaptureThread = -1;
	fKillThread = true;
	
	if (error != B_OK) {
		BMessage message(kMsgControllerCaptureStopped);
		message.AddInt32("status", (int32)error);
		SendNotices(kMsgControllerCaptureStopped, &message);
		
		delete fFileList;
		fFileList = NULL;
	}
		
	return B_OK;
}
Exemple #25
0
BRect
ScaleRectToFit(const BRect &from, const BRect &to)
{
	// Dynamic sizing algorithm
	// 1) Check to see if either dimension is bigger than the view's display area
	// 2) If smaller along both axes, make bitmap rect centered and return
	// 3) Check to see if scaling is to be horizontal or vertical on basis of longer axis
	// 4) Calculate scaling factor
	// 5) Scale both axes down by scaling factor, accounting for border width
	// 6) Center the rectangle in the direction of the smaller axis
	
	if (!to.IsValid())
		return from;
	if (!from.IsValid())
		return to;
	
	BRect r(to);
	
	if ((from.Width() <= r.Width()) && (from.Height() <= r.Height())) {
		// Smaller than view, so just center and return
		r = from;
		r.OffsetBy((to.Width() - r.Width()) / 2, (to.Height() - r.Height()) / 2);
		return r;
	}
	
	float multiplier = from.Width()/from.Height();
	if (multiplier > 1)	{
		// Landscape orientation
		
		// Scale rectangle to bounds width and center height
		r.bottom = r.top + (r.Width() / multiplier);
		r.OffsetBy(0, (to.Height() - r.Height()) / 2);
	} else {
		// Portrait orientation

		// Scale rectangle to bounds height and center width
		r.right = r.left + (r.Height() * multiplier);
		r.OffsetBy((to.Width() - r.Width()) / 2, 0);
	}
	return r;
}
void
LineChartRenderer::Render(BView* view, BRect updateRect)
{
	if (!updateRect.IsValid() || updateRect.left > fFrame.right
		|| fFrame.left > updateRect.right) {
		return;
	}

	if (fDomain.min >= fDomain.max || fRange.min >= fRange.max)
		return;

	if (!_UpdateSamples())
		return;

	// get the range to draw (draw one more sample on each side)
	int32 left = (int32)fFrame.left;
	int32 first = (int32)updateRect.left - left - 1;
	int32 last = (int32)updateRect.right - left + 1;
	if (first < 0)
		first = 0;
	if (last > fFrame.IntegerWidth())
		last = fFrame.IntegerWidth();
	if (first > last)
		return;

	double minRange = fRange.min;
	double sampleRange = fRange.max - minRange;
	if (sampleRange == 0) {
		minRange = fRange.min - 0.5;
		sampleRange = 1;
	}
	double scale = (double)fFrame.IntegerHeight() / sampleRange;

	// draw
	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
	for (int32 i = 0; DataSourceInfo* info = fDataSources.ItemAt(i); i++) {

		float bottom = fFrame.bottom;
		BShape shape;
		shape.MoveTo(BPoint(left + first,
			bottom - ((info->samples[first] - minRange) * scale)));

		for (int32 i = first; i <= last; i++) {
			shape.LineTo(BPoint(float(left + i),
				float(bottom - ((info->samples[i] - minRange) * scale))));
		}
		view->SetHighColor(info->config.Color());
		view->MovePenTo(B_ORIGIN);
		view->StrokeShape(&shape);
	}
}
Exemple #27
0
Fontboy::~Fontboy(void)
{
	PropWindow *pwin;
	BRect rect;

	// Quit all opened detail windows
	if ((proplist != NULL) &&
		(!proplist->IsEmpty())) {
		for (int32 i = 0; (pwin = (PropWindow *)proplist->ItemAt(i)); i++) {
			if ((pwin != NULL) &&
				(B_OK == pwin->Lock())) {
				rect = pwin->Frame();
				pwin->Quit();
//				pwin->Unlock();
			}
		}
		// Save last details window rect
		if (rect.IsValid())
			prefs->SetPropsRect(&rect);
	}

	if (mainwindow != NULL) {
		// Save window positions
		rect = mainwindow->Frame();
		prefs->SetMainRect(&rect);

		if (mainwindow->Lock()) {
			mainwindow->Quit();
//			mainwindow->Unlock();
		}
	}

	if (prefwindow != NULL) {
		rect = prefwindow->Frame();
		prefs->SetPrefsRect(&rect);

		if (prefwindow->Lock()) {
			prefwindow->Quit();
//			prefwindow->Unlock();
		}
	}

	prefs->SavePrefs();

	delete proplist;
	delete bhelper;
	delete fontlist;
	delete prefs;
};
Exemple #28
0
void
RocketView::Draw(BRect where)
{
	// intersection of the view and update rect
	BRect	r = Bounds() & where;

	// if rect is valid, fill rect with our background color
	if (r.IsValid())
	{
		SetHighColor(white);
		FillRect(r);
	}
	
	// draw all items
	BListView::Draw(where);
}
Exemple #29
0
void
stroke_frame(BView* v, BRect r, rgb_color left, rgb_color top, rgb_color right,
	rgb_color bottom)
{
	if (v && r.IsValid()) {
		v->BeginLineArray(4);
			v->AddLine(BPoint(r.left, r.bottom),
					   BPoint(r.left, r.top), left);
			v->AddLine(BPoint(r.left + 1.0, r.top),
					   BPoint(r.right, r.top), top);
			v->AddLine(BPoint(r.right, r.top + 1.0),
					   BPoint(r.right, r.bottom), right);
			v->AddLine(BPoint(r.right - 1.0, r.bottom),
					   BPoint(r.left + 1.0, r.bottom), bottom);
		v->EndLineArray();
	}
}
Exemple #30
0
void RegionTestcase::CheckFrame(BRegion *theRegion)
{
	BRect theFrame = theRegion->Frame();
	if (theFrame.IsValid()) {
		assert(!RegionIsEmpty(theRegion));

		BRect testFrame = theRegion->RectAt(0);
		assert(theFrame.Contains(testFrame));
		
		for(int i = 1; i < theRegion->CountRects(); i++) {
			BRect tempRect = theRegion->RectAt(i);
			assert(theFrame.Contains(tempRect));
			testFrame = testFrame | tempRect;
		}
		assert(testFrame == theFrame);	
	} else {
		assert(RegionIsEmpty(theRegion));
	}
}