Vaca::Graphics Class Reference

#include <Graphics.h>

Inheritance diagram for Vaca::Graphics:

Vaca::NonCopyable Vaca::ScreenGraphics

List of all members.


Detailed Description

Class to control a graphics context.

Warning:
This is a Win32's HDC wrapper.

Public Member Functions

 Graphics (HDC hdc)
 Creates a Graphics context related to the specified HDC.
 Graphics (HDC hdc, Image &image)
 Graphics (Widget *widget)
virtual ~Graphics ()
void noPaint ()
 Indicates that the Graphics wasn't touched.
bool wasPainted ()
Rect getClipBounds ()
void getClipRegion (Region &rgn)
void setClipRegion (Region &rgn)
void excludeClipRect (const Rect &rc)
void excludeClipRegion (Region &rgn)
void intersectClipRect (const Rect &rc)
void intersectClipRegion (Region &rgn)
void addClipRegion (Region &rgn)
void xorClipRegion (Region &rgn)
bool isVisible (const Point &pt)
bool isVisible (const Rect &rc)
Font getFont () const
void setFont (Font font)
void getFontMetrics (FontMetrics &fontMetrics)
Color getPixel (const Point &pt)
Color getPixel (int x, int y)
void setPixel (const Point &pt, const Color &color)
void setPixel (int x, int y, const Color &color)
double getMiterLimit () const
void setMiterLimit (double limit)
FillRule getFillRule () const
void setFillRule (FillRule fillRule)
void tracePath (const GraphicsPath &path, const Point &pt)
void getPath (GraphicsPath &path) const
Region getRegionFromPath () const
void strokePath (const Pen &pen)
void fillPath (const Brush &brush)
void strokeAndFillPath (const Pen &pen, const Brush &brush)
void strokePath (const GraphicsPath &path, const Pen &pen, const Point &pt)
void fillPath (const GraphicsPath &path, const Brush &brush, const Point &pt)
void strokeAndFillPath (const GraphicsPath &path, const Pen &pen, const Brush &brush, const Point &pt)
void drawString (const String &str, const Color &color, const Point &pt)
void drawString (const String &str, const Color &color, int x, int y)
void drawString (const String &str, const Color &color, const Rect &rc, int flags=DT_WORDBREAK)
void drawDisabledString (const String &str, const Rect &rc, int flags=DT_WORDBREAK)
void drawImage (Image &image, int x, int y)
void drawImage (Image &image, int dstX, int dstY, int srcX, int srcY, int width, int height)
void drawImage (Image &image, int x, int y, const Color &bgColor)
void drawImage (Image &image, int dstX, int dstY, int srcX, int srcY, int width, int height, const Color &bgColor)
void drawImage (Image &image, const Point &pt)
void drawImage (Image &image, const Point &pt, const Rect &rc)
void drawImage (Image &image, const Point &pt, const Color &bgColor)
void drawImage (Image &image, const Point &pt, const Rect &rc, const Color &bgColor)
void drawImageList (ImageList &imageList, int imageIndex, int x, int y, int style)
 Draws the specified image of the ImageList.
void drawImageList (ImageList &imageList, int imageIndex, const Point &pt, int style)
void drawLine (const Pen &pen, const Point &pt1, const Point &pt2)
void drawLine (const Pen &pen, int x1, int y1, int x2, int y2)
void drawBezier (const Pen &pen, const Point points[4])
void drawBezier (const Pen &pen, const std::vector< Point > &points)
void drawBezier (const Pen &pen, const Point &pt1, const Point &pt2, const Point &pt3, const Point &pt4)
void drawBezier (const Pen &pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
void drawRect (const Pen &pen, const Rect &rc)
void drawRect (const Pen &pen, int x, int y, int w, int h)
void drawRoundRect (const Pen &pen, const Rect &rc, const Size &ellipse)
void drawRoundRect (const Pen &pen, int x, int y, int w, int h, int ellipseWidth, int ellipseHeight)
void draw3dRect (const Rect &rc, const Color &topLeft, const Color &bottomRight)
void draw3dRect (int x, int y, int w, int h, const Color &topLeft, const Color &bottomRight)
void drawEllipse (const Pen &pen, const Rect &rc)
 Draws the outline of an ellipse.
void drawEllipse (const Pen &pen, int x, int y, int w, int h)
void drawArc (const Pen &pen, const Rect &rc, double startAngle, double sweepAngle)
 Draws an arc with rc as a bounding rectangle for the ellipse that encloses the arc.
void drawArc (const Pen &pen, int x, int y, int w, int h, double startAngle, double sweepAngle)
void drawPie (const Pen &pen, const Rect &rc, double startAngle, double sweepAngle)
void drawPie (const Pen &pen, int x, int y, int w, int h, double startAngle, double sweepAngle)
void drawChord (const Pen &pen, const Rect &rc, double startAngle, double sweepAngle)
void drawChord (const Pen &pen, int x, int y, int w, int h, double startAngle, double sweepAngle)
void drawPolyline (const Pen &pen, const std::vector< Point > &points)
void fillRect (const Brush &brush, const Rect &rc)
void fillRect (const Brush &brush, int x, int y, int w, int h)
void fillRoundRect (const Brush &brush, const Rect &rc, const Size &ellipse)
void fillRoundRect (const Brush &brush, int x, int y, int w, int h, int ellipseWidth, int ellipseHeight)
void fillEllipse (const Brush &brush, const Rect &rc)
void fillEllipse (const Brush &brush, int x, int y, int w, int h)
void fillPie (const Brush &brush, const Rect &rc, double startAngle, double sweepAngle)
void fillPie (const Brush &brush, int x, int y, int w, int h, double startAngle, double sweepAngle)
void fillChord (const Brush &brush, const Rect &rc, double startAngle, double sweepAngle)
void fillChord (const Brush &brush, int x, int y, int w, int h, double startAngle, double sweepAngle)
void fillRegion (const Brush &brush, const Region &rgn)
void fillGradientRect (const Rect &rc, const Color &startColor, const Color &endColor, Orientation orientation)
void fillGradientRect (int x, int y, int w, int h, const Color &startColor, const Color &endColor, Orientation orientation)
void drawGradientRect (const Rect &rc, const Color &topLeft, const Color &topRight, const Color &bottomLeft, const Color &bottomRight)
void drawGradientRect (int x, int y, int w, int h, const Color &topLeft, const Color &topRight, const Color &bottomLeft, const Color &bottomRight)
void drawXorFrame (const Rect &rc, int border=3)
void drawXorFrame (int x, int y, int w, int h, int border=3)
void drawFocus (const Rect &rc)
Size measureString (const String &str, int fitInWidth=32767, int flags=DT_WORDBREAK)
void setRop2 (int drawMode)
 Changes the current raster operation mode (SetROP2).
HDC getHandle () const

Protected Member Functions

 Graphics ()
 Creates a Graphics context for the screen.

Private Member Functions

void initialize ()
void drawBezier (const Pen &pen, CONST POINT *lppt, int numPoints)
void drawBezierTo (const Pen &pen, CONST POINT *lppt, int numPoints)
void drawPolyline (const Pen &pen, CONST POINT *lppt, int numPoints)

Private Attributes

HDC m_handle
HPEN m_nullPen
HBRUSH m_nullBrush
bool m_autoRelease: 1
bool m_autoDelete: 1
bool m_noPaint: 1
Font m_font
FillRule m_fillRule

Friends

class Application

Constructor & Destructor Documentation

Graphics::Graphics (  )  [protected]

Creates a Graphics context for the screen.

Graphics::Graphics ( HDC  hdc  ) 

Creates a Graphics context related to the specified HDC.

Graphics::Graphics ( HDC  hdc,
Image image 
)

Graphics::Graphics ( Widget widget  ) 

Graphics::~Graphics (  )  [virtual]


Member Function Documentation

void Graphics::noPaint (  ) 

Indicates that the Graphics wasn't touched.

It's called by the default implementation of the Widget::onPaint.

bool Graphics::wasPainted (  ) 

Rect Graphics::getClipBounds (  ) 

void Graphics::getClipRegion ( Region rgn  ) 

void Graphics::setClipRegion ( Region rgn  ) 

void Graphics::excludeClipRect ( const Rect rc  ) 

void Graphics::excludeClipRegion ( Region rgn  ) 

void Graphics::intersectClipRect ( const Rect rc  ) 

void Graphics::intersectClipRegion ( Region rgn  ) 

void Graphics::addClipRegion ( Region rgn  ) 

void Graphics::xorClipRegion ( Region rgn  ) 

bool Graphics::isVisible ( const Point pt  ) 

bool Graphics::isVisible ( const Rect rc  ) 

Font Graphics::getFont (  )  const

void Graphics::setFont ( Font  font  ) 

void Graphics::getFontMetrics ( FontMetrics fontMetrics  ) 

Color Graphics::getPixel ( const Point pt  ) 

Color Graphics::getPixel ( int  x,
int  y 
)

void Graphics::setPixel ( const Point pt,
const Color color 
)

void Graphics::setPixel ( int  x,
int  y,
const Color color 
)

double Graphics::getMiterLimit (  )  const

void Graphics::setMiterLimit ( double  limit  ) 

FillRule Graphics::getFillRule (  )  const

void Graphics::setFillRule ( FillRule  fillRule  ) 

void Graphics::tracePath ( const GraphicsPath path,
const Point pt 
)

void Graphics::getPath ( GraphicsPath path  )  const

Region Graphics::getRegionFromPath (  )  const

void Graphics::strokePath ( const Pen pen  ) 

void Graphics::fillPath ( const Brush brush  ) 

void Graphics::strokeAndFillPath ( const Pen pen,
const Brush brush 
)

void Graphics::strokePath ( const GraphicsPath path,
const Pen pen,
const Point pt 
)

void Graphics::fillPath ( const GraphicsPath path,
const Brush brush,
const Point pt 
)

void Graphics::strokeAndFillPath ( const GraphicsPath path,
const Pen pen,
const Brush brush,
const Point pt 
)

void Graphics::drawString ( const String str,
const Color color,
const Point pt 
)

void Graphics::drawString ( const String str,
const Color color,
int  x,
int  y 
)

void Graphics::drawString ( const String str,
const Color color,
const Rect rc,
int  flags = DT_WORDBREAK 
)

void Graphics::drawDisabledString ( const String str,
const Rect rc,
int  flags = DT_WORDBREAK 
)

void Graphics::drawImage ( Image image,
int  x,
int  y 
)

void Graphics::drawImage ( Image image,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  width,
int  height 
)

void Graphics::drawImage ( Image image,
int  x,
int  y,
const Color bgColor 
)

void Graphics::drawImage ( Image image,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  width,
int  height,
const Color bgColor 
)

void Graphics::drawImage ( Image image,
const Point pt 
)

void Graphics::drawImage ( Image image,
const Point pt,
const Rect rc 
)

void Graphics::drawImage ( Image image,
const Point pt,
const Color bgColor 
)

void Graphics::drawImage ( Image image,
const Point pt,
const Rect rc,
const Color bgColor 
)

void Graphics::drawImageList ( ImageList imageList,
int  imageIndex,
int  x,
int  y,
int  style 
)

Draws the specified image of the ImageList.

Parameters:
imageList List of image to get the specified image.
imageIndex Specific image to draw. This must be a valid index of the image list. You can check the size of the ImageList using ImageList::getImageCount(), so the index must be between 0 and getImageCount-1.
x TODO
y TODO
style One of the following values:
  • ILD_BLEND25
  • ILD_FOCUS
  • ILD_BLEND50
  • ILD_SELECTED
  • ILD_BLEND
  • ILD_MASK
  • ILD_NORMAL
  • ILD_TRANSPARENT

void Graphics::drawImageList ( ImageList imageList,
int  imageIndex,
const Point pt,
int  style 
)

void Graphics::drawLine ( const Pen pen,
const Point pt1,
const Point pt2 
)

void Graphics::drawLine ( const Pen pen,
int  x1,
int  y1,
int  x2,
int  y2 
)

void Graphics::drawBezier ( const Pen pen,
const Point  points[4] 
)

void Graphics::drawBezier ( const Pen pen,
const std::vector< Point > &  points 
)

void Graphics::drawBezier ( const Pen pen,
const Point pt1,
const Point pt2,
const Point pt3,
const Point pt4 
)

void Graphics::drawBezier ( const Pen pen,
int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  x4,
int  y4 
)

void Graphics::drawRect ( const Pen pen,
const Rect rc 
)

void Graphics::drawRect ( const Pen pen,
int  x,
int  y,
int  w,
int  h 
)

void Graphics::drawRoundRect ( const Pen pen,
const Rect rc,
const Size ellipse 
)

void Graphics::drawRoundRect ( const Pen pen,
int  x,
int  y,
int  w,
int  h,
int  ellipseWidth,
int  ellipseHeight 
)

void Graphics::draw3dRect ( const Rect rc,
const Color topLeft,
const Color bottomRight 
)

void Graphics::draw3dRect ( int  x,
int  y,
int  w,
int  h,
const Color topLeft,
const Color bottomRight 
)

void Graphics::drawEllipse ( const Pen pen,
const Rect rc 
)

Draws the outline of an ellipse.

It uses the current selected color (see setColor), and doesn't paint the background.

void Graphics::drawEllipse ( const Pen pen,
int  x,
int  y,
int  w,
int  h 
)

void Graphics::drawArc ( const Pen pen,
const Rect rc,
double  startAngle,
double  sweepAngle 
)

Draws an arc with rc as a bounding rectangle for the ellipse that encloses the arc.

The arc start in the startAngle (a value between -360 and 360), and as a arc length of sweepAngle (in counter-clockwise).

void Graphics::drawArc ( const Pen pen,
int  x,
int  y,
int  w,
int  h,
double  startAngle,
double  sweepAngle 
)

void Graphics::drawPie ( const Pen pen,
const Rect rc,
double  startAngle,
double  sweepAngle 
)

void Graphics::drawPie ( const Pen pen,
int  x,
int  y,
int  w,
int  h,
double  startAngle,
double  sweepAngle 
)

void Graphics::drawChord ( const Pen pen,
const Rect rc,
double  startAngle,
double  sweepAngle 
)

void Graphics::drawChord ( const Pen pen,
int  x,
int  y,
int  w,
int  h,
double  startAngle,
double  sweepAngle 
)

void Graphics::drawPolyline ( const Pen pen,
const std::vector< Point > &  points 
)

void Graphics::fillRect ( const Brush brush,
const Rect rc 
)

void Graphics::fillRect ( const Brush brush,
int  x,
int  y,
int  w,
int  h 
)

void Graphics::fillRoundRect ( const Brush brush,
const Rect rc,
const Size ellipse 
)

void Graphics::fillRoundRect ( const Brush brush,
int  x,
int  y,
int  w,
int  h,
int  ellipseWidth,
int  ellipseHeight 
)

void Graphics::fillEllipse ( const Brush brush,
const Rect rc 
)

void Graphics::fillEllipse ( const Brush brush,
int  x,
int  y,
int  w,
int  h 
)

void Graphics::fillPie ( const Brush brush,
const Rect rc,
double  startAngle,
double  sweepAngle 
)

void Graphics::fillPie ( const Brush brush,
int  x,
int  y,
int  w,
int  h,
double  startAngle,
double  sweepAngle 
)

void Graphics::fillChord ( const Brush brush,
const Rect rc,
double  startAngle,
double  sweepAngle 
)

void Graphics::fillChord ( const Brush brush,
int  x,
int  y,
int  w,
int  h,
double  startAngle,
double  sweepAngle 
)

void Graphics::fillRegion ( const Brush brush,
const Region rgn 
)

void Graphics::fillGradientRect ( const Rect rc,
const Color startColor,
const Color endColor,
Orientation  orientation 
)

void Graphics::fillGradientRect ( int  x,
int  y,
int  w,
int  h,
const Color startColor,
const Color endColor,
Orientation  orientation 
)

void Graphics::drawGradientRect ( const Rect rc,
const Color topLeft,
const Color topRight,
const Color bottomLeft,
const Color bottomRight 
)

void Graphics::drawGradientRect ( int  x,
int  y,
int  w,
int  h,
const Color topLeft,
const Color topRight,
const Color bottomLeft,
const Color bottomRight 
)

void Graphics::drawXorFrame ( const Rect rc,
int  border = 3 
)

void Graphics::drawXorFrame ( int  x,
int  y,
int  w,
int  h,
int  border = 3 
)

void Graphics::drawFocus ( const Rect rc  ) 

Size Graphics::measureString ( const String str,
int  fitInWidth = 32767,
int  flags = DT_WORDBREAK 
)

Warning:
In Win98, 32767 is the limit for fitInWidth.

void Graphics::setRop2 ( int  drawMode  ) 

Changes the current raster operation mode (SetROP2).

Parameters:
drawMode 
  • R2_BLACK
  • R2_COPYPEN
  • R2_MASKNOTPEN
  • R2_MASKPEN
  • R2_MASKPENNOT
  • R2_MERGENOTPEN
  • R2_MERGEPEN
  • R2_MERGEPENNOT
  • R2_NOP
  • R2_NOT
  • R2_NOTCOPYPEN
  • R2_NOTMASKPEN
  • R2_NOTMERGEPEN
  • R2_NOTXORPEN
  • R2_WHITE
  • R2_XORPEN

HDC Graphics::getHandle (  )  const

void Graphics::initialize (  )  [private]

void Graphics::drawBezier ( const Pen pen,
CONST POINT *  lppt,
int  numPoints 
) [private]

void Graphics::drawBezierTo ( const Pen pen,
CONST POINT *  lppt,
int  numPoints 
) [private]

void Graphics::drawPolyline ( const Pen pen,
CONST POINT *  lppt,
int  numPoints 
) [private]


Friends And Related Function Documentation

friend class Application [friend]


Member Data Documentation

HDC Vaca::Graphics::m_handle [private]

HPEN Vaca::Graphics::m_nullPen [private]

HBRUSH Vaca::Graphics::m_nullBrush [private]

bool Vaca::Graphics::m_noPaint [private]