Example #1
0
void ZLTextView::drawSelectionRectangle(int left, int top, int right, int bottom) {
	left = std::max(left, lineStartMargin());
	right = std::min(right, viewWidth() + lineStartMargin() - 1);
	if (left < right) {
		context().setFillColor(ZLTextStyleCollection::instance().baseStyle().SelectionBackgroundColorOption.value());
		context().fillRectangle(visualX(left), top, visualX(right), bottom);
	}
}
Example #2
0
bool ZLTextView::onStylusMovePressed(int x, int y) {
    if (mySelectionModel.extendTo(visualX(x), y)) {
        application().refreshWindow();
        copySelectedTextToClipboard(ZLDialogManager::CLIPBOARD_SELECTION);
    }
    return true;
}
Example #3
0
bool ZLTextView::onStylusRelease(int x, int y)
{
    if (mySelectionModel.selectWord(visualX(x), y))
    {
        application().refreshWindow();
        return true;
    }
    mySelectionModel.deactivate();
    return false;
}
Example #4
0
int ZLTextView::paragraphIndexByCoordinates(int x, int y) const {
    x = visualX(x);
    int paragraphIndex = -1;
    int yBottom = -1;
    int xLeft = context().width() + 1;
    int xRight = -1;

    for (ZLTextElementIterator it = myTextElementMap.begin(); it != myTextElementMap.end(); ++it) {
        if (it->YEnd < y) {
            paragraphIndex = it->ParagraphIndex;
            if (it->YStart > yBottom) {
                yBottom = it->YEnd;
                xLeft = it->XStart;
                xRight = -1;
            }
            xRight = it->XEnd;
            continue;
        }
        if (it->YStart > y) {
            return
                ((paragraphIndex == it->ParagraphIndex) &&
                 (xLeft <= x) && (x <= xRight)) ?
                paragraphIndex : -1;
        }
        if (it->XEnd < x) {
            paragraphIndex = it->ParagraphIndex;
            if (it->YStart > yBottom) {
                yBottom = it->YEnd;
                xLeft = it->XStart;
                xRight = -1;
            }
            xRight = it->XEnd;
            continue;
        }
        if (it->XStart > x) {
            return
                ((paragraphIndex == it->ParagraphIndex) &&
                 (it->YStart <= yBottom) && (xLeft < x)) ?
                paragraphIndex : -1;
        }
        return it->ParagraphIndex;
    }
    return -1;
}
Example #5
0
bool ZLTextView::onStylusClick(int x, int y, int count) {
    if (count > 20) {
        return true;
    } else if (count > 10) {
        mySelectionModel.extendWordSelectionToParagraph();
        application().refreshWindow();
        copySelectedTextToClipboard(ZLDialogManager::CLIPBOARD_SELECTION);
        myDoubleClickInfo.Count = 20;
        return true;
    } else if (count > 2) {
        if (mySelectionModel.selectWord(visualX(x), y)) {
            application().refreshWindow();
            copySelectedTextToClipboard(ZLDialogManager::CLIPBOARD_SELECTION);
            myDoubleClickInfo.Count = 10;
            return true;
        } else {
            myDoubleClickInfo.Count = 0;
        }
    }

    return true;
}
Example #6
0
void ZLTextView::activateSelection(int x, int y) {
    if (isSelectionEnabled()) {
        mySelectionModel.activate(visualX(x), y);
        application().refreshWindow();
    }
}
Example #7
0
const ZLTextElementArea *ZLTextView::elementByCoordinates(int x, int y) const {
    ZLTextElementIterator it =
        std::find_if(myTextElementMap.begin(), myTextElementMap.end(), ZLTextElementArea::RangeChecker(visualX(x), y));
    return (it != myTextElementMap.end()) ? &*it : 0;
}