Support for new native OS/2 tree control with drag-and-drop.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18909 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2003-01-24 22:31:41 +00:00
parent c0ae383ac0
commit 4fd899b671
13 changed files with 3769 additions and 576 deletions

View File

@@ -49,158 +49,179 @@
// wxDataFormat
// ----------------------------------------------------------------------------
wxDataFormat::wxDataFormat()
{
m_vType = wxDF_INVALID;
m_vFormat = 0;
}
wxDataFormat::wxDataFormat(
wxDataFormatId vType
)
{
PrepareFormats();
SetType(vType);
}
wxDataFormat::wxDataFormat(
const wxChar* zId
)
{
PrepareFormats();
SetId(zId);
}
wxDataFormat::wxDataFormat(
const wxString& rId
)
{
PrepareFormats();
SetId(rId);
}
wxDataFormat::wxDataFormat(
NativeFormat vFormat
)
{
PrepareFormats();
SetId(vFormat);
}
void wxDataFormat::SetType(
wxDataFormatId vType
)
{
m_vType = vType;
if (m_vType == wxDF_TEXT)
m_vFormat = 0;
else
if (m_vType == wxDF_BITMAP)
m_vFormat = 0;
else
if (m_vType == wxDF_FILENAME)
m_vFormat = 0;
else
{
wxFAIL_MSG( wxT("invalid dataformat") );
}
}
wxDataFormatId wxDataFormat::GetType() const
{
return m_vType;
}
wxString wxDataFormat::GetId() const
{
wxString sRet(""); // TODO: gdk_atom_name( m_format ) );
char zBuf[256];
wxString sRet;
::WinQueryAtomName( ::WinQuerySystemAtomTable()
,m_uFormat
,zBuf
,256
);
sRet = zBuf;
return sRet;
}
} // end of wxDataFormat::GetId()
void wxDataFormat::SetId(
NativeFormat vFormat
)
{
m_vFormat = vFormat;
// TODO:
/*
if (m_format == g_textAtom)
m_type = wxDF_TEXT;
else
if (m_format == g_pngAtom)
m_type = wxDF_BITMAP;
else
if (m_format == g_fileAtom)
m_type = wxDF_FILENAME;
else
m_type = wxDF_PRIVATE;
*/
}
void wxDataFormat::SetId(
void wxDataFormat::SetId (
const wxChar* zId
)
{
wxString tmp(zId);
m_uFormat = ::WinAddAtom( ::WinQuerySystemAtomTable()
,zId
);
} // end of wxDataFormat::SetId
m_vType = wxDF_PRIVATE;
m_vFormat = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
}
void wxDataFormat::PrepareFormats()
class CIDataObject
{
// TODO:
/*
if (!g_textAtom)
g_textAtom = gdk_atom_intern( "STRING", FALSE );
if (!g_pngAtom)
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
if (!g_fileAtom)
g_fileAtom = gdk_atom_intern( "file:ALL", FALSE );
*/
}
public:
CIDataObject(wxDataObject* pDataObject);
~CIDataObject();
//
// Operations on the DRAGITEM struct
//
bool GetData( const wxDataFormat& rFormat
,char* pzBuffer
,ULONG ulLen
);
void GetDataHere( const wxDataFormat& rFormat
,char* pzBuffer
,ULONG ulLen
);
void QueryGetData(const wxDataFormat& rFormat);
void SetData( const wxDataFormat& rFormat
,char* pzBuffer
);
private:
wxDataObject* m_pDataObject; // pointer to C++ class we belong to
DRAGITEM m_vDragItem;
}; // end of CLASS CIDataObject
bool CIDataObject::GetData (
const wxDataFormat& rFormat
, char* pzBuffer
, ULONG ulLen
)
{
QueryGetData(rFormat);
if (rFormat.GetType() == wxDF_INVALID)
return FALSE;
ULONG ulSize = m_pDataObject->GetDataSize(rFormat);
if (ulSize == 0)
{
//
// It probably means that the method is just not implemented
//
return FALSE;
}
if (rFormat.GetType() == wxDF_PRIVATE)
{
//
// For custom formats, put the size with the data - alloc the
// space for it
//
ulSize += sizeof(ULONG);
}
if (ulSize > ulLen) // not enough room to copy
return FALSE;
//
// Copy the data
//
GetDataHere( rFormat
,pzBuffer
,ulSize
);
return TRUE;
} // end of CIDataObject::GetData
void CIDataObject::GetDataHere(
const wxDataFormat& rFormat
, char* pzBuffer
, ULONG WXUNUSED(ulLen)
)
{
m_pDataObject->GetDataHere( rFormat
,(void*)pzBuffer
);
} // end of CIDataObject::GetDataHere
void CIDataObject::QueryGetData (
const wxDataFormat& rFormat
)
{
m_pDataObject->IsSupportedFormat(rFormat);
} // end of CIDataObject::QueryGetData
void CIDataObject::SetData (
const wxDataFormat& rFormat
, char* pzBuffer
)
{
ULONG ulSize;
switch (rFormat.GetType())
{
case wxDF_TEXT:
case wxDF_OEMTEXT:
case wxDF_FILENAME:
case wxDF_HTML:
ulSize = strlen((const char *)pzBuffer);
break;
case wxDF_UNICODETEXT:
ulSize = ::wcslen((const wchar_t *)pzBuffer);
break;
case wxDF_BITMAP:
case wxDF_METAFILE:
case wxDF_ENHMETAFILE:
case wxDF_TIFF:
case wxDF_DIB:
ulSize = 0; // pass via a handle
break;
case wxDF_SYLK:
case wxDF_DIF:
case wxDF_PALETTE:
case wxDF_PENDATA:
case wxDF_RIFF:
case wxDF_WAVE:
case wxDF_LOCALE:
//PUNT
break;
case wxDF_PRIVATE:
size_t* p = (size_t *)pzBuffer;
ulSize = *p++;
pzBuffer = (char*)p;
break;
}
m_pDataObject->SetData( rFormat
,ulSize
,(void*)pzBuffer
);
} // end of CIDataObject::SetData
//-------------------------------------------------------------------------
// wxDataObject
//-------------------------------------------------------------------------
wxDataObject::wxDataObject()
wxDataObject::wxDataObject ()
{
}
m_pDataObject = new DRAGITEM;
} // end of wxDataObject::wxDataObject
bool wxDataObject::IsSupportedFormat(
const wxDataFormat& rFormat
, Direction vDir
) const
wxDataObject::~wxDataObject ()
{
size_t nFormatCount = GetFormatCount(vDir);
if (nFormatCount == 1)
{
return rFormat == GetPreferredFormat();
}
else
{
wxDataFormat* pFormats = new wxDataFormat[nFormatCount];
GetAllFormats( pFormats
,vDir
);
size_t n;
for (n = 0; n < nFormatCount; n++)
{
if (pFormats[n] == rFormat)
break;
}
delete [] pFormats;
// found?
return n < nFormatCount;
}
}
delete m_pDataObject;
} // end of wxDataObject::~wxDataObject
// ----------------------------------------------------------------------------
// wxFileDataObject