From d9317fd47263a9521466156d7bf0f7988000bf15 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 13 Jan 2000 23:39:48 +0000 Subject: [PATCH] 1. added wxEnhMetaFileXXX classes 2. fixed/added copy/paste for metafiles git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 5 +- distrib/msw/tmake/filelist.txt | 2 + docs/changes.txt | 4 +- include/wx/dataobj.h | 3 + include/wx/metafile.h | 39 +++- include/wx/msw/enhmeta.h | 130 +++++++++++ include/wx/msw/gauge95.h | 3 + include/wx/msw/gaugemsw.h | 3 + include/wx/msw/metafile.h | 10 +- include/wx/msw/ole/dataobj.h | 3 +- include/wx/msw/private.h | 5 + include/wx/msw/setup0.h | 23 +- src/common/dobjcmn.cpp | 27 +++ src/generic/panelg.cpp | 7 +- src/msw/clipbrd.cpp | 49 ++++- src/msw/enhmeta.cpp | 380 +++++++++++++++++++++++++++++++++ src/msw/gauge95.cpp | 2 +- src/msw/makefile.b32 | 5 +- src/msw/makefile.bcc | 2 +- src/msw/makefile.dos | 2 +- src/msw/makefile.g95 | 3 +- src/msw/makefile.sc | 3 +- src/msw/makefile.vc | 3 +- src/msw/makefile.wat | 6 +- src/msw/metafile.cpp | 42 +++- src/msw/notebook.cpp | 8 +- src/msw/ole/dataobj.cpp | 110 +++++----- src/msw/radiobox.cpp | 5 +- src/msw/tooltip.cpp | 4 +- src/msw/utilsexc.cpp | 33 +++ src/msw/window.cpp | 36 +++- 31 files changed, 853 insertions(+), 104 deletions(-) create mode 100644 include/wx/msw/enhmeta.h create mode 100644 src/msw/enhmeta.cpp diff --git a/Makefile.in b/Makefile.in index 69e475d840..44451c8b8c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# 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! # @@ -527,6 +527,7 @@ MSW_HEADERS = \ msw/dibutils.h \ msw/dirdlg.h \ msw/dragimag.h \ + msw/enhmeta.h \ msw/filedlg.h \ msw/font.h \ msw/fontdlg.h \ @@ -1769,6 +1770,7 @@ MSW_GUIOBJS = \ dibutils.o \ dir.o \ dragimag.o \ + enhmeta.o \ filedlg.o \ font.o \ fontdlg.o \ @@ -1860,6 +1862,7 @@ MSW_GUIDEPS = \ dibutils.d \ dir.d \ dragimag.d \ + enhmeta.d \ filedlg.d \ font.d \ fontdlg.d \ diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index afca277b0b..af41b40f68 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -232,6 +232,7 @@ dirdlg.cpp M 32 dragimag.cpp M dropsrc.cpp M O droptgt.cpp M O +enhmeta.cpp M 32 filedlg.cpp M font.cpp M fontdlg.cpp M @@ -862,6 +863,7 @@ dib.h 9 dibutils.h 9 dirdlg.h 9 dragimag.h 9 +enhmeta.h 9 32 filedlg.h 9 font.h 9 fontdlg.h 9 diff --git a/docs/changes.txt b/docs/changes.txt index 8adf6fd3ca..f5d72a1ffa 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -50,10 +50,12 @@ all (GUI): 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: diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 08171926b8..544d90ef13 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -146,6 +146,9 @@ public: { return FALSE; } + + // returns TRUE if this format is supported + bool IsSupported(const wxDataFormat& format, Direction dir = Get) const; }; // ---------------------------------------------------------------------------- diff --git a/include/wx/metafile.h b/include/wx/metafile.h index 17aebfdcc8..48cd91d597 100644 --- a/include/wx/metafile.h +++ b/include/wx/metafile.h @@ -1,11 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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 diff --git a/include/wx/msw/enhmeta.h b/include/wx/msw/enhmeta.h new file mode 100644 index 0000000000..a7f235453d --- /dev/null +++ b/include/wx/msw/enhmeta.h @@ -0,0 +1,130 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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 +// 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_ diff --git a/include/wx/msw/gauge95.h b/include/wx/msw/gauge95.h index 11e77bc685..3cb7379a65 100644 --- a/include/wx/msw/gauge95.h +++ b/include/wx/msw/gauge95.h @@ -60,6 +60,9 @@ public: 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); } diff --git a/include/wx/msw/gaugemsw.h b/include/wx/msw/gaugemsw.h index 7f0a1f39f3..78cf35fc14 100644 --- a/include/wx/msw/gaugemsw.h +++ b/include/wx/msw/gaugemsw.h @@ -60,6 +60,9 @@ public: 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); } diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h index f6381d489e..c1a648fd24 100644 --- a/include/wx/msw/metafile.h +++ b/include/wx/msw/metafile.h @@ -27,13 +27,6 @@ #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 // ---------------------------------------------------------------------------- @@ -70,6 +63,7 @@ public: 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; } @@ -99,7 +93,7 @@ class WXDLLEXPORT wxMetafileDC: public wxDC 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. diff --git a/include/wx/msw/ole/dataobj.h b/include/wx/msw/ole/dataobj.h index 31af6d7da8..dd2d0cf503 100644 --- a/include/wx/msw/ole/dataobj.h +++ b/include/wx/msw/ole/dataobj.h @@ -37,7 +37,8 @@ public: 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) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index e0d3918849..f489158d1a 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -224,6 +224,11 @@ inline void wxRGBToColour(wxColour& c, COLORREF rgb) 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 // --------------------------------------------------------------------------- diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index c6de668c61..24ca1412a7 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -160,6 +160,27 @@ #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 // ---------------------------------------------------------------------------- @@ -168,8 +189,6 @@ // 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! diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index bf6ecc3dc9..aadd3914f3 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -61,6 +61,33 @@ wxDataObjectBase::~wxDataObjectBase() { } +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 // ---------------------------------------------------------------------------- diff --git a/src/generic/panelg.cpp b/src/generic/panelg.cpp index a652192722..e2b2c838e7 100644 --- a/src/generic/panelg.cpp +++ b/src/generic/panelg.cpp @@ -179,7 +179,8 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event ) void wxPanel::OnSize(wxSizeEvent& WXUNUSED(event)) { #if wxUSE_CONSTRAINTS - if (GetAutoLayout()) Layout(); + if (GetAutoLayout()) + Layout(); #endif } @@ -215,9 +216,9 @@ void wxPanel::OnFocus(wxFocusEvent& event) 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; diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index e02807caaa..1166f73e33 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -146,10 +146,27 @@ bool wxIsClipboardOpened() 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, @@ -208,7 +225,10 @@ 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; @@ -225,7 +245,20 @@ bool wxSetClipboardData(wxDataFormat dataFormat, 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: @@ -688,6 +721,10 @@ bool wxClipboard::GetData( wxDataObject& data ) formatEtc.tymed = TYMED_MFPICT; break; + case CF_ENHMETAFILE: + formatEtc.tymed = TYMED_ENHMF; + break; + default: formatEtc.tymed = TYMED_HGLOBAL; } diff --git a/src/msw/enhmeta.cpp b/src/msw/enhmeta.cpp new file mode 100644 index 0000000000..6602ce9a24 --- /dev/null +++ b/src/msw/enhmeta.cpp @@ -0,0 +1,380 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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 +// 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 diff --git a/src/msw/gauge95.cpp b/src/msw/gauge95.cpp index 38b99d60dc..74e1649158 100644 --- a/src/msw/gauge95.cpp +++ b/src/msw/gauge95.cpp @@ -67,7 +67,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id, 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 diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index b8fb7f9e5e..9bcffc4f6b 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -1,6 +1,6 @@ -# 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! # @@ -243,6 +243,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \ $(MSWDIR)\dragimag.obj \ $(MSWDIR)\dropsrc.obj \ $(MSWDIR)\droptgt.obj \ + $(MSWDIR)\enhmeta.obj \ $(MSWDIR)\filedlg.obj \ $(MSWDIR)\font.obj \ $(MSWDIR)\fontdlg.obj \ @@ -442,6 +443,8 @@ $(MSWDIR)\dropsrc.obj: $(OLEDIR)\dropsrc.$(SRCSUFF) $(MSWDIR)\droptgt.obj: $(OLEDIR)\droptgt.$(SRCSUFF) +$(MSWDIR)\enhmeta.obj: $(MSWDIR)\enhmeta.$(SRCSUFF) + $(MSWDIR)\filedlg.obj: $(MSWDIR)\filedlg.$(SRCSUFF) $(MSWDIR)\font.obj: $(MSWDIR)\font.$(SRCSUFF) diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index ba2d0c7ca3..4708312ca9 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -1,6 +1,6 @@ -# 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! # diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index f818a5491d..c88274dc83 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -1,4 +1,4 @@ -# 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! # diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index 619081eeda..7bb5fb33d6 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -1,4 +1,4 @@ -# 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! # @@ -240,6 +240,7 @@ MSWOBJS = \ $(MSWDIR)/dibutils.$(OBJSUFF) \ $(MSWDIR)/dir.$(OBJSUFF) \ $(MSWDIR)/dragimag.$(OBJSUFF) \ + $(MSWDIR)/enhmeta.$(OBJSUFF) \ $(MSWDIR)/filedlg.$(OBJSUFF) \ $(MSWDIR)/font.$(OBJSUFF) \ $(MSWDIR)/fontdlg.$(OBJSUFF) \ diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index 875c0a3c5c..3a3ce79e3d 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -1,6 +1,6 @@ -# 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 @@ -181,6 +181,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \ $(MSWDIR)\dragimag.obj \ $(MSWDIR)\ole\dropsrc.obj \ $(MSWDIR)\ole\droptgt.obj \ + $(MSWDIR)\enhmeta.obj \ $(MSWDIR)\filedlg.obj \ $(MSWDIR)\font.obj \ $(MSWDIR)\fontdlg.obj \ diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index eb11156d80..af305fa68c 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -1,4 +1,4 @@ -# 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 @@ -260,6 +260,7 @@ MSWOBJS = ..\msw\$D\accel.obj \ ..\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 \ diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index 9c90e01dfb..c5cbd08416 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -1,6 +1,6 @@ #!/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! # @@ -215,6 +215,7 @@ MSWOBJS = accel.obj & dragimag.obj & dropsrc.obj & droptgt.obj & + enhmeta.obj & filedlg.obj & font.obj & fontdlg.obj & @@ -411,6 +412,9 @@ dropsrc.obj: $(OLEDIR)\dropsrc.cpp droptgt.obj: $(OLEDIR)\droptgt.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< +enhmeta.obj: $(MSWDIR)\enhmeta.cpp + *$(CCC) $(CPPFLAGS) $(IFLAGS) $< + filedlg.obj: $(MSWDIR)\filedlg.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp index 69bca27a24..eb13f6384f 100644 --- a/src/msw/metafile.cpp +++ b/src/msw/metafile.cpp @@ -32,14 +32,15 @@ #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" @@ -128,7 +129,13 @@ bool wxMetafile::Play(wxDC *dc) 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(); @@ -458,13 +465,20 @@ size_t wxMetafileDataObject::GetDataSize() const 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; } @@ -475,8 +489,18 @@ bool wxMetafileDataObject::SetData(size_t WXUNUSED(len), const void *buf) 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") ); diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 43b70d1dbb..185a915c58 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -83,7 +83,7 @@ // event table // ---------------------------------------------------------------------------- - BEGIN_EVENT_TABLE(wxNotebook, wxControl) +BEGIN_EVENT_TABLE(wxNotebook, wxControl) EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) EVT_SIZE(wxNotebook::OnSize) @@ -91,10 +91,10 @@ 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 diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 14d98afe93..71572064ba 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -297,6 +297,10 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) 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)); @@ -363,7 +367,15 @@ STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc, 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 @@ -409,7 +421,12 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, 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; @@ -502,6 +519,10 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, case TYMED_MFPICT: pmedium->hMetaFilePict = 0; break; + + case TYMED_ENHMF: + pmedium->hEnhMetaFile = 0; + break; } ReleaseStgMedium(pmedium); @@ -652,64 +673,47 @@ void wxDataObject::SetAutoDelete() 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 diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 26868c3ec0..857106acb0 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -156,7 +156,7 @@ wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title, delete choices2; } -#endif +#endif // WXWIN_COMPATIBILITY // Radio box item wxRadioBox::wxRadioBox() @@ -194,7 +194,8 @@ bool wxRadioBox::Create(wxWindow *parent, 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 diff --git a/src/msw/tooltip.cpp b/src/msw/tooltip.cpp index f594903e77..2b6f2f5575 100644 --- a/src/msw/tooltip.cpp +++ b/src/msw/tooltip.cpp @@ -43,7 +43,7 @@ // 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 @@ -282,6 +282,7 @@ void wxToolTip::SetWindow(wxWindow *win) 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 ) @@ -298,6 +299,7 @@ void wxToolTip::SetWindow(wxWindow *win) } } } +#endif // !wxUSE_TTM_WINDOWFROMPOINT } void wxToolTip::SetTip(const wxString& tip) diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 9d778c9d5b..6df190c161 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -373,3 +373,36 @@ long wxExecute(char **argv, bool sync, wxProcess *handler) 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); +} diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 5592a346bc..b7552a3d6c 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -74,8 +74,8 @@ #include "wx/intl.h" #include "wx/log.h" - #include "wx/textctrl.h" +#include "wx/notebook.h" #include @@ -1469,6 +1469,10 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) { // 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; @@ -1586,6 +1590,36 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) } } } +#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; -- 2.45.2