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