예제 #1
0
static void
move_pen_by(void* _context, const BPoint& delta)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetPenLocation(
		context->CurrentState()->PenLocation() + delta);
}
예제 #2
0
static void
set_pen_size(void* _context, float size)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetPenSize(size);
	context->GetDrawingEngine()->SetPenSize(
		context->CurrentState()->PenSize());
		// DrawState::PenSize() returns the scaled pen size, so we
		// need to use that value to set the drawing engine pen size.
}
예제 #3
0
static void
set_font_style(void* _context, const char* _style, size_t length)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BString style(_style, length);

	ServerFont font(context->CurrentState()->Font());

	FontStyle* fontStyle = gFontManager->GetStyle(font.Family(), style);

	font.SetStyle(fontStyle);
	context->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
}
예제 #4
0
static void
set_back_color(void* _context, const rgb_color& color)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetLowColor(color);
	context->GetDrawingEngine()->SetLowColor(color);
}
예제 #5
0
static void
set_blending_mode(void* _context, source_alpha alphaSrcMode,
	alpha_function alphaFncMode)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetBlendingMode(alphaSrcMode, alphaFncMode);
}
예제 #6
0
static void
set_stipple_pattern(void* _context, const pattern& pattern)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetPattern(Pattern(pattern));
	context->GetDrawingEngine()->SetPattern(pattern);
}
예제 #7
0
static void
set_drawing_mode(void* _context, drawing_mode mode)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetDrawingMode(mode);
	context->GetDrawingEngine()->SetDrawingMode(mode);
}
예제 #8
0
static void
set_font_flags(void* _context, uint32 flags)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetFlags(flags);
	context->CurrentState()->SetFont(font, B_FONT_FLAGS);
}
예제 #9
0
static void
set_font_size(void* _context, float size)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetSize(size);
	context->CurrentState()->SetFont(font, B_FONT_SIZE);
}
예제 #10
0
static void
set_font_rotation(void* _context, float rotation)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetRotation(rotation);
	context->CurrentState()->SetFont(font, B_FONT_ROTATION);
}
예제 #11
0
static void
set_font_shear(void* _context, float shear)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetShear(shear);
	context->CurrentState()->SetFont(font, B_FONT_SHEAR);
}
예제 #12
0
static void
set_font_face(void* _context, uint16 face)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetFace(face);
	context->CurrentState()->SetFont(font, B_FONT_FACE);
}
예제 #13
0
static void
set_font_spacing(void* _context, uint8 spacing)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetSpacing(spacing);
	context->CurrentState()->SetFont(font, B_FONT_SPACING);
}
예제 #14
0
static void
set_font_encoding(void* _context, uint8 encoding)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	ServerFont font;
	font.SetEncoding(encoding);
	context->CurrentState()->SetFont(font, B_FONT_ENCODING);
}
예제 #15
0
static void
set_pen_location(void* _context, const BPoint& pt)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetPenLocation(pt);
	// the DrawingEngine/Painter does not need to be updated, since this
	// effects only the view->screen coord conversion, which is handled
	// by the view only
}
예제 #16
0
static void
set_scale(void* _context, float scale)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetScale(scale);
	context->ResyncDrawState();

	// Update the drawing engine draw state, since some stuff
	// (for example the pen size) needs to be recalculated.
}
예제 #17
0
static void
set_line_mode(void* _context, cap_mode capMode, join_mode joinMode,
	float miterLimit)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	DrawState* state = context->CurrentState();
	state->SetLineCapMode(capMode);
	state->SetLineJoinMode(joinMode);
	state->SetMiterLimit(miterLimit);
	context->GetDrawingEngine()->SetStrokeMode(capMode, joinMode, miterLimit);
}
예제 #18
0
static void
pop_state(void* _context)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->PopState();

	BPoint p(0, 0);
	context->ConvertToScreenForDrawing(&p);
	context->GetDrawingEngine()->SetDrawState(context->CurrentState(),
		(int32)p.x, (int32)p.y);
}
예제 #19
0
static void
set_font_family(void* _context, const char* _family, size_t length)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BString family(_family, length);

	FontStyle* fontStyle = gFontManager->GetStyleByIndex(family, 0);
	ServerFont font;
	font.SetStyle(fontStyle);
	context->CurrentState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
}
예제 #20
0
static void
draw_round_rect(void* _context, const BRect& _rect, const BPoint& radii,
	bool fill)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BRect rect = _rect;

	context->ConvertToScreenForDrawing(&rect);
	float scale = context->CurrentState()->CombinedScale();
	context->GetDrawingEngine()->DrawRoundRect(rect, radii.x * scale,
		radii.y * scale, fill);
}
예제 #21
0
static void
draw_string(void* _context, const char* string, size_t length, float deltaSpace,
	float deltaNonSpace)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);

	// NOTE: the picture data was recorded with a "set pen location"
	// command inserted before the "draw string" command, so we can
	// use PenLocation()
	BPoint location = context->CurrentState()->PenLocation();

	escapement_delta delta = { deltaSpace, deltaNonSpace };
	context->ConvertToScreenForDrawing(&location);
	location = context->GetDrawingEngine()->DrawString(string, length,
		location, &delta);

	context->ConvertFromScreenForDrawing(&location);
	context->CurrentState()->SetPenLocation(location);
	// the DrawingEngine/Painter does not need to be updated, since this
	// effects only the view->screen coord conversion, which is handled
	// by the view only
}
예제 #22
0
static void
stroke_line(void* _context, const BPoint& _start, const BPoint& _end)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	BPoint start = _start;
	BPoint end = _end;

	context->ConvertToScreenForDrawing(&start);
	context->ConvertToScreenForDrawing(&end);
	context->GetDrawingEngine()->StrokeLine(start, end);

	context->CurrentState()->SetPenLocation(_end);
	// the DrawingEngine/Painter does not need to be updated, since this
	// effects only the view->screen coord conversion, which is handled
	// by the view only
}
예제 #23
0
static void
clip_to_picture(void* _context, int32 pictureToken, const BPoint& where,
	bool clipToInverse)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);

	ServerPicture* picture = context->GetPicture(pictureToken);
	if (picture == NULL)
		return;

	AlphaMask* mask = new(std::nothrow) AlphaMask(
		picture, clipToInverse, where, *context->CurrentState());
	context->SetAlphaMask(mask);
	context->UpdateCurrentDrawingRegion();
	if (mask != NULL)
		mask->ReleaseReference();

	picture->ReleaseReference();
}
예제 #24
0
void
ShapePainter::Draw(BRect frame, bool filled)
{
	// We're going to draw the currently iterated shape.
	// TODO: This can be more efficient by skipping the conversion.
	int32 opCount = fOpStack.size();
	int32 ptCount = fPtStack.size();

	if (opCount > 0 && ptCount > 0) {
		int32 i;
		uint32* opList = new(std::nothrow) uint32[opCount];
		if (opList == NULL)
			return;

		BPoint* ptList = new(std::nothrow) BPoint[ptCount];
		if (ptList == NULL) {
			delete[] opList;
			return;
		}

		for (i = opCount - 1; i >= 0; i--) {
			opList[i] = fOpStack.top();
			fOpStack.pop();
		}

		for (i = ptCount - 1; i >= 0; i--) {
			ptList[i] = fPtStack.top();
			fPtStack.pop();
		}

		BPoint offset(fContext->CurrentState()->PenLocation());
		fContext->ConvertToScreenForDrawing(&offset);
		fContext->GetDrawingEngine()->DrawShape(frame, opCount, opList,
			ptCount, ptList, filled, offset, fContext->Scale());

		delete[] opList;
		delete[] ptList;
	}
}
예제 #25
0
static void
exit_font_state(void* _context)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->GetDrawingEngine()->SetFont(context->CurrentState()->Font());
}
예제 #26
0
static void
set_origin(void* _context, const BPoint& pt)
{
	DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
	context->CurrentState()->SetOrigin(pt);
}