Some more Unicode changes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2783 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ove Kaaven
1999-06-14 14:31:47 +00:00
parent ee0fc54abf
commit 5f8e1c164d
4 changed files with 61 additions and 37 deletions

View File

@@ -160,7 +160,7 @@ STDMETHODIMP wxIEnumFORMATETC::Next(ULONG celt,
FORMATETC *rgelt, FORMATETC *rgelt,
ULONG *pceltFetched) ULONG *pceltFetched)
{ {
wxLogTrace("wxIEnumFORMATETC::Next"); wxLogTrace(_T("wxIEnumFORMATETC::Next"));
if ( celt > 1 ) if ( celt > 1 )
return S_FALSE; return S_FALSE;
@@ -177,7 +177,7 @@ STDMETHODIMP wxIEnumFORMATETC::Next(ULONG celt,
STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt) STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt)
{ {
wxLogTrace("wxIEnumFORMATETC::Skip"); wxLogTrace(_T("wxIEnumFORMATETC::Skip"));
if ( m_nCurrent == 0 ) if ( m_nCurrent == 0 )
m_nCurrent++; m_nCurrent++;
@@ -187,7 +187,7 @@ STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt)
STDMETHODIMP wxIEnumFORMATETC::Reset() STDMETHODIMP wxIEnumFORMATETC::Reset()
{ {
wxLogTrace("wxIEnumFORMATETC::Reset"); wxLogTrace(_T("wxIEnumFORMATETC::Reset"));
m_nCurrent = 0; m_nCurrent = 0;
@@ -196,7 +196,7 @@ STDMETHODIMP wxIEnumFORMATETC::Reset()
STDMETHODIMP wxIEnumFORMATETC::Clone(IEnumFORMATETC **ppenum) STDMETHODIMP wxIEnumFORMATETC::Clone(IEnumFORMATETC **ppenum)
{ {
wxLogTrace("wxIEnumFORMATETC::Clone"); wxLogTrace(_T("wxIEnumFORMATETC::Clone"));
wxIEnumFORMATETC *pNew = new wxIEnumFORMATETC(m_format.cfFormat); wxIEnumFORMATETC *pNew = new wxIEnumFORMATETC(m_format.cfFormat);
pNew->AddRef(); pNew->AddRef();
@@ -225,7 +225,7 @@ wxIDataObject::wxIDataObject(wxDataObject *pDataObject)
// get data functions // get data functions
STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
{ {
wxLogTrace("wxIDataObject::GetData"); wxLogTrace(_T("wxIDataObject::GetData"));
// is data is in our format? // is data is in our format?
HRESULT hr = QueryGetData(pformatetcIn); HRESULT hr = QueryGetData(pformatetcIn);
@@ -257,7 +257,7 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc, STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
STGMEDIUM *pmedium) STGMEDIUM *pmedium)
{ {
wxLogTrace("wxIDataObject::GetDataHere"); wxLogTrace(_T("wxIDataObject::GetDataHere"));
// put data in caller provided medium // put data in caller provided medium
if ( pmedium->tymed != TYMED_HGLOBAL ) if ( pmedium->tymed != TYMED_HGLOBAL )
@@ -266,7 +266,7 @@ STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
// copy data // copy data
void *pBuf = GlobalLock(pmedium->hGlobal); void *pBuf = GlobalLock(pmedium->hGlobal);
if ( pBuf == NULL ) { if ( pBuf == NULL ) {
wxLogLastError("GlobalLock"); wxLogLastError(_T("GlobalLock"));
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
@@ -282,7 +282,7 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
STGMEDIUM *pmedium, STGMEDIUM *pmedium,
BOOL fRelease) BOOL fRelease)
{ {
wxLogTrace("wxIDataObject::SetData"); wxLogTrace(_T("wxIDataObject::SetData"));
return E_NOTIMPL; return E_NOTIMPL;
} }
@@ -291,39 +291,39 @@ STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc)
{ {
// do we accept data in this format? // do we accept data in this format?
if ( pformatetc == NULL ) { if ( pformatetc == NULL ) {
wxLogTrace("wxIDataObject::QueryGetData: invalid ptr."); wxLogTrace(_T("wxIDataObject::QueryGetData: invalid ptr."));
return E_INVALIDARG; return E_INVALIDARG;
} }
// the only one allowed by current COM implementation // the only one allowed by current COM implementation
if ( pformatetc->lindex != -1 ) { if ( pformatetc->lindex != -1 ) {
wxLogTrace("wxIDataObject::QueryGetData: bad lindex %d", wxLogTrace(_T("wxIDataObject::QueryGetData: bad lindex %d"),
pformatetc->lindex); pformatetc->lindex);
return DV_E_LINDEX; return DV_E_LINDEX;
} }
// we don't support anything other (THUMBNAIL, ICON, DOCPRINT...) // we don't support anything other (THUMBNAIL, ICON, DOCPRINT...)
if ( pformatetc->dwAspect != DVASPECT_CONTENT ) { if ( pformatetc->dwAspect != DVASPECT_CONTENT ) {
wxLogTrace("wxIDataObject::QueryGetData: bad dwAspect %d", wxLogTrace(_T("wxIDataObject::QueryGetData: bad dwAspect %d"),
pformatetc->dwAspect); pformatetc->dwAspect);
return DV_E_DVASPECT; return DV_E_DVASPECT;
} }
// @@ we only transfer data by global memory (bad for large amounts of it!) // @@ we only transfer data by global memory (bad for large amounts of it!)
if ( !(pformatetc->tymed & TYMED_HGLOBAL) ) { if ( !(pformatetc->tymed & TYMED_HGLOBAL) ) {
wxLogTrace("wxIDataObject::QueryGetData: %s != TYMED_HGLOBAL.", wxLogTrace(_T("wxIDataObject::QueryGetData: %s != TYMED_HGLOBAL."),
GetTymedName(pformatetc->tymed)); GetTymedName(pformatetc->tymed));
return DV_E_TYMED; return DV_E_TYMED;
} }
// and now check the type of data requested // and now check the type of data requested
if ( m_pDataObject->IsSupportedFormat((wxDataFormatId)pformatetc->cfFormat) ) { if ( m_pDataObject->IsSupportedFormat((wxDataFormatId)pformatetc->cfFormat) ) {
wxLogTrace("wxIDataObject::QueryGetData: %s ok", wxLogTrace(_T("wxIDataObject::QueryGetData: %s ok"),
wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat)); wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat));
return S_OK; return S_OK;
} }
else { else {
wxLogTrace("wxIDataObject::QueryGetData: %s unsupported", wxLogTrace(_T("wxIDataObject::QueryGetData: %s unsupported"),
wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat)); wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat));
return DV_E_FORMATETC; return DV_E_FORMATETC;
} }
@@ -332,7 +332,7 @@ STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc)
STDMETHODIMP wxIDataObject::GetCanonicalFormatEtc(FORMATETC *pFormatetcIn, STDMETHODIMP wxIDataObject::GetCanonicalFormatEtc(FORMATETC *pFormatetcIn,
FORMATETC *pFormatetcOut) FORMATETC *pFormatetcOut)
{ {
wxLogTrace("wxIDataObject::GetCanonicalFormatEtc"); wxLogTrace(_T("wxIDataObject::GetCanonicalFormatEtc"));
// @@ implementation is trivial, we might want something better here // @@ implementation is trivial, we might want something better here
if ( pFormatetcOut != NULL ) if ( pFormatetcOut != NULL )
@@ -343,7 +343,7 @@ STDMETHODIMP wxIDataObject::GetCanonicalFormatEtc(FORMATETC *pFormatetcIn,
STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDirection, STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDirection,
IEnumFORMATETC **ppenumFormatEtc) IEnumFORMATETC **ppenumFormatEtc)
{ {
wxLogTrace("wxIDataObject::EnumFormatEtc"); wxLogTrace(_T("wxIDataObject::EnumFormatEtc"));
if ( dwDirection == DATADIR_SET ) { if ( dwDirection == DATADIR_SET ) {
// we don't allow setting of data anyhow // we don't allow setting of data anyhow

View File

@@ -183,7 +183,7 @@ wxDropSource::~wxDropSource()
// Notes : you must call SetData() before if you had used def ctor // Notes : you must call SetData() before if you had used def ctor
wxDragResult wxDropSource::DoDragDrop(bool bAllowMove) wxDragResult wxDropSource::DoDragDrop(bool bAllowMove)
{ {
wxCHECK_MSG( m_pData != NULL, wxDragNone, "No data in wxDropSource!" ); wxCHECK_MSG( m_pData != NULL, wxDragNone, _T("No data in wxDropSource!") );
DWORD dwEffect; DWORD dwEffect;
HRESULT hr = ::DoDragDrop(m_pData->GetInterface(), HRESULT hr = ::DoDragDrop(m_pData->GetInterface(),
@@ -215,10 +215,10 @@ wxDragResult wxDropSource::DoDragDrop(bool bAllowMove)
else { else {
if ( FAILED(hr) ) { if ( FAILED(hr) ) {
wxLogApiError("DoDragDrop", hr); wxLogApiError("DoDragDrop", hr);
wxLogError("Drag & drop operation failed."); wxLogError(_T("Drag & drop operation failed."));
} }
else { else {
wxLogDebug("Unexpected success return code %08lx from DoDragDrop.", hr); wxLogDebug(_T("Unexpected success return code %08lx from DoDragDrop."), hr);
} }
return wxDragError; return wxDragError;

View File

@@ -136,7 +136,7 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
POINTL pt, POINTL pt,
DWORD *pdwEffect) DWORD *pdwEffect)
{ {
wxLogDebug("IDropTarget::DragEnter"); wxLogDebug(_T("IDropTarget::DragEnter"));
wxASSERT( m_pIDataObject == NULL ); wxASSERT( m_pIDataObject == NULL );
@@ -187,7 +187,7 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
// Notes : good place to do any clean-up // Notes : good place to do any clean-up
STDMETHODIMP wxIDropTarget::DragLeave() STDMETHODIMP wxIDropTarget::DragLeave()
{ {
wxLogDebug("IDropTarget::DragLeave"); wxLogDebug(_T("IDropTarget::DragLeave"));
// remove the UI feedback // remove the UI feedback
m_pTarget->OnLeave(); m_pTarget->OnLeave();
@@ -212,7 +212,7 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
POINTL pt, POINTL pt,
DWORD *pdwEffect) DWORD *pdwEffect)
{ {
wxLogDebug("IDropTarget::Drop"); wxLogDebug(_T("IDropTarget::Drop"));
// TODO I don't know why there is this parameter, but so far I assume // TODO 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 // that it's the same we've already got in DragEnter
@@ -344,7 +344,7 @@ bool wxDropTarget::IsAcceptedData(IDataObject *pIDataSource) const
bool wxTextDropTarget::OnDrop(long x, long y, const void *pData) bool wxTextDropTarget::OnDrop(long x, long y, const void *pData)
{ {
return OnDropText(x, y, (const char *)pData); return OnDropText(x, y, (const wxChar *)pData);
} }
size_t wxTextDropTarget::GetFormatCount() const size_t wxTextDropTarget::GetFormatCount() const
@@ -375,22 +375,22 @@ bool wxFileDropTarget::OnDrop(long x, long y, const void *pData)
UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u); UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
// for each file get the length, allocate memory and then get the name // for each file get the length, allocate memory and then get the name
char **aszFiles = new char *[nFiles]; wxChar **aszFiles = new wxChar *[nFiles];
UINT len, n; UINT len, n;
for ( n = 0; n < nFiles; n++ ) { for ( n = 0; n < nFiles; n++ ) {
// +1 for terminating NUL // +1 for terminating NUL
len = ::DragQueryFile(hdrop, n, NULL, 0) + 1; len = ::DragQueryFile(hdrop, n, NULL, 0) + 1;
aszFiles[n] = new char[len]; aszFiles[n] = new wxChar[len];
UINT len2 = ::DragQueryFile(hdrop, n, aszFiles[n], len); UINT len2 = ::DragQueryFile(hdrop, n, aszFiles[n], len);
if ( len2 != len - 1 ) { if ( len2 != len - 1 ) {
wxLogDebug("In wxFileDropTarget::OnDrop DragQueryFile returned %d " wxLogDebug(_T("In wxFileDropTarget::OnDrop DragQueryFile returned %d "
"characters, %d expected.", len2, len - 1); "characters, %d expected."), len2, len - 1);
} }
} }
bool bResult = OnDropFiles(x, y, nFiles, (const char**) aszFiles); bool bResult = OnDropFiles(x, y, nFiles, (const wxChar**) aszFiles);
// free memory // free memory
for ( n = 0; n < nFiles; n++ ) { for ( n = 0; n < nFiles; n++ ) {

View File

@@ -50,12 +50,16 @@ Uuid::Uuid(const Uuid& uuid)
// force the string to be allocated by RPC // force the string to be allocated by RPC
// (we free it later with RpcStringFree) // (we free it later with RpcStringFree)
#ifdef _UNICODE
UuidToString(&m_uuid, (unsigned short **)&m_pszUuid);
#else
UuidToString(&m_uuid, &m_pszUuid); UuidToString(&m_uuid, &m_pszUuid);
#endif
// allocate new buffer // allocate new buffer
m_pszCForm = new char[UUID_CSTRLEN]; m_pszCForm = new wxChar[UUID_CSTRLEN];
// and fill it // and fill it
memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN); memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN*sizeof(wxChar));
} }
// assignment operator // assignment operator
@@ -65,14 +69,18 @@ Uuid& Uuid::operator=(const Uuid& uuid)
// force the string to be allocated by RPC // force the string to be allocated by RPC
// (we free it later with RpcStringFree) // (we free it later with RpcStringFree)
#ifdef _UNICODE
UuidToString(&m_uuid, (unsigned short **)&m_pszUuid);
#else
UuidToString(&m_uuid, &m_pszUuid); UuidToString(&m_uuid, &m_pszUuid);
#endif
// allocate new buffer if not done yet // allocate new buffer if not done yet
if ( !m_pszCForm ) if ( !m_pszCForm )
m_pszCForm = new char[UUID_CSTRLEN]; m_pszCForm = new wxChar[UUID_CSTRLEN];
// and fill it // and fill it
memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN); memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN*sizeof(wxChar));
return *this; return *this;
} }
@@ -83,7 +91,11 @@ Uuid::~Uuid()
// this string must be allocated by RPC! // this string must be allocated by RPC!
// (otherwise you get a debug breakpoint deep inside RPC DLL) // (otherwise you get a debug breakpoint deep inside RPC DLL)
if ( m_pszUuid ) if ( m_pszUuid )
#ifdef _UNICODE
RpcStringFree((unsigned short **)&m_pszUuid);
#else
RpcStringFree(&m_pszUuid); RpcStringFree(&m_pszUuid);
#endif
// perhaps we should just use a static buffer and not bother // perhaps we should just use a static buffer and not bother
// with new and delete? // with new and delete?
@@ -97,7 +109,11 @@ void Uuid::Set(const UUID &uuid)
m_uuid = uuid; m_uuid = uuid;
// get string representation // get string representation
#ifdef _UNICODE
UuidToString(&m_uuid, (unsigned short **)&m_pszUuid);
#else
UuidToString(&m_uuid, &m_pszUuid); UuidToString(&m_uuid, &m_pszUuid);
#endif
// cache UUID in C format // cache UUID in C format
UuidToCForm(); UuidToCForm();
@@ -115,15 +131,23 @@ void Uuid::Create()
} }
// set the value // set the value
bool Uuid::Set(const char *pc) bool Uuid::Set(const wxChar *pc)
{ {
// get UUID from string // get UUID from string
if ( UuidFromString((uchar *)pc, &m_uuid) != RPC_S_OK) #ifdef _UNICODE
if ( UuidFromString((unsigned short *)pc, &m_uuid) != RPC_S_OK)
#else
if ( UuidFromString((wxUChar *)pc, &m_uuid) != RPC_S_OK)
#endif
// failed: probably invalid string // failed: probably invalid string
return FALSE; return FALSE;
// transform it back to string to normalize it // transform it back to string to normalize it
#ifdef _UNICODE
UuidToString(&m_uuid, (unsigned short **)&m_pszUuid);
#else
UuidToString(&m_uuid, &m_pszUuid); UuidToString(&m_uuid, &m_pszUuid);
#endif
// update m_pszCForm // update m_pszCForm
UuidToCForm(); UuidToCForm();
@@ -139,10 +163,10 @@ bool Uuid::Set(const char *pc)
void Uuid::UuidToCForm() void Uuid::UuidToCForm()
{ {
if ( m_pszCForm == NULL ) if ( m_pszCForm == NULL )
m_pszCForm = new char[UUID_CSTRLEN]; m_pszCForm = new wxChar[UUID_CSTRLEN];
wsprintf(m_pszCForm, "0x%8.8X,0x%4.4X,0x%4.4X,0x%2.2X,0x2.2%X," wsprintf(m_pszCForm, _T("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", "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.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[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]); m_uuid.Data4[5], m_uuid.Data4[6], m_uuid.Data4[7], m_uuid.Data4[8]);