class XGDraw

Declared in <XDraw.h>

This provides a universal interface for drawing inside of a view.

This is a stack based object; this object is generally created on a stack. To draw, a view creates this object on the stack and then calls events into it. (By being stack based, it means that when the stack unwinds, this will be destroyed and the resources will be released.)


Construction/Destruction

XGDraw::XGDraw
XGDraw::XGDraw
XGDraw::~XGDraw

State Support

XGDraw::GetDraw
XGDraw::GetFont
XGDraw::GetView

Resolution Support

XGDraw::GetResolution

Line Drawing Support

XGDraw::GetPenPos
XGDraw::LineTo
XGDraw::MoveTo

Oval Drawing

XGDraw::EraseOval
XGDraw::FrameOval
XGDraw::PaintOval

Arc Drawing

XGDraw::EraseArc
XGDraw::FrameArc
XGDraw::PaintArc

Rectangle Drawing

XGDraw::Draw3DRect
XGDraw::DrawFocusRect
XGDraw::EraseRect
XGDraw::FillRect
XGDraw::FillRect
XGDraw::FrameRect
XGDraw::InvertRect
XGDraw::PaintRect

Character Drawing

XGDraw::DrawString
XGDraw::DrawStringA
XGDraw::GetFontAscent
XGDraw::GetFontDescent
XGDraw::GetFontHeight
XGDraw::SetFont
XGDraw::StringWidth
XGDraw::StringWidthA

Image Support

XGDraw::DrawIcon
XGDraw::DrawPicture

Color Support

XGDraw::SetBackColor
XGDraw::SetForeColor

Pen Attributes

XGDraw::SetPenWidth

Clipping

XGDraw::ClipRect

Universal Internal Support

XGDraw::ColorFromPalette


Construction/Destruction

XGDraw::XGDraw

Usage: XGDraw::XGDraw(XGView*view,bool lc)

Construct a drawing object from the specified view. This is used to initiate drawing inside of a view.

XGDraw::XGDraw

Usage: XGDraw::XGDraw(XGPrinter*print)

Construct a drawing object for the printer. This is used to initiate drawing into a printer page.

XGDraw::~XGDraw

Usage: XGDraw::~XGDraw()

Destroy this, and restore drawing to the previous draw object

State Support

XGDraw::GetDraw

Usage: static XGDraw*GetDraw()

Returns the current XGDraw object; this is the thing that can be drawn in

XGDraw::GetFont

Usage: XGFont*GetFont()

Returns the current font selected into this drawing object. This increments the 'attach' count, so you must detach the font when done.

XGDraw::GetView

Usage: static XGView*GetView()

Returns the current XGView object being drawn into.

Resolution Support

XGDraw::GetResolution

Usage: Point XGDraw::GetResolution()

Returns the point resolution of the screen

Line Drawing Support

XGDraw::GetPenPos

Usage: Point XGDraw::GetPenPos(void)

Get the current pen location

XGDraw::LineTo

Usage: void XGDraw::LineTo(short x,short y)

Draw line from the pen cursor to the specified location, and updates the pen location.

XGDraw::MoveTo

Usage: void XGDraw::MoveTo(short x,short y)

Move the pen cursor to the specified location.

Oval Drawing

XGDraw::EraseOval

Usage: void XGDraw::EraseOval(Rect r)

Erase this oval. Erases a filled oval that fits within the boundaries of the provided rectangle.

XGDraw::FrameOval

Usage: void XGDraw::FrameOval(Rect r)

Frame this oval. Draws an oval outline that fits within the boundaries of the provided rectangle.

XGDraw::PaintOval

Usage: void XGDraw::PaintOval(Rect r)

Paint this oval. Draws an filled oval that fits within the boundaries of the provided rectangle.

Arc Drawing

XGDraw::EraseArc

Usage: void XGDraw::EraseArc(Rect r,short start,short length)

Erase an arc. Angles are specified in degrees similar to the Macintosh: clockwise from upright in degrees.

XGDraw::FrameArc

Usage: void XGDraw::FrameArc(Rect r,short start,short length)

Draw an arc. Angles are specified in degrees similar to the Macintosh: clockwise from upright in degrees.

XGDraw::PaintArc

Usage: void XGDraw::PaintArc(Rect r,short start,short length)

Fill an arc. Angles are specified in degrees similar to the Macintosh: clockwise from upright in degrees.

Rectangle Drawing

XGDraw::Draw3DRect

Usage: void XGDraw::Draw3DRect(Rect r,XGERectType type)

Draw the 3D rectangle using standard grays instead of the foreground and background colors

XGDraw::DrawFocusRect

Usage: void XGDraw::DrawFocusRect(Rect r)

Draws a focus rectangle. Used for indicating who has the focus. Note that this is an XOR drawing on Windows, but does _not_ XOR draw on X or the Mac.

XGDraw::EraseRect

Usage: void XGDraw::EraseRect(Rect r)

Erase the specified rectangle

XGDraw::FillRect

Usage: void XGDraw::FillRect(Rect r,Color c)

This quickly fills the rectangle with the specified color.

XGDraw::FillRect

Usage: void XGDraw::FillRect(short left,short top,short right,short bottom,Color c)

This quickly fills the rectangle defined by the four parameters with the specified color.

XGDraw::FrameRect

Usage: void XGDraw::FrameRect(Rect r)

This draws a framed rectangle

XGDraw::InvertRect

Usage: void XGDraw::InvertRect(Rect r)

Invert the specified rectangle.

XGDraw::PaintRect

Usage: void XGDraw::PaintRect(Rect r)

Paint the specified rectangle

Character Drawing

XGDraw::DrawString

Usage: void XGDraw::DrawString(const char*string,short len)

Draws a string. Either a zero-terminated string or by length

XGDraw::DrawStringA

Usage: void XGDraw::DrawStringA(const char*string,short len)

Draw with underscore. On the Macintosh this does not draw an underscore; this is not part of the Macintosh UI Guidelines. On Windows and X, this is a part of the guideline (as well as menu equivalents on windows and dialog boxes), so they are drawn.

XGDraw::GetFontAscent

Usage: short XGDraw::GetFontAscent()

Get the ascent of this font.

XGDraw::GetFontDescent

Usage: short XGDraw::GetFontDescent()

Get the descent of this font.

XGDraw::GetFontHeight

Usage: short XGDraw::GetFontHeight()

Get the total height of this font.

XGDraw::SetFont

Usage: void XGDraw::SetFont(XGFont*font)

This sets the current font for my drawing context. When a font is passed to me, I assume ownership of the font, and will detach it when done. This means if the code passing a font to me also wants to hang on to the font, it must explicitly do an attach as well.

XGDraw::StringWidth

Usage: short XGDraw::StringWidth(const char*string,short len)

Get the width of this string..

XGDraw::StringWidthA

Usage: short XGDraw::StringWidthA(const char*string,short len)

Handle string width with amperstand escape

Image Support

XGDraw::DrawIcon

Usage: void XGDraw::DrawIcon(short resID,short x,short y)

Draw an icon. This loads and draws the specified resource

XGDraw::DrawPicture

Usage: void XGDraw::DrawPicture(short resID,short x,short y)

Draw the picture. This is the same as above, except that this usually deals with pictures, stored as a separate data record

Color Support

XGDraw::SetBackColor

Usage: void XGDraw::SetBackColor(Color c)

Set background color. If this is a palette color, the color is converted to the proper RGB value first.

XGDraw::SetForeColor

Usage: void XGDraw::SetForeColor(Color c)

Set the foreground color. If this is a palette color, the color is converted to the proper RGB value first.

Pen Attributes

XGDraw::SetPenWidth

Usage: void XGDraw::SetPenWidth(short width)

Set the width of the pen to use for drawing

Clipping

XGDraw::ClipRect

Usage: void XGDraw::ClipRect(Rect*s)

Clip inside this rectangle. Allow the entire area if NULL. Does not work if the 'lc' flag is clear--like I care.

This also clips all the views that are children of my view.

Universal Internal Support

XGDraw::ColorFromPalette

Usage: Color XGDraw::ColorFromPalette(Color c)

If the palette color field is set, this gets the actual color