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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
#ifndef MEDIA_TOOLS_PLAYER_WTL_PROPS_H_
#define MEDIA_TOOLS_PLAYER_WTL_PROPS_H_
#include "media/tools/player_wtl/movie.h"
#include "resource.h"
// Movie properties dialog
class CFileName : public CWindowImpl<CFileName> {
public:
CFileName() : file_name_(NULL) {
}
void Init(HWND hwnd, wchar_t* str_name) {
ATLASSERT(::IsWindow(hwnd));
SubclassWindow(hwnd);
// Set tooltip.
tooltip_.Create(m_hWnd);
ATLASSERT(tooltip_.IsWindow());
RECT rect;
GetClientRect(&rect);
CToolInfo ti(0, m_hWnd, tooltip_id_, &rect, NULL);
tooltip_.AddTool(&ti);
// Set text.
file_name_ = str_name;
if (file_name_ == NULL)
return;
CClientDC dc(m_hWnd); // will not really paint
HFONT old_font = dc.SelectFont(AtlGetDefaultGuiFont());
RECT rect_text = rect;
dc.DrawText(file_name_, -1, &rect_text,
DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_NOPREFIX |
DT_CALCRECT);
BOOL is_too_long = (rect_text.right > rect.right);
if (is_too_long)
tooltip_.UpdateTipText(file_name_, m_hWnd, tooltip_id_);
tooltip_.Activate(is_too_long);
dc.SelectFont(old_font);
Invalidate();
UpdateWindow();
}
BEGIN_MSG_MAP(CFileName)
MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()
LRESULT OnMouseMessage(UINT message, WPARAM wparam, LPARAM lparam,
BOOL& handled) {
if (tooltip_.IsWindow()) {
MSG msg = { m_hWnd, message, wparam, lparam };
tooltip_.RelayEvent(&msg);
}
handled = FALSE;
return 1;
}
LRESULT OnPaint(UINT /*message*/, WPARAM /*wparam*/, LPARAM /*lparam*/,
BOOL& /*handled*/) {
CPaintDC dc(m_hWnd);
if (file_name_ != NULL) {
RECT rect;
GetClientRect(&rect);
dc.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
dc.SetBkMode(TRANSPARENT);
HFONT old_font = dc.SelectFont(AtlGetDefaultGuiFont());
dc.DrawText(file_name_, -1, &rect, DT_SINGLELINE | DT_LEFT |
DT_VCENTER | DT_NOPREFIX | DT_PATH_ELLIPSIS);
dc.SelectFont(old_font);
}
return 0;
}
DECLARE_WND_CLASS_EX(NULL, 0, COLOR_3DFACE)
wchar_t* file_name_;
enum { tooltip_id_ = 1313 };
CToolTipCtrl tooltip_;
};
// Movie properties.
// TODO(fbarchard): Add movie duration in seconds.
class CPageOne : public CPropertyPageImpl<CPageOne> {
public:
enum { IDD = IDD_PROP_PAGE1 };
CPageOne() : file_name_(NULL) {
}
BEGIN_MSG_MAP(CPageOne)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
CHAIN_MSG_MAP(CPropertyPageImpl<CPageOne>)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*message*/, WPARAM /*wparam*/, LPARAM /*lparam*/,
BOOL& /*handled*/) {
if (file_name_ != NULL) {
file_location_.Init(GetDlgItem(IDC_FILELOCATION), file_name_);
WIN32_FIND_DATA find_data;
HANDLE find_handle = ::FindFirstFile(file_name_, &find_data);
if (find_handle != INVALID_HANDLE_VALUE) {
// TODO(fbarchard): Support files larger than 2 GB
int size_k = (find_data.nFileSizeLow / 1024);
if (size_k == 0 && find_data.nFileSizeLow != 0)
size_k = 1;
wchar_t szBuff[100];
wsprintf(szBuff, L"%i KB", size_k);
SetDlgItemText(IDC_FILESIZE, szBuff);
// TODO(fbarchard): We need a pipeline property for frame rate.
float duration = media::Movie::GetInstance()->GetDuration();
float fps = 29.97f;
wsprintf(szBuff, L"%i.%2i Seconds, %i Frames",
static_cast<int>(duration),
static_cast<int>(duration * 100) % 100,
static_cast<int>(duration * fps));
SetDlgItemText(IDC_FILEDURATION, szBuff);
SYSTEMTIME st;
::FileTimeToSystemTime(&find_data.ftCreationTime, &st);
::GetDateFormat(LOCALE_USER_DEFAULT, 0, &st,
L"dddd, MMMM dd',' yyyy',' ",
szBuff, sizeof(szBuff) / sizeof(szBuff[0]));
wchar_t szBuff1[50];
::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st,
L"hh':'mm':'ss tt", szBuff1,
sizeof(szBuff1) / sizeof(szBuff1[0]));
lstrcat(szBuff, szBuff1);
SetDlgItemText(IDC_FILEDATE, szBuff);
szBuff[0] = 0;
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0)
lstrcat(szBuff, L"Archive, ");
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0)
lstrcat(szBuff, L"Read-only, ");
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)
lstrcat(szBuff, L"Hidden, ");
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) != 0)
lstrcat(szBuff, L"System");
int length = lstrlen(szBuff);
if (length >= 2 && szBuff[length - 2] == L',')
szBuff[length - 2] = 0;
SetDlgItemText(IDC_FILEATTRIB, szBuff);
::FindClose(find_handle);
}
} else {
SetDlgItemText(IDC_FILELOCATION, L"(Clipboard)");
SetDlgItemText(IDC_FILESIZE, L"N/A");
SetDlgItemText(IDC_FILEDATE, L"N/A");
SetDlgItemText(IDC_FILEATTRIB, L"N/A");
}
return TRUE;
}
CFileName file_location_;
wchar_t* file_name_;
};
// Frame properties.
// TODO(fbarchard): This is not implemented for movies yet.
class CPageTwo : public CPropertyPageImpl<CPageTwo> {
public:
enum { IDD = IDD_PROP_PAGE2 };
CPageTwo() : file_name_(NULL) {
}
BEGIN_MSG_MAP(CPageTwo)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
CHAIN_MSG_MAP(CPropertyPageImpl<CPageTwo>)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*message*/, WPARAM /*wparam*/, LPARAM /*lparam*/,
BOOL& /*handled*/) {
// Special - remove unused buttons, move Close button, center wizard
CPropertySheetWindow sheet = GetPropertySheet();
#if !defined(_AYGSHELL_H_) && !defined(__AYGSHELL_H__) // PPC specific.
sheet.CancelToClose();
RECT rect;
CButton btn_cancel = sheet.GetDlgItem(IDCANCEL);
btn_cancel.GetWindowRect(&rect);
sheet.ScreenToClient(&rect);
btn_cancel.ShowWindow(SW_HIDE);
CButton btn_close = sheet.GetDlgItem(IDOK);
btn_close.SetWindowPos(NULL, &rect, SWP_NOZORDER | SWP_NOSIZE);
sheet.CenterWindow(GetPropertySheet().GetParent());
sheet.ModifyStyleEx(WS_EX_CONTEXTHELP, 0);
#endif // (_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific.
// Get and display movie prperties.
SetDlgItemText(IDC_TYPE, L"MP4 Movie");
wchar_t* compression_text = L"H.264";
if (file_name_ != NULL) {
HANDLE file_handle = ::CreateFile(file_name_, GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL |
FILE_FLAG_SEQUENTIAL_SCAN, NULL);
ATLASSERT(file_handle != INVALID_HANDLE_VALUE);
if (file_handle != INVALID_HANDLE_VALUE) {
DWORD dwRead = 0;
BITMAPFILEHEADER bfh;
::ReadFile(file_handle, &bfh, sizeof(bfh), &dwRead, NULL);
BITMAPINFOHEADER bih;
::ReadFile(file_handle, &bih, sizeof(bih), &dwRead, NULL);
::CloseHandle(file_handle);
SetDlgItemInt(IDC_WIDTH, bih.biWidth);
SetDlgItemInt(IDC_HEIGHT, bih.biHeight);
SetDlgItemInt(IDC_HORRES, ::MulDiv(bih.biXPelsPerMeter, 254, 10000));
SetDlgItemInt(IDC_VERTRES, ::MulDiv(bih.biYPelsPerMeter, 254, 10000));
SetDlgItemInt(IDC_BITDEPTH, bih.biBitCount);
switch (bih.biCompression) {
case BI_RLE4:
case BI_RLE8:
compression_text = L"RLE";
break;
case BI_BITFIELDS:
compression_text = L"Uncompressed with bitfields";
break;
case BI_JPEG:
case BI_PNG:
compression_text = L"Unknown";
break;
}
SetDlgItemText(IDC_COMPRESSION, compression_text);
}
} else { // Must be pasted from the clipboard.
ATLASSERT(!bmp_.IsNull());
BITMAP bitmap = { 0 };
bool result = bmp_.GetBitmap(bitmap);
ATLASSERT(result);
if (result) {
CClientDC dc(NULL);
SetDlgItemInt(IDC_WIDTH, bitmap.bmWidth);
SetDlgItemInt(IDC_HEIGHT, bitmap.bmHeight);
// Should we use screen resolution here???
SetDlgItemInt(IDC_HORRES, dc.GetDeviceCaps(LOGPIXELSX));
SetDlgItemInt(IDC_VERTRES, dc.GetDeviceCaps(LOGPIXELSX));
SetDlgItemInt(IDC_BITDEPTH, bitmap.bmBitsPixel);
SetDlgItemText(IDC_COMPRESSION, compression_text);
}
}
return TRUE;
}
CBitmapHandle bmp_;
wchar_t* file_name_;
};
// Screen properties.
class CPageThree : public CPropertyPageImpl<CPageThree> {
public:
enum { IDD = IDD_PROP_PAGE3 };
BEGIN_MSG_MAP(CPageThree)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
CHAIN_MSG_MAP(CPropertyPageImpl<CPageThree>)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*message*/, WPARAM /*wparam*/, LPARAM /*lparam*/,
BOOL& /*handled*/) {
// Get and set screen properties.
CClientDC dc(NULL);
SetDlgItemInt(IDC_WIDTH, dc.GetDeviceCaps(HORZRES));
SetDlgItemInt(IDC_HEIGHT, dc.GetDeviceCaps(VERTRES));
SetDlgItemInt(IDC_HORRES, dc.GetDeviceCaps(LOGPIXELSX));
SetDlgItemInt(IDC_VERTRES, dc.GetDeviceCaps(LOGPIXELSY));
SetDlgItemInt(IDC_BITDEPTH, dc.GetDeviceCaps(BITSPIXEL));
return TRUE;
}
};
// TODO(fbachard): Frame properties only work for images, so
// this tab is removed until movie frame properties can be
// added.
class CBmpProperties : public CPropertySheetImpl<CBmpProperties> {
public:
CBmpProperties() {
m_psh.dwFlags |= PSH_NOAPPLYNOW;
AddPage(page1_);
// AddPage(page2_); // Not implemented for movies yet.
AddPage(page3_);
SetActivePage(0);
SetTitle(L"Movie Properties");
}
void SetFileInfo(wchar_t* file_path, HBITMAP bitmap) {
page1_.file_name_ = file_path;
page2_.file_name_ = file_path;
page2_.bmp_ = bitmap;
}
BEGIN_MSG_MAP(CBmpProperties)
CHAIN_MSG_MAP(CPropertySheetImpl<CBmpProperties>)
END_MSG_MAP()
CPageOne page1_;
CPageTwo page2_;
CPageThree page3_;
};
#endif // MEDIA_TOOLS_PLAYER_WTL_PROPS_H_
|