Exemple #1
0
void wxDropSource::Init ()
{
    m_pDragInfo = ::DrgAllocDraginfo(m_ulItems);

    //
    // Set a default drag image struct with what we know so far
    //
    m_vDragImage.cb             = sizeof(DRAGIMAGE);
    m_vDragImage.cptl           = 0;  // non-zero if fl is DRG_POLYGON
    m_vDragImage.hImage         = 0;  // Set in GiveFeedback
    m_vDragImage.sizlStretch.cx = 20L;
    m_vDragImage.sizlStretch.cy = 20L;
    m_vDragImage.fl             = DRG_ICON | DRG_STRETCH;
    m_vDragImage.cxOffset       = 0;
    m_vDragImage.cyOffset       = 0;

    HSTR    hStrType = ::DrgAddStrHandle(DRT_UNKNOWN);
    HSTR    hStrRMF;
    HSTR    hStrContainer;
    wxChar  zFormats[128];
    wxChar  zContainer[128];
    USHORT  uSize = (USHORT)(GetDataObject()->GetDataSize(GetDataObject()->GetPreferredFormat()) + 1);
    wxChar* pzBuffer = new wxChar[uSize];

    memset(pzBuffer, '\0', GetDataObject()->GetDataSize(GetDataObject()->GetPreferredFormat()));
    pzBuffer[GetDataObject()->GetDataSize(GetDataObject()->GetPreferredFormat())] = '\0';
    GetDataObject()->GetDataHere( GetDataObject()->GetPreferredFormat()
                                 ,(void*)pzBuffer
                                );

    wxStrcpy(zFormats, _T("<DRM_OS2FILE, DRF_UNKNOWN>"));
    wxStrcpy(zContainer, GetDataObject()->GetPreferredFormat().GetId());

    hStrRMF       = ::DrgAddStrHandle((PSZ)zFormats);
    hStrContainer = ::DrgAddStrHandle((PSZ)zContainer);

    m_pDragItem = new DRAGITEM[m_ulItems];
    for (ULONG i = 0; i < m_ulItems; i++)
    {
        m_pDragItem[i].hwndItem          = m_pWindow->GetHWND();
        m_pDragItem[i].hstrType          = hStrType;
        m_pDragItem[i].hstrRMF           = hStrRMF;
        m_pDragItem[i].hstrContainerName = hStrContainer;
        m_pDragItem[i].fsControl         = 0;
        m_pDragItem[i].fsSupportedOps    = DO_COPYABLE | DO_MOVEABLE | DO_LINKABLE;
        m_pDragItem[i].hstrSourceName    = ::DrgAddStrHandle((PSZ)pzBuffer);
        m_pDragItem[i].hstrTargetName    = m_pDragItem[i].hstrSourceName;
        m_pDragItem[i].ulItemID          = i;
        ::DrgSetDragitem( m_pDragInfo
                         ,&m_pDragItem[i]
                         ,sizeof(DRAGITEM)
                         ,0
                        );
    }
    delete [] pzBuffer;
    delete [] m_pDragItem;
} // end of wxDropSource::Init
wxDragResult NassiDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
{
    if ( !GetData() )
    {
        wxMessageBox(_("Failed to get drag and drop data") );
        return wxDragNone;
    }

    return m_window->OnDrop(wxPoint(x,y),
        ((NassiDataObject *)GetDataObject())->GetBrick(),
        ((NassiDataObject *)GetDataObject())->GetText(0),
        ((NassiDataObject *)GetDataObject())->GetText(1),
         def );
}
Exemple #3
0
void COleServerItem::NotifyClient(OLE_NOTIFICATION nCode, DWORD dwParam)
{
	switch (nCode)
	{
	// IDataObject notifications
	case OLE_CHANGED:
		if (m_lpDataAdviseHolder != NULL)
			m_lpDataAdviseHolder->SendOnDataChange(GetDataObject(), dwParam, 0);
		break;

	// IOleObject notifications
	case OLE_SAVED:
		if (m_lpOleAdviseHolder != NULL)
			m_lpOleAdviseHolder->SendOnSave();
		break;
	case OLE_CLOSED:
		if (m_lpOleAdviseHolder != NULL)
			m_lpOleAdviseHolder->SendOnClose();
		break;
	case OLE_RENAMED:
		if (m_lpOleAdviseHolder != NULL)
		{
			// Note: the moniker should already be updated for this to work
			LPMONIKER lpMoniker = (LPMONIKER)dwParam;
			m_lpOleAdviseHolder->SendOnRename(lpMoniker);
		}
		break;

	default:
		ASSERT(FALSE);
	}
}
    virtual wxDragResult OnData(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def)
    {
        if (!GetData())
	    return wxDragNone;

	wxString url = ((wxURLDataObject*)GetDataObject())->GetURL();
	url.Trim();
	url.Trim(false);

	wxArrayString good;

	wxStringTokenizer tokenizer(url);//tokenize lines
	while (tokenizer.HasMoreTokens()) {
	    wxString token = tokenizer.GetNextToken();
	    token.Trim();

	    URLValidator urlv;
	    wxString err = urlv.IsValid(token);
	    if (!err.IsEmpty()) {
		wxString buf;
		buf.Printf(err, token.c_str());
		wxMessageBox(buf, _("Validation conflict"),
			     wxOK | wxICON_EXCLAMATION, m_owner);
		return wxDragError;
	    }
	    good.Add(token);
	}
	for (unsigned i=0;i<good.GetCount();i++)
	    m_owner->Append(good[i]);

        return def;
    }
wxDragResult NassiDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
{
    bool HasNoBricks = !(((NassiDataObject *)GetDataObject())->HasBrick());
    // GetData() has not yet been called. so we assume here that it will get some bricks.
    // TODO (daniel#1#): Check for a nicer solution
    HasNoBricks = false;
    return m_window->OnDragOver(wxPoint(x, y), def, HasNoBricks);
}
Exemple #6
0
wxDragResult DrawInfoDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def) {
	if (GetData() == false)
		return wxDragNone;

	DrawInfoDataObject* did =  (DrawInfoDataObject*)GetDataObject();

	return m_receiver->SetDrawInfo(x, y, did->GetDrawInfo(), def);
}
wxDragResult DnDJigsawShapeDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
{
	do
	{
		if (!GetData() || !m_pOwner->GetView()) break;
		OnDropShape(wxPoint(x, y), ((DnDJigsawShapeDataObject *)GetDataObject())->GetShapeInfo());
		return def;
	}
	while(false);
	return wxDragNone;
}
Exemple #8
0
wxDragResult
MMessagesDropTargetBase::OnData(wxCoord x, wxCoord y, wxDragResult def)
{
   if ( !GetData() )
   {
      wxLogDebug(_T("Failed to get drag and drop data"));

      return wxDragNone;
   }

   return OnMsgDrop(x, y, (MMessagesDataObject *)GetDataObject(), def);
}
Exemple #9
0
bool Emfout::ToClipboard()
{
  wxASSERT_MSG(!wxTheClipboard->IsOpened(),_("Bug: The clipboard is already opened"));
  if (wxTheClipboard->Open())
  {
    bool res = wxTheClipboard->SetData(GetDataObject());
    wxTheClipboard->Close();
    m_filename = wxEmptyString;
    return res;
  }
  return false;
}
Exemple #10
0
wxDragResult SetInfoDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def) {
	if (GetData() == false)
		return wxDragNone;

	SetInfoDataObject* wid = (SetInfoDataObject*)GetDataObject();

	return m_receiver->SetSetInfo(x, 
			y, 
			wid->GetSet(), 
			wid->GetPrefix(),
			wid->GetTime(),
			wid->GetPeriod(),
			def);
}
nsresult
NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream)
{
  NS_ASSERTION(IsBlobURI(aURI), "Only call this with blob URIs");

  *aStream = nullptr;

  nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(GetDataObject(aURI));
  if (!blob) {
    return NS_ERROR_DOM_BAD_URI;
  }

  return blob->GetInternalStream(aStream);
}
nsresult
NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource)
{
  NS_ASSERTION(IsMediaSourceURI(aURI), "Only call this with mediasource URIs");

  *aSource = nullptr;

  nsCOMPtr<mozilla::dom::MediaSource> source = do_QueryInterface(GetDataObject(aURI));
  if (!source) {
    return NS_ERROR_DOM_BAD_URI;
  }

  source.forget(aSource);
  return NS_OK;
}
//--------------------------------------------------------------------------------
wxDragResult CIwLayoutDataDnDTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
{
    wxPoint Pt2(x,y);
    Pt2=m_Ctrl->ClientToScreen(Pt2);

    if (CIwTheFrame->m_CurrDnDData==NULL)
        return wxDragNone;

    GetData();
    CIwLayoutDnDObject* Data=(CIwLayoutDnDObject*)GetDataObject();
    if (Data==NULL)
        return wxDragNone;

    wxDragResult Result=m_Elem->DoDataDrop(Pt2,def,Data);
    return Result;
}
nsresult
NS_GetStreamForMediaStreamURI(nsIURI* aURI, nsIDOMMediaStream** aStream)
{
  NS_ASSERTION(IsMediaStreamURI(aURI), "Only call this with mediastream URIs");

  *aStream = nullptr;

  nsCOMPtr<nsIDOMMediaStream> stream = do_QueryInterface(GetDataObject(aURI));
  if (!stream) {
    return NS_ERROR_DOM_BAD_URI;
  }

  *aStream = stream;
  NS_ADDREF(*aStream);
  return NS_OK;
}
wxDragResult SourcesDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
{
	bool bRes = false;
	if (GetData() )
	{
		wxDataObjectSimple *dobj = ((wxDataObjectCompositeEx *)GetDataObject())->GetActualDataObject();

		if( dobj == (wxDataObjectSimple *)m_pSourcesDObj )
		{
			bRes = OnDropSources(x, y, m_pSourcesDObj->GetText());
		}
		else if( dobj == (wxDataObjectSimple *)m_pSonglistDObj )
		{
			bRes = OnDropSonglist(x, y, m_pSonglistDObj->GetText());
		}
	}
	return bRes ? def : wxDragNone;
}
Exemple #16
0
void COleServerItem::AddOtherClipboardData(COleDataSource* pDataSource)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDataSource);

	// get IEnumFORMATETC interface for the IDataObject
	LPDATAOBJECT lpDataObject = GetDataObject();
	LPENUMFORMATETC lpEnumFORMATETC;
	if (lpDataObject->EnumFormatEtc(DATADIR_GET, &lpEnumFORMATETC) != S_OK)
		return;
	ASSERT(lpEnumFORMATETC != NULL);

	// get all formats that the object will give us
	FORMATETC formatEtc;
	while (lpEnumFORMATETC->Next(1, &formatEtc, NULL) == S_OK)
	{
		STGMEDIUM stgMedium;
		if (lpDataObject->GetData(&formatEtc, &stgMedium) != S_OK)
		{
			// data is not available
			CoTaskMemFree(formatEtc.ptd);
		}
		else if (stgMedium.pUnkForRelease != NULL)
		{
			// don't cache data with pUnkForRelease != NULL
			::ReleaseStgMedium(&stgMedium);
			CoTaskMemFree(formatEtc.ptd);
		}
		else
		{
			// cache the data (now we own the stgMedium)
			pDataSource->CacheData(0, &stgMedium, &formatEtc);
		}
	}

	// cleanup
	lpEnumFORMATETC->Release();
}
wxDragResult CodeEditDropTarget::OnData (wxCoord x, wxCoord y, wxDragResult def)
{

    if (!GetData())
    {
        return wxDragNone;
    }

    // Get object
    wxDataObjectSimple *obj = ((DropTargetsComposite *)GetDataObject())->GetLastDataObject();
    if (obj == ((wxDataObjectSimple*)m_file))
    {
        if (!OnDataFiles (x, y, m_file->GetFilenames())) def = wxDragNone;
    }
    else if (obj == ((wxDataObjectSimple*)m_text))
    {
        if (!OnDataText (x, y, m_text->GetText())) def = wxDragNone;
    }else
    {
        def = wxDragNone;
    }

    return def;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTriggerPortal::IsTouchingPortal( CBaseEntity *pEntity )
{
	// First, check the touchlinks. This will find non-vphysics entities touching us
    touchlink_t *root = ( touchlink_t * )GetDataObject( TOUCHLINK );
	if ( root )
	{
		for ( touchlink_t *link = root->nextLink; link != root; link = link->nextLink )
		{
			CBaseEntity *pTouch = link->entityTouched;
			if ( pTouch == pEntity )
				return true;
		}
	}

	// Then check the friction snapshot. This will find vphysics objects touching us.
	IPhysicsObject *pPhysics = VPhysicsGetObject();
	if ( !pPhysics )
		return false;

	IPhysicsFrictionSnapshot *pSnapshot = pPhysics->CreateFrictionSnapshot();
	bool bFound = false;
	while ( pSnapshot->IsValid() )
	{
		IPhysicsObject *pOther = pSnapshot->GetObject( 1 );
		if ( ((CBaseEntity *)pOther->GetGameData()) == pEntity )
		{
			bFound = true;
			break;
		}

		pSnapshot->NextFrictionData();
	}
	pPhysics->DestroyFrictionSnapshot( pSnapshot );

	return bFound;
}