1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/metafile.h
3 // Purpose: wxMetaFile, wxMetaFileDC and wxMetaFileDataObject classes
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_METAFIILE_H_
13 #define _WX_METAFIILE_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "metafile.h"
24 #include "wx/gdiobj.h"
26 #if wxUSE_DRAG_AND_DROP
27 #include "wx/dataobj.h"
30 // ----------------------------------------------------------------------------
31 // Metafile and metafile device context classes
32 // ----------------------------------------------------------------------------
34 class WXDLLEXPORT wxMetafile
;
36 class WXDLLEXPORT wxMetafileRefData
: public wxGDIRefData
38 friend class WXDLLEXPORT wxMetafile
;
45 int m_windowsMappingMode
;
46 int m_width
, m_height
;
49 #define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
51 class WXDLLEXPORT wxMetafile
: public wxGDIObject
54 wxMetafile(const wxString
& file
= wxEmptyString
);
55 wxMetafile(const wxMetafile
& metafile
) { Ref(metafile
); }
56 virtual ~wxMetafile();
58 // After this is called, the metafile cannot be used for anything
59 // since it is now owned by the clipboard.
60 virtual bool SetClipboard(int width
= 0, int height
= 0);
62 virtual bool Play(wxDC
*dc
);
63 bool Ok() const { return (M_METAFILEDATA
&& (M_METAFILEDATA
->m_metafile
!= 0)); };
65 // set/get the size of metafile for clipboard operations
66 wxSize
GetSize() const { return wxSize(GetWidth(), GetHeight()); }
67 int GetWidth() const { return M_METAFILEDATA
->m_width
; }
68 int GetHeight() const { return M_METAFILEDATA
->m_height
; }
70 void SetWidth(int width
) { M_METAFILEDATA
->m_width
= width
; }
71 void SetHeight(int height
) { M_METAFILEDATA
->m_height
= height
; }
74 WXHANDLE
GetHMETAFILE() const { return M_METAFILEDATA
->m_metafile
; }
75 void SetHMETAFILE(WXHANDLE mf
) ;
76 int GetWindowsMappingMode() const { return M_METAFILEDATA
->m_windowsMappingMode
; }
77 void SetWindowsMappingMode(int mm
);
80 wxMetafile
& operator=(const wxMetafile
& metafile
)
81 { if (*this != metafile
) Ref(metafile
); return *this; }
82 bool operator==(const wxMetafile
& metafile
) const
83 { return m_refData
== metafile
.m_refData
; }
84 bool operator!=(const wxMetafile
& metafile
) const
85 { return m_refData
!= metafile
.m_refData
; }
88 DECLARE_DYNAMIC_CLASS(wxMetafile
)
91 class WXDLLEXPORT wxMetafileDC
: public wxDC
94 // Don't supply origin and extent
95 // Supply them to wxMakeMetaFilePlaceable instead.
96 wxMetafileDC(const wxString
& file
= wxEmptyString
);
98 // Supply origin and extent (recommended).
99 // Then don't need to supply them to wxMakeMetaFilePlaceable.
100 wxMetafileDC(const wxString
& file
, int xext
, int yext
, int xorg
, int yorg
);
102 virtual ~wxMetafileDC();
104 // Should be called at end of drawing
105 virtual wxMetafile
*Close();
106 virtual void SetMapMode(int mode
);
107 virtual void GetTextExtent(const wxString
& string
, long *x
, long *y
,
108 long *descent
= NULL
, long *externalLeading
= NULL
,
109 wxFont
*theFont
= NULL
, bool use16bit
= FALSE
) const;
112 wxMetafile
*GetMetaFile() const { return m_metaFile
; }
113 void SetMetaFile(wxMetafile
*mf
) { m_metaFile
= mf
; }
114 int GetWindowsMappingMode() const { return m_windowsMappingMode
; }
115 void SetWindowsMappingMode(int mm
) { m_windowsMappingMode
= mm
; }
118 int m_windowsMappingMode
;
119 wxMetafile
* m_metaFile
;
122 DECLARE_DYNAMIC_CLASS(wxMetafileDC
)
126 * Pass filename of existing non-placeable metafile, and bounding box.
127 * Adds a placeable metafile header, sets the mapping mode to anisotropic,
128 * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
132 // No origin or extent
133 bool WXDLLEXPORT
wxMakeMetafilePlaceable(const wxString
& filename
, float scale
= 1.0);
135 // Optional origin and extent
136 bool WXDLLEXPORT
wxMakeMetaFilePlaceable(const wxString
& filename
, int x1
, int y1
, int x2
, int y2
, float scale
= 1.0, bool useOriginAndExtent
= TRUE
);
138 // ----------------------------------------------------------------------------
139 // wxMetafileDataObject is a specialization of wxDataObject for metafile data
140 // ----------------------------------------------------------------------------
142 #if wxUSE_DRAG_AND_DROP
144 class WXDLLEXPORT wxMetafileDataObject
: public wxDataObjectSimple
148 wxMetafileDataObject() : wxDataObjectSimple(wxDF_METAFILE
)
150 wxMetafileDataObject(const wxMetafile
& metafile
)
151 : wxDataObjectSimple(wxDF_METAFILE
), m_metafile(metafile
) { }
153 // virtual functions which you may override if you want to provide data on
154 // demand only - otherwise, the trivial default versions will be used
155 virtual void SetMetafile(const wxMetafile
& metafile
)
156 { m_metafile
= metafile
; }
157 virtual wxMetafile
GetMetafile() const
158 { return m_metafile
; }
160 // implement base class pure virtuals
161 virtual size_t GetDataSize() const;
162 virtual bool GetDataHere(void *buf
) const;
163 virtual bool SetData(size_t len
, const void *buf
);
166 wxMetafile m_metafile
;
169 #endif // wxUSE_DRAG_AND_DROP
171 #endif // wxUSE_METAFILE