void iNWButton::DrawElement(iMemoryDC &ddc) const { if (!IsElementEnabled()) { m_Dibs[0].CopyToDibXY(&ddc.m_Dib,GetElementRect().point(),BLEND_ALPHABLEND); } else if (IsTrack()) { if (m_BtnState==BtnUnpressed) m_Dibs[3].CopyToDibXY(&ddc.m_Dib,GetElementRect().point(),BLEND_ALPHABLEND); else if (m_BtnState==BtnFocused) m_Dibs[2].CopyToDibXY(&ddc.m_Dib,GetElementRect().point(),BLEND_ALPHABLEND); } else { if (m_BtnState==BtnUnpressed) m_Dibs[3].CopyToDibXY(&ddc.m_Dib,GetElementRect().point(),BLEND_ALPHABLEND); else if (m_BtnState==BtnFocused) m_Dibs[1].CopyToDibXY(&ddc.m_Dib,GetElementRect().point(),BLEND_ALPHABLEND); } }
void DisplayManager::EnsureVisible(DisplayElement *pElem) { if (pElem->GetManager() == this) { WebRect rect; GetElementRect(&rect, pElem); EnsureRectVisible(&rect); } }
void iNWSliderBar::DrawElement(iMemoryDC &ddc) const { iRect elrc = GetElementRect(); iSize bsiz(m_dibBack.GetWidth()/3,m_dibBack.GetHeight()/2); // Draw Background sint32 ypos = (m_IsEnabled?0:bsiz.h); m_dibBack.CopyRectToDibXY(&ddc.m_Dib, iRect(0,ypos,bsiz.w,bsiz.h),iPoint(elrc.x,elrc.y),BLEND_ALPHABLEND); m_dibBack.TileRectToDibRect(iRect(bsiz.w,ypos,bsiz.w,bsiz.h),ddc.m_Dib,iRect(elrc.x+bsiz.w,elrc.y,elrc.w-bsiz.w*2,bsiz.h),BLEND_ALPHABLEND); m_dibBack.CopyRectToDibXY(&ddc.m_Dib, iRect(bsiz.w*2,ypos,bsiz.w,bsiz.h),iPoint(elrc.x+elrc.w-bsiz.w,elrc.y),BLEND_ALPHABLEND); // Create Bar (fake impl) iSize belsiz(m_dibBar.GetWidth()/3,m_dibBar.GetHeight()/2); iSize barsiz(elrc.w - bsiz.w*2,belsiz.h); iDib eBar(barsiz); iDib fBar(barsiz); m_dibBar.CopyRectToDibXY(&eBar, iRect(0,0,belsiz.w,belsiz.h),iPoint(0,0),BLEND_SRCCOPY); m_dibBar.TileRectToDibRect(iRect(belsiz.w,0,belsiz.w,belsiz.h),eBar,iRect(belsiz.w,0,barsiz.w-belsiz.w*2,barsiz.h),BLEND_SRCCOPY); m_dibBar.CopyRectToDibXY(&eBar, iRect(belsiz.w*2,0,belsiz.w,belsiz.h),iPoint(barsiz.w-belsiz.w,0),BLEND_SRCCOPY); m_dibBar.CopyRectToDibXY(&fBar, iRect(0,belsiz.h,belsiz.w,belsiz.h),iPoint(0,0),BLEND_SRCCOPY); m_dibBar.TileRectToDibRect(iRect(belsiz.w,belsiz.h,belsiz.w,belsiz.h),fBar,iRect(belsiz.w,0,barsiz.w-belsiz.w*2,barsiz.h),BLEND_SRCCOPY); m_dibBar.CopyRectToDibXY(&fBar, iRect(belsiz.w*2,belsiz.h,belsiz.w,belsiz.h),iPoint(barsiz.w-belsiz.w,0),BLEND_SRCCOPY); // Compose iPoint bar_pos(elrc.x+bsiz.w,elrc.y+(bsiz.h/2 - barsiz.h/2)); sint32 hpos; sint32 cpos = m_bTracking?m_TrackPos:m_Cur; if (!m_IsEnabled || cpos == m_Min || m_Min == m_Max) { hpos = 0; eBar.CopyToDibXY(&ddc.m_Dib,bar_pos,BLEND_ALPHABLEND); } else if (cpos == m_Max) { hpos = barsiz.w; fBar.CopyToDibXY(&ddc.m_Dib,bar_pos,BLEND_ALPHABLEND); } else { hpos = iCLAMP<sint32>((sint32)0,(sint32)barsiz.w,(sint32)barsiz.w * (cpos-m_Min) / (m_Max-m_Min)); fBar.CopyRectToDibXY(&ddc.m_Dib,iRect(0,0,hpos,barsiz.h),iPoint(bar_pos.x,bar_pos.y),BLEND_ALPHABLEND); eBar.CopyRectToDibXY(&ddc.m_Dib,iRect(hpos,0,barsiz.w-hpos,barsiz.h),iPoint(bar_pos.x+hpos,bar_pos.y),BLEND_ALPHABLEND); } // Draw Handle if (m_IsEnabled) { iSize hndsiz(m_dibHandle.GetWidth()/2,m_dibHandle.GetHeight()); m_dibHandle.CopyRectToDibXY(&ddc.m_Dib, iRect(m_bTracking?hndsiz.w:0,0,hndsiz.w,hndsiz.h),iPoint(bar_pos.x+hpos-(sint32)(hndsiz.w/2),bar_pos.y+barsiz.h/2-hndsiz.h/2),BLEND_ALPHABLEND); } }
void iNWSimpleButton::DrawElement(iMemoryDC &ddc) const { m_Dib.CopyToDibXY(&ddc.m_Dib,GetElementRect(),BLEND_ALPHABLEND); }
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); }