Ejemplo n.º 1
0
BRect
WorkspacesView::_WindowFrame(const BRect& workspaceFrame,
	const BRect& screenFrame, const BRect& windowFrame,
	BPoint windowPosition)
{
	BRect frame = windowFrame;
	frame.OffsetTo(windowPosition);

	// scale down the rect
	float factor = workspaceFrame.Width() / screenFrame.Width();
	frame.left = frame.left * factor;
	frame.right = frame.right * factor;

	factor = workspaceFrame.Height() / screenFrame.Height();
	frame.top = frame.top * factor;
	frame.bottom = frame.bottom * factor;

	// offset by the workspace fame position
	// and snap to integer coordinates without distorting the size too much
	frame.OffsetTo(rintf(frame.left + workspaceFrame.left),
		rintf(frame.top + workspaceFrame.top));
	frame.right = rintf(frame.right);
	frame.bottom = rintf(frame.bottom);

	return frame;
}
Ejemplo n.º 2
0
bool
TOSMagnify::CopyScreenRect(BRect srcRect)
{
	// constrain src rect to legal screen rect
	BScreen screen(Window());
	BRect scrnframe = screen.Frame();

	if (srcRect.right > scrnframe.right)
		srcRect.OffsetTo(scrnframe.right - srcRect.Width(), srcRect.top);
	if (srcRect.top < 0)
		srcRect.OffsetTo(srcRect.left, 0);

	if (srcRect.bottom > scrnframe.bottom)
		srcRect.OffsetTo(srcRect.left, scrnframe.bottom - srcRect.Height());
	if (srcRect.left < 0)
		srcRect.OffsetTo(0, srcRect.top);

	// save a copy of the bits for comparison later
	memcpy(fOldBits, fBitmap->Bits(), fBitmap->BitsLength());

	screen.ReadBitmap(fBitmap, false, &srcRect);

	// let caller know whether bits have actually changed
	return memcmp(fBitmap->Bits(), fOldBits, fBitmap->BitsLength()) != 0;
}
Ejemplo n.º 3
0
_BZombieReplicantView_ *
BShelf::_CreateZombie(BMessage *data, BDragger *&dragger)
{
	// TODO: the zombies must be adjusted and moved as well!
	BRect frame;
	if (data->FindRect("_frame", &frame) != B_OK)
		frame = BRect();

	_BZombieReplicantView_ *zombie = NULL;
	if (data->WasDropped()) {
		BPoint offset;
		BPoint dropPoint = data->DropPoint(&offset);

		frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset);

		zombie = new _BZombieReplicantView_(frame, B_ERROR);

		frame.OffsetTo(B_ORIGIN);

		dragger = new BDragger(frame, zombie);
		dragger->_SetShelf(this);
		dragger->_SetZombied(true);

		zombie->AddChild(dragger);
		zombie->SetArchive(data);
		zombie->AddFilter(new ReplicantViewFilter(this, zombie));

		fContainerView->AddChild(zombie);
	}

	return zombie;
}
BBitmap *TWipeTopLeftToBottomRightIn::TransformBitmap(uint32 time, const BBitmap *source,
			const TCuePosition &registration, DisplayQuality quality)
{
	//	Only create offscreen at first pass
	if (!m_Inited)
	{
		BRect offRect = registration.Enclosure();
		offRect.OffsetTo(0, 0);
		InitOffscreen(offRect);
	}
		
	//	Calculate times
	const uint32 taskTime 	= time - StartTime();
	const uint32 endTime 	= StartTime() + Duration();
		
	// percentDone is on a scale of 0 to 1000.  Check for overflow...
	int32  percentDone;
	
	if ( time < endTime)
		percentDone = taskTime * 1000L / Duration();
	else
		percentDone = 1001;
	
	if (percentDone > 1000)
		percentDone = 1000;
			
	// Set up source rectangle				
	BRect srcRect 	= registration.Enclosure();	
	srcRect.OffsetTo(0, 0);	
	srcRect.right 	= srcRect.left + srcRect.Width() * percentDone / 1000;
	srcRect.bottom 	= srcRect.top + srcRect.Height() * percentDone / 1000;
		
	// Set up destination rectangle
	BRect dstRect 	= registration.Enclosure();
	dstRect.OffsetTo(0, 0);
	dstRect.right 	= dstRect.left + srcRect.Width();
	dstRect.bottom 	= dstRect.top + srcRect.Height();							

		
	// Draw bitmap
	if (m_OffscreenView->LockLooper())
	{
		//	Clear offscreen
		m_OffscreenView->SetHighColor(B_TRANSPARENT_32_BIT);		
		m_OffscreenView->FillRect(m_OffscreenView->Bounds());
		
		//	Do transitioned data
		m_OffscreenView->DrawBitmap(source, srcRect, dstRect);
		m_OffscreenView->Sync();

		m_OffscreenView->UnlockLooper();	
	}
	
	//	Clone offscreen
	BBitmap *newBitmap = CloneBitmap(*m_OffscreenBitmap);
	ASSERT(newBitmap);
		
	return newBitmap;
}
Ejemplo n.º 5
0
BRect URLView::GetTextRect() {
	// This function will return a BRect that contains only the text
	// and the underline, so the mouse can change and the link will
	// be activated only when the mouse is over the text itself, not
	// just within the view.
	
	// Note:  We'll use bounding boxes, because they are the most
	//        accurate, and since the user is interacting with the
	//        view, off-by-one-pixel errors look bad.
	const char *textArray[1];
	textArray[0] = Text();
	
	escapement_delta delta;
	delta.nonspace = 0;
	delta.space = 0;
	escapement_delta escapements[1];
	escapements[0] = delta;
	
	BRect returnMe;
	BRect rectArray[1];
	rectArray[0] = returnMe;
	
	BFont font;
	GetFont( &font );
	font.GetBoundingBoxesForStrings( textArray, 1, B_SCREEN_METRIC, escapements, rectArray );

	BRect frame = Frame();
	frame.OffsetTo( B_ORIGIN );
	returnMe = rectArray[0];
	
	// Get the height of the current font.
	font_height height;
	GetFontHeight( &height );
	float descent = height.descent;
	
	// Account for rounding of the floats when drawn to avoid
	// one-pixel-off errors.
	float lowerBound = 0;
	if( (((int) descent) * 2) != ((int) (descent * 2)) )
		lowerBound = 1;
	
	// Adjust the bounding box to reflect where the text is in the view.
	returnMe.bottom += 1;
	returnMe.OffsetTo( B_ORIGIN );
	float rectHeight = returnMe.Height();
	returnMe.bottom = frame.bottom - descent;
	returnMe.top = returnMe.bottom - rectHeight;
	returnMe.bottom += 1 + underlineThickness;
	returnMe.OffsetBy( 0.0, -(1 + lowerBound) );

	return returnMe;
}
Ejemplo n.º 6
0
void
ObjectView::Pulse()
{
	Window()->Lock();
	BRect parentBounds = Parent()->Bounds();
	BRect bounds = Bounds();
	parentBounds.OffsetTo(0, 0);
	bounds.OffsetTo(0, 0);
	if (bounds != parentBounds) {
		ResizeTo(parentBounds.right - parentBounds.left,
				 parentBounds.bottom - parentBounds.top);
	}
	Window()->Unlock();
}
Ejemplo n.º 7
0
AGGView::AGGView(BRect frame,
                 agg::platform_support* agg,
                 agg::pix_format_e format,
                 bool flipY)
    : BView(frame, "AGG View", B_FOLLOW_ALL,
            B_FRAME_EVENTS | B_WILL_DRAW),
      fFormat(format),
      fFlipY(flipY),

      fAGG(agg),

      fMouseButtons(0),
      fMouseX(-1),
      fMouseY(-1),
      
      fLastKeyDown(0),

      fRedraw(true),

      fPulse(NULL),
      fLastPulse(0),
      fEnableTicks(true)
{
    SetViewColor(B_TRANSPARENT_32_BIT);
    
    frame.OffsetTo(0.0, 0.0);
    fBitmap = new BBitmap(frame, 0, pix_format_to_color_space(fFormat));
    if (fBitmap->IsValid()) {
        attach_buffer_to_BBitmap(fAGG->rbuf_window(), fBitmap, fFlipY);
    } else {
        delete fBitmap;
        fBitmap = NULL;
    }
}
Ejemplo n.º 8
0
HDialog::HDialog(BRect frame, const char *name, window_type type,
	int flags, BWindow *owner, BPositionIO* data)
	: BWindow(frame, name, type, flags)
	, fOwner(owner)
	, fPlacement(H_PLACE_LAST_POS)
{
	frame.OffsetTo(0, 0);

	AddChild(fMainView = new HDlogView(frame, "main"));

	if (data)
		_BuildIt(*data);

	AddCommonFilter(new BMessageFilter(B_KEY_DOWN,KeyDownFilter));

	if (fOwner)
	{
		BMessage m(msg_AddDialog);
		m.AddPointer("dialog", this);
		fOwner->PostMessage(&m);

		// [zooey]: let dialog float above owner:
		SetFeel(B_FLOATING_SUBSET_WINDOW_FEEL);
		AddToSubset(fOwner);
	}
} /* HDialog::HDialog */
Ejemplo n.º 9
0
BochsApplication::BochsApplication()
            : BApplication("application/x-vnd.Be-Bochs")
{
  BRect      aRect;

  int left, right, top, bottom;
  left = 5;
  top = 80;
  dimension_x = 640;
  dimension_y = 480 + bx_headerbar_y;
  right = left + dimension_x - 1;
  bottom = top + dimension_y - 1;

  // set up a rectangle and instantiate a new window
  aRect.Set(left, top, right, bottom);
  aWindow = new BochsWindow(aRect);

  // set up a rectangle and instantiate a new view
  // view rect should be same size as window rect but with left top at (0, 0)
  aRect.OffsetTo(B_ORIGIN);
  aView = new BochsView(aRect, "BochsView");
  aView->SetViewColor(0, 0, 0);

  aView->set_text_colors();

  // add view to window
  aWindow->AddChild(aView);

  // make window visible
  aWindow->Show();
}
Ejemplo n.º 10
0
MagnificationView::MagnificationView(BRect rect)
	: BBox(rect, "magnificationView", B_FOLLOW_TOP | B_FOLLOW_LEFT,
		B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER)
{
	char string[256];
	sprintf(string,"%s: %.1f%%", StringServer::ReturnString(MAG_STRING), 1600.0);

	float width, height;
	rect.OffsetTo(4.0, 1.0);
	fMagStringView = new MagStringView(rect, "magStringView", string);
	fMagStringView->GetPreferredSize(&width, &height);
	fMagStringView->ResizeTo(width, rect.Height() - 2.0);
	AddChild(fMagStringView);

	height = rect.Height() - 2.0;
	fMinusButton = new BButton(rect, "minusButton", "-",
		new BMessage(HS_ZOOM_IMAGE_OUT));
	AddChild(fMinusButton);
	fMinusButton->ResizeTo(height, height);

	fPlusButton = new BButton(rect, "plusButton", "+",
		new BMessage(HS_ZOOM_IMAGE_IN));
	AddChild(fPlusButton);
	fPlusButton->ResizeTo(height, height);

	fMinusButton->MoveBy(width + 5.0, 0.0);
	fPlusButton->MoveBy(width + 5.0 + height, 0.0);

	ResizeTo(fPlusButton->Frame().right + 1.0, Bounds().Height());
}
Ejemplo n.º 11
0
CalcWindow::CalcWindow(BRect frame, BMessage* settings)
	: BWindow(frame, kWindowTitle, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
	// create calculator view with calculator description and
	// desktop background color
	BScreen screen(this);
	rgb_color baseColor = screen.DesktopColor();

	SetSizeLimits(100.0, 400.0, 100.0, 400.0);

	frame.OffsetTo(B_ORIGIN);
	fCalcView = new CalcView(frame, baseColor, settings);

	// create replicant dragger
	BRect replicantFrame(frame);
	replicantFrame.top = replicantFrame.bottom - 7.0f;
	replicantFrame.left = replicantFrame.right - 7.0f;
	BDragger* dragger = new BDragger(replicantFrame, fCalcView,
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);

	// attach views
	AddChild(fCalcView);
	fCalcView->AddChild(dragger);

	BRect rect;
	if (settings->FindRect("window frame", &rect) == B_OK)
		SetFrame(rect);
	else
		SetFrame(frame, true);
}
Ejemplo n.º 12
0
PPDConfigView::PPDConfigView(BRect bounds, const char *name, uint32 resizeMask, uint32 flags) 
	: BView(bounds, name, resizeMask, flags) 
	, fPPD(NULL)
{	
	// add category outline list view	
	bounds.OffsetTo(0, 0);
	BRect listBounds(bounds.left + kLeftMargin, bounds.top + kTopMargin, 
		bounds.right - kHorizontalSpace, bounds.bottom - kBottomMargin);
	listBounds.right -= B_V_SCROLL_BAR_WIDTH;
	listBounds.bottom -= B_H_SCROLL_BAR_HEIGHT;

	BStringView* label = new BStringView(listBounds, "printer-settings", "Printer Settings:");
	AddChild(label);
	label->ResizeToPreferred();
	
	listBounds.top += label->Bounds().bottom + 5;

	// add details view
	fDetails = new BView(listBounds, "details", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	fDetails->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	BScrollView* scrollView = new BScrollView("details-scroll-view", 
		fDetails, B_FOLLOW_ALL_SIDES, 0, true, true);

	AddChild(scrollView);
}
Ejemplo n.º 13
0
MainView::MainView( BRect frame ) : BView (frame, "mainView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) {

	SetViewColor(216, 216, 216);

	// nutzbare Größe
	frame.OffsetTo( 0.0, 0.0 );
	frame.InsetBy( 5.0, 5.0 );
	
	// Erstellen der beiden inneren Frames
	TopView* topView = new TopView( BRect( frame.left, frame.top, frame.right, frame.bottom - 72.0 - be_plain_font->Size() - be_bold_font->Size() ) );
	AddChild( topView );

	BottomView* bottomView = new BottomView( BRect( frame.left, frame.bottom - 67.0 - be_plain_font->Size() - be_bold_font->Size(), frame.right, frame.bottom - 43.0 ) );
	AddChild( bottomView );

	// StatusBar
	BStatusBar*	statusBar	= new BStatusBar( BRect(frame.left + 5.0, frame.bottom - be_plain_font->Size() - 23.0, frame.left + 400.0, frame.bottom), "statusBar", STATUS_STATUS, NULL);
	statusBar->SetText(STATUS_SELECT_FILES);
	statusBar->SetResizingMode(B_FOLLOW_BOTTOM);
	rgb_color color = { 70, 100, 180, 255};
	statusBar->SetBarColor(color);
	statusBar->SetBarHeight(14.0);
	AddChild(statusBar);
	
	// Do it! - Button
	BButton* DoItButton = new BButton( BRect ( frame.right - be_plain_font->StringWidth(STR_DO_IT) - 25.0, frame.bottom - 30.0, frame.right - 5.0 , frame.bottom - 5.0 ), "DoIt", STR_DO_IT, new BMessage(MSG_DO_IT), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
	DoItButton->SetEnabled(false);
	AddChild(DoItButton);
};
Ejemplo n.º 14
0
void
CalcView::FrameResized(float width, float height)
{
	fWidth = width;
	fHeight = height;

	// layout expression text view
	BRect frame = _ExpressionRect();
	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT) {
		frame.InsetBy(2, 2);
		frame.right -= ceilf(fCalcIcon->Bounds().Width() * 1.5);
	} else
		frame.InsetBy(4, 4);

	fExpressionTextView->MoveTo(frame.LeftTop());
	fExpressionTextView->ResizeTo(frame.Width(), frame.Height());

	// configure expression text view font size and color
	float sizeDisp = fOptions->keypad_mode == KEYPAD_MODE_COMPACT
					 ? fHeight : fHeight * kDisplayScaleY;
	BFont font(be_bold_font);
	font.SetSize(sizeDisp * kExpressionFontScaleY);
	fExpressionTextView->SetFontAndColor(&font, B_FONT_ALL);

	frame.OffsetTo(B_ORIGIN);
	float inset = (frame.Height() - fExpressionTextView->LineHeight(0)) / 2;
	frame.InsetBy(0, inset);
	fExpressionTextView->SetTextRect(frame);
	Invalidate();
}
Ejemplo n.º 15
0
/*!
	This is the BDirectWindow subclass that rendering occurs in.
	A view is added to it so that BView based screensavers will work.
*/
ScreenSaverWindow::ScreenSaverWindow(BRect frame)
	:
	BDirectWindow(frame, "ScreenSaver Window",
		B_NO_BORDER_WINDOW_LOOK, kWindowScreenFeel,
		B_NOT_RESIZABLE | B_NOT_MOVABLE | B_NOT_MINIMIZABLE
		| B_NOT_ZOOMABLE | B_NOT_CLOSABLE, B_ALL_WORKSPACES),
	fTopView(NULL),
	fSaverRunner(NULL),
	fFilter(NULL)
{
	frame.OffsetTo(0, 0);
	fTopView = new BView(frame, "ScreenSaver View", B_FOLLOW_ALL,
		B_WILL_DRAW);
	fTopView->SetViewColor(B_TRANSPARENT_COLOR);

	fFilter = new ScreenSaverFilter();
	fTopView->AddFilter(fFilter);

	AddChild(fTopView);

	// Ensure that this view receives keyboard and mouse input
	fTopView->MakeFocus(true);
	fTopView->SetEventMask(B_KEYBOARD_EVENTS | B_POINTER_EVENTS,
		B_NO_POINTER_HISTORY);
}
Ejemplo n.º 16
0
void
ActivityView::_UpdateOffscreenBitmap()
{
	BRect frame = _HistoryFrame();
	frame.OffsetTo(B_ORIGIN);

	if (fOffscreen != NULL && frame == fOffscreen->Bounds())
		return;

	delete fOffscreen;

	// create offscreen bitmap

	fOffscreen = new(std::nothrow) BBitmap(frame, B_BITMAP_ACCEPTS_VIEWS,
		B_RGB32);
	if (fOffscreen == NULL || fOffscreen->InitCheck() != B_OK) {
		delete fOffscreen;
		fOffscreen = NULL;
		return;
	}

	BView* view = new BView(frame, NULL, B_FOLLOW_NONE, B_SUBPIXEL_PRECISE);
	view->SetViewColor(fHistoryBackgroundColor);
	view->SetLowColor(view->ViewColor());
	fOffscreen->AddChild(view);
}
Ejemplo n.º 17
0
BottomlineWindow::BottomlineWindow()
	: BWindow(BRect(0, 0, 350, 16), "", 
		kLeftTitledWindowLook, 
		B_FLOATING_ALL_WINDOW_FEEL,
		B_NOT_V_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
			| B_AVOID_FOCUS | B_WILL_ACCEPT_FIRST_CLICK)
{
	BRect textRect = Bounds();
	textRect.OffsetTo(B_ORIGIN);
	textRect.InsetBy(2,2);
	fTextView = new BTextView(Bounds(), "", textRect, be_plain_font,
		NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
	AddChild(fTextView);

	fTextView->SetText("");

	BRect   screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
	BPoint pt;
	pt.x = 100;
	pt.y = screenFrame.Height()*2/3 - Bounds().Height()/2;	
	
	MoveTo(pt);
	Show();

	SERIAL_PRINT(("BottomlineWindow created\n"));
}
Ejemplo n.º 18
0
PyeManagerWindow::PyeManagerWindow(BHandler* returnHandler, Proxy* theProxy) :
	BWindow(BRect(200, 200, 415, 500), "Payee Manager",
	B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 
	B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE)
{
	this->returnHandler = returnHandler;
	this->theProxy = theProxy;
	pyeS = theProxy->GetPyeS();

	BRect frame = Frame();
	frame.OffsetTo(0, 0);	
	BView* backdrop = new BView(frame, "backview", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	backdrop->SetViewColor(222, 222, 222);
	AddChild(backdrop);
	
	lv = new BListView(BRect(10, 10, frame.Width() - 10 - 15, frame.Height() - 70),
		"PyeManagerLV");
	backdrop->AddChild(new BScrollView("scrolllv", lv,
		B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true));
	
	FillList();
	
	BButton* b = new BButton(BRect(10, frame.bottom - 60, 100, frame.bottom - 40), 
		"NewB", "New...", new BMessage(PyeManagerWindowNewMSG));
	backdrop->AddChild(b);
	b = new BButton(BRect(110, frame.bottom - 60, 200, frame.bottom - 40), 
		"RenameB", "Rename...", new BMessage(PyeManagerWindowRenameMSG));
	backdrop->AddChild(b);
	b = new BButton(BRect(10, frame.bottom - 30, 100, frame.bottom - 10), 
		"DeleteB", "Delete...", new BMessage(PyeManagerWindowDeleteMSG));
	backdrop->AddChild(b);
	b = new BButton(BRect(110, frame.bottom - 30, 200, frame.bottom - 10), 
		"CloseB", "Close", new BMessage(PyeManagerWindowCloseMSG));
	backdrop->AddChild(b);
}
Ejemplo n.º 19
0
// Draw
void
IconValueView::Draw(BRect updateRect)
{
	BRect r;
	BRegion originalClippingRegion;
	GetClippingRegion(&originalClippingRegion);
	if (fIcon) {
		BRect b(Bounds());
		// layout icon in the center
		r = fIcon->Bounds();
		r.OffsetTo(floorf(b.left + b.Width() / 2.0 - r.Width() / 2.0),
				   floorf(b.top + b.Height() / 2.0 - r.Height() / 2.0));
		if (fIcon->ColorSpace() == B_RGBA32 || fIcon->ColorSpace() == B_RGBA32_BIG) {
			// set up transparent drawing and let
			// the base class draw the entire background
			SetHighColor(255, 255, 255, 255);
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		} else {
			// constrain clipping region to exclude bitmap
			BRegion region = originalClippingRegion;
			region.Exclude(r);
			ConstrainClippingRegion(&region);
		}
	}
	// draw surrouing area (and possibly background for bitmap)
	PropertyEditorView::Draw(updateRect);

	ConstrainClippingRegion(&originalClippingRegion);
	if (fIcon) {
		DrawBitmap(fIcon, r.LeftTop());
	}
}
Ejemplo n.º 20
0
int32 color_tear_drag (void *data)
{
	colorTearInfo *tearInfo = (colorTearInfo *) data;
	uint32 buttons = 1;
	BPoint point;
	ColorMenu *menu = tearInfo->parent;
	BRect place = tearInfo->dragRect;
	BView *view = tearInfo->someView;
	// It might seem a good idea to use `menu' as the view, but
	// this gave errors: `Method requires owner but doesn't have one'.
	delete tearInfo;	// The caller doesn't do this (race condition otherwise)

	// printf ("Entering loop; view = %p\n", view);
	while (buttons)
	{
		view->Window()->Lock();
		view->GetMouse (&point, &buttons);
		view->Window()->Unlock();
		snooze (50000);
	}
	// printf ("Exited loop\n");
	view->Window()->Lock();
	point = view->ConvertToScreen (point);
	view->Window()->Unlock();

	// printf ("Released at (%.0f, %.0f)\n", point.x, point.y);
	place.OffsetTo (point);
	
	menu->getParent()->lock->Lock();
	menu->TearDone (place, !menu->getParent()->MenuWinOnScreen);
	menu->getParent()->lock->Unlock();

	return B_NO_ERROR;
}
Ejemplo n.º 21
0
void
RemoteDrawingEngine::DrawBitmap(ServerBitmap* bitmap, const BRect& _bitmapRect,
	const BRect& _viewRect, uint32 options)
{
	if (!fClippingRegion.Intersects(_viewRect))
		return;

	BRect viewRect = _viewRect;
	BRect bitmapRect = _bitmapRect;
	if (bitmapRect.IntegerWidth() == viewRect.IntegerWidth()
		&& bitmapRect.IntegerHeight() == viewRect.IntegerHeight()) {
		// unscaled bitmap we can chop off stuff we don't need
		BRegion target(viewRect);
		target.IntersectWith(&fClippingRegion);
		BRect frame = target.Frame();

		if (frame != viewRect) {
			BPoint offset = frame.LeftTop() - viewRect.LeftTop();
			viewRect = frame;
			bitmapRect = viewRect.OffsetToCopy(bitmapRect.LeftTop() + offset);
		}
	}

	UtilityBitmap* other = NULL;
	BRect bounds = bitmap->Bounds();
	BRect newBounds;
	newBounds.right
		= min_c(bounds.IntegerWidth(), bitmapRect.IntegerWidth());
	newBounds.bottom	
		= min_c(bounds.IntegerHeight(), bitmapRect.IntegerHeight());

	if (newBounds.IntegerWidth() < bounds.IntegerWidth()
		|| newBounds.IntegerHeight() < bounds.IntegerHeight()) {

		other = new(std::nothrow) UtilityBitmap(newBounds, bitmap->ColorSpace(),
			bitmap->Flags());

		if (other != NULL && other->ImportBits(bitmap->Bits(),
				bitmap->BitsLength(), bitmap->BytesPerRow(),
				bitmap->ColorSpace(), bitmapRect.LeftTop(), BPoint(0, 0),
				newBounds.IntegerWidth() + 1,
				newBounds.IntegerHeight() + 1) == B_OK) {
			bitmapRect.OffsetTo(0, 0);
			bitmap = other;
		}
	}

	// TODO: we may want to cache/checksum bitmaps
	RemoteMessage message(NULL, fHWInterface->SendBuffer());
	message.Start(RP_DRAW_BITMAP);
	message.Add(fToken);
	message.Add(bitmapRect);
	message.Add(viewRect);
	message.Add(options);
	message.AddBitmap(*bitmap);

	if (other != NULL)
		delete other;
}
Ejemplo n.º 22
0
void
SCMOutputWindow::FrameResized(float w, float h)
{
	BRect r = fLog->Frame();
	r.OffsetTo(0.0, 0.0);
	r.InsetBy(5.0, 5.0);
	fLog->SetTextRect(r);
}
Ejemplo n.º 23
0
status_t
StyledEditView::GetStyledText(BPositionIO* stream)
{
	fSuppressChanges = true;
	status_t result = BTranslationUtils::GetStyledText(stream, this,
		fEncoding.String());
	fSuppressChanges = false;

	if (result != B_OK)
		return result;

	BNode* node = dynamic_cast<BNode*>(stream);
	if (node != NULL) {
		// get encoding
		if (node->ReadAttrString("be:encoding", &fEncoding) != B_OK) {
			// try to read as "int32"
			int32 encoding;
			ssize_t bytesRead = node->ReadAttr("be:encoding", B_INT32_TYPE, 0,
				&encoding, sizeof(encoding));
			if (bytesRead == (ssize_t)sizeof(encoding)) {
				if (encoding == 65535) {
					fEncoding = "UTF-8";
				} else {
					const BCharacterSet* characterSet
						= BCharacterSetRoster::GetCharacterSetByConversionID(encoding);
					if (characterSet != NULL)
						fEncoding = characterSet->GetName();
				}
			}
		}

		// TODO: move those into BTranslationUtils::GetStyledText() as well?

		// restore alignment
		int32 align;
		ssize_t bytesRead = node->ReadAttr("alignment", 0, 0, &align, sizeof(align));
		if (bytesRead == (ssize_t)sizeof(align))
			SetAlignment((alignment)align);

		// restore wrapping
		bool wrap;
		bytesRead = node->ReadAttr("wrap", 0, 0, &wrap, sizeof(wrap));
		if (bytesRead == (ssize_t)sizeof(wrap)) {
			SetWordWrap(wrap);
			if (wrap == false) {
				BRect textRect;
				textRect = Bounds();
				textRect.OffsetTo(B_ORIGIN);
				textRect.InsetBy(TEXT_INSET, TEXT_INSET);
					// the width comes from stylededit R5. TODO: find a better way
				textRect.SetRightBottom(BPoint(1500.0, textRect.RightBottom().y));
				SetTextRect(textRect);
			}
		}
	}

	return result;
}
Ejemplo n.º 24
0
void 
TSignatureView::AttachedToWindow()
{
	BRect	rect = Bounds();
	float	name_text_length = StringWidth(kNameText);
	float	sig_text_length = StringWidth(kSigText);
	float	divide_length;

	if (name_text_length > sig_text_length)
		divide_length = name_text_length;
	else
		divide_length = sig_text_length;

	rect.InsetBy(8,0);
	rect.top+= 8;
	
	fName = new TNameControl(rect, kNameText, new BMessage(NAME_FIELD));
	AddChild(fName);

	fName->SetDivider(divide_length + 10);
	fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	rect.OffsetBy(0,fName->Bounds().Height()+5);
	rect.bottom = rect.top + kSigHeight;
	rect.left = fName->TextView()->Frame().left;

	BRect text = rect;
	text.OffsetTo(10,0);
	fTextView = new TSigTextView(rect, text);
	BScrollView *scroller = new BScrollView("SigScroller", fTextView, B_FOLLOW_ALL, 0, false, true);
	AddChild(scroller);
	scroller->ResizeBy(-1 * scroller->ScrollBar(B_VERTICAL)->Frame().Width() - 9, 0);
	scroller->MoveBy(7,0);

	/* back up a bit to make room for the label */

	rect = scroller->Frame();
	BStringView *stringView = new BStringView(rect, "SigLabel", kSigText);
	AddChild(stringView);

	float tWidth, tHeight;
	stringView->GetPreferredSize(&tWidth, &tHeight);

	/* the 5 is for the spacer in the TextView */

	rect.OffsetBy(-1 *(tWidth) - 5, 0);
	rect.right = rect.left + tWidth;
	rect.bottom = rect.top + tHeight;

	stringView->MoveTo(rect.LeftTop());
	stringView->ResizeTo(rect.Width(), rect.Height());

	/* Resize the View to the correct height */
	scroller->SetResizingMode(B_FOLLOW_NONE);
	ResizeTo(Frame().Width(), scroller->Frame().bottom + 8);
	scroller->SetResizingMode(B_FOLLOW_ALL);
}
Ejemplo n.º 25
0
/////////////////////////////////////////////////////////////////
//init window frame.
/////////////////////////////////////////////////////////////////
BRect
kanBeApp::InitFrame(float w, float h)
{
BRect			frameRect;

	frameRect.Set(0, 0, K_CONVBUFSIZE * w + 2 * 2, h * 2 + 2 * 3);
	frameRect.OffsetTo(10, BScreen().Frame().bottom - h * 2 - 2 * 3 - 30);

	return frameRect;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
0
filter_result
ShelfContainerViewFilter::_ObjectDropFilter(BMessage *msg, BHandler **_handler)
{
	BView *mouseView = NULL;
	if (*_handler)
		mouseView = dynamic_cast<BView*>(*_handler);

	if (msg->WasDropped()) {
		if (!fShelf->fAllowDragging) {
			printf("Dragging replicants isn't allowed to this shelf.");
			beep();
			return B_SKIP_MESSAGE;
		}
	}

	BPoint point;
	BPoint offset;

	if (msg->WasDropped()) {
		point = msg->DropPoint(&offset);
		point = mouseView->ConvertFromScreen(point - offset);
	}

	BLooper *looper = NULL;
	BHandler *handler = msg->ReturnAddress().Target(&looper);

	if (Looper() == looper) {
		BDragger *dragger = NULL;
		if (handler)
			dragger = dynamic_cast<BDragger*>(handler);

		BRect rect;
		if (dragger->fRelation == BDragger::TARGET_IS_CHILD)
			rect = dragger->Frame();
		else
			rect = dragger->fTarget->Frame();
		rect.OffsetTo(point);
		point = rect.LeftTop() + fShelf->AdjustReplicantBy(rect, msg);

		if (dragger->fRelation == BDragger::TARGET_IS_PARENT)
			dragger->fTarget->MoveTo(point);
		else if (dragger->fRelation == BDragger::TARGET_IS_CHILD)
			dragger->MoveTo(point);
		else {
			//TODO: TARGET_UNKNOWN/TARGET_SIBLING
		}

	} else {
		if (fShelf->_AddReplicant(msg, &point, fShelf->fGenCount++) == B_OK)
			Looper()->DetachCurrentMessage();
	}

	return B_SKIP_MESSAGE;
}
Ejemplo n.º 28
0
void
WorkspacesSettings::UpdateFramesForScreen(BRect newScreenFrame)
{
	// don't change the position if the screen frame hasn't changed
	if (newScreenFrame == fScreenFrame)
		return;

	// adjust horizontal position
	if (fWindowFrame.right > fScreenFrame.right / 2) {
		fWindowFrame.OffsetTo(newScreenFrame.right
			- (fScreenFrame.right - fWindowFrame.left), fWindowFrame.top);
	}

	// adjust vertical position
	if (fWindowFrame.bottom > fScreenFrame.bottom / 2) {
		fWindowFrame.OffsetTo(fWindowFrame.left,
			newScreenFrame.bottom - (fScreenFrame.bottom - fWindowFrame.top));
	}

	fScreenFrame = newScreenFrame;
}
Ejemplo n.º 29
0
	PPDBuilder(BView* parent, BView* view, BMessage& settings) 
		: fParent(parent)
		, fView(view)
		, fBounds(view->Bounds())
		, fSettings(settings)
	{
		RemoveChildren(view);
		fBounds.OffsetTo(0, 0);
		fBounds.left += kLeftMargin;
		fBounds.top += kTopMargin;
		fBounds.right -= kRightMargin;
	}
Ejemplo n.º 30
0
void
StyledEditView::FrameResized(float width, float height)
{
	BTextView::FrameResized(width, height);

	if (DoesWordWrap()) {
		BRect textRect;
		textRect = Bounds();
		textRect.OffsetTo(B_ORIGIN);
		textRect.InsetBy(TEXT_INSET, TEXT_INSET);
		SetTextRect(textRect);
	}
}