Exemplo n.º 1
0
void BookTextView::PositionIndicatorWithLabels::draw() {
	PositionIndicator::draw();

	const BookTextView& bookTextView = (const BookTextView&)textView();

	if (bookTextView.ShowTOCMarksOption.value()) {
		shared_ptr<ZLTextModel> contentsModelPtr = bookTextView.myContentsModel;
		if (!contentsModelPtr.isNull()) {
			ContentsModel &contentsModel = (ContentsModel&)*contentsModelPtr;
			const int marksNumber = contentsModel.paragraphsNumber();
			const std::size_t startIndex = bookTextView.startTextIndex();
			const std::size_t endIndex = bookTextView.endTextIndex();
			const std::vector<std::size_t> &textSizeVector = textSize();
			const int fullWidth = right() - left() - 1;
			const std::size_t startPosition = textSizeVector[startIndex];
			const std::size_t fullTextSize = textSizeVector[endIndex] - startPosition;
			const int bottom = this->bottom();
			const int top = this->top();
			for (int i = 0; i < marksNumber; ++i) {
				std::size_t reference = contentsModel.reference((ZLTextTreeParagraph*)contentsModel[i]);
				if ((startIndex < reference) && (reference < endIndex)) {
					int position = left() + 2 + (int)
						(1.0 * fullWidth * (textSizeVector[reference] - startPosition) / fullTextSize);
					context().drawLine(position, bottom, position, top);
				}
			}
		}
	}
}
void InteractivePointer::update(int posX, int posY, QVector<int> val1, QVector<int> val2, int mode)
{
    // Also update current position.
    updatePosition(posX, posY);

    if (mode == 0)                      // Zoom view
    {
        this->setFixedWidth(pointerSizeX());
        this->setFixedHeight(pointerSizeY());

        zoomView(val1, winSize());
    }
    else if (mode == 1)                 // Difference view
    {
        this->setFixedWidth(pointerSizeX());
        this->setFixedHeight(pointerSizeY());

        diffView(val1, val2, winSize());
    }
    else                                // Text View
    {
        // The reason we are not adjusting the font, and/or window size here, is to help users with poor eyesight
        // to avoid small letters. So let a user find his desired font size, and adjust the pointer accordingly.        
        this->setFixedWidth(winSize() * (m_pixelsWideT + m_pixelsWideS));
        this->setFixedHeight(winSize() * (m_pixelsHighS));

        this->setLineWidth(pointerSizeY());
        textView(val1, winSize());
    }
}