本文整理汇总了C++中DisplayModel::FirstVisiblePageNo方法的典型用法代码示例。如果您正苦于以下问题:C++ DisplayModel::FirstVisiblePageNo方法的具体用法?C++ DisplayModel::FirstVisiblePageNo怎么用?C++ DisplayModel::FirstVisiblePageNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DisplayModel
的用法示例。
在下文中一共展示了DisplayModel::FirstVisiblePageNo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ZoomToSelection
void ZoomToSelection(WindowInfo* win, float factor, bool scrollToFit, bool relative) {
PointI pt;
bool zoomToPt = false;
if (win->AsFixed()) {
DisplayModel* dm = win->AsFixed();
// when not zooming to fit (which contradicts zooming to a specific point), ...
if (!relative && (ZOOM_FIT_PAGE == factor || ZOOM_FIT_CONTENT == factor) && scrollToFit) {
zoomToPt = false;
}
// either scroll towards the center of the current selection (if there is any) ...
else if (win->showSelection && win->currentTab->selectionOnPage) {
RectI selRect;
for (SelectionOnPage& sel : *win->currentTab->selectionOnPage) {
selRect = selRect.Union(sel.GetRect(dm));
}
ClientRect rc(win->hwndCanvas);
pt.x = 2 * selRect.x + selRect.dx - rc.dx / 2;
pt.y = 2 * selRect.y + selRect.dy - rc.dy / 2;
pt.x = limitValue(pt.x, selRect.x, selRect.x + selRect.dx);
pt.y = limitValue(pt.y, selRect.y, selRect.y + selRect.dy);
int pageNo = dm->GetPageNoByPoint(pt);
zoomToPt = dm->ValidPageNo(pageNo) && dm->PageVisible(pageNo);
}
// or towards the top-left-most part of the first visible page
else {
int page = dm->FirstVisiblePageNo();
PageInfo* pageInfo = dm->GetPageInfo(page);
if (pageInfo) {
RectI visible = pageInfo->pageOnScreen.Intersect(win->canvasRc);
pt = visible.TL();
int pageNo = dm->GetPageNoByPoint(pt);
zoomToPt = !visible.IsEmpty() && dm->ValidPageNo(pageNo) && dm->PageVisible(pageNo);
}
}
}
win->ctrl->SetZoomVirtual(factor * (relative ? win->ctrl->GetZoomVirtual(true) : 1), zoomToPt ? &pt : nullptr);
UpdateToolbarState(win);
}