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