void CHTMLSection::OnDraw( GS::CDrawContext &dc ) { HBRUSH hbr = NULL; if( GetBackgroundColours( dc.GetSafeHdc(), hbr ) ) { FillRect( dc.GetSafeHdc(), *this, hbr ); } else if( !IsTransparent() ) { if( m_pDocument ) { if( !m_pDocument->m_back.Draw( dc, *this ) ) { dc.FillRect( *this, m_pDefaults->m_crBackground ); } if( m_pDocument->m_pimgBackground ) { const int nPosX = left - GetScrollPosH(); const int nPosY = top - GetScrollPos(); DrawTiledBitmap( nPosX, nPosY, max( GetMaxWidth(), (UINT)Width() ), max( GetMaxHeight(), (UINT)Height() ), dc.GetSafeHdc(), m_pDocument->m_pimgBackground, m_nBackgroundFrame ); } } else { dc.FillRect( *this, m_pDefaults->m_crBackground ); } } CScrollContainer::OnDraw( dc ); }
void CRScrlBarCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) { CWnd* parent; if (m_bDrawing || !m_hWnd) return; m_bDrawing=TRUE; // all the graphics come from the file system and if this is not // available then we cant draw anything // long offsets; if (m_parent) // this contains the closest rdialog if the below case is not true { parent=m_parent; } else { // assumes we are on a listbox with an rdialog underneath it // it will probably break if its placed somewhere on its own... // I tried to set m_parent to be the listboxes parent but // I kept getting stupid errors parent=GetParent()->GetParent(); } CDC* pOffScreenDC=(CDC*)parent->SendMessage(WM_GETOFFSCREENDC,NULL,NULL); ASSERT(pOffScreenDC); // this will fail if parent is not an RDialog // offsets=parent->SendMessage(WM_GETXYOFFSET,NULL,NULL); // this is quite a complex drawing procedure so we are going // to use an offscreen DC to prevent flicker... CBitmap bitmap; bitmap.CreateCompatibleBitmap(pdc,rcBounds.right,rcBounds.bottom); CBitmap* pOldBitmap; pOldBitmap=pOffScreenDC->SelectObject(&bitmap); // ASSERT(pOffScreenDC->GetDeviceCaps(CAPS1)&C1_TRANSPARENT); /* offscreenDC2.CreateCompatibleDC(pdc); CBitmap bitmap2; bitmap2.CreateCompatibleBitmap(pdc,rcBounds.right,rcBounds.bottom); CBitmap* pOldBitmap2; pOldBitmap2=offscreenDC2.SelectObject(&bitmap2); // first draw the background artwork CRect rect; GetWindowRect(rect); CRect parentrect; parent->GetWindowRect(parentrect); int offsetx; int offsety; offsetx=short(offsets & 0x0000FFFF)+parentrect.left-rect.left; offsety=short((offsets & 0xFFFF0000)>>16)+parentrect.top-rect.top; FileNum artwork; artwork=(FileNum)parent->SendMessage(WM_GETARTWORK,NULL,NULL); DrawBitmap(artwork,pOffScreenDC2,offsetx,offsety); */ // now overlay the semi-transparent scrollbar body // if (m_bHorzAlign) // MergeBitmap(FileNum(FIL_HORZSCROLLBAR,pOffScreenDC,0,0); // else // MergeBitmap(FileNum(FIL_VERTSCROLLBAR,pOffScreenDC,0,0); if (m_bHorzAlign) { DrawTiledBitmap(FileNum(FIL_HORZ_SCROLLBAR+m_FileNumOffset),pOffScreenDC,SBWIDTH,0,rcBounds.right-rcBounds.left-SBWIDTH-SBWIDTH); } else { DrawTiledBitmap(FileNum(FIL_VERT_SCROLLBAR+m_FileNumOffset),pOffScreenDC,0,SBWIDTH,rcBounds.bottom-rcBounds.top-SBWIDTH-SBWIDTH); } /* int x; if (m_bHorzAlign) { for (x=32;x<rcBounds.right-rcBounds.left-32;x+=128) DrawBitmap(FileNum(FIL_HORZ_SCROLLBAR,pOffScreenDC,x,0); } else { for (x=32;x<rcBounds.bottom-rcBounds.top-32;x+=128) DrawBitmap(FileNum(FIL_VERT_SCROLLBAR,pOffScreenDC,0,x); }*/ // MergeDCs(pOffScreenDC2,pOffScreenDC); /* // supported in Windoze 98 only // MergeDCs does the same thing however GetClientRect(rect); BLENDFUNCTION blendfunction; blendfunction.blendOp=AC_SRC_OVER; blendfunction.blendFlags=NULL; blendfunction.SourceConstantAlpha=127; blendfunction.AlphaFormat=NULL; AlphaBlend(pOffScreenDC->m_hDC,0,0,rect.right,rect.bottom, pdc->m_hDC,0,0,rect.right,rect.bottom,blendfunction); */ // now draw the puck if (m_bHorzAlign) { int divisor=m_pagesize+m_lMaxValue-m_lMinValue; int puckwidth=0; if (divisor>0) puckwidth=(m_pagesize*(rcBounds.right-rcBounds.left-SBWIDTH-SBWIDTH-PUCKEND-PUCKEND))/divisor; int puckpos=(m_iScrollPos*(rcBounds.right-rcBounds.left-SBWIDTH-SBWIDTH-PUCKEND-PUCKEND-puckwidth))/(m_lMaxValue-m_lMinValue); DrawTransparentBitmap(FileNum(FIL_PUCK_LEFT+m_FileNumOffset),pOffScreenDC,SBWIDTH+puckpos,PUCKGAP); DrawTransparentBitmap(FileNum(FIL_PUCK_RIGHT+m_FileNumOffset),pOffScreenDC,SBWIDTH+PUCKEND+puckpos+puckwidth,PUCKGAP); // for (int x=32+12+puckpos;x<32+12+puckpos+puckwidth;x++) // { // DrawBitmap(FileNum(FIL_PUCK_MIDDLE_HORZ,pOffScreenDC,x,PUCKGAP); // } DrawTiledBitmap(FileNum(FIL_PUCK_MIDDLE_HORZ+m_FileNumOffset),pOffScreenDC,SBWIDTH+PUCKEND+puckpos,PUCKGAP,puckwidth); } else { int divisor=m_pagesize+m_lMaxValue-m_lMinValue; int puckwidth=0; if (divisor>0) puckwidth=(m_pagesize*(rcBounds.bottom-rcBounds.top-SBWIDTH-SBWIDTH-PUCKEND-PUCKEND))/divisor; int puckpos=(m_iScrollPos*(rcBounds.bottom-rcBounds.top-SBWIDTH-SBWIDTH-PUCKEND-PUCKEND-puckwidth))/(m_lMaxValue-m_lMinValue); DrawTransparentBitmap(FileNum(FIL_PUCK_TOP+m_FileNumOffset),pOffScreenDC,PUCKGAP,SBWIDTH+puckpos); DrawTransparentBitmap(FileNum(FIL_PUCK_BOTTOM+m_FileNumOffset),pOffScreenDC,PUCKGAP,SBWIDTH+PUCKEND+puckpos+puckwidth); // for (int x=32+PUCKEND+puckpos;x<32+PUCKEND+puckpos+puckwidth;x++) // { // DrawBitmap(FileNum(FIL_PUCK_MIDDLE_VERT,pOffScreenDC,PUCKGAP,x); // } DrawTiledBitmap(FileNum(FIL_PUCK_MIDDLE_VERT+m_FileNumOffset),pOffScreenDC,PUCKGAP,SBWIDTH+PUCKEND+puckpos,puckwidth); } // now draw the buttons at the ends FileNum filenum; if (m_button==1) filenum=FileNum(FIL_SCROLLBAR_BUTTON_DOWN+m_FileNumOffset); else filenum=FileNum(FIL_SCROLLBAR_BUTTON_UP+m_FileNumOffset); DrawBitmap(filenum,pOffScreenDC,0,0); if (m_button==2) filenum=FileNum(FIL_SCROLLBAR_BUTTON_DOWN+m_FileNumOffset); else filenum=FileNum(FIL_SCROLLBAR_BUTTON_UP+m_FileNumOffset); if (m_bHorzAlign) DrawBitmap(filenum,pOffScreenDC,rcBounds.right-SBWIDTH,0); else DrawBitmap(filenum,pOffScreenDC,0,rcBounds.bottom-SBWIDTH); pdc->BitBlt(0,0,rcBounds.right-rcBounds.left,rcBounds.bottom-rcBounds.top,pOffScreenDC, 0,0,SRCCOPY); // flips offscreen dc to real dc pOffScreenDC->SelectObject(pOldBitmap); // then delete the dc // offscreenDC2.SelectObject(pOldBitmap2); // offscreenDC2.DeleteDC(); m_bDrawing=FALSE; }