void CVolumeCtrl::OnLButtonDown(UINT nFlags, CPoint point) { CRect r; GetChannelRect(&r); if (r.left >= r.right) { return; } int start, stop; GetRange(start, stop); r.left += 3; r.right -= 4; if (point.x < r.left) { SetPos(start); } else if (point.x >= r.right) { SetPos(stop); } else { int w = r.right - r.left; if (start < stop) { SetPosInternal(start + ((stop - start) * (point.x - r.left) + (w / 2)) / w); } } CSliderCtrl::OnLButtonDown(nFlags, point); }
void CPlayerSeekBar::OnLButtonDown(UINT nFlags, CPoint point) { if(m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point)) { SetCapture(); MoveThumb(point); GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); } CDialogBar::OnLButtonDown(nFlags, point); }
long CPlayerSeekBar::ChannelPointFromPosition(REFERENCE_TIME rtPos) const { rtPos = min(m_rtStop, max(m_rtStart, rtPos)); long ret = 0; auto w = GetChannelRect().Width(); if (m_bHasDuration) { ret = (long)(w * (rtPos - m_rtStart) / (m_rtStop - m_rtStart)); } if (ret >= w) { ret = w - 1; } return ret; }
CRect CPlayerSeekBar::GetThumbRect() { // bool fEnabled = m_fEnabled || m_start >= m_stop; CRect r = GetChannelRect(); int x = r.left + (int)((m_start < m_stop /*&& fEnabled*/) ? (__int64)r.Width() * (m_pos - m_start) / (m_stop - m_start) : 0); int y = r.CenterPoint().y; r.SetRect(x, y, x, y); r.InflateRect(6, 7, 7, 8); return(r); }
void CPlayerSeekBar::MoveThumb(CPoint point) { CRect r = GetChannelRect(); if(r.left >= r.right) return; if(point.x < r.left) SetPos(m_start); else if(point.x >= r.right) SetPos(m_stop); else { __int64 w = r.right - r.left; if(m_start < m_stop) SetPosInternal(m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w); } }
//DragonZ BOOL CSkinItemSlider::GetFullRect(RECT& fullRect) { RECT channelRc,thumbRc,fullRc; GetChannelRect(channelRc); GetThumbImgRect(thumbRc); fullRc = channelRc; if (!m_bVeritySlider) { fullRc.right = thumbRc.left; }else { fullRc.top = thumbRc.bottom; // 从下往上填充 fullRc.bottom -= 2; } fullRect = fullRc; return TRUE; }
void CPlayerSeekBar::UpdateToolTipPosition() { CSize bubbleSize(m_tooltip.GetBubbleSize(&m_ti)); CRect windowRect; GetWindowRect(windowRect); CPoint point(m_tooltipPoint); if (AfxGetAppSettings().nTimeTooltipPosition == TIME_TOOLTIP_ABOVE_SEEKBAR) { point.x -= bubbleSize.cx / 2 - 2; point.y = GetChannelRect().TopLeft().y - (bubbleSize.cy + 13); } else { point.x += 10; point.y += 20; } point.x = max(0, min(point.x, windowRect.Width() - bubbleSize.cx)); ClientToScreen(&point); m_tooltip.SendMessage(TTM_TRACKPOSITION, 0, MAKELPARAM(point.x, point.y)); }
////////////////////////////////////////////////////////////////////////// //绘制 ////////////////////////////////////////////////////////////////////////// void CSkinItemSlider::DrawBackground(CDC* pDC, LPRECT lpInvalidRect, CRgn* pInvalidRgn, BOOL bChildSkin) { CSkinBase::DrawBackground(pDC, lpInvalidRect, pInvalidRgn); if (m_pChannelImage != NULL) { CRect channelRect = GetSkinAbsRect(); GetChannelRect(channelRect); LONG lBarHeight = GetbarHeight(); if (lBarHeight > 0) { if (!m_bVeritySlider) { channelRect.top = channelRect.top - (lBarHeight - channelRect.Height())/2; channelRect.bottom = channelRect.top + lBarHeight; }else { channelRect.left = channelRect.left - (lBarHeight - channelRect.Width())/2; channelRect.right = channelRect.left + lBarHeight; } } m_pChannelImage->Draw(*pDC, &channelRect, NULL, GetImageParam(), GetTransformedTransparentColor()); } }
void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult) { LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR); LRESULT lr = CDRF_DODEFAULT; if (m_fSelfDrawn) switch (pNMCD->dwDrawStage) { case CDDS_PREPAINT: lr = CDRF_NOTIFYITEMDRAW; break; case CDDS_ITEMPREPAINT: if (pNMCD->dwItemSpec == TBCD_CHANNEL) { CDC dc; dc.Attach(pNMCD->hdc); CRect channelRect; GetChannelRect(channelRect); CRect thumbRect; GetThumbRect(thumbRect); CopyRect(&pNMCD->rc, CRect(channelRect.left, thumbRect.top + 2, channelRect.right - 2, thumbRect.bottom - 2)); CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT)); CPen* old = dc.SelectObject(&light); dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top); dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom); dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom); dc.SelectObject(&shadow); dc.LineTo(pNMCD->rc.right, pNMCD->rc.top); dc.SelectObject(old); dc.Detach(); lr = CDRF_SKIPDEFAULT; } else if (pNMCD->dwItemSpec == TBCD_THUMB) { CDC dc; dc.Attach(pNMCD->hdc); pNMCD->rc.bottom--; CRect r(pNMCD->rc); r.DeflateRect(0, 0, 1, 0); COLORREF shadow = GetSysColor(COLOR_3DSHADOW); COLORREF light = GetSysColor(COLOR_3DHILIGHT); dc.Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); dc.Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE)); dc.SetPixel(r.left + 7, r.top - 1, GetSysColor(COLOR_BTNFACE)); dc.Detach(); lr = CDRF_SKIPDEFAULT; } break; }; pNMCD->uItemState &= ~CDIS_FOCUS; *pResult = lr; }
void CSliderCtrlEx::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) { int loopMax = colorList.GetSize(); // number of color ranges to process LPNMCUSTOMDRAW lpCustDraw = (LPNMCUSTOMDRAW)pNMHDR; //////////////////////////////////////////////////////////////////////////////// // OnCustomDraw() is called at many different stages during the painting process // of the control. We only care about the PREPAINT state or the ITEMPREPAINT // state and not always then. // // If we want to be notified about subcontrol painting, we have to say so when // we get the initial PREPAINT message. //////////////////////////////////////////////////////////////////////////////// if(lpCustDraw->dwDrawStage == CDDS_PREPAINT) { // should we report slider's position? int curVal = GetPos(); if((m_Callback != NULL) && (curVal != m_oldPosition)) { m_oldPosition = curVal; m_Callback(m_p2Object, m_data1, curVal, m_IsDragging); } // If we don't have any special coloring to do, skip all the silliness... if(loopMax <= 0) { *pResult = CDRF_DODEFAULT; } else { // We want to be informed when each part of the control is being // processed so we can intercept the channel drawing. *pResult = CDRF_NOTIFYITEMDRAW; // send messages for each piece-part } return; } /////////////////////////////////////////////////////////////////////////////// // A slider (track control) is drawn in several steps: // 1. Erase // 2. Tics // 3. Channel // 4. Thumb // // It would be nice to capture when the background has been painted and // before the other sub-pieces have been painted. Then we could just // substitute our own painting routine. But this doesn't seem to be // available. // // So this routine captures the tics by inserting operations before // painting the thumb. // // Look at the help on NMCUSTOMDRAW for complete details, but the pNMHDR // pointer looks at a structure like: // // typedef struct tagNMCUSTOMDRAWINFO { // NMHDR hdr; // DWORD dwDrawStage; // This indicates what stage of the drawing process is involved // HDC hdc; // graphics context of the control (or sub-component) // RECT rc; // DWORD dwItemSpec; // This is the particular piece-part of the slider involved // UINT uItemState; // LPARAM lItemlParam; // } NMCUSTOMDRAW // // The stages include CDDS_PREPAINT, which is just before painting of the entire // control. However, unless the *pResult parameter is set to CDRF_NOTIFYITEMDRAW, // we will get notification for the control as a whole, not for each piece-part. // So the first thing to do is set *pResult. Thereafter, we must intercept // the sub-parts. // // We don't care about painting the background (we will re-paint later on). We // don't care about PREPAINT on the CHANNEL or the TICS since we will overwrite // everything when we get to the THUMB. ///////////////////////////////////////////////////////////////////////////////// if((lpCustDraw->dwDrawStage == CDDS_ITEMPREPAINT) && (lpCustDraw->dwItemSpec != TBCD_THUMB)) { *pResult = CDRF_DODEFAULT; return; } // get channel orientation BOOL IsVertical = (TBS_VERT & GetStyle()) ? TRUE : FALSE; // Get the coordinates of the control's window CRect crect; GetClientRect(crect); // client coordinates (top = left = 0, bottom = height, right = width) // Much of this is "paraphrased" from Nic Wilson's work -- see the header file ////////////////////////////////////////////////////////////////////////////////// // This bit does the tics marks transparently. // Create a memory dc to hold a copy of the oldbitmap data that includes the tics, // because when we add the background in we will lose the tic marks. /////////////////////////////////////////////////////////////////////////////////// CDC *pDC = CDC::FromHandle(lpCustDraw->hdc); CDC SaveCDC; CBitmap SaveCBmp; //set the colours for the monochrome mask bitmap COLORREF crOldBack = pDC->SetBkColor(RGB(0,0,0)); // set to Black COLORREF crOldText = pDC->SetTextColor(RGB(255,255,255)); // set to White int iWidth = crect.Width(); // channel width int iHeight = crect.Height(); // channel height //////////////////////////////////////////////////////////////////////////// // Create an in-memory copy of displayed bitmap, including the tics. // This is a monochrome bitmap since it was created from a memory DC. // If it had been created from pDC (an actual device DC, not a memory // DC) then this would be something with 8, 16, 24, or 32 bits per pixel. // // This will have a black background, with the tic marks in white. // // For reasons I don't yet understand, this saves only the tic marks and // the channel's centerline (both originally in black), and not the other // colors (such as drawn AROUND the channel's centerline). I am not sure // what would have happened if the tic marks were not black... //////////////////////////////////////////////////////////////////////////// SaveCDC.CreateCompatibleDC(pDC); SaveCBmp.CreateCompatibleBitmap(&SaveCDC, iWidth, iHeight); CBitmap* SaveCBmpOld = (CBitmap *)SaveCDC.SelectObject(SaveCBmp); SaveCDC.BitBlt(0, 0, iWidth, iHeight, pDC, crect.left, crect.top, SRCCOPY); if(m_dumpBitmaps) // debugging stuff { SaveBitmap("MonoTicsMask.bmp",SaveCBmp); } // Do as much of this stuff in memory as possible, then blit it to the screen CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap memBM; memBM.CreateCompatibleBitmap(pDC,iWidth,iHeight); // create from pDC, not memDC CBitmap *oldbm = memDC.SelectObject(&memBM); //////////////////////////////////////////////////////////////////////////////// // copy screen bitmap to memory bitmap for manipulation. If this is the very // first time the control has been updated, the screen bitmap will show only // the tic marks (in black) and the default background color (RGB(214,207,189)). // If the control has been updated before, remnants of the previously drawn // background color ranges will also show up. //////////////////////////////////////////////////////////////////////////////// memDC.BitBlt(0,0,iWidth,iHeight,pDC,0,0,SRCCOPY); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnStart.bmp",memBM); } ///////////////////////////////////////////////////////////////////////////// // Color parts of the channel if necessary. It SHOULD be necessary since we // don't get notifications unless there are colors to print, but we may have // a race condition and it is best to check. ///////////////////////////////////////////////////////////////////////////// if(loopMax) { ///////////////////////////////////////////////////////////////////////////////// // We need to draw colors over the subrange of the channel that the center of the // thumb traverses, rather than the entire client window. Later on, extend these // colors outwards to the ends of the client window (for nicer appearance). This // allows for more precise correlation with color and thumb position. ///////////////////////////////////////////////////////////////////////////////// CRect chanRect; GetChannelRect(&chanRect); CRect thmbRect; GetThumbRect(&thmbRect); // For unknown reasons, GetChannelRect() returns a rectangle // as though it were a horizonally oriented slider, even if it isn't! if(IsVertical) { CRect n; // could probably just change chanRect directly n.left = chanRect.top; n.right = chanRect.bottom; n.top = chanRect.left; n.bottom = chanRect.right; n.NormalizeRect(); chanRect.CopyRect(&n); } // Offset into client rectangle for beginning of coloring range int Offset = chanRect.left + thmbRect.Width()/2; if(IsVertical) { Offset = chanRect.top + thmbRect.Height()/2; } // Range for center of thumb on the channel int ht = chanRect.Height() - thmbRect.Height(); int wd = chanRect.Width() - thmbRect.Width(); // scaling between control range and bitmap int min,max; GetRange(min,max); // range of values for the slider double scale = (double(max) - double(min))/double(IsVertical ? ht : wd); BOOL gotStartColor = FALSE; BOOL gotEndColor = FALSE; COLORREF startColor = 0, endColor = 0; int loop; // Loop through the array of color ranges for(loop = 0; loop < loopMax; loop++) { clrRange clr; clr = colorList[loop]; // Get the good values. If not set, then entire range is good int lval = clr.lval; int hval = clr.hval; if((lval < min) || (lval > max)) lval = min; if((hval > max) || (hval < min)) hval = max; if(lval == min) { gotStartColor = TRUE; startColor = clr.strColor; } if(hval == max) { gotEndColor = TRUE; endColor = clr.endColor; } int minVal = lval - min; // offset into bitmap for this color minVal = int(double(minVal)/scale); // width (or height for vertical slider) inside bitmap for this color int widthVal = hval - lval; widthVal = int((double(widthVal)/scale) + 1.0); // For drawing a gradient, we need to know the individual RGB values int sR,eR,sG,eG,sB,eB; // start and end R, G, and B values sR = GetRValue(clr.strColor); eR = GetRValue(clr.endColor); sG = GetGValue(clr.strColor); eG = GetGValue(clr.endColor); sB = GetBValue(clr.strColor); eB = GetBValue(clr.endColor); if(GradientFill != NULL) { TRIVERTEX vert[2]; // for specifying range to gradient fill GRADIENT_RECT gRect; // Warning C4244: conversion from 'int' to 'unsigned short', possible loss of data #pragma warning (push) #pragma warning (disable : 4244) vert[0].Red = sR<<8; // expects 16-bit color values! vert[0].Green = sG<<8; vert[0].Blue = sB<<8; vert[0].Alpha = 0; // no fading/transparency vert[1].Red = eR<<8; vert[1].Green = eG<<8; vert[1].Blue = eB<<8; vert[1].Alpha = 0; #pragma warning (pop) gRect.UpperLeft = 0; gRect.LowerRight = 1; BOOL retval; if(IsVertical) // vertically oriented? { vert[0].x = 0; vert[0].y = Offset + minVal; vert[1].x = iWidth; vert[1].y = Offset + minVal + widthVal; retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_V); } else { vert[0].x = Offset + minVal; vert[0].y = 0; vert[1].x = Offset + minVal + widthVal; vert[1].y = iHeight; retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_H); } } else { // Homebrew version of GradientFill for rectangles -- works pretty well, sort of. int i; for(i = 0; i < widthVal; i++) // for each pixel column in bitmap color range { int R = sR; int G = sG; int B = sB; if(widthVal) { R += ::MulDiv(eR - sR, i, widthVal); G += ::MulDiv(eG - sG, i, widthVal); B += ::MulDiv(eB - sB, i, widthVal); } if(IsVertical) { // widthVal really refers to height //memDC.FillSolidRect(0,minVal+i,iWidth,widthVal-i,GetNearestColor(memDC,RGB(R,G,B))); memDC.FillSolidRect( 0, // starting X value Offset + minVal + i, // starting Y value iWidth, // full width 1, // one pixel height GetNearestColor(memDC,RGB(R,G,B))); } else { //memDC.FillSolidRect(minVal+i,0,widthVal-i,iHeight,GetNearestColor(memDC,RGB(R,G,B))); memDC.FillSolidRect( Offset + minVal + i, // Starting X value 0, // Starting Y value 1, // 1 pixel wide iHeight, // full height GetNearestColor(memDC,RGB(R,G,B))); } } } } if(m_extendColors) { // If we have put in colors at the slider ends, then extend those same // colors to the rest of the background. We could try to determine the // colors by examining the bitmap, but this is awkward and it is just // as easy to grab them on-the-fly in the coloring loop above. // // If you want to see why this is done, just set m_extendColors to FALSE // and take a look at the control. Ugly. But there might be a legitimate // reason for it so leave the option to suppress. if(IsVertical) { if(gotStartColor) { memDC.FillSolidRect(0, 0, iWidth, Offset, startColor); } if(gotEndColor) { memDC.FillSolidRect(0, iHeight - Offset - 1, iWidth, Offset, endColor); } } else { if(gotStartColor) { memDC.FillSolidRect(0, 0, Offset, iHeight, startColor); } if(gotEndColor) { memDC.FillSolidRect(iWidth - Offset - 1, 0, Offset, iHeight, endColor); } } } } // The screen bitmap should now have only the color ranges filled in, no tic // marks should be visible. if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnColors.bmp",memBM); } ////////////////////////////////////////////////////////////// // More "paraphrasing" from Nic Wilson's work... ////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // At this point, memDC's bitmap contains just the color ranges drawn above. // No tic marks are visible. Doing SRCINVERT with the mask will draw in the // tic marks, but all the colors will be backwards. Also, the tics will be // whatever color was drawn in the color range stuff, rather than solid, // normal tic marks. SRCINVERT means the RGB values are changed by subtracting // from 255: // // RGB(255,0,0) --> RGB(0,255,255) // RGB(247,8,0) --> RGB(8,247,255) // RGB(214,40,255) --> RGB(41,215,0) // ///////////////////////////////////////////////////////////////////////////// memDC.SetBkColor(pDC->GetBkColor()); memDC.SetTextColor(pDC->GetTextColor()); memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnInvert.bmp",memBM); } // Change the tic marks from the color range to the background color. This // changes only the tic marks (and the channel centerline) and leaves the // rest alone. The tic marks wind up black. memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCAND); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnAnd.bmp",memBM); } // Finally, invert the color ranges to their normal values. Since the tic // marks in the SaveCDC bitmap are white, they get inverted to black. memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnFinal.bmp",memBM); } // Now copy out to screen pDC->BitBlt(0,0,iWidth,iHeight,&memDC,0,0,SRCCOPY); // restore and clean up pDC->SetBkColor(crOldBack); pDC->SetTextColor(crOldText); DeleteObject(SelectObject(SaveCDC, SaveCBmpOld)); DeleteDC(SaveCDC); DeleteObject(SelectObject(memDC,oldbm)); DeleteDC(memDC); *pResult = CDRF_DODEFAULT; m_dumpBitmaps = FALSE; // only do this once! }
void CPlayerSeekBar::OnPaint() { CPaintDC dc(this); // device context for painting bool fEnabled = m_fEnabled && m_start < m_stop; COLORREF white = GetSysColor(COLOR_WINDOW), shadow = GetSysColor(COLOR_3DSHADOW), light = GetSysColor(COLOR_3DHILIGHT), bkg = GetSysColor(COLOR_BTNFACE); // thumb { CRect r = GetThumbRect(), r2 = GetInnerThumbRect(); CRect rt = r, rit = r2; dc.Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); dc.Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); CBrush b(bkg); dc.FrameRect(&r, &b); r.DeflateRect(0, 1, 0, 1); dc.FrameRect(&r, &b); r.DeflateRect(1, 1, 0, 0); dc.Draw3dRect(&r, shadow, bkg); if(fEnabled) { r.DeflateRect(1, 1, 1, 2); CPen white(PS_INSIDEFRAME, 1, white); CPen* old = dc.SelectObject(&white); dc.MoveTo(r.left, r.top); dc.LineTo(r.right, r.top); dc.MoveTo(r.left, r.bottom); dc.LineTo(r.right, r.bottom); dc.SelectObject(old); dc.SetPixel(r.CenterPoint().x, r.top, 0); dc.SetPixel(r.CenterPoint().x, r.bottom, 0); } dc.SetPixel(r.CenterPoint().x+5, r.top-4, bkg); { CRgn rgn1, rgn2; rgn1.CreateRectRgnIndirect(&rt); rgn2.CreateRectRgnIndirect(&rit); ExtSelectClipRgn(dc, rgn1, RGN_DIFF); ExtSelectClipRgn(dc, rgn2, RGN_OR); } } // channel { CRect r = GetChannelRect(); dc.FillSolidRect(&r, fEnabled ? white : bkg); r.InflateRect(1, 1); dc.Draw3dRect(&r, shadow, light); dc.ExcludeClipRect(&r); } // background { CRect r; GetClientRect(&r); CBrush b(bkg); dc.FillRect(&r, &b); } // Do not call CDialogBar::OnPaint() for painting messages }
void CPlayerSeekBar::SetTimecodeTip(){ CString toolTip; CPoint point , screenPos; GetCursorPos(&point); screenPos = point; ScreenToClient(&point); CRect rcClient; if( !rcClient.PtInRect(point)){ //return; } CRect r = GetChannelRect(); if(r.left <= r.right){ __int64 mPos = 0; if(point.x < r.left) mPos = m_start; else if(point.x >= r.right) mPos = m_stop; else { __int64 w = r.right - r.left; if(m_start < m_stop) mPos = (m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w); } DVD_HMSF_TIMECODE tcNow = RT2HMSF(mPos); if( tcNow.bHours > 0) toolTip.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds); else toolTip.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds); //AfxMessageBox(toolTip); //if(toolTip.IsEmpty()) // toolTip = _T("Unkown"); if(!toolTip.IsEmpty()){ CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); pFrame->m_tip.m_text = toolTip; CSize tipsize = pFrame->m_tip.CountSize(); point = screenPos; CRect rcTip ( point.x - tipsize.cx/2 , point.y - tipsize.cy - 6,point.x + tipsize.cx/2 , point.y - 6); //SVP_LogMsg5(_T("Tip %d %d %d %d") , rcTip.left,rcTip.top , rcTip.right,rcTip.left); HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST); MONITORINFO mi; mi.cbSize = sizeof(MONITORINFO); GetMonitorInfo(hMonitor, &mi); if(rcTip.left < mi.rcWork.left){ rcTip.MoveToX(mi.rcWork.left + 3); }else if(rcTip.right > mi.rcWork.right){ rcTip.MoveToX(mi.rcWork.right - rcTip.Width() - 3); } pFrame->m_tip.MoveWindow( rcTip ); pFrame->m_tip.ShowWindow(SW_SHOWNOACTIVATE); pFrame->m_tip.Invalidate(); } } }
/* BOOL CPlayerSeekBar::OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult) { //AfxMessageBox(_T("x")); //where is my tooltip!?! UNREFERENCED_PARAMETER(id); TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; UINT_PTR nID = pNMHDR->idFrom; BOOL bRet = FALSE; if(nID == 0){ CString toolTip; CPoint point; GetCursorPos(&point); ScreenToClient(&point); CRect r = GetChannelRect(); if(r.left <= r.right){ __int64 mPos = 0; if(point.x < r.left) mPos = m_start; else if(point.x >= r.right) mPos = m_stop; else { __int64 w = r.right - r.left; if(m_start < m_stop) mPos = (m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w); } DVD_HMSF_TIMECODE tcNow = RT2HMSF(mPos); if( tcNow.bHours > 0) toolTip.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds); else toolTip.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds); //AfxMessageBox(toolTip); //if(toolTip.IsEmpty()) // toolTip = _T("Unkown"); if(!toolTip.IsEmpty()){ pTTT->lpszText = toolTip.GetBuffer(); pTTT->hinst = AfxGetResourceHandle(); bRet = TRUE; } } } *pResult = 0; return bRet; }*/ void CPlayerSeekBar::OnPaint() { CPaintDC dc(this); // device context for painting bool fEnabled = m_fEnabled && m_start < m_stop; AppSettings& s = AfxGetAppSettings(); COLORREF // white = s.GetColorFromTheme(_T("SeekBarPlayed"), NEWUI_COLOR_SEEKBAR_PLAYED), // shadow = s.GetColorFromTheme(_T("SeekBarBottomBorderBG"), NEWUI_COLOR_BG), // light = s.GetColorFromTheme(_T("SeekBarPlayed"), NEWUI_COLOR_BG), bkg = s.GetColorFromTheme(_T("SeekBarBG"), NEWUI_COLOR_TOOLBAR_UPPERBG); CBrush bBkg(bkg); /*/ thumb if(0){ CRect r = GetThumbRect(), r2 = GetInnerThumbRect(); CRect rt = r, rit = r2; dc.Draw3dRect(&r, light, 0); r.DeflateRect(0, 0, 1, 1); dc.Draw3dRect(&r, light, shadow); r.DeflateRect(1, 1, 1, 1); CBrush b(bkg); dc.FrameRect(&r, &b); r.DeflateRect(0, 1, 0, 1); dc.FrameRect(&r, &b); r.DeflateRect(1, 1, 0, 0); dc.Draw3dRect(&r, shadow, bkg); if(fEnabled) { r.DeflateRect(1, 1, 1, 2); CPen white(PS_INSIDEFRAME, 1, white); CPen* old = dc.SelectObject(&white); dc.MoveTo(r.left, r.top); dc.LineTo(r.right, r.top); dc.MoveTo(r.left, r.bottom); dc.LineTo(r.right, r.bottom); dc.SelectObject(old); dc.SetPixel(r.CenterPoint().x, r.top, 0); dc.SetPixel(r.CenterPoint().x, r.bottom, 0); } dc.SetPixel(r.CenterPoint().x+5, r.top-4, bkg); { CRgn rgn1, rgn2; rgn1.CreateRectRgnIndirect(&rt); rgn2.CreateRectRgnIndirect(&rit); ExtSelectClipRgn(dc, rgn1, RGN_DIFF); ExtSelectClipRgn(dc, rgn2, RGN_OR); } } */ // channel { CRect r = GetChannelRect(); int cur = r.left + (int)((m_start < m_stop /*&& fEnabled*/) ? (__int64)r.Width() * (m_pos - m_start) / (m_stop - m_start) : 0); #define CORBARS 10 COLORREF havntplayed = s.GetColorFromTheme(_T("SeekBarUnPlayed"), 0x00434343); COLORREF Bars[CORBARS] = {s.GetColorFromTheme(_T("SeekBarPlayed1"), 0x000f412d), s.GetColorFromTheme(_T("SeekBarPlayed2"), 0x0083ffdf), s.GetColorFromTheme(_T("SeekBarPlayed3"), 0x0071fdd4), s.GetColorFromTheme(_T("SeekBarPlayed4"), 0x0061f9c6), s.GetColorFromTheme(_T("SeekBarPlayed5"), 0x0061f9c6), s.GetColorFromTheme(_T("SeekBarPlayed6"), 0x0061f9c6), s.GetColorFromTheme(_T("SeekBarPlayed7"), 0x005ff5ba), s.GetColorFromTheme(_T("SeekBarPlayed8"), 0x0064f1b2), s.GetColorFromTheme(_T("SeekBarPlayed9"), 0x006fefb0), s.GetColorFromTheme(_T("SeekBarPlayed10"), 0x000f412d)}; { CPen line(PS_INSIDEFRAME, 1, bkg); CPen* old = dc.SelectObject(&line); dc.MoveTo( cur , r.top ); dc.LineTo( r.right, r.top ); dc.MoveTo( cur , r.top + CORBARS - 1); dc.LineTo( r.right, r.top + CORBARS - 1); } CRect rFilled(r); rFilled.left = cur; rFilled.top++; rFilled.bottom--; dc.FillSolidRect(&rFilled, havntplayed ); //fEnabled ? //r = GetChannelRect(); for(int i = 0; i < CORBARS ; i++){ CPen line(PS_INSIDEFRAME, 1, Bars[i]); CPen* old = dc.SelectObject(&line); dc.MoveTo( r.left , r.top + i); dc.LineTo( cur, r.top + i); } { COLORREF P2 = s.GetColorFromTheme(_T("SeekBarBorder1"), 0x000d3324); COLORREF P1 = s.GetColorFromTheme(_T("SeekBarBorder2"),0x00091611); dc.SetPixel(r.left-1, r.top+1, P2); dc.SetPixel(r.left, r.top, P2); dc.SetPixel(r.left-1, r.bottom-2, P2); dc.SetPixel(r.left, r.bottom-1, P2); dc.SetPixel(cur+1, r.top+1, P2); dc.SetPixel(cur, r.top, P2); dc.SetPixel(cur+1, r.bottom-2, P2); dc.SetPixel(cur, r.bottom-1, P2); dc.SetPixel(cur+1, r.top, P1); dc.SetPixel(cur+1, r.bottom-1, P1); dc.SetPixel(r.left-1, r.top, P1); dc.SetPixel(r.left-1, r.bottom-1, P1); CPen line(PS_INSIDEFRAME, 1, Bars[0]); CPen* old = dc.SelectObject(&line); dc.MoveTo( r.left-1 , r.top + 2); dc.LineTo( r.left-1 , r.bottom-2); dc.MoveTo( cur+1 , r.top + 2); dc.LineTo( cur+1 , r.bottom-2); } CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if( pFrame->m_aRefTime > 0){ CRect rFilled(r); rFilled.left += (__int64)r.Width() * (pFrame->m_aRefTime - m_start) / (m_stop - m_start) ; if( pFrame->m_aRefTime < pFrame->m_bRefTime ) rFilled.right = r.left + (__int64)r.Width() * (pFrame->m_bRefTime - m_start) / (m_stop - m_start) ; else rFilled.right = rFilled.left + 1; rFilled.top+=2; rFilled.bottom-=2; CBrush nBrush(HS_DIAGCROSS, s.GetColorFromTheme(_T("SeekBarABArea"), 0x003fff9a )); dc.FillRect(&rFilled,&nBrush ); //fEnabled ? } /* switch( cur % 4 ){ case 3: cur--; break; case 2: cur+=2; break; case 1: cur++; break; } for(int drawPos = cur ; drawPos < r.right; drawPos +=2){ CRect step(drawPos,r.top, drawPos+2, r.bottom); if(drawPos % 4){ dc.FillSolidRect( &step, NEWUI_COLOR_TOOLBAR_UPPERBG); }else{ dc.FillSolidRect( &step, white); } }*/ //r.InflateRect(1, 1); //dc.Draw3dRect(&r, shadow, light); dc.ExcludeClipRect(&r); } // background { CRect r; GetClientRect(&r); dc.FillRect(&r, &bBkg); } // Do not call CDialogBar::OnPaint() for painting messages }
//***************************************************************************************** void CBCGPSliderCtrl::OnDraw(CDC* pDCIn) { CBCGPMemDC memDC (*pDCIn, this); CDC* pDC = &memDC.GetDC (); if (!CBCGPVisualManager::GetInstance ()->OnFillParentBarBackground (this, pDC)) { globalData.DrawParentBackground (this, pDC, NULL); } DWORD dwStyle = GetStyle (); BOOL bVert = (dwStyle & TBS_VERT); BOOL bLeftTop = (dwStyle & TBS_BOTH) || (dwStyle & TBS_LEFT); BOOL bRightBottom = (dwStyle & TBS_BOTH) || ((dwStyle & TBS_LEFT) == 0); BOOL bIsFocused = GetSafeHwnd () == ::GetFocus (); CRect rectChannel; GetChannelRect (rectChannel); if (bVert) { CRect rect = rectChannel; rectChannel.left = rect.top; rectChannel.right = rect.bottom; rectChannel.top = rect.left; rectChannel.bottom = rect.right; } CBCGPDrawOnGlass dog(m_bOnGlass); CBCGPVisualManager::GetInstance ()->OnDrawSliderChannel (pDC, this, bVert, rectChannel, m_bOnGlass); CRect rectThumb; GetThumbRect (rectThumb); int nTicSize = max(3, (bVert ? rectThumb.Height() : rectThumb.Width()) / 3); int nTicOffset = 2; int nNumTics = GetNumTics(); for (int i = 0; i < nNumTics; i++) { int nTicPos = GetTicPos(i); if (nTicPos < 0) { if (i == nNumTics - 2) { if (bVert) { nTicPos = rectChannel.top + rectThumb.Height() / 2; } else { nTicPos = rectChannel.left + rectThumb.Width() / 2; } } else if (i == nNumTics - 1) { if (bVert) { nTicPos = rectChannel.bottom - rectThumb.Height() / 2 - 1; } else { nTicPos = rectChannel.right - rectThumb.Width() / 2 - 1; } } } if (nTicPos >= 0) { CRect rectTic1(0, 0, 0, 0); CRect rectTic2(0, 0, 0, 0); if (bVert) { if (bLeftTop) { rectTic1 = CRect(rectThumb.left - nTicOffset - nTicSize, nTicPos, rectThumb.left - nTicOffset, nTicPos + 1); } if (bRightBottom) { rectTic2 = CRect(rectThumb.right + nTicOffset, nTicPos, rectThumb.right + nTicOffset + nTicSize, nTicPos + 1); } } else { if (bLeftTop) { rectTic1 = CRect(nTicPos, rectThumb.top - nTicOffset - nTicSize, nTicPos + 1, rectThumb.top - nTicOffset); } if (bRightBottom) { rectTic2 = CRect(nTicPos, rectThumb.bottom + nTicOffset, nTicPos + 1, rectThumb.bottom + nTicOffset + nTicSize); } } if (!rectTic1.IsRectEmpty()) { CBCGPVisualManager::GetInstance ()->OnDrawSliderTic(pDC, this, rectTic1, bVert, TRUE, m_bOnGlass); } if (!rectTic2.IsRectEmpty()) { CBCGPVisualManager::GetInstance ()->OnDrawSliderTic(pDC, this, rectTic2, bVert, FALSE, m_bOnGlass); } } } CBCGPVisualManager::GetInstance ()->OnDrawSliderThumb ( pDC, this, rectThumb, m_bIsThumbHighligted || bIsFocused, m_bIsThumPressed, !IsWindowEnabled (), bVert, bLeftTop, bRightBottom, m_bOnGlass); if (bIsFocused && m_bDrawFocus) { CRect rectFocus; GetClientRect (rectFocus); if (m_bOnGlass) { CBCGPDrawManager dm (*pDC); dm.DrawFocusRect(rectFocus); } else { pDC->DrawFocusRect (rectFocus); } } }