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
+23 -32
View File
@@ -15,46 +15,37 @@
class wxDataFormat
{
public:
// the clipboard formats under GDK are GdkAtoms
typedef unsigned short NativeFormat;
wxDataFormat(unsigned int uFormat = wxDF_INVALID) { m_uFormat = uFormat; }
wxDataFormat(const wxChar* zFormat) { SetId(zFormat); }
wxDataFormat();
wxDataFormat(wxDataFormatId vType);
wxDataFormat(const wxString& rId);
wxDataFormat(const wxChar* pId);
wxDataFormat(NativeFormat vFormat);
wxDataFormat& operator=(unsigned int uFormat) { m_uFormat = uFormat; return(*this); }
wxDataFormat& operator=(const wxDataFormat& rFormat) {m_uFormat = rFormat.m_uFormat; return(*this); }
wxDataFormat& operator=(NativeFormat vFormat)
{ SetId(vFormat); return *this; }
//
// Comparison (must have both versions)
//
bool operator==(wxDataFormatId eFormat) const { return (m_uFormat == (unsigned int)eFormat); }
bool operator!=(wxDataFormatId eFormat) const { return (m_uFormat != (unsigned int)eFormat); }
bool operator==(const wxDataFormat& rFormat) const { return (m_uFormat == rFormat.m_uFormat); }
bool operator!=(const wxDataFormat& rFormat) const { return (m_uFormat != rFormat.m_uFormat); }
operator unsigned int(void) const { return m_uFormat; }
// comparison (must have both versions)
bool operator==(NativeFormat vFormat) const
{ return m_vFormat == (NativeFormat)vFormat; }
bool operator!=(NativeFormat vFormat) const
{ return m_vFormat != (NativeFormat)vFormat; }
unsigned int GetFormatId(void) const { return (unsigned int)m_uFormat; }
unsigned int GetType(void) const { return (unsigned int)m_uFormat; }
// explicit and implicit conversions to NativeFormat which is one of
// standard data types (implicit conversion is useful for preserving the
// compatibility with old code)
NativeFormat GetFormatId() const { return m_vFormat; }
operator NativeFormat() const { return m_vFormat; }
bool IsStandard(void) const;
void SetId(NativeFormat vFormat);
void SetType(unsigned int uType){ m_uFormat = uType; }
// string ids are used for custom types - this SetId() must be used for
//
// String ids are used for custom types - this SetId() must be used for
// application-specific formats
wxString GetId() const;
void SetId(const wxChar* pId);
// implementation
wxDataFormatId GetType() const;
//
wxString GetId(void) const;
void SetId(const wxChar* pId);
private:
wxDataFormatId m_vType;
NativeFormat m_vFormat;
void PrepareFormats();
void SetType(wxDataFormatId vType);
};
unsigned int m_uFormat;
}; // end of CLASS wxDataFormat
#endif // _WX_GTK_DATAFORM_H
+14 -2
View File
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// Name: mac/dataobj.h
// Purpose: declaration of the wxDataObject
// Author: Stefan Csomor
// Author: Stefan Csomor
// Modified by:
// Created: 10/21/99
// RCS-ID: $Id$
@@ -24,8 +24,20 @@ class wxDataObject : public wxDataObjectBase
{
public:
wxDataObject();
virtual ~wxDataObject();
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
virtual bool IsSupportedFormat( const wxDataFormat& eFormat
,Direction eDir = Get
) const
{
return(IsSupported( eFormat
,eDir
));
}
PDRAGITEM GetInterface(void) const {return m_pDataObject;}
private:
PDRAGITEM m_pDataObject;
};
#endif // _WX_MAC_DATAOBJ_H_
+37 -19
View File
@@ -23,6 +23,8 @@
#include <pmstddlg.h>
#endif
class CIDropTarget;
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
@@ -41,41 +43,57 @@ public:
/* start drag action */
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
virtual bool GiveFeedback(wxDragResult eEffect);
protected:
void Init(void);
bool m_bLazyDrag;
DRAGIMAGE* m_pDragImage;
DRAGINFO* m_pDragInfo;
DRAGTRANSFER* m_pDragTransfer;
};
ULONG m_ulItems;
PDRAGINFO m_pDragInfo;
DRAGIMAGE m_vDragImage;
PDRAGITEM m_pDragItem;
wxWindow* m_pWindow;
}; // end of CLASS wxDropSource
//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------
class WXDLLEXPORT wxDropTarget: public wxDropTargetBase
class WXDLLEXPORT wxDropTarget : public wxDropTargetBase
{
public:
wxDropTarget(wxDataObject *dataObject = (wxDataObject*)NULL);
wxDropTarget(wxDataObject* pDataObject = (wxDataObject*)NULL);
virtual ~wxDropTarget();
void Register(WXHWND hwnd);
void Revoke(WXHWND hwnd);
//
// These functions are called when data is moved over position (x, y) and
// may return either wxDragCopy, wxDragMove or wxDragNone depending on
// what would happen if the data were dropped here.
//
// The last parameter is what would happen by default and is determined by
// the platform-specific logic (for example, under Windows it's wxDragCopy
// if Ctrl key is pressed and wxDragMove otherwise) except that it will
// always be wxDragNone if the carried data is in an unsupported format.
//
// OnData must be implemented and other should be overridden by derived classes
//
virtual wxDragResult OnData( wxCoord vX
,wxCoord vY
,wxDragResult eResult
);
virtual bool OnDrop( wxCoord vX
,wxCoord vY
);
bool IsAcceptedData(PDRAGINFO pDataSource) const;
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
virtual bool OnDrop(wxCoord x, wxCoord y);
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult vResult);
virtual bool GetData();
// implementation
protected:
virtual bool IsAcceptable(DRAGINFO* pInfo);
virtual bool GetData(void);
wxDataFormat GetSupportedFormat(PDRAGINFO pDataSource) const;
void Release(void);
DRAGINFO* m_pDragInfo;
DRAGTRANSFER* m_pDragTransfer;
};
private:
CIDropTarget* m_pDropTarget;
}; // end of CLASS wxDropTarget
#endif //__OS2DNDH__
+2
View File
@@ -12,6 +12,8 @@
#ifndef _WX_TEXTCTRL_H_
#define _WX_TEXTCTRL_H_
typedef int (wxCALLBACK *wxTreeCtrlCompare)(long lItem1, long lItem2, long lSortData);
class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
{
public:
File diff suppressed because it is too large Load Diff
+2
View File
@@ -133,6 +133,8 @@ bool wxControl::OS2CreateControl(
zClass = WC_BUTTON;
else if ((strcmp(zClassname, "NOTEBOOK")) == 0)
zClass = WC_NOTEBOOK;
else if ((strcmp(zClassname, "CONTAINER")) == 0)
zClass = WC_CONTAINER;
dwStyle |= WS_VISIBLE;
m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
+156 -135
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
+517 -70
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2266,7 +2266,7 @@ long wxListCtrl::InsertItem (
::WinSendMsg( GetHWND()
,CM_INSERTRECORD
,MPFROMP(pRecord)
,MPFROMP(pRecordAfter)
,MPFROMP(&vInsert)
);
//
// OS/2 must mannually bump the index's of following records
+3 -3
View File
@@ -134,7 +134,6 @@ GENERICOBJS= \
..\generic\$D\textdlgg.obj \
..\generic\$D\tipdlg.obj \
..\generic\$D\tipwin.obj \
..\generic\$D\treectlg.obj \
..\generic\$D\treelay.obj \
..\generic\$D\wizard.obj
@@ -180,7 +179,6 @@ GENLIBOBJS= \
textdlgg.obj \
tipdlg.obj \
tipwin.obj \
treectlg.obj \
treelay.obj \
wizard.obj
@@ -542,6 +540,7 @@ OS2OBJS = \
..\os2\$D\toolbar.obj \
..\os2\$D\tooltip.obj \
..\os2\$D\toplevel.obj \
..\os2\$D\treectrl.obj \
..\os2\$D\utils.obj \
..\os2\$D\utilsexc.obj \
..\os2\$D\wave.obj \
@@ -624,6 +623,7 @@ OS2LIBOBJS2 = \
toolbar.obj \
tooltip.obj \
toplevel.obj \
treectrl.obj \
utils.obj \
utilsexc.obj \
wave.obj \
@@ -876,7 +876,6 @@ $(GENLIBOBJS):
copy ..\generic\$D\textdlgg.obj
copy ..\generic\$D\tipdlg.obj
copy ..\generic\$D\tipwin.obj
copy ..\generic\$D\treectlg.obj
copy ..\generic\$D\treelay.obj
copy ..\generic\$D\wizard.obj
@@ -979,6 +978,7 @@ $(OS2LIBOBJS2):
copy ..\os2\$D\toolbar.obj
copy ..\os2\$D\tooltip.obj
copy ..\os2\$D\toplevel.obj
copy ..\os2\$D\treectrl.obj
copy ..\os2\$D\utils.obj
copy ..\os2\$D\utilsexc.obj
copy ..\os2\$D\wave.obj
+2099
View File
File diff suppressed because it is too large Load Diff
-8
View File
@@ -1454,14 +1454,7 @@ void wxWindowOS2::SetDropTarget(
wxDropTarget* pDropTarget
)
{
if (m_dropTarget != 0)
{
m_dropTarget->Revoke(m_hWnd);
delete m_dropTarget;
}
m_dropTarget = pDropTarget;
if (m_dropTarget != 0)
m_dropTarget->Register(m_hWnd);
} // end of wxWindowOS2::SetDropTarget
#endif
@@ -3530,7 +3523,6 @@ bool wxWindowOS2::HandleDestroy()
#if wxUSE_DRAG_AND_DROP
if (m_dropTarget != NULL)
{
m_dropTarget->Revoke(m_hWnd);
delete m_dropTarget;
m_dropTarget = NULL;
}
+214 -306
View File
File diff suppressed because it is too large Load Diff