2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: metafile.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxMetafileDC
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxMetafileDC
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a type of device context that allows a metafile object to be
|
|
|
|
created (Windows only), and has most of the characteristics of a normal
|
2008-10-11 09:10:48 -04:00
|
|
|
@b wxDC.
|
|
|
|
The wxMetafileDC::Close member must be called after drawing into the
|
2008-03-08 08:52:38 -05:00
|
|
|
device context, to return a metafile. The only purpose for this at
|
2008-10-11 09:10:48 -04:00
|
|
|
present is to allow the metafile to be copied to the clipboard
|
|
|
|
(see wxMetafile).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Adding metafile capability to an application should be easy if you
|
|
|
|
already write to a wxDC; simply pass the wxMetafileDC to your drawing
|
|
|
|
function instead. You may wish to conditionally compile this code so it
|
2008-10-11 09:10:48 -04:00
|
|
|
is not compiled under X (although no harm will result if you leave it in).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that a metafile saved to disk is in standard Windows metafile format,
|
|
|
|
and cannot be imported into most applications. To make it importable,
|
2008-10-11 09:10:48 -04:00
|
|
|
call the function ::wxMakeMetafilePlaceable after closing your disk-based
|
|
|
|
metafile device context.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{dc}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxMetafile, wxDC
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxMetafileDC : public wxDC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-11 09:10:48 -04:00
|
|
|
Constructor.
|
|
|
|
If no filename is passed, the metafile is created in memory.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-10 13:31:45 -05:00
|
|
|
wxMetafileDC(const wxString& filename = wxEmptyString);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
|
|
|
~wxMetafileDC();
|
|
|
|
|
|
|
|
/**
|
2008-10-11 09:10:48 -04:00
|
|
|
This must be called after the device context is finished with.
|
|
|
|
A metafile is returned, and ownership of it passes to the calling
|
2008-03-08 08:52:38 -05:00
|
|
|
application (so it should be destroyed explicitly).
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxMetafile* Close();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxMetafile
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A @b wxMetafile represents the MS Windows metafile object, so metafile
|
|
|
|
operations have no effect in X. In wxWidgets, only sufficient functionality
|
|
|
|
has been provided for copying a graphic to the clipboard; this may be extended
|
2008-10-11 09:10:48 -04:00
|
|
|
in a future version.
|
|
|
|
|
|
|
|
Presently, the only way of creating a metafile is to use a wxMetafileDC.
|
|
|
|
|
|
|
|
@onlyfor{wxmsw}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxMetafileDC
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxMetafile : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-11 09:10:48 -04:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
If a filename is given, the Windows disk metafile is read in.
|
|
|
|
Check whether this was performed successfully by using the IsOk() member.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-10 13:31:45 -05:00
|
|
|
wxMetafile(const wxString& filename = wxEmptyString);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
2008-10-11 09:10:48 -04:00
|
|
|
|
|
|
|
See @ref overview_refcount_destruct for more info.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
~wxMetafile();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the metafile is valid.
|
|
|
|
*/
|
2009-01-10 13:00:53 -05:00
|
|
|
bool IsOk();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Plays the metafile into the given device context, returning
|
|
|
|
@true if successful.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Play(wxDC* dc);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Passes the metafile data to the clipboard. The metafile can no longer be
|
|
|
|
used for anything, but the wxMetafile object must still be destroyed by
|
|
|
|
the application.
|
2008-10-11 09:10:48 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Below is a example of metafile, metafile device context and clipboard use
|
|
|
|
from the @c hello.cpp example. Note the way the metafile dimensions
|
|
|
|
are passed to the clipboard, making use of the device context's ability
|
|
|
|
to keep track of the maximum extent of drawing commands.
|
2008-10-11 09:10:48 -04:00
|
|
|
|
|
|
|
@code
|
|
|
|
wxMetafileDC dc;
|
2009-01-10 13:00:53 -05:00
|
|
|
if (dc.IsOk())
|
2008-10-11 09:10:48 -04:00
|
|
|
{
|
|
|
|
Draw(dc, false);
|
|
|
|
wxMetafile *mf = dc.Close();
|
|
|
|
if (mf)
|
|
|
|
{
|
|
|
|
bool success = mf->SetClipboard((int)(dc.MaxX() + 10), (int)(dc.MaxY() + 10));
|
|
|
|
delete mf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool SetClipboard(int width = 0, int height = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2009-01-05 15:48:06 -05:00
|
|
|
/** @addtogroup group_funcmacro_gdi */
|
2008-03-11 03:57:21 -04:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Given a filename for an existing, valid metafile (as constructed using
|
2008-03-11 03:57:21 -04:00
|
|
|
wxMetafileDC) makes it into a placeable metafile by prepending a header
|
|
|
|
containing the given bounding box. The bounding box may be obtained from a
|
|
|
|
device context after drawing into it, using the functions wxDC::MinX(),
|
2008-03-20 02:00:05 -04:00
|
|
|
wxDC::MinY(), wxDC::MaxX() and wxDC::MaxY().
|
|
|
|
|
|
|
|
In addition to adding the placeable metafile header, this function adds the
|
|
|
|
equivalent of the following code to the start of the metafile data:
|
2008-03-09 08:33:59 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
|
|
|
SetMapMode(dc, MM_ANISOTROPIC);
|
2008-03-11 03:57:21 -04:00
|
|
|
SetWindowOrg(dc, minX, minY);
|
|
|
|
SetWindowExt(dc, maxX - minX, maxY - minY);
|
2008-03-08 08:52:38 -05:00
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This simulates the wxMM_TEXT mapping mode, which wxWidgets assumes.
|
2008-03-20 02:00:05 -04:00
|
|
|
|
2008-03-11 03:57:21 -04:00
|
|
|
Placeable metafiles may be imported by many Windows applications, and can
|
2008-03-20 02:00:05 -04:00
|
|
|
be used in RTF (Rich Text Format) files.
|
|
|
|
|
|
|
|
@a scale allows the specification of scale for the metafile.
|
|
|
|
|
|
|
|
This function is only available under Windows.
|
|
|
|
|
|
|
|
@header{wx/metafile.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-20 02:00:05 -04:00
|
|
|
bool wxMakeMetafilePlaceable(const wxString& filename,
|
|
|
|
int minX, int minY,
|
|
|
|
int maxX, int maxY,
|
|
|
|
float scale = 1.0);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-03-11 03:57:21 -04:00
|
|
|
//@}
|
|
|
|
|