Faith::Painter Class Reference

Used for drawing things on a PaintDevice. More...

#include <faith/painter.h>

List of all members.

Public Types

 Auto
 LTR
 RTL
enum  TextDirection { Auto, LTR, RTL }

Public Member Functions

 Painter (PaintDevice *dest, const Widget *copyAttrib=0)
 Painter ()
 ~Painter ()
void save ()
void restore ()
void begin (PaintDevice *dest, const Widget *copyAttrib=0)
void end ()
Point xForm (const Point &pt)
Rect xForm (const Rect &pt)
Internal::Drawable * handle ()
void drawLine (int ax, int ay, int bx, int by)
void drawLine (const Point &a, const Point &b)
void drawPolygon (const std::vector< Faith::Point > &points, int start=0, int count=-1)
void drawPolygon (int count, const Faith::Point *points)
void drawText (const Point &p, const String &str, int pos=0, int len=-1, TextDirection dir=Auto)
void drawText (int x, int y, const String &str, int pos=0, int len=-1, TextDirection dir=Auto)
void drawText (const Rect &rect, int textflags, const String &str, int pos=0, int len=-1)
void drawText (int x, int y, int w, int h, int textflags, const String &str, int pos=0, int len=-1)
void fillRect (const Rect &rect, const Color &color)
void fillRect (int x, int y, int w, int h, const Color &color)
void drawImage (const Point &p, const Image &image, int fromx=0, int fromy=0, int w=-1, int h=-1)
void drawImage (int x, int y, const Image &image, int fromx=0, int fromy=0, int w=-1, int h=-1)
void drawImage (const Image &image, int fromx=0, int fromy=0, int w=-1, int h=-1)
void drawPixmap (const Point &p, const Faith::Pixmap &pixmap, int fromx=0, int fromy=0, int w=-1, int h=-1)
void drawPixmap (int x, int y, const Faith::Pixmap &pixmap, int fromx=0, int fromy=0, int w=-1, int h=-1)
void drawPixmap (const Faith::Pixmap &pixmap, int fromx=0, int fromy=0, int w=-1, int h=-1)
void drawPoint (const Point &pt)
void drawPoint (int x, int y)
void setBackground (const Color &color)
Color background () const
void setFont (const Font &font)
Font font () const
void setPen (const Pen &pen)
Pen pen () const
void setOrigin (const Point &point)
void setOrigin (int x, int y)
Point origin () const
void setClipRectangle (const Rect &rectangle)
Rect clipRectangle () const
void setClipping (bool c)
bool isClipping () const


Detailed Description

Used for drawing things on a PaintDevice.

Has various classes for drawing things on a Widget or a Pixmap (any PaintDevice)

This should be called from Widget::paintEvent if used to draw on a Widget


Member Enumeration Documentation

enum Faith::Painter::TextDirection

which way do you want to draw the text? Auto guesses by means of charset, RTL does Right to Left, like Hebrew LTR does Left to Right, like Latin

Enumerator:
Auto 
LTR 
RTL 


Constructor & Destructor Documentation

Faith::Painter::Painter ( PaintDevice dest,
const Widget copyAttrib = 0 
)

Draw on the PaintDevice dest , adopting background colors and other properties from copyAttrib if specified

Faith::Painter::Painter (  ) 

Faith::Painter::~Painter (  ) 


Member Function Documentation

Color Faith::Painter::background (  )  const

Returns:
the background color as set by setBackground

void Faith::Painter::begin ( PaintDevice dest,
const Widget copyAttrib = 0 
)

Begins painting on the given device.

If you pass it a copyAttrib, it will take the background color and such of it, which is useful for double buffering

Rect Faith::Painter::clipRectangle (  )  const

Returns:
the clipping rectangle as set by setClipRectangle

void Faith::Painter::drawImage ( const Image image,
int  fromx = 0,
int  fromy = 0,
int  w = -1,
int  h = -1 
) [inline]

Draws the image at the origin of the destination

void Faith::Painter::drawImage ( int  x,
int  y,
const Image image,
int  fromx = 0,
int  fromy = 0,
int  w = -1,
int  h = -1 
) [inline]

Same as the above but accepts different argument types

void Faith::Painter::drawImage ( const Point p,
const Image image,
int  fromx = 0,
int  fromy = 0,
int  w = -1,
int  h = -1 
)

Draws image where its top left is at the point p

The relative of the source can also by specified with x, y, , w, h

void Faith::Painter::drawLine ( const Point a,
const Point b 
)

Draws a line from the point a to the point b, including the last pixel

void Faith::Painter::drawLine ( int  ax,
int  ay,
int  bx,
int  by 
) [inline]

Draws a line from the point (ax,bx) to the point (bx,by), including the last pixel

void Faith::Painter::drawPixmap ( const Faith::Pixmap pixmap,
int  fromx = 0,
int  fromy = 0,
int  w = -1,
int  h = -1 
) [inline]

Same as the above but accepts different argument types

void Faith::Painter::drawPixmap ( int  x,
int  y,
const Faith::Pixmap pixmap,
int  fromx = 0,
int  fromy = 0,
int  w = -1,
int  h = -1 
) [inline]

Same as the above but accepts different argument types

void Faith::Painter::drawPixmap ( const Point p,
const Faith::Pixmap pixmap,
int  fromx = 0,
int  fromy = 0,
int  w = -1,
int  h = -1 
)

Copies a pixmap instead of an image, but otherwise behaves the same as the drawImage functions

If pixmap has just one-bit-per-pixel (is a Bitmap), then it will be drawn in foreground and background colors instead of the colors in the bitmap

void Faith::Painter::drawPoint ( int  x,
int  y 
) [inline]

Same as the above but accepts different argument types

void Faith::Painter::drawPoint ( const Point pt  ) 

Draws with the pen at the given point

void Faith::Painter::drawPolygon ( int  count,
const Faith::Point points 
)

Just like the above but takes different argument types for convenience.

void Faith::Painter::drawPolygon ( const std::vector< Faith::Point > &  points,
int  start = 0,
int  count = -1 
)

Draws a filled polygon of all the given points, connecting the point one to the first point. The fill color is the current background color.

Parameters:
start begins at points[start]
count finishes at points[start+count-1]

void Faith::Painter::drawText ( int  x,
int  y,
int  w,
int  h,
int  textflags,
const String str,
int  pos = 0,
int  len = -1 
) [inline]

The above function with different parameter types

void Faith::Painter::drawText ( const Rect rect,
int  textflags,
const String str,
int  pos = 0,
int  len = -1 
)

Draws the text enclosed in this rectangle (not related to baseline. Will clip, will not word wrap

void Faith::Painter::drawText ( int  x,
int  y,
const String str,
int  pos = 0,
int  len = -1,
TextDirection  dir = Auto 
) [inline]

Like the above, but accepts different argument types

void Faith::Painter::drawText ( const Point p,
const String str,
int  pos = 0,
int  len = -1,
TextDirection  dir = Auto 
)

Draws the string str at the given point, where you are specifying the baseline of

void Faith::Painter::end (  ) 

Stops drawing on the set PaintDevice

void Faith::Painter::fillRect ( int  x,
int  y,
int  w,
int  h,
const Color color 
) [inline]

The same as the above function with different argument types

void Faith::Painter::fillRect ( const Rect rect,
const Color color 
)

Fills the rectangle rect with color

Font Faith::Painter::font (  )  const

Returns:
the font as set by setFont

Internal::Drawable* Faith::Painter::handle (  ) 

a handle to the graphics device context

bool Faith::Painter::isClipping (  )  const

Returns:
whether or not clipping is enabled, as set by setClipping

Point Faith::Painter::origin (  )  const

Same as the above but accepts different argument types

Pen Faith::Painter::pen (  )  const

Returns:
the pen as set by setPen

void Faith::Painter::restore (  ) 

pop the current settings for this Painter off a stack, restoring the settings as they were immediately before calling

See also:
save

void Faith::Painter::save (  ) 

push the current settings for this Painter onto a stack, so if you need to change modes, you won't contaminate the painter Once you're done with your changed painter, call

See also:
restore()
all functions which change the state of this class are handled by save, unless otherwise specified

void Faith::Painter::setBackground ( const Color color  ) 

Sets the background color used for fills

void Faith::Painter::setClipping ( bool  c  ) 

if clipping is enabled

void Faith::Painter::setClipRectangle ( const Rect rectangle  ) 

sets the region of clipping for when you draw. Painting on the region outside of this rectangle simply has no effect

void Faith::Painter::setFont ( const Font font  ) 

Sets the font as used by the drawText functions

void Faith::Painter::setOrigin ( int  x,
int  y 
) [inline]

Same as the above but accepts different argument types

void Faith::Painter::setOrigin ( const Point point  ) 

sets the position of (0,0) on the destination device.

 p.setOrigin(Point(5,5));
 p.drawPoint(0,0);
	 *

has the same effect as:

 p.drawPoint(5,5);
	 *

void Faith::Painter::setPen ( const Pen pen  ) 

set the pen - the color lines and points are drawn with, in addition to the borders of shapes (and more!)

Rect Faith::Painter::xForm ( const Rect pt  ) 

Point Faith::Painter::xForm ( const Point pt  ) 


The documentation for this class was generated from the following file:
Generated on Fri Sep 1 00:23:09 2006 for Faith by  doxygen 1.4.7