diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
commit | efbc9d9043ff8ff92716ddd00a5f61412d535593 (patch) | |
tree | 8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/apps/mplayerc/VolumeCtrl.cpp | |
parent | df6b139a6d9027156f614b68687e039e3a5854db (diff) |
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc/VolumeCtrl.cpp')
-rw-r--r-- | src/apps/mplayerc/VolumeCtrl.cpp | 200 |
1 files changed, 100 insertions, 100 deletions
diff --git a/src/apps/mplayerc/VolumeCtrl.cpp b/src/apps/mplayerc/VolumeCtrl.cpp index 23bfc1343..2da29e9e7 100644 --- a/src/apps/mplayerc/VolumeCtrl.cpp +++ b/src/apps/mplayerc/VolumeCtrl.cpp @@ -39,38 +39,38 @@ CVolumeCtrl::~CVolumeCtrl() bool CVolumeCtrl::Create(CWnd* pParentWnd)
{
- if(!CSliderCtrl::Create(WS_CHILD | WS_VISIBLE | TBS_NOTICKS | TBS_HORZ, CRect(0, 0, 0, 0), pParentWnd, IDC_SLIDER1))
- return(false);
+ if(!CSliderCtrl::Create(WS_CHILD|WS_VISIBLE|TBS_NOTICKS|TBS_HORZ, CRect(0,0,0,0), pParentWnd, IDC_SLIDER1))
+ return(false);
- SetRange(1, 100);
- SetPosInternal(AfxGetAppSettings().nVolume);
- SetPageSize(5);
- SetLineSize(0);
+ SetRange(1, 100);
+ SetPosInternal(AfxGetAppSettings().nVolume);
+ SetPageSize(5);
+ SetLineSize(0);
- return(true);
+ return(true);
}
void CVolumeCtrl::SetPosInternal(int pos)
{
- SetPos(pos);
- GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us
+ SetPos(pos);
+ GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us
}
void CVolumeCtrl::IncreaseVolume()
{
- (GetPos() == 1) ? SetPosInternal(GetPos() + GetPageSize() - 1) : SetPosInternal(GetPos() + GetPageSize());
+ (GetPos() == 1) ? SetPosInternal(GetPos() + GetPageSize() - 1) : SetPosInternal(GetPos() + GetPageSize());
}
void CVolumeCtrl::DecreaseVolume()
{
- SetPosInternal(GetPos() - GetPageSize());
+ SetPosInternal(GetPos() - GetPageSize());
}
BEGIN_MESSAGE_MAP(CVolumeCtrl, CSliderCtrl)
- ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)
- ON_WM_LBUTTONDOWN()
- ON_WM_SETFOCUS()
- ON_WM_HSCROLL_REFLECT()
+ ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)
+ ON_WM_LBUTTONDOWN()
+ ON_WM_SETFOCUS()
+ ON_WM_HSCROLL_REFLECT()
END_MESSAGE_MAP()
// CVolumeCtrl message handlers
@@ -78,108 +78,108 @@ END_MESSAGE_MAP() 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 r;
- GetClientRect(r);
- r.DeflateRect(8, 4, 10, 6);
- CopyRect(&pNMCD->rc, &r);
- 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;
+ 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 r;
+ GetClientRect(r);
+ r.DeflateRect(8, 4, 10, 6);
+ CopyRect(&pNMCD->rc, &r);
+ 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 CVolumeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
- CRect r;
- GetChannelRect(&r);
+ CRect r;
+ GetChannelRect(&r);
+
+ if(r.left >= r.right) return;
- if(r.left >= r.right) return;
+ int start, stop;
+ GetRange(start, stop);
- int start, stop;
- GetRange(start, stop);
+ int pos = GetPos();
- int pos = GetPos();
+ r.left += 3;
+ r.right -= 4;
- 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);
+ }
- 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);
+ CSliderCtrl::OnLButtonDown(nFlags, point);
}
void CVolumeCtrl::OnSetFocus(CWnd* pOldWnd)
{
- CSliderCtrl::OnSetFocus(pOldWnd);
+ CSliderCtrl::OnSetFocus(pOldWnd);
- AfxGetMainWnd()->SetFocus(); // don't focus on us, parents will take care of our positioning
+ AfxGetMainWnd()->SetFocus(); // don't focus on us, parents will take care of our positioning
}
void CVolumeCtrl::HScroll(UINT nSBCode, UINT nPos)
{
- AfxGetAppSettings().nVolume = GetPos();
+ AfxGetAppSettings().nVolume = GetPos();
- CFrameWnd* pFrame = GetParentFrame();
- if(pFrame && pFrame != GetParent())
- pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
+ CFrameWnd* pFrame = GetParentFrame();
+ if(pFrame && pFrame != GetParent())
+ pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
}
|