]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/metafile.tex
1. wxFile docs updated, wxTextFile and wxTempFile docs written (thanks HelpGen :-)
[wxWidgets.git] / docs / latex / wx / metafile.tex
1
2 \section{\class{wxMetaFile}}\label{wxmetafile}
3
4 A {\bf wxMetaFile} represents the MS Windows metafile object, so metafile
5 operations have no effect in X. In wxWindows, only sufficient functionality
6 has been provided for copying a graphic to the clipboard; this may be extended
7 in a future version. Presently, the only way of creating a metafile
8 is 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
24 Constructor. If a filename is given, the Windows disk metafile is
25 read in. Check whether this was performed successfully by
26 using the \helpref{wxMetaFile::Ok}{wxmetafileok} member.
27
28 \membersection{wxMetaFile::\destruct{wxMetaFile}}
29
30 \func{}{\destruct{wxMetaFile}}{\void}
31
32 Destructor.
33
34 \membersection{wxMetaFile::Ok}\label{wxmetafileok}
35
36 \func{bool}{Ok}{\void}
37
38 Returns TRUE if the metafile is valid.
39
40 \membersection{wxMetaFile::Play}\label{wxmetafileplay}
41
42 \func{bool}{Play}{\param{wxDC *}{dc}}
43
44 Plays the metafile into the given device context, returning
45 TRUE if successful.
46
47 \membersection{wxMetaFile::SetClipboard}
48
49 \func{bool}{SetClipboard}{\param{int}{ width = 0}, \param{int}{ height = 0}}
50
51 Passes the metafile data to the clipboard. The metafile can no longer be
52 used for anything, but the wxMetaFile object must still be destroyed by
53 the application.
54
55 Below is a example of metafle, metafile device context and clipboard use
56 from the {\tt hello.cpp} example. Note the way the metafile dimensions
57 are passed to the clipboard, making use of the device context's ability
58 to 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
76 This is a type of device context that allows a metafile object to be
77 created (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
79 device context, to return a metafile. The only purpose for this at
80 present is to allow the metafile to be copied to the clipboard (see \helpref{wxMetaFile}{wxmetafile}).
81
82 Adding metafile capability to an application should be easy if you
83 already write to a wxDC; simply pass the wxMetaFileDC to your drawing
84 function instead. You may wish to conditionally compile this code so it
85 is not compiled under X (although no harm will result if you leave it
86 in).
87
88 Note that a metafile saved to disk is in standard Windows metafile format,
89 and cannot be imported into most applications. To make it importable,
90 call the function \helpref{::wxMakeMetaFilePlaceable}{wxmakemetafileplaceable} after
91 closing 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
108 Constructor. If no filename is passed, the metafile is created
109 in memory.
110
111 \membersection{wxMetaFileDC::\destruct{wxMetaFileDC}}
112
113 \func{}{\destruct{wxMetaFileDC}}{\void}
114
115 Destructor.
116
117 \membersection{wxMetaFileDC::Close}\label{wxmetafiledcclose}
118
119 \func{wxMetaFile *}{Close}{\void}
120
121 This must be called after the device context is finished with. A
122 metafile is returned, and ownership of it passes to the calling
123 application (so it should be destroyed explicitly).
124
125