]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/metafile.tex
GTK
[wxWidgets.git] / docs / latex / wx / metafile.tex
CommitLineData
a660d684
KB
1
2\section{\class{wxMetaFile}}\label{wxmetafile}
3
4A {\bf wxMetaFile} represents the MS Windows metafile object, so metafile
5operations have no effect in X. In wxWindows, only sufficient functionality
6has been provided for copying a graphic to the clipboard; this may be extended
7in a future version. Presently, the only way of creating a metafile
8is to use a wxMetafileDC.
9
10\wxheading{Derived from}
11
12\helpref{wxObject}{wxobject}
13
14\wxheading{See also}
15
16\helpref{wxMetaFileDC}{wxmetafiledc}
17
18\latexignore{\rtfignore{\wxheading{Members}}}
19
20\membersection{wxMetaFile::wxMetaFile}
21
22\func{}{wxMetaFile}{\param{const wxString\& }{filename = ""}}
23
24Constructor. If a filename is given, the Windows disk metafile is
25read in. Check whether this was performed successfully by
26using the \helpref{wxMetaFile::Ok}{wxmetafileok} member.
27
28\membersection{wxMetaFile::\destruct{wxMetaFile}}
29
30\func{}{\destruct{wxMetaFile}}{\void}
31
32Destructor.
33
34\membersection{wxMetaFile::Ok}\label{wxmetafileok}
35
36\func{bool}{Ok}{\void}
37
38Returns TRUE if the metafile is valid.
39
40\membersection{wxMetaFile::Play}\label{wxmetafileplay}
41
42\func{bool}{Play}{\param{wxDC *}{dc}}
43
44Plays the metafile into the given device context, returning
45TRUE if successful.
46
47\membersection{wxMetaFile::SetClipboard}
48
49\func{bool}{SetClipboard}{\param{int}{ width = 0}, \param{int}{ height = 0}}
50
51Passes the metafile data to the clipboard. The metafile can no longer be
52used for anything, but the wxMetaFile object must still be destroyed by
53the application.
54
55Below is a example of metafle, metafile device context and clipboard use
56from the {\tt hello.cpp} example. Note the way the metafile dimensions
57are passed to the clipboard, making use of the device context's ability
58to keep track of the maximum extent of drawing commands.
59
60\begin{verbatim}
61 wxMetaFileDC dc;
62 if (dc.Ok())
63 {
64 Draw(dc, FALSE);
65 wxMetaFile *mf = dc.Close();
66 if (mf)
67 {
68 bool success = mf->SetClipboard((int)(dc.MaxX() + 10), (int)(dc.MaxY() + 10));
69 delete mf;
70 }
71 }
72\end{verbatim}
73
74\section{\class{wxMetaFileDC}}\label{wxmetafiledc}
75
76This is a type of device context that allows a metafile object to be
77created (Windows only), and has most of the characteristics of a normal
78\rtfsp{\bf wxDC}. The \helpref{wxMetaFileDC::Close}{wxmetafiledcclose} member must be called after drawing into the
79device context, to return a metafile. The only purpose for this at
80present is to allow the metafile to be copied to the clipboard (see \helpref{wxMetaFile}{wxmetafile}).
81
82Adding metafile capability to an application should be easy if you
83already write to a wxDC; simply pass the wxMetaFileDC to your drawing
84function instead. You may wish to conditionally compile this code so it
85is not compiled under X (although no harm will result if you leave it
86in).
87
88Note that a metafile saved to disk is in standard Windows metafile format,
89and cannot be imported into most applications. To make it importable,
90call the function \helpref{::wxMakeMetaFilePlaceable}{wxmakemetafileplaceable} after
91closing your disk-based metafile device context.
92
93\wxheading{Derived from}
94
95\helpref{wxDC}{wxdc}\\
96\helpref{wxObject}{wxobject}
97
98\wxheading{See also}
99
100\helpref{wxMetaFile}{wxmetafile}, \helpref{wxDC}{wxdc}
101
102\latexignore{\rtfignore{\wxheading{Members}}}
103
104\membersection{wxMetaFileDC::wxMetaFileDC}
105
106\func{}{wxMetaFileDC}{\param{const wxString\& }{filename = ""}}
107
108Constructor. If no filename is passed, the metafile is created
109in memory.
110
111\membersection{wxMetaFileDC::\destruct{wxMetaFileDC}}
112
113\func{}{\destruct{wxMetaFileDC}}{\void}
114
115Destructor.
116
117\membersection{wxMetaFileDC::Close}\label{wxmetafiledcclose}
118
119\func{wxMetaFile *}{Close}{\void}
120
121This must be called after the device context is finished with. A
122metafile is returned, and ownership of it passes to the calling
123application (so it should be destroyed explicitly).
124
125