📄 interface.cpp
字号:
/*****************************************************************************
*
* 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: interface.c 624 2006-02-01 17:48:42Z picard $
*
* The Core Pocket Media Player
* Copyright (c) 2004-2005 Gabor Kovacs
*
****************************************************************************/
/*
注: 要注意LIB的链接顺序, 先链MFC的库,再链CRT的库
在项目设置中,先省略库coredll.lib uafxwced.lib
然后在Object/Lib中按顺序加入:uafxwced.lib coredll.lib
否则会出现new/delete的链接错误.
*/
//#include <afx.h>
#ifdef __cplusplus
extern "C"
{
#endif
#include "../../common/common.h"
#include "../win.h"
#include "interface.h"
#include "resource.h"
#include "openfile_win32.h"
#include "../about.h"
#include "../benchresult.h"
#include "../mediainfo.h"
#include "../settings.h"
#include "playlst.h"
#include "../skin.h"
#include "../../config.h"
/////////////////////////////////
#ifdef __cplusplus
}
#endif
//add by zy
#include "../inicode.h"
#include "cimage.h"
#include "../QSkinButton.h"
#include "../QSkinSlider.h"
#include "../QSkinListBox.h"
#include "../Globals.h"
//#include "OpenVideoDlg.h"
#define CORETHEQUE_UI_ID FOURCC('C','T','Q','U')
#if defined(TARGET_WINCE) || defined(TARGET_WIN32)
#ifndef STRICT
#define STRICT
#endif
#include <windows.h>
#if _MSC_VER > 1000
#pragma warning(disable : 4201)
#endif
#include <commctrl.h>
#define REG_INITING 0x2400
#define TIMER_CLIPPING 500
#define TIMER_INITING 501
#define TIMER_SLEEP 502
#define TIMER_KEYINSEEK 503
#define TIMER_SLIDERINSEEK 504
#define TIMER_SLIDERINVOL 505
#define TIMER_CLIPPING2 506
#define TIMER_TITLESCROLL 507
#define SLIDERINSEEK_CYCLE 250
#define SLIDERINVOL_CYCLE 100
#define KEYINSEEK_START 1000
#define KEYINSEEK_REPEAT 500
#define CLIPPING_CYCLE 200
#define INITING_CYCLE 3000
#define SLEEP_CYCLE 5000
#define CLIPPING2_CYCLE 200
#define TITLESCROLL_CYCLE 150
#define TITLESCROLL_WAIT (4000/TITLESCROLL_CYCLE)
#define TRACKMAX 30000
#define TRACKHEIGHT 16
#define TRACKTHUMB 12
#define TITLEHEIGHT 16
#define TITLEFONT 11
#define VOLMINWIDTH 35
#define VOLTHUMB 12
#define IF_AUDIO 50000
#define IF_VIDEO 51000
#define IF_VIDEOACCEL 52000
#define IF_CHAPTER 53000
#define IF_STREAM_AUDIO 54000
#define IF_STREAM_VIDEO 55000
#define IF_STREAM_SUBTITLE 56000
static int HotKey[] =
{
IF_FILE_OPENFILE,
IF_FILE_PLAYLIST,
IF_PLAY,
IF_PLAYPAUSE,
IF_PLAY_FULLSCREEN,
IF_STOP,
IF_MOVE_FFWD,
IF_MOVE_BACK,
IF_NEXT,
IF_PREV,
IF_PREV_SMART,
IF_NEXT2,
IF_PREV_SMART2,
IF_FASTFORWARD,
IF_OPTIONS_VOLUME_UP,
IF_OPTIONS_VOLUME_DOWN,
IF_OPTIONS_VOLUME_UP_FINE,
IF_OPTIONS_VOLUME_DOWN_FINE,
IF_OPTIONS_MUTE,
IF_OPTIONS_EQUALIZER,
IF_OPTIONS_FULLSCREEN,
IF_OPTIONS_ZOOM_FIT,
IF_OPTIONS_ZOOM_IN,
IF_OPTIONS_ZOOM_OUT,
IF_OPTIONS_ROTATE,
IF_OPTIONS_BRIGHTNESS_UP,
IF_OPTIONS_BRIGHTNESS_DOWN,
IF_OPTIONS_CONTRAST_UP,
IF_OPTIONS_CONTRAST_DOWN,
IF_OPTIONS_SATURATION_UP,
IF_OPTIONS_SATURATION_DOWN,
IF_OPTIONS_TOGGLE_VIDEO,
IF_OPTIONS_TOGGLE_AUDIO,
//!SUBTITLE IF_OPTIONS_TOGGLE_SUBTITLE,
IF_OPTIONS_AUDIO_STEREO_TOGGLE,
IF_OPTIONS_SCREEN,
IF_FILE_EXIT,
IF_HIDE
};
#define HOTKEYCOUNT (sizeof(HotKey)/sizeof(int))
#define MAX_SRC_IMAGES 6 //位图总数,包括掩码位图,other图
CImage m_imgState[MAX_SRC_IMAGES]; //Normal,Hilight,Down和Disabled状态
CImage m_imgDispAreaBg;
CIniCode g_ini;
CIniCode g_aSkin;
#define MAX_BUTTONS 17 //18
CQSkinButton ga_SkinBtns[MAX_BUTTONS];
#define IDC_BUTTON_BASE 0x600 //按钮的起始ID
#define IDC_LIST_PLAYLIST 0x700 //播放列表的ID
CQSkinSlider g_TrackSlider;
CQSkinSlider g_VolSlider;
CQSkinListBox g_PlayListbox;
BTN_INFO ga_ButtonInfos[] = {
{_T("IDW_MAIN_PLAYPAUSE"), IF_PLAYPAUSE, 1}, //{_T("IDW_MAIN_PLAYPAUSE"), IF_PLAY, 1},
//{_T("IDW_MAIN_PAUSE"), IF_PLAYPAUSE, 1},
{_T("IDW_MAIN_FULLSCREEN"), IF_OPTIONS_FULLSCREEN, 1},
{_T("IDW_MAIN_SELFILES"), IF_FILE_OPENFILE, 0},
{_T("IDW_MAIN_PREV"), IF_PREV, 0},
{_T("IDW_MAIN_NEXT"), IF_NEXT, 0},
{_T("IDW_MAIN_CLOSE"), IF_FILE_EXIT, 0},
{_T("IDW_MAIN_PLAYLIST"), IF_FILE_PLAYLIST, 0},
{_T("IDW_MAIN_MUTE"), IF_OPTIONS_MUTE, 1},
{_T("IDW_MAIN_STOP"), IF_STOP, 0},
{_T("IDW_MAIN_SHUFFLE"), IF_OPTIONS_SHUFFLE, 1}, //{_T("IDW_MAIN_SHUFFLE"), IF_SHUFFLE, 1},
{_T("IDW_MAIN_REPEAT"), IF_OPTIONS_REPEAT, 1},//{_T("IDW_MAIN_REPEAT"), IF_REPEAT, 1},
{_T("IDW_MAIN_FASTFORWARD"), IF_MOVE_FFWD, 0},//{_T("IDW_MAIN_FASTFORWARD"), IF_FASTFORWARD, 1},
{_T("IDW_MAIN_MOVEBACK"), IF_MOVE_BACK, 0},
{_T("IDW_MAIN_HIDE"), IF_HIDE, 0},
//
{_T("IDW_PLAYLIST_UP"), IF_PLAYLIST_UP, 0},
{_T("IDW_PLAYLIST_DOWN"), IF_PLAYLIST_DOWN, 0},
{_T("IDW_PLAYLIST_REMOVE"), IF_PLAYLIST_REMOVE, 0},
};
//取索引号
static int GetButtonInfoIndex( UINT uCmdID ) {
for( int n=0; n<MAX_BUTTONS; n++ ) {
if( ga_ButtonInfos[n].uCmdID==uCmdID )
break;
}
if( n>=MAX_BUTTONS ) {
return -1;
}
return n;
}
typedef struct intface
{
win Win;
DWORD ThreadId;
player* Player; //播放内核
node* Color;
node* Equalizer;
WNDPROC DefTrackProc;
WNDPROC DefVolProc;
HWND WndTrack; //进度条
HWND WndTitle; //标题条
HWND WndVol; //音量条
HWND WndVolBack; //音量条的底. 为什么要一个底?
WNDPROC DefPlayListProc;
HWND WndPlayList; //播放列表子窗口
HFONT PLFont;
int PLFontSize;
HBRUSH PLBrush;
rgbval_t PLFace;
rgbval_t PLText;
RECT rtPlayList; //播放列表位置
BOOL PLInUpdate; //正在更新播放列表
int TrackThumb;
RECT ClientRect;
rect SkinViewport;
rect SkinArea;
rect Viewport; //播放图像的区域?
int InSkin;
bool_t InVol;
bool_t InSeek;
bool_t Capture;
bool_t ForceFullScreen;
bool_t TrackBar; //是否显示播放进度条
bool_t TitleBar; //是否显示标题
bool_t TaskBar; //是否显示任务条
bool_t Buttons; //是否显示工具条按钮
bool_t Focus;
bool_t Clipping;
bool_t Overlap;
bool_t VolResizeNeeded;
bool_t VolResizeNeeded2;
bool_t Exited;
POINT Offset;
bool_t Bench;
bool_t Wait;
bool_t CmdLineMode;
int Vol;
int HotKey[HOTKEYCOUNT];
// refresh states
int TrackSetPos;
int TrackPos;
bool_t Play;
bool_t FFwd;
bool_t FullScreen;
bool_t Mute;
HFONT TitleFont;
int TitleFontSize;
tick_t TitleTime; //已播放时间
int TitleTimeWidth;
int TitleNameWidth;
int TitleNameSize;
int TitleNameOffset;
int ScrollMode;
bool_t UpdateScroll;
int TitleDurWidth;
int TitleBorder;
int TitleTop;
int TitleWidth;
int TitleHeight;
HBRUSH TitleBrush;
rgbval_t TitleFace;
rgbval_t TitleText;
tchar_t TitleName[256]; //标题文字
tchar_t TitleDur[32]; //媒体总时间
int MenuPreAmp;
int MenuStreams;
int MenuAStream;
int MenuVStream;
int MenuSubStream;
array VOutput;
array AOutput;
bool_t AllKeys;
bool_t AllKeysWarning;
int SkinNo;
skin Skin[MAX_SKIN];
tchar_t SkinPath[MAXPATH];
//add by zy
CImage *m_pimgState[MAX_SRC_IMAGES]; //Normal,Hilight,Down和Disabled状态,掩码图
CImage *m_pimgDispAreaBg; //播放区背景图
CIniCode *pIni; //此结构中不能直接放对象实体
CIniCode *paSkin;
RECT DispAreaRect; //图片在此区域显示
WNDPROC DefQSkinSliderProc;
CQSkinButton *ga_pSkinBtns[MAX_BUTTONS]; //按钮指针
RECT rtTrack; //进度条位置
RECT rtTitle; //标题条位置
RECT rtVol; //音量条位置
CQSkinSlider *pTrackSlider;
CQSkinSlider *pVolSlider;
CQSkinListBox *pPlayListbox;
} intface;
//extern void GetModulePath(tchar_t* Path,const tchar_t* Module);
void GetModulePath(tchar_t* Path,const tchar_t* Module)
{
tchar_t* s;
HANDLE Handle = NULL;
if (Module)
Handle = GetModuleHandle(Module);
GetModuleFileName( (HINSTANCE)Handle,Path,MAXPATH);
s = tcsrchr(Path,'\\');
if (s) s[1]=0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//播放列表
#define MSG_PLAYER2 WM_APP + 0x300
//更新列表的显示
static void UpdatePlayList(intface* p)
{
tchar_t s[256];
// tchar_t s2[256];
int i;
int Count=0;
int Current = -1;
p->Player->Get(p->Player,PLAYER_LIST_COUNT,&Count,sizeof(int));
p->Player->Get(p->Player,PLAYER_LIST_CURRENT,&Current,sizeof(int));
i = ListBox_GetCount(p->WndPlayList);
while (i > Count)
ListBox_DeleteString(p->WndPlayList,--i);
// Item.mask=LVIF_TEXT;
// Item.pszText=T("");
// Item.cchTextMax=1;
// Item.iSubItem=0;
ListBox_ResetContent(p->WndPlayList);
for (i=0;i<Count;++i) {
s[0] = 0;
p->Player->Get(p->Player,PLAYER_LIST_AUTOTITLE+i,s,sizeof(s));
ListBox_AddString(p->WndPlayList,s);
}
if( Current>=0 ) {
//ListBox_SetSel( p->WndPlayList, TRUE, Current );
ListBox_SetCurSel( p->WndPlayList, Current );
}
}
//窗口函数
LRESULT CALLBACK PlayListWndProc(HWND WndPlayList, UINT Msg, WPARAM wParam, LPARAM lParam)
{
intface* p = (intface*) WinGetObject(WndPlayList); //因为p->Win是p的第一项?
switch (Msg) {
case WM_SETFOCUS:
SendMessage( (HWND)p->Win.Wnd, Msg, wParam, lParam );
break;
case MSG_PLAYER2:
if (p->WndPlayList)
{
p->PLInUpdate = 1;
UpdatePlayList(p);
p->PLInUpdate = 0;
}
return 1;
default:
break;
//return 0;
}
return CallWindowProc(p->DefPlayListProc,WndPlayList,Msg,wParam,lParam);
}
static int PLListNotify(intface* p,int Param,int Param2)
{
if (p->Win.Wnd)
PostMessage((HWND)p->Win.Wnd,MSG_PLAYER2,0,0);
return ERR_NONE;
}
//通知播放器更新列表?
static void PLBeginUpdate(intface* p)
{
notify Notify;
Notify.Func = NULL;
Notify.This = 0;
p->Player->Set(p->Player,PLAYER_LIST_NOTIFY,&Notify,sizeof(Notify));
//p->Pos = GetPos(p);
p->PLInUpdate = 1;
}
static void PLEndUpdate(intface* p)
{
// int n;
notify Notify;
Notify.Func = (notifyfunc)PLListNotify;
Notify.This = p;
p->Player->Set(p->Player,PLAYER_LIST_NOTIFY,&Notify,sizeof(Notify));
UpdatePlayList(p);
//设当前项
// for (n=0;n<ListView_GetItemCount(p->WndList);++n)
// ListView_SetItemState(p->WndList,n,n==p->Pos?LVIS_FOCUSED|LVIS_SELECTED:0,LVIS_FOCUSED|LVIS_SELECTED);
// if (p->Pos>=n || p->Pos<0) {
// ListView_SetItemState(p->WndList,0,LVIS_FOCUSED,LVIS_FOCUSED);
// p->Pos = 0;
// }
// ListView_EnsureVisible(p->WndList,p->Pos,TRUE);
p->PLInUpdate = 0;
}
static void PLPlay(intface* p, int i)
{
bool_t b;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -