dc.tex

来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 1,124 行 · 第 1/3 页

TEX
1,124
字号
or list of pointers to points, adding the optional offset coordinate.

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
for 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 list
of wxPoint objects.}

\perlnote{The wxPerl version of this method accepts 
  as its first parameter a reference to an array
  of wxPoint objects.}


\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 the
optional offset coordinates.

Notice that for the platforms providing a native implementation
of this function (Windows and PostScript-based wxDC currently), this is more
efficient 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 for
filling 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 given
size.  The current pen is used for the outline and the current brush
for 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. In
particular, a font different from {\tt wxNORMAL\_FONT} should be used as the
latter is not a TrueType font. {\tt wxSWISS\_FONT} is an example of a font
which 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 given
size.  The corners are quarter-circles using the given radius. The
current pen is used for the outline and the current brush for filling
the shape.

If {\it radius} is positive, the value is assumed to be the
radius of the rounded corner. If {\it radius} is negative,
the absolute value is assumed to be the {\it proportion} of the smallest
dimension of the rectangle. This means that the corner can be
a sensible size relative to the size of the rectangle, and also avoids
the strange effects X produces when the corners are too big for
the 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 current
pen.

\func{void}{DrawSpline}{\param{wxList *}{points}}

Draws a spline between all given control points, using the current
pen.  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 list
of 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 bounding
the string. See \helpref{wxDC::GetTextExtent}{wxdcgettextextent} for how
to get the dimensions of a text string, which can be used to position the
text more precisely.

{\bf NB:} under wxGTK the current 
\helpref{logical function}{wxdcgetlogicalfunction} is used by this function
but it is ignored by wxMSW. Thus, you should avoid using logical functions
with 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 cache
which can speed up the \helpref{Blit}{wxdcblit} operation when
drawing a large number of masked bitmaps.

If using the cache functions in your code, please test for the
wxUSE\_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, using
the {\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 find
colour borders if the pixels do not match the colour exactly. However the
function 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 the
rectangle 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 has
some default font after creation, this method would return a \texttt{wxNullFont} 
initially and only after calling \helpref{wxDC::SetFont}{wxdcsetfont} a valid
font is returned.


\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::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 generic
version simply builds a running total of the widths of each character
using \helpref{GetTextExtent}{wxdcgettextextent}, however if the
various platforms have a native API function that is faster or more
accurate than the generic implementation then it should be used
instead. 

\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 not
required as a parameter.}

\perlnote{This method only takes the parameters {\tt x} and {\tt y} and returns
a 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}\rtfsp
represent the maximum horizontal and vertical `pixel' values used in your
application, the following code will scale the graphic to fit on the
printer 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, wxPython
implements 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}

\func{void}{GetTextExtent}{\param{const wxString\& }{string}, \param{wxCoord *}{w}, \param{wxCoord *}{h},\\
  \param{wxCoord *}{descent = NULL}, \param{wxCoord *}{externalLeading = NULL}, \param{wxFont *}{font = NULL}}

Gets the dimensions of the string using the currently selected font.
\rtfsp{\it string} is the text string to measure, {\it w} and {\it h} are
the total width and height respectively, {\it descent} is the
dimension from the baseline of the font to the bottom of the
descender, and {\it externalLeading} is any extra vertical space added

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?