]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/metafile.cpp
Catching up to latest thread changes
[wxWidgets.git] / src / mac / carbon / metafile.cpp
... / ...
CommitLineData
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
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"
35#include "wx/clipbrd.h"
36
37#include <stdio.h>
38#include <string.h>
39
40extern bool wxClipboardIsOpen;
41
42#if !USE_SHARED_LIBRARY
43IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
44IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
45#endif
46
47/*
48 * Metafiles
49 * Currently, the only purpose for making a metafile is to put
50 * it on the clipboard.
51 */
52
53wxMetafileRefData::wxMetafileRefData(void)
54{
55 m_metafile = 0;
56}
57
58wxMetafileRefData::~wxMetafileRefData(void)
59{
60 if (m_metafile)
61 {
62 KillPicture( m_metafile ) ;
63 m_metafile = 0;
64 }
65}
66
67wxMetaFile::wxMetaFile(const wxString& file)
68{
69 m_refData = new wxMetafileRefData;
70
71
72 M_METAFILEDATA->m_metafile = 0;
73 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
74/*
75 if (!file.IsNull() && (file.Cmp("") == 0))
76 M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
77*/
78}
79
80wxMetaFile::~wxMetaFile()
81{
82}
83
84bool wxMetaFile::SetClipboard(int width, int height)
85{
86 if (!m_refData)
87 return FALSE;
88/*
89 bool alreadyOpen=wxClipboardOpen();
90 if (!alreadyOpen)
91 {
92 wxOpenClipboard();
93 if (!wxEmptyClipboard()) return FALSE;
94 }
95 bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
96 if (!alreadyOpen) wxCloseClipboard();
97 return (bool) success;
98 */
99 return TRUE ;
100}
101
102bool wxMetaFile::Play(wxDC *dc)
103{
104 if (!m_refData)
105 return FALSE;
106
107 if (!dc->Ok() )
108 return FALSE;
109
110 dc->MacVerifySetup() ;
111
112 {
113 PicHandle pict = GetHMETAFILE() ;
114 DrawPicture( pict , &(**pict).picFrame ) ;
115 }
116/*
117 if (!m_refData)
118 return FALSE;
119
120 dc->BeginDrawing();
121
122 if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
123 PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
124
125 dc->EndDrawing();
126*/
127 return TRUE;
128}
129
130/*
131 * Metafile device context
132 *
133 */
134
135// Original constructor that does not takes origin and extent. If you use this,
136// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
137wxMetaFileDC::wxMetaFileDC(const wxString& file)
138{
139 m_metaFile = NULL;
140 m_minX = 10000;
141 m_minY = 10000;
142 m_maxX = -10000;
143 m_maxY = -10000;
144
145 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
146
147 m_metaFile = new wxMetaFile("") ;
148 Rect r={0,0,100,100} ;
149
150 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
151 ::GetPort( &m_macPort ) ;
152 m_ok = TRUE ;
153
154 SetMapMode(wxMM_TEXT);
155}
156
157// New constructor that takes origin and extent. If you use this, don't
158// give origin/extent arguments to wxMakeMetaFilePlaceable.
159
160wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
161{
162 m_minX = 10000;
163 m_minY = 10000;
164 m_maxX = -10000;
165 m_maxY = -10000;
166
167 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
168
169 m_metaFile = new wxMetaFile("") ;
170 Rect r={yorg,xorg,yorg+yext,xorg+xext} ;
171
172 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
173 ::GetPort( &m_macPort ) ;
174 m_ok = TRUE ;
175
176 SetMapMode(wxMM_TEXT);
177}
178
179wxMetaFileDC::~wxMetaFileDC()
180{
181}
182
183wxMetaFile *wxMetaFileDC::Close()
184{
185 ClosePicture() ;
186 return m_metaFile;
187}
188
189
190#endif