-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackwardButton.cpp
More file actions
175 lines (139 loc) · 4.08 KB
/
BackwardButton.cpp
File metadata and controls
175 lines (139 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// BackwardButton.cpp : implementation file
//
#include "stdafx.h"
#include "MediaPlayer.h"
#include "BackwardButton.h"
#include "MediaPlayerDialog.h"
#include "MainFrm.h"
#include "TaskListDialog.h"
#include "FilePreView.h"
extern CMainFrame* g_pMainFrame;
// CBackwardButton
IMPLEMENT_DYNAMIC(CBackwardButton, CWnd)
CBackwardButton::CBackwardButton()
{
m_pMediaPlayerDlg = nullptr;
}
CBackwardButton::~CBackwardButton()
{
}
BEGIN_MESSAGE_MAP(CBackwardButton, CWnd)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CBackwardButton message handlers
void CBackwardButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// this->SetDlgItemText(IDC_BUTTON_BACK, _T("hello"));
// TODO: Add your code to draw the specified item
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
ASSERT(pDC != NULL);
UINT uStyle = DFCS_BUTTONPUSH;
// This code only works with buttons.
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
// If drawing selected, add the pushed style to DrawFrameControl.
if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;
// Draw the button frame.
::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem,
DFC_BUTTON, uStyle);
DrawFastBackwardIcon(*pDC, lpDrawItemStruct->rcItem);
// Get the button's text.
// CString strText = _T("hello");
// GetWindowText(strText);
// Draw the button text using the text color red.
// COLORREF crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(255,0,0));
// ::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(),
// &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
// ::SetTextColor(lpDrawItemStruct->hDC, crOldColor);
}
void CBackwardButton::DrawFastBackwardIcon(CDC& dc, const RECT& rect)
{
CRect rt(rect.left, rect.top, rect.right, rect.bottom);
rt.DeflateRect(3, 3, 3, 3);
long lTop = rt.top;
long lTop_ = lTop;
long lBottom = rt.bottom;
long lBottom_ = lBottom;
long lCenter = rt.left + rt.Width() / 2;
long lCenter_ = lCenter;
long lHeight = rt.bottom - rt.top;
long lRight = rt.right - 3;
const long lIncrease = 1L;
while (true)
{
if (lTop >= lBottom)
{
break;
}
dc.MoveTo(lCenter, lTop /*+= lIncrease*/);
dc.LineTo(lCenter, lBottom /*-= lIncrease*/);
lCenter -= 1;
lTop += lIncrease;
lBottom -= lIncrease;
}
while (true)
{
if (lTop_ >= lBottom_)
{
break;
}
dc.MoveTo(lRight, lTop_ /*+= lIncrease*/);
dc.LineTo(lRight, lBottom_ /*-= lIncrease*/);
lRight -= 1;
lTop_ += lIncrease;
lBottom_ -= lIncrease;
}
}
void CBackwardButton::SetParentDlg(CMediaPlayerDialog* pDlg)
{
if (pDlg)
{
m_pMediaPlayerDlg = pDlg;
}
}
void CBackwardButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
// CSplitterWnd& split = g_pMainFrame->GetSplitterWnd2();
// CFilePreView* pFilePrevView = (CFilePreView*)(split.GetPane(1, 0));
// CTaskListDialog* pDlg = pFilePrevView->GetTaskListDlg();
//
// std::vector<CString>& Mp4PathAry = const_cast<std::vector<CString>&>(pDlg->GetMp4PathAry());
// std::vector<CString>::reverse_iterator rit = Mp4PathAry.rbegin();
// const CString& strMp4Path = m_pMediaPlayerDlg->GetMp4Path();
//
// int nSelMp4 = Mp4PathAry.size();
// while (true)
// {
// if (rit == Mp4PathAry.rend())
// {
// nSelMp4 = Mp4PathAry.size() - 1;
// rit = Mp4PathAry.rbegin();
// }
//
// if (*rit == strMp4Path)
// {
// --nSelMp4;
// ++rit;
// break;
// }
//
// --nSelMp4;
// ++rit;
// }
//
// if (rit == Mp4PathAry.rend())
// {
// nSelMp4 = Mp4PathAry.size() - 1;
//
// rit = Mp4PathAry.rbegin();
// }
//
// const CString& strNextMp4 = *rit;
//
// pDlg->SetCurSelMp4(nSelMp4);
//
// CVLCPlayer::Instance()->OpenMedia(strNextMp4);
// CVLCPlayer::Instance()->Play();
CButton::OnLButtonDown(nFlags, point);
}