예제 #1
0
// -------------------------------------------------------------------
CairoDevice::CairoDevice(cairo_t * dev, VGSystem * sys) 
	: fNativeDevice(0), fSystem(sys), fTextFont(0), fMusicFont(0), fFillColor(0,0,0), fPenColor(0,0,0)
{
	fNativeDevice = cairo_reference (dev);
	SetFontColor( VGColor(0,0,0,ALPHA_OPAQUE) );
	SetFontBackgroundColor( VGColor(255,255,255,ALPHA_TRANSPARENT) );	// transparent
	SetFontAlign( kAlignLeft | kAlignBase );
}
예제 #2
0
CairoDevice::CairoDevice(int w, int h, VGSystem * sys) 
	: fNativeDevice(0), fSystem(sys), fTextFont(0), fMusicFont(0), fFillColor(255,255,255), fPenColor(0,0,0)
{
	cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
	fNativeDevice = cairo_create (surface);
	cairo_surface_destroy (surface);	
	SetFontColor( VGColor(0,0,0,ALPHA_OPAQUE) );
	SetFontBackgroundColor( VGColor(255,255,255,ALPHA_TRANSPARENT) );	// transparent
	SetFontAlign( kAlignLeft | kAlignBase );
}
예제 #3
0
// --------------------------------------------------------------
void GDeviceWin32::initialize(VGSystem* sys)
{
	SelectPen( VGColor(0,0,0,ALPHA_OPAQUE), 1);		//opaque black
	SelectFillColor( VGColor(0,0,0,ALPHA_OPAQUE) );	//opaque black
	SetFontColor( VGColor(0,0,0) );					//opaque black
	SetFontBackgroundColor( VGColor(255,255,255,ALPHA_TRANSPARENT) );	//transp. white
	SetFontAlign( kAlignLeft | kAlignBase );

	// guido hack - must be removed asap
	mSys = sys;
}
예제 #4
0
// --------------------------------------------------------------
void openFrameworksDevice::initialize()
{
    fXPos = fYPos = 0;
    fXOrigin = fYOrigin = 0;
    fLineThick = 1.0;
    fXScale = fYScale = 1.0f;
    fDPI = 72.f;
    fCurrentFont = 0;
    fFontAlign   = 0;
    fRasterOpMode = kOpCopy;
    fFillColorStack.push( VGColor(0,0,0) );
    fPenColorStack.push( VGColor(0,0,0) );
}
예제 #5
0
// --------------------------------------------------------------
VGColor
GDeviceWin32::GetFontColor() const
{
	//COLORREF c = GetTextColor( mHDC ); // COLORREF mask is 0x00bbggrr
	unsigned char c = (unsigned char)GetTextColor( mHDC ); // COLORREF mask is 0x00bbggrr
	return VGColor ( c & 0xff, c & 0xff00, c & 0xff0000);
}
예제 #6
0
void CairoDevice::PushPenColor( const VGColor & color)
{
	double r, g, b, a;
	cairo_pattern_get_rgba (cairo_get_source(fNativeDevice), &r, &g, &b, &a);	
	fPenColorStack.push (VGColor(cc2c(r), cc2c(g), cc2c(b), cc2c(a))); 
	SelectPenColor (color);
}
예제 #7
0
// --------------------------------------------------------------
VGColor
GDeviceWin32::GetFontBackgroundColor() const
{
	int mode = GetBkMode(mHDC);
//	COLORREF c = GetBkColor(mHDC);
	unsigned char c = (unsigned char)GetTextColor( mHDC ); // COLORREF mask is 0x00bbggrr
	return VGColor ( c & 0xff, c & 0xff00, c & 0xff0000, mode == TRANSPARENT ? ALPHA_TRANSPARENT : ALPHA_OPAQUE);
}
예제 #8
0
// --------------------------------------------------------------
void
GDeviceWin32::Rectangle( float left, float top, float right, float bottom )
{
	// first select a null width pen to avoid outlining
	PushPen(VGColor(0,0,0), 0);
	::Rectangle( mHDC, RInt(left)+1, RInt(top)+1, RInt(right)+1, RInt(bottom)+1 );
	PopPen();
}
예제 #9
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();
    }
}
예제 #10
0
ofxGuido::ofxGuido(int w, int h) :
	mARHandler(0), mGRHandler(0), mW(w), mH(h), mBackground(){
	mGuidoDevice = mGuidoSystem.CreateMemoryDevice(w, h);
	mGuidoDevice->SelectFillColor(VGColor(0, 0, 0));
	mGuidoInitDesc.graphicDevice = mGuidoDevice;
	mGuidoInitDesc.musicFont = "guido2t.ttf";
	mGuidoInitDesc.textFont = "guidotext.ttf";
	GuidoInit(&mGuidoInitDesc);
	GuidoGetDefaultLayoutSettings(&mGuidoLayoutSettings);
	mGuidoOnDrawDesc.hdc = mGuidoDevice;
	mGuidoParser = GuidoOpenParser();
	// Setup a large default format to avoid system breaks. They can also be avoided
	// by using the GMN advanced tag \set<autoSystemBreak="off">
	// Extra right margin makes room for the systems brace.
	GuidoPageFormat gpf = { 5000, 5000, 150, 100, 100, 100 }; // w, h, ml, mt, mr, mb
	GuidoSetDefaultPageFormat(&gpf);
	mBackground.set(0, 0, 0, 0);
}
예제 #11
0
// --------------------------------------------------------------
void
GDeviceWin32::Polygon( const float * xCoords, const float * yCoords, int count )
{
	if( count > mPtCount )
	{
		delete [] mPtArray;
		mPtArray = new POINT [ count ];
		if( mPtArray )
			mPtCount = count;
		else
			return;
	}

	for( int index = 0; index < count; index ++ )
	{
		mPtArray[ index ].x = RInt( xCoords[ index ] );
		mPtArray[ index ].y = RInt( yCoords[ index ] );
	}

	// first select a null width pen to avoid outlining
	PushPen(VGColor(0,0,0), 0);
	::Polygon( mHDC, mPtArray, count );
	PopPen();
}
예제 #12
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;
}