e2a6f23364
added overloaded wxGetHostName etc. functions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
43 lines
2.1 KiB
TeX
43 lines
2.1 KiB
TeX
\section{Device context overview}\label{dcoverview}
|
|
|
|
Classes: \helpref{wxDC}{wxdc}, \helpref{wxPostScriptDC}{wxpostscriptdc},\rtfsp
|
|
\rtfsp\helpref{wxMetafileDC}{wxmetafiledc}, \helpref{wxMemoryDC}{wxmemorydc}, \helpref{wxPrinterDC}{wxprinterdc},\rtfsp
|
|
\helpref{wxScreenDC}{wxscreendc}, \helpref{wxClientDC}{wxclientdc}, \helpref{wxPaintDC}{wxpaintdc},\rtfsp
|
|
\helpref{wxWindowDC}{wxwindowdc}.
|
|
|
|
A wxDC is a {\it device context} onto which graphics and text can be drawn.
|
|
The device context is intended to represent a number of output devices in a generic way,
|
|
with the same API being used throughout.
|
|
|
|
Some device contexts are created temporarily in order to draw on a window.
|
|
This is true of \helpref{wxScreenDC}{wxscreendc}, \helpref{wxClientDC}{wxclientdc}, \helpref{wxPaintDC}{wxpaintdc},
|
|
and \helpref{wxWindowDC}{wxwindowdc}. The following describes the differences between
|
|
these device contexts and when you should use them.
|
|
|
|
\begin{itemize}\itemsep=0pt
|
|
\item {\bf wxScreenDC.} Use this to paint on the screen, as opposed to an individual window.
|
|
\item {\bf wxClientDC.} Use this to paint on the client area of window (the part without
|
|
borders and other decorations), but do not use it from within an \helpref{wxWindow::OnPaint}{wxwindowonpaint} event.
|
|
\item {\bf wxPaintDC.} Use this to paint on the client area of a window, but {\it only} from
|
|
within an \helpref{wxWindow::OnPaint}{wxwindowonpaint} event.
|
|
\item {\bf wxWindowDC.} Use this to paint on the whole area of a window, including decorations.
|
|
This may not be available on non-Windows platforms.
|
|
\end{itemize}
|
|
|
|
To use a client, paint or window device context, create an object on the stack with
|
|
the window as argument, for example:
|
|
|
|
\begin{verbatim}
|
|
void MyWindow::OnMyCmd(wxCommandEvent& event)
|
|
{
|
|
wxClientDC dc(window);
|
|
DrawMyPicture(dc);
|
|
}
|
|
\end{verbatim}
|
|
|
|
Try to write code so it is parameterised by wxDC - if you do this, the same piece of code may
|
|
write to a number of different devices, by passing a different device context. This doesn't
|
|
work for everything (for example not all device contexts support bitmap drawing) but
|
|
will work most of the time.
|
|
|