-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMSFadeBar.cpp
More file actions
186 lines (160 loc) · 4.7 KB
/
Copy pathMSFadeBar.cpp
File metadata and controls
186 lines (160 loc) · 4.7 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
176
177
178
179
180
181
182
183
184
185
186
// Copyleft 2004 Chris Korda
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
/*
chris korda
revision history:
rev date comments
00 28sep04 initial version
01 07oct04 undo slider was updating edit ctrl but not slider
mute/solo fade time dialog bar
*/
// MSFadeBar.cpp : implementation file
//
#include "stdafx.h"
#include "Resource.h"
#include "MSFadeBar.h"
#include "AutoSliderDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMSFadeBar dialog
CMSFadeBar::CMSFadeBar()
: CDialogBarEx(NULL)
{
//{{AFX_DATA_INIT(CMSFadeBar)
//}}AFX_DATA_INIT
}
void CMSFadeBar::GetInfo(CAutoInfo& Info) const
{
m_TimeEdit.GetInfo(Info);
}
void CMSFadeBar::SetInfo(const CAutoInfo& Info)
{
m_TimeEdit.SetInfo(Info);
m_Slider.SetPos(m_TimeEdit.GetPos());
}
void CMSFadeBar::SetTime(int Time)
{
m_TimeEdit.SetTime(Time);
m_Slider.SetPos(m_TimeEdit.GetPos());
}
void CMSFadeBar::SaveUndoState(CUndoState& State)
{
switch (State.GetCtrlID()) {
case IDC_MS_FADE_SLIDER: // slider position isn't precise enough
State.m_Val.x.i = m_TimeEdit.GetTime();
break;
case IDC_MS_FADE_MINUTES: // minutes changes time as side effect
WndToUndo(&m_Minutes)->SaveUndoState(State);
State.m_Val.y.i = m_TimeEdit.GetTime();
break;
}
}
void CMSFadeBar::RestoreUndoState(const CUndoState& State)
{
switch (State.GetCtrlID()) {
case IDC_MS_FADE_SLIDER:
m_TimeEdit.SetTime(State.m_Val.x.i);
m_Slider.SetPos(m_TimeEdit.GetPos()); // update slider too
break;
case IDC_MS_FADE_MINUTES:
WndToUndo(&m_Minutes)->RestoreUndoState(State);
m_TimeEdit.SetTime(State.m_Val.y.i);
break;
}
}
void CMSFadeBar::GetUndoTitle(const CUndoState& State, CString& Title)
{
CUndoable *uap = FindUndoable(State.GetCtrlID());
if (uap != NULL)
uap->GetUndoTitle(State, Title);
}
void CMSFadeBar::UpdateTime()
{
OnTimeChange();
}
void CMSFadeBar::OnTimeChange()
{
}
void CMSFadeBar::DoDataExchange(CDataExchange* pDX)
{
CDialogBarEx::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMSFadeBar)
DDX_Control(pDX, IDC_MS_FADE_SPIN, m_TimeSpin);
DDX_Control(pDX, IDC_MS_FADE_EDIT, m_TimeEdit);
DDX_Control(pDX, IDC_MS_FADE_SLIDER, m_Slider);
DDX_Control(pDX, IDC_MS_FADE_MINUTES, m_Minutes);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMSFadeBar, CDialogBarEx)
//{{AFX_MSG_MAP(CMSFadeBar)
ON_WM_SIZE()
ON_WM_HSCROLL()
ON_NOTIFY(UDN_DELTAPOS, IDC_MS_FADE_SPIN, OnDeltaposTimeSpin)
ON_BN_CLICKED(IDC_MS_FADE_MINUTES, OnMinutes)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_INITDIALOG, OnInitDialog)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMSFadeBar message handlers
LRESULT CMSFadeBar::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
CDialogBarEx::OnInitDialog(wParam, lParam);
SetWindowText(LDS(MS_FADE_BAR));
SetBarCaption(LDS(MS_FADE_CAPTION));
m_Slider.SetRange(0, CAutoSliderDlg::SLIDER_RANGE);
m_Slider.CreateTicks(CAutoSliderDlg::SLIDER_TICKS);
// give edit control a fatter font
m_TimeEdit.SendMessage(WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT));
m_TimeEdit.SetUndoTitle(LDS(MS_FADE_EDIT));
m_Slider.SetRange(0, 60);
m_Minutes.SetIcons(IDI_MINUTESU, IDI_MINUTESD);
// add controls to resizing object
m_Resize.AddControl(IDC_MS_FADE_SLIDER, BIND_LEFT | BIND_RIGHT);
m_Resize.AddControl(IDC_MS_FADE_MINUTES, BIND_RIGHT);
m_Resize.AddControl(IDC_MS_FADE_EDIT, BIND_RIGHT);
m_Resize.AddControl(IDC_MS_FADE_SPIN, BIND_RIGHT);
m_Resize.FixControls();
// these controls send undo notifications, but we handle save/restore
m_Slider.SetUndoHandler(this);
m_Minutes.SetUndoHandler(this);
return TRUE;
}
void CMSFadeBar::OnSize(UINT nType, int cx, int cy)
{
CDialogBarEx::OnSize(nType, cx, cy);
m_Resize.OnSize();
}
void CMSFadeBar::OnMinutes()
{
m_TimeEdit.SetUnit(m_Minutes.GetCheck());
UpdateTime();
}
void CMSFadeBar::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CDialogBarEx::OnHScroll(nSBCode, nPos, pScrollBar);
m_TimeEdit.SetPos(m_Slider.GetPos());
UpdateTime();
}
BOOL CMSFadeBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR *nmh = (NMHDR *)lParam;
if (nmh->hwndFrom == m_TimeEdit.m_hWnd) {
m_Slider.SetPos(m_TimeEdit.GetPos());
m_Minutes.SetCheck(m_TimeEdit.GetUnit());
UpdateTime();
return(TRUE);
}
return CDialogBarEx::OnNotify(wParam, lParam, pResult);
}
void CMSFadeBar::OnDeltaposTimeSpin(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
m_TimeEdit.AddSpin(-pNMUpDown->iDelta);
*pResult = 0;
}