void BSlider::DrawSlider() { if (LockLooper()) { #if USE_OFF_SCREEN_VIEW if (!fOffScreenBits) return; if (fOffScreenBits->Lock()) { #endif DrawBar(); DrawHashMarks(); DrawThumb(); DrawFocusMark(); DrawText(); #if USE_OFF_SCREEN_VIEW fOffScreenView->Sync(); fOffScreenBits->Unlock(); DrawBitmap(fOffScreenBits, B_ORIGIN); } #endif UnlockLooper(); } }
void BChannelSlider::DrawChannel(BView* into, int32 channel, BRect area, bool pressed) { float hCenter = area.Width() / 2; float vCenter = area.Height() / 2; BPoint leftTop; BPoint bottomRight; if (fIsVertical) { leftTop.Set(area.left + hCenter, area.top + vCenter); bottomRight.Set(leftTop.x, leftTop.y + ThumbRangeFor(channel)); } else { leftTop.Set(area.left, area.top + vCenter); bottomRight.Set(area.left + ThumbRangeFor(channel), leftTop.y); } DrawGroove(into, channel, leftTop, bottomRight); BPoint thumbLocation = leftTop; if (fIsVertical) thumbLocation.y += ThumbDeltaFor(channel); else thumbLocation.x += ThumbDeltaFor(channel); DrawThumb(into, channel, thumbLocation, pressed); }
void TScrollBar::Draw(TRegion* clip) { TDrawContext context(this, clip); DrawArrow1(context, fInTrackingRect && fTrackingPart == kArrow1); DrawArrow2(context, fInTrackingRect && fTrackingPart == kArrow2); DrawThumb(context); }
void CSkinScrollBar::OnPaint(HDC hDC) { if (!IsVisible()) return; DrawBg(hDC); DrawLeftUpBtn(hDC); DrawRightDownBtn(hDC); DrawThumb(hDC); DrawRail(hDC); }
void TScrollBar::SetRange(int32 minimum, int32 maximum) { fMinimum = minimum; fMaximum = maximum; if (fValue < minimum) fValue = minimum; else if (fValue > maximum) fValue = maximum; TDrawContext context(this); DrawThumb(context); }
void mxExpressionSlider::redraw() { HWND wnd = (HWND)getHandle(); if ( !wnd ) return; HDC finalDC = GetDC( wnd ); if ( !finalDC ) return; RECT rc; GetClientRect( wnd, &rc ); int w = rc.right - rc.left; int h = rc.bottom - rc.top; HDC dc = CreateCompatibleDC( finalDC ); HBITMAP oldbm, bm; bm = CreateCompatibleBitmap( finalDC, w, h ); oldbm = (HBITMAP)SelectObject( dc, bm ); HBRUSH br = CreateSolidBrush( GetSysColor( COLOR_3DFACE ) ); FillRect( dc, &rc, br ); DeleteObject( br ); DrawTitle( dc ); DrawBar( dc ); // Draw slider for ( int i = ( m_bPaired ? 1 : 0 ); i >= 0 ; i-- ) { DrawThumb( i, dc ); } BitBlt( finalDC, 0, 0, w, h, dc, 0, 0, SRCCOPY ); SelectObject( dc, oldbm ); DeleteObject( bm ); DeleteDC( dc ); ReleaseDC( wnd, finalDC ); ValidateRect( wnd, &rc ); }
void CLibraryTipCtrl::OnPaint(CDC* pDC) { CSingleLock pLock( &m_pSection, TRUE ); CPoint pt( 0, 0 ); DrawText( pDC, &pt, m_sName ); pt.y += TIP_TEXTHEIGHT; pDC->SelectObject( &CoolInterface.m_fntNormal ); if ( m_sSHA1.GetLength() ) { DrawText( pDC, &pt, m_sSHA1 ); pt.y += TIP_TEXTHEIGHT; } if ( m_sTTH.GetLength() ) { DrawText( pDC, &pt, m_sTTH ); pt.y += TIP_TEXTHEIGHT; } if ( m_sED2K.GetLength() ) { DrawText( pDC, &pt, m_sED2K ); pt.y += TIP_TEXTHEIGHT; } DrawRule( pDC, &pt ); CRect rcThumb( pt.x, pt.y, pt.x + 96, pt.y + 96 ); CRect rcWork( &rcThumb ); DrawThumb( pDC, rcWork ); pDC->ExcludeClipRect( &rcThumb ); int nCount = 0; for ( POSITION pos = m_pMetadata.GetIterator() ; pos ; ) { CMetaItem* pItem = m_pMetadata.GetNext( pos ); DrawText( pDC, &pt, theApp.m_bRTL ? ':' + pItem->m_sKey : pItem->m_sKey + ':', 100 ); DrawText( pDC, &pt, pItem->m_sValue, 100 + m_nKeyWidth ); pt.y += TIP_TEXTHEIGHT; if ( ++nCount == 5 ) { pt.x += 98; pt.y -= 2; DrawRule( pDC, &pt, TRUE ); pt.x -= 98; pt.y -= 2; } } }
void TScrollBar::SetValue(int32 value) { if (value < fMinimum) value = fMinimum; else if (value > fMaximum) value = fMaximum; if (value != fValue) { TRect oldThumb; GetThumb(oldThumb); fValue = value; HandleCommand(this, this, kValueChangedCommandID); TRect newThumb; GetThumb(newThumb); if (newThumb != oldThumb) { TDrawContext context(this); TRect rect; if (newThumb.left < oldThumb.left) rect.Set(newThumb.right, newThumb.top, oldThumb.right, newThumb.bottom); else if (newThumb.left > oldThumb.left) rect.Set(oldThumb.left, newThumb.top, newThumb.left, newThumb.bottom); if (newThumb.top < oldThumb.top) rect.Set(newThumb.left, newThumb.bottom, newThumb.right, oldThumb.bottom); else if (newThumb.top > oldThumb.top) rect.Set(newThumb.left, oldThumb.top, newThumb.right, newThumb.top); if (context.GetDepth() < 8) { context.SetStipple(TGraphicsUtils::GetGrayStipple()); context.SetForeColor(kBlackColor); context.SetBackColor(kWhiteColor); } else context.SetForeColor(kMediumGrayColor); context.PaintRect(rect); DrawThumb(context); } } }
FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) { DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix); } if (HasEdge()) { DrawEdge(pGraphics, FWL_PART_SCB_Edge, pTheme, pMatrix); } DrawTrack(pGraphics, pTheme, TRUE, pMatrix); DrawTrack(pGraphics, pTheme, FALSE, pMatrix); DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix); DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix); DrawThumb(pGraphics, pTheme, pMatrix); return FWL_ERR_Succeeded; }
void CAlbumTipCtrl::OnPaint(CDC* pDC) { CPoint pt( 0, 0 ); DrawText( pDC, &pt, m_sName ); pt.y += TIP_TEXTHEIGHT; pDC->SelectObject( &CoolInterface.m_fntNormal ); DrawText( pDC, &pt, m_sType ); pt.y += TIP_TEXTHEIGHT; DrawRule( pDC, &pt ); CRect rcThumb( pt.x, pt.y, pt.x + 96, pt.y + 96 ); CRect rcWork( &rcThumb ); DrawThumb( pDC, rcWork ); pDC->ExcludeClipRect( &rcThumb ); int nCount = 0; for ( POSITION pos = m_pMetadata.GetIterator(); pos; ) { CMetaItem* pItem = m_pMetadata.GetNext( pos ); DrawText( pDC, &pt, pItem->m_sKey + ':', 100 ); DrawText( pDC, &pt, pItem->m_sValue, 100 + m_nKeyWidth ); pt.y += TIP_TEXTHEIGHT; if ( ++nCount == 5 ) { pt.x += 98; pt.y -= 2; DrawRule( pDC, &pt, TRUE ); pt.x -= 98; pt.y -= 2; } } }
//+--------------------------------------------------------------------------- // // Member: CScrollbar::Draw // // Synopsis: Draw the scroll bar in the given direction. // // Arguments: direction 0 for horizontal, 1 for vertical // rcScrollbar bounds of entire scroll bar // rcRedraw bounds to be redrawn // contentSize size of content controlled by scroll bar // containerSize size of area to scroll within // scrollAmount amount that the content is scrolled // partPressed which part, if any, is pressed // hdc DC to draw into // params customizable scroll bar parameters // pDI draw info // dwFlags rendering flags // // Notes: // //---------------------------------------------------------------------------- void CScrollbar::Draw( int direction, const CRect& rcScrollbar, const CRect& rcRedraw, long contentSize, long containerSize, long scrollAmount, SCROLLBARPART partPressed, HDC hdc, const CScrollbarParams& params, CDrawInfo* pDI, DWORD dwFlags) { Assert(hdc != NULL); // for now, we're using CDrawInfo, which should have the same hdc Assert(pDI->_hdc == hdc); // trivial rejection if nothing to draw if(!rcScrollbar.Intersects(rcRedraw)) { return; } BOOL fDisabled = (params._fForceDisabled) || (containerSize>=contentSize); long scaledButtonWidth = GetScaledButtonWidth(direction, rcScrollbar, params._buttonWidth); // compute rects for buttons and track CRect rcTrack(rcScrollbar); rcTrack[direction] += scaledButtonWidth; rcTrack[direction+2] -= scaledButtonWidth; // draw buttons unless requested not to (it's expensive to draw these!) if((dwFlags & DISPSCROLLBARHINT_NOBUTTONDRAW) == 0) { CRect rcButton[2]; rcButton[0] = rcScrollbar; rcButton[0][direction+2] = rcTrack[direction]; rcButton[1] = rcScrollbar; rcButton[1][direction] = rcTrack[direction+2]; // draw buttons CSize sizeButton; pDI->DocumentFromWindow( &sizeButton, rcButton[0].Width(), rcButton[0].Height()); for(int i=0; i<2; i++) { if(rcRedraw.Intersects(rcButton[i])) { BOOL fButtonPressed = (i==0 && partPressed==SBP_PREVBUTTON) || (i==1 && partPressed==SBP_NEXTBUTTON); CScrollButton scrollButton(params._pColors, params._fFlat); scrollButton.DrawButton( pDI, NULL, // no hwnd, we don't want to invalidate (direction==0?(i==0?BG_LEFT:BG_RIGHT):(i==0?BG_UP:BG_DOWN)), fButtonPressed, !fDisabled, FALSE, // never focused rcButton[i], sizeButton, 0); // assume both button glyphs are the same size } } } // draw track if(rcRedraw.Intersects(rcTrack)) { if(fDisabled) { // no thumb, so draw non-pressed track DrawTrack(rcTrack, FALSE, fDisabled, hdc, params); } else { // calculate thumb rect CRect rcThumb; GetPartRect( &rcThumb, SBP_THUMB, direction, rcScrollbar, contentSize, containerSize, scrollAmount, params._buttonWidth, pDI, FALSE); // can track contain the thumb? if(!rcTrack.Contains(rcThumb)) { DrawTrack(rcTrack, FALSE, fDisabled, hdc, params); } else { // draw previous track CRect rcTrackPart(rcTrack); rcTrackPart[direction+2] = rcThumb[direction]; if(rcRedraw.Intersects(rcTrackPart)) { DrawTrack(rcTrackPart, partPressed==SBP_PREVTRACK, fDisabled, hdc, params); } // draw thumb if(rcRedraw.Intersects(rcThumb)) { DrawThumb(rcThumb, partPressed==SBP_THUMB, hdc, params, pDI ); } // draw next track rcTrackPart = rcTrack; rcTrackPart[direction] = rcThumb[direction+2]; if(rcRedraw.Intersects(rcTrackPart)) { DrawTrack(rcTrackPart, partPressed==SBP_NEXTTRACK, fDisabled, hdc, params); } } } } }
void CXTPSkinObjectTrackBar::OnDraw(CDC* pDC) { CXTPClientRect rc(this); CXTPBufferDC dcMem(*pDC, rc); NMCUSTOMDRAW nm; ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_PREPAINT; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); LRESULT lrCdrf = GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); FillBackground(&dcMem, rc); if (::GetFocus() == m_hWnd && ((SendMessage(WM_QUERYUISTATE) & UISF_HIDEFOCUS) == 0)) { dcMem.SetBkColor(GetColor(COLOR_BTNHIGHLIGHT)); DrawFocusRect(dcMem, &rc); } FillDrawRect(); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPREPAINT; nm.dwItemSpec = TBCD_TICS; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } DrawTics(&dcMem); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPOSTPAINT; nm.dwItemSpec = TBCD_TICS; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPREPAINT; nm.dwItemSpec = TBCD_CHANNEL; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } DrawChannel(&dcMem); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPOSTPAINT; nm.dwItemSpec = TBCD_CHANNEL; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPREPAINT; nm.dwItemSpec = TBCD_THUMB; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } DrawThumb(&dcMem); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPOSTPAINT; nm.dwItemSpec = TBCD_THUMB; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } if (lrCdrf & CDRF_NOTIFYPOSTPAINT) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_POSTPAINT; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } }
void CEarSliderCtrl::OnReflectCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) { NMCUSTOMDRAW nmcd = *(LPNMCUSTOMDRAW)pNMHDR; LPNMCUSTOMDRAW lpcd = (LPNMCUSTOMDRAW)pNMHDR; UINT drawStage = nmcd.dwDrawStage; UINT itemSpec = nmcd.dwItemSpec; CDC *pDC = CDC::FromHandle(nmcd.hdc); switch(drawStage) { case CDDS_PREPAINT: *pResult = CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT ; break; case CDDS_PREERASE: case CDDS_POSTERASE: case CDDS_ITEMPREERASE: case CDDS_ITEMPOSTERASE: *pResult = CDRF_DODEFAULT; break; case CDDS_ITEMPREPAINT: /* switch(itemSpec) { case TBCD_CHANNEL: *pResult = CDRF_DODEFAULT| CDRF_NOTIFYPOSTPAINT; break; case TBCD_TICS: case TBCD_THUMB: *pResult = CDRF_DODEFAULT; break; } break;*/ switch(itemSpec) { case TBCD_TICS: *pResult = CDRF_DODEFAULT; break; case TBCD_THUMB: //DrawThumb(pDC, lpcd); if( m_focused ) { CString str; DrawThumb(pDC, lpcd); *pResult = CDRF_SKIPDEFAULT; break; } else { *pResult = CDRF_DODEFAULT ; //CDRF_SKIPDEFAULT;// CDRF_DODEFAULT;//CDRF_SKIPDEFAULT;//CDRF_SKIPDEFAULT; break; } // str.Format(_T("%x"),lpcd->uItemState); CDIS_GRAYED // DrawThumb(pDC, lpcd,str); // *pResult = CDRF_SKIPDEFAULT; // break; case TBCD_CHANNEL: if(this->IsWindowVisible()) { DrawChannel(pDC,&nmcd); *pResult = CDRF_SKIPDEFAULT;//CDRF_SKIPDEFAULT;//CDRF_SKIPDEFAULT;// //CDRF_SKIPDEFAULT; //CDRF_SKIPDEFAULT ;//CDRF_SKIPDEFAULT; //CDRF_SKIPDEFAULT; } else { *pResult = CDRF_DODEFAULT; } break; } break; case CDDS_ITEMPOSTPAINT: switch(itemSpec) { case TBCD_CHANNEL: /* { COLORREF m_color = RGB(128,128,128); COLORREF m_clr = ::GetSysColor(COLOR_BTNFACE); //RGB(200,30,40); HDC hbkdc = this->GetParent()->GetDC()->GetSafeHdc(); COLORREF bkcolor = ::GetBkColor(hbkdc); CDC* pDC = CDC::FromHandle( nmcd.hdc ); CPen pen(PS_SOLID,nmcd.rc.right-nmcd.rc.left, bkcolor); //m_clr); //pDC->SelectObject(&pen); RECT rrc = {nmcd.rc.left, nmcd.rc.top+1, nmcd.rc.right, nmcd.rc.bottom-1}; // pDC->SetBkMode(TRANSPARENT); // pDC->Draw3dRect( &rrc, bkcolor, bkcolor ); pDC->SelectObject(&pen); pDC->MoveTo(nmcd.rc.left,nmcd.rc.top); pDC->LineTo(nmcd.rc.left,nmcd.rc.bottom); pDC->MoveTo(nmcd.rc.right,nmcd.rc.top); pDC->LineTo(nmcd.rc.right,nmcd.rc.bottom); //pDC->DrawEdge(&nmcd.rc,EDGE_BUMP,BF_RECT); pDC->Detach(); } *pResult = CDRF_SKIPDEFAULT; break;*/ case TBCD_TICS: *pResult = CDRF_DODEFAULT; break; case TBCD_THUMB: *pResult = CDRF_DODEFAULT ; // CDRF_DODEFAULT; // CDRF_SKIPDEFAULT; //CDRF_DODEFAULT; //CDRF_DODEFAULT;//CDRF_SKIPDEFAULT; break; } break; case CDDS_POSTPAINT: *pResult = CDRF_DODEFAULT; break; default: ASSERT( FALSE ); } }