]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/metafile.cpp
Committing in .
[wxWidgets.git] / src / mac / carbon / metafile.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: metafile.cpp
3// Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional.
4// Author: AUTHOR
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "metafile.h"
14#endif
15
519cb848
SC
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include "wx/setup.h"
25#endif
26
27#if wxUSE_METAFILE
28
29#ifndef WX_PRECOMP
30#include "wx/utils.h"
31#include "wx/app.h"
32#endif
33
34#include "wx/metafile.h"
e9576ca5
SC
35#include "wx/clipbrd.h"
36
519cb848
SC
37#include <stdio.h>
38#include <string.h>
39
e9576ca5
SC
40extern bool wxClipboardIsOpen;
41
519cb848
SC
42IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
43IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
e9576ca5 44
519cb848
SC
45/*
46 * Metafiles
47 * Currently, the only purpose for making a metafile is to put
48 * it on the clipboard.
49 */
50
51wxMetafileRefData::wxMetafileRefData(void)
52{
53 m_metafile = 0;
54}
55
56wxMetafileRefData::~wxMetafileRefData(void)
57{
58 if (m_metafile)
59 {
60 KillPicture( m_metafile ) ;
61 m_metafile = 0;
62 }
63}
64
e9576ca5
SC
65wxMetaFile::wxMetaFile(const wxString& file)
66{
519cb848
SC
67 m_refData = new wxMetafileRefData;
68
69
70 M_METAFILEDATA->m_metafile = 0;
71 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
72/*
73 if (!file.IsNull() && (file.Cmp("") == 0))
74 M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
75*/
e9576ca5
SC
76}
77
78wxMetaFile::~wxMetaFile()
79{
e9576ca5
SC
80}
81
82bool wxMetaFile::SetClipboard(int width, int height)
83{
519cb848
SC
84 if (!m_refData)
85 return FALSE;
86/*
e9576ca5
SC
87 bool alreadyOpen=wxClipboardOpen();
88 if (!alreadyOpen)
89 {
90 wxOpenClipboard();
91 if (!wxEmptyClipboard()) return FALSE;
92 }
519cb848 93 bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
e9576ca5
SC
94 if (!alreadyOpen) wxCloseClipboard();
95 return (bool) success;
519cb848
SC
96 */
97 return TRUE ;
e9576ca5
SC
98}
99
100bool wxMetaFile::Play(wxDC *dc)
101{
519cb848 102 if (!m_refData)
e9576ca5 103 return FALSE;
519cb848
SC
104
105 if (!dc->Ok() )
106 return FALSE;
107
108 dc->MacVerifySetup() ;
109
110 {
111 PicHandle pict = GetHMETAFILE() ;
112 DrawPicture( pict , &(**pict).picFrame ) ;
113 }
114/*
115 if (!m_refData)
116 return FALSE;
117
118 dc->BeginDrawing();
119
120 if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
121 PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
122
123 dc->EndDrawing();
124*/
125 return TRUE;
e9576ca5
SC
126}
127
128/*
129 * Metafile device context
130 *
131 */
132
133// Original constructor that does not takes origin and extent. If you use this,
134// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
135wxMetaFileDC::wxMetaFileDC(const wxString& file)
136{
519cb848
SC
137 m_metaFile = NULL;
138 m_minX = 10000;
139 m_minY = 10000;
140 m_maxX = -10000;
141 m_maxY = -10000;
142
143 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
144
145 m_metaFile = new wxMetaFile("") ;
146 Rect r={0,0,100,100} ;
147
148 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
149 ::GetPort( &m_macPort ) ;
150 m_ok = TRUE ;
151
152 SetMapMode(wxMM_TEXT);
e9576ca5
SC
153}
154
155// New constructor that takes origin and extent. If you use this, don't
156// give origin/extent arguments to wxMakeMetaFilePlaceable.
519cb848 157
e9576ca5
SC
158wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
159{
519cb848
SC
160 m_minX = 10000;
161 m_minY = 10000;
162 m_maxX = -10000;
163 m_maxY = -10000;
e9576ca5 164
519cb848 165 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
e9576ca5 166
519cb848
SC
167 m_metaFile = new wxMetaFile("") ;
168 Rect r={yorg,xorg,yorg+yext,xorg+xext} ;
169
170 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
171 ::GetPort( &m_macPort ) ;
172 m_ok = TRUE ;
e9576ca5 173
519cb848 174 SetMapMode(wxMM_TEXT);
e9576ca5
SC
175}
176
519cb848 177wxMetaFileDC::~wxMetaFileDC()
e9576ca5 178{
e9576ca5
SC
179}
180
519cb848 181wxMetaFile *wxMetaFileDC::Close()
e9576ca5 182{
519cb848
SC
183 ClosePicture() ;
184 return m_metaFile;
e9576ca5
SC
185}
186
e9576ca5
SC
187
188#endif