Ejemplo n.º 1
0
void
IconSpewer::DrawSomeOld()
{
#if 0
	if (!oldIconCacheInited)
		BIconCache::InitIconCaches();

	target->Lock();
	target->SetTitle("old cache");
	BView* view = target->FindView("iconView");
	ASSERT(view);

	BRect bounds(target->Bounds());
	view->SetHighColor(Color(255, 255, 255));
	view->FillRect(bounds);

	view->SetHighColor(Color(0, 0, 0));
	char buffer[256];
	if (cycleTime) {
		sprintf(buffer, "last cycle time %Ld ms", cycleTime/1000);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
	}
	if (numDrawn) {
		sprintf(buffer, "average draw time %Ld us per icon",
			watch.ElapsedTime() / numDrawn);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
	}
	sprintf(buffer, "directory: %s", currentPath.Path());
	view->DrawString(buffer, BPoint(20, bounds.bottom - 40));

	target->Unlock();

	for (int32 row = 0; row < kRowCount; row++) {
		for (int32 column = 0; column < kColumnCount; column++) {
			BEntry entry(NextRef());
			BModel model(&entry, true);

			if (!target->Lock())
				return;

			if (model.IsDirectory())
				entry.GetPath(&currentPath);

			BIconCache::LockIconCache();
			BIconCache* iconCache
				= BIconCache::GetIconCache(&model, kIconSize);
			iconCache->Draw(view, BPoint(column * (kIconSize + 2),
				row * (kIconSize + 2)), B_NORMAL_ICON, kIconSize, true);
			BIconCache::UnlockIconCache();

			target->Unlock();
			numDrawn++;
		}
	}
#endif
}
Ejemplo n.º 2
0
void
IconSpewer::DrawSomeNew()
{
	target->Lock();
	BView* view = target->FindView("iconView");
	ASSERT(view);

	BRect bounds(target->Bounds());
	view->SetHighColor(Color(255, 255, 255));
	view->FillRect(bounds);

	view->SetHighColor(Color(0, 0, 0));
	char buffer[256];
	if (cycleTime) {
		sprintf(buffer, "last cycle time %" B_PRId64 " ms", cycleTime/1000);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
	}

	if (numDrawn) {
		sprintf(buffer, "average draw time %" B_PRId64 " us per icon",
			watch.ElapsedTime() / numDrawn);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
	}

	sprintf(buffer, "directory: %s", currentPath.Path());
	view->DrawString(buffer, BPoint(20, bounds.bottom - 40));

	target->Unlock();

	for (int32 row = 0; row < kRowCount; row++) {
		for (int32 column = 0; column < kColumnCount; column++) {
			BEntry entry(NextRef());
			Model model(&entry, true);

			if (!target->Lock())
				return;

			if (model.IsDirectory())
				entry.GetPath(&currentPath);

			IconCache::sIconCache->Draw(&model, view,
				BPoint(column * (kIconSize + 2), row * (kIconSize + 2)),
				kNormalIcon, kIconSize, true);
			target->Unlock();
			numDrawn++;
		}
	}
}
Ejemplo n.º 3
0
void CounterView::Draw (BRect updateRect)
{
  BRect MovingRect (
    m_MovingDotPoint.x,
    m_MovingDotPoint.y,
    m_MovingDotPoint.x + m_MovingDotSize,
    m_MovingDotPoint.y + m_MovingDotSize);
  char TempString [40];

  if (m_BackingBitmap != NULL)
  {
    m_BackingBitmap->Lock ();
    m_BackingView.SetHighColor (60, 60, 255, 8);
    m_BackingView.FillRect (m_BndRect);
    m_BackingView.SetHighColor (255, 255, 0, 255);
    m_BackingView.MovePenTo (m_TextStartPoint);
    sprintf (TempString, "%d", m_CurrentCount);
    m_BackingView.DrawString (TempString);
    m_BackingView.FillRect (MovingRect);
    m_BackingView.Sync ();
    m_BackingBitmap->Unlock ();
    MovePenTo (0, 0);
    DrawBitmap (m_BackingBitmap);
  }
}
Ejemplo n.º 4
0
void wxStatusBarBeOS::DrawStatusBar()
{

	int i=0;
	int leftPos=0;
	wxArrayInt widthsAbs;
	wxString text;

	m_view->Clear();
	BRect bounds(m_view->bounds());
	BView * drawview = m_view->GetBack();
	if(drawview->LockLooper())
	{	
		rgb_color clr;
		drawview->PushState();
		clr = drawview->ViewColor();
		clr.red-=50; clr.green-=50; clr.blue-=50;
		drawview->SetHighColor(clr);
		drawview->StrokeLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top));
		clr.red+=100; clr.green+=100; clr.blue+=100;
		drawview->SetHighColor(clr);
		drawview->StrokeLine(BPoint(bounds.left, bounds.top+1), BPoint(bounds.right, bounds.top+1));
		drawview->PopState();
		
		if(m_nFields>0)
			widthsAbs = CalculateAbsWidths(bounds.IntegerWidth() - 2*(m_nFields - 1));
		
		drawview->SetDrawingMode(B_OP_OVER);
		for(i=0;i<m_nFields;i++)
		{
			text = GetStatusBufferText(i);
			drawview->DrawString(text, BPoint(leftPos, bounds.bottom-2));
			leftPos+=widthsAbs[i]+2;
		}
		
		drawview->UnlockLooper();
	}
	m_view->flush();
}
Ejemplo n.º 5
0
BBitmap *DragonView::_MakeNoneImage( void )
{
	// Draw an "empty" bitmap to represent "no image"; we'll use one
	// that tells the user what to do.
	BBitmap *bitmap = new BBitmap( BRect( 0, 0, 319, 199 ),
								   BScreen().ColorSpace(),
								   true );
	BView *view = new BView( bitmap->Bounds(),
							 "not a bitmap",
							 B_FOLLOW_ALL_SIDES, 0 );
	bitmap->AddChild( view );

	DragonApp *app = dynamic_cast<DragonApp *>( be_app );
	
	rgb_color White = { 255, 255, 255, 0 };
	rgb_color Black = { 0, 0, 0, 0 };
	
	bitmap->Lock();

	view->SetLowColor( White );
	view->SetViewColor( White );
	view->SetHighColor( Black );
	view->SetDrawingMode( B_OP_OVER );
	view->FillRect( view->Bounds(), B_SOLID_LOW );

	// Excercise for the reader here:  Read the old newsletter articles
	// about how to use the font metrics to find out how large a font is,
	// then center to font in the window dynamically no matter what font
	// settings the user has.

	view->SetFont( be_plain_font );
	view->MovePenTo( 5, 100 );
	view->DrawString( app->rsrc_strings->FindString( RSRC_Drop_an_image ) );
	view->Sync();
	
	bitmap->Unlock();

	return bitmap;
}
Ejemplo n.º 6
0
// MouseMoved
void
ObjectView::MouseMoved(BPoint where, uint32 transit,
					   const BMessage* dragMessage)
{
//	BRect dirty(where, where);
//	dirty.InsetBy(-10, -10);
//	Invalidate(dirty);
	
if (dragMessage) {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y);
//Window()->CurrentMessage()->PrintToStream();
} else {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y);
}

	if (fScrolling) {
		BCursor cursor(kGrabCursor);
		SetViewCursor(&cursor);
	
		BPoint offset = fLastMousePos - where;
		ScrollBy(offset.x, offset.y);
		fLastMousePos = where + offset;
	} else if (fInitiatingDrag) {
		BPoint offset = fLastMousePos - where;
		if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) {
			BMessage newDragMessage('drag');
			BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32,
				true);
			if (dragBitmap->Lock()) {
				BView* helper = new BView(dragBitmap->Bounds(),
					"offscreen view", B_FOLLOW_ALL, B_WILL_DRAW);
				dragBitmap->AddChild(helper);
				helper->SetDrawingMode(B_OP_ALPHA);
				helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);

				BRect r(helper->Bounds());
				helper->SetHighColor(0, 0, 0, 128);
				helper->StrokeRect(r);

				helper->SetHighColor(200, 200, 200, 100);
				r.InsetBy(1, 1);
				helper->FillRect(r);

				helper->SetHighColor(0, 0, 0, 255);
				const char* text = B_TRANSLATE("Test");
				float pos = (r.Width() - helper->StringWidth(text)) / 2;
				helper->DrawString(text, BPoint(pos, 25));
				helper->Sync();
			}
			
			DragMessage(&newDragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN,
				this);
			fInitiatingDrag = false;
		}
	} else {
		BCursor cursor(kMoveCursor);
		SetViewCursor(&cursor);
	
		if (fState && fState->IsTracking()) {
			BRect before = fState->Bounds();
	
			fState->MouseMoved(where);
	
			BRect after = fState->Bounds();
			BRect invalid(before | after);
			Invalidate(invalid);
		}
	}
//	SetViewCursor();
}
Ejemplo n.º 7
0
void
RemoteView::_DrawThread()
{
	RemoteMessage reply(NULL, fSendBuffer);
	RemoteMessage message(fReceiveBuffer, NULL);

	// cursor
	BPoint cursorHotSpot(0, 0);

	while (!fStopThread) {
		uint16 code;
		status_t status = message.NextMessage(code);
		if (status != B_OK) {
			TRACE_ERROR("failed to read message from receiver\n");
			break;
		}

		TRACE("code %u with %ld bytes data\n", code, message.DataLeft());

		BAutolock locker(this->Looper());
		if (!locker.IsLocked())
			break;

		// handle stuff that doesn't go to a specicifc engine
		switch (code) {
			case RP_INIT_CONNECTION:
			{
				uint16 port;
				status_t result = message.Read(port);
				if (result != B_OK) {
					TRACE_ERROR("failed to read remote port\n");
					continue;
				}

				BNetEndpoint *endpoint = fReceiver->Endpoint();
				if (endpoint == NULL) {
					TRACE_ERROR("receiver not connected anymore\n");
					continue;
				}

				in_addr remoteHost;
				char hostName[MAXHOSTNAMELEN + 1];
				BNetAddress address(endpoint->RemoteAddr());
				address.GetAddr(remoteHost);
				address.GetAddr(hostName, NULL);
				address.SetTo(remoteHost, port);

				TRACE("connecting to host \"%s\" port %u\n", hostName, port);
				result = fSendEndpoint->Connect(address);
				if (result != B_OK) {
					TRACE_ERROR("failed to connect to host \"%s\" port %u\n",
						hostName, port);
					continue;
				}

				BRect bounds = fOffscreenBitmap->Bounds();
				reply.Start(RP_UPDATE_DISPLAY_MODE);
				reply.Add(bounds.IntegerWidth() + 1);
				reply.Add(bounds.IntegerHeight() + 1);
				if (reply.Flush() == B_OK)
					fIsConnected = true;

				continue;
			}

			case RP_CLOSE_CONNECTION:
			{
				be_app->PostMessage(B_QUIT_REQUESTED);
				continue;
			}

			case RP_CREATE_STATE:
			case RP_DELETE_STATE:
			{
				uint32 token;
				message.Read(token);

				if (code == RP_CREATE_STATE)
					_CreateState(token);
				else
					_DeleteState(token);

				continue;
			}

			case RP_SET_CURSOR:
			{
				BBitmap *bitmap;
				BPoint oldHotSpot = cursorHotSpot;
				message.Read(cursorHotSpot);
				if (message.ReadBitmap(&bitmap) != B_OK)
					continue;

				delete fCursorBitmap;
				fCursorBitmap = bitmap;

				Invalidate(fCursorFrame);

				BRect bounds = fCursorBitmap->Bounds();
				fCursorFrame.right = fCursorFrame.left
					+ bounds.IntegerWidth() + 1;
				fCursorFrame.bottom = fCursorFrame.bottom
					+ bounds.IntegerHeight() + 1;

				fCursorFrame.OffsetBy(oldHotSpot - cursorHotSpot);

				Invalidate(fCursorFrame);
				continue;
			}

			case RP_SET_CURSOR_VISIBLE:
			{
				bool wasVisible = fCursorVisible;
				message.Read(fCursorVisible);
				if (wasVisible != fCursorVisible)
					Invalidate(fCursorFrame);
				continue;
			}

			case RP_MOVE_CURSOR_TO:
			{
				BPoint position;
				message.Read(position);

				if (fCursorVisible)
					Invalidate(fCursorFrame);

				fCursorFrame.OffsetTo(position - cursorHotSpot);

				Invalidate(fCursorFrame);
				continue;
			}

			case RP_INVALIDATE_RECT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				Invalidate(rect);
				continue;
			}

			case RP_INVALIDATE_REGION:
			{
				BRegion region;
				if (message.ReadRegion(region) != B_OK)
					continue;

				Invalidate(&region);
				continue;
			}

			case RP_FILL_REGION_COLOR_NO_CLIPPING:
			{
				BRegion region;
				rgb_color color;

				message.ReadRegion(region);
				if (message.Read(color) != B_OK)
					continue;

				fOffscreen->LockLooper();
				fOffscreen->SetHighColor(color);
				fOffscreen->FillRegion(&region);
				fOffscreen->UnlockLooper();
				Invalidate(&region);
				continue;
			}

			case RP_COPY_RECT_NO_CLIPPING:
			{
				int32 xOffset, yOffset;
				BRect rect;

				message.Read(xOffset);
				message.Read(yOffset);
				if (message.Read(rect) != B_OK)
					continue;

				BRect dest = rect.OffsetByCopy(xOffset, yOffset);
				fOffscreen->LockLooper();
				fOffscreen->CopyBits(rect, dest);
				fOffscreen->UnlockLooper();
				continue;
			}
		}

		uint32 token;
		message.Read(token);

		engine_state *state = _FindState(token);
		if (state == NULL) {
			TRACE_ERROR("didn't find state for token %lu\n", token);
			continue;
		}

		BView *offscreen = state->view;
		::pattern &pattern = state->pattern;
		BRegion &clippingRegion = state->clipping_region;
		float &penSize = state->pen_size;
		bool &syncDrawing = state->sync_drawing;
		BRegion invalidRegion;

		BAutolock offscreenLocker(offscreen->Looper());
		if (!offscreenLocker.IsLocked())
			break;

		switch (code) {
			case RP_ENABLE_SYNC_DRAWING:
				syncDrawing = true;
				continue;

			case RP_DISABLE_SYNC_DRAWING:
				syncDrawing = false;
				continue;

			case RP_SET_OFFSETS:
			{
				int32 xOffset, yOffset;
				message.Read(xOffset);
				if (message.Read(yOffset) != B_OK)
					continue;

				offscreen->MovePenTo(xOffset, yOffset);
				break;
			}

			case RP_SET_HIGH_COLOR:
			case RP_SET_LOW_COLOR:
			{
				rgb_color color;
				if (message.Read(color) != B_OK)
					continue;

				if (code == RP_SET_HIGH_COLOR)
					offscreen->SetHighColor(color);
				else
					offscreen->SetLowColor(color);

				break;
			}

			case RP_SET_PEN_SIZE:
			{
				float newPenSize;
				if (message.Read(newPenSize) != B_OK)
					continue;

				offscreen->SetPenSize(newPenSize);
				penSize = newPenSize / 2;
				break;
			}

			case RP_SET_STROKE_MODE:
			{
				cap_mode capMode;
				join_mode joinMode;
				float miterLimit;

				message.Read(capMode);
				message.Read(joinMode);
				if (message.Read(miterLimit) != B_OK)
					continue;

				offscreen->SetLineMode(capMode, joinMode, miterLimit);
				break;
			}

			case RP_SET_BLENDING_MODE:
			{
				source_alpha sourceAlpha;
				alpha_function alphaFunction;

				message.Read(sourceAlpha);
				if (message.Read(alphaFunction) != B_OK)
					continue;

				offscreen->SetBlendingMode(sourceAlpha, alphaFunction);
				break;
			}

			case RP_SET_PATTERN:
			{
				if (message.Read(pattern) != B_OK)
					continue;
				break;
			}

			case RP_SET_DRAWING_MODE:
			{
				drawing_mode drawingMode;
				if (message.Read(drawingMode) != B_OK)
					continue;

				offscreen->SetDrawingMode(drawingMode);
				break;
			}

			case RP_SET_FONT:
			{
				BFont font;
				if (message.ReadFontState(font) != B_OK)
					continue;

				offscreen->SetFont(&font);
				break;
			}

			case RP_CONSTRAIN_CLIPPING_REGION:
			{
				if (message.ReadRegion(clippingRegion) != B_OK)
					continue;

				offscreen->ConstrainClippingRegion(&clippingRegion);
				break;
			}

			case RP_INVERT_RECT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				offscreen->InvertRect(rect);
				invalidRegion.Include(rect);
				break;
			}

			case RP_DRAW_BITMAP:
			{
				BBitmap *bitmap;
				BRect bitmapRect, viewRect;
				uint32 options;

				message.Read(bitmapRect);
				message.Read(viewRect);
				message.Read(options);
				if (message.ReadBitmap(&bitmap) != B_OK || bitmap == NULL)
					continue;

				offscreen->DrawBitmap(bitmap, bitmapRect, viewRect, options);
				invalidRegion.Include(viewRect);
				delete bitmap;
				break;
			}

			case RP_DRAW_BITMAP_RECTS:
			{
				color_space colorSpace;
				int32 rectCount;
				uint32 flags, options;

				message.Read(options);
				message.Read(colorSpace);
				message.Read(flags);
				message.Read(rectCount);
				for (int32 i = 0; i < rectCount; i++) {
					BBitmap *bitmap;
					BRect viewRect;

					message.Read(viewRect);
					if (message.ReadBitmap(&bitmap, true, colorSpace,
							flags) != B_OK || bitmap == NULL) {
						continue;
					}

					offscreen->DrawBitmap(bitmap, bitmap->Bounds(), viewRect,
						options);
					invalidRegion.Include(viewRect);
					delete bitmap;
				}

				break;
			}

			case RP_STROKE_ARC:
			case RP_FILL_ARC:
			case RP_FILL_ARC_GRADIENT:
			{
				BRect rect;
				float angle, span;

				message.Read(rect);
				message.Read(angle);
				if (message.Read(span) != B_OK)
					continue;

				if (code == RP_STROKE_ARC) {
					offscreen->StrokeArc(rect, angle, span, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ARC)
					offscreen->FillArc(rect, angle, span, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillArc(rect, angle, span, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_BEZIER:
			case RP_FILL_BEZIER:
			case RP_FILL_BEZIER_GRADIENT:
			{
				BPoint points[4];
				if (message.ReadList(points, 4) != B_OK)
					continue;

				BRect bounds = _BuildInvalidateRect(points, 4);
				if (code == RP_STROKE_BEZIER) {
					offscreen->StrokeBezier(points, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_BEZIER)
					offscreen->FillBezier(points, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillBezier(points, *gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_ELLIPSE:
			case RP_FILL_ELLIPSE:
			case RP_FILL_ELLIPSE_GRADIENT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				if (code == RP_STROKE_ELLIPSE) {
					offscreen->StrokeEllipse(rect, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ELLIPSE)
					offscreen->FillEllipse(rect, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillEllipse(rect, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_POLYGON:
			case RP_FILL_POLYGON:
			case RP_FILL_POLYGON_GRADIENT:
			{
				BRect bounds;
				bool closed;
				int32 numPoints;

				message.Read(bounds);
				message.Read(closed);
				if (message.Read(numPoints) != B_OK)
					continue;

				BPoint points[numPoints];
				for (int32 i = 0; i < numPoints; i++)
					message.Read(points[i]);

				if (code == RP_STROKE_POLYGON) {
					offscreen->StrokePolygon(points, numPoints, bounds, closed,
						pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_POLYGON)
					offscreen->FillPolygon(points, numPoints, bounds, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillPolygon(points, numPoints, bounds,
						*gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_RECT:
			case RP_FILL_RECT:
			case RP_FILL_RECT_GRADIENT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				if (code == RP_STROKE_RECT) {
					offscreen->StrokeRect(rect, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_RECT)
					offscreen->FillRect(rect, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRect(rect, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_ROUND_RECT:
			case RP_FILL_ROUND_RECT:
			case RP_FILL_ROUND_RECT_GRADIENT:
			{
				BRect rect;
				float xRadius, yRadius;

				message.Read(rect);
				message.Read(xRadius);
				if (message.Read(yRadius) != B_OK)
					continue;

				if (code == RP_STROKE_ROUND_RECT) {
					offscreen->StrokeRoundRect(rect, xRadius, yRadius,
						pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ROUND_RECT)
					offscreen->FillRoundRect(rect, xRadius, yRadius, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRoundRect(rect, xRadius, yRadius,
						*gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_SHAPE:
			case RP_FILL_SHAPE:
			case RP_FILL_SHAPE_GRADIENT:
			{
				BRect bounds;
				int32 opCount, pointCount;

				message.Read(bounds);
				if (message.Read(opCount) != B_OK)
					continue;

				BMessage archive;
				for (int32 i = 0; i < opCount; i++) {
					int32 op;
					message.Read(op);
					archive.AddInt32("ops", op);
				}

				if (message.Read(pointCount) != B_OK)
					continue;

				for (int32 i = 0; i < pointCount; i++) {
					BPoint point;
					message.Read(point);
					archive.AddPoint("pts", point);
				}

				BPoint offset;
				message.Read(offset);

				float scale;
				if (message.Read(scale) != B_OK)
					continue;

				offscreen->PushState();
				offscreen->MovePenTo(offset);
				offscreen->SetScale(scale);

				BShape shape(&archive);
				if (code == RP_STROKE_SHAPE) {
					offscreen->StrokeShape(&shape, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_SHAPE)
					offscreen->FillShape(&shape, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK) {
						offscreen->PopState();
						continue;
					}

					offscreen->FillShape(&shape, *gradient);
					delete gradient;
				}

				offscreen->PopState();
				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_TRIANGLE:
			case RP_FILL_TRIANGLE:
			case RP_FILL_TRIANGLE_GRADIENT:
			{
				BRect bounds;
				BPoint points[3];

				message.ReadList(points, 3);
				if (message.Read(bounds) != B_OK)
					continue;

				if (code == RP_STROKE_TRIANGLE) {
					offscreen->StrokeTriangle(points[0], points[1], points[2],
						bounds, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_TRIANGLE) {
					offscreen->FillTriangle(points[0], points[1], points[2],
						bounds, pattern);
				} else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillTriangle(points[0], points[1], points[2],
						bounds, *gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_LINE:
			{
				BPoint points[2];
				if (message.ReadList(points, 2) != B_OK)
					continue;

				offscreen->StrokeLine(points[0], points[1], pattern);

				BRect bounds = _BuildInvalidateRect(points, 2);
				invalidRegion.Include(bounds.InsetBySelf(-penSize, -penSize));
				break;
			}

			case RP_STROKE_LINE_ARRAY:
			{
				int32 numLines;
				if (message.Read(numLines) != B_OK)
					continue;

				BRect bounds;
				offscreen->BeginLineArray(numLines);
				for (int32 i = 0; i < numLines; i++) {
					rgb_color color;
					BPoint start, end;
					message.ReadArrayLine(start, end, color);
					offscreen->AddLine(start, end, color);

					bounds.left = min_c(bounds.left, min_c(start.x, end.x));
					bounds.top = min_c(bounds.top, min_c(start.y, end.y));
					bounds.right = max_c(bounds.right, max_c(start.x, end.x));
					bounds.bottom = max_c(bounds.bottom, max_c(start.y, end.y));
				}

				offscreen->EndLineArray();
				invalidRegion.Include(bounds);
				break;
			}

			case RP_FILL_REGION:
			case RP_FILL_REGION_GRADIENT:
			{
				BRegion region;
				if (message.ReadRegion(region) != B_OK)
					continue;

				if (code == RP_FILL_REGION)
					offscreen->FillRegion(&region, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRegion(&region, *gradient);
					delete gradient;
				}

				invalidRegion.Include(&region);
				break;
			}

			case RP_STROKE_POINT_COLOR:
			{
				BPoint point;
				rgb_color color;

				message.Read(point);
				if (message.Read(color) != B_OK)
					continue;

				rgb_color oldColor = offscreen->HighColor();
				offscreen->SetHighColor(color);
				offscreen->StrokeLine(point, point);
				offscreen->SetHighColor(oldColor);

				invalidRegion.Include(
					BRect(point, point).InsetBySelf(-penSize, -penSize));
				break;
			}

			case RP_STROKE_LINE_1PX_COLOR:
			{
				BPoint points[2];
				rgb_color color;

				message.ReadList(points, 2);
				if (message.Read(color) != B_OK)
					continue;

				float oldSize = offscreen->PenSize();
				rgb_color oldColor = offscreen->HighColor();
				drawing_mode oldMode = offscreen->DrawingMode();
				offscreen->SetPenSize(1);
				offscreen->SetHighColor(color);
				offscreen->SetDrawingMode(B_OP_OVER);

				offscreen->StrokeLine(points[0], points[1]);

				offscreen->SetDrawingMode(oldMode);
				offscreen->SetHighColor(oldColor);
				offscreen->SetPenSize(oldSize);

				invalidRegion.Include(_BuildInvalidateRect(points, 2));
				break;
			}

			case RP_STROKE_RECT_1PX_COLOR:
			case RP_FILL_RECT_COLOR:
			{
				BRect rect;
				rgb_color color;

				message.Read(rect);
				if (message.Read(color) != B_OK)
					continue;

				rgb_color oldColor = offscreen->HighColor();
				offscreen->SetHighColor(color);

				if (code == RP_STROKE_RECT_1PX_COLOR) {
					float oldSize = PenSize();
					offscreen->SetPenSize(1);
					offscreen->StrokeRect(rect);
					offscreen->SetPenSize(oldSize);
				} else
					offscreen->FillRect(rect);

				offscreen->SetHighColor(oldColor);
				invalidRegion.Include(rect);
				break;
			}

			case RP_DRAW_STRING:
			{
				BPoint point;
				size_t length;
				char *string;
				bool hasDelta;

				message.Read(point);
				message.ReadString(&string, length);
				if (message.Read(hasDelta) != B_OK) {
					free(string);
					continue;
				}

				if (hasDelta) {
					escapement_delta delta[length];
					message.ReadList(delta, length);
					offscreen->DrawString(string, point, delta);
				} else
					offscreen->DrawString(string, point);

				free(string);
				reply.Start(RP_DRAW_STRING_RESULT);
				reply.Add(token);
				reply.Add(offscreen->PenLocation());
				reply.Flush();

				font_height height;
				offscreen->GetFontHeight(&height);

				BRect bounds(point, offscreen->PenLocation());
				bounds.top -= height.ascent;
				bounds.bottom += height.descent;
				invalidRegion.Include(bounds);
				break;
			}

			case RP_DRAW_STRING_WITH_OFFSETS:
			{
				size_t length;
				char *string;
				message.ReadString(&string, length);
				int32 count = UTF8CountChars(string, length);

				BPoint offsets[count];
				if (message.ReadList(offsets, count) != B_OK) {
					free(string);
					continue;
				}

				offscreen->DrawString(string, offsets, count);

				free(string);
				reply.Start(RP_DRAW_STRING_RESULT);
				reply.Add(token);
				reply.Add(offscreen->PenLocation());
				reply.Flush();

				BFont font;
				offscreen->GetFont(&font);

				BRect boxes[count];
				font.GetBoundingBoxesAsGlyphs(string, count, B_SCREEN_METRIC,
					boxes);

				font_height height;
				offscreen->GetFontHeight(&height);

				for (int32 i = 0; i < count; i++) {
					// TODO: validate
					boxes[i].OffsetBy(offsets[i] + BPoint(0, -height.ascent));
					invalidRegion.Include(boxes[i]);
				}

				break;
			}

			case RP_READ_BITMAP:
			{
				BRect bounds;
				bool drawCursor;

				message.Read(bounds);
				if (message.Read(drawCursor) != B_OK)
					continue;

				// TODO: support the drawCursor flag
				BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_RGB32);
				bitmap.ImportBits(fOffscreenBitmap, bounds.LeftTop(),
					BPoint(0, 0), bounds.IntegerWidth() + 1,
					bounds.IntegerHeight() + 1);

				reply.Start(RP_READ_BITMAP_RESULT);
				reply.Add(token);
				reply.AddBitmap(&bitmap);
				reply.Flush();
				break;
			}

			default:
				TRACE_ERROR("unknown protocol code: %u\n", code);
				break;
		}

		if (syncDrawing) {
			offscreen->Sync();
			Invalidate(&invalidRegion);
		}
	}
}
Ejemplo n.º 8
0
void MonthWindowView::DrawMonth()
{
 Bmp->Lock();
 
 float y=yearStringView->Frame().bottom+h_cell;
 float x=0;
 
 if(NewMonth)
 {
  BmpView->SetHighColor(VIEW_COLOR);
  BmpView->FillRect(BRect(0,y+1,
                    BmpView->Bounds().right,todayStringView->Frame().top-6));
  BmpView->SetHighColor(0,0,0,0);
  NewMonth=false;
 }
 
 int byear=cyear; // base year
 if(tyear<byear) byear=tyear;
  
 int day1=0, m=0, k=byear;
 
 while(k<cyear)
 {
  day1++;

  if(k%4==0) // leap year?
   if((k%100!=0) || (k%400==0)) day1++; // yes
  
  k++;
 }
 while(++m<cmonth)
 {
  day1+=(monthDays[m-1]-28);
  if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++;
 }
 day1++; // day1 is number of 1st day of chosen month in chosen year
 day1=day1%7;
 
 int day2=0;
 m=0;
 k=byear;
 while(k<tyear)
 {
  day2++;
  if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++;
  k++;
 }
 while(++m<tmonth)
 {
  day2+=(monthDays[m-1]-28);
  if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++;
 }
 day2+=tday; // day2 - number of today's day in today's year
 day2=day2%7;
 
 k=(twday==0) ? 6 : twday-1;
 
 k=k-day2+day1;
 while(k<0) k+=7;
 k=k%7;
 cwday1=k;
 
 x=w_cell*k+1;
 y+=h_cell;
 
 int qu_days=monthDays[cmonth-1]; // quantity of days in month
 
 if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
 
 BString s;
 int t=0;
 while(t<qu_days)
 {
  t++;
  
  s<<t;
  
  if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(200,0,0,0);
  BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y));
  if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0);
  
  if(t==cday)
  {
   cwday=k;
   if(which_focused==2) BmpView->SetHighColor(ACTIVE_COLOR);
   else BmpView->SetHighColor(NOACTIVE_COLOR);
   cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4);
   BmpView->StrokeRect(cursor);
   BmpView->SetHighColor(0,0,0,0);
  }
  
  x+=w_cell;
  k++;
  s.SetTo("");
  
  if(k==7)
  {
   k=0;
   y+=h_cell;
   x=1;
  }
 }
 
 BmpView->Sync();
 Bmp->Unlock();
 Draw(Bounds());
}
Ejemplo n.º 9
0
void MonthWindowView::AttachedToWindow(void)
{
 SetFont(be_plain_font);
 
 SetViewColor(VIEW_COLOR);
 
 // Calculate size of cell needed for number of day of month
 font_height h;
 be_plain_font->GetHeight(&h);
 h_cell=(int)(h.ascent+h.descent+h.leading+6);
 w_cell=StringWidth("4")*4;
 
 

#ifdef __LANG_RUSSIAN
 
 BString s("");
 s<<tday;
 s.Append(" ");
 switch(tmonth)
 {
  case 1:
  {
   s.Append("января ");
   break;
  }
  case 2:
  {
   s.Append("февраля ");
   break;
  }
  case 3:
  {
   s.Append("марта ");
   break;
  }
  case 4:
  {
   s.Append("апреля ");
   break;
  }
  case 5:
  {
   s.Append("мая ");
   break;
  }
  case 6:
  {
   s.Append("июня ");
   break;
  }
  case 7:
  {
   s.Append("июля ");
   break;
  }
  case 8:
  {
   s.Append("августа ");
   break;
  }
  case 9:
  {
   s.Append("сентября ");
   break;
  }
  case 10:
  {
   s.Append("октября ");
   break;
  }
  case 11:
  {
   s.Append("ноября ");
   break;
  }
  case 12:
  {
   s.Append("декабря ");
   break;
  }
 }
 s<<tyear;
 s.Append(" г.");

#else // localized, english and french
 
 BString s("");
 s<<tday;
 s.Append(" ");
 s.Append(monthNames[tmonth-1]);
 s.Append(" ");
 s<<tyear;

#endif
 
 msng=new BMessenger(this);
 todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng,
                                          BRect(10,10,100,100),"todayMStringViewAViX",
                                          s.String());
 AddChild(todayStringView);
 todayStringView->ResizeToPreferred();
 todayStringView->SetViewColor(VIEW_COLOR);
 
 monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
                                 monthNames[8]);
 monthStringView->SetAlignment(B_ALIGN_CENTER);
 AddChild(monthStringView);
 monthStringView->ResizeToPreferred();
 monthStringView->SetText(monthNames[cmonth-1]);
 monthStringView->SetViewColor(VIEW_COLOR);
 
 s.SetTo("");
 if(cyear<10) s.Append("000");
 else if(cyear<100) s.Append("00");
 else if(cyear<1000) s.Append("0");
 s<<cyear;
 
 yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
                                "0000");
 AddChild(yearStringView);
 yearStringView->ResizeToPreferred();
 yearStringView->SetText(s.String());
 yearStringView->SetViewColor(VIEW_COLOR);
 
 ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
 Window()->ResizeTo(Bounds().right, Bounds().bottom);
 
 yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
                                             BRect(10,10,100,100),
                                             "yearMStringViewAViX0",
                                             "<<");
 AddChild(yearMStringView[0]);
 yearMStringView[0]->ResizeToPreferred();
 yearMStringView[0]->SetViewColor(VIEW_COLOR);
 
 yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
                                             BRect(10,10,100,100),
                                             "yearMStringViewAViX1",
                                             ">>");
 AddChild(yearMStringView[1]);
 yearMStringView[1]->ResizeToPreferred();
 yearMStringView[1]->SetViewColor(VIEW_COLOR);
 
 monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng,
                                              BRect(10,10,100,100),
                                              "monthMStringViewAViX0",
                                              "<<");
 AddChild(monthMStringView[0]);
 monthMStringView[0]->ResizeToPreferred();
 monthMStringView[0]->SetViewColor(VIEW_COLOR);
 
 monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng,
                                              BRect(10,10,100,100),
                                              "monthMStringViewAViX1",
                                              ">>");
 AddChild(monthMStringView[1]);
 monthMStringView[1]->ResizeToPreferred();
 monthMStringView[1]->SetViewColor(VIEW_COLOR);
 
 todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2,
                         Bounds().bottom-todayStringView->Bounds().bottom-2);
 if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(NOACTIVE_COLOR);
  
 yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5);
 yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5);
 yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5);
 
 
 monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5);
 monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5);
 monthMStringView[1]->MoveTo(monthStringView->Frame().right,5);
 
 which_focused=2; // days of month
 
 
 Bmp=new BBitmap(BRect(Frame()),B_RGB32,true);
 BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW);
 Bmp->AddChild(BmpView);
 
 Bmp->Lock();
 BmpView->SetHighColor(VIEW_COLOR);
 BmpView->FillRect(BmpView->Frame());
 
 BmpView->SetHighColor(LINE_COLOR);
 BmpView->StrokeLine(BPoint(3,todayStringView->Frame().top-5),
                     BPoint(Bounds().right-3,todayStringView->Frame().top-5));
 BmpView->StrokeLine(BPoint(3,yearStringView->Frame().bottom+2),
                     BPoint(Bounds().right-3,yearStringView->Frame().bottom+2));
 BmpView->SetHighColor(0,0,0,0);
 
 float y=yearStringView->Frame().bottom+h_cell;
 float x=0;
 for(int i=0;i<7;i++)
 {
  BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y));
  x+=w_cell;
 }
 
 BmpView->Sync();
 Bmp->Unlock();
 DrawMonth();
}
Ejemplo n.º 10
0
void
BSlider::DrawText()
{
	BRect bounds(Bounds());
	BView *view = OffscreenView();

	rgb_color base = LowColor();
	uint32 flags = 0;
	if (be_control_look == NULL) {
		if (IsEnabled()) {
			view->SetHighColor(0, 0, 0);
		} else {
			view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT));
		}
	} else
 		flags = be_control_look->Flags(this);

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	if (Orientation() == B_HORIZONTAL) {
		if (Label()) {
			if (be_control_look == NULL) {
				view->DrawString(Label(),
					BPoint(0.0, ceilf(fontHeight.ascent)));
			} else {
				be_control_look->DrawLabel(view, Label(), base, flags,
					BPoint(0.0, ceilf(fontHeight.ascent)));
			}
		}

		// the update text is updated in SetValue() only
		if (fUpdateText != NULL) {
			if (be_control_look == NULL) {
				view->DrawString(fUpdateText, BPoint(bounds.right
					- StringWidth(fUpdateText), ceilf(fontHeight.ascent)));
			} else {
				be_control_look->DrawLabel(view, fUpdateText, base, flags,
					BPoint(bounds.right - StringWidth(fUpdateText),
						ceilf(fontHeight.ascent)));
			}
		}

		if (fMinLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMinLimitLabel, BPoint(0.0, bounds.bottom
					- fontHeight.descent));
			} else {
				be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
					BPoint(0.0, bounds.bottom - fontHeight.descent));
			}
		}

		if (fMaxLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMaxLimitLabel, BPoint(bounds.right
					- StringWidth(fMaxLimitLabel), bounds.bottom
					- fontHeight.descent));
			} else {
				be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
					BPoint(bounds.right - StringWidth(fMaxLimitLabel),
						bounds.bottom - fontHeight.descent));
			}
		}
	} else {
		float lineHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)
			+ ceilf(fontHeight.leading);
		float baseLine = ceilf(fontHeight.ascent);

		if (Label()) {
			if (be_control_look == NULL) {
				view->DrawString(Label(), BPoint((bounds.Width()
					- StringWidth(Label())) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, Label(), base, flags,
					BPoint((bounds.Width() - StringWidth(Label())) / 2.0,
						baseLine));
			}
			baseLine += lineHeight;
		}

		if (fMaxLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMaxLimitLabel, BPoint((bounds.Width()
					- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
					BPoint((bounds.Width()
						- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
			}
		}

		baseLine = bounds.bottom - ceilf(fontHeight.descent);

		if (fMinLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMinLimitLabel, BPoint((bounds.Width()
					- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
					BPoint((bounds.Width()
						- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
			}
			baseLine -= lineHeight;
		}

		if (fUpdateText != NULL) {
			if (be_control_look == NULL) {
				view->DrawString(fUpdateText, BPoint((bounds.Width()
					- StringWidth(fUpdateText)) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, fUpdateText, base, flags,
					BPoint((bounds.Width()
						- StringWidth(fUpdateText)) / 2.0, baseLine));
			}
		}
	}
}
Ejemplo n.º 11
0
void CalcoloKtView::Draw(BRect)
{
	
	BView *iconView;
    iconView = (BView *)FindView("iconView");
         	
	iconView->SetHighColor(0, 0, 0);	
	
	BPoint	p1, p2;
	
	// Dimensioni della BView iconView 130 x 60 pixels
	
	float x_origin;
	float y_origin;
	float l_tot;
	float h_tot;
	
	// .:: Dimensioni principali dell'icona ::.
	
	x_origin = 25;
	y_origin = 5;
	l_tot = 90;
	h_tot = 52;
	
	// .:: Sezione Sx ::.
	
	p1.x = x_origin;
	p1.y = y_origin;
	p2.x = x_origin + l_tot * 5 / 9;
	p2.y = y_origin;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);

	p1.x = x_origin;
	p1.y = y_origin + h_tot;
	p2.x = x_origin + l_tot * 5 / 9;
	p2.y = y_origin + h_tot;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);

	p1.x = x_origin + l_tot * 5 / 9;
	p1.y = y_origin;
	p2.x = x_origin + l_tot * 5 / 9;
	p2.y = y_origin + h_tot;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	// .:: Quota Sx ::.
	
	p1.x = x_origin + (l_tot * 5 / 9)/2;
	p1.y = y_origin;
	p2.x = x_origin + (l_tot * 5 / 9)/2;
	p2.y = y_origin + h_tot;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	// .:: Freccie quota Sx ::.
	
	float largfreccie;
	BPoint p3;
	
	largfreccie = h_tot * 3 / 52;
	
	p1.x = x_origin + (l_tot * 5 / 9)/2;
	p1.y = y_origin;
	p2.x = p1.x - largfreccie / 2;
	p2.y = p1.y + largfreccie * 2;
	p3.x = p1.x + largfreccie / 2;
	p3.y = p1.y + largfreccie * 2;
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	p1.x = x_origin + (l_tot * 5 / 9)/2;
	p1.y = y_origin + h_tot;
	p2.x = p1.x - largfreccie / 2;
	p2.y = p1.y - largfreccie * 2;
	p3.x = p1.x + largfreccie / 2;
	p3.y = p1.y - largfreccie * 2;
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	// .:: Testo quota Sx ::.
	
	BPoint dimtext;
	BFont font(be_plain_font); 
	
	float fontsize;
	
	fontsize = h_tot * 7 / 52;
	
	font.SetSize(fontsize);
	iconView->SetFont(&font);

	dimtext.x = x_origin + (l_tot * 5 / 9)/2 + l_tot * 5 / 90;
	dimtext.y = y_origin + h_tot / 2 + fontsize / 2;
	
	iconView->MovePenTo(dimtext);
   	iconView->DrawString("D");
	
	// .:: Sezione Dx ::.
	
	float arcradius;
	
	arcradius = l_tot * 7 / 90;
	
	p1.x = x_origin + l_tot * 5 / 9 + arcradius;
	p1.y = y_origin + h_tot / 4;
	p2.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45;
	p2.y = y_origin + h_tot / 4;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	p1.x = x_origin + l_tot * 5 / 9 + arcradius;
	p1.y = y_origin + h_tot *3 / 4;
	p2.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45;
	p2.y = y_origin + h_tot *3 / 4;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	// .:: Quota Dx ::.
	
	p1.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 7 / 45;
	p1.y = y_origin + h_tot / 4;
	p2.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 7 / 45;
	p2.y = y_origin + h_tot *3 / 4;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	// .:: Freccie quota Sx ::.
	
	largfreccie = h_tot * 3 / 52;
	
	p1.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 7 / 45;
	p1.y = y_origin + h_tot / 4;
	p2.x = p1.x - largfreccie / 2;
	p2.y = p1.y + largfreccie * 2;
	p3.x = p1.x + largfreccie / 2;
	p3.y = p1.y + largfreccie * 2;
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	p1.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 7 / 45;
	p1.y = y_origin + h_tot *3 / 4;
	p2.x = p1.x - largfreccie / 2;
	p2.y = p1.y - largfreccie * 2;
	p3.x = p1.x + largfreccie / 2;
	p3.y = p1.y - largfreccie * 2;
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	// .:: Testo quota Dx ::.
	
	dimtext.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 7 / 45 + l_tot * 5 / 90;
	dimtext.y = y_origin + h_tot / 2 + fontsize / 2;
	
	iconView->MovePenTo(dimtext);
   	iconView->DrawString("d");
   	
   	
   	// .:: Simbolo di continuazione a Sx ::.
   	
   	float xbezorig;
   	float ybezorig;
   	float xunit;
   	float yunit;
   	BPoint controlpoints[4];

   	xbezorig = x_origin;
	ybezorig = y_origin;
	   	
   	xunit = l_tot * 2 / 45;
   	yunit = h_tot / 20;
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig;
   	controlpoints[1].x = xbezorig + 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 1 * yunit; 	
   	controlpoints[2].x = xbezorig + 1.2 * xunit;
   	controlpoints[2].y = ybezorig + 2 * yunit;
   	controlpoints[3].x = xbezorig + 1.5 * xunit;
   	controlpoints[3].y = ybezorig + 3 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1.5 * xunit;
   	controlpoints[0].y = ybezorig + 3 * yunit;
   	controlpoints[1].x = xbezorig + 1.7 * xunit;
   	controlpoints[1].y = ybezorig + 4 * yunit;
   	controlpoints[2].x = xbezorig + 1.5 * xunit;
   	controlpoints[2].y = ybezorig + 5 * yunit;
   	controlpoints[3].x = xbezorig + 1.1 * xunit;
   	controlpoints[3].y = ybezorig + 6 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1.1 * xunit;
   	controlpoints[0].y = ybezorig + 6 * yunit;
   	controlpoints[1].x = xbezorig + 1 * xunit;
   	controlpoints[1].y = ybezorig + 7 * yunit;
   	controlpoints[2].x = xbezorig + 0.8 * xunit;
   	controlpoints[2].y = ybezorig + 8 * yunit;
   	controlpoints[3].x = xbezorig + 0.3 * xunit;
   	controlpoints[3].y = ybezorig + 9 * yunit;
   	   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1 * xunit;
   	controlpoints[0].y = ybezorig + 7 * yunit;
   	controlpoints[1].x = xbezorig + 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 8 * yunit;
   	controlpoints[2].x = xbezorig + 0.3 * xunit;
   	controlpoints[2].y = ybezorig + 9 * yunit;
   	controlpoints[3].x = xbezorig;
   	controlpoints[3].y = ybezorig + 10 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig + 10 * yunit;
   	controlpoints[1].x = xbezorig - 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 11 * yunit; 	
   	controlpoints[2].x = xbezorig - 1.2 * xunit;
   	controlpoints[2].y = ybezorig + 12 * yunit;
   	controlpoints[3].x = xbezorig - 1.5 * xunit;
   	controlpoints[3].y = ybezorig + 13 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1.5 * xunit;
   	controlpoints[0].y = ybezorig + 13 * yunit;
   	controlpoints[1].x = xbezorig - 1.7 * xunit;
   	controlpoints[1].y = ybezorig + 14 * yunit;
   	controlpoints[2].x = xbezorig - 1.5 * xunit;
   	controlpoints[2].y = ybezorig + 15 * yunit;
   	controlpoints[3].x = xbezorig - 1.1 * xunit;
   	controlpoints[3].y = ybezorig + 16 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1.1 * xunit;
   	controlpoints[0].y = ybezorig + 16 * yunit;
   	controlpoints[1].x = xbezorig - 1 * xunit;
   	controlpoints[1].y = ybezorig + 17 * yunit;
   	controlpoints[2].x = xbezorig - 0.8 * xunit;
   	controlpoints[2].y = ybezorig + 18 * yunit;
   	controlpoints[3].x = xbezorig - 0.3 * xunit;
   	controlpoints[3].y = ybezorig + 19 * yunit;
   	   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1 * xunit;
   	controlpoints[0].y = ybezorig + 17 * yunit;
   	controlpoints[1].x = xbezorig - 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 18 * yunit;
   	controlpoints[2].x = xbezorig - 0.3 * xunit;
   	controlpoints[2].y = ybezorig + 19 * yunit;
   	controlpoints[3].x = xbezorig;
   	controlpoints[3].y = ybezorig + 20 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig;
   	controlpoints[1].x = xbezorig - 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 1 * yunit; 	
   	controlpoints[2].x = xbezorig - 1.2 * xunit;
   	controlpoints[2].y = ybezorig + 2 * yunit;
   	controlpoints[3].x = xbezorig - 1.5 * xunit;
   	controlpoints[3].y = ybezorig + 3 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1.5 * xunit;
   	controlpoints[0].y = ybezorig + 3 * yunit;
   	controlpoints[1].x = xbezorig - 1.7 * xunit;
   	controlpoints[1].y = ybezorig + 4 * yunit;
   	controlpoints[2].x = xbezorig - 1.5 * xunit;
   	controlpoints[2].y = ybezorig + 5 * yunit;
   	controlpoints[3].x = xbezorig - 1.1 * xunit;
   	controlpoints[3].y = ybezorig + 6 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1.1 * xunit;
   	controlpoints[0].y = ybezorig + 6 * yunit;
   	controlpoints[1].x = xbezorig - 1 * xunit;
   	controlpoints[1].y = ybezorig + 7 * yunit;
   	controlpoints[2].x = xbezorig - 0.8 * xunit;
   	controlpoints[2].y = ybezorig + 8 * yunit;
   	controlpoints[3].x = xbezorig - 0.3 * xunit;
   	controlpoints[3].y = ybezorig + 9 * yunit;
   	   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1 * xunit;
   	controlpoints[0].y = ybezorig + 7 * yunit;
   	controlpoints[1].x = xbezorig - 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 8 * yunit;
   	controlpoints[2].x = xbezorig - 0.3 * xunit;
   	controlpoints[2].y = ybezorig + 9 * yunit;
   	controlpoints[3].x = xbezorig;
   	controlpoints[3].y = ybezorig + 10 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	
   	// .:: Simbolo di continuazione a Dx ::.

   	xbezorig = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45;
	ybezorig = y_origin + h_tot / 4;
	   	
   	xunit = l_tot * 2 / 90;
   	yunit = h_tot / 40;
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig;
   	controlpoints[1].x = xbezorig + 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 1 * yunit; 	
   	controlpoints[2].x = xbezorig + 1.2 * xunit;
   	controlpoints[2].y = ybezorig + 2 * yunit;
   	controlpoints[3].x = xbezorig + 1.5 * xunit;
   	controlpoints[3].y = ybezorig + 3 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1.5 * xunit;
   	controlpoints[0].y = ybezorig + 3 * yunit;
   	controlpoints[1].x = xbezorig + 1.7 * xunit;
   	controlpoints[1].y = ybezorig + 4 * yunit;
   	controlpoints[2].x = xbezorig + 1.5 * xunit;
   	controlpoints[2].y = ybezorig + 5 * yunit;
   	controlpoints[3].x = xbezorig + 1.1 * xunit;
   	controlpoints[3].y = ybezorig + 6 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1.1 * xunit;
   	controlpoints[0].y = ybezorig + 6 * yunit;
   	controlpoints[1].x = xbezorig + 1 * xunit;
   	controlpoints[1].y = ybezorig + 7 * yunit;
   	controlpoints[2].x = xbezorig + 0.8 * xunit;
   	controlpoints[2].y = ybezorig + 8 * yunit;
   	controlpoints[3].x = xbezorig + 0.3 * xunit;
   	controlpoints[3].y = ybezorig + 9 * yunit;
   	   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1 * xunit;
   	controlpoints[0].y = ybezorig + 7 * yunit;
   	controlpoints[1].x = xbezorig + 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 8 * yunit;
   	controlpoints[2].x = xbezorig + 0.3 * xunit;
   	controlpoints[2].y = ybezorig + 9 * yunit;
   	controlpoints[3].x = xbezorig;
   	controlpoints[3].y = ybezorig + 10 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig + 10 * yunit;
   	controlpoints[1].x = xbezorig - 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 11 * yunit; 	
   	controlpoints[2].x = xbezorig - 1.2 * xunit;
   	controlpoints[2].y = ybezorig + 12 * yunit;
   	controlpoints[3].x = xbezorig - 1.5 * xunit;
   	controlpoints[3].y = ybezorig + 13 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1.5 * xunit;
   	controlpoints[0].y = ybezorig + 13 * yunit;
   	controlpoints[1].x = xbezorig - 1.7 * xunit;
   	controlpoints[1].y = ybezorig + 14 * yunit;
   	controlpoints[2].x = xbezorig - 1.5 * xunit;
   	controlpoints[2].y = ybezorig + 15 * yunit;
   	controlpoints[3].x = xbezorig - 1.1 * xunit;
   	controlpoints[3].y = ybezorig + 16 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1.1 * xunit;
   	controlpoints[0].y = ybezorig + 16 * yunit;
   	controlpoints[1].x = xbezorig - 1 * xunit;
   	controlpoints[1].y = ybezorig + 17 * yunit;
   	controlpoints[2].x = xbezorig - 0.8 * xunit;
   	controlpoints[2].y = ybezorig + 18 * yunit;
   	controlpoints[3].x = xbezorig - 0.3 * xunit;
   	controlpoints[3].y = ybezorig + 19 * yunit;
   	   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig - 1 * xunit;
   	controlpoints[0].y = ybezorig + 17 * yunit;
   	controlpoints[1].x = xbezorig - 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 18 * yunit;
   	controlpoints[2].x = xbezorig - 0.3 * xunit;
   	controlpoints[2].y = ybezorig + 19 * yunit;
   	controlpoints[3].x = xbezorig;
   	controlpoints[3].y = ybezorig + 20 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig + 10 * yunit;
   	controlpoints[1].x = xbezorig + 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 11 * yunit; 	
   	controlpoints[2].x = xbezorig + 1.2 * xunit;
   	controlpoints[2].y = ybezorig + 12 * yunit;
   	controlpoints[3].x = xbezorig + 1.5 * xunit;
   	controlpoints[3].y = ybezorig + 13 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1.5 * xunit;
   	controlpoints[0].y = ybezorig + 13 * yunit;
   	controlpoints[1].x = xbezorig + 1.7 * xunit;
   	controlpoints[1].y = ybezorig + 14 * yunit;
   	controlpoints[2].x = xbezorig + 1.5 * xunit;
   	controlpoints[2].y = ybezorig + 15 * yunit;
   	controlpoints[3].x = xbezorig + 1.1 * xunit;
   	controlpoints[3].y = ybezorig + 16 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1.1 * xunit;
   	controlpoints[0].y = ybezorig + 16 * yunit;
   	controlpoints[1].x = xbezorig + 1 * xunit;
   	controlpoints[1].y = ybezorig + 17 * yunit;
   	controlpoints[2].x = xbezorig + 0.8 * xunit;
   	controlpoints[2].y = ybezorig + 18 * yunit;
   	controlpoints[3].x = xbezorig + 0.3 * xunit;
   	controlpoints[3].y = ybezorig + 19 * yunit;
   	   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	controlpoints[0].x = xbezorig + 1 * xunit;
   	controlpoints[0].y = ybezorig + 17 * yunit;
   	controlpoints[1].x = xbezorig + 0.8 * xunit;
   	controlpoints[1].y = ybezorig + 18 * yunit;
   	controlpoints[2].x = xbezorig + 0.3 * xunit;
   	controlpoints[2].y = ybezorig + 19 * yunit;
   	controlpoints[3].x = xbezorig;
   	controlpoints[3].y = ybezorig + 20 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	// .:: Archi di raccordo ::.

	xunit = arcradius / 3;
   	yunit = arcradius / 3;
   	
    xbezorig = x_origin + l_tot * 5 / 9;
	ybezorig = y_origin + h_tot / 4 - arcradius;
   	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig;
   	controlpoints[1].x = xbezorig + 0.5 * xunit;
   	controlpoints[1].y = ybezorig + 1 * yunit; 	
   	controlpoints[2].x = xbezorig + 1 * xunit;
   	controlpoints[2].y = ybezorig + 2 * yunit;
   	controlpoints[3].x = xbezorig + 3 * xunit;
   	controlpoints[3].y = ybezorig + 3 * yunit;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	xbezorig = x_origin + l_tot * 5 / 9;
	ybezorig = y_origin + h_tot *3 / 4;
	
   	controlpoints[0].x = xbezorig;
   	controlpoints[0].y = ybezorig + 3 * yunit;
   	controlpoints[1].x = xbezorig + 0.5 * xunit;
   	controlpoints[1].y = ybezorig + 2 * yunit; 	
   	controlpoints[2].x = xbezorig + 1 * xunit;
   	controlpoints[2].y = ybezorig + 1 * yunit;
   	controlpoints[3].x = xbezorig + 3 * xunit;
   	controlpoints[3].y = ybezorig;
   	
   	iconView->StrokeBezier(controlpoints, B_SOLID_HIGH);
   	
   	// .:: Quota raggio raccordo ::.
	
	xbezorig = x_origin + l_tot * 5 / 9;
	ybezorig = y_origin + h_tot / 4 - arcradius;
   	
   	float pigreco;
   	
   	pigreco = atan(1) * 4;
   	   	
	p1.x = xbezorig + 1.2 * xunit;
	p1.y = ybezorig + 1.8 * yunit;
	p2.x = p1.x + 2 * arcradius * cos(pigreco / 4);
	p2.y = p1.y - 2 * arcradius * sin(pigreco / 4);
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	
	// .:: Freccia quota raggio di raccordo ::.
	
	p2.x = p1.x + (-1 * largfreccie / 2 * cos(pigreco / 4) + largfreccie * 2 * sin(pigreco / 4));
	p2.y = p1.y + (-1 * largfreccie / 2 * sin(pigreco / 4) - largfreccie * 2 * cos(pigreco / 4));
	p3.x = p1.x + (largfreccie / 2 * cos(pigreco / 4) + largfreccie * 2 * sin(pigreco / 4));
	p3.y = p1.y + (largfreccie / 2 * sin(pigreco / 4) - largfreccie * 2 * cos(pigreco / 4));
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
   	
   	// .:: Testo quota raggio di raccordo ::.
   	
   	p2.x = p1.x + 2 * arcradius * cos(pigreco / 4);
   	p2.y = p1.y - arcradius / 2 * sin(pigreco / 4);
	
	iconView->MovePenTo(p2);
   	iconView->DrawString("r");
   	
   	// .:: Quota forza Sx ::.
   	
   	p1.x = x_origin - 3 * xunit;
	p1.y = y_origin + h_tot / 2;
	p2.x = x_origin - 8 * xunit;
	p2.y = y_origin + h_tot / 2;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
   	
   	p1.x = x_origin - 8 * xunit;
	p1.y = y_origin + h_tot / 2;
   	p2.x = p1.x + largfreccie * 2;
	p2.y = p1.y - largfreccie / 2;
	p3.x = p1.x + largfreccie * 2;
	p3.y = p1.y + largfreccie / 2;
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	p1.x = x_origin - 11 / 2 * xunit;
	p1.y = y_origin + h_tot / 2 - yunit;
	
	iconView->MovePenTo(p1);
   	iconView->DrawString("P");
   	
   	// .:: Quota forza Dx ::.
   	
   	p1.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45 + 3 * xunit;
	p1.y = y_origin + h_tot / 2;
	p2.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45 + 8 * xunit;
	p2.y = y_origin + h_tot / 2;
	
	iconView->StrokeLine(p1, p2, B_SOLID_HIGH);
   	
   	p1.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45 + 8 * xunit;
	p1.y = y_origin + h_tot / 2;
   	p2.x = p1.x - largfreccie * 2;
	p2.y = p1.y - largfreccie / 2;
	p3.x = p1.x - largfreccie * 2;
	p3.y = p1.y + largfreccie / 2;
	
	iconView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
   	
   	p1.x = x_origin + l_tot * 5 / 9 + arcradius + l_tot * 14 / 45 + 11 / 2 * xunit;
	p1.y = y_origin + h_tot / 2 - yunit;
	
	iconView->MovePenTo(p1);
   	iconView->DrawString("P");
   	
   	// .:: Grafico ::.
   	
   	// Dimensioni della BView drawView 310 x 210 pixels
   	
	BView *drawView;
    drawView = (BView *)FindView("drawView");
         	
	drawView->SetHighColor(0, 0, 0);	
	
	p1.x = 30;
	p1.y = 0;
	p2.x = 30;
	p2.y = 200;
	
	drawView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
   	p2.x = p1.x - largfreccie / 2;
	p2.y = p1.y + largfreccie * 2;
	p3.x = p1.x + largfreccie / 2;
	p3.y = p1.y + largfreccie * 2;
	
	drawView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	p1.x = 30;
	p1.y = 200;
	p2.x = 310;
	p2.y = 200;
	
	drawView->StrokeLine(p1, p2, B_SOLID_HIGH);
	
	p1.x = 310;
	p1.y = 200;
	p2.x = p1.x - largfreccie * 2;
	p2.y = p1.y - largfreccie / 2;
	p3.x = p1.x - largfreccie * 2;
	p3.y = p1.y + largfreccie / 2;
	
	drawView->FillTriangle(p1, p2, p3, B_SOLID_HIGH);
	
	for (int i = 280; i > 0; i = i - 50)
	{
		p1.x = i;
		p1.y = 198;
		p2.x = i;
		p2.y = 202;
	
		drawView->StrokeLine(p1, p2, B_SOLID_HIGH);
		
		p1.y = 210;
		
		float flxLabel;
		BString strxLabel;
		
		flxLabel = (i - 10) / 50 * 0.05;
    	strxLabel << (float)flxLabel;
    
		drawView->MovePenTo(p1);
   		drawView->DrawString(strxLabel.String());
		
	}
	
	for (int i = 200; i > 0; i = i - 25)
	{
		p1.x = 28;
		p1.y = i;
		p2.x = 32;
		p2.y = i;
	
		drawView->StrokeLine(p1, p2, B_SOLID_HIGH);
		
		p1.x = 0;
		
		float flyLabel;
		BString stryLabel;
		
		flyLabel = (200 - i) / 25 * 0.5;
    	stryLabel << (float)flyLabel;
    
		drawView->MovePenTo(p1);
   		drawView->DrawString(stryLabel.String());
   		
	}
	
	p1.x = 10;
	p1.y = 10;
	
	drawView->MovePenTo(p1);
   	drawView->DrawString("Kt");
   	
   	p1.x = 157;
	p1.y = 210;
	
	drawView->MovePenTo(p1);
   	drawView->DrawString("r/d");

}
Ejemplo n.º 12
0
// This function returns the number of pixels of the text that
// were clipped if the text does not fit into the clipping rect.
// If the text all fit, it returns 0.
int
BeOSCanvas::RenderText( int iFontHeight, Rect& oClipRect,
                        string& oText, AlignEnum eAlign,
                        Font* pFont, const Color& oColor,
                        bool bBold, bool bItalic, bool bUnderline )
{
    Erase( oClipRect );

    BView* v = m_pBufferBitmap->OffscreenView();
    if ( !v ) return 0;

    BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();
    assert( bitmap );

    BFont font;
    font_height fontHeight;
    BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
                    float(oClipRect.x2-1), float(oClipRect.y2-1) );
    BRegion clipRegion;
    clipRegion.Set( clipRect );

    if ( !bitmap->Lock() )
    {
        puts( "lock failed" );
        return 0;
    }

    v->ConstrainClippingRegion( &clipRegion );
    v->SetDrawingMode( B_OP_OVER );
    if ( bBold )
    {
        v->SetFont( be_bold_font );
    }
    else
    {
        v->SetFont( be_plain_font );
    }
    v->SetFontSize( (float)iFontHeight - 1 );
    v->GetFont( &font );
    font.GetHeight( &fontHeight );
    
    float width = v->StringWidth(oText.c_str(), oText.size());
    
    if(eAlign == eCenter)
        v->MovePenTo( float(oClipRect.x1) +
                      (float(oClipRect.x2 - oClipRect.x1) - width)/2,
                      float(oClipRect.y2-fontHeight.descent) );	
    else if (eAlign == eRight)
        v->MovePenTo( float(oClipRect.x2) - width,
                      float(oClipRect.y2-fontHeight.descent) );
    else
        v->MovePenTo( float(oClipRect.x1),
                      float(oClipRect.y2-fontHeight.descent) );

    v->DrawString( oText.c_str() );
    v->Sync();

    bitmap->Unlock();

    Invalidate( oClipRect );

    return (width < oClipRect.Width()) ? 0 : int(width - oClipRect.Width());
}
Ejemplo n.º 13
0
int
BeOSCanvas::RenderOffsetText( int iFontHeight, Rect& oClipRect,
                              string& oText, int iOffset,
                              Font* pFont, const Color& oColor,
                              bool bBold, bool bItalic,
                              bool bUnderline )
{
    Erase( oClipRect );

    BView* v = m_pBufferBitmap->OffscreenView();
    if ( !v ) return 0;

    BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();

    BFont font;
    font_height fontHeight;
    BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
                    float(oClipRect.x2-1), float(oClipRect.y2-1) );
    BRegion clipRegion;
    clipRegion.Set( clipRect );

    if ( !bitmap->Lock() )
    {
        puts( "Lock Failed" );
        return 0;
    }

    v->ConstrainClippingRegion( &clipRegion );
    if ( bBold )
    {
        v->SetFont( be_bold_font );
    }
    else
    {
        v->SetFont( be_plain_font );
    }
    v->SetFontSize( (float)iFontHeight - 1 );
    v->GetFont( &font );
    font.GetHeight( &fontHeight );

    float width = v->StringWidth(oText.c_str(), oText.size());
    width += iMarqueeSpacer;

    if ( iOffset > width )
    {
        bitmap->Unlock();
        return int( width ) - iOffset;
    }

    v->MovePenTo( float(oClipRect.x1 - iOffset),
                  float(oClipRect.y2 - fontHeight.descent) );
    v->DrawString( oText.c_str() );
    int ret = int( width ) - iOffset - oClipRect.Width();
    if ( ret < 0 )
    {
        v->MovePenTo( float(oClipRect.x1 - iOffset + width),
                      float(oClipRect.y2 - fontHeight.descent) );
        v->DrawString( oText.c_str() );
    }

    v->Sync();
    bitmap->Unlock();

    Invalidate( oClipRect );

    return MAX( 0, ret );
}
Ejemplo n.º 14
0
void URLView::DoPersonDrag() {
	// Handle all of the bookmark dragging.  This includes setting up
	// the drag message and drawing the dragged bitmap.
	
	// Set up the drag message to support both BTextView dragging (using
	// the e-mail address) and file dropping (to Tracker).
	BMessage *dragMessage = new BMessage( B_MIME_DATA );
	dragMessage->AddInt32( "be:actions", B_COPY_TARGET );
	dragMessage->AddString( "be:types", "application/octet-stream" );
	dragMessage->AddString( "be:filetypes", "application/x-person" );
	dragMessage->AddString( "be:type_descriptions", "person" );
	dragMessage->AddString( "be:clip_name", Text() );
	
	// This allows the user to drag the e-mail address into a
	// standard BTextView.
	BString email = GetImportantURL();
	dragMessage->AddData( "text/plain", B_MIME_DATA, email.String(),
						  email.Length() + 1 );
	
	// Query for the system's icon for bookmarks.
	BBitmap *personIcon = new BBitmap( BRect( 0, 0, iconSize - 1,
									   iconSize - 1 ), B_CMAP8 );
	#ifdef ZETA
		BMimeType mime( "application/x-vnd.Be-PEPL" );
	#else
		BMimeType mime( "application/x-person" );
	#endif
	if( iconSize == 16 ) mime.GetIcon( personIcon, B_MINI_ICON );
	else mime.GetIcon( personIcon, B_LARGE_ICON );
	
	// Find the size of the bitmap to drag.  If the text is bigger than the
	// icon, use that size.  Otherwise, use the icon's.  Center the icon
	// vertically in the bitmap.
	BRect rect = GetTextRect();
	rect.right += iconSize + 4;
	if( (rect.bottom - rect.top) < iconSize ) {
		int adjustment = (int) ((iconSize - (rect.bottom - rect.top)) / 2) + 1;
		rect.top -= adjustment;
		rect.bottom += adjustment;
	}
	
	// Make sure the rectangle starts at 0,0.
	rect.bottom += 0 - rect.top;
	rect.top = 0;
	
	// Create the bitmap to draw the dragged image in.
	BBitmap *dragBitmap = new BBitmap( rect, B_RGBA32, true );
	BView *dragView = new BView( rect, "Drag View", 0, 0 );
	dragBitmap->Lock();
	dragBitmap->AddChild( dragView );
	
	BRect frameRect = dragView->Frame();
	
	// Make the background of the dragged image transparent.
	dragView->SetHighColor( B_TRANSPARENT_COLOR );
	dragView->FillRect( frameRect );

	// We want 'g's, etc. to go below the underline.  When the BeOS can
	// do underlining of any font, this code can be removed.
	font_height height;
	GetFontHeight( &height );
	float descent = height.descent;

	// Find the vertical center of the view so we can vertically
	// center everything.
	int centerPixel = (int) ((frameRect.bottom - frameRect.top) / 2);
	int textCenter  = (int) (descent + underlineThickness) + centerPixel;

	// We want to draw everything only half opaque.
	dragView->SetDrawingMode( B_OP_ALPHA );
	dragView->SetHighColor( 0.0, 0.0, 0.0, 128.0 );
	dragView->SetBlendingMode( B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE );

	// Center the icon in the view.
	dragView->MovePenTo( BPoint( frameRect.left,
								 centerPixel - (iconSize / 2) ) );
	dragView->DrawBitmap( personIcon );

	// Draw the text in the same font (size, etc.) as the link view.
	// Note:  DrawString() draws the text at one pixel above the pen's
	//		  current y coordinate.
	BFont font;
	GetFont( &font );
	dragView->SetFont( &font );
	dragView->MovePenTo( BPoint( frameRect.left + iconSize + 4, textCenter ) );
	dragView->DrawString( Text() );
	
	// Be sure to flush the view buffer so everything is drawn.
	dragView->Flush();
	dragBitmap->Unlock();
	
	// The Person icon adds some width to the bitmap that we are
	// going to draw.  So horizontally offset the bitmap proportionally
	// to where the user clicked on the link.
	float horiz = dragOffset.x / GetTextRect().Width();
	dragOffset.x = horiz * frameRect.right;

	DragMessage( dragMessage, dragBitmap, B_OP_ALPHA,
				 BPoint( dragOffset.x,
				 		 (rect.Height() + underlineThickness) / 2 + 2), this );
	delete dragMessage;

	draggedOut = true;
}
Ejemplo n.º 15
0
void
ColorStepView::Draw(BRect updateRect)
{
	BView *view = NULL;
	if(fOffScreenView){
		view = fOffScreenView;
	}
	else{
		view = this;
	}

	if (!fOffScreenBitmap || !fOffScreenBitmap->Lock())
		return;
	view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	view->FillRect(updateRect);

	BRect colorBarRect =  fSlider->BarFrame();
	colorBarRect.top = 0;
	colorBarRect.bottom = kColorBarHeight;
	colorBarRect.OffsetTo(colorBarRect.left, fSlider->Frame().bottom);

	float pos = 0.0;
	for (int i = fPerformanceList->CountItems() - 1; i >= 0 ; i--) {
		performance_step* perfState = fPerformanceList->ItemAt(i);

		float nextPos = perfState->cpu_usage;
		float width = colorBarRect.Width();

		BRect subRect(colorBarRect);
		subRect.left += pos * width;
		subRect.right = colorBarRect.left + nextPos * width;

		view->SetHighColor(perfState->color);
		view->FillRect(subRect);

		pos = nextPos;
	}
	// draw label
	if (IsEnabled()) {
		view->SetHighColor(0, 0, 0);
	} else {
		view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT));
	}

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float totalFontHeight = fontHeight.descent + fontHeight.ascent;

	view->DrawString(fMinFrequencyLabel.String(),
						BPoint(0.0,
								colorBarRect.bottom + totalFontHeight + 5));

	view->DrawString(fMaxFrequencyLabel.String(),
						BPoint(Bounds().right
								- StringWidth(fMaxFrequencyLabel.String()),
								colorBarRect.bottom	+ totalFontHeight + 5));

	// blit bitmap
	view->Sync();
	fOffScreenBitmap->Unlock();
	DrawBitmap(fOffScreenBitmap, B_ORIGIN);

	BView::Draw(updateRect);
}