VCF::GraphicsContext Class Reference
A GraphicsContext provides the lowest level graphics interface to the native systems 2D drawing operations. More...
#include <vcf/GraphicsKit/GraphicsContext.h>
Inheritance diagram for VCF::GraphicsContext:

Public Types | |
| typedef std::vector< GraphicsState * > | GraphicsStateCollection |
| typedef GraphicsStateCollection::iterator | GraphicsStateIterator |
| typedef GraphicsStateCollection::const_iterator | GraphicsStateConstIterator |
| enum | DrawingOperation { doStroke, doFill, doText, doImage } |
| represents what kind of high level drawing operation we are performing. More... | |
| enum | GraphicsDrawingState { gsNone = 0, gsAddingGraphicsOps, gsExecutingGraphicsOps } |
| enum | TextDrawingOptions { tdoNone = 0, tdoWordWrap = 1, tdoLeftAlign = 2, tdoCenterHorzAlign = 4, tdoRightAlign = 8, tdoBottomAlign = 16, tdoCenterVertAlign = 32, tdoTopAlign = 64 } |
| text drawing options More... | |
| enum | EdgeType { etNoSides = 0x000, etLeftSide = 0x001, etRightSide = 0x002, etTopSide = 0x004, etBottomSide = 0x008, etAllSides = 0x00F, etRecessed = 0x010, etEtched = 0x020, etRaised = 0x030, etSunken = 0x040 } |
| enum | ThemeTextType { ttMenuItemFont = 0, ttSelectedMenuItemFont, ttSystemFont, ttSystemSmallFont, ttControlFont, ttMessageFont, ttToolTipFont } |
| enum | CompositingMode { cmNone = 0xFF, cmClear = 0, cmSource, cmDestination, cmSrcOver, cmDestOver, cmSrcIn, cmDestIn, cmSrcOut, cmDestOut, cmSrcATop, cmDestATop, cmXOR, cmPlus, cmMinus, cmMultiply, cmScreen, cmOverlay, cmDarken, cmLighten, cmColorDodge, cmColorBurn, cmHardLight, cmSoftLight, cmExclusion, cmDifference, cmContrast, cmCustom } |
| These are the set of standard compositing or "blend" modes that the GraphicsContext supports. More... | |
| enum | LineCapStyle { lcsButtCap = 0, lcsRoundCap, lcsSquareCap } |
| The set of enum values define the standard line cap style. More... | |
| enum | LineJoinStyle { ljsMiterJoin = 0, ljsRoundJoin, ljsBevelJoin } |
| The set of enum values for defining the line join style. More... | |
| enum | RenderAreaAlphaState { rasDefault = 0, rasNonDefaultAlphaVals, rasDirty } |
| Describes the state of the alpha channel. More... | |
Public Member Functions | |
| GraphicsContext () | |
| GraphicsContext (const uint32 &width, const uint32 &height) | |
| Creates a new blank graphics context of the specified width and height. | |
| GraphicsContext (OSHandleID contextID) | |
| Create a new context based on a context ID. | |
| virtual | ~GraphicsContext () |
| void | init () |
| This is going to be removed from the bext release. | |
| ContextPeer * | getPeer () |
| bool | isAntiAliasingOn () |
| void | setAntiAliasingOn (bool antiAliasingOn) |
| void | setCurrentFont (Font *font) |
| sets the current font A copy of the Font is made when this is set | |
| void | setCurrentFont (const Font *font) |
| sets the current font A copy of the Font is made when this is set | |
| Font * | getCurrentFont () |
| returns the current Font | |
| void | setCurrentFill (Fill *fill) |
| sets the current fill | |
| void | setCurrentStroke (Stroke *stroke) |
| sets the current stroke | |
| void | setClippingRect (Rect *rect) |
| void | setClippingPath (Path *clippingPath) |
| Rect | getClippingRect () |
| Path * | getClippingPath () |
| Rect | getViewableBounds () |
| void | setViewableBounds (const Rect &bounds) |
| void | setRenderArea (Rect bounds) |
| This method sets the image bounds for the drawing area image. | |
| void | deleteRenderArea () |
| This deletes the drawing area, and frees any resources associated with it. | |
| void | flushRenderArea () |
| Draws the drawing area image on to the graphics context. | |
| void | cacheRenderAreaAlpha () |
| void | resetRenderAreaAlpha () |
| bool | hasRenderArea () |
| void | renderAreaAlphaOverwritten () |
| void | setRenderAreaAlphaSize (bool usingNonDefaultAlpha) |
| Image * | getRenderArea () |
| agg::rendering_buffer * | getRenderingBuffer () |
| void | setRenderingBuffer (agg::rendering_buffer *buffer) |
| agg::scanline_u8 & | internal_getRenderAreaScanline () |
| int | saveState () |
| saves the state of a Graphics context after the paint operations are done. | |
| void | restoreState (int state) |
| Restores the state of a Graphics context after the paint operations are done. | |
| LineCapStyle | getLineCapStyle () |
| Returns the current line cap style. | |
| void | setLineCapStyle (LineCapStyle val) |
| Sets the line cap style. | |
| LineJoinStyle | getLineJoinStyle () |
| void | setLineJoinStyle (LineJoinStyle val) |
| double | getMiterLimit () |
| Returns the current miter limit. | |
| void | setMiterLimit (double val) |
| Sets the current miter limit. | |
| void | setCompositingMode (CompositingMode compositeMode) |
| Sets the current compositing mode. | |
| CompositingMode | getCompositingMode () |
| Returns the current composite mode. | |
| void | setColor (Color *color) |
| Sets the current color of the graphics context to use for filling or stroking paths. | |
| void | setColor (const Color *color) |
| Sets the current color of the graphics context to use for filling or stroking paths. | |
| Color * | getColor () |
| Image * | getAlphaMask () |
| void | setAlphaMask (Image *alphaMask) |
| void | setOrigin (const double &x, const double &y) |
| Sets the context's origin for drawing. | |
| void | setOrigin (const Point &pt) |
| Point | getOrigin () |
| void | setRotation (const double &theta) |
| sets the current rotation value of the transformation matrix. | |
| void | setTranslation (const double transX, const double &transY) |
| Set the x and y translation values for the transformation matrix. | |
| void | setShear (const double &shearX, const double &shearY) |
| Sets the x and y shear values, in degrees, for the transformation matrix. | |
| void | setScale (const double &scaleX, const double &scaleY) |
| Sets the x and y scale values for the transformation matrix. | |
| void | concatRotation (const double &theta) |
| void | concatTranslation (const double transX, const double &transY) |
| void | concatShear (const double &shearX, const double &shearY) |
| void | concatScale (const double &scaleX, const double &scaleY) |
| bool | isDefaultTransform () |
| This test to see if the current rotation translation, scale, and shear values are all at their default values. | |
| void | makeDefaultTransform () |
| This (re)sets the current values for rotation, shear, scale, and translation to their default values. | |
| double | getRotation () |
| double | getTranslationX () |
| double | getTranslationY () |
| double | getShearX () |
| double | getShearY () |
| double | getScaleX () |
| double | getScaleY () |
| bool | isXORModeOn () |
| void | setXORModeOn (const bool &XORModeOn) |
| void | setAlpha (const double &alpha) |
| double | getAlpha () |
| void | copyContext (const Rect &sourceRect, const Rect &destRect, GraphicsContext *context) |
| void | fillPath () |
| void | strokePath () |
| void | draw (Path *path) |
| draws a path. | |
| void | drawImage (const double &x, const double &y, Image *image, const bool &renderImmediately=true) |
| draws an image at the x,y, coordinates | |
| void | drawImage (const Point &pt, Image *image, const bool &renderImmediately=true) |
| void | bitBlit (const double &x, const double &y, Image *image) |
| "Blits" the image to the underlying graphics context. | |
| void | bitBlit (const Point &pt, Image *image) |
| void | bitBlit (const double &x, const double &y, Rect *imageBounds, Image *image) |
| void | bitBlit (const Point &pt, Rect *imageBounds, Image *image) |
| void | drawImageWithState (const double &x, const double &y, Image *image, const bool &enabled, const bool &renderImmediately=true) |
| draws an image at the x,y, coordinates, with state | |
| void | drawImageWithState (const Point &pt, Image *image, const bool &enabled, const bool &renderImmediately=true) |
| void | drawImageWithinBounds (Rect *bounds, Image *image, const bool &renderImmediately=true) |
| draws a portion of the image. | |
| void | drawPartialImage (const double &x, const double &y, Rect *imageBounds, Image *image, const bool &renderImmediately=true) |
| draws a partial image at the x,y, coordinates specified | |
| void | drawPartialImage (const Point &pt, Rect *imageBounds, Image *image, const bool &renderImmediately=true) |
| void | renderImages (bool freeImages=true) |
| void | setCurrentTransform (const Matrix2D &transform) |
| Matrix2D * | getCurrentTransform () |
| void | setStrokeWidth (const double &width) |
| End of high level gaphics functions. | |
| double | getStrokeWidth () |
| void | textAt (const double &x, const double &y, const String &text) |
| void | textAt (const Point &pt, const String &text) |
| void | textAt (const double &x, const double &y, const String &text, const int32 drawOptions) |
| void | textAt (const Point &pt, const String &text, const int32 drawOptions) |
| void | textWithStateAt (const double &x, const double &y, const String &text, const bool &enabled) |
| void | textWithStateAt (const Point &pt, const String &text, const bool &enabled) |
| void | textBoundedBy (Rect *bounds, const String &text, const bool &wordWrap=true) |
| draws text within the bounds specified. | |
| void | textBoundedBy (Rect *bounds, const String &text, const int32 drawOptions) |
| double | getTextWidth (const String &text) |
| double | getTextHeight (const String &text) |
| void | rectangle (const double &x1, const double &y1, const double &x2, const double &y2) |
| void | rectangle (const Rect &rc) |
| void | rectangle (const Point &pt1, const Point &pt2) |
| void | rectangle (Rect *r) |
| void | lineTo (const double &x, const double &y) |
| void | lineTo (const Point &pt) |
| void | moveTo (const double &x, const double &y) |
| void | moveTo (const Point &pt) |
| void | closePath (const double &x, const double &y) |
| void | closePath (const Point &pt) |
| void | roundRect (const double &x1, const double &y1, const double &x2, const double &y2, const double &xc, const double &yc) |
| void | roundRect (const Rect &rc, const Point &ptc) |
| void | roundRect (const Point &pt1, const Point &pt2, const Point &ptc) |
| void | roundRect (Rect *r, Point *p) |
| void | circle (const double &x, const double &y, const double &radius) |
| void | circle (const Point &pt, const double &radius) |
| void | ellipse (const double &x1, const double &y1, const double &x2, const double &y2) |
| void | ellipse (const Point &pt1, const Point &pt2) |
| void | arc (const double ¢erX, const double ¢erY, const double &radiusWidth, const double &radiusHeight, const double &startAngle, const double &endAngle) |
| void | arc (const Point ¢erPt, const Size &radius, const double &startAngle, const double &endAngle) |
| void | pie (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4) |
| void | pie (const Point &pt1, const Point &pt2, const Point &pt3, const Point &pt4) |
| void | chord (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4) |
| void | chord (const Point &pt1, const Point &pt2, const Point &pt3, const Point &pt4) |
| void | polyline (const std::vector< Point > &pts) |
| void | curve (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4) |
| void | curve (const Point &pt1, const Point &pt2, const Point &pt3, const Point &pt4) |
| void | drawThemeSelectionRect (Rect *rect, DrawUIState &state) |
| The following functions are related to theme compliant drawing. | |
| void | drawThemeFocusRect (Rect *rect, DrawUIState &state) |
| void | drawThemeButtonRect (Rect *rect, ButtonState &state, Rect *captionRect=NULL) |
| void | drawThemeButtonFocusRect (Rect *rect) |
| void | drawThemeCheckboxRect (Rect *rect, ButtonState &state) |
| void | drawThemeRadioButtonRect (Rect *rect, ButtonState &state) |
| void | drawThemeComboboxRect (Rect *rect, ButtonState &state) |
| void | drawThemeScrollButtonRect (Rect *rect, ScrollBarState &state) |
| void | drawThemeDisclosureButton (Rect *rect, DisclosureButtonState &state) |
| Draws a button that is used to open up more details, for example the button that opens up a tree node to reveal it's children, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeTab (Rect *rect, TabState &state) |
| Draws a tab, the part of the TabbedPages control that acts like a little button to activate a page, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeTabPage (Rect *rect, DrawUIState &state) |
| Draws a tab page - the page on which other controls for the page are parented to, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeTabContent (Rect *rect, DrawUIState &state) |
| void | drawThemeTabs (Rect *rect, DrawUIState &paneState, TabState &selectedTabState, TabState &otherTabs, const std::vector< String > &tabNames, int selectedTabIndex) |
| void | drawThemeTickMarks (Rect *rect, SliderState &state) |
| Draws tick marks, like that used for a slider control, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeSlider (Rect *rect, SliderState &state) |
| Draws a slider control, like that used for a slider control, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeProgress (Rect *rect, ProgressState &state) |
| Draws a progress bar control, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeImage (Rect *rect, Image *image, DrawUIState &state) |
| void | drawThemeHeader (Rect *rect, ButtonState &state) |
| Draws a header control that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeEdge (Rect *rect, DrawUIState &state, const int32 &edgeSides, const int32 &edgeStyle) |
| draws edges, useful for separators, that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeSizeGripper (Rect *rect, DrawUIState &state) |
| Draws a size gripper for resizing a control/window that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeBackground (Rect *rect, BackgroundState &state) |
| Draws a them compliant background. | |
| void | drawThemeMenuItem (Rect *rect, MenuState &state) |
| Draws the background appropriate for a menu item that is compliant with the native windowing systems default look and feel. | |
| void | drawThemeMenuItemText (Rect *rect, MenuState &state) |
| Draws the menu items text such that it's compliant with the native windowing platform look and feel. | |
| void | drawThemeText (Rect *rect, TextState &state) |
Protected Member Functions | |
| void | buildArc (double centerX, double centerY, double radiusWidth, double radiusHeight, double startAngle, double endAngle, std::vector< Point > &pts, const Matrix2D &transform) |
| void | buildRoundRect (double x1, double y1, double x2, double y2, double cornerArcWidth, double cornerArcHeight, std::vector< Point > &pts, const Matrix2D &transform) |
| void | buildEllipse (double x1, double y1, double x2, double y2, std::vector< Point > &pts, const Matrix2D &transform) |
| void | checkPathOperations () |
| void | execPathOperations () |
| void | renderImage (agg::rendering_buffer &destBuffer, Rect &destRect, ImageOperation &imgOp) |
| Rect | getRenderDestRect () |
| Rect | getTransformedImageRect (ImageOperation &imgOp) |
| Point | getTransformedImagePoint (ImageOperation &imgOp) |
Protected Attributes | |
| ContextPeer * | contextPeer_ |
| GraphicsDrawingState | currentDrawingState_ |
| std::vector< PointOperation > | pathOperations_ |
| std::vector< ImageOperation > | imageOperations_ |
| Rect | viewableBounds_ |
| RenderArea * | renderArea_ |
| GraphicsStateCollection | stateCollection_ |
| the collection of all the saved Graphics states. | |
| int | graphicsStateIndex_ |
| the index of the current state in the collection of all the saved Graphics states. | |
| GraphicsState * | currentGraphicsState_ |
| the current Graphics state that has been saved. | |
Classes | |
| struct | ImageOperation |
| struct | PointOperation |
Detailed Description
A GraphicsContext provides the lowest level graphics interface to the native systems 2D drawing operations.Based loosely on PostScript, a Context takes a series of of drawing operations, or commands (lineTo, moveTo, etc), and then executes them by either filling or strokeing the path(s) that result from the commands. Thus calling ellipse() will not draw anything till the strokePath() or fillPath() methods have been called. All path commands should add their information to a stack of some sort that is then looped through and executed using the appropriate native graphics calls. At each path command a test should be made as to whether the buffer should be cleared. The buffer should be cleared only after the stroke of fill methods have been called. For example:
ellipse(23,23,45,67) //added to buffer moveTo(89,100) //add to buffer lineTo(300,40) //add to buffer strokePath() fillPath() rectangle(200,300,400,400)//buffer cleared, then add to buffer
- Version:
- 1.0
- Author:
- Jim Crafton
Member Typedef Documentation
|
|
|
|
|
|
|
|
|
Member Enumeration Documentation
|
|
These are the set of standard compositing or "blend" modes that the GraphicsContext supports. The last mode, cmCustom, is for future use, and will allow some custom compositing function to be used. The blend/compositing modes below are the same as used in AGG and in the PDF specification. [todo] We should have some little pictures of what each blend mode looks like... [/todo] |
|
|
represents what kind of high level drawing operation we are performing. We can stroke a path, fill a path, draw an image, or draw text. This is used by the ConextPeer's prepareForDrawing() so it know's how best to prepare the low level graphics resources. For example strokePath() would call the ConextPeer's prepareForDrawing() and pass in GraphicsContext::doStroke, indicating that any upcoming calls to moveTo, lineTo, rectangle, etc will be drawn using the attributes of the GraphicsContext's stroke. |
|
|
|
|
|
|
|
|
The set of enum values define the standard line cap style. These are the same line cap styles that the PDF spec and Win32 uses. |
|
|
The set of enum values for defining the line join style. These values are the same as those found in the PDF spec and Win32. |
|
|
Describes the state of the alpha channel. The state is used to check whether or not the render area's alpha values have been accidentally overwritten by native GDI calls. If they have, we can then reset them back to 255, which is the default value. The default state is rasDefault, which means that all the render area's alpha values are at 0xFF (255). When the graphics context's drawing routine's are called they may, depending on the platform, overwrite the render area's alpha values. If this happens then the state must be set to rasDirty, indicating that the graphics context needs to reset the alpha values back to the original state before any drawing gets done that depends on accurate alpha values being present in the render area's buffer. If the alpha values of the render area have been modified by the programmer and need to be retained, then the default state should be changed from rasDefault to rasNonDefaultAlphaVals. |
|
|
text drawing options
|
|
|
|
Constructor & Destructor Documentation
|
|
|
|
||||||||||||
|
Creates a new blank graphics context of the specified width and height.
|
|
|
Create a new context based on a context ID. See ContextPeer getContextID() Doing this should caryy over any of the current settings of the context that the contextID represents. |
|
|
|
Member Function Documentation
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||
|
|
|
|
