]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/metafile.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMetafileDC
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 This is a type of device context that allows a metafile object to be
13 created (Windows only), and has most of the characteristics of a normal
14 @b wxDC. The wxMetafileDC::Close member must be called after drawing into the
15 device context, to return a metafile. The only purpose for this at
16 present is to allow the metafile to be copied to the clipboard (see wxMetafile).
18 Adding metafile capability to an application should be easy if you
19 already write to a wxDC; simply pass the wxMetafileDC to your drawing
20 function instead. You may wish to conditionally compile this code so it
21 is not compiled under X (although no harm will result if you leave it
24 Note that a metafile saved to disk is in standard Windows metafile format,
25 and cannot be imported into most applications. To make it importable,
26 call the function ::wxMakeMetafilePlaceable after
27 closing your disk-based metafile device context.
34 class wxMetafileDC
: public wxDC
38 Constructor. If no filename is passed, the metafile is created
41 wxMetafileDC(const wxString
& filename
= "");
49 This must be called after the device context is finished with. A
50 metafile is returned, and ownership of it passes to the calling
51 application (so it should be destroyed explicitly).
61 A @b wxMetafile represents the MS Windows metafile object, so metafile
62 operations have no effect in X. In wxWidgets, only sufficient functionality
63 has been provided for copying a graphic to the clipboard; this may be extended
64 in a future version. Presently, the only way of creating a metafile
65 is to use a wxMetafileDC.
72 class wxMetafile
: public wxObject
76 Constructor. If a filename is given, the Windows disk metafile is
77 read in. Check whether this was performed successfully by
78 using the @ref isok() wxMetafile:IsOk member.
80 wxMetafile(const wxString
& filename
= "");
84 See @ref overview_refcountdestruct "reference-counted object destruction" for
90 Returns @true if the metafile is valid.
95 Plays the metafile into the given device context, returning
101 Passes the metafile data to the clipboard. The metafile can no longer be
102 used for anything, but the wxMetafile object must still be destroyed by
104 Below is a example of metafile, metafile device context and clipboard use
105 from the @c hello.cpp example. Note the way the metafile dimensions
106 are passed to the clipboard, making use of the device context's ability
107 to keep track of the maximum extent of drawing commands.
109 bool SetClipboard(int width
= 0, int height
= 0);
114 // ============================================================================
115 // Global functions/macros
116 // ============================================================================
118 /** @ingroup group_funcmacro_gdi */
122 Given a filename for an existing, valid metafile (as constructed using
123 wxMetafileDC) makes it into a placeable metafile by prepending a header
124 containing the given bounding box. The bounding box may be obtained from a
125 device context after drawing into it, using the functions wxDC::MinX(),
126 wxDC::MinY(), wxDC::MaxX() and wxDC::MaxY().
128 In addition to adding the placeable metafile header, this function adds the
129 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
140 be used in RTF (Rich Text Format) files.
142 @a scale allows the specification of scale for the metafile.
144 This function is only available under Windows.
146 @header{wx/metafile.h}
148 bool wxMakeMetafilePlaceable(const wxString
& filename
,