📄 dc.tex
字号:
\membersection{wxDC::DrawPolyPolygon}\label{wxdcdrawpolypolygon}\func{void}{DrawPolyPolygon}{\param{int}{ n}, \param{int}{ count[]}, \param{wxPoint}{ points[]}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0},\\ \param{int }{fill\_style = wxODDEVEN\_RULE}}Draws two or more filled polygons using an array of {\it points}, adding theoptional offset coordinates.Notice that for the platforms providing a native implementationof this function (Windows and PostScript-based wxDC currently), this is moreefficient than using \helpref{DrawPolygon}{wxdcdrawpolygon} in a loop.{\it n} specifies the number of polygons to draw, the array {\it count} of size {\it n} specifies the number of points in each of the polygons in the {\it points} array.The last argument specifies the fill rule: {\bf wxODDEVEN\_RULE} (the default)or {\bf wxWINDING\_RULE}.The current pen is used for drawing the outline, and the current brush forfilling the shape. Using a transparent brush suppresses filling.The polygons maybe disjoint or overlapping. Each polygon specified in a call to{\bf DrawPolyPolygon} must be closed. Unlike polygons created by the\helpref{DrawPolygon}{wxdcdrawpolygon} member function, the polygons created by{\bf DrawPolyPolygon} are not closed automatically.\pythonnote{Not implemented yet}\perlnote{Not implemented yet}\membersection{wxDC::DrawPoint}\label{wxdcdrawpoint}\func{void}{DrawPoint}{\param{wxCoord}{ x}, \param{wxCoord}{ y}}Draws a point using the color of the current pen. Note that the other properties of the pen are not used, such as width etc..\membersection{wxDC::DrawRectangle}\label{wxdcdrawrectangle}\func{void}{DrawRectangle}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}Draws a rectangle with the given top left corner, and with the givensize. The current pen is used for the outline and the current brushfor filling the shape.\membersection{wxDC::DrawRotatedText}\label{wxdcdrawrotatedtext}\func{void}{DrawRotatedText}{\param{const wxString\& }{text}, \param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{double}{ angle}}Draws the text rotated by {\it angle} degrees.{\bf NB:} Under Win9x only TrueType fonts can be drawn by this function. Inparticular, a font different from {\tt wxNORMAL\_FONT} should be used as thelatter is not a TrueType font. {\tt wxSWISS\_FONT} is an example of a fontwhich is.\wxheading{See also}\helpref{DrawText}{wxdcdrawtext}\membersection{wxDC::DrawRoundedRectangle}\label{wxdcdrawroundedrectangle}\func{void}{DrawRoundedRectangle}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}, \param{double}{ radius}}Draws a rectangle with the given top left corner, and with the givensize. The corners are quarter-circles using the given radius. Thecurrent pen is used for the outline and the current brush for fillingthe shape.If {\it radius} is positive, the value is assumed to be theradius of the rounded corner. If {\it radius} is negative,the absolute value is assumed to be the {\it proportion} of the smallestdimension of the rectangle. This means that the corner can bea sensible size relative to the size of the rectangle, and also avoidsthe strange effects X produces when the corners are too big forthe rectangle.\membersection{wxDC::DrawSpline}\label{wxdcdrawspline}\func{void}{DrawSpline}{\param{int }{n}, \param{wxPoint }{points[]}}Draws a spline between all given control points, using the currentpen.\func{void}{DrawSpline}{\param{wxList *}{points}}Draws a spline between all given control points, using the currentpen. Doesn't delete the wxList and contents.\func{void}{DrawSpline}{\param{wxCoord}{ x1}, \param{wxCoord}{ y1}, \param{wxCoord}{ x2}, \param{wxCoord}{ y2}, \param{wxCoord}{ x3}, \param{wxCoord}{ y3}}Draws a three-point spline using the current pen.\pythonnote{The wxPython version of this method accepts a Python listof wxPoint objects.}\perlnote{The wxPerl version of this method accepts a reference to an array of wxPoint objects.}\membersection{wxDC::DrawText}\label{wxdcdrawtext}\func{void}{DrawText}{\param{const wxString\& }{text}, \param{wxCoord}{ x}, \param{wxCoord}{ y}}Draws a text string at the specified point, using the current text font,and the current text foreground and background colours.The coordinates refer to the top-left corner of the rectangle boundingthe string. See \helpref{wxDC::GetTextExtent}{wxdcgettextextent} for howto get the dimensions of a text string, which can be used to position thetext more precisely.{\bf NB:} under wxGTK the current \helpref{logical function}{wxdcgetlogicalfunction} is used by this functionbut it is ignored by wxMSW. Thus, you should avoid using logical functionswith this function in portable programs.\begin{comment}\membersection{wxDC::EnableCache}\label{wxdcenablecache}\func{static void}{EnableCache}{\param{bool}{ enableCache}}On supported platforms (currently only Windows), enables the DC cachewhich can 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::CacheEnabled}{wxdccacheenabled}, \helpref{wxDC::ClearCache}\end{comment}\membersection{wxDC::EndDoc}\label{wxdcenddoc}\func{void}{EndDoc}{\void}Ends a document (only relevant when outputting to a printer).\membersection{wxDC::EndPage}\label{wxdcendpage}\func{void}{EndPage}{\void}Ends a document page (only relevant when outputting to a printer).\membersection{wxDC::FloodFill}\label{wxdcfloodfill}\func{bool}{FloodFill}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{const wxColour\&}{ colour}, \param{int}{ style=wxFLOOD\_SURFACE}}Flood fills the device context starting from the given point, usingthe {\it current brush colour}, and using a style:\begin{itemize}\itemsep=0pt\item wxFLOOD\_SURFACE: the flooding occurs until a colour other than the given colour is encountered.\item wxFLOOD\_BORDER: the area to be flooded is bounded by the given colour.\end{itemize}Returns false if the operation failed.{\it Note:} The present implementation for non-Windows platforms may fail to findcolour borders if the pixels do not match the colour exactly. However thefunction will still return true.\membersection{wxDC::GetBackground}\label{wxdcgetbackground}\constfunc{const wxBrush\&}{GetBackground}{\void}Gets the brush used for painting the background (see \helpref{wxDC::SetBackground}{wxdcsetbackground}).\membersection{wxDC::GetBackgroundMode}\label{wxdcgetbackgroundmode}\constfunc{int}{GetBackgroundMode}{\void}Returns the current background mode: {\tt wxSOLID} or {\tt wxTRANSPARENT}.\wxheading{See also}\helpref{SetBackgroundMode}{wxdcsetbackgroundmode}\membersection{wxDC::GetBrush}\label{wxdcgetbrush}\constfunc{const wxBrush\&}{GetBrush}{\void}Gets the current brush (see \helpref{wxDC::SetBrush}{wxdcsetbrush}).\membersection{wxDC::GetCharHeight}\label{wxdcgetcharheight}\func{wxCoord}{GetCharHeight}{\void}Gets the character height of the currently set font.\membersection{wxDC::GetCharWidth}\label{wxdcgetcharwidth}\func{wxCoord}{GetCharWidth}{\void}Gets the average character width of the currently set font.\membersection{wxDC::GetClippingBox}\label{wxdcgetclippingbox}\func{void}{GetClippingBox}{\param{wxCoord}{ *x}, \param{wxCoord}{ *y}, \param{wxCoord}{ *width}, \param{wxCoord}{ *height}}Gets the rectangle surrounding the current clipping region.\pythonnote{No arguments are required and the four values defining therectangle are returned as a tuple.}\perlnote{This method takes no arguments and returns a four element list{\tt ( x, y, width, height )}}\membersection{wxDC::GetFont}\label{wxdcgetfont}\constfunc{const wxFont\&}{GetFont}{\void}Gets the current font. Notice that even although each device context object hassome default font after creation, this method would return a \texttt{wxNullFont} initially and only after calling \helpref{wxDC::SetFont}{wxdcsetfont} a validfont is returned.\membersection{wxDC::GetLayoutDirection}\label{wxdcgetlayoutdirection}\constfunc{wxLayoutDirection}{GetLayoutDirection}{\void}Gets the current layout direction of the device context. On platforms where RTL layoutis supported, the return value will either be \texttt{wxLayout\_LeftToRight} or \texttt{wxLayout\_RightToLeft}. If RTL layout is not supported, the return value will be \texttt{wxLayout\_Default}.\wxheading{See also}\helpref{SetLayoutDirection}{wxdcsetlayoutdirection}\membersection{wxDC::GetLogicalFunction}\label{wxdcgetlogicalfunction}\func{int}{GetLogicalFunction}{\void}Gets the current logical function (see \helpref{wxDC::SetLogicalFunction}{wxdcsetlogicalfunction}).\membersection{wxDC::GetMapMode}\label{wxdcgetmapmode}\func{int}{GetMapMode}{\void}Gets the {\it mapping mode} for the device context (see \helpref{wxDC::SetMapMode}{wxdcsetmapmode}).\membersection{wxDC::GetMultiLineTextExtent}\label{wxdcgetmultilinetextextent}\constfunc{void}{GetMultiLineTextExtent}{\param{const wxString\& }{string}, \param{wxCoord *}{w},\\ \param{wxCoord *}{h}, \param{wxCoord *}{heightLine = NULL}, \param{wxFont *}{font = NULL}}\constfunc{wxSize}{GetMultiLineTextExtent}{\param{const wxString\& }{string}}Gets the dimensions of the string using the currently selected font.\rtfsp{\it string} is the text string to measure, {\it heightLine}, if non NULL,is where to store the height of a single line.The text extent is returned in {\it w} and {\it h} pointers (first form) or asa \helpref{wxSize}{wxsize} object (second form).If the optional parameter {\it font} is specified and valid, then it is usedfor the text extent calculation. Otherwise the currently selected font is.Note that this function works both with single-line and multi-line strings.\wxheading{See also}\helpref{wxFont}{wxfont},\rtfsp\helpref{wxDC::SetFont}{wxdcsetfont},\rtfsp\helpref{wxDC::GetPartialTextExtents}{wxdcgetpartialtextextents},\rtfsp\helpref{wxDC::GetTextExtent}{wxdcgettextextent}\membersection{wxDC::GetPartialTextExtents}\label{wxdcgetpartialtextextents}\constfunc{bool}{GetPartialTextExtents}{\param{const wxString\& }{text}, \param{wxArrayInt\& }{widths}}Fills the {\it widths} array with the widths from the beginning of {\it text} to the corresponding character of {\it text}. The genericversion simply builds a running total of the widths of each characterusing \helpref{GetTextExtent}{wxdcgettextextent}, however if thevarious platforms have a native API function that is faster or moreaccurate than the generic implementation then it should be usedinstead. \wxheading{See also}\helpref{wxDC::GetMultiLineTextExtent}{wxdcgetmultilinetextextent},\rtfsp\helpref{wxDC::GetTextExtent}{wxdcgettextextent}\pythonnote{This method only takes the {\it text} parameter and returns a Python list of integers.}\membersection{wxDC::GetPen}\label{wxdcgetpen}\constfunc{const wxPen\&}{GetPen}{\void}Gets the current pen (see \helpref{wxDC::SetPen}{wxdcsetpen}).\membersection{wxDC::GetPixel}\label{wxdcgetpixel}\func{bool}{GetPixel}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxColour *}{colour}}Gets in {\it colour} the colour at the specified location.Not available for wxPostScriptDC or wxMetafileDC.Note that setting a pixel can be done using \helpref{DrawPoint}{wxdcdrawpoint}.\pythonnote{For wxPython the wxColour value is returned and is notrequired as a parameter.}\perlnote{This method only takes the parameters {\tt x} and {\tt y} and returnsa Wx::Colour value}\membersection{wxDC::GetPPI}\label{wxdcgetppi}\constfunc{wxSize}{GetPPI}{\void}Returns the resolution of the device in pixels per inch.\membersection{wxDC::GetSize}\label{wxdcgetsize}\constfunc{void}{GetSize}{\param{wxCoord *}{width}, \param{wxCoord *}{height}}\constfunc{wxSize}{GetSize}{\void}This gets the horizontal and vertical resolution in device units. It can be used to scale graphics to fit the page.For example, if {\it maxX} and {\it maxY}\rtfsprepresent the maximum horizontal and vertical `pixel' values used in yourapplication, the following code will scale the graphic to fit on theprinter page:\begin{verbatim} wxCoord w, h; dc.GetSize(&w, &h); double scaleX=(double)(maxX/w); double scaleY=(double)(maxY/h); dc.SetUserScale(min(scaleX,scaleY),min(scaleX,scaleY));\end{verbatim}\pythonnote{In place of a single overloaded method name, wxPythonimplements the following methods:\par\indented{2cm}{\begin{twocollist}\twocolitem{{\bf GetSize()}}{Returns a wxSize}\twocolitem{{\bf GetSizeTuple()}}{Returns a 2-tuple (width, height)}\end{twocollist}}}\perlnote{In place of a single overloaded method, wxPerl uses:\par\indented{2cm}{\begin{twocollist}\twocolitem{{\bf GetSize()}}{Returns a Wx::Size}\twocolitem{{\bf GetSizeWH()}}{Returns a 2-element list {\tt ( width, height )}}\end{twocollist}}}\membersection{wxDC::GetSizeMM}\label{wxdcgetsizemm}\constfunc{void}{GetSizeMM}{\param{wxCoord *}{width}, \param{wxCoord *}{height}}\constfunc{wxSize}{GetSizeMM}{\void}Returns the horizontal and vertical resolution in millimetres.\membersection{wxDC::GetTextBackground}\label{wxdcgettextbackground}\constfunc{const wxColour\&}{GetTextBackground}{\void}Gets the current text background colour (see \helpref{wxDC::SetTextBackground}{wxdcsettextbackground}).\membersection{wxDC::GetTextExtent}\label{wxdcgettextextent}\constfunc{void}{GetTextExtent}{\param{const wxString\& }{string}, \param{wxCoord *}{w}, \param{wxCoord *}{h},\\ \param{wxCoord *}{descent = NULL}, \param{wxCoord *}{externalLeading = NULL}, \param{wxFont *}{font = NULL}}\constfunc{wxSize}{GetTextExtent}{\param{const wxString\& }{string}}Gets the dimensions of the string using the currently selected font.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -