]>
git.saurik.com Git - wxWidgets.git/blob - interface/metafile.h
a3d844459542409354dc1b01d5637f8bf0a49ab5
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxMetafileDC class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This is a type of device context that allows a metafile object to be
14 created (Windows only), and has most of the characteristics of a normal
15 @b wxDC. The wxMetafileDC::Close member must be called after drawing into the
16 device context, to return a metafile. The only purpose for this at
17 present is to allow the metafile to be copied to the clipboard (see wxMetafile).
19 Adding metafile capability to an application should be easy if you
20 already write to a wxDC; simply pass the wxMetafileDC to your drawing
21 function instead. You may wish to conditionally compile this code so it
22 is not compiled under X (although no harm will result if you leave it
25 Note that a metafile saved to disk is in standard Windows metafile format,
26 and cannot be imported into most applications. To make it importable,
27 call the function ::wxMakeMetafilePlaceable after
28 closing your disk-based metafile device context.
36 class wxMetafileDC
: public wxDC
40 Constructor. If no filename is passed, the metafile is created
43 wxMetafileDC(const wxString
& filename
= "");
51 This must be called after the device context is finished with. A
52 metafile is returned, and ownership of it passes to the calling
53 application (so it should be destroyed explicitly).
63 A @b wxMetafile represents the MS Windows metafile object, so metafile
64 operations have no effect in X. In wxWidgets, only sufficient functionality
65 has been provided for copying a graphic to the clipboard; this may be extended
66 in a future version. Presently, the only way of creating a metafile
67 is to use a wxMetafileDC.
75 class wxMetafile
: public wxObject
79 Constructor. If a filename is given, the Windows disk metafile is
80 read in. Check whether this was performed successfully by
81 using the @ref isok() wxMetafile:IsOk member.
83 wxMetafile(const wxString
& filename
= "");
87 See @ref overview_refcountdestruct "reference-counted object destruction" for
93 Returns @true if the metafile is valid.
95 #define bool Ok() /* implementation is private */
98 Plays the metafile into the given device context, returning
101 bool Play(wxDC
* dc
);
104 Passes the metafile data to the clipboard. The metafile can no longer be
105 used for anything, but the wxMetafile object must still be destroyed by
108 Below is a example of metafile, metafile device context and clipboard use
109 from the @c hello.cpp example. Note the way the metafile dimensions
110 are passed to the clipboard, making use of the device context's ability
111 to keep track of the maximum extent of drawing commands.
113 bool SetClipboard(int width
= 0, int height
= 0);
117 // ============================================================================
118 // Global functions/macros
119 // ============================================================================
122 Given a filename for an existing, valid metafile (as constructed using
124 makes it into a placeable metafile by prepending a header containing the given
125 bounding box. The bounding box may be obtained from a device context after
127 into it, using the functions wxDC::MinX, wxDC::MinY, wxDC::MaxX and wxDC::MaxY.
129 In addition to adding the placeable metafile header, this function adds
130 the equivalent of the following code to the start of the metafile data:
132 SetMapMode(dc, MM_ANISOTROPIC);
133 SetWindowOrg(dc, minX, minY);
134 SetWindowExt(dc, maxX - minX, maxY - minY);
137 This simulates the wxMM_TEXT mapping mode, which wxWidgets assumes.
139 Placeable metafiles may be imported by many Windows applications, and can be
140 used in RTF (Rich Text Format) files.
142 @e scale allows the specification of scale for the metafile.
144 This function is only available under Windows.
146 bool wxMakeMetafilePlaceable(const wxString
& filename
, int minX
,