📄 skin.cpp
字号:
DeleteDC(bdc);
ReleaseDC(hwnd, hdc);
return 1;
}
int Skin::SetProgressValue(HWND hwnd, double progress)
{
int sizeX, sizeY;
RECT clientRect;
HDC hdc, bdc;
if(progress != this->progress) {
hdc = GetDC(this->hwnd);
bdc = CreateCompatibleDC(hdc);
if(hdc == NULL) {
return 0;
}
SelectObject(bdc, this->skin);
/*
* Get some info about the
* window size and all.
*/
GetClientRect(hwnd, &clientRect);
sizeX = clientRect.right - clientRect.left;
sizeY = clientRect.bottom - clientRect.top;
BitBlt(hdc, progressCursor.left, progressCursor.top,
(progressCursor.right - progressCursor.left),
(progressCursor.bottom - progressCursor.top),
bdc, 200, 321, SRCCOPY);
SetProgress(hwnd, progress);
/*
* The cursor
*/
SelectObject(bdc, this->controls);
BitBlt(hdc, progressCursor.left, progressCursor.top,
(progressCursor.right - progressCursor.left),
(progressCursor.bottom - progressCursor.top),
bdc, 2, 45, SRCCOPY);
DeleteDC(bdc);
ReleaseDC(hwnd, hdc);
}
return 1;
}
/*
* Calculates the video size
* and position on the hwnd
*/
RECT *Skin::GetVideoRect()
{
if(this->hwnd) {
GetClientRect(this->hwnd, &this->videoRect);
if(this->compactMode) {
return &this->videoRect;
}
else {
this->videoRect.left = 7;
this->videoRect.right -= 15;
this->videoRect.top = 22;
this->videoRect.bottom -= 115;
return &this->videoRect;
}
}
return &this->videoRect;
}
/*
* Set/Unset the compact mode
*/
int Skin::SetCompact(int compact)
{
this->compactMode = compact;
return 0;
}
/*
* Gives the Progress and Volume
*
*/
int Skin::GetProgress()
{
return (int) this->progress;
}
int Skin::GetVolume()
{
return this->volume;
}
/*
* Display : display the skin
* into a window
*
*/
Skin::Display(HWND hwnd, MediaPlayback *playback)
{
HDC hdc, bdc;
PAINTSTRUCT ps;
int sizeX, sizeY, i;
RECT clientRect;
HBRUSH brush, oldBrush;
/*
* Get some info about the
* window size and all.
*/
GetClientRect(hwnd, &clientRect);
sizeX = clientRect.right - clientRect.left;
sizeY = clientRect.bottom - clientRect.top;
this->hwnd = hwnd;
if(!playback->IsInFullscreen() || playback->desktopMode) {
hdc = BeginPaint(hwnd, &ps);
if(this->compactMode) {
/*
* Simply Draw the logo
*/
bdc = CreateCompatibleDC(hdc);
SelectObject(bdc, this->logo);
if(playback->IsOverlay()) {
brush = CreateSolidBrush(DD_OVERLAY_COLORREF);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 0, 0, sizeX, sizeY);
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
}
else {
if(!playback->IsPlaying()) {
brush = CreateSolidBrush(this->skinColor);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 0, 0, DEFAULT_SKIN_WIDTH + (sizeX - DEFAULT_SKIN_WIDTH),
DEFAULT_SKIN_HEIGHT + (sizeY - DEFAULT_SKIN_HEIGHT));
SelectObject(bdc, this->logo);
if(sizeY > LOGO_HEIGHT)
BitBlt(hdc, (sizeX - LOGO_WIDTH)/2, (sizeY - LOGO_HEIGHT)/2, LOGO_WIDTH, LOGO_HEIGHT, bdc, 0, 0, SRCCOPY);
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
}
}
DeleteDC(bdc);
}
else {
/*
* Paint the normal skin
*/
bdc = CreateCompatibleDC(hdc);
SelectObject(bdc, this->skin);
if(hdc == NULL || bdc == NULL) {
return 0;
}
/*
* First blit the background
*/
/*
* Title
*/
BitBlt(hdc, 0, 0, 21, 22, bdc, 0, 0, SRCCOPY);
for(i = 0; i < (sizeX - DEFAULT_SKIN_WIDTH) / 2; i++) {
BitBlt(hdc, 21 + i, 0, 1, 22, bdc, 21, 0, SRCCOPY);
}
BitBlt(hdc, 21 + (sizeX - DEFAULT_SKIN_WIDTH) / 2, 0, 240, 22, bdc, 21, 0, SRCCOPY);
for(i = 0; i < (sizeX - DEFAULT_SKIN_WIDTH) / 2 + ((sizeX - DEFAULT_SKIN_WIDTH) % 2); i++) {
BitBlt(hdc, 261 + (sizeX - DEFAULT_SKIN_WIDTH) / 2 + i, 0, 1, 22, bdc, 261, 0, SRCCOPY);
}
BitBlt(hdc, 261 + (sizeX - DEFAULT_SKIN_WIDTH), 0, 39, 22, bdc, 261, 0, SRCCOPY);
/*
* The play Area
*
*/
for(i=0; i < 238 + (sizeY - DEFAULT_SKIN_HEIGHT); i++) {
BitBlt(hdc, 0, 22 + i, 7, 1, bdc, 0, 22, SRCCOPY);
BitBlt(hdc, 292 + (sizeX - DEFAULT_SKIN_WIDTH), 22 + i, 8, 1, bdc, 292, 22, SRCCOPY);
}
/*
* The bottom
*/
BitBlt(hdc, 0, 260 + (sizeY - DEFAULT_SKIN_HEIGHT), 200, 115, bdc, 0, 260, SRCCOPY);
BitBlt(hdc, 200 + (sizeX - DEFAULT_SKIN_WIDTH), 260 + (sizeY - DEFAULT_SKIN_HEIGHT), 100, 115, bdc, 200, 260, SRCCOPY);
SelectObject(bdc, this->bottom);
if(sizeX - DEFAULT_SKIN_WIDTH > 0) {
int pass = (sizeX - DEFAULT_SKIN_WIDTH) / 256;
for(i=0; i < pass; i++) {
BitBlt(hdc, 200 + i*256, 260 + (sizeY - DEFAULT_SKIN_HEIGHT), 256, 115, bdc, 0, 0, SRCCOPY);
}
BitBlt(hdc, 200 + pass*256, 260 + (sizeY - DEFAULT_SKIN_HEIGHT), (sizeX - DEFAULT_SKIN_WIDTH) - pass*256, 115, bdc, 0, 0, SRCCOPY);
}
/*
* Some info
*/
if(playback->HasVideo() && !this->compactMode) {
HFONT font, oldFont;
DWORD time, total;
char buffer[24];
DWORD h, m, s, ht, mt, st;
char *file;
font = CreateFont(13, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
oldFont = (HFONT) SelectObject(hdc, (HGDIOBJ) font);
SetBkMode(hdc, TRANSPARENT);
if(strrchr(playback->GetFilename(), '\\') != NULL) {
file = strrchr(playback->GetFilename(), '\\')+1;
}
else {
file = playback->GetFilename();
}
TextOut(hdc, 20, 282 + (sizeY - DEFAULT_SKIN_HEIGHT), file, strlen(file));
time = playback->GetActualTime();
total = playback->GetTotalTime();
h = time / 3600;
m = (time - h*3600) / 60;
s = (time - h*3600 - m*60);
ht = total / 3600;
mt = (total - ht*3600) / 60;
st = (total - ht*3600 - mt*60);
sprintf(buffer, "%.2d:%.2d:%.2d / %.2d:%.2d:%.2d", h, m, s, ht, mt, st);
TextOut(hdc, 20, 296 + (sizeY - DEFAULT_SKIN_HEIGHT), buffer, strlen(buffer));
SelectObject(hdc, (HGDIOBJ) oldFont);
DeleteObject((HGDIOBJ)font);
}
/*
* Now the controls
*
*/
SelectObject(bdc, this->controls);
BitBlt(hdc, progressCursor.left, progressCursor.top, (progressCursor.right - progressCursor.left), (progressCursor.bottom - progressCursor.top),
bdc, 2, 45, SRCCOPY);
BitBlt(hdc, volumeCursor.left, volumeCursor.top, (volumeCursor.right - volumeCursor.left), (volumeCursor.bottom - volumeCursor.top),
bdc, 32, 45, SRCCOPY);
/*
* And the time info
*/
if(!playback->desktopMode) {
if(!playback->IsPlaying() && !playback->IsPaused()) {
brush = CreateSolidBrush(this->skinColor);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 7, 22, 292 + (sizeX - DEFAULT_SKIN_WIDTH), 260 + (sizeY - DEFAULT_SKIN_HEIGHT));
SelectObject(bdc, this->logo);
if(sizeY > LOGO_HEIGHT + 135 + 22)
BitBlt(hdc, (sizeX - LOGO_WIDTH)/2, 50 + (sizeY - DEFAULT_SKIN_HEIGHT)/2, LOGO_WIDTH, LOGO_HEIGHT, bdc, 0, 0, SRCCOPY);
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
}
else {
if(playback->IsOverlay()) {
brush = CreateSolidBrush(DD_OVERLAY_COLORREF);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 7, 22, 292 + (sizeX - DEFAULT_SKIN_WIDTH), 260 + (sizeY - DEFAULT_SKIN_HEIGHT));
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
}
}
if(playback->IsPaused()) {
if(playback->IsOverlay()) {
brush = CreateSolidBrush(DD_OVERLAY_COLORREF);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 7, 22, 292 + (sizeX - DEFAULT_SKIN_WIDTH), 260 + (sizeY - DEFAULT_SKIN_HEIGHT));
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
}
else {
brush = CreateSolidBrush(0);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 7, 22, 292 + (sizeX - DEFAULT_SKIN_WIDTH), 260 + (sizeY - DEFAULT_SKIN_HEIGHT));
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
}
}
}
DeleteDC(bdc);
}
EndPaint(hwnd, &ps);
}
else {
if(playback->IsOverlay() && playback->HasVideo()) {
RECT *fullRects;
fullRects = playback->videoRenderer->GetFullscreenRects();
if(fullRects != NULL) {
GetClientRect(hwnd, &clientRect);
hdc = BeginPaint(hwnd, &ps);
brush = CreateSolidBrush(0);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, fullRects[0].left, fullRects[0].top, fullRects[0].left + fullRects[0].right + 50, fullRects[0].top + fullRects[0].bottom);
Rectangle(hdc, fullRects[2].left, fullRects[2].top, fullRects[2].left + fullRects[2].right + 50, fullRects[2].top + fullRects[2].bottom + 50);
DeleteObject((HGDIOBJ) brush);
brush = CreateSolidBrush(DD_OVERLAY_COLORREF_FULLSCREEN);
(HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, fullRects[1].left, fullRects[1].top, fullRects[1].left + fullRects[1].right + 50, fullRects[1].top + fullRects[1].bottom);
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
EndPaint(hwnd, &ps);
}
}
else {
if(playback->HasVideo()) {
hdc = BeginPaint(hwnd, &ps);
brush = CreateSolidBrush(0);
oldBrush = (HBRUSH) SelectObject(hdc, brush);
Rectangle(hdc, 0, 0, sizeX, sizeY);
SelectObject(hdc, oldBrush);
DeleteObject((HGDIOBJ) brush);
EndPaint(hwnd, &ps);
}
}
}
return 1;
}
/*
* Display the FPS
*
*/
int Skin::DisplayFps(HWND hwnd, MediaPlayback *playback)
{
HDC hdc, bdc;
int sizeX, sizeY;
RECT clientRect;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -