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
State Support
Resolution Support
Line Drawing Support
Oval Drawing
Arc Drawing
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
Color Support
Pen Attributes
Clipping
Universal Internal Support
Construction/Destruction
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.
Usage: XGDraw::XGDraw(XGPrinter*print)
Construct a drawing object for the printer. This is used to initiate drawing into a printer page.
Usage: XGDraw::~XGDraw()
Destroy this, and restore drawing to the previous draw object
State Support
Usage: static XGDraw*GetDraw()
Returns the current XGDraw object; this is the thing that can be drawn in
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.
Usage: static XGView*GetView()
Returns the current XGView object being drawn into.
Resolution Support
Usage: Point XGDraw::GetResolution()
Returns the point resolution of the screen
Line Drawing Support
Usage: Point XGDraw::GetPenPos(void)
Get the current pen location
Usage: void XGDraw::LineTo(short x,short y)
Draw line from the pen cursor to the specified location, and updates the pen location.
Usage: void XGDraw::MoveTo(short x,short y)
Move the pen cursor to the specified location.
Oval Drawing
Usage: void XGDraw::EraseOval(Rect r)
Erase this oval. Erases a filled oval that fits within the boundaries of the provided rectangle.
Usage: void XGDraw::FrameOval(Rect r)
Frame this oval. Draws an oval outline that fits within the boundaries of the provided rectangle.
Usage: void XGDraw::PaintOval(Rect r)
Paint this oval. Draws an filled oval that fits within the boundaries of the provided rectangle.
Arc Drawing
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.
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.
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
Usage: void XGDraw::Draw3DRect(Rect r,XGERectType type)
Draw the 3D rectangle using standard grays instead of the foreground and background colors
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.
Usage: void XGDraw::EraseRect(Rect r)
Erase the specified rectangle
Usage: void XGDraw::FillRect(Rect r,Color c)
This quickly fills the rectangle with the specified color.
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.
Usage: void XGDraw::FrameRect(Rect r)
This draws a framed rectangle
Usage: void XGDraw::InvertRect(Rect r)
Invert the specified rectangle.
Usage: void XGDraw::PaintRect(Rect r)
Paint the specified rectangle
Character Drawing
Usage: void XGDraw::DrawString(const char*string,short len)
Draws a string. Either a zero-terminated string or by length
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.
Usage: short XGDraw::GetFontAscent()
Get the ascent of this font.
Usage: short XGDraw::GetFontDescent()
Get the descent of this font.
Usage: short XGDraw::GetFontHeight()
Get the total height of this font.
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.
Usage: short XGDraw::StringWidth(const char*string,short len)
Get the width of this string..
Usage: short XGDraw::StringWidthA(const char*string,short len)
Handle string width with amperstand escape
Image Support
Usage: void XGDraw::DrawIcon(short resID,short x,short y)
Draw an icon. This loads and draws the specified resource
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
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.
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
Usage: void XGDraw::SetPenWidth(short width)
Set the width of the pen to use for drawing
Clipping
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
Usage: Color XGDraw::ColorFromPalette(Color c)
If the palette color field is set, this gets the actual color