graphicscontext.h
来自「这是VCF框架的代码」· C头文件 代码 · 共 1,066 行 · 第 1/3 页
H
1,066 行
#ifndef _VCF_GRAPHICSCONTEXT_H__#define _VCF_GRAPHICSCONTEXT_H__//GraphicsContext.h/*Copyright 2000-2004 The VCF Project.Please see License.txt in the top level directorywhere you installed the VCF.*/#if _MSC_VER > 1000# pragma once#endif#ifndef AGG_RENDERING_BUFFER_INCLUDED#include "thirdparty/common/agg/include/agg_rendering_buffer.h"#endifnamespace VCF{class ContextPeer;class Image;class Fill;class Path;class Stroke;class Font;class DrawUIState;class MenuState;class ButtonState;class DisclosureButtonState;class ProgressState ;class SliderState;class ScrollBarState;class TabState;class BackgroundState;class TextState;class GraphicsState;/**\class GraphicsContext GraphicsContext.h "vcf/GraphicsKit/GraphicsContext.h"A GraphicsContext provides the lowest level graphics interface to thenative 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 orstrokeing the path(s) that result from the commands. Thus callingellipse() will not draw anything till the strokePath() or fillPath()methods have been called. All path commands should add their informationto a stack of some sort that is then looped through and executedusing the appropriate native graphics calls. At each path commanda test should be made as to whether the buffer should be cleared.The buffer should be cleared only after the stroke of fill methodshave been called. For example:\code 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\endcode@version 1.0@author Jim Crafton*/class GRAPHICSKIT_API GraphicsContext : public Object {public: GraphicsContext( ); /** Creates a new blank graphics context of the specified width and height */ GraphicsContext( const unsigned long& width, const unsigned long& 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. */ GraphicsContext( OSHandleID contextID ); virtual ~GraphicsContext( ); /** 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. */ enum DrawingOperation { doStroke, doFill, doText, doImage }; enum GraphicsDrawingState { gsNone = 0, gsAddingGraphicsOps, gsExecutingGraphicsOps }; /** text drawing options */ enum TextDrawingOptions{ tdoNone=0, tdoWordWrap=1, tdoLeftAlign=2, tdoCenterHorzAlign=4, tdoRightAlign=8, tdoBottomAlign=16, tdoCenterVertAlign=32, tdoTopAlign=64 }; 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 }; typedef std::vector<GraphicsState*> GraphicsStateCollection; typedef GraphicsStateCollection::iterator GraphicsStateIterator; typedef GraphicsStateCollection::const_iterator GraphicsStateConstIterator;public: void init( ); bool isAntiAliasingOn( ); void setAntiAliasingOn( bool antiAliasingOn ); /** sets the current font A copy of the Font is made when this is set @deprecated */ void setCurrentFont( Font * font ); /** sets the current font A copy of the Font is made when this is set */ void setCurrentFont( const Font * font ); /** returns the current Font */ Font* getCurrentFont( ); /** sets the current fill */ void setCurrentFill(Fill * fill ); /** sets the current stroke */ void setCurrentStroke(Stroke * stroke ); void setClippingRect( Rect* rect ); void setClippingPath( Path* clippingPath ); Rect getClippingRect( ); Path* getClippingPath( ); Rect getViewableBounds() { return viewableBounds_; } void setViewableBounds( const Rect& bounds ) { viewableBounds_ = bounds; } void setDrawingArea( Rect bounds ); void deleteDrawingArea( ); void flushDrawingArea( ); void markRenderAreaDirty() { renderAreaDirty_ = true; } bool isRenderAreaDirty() { if ( hasDrawingArea() ) { return renderAreaDirty_; } return false; } bool hasDrawingArea() { return NULL != drawingArea_; } Image* getDrawingArea() { return drawingArea_; } agg::rendering_buffer* getRenderingBuffer() { return renderBuffer_; } void setRenderingBuffer( agg::rendering_buffer* buffer ) { renderBuffer_ = buffer; } /** saves the state of a Graphics context after the paint operations are done. The save/restore idea idea is the same as for Win32 SaveDC and RestoreDC. It allows you to save the state of the DC (device context) at a given point in time, and then make a whole bunch of changes to it, and when you're all done just call RestoreDC() and everything is set back. This prevents all sorts of extra SelectObject() calls and is more efficent. Similarly this makes it easy to guarantee that the state of the GraphicsContext is reset correctly. @return int, the index of the newly saved graphics state. @see GraphicsContext::restoreState() */ int saveState( ); /** Restores the state of a Graphics context after the paint operations are done. @param int state, the index of the graphics state we want to restore. All the graphics states saved after this index are lost as they have lost meaning, and the current graphics state index is set to the state just restored. @see GraphicsContext::saveState() */ void restoreState( int state ); /** Sets the current color of the graphics context to use for filling or stroking paths. @deprecated */ void setColor( Color* color ); /** Sets the current color of the graphics context to use for filling or stroking paths. */ void setColor( const Color* color ); Color* getColor( ); void fillPath( ); void strokePath( ); ContextPeer* getPeer( ); void copyContext( const Rect& sourceRect, const Rect& destRect, GraphicsContext* context ); /** Sets the context's origin for drawing. The default is 0,0 in the top, left of the corner of screen real estate the context represents */ void setOrigin( const double& x, const double& y ); void setOrigin( const Point & pt ); Point getOrigin( ); /** sets the current rotation value of the transformation matrix. The theta argument is in degrees. */ void setRotation( const double& theta ); /** Set the x and y translation values for the transformation matrix. */ void setTranslation( const double transX, const double& transY ); /** Sets the x and y shear values, in degrees, for the transformation matrix */ void setShear( const double& shearX, const double& shearY ); /** Sets the x and y scale values for the transformation matrix. To double the size of drawn elements use a scaleX value of 2.0 and a scaleY value of 2.0. To flip the y coordinates use a scaleY of -1.0. */ void setScale( const double& scaleX, const double& scaleY ); 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 ); /** This test to see if the current rotation translation, scale, and shear values are all at their default values. */ bool isDefaultTransform( ); /** This (re)sets the current values for rotation, shear, scale, and translation to their default values. */ void makeDefaultTransform( ); double getRotation( ); double getTranslationX( ); double getTranslationY( ); double getShearX( );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?