#
-# This file was automatically generated by tmake at 17:13, 2000/01/12
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
#
msw/dibutils.h \
msw/dirdlg.h \
msw/dragimag.h \
+ msw/enhmeta.h \
msw/filedlg.h \
msw/font.h \
msw/fontdlg.h \
dibutils.o \
dir.o \
dragimag.o \
+ enhmeta.o \
filedlg.o \
font.o \
fontdlg.o \
dibutils.d \
dir.d \
dragimag.d \
+ enhmeta.d \
filedlg.d \
font.d \
fontdlg.d \
dragimag.cpp M
dropsrc.cpp M O
droptgt.cpp M O
+enhmeta.cpp M 32
filedlg.cpp M
font.cpp M
fontdlg.cpp M
dibutils.h 9
dirdlg.h 9
dragimag.h 9
+enhmeta.h 9 32
filedlg.h 9
font.h 9
fontdlg.h 9
wxMSW:
+- support for enhanced metafiles added, support for copying/pasting metafiles
+ (WMF and enhanced ones) fixed/added.
- implemented setting colours for push buttons
- wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
-- tooltips work with wxRadioBox
- loading/saving big (> 32K) files in wxTextCtrl works
+- tooltips work with wxRadioBox
- returning FALSE from OnPrintPage() aborts printing
wxGTK:
{
return FALSE;
}
+
+ // returns TRUE if this format is supported
+ bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
};
// ----------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/metafile.h
+// Purpose: wxMetaFile class declaration
+// Author: wxWindows team
+// Modified by:
+// Created: 13.01.00
+// RCS-ID: $Id$
+// Copyright: (c) wxWindows team
+// Licence: wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
#ifndef _WX_METAFILE_H_BASE_
#define _WX_METAFILE_H_BASE_
+// provide synonyms for all metafile classes
+#define wxMetaFile wxMetafile
+#define wxMetaFileDC wxMetafileDC
+#define wxMetaFileDataObject wxMetafileDataObject
+
+#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
+
#if defined(__WXMSW__)
-#include "wx/msw/metafile.h"
-#endif
-#if defined(__WXPM__)
-#include "wx/os2/metafile.h"
+ #if defined(__WIN32__) && wxUSE_ENH_METAFILE
+ #include "wx/msw/enhmeta.h"
+
+ // map all metafile classes to enh metafile
+ #if !wxUSE_WIN_METAFILES_ALWAYS
+ typedef wxEnhMetaFile wxMetafile;
+ typedef wxEnhMetaFileDC wxMetafileDC;
+ typedef wxEnhMetaFileDataObject wxMetafileDataObject;
+
+ // this flag will be set if wxMetafile class is wxEnhMetaFile
+ #define wxMETAFILE_IS_ENH
+ #endif // wxUSE_WIN_METAFILES_ALWAYS
+ #else // Win16
+ #include "wx/msw/metafile.h"
+ #endif
+#elif defined(__WXPM__)
+ #include "wx/os2/metafile.h"
#endif
#endif
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/msw/enhmeta.h
+// Purpose: wxEnhMetaFile class for Win32
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 13.01.00
+// RCS-ID: $Id$
+// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence: wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MSW_ENHMETA_H_
+#define _WX_MSW_ENHMETA_H_
+
+#ifdef __GNUG__
+ #pragma interface "enhmeta.h"
+#endif
+
+#include "wx/dc.h"
+
+#if wxUSE_DRAG_AND_DROP
+ #include "wx/dataobj.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxEnhMetaFile : public wxObject
+{
+public:
+ wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
+ { Init(); }
+ wxEnhMetaFile(const wxEnhMetaFile& metafile)
+ { Init(); Assign(metafile); }
+ wxEnhMetaFile& operator=(const wxEnhMetaFile& metafile)
+ { Free(); Assign(metafile); return *this; }
+
+ virtual ~wxEnhMetaFile()
+ { Free(); }
+
+ // display the picture stored in the metafile on the given DC
+ bool Play(wxDC *dc, wxRect *rectBound = (wxRect *)NULL);
+
+ // accessors
+ bool Ok() const { return m_hMF != 0; }
+
+ wxSize GetSize() const;
+ int GetWidth() const { return GetSize().x; }
+ int GetHeight() const { return GetSize().y; }
+
+ const wxString& GetFileName() const { return m_filename; }
+
+ // implementation
+ WXHANDLE GetHENHMETAFILE() const { return m_hMF; }
+ void SetHENHMETAFILE(WXHANDLE hMF) { Free(); m_hMF = hMF; }
+
+protected:
+ void Init() { m_hMF = 0; }
+ void Free();
+ void Assign(const wxEnhMetaFile& mf);
+
+private:
+ wxString m_filename;
+ WXHANDLE m_hMF;
+
+ DECLARE_DYNAMIC_CLASS(wxEnhMetaFile)
+};
+
+// ----------------------------------------------------------------------------
+// wxEnhMetaFileDC: allows to create a wxEnhMetaFile
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxEnhMetaFileDC : public wxDC
+{
+public:
+ // the ctor parameters specify the filename (empty for memory metafiles),
+ // the metafile picture size and the optional description/comment
+ wxEnhMetaFileDC(const wxString& filename = wxEmptyString,
+ int width = 0, int height = 0,
+ const wxString& description = wxEmptyString);
+
+ virtual ~wxEnhMetaFileDC();
+
+ // obtain a pointer to the new metafile (caller should delete it)
+ wxEnhMetaFile *Close();
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxEnhMetaFileDC)
+};
+
+// ----------------------------------------------------------------------------
+// wxEnhMetaFileDataObject is a specialization of wxDataObject for enh metafile
+// ----------------------------------------------------------------------------
+
+#if wxUSE_DRAG_AND_DROP
+
+// notice that we want to support both CF_METAFILEPICT and CF_ENHMETAFILE and
+// so we derive from and not from wxDataObjectSimple
+class WXDLLEXPORT wxEnhMetaFileDataObject : public wxDataObject
+{
+public:
+ // ctors
+ wxEnhMetaFileDataObject() { }
+ wxEnhMetaFileDataObject(const wxEnhMetaFile& metafile)
+ : m_metafile(metafile) { }
+
+ // virtual functions which you may override if you want to provide data on
+ // demand only - otherwise, the trivial default versions will be used
+ virtual void SetMetafile(const wxEnhMetaFile& metafile)
+ { m_metafile = metafile; }
+ virtual wxEnhMetaFile GetMetafile() const
+ { return m_metafile; }
+
+ // implement base class pure virtuals
+ virtual wxDataFormat GetPreferredFormat(Direction dir) const;
+ virtual size_t GetFormatCount(Direction dir) const;
+ virtual void GetAllFormats(wxDataFormat *formats, Direction dir) const;
+ virtual size_t GetDataSize(const wxDataFormat& format) const;
+ virtual bool GetDataHere(const wxDataFormat& format, void *buf) const;
+ virtual bool SetData(const wxDataFormat& format, size_t len,
+ const void *buf);
+
+protected:
+ wxEnhMetaFile m_metafile;
+};
+
+#endif // wxUSE_DRAG_AND_DROP
+
+#endif // _WX_MSW_ENHMETA_H_
bool SetForegroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col);
+ // overriden base class virtuals
+ virtual bool AcceptsFocus() const { return FALSE; }
+
// Backward compatibility
#if WXWIN_COMPATIBILITY
void SetButtonColour(const wxColour& col) { SetForegroundColour(col); }
bool SetForegroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col);
+ // overriden base class virtuals
+ virtual bool AcceptsFocus() const { return FALSE; }
+
// Backward compatibility
#if WXWIN_COMPATIBILITY
void SetButtonColour(const wxColour& col) { SetForegroundColour(col); }
#include "wx/dataobj.h"
#endif
-// provide synonyms for all metafile classes
-#define wxMetaFile wxMetafile
-#define wxMetaFileDC wxMetafileDC
-#define wxMetaFileDataObject wxMetafileDataObject
-
-#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
-
// ----------------------------------------------------------------------------
// Metafile and metafile device context classes
// ----------------------------------------------------------------------------
bool Ok() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
// set/get the size of metafile for clipboard operations
+ wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
int GetWidth() const { return M_METAFILEDATA->m_width; }
int GetHeight() const { return M_METAFILEDATA->m_height; }
public:
// Don't supply origin and extent
// Supply them to wxMakeMetaFilePlaceable instead.
- wxMetafileDC(const wxString& file = "");
+ wxMetafileDC(const wxString& file = wxEmptyString);
// Supply origin and extent (recommended).
// Then don't need to supply them to wxMakeMetaFilePlaceable.
void SetAutoDelete();
// return TRUE if we support this format in "Get" direction
- bool IsSupportedFormat(const wxDataFormat& format) const;
+ bool IsSupportedFormat(const wxDataFormat& format) const
+ { return wxDataObjectBase::IsSupported(format, Get); }
#ifdef __WXDEBUG__
// function to return symbolic name of clipboard format (for debug messages)
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
}
+// translations between HIMETRIC units (which OLE likes) and pixels (which are
+// liked by all the others) - implemented in msw/utilsexc.cpp
+extern void HIMETRICToPixel(LONG *x, LONG *y);
+extern void PixelToHIMETRIC(LONG *x, LONG *y);
+
// ---------------------------------------------------------------------------
// small helper classes
// ---------------------------------------------------------------------------
#define wxUSE_CARET 1
#define wxUSE_SLIDER 1
+// ----------------------------------------------------------------------------
+// Metafiles support
+// ----------------------------------------------------------------------------
+
+// Windows supports the graphics format known as metafile which is, though not
+// portable, is widely used under Windows and so is supported by wxWin (under
+// Windows only, of course). Win16 (Win3.1) used the so-called "Window
+// MetaFiles" or WMFs which were replaced with "Enhanced MetaFiles" or EMFs in
+// Win32 (Win9x, NT, 2000). Both of these are supported in wxWin and, by
+// default, WMFs will be used under Win16 and EMFs under Win32. This may be
+// changed by setting wxUSE_WIN_METAFILES_ALWAYS to 1 and/or setting
+// wxUSE_ENH_METAFILE to 0. You may also set wxUSE_METAFILE to 0 to not compile
+// in any metafile related classes at all.
+//
+// Default is 1 for wxUSE_ENH_METAFILE and 0 for wxUSE_WIN_METAFILES_ALWAYS.
+//
+// Recommended setting: default or 0 for everything for portable programs.
+#define wxUSE_METAFILE 1
+#define wxUSE_ENH_METAFILE 1
+#define wxUSE_WIN_METAFILES_ALWAYS 0
+
// ----------------------------------------------------------------------------
// Postscript support settings
// ----------------------------------------------------------------------------
// 0 for no PostScript device context
#define wxUSE_AFM_FOR_POSTSCRIPT 0
// 1 to use font metric files in GetTextExtent
-#define wxUSE_METAFILE 1
- // 0 for no Metafile and metafile device context
#define wxUSE_IPC 1
// 0 for no interprocess comms
// Note: wxHELP uses IPC under X so these are interdependent!
{
}
+bool wxDataObjectBase::IsSupported(const wxDataFormat& format,
+ Direction dir) const
+{
+ size_t nFormatCount = GetFormatCount(dir);
+ if ( nFormatCount == 1 )
+ {
+ return format == GetPreferredFormat(dir);
+ }
+ else
+ {
+ wxDataFormat *formats = new wxDataFormat[nFormatCount];
+ GetAllFormats(formats, dir);
+
+ size_t n;
+ for ( n = 0; n < nFormatCount; n++ )
+ {
+ if ( formats[n] == format )
+ break;
+ }
+
+ delete [] formats;
+
+ // found?
+ return n < nFormatCount;
+ }
+}
+
// ----------------------------------------------------------------------------
// wxDataObjectComposite
// ----------------------------------------------------------------------------
void wxPanel::OnSize(wxSizeEvent& WXUNUSED(event))
{
#if wxUSE_CONSTRAINTS
- if (GetAutoLayout()) Layout();
+ if (GetAutoLayout())
+ Layout();
#endif
}
if (m_winLastFocused)
{
// It might happen that the window got reparented or no longer
- // accepts the focus.
+ // accepts the focus.
if ((m_winLastFocused->GetParent() == this) &&
- (m_winLastFocused->AcceptsFocus()))
+ (m_winLastFocused->AcceptsFocus()))
{
m_winLastFocused->SetFocus();
return;
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
- // for bitmaps, DIBs will also do
- return (::IsClipboardFormatAvailable(dataFormat) != 0) ||
- (dataFormat.GetFormatId() == CF_BITMAP &&
- ::IsClipboardFormatAvailable(CF_DIB));
+ if ( ::IsClipboardFormatAvailable(dataFormat) )
+ {
+ // ok from the first try
+ return TRUE;
+ }
+
+ // for several standard formats, we can convert from some other ones too
+ switch ( dataFormat.GetFormatId() )
+ {
+ // for bitmaps, DIBs will also do
+ case CF_BITMAP:
+ return ::IsClipboardFormatAvailable(CF_DIB) != 0;
+
+#if wxUSE_ENH_METAFILE
+ case CF_METAFILEPICT:
+ return ::IsClipboardFormatAvailable(CF_ENHMETAFILE) != 0;
+#endif // wxUSE_ENH_METAFILE
+
+ default:
+ return FALSE;
+ }
}
bool wxSetClipboardData(wxDataFormat dataFormat,
break;
}
-#if wxUSE_METAFILE
+ // VZ: I'm told that this code works, but it doesn't seem to work for me
+ // and, anyhow, I'd be highly surprized if it did. So I leave it here
+ // but IMNSHO it is completely broken.
+#if wxUSE_METAFILE && !defined(wxMETAFILE_IS_ENH)
case wxDF_METAFILE:
{
wxMetafile *wxMF = (wxMetafile *)data;
handle = SetClipboardData(CF_METAFILEPICT, data);
break;
}
-#endif
+#endif // wxUSE_METAFILE
+
+#if wxUSE_ENH_METAFILE
+ case wxDF_ENHMETAFILE:
+ {
+ wxEnhMetaFile *emf = (wxEnhMetaFile *)data;
+ wxEnhMetaFile emfCopy = *emf;
+
+ handle = SetClipboardData(CF_ENHMETAFILE,
+ (void *)emfCopy.GetHENHMETAFILE());
+ }
+ break;
+#endif // wxUSE_ENH_METAFILE
+
case CF_SYLK:
case CF_DIF:
case CF_TIFF:
formatEtc.tymed = TYMED_MFPICT;
break;
+ case CF_ENHMETAFILE:
+ formatEtc.tymed = TYMED_ENHMF;
+ break;
+
default:
formatEtc.tymed = TYMED_HGLOBAL;
}
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: msw/enhmeta.cpp
+// Purpose: implementation of wxEnhMetaFileXXX classes
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 13.01.00
+// RCS-ID: $Id$
+// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Licence: wxWindows license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+ #pragma implementation "enhmeta.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#if wxUSE_ENH_METAFILE
+
+#ifndef WX_PRECOMP
+ #include "wx/string.h"
+ #include "wx/log.h"
+#endif //WX_PRECOMP
+
+#include "wx/metafile.h"
+
+#include "wx/msw/private.h"
+
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxEnhMetaFile, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+#define GetEMF() ((HENHMETAFILE)m_hMF)
+#define GetEMFOf(mf) ((HENHMETAFILE)((mf).m_hMF))
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// we must pass NULL if the string is empty to metafile functions
+static inline const wxChar *GetMetaFileName(const wxString& fn)
+ { return !fn ? (wxChar *)NULL : fn.c_str(); }
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxEnhMetaFile
+// ----------------------------------------------------------------------------
+
+void wxEnhMetaFile::Assign(const wxEnhMetaFile& mf)
+{
+ if ( &mf == this )
+ return;
+
+ if ( mf.m_hMF )
+ {
+ m_hMF = (WXHANDLE)::CopyEnhMetaFile(GetEMFOf(mf),
+ GetMetaFileName(m_filename));
+ if ( !m_hMF )
+ {
+ wxLogLastError(_T("CopyEnhMetaFile"));
+ }
+ }
+ else
+ {
+ m_hMF = 0;
+ }
+}
+
+void wxEnhMetaFile::Free()
+{
+ if ( m_hMF )
+ {
+ if ( !::DeleteEnhMetaFile(GetEMF()) )
+ {
+ wxLogLastError(_T("DeleteEnhMetaFile"));
+ }
+ }
+}
+
+bool wxEnhMetaFile::Play(wxDC *dc, wxRect *rectBound)
+{
+ wxCHECK_MSG( Ok(), FALSE, _T("can't play invalid enhanced metafile") );
+ wxCHECK_MSG( dc, FALSE, _T("invalid wxDC in wxEnhMetaFile::Play") );
+
+ RECT rect;
+ if ( rectBound )
+ {
+ rect.top = rectBound->y;
+ rect.left = rectBound->x;
+ rect.right = rectBound->x + rectBound->width;
+ rect.bottom = rectBound->y + rectBound->height;
+ }
+ else
+ {
+ wxSize size = GetSize();
+
+ rect.top =
+ rect.left = 0;
+ rect.right = size.x;
+ rect.bottom = size.y;
+ }
+
+ if ( !::PlayEnhMetaFile(GetHdcOf(*dc), GetEMF(), &rect) )
+ {
+ wxLogLastError(_T("PlayEnhMetaFile"));
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+wxSize wxEnhMetaFile::GetSize() const
+{
+ wxSize size = wxDefaultSize;
+
+ if ( Ok() )
+ {
+ ENHMETAHEADER hdr;
+ if ( !::GetEnhMetaFileHeader(GetEMF(), sizeof(hdr), &hdr) )
+ {
+ wxLogLastError(_T("GetEnhMetaFileHeader"));
+ }
+ else
+ {
+ // the width and height are in HIMETRIC (0.01mm) units, transform
+ // them to pixels
+ LONG w = hdr.rclFrame.right,
+ h = hdr.rclFrame.bottom;
+
+ HIMETRICToPixel(&w, &h);
+
+ size.x = w;
+ size.y = h;
+ }
+ }
+
+ return size;
+}
+
+// ----------------------------------------------------------------------------
+// wxEnhMetaFileDC
+// ----------------------------------------------------------------------------
+
+wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
+ int width, int height,
+ const wxString& description)
+{
+ ScreenHDC hdcRef;
+
+ RECT rect, *pRect;
+ if ( width && height )
+ {
+ rect.top =
+ rect.left = 0;
+ rect.right = width;
+ rect.bottom = height;
+
+ // CreateEnhMetaFile() wants them in HIMETRIC
+ PixelToHIMETRIC(&rect.right, &rect.bottom);
+
+ pRect = ▭
+ }
+ else
+ {
+ // GDI will try to find out the size for us (not recommended)
+ pRect = (LPRECT)NULL;
+ }
+
+ m_hDC = (WXHDC)::CreateEnhMetaFile(hdcRef, GetMetaFileName(filename),
+ pRect, description);
+ if ( !m_hDC )
+ {
+ wxLogLastError(_T("CreateEnhMetaFile"));
+ }
+}
+
+wxEnhMetaFile *wxEnhMetaFileDC::Close()
+{
+ wxCHECK_MSG( Ok(), NULL, _T("invalid wxEnhMetaFileDC") );
+
+ HENHMETAFILE hMF = ::CloseEnhMetaFile(GetHdc());
+ if ( !hMF )
+ {
+ wxLogLastError(_T("CloseEnhMetaFile"));
+
+ return NULL;
+ }
+
+ wxEnhMetaFile *mf = new wxEnhMetaFile;
+ mf->SetHENHMETAFILE((WXHANDLE)hMF);
+ return mf;
+}
+
+wxEnhMetaFileDC::~wxEnhMetaFileDC()
+{
+ // avoid freeing it in the base class dtor
+ m_hDC = 0;
+}
+
+// ----------------------------------------------------------------------------
+// wxEnhMetaFileDataObject
+// ----------------------------------------------------------------------------
+
+wxDataFormat
+wxEnhMetaFileDataObject::GetPreferredFormat(Direction WXUNUSED(dir)) const
+{
+ return wxDF_ENHMETAFILE;
+}
+
+size_t wxEnhMetaFileDataObject::GetFormatCount(Direction WXUNUSED(dir)) const
+{
+ // wxDF_ENHMETAFILE and wxDF_METAFILE
+ return 2;
+}
+
+void wxEnhMetaFileDataObject::GetAllFormats(wxDataFormat *formats,
+ Direction WXUNUSED(dir)) const
+{
+ formats[0] = wxDF_ENHMETAFILE;
+ formats[1] = wxDF_METAFILE;
+}
+
+size_t wxEnhMetaFileDataObject::GetDataSize(const wxDataFormat& format) const
+{
+ if ( format == wxDF_ENHMETAFILE )
+ {
+ // we pass data by handle and not HGLOBAL
+ return 0u;
+ }
+ else
+ {
+ wxASSERT_MSG( format == wxDF_METAFILE, _T("unsupported format") );
+
+ return sizeof(METAFILEPICT);
+ }
+}
+
+bool wxEnhMetaFileDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
+{
+ wxCHECK_MSG( m_metafile.Ok(), FALSE, _T("copying invalid enh metafile") );
+
+ HENHMETAFILE hEMF = (HENHMETAFILE)m_metafile.GetHENHMETAFILE();
+
+ if ( format == wxDF_ENHMETAFILE )
+ {
+ HENHMETAFILE hEMFCopy = ::CopyEnhMetaFile(hEMF, NULL);
+ if ( !hEMFCopy )
+ {
+ wxLogLastError(_T("CopyEnhMetaFile"));
+
+ return FALSE;
+ }
+
+ *(HENHMETAFILE *)buf = hEMFCopy;
+ }
+ else
+ {
+ wxASSERT_MSG( format == wxDF_METAFILE, _T("unsupported format") );
+
+ // convert to WMF
+
+ ScreenHDC hdc;
+
+ // first get the buffer size and alloc memory
+ size_t size = ::GetWinMetaFileBits(hEMF, 0, NULL, MM_ANISOTROPIC, hdc);
+ wxCHECK_MSG( size, FALSE, _T("GetWinMetaFileBits() failed") );
+
+ BYTE *bits = (BYTE *)malloc(size);
+
+ // then get the enh metafile bits
+ if ( !::GetWinMetaFileBits(hEMF, size, bits, MM_ANISOTROPIC, hdc) )
+ {
+ wxLogLastError(_T("GetWinMetaFileBits"));
+
+ free(bits);
+
+ return FALSE;
+ }
+
+ // and finally convert them to the WMF
+ HMETAFILE hMF = ::SetMetaFileBitsEx(size, bits);
+ free(bits);
+ if ( !hMF )
+ {
+ wxLogLastError(_T("SetMetaFileBitsEx"));
+
+ return FALSE;
+ }
+
+ METAFILEPICT *mfpict = (METAFILEPICT *)buf;
+
+ wxSize sizeMF = m_metafile.GetSize();
+ mfpict->hMF = hMF;
+ mfpict->mm = MM_ANISOTROPIC;
+ mfpict->xExt = sizeMF.x;
+ mfpict->yExt = sizeMF.y;
+
+ PixelToHIMETRIC(&mfpict->xExt, &mfpict->yExt);
+ }
+
+ return TRUE;
+}
+
+bool wxEnhMetaFileDataObject::SetData(const wxDataFormat& format,
+ size_t WXUNUSED(len),
+ const void *buf)
+{
+ HENHMETAFILE hEMF;
+
+ if ( format == wxDF_ENHMETAFILE )
+ {
+ hEMF = *(HENHMETAFILE *)buf;
+
+ wxCHECK_MSG( hEMF, FALSE, _T("pasting invalid enh metafile") );
+ }
+ else
+ {
+ wxASSERT_MSG( format == wxDF_METAFILE, _T("unsupported format") );
+
+ // convert from WMF
+ const METAFILEPICT *mfpict = (const METAFILEPICT *)buf;
+
+ // first get the buffer size
+ size_t size = ::GetMetaFileBitsEx(mfpict->hMF, 0, NULL);
+ wxCHECK_MSG( size, FALSE, _T("GetMetaFileBitsEx() failed") );
+
+ // then get metafile bits
+ BYTE *bits = (BYTE *)malloc(size);
+ if ( !::GetMetaFileBitsEx(mfpict->hMF, size, bits) )
+ {
+ wxLogLastError(_T("GetMetaFileBitsEx"));
+
+ free(bits);
+
+ return FALSE;
+ }
+
+ ScreenHDC hdcRef;
+
+ // and finally create an enhanced metafile from them
+ hEMF = ::SetWinMetaFileBits(size, bits, hdcRef, mfpict);
+ free(bits);
+ if ( !hEMF )
+ {
+ wxLogLastError(_T("SetWinMetaFileBits"));
+
+ return FALSE;
+ }
+ }
+
+ m_metafile.SetHENHMETAFILE((WXHANDLE)hEMF);
+
+ return TRUE;
+}
+
+#endif // wxUSE_ENH_METAFILE
int width = size.x;
int height = size.y;
- long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
+ long msFlags = WS_CHILD | WS_VISIBLE;
#ifndef PBS_VERTICAL
#define PBS_VERTICAL 0x04
-# This file was automatically generated by tmake at 19:06, 2000/01/05
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
#
$(MSWDIR)\dragimag.obj \
$(MSWDIR)\dropsrc.obj \
$(MSWDIR)\droptgt.obj \
+ $(MSWDIR)\enhmeta.obj \
$(MSWDIR)\filedlg.obj \
$(MSWDIR)\font.obj \
$(MSWDIR)\fontdlg.obj \
$(MSWDIR)\droptgt.obj: $(OLEDIR)\droptgt.$(SRCSUFF)
+$(MSWDIR)\enhmeta.obj: $(MSWDIR)\enhmeta.$(SRCSUFF)
+
$(MSWDIR)\filedlg.obj: $(MSWDIR)\filedlg.$(SRCSUFF)
$(MSWDIR)\font.obj: $(MSWDIR)\font.$(SRCSUFF)
-# This file was automatically generated by tmake at 19:06, 2000/01/05
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
#
-# This file was automatically generated by tmake at 19:06, 2000/01/05
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
#
-# This file was automatically generated by tmake at 15:55, 2000/01/12
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
#
$(MSWDIR)/dibutils.$(OBJSUFF) \
$(MSWDIR)/dir.$(OBJSUFF) \
$(MSWDIR)/dragimag.$(OBJSUFF) \
+ $(MSWDIR)/enhmeta.$(OBJSUFF) \
$(MSWDIR)/filedlg.$(OBJSUFF) \
$(MSWDIR)/font.$(OBJSUFF) \
$(MSWDIR)/fontdlg.$(OBJSUFF) \
-# This file was automatically generated by tmake at 19:06, 2000/01/05
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
# Symantec C++ makefile for the msw objects
$(MSWDIR)\dragimag.obj \
$(MSWDIR)\ole\dropsrc.obj \
$(MSWDIR)\ole\droptgt.obj \
+ $(MSWDIR)\enhmeta.obj \
$(MSWDIR)\filedlg.obj \
$(MSWDIR)\font.obj \
$(MSWDIR)\fontdlg.obj \
-# This file was automatically generated by tmake at 19:06, 2000/01/05
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
# File: makefile.vc
..\msw\$D\dragimag.obj \
..\msw\ole\$D\dropsrc.obj \
..\msw\ole\$D\droptgt.obj \
+ ..\msw\$D\enhmeta.obj \
..\msw\$D\filedlg.obj \
..\msw\$D\font.obj \
..\msw\$D\fontdlg.obj \
#!/binb/wmake.exe
-# This file was automatically generated by tmake at 19:06, 2000/01/05
+# This file was automatically generated by tmake at 00:09, 2000/01/14
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
#
dragimag.obj &
dropsrc.obj &
droptgt.obj &
+ enhmeta.obj &
filedlg.obj &
font.obj &
fontdlg.obj &
droptgt.obj: $(OLEDIR)\droptgt.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+enhmeta.obj: $(MSWDIR)\enhmeta.cpp
+ *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
filedlg.obj: $(MSWDIR)\filedlg.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
#include "wx/setup.h"
#endif
-#if wxUSE_METAFILE
-
#ifndef WX_PRECOMP
#include "wx/utils.h"
#include "wx/app.h"
#endif
#include "wx/metafile.h"
+
+#if wxUSE_METAFILE && !defined(wxMETAFILE_IS_ENH)
+
#include "wx/clipbrd.h"
#include "wx/msw/private.h"
dc->BeginDrawing();
if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
- PlayMetaFile(GetHdcOf(*dc), (HMETAFILE) M_METAFILEDATA->m_metafile);
+ {
+ if ( !::PlayMetaFile(GetHdcOf(*dc), (HMETAFILE)
+ M_METAFILEDATA->m_metafile) )
+ {
+ wxLogLastError(_T("PlayMetaFile"));
+ }
+ }
dc->EndDrawing();
bool wxMetafileDataObject::GetDataHere(void *buf) const
{
METAFILEPICT *mfpict = (METAFILEPICT *)buf;
- const wxMetafile mf = GetMetafile();
- mfpict->mm = mf.GetWindowsMappingMode();
+ const wxMetafile& mf = GetMetafile();
+
+ wxCHECK_MSG( mf.GetHMETAFILE(), FALSE, _T("copying invalid metafile") );
+
+ // doesn't seem to work with any other mapping mode...
+ mfpict->mm = MM_ANISOTROPIC; //mf.GetWindowsMappingMode();
mfpict->xExt = mf.GetWidth();
mfpict->yExt = mf.GetHeight();
- mfpict->hMF = (HMETAFILE)mf.GetHMETAFILE();
- wxCHECK_MSG( mfpict->hMF, FALSE, _T("copying invalid metafile") );
+ // transform the picture size to HIMETRIC units (0.01mm) - as we don't know
+ // what DC the picture will be rendered to, use the default display one
+ PixelToHIMETRIC(&mfpict->xExt, &mfpict->yExt);
+
+ mfpict->hMF = CopyMetaFile((HMETAFILE)mf.GetHMETAFILE(), NULL);
return TRUE;
}
wxMetafile mf;
mf.SetWindowsMappingMode(mfpict->mm);
- mf.SetWidth(mfpict->xExt);
- mf.SetHeight(mfpict->yExt);
+
+ int w = mfpict->xExt,
+ h = mfpict->yExt;
+ if ( mfpict->mm == MM_ANISOTROPIC )
+ {
+ // in this case xExt and yExt contain suggested size in HIMETRIC units
+ // (0.01 mm) - transform this to something more reasonable (pixels)
+ HIMETRICToPixel(&w, &h);
+ }
+
+ mf.SetWidth(w);
+ mf.SetHeight(h);
mf.SetHMETAFILE((WXHANDLE)mfpict->hMF);
wxCHECK_MSG( mfpict->hMF, FALSE, _T("pasting invalid metafile") );
// event table
// ----------------------------------------------------------------------------
- BEGIN_EVENT_TABLE(wxNotebook, wxControl)
+BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
- END_EVENT_TABLE()
+END_EVENT_TABLE()
- IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
- IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
// ============================================================================
// implementation
pmedium->tymed = TYMED_GDI;
break;
+ case wxDF_ENHMETAFILE:
+ pmedium->tymed = TYMED_ENHMF;
+ break;
+
case wxDF_METAFILE:
pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
sizeof(METAFILEPICT));
return E_UNEXPECTED;
break;
+ case TYMED_ENHMF:
+ if ( !m_pDataObject->GetDataHere(wxDF_ENHMETAFILE,
+ &pmedium->hEnhMetaFile) )
+ return E_UNEXPECTED;
+ break;
+
case TYMED_MFPICT:
+ // fall through - we pass METAFILEPICT through HGLOBAL
+
case TYMED_HGLOBAL:
{
// copy data
m_pDataObject->SetData(wxDF_BITMAP, 0, &pmedium->hBitmap);
break;
+ case TYMED_ENHMF:
+ m_pDataObject->SetData(wxDF_ENHMETAFILE, 0, &pmedium->hEnhMetaFile);
+ break;
+
case TYMED_MFPICT:
+ // fall through - we pass METAFILEPICT through HGLOBAL
case TYMED_HGLOBAL:
{
wxDataFormat format = pformatetc->cfFormat;
case TYMED_MFPICT:
pmedium->hMetaFilePict = 0;
break;
+
+ case TYMED_ENHMF:
+ pmedium->hEnhMetaFile = 0;
+ break;
}
ReleaseStgMedium(pmedium);
m_pIDataObject = NULL;
}
-bool wxDataObject::IsSupportedFormat(const wxDataFormat& format) const
-{
- size_t nFormatCount = GetFormatCount();
- if ( nFormatCount == 1 ) {
- return format == GetPreferredFormat();
- }
- else {
- wxDataFormat *formats = new wxDataFormat[nFormatCount];
- GetAllFormats(formats);
+#ifdef __WXDEBUG__
- size_t n;
- for ( n = 0; n < nFormatCount; n++ ) {
- if ( formats[n] == format )
- break;
- }
+const char *wxDataObject::GetFormatName(wxDataFormat format)
+{
+ // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
+ #ifdef __VISUALC__
+ #pragma warning(disable:4063)
+ #endif // VC++
+
+ static char s_szBuf[256];
+ switch ( format ) {
+ case CF_TEXT: return "CF_TEXT";
+ case CF_BITMAP: return "CF_BITMAP";
+ case CF_METAFILEPICT: return "CF_METAFILEPICT";
+ case CF_SYLK: return "CF_SYLK";
+ case CF_DIF: return "CF_DIF";
+ case CF_TIFF: return "CF_TIFF";
+ case CF_OEMTEXT: return "CF_OEMTEXT";
+ case CF_DIB: return "CF_DIB";
+ case CF_PALETTE: return "CF_PALETTE";
+ case CF_PENDATA: return "CF_PENDATA";
+ case CF_RIFF: return "CF_RIFF";
+ case CF_WAVE: return "CF_WAVE";
+ case CF_UNICODETEXT: return "CF_UNICODETEXT";
+ case CF_ENHMETAFILE: return "CF_ENHMETAFILE";
+ case CF_HDROP: return "CF_HDROP";
+ case CF_LOCALE: return "CF_LOCALE";
- delete [] formats;
+ default:
+ if ( !GetClipboardFormatName(format, s_szBuf, WXSIZEOF(s_szBuf)) )
+ {
+ // it must be a new predefined format we don't know the name of
+ sprintf(s_szBuf, "unknown CF (0x%04x)", format);
+ }
- // found?
- return n < nFormatCount;
+ return s_szBuf;
}
-}
-#ifdef __WXDEBUG__
-
-const char *wxDataObject::GetFormatName(wxDataFormat format)
-{
- // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
- #ifdef __VISUALC__
- #pragma warning(disable:4063)
- #endif // VC++
-
- static char s_szBuf[128];
- switch ( format ) {
- case CF_TEXT: return "CF_TEXT";
- case CF_BITMAP: return "CF_BITMAP";
- case CF_METAFILEPICT: return "CF_METAFILEPICT";
- case CF_SYLK: return "CF_SYLK";
- case CF_DIF: return "CF_DIF";
- case CF_TIFF: return "CF_TIFF";
- case CF_OEMTEXT: return "CF_OEMTEXT";
- case CF_DIB: return "CF_DIB";
- case CF_PALETTE: return "CF_PALETTE";
- case CF_PENDATA: return "CF_PENDATA";
- case CF_RIFF: return "CF_RIFF";
- case CF_WAVE: return "CF_WAVE";
- case CF_UNICODETEXT: return "CF_UNICODETEXT";
- case CF_ENHMETAFILE: return "CF_ENHMETAFILE";
- case CF_HDROP: return "CF_HDROP";
- case CF_LOCALE: return "CF_LOCALE";
- default:
- sprintf(s_szBuf, "clipboard format 0x%x (unknown)", format);
- return s_szBuf;
- }
-
- #ifdef __VISUALC__
- #pragma warning(default:4063)
- #endif // VC++
+ #ifdef __VISUALC__
+ #pragma warning(default:4063)
+ #endif // VC++
}
#endif // Debug
delete choices2;
}
-#endif
+#endif // WXWIN_COMPATIBILITY
// Radio box item
wxRadioBox::wxRadioBox()
return FALSE;
// create the static box
- if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, title, 0) )
+ if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX | WS_GROUP,
+ pos, size, title, 0) )
return FALSE;
// and now create the buttons
// For now, instead of this, we just add all radiobox buttons to the
// tooltip control as well (see SetWindow) - this is probably less
// efficient, but it works.
-#define wxUSE_TTM_WINDOWFROMPOINT 0
+#define wxUSE_TTM_WINDOWFROMPOINT 1
// ----------------------------------------------------------------------------
// global variables
Add(m_window->GetHWND());
}
+#if 1 //!wxUSE_TTM_WINDOWFROMPOINT
// and all of its subcontrols (e.g. radiobuttons in a radiobox) as well
wxControl *control = wxDynamicCast(m_window, wxControl);
if ( control )
}
}
}
+#endif // !wxUSE_TTM_WINDOWFROMPOINT
}
void wxToolTip::SetTip(const wxString& tip)
return wxExecute(command, sync, handler);
}
+// ----------------------------------------------------------------------------
+// Metafile helpers
+// ----------------------------------------------------------------------------
+
+extern void PixelToHIMETRIC(LONG *x, LONG *y)
+{
+ ScreenHDC hdcRef;
+
+ int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
+ iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
+ iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
+ iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
+
+ *x *= (iWidthMM * 100);
+ *x /= iWidthPels;
+ *y *= (iHeightMM * 100);
+ *y /= iHeightPels;
+}
+
+extern void HIMETRICToPixel(LONG *x, LONG *y)
+{
+ ScreenHDC hdcRef;
+
+ int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE),
+ iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE),
+ iWidthPels = GetDeviceCaps(hdcRef, HORZRES),
+ iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
+
+ *x *= iWidthPels;
+ *x /= (iWidthMM * 100);
+ *y *= iHeightPels;
+ *y /= (iHeightMM * 100);
+}
#include "wx/intl.h"
#include "wx/log.h"
-
#include "wx/textctrl.h"
+#include "wx/notebook.h"
#include <string.h>
{
// intercept dialog navigation keys
MSG *msg = (MSG *)pMsg;
+
+ // here we try to do all the job which ::IsDialogMessage() usually does
+ // internally
+#if 0
bool bProcess = TRUE;
if ( msg->message != WM_KEYDOWN )
bProcess = FALSE;
}
}
}
+#else
+ // let ::IsDialogMessage() do almost everything and handle just the
+ // things it doesn't here: Ctrl-TAB for switching notebook pages
+ if ( msg->message == WM_KEYDOWN )
+ {
+ // don't process system keys here
+ if ( !(HIWORD(msg->lParam) & KF_ALTDOWN) )
+ {
+ if ( (msg->wParam == VK_TAB) &&
+ (::GetKeyState(VK_CONTROL) & 0x100) != 0 )
+ {
+ // find the first notebook parent and change its page
+ wxWindow *win = this;
+ wxNotebook *nbook = NULL;
+ while ( win && !nbook )
+ {
+ nbook = wxDynamicCast(win, wxNotebook);
+ win = win->GetParent();
+ }
+
+ if ( nbook )
+ {
+ bool forward = !(::GetKeyState(VK_SHIFT) & 0x100);
+
+ nbook->AdvanceSelection(forward);
+ }
+ }
+ }
+ }
+#endif // 0
if ( ::IsDialogMessage(GetHwnd(), msg) )
return TRUE;