Exemplo n.º 1
0
void GRSimpleBeam::OnDraw( VGDevice & hdc ) const
{
	const unsigned char * colref = getColRef();

	if (colref) {
		VGColor color ( colref ); 	// custom or black
		hdc.PushFillColor( color );
		hdc.PushPen( color, 1 );
	}
	float ax [4] = { fPoints[0].x, fPoints[1].x, fPoints[3].x, fPoints[2].x };
	float ay [4] = { fPoints[0].y, fPoints[1].y, fPoints[3].y, fPoints[2].y };


// DF added to check for incorrect coordinates
// makes sure that the right point is not to the left of the left point :-)
// actually this should be checked at coordinates computation time
// todo: check the object that computes the beam coordinates
	if (ax[0] > ax[2]) { ax[2] = ax[0]; }
	if (ax[1] > ax[3]) { ax[3] = ax[1]; }
	
	// This does the drawing!
	hdc.Polygon( ax, ay, 4 );

	// - Cleanup
	if (colref) {
		hdc.PopPen();
		hdc.PopFillColor();
	}
}
Exemplo n.º 2
0
void GRCrescendo::OnDraw( VGDevice & hdc) const
{
	if (!mDraw)
		return;

    if (fCrescInfos->points[0].x == fCrescInfos->points[1].x)
        return;

    assert(gCurSystem);

	GRSystemStartEndStruct * sse = getSystemStartEndStruct(gCurSystem);
	if (sse == 0)
		return;

    const VGColor prevTextColor = hdc.GetFontColor();

    if (mColRef) {
        hdc.PushPenColor(VGColor(mColRef));
        hdc.PushFillColor(VGColor(mColRef));
        hdc.SetFontColor(VGColor(mColRef));
    }

    hdc.PushPenWidth(fCrescInfos->thickness);

    hdc.Line(fCrescInfos->points[0].x , fCrescInfos->points[0].y, fCrescInfos->points[1].x , fCrescInfos->points[1].y);
	hdc.Line(fCrescInfos->points[0].x , fCrescInfos->points[0].y, fCrescInfos->points[2].x , fCrescInfos->points[2].y);

    const float xMarkingOffset = fCrescInfos->points[1].x + 30;
    const float yMarkingOffset = fCrescInfos->points[0].y - 277 + (mTagSize - 1) * 25;

    if (fCrescInfos->fMarkingSymbol != 0)
        OnDrawSymbol(hdc, fCrescInfos->fMarkingSymbol, xMarkingOffset, yMarkingOffset, mTagSize);
    
    hdc.PopPenWidth();

    if (mColRef) {
        hdc.SetFontColor(prevTextColor);
        hdc.PopFillColor();
        hdc.PopPenColor();
    }
}
Exemplo n.º 3
0
void GRBeam::OnDraw( VGDevice & hdc) const
{
	if (error) return;

	GRSystemStartEndStruct * sse = getSystemStartEndStruct( gCurSystem );
	if (sse == 0) return;

	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	assert(st);

	if (mColRef) {
		VGColor color ( mColRef ); 	// custom or black
		hdc.PushFillColor( color );
		hdc.PushPen( color, 1);
	}
		
	float ax [4] = { st->p[0].x, st->p[1].x, st->p[3].x, st->p[2].x };
	float ay [4] = { st->p[0].y, st->p[1].y, st->p[3].y, st->p[2].y };
	
	// This does the drawing!
	hdc.Polygon( ax, ay, 4 );
	
	if (st->simpleBeams)
	{
		GuidoPos smplpos = st->simpleBeams->GetHeadPosition();
		while (smplpos)
		{
			GRSimpleBeam * smplbeam = st->simpleBeams->GetNext(smplpos);
			smplbeam->OnDraw(hdc);
		}
	}

	if (mColRef) {
		hdc.PopPen();
		hdc.PopFillColor();
	}
}
Exemplo n.º 4
0
void GRCluster::OnDraw(VGDevice &hdc) const
{
    if (mDraw) {
        if (fNoteFormatColor) {
            VGColor color(fNoteFormatColor);
            hdc.PushPen(color, 1);

            if (!mColRef)
                hdc.PushFillColor(color);
        }

    	if (mColRef) {
            VGColor color(mColRef);
            hdc.PushFillColor(color);
            hdc.PushPenColor(color);
        }

    	// - Quarter notes and less
    	if (fDuration < DURATION_2) {
            const float xCoords [] = {
                mMapping.left,
                mMapping.right,
                mMapping.right,
                mMapping.left};
            const float yCoords [] = {
                mMapping.top,
                mMapping.top,
                mMapping.bottom,
                mMapping.bottom};

            hdc.Polygon(xCoords, yCoords, 4);
        }
	    else {
            const float xCoords1 [] = {
                mMapping.left,
                mMapping.right,
                mMapping.right,
                mMapping.left};
            const float yCoords1 [] = {
                mMapping.top,
                mMapping.top,
                mMapping.top + 6 * mTagSize * fsize,
                mMapping.top + 6 * mTagSize * fsize};
            const float xCoords2 [] = {
                mMapping.right - 6 * mTagSize * fsize,
                mMapping.right,
                mMapping.right,
                mMapping.right - 6 * mTagSize * fsize};
            const float yCoords2 [] = {
                mMapping.top,
                mMapping.top,
                mMapping.bottom,
                mMapping.bottom};
            const float xCoords3 [] = {
                mMapping.left,
                mMapping.right,
                mMapping.right,
                mMapping.left};
            const float yCoords3 [] = {
                mMapping.bottom - 6 * mTagSize * fsize,
                mMapping.bottom - 6 * mTagSize * fsize,
                mMapping.bottom,
                mMapping.bottom};
            const float xCoords4 [] = {
                mMapping.left,
                mMapping.left + 6 * mTagSize * fsize,
                mMapping.left + 6 * mTagSize * fsize,
                mMapping.left};
            const float yCoords4 [] = {
                mMapping.top,
                mMapping.top,
                mMapping.bottom,
                mMapping.bottom};

            hdc.Polygon(xCoords1, yCoords1, 4);
            hdc.Polygon(xCoords2, yCoords2, 4);
            hdc.Polygon(xCoords3, yCoords3, 4);
            hdc.Polygon(xCoords4, yCoords4, 4);
        }

	    // - Restore context
	    if (mColRef) {
            hdc.PopPenColor();
		    hdc.PopFillColor();
        }

        if (fNoteFormatColor) {
            if (!mColRef)
                hdc.PopFillColor();

            hdc.PopPen();
        }
	}
}
Exemplo n.º 5
0
// -----------------------------------------------------------------------------
void GRBowing::OnDraw( VGDevice & hdc) const
{
// DrawBoundingBox( hdc, GColor( 255, 120, 150, 120 )); // DEBUG
	if(!mDraw)
		return;

	if (error) return;
	
	assert( gCurSystem );

	GRSystemStartEndStruct * sse = getSystemStartEndStruct( gCurSystem );
	if( sse == 0)
		return; // don't draw

	// now we need to get the position and offset for the current bowing ...

	GRBowingSaveStruct * bowInfos = (GRBowingSaveStruct *)sse->p;
	assert(bowInfos);

/*
	NVPoint pstart, pmid, pend, poffsetUp, poffsetDown;
	pstart.x=bowInfos->position.x+bowInfos->offsets[0].x;
	pstart.y=bowInfos->position.y+bowInfos->offsets[0].y;
	pmid.x=bowInfos->position.x+bowInfos->offsets[1].x;
	pmid.y=bowInfos->position.y+bowInfos->offsets[1].y;
	pend.x=bowInfos->position.x+bowInfos->offsets[2].x;
	pend.y=bowInfos->position.y+bowInfos->offsets[2].y;
*/
//	GColor backColor = hdc.GetTextBackgroundColor();
//	hdc.SetTextBackgroundColor( 255,0,0 ); // why red?

	// now we do it with correct colors:
//	VGColor color ( mColRef ); 	// custom or black
	if (mColRef) hdc.PushFillColor( VGColor( mColRef ) );
//	hdc.PushPen( color, 1 );

	const float x = bowInfos->position.x;
	const float y = bowInfos->position.y;
// keith hamel
	::drawSlur( hdc,
				x + bowInfos->offsets[0].x,
				y + bowInfos->offsets[0].y,
				x + bowInfos->offsets[1].x,
				y + bowInfos->offsets[1].y,
				x + bowInfos->offsets[2].x,
				y + bowInfos->offsets[2].y,
				bowInfos->inflexion );

	// no floodfill until point-issue is eliminated
	///ExtFloodFill(hdc,pmid.x,pmid.y,fg,FLOODFILLSURFACE);
	// FloodFill(hdc,pmid.x,pmid.y,fg);

	// restore old pen and brush
//	hdc.PopPen();
	if (mColRef) hdc.PopFillColor();

	// overdraw borderlines with black color
	/* drawslur(hdc, pstart,poffsetUp,pend);
	drawslur(hdc, pstart,poffsetDown,pend); */

	// restore old backgound color
	// hdc.SetTextBackgroundColor( backColor );
}
Exemplo n.º 6
0
// --------------------------------------------------------------------------
void GRRepeatBegin::OnDraw(VGDevice & hdc ) const
{
    if (!mDraw || fSize < kMinNoteSize)
		return;

    VGColor prevColor = hdc.GetFontColor();
    if (mColRef) {
        hdc.PushFillColor(VGColor(mColRef));
        hdc.SetFontColor(VGColor(mColRef));
    }

    // - Vertical adjustement according to staff's line number
    float offsety1 = (fmod(- 0.5f * fLineNumber - 2, 3) + 1.5f) * LSPACE;
    float offsety2 = 0;

    if (fLineNumber != 0 && fLineNumber != 1)
        offsety2 = ((fLineNumber - 5) % 6) * LSPACE;

    float rightLineThickness = 1.8f * kLineThick * fSize;

    // - Horizontal adjustement according to staff's lines size and staff's size
    const float offsetX = 0.5f * (fStaffThickness - 4) - 30 * (fSize - 1) + (fSize - 1) * (fStaffThickness - 4) * 0.5f + 40;

    const float spacing = fBaseThickness + LSPACE * 0.4f * fSize - rightLineThickness;
	const float x1 = mPosition.x - mBoundingBox.Width() + offsetX;
	const float x2 = x1 + spacing;
    const float y1 = mPosition.y + offsety1 * fSize;
	const float y2 = y1 + (mBoundingBox.bottom + offsety2) * fSize;

    hdc.Rectangle(x1, y1, x1 + fBaseThickness, y2);
	hdc.Rectangle(x2, y1, x2 + rightLineThickness, y2);

    /* Two points drawing */
    float offsety1AccordingToLineNumber = 0;
    float offsety2AccordingToLineNumber = 0;

    if (fLineNumber == 0)
        offsety1AccordingToLineNumber = - LSPACE / 2 * fSize;
    else if (fLineNumber == 1)
        offsety1AccordingToLineNumber = - LSPACE * fSize;
    else if (fLineNumber == 2)
    {
        offsety1AccordingToLineNumber = 14 * fSize;
        offsety2AccordingToLineNumber = - 2 * offsety1AccordingToLineNumber;
    }

    int   pointSymbol = 220;
    float pointOffsety1 = - 5 * fSize + offsety1AccordingToLineNumber;
    float pointOffsety2 = pointOffsety1 + LSPACE * fSize + offsety2AccordingToLineNumber;
    float pointOffsetx = 28 * (fSize - 1) + 0.5f * (fStaffThickness - 4) + (fSize - 1) * (fStaffThickness - 4) * 0.5f + 8;
    float pointSize = 0.4f * fSize;

    DrawSymbol(hdc, pointSymbol, pointOffsetx, pointOffsety1, pointSize);
    DrawSymbol(hdc, pointSymbol, pointOffsetx, pointOffsety2, pointSize);
    /**********************/

    if (mColRef) {
        hdc.SetFontColor(prevColor);
        hdc.PopFillColor();
    }
}
Exemplo n.º 7
0
void GRBeam::OnDraw( VGDevice & hdc) const
{
	if (error) return;

	if(!mDraw)
		return;

	GRSystemStartEndStruct * sse = getSystemStartEndStruct( gCurSystem );
	if (sse == 0) return;

	GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p;
	assert(st);

	if (mColRef) {
		VGColor color ( mColRef ); 	// custom or black
		hdc.PushFillColor( color );
		hdc.PushPen( color, 1);
	}
		
	float ax [4] = { st->p[0].x, st->p[1].x, st->p[3].x, st->p[2].x };
	float ay [4] = { st->p[0].y, st->p[1].y, st->p[3].y, st->p[2].y };
	
	// This does the drawing!
	hdc.Polygon(ax, ay, 4);
	
	if (st->simpleBeams)
	{
		GuidoPos smplpos = st->simpleBeams->GetHeadPosition();
		while (smplpos)
		{
			GRSimpleBeam * smplbeam = st->simpleBeams->GetNext(smplpos);
			smplbeam->OnDraw(hdc);
		}
	}

	if(drawDur)
	{
		const char * fraction = st->duration.c_str();
		size_t n = st->duration.length();

        hdc.PushPenWidth(4);

		if(sse->startflag != GRSystemStartEndStruct::OPENLEFT)
		{	
			hdc.Line(st->DurationLine[0].x, st->DurationLine[0].y, st->DurationLine[1].x, st->DurationLine[1].y);
			hdc.Line(st->DurationLine[1].x, st->DurationLine[1].y, st->DurationLine[2].x, st->DurationLine[2].y);
			hdc.Line(st->DurationLine[3].x, st->DurationLine[3].y, st->DurationLine[4].x, st->DurationLine[4].y);
		}
		else
			hdc.Line(st->DurationLine[1].x, st->DurationLine[1].y, st->DurationLine[4].x, st->DurationLine[4].y);
		if(sse->endflag != GRSystemStartEndStruct::OPENRIGHT)
			hdc.Line(st->DurationLine[4].x, st->DurationLine[4].y, st->DurationLine[5].x, st->DurationLine[5].y);
		
		const VGFont* hmyfont;
		hmyfont = FontManager::gFontText;
		hdc.SetTextFont( hmyfont );

		if (sse->startflag != GRSystemStartEndStruct::OPENLEFT)
			hdc.DrawString(st->DurationLine[2].x + LSPACE/4, st->DurationLine[2].y + LSPACE / 2, fraction, n);

        hdc.PopPenWidth();
	}

	if (mColRef)
    {
		hdc.PopPen();
		hdc.PopFillColor();
	}

}
Exemplo n.º 8
0
// ----------------------------------------------------------------------------
//		* DoDraw
// ----------------------------------------------------------------------------
void
GuidoCarbonControl::DoDraw()
{
 	const GRHandler guidoRef = GetGuidoGR();	
	if( guidoRef == 0 ) return;
	
  	ControlRef theControl = GetControlRef();
  	if( theControl == 0 ) return;
 	
 	// - Get our local size
 	int localWidth;
	int localHeight;
	GetSize( &localWidth, &localHeight );
	CGRect deviceRect = ::CGRectMake( 0, 0, localWidth, localHeight );

	//	VGDevice * device = GetGDevice(); 	// <- was
	const int kScrollBarHeight = 15;
	
	// - Create the graphic context. It must be initialized with the actual size of the window,
	// otherwise the y-origin is not calculated properly.
	WindowRef winRef = ::GetControlOwner( theControl );
	GrafPtr port = ::GetWindowPort( winRef );
	CGContextRef contextRef = 0;
	OSStatus status = ::CreateCGContextForPort( port, &contextRef );
	if( status != noErr ) return;
	
	GSystemOSX system(contextRef, NULL);
	VGDevice* device = system.CreateDisplayDevice();
	device->NotifySize(localWidth, localHeight + kScrollBarHeight );
	
	::CGContextRelease(contextRef);	// because the device now owns the context.	

	// - Draw the background
	device->BeginDraw();
	device->PushPen( VGColor( 0, 0, 0, ALPHA_OPAQUE ), 1 );
	device->PushFillColor( VGColor( 255, 255, 255, ALPHA_TRANSPARENT ));
	device->Rectangle( 0, 0, localWidth, localHeight );
	device->PopFillColor();
	device->PopPen();
	
	// - Setup the clipping rectangle, to avoid drawing on scrollbars.
	::CGContextClipToRect( contextRef, deviceRect ); 

	// - Draw the music score
	int virtualScrollX = (int)((float)mScrollX * 10 / GetZoom());
	int virtualScrollY = (int)((float)mScrollY * 10 / GetZoom());
	float virtualVisibleWidth = localWidth * 10 / GetZoom();
	float virtualVisibleHeight = localHeight * 10 / GetZoom();

	float fullScoreWidth;
	float fullScoreHeight;
	GetFullScoreSize( &fullScoreWidth, &fullScoreHeight );

	GuidoOnDrawDesc desc;
	desc.handle = guidoRef;	 
	desc.hdc = device;
	desc.updateRegion.erase = false;
	desc.updateRegion.left = virtualScrollX;	// absolute virtual coordinates clip rect
	desc.updateRegion.top = virtualScrollY;
	desc.updateRegion.right = (int)(virtualScrollX + virtualVisibleWidth);
	desc.updateRegion.bottom = (int)(virtualScrollY + virtualVisibleHeight);
	desc.scrollx = (int)virtualScrollX;
	desc.scrolly = (int)virtualScrollY;
	desc.page = GetPageNum();
	desc.sizex = (int)fullScoreWidth;
	desc.sizey = (int)fullScoreHeight;
	
	MClock clock;
	GuidoOnDraw( &desc );
 
// debug
#if 0
	std::cout << "Score : sizex = " << desc.sizex << " ; sizey = " << desc.sizey << std::endl; 
	std::cout << "Guido: time do draw the score: " << clock.Milliseconds() << " ms" << std::endl;
//	std::cout << "Guido: graphical objects: " << GuidoGRObjectCount() << std::endl;
#endif
 
 	if( GetParam( kDrawSymbolMap ) == 1 )
 		DrawSymbolMap();
	
//	drawMap (guidoRef, device, GetPageNum());

	device->EndDraw();
	delete device;
}
Exemplo n.º 9
0
/** \brief Draws the score page.

	The GuidoEngine does not draw nor erase the background.
	Client applications must display it by themself. Usually, printing
	does not require to draw a background.

*/
void GRPage::OnDraw( VGDevice & hdc, const GuidoOnDrawDesc & inDrawInfos ) const
{

	setScaling( hdc, (float)inDrawInfos.sizex, (float)inDrawInfos.sizey );

	// if croll coords are in virtual units:
	hdc.SetOrigin( - (float)inDrawInfos.scrollx, - (float)inDrawInfos.scrolly ); // (JB) sign change


	// if scroll coords are in device units:
	//	hdc.SetOrigin( - (float)inDrawInfos.scrollx / hdc.GetXScale(), 
	//		- (float)inDrawInfos.scrolly / hdc.GetYScale());
	
	if ( /*fullredraw ||*/ inDrawInfos.updateRegion.erase )// (JB)   || c->ps.hdc == NULL 
	{
		gClipRect.Set( 0, 0, getPageWidth(), getPageHeight());
	}
	else
	{			
		/*	was: 
		// This is the update region
		const GCoord left = c->updateRegion.left;
 		const GCoord top = c->updateRegion.top;
		const GCoord right = c->updateRegion.right;
		const GCoord bottom = c->updateRegion.bottom;

		DPtoLPRect( hdc, left, top, right, bottom, &gClipRect ); // (JB) still ok ? */
	
		gClipRect.Set( float(inDrawInfos.updateRegion.left), float(inDrawInfos.updateRegion.top), 
						float(inDrawInfos.updateRegion.right), float(inDrawInfos.updateRegion.bottom) );
	}


#if (0)
	// Draw margins.
	const float x1 = getMarginLeft();
	const float x2 = getPageWidth() - getMarginRight();
	const float x3 = getPageWidth();
	const float y1 = getMarginTop();
	const float y2 = getPageHeight() - getMarginBottom();
	const float y3 = getPageHeight();

	hdc.PushPen( VGColor( 150, 150, 255 ), 5 );			// opaque
	hdc.PushFillColor( VGColor( 0, 0, 0, ALPHA_OPAQUE ));	
	
// DrawBoundingBox( hdc, GColor( 200, 255, 200 ));

	hdc.Rectangle( 0, 0, x3, y3 );
	hdc.Rectangle( x1, y1, x2, y2 );

	hdc.Line( 0, 0, x1, y1 );	// top left
	hdc.Line( 0, y3, x1, y2 );	// bottom left
	hdc.Line( x3, 0, x2, y1 );	// top right
	hdc.Line( x3, y3, x2, y2 );	// bottom right
	hdc.PopFillColor();
	hdc.PopPen();
#endif

	// - Draws elements of the page.
	OnDraw( hdc );
//    trace (hdc);
}