]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/metafile.cpp
added DEP_INFO_FLAGS to compilation options
[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 wxUSE_DRAG_AND_DROP
87//TODO finishi this port , we need the data obj first
88 if (!m_refData)
89 return FALSE;
90
91 bool alreadyOpen=wxTheClipboard->IsOpened() ;
92 if (!alreadyOpen)
93 {
94 wxTheClipboard->Open();
95 if (!wxTheClipboard->Clear()) return FALSE;
96 }
97 bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
98 if (!alreadyOpen) wxCloseClipboard();
99 return (bool) success;
100#endif
101 return TRUE ;
102}
103
104void wxMetafile::SetHMETAFILE(PicHandle mf)
105{
106 if (!m_refData)
107 m_refData = new wxMetafileRefData;
108
109 M_METAFILEDATA->m_metafile = mf;
110}
111
112bool wxMetaFile::Play(wxDC *dc)
113{
114 if (!m_refData)
115 return FALSE;
116
117 if (!dc->Ok() )
118 return FALSE;
119
120 {
121 wxMacPortSetter helper( dc ) ;
122 PicHandle pict = GetHMETAFILE() ;
123 DrawPicture( pict , &(**pict).picFrame ) ;
124 }
125 return TRUE;
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{
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,1000,1000} ;
147
148 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
149 ::GetPort( &m_macPort ) ;
150 m_ok = TRUE ;
151
152 SetMapMode(wxMM_TEXT);
153}
154
155// New constructor that takes origin and extent. If you use this, don't
156// give origin/extent arguments to wxMakeMetaFilePlaceable.
157
158wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
159{
160 m_minX = 10000;
161 m_minY = 10000;
162 m_maxX = -10000;
163 m_maxY = -10000;
164
165 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
166
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 ;
173
174 SetMapMode(wxMM_TEXT);
175}
176
177wxMetaFileDC::~wxMetaFileDC()
178{
179}
180
181wxMetaFile *wxMetaFileDC::Close()
182{
183 ClosePicture() ;
184 return m_metaFile;
185}
186
187#endif