GUIDOLib  1.7.7
Guido Engine Internal Documentation
NullGDevice.h
1 #ifndef NullGDevice_H
2 #define NullGDevice_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2004-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 
27 
28 #include "VGDevice.h"
29 #include "NullGFont.h"
30 
31 // --------------------------------------------------------------
32 class NullGDevice : public VGDevice
33 {
34  public:
36  : mSys(sys), mCurrTextFont("textFont", 10, 0), mCurrMusicFont("musicFont", 10, 0) {}
37  NullGDevice(VGSystem * sys, int inWidth, int inHeight )
38  : mSys(sys), mCurrTextFont("textFont", 10, 0), mCurrMusicFont("musicFont", 10, 0) {}
39  virtual ~NullGDevice() {}
40 
41  virtual bool IsValid() const { return true; }
42 
43  // - Drawing services ------------------------------------------------
44  virtual bool BeginDraw() { return true; }
45  virtual void EndDraw() {}
46  virtual void InvalidateRect( float left, float top, float right, float bottom ) {}
47 
48  // - Standard graphic primitives -------------------------
49  virtual void MoveTo( float x, float y ) {}
50  virtual void LineTo( float x, float y ) {}
51  virtual void Line( float x1, float y1, float x2, float y2 ) {}
52  virtual void Frame( float left, float top, float right, float bottom ) {}
53  virtual void Arc( float left, float top, float right, float bottom, float startX, float startY, float endX, float endY ) {}
54  virtual void FrameEllipse( float x, float y, float width, float height) {}
55 
56  // - Filled surfaces --------------------------------------
57  virtual void Ellipse( float x, float y, float width, float height, const VGColor& color) {}
58  virtual void Triangle( float x1, float y1, float x2, float y2, float x3, float y3 ) {}
59  virtual void Polygon( const float * xCoords, const float * yCoords, int count ) {}
60  virtual void Rectangle( float left, float top, float right, float bottom ) {}
61 
62  // - Font services ---------------------------------------------------
63  virtual void SetMusicFont( const VGFont * font ) {}
64  virtual const VGFont * GetMusicFont() const { return &mCurrMusicFont; }
65  virtual void SetTextFont( const VGFont * font ) {}
66  virtual const VGFont * GetTextFont() const { return &mCurrTextFont; }
67 
68  // - Pen & brush services --------------------------------------------
69  virtual void SelectPen( const VGColor & inColor, float width ) {}
70  virtual void SelectFillColor( const VGColor & c ) {}
71  virtual void PushPen( const VGColor & inColor, float inWidth ) {}
72  virtual void PopPen() {}
73  virtual void PushFillColor( const VGColor & inColor ) {}
74  virtual void PopFillColor() {}
75  virtual void SetRasterOpMode( VRasterOpMode ROpMode) {}
76  virtual VRasterOpMode GetRasterOpMode() const { return kOpCopy; }
77 
78  // - Bitmap services (bit-block copy methods) --------------------------
79  virtual bool CopyPixels( VGDevice* pSrcDC, float alpha = -1.0 ) { return true; }
80  virtual bool CopyPixels( int xDest, int yDest, VGDevice* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, float alpha = -1.0 ) { return true; }
81  virtual bool CopyPixels( int xDest, int yDest, int dstWidth, int dstHeight, VGDevice* pSrcDC, float alpha = -1.0 ) { return true; }
82  virtual bool CopyPixels( int xDest, int yDest, int dstWidth, int dstHeight, VGDevice* pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, float alpha = -1.0) { return true; }
83 
84  // - Coordinate services ------------------------------------------------
85  virtual void SetScale( float x, float y ) {}
86  virtual void SetOrigin( float x, float y ) {}
87  virtual void OffsetOrigin( float x, float y ) {}
88  virtual void LogicalToDevice( float * x, float * y ) const {}
89  virtual void DeviceToLogical( float * x, float * y ) const {}
90  virtual float GetXScale() const { return 1.f; }
91  virtual float GetYScale() const { return 1.f; }
92  virtual float GetXOrigin() const { return 0.f; }
93  virtual float GetYOrigin() const { return 0.f; }
94 
95  virtual void NotifySize( int inWidth, int inHeight ) {}
96  virtual int GetWidth() const { return 500; }
97  virtual int GetHeight() const { return 1000; }
98 
99  // - Text and music symbols services -------------------------------------
100  virtual void DrawMusicSymbol(float x, float y, unsigned int inSymbolID ) {}
101  virtual void DrawString( float x, float y, const char * s, int inCharCount ) {}
102  virtual void SetFontColor( const VGColor & inColor ) {}
103  virtual VGColor GetFontColor() const { return VGColor(50); }
104  virtual void SetFontBackgroundColor( const VGColor & inColor ) {}
105  virtual VGColor GetFontBackgroundColor() const { return VGColor(50); }
106  virtual void SetFontAlign( unsigned int inAlign ) {}
107  virtual unsigned int GetFontAlign() const { return kAlignBase; }
108 
109  // - Printer informations services ----------------------------------------
110  virtual void SetDPITag( float inDPI = 72.0f ) {}
111  virtual float GetDPITag() const { return 72.f; }
112  virtual void* GetBitMapPixels() { return 0; }
113  virtual void ReleaseBitMapPixels() {}
114 
116  virtual const char* GetImageData(const char* & outDataPtr, int& outLength) { outLength=0; return 0;}
118  virtual void ReleaseImageData(const char *) const {}
119 
121  virtual VGSystem * getVGSystem() const { return mSys; }
122 
123  protected:
125  virtual void * GetNativeContext() const { return 0; }
126 
127  private:
128  VGSystem* mSys;
129  NullGFont mCurrTextFont;
130  NullGFont mCurrMusicFont;
131 
132  public:
133  // VGDevice extension
134  virtual void SelectPenColor(const VGColor & inColor) {}
135  virtual void SelectPenWidth(float witdh) {}
136 
137  virtual void PushPenColor( const VGColor & inColor) {}
138  virtual void PopPenColor() {}
139 
140  virtual void PushPenWidth( float width) {}
141  virtual void PopPenWidth() {}
142 };
143 
144 
145 #endif
146 
147 
148 
NullGDevice::SetDPITag
virtual void SetDPITag(float inDPI=72.0f)
Sets the printing resolution of the current VGDevice.
Definition: NullGDevice.h:110
NullGDevice::OffsetOrigin
virtual void OffsetOrigin(float x, float y)
Offsets the current VGDevice's origin (see above).
Definition: NullGDevice.h:87
NullGDevice::GetDPITag
virtual float GetDPITag() const
Returns the printing resolution of the current VGDevice.
Definition: NullGDevice.h:111
NullGDevice::GetMusicFont
virtual const VGFont * GetMusicFont() const
Returns the currently selected music VGFont.
Definition: NullGDevice.h:64
NullGDevice::EndDraw
virtual void EndDraw()
Definition: NullGDevice.h:45
NullGDevice::SetFontColor
virtual void SetFontColor(const VGColor &inColor)
Sets the text/music color for the current VGDevice.
Definition: NullGDevice.h:102
NullGDevice::GetWidth
virtual int GetWidth() const
Returns the width (set via NotifySize) of the current VGDevice.
Definition: NullGDevice.h:96
NullGDevice::GetRasterOpMode
virtual VRasterOpMode GetRasterOpMode() const
Definition: NullGDevice.h:76
NullGDevice::PopPenWidth
virtual void PopPenWidth()
Definition: NullGDevice.h:141
NullGDevice::SetRasterOpMode
virtual void SetRasterOpMode(VRasterOpMode ROpMode)
Definition: NullGDevice.h:75
NullGDevice::ReleaseImageData
virtual void ReleaseImageData(const char *) const
Release the pointer returned by GetImageData.
Definition: NullGDevice.h:118
VGDevice::kAlignBase
Definition: VGDevice.h:88
NullGDevice::LogicalToDevice
virtual void LogicalToDevice(float *x, float *y) const
Definition: NullGDevice.h:88
NullGDevice::SelectPenWidth
virtual void SelectPenWidth(float witdh)
Creates a new VGPen object with the specified VGColor.
Definition: NullGDevice.h:135
NullGDevice::GetTextFont
virtual const VGFont * GetTextFont() const
Returns the currently selected text VGFont.
Definition: NullGDevice.h:66
NullGDevice::Line
virtual void Line(float x1, float y1, float x2, float y2)
Definition: NullGDevice.h:51
NullGDevice::NullGDevice
NullGDevice(VGSystem *sys)
Definition: NullGDevice.h:35
NullGDevice::SetScale
virtual void SetScale(float x, float y)
Sets the scale factors of the current VGDevice to the input values.
Definition: NullGDevice.h:85
NullGDevice::SelectPen
virtual void SelectPen(const VGColor &inColor, float width)
Definition: NullGDevice.h:69
NullGDevice::InvalidateRect
virtual void InvalidateRect(float left, float top, float right, float bottom)
Definition: NullGDevice.h:46
NullGDevice::SetOrigin
virtual void SetOrigin(float x, float y)
Specifies which VGDevice point (x,y) maps to the window origin (0,0).
Definition: NullGDevice.h:86
NullGDevice::DrawMusicSymbol
virtual void DrawMusicSymbol(float x, float y, unsigned int inSymbolID)
Definition: NullGDevice.h:100
NullGDevice::GetXOrigin
virtual float GetXOrigin() const
Definition: NullGDevice.h:92
NullGDevice::CopyPixels
virtual bool CopyPixels(int xDest, int yDest, int dstWidth, int dstHeight, VGDevice *pSrcDC, float alpha=-1.0)
Definition: NullGDevice.h:81
NullGDevice::Ellipse
virtual void Ellipse(float x, float y, float width, float height, const VGColor &color)
Draws a filled ellipse.
Definition: NullGDevice.h:57
NullGDevice::IsValid
virtual bool IsValid() const
Returns the ability of the current VGdevice to be drawn into.
Definition: NullGDevice.h:41
NullGDevice::GetBitMapPixels
virtual void * GetBitMapPixels()
Allows pixels operations and returns a pointer to the bitmap pixels.
Definition: NullGDevice.h:112
NullGDevice::LineTo
virtual void LineTo(float x, float y)
Definition: NullGDevice.h:50
NullGDevice::NullGDevice
NullGDevice(VGSystem *sys, int inWidth, int inHeight)
Definition: NullGDevice.h:37
NullGDevice::GetImageData
virtual const char * GetImageData(const char *&outDataPtr, int &outLength)
Gives the current device data and returns the data associated mime type.
Definition: NullGDevice.h:116
NullGDevice::CopyPixels
virtual bool CopyPixels(VGDevice *pSrcDC, float alpha=-1.0)
Definition: NullGDevice.h:79
NullGDevice::SetFontBackgroundColor
virtual void SetFontBackgroundColor(const VGColor &inColor)
Sets the text/music background color for the current VGDevice.
Definition: NullGDevice.h:104
NullGDevice::CopyPixels
virtual bool CopyPixels(int xDest, int yDest, VGDevice *pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, float alpha=-1.0)
Definition: NullGDevice.h:80
NullGDevice::SetMusicFont
virtual void SetMusicFont(const VGFont *font)
Definition: NullGDevice.h:63
NullGDevice::GetYScale
virtual float GetYScale() const
Definition: NullGDevice.h:91
NullGDevice::GetXScale
virtual float GetXScale() const
Definition: NullGDevice.h:90
NullGDevice::Polygon
virtual void Polygon(const float *xCoords, const float *yCoords, int count)
Definition: NullGDevice.h:59
NullGDevice::MoveTo
virtual void MoveTo(float x, float y)
Moves the current position to the point specified by (x,y).
Definition: NullGDevice.h:49
NullGDevice::PopFillColor
virtual void PopFillColor()
Definition: NullGDevice.h:74
NullGDevice::Rectangle
virtual void Rectangle(float left, float top, float right, float bottom)
Definition: NullGDevice.h:60
VGSystem
Generic pure virtual class for manipulating platform independant drawing devices and fonts.
Definition: VGSystem.h:61
NullGDevice::PopPenColor
virtual void PopPenColor()
Definition: NullGDevice.h:138
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
VGColor
Generic class to manipulate device independant colors.
Definition: VGColor.h:34
NullGDevice::Triangle
virtual void Triangle(float x1, float y1, float x2, float y2, float x3, float y3)
Definition: NullGDevice.h:58
NullGDevice::SelectPenColor
virtual void SelectPenColor(const VGColor &inColor)
Creates a new VGPen object with the specified VGColor.
Definition: NullGDevice.h:134
VGDevice::VRasterOpMode
VRasterOpMode
Raster operation modes (color fill, bit copy, etc.)
Definition: VGDevice.h:77
NullGDevice::FrameEllipse
virtual void FrameEllipse(float x, float y, float width, float height)
Draws an ellipse.
Definition: NullGDevice.h:54
NullGDevice
Definition: NullGDevice.h:32
NullGDevice::BeginDraw
virtual bool BeginDraw()
Definition: NullGDevice.h:44
NullGDevice::PushPenColor
virtual void PushPenColor(const VGColor &inColor)
Definition: NullGDevice.h:137
NullGDevice::CopyPixels
virtual bool CopyPixels(int xDest, int yDest, int dstWidth, int dstHeight, VGDevice *pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, float alpha=-1.0)
Definition: NullGDevice.h:82
NullGDevice::Frame
virtual void Frame(float left, float top, float right, float bottom)
Definition: NullGDevice.h:52
NullGDevice::GetFontColor
virtual VGColor GetFontColor() const
Returns the text/music color of the current VGDevice.
Definition: NullGDevice.h:103
NullGDevice::PushPen
virtual void PushPen(const VGColor &inColor, float inWidth)
Definition: NullGDevice.h:71
NullGDevice::SetFontAlign
virtual void SetFontAlign(unsigned int inAlign)
Definition: NullGDevice.h:106
NullGDevice::PushFillColor
virtual void PushFillColor(const VGColor &inColor)
Definition: NullGDevice.h:73
NullGDevice::GetFontBackgroundColor
virtual VGColor GetFontBackgroundColor() const
Returns the text/music background color of the current VGDevice.
Definition: NullGDevice.h:105
NullGDevice::ReleaseBitMapPixels
virtual void ReleaseBitMapPixels()
Update bitmap pixels and ends pixels operations.
Definition: NullGDevice.h:113
VGFont
Generic pure virtual & device-independant font class.
Definition: VGFont.h:36
NullGDevice::SetTextFont
virtual void SetTextFont(const VGFont *font)
Definition: NullGDevice.h:65
NullGDevice::Arc
virtual void Arc(float left, float top, float right, float bottom, float startX, float startY, float endX, float endY)
Definition: NullGDevice.h:53
NullGDevice::GetFontAlign
virtual unsigned int GetFontAlign() const
Definition: NullGDevice.h:107
NullGDevice::PushPenWidth
virtual void PushPenWidth(float width)
Definition: NullGDevice.h:140
NullGDevice::DeviceToLogical
virtual void DeviceToLogical(float *x, float *y) const
Definition: NullGDevice.h:89
NullGDevice::GetNativeContext
virtual void * GetNativeContext() const
Returns the platform-specific device context object.
Definition: NullGDevice.h:125
NullGDevice::getVGSystem
virtual VGSystem * getVGSystem() const
temporary hack - must be removed asap
Definition: NullGDevice.h:121
NullGDevice::GetHeight
virtual int GetHeight() const
Returns the height (set via NotifySize) of the current VGDevice.
Definition: NullGDevice.h:97
NullGDevice::GetYOrigin
virtual float GetYOrigin() const
Definition: NullGDevice.h:93
NullGDevice::PopPen
virtual void PopPen()
Definition: NullGDevice.h:72
VGDevice::kOpCopy
Definition: VGDevice.h:79
NullGDevice::SelectFillColor
virtual void SelectFillColor(const VGColor &c)
Definition: NullGDevice.h:70
NullGFont
Generic pure virtual & device-independant font class.
Definition: NullGFont.h:27
NullGDevice::~NullGDevice
virtual ~NullGDevice()
Definition: NullGDevice.h:39
NullGDevice::NotifySize
virtual void NotifySize(int inWidth, int inHeight)
Definition: NullGDevice.h:95
NullGDevice::DrawString
virtual void DrawString(float x, float y, const char *s, int inCharCount)
Definition: NullGDevice.h:101

Guido Project Copyright © 2019 Grame-CNCM