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