now MSW stuff is complete

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-05-20 14:21:00 +00:00
parent 2bda0e1738
commit bbf1f0e5cf
118 changed files with 9265 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#
# File: makefile.b32
# Author: Andre Beltman
# Created: 1995
# Updated:
# Copyright: (c) 1995, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Imports 32bit ctl3d library for Windows 95
# and Borland C++ 4.x
WXDIR = $(WXWIN)
WXLIB = $(WXDIR)\lib
LIBTARGET= $(WXLIB)\ctl3d32.lib
all: $(LIBTARGET)
$(LIBTARGET):
erase $(LIBTARGET)
implib $(LIBTARGET) ..\ctl3d32.dll
clean:
-erase $(LIBTARGET)

View File

@@ -0,0 +1,25 @@
#
# File: makefile.b32
# Author: Andre Beltman
# Created: 1995
# Updated:
# Copyright: (c) 1995, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Imports ctl3d library
# and Borland C++ 4.x
WXDIR = $(WXWIN)
WXLIB = $(WXDIR)\lib
LIBTARGET= $(WXLIB)\ctl3dv2.lib
all: $(LIBTARGET)
$(LIBTARGET):
erase $(LIBTARGET)
implib $(LIBTARGET) ..\ctl3dv2.dll
clean:
-erase $(LIBTARGET)

BIN
src/msw/ctl3d/ctl3d.dll Normal file

Binary file not shown.

BIN
src/msw/ctl3d/ctl3d32.dll Normal file

Binary file not shown.

BIN
src/msw/ctl3d/ctl3dv2.dll Normal file

Binary file not shown.

View File

@@ -0,0 +1,61 @@
/*-----------------------------------------------------------------------
| CTL3D.DLL
|
| Adds 3d effects to Windows controls
|
| See ctl3d.doc for info
|
-----------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
BOOL WINAPI Ctl3dSubclassDlg(HWND, WORD);
BOOL WINAPI Ctl3dSubclassDlgEx(HWND, DWORD);
WORD WINAPI Ctl3dGetVer(void);
BOOL WINAPI Ctl3dEnabled(void);
HBRUSH WINAPI Ctl3dCtlColor(HDC, LONG); // ARCHAIC, use Ctl3dCtlColorEx
HBRUSH WINAPI Ctl3dCtlColorEx(UINT wm, WPARAM wParam, LPARAM lParam);
BOOL WINAPI Ctl3dColorChange(void);
BOOL WINAPI Ctl3dSubclassCtl(HWND);
LONG WINAPI Ctl3dDlgFramePaint(HWND, UINT, WPARAM, LPARAM);
BOOL WINAPI Ctl3dAutoSubclass(HANDLE);
BOOL WINAPI Ctl3dRegister(HANDLE);
BOOL WINAPI Ctl3dUnregister(HANDLE);
//begin DBCS: far east short cut key support
VOID WINAPI Ctl3dWinIniChange(void);
//end DBCS
/* Ctl3dSubclassDlg3d flags */
#define CTL3D_BUTTONS 0x0001
#define CTL3D_LISTBOXES 0x0002
#define CTL3D_EDITS 0x0004
#define CTL3D_COMBOS 0x0008
#define CTL3D_STATICTEXTS 0x0010
#define CTL3D_STATICFRAMES 0x0020
#define CTL3D_NODLGWINDOW 0x00010000
#define CTL3D_ALL 0xffff
#define WM_DLGBORDER (WM_USER+3567)
/* WM_DLGBORDER *(int FAR *)lParam return codes */
#define CTL3D_NOBORDER 0
#define CTL3D_BORDER 1
#define WM_DLGSUBCLASS (WM_USER+3568)
/* WM_DLGSUBCLASS *(int FAR *)lParam return codes */
#define CTL3D_NOSUBCLASS 0
#define CTL3D_SUBCLASS 1
/* Resource ID for 3dcheck.bmp (for .lib version of ctl3d) */
#define CTL3D_3DCHECK 26567
#ifdef __cplusplus
}
#endif

Binary file not shown.

Binary file not shown.

31
src/msw/ctl3d/readme.txt Normal file
View File

@@ -0,0 +1,31 @@
CTL3D
-----
CTL3D gives 3D controls to 16-bit Windows 3.1 applications.
Its use in wxWindows is controlled by the CTL3D symbol
in include/base/wx_setup.h.
If using a 16-bit compiler, copy ctl3dv2.lib to your compiler
library directory, and remember to distribute ctl3dv2.dll
with your applications. The DLL should be copied to
windows/system and DELETED from the application installation
directory.
If using Watcom C++ in 386 mode, things are slightly more complex: you need
to link with Patrick Halke's ctl3d32.obj which provides an interface
from 32-bits to the 16-bit CTL3DV2 library. Link your application
with ctl3d32.obj file instead of ctl3dv2.lib, distributing
ctl3dv2.dll as above.
ctl3d.dll ; Version 1 of the CTL3D library DLL: obsolete
ctl3dv2.dll ; Version 2 of the CTL3D library DLL
readme.txt ; This file
msvc/ctl3d.h ; Header file for either version of CTL3D
msvc/ctl3d.lib ; Import library for 16-bit compilers
watcom/import32.zip ; Import libraries for Watcom WIN32 compilation
wat386/ ; Source & objects for Watcom 386 object file to
; interface 16<->32 bit modes
borland/ ; Makefiles for making import libraries for Borland

Binary file not shown.

View File

@@ -0,0 +1,61 @@
/*-----------------------------------------------------------------------
| CTL3D.DLL
|
| Adds 3d effects to Windows controls
|
| See ctl3d.doc for info
|
-----------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
BOOL WINAPI Ctl3dSubclassDlg(HWND, WORD);
BOOL WINAPI Ctl3dSubclassDlgEx(HWND, DWORD);
WORD WINAPI Ctl3dGetVer(void);
BOOL WINAPI Ctl3dEnabled(void);
HBRUSH WINAPI Ctl3dCtlColor(HDC, LONG); // ARCHAIC, use Ctl3dCtlColorEx
HBRUSH WINAPI Ctl3dCtlColorEx(UINT wm, WPARAM wParam, LPARAM lParam);
BOOL WINAPI Ctl3dColorChange(void);
BOOL WINAPI Ctl3dSubclassCtl(HWND);
LONG WINAPI Ctl3dDlgFramePaint(HWND, UINT, WPARAM, LPARAM);
BOOL WINAPI Ctl3dAutoSubclass(HANDLE);
BOOL WINAPI Ctl3dRegister(HANDLE);
BOOL WINAPI Ctl3dUnregister(HANDLE);
//begin DBCS: far east short cut key support
VOID WINAPI Ctl3dWinIniChange(void);
//end DBCS
/* Ctl3dSubclassDlg3d flags */
#define CTL3D_BUTTONS 0x0001
#define CTL3D_LISTBOXES 0x0002
#define CTL3D_EDITS 0x0004
#define CTL3D_COMBOS 0x0008
#define CTL3D_STATICTEXTS 0x0010
#define CTL3D_STATICFRAMES 0x0020
#define CTL3D_NODLGWINDOW 0x00010000
#define CTL3D_ALL 0xffff
#define WM_DLGBORDER (WM_USER+3567)
/* WM_DLGBORDER *(int FAR *)lParam return codes */
#define CTL3D_NOBORDER 0
#define CTL3D_BORDER 1
#define WM_DLGSUBCLASS (WM_USER+3568)
/* WM_DLGSUBCLASS *(int FAR *)lParam return codes */
#define CTL3D_NOSUBCLASS 0
#define CTL3D_SUBCLASS 1
/* Resource ID for 3dcheck.bmp (for .lib version of ctl3d) */
#define CTL3D_3DCHECK 26567
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,285 @@
/*
* File: ctl3d32.c
* Purpose: 32bit interface to CTL3D functions for Watcom C/C++
* Author: Patrick Halke
* Created: 1995
* Updated:
* Copyright: (c) 1995
*/
#include <malloc.h>
#include <windows.h>
#include "ctl3d.h"
#if defined(__WINDOWS_386__)
#ifdef __cplusplus
extern "C" {
#endif
#undef FAR
#define FAR
#define INDIR_INT INDIR_WORD
#define INDIR_UINT INDIR_WORD
#define INDIR_WPARAM INDIR_UINT
#define INDIR_LPARAM INDIR_DWORD
#define INDIR_LONG INDIR_DWORD
#define INDIR_ULONG INDIR_DWORD
#ifdef STRICT
#define INDIR_HANDLE INDIR_PTR
#define INDIR_HWND INDIR_PTR
#define INDIR_HDC INDIR_PTR
#else
#define INDIR_HANDLE INDIR_UINT
#define INDIR_HWND INDIR_UINT
#define INDIR_HDC INDIR_UINT
#endif
typedef struct tagCTL3DFUNCTIONS {
HINSTANCE dll;
/* Function Handles */
HINDIR _Ctl3dSubclassDlg;
HINDIR _Ctl3dSubclassDlgEx;
HINDIR _Ctl3dGetVer;
HINDIR _Ctl3dEnabled;
HINDIR _Ctl3dCtlColor;
HINDIR _Ctl3dCtlColorEx;
HINDIR _Ctl3dColorChange;
HINDIR _Ctl3dSubclassCtl;
HINDIR _Ctl3dDlgFramePaint;
HINDIR _Ctl3dAutoSubclass;
HINDIR _Ctl3dRegister;
HINDIR _Ctl3dUnregister;
HINDIR _Ctl3dWinIniChange;
} CTL3DFUNCTIONS;
static CTL3DFUNCTIONS Ctl3dFunc = { 0 };
static BOOL load_functions( CTL3DFUNCTIONS* functions )
{
FARPROC proc;
HINSTANCE dll;
dll = LoadLibrary( "CTL3D.DLL" );
if( dll < HINSTANCE_ERROR ) {
return( FALSE );
}
/* Function thunks */
proc = GetProcAddress(dll, "Ctl3dSubclassDlg");
functions->_Ctl3dSubclassDlg = GetIndirectFunctionHandle( proc,
INDIR_HWND,
INDIR_WORD,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dSubclassDlgEx" );
functions->_Ctl3dSubclassDlgEx = GetIndirectFunctionHandle( proc,
INDIR_HWND,
INDIR_DWORD,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dGetVer" );
functions->_Ctl3dGetVer = GetIndirectFunctionHandle( proc,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dEnabled" );
functions->_Ctl3dEnabled = GetIndirectFunctionHandle( proc,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dCtlColor" );
functions->_Ctl3dCtlColor = GetIndirectFunctionHandle( proc,
INDIR_HDC,
INDIR_LONG,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dCtlColorEx" );
functions->_Ctl3dCtlColorEx = GetIndirectFunctionHandle( proc,
INDIR_UINT,
INDIR_WPARAM,
INDIR_LPARAM,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dColorChange" );
functions->_Ctl3dColorChange = GetIndirectFunctionHandle( proc,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dSubclassCtl" );
functions->_Ctl3dSubclassCtl = GetIndirectFunctionHandle( proc,
INDIR_HWND,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dDlgFramePaint" );
functions->_Ctl3dDlgFramePaint = GetIndirectFunctionHandle( proc,
INDIR_HWND,
INDIR_UINT,
INDIR_WPARAM,
INDIR_LPARAM,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dAutoSubclass" );
functions->_Ctl3dAutoSubclass = GetIndirectFunctionHandle( proc,
INDIR_HANDLE,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dRegister" );
functions->_Ctl3dRegister = GetIndirectFunctionHandle( proc,
INDIR_HANDLE,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dUnregister" );
functions->_Ctl3dUnregister = GetIndirectFunctionHandle( proc,
INDIR_HANDLE,
INDIR_ENDLIST );
proc = GetProcAddress( dll, "Ctl3dWinIniChange" );
functions->_Ctl3dWinIniChange = GetIndirectFunctionHandle( proc,
INDIR_ENDLIST );
functions->dll = dll;
return( TRUE );
}
static void unload_functions( CTL3DFUNCTIONS * functions )
{
FreeLibrary( functions->dll );
functions->dll = 0;
}
/* Function Definitions */
BOOL WINAPI Ctl3dSubclassDlg(HWND hwnd, WORD w)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dSubclassDlg,
hwnd, w);
}
BOOL WINAPI Ctl3dSubclassDlgEx(HWND hwnd, DWORD dw)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dSubclassDlgEx,
hwnd, dw);
}
WORD WINAPI Ctl3dGetVer(void)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (WORD)InvokeIndirectFunction(Ctl3dFunc._Ctl3dGetVer);
}
BOOL WINAPI Ctl3dEnabled(void)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dEnabled);
}
HBRUSH WINAPI Ctl3dCtlColor(HDC hdc, LONG l)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (HBRUSH)InvokeIndirectFunction(Ctl3dFunc._Ctl3dCtlColor,
hdc, l);
}
HBRUSH WINAPI Ctl3dCtlColorEx(UINT ui, WPARAM wp, LPARAM lp)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (HBRUSH)InvokeIndirectFunction(Ctl3dFunc._Ctl3dCtlColorEx,
ui, wp, lp);
}
BOOL WINAPI Ctl3dColorChange(void)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dColorChange);
}
BOOL WINAPI Ctl3dSubclassCtl(HWND hwnd)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dSubclassCtl,
hwnd);
}
LONG WINAPI Ctl3dDlgFramePaint(HWND hwnd, UINT ui, WPARAM wp, LPARAM lp)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (LONG)InvokeIndirectFunction(Ctl3dFunc._Ctl3dDlgFramePaint,
hwnd, ui, wp, lp);
}
BOOL WINAPI Ctl3dAutoSubclass(HANDLE hnd)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dAutoSubclass,
hnd);
}
BOOL WINAPI Ctl3dRegister(HANDLE hnd)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dRegister,
hnd);
}
BOOL WINAPI Ctl3dUnregister(HANDLE hnd)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return FALSE;
return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dUnregister,
hnd);
}
VOID WINAPI Ctl3dWinIniChange(void)
{
if (!Ctl3dFunc.dll)
if (!load_functions(&Ctl3dFunc))
return;
InvokeIndirectFunction(Ctl3dFunc._Ctl3dWinIniChange);
}
#ifdef __cplusplus
}
#endif
#endif // __WINDOWS_386__

View File

@@ -0,0 +1 @@
+-ctl3d32.obj

Binary file not shown.

View File

@@ -0,0 +1,11 @@
Using this package should be no big problem. You only need to change your
wx_setup.h for including the CTL3D stuff, compile ctl3d32.c and add
ctl3d32.obj to wx.lib (or just link it with your application).
Please send bug reports to 'patrick@zaphod.ruhr.de'.
Good luck
- patrick

View File

@@ -0,0 +1,23 @@
CC = wcc386
CXX = wpp386
LIB = wlib
IFLAGS = -i=..\\..\\include\\base;..\\..\\include\\msw
CFLAGS = $(IFLAGS) -zq -zW -w1 -d2 -ot -3 -dwx_msw
WXDIR = ..\\..
LIBTARGET = $(WXDIR)\\lib\\wx.lib
C_SRCS = ctl3d32.c
OBJECTS = $(C_SRCS:.c=.obj) $(CC_SRCS:.cc=.obj)
.c.obj:
$(CC) $(CFLAGS) $<
.cc.obj:
$(CXX) $(CFLAGS) $<
all: $(OBJECTS) $(LIBTARGET)
$(LIBTARGET): $(OBJECTS)
$(LIB) /P=256 $(LIBTARGET) @ctl3d32.lnk

459
src/msw/ole/droptgt.cpp Normal file
View File

@@ -0,0 +1,459 @@
///////////////////////////////////////////////////////////////////////////////
// Name: ole/droptgt.cpp
// Purpose: wxDropTarget implementation
// Author: Vadim Zeitlin
// Modified by:
// Created:
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// Declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "droptgt.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#define IN_WX_MAIN_CPP
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#include <wx/setup.h>
#if USE_DRAG_AND_DROP
#include <wx/log.h>
#ifdef __WIN32__
#ifndef __GNUWIN32__
#include <shlobj.h> // for DROPFILES structure
#endif
#else
#include <shellapi.h>
#endif
#include <wx/msw/ole/droptgt.h>
#ifndef __WIN32__
#include <ole2.h>
#include <olestd.h>
#endif
#include <wx/msw/ole/oleutils.h>
// ----------------------------------------------------------------------------
// IDropTarget interface: forward all interesting things to wxDropTarget
// (the name is unfortunate, but wx_I_DropTarget is not at all the same thing
// as wxDropTarget which is 'public' class, while this one is private)
// ----------------------------------------------------------------------------
class wxIDropTarget : public IDropTarget
{
public:
wxIDropTarget(wxDropTarget *p);
~wxIDropTarget();
// IDropTarget methods
STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
STDMETHODIMP DragLeave(void);
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
// @@ we assume that if QueryGetData() returns S_OK, than we can really
// get data in this format, so we remember here the format for which
// QueryGetData() succeeded
void SetSupportedFormat(wxDataFormat cfFormat) { m_cfFormat = cfFormat; }
DECLARE_IUNKNOWN_METHODS;
protected:
IDataObject *m_pIDataObject; // !NULL between DragEnter and DragLeave/Drop
wxDropTarget *m_pTarget; // the real target (we're just a proxy)
wxDataFormat m_cfFormat; // the format in which to ask for data
private:
static inline DWORD GetDropEffect(DWORD flags);
};
// ============================================================================
// wxIDropTarget implementation
// ============================================================================
// Name : static wxDropTarget::GetDropEffect
// Purpose : determine the drop operation from keyboard/mouse state.
// Returns : DWORD combined from DROPEFFECT_xxx constants
// Params : [in] DWORD flags kbd & mouse flags as passed to
// IDropTarget methods
// Notes : We do "move" normally and "copy" if <Ctrl> is pressed,
// which is the standard behaviour (currently there is no
// way to redefine it)
DWORD wxIDropTarget::GetDropEffect(DWORD flags)
{
return flags & MK_CONTROL ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
}
wxIDropTarget::wxIDropTarget(wxDropTarget *pTarget)
{
m_cRef = 0;
m_pTarget = pTarget;
m_cfFormat = 0;
m_pIDataObject = NULL;
}
wxIDropTarget::~wxIDropTarget()
{
}
BEGIN_IID_TABLE(wxIDropTarget)
ADD_IID(Unknown)
ADD_IID(DropTarget)
END_IID_TABLE;
IMPLEMENT_IUNKNOWN_METHODS(wxIDropTarget)
#if 0
STDMETHODIMP wxIDropTarget::QueryInterface(REFIID riid, void **ppv)
{
// wxLogQueryInterface(wxIDropTarget, riid);
if ( IsIidFromList(riid, ms_aIids, WXSIZEOF(ms_aIids)) ) {
*ppv = this;
AddRef();
return S_OK;
}
else {
*ppv = NULL;
return (HRESULT) E_NOINTERFACE;
}
}
STDMETHODIMP_(ULONG) wxIDropTarget::AddRef()
{
wxLogAddRef(wxIDropTarget, m_cRef);
return ++m_cRef;
}
STDMETHODIMP_(ULONG) wxIDropTarget::Release()
{
wxLogRelease(wxIDropTarget, m_cRef);
if ( --m_cRef == 0 ) {
delete this;
return 0;
}
else
return m_cRef;
}
#endif
// Name : wxIDropTarget::DragEnter
// Purpose : Called when the mouse enters the window (dragging something)
// Returns : S_OK
// Params : [in] IDataObject *pIDataSource : source data
// [in] DWORD grfKeyState : kbd & mouse state
// [in] POINTL pt : mouse coordinates
// [out]DWORD *pdwEffect : effect flag
// Notes :
STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
DWORD grfKeyState,
POINTL pt,
DWORD *pdwEffect)
{
wxLogDebug("IDropTarget::DragEnter");
wxASSERT( m_pIDataObject == NULL );
if ( !m_pTarget->IsAcceptedData(pIDataSource) ) {
// we don't accept this kind of data
*pdwEffect = DROPEFFECT_NONE;
return S_OK;
}
// @@ should check the point also?
*pdwEffect = GetDropEffect(grfKeyState);
// get hold of the data object
m_pIDataObject = pIDataSource;
m_pIDataObject->AddRef();
// give some visual feedback
m_pTarget->OnEnter();
return S_OK;
}
// Name : wxIDropTarget::DragOver
// Purpose : Indicates that the mouse was moved inside the window represented
// by this drop target.
// Returns : S_OK
// Params : [in] DWORD grfKeyState kbd & mouse state
// [in] POINTL pt mouse coordinates
// [out]LPDWORD pdwEffect effect flag
// Notes : We're called on every WM_MOUSEMOVE, so this function should be
// very efficient.
STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
POINTL pt,
LPDWORD pdwEffect)
{
// there are too many of them... wxLogDebug("IDropTarget::DragOver");
*pdwEffect = m_pIDataObject == NULL ? DROPEFFECT_NONE
: GetDropEffect(grfKeyState);
return S_OK;
}
// Name : wxIDropTarget::DragLeave
// Purpose : Informs the drop target that the operation has left its window.
// Returns : S_OK
// Notes : good place to do any clean-up
STDMETHODIMP wxIDropTarget::DragLeave()
{
wxLogDebug("IDropTarget::DragLeave");
// remove the UI feedback
m_pTarget->OnLeave();
// release the held object
RELEASE_AND_NULL(m_pIDataObject);
return S_OK;
}
// Name : wxIDropTarget::Drop
// Purpose : Instructs the drop target to paste data that was just now
// dropped on it.
// Returns : S_OK
// Params : [in] IDataObject *pIDataSource the data to paste
// [in] DWORD grfKeyState kbd & mouse state
// [in] POINTL pt where the drop occured?
// [ouy]DWORD *pdwEffect operation effect
// Notes :
STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
DWORD grfKeyState,
POINTL pt,
DWORD *pdwEffect)
{
wxLogDebug("IDropTarget::Drop");
// @@ I don't know why there is this parameter, but so far I assume
// that it's the same we've already got in DragEnter
wxASSERT( m_pIDataObject == pIDataSource );
STGMEDIUM stm;
*pdwEffect = DROPEFFECT_NONE;
// should be set by SetSupportedFormat() call
wxASSERT( m_cfFormat != 0 );
FORMATETC fmtMemory;
fmtMemory.cfFormat = m_cfFormat;
fmtMemory.ptd = NULL;
fmtMemory.dwAspect = DVASPECT_CONTENT;
fmtMemory.lindex = -1;
fmtMemory.tymed = TYMED_HGLOBAL; // @@@@ to add other media
HRESULT hr = pIDataSource->GetData(&fmtMemory, &stm);
if ( SUCCEEDED(hr) ) {
if ( stm.hGlobal != NULL ) {
if ( m_pTarget->OnDrop(pt.x, pt.y, GlobalLock(stm.hGlobal)) )
*pdwEffect = GetDropEffect(grfKeyState);
//else: DROPEFFECT_NONE
GlobalUnlock(stm.hGlobal);
ReleaseStgMedium(&stm);
}
}
else
{
// wxLogApiError("GetData", hr);
}
// release the held object
RELEASE_AND_NULL(m_pIDataObject);
return S_OK;
}
// ============================================================================
// wxDropTarget implementation
// ============================================================================
// ----------------------------------------------------------------------------
// ctor/dtor
// ----------------------------------------------------------------------------
wxDropTarget::wxDropTarget()
{
// create an IDropTarget implementation which will notify us about
// d&d operations.
m_pIDropTarget = new wxIDropTarget(this);
m_pIDropTarget->AddRef();
}
wxDropTarget::~wxDropTarget()
{
ReleaseInterface(m_pIDropTarget);
}
// ----------------------------------------------------------------------------
// [un]register drop handler
// ----------------------------------------------------------------------------
bool wxDropTarget::Register(WXHWND hwnd)
{
HRESULT hr = ::CoLockObjectExternal(m_pIDropTarget, TRUE, FALSE);
if ( FAILED(hr) ) {
// wxLogApiError("CoLockObjectExternal", hr);
return FALSE;
}
hr = ::RegisterDragDrop((HWND) hwnd, m_pIDropTarget);
if ( FAILED(hr) ) {
::CoLockObjectExternal(m_pIDropTarget, FALSE, FALSE);
// wxLogApiError("RegisterDragDrop", hr);
return FALSE;
}
return TRUE;
}
void wxDropTarget::Revoke(WXHWND hwnd)
{
HRESULT hr = ::RevokeDragDrop((HWND) hwnd);
if ( FAILED(hr) )
{
// wxLogApiError("RevokeDragDrop", hr);
}
::CoLockObjectExternal(m_pIDropTarget, FALSE, TRUE);
}
// ----------------------------------------------------------------------------
// determine if we accept data of this type
// ----------------------------------------------------------------------------
bool wxDropTarget::IsAcceptedData(IDataObject *pIDataSource) const
{
// this strucutre describes a data of any type (first field will be
// changing) being passed through global memory block.
static FORMATETC s_fmtMemory = {
0,
NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
// cycle thorugh all supported formats
for ( size_t n = 0; n < GetFormatCount(); n++ ) {
s_fmtMemory.cfFormat = GetFormat(n);
// @ don't use SUCCEEDED macro here: QueryGetData returns 1 (whatever it
// means) for file drag and drop
if ( pIDataSource->QueryGetData(&s_fmtMemory) == S_OK ) {
// remember this format: we'll later ask for data in it
m_pIDropTarget->SetSupportedFormat(s_fmtMemory.cfFormat);
return TRUE;
}
}
return FALSE;
}
// ============================================================================
// wxTextDropTarget
// ============================================================================
bool wxTextDropTarget::OnDrop(long x, long y, const void *pData)
{
return OnDropText(x, y, (const char *)pData);
}
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
}
wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
return CF_TEXT;
}
// ============================================================================
// wxFileDropTarget
// ============================================================================
bool wxFileDropTarget::OnDrop(long x, long y, const void *pData)
{
// the documentation states that the first member of DROPFILES structure
// is a "DWORD offset of double NUL terminated file list". What they mean by
// this (I wonder if you see it immediately) is that the list starts at
// ((char *)&(pDropFiles.pFiles)) + pDropFiles.pFiles. We're also advised to
// use DragQueryFile to work with this structure, but not told where and how
// to get HDROP.
HDROP hdrop = (HDROP)pData; // @@ it works, but I'm not sure about it
// get number of files (magic value -1)
UINT nFiles = ::DragQueryFile(hdrop, -1, NULL, 0);
// for each file get the length, allocate memory and then get the name
char **aszFiles = new char *[nFiles];
UINT len, n;
for ( n = 0; n < nFiles; n++ ) {
// +1 for terminating NUL
len = ::DragQueryFile(hdrop, n, NULL, 0) + 1;
aszFiles[n] = new char[len];
UINT len2 = ::DragQueryFile(hdrop, n, aszFiles[n], len);
if ( len2 != len - 1 ) {
wxLogDebug("In wxFileDropTarget::OnDrop DragQueryFile returned %d "
"characters, %d expected.", len2, len - 1);
}
}
bool bResult = OnDropFiles(x, y, nFiles, (const char**) aszFiles);
// free memory
for ( n = 0; n < nFiles; n++ ) {
delete [] aszFiles[n];
}
delete [] aszFiles;
return bResult;
}
size_t wxFileDropTarget::GetFormatCount() const
{
return 1;
}
wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
#ifdef __WIN32__
return CF_HDROP;
#else
// TODO: how to implement this in WIN16?
return CF_TEXT;
#endif
}
#endif
// USE_DRAG_AND_DROP

193
src/msw/ole/oleutils.cpp Normal file
View File

@@ -0,0 +1,193 @@
///////////////////////////////////////////////////////////////////////////////
// Name: ole/oleutils.cpp
// Purpose: implementation of OLE helper functions
// Author: Vadim Zeitlin
// Modified by:
// Created: 19.02.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// Declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "oleutils.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#define IN_WX_MAIN_CPP
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#include <wx/setup.h>
#if USE_DRAG_AND_DROP
#include <wx/log.h>
#include <windows.h>
// OLE
#include <wx/msw/ole/uuid.h>
#include <wx/msw/ole/oleutils.h>
#ifndef __BORLANDC__
#include <docobj.h>
#endif
// ============================================================================
// Implementation
// ============================================================================
// return TRUE if the iid is in the array
bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount)
{
for ( size_t i = 0; i < nCount; i++ ) {
if ( riid == *aIids[i] )
return TRUE;
}
return FALSE;
}
// ----------------------------------------------------------------------------
// Debug support
// ----------------------------------------------------------------------------
#ifdef __DEBUG__
const char *GetIidName(REFIID riid)
{
// an association between symbolic name and numeric value of an IID
struct KNOWN_IID {
const IID *pIid;
const char *szName;
};
// construct the table containing all known interfaces
#define ADD_KNOWN_IID(name) { &IID_I##name, #name }
static const KNOWN_IID aKnownIids[] = {
ADD_KNOWN_IID(AdviseSink),
ADD_KNOWN_IID(AdviseSink2),
ADD_KNOWN_IID(BindCtx),
ADD_KNOWN_IID(ClassFactory),
ADD_KNOWN_IID(ContinueCallback),
ADD_KNOWN_IID(EnumOleDocumentViews),
ADD_KNOWN_IID(OleCommandTarget),
ADD_KNOWN_IID(OleDocument),
ADD_KNOWN_IID(OleDocumentSite),
ADD_KNOWN_IID(OleDocumentView),
ADD_KNOWN_IID(Print),
ADD_KNOWN_IID(DataAdviseHolder),
ADD_KNOWN_IID(DataObject),
ADD_KNOWN_IID(Debug),
ADD_KNOWN_IID(DebugStream),
ADD_KNOWN_IID(DfReserved1),
ADD_KNOWN_IID(DfReserved2),
ADD_KNOWN_IID(DfReserved3),
ADD_KNOWN_IID(Dispatch),
ADD_KNOWN_IID(DropSource),
ADD_KNOWN_IID(DropTarget),
ADD_KNOWN_IID(EnumCallback),
ADD_KNOWN_IID(EnumFORMATETC),
ADD_KNOWN_IID(EnumGeneric),
ADD_KNOWN_IID(EnumHolder),
ADD_KNOWN_IID(EnumMoniker),
ADD_KNOWN_IID(EnumOLEVERB),
ADD_KNOWN_IID(EnumSTATDATA),
ADD_KNOWN_IID(EnumSTATSTG),
ADD_KNOWN_IID(EnumString),
ADD_KNOWN_IID(EnumUnknown),
ADD_KNOWN_IID(EnumVARIANT),
ADD_KNOWN_IID(ExternalConnection),
ADD_KNOWN_IID(InternalMoniker),
ADD_KNOWN_IID(LockBytes),
ADD_KNOWN_IID(Malloc),
ADD_KNOWN_IID(Marshal),
ADD_KNOWN_IID(MessageFilter),
ADD_KNOWN_IID(Moniker),
ADD_KNOWN_IID(OleAdviseHolder),
ADD_KNOWN_IID(OleCache),
ADD_KNOWN_IID(OleCache2),
ADD_KNOWN_IID(OleCacheControl),
ADD_KNOWN_IID(OleClientSite),
ADD_KNOWN_IID(OleContainer),
ADD_KNOWN_IID(OleInPlaceActiveObject),
ADD_KNOWN_IID(OleInPlaceFrame),
ADD_KNOWN_IID(OleInPlaceObject),
ADD_KNOWN_IID(OleInPlaceSite),
ADD_KNOWN_IID(OleInPlaceUIWindow),
ADD_KNOWN_IID(OleItemContainer),
ADD_KNOWN_IID(OleLink),
ADD_KNOWN_IID(OleManager),
ADD_KNOWN_IID(OleObject),
ADD_KNOWN_IID(OlePresObj),
ADD_KNOWN_IID(OleWindow),
ADD_KNOWN_IID(PSFactory),
ADD_KNOWN_IID(ParseDisplayName),
ADD_KNOWN_IID(Persist),
ADD_KNOWN_IID(PersistFile),
ADD_KNOWN_IID(PersistStorage),
ADD_KNOWN_IID(PersistStream),
ADD_KNOWN_IID(ProxyManager),
ADD_KNOWN_IID(RootStorage),
ADD_KNOWN_IID(RpcChannel),
ADD_KNOWN_IID(RpcProxy),
ADD_KNOWN_IID(RpcStub),
ADD_KNOWN_IID(RunnableObject),
ADD_KNOWN_IID(RunningObjectTable),
ADD_KNOWN_IID(StdMarshalInfo),
ADD_KNOWN_IID(Storage),
ADD_KNOWN_IID(Stream),
ADD_KNOWN_IID(StubManager),
ADD_KNOWN_IID(Unknown),
ADD_KNOWN_IID(ViewObject),
ADD_KNOWN_IID(ViewObject2),
};
// don't clobber preprocessor name space
#undef ADD_KNOWN_IID
// try to find the interface in the table
for ( uint ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) {
if ( riid == *aKnownIids[ui].pIid ) {
return aKnownIids[ui].szName;
}
}
// unknown IID, just transform to string
static Uuid s_uuid;
s_uuid.Set(riid);
return s_uuid;
}
void wxLogQueryInterface(const char *szInterface, REFIID riid)
{
wxLogTrace("%s::QueryInterface (iid = %s)", szInterface, GetIidName(riid));
}
void wxLogAddRef(const char *szInterface, ULONG cRef)
{
wxLogTrace("After %s::AddRef: m_cRef = %d", szInterface, cRef + 1);
}
void wxLogRelease(const char *szInterface, ULONG cRef)
{
wxLogTrace("After %s::Release: m_cRef = %d", szInterface, cRef - 1);
}
#endif //DEBUG
#endif
// USE_DRAG_AND_DROP

153
src/msw/ole/uuid.cpp Normal file
View File

@@ -0,0 +1,153 @@
///////////////////////////////////////////////////////////////////////////////
// Name: ole/uuid.cpp
// Purpose: implements Uuid class, see uuid.h for details
// Author: Vadim Zeitlin
// Modified by:
// Created: 12.09.96
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// Declarations
// ============================================================================
#ifdef __GNUG__
#pragma implementation "uuid.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#define IN_WX_MAIN_CPP
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#include <wx/setup.h>
#if USE_DRAG_AND_DROP
// standard headers
#include <rpc.h> // UUID related functions
#include <wx/msw/ole/uuid.h>
// ============================================================================
// Implementation
// ============================================================================
// length of UUID in C format
#define UUID_CSTRLEN 100 // real length is 66
// copy ctor
Uuid::Uuid(const Uuid& uuid)
{
// bitwise copy Ok for UUIDs
m_uuid = uuid.m_uuid;
// force the string to be allocated by RPC
// (we free it later with RpcStringFree)
UuidToString(&m_uuid, &m_pszUuid);
// allocate new buffer
m_pszCForm = new char[UUID_CSTRLEN];
// and fill it
memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN);
}
// assignment operator
Uuid& Uuid::operator=(const Uuid& uuid)
{
m_uuid = uuid.m_uuid;
// force the string to be allocated by RPC
// (we free it later with RpcStringFree)
UuidToString(&m_uuid, &m_pszUuid);
// allocate new buffer if not done yet
if ( !m_pszCForm )
m_pszCForm = new char[UUID_CSTRLEN];
// and fill it
memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN);
return *this;
}
// dtor
Uuid::~Uuid()
{
// this string must be allocated by RPC!
// (otherwise you get a debug breakpoint deep inside RPC DLL)
if ( m_pszUuid )
RpcStringFree(&m_pszUuid);
// perhaps we should just use a static buffer and not bother
// with new and delete?
if ( m_pszCForm )
delete [] m_pszCForm;
}
// update string representation of new UUID
void Uuid::Set(const UUID &uuid)
{
m_uuid = uuid;
// get string representation
UuidToString(&m_uuid, &m_pszUuid);
// cache UUID in C format
UuidToCForm();
}
// create a new UUID
void Uuid::Create()
{
UUID uuid;
// can't fail
UuidCreate(&uuid);
Set(uuid);
}
// set the value
bool Uuid::Set(const char *pc)
{
// get UUID from string
if ( UuidFromString((uchar *)pc, &m_uuid) != RPC_S_OK)
// failed: probably invalid string
return FALSE;
// transform it back to string to normalize it
UuidToString(&m_uuid, &m_pszUuid);
// update m_pszCForm
UuidToCForm();
return TRUE;
}
// stores m_uuid in m_pszCForm in a format required by
// DEFINE_GUID macro: i.e. something like
// 0x7D8A2281L,0x4C61,0x11D0,0xBA,0xBD,0x00,0x00,0xC0,0x18,0xBA,0x27
// m_pszUuid is of the form (no, it's not quite the same UUID :-)
// 6aadc650-67b0-11d0-bac8-0000c018ba27
void Uuid::UuidToCForm()
{
if ( m_pszCForm == NULL )
m_pszCForm = new char[UUID_CSTRLEN];
wsprintf(m_pszCForm, "0x%8.8X,0x%4.4X,0x%4.4X,0x%2.2X,0x2.2%X,"
"0x2.2%X,0x2.2%X,0x2.2%X,0x2.2%X,0x2.2%X,0x2.2%X",
m_uuid.Data1, m_uuid.Data2, m_uuid.Data3,
m_uuid.Data4[1], m_uuid.Data4[2], m_uuid.Data4[3], m_uuid.Data4[4],
m_uuid.Data4[5], m_uuid.Data4[6], m_uuid.Data4[7], m_uuid.Data4[8]);
}
#endif
// USE_DRAG_AND_DROP