topFirst = first;
app.saveState();
app.rectangle(offsetX, offsetX, box.getWidth() - 2 * offsetX, box.getHeight() - 2 * offsetX);
app.clip();
app.newPath();
BaseColor fcolor = textColor == null ? GrayColor.GRAYBLACK : textColor;
// background boxes for selected value[s]
app.setColorFill(new BaseColor(10, 36, 106));
for (int curVal = 0; curVal < choiceSelections.size(); ++curVal) {
int curChoice = (choiceSelections.get( curVal )).intValue();
// only draw selections within our display range... not strictly necessary with
// that clipping rect from above, but it certainly doesn't hurt either
if (curChoice >= first && curChoice <= last) {
app.rectangle(offsetX, offsetX + h - (curChoice - first + 1) * leading, box.getWidth() - 2 * offsetX, leading);
app.fill();
}
}
float xp = offsetX * 2;
float yp = offsetX + h - ufont.getFontDescriptor(BaseFont.BBOXURY, usize);
for (int idx = first; idx < last; ++idx, yp -= leading) {
String ptext = choices[idx];
int rtl = checkRTL(ptext) ? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_NO_BIDI;
ptext = removeCRLF(ptext);
// highlight selected values against their (presumably) darker background
BaseColor textCol = choiceSelections.contains( Integer.valueOf( idx )) ? GrayColor.GRAYWHITE : fcolor;
Phrase phrase = composePhrase(ptext, ufont, textCol, usize);
ColumnText.showTextAligned(app, Element.ALIGN_LEFT, phrase, xp, yp, 0, rtl, 0);
}
app.restoreState();
app.endVariableText();