Exemplo n.º 1
0
bool ZUITextEngine::Click(ZPoint inHitPoint, const ZEvent_Mouse& inEvent)
	{
	size_t selectStart, selectLength;
	this->GetSelection(selectStart, selectLength);
	if (selectLength != 0)
		{
		size_t cursorOffset = this->PointToOffset(this->FromHost(inHitPoint));
		if (cursorOffset >= selectStart && cursorOffset < selectStart + selectLength)
			{
			if (fHost->GetHostPane(this)->GetWindow()->WaitForMouse())
				{
				ZTuple theTuple = this->GetTuple(selectStart, selectLength);
				if (ZDragInitiator* theDragInitiator = fHost->GetHostPane(this)->GetWindow()->CreateDragInitiator())
					{
					ZDC theDC = this->GetHostDC();
					ZDCRgn hiliteRgn = theDC.GetClip() & this->GetTextRgn(selectStart, selectLength);
					theDC.SetClip(hiliteRgn);

					ZDCPixmap thePixmap;
					ZPoint hiliteRgnSize = hiliteRgn.Bounds().Size();
					if ((hiliteRgnSize.h * hiliteRgnSize.v) <= 90000)
						{
						ZDC_Off theOffDC(theDC, true);
						this->DrawRange(theOffDC, selectStart, selectLength);
						theOffDC.Sync();
						thePixmap = theOffDC.GetPixmap(theOffDC.GetClip().Bounds());
						}
					ZPoint theOffset = hiliteRgn.Bounds().TopLeft();
					hiliteRgn -= theOffset;
					theDragInitiator->DoDrag(theTuple, fHost->GetHostPane(this)->ToGlobal(inHitPoint), this->FromHost(inHitPoint) - theOffset, theDragInitiator->OutlineRgn(hiliteRgn), thePixmap, hiliteRgn, this);
					return true;
					}
				}
			}
		}
	return false;
	}
Exemplo n.º 2
0
void ZDCCanvas_X_NonWindow::Scroll(ZDCState& ioState, const ZRect& inRect, ZCoord hDelta, ZCoord vDelta)
	{
	if (!fDrawable)
		return;
	SetupLock theSetupLock(this);

	++fChangeCount_Clip;

	ZPoint offset(hDelta, vDelta);

	// destRgn is the pixels we want and are able to draw to.
	ZDCRgn destRgn = ((ioState.fClip + ioState.fClipOrigin) & (inRect + ioState.fOrigin));

	// srcRgn is the set of pixels we're want and are able to copy from.
	ZDCRgn srcRgn = ((destRgn - offset) & (inRect + ioState.fOrigin));

	// drawnRgn is the destination pixels that will be drawn by the CopyBits call, it's the srcRgn
	// shifted back to the destination.
	ZDCRgn drawnRgn = srcRgn + offset;

	// invalidRgn is the destination pixels we wanted to draw but could not because they were
	// outside the visRgn, or were in the excludeRgn
	ZDCRgn invalidRgn = destRgn - drawnRgn;

	// And set the clip (drawnRgn)
	fXServer->SetRegion(fGC, drawnRgn.GetRegion());
	++fChangeCount_Clip;

	fXServer->SetFunction(fGC, GXcopy);
	++fChangeCount_Mode;

	ZRect drawnBounds = drawnRgn.Bounds();

	fXServer->CopyArea(fDrawable, fDrawable, fGC,
				drawnBounds.Left() - offset.h, drawnBounds.Top() - offset.v,
				drawnBounds.Width(), drawnBounds.Height(),
				drawnBounds.Left(), drawnBounds.Top());
	}