📄 dc.tex
字号:
\section{\class{wxDC}}\label{wxdc}A wxDC is a {\it device context} onto which graphics and text can be drawn.It is intended to represent a number of output devices in a generic way,so a window can have a device context associated with it, and a printer also has a device context.In this way, the same piece of code may write to a number of different devices,if the device context is used as a parameter.Notice that wxDC is an abstract base class and can't be created directly,please use \helpref{wxPaintDC}{wxpaintdc}, \helpref{wxClientDC}{wxclientdc}, \helpref{wxWindowDC}{wxwindowdc}, \helpref{wxScreenDC}{wxscreendc}, \helpref{wxMemoryDC}{wxmemorydc} or \helpref{wxPrinterDC}{wxprinterdc}.% VZ: we should really document them instead of this lame excuse, but I don't% have time for it now, when it is done please remove thisPlease note that in addition to the versions of the methods documented here,there are also versions which accept single {\tt wxPoint} parameter instead oftwo {\tt wxCoord} ones or {\tt wxPoint} and {\tt wxSize} instead of four ofthem.\wxheading{Support for Transparency / Alpha Channel}On Mac OS X when using Core Graphics (wx\_MAC\_USE\_CORE\_GRAPHICS set to 1) colors with alpha are supported, so instances {\tt wxPen} or {\tt wxBrush} that are built from {\tt wxColour} usethe color's alpha values when stroking or filling.\wxheading{Derived from}\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/dc.h>\wxheading{See also}\helpref{Overview}{dcoverview}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxDC::Blit}\label{wxdcblit}\func{bool}{Blit}{\param{wxCoord}{ xdest}, \param{wxCoord}{ ydest}, \param{wxCoord}{ width}, \param{wxCoord}{ height}, \param{wxDC* }{source}, \param{wxCoord}{ xsrc}, \param{wxCoord}{ ysrc}, \param{int}{ logicalFunc = wxCOPY}, \param{bool }{useMask = false}, \param{wxCoord}{ xsrcMask = -1}, \param{wxCoord}{ ysrcMask = -1}}Copy from a source DC to this DC, specifying the destinationcoordinates, size of area to copy, source DC, source coordinates,logical function, whether to use a bitmap mask, and mask source position.\wxheading{Parameters}\docparam{xdest}{Destination device context x position.}\docparam{ydest}{Destination device context y position.}\docparam{width}{Width of source area to be copied.}\docparam{height}{Height of source area to be copied.}\docparam{source}{Source device context.}\docparam{xsrc}{Source device context x position.}\docparam{ysrc}{Source device context y position.}\docparam{logicalFunc}{Logical function to use: see \helpref{wxDC::SetLogicalFunction}{wxdcsetlogicalfunction}.}\docparam{useMask}{If true, Blit does a transparent blit using the mask that is associated with the bitmapselected into the source device context. The Windows implementation does the following if MaskBlt cannot be used:\begin{enumerate}\item Creates a temporary bitmap and copies the destination area into it.\item Copies the source area into the temporary bitmap using the specified logical function.\item Sets the masked area in the temporary bitmap to BLACK by ANDing themask bitmap with the temp bitmap with the foreground colour set to WHITEand the bg colour set to BLACK.\item Sets the unmasked area in the destination area to BLACK by ANDing themask bitmap with the destination area with the foreground colour set to BLACKand the background colour set to WHITE.\item ORs the temporary bitmap with the destination area.\item Deletes the temporary bitmap.\end{enumerate}This sequence of operations ensures that the source's transparent area need not be black,and logical functions are supported.{\bf Note:} on Windows, blitting with masks can be speeded up considerably by compilingwxWidgets with the wxUSE\_DC\_CACHE option enabled. You can also influence whether MaskBltor the explicit mask blitting code above is used, by using \helpref{wxSystemOptions}{wxsystemoptions} andsetting the {\bf no-maskblt} option to 1.}\docparam{xsrcMask}{Source x position on the mask. If both xsrcMask and ysrcMask are -1, xsrc and ysrcwill be assumed for the mask source position. Currently only implemented on Windows.}\docparam{ysrcMask}{Source y position on the mask. If both xsrcMask and ysrcMask are -1, xsrc and ysrcwill be assumed for the mask source position. Currently only implemented on Windows.}\wxheading{Remarks}There is partial support for Blit in wxPostScriptDC, under X.See \helpref{wxMemoryDC}{wxmemorydc} for typical usage.\wxheading{See also}\helpref{wxMemoryDC}{wxmemorydc}, \helpref{wxBitmap}{wxbitmap}, \helpref{wxMask}{wxmask}\begin{comment}\membersection{wxDC::CacheEnabled}\label{wxdccacheenabled}\func{static bool}{CacheEnabled}{\void}On supported platforms (currently only Windows), returns trueif the DC cache is enabled. The DC cachecan speed up the \helpref{Blit}{wxdcblit} operation whendrawing a large number of masked bitmaps.If using the cache functions in your code, please test for thewxUSE\_DC\_CACHEING preprocessor symbol for portability.\wxheading{See also}\helpref{wxDC::EnableCache}{wxdcenablecache}, \helpref{wxDC::ClearCache}\end{comment}\membersection{wxDC::CalcBoundingBox}\label{wxdccalcboundingbox}\func{void}{CalcBoundingBox}{\param{wxCoord }{x}, \param{wxCoord }{y}}Adds the specified point to the bounding box which can be retrieved with \helpref{MinX}{wxdcminx}, \helpref{MaxX}{wxdcmaxx} and \helpref{MinY}{wxdcminy}, \helpref{MaxY}{wxdcmaxy} functions.\wxheading{See also}\helpref{ResetBoundingBox}{wxdcresetboundingbox}\membersection{wxDC::Clear}\label{wxdcclear}\func{void}{Clear}{\void}Clears the device context using the current background brush.\begin{comment}\membersection{wxDC::ClearCache}\label{wxdcclearcache}\func{static void}{ClearCache}{\void}On supported platforms (currently only Windows), clearsthe contents of the DC cache (one bitmap and two Windows device contexts). The DC cachecan speed up the \helpref{Blit}{wxdcblit} operation whendrawing a large number of masked bitmaps. You shouldcall ClearCache at the end of length DC operations if you wish to only usethe cache transiently; you should also call it as your application exits.If using the cache functions in your code, please test for thewxUSE\_DC\_CACHEING preprocessor symbol for portability.\wxheading{See also}\helpref{wxDC::EnableCache}{wxdcenablecache}, \helpref{wxDC::CacheEnabled}\end{comment}\membersection{wxDC::ComputeScaleAndOrigin}\label{wxdccomputescaleandorigin}\func{virtual void}{ComputeScaleAndOrigin}{\void}Performs all necessary computations for given platform and context typeafter each change of scale and origin parameters. Usually called automatically internally after such changes.\membersection{wxDC::CrossHair}\label{wxdccrosshair}\func{void}{CrossHair}{\param{wxCoord}{ x}, \param{wxCoord}{ y}}Displays a cross hair using the current pen. This is a verticaland horizontal line the height and width of the window, centredon the given point.\membersection{wxDC::DestroyClippingRegion}\label{wxdcdestroyclippingregion}\func{void}{DestroyClippingRegion}{\void}Destroys the current clipping region so that none of the DC is clipped.See also \helpref{wxDC::SetClippingRegion}{wxdcsetclippingregion}.\membersection{wxDC::DeviceToLogicalX}\label{wxdcdevicetologicalx}\func{wxCoord}{DeviceToLogicalX}{\param{wxCoord}{ x}}Convert device X coordinate to logical coordinate, using the currentmapping mode.\membersection{wxDC::DeviceToLogicalXRel}\label{wxdcdevicetologicalxrel}\func{wxCoord}{DeviceToLogicalXRel}{\param{wxCoord}{ x}}Convert device X coordinate to relative logical coordinate, using the currentmapping mode but ignoring the x axis orientation.Use this function for converting a width, for example.\membersection{wxDC::DeviceToLogicalY}\label{wxdcdevicetologicaly}\func{wxCoord}{DeviceToLogicalY}{\param{wxCoord}{ y}}Converts device Y coordinate to logical coordinate, using the currentmapping mode.\membersection{wxDC::DeviceToLogicalYRel}\label{wxdcdevicetologicalyrel}\func{wxCoord}{DeviceToLogicalYRel}{\param{wxCoord}{ y}}Convert device Y coordinate to relative logical coordinate, using the currentmapping mode but ignoring the y axis orientation.Use this function for converting a height, for example.\membersection{wxDC::DrawArc}\label{wxdcdrawarc}\func{void}{DrawArc}{\param{wxCoord}{ x1}, \param{wxCoord}{ y1}, \param{wxCoord}{ x2}, \param{wxCoord}{ y2}, \param{wxCoord}{ xc}, \param{wxCoord}{ yc}}Draws an arc of a circle, centred on ({\it xc, yc}), with starting point ({\it x1, y1})and ending at ({\it x2, y2}). The current pen is used for the outlineand the current brush for filling the shape.The arc is drawn in an anticlockwise direction from the start point to the end point.\membersection{wxDC::DrawBitmap}\label{wxdcdrawbitmap}\func{void}{DrawBitmap}{\param{const wxBitmap\&}{ bitmap}, \param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{bool}{ transparent}}Draw a bitmap on the device context at the specified point. If {\it transparent} is true and the bitmap hasa transparency mask, the bitmap will be drawn transparently.When drawing a mono-bitmap, the current text foreground colour will be used to draw the foregroundof the bitmap (all bits set to 1), and the current text background colour to draw the background(all bits set to 0). See also \helpref{SetTextForeground}{wxdcsettextforeground}, \helpref{SetTextBackground}{wxdcsettextbackground} and \helpref{wxMemoryDC}{wxmemorydc}.\membersection{wxDC::DrawCheckMark}\label{wxdcdrawcheckmark}\func{void}{DrawCheckMark}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}\func{void}{DrawCheckMark}{\param{const wxRect \&}{rect}}Draws a check mark inside the given rectangle.\membersection{wxDC::DrawCircle}\label{wxdcdrawcircle}\func{void}{DrawCircle}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ radius}}\func{void}{DrawCircle}{\param{const wxPoint\&}{ pt}, \param{wxCoord}{ radius}}Draws a circle with the given centre and radius.\wxheading{See also}\helpref{DrawEllipse}{wxdcdrawellipse}\membersection{wxDC::DrawEllipse}\label{wxdcdrawellipse}\func{void}{DrawEllipse}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}\func{void}{DrawEllipse}{\param{const wxPoint\&}{ pt}, \param{const wxSize\&}{ size}}\func{void}{DrawEllipse}{\param{const wxRect\&}{ rect}}Draws an ellipse contained in the rectangle specified either with the given topleft corner and the given size or directly. The current pen is used for theoutline and the current brush for filling the shape.\wxheading{See also}\helpref{DrawCircle}{wxdcdrawcircle}\membersection{wxDC::DrawEllipticArc}\label{wxdcdrawellipticarc}\func{void}{DrawEllipticArc}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}, \param{double}{ start}, \param{double}{ end}}Draws an arc of an ellipse. The current pen is used for drawing the arc andthe current brush is used for drawing the pie.{\it x} and {\it y} specify the x and y coordinates of the upper-left corner of the rectangle that containsthe ellipse.{\it width} and {\it height} specify the width and height of the rectangle that containsthe ellipse.{\it start} and {\it end} specify the start and end of the arc relative to the three-o'clockposition from the center of the rectangle. Angles are specifiedin degrees (360 is a complete circle). Positive values meancounter-clockwise motion. If {\it start} is equal to {\it end}, acomplete ellipse will be drawn.\membersection{wxDC::DrawIcon}\label{wxdcdrawicon}\func{void}{DrawIcon}{\param{const wxIcon\&}{ icon}, \param{wxCoord}{ x}, \param{wxCoord}{ y}}Draw an icon on the display (does nothing if the device context is PostScript).This can be the simplest way of drawing bitmaps on a window.\membersection{wxDC::DrawLabel}\label{wxdcdrawlabel}\func{virtual void}{DrawLabel}{\param{const wxString\&}{ text}, \param{const wxBitmap\&}{ image}, \param{const wxRect\&}{ rect}, \param{int}{ alignment = wxALIGN\_LEFT | wxALIGN\_TOP}, \param{int}{ indexAccel = -1}, \param{wxRect *}{rectBounding = NULL}}\func{void}{DrawLabel}{\param{const wxString\&}{ text}, \param{const wxRect\&}{ rect}, \param{int}{ alignment = wxALIGN\_LEFT | wxALIGN\_TOP}, \param{int}{ indexAccel = -1}}Draw optional bitmap and the text into the given rectangle and aligns it as specifiedby alignment parameter; it also will emphasize the character with the given index ifit is != -1 and return the bounding rectangle if required.\membersection{wxDC::DrawLine}\label{wxdcdrawline}\func{void}{DrawLine}{\param{wxCoord}{ x1}, \param{wxCoord}{ y1}, \param{wxCoord}{ x2}, \param{wxCoord}{ y2}}Draws a line from the first point to the second. The current pen is usedfor drawing the line. Note that the point $(x2, y2)$ is {\emph not} part of theline and is not drawn by this function (this is consistent with the behaviourof many other toolkits).\membersection{wxDC::DrawLines}\label{wxdcdrawlines}\func{void}{DrawLines}{\param{int}{ n}, \param{wxPoint}{ points[]}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0}}\func{void}{DrawLines}{\param{wxList *}{points}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0}}Draws lines using an array of {\it points} of size {\it n}, or list ofpointers to points, adding the optional offset coordinate. The currentpen is used for drawing the lines. The programmer is responsible fordeleting the list of points.\pythonnote{The wxPython version of this method accepts a Python listof wxPoint objects.}\perlnote{The wxPerl version of this method accepts as its first parameter a reference to an array of wxPoint objects.}\membersection{wxDC::DrawPolygon}\label{wxdcdrawpolygon}\func{void}{DrawPolygon}{\param{int}{ n}, \param{wxPoint}{ points[]}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0},\\ \param{int }{fill\_style = wxODDEVEN\_RULE}}\func{void}{DrawPolygon}{\param{wxList *}{points}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0},\\ \param{int }{fill\_style = wxODDEVEN\_RULE}}Draws a filled polygon using an array of {\it points} of size {\it n},or list of pointers to points, adding the optional offset coordinate.The last argument specifies the fill rule: {\bf wxODDEVEN\_RULE} (thedefault) or {\bf wxWINDING\_RULE}.The current pen is used for drawing the outline, and the current brushfor filling the shape. Using a transparent brush suppresses filling.The programmer is responsible for deleting the list of points.Note that wxWidgets automatically closes the first and last points.\pythonnote{The wxPython version of this method accepts a Python listof wxPoint objects.}\perlnote{The wxPerl version of this method accepts as its first parameter a reference to an array of wxPoint objects.}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -