void ScribePage
::paint(QPainter * painter ,
{
/* QTextDocument = _d */
PageTotal = _d->pageCount();
const int PageSumm = qBound (1,_d->pageCount(),MaximumPages);
root_format = Tframe->frameFormat();
const QRectF ActiveBlock
= CurrentBlockRect
();
/* discovery qtextcursor living Current_Page_Nr */
painter->save();
painter->setPen( Qt::NoPen );
painter->setBrush(Qt::lightGray);
painter->drawRect(boundingRect());
painter->restore();
for (int i = 0; i < PageSumm; ++i) {
const QPointF topleft
= PageIndexTopLeft
(i
);
/* page top left point */ DrawPage(i,painter,i); /* active page from cursor !!
selectAll must draw cursor each page*/
}
}
void ScribePage::DrawPage( const int index ,
QPainter * painter ,
const int cursorpage
) {
const QPointF topleft
= PageIndexTopLeft
(index
);
CTX.
palette.
setColor(QPalette::Text, Qt
::black);
const QRectF body
= QRectF(0, topleft.
y() ,Page_Edit_Rect.
width(),
Page_Edit_Rect.height()); /* on view */
QRectF view
(0, index
* body.
height(), body.
width(), body.
height() );
/* on doc */
if (index != cursorpage || !Edit_On()) {
painter->save();
painter->translate(body.left(), body.top() - index * body.height());
painter->setClipRect(view);
CTX.clip = view;
_d->documentLayout()->draw(painter,CTX);
painter->restore();
return;
}
/* draw cursor active page no !edit no print only display edit! */
painter->save();
painter->translate(body.left(), body.top() - index * body.height());
painter->setClipRect(view);
CTX.clip = view;
QColor BackHightlight
("#0072ab");
BackHightlight.setAlpha(180);
CTX.
palette.
setColor(QPalette::Text, Qt
::black);
CTX.
palette.
setColor(QPalette::Highlight,BackHightlight
);
CTX.
palette.
setColor(QPalette::HighlightedText,Qt
::white);
CTX.selections;
CTX.clip = view;
CTX.cursorPosition = -1;
/* play cursor */
if (cursortime) { /* blink intervall by timer */
CTX.cursorPosition = C_cursor.position();
}
if ( C_cursor.hasSelection()) {
Internal_selection.cursor = C_cursor;
Internal_selection.
format.
setBackground(CTX.
palette.
brush(cg,
QPalette::Highlight));
Internal_selection.
format.
setForeground(CTX.
palette.
brush(cg,
QPalette::HighlightedText));
Internal_selection.
format.
setProperty(QTextFormat::FullWidthSelection,
true);
CTX.selections.append(Internal_selection);
}
_d->documentLayout()->draw(painter,CTX);
painter->restore();
}
void ScribePage::paint(QPainter * painter ,
const QStyleOptionGraphicsItem *option , QWidget *widget )
{
/* QTextDocument = _d */
PageTotal = _d->pageCount();
const int PageSumm = qBound (1,_d->pageCount(),MaximumPages);
QTextFrame *Tframe = _d->rootFrame();
root_format = Tframe->frameFormat();
const QRectF ActiveBlock = CurrentBlockRect();
/* discovery qtextcursor living Current_Page_Nr */
painter->save();
painter->setPen( Qt::NoPen );
painter->setBrush(Qt::lightGray);
painter->drawRect(boundingRect());
painter->restore();
for (int i = 0; i < PageSumm; ++i) {
const QPointF topleft = PageIndexTopLeft(i); /* page top left point */
DrawPage(i,painter,i); /* active page from cursor !!
selectAll must draw cursor each page*/
}
}
void ScribePage::DrawPage( const int index ,
QPainter * painter , const int cursorpage )
{
const QPointF topleft = PageIndexTopLeft(index);
QAbstractTextDocumentLayout::PaintContext CTX;
CTX.palette.setColor(QPalette::Text, Qt::black);
const QRectF body = QRectF(0, topleft.y() ,Page_Edit_Rect.width(),
Page_Edit_Rect.height()); /* on view */
QRectF view(0, index * body.height(), body.width(), body.height() ); /* on doc */
if (index != cursorpage || !Edit_On()) {
painter->save();
painter->translate(body.left(), body.top() - index * body.height());
painter->setClipRect(view);
CTX.clip = view;
_d->documentLayout()->draw(painter,CTX);
painter->restore();
return;
}
/* draw cursor active page no !edit no print only display edit! */
painter->save();
painter->translate(body.left(), body.top() - index * body.height());
painter->setClipRect(view);
CTX.clip = view;
QColor BackHightlight("#0072ab");
BackHightlight.setAlpha(180);
CTX.palette.setColor(QPalette::Text, Qt::black);
CTX.palette.setColor(QPalette::Highlight,BackHightlight);
CTX.palette.setColor(QPalette::HighlightedText,Qt::white);
CTX.selections;
CTX.clip = view;
CTX.cursorPosition = -1;
/* play cursor */
if (cursortime) { /* blink intervall by timer */
CTX.cursorPosition = C_cursor.position();
}
if ( C_cursor.hasSelection()) {
QAbstractTextDocumentLayout::Selection Internal_selection;
Internal_selection.cursor = C_cursor;
QPalette::ColorGroup cg = cursorIsFocusIndicator ? QPalette::Active : QPalette::Inactive;
Internal_selection.format.setBackground(CTX.palette.brush(cg, QPalette::Highlight));
Internal_selection.format.setForeground(CTX.palette.brush(cg, QPalette::HighlightedText));
Internal_selection.format.setProperty(QTextFormat::FullWidthSelection, true);
CTX.selections.append(Internal_selection);
}
_d->documentLayout()->draw(painter,CTX);
painter->restore();
}
To copy to clipboard, switch view to plain text mode
Bookmarks