wxRuby Documentation Home

# Wx::Metafile

A Metafile represents the MS Windows metafile object, so metafile
operations have no effect in X. In Widgets, only sufficient functionality
has been provided for copying a graphic to the clipboard; this may be extended
in a future version. Presently, the only way of creating a metafile
is to use a MetafileDC.

## Derived from

Object

## See also

MetafileDC

## Methods

- Metafile.new
- Metafile#ok
- Metafile#play
- Metafile#set_clipboard

### Metafile.new

Metafile.new(%(arg-type)String% filename = "")

Constructor. If a filename is given, the Windows disk metafile is
read in. Check whether this was performed successfully by
using the Metafile#ok member.

destructor()

Destructor.

### Metafile#ok

Boolean ok()

Returns true if the metafile is valid.

### Metafile#play

Boolean play(%(arg-type)DC% dc)

Plays the metafile into the given device context, returning
true if successful.

### Metafile#set_clipboard

Boolean set_clipboard(%(arg-type)Integer% width = 0, Integer height = 0)

Passes the metafile data to the clipboard. The metafile can no longer be
used for anything, but the Metafile object must still be destroyed by
the application.

Below is a example of metafile, metafile device context and clipboard use
from the `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.

MetafileDC dc; if (dc.Ok()) { Draw(dc, false); Metafile *mf = dc.Close(); if (mf) { bool success = mf→SetClipboard((int)(dc.MaxX() + 10), (int)(dc.MaxY() + 10)); delete mf; } }

[This page automatically generated from the Textile source at 2023-06-09 00:45:34 +0000]