*** empty log message ***

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-10-22 04:37:39 +00:00
parent 2e1a688e3e
commit 6dddc146fb
11 changed files with 707 additions and 296 deletions

View File

@@ -451,11 +451,22 @@ void wxClipboard::Clear()
{
}
bool wxClipboard::Flush()
{
// TODO:
return FALSE;
}
bool wxClipboard::Open()
{
return wxOpenClipboard();
}
bool wxClipboard::IsOpened() const
{
return wxIsClipboardOpened();
}
bool wxClipboard::SetData( wxDataObject *data )
{
(void)wxEmptyClipboard();
@@ -604,25 +615,6 @@ bool wxClipboard::GetData( wxDataObject *data )
#endif
}
//-----------------------------------------------------------------------------
// wxClipboardModule
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
bool wxClipboardModule::OnInit()
{
wxTheClipboard = new wxClipboard();
return TRUE;
}
void wxClipboardModule::OnExit()
{
if (wxTheClipboard) delete wxTheClipboard;
wxTheClipboard = (wxClipboard*) NULL;
}
#else
#error "Please turn wxUSE_CLIPBOARD on to compile this file."
#endif // wxUSE_CLIPBOARD

347
src/os2/dataobj.cpp Normal file
View File

@@ -0,0 +1,347 @@
///////////////////////////////////////////////////////////////////////////////
// Name: os2/dataobj.cpp
// Purpose: implementation of wx[I]DataObject class
// Author: David Webster
// Modified by:
// Created: 10/21/99
// RCS-ID: $Id$
// Copyright: (c) 1999 David Webster
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "dataobj.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#endif
#include "wx/defs.h"
#include "wx/log.h"
#include "wx/dataobj.h"
#define INCL_DOS
#include <os2.h>
// ----------------------------------------------------------------------------
// functions
// ----------------------------------------------------------------------------
#ifdef __WXDEBUG__
static const wxChar *GetTymedName(DWORD tymed);
#endif // Debug
// ----------------------------------------------------------------------------
// wxDataFormat
// ----------------------------------------------------------------------------
wxDataFormat::wxDataFormat(
wxDataFormatId vType
)
{
PrepareFormats();
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 ) );
return sRet;
}
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(
const wxChar* zId
)
{
wxString tmp(zId);
m_vType = wxDF_PRIVATE;
m_vFormat = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
}
void wxDataFormat::PrepareFormats()
{
// 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 );
*/
}
//-------------------------------------------------------------------------
// wxDataObject
//-------------------------------------------------------------------------
wxDataObject::wxDataObject()
{
}
bool wxDataObject::IsSupportedFormat(
const wxDataFormat& rFormat
, Direction vDir
) const
{
size_t nFormatCount = GetFormatCount(vDir);
if (nFormatCount == 1)
{
return rFormat == GetPreferredFormat();
}
else
{
wxDataFormat* pFormats = new wxDataFormat[nFormatCount];
GetAllFormats( rFormats
,vDir
);
size_t n;
for (n = 0; n < nFormatCount; n++)
{
if (rFormats[n] == rFormat)
break;
}
delete [] rFormats;
// found?
return n < nFormatCount;
}
}
// ----------------------------------------------------------------------------
// wxFileDataObject
// ----------------------------------------------------------------------------
bool wxFileDataObject::GetDataHere(
void* pBuf
) const
{
wxString sFilenames;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
filenames += m_filenames[i];
filenames += (wxChar)0;
}
memcpy(pBuf, filenames.mbc_str(), filenames.Len() + 1);
return TRUE;
}
size_t wxFileDataObject::GetDataSize() const
{
size_t nRes = 0;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
nRes += m_filenames[i].Len();
nRes += 1;
}
return nRes + 1;
}
bool wxFileDataObject::SetData(
size_t WXUNUSED(nSize)
, const void* pBuf
)
{
/* TODO */
wxString sFile( (const char *)pBuf); /* char, not wxChar */
AddFile(sFile);
return TRUE;
}
void wxFileDataObject::AddFile(
const wxString& rFilename
)
{
m_filenames.Add(rFilename);
}
// ----------------------------------------------------------------------------
// wxBitmapDataObject
// ----------------------------------------------------------------------------
wxBitmapDataObject::wxBitmapDataObject()
{
Init();
}
wxBitmapDataObject::wxBitmapDataObject(
const wxBitmap& rBitmap
)
: wxBitmapDataObjectBase(rBitmap)
{
Init();
DoConvertToPng();
}
wxBitmapDataObject::~wxBitmapDataObject()
{
Clear();
}
void wxBitmapDataObject::SetBitmap(
const wxBitmap& rBitmap
)
{
ClearAll();
wxBitmapDataObjectBase::SetBitmap(rBitmap);
DoConvertToPng();
}
bool wxBitmapDataObject::GetDataHere(
void* pBuf
) const
{
if (!m_pngSize)
{
wxFAIL_MSG(wxT("attempt to copy empty bitmap failed"));
return FALSE;
}
memcpy(pBuf, m_pngData, m_pngSize);
return TRUE;
}
bool wxBitmapDataObject::SetData(
size_t nSize
, const void* pBuf
)
{
Clear();
m_pngSize = nSize;
m_pngData = malloc(m_pngSize);
memcpy(m_pngData, pBuf, m_pngSize);
wxMemoryInputStream vMstream((char*)m_pngData, m_pngSize);
wxImage vImage;
wxPNGHandler vHandler;
if (!vHandler.LoadFile(&vImage, vMstream))
{
return FALSE;
}
m_bitmap = vImage.ConvertToBitmap();
return m_bitmap.Ok();
}
void wxBitmapDataObject::DoConvertToPng()
{
if (!m_bitmap.Ok())
return;
wxImage vImage(m_bitmap);
wxPNGHandler vHandler;
wxCountingOutputStream vCount;
vHandler.SaveFile(&rImage, vCount);
m_pngSize = vCount.GetSize() + 100; // sometimes the size seems to vary ???
m_pngData = malloc(m_pngSize);
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
vHandler.SaveFile(&vImage, vMstream );
}

View File

@@ -1,9 +1,9 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dnd.cpp
// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/21/99
// RCS-ID: $Id$
// Copyright: (c) 1998 AUTHOR
// Licence: wxWindows licence
@@ -26,108 +26,153 @@
// wxDropTarget
// ----------------------------------------------------------------------------
wxDropTarget::wxDropTarget()
wxDropTarget::wxDropTarget(
wxDataObject* pDataObject
)
{
// TODO:
};
wxDropTarget::~wxDropTarget()
{
};
void wxDropTarget::Register(
WXHWND hwnd
)
{
//TODO:
};
void wxDropTarget::Revoke(
WXHWND hwnd
)
{
//TODO:
};
wxDragResult wxDropTarget::OnDragOver(
wxCoord x
, wxCoord y
, wxDragResult vDef
)
{
//TODO:
return vDef;
};
bool wxDropTarget::OnDrop(
wxCoord x
, wxCoord y
)
{
//TODO:
return FALSE;
};
bool wxDropTarget::OnData(
wxCoord x
, wxCoord y
)
{
//TODO:
return FALSE;
};
bool wxDropTarget::GetData()
{
//TODO:
return FALSE;
};
bool wxDropTarget::IsAcceptable(
DRAGINFO* pInfo
)
{
//TODO:
return FALSE;
};
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
bool wxTextDropTarget::OnDrop( long x, long y, const void *pData )
wxTextDropTarget::wxTextDropTarget()
{
OnDropText( x, y, (const char*)pData );
return TRUE;
};
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
{
printf( "Got dropped text: %s.\n", psz );
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
return TRUE;
};
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
// TODO:
}
wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
wxTextDropTarget::~wxTextDropTarget()
{
return wxDF_TEXT;
// TODO:
}
bool wxTextDropTarget::OnData(
wxCoord x
, wxCoord y
)
{
// TODO:
return FALSE;
};
// ----------------------------------------------------------------------------
// wxFileDropTarget
// ----------------------------------------------------------------------------
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
wxFileDropTarget::wxFileDropTarget()
{
printf( "Got %d dropped files.\n", (int)nFiles );
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
return TRUE;
// TODO:
}
bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) )
wxFileDropTarget::~wxFileDropTarget()
{
char *str = "/this/is/a/path.txt";
return OnDropFiles(x, y, 1, &str );
// TODO:
}
size_t wxFileDropTarget::GetFormatCount() const
bool wxFileDropTarget::OnData(
wxCoord x
, wxCoord y
)
{
return 1;
}
wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
return wxDF_FILENAME;
}
// TODO:
return FALSE;
};
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// drag request
wxDropSource::wxDropSource( wxWindow *win )
wxDropSource::wxDropSource(
wxWindow* pWin
)
{
// TODO
// m_window = win;
m_data = NULL;
// m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
// m_goaheadCursor = wxCursor( wxCURSOR_HAND );
};
wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
wxDropSource::wxDropSource(
wxDataObject& rData
, wxWindow* pWin
)
{
// TODO
// m_window = win;
m_data = &data;
// m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
// m_goaheadCursor = wxCursor( wxCURSOR_HAND );
};
void wxDropSource::SetData( wxDataObject &data )
wxDropSource::~wxDropSource()
{
m_data = &data;
// TODO
};
wxDropSource::~wxDropSource(void)
{
};
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
wxDragResult wxDropSource::DoDragDrop(
bool WXUNUSED(bAllowMove)
)
{
// TODO
return wxDragError;
};
void wxDropSource::Init()
{
// TODO
};

View File

@@ -339,6 +339,7 @@ OS2OBJS = \
..\os2\$D\control.obj \
..\os2\$D\cursor.obj \
..\os2\$D\data.obj \
..\os2\$D\dataobj.obj \
..\os2\$D\dc.obj \
..\os2\$D\dcclient.obj \
..\os2\$D\dcmemory.obj \
@@ -416,6 +417,7 @@ OS2LIBOBJS1 = \
control.obj \
cursor.obj \
data.obj \
dataobj.obj \
dc.obj \
dcclient.obj \
dcmemory.obj \
@@ -444,10 +446,10 @@ OS2LIBOBJS1 = \
menuitem.obj \
metafile.obj \
minifram.obj \
msgdlg.obj \
nativdlg.obj
msgdlg.obj
OS2LIBOBJS2 = \
nativdlg.obj \
notebook.obj \
ownerdrw.obj \
palette.obj \