]> git.saurik.com Git - wxWidgets.git/blame - src/mac/metafile.cpp
set more event object fields for lbox dbl click events
[wxWidgets.git] / src / mac / 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
2f1ae414 42#if !USE_SHARED_LIBRARY
519cb848
SC
43IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
44IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
2f1ae414 45#endif
e9576ca5 46
519cb848
SC
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 {
2f1ae414 62 KillPicture( m_metafile ) ;
519cb848
SC
63 m_metafile = 0;
64 }
65}
66
e9576ca5
SC
67wxMetaFile::wxMetaFile(const wxString& file)
68{
519cb848
SC
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*/
e9576ca5
SC
78}
79
80wxMetaFile::~wxMetaFile()
81{
e9576ca5
SC
82}
83
84bool wxMetaFile::SetClipboard(int width, int height)
85{
519cb848
SC
86 if (!m_refData)
87 return FALSE;
2f1ae414 88
e9576ca5
SC
89 bool alreadyOpen=wxClipboardOpen();
90 if (!alreadyOpen)
91 {
92 wxOpenClipboard();
93 if (!wxEmptyClipboard()) return FALSE;
94 }
519cb848 95 bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
e9576ca5 96 if (!alreadyOpen) wxCloseClipboard();
2f1ae414
SC
97 return (bool) success;
98
519cb848 99 return TRUE ;
e9576ca5
SC
100}
101
2f1ae414
SC
102void wxMetafile::SetHMETAFILE(PicHandle mf)
103{
104 if (!m_refData)
105 m_refData = new wxMetafileRefData;
106
107 M_METAFILEDATA->m_metafile = mf;
108}
109
e9576ca5
SC
110bool wxMetaFile::Play(wxDC *dc)
111{
519cb848 112 if (!m_refData)
e9576ca5 113 return FALSE;
519cb848
SC
114
115 if (!dc->Ok() )
116 return FALSE;
117
118 dc->MacVerifySetup() ;
119
120 {
121 PicHandle pict = GetHMETAFILE() ;
122 DrawPicture( pict , &(**pict).picFrame ) ;
123 }
124/*
125 if (!m_refData)
126 return FALSE;
127
128 dc->BeginDrawing();
129
130 if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
131 PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
132
133 dc->EndDrawing();
134*/
135 return TRUE;
e9576ca5
SC
136}
137
138/*
139 * Metafile device context
140 *
141 */
142
143// Original constructor that does not takes origin and extent. If you use this,
144// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
145wxMetaFileDC::wxMetaFileDC(const wxString& file)
146{
519cb848
SC
147 m_metaFile = NULL;
148 m_minX = 10000;
149 m_minY = 10000;
150 m_maxX = -10000;
151 m_maxY = -10000;
152
153 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
154
2f1ae414
SC
155 m_metaFile = new wxMetaFile("") ;
156 Rect r={0,0,1000,1000} ;
519cb848 157
2f1ae414
SC
158 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
159 ::GetPort( &m_macPort ) ;
519cb848
SC
160 m_ok = TRUE ;
161
162 SetMapMode(wxMM_TEXT);
e9576ca5
SC
163}
164
165// New constructor that takes origin and extent. If you use this, don't
166// give origin/extent arguments to wxMakeMetaFilePlaceable.
519cb848 167
e9576ca5
SC
168wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
169{
519cb848
SC
170 m_minX = 10000;
171 m_minY = 10000;
172 m_maxX = -10000;
173 m_maxY = -10000;
e9576ca5 174
519cb848 175 wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ;
e9576ca5 176
519cb848
SC
177 m_metaFile = new wxMetaFile("") ;
178 Rect r={yorg,xorg,yorg+yext,xorg+xext} ;
179
180 m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
181 ::GetPort( &m_macPort ) ;
182 m_ok = TRUE ;
e9576ca5 183
519cb848 184 SetMapMode(wxMM_TEXT);
e9576ca5
SC
185}
186
519cb848 187wxMetaFileDC::~wxMetaFileDC()
e9576ca5 188{
e9576ca5
SC
189}
190
519cb848 191wxMetaFile *wxMetaFileDC::Close()
e9576ca5 192{
519cb848
SC
193 ClosePicture() ;
194 return m_metaFile;
e9576ca5
SC
195}
196
e9576ca5 197#endif