void DisplayManager::EnsureVisible(DisplayElement *pElem) { if (pElem->GetManager() == this) { WebRect rect; GetElementRect(&rect, pElem); EnsureRectVisible(&rect); } }
void InstanceCtrl::EnsureVisible ( VisualCoord coord ) { if(coord.isItem()) { wxRect rect; GetItemRect(coord, rect, false); EnsureRectVisible(rect); } // possibly add more for groups, headers, etc. }
void CGraphStudioModelessDialog::RestorePosition() { if (!view || !ShouldRestorePosition()) return; position_saved = false; CRect rect_current; this->GetWindowRect(&rect_current); // if any settings fail to read then defaults will be unusable CRect rect_touse; const CString name(GetSettingsName()); rect_touse.left = AfxGetApp()->GetProfileInt(name, _T("left"), INT_MIN); rect_touse.top = AfxGetApp()->GetProfileInt(name, _T("top"), INT_MIN); if (ShouldRestoreSize()) { rect_touse.right = rect_touse.left + AfxGetApp()->GetProfileInt(name, _T("width"), INT_MAX/2); rect_touse.bottom = rect_touse.top + AfxGetApp()->GetProfileInt(name, _T("height"), INT_MAX/2); } else { rect_touse.right = rect_touse.left + rect_current.Width(); rect_touse.bottom = rect_touse.top + rect_current.Height(); } CRect rect_default(GetDefaultRect()); if (!ShouldRestoreSize()) { rect_default.right = rect_default.left + rect_current.Width(); rect_default.bottom = rect_default.top + rect_current.Height(); } CRect rect_frame; view->GetParentFrame()->GetWindowRect(&rect_frame); rect_touse.OffsetRect(rect_frame.left, rect_frame.top); // adjust rects by position of frame window rect_default.OffsetRect(rect_frame.left, rect_frame.top); EnsureRectVisible(rect_touse, rect_default); const int flags = ShouldRestoreSize() ? 0 : SWP_NOSIZE; this->SetWindowPos(NULL, rect_touse.left, rect_touse.top, rect_touse.Width(), rect_touse.Height(), flags); }
void DisplayManager::Draw(DISPLAY_INT x, DISPLAY_INT y, WebRect *pViewport, WebGraphics *pGC) { if (mNoRefresh) { DisplayManager* parentDisplayManager = GetManager(); if (parentDisplayManager) { // This handles the case where a DisplayManager that is NOT the root // DisplayManager has a positive refresh lock, prohibiting its being // drawn, but the parent DisplayManager does not (otherwise we would // not even be in our Draw method); in this case: // // IF this element is within the collective invalid region being // painted, THEN we want to re-invalidate the invalid part of (this), // which will cause said region to re-paint when the refresh lock // is removed from this element and this->Refresh is eventually called. WebRect clipRect; pGC->GetClip(&clipRect); WebRect screenRect(mRect); screenRect.MoveTo(x,y); if (clipRect.Overlaps(&screenRect)) { SetManagerFlag(MANAGER_FLAG_TRIED_TO_DRAW); //screenRect.And(&clipRect); //screenRect.Shift(-pViewport->left, -pViewport->top); //parentDisplayManager->InvalidateViewportRegion(&screenRect); } } return; } FormatResult result; switch (GetScrollMode()) { case SCROLL_MODE_NONE: if (mpVScroll || mpHScroll) { DetachVScroll(); DetachHScroll(); UpdateViewport(); } break; case SCROLL_MODE_HSCROLL: if (mpVScroll || !mpHScroll) { DetachVScroll(); AttachHScroll(); UpdateViewport(); } break; case SCROLL_MODE_VSCROLL: if (!mpVScroll || mpHScroll) { AttachVScroll(); DetachHScroll(); UpdateViewport(); } break; case SCROLL_MODE_BOTH: if (!mpVScroll || !mpHScroll) { AttachVScroll(); AttachHScroll(); UpdateViewport(); } break; case SCROLL_MODE_AUTO: break; } if (mRoot.Get()) { int i = 0; do { result = mRoot.Get()->FormatForViewport(&mViewRect, (mpHScroll != 0), (mpVScroll != 0)); if (GetScrollMode() == SCROLL_MODE_AUTO) { if (result == DISPLAY_FORMAT_NEEDS_VSCROLL) { // create a vscroll bar if (mpVScroll) { // what the... we already have a vscroll bar! break; } AttachVScroll(); // check for creation failure - may indicate low memory condition if (!mpVScroll) { // can't go on... break; } UpdateViewport(); } else if (result == DISPLAY_FORMAT_NEEDS_HSCROLL) { // create a hscroll bar if (mpHScroll) { // what the... we already have a hscroll bar! break; } AttachHScroll(); // check for creation failure - may indicate low memory condition if (!mpHScroll) { // can't go on... break; } UpdateViewport(); } } else { break; } // put a hard upper bound on the number of times we try to re-format // (4, since this means we've covered all combinations of horizontal // and vertical scroll bars on the window) i++; } while (result != DISPLAY_FORMAT_SUCCESS && i < 5); if (GetScrollMode() == SCROLL_MODE_AUTO) { WebRect rootBounds; GetRootBounds(&rootBounds); if (rootBounds.Height() <= mViewRect.Height() && mpVScroll) { DetachVScroll(); UpdateViewport(); mRoot.Get()->FormatForViewport(&mViewRect, (mpHScroll != 0), (mpVScroll != 0)); GetRootBounds(&rootBounds); } if (rootBounds.Width() <= mViewRect.Width() && mpHScroll) { DetachHScroll(); UpdateViewport(); mRoot.Get()->FormatForViewport(&mViewRect, (mpHScroll != 0), (mpVScroll != 0)); GetRootBounds(&rootBounds); } if (rootBounds.Height() <= mViewRect.Height() && mpVScroll) { DetachVScroll(); UpdateViewport(); mRoot.Get()->FormatForViewport(&mViewRect, (mpHScroll != 0), (mpVScroll != 0)); GetRootBounds(&rootBounds); } } mViewportChanged = WEBC_FALSE; CorrectViewportPosition(); if (mpFocus && (mpVScroll!=0) && (mpHScroll!=0)) { WebRect focusRect; WebRect elemRect; WEBC_BOOL ensureFocusVisible = mpFocus->GetFocusRect (&focusRect); if (ensureFocusVisible) { GetElementRect(&elemRect, mpFocus); focusRect.Shift(elemRect.left, elemRect.top); // this will adjust the scroll bars so that the given rect is in view EnsureRectVisible(&focusRect); } } } DisplayElement::Draw(x, y, pViewport, pGC); }