GUIDOLib  1.7.7
A Music Score Rendering Engine
VGDevice.h
Go to the documentation of this file.
1 #ifndef VGDevice_H
2 #define VGDevice_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2003--2006 Grame
7 
8  This Source Code Form is subject to the terms of the Mozilla Public
9  License, v. 2.0. If a copy of the MPL was not distributed with this
10  file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 
12  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
13  research@grame.fr
14 
15 */
16 
17 #include "VGColor.h"
18 
19 class VGFont;
20 class VGSystem;
21 
27 // --------------------------------------------------------------
28 // VGDevice class
29 // --------------------------------------------------------------
68 class VGDevice
69 {
70 
71  friend class VGFont; //to use GetNativeContext()
72  friend class DecoratorDevice;
73 
74  public:
75 
78  kUnknown = 0, // unknown mode, use default
79  kOpCopy = 1, // direct copy
80  kOpAnd = 2, // AND
81  kOpXOr = 4, // XOR = src invert
82  kOpInvert = 8, // dest invert
83  kOpOr = 16 // OR
84  };
85 
90  kAlignTop = 4,
92  kAlignLeft = 16,
95  };
96 
97  virtual ~VGDevice() {}
98 
100  virtual bool IsValid() const = 0;
101 
102 
103  // - Drawing services ------------------------------------------------
104 
108  virtual bool BeginDraw() = 0;
109 
113  virtual void EndDraw() = 0;
114 
117  virtual void InvalidateRect( float left, float top,
118  float right, float bottom ) = 0;
119 
120  // - Standard graphic primitives -------------------------
121 
123  virtual void MoveTo( float x, float y ) = 0;
124 
127  virtual void LineTo( float x, float y ) = 0;
128 
131  virtual void Line( float x1, float y1,
132  float x2, float y2 ) = 0;
133 
136  virtual void Frame( float left, float top,
137  float right, float bottom ) = 0;
138 
144  virtual void Arc( float left, float top,
145  float right, float bottom,
146  float startX, float startY,
147  float endX, float endY ) = 0;
148 
150  virtual void FrameEllipse( float x, float y, float width, float height) = 0;
151 
152  // - Filled surfaces --------------------------------------
153  // The raster op mode for color filling should be specified
154  // with SetRasterOpMode() before using one of these.
155 
157  virtual void Ellipse( float x, float y, float width, float height, const VGColor& color) = 0;
158 
162  virtual void Triangle( float x1, float y1,
163  float x2, float y2,
164  float x3, float y3 ) = 0;
165 
169  virtual void Polygon( const float * xCoords,
170  const float * yCoords, int count ) = 0;
171 
174  virtual void Rectangle( float left, float top,
175  float right, float bottom ) = 0;
176 
177  // - Font services ---------------------------------------------------
178 
182  virtual void SetMusicFont( const VGFont * font ) = 0;
183 
185  virtual const VGFont * GetMusicFont() const = 0;
186 
190  virtual void SetTextFont( const VGFont * font ) = 0;
191 
193  virtual const VGFont * GetTextFont() const = 0;
194 
196  virtual void selectfont(int) {};
197 
198 
199  // - Pen & brush services --------------------------------------------
200 
203  virtual void SelectPen( const VGColor & inColor,
204  float witdh ) = 0;
205 
209  virtual void SelectFillColor( const VGColor & c ) = 0;
210 
213  virtual void PushPen( const VGColor & inColor,
214  float inWidth ) = 0;
215 
218  virtual void PopPen() = 0;
219 
223  virtual void PushFillColor( const VGColor & inColor ) = 0;
224 
228  virtual void PopFillColor() = 0;
229 
235  virtual void SetRasterOpMode( VRasterOpMode ROpMode) = 0;
236 
240  virtual VRasterOpMode GetRasterOpMode() const = 0;
241 
242 
243  // - Bitmap services (bit-block copy methods) --------------------------
244 
251  virtual bool CopyPixels( VGDevice* pSrcDC, float alpha = -1.0) = 0;
252 
260  virtual bool CopyPixels( int xDest, int yDest,
261  VGDevice* pSrcDC,
262  int xSrc, int ySrc,
263  int nSrcWidth, int nSrcHeight, float alpha = -1.0) = 0;
264 
265  // only for \DrHoos and \DrRenz
273  virtual bool CopyPixels( int xDest, int yDest,
274  int dstWidth, int dstHeight,
275  VGDevice* pSrcDC, float alpha = -1.0) = 0;
276 
284  virtual bool CopyPixels( int xDest, int yDest,
285  int dstWidth, int dstHeight,
286  VGDevice* pSrcDC,
287  int xSrc, int ySrc,
288  int nSrcWidth, int nSrcHeight, float alpha = -1.0) = 0;
289 
290  // - Coordinate services ------------------------------------------------
291 
293  virtual void SetScale( float x, float y ) = 0;
294 
296  virtual void SetOrigin( float x, float y ) = 0;
297 
299  virtual void OffsetOrigin( float x, float y ) = 0;
300 
303  virtual void LogicalToDevice( float * x, float * y ) const = 0;
304 
307  virtual void DeviceToLogical( float * x, float * y ) const = 0;
308 
311  virtual float GetXScale() const = 0;
312  virtual float GetYScale() const = 0;
313  virtual float GetXOrigin() const = 0;
314  virtual float GetYOrigin() const = 0;
315 
319  virtual void NotifySize( int inWidth, int inHeight ) = 0;
320 
322  virtual int GetWidth() const = 0;
323 
325  virtual int GetHeight() const = 0;
326 
327 
328  // - Text and music symbols services -------------------------------------
329 
333  virtual void DrawMusicSymbol(float x, float y,
334  unsigned int inSymbolID ) = 0;
335 
339  virtual void DrawString( float x, float y,
340  const char * s,
341  int inCharCount ) = 0;
342 
344  virtual void SetFontColor( const VGColor & inColor ) = 0;
345 
347  virtual VGColor GetFontColor() const = 0;
348 
350  virtual void SetFontBackgroundColor( const VGColor & inColor ) = 0;
351 
353  virtual VGColor GetFontBackgroundColor() const = 0;
354 
357  virtual void SetFontAlign( unsigned int inAlign ) = 0;
358 
361  virtual unsigned int GetFontAlign() const = 0;
362 
363  // - Printer informations services ----------------------------------------
364 
366  virtual void SetDPITag( float inDPI ) = 0;
368  virtual float GetDPITag() const = 0;
369 
371  virtual void* GetBitMapPixels() = 0;
373  virtual void ReleaseBitMapPixels() = 0;
374 
376  virtual const char* GetImageData(const char* & outDataPtr, int& outLength) = 0;
378  virtual void ReleaseImageData(const char *) const = 0;
379 
381  virtual VGSystem * getVGSystem() const = 0;
382 
383  // - Data export services ----------------------------------------
385 // virtual void ExportToFile( const char * inFilePath ) = 0;
386 
387 
389  virtual void * GetNativeContext() const = 0;
390 
391 
392  public:
393 
394  // - VGDevice extension --------------------------------------------
396  virtual void SelectPenColor( const VGColor & inColor) = 0;
397 
399  virtual void SelectPenWidth( float witdh) = 0;
400 
401  virtual void PushPenColor( const VGColor & inColor) = 0;
402  virtual void PopPenColor() = 0;
403 
404  virtual void PushPenWidth( float width) = 0;
405  virtual void PopPenWidth() = 0;
406 
407 };
408 
411 #endif
VGDevice::Triangle
virtual void Triangle(float x1, float y1, float x2, float y2, float x3, float y3)=0
VGDevice::ReleaseImageData
virtual void ReleaseImageData(const char *) const =0
Release the pointer returned by GetImageData.
VGDevice::kOpOr
Definition: VGDevice.h:83
VGDevice::GetTextFont
virtual const VGFont * GetTextFont() const =0
Returns the currently selected text VGFont.
VGDevice::kAlignTop
Definition: VGDevice.h:90
VGDevice::EndDraw
virtual void EndDraw()=0
VGDevice::GetWidth
virtual int GetWidth() const =0
Returns the width (set via NotifySize) of the current VGDevice.
VGDevice::GetImageData
virtual const char * GetImageData(const char *&outDataPtr, int &outLength)=0
Gives the current device data and returns the data associated mime type.
VGDevice::PopPen
virtual void PopPen()=0
VGDevice::SetTextFont
virtual void SetTextFont(const VGFont *font)=0
VGDevice::GetNativeContext
virtual void * GetNativeContext() const =0
Exports all graphical data to an image file.
VGDevice::FrameEllipse
virtual void FrameEllipse(float x, float y, float width, float height)=0
Draws an ellipse.
VGDevice::GetFontColor
virtual VGColor GetFontColor() const =0
Returns the text/music color of the current VGDevice.
VGDevice::kAlignBase
Definition: VGDevice.h:88
VGDevice::MoveTo
virtual void MoveTo(float x, float y)=0
Moves the current position to the point specified by (x,y).
VGDevice::DecoratorDevice
friend class DecoratorDevice
Definition: VGDevice.h:72
VGDevice::GetXScale
virtual float GetXScale() const =0
VGDevice::PopPenColor
virtual void PopPenColor()=0
VGDevice::ReleaseBitMapPixels
virtual void ReleaseBitMapPixels()=0
Update bitmap pixels and ends pixels operations.
VGDevice::InvalidateRect
virtual void InvalidateRect(float left, float top, float right, float bottom)=0
VGDevice::SetFontBackgroundColor
virtual void SetFontBackgroundColor(const VGColor &inColor)=0
Sets the text/music background color for the current VGDevice.
VGDevice::GetDPITag
virtual float GetDPITag() const =0
Returns the printing resolution of the current VGDevice.
VGDevice::GetMusicFont
virtual const VGFont * GetMusicFont() const =0
Returns the currently selected music VGFont.
VGDevice::IsValid
virtual bool IsValid() const =0
Returns the ability of the current VGdevice to be drawn into.
VGDevice::VTextAlignMode
VTextAlignMode
Text alignment modes.
Definition: VGDevice.h:87
VGDevice::kAlignBaseLeft
Definition: VGDevice.h:94
VGDevice::BeginDraw
virtual bool BeginDraw()=0
VGDevice::kUnknown
Definition: VGDevice.h:78
VGDevice::PushPen
virtual void PushPen(const VGColor &inColor, float inWidth)=0
VGDevice::GetRasterOpMode
virtual VRasterOpMode GetRasterOpMode() const =0
VGDevice::GetFontAlign
virtual unsigned int GetFontAlign() const =0
VGDevice::GetXOrigin
virtual float GetXOrigin() const =0
VGDevice::PopPenWidth
virtual void PopPenWidth()=0
VGDevice::PushFillColor
virtual void PushFillColor(const VGColor &inColor)=0
VGDevice::SelectPenColor
virtual void SelectPenColor(const VGColor &inColor)=0
Creates a new VGPen object with the specified VGColor.
VGDevice::Ellipse
virtual void Ellipse(float x, float y, float width, float height, const VGColor &color)=0
Draws a filled ellipse.
VGDevice::SetScale
virtual void SetScale(float x, float y)=0
Sets the scale factors of the current VGDevice to the input values.
VGDevice::SelectFillColor
virtual void SelectFillColor(const VGColor &c)=0
VGDevice::GetHeight
virtual int GetHeight() const =0
Returns the height (set via NotifySize) of the current VGDevice.
VGDevice::SetMusicFont
virtual void SetMusicFont(const VGFont *font)=0
VGDevice::SelectPenWidth
virtual void SelectPenWidth(float witdh)=0
Creates a new VGPen object with the specified VGColor.
VGDevice::~VGDevice
virtual ~VGDevice()
Definition: VGDevice.h:97
VGSystem
Generic pure virtual class for manipulating platform independant drawing devices and fonts.
Definition: VGSystem.h:61
VGDevice::CopyPixels
virtual bool CopyPixels(VGDevice *pSrcDC, float alpha=-1.0)=0
VGDevice::SetFontColor
virtual void SetFontColor(const VGColor &inColor)=0
Sets the text/music color for the current VGDevice.
VGDevice::NotifySize
virtual void NotifySize(int inWidth, int inHeight)=0
VGDevice::LineTo
virtual void LineTo(float x, float y)=0
VGDevice::PopFillColor
virtual void PopFillColor()=0
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
VGColor
Generic class to manipulate device independant colors.
Definition: VGColor.h:34
VGDevice::kAlignRight
Definition: VGDevice.h:93
VGDevice::Frame
virtual void Frame(float left, float top, float right, float bottom)=0
VGDevice::kOpInvert
Definition: VGDevice.h:82
VGDevice::SetFontAlign
virtual void SetFontAlign(unsigned int inAlign)=0
VGDevice::VRasterOpMode
VRasterOpMode
Raster operation modes (color fill, bit copy, etc.)
Definition: VGDevice.h:77
VGDevice::GetFontBackgroundColor
virtual VGColor GetFontBackgroundColor() const =0
Returns the text/music background color of the current VGDevice.
VGDevice::PushPenColor
virtual void PushPenColor(const VGColor &inColor)=0
VGDevice::DeviceToLogical
virtual void DeviceToLogical(float *x, float *y) const =0
VGDevice::Rectangle
virtual void Rectangle(float left, float top, float right, float bottom)=0
VGDevice::GetYScale
virtual float GetYScale() const =0
VGDevice::PushPenWidth
virtual void PushPenWidth(float width)=0
VGDevice::OffsetOrigin
virtual void OffsetOrigin(float x, float y)=0
Offsets the current VGDevice's origin (see above).
VGDevice::SetRasterOpMode
virtual void SetRasterOpMode(VRasterOpMode ROpMode)=0
VGDevice::kAlignCenter
Definition: VGDevice.h:91
VGDevice::kAlignLeft
Definition: VGDevice.h:92
VGDevice::Arc
virtual void Arc(float left, float top, float right, float bottom, float startX, float startY, float endX, float endY)=0
VGDevice::GetYOrigin
virtual float GetYOrigin() const =0
VGDevice::SetDPITag
virtual void SetDPITag(float inDPI)=0
Sets the printing resolution of the current VGDevice.
VGDevice::kOpXOr
Definition: VGDevice.h:81
VGFont
Generic pure virtual & device-independant font class.
Definition: VGFont.h:36
VGDevice::LogicalToDevice
virtual void LogicalToDevice(float *x, float *y) const =0
VGDevice::getVGSystem
virtual VGSystem * getVGSystem() const =0
temporary hack - must be removed asap
VGDevice::DrawMusicSymbol
virtual void DrawMusicSymbol(float x, float y, unsigned int inSymbolID)=0
VGDevice::kOpCopy
Definition: VGDevice.h:79
VGDevice::Line
virtual void Line(float x1, float y1, float x2, float y2)=0
VGColor.h
VGDevice::kAlignBottom
Definition: VGDevice.h:89
VGDevice::SelectPen
virtual void SelectPen(const VGColor &inColor, float witdh)=0
VGDevice::GetBitMapPixels
virtual void * GetBitMapPixels()=0
Allows pixels operations and returns a pointer to the bitmap pixels.
VGDevice::selectfont
virtual void selectfont(int)
Selects a font (only for SVG device).
Definition: VGDevice.h:196
VGDevice::SetOrigin
virtual void SetOrigin(float x, float y)=0
Specifies which VGDevice point (x,y) maps to the window origin (0,0).
VGDevice::DrawString
virtual void DrawString(float x, float y, const char *s, int inCharCount)=0
VGDevice::Polygon
virtual void Polygon(const float *xCoords, const float *yCoords, int count)=0
VGDevice::kOpAnd
Definition: VGDevice.h:80

Guido Project Copyright © 2019 Grame-CNCM