📄 trackview.cpp
字号:
/*****************************************************************
|
| Xaudio Player for Windows CE
|
| (c) 1996-1998 MpegTV, LLC
| Author: Gilles Boccon-Gibod (gilles@mpegtv.com)
|
****************************************************************/
/*----------------------------------------------------------------------
| includes
+---------------------------------------------------------------------*/
#ifndef STRICT
#define STRICT
#endif
#include <windows.h>
#include "xaplayer.h"
#include "trackview.h"
#include "resource.h"
#include "ceutils.h"
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
const TCHAR XA_TRACKVIEW_CLASS_NAME[] = TEXT("Xaudio Track View");
const int XA_TRACKVIEW_TIMECODE_DIGIT_SPACING = 1;
const int XA_TRACKVIEW_STATE_SPACING = 4;
const int XA_TRACKVIEW_CHANNELS_SPACING = 4;
const int XA_TRACKVIEW_DURATION_DIGIT_SPACING = 1;
const int XA_TRACKVIEW_FREQUENCY_V_SPACING = 2;
const int XA_TRACKVIEW_FREQUENCY_DIGIT_SPACING = 1;
const int XA_TRACKVIEW_FREQUENCY_LABEL_SPACING = 2;
const int XA_TRACKVIEW_FREQUENCY_BITRATE_SPACING = 5;
const int XA_TRACKVIEW_BITRATE_V_SPACING = 2;
const int XA_TRACKVIEW_BITRATE_DIGIT_SPACING = 1;
const int XA_TRACKVIEW_BITRATE_LABEL_SPACING = 2;
/*----------------------------------------------------------------------
| TrackViewImage::LoadFromResource
+---------------------------------------------------------------------*/
void
TrackViewImage::LoadFromResource(HINSTANCE instance, LPCTSTR name)
{
m_Bitmap = LoadBitmap(instance, name);
BITMAP bitmap;
GetObject(m_Bitmap, sizeof(bitmap), &bitmap);
m_Bounds.left = 0;
m_Bounds.top = 0;
m_Bounds.right = bitmap.bmWidth;
m_Bounds.bottom = bitmap.bmHeight;
}
/*----------------------------------------------------------------------
| TrackViewImage::Paint
+---------------------------------------------------------------------*/
void
TrackViewImage::Paint(HDC source_dc, HDC dest_dc)
{
SelectObject(source_dc, m_Bitmap);
BitBlt(dest_dc,
m_Bounds.left,
m_Bounds.top,
m_Bounds.right-m_Bounds.left,
m_Bounds.bottom-m_Bounds.top,
source_dc, 0, 0, SRCCOPY);
}
/*----------------------------------------------------------------------
| TrackViewImage::Move
+---------------------------------------------------------------------*/
void
TrackViewImage::Move(int dx, int dy)
{
m_Bounds.left += dx;
m_Bounds.top += dy;
m_Bounds.right += dx;
m_Bounds.bottom += dy;
}
/*----------------------------------------------------------------------
| TrackViewPolyImage::LoadFromResource
+---------------------------------------------------------------------*/
void
TrackViewPolyImage::LoadFromResource(HINSTANCE instance, LPCTSTR name,
unsigned int nb_images)
{
m_Bitmap = LoadBitmap(instance, name);
BITMAP bitmap;
GetObject(m_Bitmap, sizeof(bitmap), &bitmap);
m_Width = bitmap.bmWidth/nb_images;
m_Bounds.left = 0;
m_Bounds.top = 0;
m_Bounds.right = m_Width;
m_Bounds.bottom = bitmap.bmHeight;
}
/*----------------------------------------------------------------------
| TrackViewPolyImage::Paint
+---------------------------------------------------------------------*/
void
TrackViewPolyImage::Paint(HDC source_dc, HDC dest_dc)
{
SelectObject(source_dc, m_Bitmap);
BitBlt(dest_dc,
m_Bounds.left,
m_Bounds.top,
m_Bounds.right-m_Bounds.left,
m_Bounds.bottom-m_Bounds.top,
source_dc, m_Index*m_Width, 0, SRCCOPY);
}
/*----------------------------------------------------------------------
| TrackViewNumberImage::LoadFromResource
+---------------------------------------------------------------------*/
void
TrackViewNumberImage::LoadFromResource(HINSTANCE instance, LPCTSTR name,
unsigned int nb_digits)
{
m_Bitmap = LoadBitmap(instance, name);
m_NbDigits = nb_digits;
BITMAP bitmap;
GetObject(m_Bitmap, sizeof(bitmap), &bitmap);
m_DigitWidth = bitmap.bmWidth/10;
m_Bounds.left = 0;
m_Bounds.top = 0;
m_Bounds.right = m_NbDigits*m_DigitWidth + (m_NbDigits-1)*m_DigitSpacing;
m_Bounds.bottom = bitmap.bmHeight;
}
/*----------------------------------------------------------------------
| TrackViewNumberImage::Paint
+---------------------------------------------------------------------*/
void
TrackViewNumberImage::Paint(HDC source_dc, HDC dest_dc)
{
int x = m_Bounds.left;
int height = m_Bounds.bottom-m_Bounds.top;
SelectObject(source_dc, m_Bitmap);
for (int i=0; i<m_NbDigits; i++) {
BitBlt(dest_dc,
x,
m_Bounds.top,
m_DigitWidth,
height,
source_dc, m_Indexes[i]*m_DigitWidth, 0, SRCCOPY);
x += m_DigitWidth + m_DigitSpacing;
}
}
/*----------------------------------------------------------------------
| TrackViewNumberImage::SetDigitSpacing
+---------------------------------------------------------------------*/
void
TrackViewNumberImage::SetDigitSpacing(unsigned int spacing)
{
m_DigitSpacing = spacing;
m_Bounds.right = m_Bounds.left +
m_NbDigits*m_DigitWidth + (m_NbDigits-1)*m_DigitSpacing;
}
/*----------------------------------------------------------------------
| TrackViewNumberImage::SetValue
+---------------------------------------------------------------------*/
void
TrackViewNumberImage::SetValue(unsigned int value)
{
for (int i=m_NbDigits-1; i>=0; i--) {
m_Indexes[i] = value%10;
value -= m_Indexes[i];
value /= 10;
}
}
/*----------------------------------------------------------------------
| TrackViewTimecodeImage::LoadFromResource
+---------------------------------------------------------------------*/
void
TrackViewTimecodeImage::LoadFromResource(HINSTANCE instance, LPCTSTR name)
{
m_Bitmap = LoadBitmap(instance, name);
m_NbDigits = 4;
BITMAP bitmap;
GetObject(m_Bitmap, sizeof(bitmap), &bitmap);
m_DigitWidth = (2*bitmap.bmWidth)/21;
m_ColonWidth = bitmap.bmWidth - (10*m_DigitWidth);
m_Bounds.left = 0;
m_Bounds.top = 0;
m_Bounds.right = m_NbDigits*(m_DigitWidth + m_DigitSpacing) + m_ColonWidth;
m_Bounds.bottom = bitmap.bmHeight;
}
/*----------------------------------------------------------------------
| TrackViewTimecodeImage::Paint
+---------------------------------------------------------------------*/
void
TrackViewTimecodeImage::Paint(HDC source_dc, HDC dest_dc)
{
int x = m_Bounds.left;
int height = m_Bounds.bottom-m_Bounds.top;
SelectObject(source_dc, m_Bitmap);
for (int i=0; i<4; i++) {
BitBlt(dest_dc,
x,
m_Bounds.top,
m_DigitWidth,
height,
source_dc, m_Indexes[i]*m_DigitWidth, 0, SRCCOPY);
x += m_DigitWidth + m_DigitSpacing;
if (i == 1) x += m_ColonWidth + m_DigitSpacing;
}
BitBlt(dest_dc,
m_Bounds.left + 2*(m_DigitWidth + m_DigitSpacing),
m_Bounds.top,
m_ColonWidth,
height,
source_dc, 10*m_DigitWidth, 0, SRCCOPY);
}
/*----------------------------------------------------------------------
| TrackViewTimecodeImage::SetDigitSpacing
+---------------------------------------------------------------------*/
void
TrackViewTimecodeImage::SetDigitSpacing(unsigned int spacing)
{
m_DigitSpacing = spacing;
m_Bounds.right = m_Bounds.left +
m_NbDigits*m_DigitWidth + m_NbDigits*m_DigitSpacing +
m_ColonWidth;
}
/*----------------------------------------------------------------------
| TrackViewTimecodeImage::SetValue
+---------------------------------------------------------------------*/
void
TrackViewTimecodeImage::SetValue(unsigned int minutes,
unsigned int seconds)
{
m_Indexes[0] = minutes/10;
m_Indexes[1] = minutes%10;
m_Indexes[2] = seconds/10;
m_Indexes[3] = seconds%10;
}
/*----------------------------------------------------------------------
| TrackViewTimecodeImage::SetValue
+---------------------------------------------------------------------*/
void
TrackViewTimecodeImage::SetValue(unsigned int seconds)
{
SetValue(seconds/60, seconds%60);
}
/*----------------------------------------------------------------------
| TrackViewWindowProc
+---------------------------------------------------------------------*/
LRESULT CALLBACK
TrackViewWindowProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
XA_HANDLE_WINDOW_MESSAGE(TrackView,
HandleWindowsMessage,
window,
message,
wparam,
lparam);
}
/*----------------------------------------------------------------------
| TrackView::TrackView
+---------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -