void CSplitterCursor::Drag(int nX) { if (m_fDragging) { DrawDrag(); SetX(nX); DrawDrag(); } }
NS_IMETHODIMP nsDragServiceProxy::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aArrayTransferables, nsIScriptableRegion* aRegion, uint32_t aActionType) { nsresult rv = nsBaseDragService::InvokeDragSession(aDOMNode, aArrayTransferables, aRegion, aActionType); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMDocument> sourceDocument; aDOMNode->GetOwnerDocument(getter_AddRefs(sourceDocument)); nsCOMPtr<nsIDocument> doc = do_QueryInterface(sourceDocument); NS_ENSURE_STATE(doc->GetDocShell()); mozilla::dom::TabChild* child = mozilla::dom::TabChild::GetFrom(doc->GetDocShell()); NS_ENSURE_STATE(child); nsTArray<mozilla::dom::IPCDataTransfer> dataTransfers; nsContentUtils::TransferablesToIPCTransferables(aArrayTransferables, dataTransfers, child->Manager(), nullptr); if (mHasImage || mSelection) { nsIntRect dragRect; nsPresContext* pc; mozilla::RefPtr<mozilla::gfx::SourceSurface> surface; DrawDrag(mSourceNode, aRegion, mScreenX, mScreenY, &dragRect, &surface, &pc); if (surface) { mozilla::RefPtr<mozilla::gfx::DataSourceSurface> dataSurface = surface->GetDataSurface(); mozilla::gfx::IntSize size = dataSurface->GetSize(); size_t length; int32_t stride; mozilla::UniquePtr<char[]> surfaceData = nsContentUtils::GetSurfaceData(dataSurface, &length, &stride); nsDependentCString dragImage(surfaceData.get(), length); mozilla::unused << child->SendInvokeDragSession(dataTransfers, aActionType, dragImage, size.width, size.height, stride, static_cast<uint8_t>(dataSurface->GetFormat()), dragRect.x, dragRect.y); StartDragSession(); return NS_OK; } } mozilla::unused << child->SendInvokeDragSession(dataTransfers, aActionType, nsCString(), 0, 0, 0, 0, 0, 0); StartDragSession(); return NS_OK; }
void CSplitterCursor::EndDrag(int nX) { if (m_fDragging) { DrawDrag(); SetX(nX); ReleaseCapture(); m_fDragging = FALSE; } }
void CSplitterCursor::StartDrag(int nX, int nOffset, int nClipLeft, int nClipRight) { if (!m_fDragging) { m_pWnd->SetCapture(); m_fDragging = TRUE; m_nOffset = nOffset; m_nClipLeft = nClipLeft; m_nClipRight = nClipRight; SetX(nX); DrawDrag(); } }
//--------------------------------------------------------------------------- void __fastcall TMissionEditor::PGPaint(TObject *Sender) { TPaintBox* PaintBox=(TPaintBox*)Sender; MapBlock& block=PaintGrid[PaintBox->Tag%65536][PaintBox->Tag/65536]; if (CouldDoBetter(block)) { Mono_Text.PrintF("Paint %i,%i: ",PaintBox->Tag%65536,PaintBox->Tag/65536); int os=block.scaled+block.dirty*2; RescaleArt(block); if (os!=block.scaled+block.dirty*2) { TRect t=PaintBox->Canvas->ClipRect; if ( (t.Left!=0 && PaintBox->Left>=0) || (t.Top!=0 && PaintBox->Top>=0) || (t.Right!=256 && PaintBox->Left<=ScrollBox->ClientRect.Right-256) || (t.Bottom!=256 && PaintBox->Top<=ScrollBox->ClientRect.Bottom-256) ) { block.dirty=true; block.scaled=false; } } // os=os; } PaintBox->Canvas->Brush->Style = bsSolid; PaintBox->Canvas->Draw(0,0,block.backdrop); CurrCanvas=█ MapOriginX=block.wx(); MapOriginY=FULLY-block.WZ; CurrCanvas->Pen(psSolid,(TColor)0xFFFFFF,2); DrawStatics(); DrawDrag(block); }
PRBool nsDragService::CreateDragImage(nsIDOMNode *aDOMNode, nsIScriptableRegion *aRegion, SHDRAGIMAGE *psdi) { if (!psdi) return PR_FALSE; memset(psdi, 0, sizeof(SHDRAGIMAGE)); if (!aDOMNode) return PR_FALSE; // Prepare the drag image nsIntRect dragRect; nsRefPtr<gfxASurface> surface; nsPresContext* pc; DrawDrag(aDOMNode, aRegion, mScreenX, mScreenY, &dragRect, getter_AddRefs(surface), &pc); if (!surface) return PR_FALSE; PRUint32 bmWidth = dragRect.width, bmHeight = dragRect.height; if (bmWidth == 0 || bmHeight == 0) return PR_FALSE; psdi->crColorKey = CLR_NONE; nsRefPtr<gfxImageSurface> imgSurface = new gfxImageSurface( gfxIntSize(bmWidth, bmHeight), gfxImageSurface::ImageFormatARGB32); if (!imgSurface) return PR_FALSE; nsRefPtr<gfxContext> context = new gfxContext(imgSurface); if (!context) return PR_FALSE; context->SetOperator(gfxContext::OPERATOR_SOURCE); context->SetSource(surface); context->Paint(); BITMAPV5HEADER bmih; memset((void*)&bmih, 0, sizeof(BITMAPV5HEADER)); bmih.bV5Size = sizeof(BITMAPV5HEADER); bmih.bV5Width = bmWidth; bmih.bV5Height = -bmHeight; // flip vertical bmih.bV5Planes = 1; bmih.bV5BitCount = 32; bmih.bV5Compression = BI_BITFIELDS; bmih.bV5RedMask = 0x00FF0000; bmih.bV5GreenMask = 0x0000FF00; bmih.bV5BlueMask = 0x000000FF; bmih.bV5AlphaMask = 0xFF000000; HDC hdcSrc = CreateCompatibleDC(NULL); void *lpBits = NULL; if (hdcSrc) { psdi->hbmpDragImage = ::CreateDIBSection(hdcSrc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&lpBits, NULL, 0); if (psdi->hbmpDragImage && lpBits) { memcpy(lpBits,imgSurface->Data(),(bmWidth*bmHeight*4)); } psdi->sizeDragImage.cx = bmWidth; psdi->sizeDragImage.cy = bmHeight; // Mouse position in center if (mScreenX == -1 || mScreenY == -1) { psdi->ptOffset.x = (PRUint32)((float)bmWidth/2.0f); psdi->ptOffset.y = (PRUint32)((float)bmHeight/2.0f); } else { PRInt32 sx = mScreenX, sy = mScreenY; ConvertToUnscaledDevPixels(pc, &sx, &sy); psdi->ptOffset.x = sx - dragRect.x; psdi->ptOffset.y = sy - dragRect.y; } DeleteDC(hdcSrc); } return psdi->hbmpDragImage != NULL; }