void SetupStartHitPoint(CssBoxHitChain startChain, IFonts ifonts)
{
//find global location of start point
HitInfo startHit = startChain.GetLastHit();
//-----------------------------
this.startHitRun = null;
this.startHitRunCharIndex = 0;
switch (startHit.hitObjectKind)
{
case HitObjectKind.Run:
{
CssRun run = (CssRun)startHit.hitObject;
//-------------------------------------------------------
int sel_index;
int sel_offset;
run.FindSelectionPoint(ifonts,
startHit.localX,
out sel_index,
out sel_offset);
this.startHitRunCharIndex = sel_index;
//modify hitpoint
this.startHitHostLine = (CssLineBox)startChain.GetHitInfo(startChain.Count - 2).hitObject;
this.startLineBeginSelectionAtPixel = (int)(run.Left + sel_offset);
this.startHitRun = run;
}
break;
case HitObjectKind.LineBox:
{
this.startHitHostLine = (CssLineBox)startHit.hitObject;
this.startLineBeginSelectionAtPixel = startHit.localX;
//make global
}
break;
case HitObjectKind.CssBox:
{
CssBox box = (CssBox)startHit.hitObject;
//find first nearest line at point
CssLineBox startHitLine = FindNearestLine(box, startChain.RootGlobalY, 5);
this.startLineBeginSelectionAtPixel = 0;
if (startHitLine != null)
{
this.startHitHostLine = startHitLine;
}
else
{
//if not found?
this.startHitHostLine = null;
}
}
break;
default:
{
throw new NotSupportedException();
}
}
}