Exemplo n.º 1
0
ZPoint ZTextUtil::sCalcSize(const ZDC& inDC, ZCoord inWidth, const char* inText, size_t inTextLength)
	{
	ZPoint stringDimensions = ZPoint::sZero;
	if (inTextLength == 0) 
		return stringDimensions;

	ZCoord ascent, descent, leading;
	inDC.GetFontInfo(ascent, descent, leading);

	size_t currentLineOffset = 0;
	size_t remainingTextLength = inTextLength;

	while (remainingTextLength > 0)
		{
		size_t nextLineDelta;
		inDC.BreakLine(inText + currentLineOffset, remainingTextLength, inWidth, nextLineDelta);
		ZCoord brokenWidth = inDC.GetTextWidth(inText + currentLineOffset, nextLineDelta);
		if (stringDimensions.h < brokenWidth)
			stringDimensions.h = brokenWidth;
		stringDimensions.v += ascent + descent;
		currentLineOffset += nextLineDelta;
		remainingTextLength -= nextLineDelta;
		}

	return stringDimensions;
	}
Exemplo n.º 2
0
void ZUITextPane_TextEngine::DoIdle()
	{
	ASSERTLOCKED();
	ZDC theDC = this->GetDC();
	fTextEngine->Idle(theDC, this->GetEngineActive(fTextEngine) && this->GetEngineEditable(fTextEngine));
	theDC.Flush();
	}
Exemplo n.º 3
0
ZDC ZUITextEngine::GetHostDC()
	{
	ZDC theDC = fHost->GetHostPane(this)->GetDC();
	theDC.SetClip(fHost->GetEngineClip(this));
	theDC.OffsetOrigin(fHost->GetEngineLocation(this));
	return theDC;
	}
Exemplo n.º 4
0
ZDC_Off::ZDC_Off(const ZDC& inOther, bool inForceOffscreen)
:	ZDC(inOther)
	{
	// Initially, we copy all settings from inOther, then we attempt to
	// create a new offscreen canvas.
	if (inForceOffscreen || !fCanvas->IsOffScreen())
		{
		ZRect canvasClipRect = this->GetClip().Bounds() + this->GetOrigin();
		ZRef<ZDCCanvas> offCanvas;
		try
			{
			// We allow the offscreen creation to fail if inForceOffscreen is false.
			offCanvas = fCanvas->CreateOffScreen(canvasClipRect);
			}
		catch (...)
			{
			if (inForceOffscreen)
				throw;
			}
		if (offCanvas && offCanvas->IsOffScreen())
			{
			fCanvas = offCanvas;
			this->ZeroChangeCounts();
			fState.fOriginComp = canvasClipRect.TopLeft();
			this->SetOrigin(inOther.GetOrigin());
			this->SetPatternOrigin(inOther.GetPatternOrigin());
			this->SetClip(inOther.GetClip());
			}
		}
	}
Exemplo n.º 5
0
// This version takes a width for the first line and another for subsequent lines. This is useful when the display of a string 
// will start on one that has already been partially "consumed" by some other element(s). -ec 99.09.13
void ZTextUtil::sCalcLineBreaks(const ZDC& inDC, ZCoord inWidth1, ZCoord inWidth2, const string& inString, vector<ZTextUtil::LineBreak>& outLineBreaks)
	{
	if (inString.size() == 0)
		return;

	//ZCoord ascent, descent, leading;
	//inDC.GetFontInfo(ascent, descent, leading);
	ZCoord availableWidth = inWidth1;

	const char* textStart = &inString.at(0);
	size_t currentLineOffset = 0;
	size_t remainingTextLength = inString.size();

	while (remainingTextLength > 0)
		{
		size_t nextLineDelta;
#if 1 // rough fix. -ec 99.11.18
		if (availableWidth < 0)
			availableWidth = 0;
#else
		ZAssert(availableWidth >= 0);
#endif
		inDC.BreakLine(textStart + currentLineOffset, remainingTextLength, availableWidth, nextLineDelta);
		outLineBreaks.push_back(LineBreak(currentLineOffset, nextLineDelta));
		currentLineOffset += nextLineDelta;
		remainingTextLength -= nextLineDelta;
		availableWidth = inWidth2;
		}
	}
Exemplo n.º 6
0
//void ZTextUtil::sDraw(const ZDC& inDC, ZPoint inLocation, ZCoord inWidth, const char* inText, size_t inTextLength)
void ZTextUtil_sDraw(const ZDC& inDC, ZPoint inLocation, ZCoord inWidth, const char* inText, size_t inTextLength)
	{
	if (inTextLength == 0) 
		return;

	ZCoord ascent, descent, leading;
	inDC.GetFontInfo(ascent, descent, leading);
	inLocation.v += ascent;

	size_t currentLineOffset = 0;
	size_t remainingTextLength = inTextLength;

	while (remainingTextLength > 0)
		{
		size_t nextLineDelta;
		inDC.BreakLine(inText + currentLineOffset, remainingTextLength, inWidth, nextLineDelta);
		inDC.DrawText(inLocation, inText + currentLineOffset, nextLineDelta);
		inLocation.v += ascent + descent;
		currentLineOffset += nextLineDelta;
		remainingTextLength -= nextLineDelta;
		}
	}
Exemplo n.º 7
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.º 8
0
//## This lets some calling routine do the while-loop over the text.
// AG 2000-04-01. Of course, it would be better to recast the calling code to manage the issue itself,
// however we live in an imperfect universe. :) This will be going away soon.
size_t ZTextUtil::sCalcNextLineBreak(const ZDC& inDC, ZCoord inWidth, const char* inText, size_t inTextLength, size_t inOffset)
	{
#if 1 // the alternative couldn't be right! -ec 01.10.17
	if (inTextLength == 0)
		return 0;
#else
	if (inTextLength)
		return 0;
#endif

	size_t remainingTextLength = inTextLength - inOffset;

// this guarantees that we won't get overflows, and crashes with strings longer than 32767 bytes. -ec 00.02.24
	remainingTextLength = min(remainingTextLength, size_t(32767));

	size_t nextLineDelta;
	inDC.BreakLine(inText + inOffset, remainingTextLength, inWidth, nextLineDelta);
	return nextLineDelta;
	}
Exemplo n.º 9
0
void ZTextUtil::sCalcLineBreaks(const ZDC& inDC, ZCoord inWidth, const string& inString, vector<ZTextUtil::LineBreak>& outLineBreaks)
	{
	if (inString.size() == 0)
		return;

	//ZCoord ascent, descent, leading;
	//inDC.GetFontInfo(ascent, descent, leading);

	const char* textStart = &inString.at(0);
	size_t currentLineOffset = 0;
	size_t remainingTextLength = inString.size();

	while (remainingTextLength > 0)
		{
		size_t nextLineDelta;
		inDC.BreakLine(textStart + currentLineOffset, remainingTextLength, inWidth, nextLineDelta);
		outLineBreaks.push_back(LineBreak(currentLineOffset, nextLineDelta));
		currentLineOffset += nextLineDelta;
		remainingTextLength -= nextLineDelta;
		}
	}
Exemplo n.º 10
0
void ZSuperPane::DoDraw(const ZDC& inDC, const ZDCRgn& inBoundsRgn)
	{
	inDC.Fill(inDC.GetClip() - this->GetSubPaneRgn());
	}
Exemplo n.º 11
0
void ZSubPane::DoDraw(const ZDC& inDC, const ZDCRgn& inBoundsRgn)
	{
	inDC.Fill(inBoundsRgn);
	}