📄 win32preferencewindow.cpp
字号:
{
m_proposedValues.logPerformance = false;
}
if(m_proposedValues != m_currentValues)
{
PropSheet_Changed(GetParent(hwnd), hwnd);
}
else
{
PropSheet_UnChanged(GetParent(hwnd), hwnd);
}
break;
}
case IDC_LOGMAIN:
{
if(Button_GetCheck(hwndLogMain) == BST_CHECKED)
{
m_proposedValues.logMain = true;
}
else
{
m_proposedValues.logMain = false;
}
if(m_proposedValues != m_currentValues)
{
PropSheet_Changed(GetParent(hwnd), hwnd);
}
else
{
PropSheet_UnChanged(GetParent(hwnd), hwnd);
}
break;
}
}
break;
}
case WM_NOTIFY:
{
NMHDR* notify = (NMHDR*)lParam;
switch(notify->code)
{
case PSN_SETACTIVE:
{
break;
}
case PSN_APPLY:
{
SavePrefsValues(prefs, &m_proposedValues);
break;
}
case PSN_KILLACTIVE:
{
break;
}
case PSN_RESET:
{
SavePrefsValues(prefs, &m_originalValues);
break;
}
}
break;
}
}
return result;
}
bool Win32PreferenceWindow::PrefAboutProc(HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
bool result = false;
static PROPSHEETPAGE* psp = NULL;
static Preferences* prefs = NULL;
switch(msg)
{
case WM_INITDIALOG:
{
// remember these for later...
psp = (PROPSHEETPAGE*)lParam;
prefs = (Preferences*)psp->lParam;
break;
}
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)lParam;
UINT ctrlId = wParam;
HFONT font, oldFont;
font = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
oldFont = (HFONT)SelectObject(dis->hDC, font);
RECT clientRect;
GetClientRect(dis->hwndItem, &clientRect);
switch(ctrlId)
{
case IDC_APP:
{
DrawText(dis->hDC,
BRANDING,
strlen(BRANDING),
&clientRect,
DT_CENTER|DT_SINGLELINE);
break;
}
case IDC_VERSION:
{
char version[32];
sprintf(version, "version %s", BRANDING_VERSION);
DrawText(dis->hDC,
version,
strlen(version),
&clientRect,
DT_CENTER|DT_SINGLELINE);
break;
}
case IDC_BASED_ON_FREEAMP:
{
if(strcmp(BRANDING, "FreeAmp"))
{
const char* text = "(based on FreeAmp)";
DrawText(dis->hDC,
text,
strlen(text),
&clientRect,
DT_CENTER|DT_SINGLELINE);
}
break;
}
case IDC_CREDIT:
{
const char* credit1 =
"FreeAmp is an Open Source effort to build the best "
"digital audio player available. In the interest of "
"supporting the free software community, while at "
"the same time fostering the growth of the online "
"delivery of music, EMusic.com is funding both the "
"FreeAmp.org domain and the efforts of the FreeAmp "
"team. The FreeAmp team consists of: Mark B. Elrod, "
"Robert Kaye, Isaac Richards, Brett Thomas, and "
"Jason Woodward.";
const char* credit2 =
"Other people have also contributed to FreeAmp:";
const char* credit3 =
"William Bull, Alan Cutter, Gabor Fleischer, "
"Jean-Michel HERVE, Hiromasa Kato, Michael Bruun "
"Petersen, Sylvain Rebaud, The Snowblind Alliance, "
"Tom Spindler, and Valters Vingolds.";
const char* credit4 =
"FreeAmp is being released under the terms of the "
"GPL. As is provided by the GPL, all of EMusic.com's "
"and your efforts toward FreeAmp will be released "
"back to the community at large.";
RECT halfHeightRect = clientRect;
int halfHeight = DrawText(
dis->hDC,
credit1,
strlen(credit1),
&halfHeightRect,
DT_LEFT|DT_SINGLELINE|DT_CALCRECT)/3;
int height;
height = DrawText(
dis->hDC,
credit1,
strlen(credit1),
&clientRect,
DT_LEFT|DT_WORDBREAK);
clientRect.top += height + halfHeight;
height = DrawText(
dis->hDC,
credit2,
strlen(credit2),
&clientRect,
DT_LEFT|DT_WORDBREAK);
clientRect.top += height + halfHeight;
height = DrawText(
dis->hDC,
credit3,
strlen(credit3),
&clientRect,
DT_LEFT|DT_WORDBREAK);
clientRect.top += height + halfHeight;
height = DrawText(
dis->hDC,
credit4,
strlen(credit4),
&clientRect,
DT_LEFT|DT_WORDBREAK);
break;
}
}
SelectObject(dis->hDC, oldFont);
DeleteObject(font);
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_GOTOFREEAMP:
{
ShellExecute( hwnd,
"open",
"http://www.freeamp.org/",
NULL,
NULL,
SW_SHOWNORMAL);
break;
}
case IDC_GOTOEMUSIC:
{
ShellExecute( hwnd,
"open",
"http://www.emusic.com/",
NULL,
NULL,
SW_SHOWNORMAL);
break;
}
}
break;
}
case WM_HELP:
{
LaunchHelp(hwnd, Preferences_About);
break;
}
case WM_NOTIFY:
{
NMHDR* notify = (NMHDR*)lParam;
switch(notify->code)
{
case PSN_HELP:
{
LaunchHelp(hwnd, Preferences_About);
break;
}
case PSN_SETACTIVE:
{
break;
}
case PSN_APPLY:
{
SavePrefsValues(prefs, &m_proposedValues);
break;
}
case PSN_KILLACTIVE:
{
break;
}
case PSN_RESET:
{
SavePrefsValues(prefs, &m_originalValues);
break;
}
}
break;
}
}
return result;
}
void Win32PreferenceWindow::LoadThemeListBox(HWND hwnd)
{
map<string, string>::iterator i;
//m_pThemeMan->GetCurrentTheme(m_proposedValues.currentTheme);
m_oThemeList.clear();
SendDlgItemMessage(hwnd, IDC_THEMELISTBOX, LB_RESETCONTENT, 0, 0);
m_pThemeMan->GetThemeList(m_oThemeList);
for(i = m_oThemeList.begin(); i != m_oThemeList.end(); i++)
{
int index;
index = SendDlgItemMessage(hwnd, IDC_THEMELISTBOX, LB_ADDSTRING,
0, (LPARAM)(*i).first.c_str());
if ((*i).first == m_proposedValues.currentTheme)
SendDlgItemMessage(hwnd, IDC_THEMELISTBOX, LB_SETCURSEL, index, 0);
}
EnableWindow(GetDlgItem(hwnd, IDC_DELETETHEME), 0);
}
bool Win32PreferenceWindow::PrefThemeProc(HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
bool result = false;
static PROPSHEETPAGE* psp = NULL;
static Preferences* prefs = NULL;
switch(msg)
{
case WM_INITDIALOG:
{
// remember these for later...
psp = (PROPSHEETPAGE*)lParam;
prefs = (Preferences*)psp->lParam;
LoadThemeListBox(hwnd);
SetFocus(GetDlgItem(hwnd, IDC_THEMELISTBOX));
result = false;
break;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_THEMELISTBOX:
{
switch (HIWORD(wParam))
{
case LBN_SELCHANGE:
{
int iIndex;
char szCurSel[256];
iIndex = SendDlgItemMessage(hwnd, IDC_THEMELISTBOX,
LB_GETCURSEL, 0, 0);
if(iIndex >= 0)
{
SendDlgItemMessage(hwnd, IDC_THEMELISTBOX,
LB_GETTEXT, iIndex,
(LPARAM)szCurSel);
if (strcasecmp(szCurSel, "freeamp"))
EnableWindow(GetDlgItem(hwnd, IDC_DELETETHEME), 1);
else
EnableWindow(GetDlgItem(hwnd, IDC_DELETETHEME), 0);
m_proposedValues.currentTheme = string(szCurSel);
if(m_proposedValues != m_currentValues)
{
PropSheet_Changed(GetParent(hwnd), hwnd);
}
else
{
PropSheet_UnC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -