void CHTMLSection::SetCurrentFocus( CFocusControlABC *pFocus, bool bScrollIntoView ) { if( m_pFocus ) { m_pFocus->SetFocus( false ); } m_pFocus = pFocus; if( m_pFocus ) { m_pFocus->SetFocus( true ); if( bScrollIntoView ) { // // Now we need to ensure that our focused section is visible WinHelper::CRect rcBounds; m_pFocus->GetObjectRect( rcBounds ); bool bChanged = false; if( rcBounds.Height() > Height() ) { SetPos( rcBounds.top ); bChanged = true; } else { rcBounds.Offset( GetScrollPosH(), GetScrollPos() ); int nPos = GetScrollPos(); int nBottom = nPos + Height(); if( rcBounds.top < nPos ) { ScrollV( rcBounds.top - nPos ); bChanged = true; } else if( rcBounds.bottom > nBottom ) { ScrollV( rcBounds.bottom - nBottom ); bChanged = true; } } if( bChanged ) { ForceRedraw(); NotifyParent( 1 ); } } } }
void LScrollV(Layer *l, int n, int ys, int ye, int bce) { int ys2, ye2, xs2, xe2; if (n == 0) return; if (l->l_pause.d) LayPauseUpdateRegion(l, 0, l->l_width - 1, ys, ye); for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) { if (l->l_pause.d && cv->c_slorient) continue; for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) { xs2 = vp->v_xoff; xe2 = l->l_width - 1 + vp->v_xoff; ys2 = ys + vp->v_yoff; ye2 = ye + vp->v_yoff; if (xs2 < vp->v_xs) xs2 = vp->v_xs; if (xe2 > vp->v_xe) xe2 = vp->v_xe; if (ys2 < vp->v_ys) ys2 = vp->v_ys; if (ye2 > vp->v_ye) ye2 = vp->v_ye; if (ys2 > ye2 || xs2 > xe2) continue; display = cv->c_display; if (D_blocked) continue; ScrollV(vp->v_xs, ys2, vp->v_xe, ye2, n, bce); if (ye2 - ys2 == ye - ys) continue; if (n > 0) { ys2 = ye2 + 1 - n; ye2 = ye + vp->v_yoff - n; } else { ye2 = ys2 - 1 - n; ys2 = ys + vp->v_yoff - n; } if (ys2 < vp->v_ys) ys2 = vp->v_ys; if (ye2 > vp->v_ye) ye2 = vp->v_ye; if (ys2 <= ye2) RefreshArea(xs2, ys2, xe2, ye2, 1); } } }
void CXTPCalendarWeekView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { CSelectionChangedContext selChanged(this); TBase::OnKeyDown(nChar, nRepCnt, nFlags); if (nChar == VK_LEFT || nChar == VK_RIGHT || nChar == VK_UP || nChar == VK_DOWN || nChar == VK_PRIOR || nChar == VK_NEXT) { CXTPCalendarControl::CUpdateContext updateContext(m_pControl, xtpCalendarUpdateRedraw); BOOL bVKShift = (GetKeyState(VK_SHIFT) < 0); COleDateTimeSpan spDay(1, 0, 0, 0); COleDateTimeSpan spWeek(7, 0, 0, 0); int nDVCount = GetViewDayCount(); BOOL bSelReseted = !m_selectedBlock.dtEnd.GetStatus() == COleDateTime::valid; COleDateTime dtLastSelDay = GetLastSelectedDate(); int nLastSelDayIdx = (dtLastSelDay.GetDayOfWeek() - m_nFirstDayOfWeekIndex + 7) % 7; COleDateTime dtNewSelDay = dtLastSelDay; int nSatDayIdx = 7 - m_nFirstDayOfWeekIndex; int nNewIdx = nLastSelDayIdx + 3; int nHalfShift = nNewIdx > nSatDayIdx && nLastSelDayIdx <= nSatDayIdx || nNewIdx > nSatDayIdx + 7 && nLastSelDayIdx <= nSatDayIdx + 7 ? 4 : 3; COleDateTimeSpan spHalfWeekPlus(nHalfShift, 0, 0, 0); COleDateTimeSpan spHalfWeekMinus(7 - nHalfShift, 0, 0, 0); CXTPDrawHelpers::KeyToLayout(m_pControl, nChar); if (nChar == VK_LEFT) { dtNewSelDay -= spHalfWeekMinus; } else if (nChar == VK_RIGHT) { dtNewSelDay += spHalfWeekPlus; } else if (nChar == VK_UP) { dtNewSelDay -= spDay; } else if (nChar == VK_DOWN) { dtNewSelDay += spDay; } else if (nChar == VK_PRIOR) { dtNewSelDay -= spWeek; } else if (nChar == VK_NEXT) { dtNewSelDay += spWeek; } //--------------------------------------------------------------------------- COleDateTime dtFirstDay = GetViewDayDate(0); COleDateTime dtLastDay = GetViewDayDate(nDVCount-1); BOOL bNeedScroll = dtNewSelDay < dtFirstDay || dtNewSelDay > dtLastDay; if (bNeedScroll && !m_bScrollV_Disabled) { if (dtNewSelDay < dtFirstDay) { ScrollV(m_nCurrPos-1, m_nCurrPos-1); bSelReseted = TRUE; CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar); } if (dtNewSelDay > dtLastDay) { ScrollV(m_nCurrPos + 1, m_nCurrPos + 1); bSelReseted = TRUE; CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar); } } //--------------------------------------------------------------------------- if (!bNeedScroll || !m_bScrollV_Disabled) { if (bVKShift && !bSelReseted) { SelectDays(dtNewSelDay); } else { SelectDay(dtNewSelDay); } } } }