2011-08-28 10:58:26 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2011 Birunthan Mohanathas, Kimmo Pekkola
|
|
|
|
|
|
|
|
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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-08-28 10:58:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "Rainmeter.h"
|
|
|
|
#include "System.h"
|
|
|
|
#include "MeterWindow.h"
|
2011-11-10 18:31:01 +00:00
|
|
|
#include "TrayWindow.h"
|
2011-08-28 10:58:26 +00:00
|
|
|
#include "Measure.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "DialogAbout.h"
|
|
|
|
#include "../Version.h"
|
2014-02-11 19:17:05 +00:00
|
|
|
#include "../Common/Platform.h"
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
WINDOWPLACEMENT DialogAbout::c_WindowPlacement = {0};
|
2013-05-31 14:28:39 +00:00
|
|
|
DialogAbout* DialogAbout::c_Dialog = nullptr;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::DialogAbout() : Dialog()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Destructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::~DialogAbout()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
/*
|
|
|
|
** Opens the About dialog.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::Open(int tab)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
|
|
|
if (!c_Dialog)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
c_Dialog = new DialogAbout();
|
2012-12-13 09:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c_Dialog->ShowDialogWindow(
|
|
|
|
GetString(ID_STR_ABOUTRAINMETER),
|
|
|
|
0, 0, 400, 210,
|
|
|
|
DS_CENTER | WS_POPUP | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
|
2012-12-22 09:18:53 +00:00
|
|
|
WS_EX_APPWINDOW | WS_EX_CONTROLPARENT | ((*GetString(ID_STR_ISRTL) == L'1') ? WS_EX_LAYOUTRTL : 0),
|
2014-07-23 10:47:09 +00:00
|
|
|
Rainmeter::GetInstance().GetWindow());
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
// Fake WM_NOTIFY to change tab
|
|
|
|
NMHDR nm;
|
|
|
|
nm.code = TCN_SELCHANGE;
|
|
|
|
nm.idFrom = Id_Tab;
|
2012-12-13 10:11:27 +00:00
|
|
|
nm.hwndFrom = c_Dialog->GetControl(Id_Tab);
|
2012-12-13 09:12:25 +00:00
|
|
|
TabCtrl_SetCurSel(nm.hwndFrom, tab);
|
|
|
|
c_Dialog->OnNotify(0, (LPARAM)&nm);
|
|
|
|
}
|
|
|
|
|
2011-10-29 10:36:07 +00:00
|
|
|
/*
|
|
|
|
** Opens the About dialog by tab name.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::Open(const WCHAR* name)
|
2011-10-29 10:36:07 +00:00
|
|
|
{
|
|
|
|
int tab = 0;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
2012-02-20 17:27:00 +00:00
|
|
|
if (_wcsicmp(name, L"Skins") == 0 ||
|
|
|
|
_wcsicmp(name, L"Measures") == 0) // For backwards compatibility
|
2011-10-29 10:36:07 +00:00
|
|
|
{
|
|
|
|
tab = 1;
|
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(name, L"Plugins") == 0)
|
2011-10-29 10:36:07 +00:00
|
|
|
{
|
|
|
|
tab = 2;
|
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(name, L"Version") == 0)
|
2011-10-29 10:36:07 +00:00
|
|
|
{
|
|
|
|
tab = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Open(tab);
|
|
|
|
}
|
|
|
|
|
2011-09-08 17:05:48 +00:00
|
|
|
/*
|
|
|
|
** Shows log if dialog isn't already open.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::ShowAboutLog()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-08 15:37:33 +00:00
|
|
|
if (!c_Dialog)
|
|
|
|
{
|
2011-09-08 17:05:48 +00:00
|
|
|
Open();
|
2011-09-08 15:37:33 +00:00
|
|
|
}
|
2011-09-08 17:05:48 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
void DialogAbout::AddLogItem(Logger::Level level, LPCWSTR time, LPCWSTR source, LPCWSTR message)
|
2011-09-08 17:05:48 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
if (c_Dialog && c_Dialog->m_TabLog.IsInitialized())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
c_Dialog->m_TabLog.AddItem(level, time, source, message);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::UpdateSkins()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-02-20 17:27:00 +00:00
|
|
|
if (c_Dialog && c_Dialog->m_TabSkins.IsInitialized())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-02-20 17:27:00 +00:00
|
|
|
c_Dialog->m_TabSkins.UpdateSkinList();
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::UpdateMeasures(MeterWindow* meterWindow)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-02-20 17:27:00 +00:00
|
|
|
if (c_Dialog && c_Dialog->m_TabSkins.IsInitialized())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-02-20 17:27:00 +00:00
|
|
|
c_Dialog->m_TabSkins.UpdateMeasureList(meterWindow);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Dialog::Tab& DialogAbout::GetActiveTab()
|
2012-02-21 09:03:16 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
int sel = TabCtrl_GetCurSel(GetControl(Id_Tab));
|
2012-02-21 09:03:16 +00:00
|
|
|
if (sel == 0)
|
|
|
|
{
|
|
|
|
return m_TabLog;
|
|
|
|
}
|
|
|
|
else if (sel == 1)
|
|
|
|
{
|
|
|
|
return m_TabSkins;
|
|
|
|
}
|
|
|
|
else if (sel == 2)
|
|
|
|
{
|
|
|
|
return m_TabPlugins;
|
|
|
|
}
|
|
|
|
else // if (sel == 3)
|
|
|
|
{
|
|
|
|
return m_TabVersion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
switch (uMsg)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
return OnInitDialog(wParam, lParam);
|
2012-02-14 17:00:07 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case WM_ACTIVATE:
|
|
|
|
return OnActivate(wParam, lParam);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
return OnCommand(wParam, lParam);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
return OnNotify(wParam, lParam);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
MINMAXINFO* mmi = (MINMAXINFO*)lParam;
|
2013-06-29 16:59:18 +00:00
|
|
|
mmi->ptMinTrackSize.x = 700;
|
2012-12-13 09:12:25 +00:00
|
|
|
mmi->ptMinTrackSize.y = 350;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
{
|
|
|
|
if (wParam != SIZE_MINIMIZED)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
int w = LOWORD(lParam);
|
|
|
|
int h = HIWORD(lParam);
|
|
|
|
RECT r;
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_Tab);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(item, nullptr, 0, 0, w - 18, h - 47, SWP_NOMOVE | SWP_NOZORDER);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_CloseButton);
|
2012-12-13 09:12:25 +00:00
|
|
|
GetClientRect(item, &r);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(item, nullptr, w - r.right - 9, h - r.bottom - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
w -= 48;
|
|
|
|
h -= 100;
|
|
|
|
m_TabLog.Resize(w, h);
|
|
|
|
m_TabSkins.Resize(w, h);
|
|
|
|
m_TabPlugins.Resize(w, h);
|
|
|
|
m_TabVersion.Resize(w, h);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2012-12-13 09:12:25 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
{
|
|
|
|
GetWindowPlacement(m_Window, &c_WindowPlacement);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (c_WindowPlacement.showCmd == SW_SHOWMINIMIZED)
|
|
|
|
{
|
|
|
|
c_WindowPlacement.showCmd = SW_SHOWNORMAL;
|
|
|
|
}
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
delete c_Dialog;
|
2013-05-31 14:28:39 +00:00
|
|
|
c_Dialog = nullptr;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2012-12-13 09:12:25 +00:00
|
|
|
return TRUE;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
static const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_BUTTON(Id_CloseButton, ID_STR_CLOSE,
|
|
|
|
344, 191, 50, 14,
|
2012-12-13 10:20:14 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0),
|
|
|
|
CT_TAB(Id_Tab, 0,
|
|
|
|
6, 6, 388, 181,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | TCS_FIXEDWIDTH, 0) // Last for correct tab order.
|
2012-12-13 09:12:25 +00:00
|
|
|
};
|
2012-02-14 17:00:07 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
CreateControls(s_Controls, _countof(s_Controls), m_Font, GetString);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_Tab);
|
2012-12-13 10:20:14 +00:00
|
|
|
m_TabLog.Create(m_Window);
|
|
|
|
m_TabSkins.Create(m_Window);
|
|
|
|
m_TabPlugins.Create(m_Window);
|
|
|
|
m_TabVersion.Create(m_Window);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
TCITEM tci = {0};
|
|
|
|
tci.mask = TCIF_TEXT;
|
2011-09-24 09:13:13 +00:00
|
|
|
tci.pszText = GetString(ID_STR_LOG);
|
2011-08-28 10:58:26 +00:00
|
|
|
TabCtrl_InsertItem(item, 0, &tci);
|
2012-02-20 17:27:00 +00:00
|
|
|
tci.pszText = GetString(ID_STR_SKINS);
|
2011-08-28 10:58:26 +00:00
|
|
|
TabCtrl_InsertItem(item, 1, &tci);
|
2011-09-24 09:13:13 +00:00
|
|
|
tci.pszText = GetString(ID_STR_PLUGINS);
|
2011-08-28 10:58:26 +00:00
|
|
|
TabCtrl_InsertItem(item, 2, &tci);
|
2011-09-24 09:13:13 +00:00
|
|
|
tci.pszText = GetString(ID_STR_VERSION);
|
2011-08-28 12:28:00 +00:00
|
|
|
TabCtrl_InsertItem(item, 3, &tci);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
HICON hIcon = GetIcon(IDI_RAINMETER);
|
|
|
|
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_CloseButton);
|
2012-12-13 09:12:25 +00:00
|
|
|
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
|
|
|
|
|
2014-02-12 21:42:02 +00:00
|
|
|
if (IsWindowsVistaOrGreater())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
item = m_TabLog.GetControl(TabLog::Id_ItemsListView);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowTheme(item, L"explorer", nullptr);
|
2013-05-31 14:18:52 +00:00
|
|
|
item = m_TabSkins.GetControl(TabSkins::Id_ItemsListView);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowTheme(item, L"explorer", nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 11:27:25 +00:00
|
|
|
if (c_WindowPlacement.length == 0)
|
|
|
|
{
|
|
|
|
c_WindowPlacement.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
GetWindowPlacement(m_Window, &c_WindowPlacement);
|
|
|
|
}
|
2011-09-05 05:20:36 +00:00
|
|
|
SetWindowPlacement(m_Window, &c_WindowPlacement);
|
2011-09-04 11:27:25 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
return TRUE;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::OnCommand(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_CloseButton:
|
|
|
|
PostMessage(m_Window, WM_CLOSE, 0, 0);
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::OnNotify(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
LPNMHDR nm = (LPNMHDR)lParam;
|
|
|
|
switch (nm->idFrom)
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_Tab:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (nm->code == TCN_SELCHANGE)
|
|
|
|
{
|
2012-02-14 17:00:07 +00:00
|
|
|
// Disable all tab windows first
|
|
|
|
EnableWindow(m_TabLog.GetWindow(), FALSE);
|
2012-02-20 17:27:00 +00:00
|
|
|
EnableWindow(m_TabSkins.GetWindow(), FALSE);
|
2012-02-14 17:00:07 +00:00
|
|
|
EnableWindow(m_TabPlugins.GetWindow(), FALSE);
|
|
|
|
EnableWindow(m_TabVersion.GetWindow(), FALSE);
|
|
|
|
|
2012-02-21 09:03:16 +00:00
|
|
|
GetActiveTab().Activate();
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-02-21 09:03:16 +00:00
|
|
|
return 1;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 09:03:16 +00:00
|
|
|
return 0;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Log tab
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::TabLog::TabLog() : Tab(),
|
2011-08-28 10:58:26 +00:00
|
|
|
m_Error(true),
|
|
|
|
m_Warning(true),
|
|
|
|
m_Notice(true),
|
|
|
|
m_Debug(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabLog::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 370, 148, owner);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
2013-08-25 18:09:54 +00:00
|
|
|
// FIXME: Temporary hack.
|
|
|
|
short buttonWidth = (short)_wtoi(GetString(ID_STR_NUM_BUTTONWIDTH));
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
static const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_LISTVIEW(Id_ItemsListView, 0,
|
|
|
|
0, 0, 368, 135,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_BORDER | LVS_ICON | LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER, 0),
|
|
|
|
CT_CHECKBOX(Id_ErrorCheckBox, ID_STR_ERROR,
|
|
|
|
0, 139, 70, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_WarningCheckBox, ID_STR_WARNING,
|
|
|
|
70, 139, 70, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_NoticeCheckBox, ID_STR_NOTICE,
|
|
|
|
140, 139, 70, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_DebugCheckBox, ID_STR_DEBUG,
|
|
|
|
210, 139, 70, 9,
|
2013-08-25 18:09:54 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_ClearButton, ID_STR_CLEAR,
|
|
|
|
(368 - buttonWidth), 139, buttonWidth, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
/*
|
|
|
|
** Called when tab is displayed.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabLog::Initialize()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-02-21 09:32:44 +00:00
|
|
|
// Add columns to the list view
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ItemsListView);
|
2012-02-21 09:32:44 +00:00
|
|
|
ListView_SetExtendedListViewStyleEx(item, 0, LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Set folder/.ini icons for tree list
|
2012-05-17 08:40:47 +00:00
|
|
|
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 3, 1);
|
2011-12-09 08:40:19 +00:00
|
|
|
HMODULE hDLL = GetModuleHandle(L"user32");
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
HICON hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(103), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImageList, hIcon);
|
|
|
|
DeleteObject(hIcon);
|
|
|
|
|
|
|
|
hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(101), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImageList, hIcon);
|
|
|
|
DeleteObject(hIcon);
|
|
|
|
|
|
|
|
hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(104), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
ImageList_AddIcon(hImageList, hIcon);
|
|
|
|
DeleteObject(hIcon);
|
|
|
|
|
|
|
|
ListView_SetImageList(item, (WPARAM)hImageList, LVSIL_SMALL);
|
|
|
|
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
|
|
|
lvc.fmt = LVCFMT_LEFT; // left-aligned column
|
|
|
|
lvc.iSubItem = 0;
|
|
|
|
lvc.cx = 75;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_TYPE);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 0, &lvc);
|
|
|
|
lvc.iSubItem = 1;
|
|
|
|
lvc.cx = 85;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_TIME);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 1, &lvc);
|
|
|
|
lvc.iSubItem = 2;
|
2013-06-29 16:59:18 +00:00
|
|
|
lvc.cx = 225;
|
|
|
|
lvc.pszText = GetString(ID_STR_SOURCE);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 2, &lvc);
|
2013-06-29 16:59:18 +00:00
|
|
|
lvc.iSubItem = 4;
|
|
|
|
|
|
|
|
// Start 4th column at max width
|
2013-07-12 07:34:40 +00:00
|
|
|
RECT rect;
|
|
|
|
lvc.cx = GetWindowRect(item, &rect) ? (rect.right - rect.left - 405) : 180;
|
2013-06-29 16:59:18 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_MESSAGE);
|
|
|
|
ListView_InsertColumn(item, 3, &lvc);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2011-09-03 16:45:29 +00:00
|
|
|
// Add stored entires
|
2013-06-13 14:22:42 +00:00
|
|
|
for (const auto& entry : GetLogger().GetEntries())
|
2011-09-03 16:45:29 +00:00
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
AddItem(entry.level, entry.timestamp.c_str(), entry.source.c_str(), entry.message.c_str());
|
2011-09-03 16:45:29 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ErrorCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
Button_SetCheck(item, BST_CHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_WarningCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
Button_SetCheck(item, BST_CHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_NoticeCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
Button_SetCheck(item, BST_CHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DebugCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
Button_SetCheck(item, BST_CHECKED);
|
2012-11-13 15:39:12 +00:00
|
|
|
|
|
|
|
m_Initialized = true;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Resizes window and repositions controls.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabLog::Resize(int w, int h)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(m_Window, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-08-25 18:09:54 +00:00
|
|
|
// FIXME: Temporary hack.
|
|
|
|
short buttonWidth = (short)_wtoi(GetString(ID_STR_NUM_BUTTONWIDTH));
|
|
|
|
|
2011-09-17 19:30:31 +00:00
|
|
|
RECT r;
|
2013-08-25 18:09:54 +00:00
|
|
|
LONG bottom;
|
|
|
|
HWND item = GetControl(Id_ClearButton);
|
2011-09-17 19:30:31 +00:00
|
|
|
GetClientRect(item, &r);
|
2013-08-25 18:09:54 +00:00
|
|
|
bottom = r.bottom;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-08-25 18:09:54 +00:00
|
|
|
SetWindowPos(item, nullptr, w - r.right, h - bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
|
|
|
|
|
|
|
item = GetControl(Id_ErrorCheckBox);
|
|
|
|
GetClientRect(item, &r);
|
|
|
|
SetWindowPos(item, nullptr, 0, h - bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_WarningCheckBox);
|
2013-08-25 18:09:54 +00:00
|
|
|
SetWindowPos(item, nullptr, r.right, h - bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_NoticeCheckBox);
|
2013-08-25 18:09:54 +00:00
|
|
|
SetWindowPos(item, nullptr, r.right * 2, h - bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DebugCheckBox);
|
2013-08-25 18:09:54 +00:00
|
|
|
SetWindowPos(item, nullptr, r.right * 3, h - bottom, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2011-09-17 19:30:31 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ItemsListView);
|
2013-08-25 18:09:54 +00:00
|
|
|
SetWindowPos(item, nullptr, 0, 0, w, h - bottom - 10, SWP_NOMOVE | SWP_NOZORDER);
|
2011-09-17 19:30:31 +00:00
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
// Adjust 4th colum
|
2011-09-17 19:30:31 +00:00
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_WIDTH;
|
2013-06-29 16:59:18 +00:00
|
|
|
lvc.cx = w - 20 -
|
|
|
|
(ListView_GetColumnWidth(item, 0) +
|
|
|
|
ListView_GetColumnWidth(item, 1) +
|
|
|
|
ListView_GetColumnWidth(item, 2));
|
|
|
|
ListView_SetColumn(item, 3, &lvc);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Adds item to log.
|
|
|
|
**
|
|
|
|
*/
|
2013-06-29 16:59:18 +00:00
|
|
|
void DialogAbout::TabLog::AddItem(Logger::Level level, LPCWSTR time, LPCWSTR source, LPCWSTR message)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-23 16:28:38 +00:00
|
|
|
WCHAR buffer[32];
|
2011-08-28 10:58:26 +00:00
|
|
|
LVITEM vitem;
|
|
|
|
vitem.mask = LVIF_IMAGE | LVIF_TEXT;
|
|
|
|
vitem.iItem = 0;
|
|
|
|
vitem.iSubItem = 0;
|
2011-09-23 16:28:38 +00:00
|
|
|
vitem.pszText = buffer;
|
|
|
|
HWND item;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
case Logger::Level::Error:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (!m_Error) return;
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ErrorCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
vitem.iImage = 0;
|
|
|
|
break;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
case Logger::Level::Warning:
|
2012-02-16 17:38:45 +00:00
|
|
|
if (!m_Warning) return;
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_WarningCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
vitem.iImage = 1;
|
|
|
|
break;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
case Logger::Level::Notice:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (!m_Notice) return;
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_NoticeCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
vitem.iImage = 2;
|
|
|
|
break;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
case Logger::Level::Debug:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (!m_Debug) return;
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DebugCheckBox);
|
2012-05-17 08:40:47 +00:00
|
|
|
vitem.iImage = I_IMAGENONE;
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-09-23 16:28:38 +00:00
|
|
|
|
|
|
|
GetWindowText(item, buffer, 32);
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ItemsListView);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertItem(item, &vitem);
|
|
|
|
ListView_SetItemText(item, vitem.iItem, 1, (WCHAR*)time);
|
2013-06-29 16:59:18 +00:00
|
|
|
ListView_SetItemText(item, vitem.iItem, 2, (WCHAR*)source);
|
|
|
|
ListView_SetItemText(item, vitem.iItem, 3, (WCHAR*)message);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (!ListView_IsItemVisible(item, 0))
|
|
|
|
{
|
|
|
|
ListView_Scroll(item, 0, 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabLog::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
2012-12-13 09:12:25 +00:00
|
|
|
return OnCommand(wParam, lParam);
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
return OnNotify(wParam, lParam);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabLog::OnCommand(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ErrorCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == BN_CLICKED)
|
|
|
|
{
|
|
|
|
m_Error = !m_Error;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_WarningCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == BN_CLICKED)
|
|
|
|
{
|
|
|
|
m_Warning = !m_Warning;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_NoticeCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == BN_CLICKED)
|
|
|
|
{
|
|
|
|
m_Notice = !m_Notice;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_DebugCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == BN_CLICKED)
|
|
|
|
{
|
|
|
|
m_Debug = !m_Debug;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-08-25 18:09:54 +00:00
|
|
|
case Id_ClearButton:
|
|
|
|
if (HIWORD(wParam) == BN_CLICKED)
|
|
|
|
{
|
|
|
|
HWND item = GetControl(Id_ItemsListView);
|
|
|
|
ListView_DeleteAllItems(item);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabLog::OnNotify(WPARAM wParam, LPARAM lParam)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
|
|
|
LPNMHDR nm = (LPNMHDR)lParam;
|
|
|
|
switch (nm->code)
|
|
|
|
{
|
|
|
|
case LVN_KEYDOWN:
|
2012-02-21 09:03:16 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
NMLVKEYDOWN* lvkd = (NMLVKEYDOWN*)nm;
|
|
|
|
if (lvkd->wVKey == 0x43 && // C key.
|
|
|
|
IsCtrlKeyDown())
|
2012-02-21 09:03:16 +00:00
|
|
|
{
|
2013-07-12 07:34:40 +00:00
|
|
|
const int sel = ListView_GetNextItem(nm->hwndFrom, -1, LVNI_FOCUSED | LVNI_SELECTED);
|
2012-02-21 09:03:16 +00:00
|
|
|
if (sel != -1)
|
|
|
|
{
|
2013-07-12 07:34:40 +00:00
|
|
|
WCHAR buffer[512];
|
|
|
|
|
|
|
|
// Get message.
|
|
|
|
ListView_GetItemText(nm->hwndFrom, sel, 3, buffer, 512);
|
|
|
|
std::wstring message = buffer;
|
2013-06-29 16:59:18 +00:00
|
|
|
|
2013-07-12 07:34:40 +00:00
|
|
|
// Get source (if any).
|
2013-06-29 16:59:18 +00:00
|
|
|
ListView_GetItemText(nm->hwndFrom, sel, 2, buffer, 512);
|
|
|
|
if (*buffer)
|
|
|
|
{
|
2013-07-12 07:34:40 +00:00
|
|
|
message += L" (";
|
2013-06-29 16:59:18 +00:00
|
|
|
message += buffer;
|
2013-07-12 07:34:40 +00:00
|
|
|
message += L')';
|
2013-06-29 16:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
System::SetClipboardText(message);
|
2012-02-21 09:03:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
default:
|
2012-12-13 09:12:25 +00:00
|
|
|
return FALSE;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
return TRUE;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Measures tab
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::TabSkins::TabSkins() : Tab(),
|
2011-11-21 12:53:55 +00:00
|
|
|
m_SkinWindow()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabSkins::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 370, 148, owner);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
static const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_LISTBOX(Id_SkinsListBox, 0,
|
|
|
|
0, 0, 120, 148,
|
2012-12-13 18:07:38 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP | LBS_NOTIFY | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL, WS_EX_CLIENTEDGE),
|
2012-12-13 09:12:25 +00:00
|
|
|
CT_LISTVIEW(Id_ItemsListView, 0,
|
|
|
|
125, 0, 242, 148,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_BORDER | LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabSkins::Initialize()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-02-21 09:32:44 +00:00
|
|
|
// Add columns to the list view
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ItemsListView);
|
2012-02-21 09:32:44 +00:00
|
|
|
ListView_SetExtendedListViewStyleEx(item, 0, LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
2012-02-20 17:27:00 +00:00
|
|
|
|
|
|
|
LVGROUP lvg;
|
|
|
|
lvg.cbSize = sizeof(LVGROUP);
|
|
|
|
lvg.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_STATE;
|
2014-02-12 21:42:02 +00:00
|
|
|
lvg.state = (IsWindowsVistaOrGreater()) ? LVGS_COLLAPSIBLE : LVGS_NORMAL;
|
2012-02-20 17:27:00 +00:00
|
|
|
lvg.iGroupId = 0;
|
|
|
|
lvg.pszHeader = GetString(ID_STR_MEASURES);
|
|
|
|
ListView_InsertGroup(item, 0, &lvg);
|
|
|
|
lvg.iGroupId = 1;
|
2012-02-21 09:38:11 +00:00
|
|
|
lvg.pszHeader = GetString(ID_STR_VARIABLES);
|
2012-02-20 17:27:00 +00:00
|
|
|
ListView_InsertGroup(item, 1, &lvg);
|
|
|
|
|
|
|
|
ListView_EnableGroupView(item, TRUE);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
2012-02-20 17:27:00 +00:00
|
|
|
lvc.fmt = LVCFMT_LEFT;
|
2011-08-28 10:58:26 +00:00
|
|
|
lvc.iSubItem = 0;
|
|
|
|
lvc.cx = 120;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_NAME);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 0, &lvc);
|
|
|
|
lvc.iSubItem = 1;
|
|
|
|
lvc.cx = 90;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_RANGE);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 1, &lvc);
|
|
|
|
lvc.iSubItem = 2;
|
2013-06-29 16:59:18 +00:00
|
|
|
|
|
|
|
// Start 3rd column at max width
|
2013-07-12 07:34:40 +00:00
|
|
|
RECT rect;
|
|
|
|
lvc.cx = GetWindowRect(item, &rect) ? (rect.right - rect.left - 230) : 130;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_VALUE);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 2, &lvc);
|
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
UpdateSkinList();
|
2012-11-13 15:39:12 +00:00
|
|
|
|
|
|
|
m_Initialized = true;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Resizes window and repositions controls.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabSkins::Resize(int w, int h)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(m_Window, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_SkinsListBox);
|
2013-06-29 16:59:18 +00:00
|
|
|
SetWindowPos(item, nullptr, 0, 0, 265, h, SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ItemsListView);
|
2013-06-29 16:59:18 +00:00
|
|
|
SetWindowPos(item, nullptr, 275, 0, w - 275, h, SWP_NOZORDER);
|
2011-09-03 16:45:29 +00:00
|
|
|
|
|
|
|
// Adjust third column
|
2011-08-28 10:58:26 +00:00
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_WIDTH;
|
2013-06-29 16:59:18 +00:00
|
|
|
lvc.cx = w - 275 - 20 -
|
|
|
|
(ListView_GetColumnWidth(item, 0) +
|
|
|
|
ListView_GetColumnWidth(item, 1));
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_SetColumn(item, 2, &lvc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates the list of skins.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabSkins::UpdateSkinList()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
// Delete all entries
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_SkinsListBox);
|
2011-11-21 12:53:55 +00:00
|
|
|
ListBox_ResetContent(item);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
// Add entries for each skin
|
|
|
|
std::wstring::size_type maxLength = 0;
|
2014-07-23 10:47:09 +00:00
|
|
|
const std::map<std::wstring, MeterWindow*>& windows = Rainmeter::GetInstance().GetAllMeterWindows();
|
2013-05-31 14:18:52 +00:00
|
|
|
std::map<std::wstring, MeterWindow*>::const_iterator iter = windows.begin();
|
2011-11-21 12:53:55 +00:00
|
|
|
bool found = false;
|
2011-08-28 10:58:26 +00:00
|
|
|
for ( ; iter != windows.end(); ++iter)
|
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
const std::wstring& skinName = (*iter).first;
|
|
|
|
std::wstring::size_type curLength = skinName.length();
|
|
|
|
if (curLength > maxLength)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
maxLength = curLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
const WCHAR* name = skinName.c_str();
|
|
|
|
int index = ListBox_AddString(item, name);
|
|
|
|
if (!found && m_SkinWindow == (*iter).second)
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
m_SkinWindow = (*iter).second;
|
|
|
|
ListBox_SetCurSel(item, index);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
ListBox_SetHorizontalExtent(item, 6 * maxLength);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
if (windows.empty())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
m_SkinWindow = nullptr;
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ItemsListView);
|
2011-11-21 12:53:55 +00:00
|
|
|
ListView_DeleteAllItems(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Default to first skin
|
|
|
|
m_SkinWindow = (*windows.begin()).second;
|
|
|
|
ListBox_SetCurSel(item, 0);
|
|
|
|
UpdateMeasureList(m_SkinWindow);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates the list of measures and values.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabSkins::UpdateMeasureList(MeterWindow* meterWindow)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
if (!meterWindow)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
// Find selected skin
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_SkinsListBox);
|
2013-05-31 14:28:39 +00:00
|
|
|
int selected = (int)SendMessage(item, LB_GETCURSEL, 0, 0);
|
2011-11-21 12:53:55 +00:00
|
|
|
|
2014-07-23 10:47:09 +00:00
|
|
|
const std::map<std::wstring, MeterWindow*>& windows = Rainmeter::GetInstance().GetAllMeterWindows();
|
2013-05-31 14:18:52 +00:00
|
|
|
std::map<std::wstring, MeterWindow*>::const_iterator iter = windows.begin();
|
2011-11-21 12:53:55 +00:00
|
|
|
while (selected && iter != windows.end())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
++iter;
|
|
|
|
--selected;
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
m_SkinWindow = (*iter).second;
|
|
|
|
}
|
|
|
|
else if (meterWindow != m_SkinWindow)
|
|
|
|
{
|
|
|
|
// Called by a skin other than currently visible one, so return
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ItemsListView);
|
2011-11-21 12:53:55 +00:00
|
|
|
SendMessage(item, WM_SETREDRAW, FALSE, 0);
|
|
|
|
int count = ListView_GetItemCount(item);
|
2012-02-20 17:54:15 +00:00
|
|
|
|
|
|
|
LVITEM lvi;
|
2012-02-23 16:33:05 +00:00
|
|
|
lvi.mask = LVIF_TEXT | LVIF_GROUPID | LVIF_PARAM;
|
2012-02-20 17:54:15 +00:00
|
|
|
lvi.iSubItem = 0;
|
|
|
|
lvi.iItem = 0;
|
2012-02-23 16:33:05 +00:00
|
|
|
lvi.lParam = 0;
|
2012-02-20 17:54:15 +00:00
|
|
|
|
2012-02-20 18:46:36 +00:00
|
|
|
lvi.iGroupId = 0;
|
2013-05-31 14:18:52 +00:00
|
|
|
const std::vector<Measure*>& measures = m_SkinWindow->GetMeasures();
|
|
|
|
std::vector<Measure*>::const_iterator j = measures.begin();
|
2011-11-21 12:53:55 +00:00
|
|
|
for ( ; j != measures.end(); ++j)
|
|
|
|
{
|
2012-02-20 17:54:15 +00:00
|
|
|
lvi.pszText = (WCHAR*)(*j)->GetName();
|
|
|
|
|
|
|
|
if (lvi.iItem < count)
|
2011-11-21 12:53:55 +00:00
|
|
|
{
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_SetItem(item, &lvi);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2011-11-21 12:53:55 +00:00
|
|
|
else
|
|
|
|
{
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_InsertItem(item, &lvi);
|
2011-11-21 12:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR buffer[256];
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure::GetScaledValue(AUTOSCALE_ON, 1, (*j)->GetMinValue(), buffer, _countof(buffer));
|
2011-11-21 12:53:55 +00:00
|
|
|
std::wstring range = buffer;
|
|
|
|
range += L" - ";
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure::GetScaledValue(AUTOSCALE_ON, 1, (*j)->GetMaxValue(), buffer, _countof(buffer));
|
2011-11-21 12:53:55 +00:00
|
|
|
range += buffer;
|
|
|
|
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_SetItemText(item, lvi.iItem, 1, (WCHAR*)range.c_str());
|
2013-04-10 15:59:41 +00:00
|
|
|
ListView_SetItemText(item, lvi.iItem, 2, (WCHAR*)(*j)->GetStringOrFormattedValue(
|
|
|
|
AUTOSCALE_OFF, 1, -1, false));
|
2012-02-20 17:54:15 +00:00
|
|
|
++lvi.iItem;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2011-11-21 12:53:55 +00:00
|
|
|
|
2012-02-20 18:46:36 +00:00
|
|
|
lvi.iGroupId = 1;
|
2012-02-20 17:27:00 +00:00
|
|
|
const auto& variables = m_SkinWindow->GetParser().GetVariables();
|
|
|
|
for (auto iter = variables.cbegin(); iter != variables.cend(); ++iter)
|
|
|
|
{
|
2012-05-24 06:30:22 +00:00
|
|
|
const WCHAR* name = (*iter).first.c_str();
|
|
|
|
lvi.lParam = (LPARAM)name;
|
|
|
|
|
|
|
|
if (wcscmp(name, L"@") == 0)
|
|
|
|
{
|
|
|
|
// Ignore reserved variables
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::wstring tmpStr = (*iter).first;
|
2013-12-23 19:42:31 +00:00
|
|
|
_wcslwr(&tmpStr[0]);
|
2012-05-24 06:30:22 +00:00
|
|
|
lvi.pszText = (WCHAR*)tmpStr.c_str();
|
2012-02-20 17:54:15 +00:00
|
|
|
|
|
|
|
if (lvi.iItem < count)
|
2012-02-20 17:27:00 +00:00
|
|
|
{
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_SetItem(item, &lvi);
|
2012-02-20 17:27:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_InsertItem(item, &lvi);
|
2012-02-20 17:27:00 +00:00
|
|
|
}
|
|
|
|
|
2012-02-20 18:46:36 +00:00
|
|
|
ListView_SetItemText(item, lvi.iItem, 1, L"");
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_SetItemText(item, lvi.iItem, 2, (WCHAR*)(*iter).second.c_str());
|
|
|
|
++lvi.iItem;
|
2012-02-20 17:27:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
// Delete unnecessary items
|
2012-02-20 17:54:15 +00:00
|
|
|
while (count > lvi.iItem)
|
2011-11-21 12:53:55 +00:00
|
|
|
{
|
2012-02-20 17:54:15 +00:00
|
|
|
ListView_DeleteItem(item, lvi.iItem);
|
2011-11-21 12:53:55 +00:00
|
|
|
--count;
|
|
|
|
}
|
|
|
|
|
2012-02-23 16:49:17 +00:00
|
|
|
int selIndex = ListView_GetNextItem(item, -1, LVNI_FOCUSED | LVNI_SELECTED);
|
2012-02-23 16:33:05 +00:00
|
|
|
|
2012-02-23 16:49:17 +00:00
|
|
|
ListView_SortItems(item, ListSortProc, 0);
|
2012-02-23 16:33:05 +00:00
|
|
|
|
|
|
|
if (selIndex != -1)
|
|
|
|
{
|
2012-02-23 16:49:17 +00:00
|
|
|
// Re-select previously selected item
|
2012-02-23 16:33:05 +00:00
|
|
|
ListView_SetItemState(item, selIndex, LVIS_FOCUSED | LVNI_SELECTED, LVIS_FOCUSED | LVNI_SELECTED);
|
|
|
|
}
|
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
SendMessage(item, WM_SETREDRAW, TRUE, 0);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
int CALLBACK DialogAbout::TabSkins::ListSortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
2012-02-23 16:33:05 +00:00
|
|
|
{
|
|
|
|
// Measures
|
|
|
|
if (!lParam1 && !lParam2) return 0;
|
|
|
|
if (!lParam1) return -1;
|
|
|
|
if (!lParam2) return 1;
|
|
|
|
|
|
|
|
// Variables
|
2012-02-23 16:49:17 +00:00
|
|
|
return wcscmp((const WCHAR*)lParam1, (const WCHAR*)lParam2);
|
2012-02-23 16:33:05 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabSkins::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
2012-12-13 09:12:25 +00:00
|
|
|
return OnCommand(wParam, lParam);
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
return OnNotify(wParam, lParam);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_SkinsListBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == LBN_SELCHANGE)
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
UpdateMeasureList(nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-02-21 09:03:16 +00:00
|
|
|
return 1;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 09:03:16 +00:00
|
|
|
return 0;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
|
|
|
LPNMHDR nm = (LPNMHDR)lParam;
|
|
|
|
switch (nm->code)
|
|
|
|
{
|
|
|
|
case LVN_KEYDOWN:
|
|
|
|
{
|
|
|
|
NMLVKEYDOWN* lvkd = (NMLVKEYDOWN*)nm;
|
|
|
|
if (lvkd->wVKey == 0x43 && IsCtrlKeyDown()) // CTRL + C.
|
|
|
|
{
|
|
|
|
int sel = ListView_GetNextItem(nm->hwndFrom, -1, LVNI_FOCUSED | LVNI_SELECTED);
|
|
|
|
if (sel != -1)
|
|
|
|
{
|
|
|
|
std::wstring tmpSz(512, L'0');
|
|
|
|
ListView_GetItemText(nm->hwndFrom, sel, 2, &tmpSz[0], 512);
|
2013-05-31 14:18:52 +00:00
|
|
|
System::SetClipboardText(tmpSz);
|
2012-12-13 09:12:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Plugins tab
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::TabPlugins::TabPlugins() : Tab()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabPlugins::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 370, 148, owner);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
static const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_LISTVIEW(Id_ItemsListView, 0,
|
|
|
|
0, 0, 368, 148,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_BORDER | LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabPlugins::Initialize()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
// Add columns to the list view
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ItemsListView);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
2011-09-23 16:28:38 +00:00
|
|
|
lvc.fmt = LVCFMT_LEFT; // left-aligned column
|
2011-08-28 10:58:26 +00:00
|
|
|
lvc.iSubItem = 0;
|
|
|
|
lvc.cx = 140;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_NAME);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 0, &lvc);
|
|
|
|
lvc.iSubItem = 1;
|
|
|
|
lvc.cx = 80;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_VERSION);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 1, &lvc);
|
|
|
|
lvc.iSubItem = 2;
|
2013-06-29 16:59:18 +00:00
|
|
|
|
|
|
|
// Start 3rd column at max width
|
2013-07-12 07:34:40 +00:00
|
|
|
RECT rect;
|
|
|
|
lvc.cx = GetWindowRect(item, &rect) ? (rect.right - rect.left - 193) : 290;
|
2011-09-24 09:13:13 +00:00
|
|
|
lvc.pszText = GetString(ID_STR_AUTHOR);
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_InsertColumn(item, 2, &lvc);
|
|
|
|
|
|
|
|
LVITEM vitem;
|
|
|
|
vitem.mask = LVIF_TEXT;
|
|
|
|
vitem.iItem = 0;
|
|
|
|
vitem.iSubItem = 0;
|
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
auto findPlugins = [&](const std::wstring& path)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-09 15:38:45 +00:00
|
|
|
std::wstring filter = path + L"*.dll";
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
HANDLE hSearch = FindFirstFile(filter.c_str(), &fd);
|
2012-06-19 14:33:11 +00:00
|
|
|
if (hSearch == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
int index = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
// Try to get the version and author
|
|
|
|
std::wstring tmpSz = path + fd.cFileName;
|
|
|
|
const WCHAR* path = tmpSz.c_str();
|
2012-01-08 17:35:29 +00:00
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
vitem.iItem = index;
|
|
|
|
vitem.pszText = fd.cFileName;
|
2012-01-08 17:35:29 +00:00
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
// Try to get version and author from file resources first
|
|
|
|
DWORD handle;
|
|
|
|
DWORD versionSize = GetFileVersionInfoSize(path, &handle);
|
|
|
|
if (versionSize)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
void* data = new BYTE[versionSize];
|
|
|
|
if (GetFileVersionInfo(path, 0, versionSize, data))
|
2012-01-08 17:35:29 +00:00
|
|
|
{
|
2012-06-09 15:38:45 +00:00
|
|
|
UINT len;
|
|
|
|
struct LANGCODEPAGE
|
2012-01-08 17:35:29 +00:00
|
|
|
{
|
2012-06-09 15:38:45 +00:00
|
|
|
WORD wLanguage;
|
|
|
|
WORD wCodePage;
|
|
|
|
} *lcp;
|
2012-01-08 17:35:29 +00:00
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
if (VerQueryValue(data, L"\\VarFileInfo\\Translation", (LPVOID*)&lcp, &len))
|
|
|
|
{
|
|
|
|
WCHAR key[64];
|
|
|
|
LPWSTR value;
|
2012-01-08 17:35:29 +00:00
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\ProductName", lcp[0].wLanguage, lcp[0].wCodePage);
|
|
|
|
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len) &&
|
|
|
|
wcscmp(value, L"Rainmeter") == 0)
|
2012-01-08 17:35:29 +00:00
|
|
|
{
|
2012-06-09 15:38:45 +00:00
|
|
|
ListView_InsertItem(item, &vitem);
|
|
|
|
++index;
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\FileVersion", lcp[0].wLanguage, lcp[0].wCodePage);
|
|
|
|
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
|
|
|
|
{
|
|
|
|
ListView_SetItemText(item, vitem.iItem, 1, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\LegalCopyright", lcp[0].wLanguage, lcp[0].wCodePage);
|
|
|
|
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
|
|
|
|
{
|
|
|
|
ListView_SetItemText(item, vitem.iItem, 2, value);
|
|
|
|
}
|
2012-01-08 17:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
delete [] data;
|
|
|
|
if (found) continue;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
// Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
|
|
|
|
DWORD err = 0;
|
2013-05-31 14:18:52 +00:00
|
|
|
HMODULE dll = System::RmLoadLibrary(path, &err);
|
2012-06-09 15:38:45 +00:00
|
|
|
if (dll)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-09 15:38:45 +00:00
|
|
|
ListView_InsertItem(item, &vitem);
|
|
|
|
++index;
|
|
|
|
|
|
|
|
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
|
|
|
|
if (GetVersionFunc)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-09 15:38:45 +00:00
|
|
|
UINT version = GetVersionFunc();
|
|
|
|
WCHAR buffer[64];
|
|
|
|
_snwprintf_s(buffer, _TRUNCATE, L"%u.%u", version / 1000, version % 1000);
|
|
|
|
ListView_SetItemText(item, vitem.iItem, 1, buffer);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-06-09 15:38:45 +00:00
|
|
|
GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");
|
|
|
|
if (GetAuthorFunc)
|
|
|
|
{
|
|
|
|
LPCTSTR author = GetAuthorFunc();
|
|
|
|
if (author && *author)
|
|
|
|
{
|
|
|
|
ListView_SetItemText(item, vitem.iItem, 2, (LPWSTR)author);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeLibrary(dll);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(L"About Dialog - Unable to load plugin: %s (%u)", tmpSz.c_str(), err);
|
2012-06-09 15:38:45 +00:00
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2012-06-09 15:38:45 +00:00
|
|
|
while (FindNextFile(hSearch, &fd));
|
|
|
|
FindClose(hSearch);
|
|
|
|
};
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2014-07-23 10:47:09 +00:00
|
|
|
findPlugins(Rainmeter::GetInstance().GetPluginPath());
|
|
|
|
if (Rainmeter::GetInstance().HasUserPluginPath())
|
2012-06-21 09:06:17 +00:00
|
|
|
{
|
2014-07-23 10:47:09 +00:00
|
|
|
findPlugins(Rainmeter::GetInstance().GetUserPluginPath());
|
2012-06-21 09:06:17 +00:00
|
|
|
}
|
2012-11-13 15:39:12 +00:00
|
|
|
|
|
|
|
m_Initialized = true;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Resizes window and repositions controls.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabPlugins::Resize(int w, int h)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(m_Window, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ItemsListView);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(item, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Adjust third colum
|
|
|
|
LVCOLUMN lvc;
|
|
|
|
lvc.mask = LVCF_WIDTH;
|
2013-06-29 16:59:18 +00:00
|
|
|
lvc.cx = w - 20 -
|
|
|
|
(ListView_GetColumnWidth(item, 0) +
|
|
|
|
ListView_GetColumnWidth(item, 1));
|
2011-08-28 10:58:26 +00:00
|
|
|
ListView_SetColumn(item, 2, &lvc);
|
|
|
|
}
|
|
|
|
|
2011-08-28 12:28:00 +00:00
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Version tab
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::TabVersion::TabVersion() : Tab()
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabVersion::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 370, 148, owner);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
// FIXME: Temporary hack.
|
|
|
|
short buttonWidth = (short)_wtoi(GetString(ID_STR_NUM_BUTTONWIDTH));
|
|
|
|
|
|
|
|
const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_ICON(Id_AppIcon, 0,
|
|
|
|
0, 8, 24, 24,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_LABEL(Id_VersionLabel, 0,
|
|
|
|
28, 0, 300, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_LINKLABEL(Id_HomeLink, ID_STR_GETLATESTVERSION,
|
|
|
|
28, 13, 300, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_LINKLABEL(Id_LicenseLink, ID_STR_COPYRIGHTNOTICE,
|
|
|
|
28, 26, 300, 9,
|
|
|
|
WS_VISIBLE, 0),
|
2014-02-11 19:17:05 +00:00
|
|
|
CT_LABEL(Id_WinVerLabel, 0,
|
2012-12-13 09:12:25 +00:00
|
|
|
0, 43, 360, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
2014-02-11 19:17:05 +00:00
|
|
|
CT_LABEL(Id_PathLabel, 0,
|
2012-12-13 09:12:25 +00:00
|
|
|
0, 56, 360, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
2014-02-11 19:17:05 +00:00
|
|
|
CT_LABEL(Id_IniFileLabel, 0,
|
2012-12-13 09:12:25 +00:00
|
|
|
0, 69, 360, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
2014-02-11 19:17:05 +00:00
|
|
|
CT_LABEL(Id_SkinPathLabel, 0,
|
|
|
|
0, 82, 360, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
2012-12-13 09:12:25 +00:00
|
|
|
CT_BUTTON(Id_CopyButton, ID_STR_COPYTOCLIPBOARD,
|
2014-02-11 19:17:05 +00:00
|
|
|
0, 98, buttonWidth + 25, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabVersion::Initialize()
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_AppIcon);
|
2012-05-05 15:53:33 +00:00
|
|
|
HICON icon = GetIcon(IDI_RAINMETER, true);
|
2011-09-24 13:10:31 +00:00
|
|
|
Static_SetIcon(item, icon);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_VersionLabel);
|
2011-09-23 16:28:38 +00:00
|
|
|
WCHAR tmpSz[64];
|
2011-09-24 13:10:31 +00:00
|
|
|
_snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE);
|
2011-08-28 12:28:00 +00:00
|
|
|
SetWindowText(item, tmpSz);
|
|
|
|
|
2014-02-11 19:17:05 +00:00
|
|
|
item = GetControl(Id_WinVerLabel);
|
2014-02-13 16:57:08 +00:00
|
|
|
SetWindowText(item, Platform::GetPlatformFriendlyName().c_str());
|
2014-02-11 19:17:05 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_PathLabel);
|
2014-07-23 10:47:09 +00:00
|
|
|
std::wstring text = L"Path: " + Rainmeter::GetInstance().GetPath();
|
2011-10-03 12:26:49 +00:00
|
|
|
SetWindowText(item, text.c_str());
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_IniFileLabel);
|
2014-07-23 10:47:09 +00:00
|
|
|
text = L"IniFile: " + Rainmeter::GetInstance().GetIniFile();
|
2011-10-03 12:26:49 +00:00
|
|
|
SetWindowText(item, text.c_str());
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SkinPathLabel);
|
2014-07-23 10:47:09 +00:00
|
|
|
text = L"SkinPath: " + Rainmeter::GetInstance().GetSkinPath();
|
2011-08-28 12:28:00 +00:00
|
|
|
SetWindowText(item, text.c_str());
|
2012-11-13 15:39:12 +00:00
|
|
|
|
|
|
|
m_Initialized = true;
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Resizes window and repositions controls.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogAbout::TabVersion::Resize(int w, int h)
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(m_Window, nullptr, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabVersion::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
2012-12-13 09:12:25 +00:00
|
|
|
return OnCommand(wParam, lParam);
|
2011-08-28 12:28:00 +00:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
2012-12-13 09:12:25 +00:00
|
|
|
return OnNotify(wParam, lParam);
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabVersion::OnCommand(WPARAM wParam, LPARAM lParam)
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_CopyButton:
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
2011-09-23 16:28:38 +00:00
|
|
|
WCHAR tmpSz[64];
|
2012-09-08 17:09:14 +00:00
|
|
|
int len = _snwprintf_s(tmpSz, _TRUNCATE, L"%s%s r%i %s (%s)", APPVERSION, revision_beta ? L" beta" : L"", revision_number, APPBITS, APPDATE);
|
|
|
|
std::wstring text(tmpSz, len);
|
2014-02-11 19:24:26 +00:00
|
|
|
text += L'\n';
|
2014-02-13 16:19:54 +00:00
|
|
|
text += Platform::GetPlatformFriendlyName();
|
2011-10-03 12:26:49 +00:00
|
|
|
text += L"\nPath: ";
|
2014-07-23 10:47:09 +00:00
|
|
|
text += Rainmeter::GetInstance().GetPath();
|
2011-10-03 12:26:49 +00:00
|
|
|
text += L"\nIniFile: ";
|
2014-07-23 10:47:09 +00:00
|
|
|
text += Rainmeter::GetInstance().GetIniFile();
|
2011-10-03 12:26:49 +00:00
|
|
|
text += L"\nSkinPath: ";
|
2014-07-23 10:47:09 +00:00
|
|
|
text += Rainmeter::GetInstance().GetSkinPath();
|
2013-05-31 14:18:52 +00:00
|
|
|
System::SetClipboardText(text);
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-02-21 09:03:16 +00:00
|
|
|
return 1;
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 09:03:16 +00:00
|
|
|
return 0;
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogAbout::TabVersion::OnNotify(WPARAM wParam, LPARAM lParam)
|
2011-08-28 12:28:00 +00:00
|
|
|
{
|
|
|
|
LPNMHDR nm = (LPNMHDR)lParam;
|
|
|
|
switch (nm->code)
|
|
|
|
{
|
|
|
|
case NM_CLICK:
|
2012-12-13 09:12:25 +00:00
|
|
|
if (nm->idFrom == Id_HomeLink)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler::RunFile(L"http://rainmeter.net");
|
2012-12-13 09:12:25 +00:00
|
|
|
}
|
|
|
|
else if (nm->idFrom == Id_HomeLink)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler::RunFile(L"http://gnu.org/licenses");
|
2012-12-13 09:12:25 +00:00
|
|
|
}
|
2011-08-28 12:28:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|