📄 skin.cpp
字号:
if(playback) {
/*
* Get some info about the
* window size and all.
*/
GetClientRect(hwnd, &clientRect);
sizeX = clientRect.right - clientRect.left;
sizeY = clientRect.bottom - clientRect.top;
hdc = GetDC(hwnd);
bdc = CreateCompatibleDC(hdc);
SelectObject(bdc, this->skin);
BitBlt(hdc, 0, 260 + (sizeY - DEFAULT_SKIN_HEIGHT), 200, 40, bdc, 0, 260, SRCCOPY);
char msg[10];
sprintf(msg, "%3.f FPS", playback->GetCurrentFps());
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 15, 280 + (sizeY - DEFAULT_SKIN_HEIGHT), msg, 7);
DeleteDC(bdc);
ReleaseDC(hwnd, hdc);
}
return 1;
}
/*
* Displays the buffering Bar
*
*
*/
int Skin::DrawTime(HWND hwnd, MediaPlayback *playback) {
HDC hdc, bdc, ddc;
int sizeX, sizeY;
RECT clientRect;
HFONT font, oldFont;
HBITMAP buff;
if(hwnd) {
/*
* Get some info about the
* window size and all.
*/
GetClientRect(hwnd, &clientRect);
sizeX = clientRect.right - clientRect.left;
sizeY = clientRect.bottom - clientRect.top;
hdc = GetDC(hwnd);
bdc = CreateCompatibleDC(hdc);
ddc = CreateCompatibleDC(hdc);
buff = CreateCompatibleBitmap(hdc, 106, 28);
SelectObject(bdc, this->skin);
SelectObject(ddc, buff);
BitBlt(ddc, 0, 0, 106, 28, bdc, 17, 280, SRCCOPY);
HFONT font, oldFont;
DWORD time, total;
char buffer[24];
DWORD h, m, s, ht, mt, st;
char *file;
if(strrchr(playback->GetFilename(), '\\') != NULL) {
file = strrchr(playback->GetFilename(), '\\')+1;
}
else {
file = playback->GetFilename();
}
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(ddc, (HGDIOBJ) font);
SetBkMode(ddc, TRANSPARENT);
TextOut(ddc, 3, 2, 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(ddc, 3, 16, buffer, strlen(buffer));
SelectObject(ddc, (HGDIOBJ) oldFont);
DeleteObject((HGDIOBJ)font);
BitBlt(hdc, 17, 280 + (sizeY - DEFAULT_SKIN_HEIGHT), 106, 28, ddc, 0, 0, SRCCOPY);
DeleteObject((HGDIOBJ) buff);
DeleteDC(bdc);
DeleteDC(ddc);
ReleaseDC(hwnd, hdc);
}
return 0;
}
int Skin::DrawBufferingState(HWND hwnd, DWORD state)
{
HDC hdc, bdc;
int sizeX, sizeY;
RECT clientRect;
HFONT font, oldFont;
if(hwnd && state > 0) {
/*
* Get some info about the
* window size and all.
*/
GetClientRect(hwnd, &clientRect);
sizeX = clientRect.right - clientRect.left;
sizeY = clientRect.bottom - clientRect.top;
hdc = GetDC(hwnd);
bdc = CreateCompatibleDC(hdc);
SelectObject(bdc, this->skin);
BitBlt(hdc, 17, 280 + (sizeY - DEFAULT_SKIN_HEIGHT), 106, 28, bdc, 17, 280, SRCCOPY);
font = CreateFont(12, 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);
TextOut(hdc, 20, 282 + (sizeY - DEFAULT_SKIN_HEIGHT), "Buffering...", 12);
SelectObject(hdc, (HGDIOBJ) oldFont);
DeleteObject((HGDIOBJ)font);
MoveToEx(hdc, 20, 295 + (sizeY - DEFAULT_SKIN_HEIGHT), NULL);
LineTo(hdc, 120, 295 + (sizeY - DEFAULT_SKIN_HEIGHT));
LineTo(hdc, 120, 305 + (sizeY - DEFAULT_SKIN_HEIGHT));
LineTo(hdc, 20, 305 + (sizeY - DEFAULT_SKIN_HEIGHT));
LineTo(hdc, 20, 295 + (sizeY - DEFAULT_SKIN_HEIGHT));
Rectangle(hdc, 20, 295 + (sizeY - DEFAULT_SKIN_HEIGHT), 20 + state, 305 + (sizeY - DEFAULT_SKIN_HEIGHT));
DeleteDC(bdc);
ReleaseDC(hwnd, hdc);
}
return 1;
}
/*
* Update the rects according
* to the new size of the window
*
*/
int Skin::UpdateSize(HWND hwnd)
{
int sizeX, sizeY;
RECT clientRect;
/*
* Get some info about the
* window size and all.
*/
GetClientRect(hwnd, &clientRect);
sizeX = clientRect.right - clientRect.left;
sizeY = clientRect.bottom - clientRect.top;
this->menuButton.left = 2;
this->menuButton.right = 14;
this->menuButton.top = 3;
this->menuButton.bottom = 14;
this->minimizeButton.left = 266 + (sizeX - DEFAULT_SKIN_WIDTH);
this->minimizeButton.right = 278 + (sizeX - DEFAULT_SKIN_WIDTH);
this->minimizeButton.top = 3;
this->minimizeButton.bottom = 14;
this->closeButton.left = 283 + (sizeX - DEFAULT_SKIN_WIDTH);
this->closeButton.right = 295 + (sizeX - DEFAULT_SKIN_WIDTH);
this->closeButton.top = 3;
this->closeButton.bottom = 14;
this->rewindButton.left = 15;
this->rewindButton.right = 15+29;
this->rewindButton.top = 343 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->rewindButton.bottom = 360 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->stopButton.left = 52;
this->stopButton.right = 52+29;
this->stopButton.top = 343 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->stopButton.bottom = 360 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->playButton.left = 89;
this->playButton.right = 89+29;
this->playButton.top = 343 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->playButton.bottom = 360 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->pauseButton.left = 126;
this->pauseButton.right = 126+29;
this->pauseButton.top = 343 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->pauseButton.bottom = 360 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->forwardButton.left = 163;
this->forwardButton.right = 192;
this->forwardButton.top = 343 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->forwardButton.bottom = 360 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->loadButton.left = 236 + (sizeX - DEFAULT_SKIN_WIDTH);
this->loadButton.right = 236 + 44 + (sizeX - DEFAULT_SKIN_WIDTH);
this->loadButton.top = 343 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->loadButton.bottom = 360 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->resizeButton.left = 282 + (sizeX - DEFAULT_SKIN_WIDTH);
this->resizeButton.right = 282 + 15 + (sizeX - DEFAULT_SKIN_WIDTH);
this->resizeButton.top = 357 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->resizeButton.bottom = 357 + 15 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->progressBar.left = 12;
this->progressBar.right = 281 + (sizeX - DEFAULT_SKIN_WIDTH);
this->progressBar.top = 325 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->progressBar.bottom = 332 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->volumeBar.left = 212 + (sizeX - DEFAULT_SKIN_WIDTH);
this->volumeBar.right = 273 + (sizeX - DEFAULT_SKIN_WIDTH);
this->volumeBar.top = 296 + (sizeY - DEFAULT_SKIN_HEIGHT);
this->volumeBar.bottom = 304 + (sizeY - DEFAULT_SKIN_HEIGHT);
SetVolume(hwnd, this->volume);
SetProgress(hwnd, this->progress);
return 1;
}
/*
* Updates special zones upon action
*
*/
int Skin::SetActionStart(HWND hwnd, int action)
{
HDC hdc, bdc;
hdc = GetDC(hwnd);
bdc = CreateCompatibleDC(hdc);
if(hdc == NULL || bdc == NULL) {
return 0;
}
SelectObject(bdc, this->controls);
switch(action) {
case ACTION_REWIND:
BitBlt(hdc, rewindButton.left, rewindButton.top, (rewindButton.right - rewindButton.left), (rewindButton.bottom - rewindButton.top),
bdc, 2, 26, SRCCOPY);
break;
case ACTION_STOP:
BitBlt(hdc, stopButton.left, stopButton.top, (stopButton.right - stopButton.left), (stopButton.bottom - stopButton.top),
bdc, 33, 26, SRCCOPY);
break;
case ACTION_PLAY:
BitBlt(hdc, playButton.left, playButton.top, (playButton.right - playButton.left), (playButton.bottom - playButton.top),
bdc, 64, 26, SRCCOPY);
break;
case ACTION_PAUSE:
BitBlt(hdc, pauseButton.left, pauseButton.top, (pauseButton.right - pauseButton.left), (pauseButton.bottom - pauseButton.top),
bdc, 95, 26, SRCCOPY);
break;
case ACTION_FORWARD:
BitBlt(hdc, forwardButton.left, forwardButton.top, (forwardButton.right - forwardButton.left), (forwardButton.bottom - forwardButton.top),
bdc, 126, 26, SRCCOPY);
break;
case ACTION_LOAD:
BitBlt(hdc, loadButton.left, loadButton.top, (loadButton.right - loadButton.left), (loadButton.bottom - loadButton.top),
bdc, 157, 26, SRCCOPY);
break;
default:
break;
}
DeleteDC(bdc);
ReleaseDC(hwnd, hdc);
return 1;
}
int Skin::SetActionEnd(HWND hwnd, int action)
{
HDC hdc, bdc;
hdc = GetDC(hwnd);
bdc = CreateCompatibleDC(hdc);
if(hdc == NULL || bdc == NULL) {
return 0;
}
SelectObject(bdc, this->skin);
switch(action) {
case ACTION_REWIND:
BitBlt(hdc, rewindButton.left, rewindButton.top, (rewindButton.right - rewindButton.left), (rewindButton.bottom - rewindButton.top),
bdc, 15, 343, SRCCOPY);
break;
case ACTION_STOP:
BitBlt(hdc, stopButton.left, stopButton.top, (stopButton.right - stopButton.left), (stopButton.bottom - stopButton.top),
bdc, 52, 343, SRCCOPY);
break;
case ACTION_PLAY:
BitBlt(hdc, playButton.left, playButton.top, (playButton.right - playButton.left), (playButton.bottom - playButton.top),
bdc, 89, 343, SRCCOPY);
break;
case ACTION_PAUSE:
BitBlt(hdc, pauseButton.left, pauseButton.top, (pauseButton.right - pauseButton.left), (pauseButton.bottom - pauseButton.top),
bdc, 126, 343, SRCCOPY);
break;
case ACTION_FORWARD:
BitBlt(hdc, forwardButton.left, forwardButton.top, (forwardButton.right - forwardButton.left), (forwardButton.bottom - forwardButton.top),
bdc, 163, 343, SRCCOPY);
break;
case ACTION_LOAD:
BitBlt(hdc, loadButton.left, loadButton.top, (loadButton.right - loadButton.left), (loadButton.bottom - loadButton.top),
bdc, 236, 343, SRCCOPY);
break;
default:
break;
}
DeleteDC(bdc);
ReleaseDC(hwnd, hdc);
return 1;
}
/*
* Returns the action corresponding
* to the given mouse click inside
* the skin
*
*/
int Skin::GetAction(int x, int y)
{
if(isInsideRect(x, y, this->menuButton))
return ACTION_MENU;
if(isInsideRect(x, y, this->minimizeButton))
return ACTION_MINIMIZE;
if(isInsideRect(x, y, this->closeButton))
return ACTION_CLOSE;
if(isInsideRect(x, y, this->rewindButton))
return ACTION_REWIND;
if(isInsideRect(x, y, this->stopButton))
return ACTION_STOP;
if(isInsideRect(x, y, this->playButton))
return ACTION_PLAY;
if(isInsideRect(x, y, this->pauseButton))
return ACTION_PAUSE;
if(isInsideRect(x, y, this->forwardButton))
return ACTION_FORWARD;
if(isInsideRect(x, y, this->loadButton))
return ACTION_LOAD;
if(isInsideRect(x, y, this->resizeButton))
return ACTION_RESIZE;
if(isInsideRect(x, y, this->volumeCursor))
return ACTION_VOLUME_CURSOR;
if(isInsideRect(x, y, this->progressCursor))
return ACTION_PROGRESS_CURSOR;
if(isInsideRect(x, y, this->volumeBar))
return ACTION_VOLUME_BAR;
if(isInsideRect(x, y, this->progressBar))
return ACTION_PROGRESS_BAR;
return ACTION_NONE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -