]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/metafile.h
When registering editor, try wxRTTI class name in additon to result of wxPGEditor...
[wxWidgets.git] / interface / wx / metafile.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: metafile.h
e54c96f1 3// Purpose: interface of wxMetafileDC
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxMetafileDC
7c913512 11
23324ae1
FM
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).
7c913512 17
23324ae1
FM
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
22 in).
7c913512 23
23324ae1
FM
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.
7c913512 28
23324ae1
FM
29 @library{wxcore}
30 @category{dc}
7c913512 31
e54c96f1 32 @see wxMetafile, wxDC
23324ae1
FM
33*/
34class wxMetafileDC : public wxDC
35{
36public:
37 /**
38 Constructor. If no filename is passed, the metafile is created
39 in memory.
40 */
41 wxMetafileDC(const wxString& filename = "");
42
43 /**
44 Destructor.
45 */
46 ~wxMetafileDC();
47
48 /**
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).
52 */
4cc4bfaf 53 wxMetafile* Close();
23324ae1
FM
54};
55
56
e54c96f1 57
23324ae1
FM
58/**
59 @class wxMetafile
7c913512 60
23324ae1
FM
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.
7c913512 66
23324ae1
FM
67 @library{wxcore}
68 @category{FIXME}
7c913512 69
e54c96f1 70 @see wxMetafileDC
23324ae1
FM
71*/
72class wxMetafile : public wxObject
73{
74public:
75 /**
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.
79 */
80 wxMetafile(const wxString& filename = "");
81
82 /**
83 Destructor.
84 See @ref overview_refcountdestruct "reference-counted object destruction" for
85 more info.
86 */
87 ~wxMetafile();
88
89 /**
90 Returns @true if the metafile is valid.
91 */
4cc4bfaf 92 bool Ok();
23324ae1
FM
93
94 /**
95 Plays the metafile into the given device context, returning
96 @true if successful.
97 */
4cc4bfaf 98 bool Play(wxDC* dc);
23324ae1
FM
99
100 /**
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
103 the application.
23324ae1
FM
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.
108 */
109 bool SetClipboard(int width = 0, int height = 0);
110};
111
112
e54c96f1 113
23324ae1
FM
114// ============================================================================
115// Global functions/macros
116// ============================================================================
117
3db7c3b1 118/** @ingroup group_funcmacro_gdi */
c83e60aa
BP
119//@{
120
23324ae1
FM
121/**
122 Given a filename for an existing, valid metafile (as constructed using
c83e60aa
BP
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(),
a055a116
BP
126 wxDC::MinY(), wxDC::MaxX() and wxDC::MaxY().
127
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:
4cc4bfaf 130
23324ae1
FM
131 @code
132 SetMapMode(dc, MM_ANISOTROPIC);
c83e60aa
BP
133 SetWindowOrg(dc, minX, minY);
134 SetWindowExt(dc, maxX - minX, maxY - minY);
23324ae1 135 @endcode
7c913512 136
23324ae1 137 This simulates the wxMM_TEXT mapping mode, which wxWidgets assumes.
a055a116 138
c83e60aa 139 Placeable metafiles may be imported by many Windows applications, and can
a055a116
BP
140 be used in RTF (Rich Text Format) files.
141
142 @a scale allows the specification of scale for the metafile.
143
144 This function is only available under Windows.
145
146 @header{wx/metafile.h}
23324ae1 147*/
a055a116
BP
148bool wxMakeMetafilePlaceable(const wxString& filename,
149 int minX, int minY,
150 int maxX, int maxY,
151 float scale = 1.0);
23324ae1 152
c83e60aa
BP
153//@}
154