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
This commit is contained in:
Vadim Zeitlin
2000-01-13 23:39:48 +00:00
parent 02b6f53109
commit d9317fd472
31 changed files with 852 additions and 103 deletions

View File

@@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
# #
@@ -527,6 +527,7 @@ MSW_HEADERS = \
msw/dibutils.h \ msw/dibutils.h \
msw/dirdlg.h \ msw/dirdlg.h \
msw/dragimag.h \ msw/dragimag.h \
msw/enhmeta.h \
msw/filedlg.h \ msw/filedlg.h \
msw/font.h \ msw/font.h \
msw/fontdlg.h \ msw/fontdlg.h \
@@ -1769,6 +1770,7 @@ MSW_GUIOBJS = \
dibutils.o \ dibutils.o \
dir.o \ dir.o \
dragimag.o \ dragimag.o \
enhmeta.o \
filedlg.o \ filedlg.o \
font.o \ font.o \
fontdlg.o \ fontdlg.o \
@@ -1860,6 +1862,7 @@ MSW_GUIDEPS = \
dibutils.d \ dibutils.d \
dir.d \ dir.d \
dragimag.d \ dragimag.d \
enhmeta.d \
filedlg.d \ filedlg.d \
font.d \ font.d \
fontdlg.d \ fontdlg.d \

View File

@@ -232,6 +232,7 @@ dirdlg.cpp M 32
dragimag.cpp M dragimag.cpp M
dropsrc.cpp M O dropsrc.cpp M O
droptgt.cpp M O droptgt.cpp M O
enhmeta.cpp M 32
filedlg.cpp M filedlg.cpp M
font.cpp M font.cpp M
fontdlg.cpp M fontdlg.cpp M
@@ -862,6 +863,7 @@ dib.h 9
dibutils.h 9 dibutils.h 9
dirdlg.h 9 dirdlg.h 9
dragimag.h 9 dragimag.h 9
enhmeta.h 9 32
filedlg.h 9 filedlg.h 9
font.h 9 font.h 9
fontdlg.h 9 fontdlg.h 9

View File

@@ -50,10 +50,12 @@ all (GUI):
wxMSW: wxMSW:
- support for enhanced metafiles added, support for copying/pasting metafiles
(WMF and enhanced ones) fixed/added.
- implemented setting colours for push buttons - implemented setting colours for push buttons
- wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun) - wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
- tooltips work with wxRadioBox
- loading/saving big (> 32K) files in wxTextCtrl works - loading/saving big (> 32K) files in wxTextCtrl works
- tooltips work with wxRadioBox
- returning FALSE from OnPrintPage() aborts printing - returning FALSE from OnPrintPage() aborts printing
wxGTK: wxGTK:

View File

@@ -146,6 +146,9 @@ public:
{ {
return FALSE; return FALSE;
} }
// returns TRUE if this format is supported
bool IsSupported(const wxDataFormat& format, Direction dir = Get) const;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -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_ #ifndef _WX_METAFILE_H_BASE_
#define _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__) #if defined(__WXMSW__)
#include "wx/msw/metafile.h" #if defined(__WIN32__) && wxUSE_ENH_METAFILE
#endif #include "wx/msw/enhmeta.h"
#if defined(__WXPM__)
#include "wx/os2/metafile.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
#endif #endif

130
include/wx/msw/enhmeta.h Normal file
View File

@@ -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 <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_

View File

@@ -60,6 +60,9 @@ public:
bool SetForegroundColour(const wxColour& col); bool SetForegroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col); bool SetBackgroundColour(const wxColour& col);
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
// Backward compatibility // Backward compatibility
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
void SetButtonColour(const wxColour& col) { SetForegroundColour(col); } void SetButtonColour(const wxColour& col) { SetForegroundColour(col); }

View File

@@ -60,6 +60,9 @@ public:
bool SetForegroundColour(const wxColour& col); bool SetForegroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col); bool SetBackgroundColour(const wxColour& col);
// overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; }
// Backward compatibility // Backward compatibility
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
void SetButtonColour(const wxColour& col) { SetForegroundColour(col); } void SetButtonColour(const wxColour& col) { SetForegroundColour(col); }

View File

@@ -27,13 +27,6 @@
#include "wx/dataobj.h" #include "wx/dataobj.h"
#endif #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 // Metafile and metafile device context classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -70,6 +63,7 @@ public:
bool Ok() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); }; bool Ok() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
// set/get the size of metafile for clipboard operations // 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 GetWidth() const { return M_METAFILEDATA->m_width; }
int GetHeight() const { return M_METAFILEDATA->m_height; } int GetHeight() const { return M_METAFILEDATA->m_height; }
@@ -99,7 +93,7 @@ class WXDLLEXPORT wxMetafileDC: public wxDC
public: public:
// Don't supply origin and extent // Don't supply origin and extent
// Supply them to wxMakeMetaFilePlaceable instead. // Supply them to wxMakeMetaFilePlaceable instead.
wxMetafileDC(const wxString& file = ""); wxMetafileDC(const wxString& file = wxEmptyString);
// Supply origin and extent (recommended). // Supply origin and extent (recommended).
// Then don't need to supply them to wxMakeMetaFilePlaceable. // Then don't need to supply them to wxMakeMetaFilePlaceable.

View File

@@ -37,7 +37,8 @@ public:
void SetAutoDelete(); void SetAutoDelete();
// return TRUE if we support this format in "Get" direction // 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__ #ifdef __WXDEBUG__
// function to return symbolic name of clipboard format (for debug messages) // function to return symbolic name of clipboard format (for debug messages)

View File

@@ -224,6 +224,11 @@ inline void wxRGBToColour(wxColour& c, COLORREF rgb)
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(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 // small helper classes
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -160,6 +160,27 @@
#define wxUSE_CARET 1 #define wxUSE_CARET 1
#define wxUSE_SLIDER 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 // Postscript support settings
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -168,8 +189,6 @@
// 0 for no PostScript device context // 0 for no PostScript device context
#define wxUSE_AFM_FOR_POSTSCRIPT 0 #define wxUSE_AFM_FOR_POSTSCRIPT 0
// 1 to use font metric files in GetTextExtent // 1 to use font metric files in GetTextExtent
#define wxUSE_METAFILE 1
// 0 for no Metafile and metafile device context
#define wxUSE_IPC 1 #define wxUSE_IPC 1
// 0 for no interprocess comms // 0 for no interprocess comms
// Note: wxHELP uses IPC under X so these are interdependent! // Note: wxHELP uses IPC under X so these are interdependent!

View File

@@ -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 // wxDataObjectComposite
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -179,7 +179,8 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
void wxPanel::OnSize(wxSizeEvent& WXUNUSED(event)) void wxPanel::OnSize(wxSizeEvent& WXUNUSED(event))
{ {
#if wxUSE_CONSTRAINTS #if wxUSE_CONSTRAINTS
if (GetAutoLayout()) Layout(); if (GetAutoLayout())
Layout();
#endif #endif
} }

View File

@@ -146,10 +146,27 @@ bool wxIsClipboardOpened()
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{ {
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 // for bitmaps, DIBs will also do
return (::IsClipboardFormatAvailable(dataFormat) != 0) || case CF_BITMAP:
(dataFormat.GetFormatId() == CF_BITMAP && return ::IsClipboardFormatAvailable(CF_DIB) != 0;
::IsClipboardFormatAvailable(CF_DIB));
#if wxUSE_ENH_METAFILE
case CF_METAFILEPICT:
return ::IsClipboardFormatAvailable(CF_ENHMETAFILE) != 0;
#endif // wxUSE_ENH_METAFILE
default:
return FALSE;
}
} }
bool wxSetClipboardData(wxDataFormat dataFormat, bool wxSetClipboardData(wxDataFormat dataFormat,
@@ -208,7 +225,10 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
break; 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: case wxDF_METAFILE:
{ {
wxMetafile *wxMF = (wxMetafile *)data; wxMetafile *wxMF = (wxMetafile *)data;
@@ -225,7 +245,20 @@ bool wxSetClipboardData(wxDataFormat dataFormat,
handle = SetClipboardData(CF_METAFILEPICT, data); handle = SetClipboardData(CF_METAFILEPICT, data);
break; 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_SYLK:
case CF_DIF: case CF_DIF:
case CF_TIFF: case CF_TIFF:
@@ -688,6 +721,10 @@ bool wxClipboard::GetData( wxDataObject& data )
formatEtc.tymed = TYMED_MFPICT; formatEtc.tymed = TYMED_MFPICT;
break; break;
case CF_ENHMETAFILE:
formatEtc.tymed = TYMED_ENHMF;
break;
default: default:
formatEtc.tymed = TYMED_HGLOBAL; formatEtc.tymed = TYMED_HGLOBAL;
} }

380
src/msw/enhmeta.cpp Normal file
View File

@@ -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 <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 = &rect;
}
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

View File

@@ -67,7 +67,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
int width = size.x; int width = size.x;
int height = size.y; int height = size.y;
long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP; long msFlags = WS_CHILD | WS_VISIBLE;
#ifndef PBS_VERTICAL #ifndef PBS_VERTICAL
#define PBS_VERTICAL 0x04 #define PBS_VERTICAL 0x04

View File

@@ -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! # 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)\dragimag.obj \
$(MSWDIR)\dropsrc.obj \ $(MSWDIR)\dropsrc.obj \
$(MSWDIR)\droptgt.obj \ $(MSWDIR)\droptgt.obj \
$(MSWDIR)\enhmeta.obj \
$(MSWDIR)\filedlg.obj \ $(MSWDIR)\filedlg.obj \
$(MSWDIR)\font.obj \ $(MSWDIR)\font.obj \
$(MSWDIR)\fontdlg.obj \ $(MSWDIR)\fontdlg.obj \
@@ -442,6 +443,8 @@ $(MSWDIR)\dropsrc.obj: $(OLEDIR)\dropsrc.$(SRCSUFF)
$(MSWDIR)\droptgt.obj: $(OLEDIR)\droptgt.$(SRCSUFF) $(MSWDIR)\droptgt.obj: $(OLEDIR)\droptgt.$(SRCSUFF)
$(MSWDIR)\enhmeta.obj: $(MSWDIR)\enhmeta.$(SRCSUFF)
$(MSWDIR)\filedlg.obj: $(MSWDIR)\filedlg.$(SRCSUFF) $(MSWDIR)\filedlg.obj: $(MSWDIR)\filedlg.$(SRCSUFF)
$(MSWDIR)\font.obj: $(MSWDIR)\font.$(SRCSUFF) $(MSWDIR)\font.obj: $(MSWDIR)\font.$(SRCSUFF)

View File

@@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
# #

View File

@@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
# #

View File

@@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
# #
@@ -240,6 +240,7 @@ MSWOBJS = \
$(MSWDIR)/dibutils.$(OBJSUFF) \ $(MSWDIR)/dibutils.$(OBJSUFF) \
$(MSWDIR)/dir.$(OBJSUFF) \ $(MSWDIR)/dir.$(OBJSUFF) \
$(MSWDIR)/dragimag.$(OBJSUFF) \ $(MSWDIR)/dragimag.$(OBJSUFF) \
$(MSWDIR)/enhmeta.$(OBJSUFF) \
$(MSWDIR)/filedlg.$(OBJSUFF) \ $(MSWDIR)/filedlg.$(OBJSUFF) \
$(MSWDIR)/font.$(OBJSUFF) \ $(MSWDIR)/font.$(OBJSUFF) \
$(MSWDIR)/fontdlg.$(OBJSUFF) \ $(MSWDIR)/fontdlg.$(OBJSUFF) \

View File

@@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
# Symantec C++ makefile for the msw objects # Symantec C++ makefile for the msw objects
@@ -181,6 +181,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
$(MSWDIR)\dragimag.obj \ $(MSWDIR)\dragimag.obj \
$(MSWDIR)\ole\dropsrc.obj \ $(MSWDIR)\ole\dropsrc.obj \
$(MSWDIR)\ole\droptgt.obj \ $(MSWDIR)\ole\droptgt.obj \
$(MSWDIR)\enhmeta.obj \
$(MSWDIR)\filedlg.obj \ $(MSWDIR)\filedlg.obj \
$(MSWDIR)\font.obj \ $(MSWDIR)\font.obj \
$(MSWDIR)\fontdlg.obj \ $(MSWDIR)\fontdlg.obj \

View File

@@ -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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
# File: makefile.vc # File: makefile.vc
@@ -260,6 +260,7 @@ MSWOBJS = ..\msw\$D\accel.obj \
..\msw\$D\dragimag.obj \ ..\msw\$D\dragimag.obj \
..\msw\ole\$D\dropsrc.obj \ ..\msw\ole\$D\dropsrc.obj \
..\msw\ole\$D\droptgt.obj \ ..\msw\ole\$D\droptgt.obj \
..\msw\$D\enhmeta.obj \
..\msw\$D\filedlg.obj \ ..\msw\$D\filedlg.obj \
..\msw\$D\font.obj \ ..\msw\$D\font.obj \
..\msw\$D\fontdlg.obj \ ..\msw\$D\fontdlg.obj \

View File

@@ -1,6 +1,6 @@
#!/binb/wmake.exe #!/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! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
# #
@@ -215,6 +215,7 @@ MSWOBJS = accel.obj &
dragimag.obj & dragimag.obj &
dropsrc.obj & dropsrc.obj &
droptgt.obj & droptgt.obj &
enhmeta.obj &
filedlg.obj & filedlg.obj &
font.obj & font.obj &
fontdlg.obj & fontdlg.obj &
@@ -411,6 +412,9 @@ dropsrc.obj: $(OLEDIR)\dropsrc.cpp
droptgt.obj: $(OLEDIR)\droptgt.cpp droptgt.obj: $(OLEDIR)\droptgt.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $< *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
enhmeta.obj: $(MSWDIR)\enhmeta.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
filedlg.obj: $(MSWDIR)\filedlg.cpp filedlg.obj: $(MSWDIR)\filedlg.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $< *$(CCC) $(CPPFLAGS) $(IFLAGS) $<

View File

@@ -32,14 +32,15 @@
#include "wx/setup.h" #include "wx/setup.h"
#endif #endif
#if wxUSE_METAFILE
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/app.h" #include "wx/app.h"
#endif #endif
#include "wx/metafile.h" #include "wx/metafile.h"
#if wxUSE_METAFILE && !defined(wxMETAFILE_IS_ENH)
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
@@ -128,7 +129,13 @@ bool wxMetafile::Play(wxDC *dc)
dc->BeginDrawing(); dc->BeginDrawing();
if (dc->GetHDC() && M_METAFILEDATA->m_metafile) 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(); dc->EndDrawing();
@@ -458,13 +465,20 @@ size_t wxMetafileDataObject::GetDataSize() const
bool wxMetafileDataObject::GetDataHere(void *buf) const bool wxMetafileDataObject::GetDataHere(void *buf) const
{ {
METAFILEPICT *mfpict = (METAFILEPICT *)buf; METAFILEPICT *mfpict = (METAFILEPICT *)buf;
const wxMetafile mf = GetMetafile(); const wxMetafile& mf = GetMetafile();
mfpict->mm = mf.GetWindowsMappingMode();
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->xExt = mf.GetWidth();
mfpict->yExt = mf.GetHeight(); 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; return TRUE;
} }
@@ -475,8 +489,18 @@ bool wxMetafileDataObject::SetData(size_t WXUNUSED(len), const void *buf)
wxMetafile mf; wxMetafile mf;
mf.SetWindowsMappingMode(mfpict->mm); 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); mf.SetHMETAFILE((WXHANDLE)mfpict->hMF);
wxCHECK_MSG( mfpict->hMF, FALSE, _T("pasting invalid metafile") ); wxCHECK_MSG( mfpict->hMF, FALSE, _T("pasting invalid metafile") );

View File

@@ -83,7 +83,7 @@
// event table // event table
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxNotebook, wxControl) BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize) EVT_SIZE(wxNotebook::OnSize)
@@ -91,10 +91,10 @@
EVT_SET_FOCUS(wxNotebook::OnSetFocus) EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
// ============================================================================ // ============================================================================
// implementation // implementation

View File

@@ -297,6 +297,10 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
pmedium->tymed = TYMED_GDI; pmedium->tymed = TYMED_GDI;
break; break;
case wxDF_ENHMETAFILE:
pmedium->tymed = TYMED_ENHMF;
break;
case wxDF_METAFILE: case wxDF_METAFILE:
pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
sizeof(METAFILEPICT)); sizeof(METAFILEPICT));
@@ -363,7 +367,15 @@ STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
return E_UNEXPECTED; return E_UNEXPECTED;
break; break;
case TYMED_ENHMF:
if ( !m_pDataObject->GetDataHere(wxDF_ENHMETAFILE,
&pmedium->hEnhMetaFile) )
return E_UNEXPECTED;
break;
case TYMED_MFPICT: case TYMED_MFPICT:
// fall through - we pass METAFILEPICT through HGLOBAL
case TYMED_HGLOBAL: case TYMED_HGLOBAL:
{ {
// copy data // copy data
@@ -409,7 +421,12 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
m_pDataObject->SetData(wxDF_BITMAP, 0, &pmedium->hBitmap); m_pDataObject->SetData(wxDF_BITMAP, 0, &pmedium->hBitmap);
break; break;
case TYMED_ENHMF:
m_pDataObject->SetData(wxDF_ENHMETAFILE, 0, &pmedium->hEnhMetaFile);
break;
case TYMED_MFPICT: case TYMED_MFPICT:
// fall through - we pass METAFILEPICT through HGLOBAL
case TYMED_HGLOBAL: case TYMED_HGLOBAL:
{ {
wxDataFormat format = pformatetc->cfFormat; wxDataFormat format = pformatetc->cfFormat;
@@ -502,6 +519,10 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
case TYMED_MFPICT: case TYMED_MFPICT:
pmedium->hMetaFilePict = 0; pmedium->hMetaFilePict = 0;
break; break;
case TYMED_ENHMF:
pmedium->hEnhMetaFile = 0;
break;
} }
ReleaseStgMedium(pmedium); ReleaseStgMedium(pmedium);
@@ -652,29 +673,6 @@ void wxDataObject::SetAutoDelete()
m_pIDataObject = NULL; 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);
size_t n;
for ( n = 0; n < nFormatCount; n++ ) {
if ( formats[n] == format )
break;
}
delete [] formats;
// found?
return n < nFormatCount;
}
}
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
const char *wxDataObject::GetFormatName(wxDataFormat format) const char *wxDataObject::GetFormatName(wxDataFormat format)
@@ -684,7 +682,7 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
#pragma warning(disable:4063) #pragma warning(disable:4063)
#endif // VC++ #endif // VC++
static char s_szBuf[128]; static char s_szBuf[256];
switch ( format ) { switch ( format ) {
case CF_TEXT: return "CF_TEXT"; case CF_TEXT: return "CF_TEXT";
case CF_BITMAP: return "CF_BITMAP"; case CF_BITMAP: return "CF_BITMAP";
@@ -702,8 +700,14 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
case CF_ENHMETAFILE: return "CF_ENHMETAFILE"; case CF_ENHMETAFILE: return "CF_ENHMETAFILE";
case CF_HDROP: return "CF_HDROP"; case CF_HDROP: return "CF_HDROP";
case CF_LOCALE: return "CF_LOCALE"; case CF_LOCALE: return "CF_LOCALE";
default: default:
sprintf(s_szBuf, "clipboard format 0x%x (unknown)", format); 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);
}
return s_szBuf; return s_szBuf;
} }

View File

@@ -156,7 +156,7 @@ wxRadioBox::wxRadioBox(wxWindow *parent, wxFunction func, const char *title,
delete choices2; delete choices2;
} }
#endif #endif // WXWIN_COMPATIBILITY
// Radio box item // Radio box item
wxRadioBox::wxRadioBox() wxRadioBox::wxRadioBox()
@@ -194,7 +194,8 @@ bool wxRadioBox::Create(wxWindow *parent,
return FALSE; return FALSE;
// create the static box // 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; return FALSE;
// and now create the buttons // and now create the buttons

View File

@@ -43,7 +43,7 @@
// For now, instead of this, we just add all radiobox buttons to the // For now, instead of this, we just add all radiobox buttons to the
// tooltip control as well (see SetWindow) - this is probably less // tooltip control as well (see SetWindow) - this is probably less
// efficient, but it works. // efficient, but it works.
#define wxUSE_TTM_WINDOWFROMPOINT 0 #define wxUSE_TTM_WINDOWFROMPOINT 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global variables // global variables
@@ -282,6 +282,7 @@ void wxToolTip::SetWindow(wxWindow *win)
Add(m_window->GetHWND()); Add(m_window->GetHWND());
} }
#if 1 //!wxUSE_TTM_WINDOWFROMPOINT
// and all of its subcontrols (e.g. radiobuttons in a radiobox) as well // and all of its subcontrols (e.g. radiobuttons in a radiobox) as well
wxControl *control = wxDynamicCast(m_window, wxControl); wxControl *control = wxDynamicCast(m_window, wxControl);
if ( control ) if ( control )
@@ -298,6 +299,7 @@ void wxToolTip::SetWindow(wxWindow *win)
} }
} }
} }
#endif // !wxUSE_TTM_WINDOWFROMPOINT
} }
void wxToolTip::SetTip(const wxString& tip) void wxToolTip::SetTip(const wxString& tip)

View File

@@ -373,3 +373,36 @@ long wxExecute(char **argv, bool sync, wxProcess *handler)
return wxExecute(command, sync, 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);
}

View File

@@ -74,8 +74,8 @@
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/notebook.h"
#include <string.h> #include <string.h>
@@ -1469,6 +1469,10 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
{ {
// intercept dialog navigation keys // intercept dialog navigation keys
MSG *msg = (MSG *)pMsg; MSG *msg = (MSG *)pMsg;
// here we try to do all the job which ::IsDialogMessage() usually does
// internally
#if 0
bool bProcess = TRUE; bool bProcess = TRUE;
if ( msg->message != WM_KEYDOWN ) if ( msg->message != WM_KEYDOWN )
bProcess = FALSE; 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) ) if ( ::IsDialogMessage(GetHwnd(), msg) )
return TRUE; return TRUE;